refactor and reorganize!!
This commit is contained in:
1 parent
e7f10c4f59
commit
832122e63c
11 files changed
+1082
-283
No files matched your search
@@ -95,30 +95,17 @@ async def migrate_sku_to_gtin():
|
||||
print(f"[@INFO] Item {item_id} ({item_name})")
|
||||
print(f"[@INFO] Variation {var_id}: Moving SKU '{sku}' to UPC")
|
||||
|
||||
# Build updated variation
|
||||
updated_var = {
|
||||
"type": "ITEM_VARIATION",
|
||||
"id": var_id,
|
||||
"version": var_version,
|
||||
"item_variation_data": {
|
||||
"item_id": item_id,
|
||||
"name": var_data.get("name", "Regular"),
|
||||
"pricing_type": var_data.get(
|
||||
"pricing_type", "FIXED_PRICING"
|
||||
),
|
||||
"upc": sku, # Move SKU value to UPC
|
||||
"sku": (
|
||||
set_number if set_number else None
|
||||
), # Set to LEGO set number if available
|
||||
},
|
||||
}
|
||||
# Preserve all existing variation data and only modify what we need
|
||||
updated_var = var.copy() # Shallow copy the entire variation
|
||||
updated_var_data = var_data.copy() # Copy the variation_data
|
||||
|
||||
# Preserve pricing info
|
||||
if "price_money" in var_data:
|
||||
updated_var["item_variation_data"]["price_money"] = var_data[
|
||||
"price_money"
|
||||
]
|
||||
# Update only UPC and SKU fields
|
||||
updated_var_data["upc"] = sku # Move SKU value to UPC
|
||||
updated_var_data["sku"] = (
|
||||
set_number if set_number else None
|
||||
) # Set to LEGO set number
|
||||
|
||||
updated_var["item_variation_data"] = updated_var_data
|
||||
updated_variations.append(updated_var)
|
||||
needs_update = True
|
||||
else:
|
||||
|
||||
Reference in new issue
Block a user