Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 17 additions & 6 deletions woocommerce_fusion/tasks/sync_items.py
Original file line number Diff line number Diff line change
Expand Up @@ -393,12 +393,23 @@ def create_item(self, wc_product: WooCommerceProduct) -> None:
# Handle variants' attributes
if wc_product.type in ["variable", "variation"]:
self.create_or_update_item_attributes(wc_product)
wc_attributes = json.loads(wc_product.attributes)
for wc_attribute in wc_attributes:
row = item.append("attributes")
row.attribute = wc_attribute["name"]
if wc_product.type == "variation":
row.attribute_value = wc_attribute["option"]
# wc_attributes = json.loads(wc_product.attributes)
wc_attributes = json.loads(wc_product.attributes) if wc_product.attributes else []

if not wc_attributes and wc_product.type == "variation":
pass

# for wc_attribute in wc_attributes:
# row = item.append("attributes")
# row.attribute = wc_attribute["name"]
# if wc_product.type == "variation":
# row.attribute_value = wc_attribute["option"]
else:
for wc_attribute in wc_attributes:
row = item.append("attributes")
row.attribute = wc_attribute["name"]
if wc_product.type == "variation":
row.attribute_value = wc_attribute["option"]

# Handle variants
if wc_product.type == "variable":
Expand Down
Loading