Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Restore the price field to allow back compatibility But yet don't expose the base price
NyanKiyoshicd189aa0940f
diff --git a/saleor/graphql/product/types.py b/saleor/graphql/product/types.pyindex 3e0e3cd86d..83d6185a26 100644--- a/saleor/graphql/product/types.py+++ b/saleor/graphql/product/types.py@@ -253,7 +253,7 @@ class ProductVariant(CountableDjangoObjectType):pricing = graphene.Field(VariantPricingInfo,description=dedent(- """Lists the storefront product's pricing,+ """Lists the storefront variant's pricing,the current price and discounts, only meant for displaying"""))is_available = graphene.Boolean(description='Whether the variant is in stock and visible or not.')@@ -390,7 +390,7 @@ class Product(CountableDjangoObjectType):deprecation_reason='Has been renamed to \'pricing\'.')pricing = graphene.Field(ProductPricingInfo, description=dedent(- """Lists the storefront product's pricing,+ """Lists the storefront product's pricing,the current price and discounts, only meant for displaying."""))is_available = graphene.Boolean(description='Whether the product is in stock and visible or not.')@@ -486,10 +486,15 @@ class Product(CountableDjangoObjectType):return self.is_available@permission_required('product.manage_products')- def resolve_price(self, _info):+ def resolve_base_price(self, _info):return self.price- resolve_base_price = resolve_price+ @gql_optimizer.resolver_hints(+ prefetch_related=('variants', 'collections'),+ only=['publication_date', 'charge_taxes', 'price', 'tax_rate'])+ def resolve_price(self, info):+ price_range = self.get_price_range(info.context.discounts)+ return price_range.start.net@gql_optimizer.resolver_hints(prefetch_related='product_type__product_attributes__values')diff --git a/tests/api/test_product.py b/tests/api/test_product.pyindex 5ac87af192..a2a4adeb3e 100644--- a/tests/api/test_product.py+++ b/tests/api/test_product.py@@ -104,6 +104,9 @@ def test_product_query(staff_api_client, product, permission_manage_products):stockQuantity}isAvailable+ price {+ amount+ }pricing {available,priceRange {@@ -159,6 +162,7 @@ def test_product_query(staff_api_client, product, permission_manage_products):'purchaseCost']['stop']['amount']assert product_data['isAvailable'] is product.is_visibleassert product_data['pricing']['available'] is product.is_visible+ assert product_data['price']['amount'] == product.price.amountassert margin[0] == product_data['margin']['start']assert margin[1] == product_data['margin']['stop']