Skip to content

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

Fix missing currency on varaint channel listing (#18078)

Filip Owczarek07f8aad09d81
diff --git a/saleor/graphql/product/mutations/channels.py b/saleor/graphql/product/mutations/channels.py
index cd56bf458e..66be6a0884 100644
--- a/saleor/graphql/product/mutations/channels.py
+++ b/saleor/graphql/product/mutations/channels.py
@@ -282,7 +282,9 @@ class ProductChannelListingUpdate(BaseChannelListingMutation):
variant_channel_listings = []
for variant in variants:
variant_channel_listings.append(
- ProductVariantChannelListing(channel=channel, variant=variant)
+ ProductVariantChannelListing(
+ channel=channel, variant=variant, currency=channel.currency_code
+ )
)
try:
diff --git a/saleor/graphql/product/tests/mutations/test_product_channel_listing_update.py b/saleor/graphql/product/tests/mutations/test_product_channel_listing_update.py
index 997dbb1c17..9093646630 100644
--- a/saleor/graphql/product/tests/mutations/test_product_channel_listing_update.py
+++ b/saleor/graphql/product/tests/mutations/test_product_channel_listing_update.py
@@ -1115,11 +1115,19 @@ def test_product_channel_listing_add_variant_as_staff_user(
# then
data = content["data"]["productChannelListingUpdate"]
variant_data = data["product"]["variants"]
-
assert not data["errors"]
assert variant_data[0]["channelListings"][0]["channel"]["slug"] == channel_USD.slug
assert variant_data[1]["channelListings"][0]["channel"]["slug"] == channel_USD.slug
+ variant_channel_listing1 = ProductVariantChannelListing.objects.get(
+ channel=channel_USD, variant=variant_1
+ )
+ variant_channel_listing2 = ProductVariantChannelListing.objects.get(
+ channel=channel_USD, variant=variant_2
+ )
+ assert variant_channel_listing1.currency == channel_USD.currency_code
+ assert variant_channel_listing2.currency == channel_USD.currency_code
+
def test_product_channel_listing_add_variant_as_app(
app_api_client, product, permission_manage_products, channel_USD
@@ -1157,6 +1165,15 @@ def test_product_channel_listing_add_variant_as_app(
assert variant_data[0]["channelListings"][0]["channel"]["slug"] == channel_USD.slug
assert variant_data[1]["channelListings"][0]["channel"]["slug"] == channel_USD.slug
+ variant_channel_listing1 = ProductVariantChannelListing.objects.get(
+ channel=channel_USD, variant=variant_1
+ )
+ variant_channel_listing2 = ProductVariantChannelListing.objects.get(
+ channel=channel_USD, variant=variant_2
+ )
+ assert variant_channel_listing1.currency == channel_USD.currency_code
+ assert variant_channel_listing2.currency == channel_USD.currency_code
+
def test_product_channel_listing_remove_variant_as_staff_user(
staff_api_client, product, permission_manage_products, channel_USD, channel_PLN