very confusing lol
This commit is contained in:
1 parent
16d0cd85c2
commit
da382942d3
1 file changed
+11
-10
+11
-10
@@ -234,13 +234,15 @@ async def update_itm(item_id: str, lego_set: dict, item_data: dict = None):
|
||||
# Convert price to cents for Square API
|
||||
price_in_cents = int(set_adjustedprice * 100)
|
||||
|
||||
# Get current item to retrieve variation ID (only if not provided)
|
||||
if item_data is None:
|
||||
item = await get_item_by_id(item_id)
|
||||
else:
|
||||
item = item_data
|
||||
# ALWAYS fetch fresh item data right before update to get latest version
|
||||
# The item_data parameter is just used to avoid lookup during enrichment check,
|
||||
# but we need fresh data for the update to avoid version conflicts
|
||||
print(
|
||||
f"[@DEBUG] Fetching fresh item data before update to get current version..."
|
||||
)
|
||||
fresh_item = await get_item_by_id(item_id)
|
||||
|
||||
variations = item.get("variations", [])
|
||||
variations = fresh_item.get("variations", [])
|
||||
|
||||
if not variations:
|
||||
print(
|
||||
@@ -253,11 +255,10 @@ async def update_itm(item_id: str, lego_set: dict, item_data: dict = None):
|
||||
variation_version = variations[0].get("version")
|
||||
|
||||
# Get current version for version control
|
||||
current_version = item.get("version")
|
||||
current_version = fresh_item.get("version")
|
||||
|
||||
print(f"[@DEBUG] Item version: {current_version}")
|
||||
print(f"[@DEBUG] Variation version: {variation_version}")
|
||||
print(f"[@DEBUG] Full item data: {json.dumps(item, indent=2)}")
|
||||
print(f"[@DEBUG] Fresh item version: {current_version}")
|
||||
print(f"[@DEBUG] Fresh variation version: {variation_version}")
|
||||
|
||||
# Build upsert body
|
||||
upsert_body = {
|
||||
|
||||
Reference in new issue
Block a user