Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Fix unavailable products through category
fowczrek9d46d03c89c2
diff --git a/saleor/graphql/product/tests/test_category.py b/saleor/graphql/product/tests/test_category.pyindex dd8ff28a65..3b2a2a87e3 100644--- a/saleor/graphql/product/tests/test_category.py+++ b/saleor/graphql/product/tests/test_category.py@@ -106,6 +106,27 @@ def test_category_query_object_with_invalid_object_type(assert content["data"]["category"] is None+def test_category_query_doesnt_show_not_available_products(+ user_api_client, product, channel_USD+):+ category = Category.objects.first()+ variant = product.variants.get()+ # Set product as not visible due to lack of price.+ variant.channel_listings.update(price_amount=None)++ variables = {+ "id": graphene.Node.to_global_id("Category", category.pk),+ "channel": channel_USD.slug,+ }++ response = user_api_client.post_graphql(QUERY_CATEGORY, variables=variables)+ content = get_graphql_content(response)+ category_data = content["data"]["category"]+ assert category_data is not None+ assert category_data["name"] == category.name+ assert not category_data["products"]["edges"]++def test_category_query_description(user_api_client, product, channel_USD):category = Category.objects.first()description = dummy_editorjs("Test description.", json_format=True)diff --git a/saleor/graphql/product/types/products.py b/saleor/graphql/product/types/products.pyindex f084608460..a9af3ac577 100644--- a/saleor/graphql/product/types/products.py+++ b/saleor/graphql/product/types/products.py@@ -1575,7 +1575,7 @@ class Category(ModelObjectType):qs = models.Product.objects.all()if not has_required_permissions:qs = (- qs.published(channel)+ qs.visible_to_user(requestor, channel).annotate_visible_in_listings(channel).exclude(visible_in_listings=False,