diff --git a/src/asquare.py b/src/asquare.py index afe24a1..f649c18 100644 --- a/src/asquare.py +++ b/src/asquare.py @@ -271,21 +271,27 @@ async def update_itm(item_id: str, lego_set: dict, item_data: dict = None): # Get current version for version control current_version = fresh_item.get("version") - category_id = fresh_item.get("category_id") + + # batch_get doesn't return category_id, so use original item_data if available + if item_data and item_data.get("category_id"): + category_id = item_data.get("category_id") + print(f"[@DEBUG] Using category_id from item_data: {category_id}") + else: + category_id = fresh_item.get("category_id") or LEGO_CAT_ID + print( + f"[@DEBUG] Category ID from fresh_item: {fresh_item.get('category_id')}" + ) + if not fresh_item.get("category_id"): + print( + f"[@WARNING] No category_id in fresh_item, using LEGO_CAT_ID: {LEGO_CAT_ID}" + ) print(f"[@DEBUG] Fresh item version: {current_version}") print(f"[@DEBUG] Fresh variation version: {variation_version}") - print(f"[@DEBUG] Category ID from fresh_item: {category_id}") + print(f"[@DEBUG] Final category_id: {category_id}") print(f"[@DEBUG] Present at all locations: {present_at_all_locations}") print(f"[@DEBUG] Present at locations: {present_at_location_ids}") - # Ensure we have a category_id - if not category_id: - print( - f"[@WARNING] No category_id in fresh_item, using LEGO_CAT_ID: {LEGO_CAT_ID}" - ) - category_id = LEGO_CAT_ID - # Build upsert body variation_obj = { "type": "ITEM_VARIATION", @@ -319,7 +325,7 @@ async def update_itm(item_id: str, lego_set: dict, item_data: dict = None): "variations": [variation_obj], }, } - + upsert_body = { "idempotency_key": str(uuid.uuid4()), "object": item_obj,