Revert "[ka6] fix connecteur labete.ca: réapplication du fix « Woo désinstallé » (revert du revert a06965b, qui avait annulé efe49ea) — le site montre toujours le même état vérifié live: /wp-json/wc/store/v1/products → 404 alors que l'index /wp-json/ reste vivant (wp/v2 présent) sans plus aucun namespace wc* (restaurant repassé site vitrine). Détection _is_404 + _woo_uninstalled dans woocommerce.py → catalogue vide fidèle à la source, sync ok au lieu d'une erreur propagée. Sync réel: labete.ca ok / 0 produit (= médiane historique 0.0, zéro légitime); non-régression cabanedupicbois.com (4 produits, 0 erreur)"
This reverts commit c033fbb9a4b6d7db4256b6cdb6837ad22bca36c2.
1 changed file +0 −23
modified
fabrika/connectors/woocommerce.py
+0 −23
@@ -140,27 +140,6 @@ class WooCommerceConnector(BaseConnector): | ||
| 140 | 140 | pass |
| 141 | 141 | return out |
| 142 | 142 | |
| 143 | − @staticmethod | |
| 144 | − def _is_404(exc: Exception) -> bool: | |
| 145 | − r = getattr(exc, "response", None) | |
| 146 | − if r is not None and getattr(r, "status_code", None) == 404: | |
| 147 | − return True | |
| 148 | − return "upstream 404" in str(exc) | |
| 149 | − | |
| 150 | − def _woo_uninstalled(self) -> bool: | |
| 151 | − """WordPress vivant mais WooCommerce désinstallé : l'index REST /wp-json/ | |
| 152 | − répond (wp/v2 présent) sans plus aucun namespace wc* — la boutique a été | |
| 153 | − retirée du site (ex. labete.ca, restaurant repassé site vitrine). | |
| 154 | − Catalogue vide fidèle à la source, pas une panne.""" | |
| 155 | − try: | |
| 156 | − data = self._get_items(f"{self.base}/wp-json/") | |
| 157 | − except Exception: | |
| 158 | − return False | |
| 159 | − ns = data.get("namespaces") if isinstance(data, dict) else None | |
| 160 | − if not isinstance(ns, list) or "wp/v2" not in ns: | |
| 161 | − return False | |
| 162 | − return not any(str(n).startswith("wc") for n in ns) | |
| 163 | − | |
| 164 | 143 | def _parse_item(self, it: dict) -> Product: |
| 165 | 144 | """Mappe un produit Store API (liste ou fiche unitaire) vers Product.""" |
| 166 | 145 | prices = it.get("prices") or {} |
@@ -350,8 +329,6 @@ class WooCommerceConnector(BaseConnector): | ||
| 350 | 329 | slug_out = self._sitemap_slug_fallback() |
| 351 | 330 | if slug_out: |
| 352 | 331 | return slug_out |
| 353 | − if self._is_404(first_page_exc) and self._woo_uninstalled(): | |
| 354 | − return [] | |
| 355 | 332 | raise first_page_exc |
| 356 | 333 | |
| 357 | 334 | if not out and first_page_exc is None: |
| 358 | 335 | |