Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Add two missing fields to product type
Adam Janik9166e1ccca69
diff --git a/saleor/graphql/api.py b/saleor/graphql/api.pyindex ac747abffb..a6daa3a49c 100644--- a/saleor/graphql/api.py+++ b/saleor/graphql/api.py@@ -5,8 +5,8 @@ from graphene_django.filter import DjangoFilterConnectionFieldfrom ..page import models as page_modelsfrom .core.filters import DistinctFilterSet-from .page.mutations import PageCreate, PageDelete, PageUpdatefrom .page.types import Page, resolve_pages+from .page.mutations import PageCreate, PageDelete, PageUpdatefrom .product.filters import ProductFilterSetfrom .product.mutations import (CategoryCreateMutation, CategoryDelete, CategoryUpdateMutation,diff --git a/saleor/graphql/page/mutations.py b/saleor/graphql/page/mutations.pyindex 41de9d3b17..9237c0b53a 100644--- a/saleor/graphql/page/mutations.py+++ b/saleor/graphql/page/mutations.py@@ -3,8 +3,6 @@ from ...page import modelsfrom ..core.mutations import (ModelDeleteMutation, ModelFormMutation, ModelFormUpdateMutation,StaffMemberRequiredMixin)-# TODO: This dummy import allows application to start. Find out why-from .types import Pageclass PageCreate(StaffMemberRequiredMixin, ModelFormMutation):diff --git a/saleor/graphql/product/types.py b/saleor/graphql/product/types.pyindex a33919059d..35f24da13e 100644--- a/saleor/graphql/product/types.py+++ b/saleor/graphql/product/types.py@@ -93,6 +93,8 @@ class Product(CountableDjangoObjectType):description='List of product attributes assigned to this product.')purchase_cost = graphene.Field(TaxedMoneyRange)gross_margin = graphene.List(GrossMargin)+ price_range = graphene.Field(TaxedMoneyRange)+ price_range_undiscounted = graphene.Field(TaxedMoneyRange)class Meta:description = """Represents an individual item for sale in the@@ -127,8 +129,11 @@ class Product(CountableDjangoObjectType):_, gross_margin = get_product_costs_data(self)return [GrossMargin(gross_margin[0], gross_margin[1])]- @permission_required('product.view_product')def resolve_price_range(self, info):+ context = info.context+ return self.get_price_range(discounts=context.discounts)++ def resolve_price_range_undiscounted(self, info):return self.get_price_range()@@ -254,11 +259,11 @@ def resolve_categories(info, level=None):def resolve_products(info, category_id):user = info.context.user+ products = products_visible_to_user(user=user).distinct()if category_id is not None:category = get_node(info, category_id, only_type=Category)- return products_visible_to_user(- user=user).filter(category=category).distinct()- return products_visible_to_user(user=user).distinct()+ return products.filter(category=category)+ return productsdef resolve_attributes(category_id, info):