Skip to content

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

Add visibleInListings product type field

IKarbowiakb02db42466af
diff --git a/saleor/graphql/product/tests/test_product.py b/saleor/graphql/product/tests/test_product.py
index 12cb2e440b..5babdec2bc 100644
--- a/saleor/graphql/product/tests/test_product.py
+++ b/saleor/graphql/product/tests/test_product.py
@@ -122,6 +122,7 @@ QUERY_PRODUCT = """
}
availableForPurchase
isAvailableForPurchase
+ visibleInListings
}
}
"""
@@ -130,13 +131,21 @@ QUERY_PRODUCT = """
def test_product_query_by_id(
user_api_client, product,
):
+ # given
+ product.visible_in_listings = True
+ product.save(update_fields=["visible_in_listings"])
+
variables = {"id": graphene.Node.to_global_id("Product", product.pk)}
+ # when
response = user_api_client.post_graphql(QUERY_PRODUCT, variables=variables)
+
+ # then
content = get_graphql_content(response)
product_data = content["data"]["product"]
assert product_data is not None
assert product_data["name"] == product.name
+ assert product_data["visibleInListings"] is True
def test_product_query_by_id_weight_returned_in_default_unit(
diff --git a/saleor/graphql/product/types/products.py b/saleor/graphql/product/types/products.py
index 5557b10151..3bf54f6068 100644
--- a/saleor/graphql/product/types/products.py
+++ b/saleor/graphql/product/types/products.py
@@ -503,6 +503,7 @@ class Product(CountableDjangoObjectType):
"seo_title",
"updated_at",
"weight",
+ "visible_in_listings",
]
@staticmethod
diff --git a/saleor/graphql/schema.graphql b/saleor/graphql/schema.graphql
index 529e0192b3..9c91887bfd 100644
--- a/saleor/graphql/schema.graphql
+++ b/saleor/graphql/schema.graphql
@@ -3638,6 +3638,7 @@ type Product implements Node & ObjectWithMetadata {
chargeTaxes: Boolean!
weight: Weight
availableForPurchase: Date
+ visibleInListings: Boolean!
privateMetadata: [MetadataItem]!
metadata: [MetadataItem]!
privateMeta: [MetaStore]! @deprecated(reason: "Use the `privetaMetadata` field. This field will be removed after 2020-07-31.")