Skip to content

Commit

Permalink
fix: ignore deleted variants from sync
Browse files Browse the repository at this point in the history
  • Loading branch information
ankush committed Oct 28, 2022
1 parent 5e8928e commit 27c6907
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion ecommerce_integrations/shopify/inventory.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

import frappe
from frappe.utils import cint, now
from pyactiveresource.connection import ResourceNotFound
from shopify.resources import InventoryLevel, Variant

from ecommerce_integrations.controllers.inventory import (
Expand Down Expand Up @@ -54,6 +55,10 @@ def upload_inventory_data_to_shopify(inventory_levels, warehous_map) -> None:
)
update_inventory_sync_status(d.ecom_item, time=synced_on)
d.status = "Success"
except ResourceNotFound:
# Variant or location is deleted, mark as last synced and ignore.
update_inventory_sync_status(d.ecom_item, time=synced_on)
d.status = "Not Found"
except Exception as e:
d.status = "Failed"
d.failure_reason = str(e)
Expand All @@ -72,7 +77,7 @@ def _log_inventory_update_status(inventory_levels) -> None:

stats = Counter([d.status for d in inventory_levels])

percent_successful = stats["Success"] / (stats["Success"] + stats["Failed"])
percent_successful = stats["Success"] / len(inventory_levels)

if percent_successful == 0:
status = "Failed"
Expand Down

0 comments on commit 27c6907

Please sign in to comment.