Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Fix product search filter
IKarbowiak92de40143d96
diff --git a/saleor/graphql/product/filters.py b/saleor/graphql/product/filters.pyindex 2af1351c34..26d74eeeb7 100644--- a/saleor/graphql/product/filters.py+++ b/saleor/graphql/product/filters.py@@ -180,7 +180,7 @@ def filter_stock_availability(qs, _, value):def filter_search(qs, _, value):if value:search = picker.pick_backend()- qs &= search(value).distinct()+ qs = qs.distinct() & search(value).distinct()return qsdiff --git a/saleor/graphql/product/tests/test_product.py b/saleor/graphql/product/tests/test_product.pyindex 180311f899..04696e0599 100644--- a/saleor/graphql/product/tests/test_product.py+++ b/saleor/graphql/product/tests/test_product.py@@ -453,6 +453,31 @@ def test_products_query_with_filter_collection(assert products[0]["node"]["name"] == second_product.name+def test_products_query_with_filter_category_and_search(+ query_products_with_filter, staff_api_client, product, permission_manage_products,+):+ category = Category.objects.create(name="Custom", slug="custom")+ second_product = product+ second_product.id = None+ second_product.slug = "second-product"+ second_product.category = category+ product.category = category+ second_product.save()+ product.save()++ category_id = graphene.Node.to_global_id("Category", category.id)+ variables = {"filter": {"categories": [category_id], "search": product.name}}+ staff_api_client.user.user_permissions.add(permission_manage_products)+ response = staff_api_client.post_graphql(query_products_with_filter, variables)+ content = get_graphql_content(response)+ product_id = graphene.Node.to_global_id("Product", product.id)+ products = content["data"]["products"]["edges"]++ assert len(products) == 1+ assert products[0]["node"]["id"] == product_id+ assert products[0]["node"]["name"] == product.name++@pytest.mark.parametrize("products_filter",[