Skip to content

Saleor Core: the high performance, composable, headless commerce API.

Check if sale contains product, category, collection before run celery task

Krzysztof Świątek1f4fcacd26bb
diff --git a/saleor/graphql/discount/mutations.py b/saleor/graphql/discount/mutations.py
index 8fc8dd3a02..9275811f34 100644
--- a/saleor/graphql/discount/mutations.py
+++ b/saleor/graphql/discount/mutations.py
@@ -270,7 +270,11 @@ class SaleUpdateMinimalVariantPriceMixin:
def success_response(cls, instance):
# Update the "minimal_variant_prices" of the associated, discounted
# products (including collections and categories).
- update_products_minimal_variant_prices_of_discount_task.delay(instance.pk)
+ products_exists = instance.products.all().exists()
+ categories_exists = instance.categories.all().exists()
+ collections_exists = instance.collections.all().exists()
+ if products_exists or categories_exists or collections_exists:
+ update_products_minimal_variant_prices_of_discount_task.delay(instance.pk)
return super().success_response(instance)