Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Change ordering of update in product discounted price task (#12690)
Tomasz Szymański2bfbb1013bb6
diff --git a/saleor/product/utils/variant_prices.py b/saleor/product/utils/variant_prices.pyindex ba38acdc0f..3c9780a7a6 100644--- a/saleor/product/utils/variant_prices.py+++ b/saleor/product/utils/variant_prices.py@@ -71,10 +71,16 @@ def _products_in_batches(products_qs):# Results in memory usage of ~40MB for 500 productsBATCH_SIZE = 500+ first_batch = True+while True:+ filter_args = {}+ if not first_batch:+ filter_args = {"pk__lt": start_pk}+ first_batch = Falseproducts = list(- products_qs.order_by("pk")- .filter(pk__gt=start_pk)+ products_qs.order_by("-pk")+ .filter(**filter_args).prefetch_related("channel_listings", "collections")[:BATCH_SIZE])if not products: