mismatch
This commit is contained in:
1 parent
0089ce8556
commit
97174b2080
1 file changed
+18
-20
+18
-20
@@ -266,23 +266,9 @@ async def update_itm(item_id: str, lego_set: dict, item_data: dict = None):
|
||||
print(f"[@DEBUG] Fresh variation version: {variation_version}")
|
||||
|
||||
# Build upsert body
|
||||
upsert_body = {
|
||||
"idempotency_key": str(uuid.uuid4()),
|
||||
"object": {
|
||||
"type": "ITEM",
|
||||
"id": item_id,
|
||||
"version": current_version, # Include version for conflict prevention
|
||||
"item_data": {
|
||||
"name": pw_name,
|
||||
"description": f"{set_name} - {set_theme}",
|
||||
"variations": [
|
||||
{
|
||||
variation_obj = {
|
||||
"type": "ITEM_VARIATION",
|
||||
"id": (
|
||||
variation_id
|
||||
if variation_id
|
||||
else "#TEMP_VARIATION_ID"
|
||||
),
|
||||
"id": variation_id if variation_id else "#TEMP_VARIATION_ID",
|
||||
"item_variation_data": {
|
||||
"item_id": item_id,
|
||||
"name": "Regular",
|
||||
@@ -294,16 +280,28 @@ async def update_itm(item_id: str, lego_set: dict, item_data: dict = None):
|
||||
"sku": set_upc if set_upc else None,
|
||||
},
|
||||
}
|
||||
],
|
||||
|
||||
# Include variation version if it exists (required for updates)
|
||||
if variation_version is not None:
|
||||
variation_obj["version"] = variation_version
|
||||
|
||||
upsert_body = {
|
||||
"idempotency_key": str(uuid.uuid4()),
|
||||
"object": {
|
||||
"type": "ITEM",
|
||||
"id": item_id,
|
||||
"version": current_version, # Include version for conflict prevention
|
||||
"item_data": {
|
||||
"name": pw_name,
|
||||
"description": f"{set_name} - {set_theme}",
|
||||
"variations": [variation_obj],
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
# Remove None values
|
||||
if not set_upc:
|
||||
del upsert_body["object"]["item_data"]["variations"][0][
|
||||
"item_variation_data"
|
||||
]["sku"]
|
||||
del variation_obj["item_variation_data"]["sku"]
|
||||
|
||||
print(f"[@DEBUG] Upserting item {item_id} with name: {pw_name}")
|
||||
|
||||
|
||||
Reference in new issue
Block a user