diff --git a/src/scripts/migrate_sku_to_gtin.py b/src/scripts/migrate_sku_to_gtin.py index 5fdc057..cfe5d76 100644 --- a/src/scripts/migrate_sku_to_gtin.py +++ b/src/scripts/migrate_sku_to_gtin.py @@ -41,19 +41,21 @@ async def migrate_sku_to_gtin(): while True: print(f"[@INFO] Processing page {page}...") - result = await client.catalog.search( - body={ - "object_types": ["ITEM"], - "query": { - "exact_query": { - "attribute_name": "category_id", - "attribute_value": SQUARE_LEGO_CAT_ID, - } - }, - "limit": 100, - "cursor": cursor, - } - ) + search_params = { + "object_types": ["ITEM"], + "query": { + "exact_query": { + "attribute_name": "category_id", + "attribute_value": SQUARE_LEGO_CAT_ID, + } + }, + "limit": 100, + } + + if cursor: + search_params["cursor"] = cursor + + result = await client.catalog.search(**search_params) result_json = json.loads(result.model_dump_json()) items = result_json.get("objects", [])