Skip to content

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

Save discounted_price for ProduvtVariantBulkUpdate (#15669)

Maciej Korycinskicb8a346d9872
diff --git a/saleor/graphql/product/bulk_mutations/product_variant_bulk_update.py b/saleor/graphql/product/bulk_mutations/product_variant_bulk_update.py
index c527059ccc..7a4824d644 100644
--- a/saleor/graphql/product/bulk_mutations/product_variant_bulk_update.py
+++ b/saleor/graphql/product/bulk_mutations/product_variant_bulk_update.py
@@ -691,7 +691,12 @@ class ProductVariantBulkUpdate(BaseMutation):
models.ProductVariantChannelListing.objects.bulk_create(listings_to_create)
models.ProductVariantChannelListing.objects.bulk_update(
listings_to_update,
- fields=["price_amount", "cost_price_amount", "preorder_quantity_threshold"],
+ fields=[
+ "price_amount",
+ "discounted_price_amount",
+ "cost_price_amount",
+ "preorder_quantity_threshold",
+ ],
)
warehouse_models.Stock.objects.filter(id__in=stocks_to_remove).delete()
models.ProductVariantChannelListing.objects.filter(
diff --git a/saleor/graphql/product/tests/mutations/test_product_variant_bulk_update.py b/saleor/graphql/product/tests/mutations/test_product_variant_bulk_update.py
index 70c5f60b00..9decc564a6 100644
--- a/saleor/graphql/product/tests/mutations/test_product_variant_bulk_update.py
+++ b/saleor/graphql/product/tests/mutations/test_product_variant_bulk_update.py
@@ -410,9 +410,7 @@ def test_product_variant_bulk_update_channel_listings_input(
variant_id = graphene.Node.to_global_id("ProductVariant", variant.pk)
ProductChannelListing.objects.create(product=product, channel=channel_PLN)
- existing_variant_listing = variant.channel_listings.exclude(
- channel=channel_PLN
- ).last()
+ existing_variant_listing = variant.channel_listings.get()
assert variant.channel_listings.count() == 1
product_id = graphene.Node.to_global_id("Product", product.pk)
@@ -452,8 +450,21 @@ def test_product_variant_bulk_update_channel_listings_input(
)
get_graphql_content(response, ignore_errors=True)
- existing_variant_listing.refresh_from_db()
# then
+ existing_variant_listing.refresh_from_db()
+ assert (
+ existing_variant_listing.price_amount == new_price_for_existing_variant_listing
+ )
+ assert (
+ existing_variant_listing.discounted_price_amount
+ == new_price_for_existing_variant_listing
+ )
+ new_variant_listing = variant.channel_listings.get(channel=channel_PLN)
+ assert new_variant_listing.price_amount == not_existing_variant_listing_price
+ assert (
+ new_variant_listing.discounted_price_amount
+ == not_existing_variant_listing_price
+ )
# only promotions with created channel will be marked as dirty
second_promotion_rule.refresh_from_db()