Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Fix sending the old data in productChannelListingUpdate mutation (#10509)
Iga Karbowiak48e2bc7e3def
diff --git a/saleor/graphql/product/mutations/channels.py b/saleor/graphql/product/mutations/channels.pyindex 7a0a02cc82..485cce25da 100644--- a/saleor/graphql/product/mutations/channels.py+++ b/saleor/graphql/product/mutations/channels.py@@ -332,12 +332,12 @@ class ProductChannelListingUpdate(BaseChannelListingMutation):def save(cls, info, product: "ProductModel", cleaned_input: Dict):cls.update_channels(product, cleaned_input.get("update_channels", []))cls.remove_channels(product, cleaned_input.get("remove_channels", []))+ product = ProductModel.objects.prefetched_for_webhook().get(pk=product.pk)transaction.on_commit(lambda: info.context.plugins.product_updated(product))@classmethoddef perform_mutation(cls, _root, info, id, input):- qs = ProductModel.objects.prefetched_for_webhook()- product = cls.get_node_or_error(info, id, only_type=Product, field="id", qs=qs)+ product = cls.get_node_or_error(info, id, only_type=Product, field="id")errors = defaultdict(list)cleaned_input = cls.clean_channels(diff --git a/saleor/graphql/product/tests/test_product_channel_listing_update.py b/saleor/graphql/product/tests/test_product_channel_listing_update.pyindex 37eb5a0926..c9bc94c604 100644--- a/saleor/graphql/product/tests/test_product_channel_listing_update.py+++ b/saleor/graphql/product/tests/test_product_channel_listing_update.py@@ -279,12 +279,11 @@ def test_product_channel_listing_update_trigger_webhook_product_updated(product,permission_manage_products,channel_USD,- channel_PLN,):# givenpublication_date = datetime.datetime.now(pytz.utc)product_id = graphene.Node.to_global_id("Product", product.pk)- channel_id = graphene.Node.to_global_id("Channel", channel_PLN.id)+ channel_id = graphene.Node.to_global_id("Channel", channel_USD.id)available_for_purchase_date = datetime.datetime(2007, 1, 1, tzinfo=pytz.utc)variables = {"id": product_id,@@ -312,6 +311,10 @@ def test_product_channel_listing_update_trigger_webhook_product_updated(# thenmock_product_updated.assert_called_once_with(product)+ listings = mock_product_updated.call_args.args[0].channel_listings.all()+ for listing in listings:+ if listing.channel == channel_USD:+ assert listing.available_for_purchase_at == available_for_purchase_datedef test_product_channel_listing_update_as_app(