From 939dc6ee3bf13ba47bbbb7d564890995d71d57b3 Mon Sep 17 00:00:00 2001 From: Moggach Date: Tue, 4 Jun 2024 13:08:26 +0000 Subject: [PATCH] skip over products with empty metafields on shopify sync --- app/models/wagtail.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/app/models/wagtail.py b/app/models/wagtail.py index b1ada1e..f64ea9a 100644 --- a/app/models/wagtail.py +++ b/app/models/wagtail.py @@ -740,6 +740,13 @@ def sync_from_shopify_product_id(cls, shopify_product_id): product = shopify.Product.find(shopify_product_id) metafields = product.metafields() metafields = metafields_to_dict(metafields) + + # TODO adjust this function so that we can get different metafields from merchandise as opposed to books + + if not metafields: + print('metafields are empty, skipping product') + return None + if cls.objects.filter(shopify_product_id=shopify_product_id).exists(): return cls.update_instance_for_product(product, metafields) else: