Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Fix missing prefetch (#17426)
Tomasz Szymański68777a15d2a4
diff --git a/saleor/product/utils/variant_prices.py b/saleor/product/utils/variant_prices.pyindex 87b8b0e506..39ccbdcfd7 100644--- a/saleor/product/utils/variant_prices.py+++ b/saleor/product/utils/variant_prices.py@@ -55,9 +55,11 @@ def update_discounted_prices_for_promotion(changed_variant_listing_promotion_rule_to_create = []changed_variant_listing_promotion_rule_to_update = []- product_channel_listings = ProductChannelListing.objects.using(- settings.DATABASE_CONNECTION_REPLICA_NAME- ).filter(Exists(products.filter(id=OuterRef("product_id"))))+ product_channel_listings = (+ ProductChannelListing.objects.using(settings.DATABASE_CONNECTION_REPLICA_NAME)+ .filter(Exists(products.filter(id=OuterRef("product_id"))))+ .prefetch_related("channel")+ )if only_dirty_products:product_channel_listings.filter(discounted_price_dirty=True)