diff --git a/backend/queue_worker.py b/backend/queue_worker.py index b5851e6..3cba263 100644 --- a/backend/queue_worker.py +++ b/backend/queue_worker.py @@ -122,7 +122,9 @@ class QueueWorker: if not children: cat = tree_by_id.get(parent_id) if cat: - path_model = (cat.get("url") or "").lstrip("/") or None + url_slug = (cat.get("url") or "").lstrip("/") + # Trendyol Search API now requires -x-c{id} suffix on pathModel + path_model = f"{url_slug}-x-c{cat['id']}" if url_slug else None return [(path_model, cat["name"], cat["id"])] return [] leaves = [] diff --git a/backend/scraper.py b/backend/scraper.py index 3e0427c..6e7801e 100644 --- a/backend/scraper.py +++ b/backend/scraper.py @@ -210,7 +210,11 @@ class TrendyolSearchScraper: if not first: return [] - total = first.get("total", 0) or first.get("totalCount", 0) or first.get("roughTotal", 0) + total_raw = first.get("total") or first.get("totalCount") or first.get("roughTotal") or 0 + try: + total = int(total_raw) + except (ValueError, TypeError): + total = 0 raw_products = first.get("products", []) if total == 0 and not raw_products: