Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Switched from JSONB mapping of attributes to M2M
NyanKiyoshi749b4e43ee99
diff --git a/saleor/core/db/__init__.py b/saleor/core/db/__init__.pynew file mode 100644index 0000000000..e69de29bb2diff --git a/saleor/core/db/fields.py b/saleor/core/db/fields.pynew file mode 100644index 0000000000..07b3d1f358--- /dev/null+++ b/saleor/core/db/fields.py@@ -0,0 +1,25 @@+import json+from typing import Callable++from django.contrib.postgres.fields.jsonb import JSONField+from django.utils.translation import gettext_lazy+++class SanitizedJSONField(JSONField):+ description = gettext_lazy(+ "A JSON field that runs a given sanitization method "+ "before saving into the database."+ )++ def __init__(self, *args, sanitizer: Callable[[dict], dict], **kwargs):+ super(SanitizedJSONField, self).__init__(*args, **kwargs)+ self._sanitizer_method = sanitizer++ def deconstruct(self):+ name, path, args, kwargs = super().deconstruct()+ kwargs["sanitizer"] = self._sanitizer_method+ return name, path, args, kwargs++ def get_db_prep_save(self, value: dict, connection):+ """Sanitize the value for saving using the passed sanitizer."""+ return json.dumps(self._sanitizer_method(value))diff --git a/saleor/core/fields.py b/saleor/core/fields.pydeleted file mode 100644index a156bbcd8f..0000000000--- a/saleor/core/fields.py+++ /dev/null@@ -1,82 +0,0 @@-import json-from typing import Callable--from django.contrib.postgres.fields import jsonb-from django.contrib.postgres.fields.jsonb import JSONField, KeyTransform-from django.db.models import Transform-from django.utils.translation import gettext_lazy---class SanitizedJSONField(JSONField):- description = gettext_lazy(- "A JSON field that runs a given sanitization method "- "before saving into the database."- )-- def __init__(self, *args, sanitizer: Callable[[dict], dict], **kwargs):- super(SanitizedJSONField, self).__init__(*args, **kwargs)- self._sanitizer_method = sanitizer-- def deconstruct(self):- name, path, args, kwargs = super().deconstruct()- kwargs["sanitizer"] = self._sanitizer_method- return name, path, args, kwargs-- def get_db_prep_save(self, value: dict, connection):- """Sanitize the value for saving using the passed sanitizer."""- return json.dumps(self._sanitizer_method(value))---class FilterableJSONBField(jsonb.JSONField):- """A JSONB field with filtering support over numerical keys.-- This only redefine the JSONB field of django to register a custom lookup key- that allow us to filter JSONB field by key value no matter what. Where django's- behavior is to filter by key index position if the lookup value is a string number.-- This is a temporary fix waiting for a fix from django.-- Refer to https://code.djangoproject.com/ticket/30566.- """-- _FROM_KEY_LOOKUP = "from_key_"- _FROM_KEY_LOOKUP_LEN = len(_FROM_KEY_LOOKUP)-- def get_transform(self, lookup_name):- if not lookup_name.startswith(self._FROM_KEY_LOOKUP):- return super().get_lookup(lookup_name)- lookup_name = lookup_name[self._FROM_KEY_LOOKUP_LEN :] # noqa: black conflict- return KeyTransformFactory(lookup_name)---class FromKeyLookup(Transform):- operator = "->"- nested_operator = "#>"-- def __init__(self, key_name, *args, **kwargs):- super().__init__(*args, **kwargs)- self.key_name = key_name-- def as_sql(self, compiler, connection):- key_transforms = [self.key_name]- previous = self.lhs-- while isinstance(previous, KeyTransform):- key_transforms.insert(0, previous.key_name)- previous = previous.lhs-- lhs, params = compiler.compile(previous)-- if len(key_transforms) > 1:- operator, lookup = self.nested_operator, key_transforms- else:- operator, lookup = self.operator, self.key_name- return "(%s %s %%s)" % (lhs, operator), [lookup] + params---class KeyTransformFactory:- def __init__(self, key_name):- self.key_name = key_name-- def __call__(self, *args, **kwargs):- return FromKeyLookup(self.key_name, *args, **kwargs)diff --git a/saleor/core/utils/random_data.py b/saleor/core/utils/random_data.pyindex 45ab0fb7c5..34816d5dfd 100644--- a/saleor/core/utils/random_data.py+++ b/saleor/core/utils/random_data.py@@ -5,6 +5,7 @@ import randomimport unicodedataimport uuidfrom collections import defaultdict+from typing import Type, Unionfrom unittest.mock import patchfrom django.conf import settings@@ -38,15 +39,21 @@ from ...payment.utils import (gateway_void,)from ...product.models import (+ AssignedProductAttribute,+ AssignedVariantAttribute,Attribute,+ AttributeProduct,AttributeValue,+ AttributeVariant,Category,Collection,+ CollectionProduct,Product,ProductImage,ProductType,ProductVariant,)+from ...product.tasks import update_products_minimal_variant_prices_of_discount_taskfrom ...product.thumbnails import (create_category_background_image_thumbnails,create_collection_background_image_thumbnails,@@ -151,29 +158,28 @@ def create_collections(data, placeholder_dir):for collection in data:pk = collection["pk"]defaults = collection["fields"]- products_in_collection = defaults.pop("products")image_name = COLLECTION_IMAGES[pk]background_image = get_image(placeholder_dir, image_name)defaults["background_image"] = background_image- collection = Collection.objects.update_or_create(pk=pk, defaults=defaults)[0]+ Collection.objects.update_or_create(pk=pk, defaults=defaults)create_collection_background_image_thumbnails.delay(pk)- collection.products.set(Product.objects.filter(pk__in=products_in_collection))+++def assign_products_to_collections(associations: list):+ for value in associations:+ pk = value["pk"]+ defaults = value["fields"]+ defaults["collection_id"] = defaults.pop("collection")+ defaults["product_id"] = defaults.pop("product")+ CollectionProduct.objects.update_or_create(pk=pk, defaults=defaults)def create_attributes(attributes_data):for attribute in attributes_data:pk = attribute["pk"]defaults = attribute["fields"]- product_type_id = defaults.pop("product_type")- product_variant_type_id = defaults.pop("product_variant_type")attr, _ = Attribute.objects.update_or_create(pk=pk, defaults=defaults)- if product_type_id:- attr.product_types.add(product_type_id)-- if product_variant_type_id:- attr.product_variant_types.add(product_variant_type_id)-def create_attributes_values(values_data):for value in values_data:@@ -195,7 +201,6 @@ def create_products(products_data, placeholder_dir, create_images):defaults["weight"] = get_weight(defaults["weight"])defaults["category_id"] = defaults.pop("category")defaults["product_type_id"] = defaults.pop("product_type")- defaults["attributes"] = json.loads(defaults["attributes"])product, _ = Product.objects.update_or_create(pk=pk, defaults=defaults)if create_images:@@ -214,12 +219,51 @@ def create_product_variants(variants_data):if product_id not in IMAGES_MAPPING:continuedefaults["product_id"] = product_id- defaults["attributes"] = json.loads(defaults["attributes"])set_field_as_money(defaults, "price_override")set_field_as_money(defaults, "cost_price")ProductVariant.objects.update_or_create(pk=pk, defaults=defaults)+def assign_attributes_to_product_types(+ association_model: Union[Type[AttributeProduct], Type[AttributeVariant]],+ attributes: list,+):+ for value in attributes:+ pk = value["pk"]+ defaults = value["fields"]+ defaults["attribute_id"] = defaults.pop("attribute")+ defaults["product_type_id"] = defaults.pop("product_type")+ association_model.objects.update_or_create(pk=pk, defaults=defaults)+++def assign_attributes_to_products(product_attributes):+ for value in product_attributes:+ pk = value["pk"]+ defaults = value["fields"]+ defaults["product_id"] = defaults.pop("product")+ defaults["assignment_id"] = defaults.pop("assignment")+ assigned_values = defaults.pop("values")+ assoc, created = AssignedProductAttribute.objects.update_or_create(+ pk=pk, defaults=defaults+ )+ if created:+ assoc.values.set(AttributeValue.objects.filter(pk__in=assigned_values))+++def assign_attributes_to_variants(variant_attributes):+ for value in variant_attributes:+ pk = value["pk"]+ defaults = value["fields"]+ defaults["variant_id"] = defaults.pop("variant")+ defaults["assignment_id"] = defaults.pop("assignment")+ assigned_values = defaults.pop("values")+ assoc, created = AssignedVariantAttribute.objects.update_or_create(+ pk=pk, defaults=defaults+ )+ if created:+ assoc.values.set(AttributeValue.objects.filter(pk__in=assigned_values))++def set_field_as_money(defaults, field):amount_field = f"{field}_amount"if amount_field in defaults and defaults[amount_field] is not None:@@ -250,9 +294,22 @@ def create_products_by_schema(placeholder_dir, create_images):create_images=create_images,)create_product_variants(variants_data=types["product.productvariant"])+ assign_attributes_to_product_types(+ AttributeProduct, attributes=types["product.attributeproduct"]+ )+ assign_attributes_to_product_types(+ AttributeVariant, attributes=types["product.attributevariant"]+ )+ assign_attributes_to_products(+ product_attributes=types["product.assignedproductattribute"]+ )+ assign_attributes_to_variants(+ variant_attributes=types["product.assignedvariantattribute"]+ )create_collections(data=types["product.collection"], placeholder_dir=placeholder_dir)+ assign_products_to_collections(associations=types["product.collectionproduct"])class SaleorProvider(BaseProvider):@@ -473,6 +530,7 @@ def create_orders(how_many=10):def create_product_sales(how_many=5):for dummy in range(how_many):sale = create_fake_sale()+ update_products_minimal_variant_prices_of_discount_task.delay(sale.pk)yield "Sale: %s" % (sale,)diff --git a/saleor/dashboard/product/forms.py b/saleor/dashboard/product/forms.pyindex 542ce123aa..f5cd4beaff 100644--- a/saleor/dashboard/product/forms.py+++ b/saleor/dashboard/product/forms.py@@ -1,10 +1,10 @@import bleachfrom django import formsfrom django.conf import settings+from django.db import transactionfrom django.db.models import Countfrom django.forms.models import ModelChoiceIteratorfrom django.forms.widgets import CheckboxSelectMultiple-from django.utils.encoding import smart_textfrom django.utils.text import slugifyfrom django.utils.translation import pgettext_lazyfrom django_prices.forms import MoneyField@@ -29,7 +29,10 @@ from ...product.tasks import (update_variants_names,)from ...product.thumbnails import create_product_thumbnails-from ...product.utils.attributes import get_name_from_attributes+from ...product.utils.attributes import (+ associate_attribute_values_to_instance,+ generate_name_for_variant,+)from ..forms import (ModelChoiceOrCreationField,MoneyModelForm,@@ -198,50 +201,60 @@ class AttributesMixin:available_attributes = Attribute.objects.none()- # Name of a field in self.instance that hold attributes HStore- model_attributes_field = None-def __init__(self, *args, **kwargs):- if not self.model_attributes_field:+ if not self.instance_attributes_rel:raise Exception(- "model_attributes_field must be set in subclasses of "+ "instance_attributes_rel must be set in subclasses of ""AttributesMixin.")def prepare_fields_for_attributes(self):- initial_attrs = getattr(self.instance, self.model_attributes_field)+ initial_attrs = self.instance.attributes+for attribute in self.available_attributes:++ attribute_rel = initial_attrs.filter(+ assignment__attribute_id=attribute.pk+ ).first()+ initial = None if attribute_rel is None else attribute_rel.values.first()+field_defaults = {"label": attribute.name,"required": False,- "initial": initial_attrs.get(str(attribute.pk)),+ "initial": initial,}+if attribute.has_values():field = ModelChoiceOrCreationField(queryset=attribute.values.all(), **field_defaults)else:field = forms.CharField(**field_defaults)+self.fields[attribute.get_formfield_name()] = fielddef iter_attribute_fields(self):+ """In use in templates to retrieve the attributes input fields."""for attr in self.available_attributes:yield self[attr.get_formfield_name()]- def get_saved_attributes(self):- attributes = {}+ def save_attributes(self):+ assert self.instance.pk is not None, "The instance must be saved first"+for attr in self.available_attributes:value = self.cleaned_data.pop(attr.get_formfield_name())- if value:- # if the passed attribute value is a string,- # create the attribute value.- if not isinstance(value, AttributeValue):- value = AttributeValue(- attribute_id=attr.pk, name=value, slug=slugify(value)- )- value.save()- attributes[smart_text(attr.pk)] = [smart_text(value.pk)]- return attributes++ # Skip if no value was supplied for that attribute+ if not value:+ continue++ # If the passed attribute value is a string, create the attribute value.+ if not isinstance(value, AttributeValue):+ value = AttributeValue.objects.create(+ attribute_id=attr.pk, name=value, slug=slugify(value)+ )++ associate_attribute_values_to_instance(self.instance, attr, value)class ProductForm(MoneyModelForm, AttributesMixin):@@ -270,8 +283,6 @@ class ProductForm(MoneyModelForm, AttributesMixin):)price = make_money_field()- model_attributes_field = "attributes"-class Meta:model = Productexclude = [@@ -347,21 +358,23 @@ class ProductForm(MoneyModelForm, AttributesMixin):)return seo_description+ @transaction.atomicdef save(self, commit=True):- attributes = self.get_saved_attributes()- self.instance.attributes = attributes+ assert commit is True, "Commit is required to build the M2M structure"- instance = super().save()- instance.collections.clear()+ super().save()++ self.save_attributes()+ self.instance.collections.clear()for collection in self.cleaned_data["collections"]:- instance.collections.add(collection)- update_product_minimal_variant_price_task.delay(instance.pk)- return instance+ self.instance.collections.add(collection)++ update_product_minimal_variant_price_task.delay(self.instance.pk)+ return self.instanceclass ProductVariantForm(MoneyModelForm, AttributesMixin):- model_attributes_field = "attributes"weight = WeightField(required=False,label=pgettext_lazy("ProductVariant weight", "Weight"),@@ -434,19 +447,19 @@ class ProductVariantForm(MoneyModelForm, AttributesMixin):or self.instance.product.product_type.weight.value)+ @transaction.atomicdef save(self, commit=True):- assert commit is True, "Commit is required"+ assert commit is True, "Commit is required to build the M2M structure"- attributes = self.get_saved_attributes()- self.instance.attributes = attributes- attrs = self.instance.product.product_type.variant_attributes.prefetch_related(- "values__translations"- )- self.instance.name = get_name_from_attributes(self.instance, attrs)+ # We need to save first to create the attribute mapping+ # and then to update the price cache+ super().save()++ self.save_attributes()- super().save(commit=commit)+ self.instance.name = generate_name_for_variant(self.instance)+ self.instance.save(update_fields=["name"])- # Note: save must always be called with commit=Trueupdate_product_minimal_variant_price_task.delay(self.instance.product_id)return self.instancediff --git a/saleor/dashboard/product/views.py b/saleor/dashboard/product/views.pyindex a5de2fdb3d..fb255c8973 100644--- a/saleor/dashboard/product/views.py+++ b/saleor/dashboard/product/views.py@@ -17,9 +17,9 @@ from ...product.models import (ProductType,ProductVariant,)+from ...product.tasks import update_product_minimal_variant_price_taskfrom ...product.utils.availability import get_product_availabilityfrom ...product.utils.costs import get_margin_for_variant, get_product_costs_data-from ...product.tasks import update_product_minimal_variant_price_taskfrom ..views import staff_member_requiredfrom . import formsfrom .filters import AttributeFilter, ProductFilter, ProductTypeFilter@@ -154,7 +154,9 @@ def product_create(request, type_pk):@permission_required("product.manage_products")def product_edit(request, pk):product = get_object_or_404(- Product.objects.prefetch_related("variants", "product_type__attributeproduct"),+ Product.objects.prefetch_related(+ "variants", "product_type", "product_type__attributeproduct", "attributes"+ ),pk=pk,)form = forms.ProductForm(request.POST or None, instance=product)@@ -353,7 +355,14 @@ def variant_create(request, product_pk):@permission_required("product.manage_products")def variant_edit(request, product_pk, variant_pk):product = get_object_or_404(Product.objects.all(), pk=product_pk)- variant = get_object_or_404(product.variants.all(), pk=variant_pk)+ variant = get_object_or_404(+ product.variants.prefetch_related(+ "product__product_type",+ "product__product_type__attributevariant",+ "attributes",+ ),+ pk=variant_pk,+ )form = forms.ProductVariantForm(request.POST or None, instance=variant)if form.is_valid():form.save()diff --git a/saleor/graphql/checkout/mutations.py b/saleor/graphql/checkout/mutations.pyindex 08f108c955..4dcfbe60cc 100644--- a/saleor/graphql/checkout/mutations.py+++ b/saleor/graphql/checkout/mutations.py@@ -420,9 +420,7 @@ class CheckoutShippingAddressUpdate(BaseMutation, I18nMixin):@classmethoddef perform_mutation(cls, _root, info, checkout_id, shipping_address):- pk = from_global_id_strict_type(- info, checkout_id, Checkout, field="checkout_id"- )+ pk = from_global_id_strict_type(checkout_id, Checkout, field="checkout_id")try:checkout = models.Checkout.objects.prefetch_related(@@ -512,7 +510,7 @@ class CheckoutShippingMethodUpdate(BaseMutation):@classmethoddef perform_mutation(cls, _root, info, checkout_id, shipping_method_id):pk = from_global_id_strict_type(- info, checkout_id, only_type=Checkout, field="checkout_id"+ checkout_id, only_type=Checkout, field="checkout_id")try:diff --git a/saleor/graphql/core/mutations.py b/saleor/graphql/core/mutations.pyindex f9af4e6c22..6780f38c6c 100644--- a/saleor/graphql/core/mutations.py+++ b/saleor/graphql/core/mutations.py@@ -1,5 +1,5 @@from itertools import chain-from typing import Tuple+from typing import Tuple, Unionimport graphenefrom django.contrib.auth import get_user_model@@ -8,7 +8,9 @@ from django.core.exceptions import (ImproperlyConfigured,ValidationError,)+from django.db.models import QuerySetfrom django.db.models.fields.files import FileField+from graphene import ObjectTypefrom graphene.types.mutation import MutationOptionsfrom graphene_django.registry import get_global_registryfrom graphql.error import GraphQLError@@ -19,7 +21,7 @@ from ...account import modelsfrom ..account.types import Userfrom ..utils import get_nodesfrom .types import Error, MetaInput, MetaPath, Upload-from .utils import snake_to_camel_case+from .utils import from_global_id_strict_type, snake_to_camel_caseregistry = get_global_registry()@@ -104,12 +106,40 @@ class BaseMutation(graphene.Mutation):cls._meta.fields.update(fields)@classmethod- def get_node_or_error(cls, info, node_id, field="id", only_type=None):+ def get_node_by_id(+ cls, info, graphene_type: ObjectType, node_id: Union[int, str], qs=None+ ):+ """Attempt to resolve a node from the given internal ID.++ Whether by using the provided query set object or by calling type's get_node().+ """+ if qs is not None:+ return qs.filter(pk=node_id).first()+ get_node = getattr(graphene_type, "get_node", None)+ if get_node:+ return get_node(info, node_id)+ return None++ @classmethod+ def get_node_or_error(cls, info, node_id, field="id", only_type=None, qs=None):if not node_id:return Nonetry:- node = graphene.Node.get_node_from_global_id(info, node_id, only_type)+ if only_type is not None:+ internal_id = from_global_id_strict_type(+ node_id, only_type, field=field+ )+ else:+ # FIXME: warn when supplied only_type is None?+ only_type, internal_id = graphene.Node.from_global_id(node_id)++ if isinstance(only_type, str):+ only_type = info.schema.get_type(only_type).graphene_type++ node = cls.get_node_by_id(+ info, graphene_type=only_type, node_id=internal_id, qs=qs+ )except (AssertionError, GraphQLError) as e:raise ValidationError({field: str(e)})else:@@ -330,11 +360,17 @@ class ModelMutation(BaseMutation):instance.save()@classmethod- def get_instance(cls, info, **data):+ def get_instance(cls, info, __qs: QuerySet = None, **data):+ """Retrieve an instance from the supplied global id.++ Optionally take a __qs parameter to resolve the node using a custom query set.+ """object_id = data.get("id")if object_id:model_type = registry.get_type_for_model(cls._meta.model)- instance = cls.get_node_or_error(info, object_id, only_type=model_type)+ instance = cls.get_node_or_error(+ info, object_id, only_type=model_type, qs=__qs+ )else:instance = cls._meta.model()return instancediff --git a/saleor/graphql/core/utils/__init__.py b/saleor/graphql/core/utils/__init__.pyindex 2b5c22b675..ea47bb3c80 100644--- a/saleor/graphql/core/utils/__init__.py+++ b/saleor/graphql/core/utils/__init__.py@@ -1,6 +1,10 @@+import binascii+from typing import Union+import grapheneimport graphene_django_optimizer as gql_optimizerfrom django.core.exceptions import ValidationError+from graphene import ObjectTypedef clean_seo_fields(data):@@ -30,12 +34,17 @@ def validate_image_file(file, field_name):raise ValidationError({field_name: "Invalid file type"})-def from_global_id_strict_type(info, global_id, only_type, field="id"):+def from_global_id_strict_type(+ global_id: str, only_type: Union[ObjectType, str], field: str = "id"+) -> str:"""Resolve a node global id with a strict given type required."""- _type, _id = graphene.Node.from_global_id(global_id)- graphene_type = info.schema.get_type(_type).graphene_type- if graphene_type != only_type:- raise ValidationError({field: "Couldn't resolve to a node: %s" % global_id})+ try:+ _type, _id = graphene.Node.from_global_id(global_id)+ except (binascii.Error, UnicodeDecodeError) as exc:+ raise ValidationError({field: f"Invalid base64 global ID"}) from exc++ if str(_type) != str(only_type):+ raise ValidationError({field: f"Must receive a {only_type} id."})return _iddiff --git a/saleor/graphql/payment/mutations.py b/saleor/graphql/payment/mutations.pyindex d131aefa51..b78b510d31 100644--- a/saleor/graphql/payment/mutations.py+++ b/saleor/graphql/payment/mutations.py@@ -65,7 +65,7 @@ class CheckoutPaymentCreate(BaseMutation, I18nMixin):@classmethoddef perform_mutation(cls, _root, info, checkout_id, **data):checkout_id = from_global_id_strict_type(- info, checkout_id, only_type=Checkout, field="checkout_id"+ checkout_id, only_type=Checkout, field="checkout_id")checkout = models.Checkout.objects.prefetch_related("lines__variant__product__collections"diff --git a/saleor/graphql/product/filters.py b/saleor/graphql/product/filters.pyindex 355c7ef7e9..e2fdf4a991 100644--- a/saleor/graphql/product/filters.py+++ b/saleor/graphql/product/filters.py@@ -1,11 +1,13 @@-import functools-import operatorfrom collections import defaultdictimport django_filters-from django.db.models import Q, Sum+from django.db.models import Sumfrom graphene_django.filter import GlobalIDFilter, GlobalIDMultipleChoiceFilter+from ...product.filters import (+ T_PRODUCT_FILTER_QUERIES,+ filter_products_by_attributes_values,+)from ...product.models import Attribute, Category, Collection, Product, ProductTypefrom ...search.backends import pickerfrom ..core.filters import EnumFilter, ListObjectTypeFilter, ObjectTypeFilter@@ -33,7 +35,7 @@ def filter_fields_containing_value(*search_fields: str):return _filter_qs-def filter_products_by_attributes(qs, filter_value):+def _clean_product_attributes_filter_input(filter_value) -> T_PRODUCT_FILTER_QUERIES:attributes = Attribute.objects.prefetch_related("values")attributes_map = {attribute.slug: attribute.pk for attribute in attributes}values_map = {@@ -41,6 +43,7 @@ def filter_products_by_attributes(qs, filter_value):for attr in attributes}queries = defaultdict(list)+# Convert attribute:value pairs into a dictionary where# attributes are keys and values are grouped in listsfor attr_name, val_slug in filter_value:@@ -49,21 +52,13 @@ def filter_products_by_attributes(qs, filter_value):attr_pk = attributes_map[attr_name]attr_val_pk = values_map[attr_name].get(val_slug, val_slug)queries[attr_pk].append(attr_val_pk)- # Combine filters of the same attribute with OR operator- # and then combine full query with AND operator.- combine_and = [- functools.reduce(- operator.or_,- [- Q(**{f"variants__attributes__from_key_{key}__has_key": str(v)})- | Q(**{f"attributes__from_key_{key}__has_key": str(v)})- for v in values- ],- )- for key, values in queries.items()- ]- query = functools.reduce(operator.and_, combine_and)- return qs.filter(query).distinct()++ return queries+++def filter_products_by_attributes(qs, filter_value):+ queries = _clean_product_attributes_filter_input(filter_value)+ return filter_products_by_attributes_values(qs, queries)def filter_products_by_price(qs, price_lte=None, price_gte=None):diff --git a/saleor/graphql/product/interfaces.py b/saleor/graphql/product/interfaces.pydeleted file mode 100644index 61db2c2105..0000000000--- a/saleor/graphql/product/interfaces.py+++ /dev/null@@ -1,10 +0,0 @@-from dataclasses import dataclass-from typing import List--from ...product import models---@dataclass(frozen=True)-class ResolvedAttributeInput:- instance: models.Attribute- values: List[str]diff --git a/saleor/graphql/product/mutations/attributes.py b/saleor/graphql/product/mutations/attributes.pyindex 5e2c67431c..82ea0f1bde 100644--- a/saleor/graphql/product/mutations/attributes.py+++ b/saleor/graphql/product/mutations/attributes.py@@ -299,7 +299,7 @@ class AttributeAssign(BaseMutation):for operation in operations:pk = from_global_id_strict_type(- info, operation.id, only_type=Attribute, field="operations"+ operation.id, only_type=Attribute, field="operations")if operation.type == AttributeTypeEnum.PRODUCT:product_attrs_pks.append(pk)@@ -438,7 +438,7 @@ class AttributeUnassign(BaseMutation):# Resolve all the passed IDs to intsattribute_pks = [from_global_id_strict_type(- info, attribute_id, only_type=Attribute, field="attribute_id"+ attribute_id, only_type=Attribute, field="attribute_id")for attribute_id in attribute_ids]@@ -620,7 +620,7 @@ class ProductTypeReorderAttributes(BaseMutation):@classmethoddef perform_mutation(cls, _root, info, product_type_id, type, moves):pk = from_global_id_strict_type(- info, product_type_id, only_type=ProductType, field="product_type_id"+ product_type_id, only_type=ProductType, field="product_type_id")if type == AttributeTypeEnum.PRODUCT:@@ -647,7 +647,7 @@ class ProductTypeReorderAttributes(BaseMutation):# Resolve the attributesfor move_info in moves:attribute_pk = from_global_id_strict_type(- info, move_info.id, only_type=Attribute, field="moves"+ move_info.id, only_type=Attribute, field="moves")try:@@ -685,7 +685,7 @@ class AttributeReorderValues(BaseMutation):@classmethoddef perform_mutation(cls, _root, info, attribute_id, moves):pk = from_global_id_strict_type(- info, attribute_id, only_type=Attribute, field="attribute_id"+ attribute_id, only_type=Attribute, field="attribute_id")try:@@ -701,7 +701,7 @@ class AttributeReorderValues(BaseMutation):# Resolve the valuesfor move_info in moves:value_pk = from_global_id_strict_type(- info, move_info.id, only_type=AttributeValue, field="moves"+ move_info.id, only_type=AttributeValue, field="moves")try:diff --git a/saleor/graphql/product/mutations/products.py b/saleor/graphql/product/mutations/products.pyindex 420aa37938..6cb2caefc3 100644--- a/saleor/graphql/product/mutations/products.py+++ b/saleor/graphql/product/mutations/products.py@@ -1,10 +1,12 @@-from typing import Dict, List+from typing import Iterable, List, Tuple, Unionimport graphenefrom django.core.exceptions import ObjectDoesNotExist, ValidationErrorfrom django.db import transaction+from django.db.models import Q, QuerySetfrom django.template.defaultfilters import slugifyfrom graphene.types import InputObjectType+from graphql_relay import from_global_idfrom ....product import modelsfrom ....product.tasks import (@@ -17,7 +19,10 @@ from ....product.thumbnails import (create_collection_background_image_thumbnails,create_product_thumbnails,)-from ....product.utils.attributes import get_name_from_attributes+from ....product.utils.attributes import (+ associate_attribute_values_to_instance,+ generate_name_for_variant,+)from ...core.mutations import (BaseMutation,ClearMetaBaseMutation,@@ -34,7 +39,6 @@ from ...core.utils import ()from ...core.utils.reordering import perform_reorderingfrom ..types import (- Attribute,Category,Collection,MoveProductInput,@@ -42,7 +46,10 @@ from ..types import (ProductImage,ProductVariant,)-from ..utils import attributes_to_json+from ..utils import (+ validate_attribute_input_for_product,+ validate_attribute_input_for_variant,+)class CategoryInput(graphene.InputObjectType):@@ -231,7 +238,7 @@ class CollectionReorderProducts(BaseMutation):@classmethoddef perform_mutation(cls, _root, info, collection_id, moves):pk = from_global_id_strict_type(- info, collection_id, only_type=Collection, field="collection_id"+ collection_id, only_type=Collection, field="collection_id")try:@@ -250,7 +257,7 @@ class CollectionReorderProducts(BaseMutation):# Resolve the productsfor move_info in moves:product_pk = from_global_id_strict_type(- info, move_info.product_id, only_type=Product, field="moves"+ move_info.product_id, only_type=Product, field="moves")try:@@ -396,8 +403,8 @@ class CategoryClearPrivateMeta(ClearMetaBaseMutation):class AttributeValueInput(InputObjectType):- id = graphene.ID(description="ID of an attribute")- slug = graphene.String(description="Slug of an attribute.")+ id = graphene.ID(description="ID of the selected attribute")+ slug = graphene.String(description="Slug of the selected attribute.")values = graphene.List(graphene.String,required=True,@@ -457,6 +464,189 @@ class ProductCreateInput(ProductInput):)+T_INPUT_MAP = List[Tuple[models.Attribute, List[str]]]+T_INSTANCE = Union[models.Product, models.ProductVariant]+++class AttributeAssignmentMixin:+ """Handles cleaning of the attribute input and creating the proper relations.++ 1. You should first call ``clean_input``, to transform and attempt to resolve+ the provided input into actual objects.+ 2. You should then call ``is_valid`` with the cleaned input to perform a few+ checks to validate the operations supplied by the user are possible and allowed.+ 3. Once everything is ready and all your data is saved inside a transaction,+ you shall call ``save`` with the cleaned input to build all the required+ relations. Once the ``save`` call is done, you are safe from continuing working+ or to commit the transaction.++ Note: you shall never call ``save`` outside of a transaction and never before+ the targeted instance owns a primary key. Failing to do so, the relations will+ be unable to build or might only be partially built.+ """++ @classmethod+ def _get_attribute_nodes(+ cls,+ qs: QuerySet,+ *,+ global_ids: List[str],+ pks: Iterable[int],+ slugs: Iterable[str],+ ):+ """Retrieve attributes nodes from given global IDs and/or slugs."""+ qs = qs.filter(Q(pk__in=pks) | Q(slug__in=slugs))+ nodes = list(qs) # type: List[models.Attribute]++ if not nodes:+ raise ValidationError(+ f"Could not resolve to a node: ids={global_ids} and slugs={list(slugs)}"+ )++ nodes_pk_list = set()+ nodes_slug_list = set()+ for node in nodes:+ nodes_pk_list.add(node.pk)+ nodes_slug_list.add(node.slug)++ for pk, global_id in zip(pks, global_ids):+ if pk not in nodes_pk_list:+ raise ValidationError(f"Could not resolve {global_id!r} to Attribute")++ for slug in slugs:+ if slug not in nodes_slug_list:+ raise ValidationError(f"Could not resolve slug {slug!r} to Attribute")++ return nodes++ @classmethod+ def _resolve_attribute_global_id(cls, global_id: str) -> int:+ """Resolve an Attribute global ID into an internal ID (int)."""+ graphene_type, internal_id = from_global_id(global_id) # type: str, str+ if graphene_type != "Attribute":+ raise ValidationError(f"Must receive an Attribute id, got {graphene_type}.")+ if not internal_id.isnumeric():+ raise ValidationError(f"An invalid ID value was passed: {global_id}")+ return int(internal_id)++ @classmethod+ def _pre_save_values(cls, attribute: models.Attribute, values: List[str]):+ """Lazy-retrieve or create the database objects from the supplied raw values."""+ get_or_create = attribute.values.get_or_create+ return tuple(+ get_or_create(attribute=attribute, name=value, slug=slugify(value))[0]+ for value in values+ )++ @classmethod+ def _check_input_for_product(cls, cleaned_input: T_INPUT_MAP, qs: QuerySet):+ """Check the cleaned attribute input for a product.++ An Attribute queryset is supplied.++ - ensure all required attributes are passed+ - ensure the values are correct for a product+ """+ supplied_attribute_pk = []+ for attribute, values in cleaned_input:+ validate_attribute_input_for_product(attribute, values)+ supplied_attribute_pk.append(attribute.pk)++ # Asserts all required attributes are supplied+ missing_required_filter = Q(value_required=True) & ~Q(+ pk__in=supplied_attribute_pk+ )++ if qs.filter(missing_required_filter).exists():+ raise ValidationError(+ "All attributes flagged as having a value required must be supplied."+ )++ @classmethod+ def _check_input_for_variant(cls, cleaned_input: T_INPUT_MAP, qs: QuerySet):+ """Check the cleaned attribute input for a variant.++ An Attribute queryset is supplied.++ - ensure all attributes are passed+ - ensure the values are correct for a variant+ """+ if len(cleaned_input) != qs.count():+ raise ValidationError("All attributes must take a value")++ for attribute, values in cleaned_input:+ validate_attribute_input_for_variant(attribute, values)++ @classmethod+ def clean_input(cls, raw_input: dict, attributes_qs: QuerySet) -> T_INPUT_MAP:+ """Resolve and prepare the input for further checks.++ :param raw_input: The user's attributes input.+ :param attributes_qs: A queryset of attributes, must prefetch attribute values.++ :raises ValidationError: contain the message.+ :return: The resolved data+ """++ # Mapping to associate the input values back to the resolved attribute nodes+ pks = {}+ slugs = {}++ # Temporary storage of the passed ID for error reporting+ global_ids = []++ for attribute_input in raw_input:+ global_id = attribute_input.get("id")+ slug = attribute_input.get("slug")+ values = attribute_input["values"]++ if global_id:+ internal_id = cls._resolve_attribute_global_id(global_id)+ global_ids.append(global_id)+ pks[internal_id] = values+ elif slug:+ slugs[slug] = values+ else:+ raise ValidationError("You must whether supply an ID or a slug")++ attributes = cls._get_attribute_nodes(+ attributes_qs, global_ids=global_ids, pks=pks.keys(), slugs=slugs.keys()+ )+ cleaned_input = []+ for attribute in attributes:+ key = pks.get(attribute.pk, None)++ if key is None:+ key = slugs[attribute.slug]++ cleaned_input.append((attribute, key))+ return cleaned_input++ @classmethod+ def validate_input(cls, cleaned_input: T_INPUT_MAP, attribute_qs, is_variant: bool):+ """Check if no invalid operations were supplied.++ :raises ValidationError: when an invalid operation was found.+ """+ if is_variant:+ return cls._check_input_for_variant(cleaned_input, attribute_qs)+ else:+ return cls._check_input_for_product(cleaned_input, attribute_qs)++ @classmethod+ def save(cls, instance: T_INSTANCE, cleaned_input: T_INPUT_MAP):+ """Save the cleaned input into the database against the given instance.++ Note: this should always be ran inside a transaction.++ :param instance: the product or variant to associate the attribute against.+ :param cleaned_input: the cleaned user input (refer to clean_attributes)+ """+ for attribute, values in cleaned_input:+ values = cls._pre_save_values(attribute, values)+ associate_attribute_values_to_instance(instance, attribute, *values)++class ProductCreate(ModelMutation):class Arguments:input = ProductCreateInput(@@ -468,6 +658,17 @@ class ProductCreate(ModelMutation):model = models.Productpermissions = ("product.manage_products",)+ @classmethod+ def clean_attributes(+ cls, attributes: dict, product_type: models.ProductType+ ) -> T_INPUT_MAP:+ attributes_qs = product_type.product_attributes+ attributes = AttributeAssignmentMixin.clean_input(attributes, attributes_qs)+ AttributeAssignmentMixin.validate_input(+ attributes, attributes_qs, is_variant=False+ )+ return attributes+@classmethoddef clean_input(cls, info, instance, data):cleaned_input = super().clean_input(info, instance, data)@@ -476,10 +677,10 @@ class ProductCreate(ModelMutation):# `Product` model, which is HStore field that maps attribute's PK to# the value's PK.- attributes = cleaned_input.pop("attributes", [])+ attributes = cleaned_input.get("attributes")product_type = (instance.product_type if instance.pk else cleaned_input.get("product_type")- )+ ) # type: models.ProductType# Try to get price from "basePrice" or "price" field. Once "price" is removed# from the schema, only "basePrice" should be used here.@@ -500,13 +701,13 @@ class ProductCreate(ModelMutation):info.context.extensions.assign_tax_code_to_object_meta(instance, tax_code)if attributes and product_type:- qs = product_type.product_attributes.prefetch_related("values")try:- attributes = attributes_to_json(attributes, qs)- except ValueError as e:- raise ValidationError({"attributes": str(e)})- else:- cleaned_input["attributes"] = attributes+ cleaned_input["attributes"] = cls.clean_attributes(+ attributes, product_type+ )+ except ValidationError as exc:+ raise ValidationError({"attributes": str(exc.args[0])})+clean_seo_fields(cleaned_input)cls.clean_sku(product_type, cleaned_input)return cleaned_input@@ -527,6 +728,18 @@ class ProductCreate(ModelMutation):elif models.ProductVariant.objects.filter(sku=input_sku).exists():raise ValidationError({"sku": "Product with this SKU already exists."})+ @classmethod+ def get_instance(cls, info, __qs: QuerySet = None, **data):+ """Prefetch related fields that are needed to process the mutation."""+ # If we are updating an instance and want to update its attributes,+ # prefetch them.+ if data.get("id") and data.get("attributes"):+ __qs = cls.Meta.model.objects.prefetch_related(+ "product_type__product_attributes",+ "attributes__assignment__attribute__values",+ )+ return super().get_instance(info, __qs, **data)+@classmethod@transaction.atomicdef save(cls, info, instance, cleaned_input):@@ -545,6 +758,10 @@ class ProductCreate(ModelMutation):quantity=quantity,)+ attributes = cleaned_input.get("attributes")+ if attributes:+ AttributeAssignmentMixin.save(instance, attributes)+@classmethoddef _save_m2m(cls, info, instance, cleaned_data):collections = cleaned_data.get("collections", None)@@ -595,6 +812,10 @@ class ProductUpdate(ProductCreate):# Recalculate the "minimal variant price"update_product_minimal_variant_price_task.delay(instance.pk)+ attributes = cleaned_input.get("attributes")+ if attributes:+ AttributeAssignmentMixin.save(instance, attributes)+class ProductDelete(ModelDeleteMutation):class Arguments:@@ -683,38 +904,18 @@ class ProductVariantCreate(ModelMutation):permissions = ("product.manage_products",)@classmethod- def clean_product_type_attributes(cls, info, attributes_qs, attributes_input):- # transform attributes_input list to a dict of slug:value pairs- input_slug_map = {} # type: Dict[str, List[str]]- input_id_map = {} # type: Dict[int, List[str]]-- for attr_input in attributes_input:- attr_id = attr_input.get("id", None)- slug = attr_input.get("slug", None)- values = attr_input["values"]-- if attr_id:- attr_id = from_global_id_strict_type(- info, attr_id, only_type=Attribute, field="attributes"- )- input_id_map[int(attr_id)] = values- elif slug:- input_slug_map[slug] = values- else:- raise ValidationError(- {"attributes": "Please provide a value's identifier."}- )-- for attr in attributes_qs:- values_by_id = input_id_map.get(attr.id, None)- values_by_slug = input_slug_map.get(attr.slug, None)-- if not values_by_id and not values_by_slug:- fieldname = "attributes:%s" % attr.slug- raise ValidationError({fieldname: "This field cannot be blank."})+ def clean_attributes(+ cls, attributes: dict, product_type: models.ProductType+ ) -> T_INPUT_MAP:+ attributes_qs = product_type.variant_attributes+ attributes = AttributeAssignmentMixin.clean_input(attributes, attributes_qs)+ AttributeAssignmentMixin.validate_input(+ attributes, attributes_qs, is_variant=True+ )+ return attributes@classmethod- def clean_input(cls, info, instance, data):+ def clean_input(cls, info, instance: models.ProductVariant, data: dict):cleaned_input = super().clean_input(info, instance, data)cost_price_amount = cleaned_input.pop("cost_price", None)@@ -729,32 +930,39 @@ class ProductVariantCreate(ModelMutation):# We need to transform them into the format they're stored in the# `Product` model, which is HStore field that maps attribute's PK to# the value's PK.-- if "attributes" in data:- attributes_input = cleaned_input.pop("attributes")- product = instance.product if instance.pk else cleaned_input.get("product")- product_type = product.product_type- variant_attrs = product_type.variant_attributes.prefetch_related("values")- try:- cls.clean_product_type_attributes(info, variant_attrs, attributes_input)- attributes = attributes_to_json(attributes_input, variant_attrs)- except ValueError as e:- raise ValidationError({"attributes": str(e)})+ attributes = cleaned_input.get("attributes")+ if attributes:+ if instance.product_id is not None:+ # If the variant is getting updated,+ # simply retrieve the associated product type+ product_type = instance.product.product_typeelse:- cleaned_input["attributes"] = attributes+ # If the variant is getting created, no product type is associated yet,+ # retrieve it from the required "product" input field+ product_type = cleaned_input["product"].product_type+ try:+ cleaned_input["attributes"] = cls.clean_attributes(+ attributes, product_type+ )+ except ValidationError as exc:+ raise ValidationError({"attributes": str(exc.args[0])})return cleaned_input@classmethod+ @transaction.atomic()def save(cls, info, instance, cleaned_input):- attributes = instance.product.product_type.variant_attributes.prefetch_related(- "values__translations"- )- instance.name = get_name_from_attributes(instance, attributes)+ # FIXME: get_node should prefetchinstance.save()# Recalculate the "minimal variant price" for the parent productupdate_product_minimal_variant_price_task.delay(instance.product_id)+ attributes = cleaned_input.get("attributes")+ if attributes:+ AttributeAssignmentMixin.save(instance, attributes)+ instance.name = generate_name_for_variant(instance)+ instance.save(update_fields=["name"])+class ProductVariantUpdate(ProductVariantCreate):class Arguments:diff --git a/saleor/graphql/product/types/attributes.py b/saleor/graphql/product/types/attributes.pyindex e2ec7942b8..d4146a3cc9 100644--- a/saleor/graphql/product/types/attributes.py+++ b/saleor/graphql/product/types/attributes.py@@ -5,6 +5,7 @@ import graphene_django_optimizer as gql_optimizerfrom graphene import relayfrom ....product import models+from ....product.utils.attributes import T_ASSIGNMENT_RELfrom ...core.connection import CountableDjangoObjectTypefrom ...core.resolvers import resolve_meta, resolve_private_metafrom ...core.types import MetadataObjectType@@ -203,6 +204,10 @@ class SelectedAttribute(graphene.ObjectType):class Meta:description = "Represents a custom attribute."+ @staticmethod+ def resolve_value(root: T_ASSIGNMENT_REL, _info):+ return root.values.first()+class AttributeInput(graphene.InputObjectType):slug = graphene.String(required=True, description=AttributeDescriptions.SLUG)diff --git a/saleor/graphql/product/types/products.py b/saleor/graphql/product/types/products.pyindex 7ee4b52efa..4a07f0dd85 100644--- a/saleor/graphql/product/types/products.py+++ b/saleor/graphql/product/types/products.py@@ -1,5 +1,4 @@-from collections import OrderedDict-from typing import Dict+from typing import List, Unionimport grapheneimport graphene_django_optimizer as gql_optimizer@@ -75,31 +74,55 @@ def prefetch_products_collection_sorted(info, *_args, **_kwargs):)-def resolve_attribute_list(attributes_json, attributes_qs):- """Resolve attributes dict into a list of `SelectedAttribute`s.+def resolve_attribute_list(+ instance: Union[models.Product, models.ProductVariant], *, user+) -> List[SelectedAttribute]:+ """Resolve attributes from a product into a list of `SelectedAttribute`s.- keys = list(attributes.keys())- values = list(attributes.values())-- `attributes_qs` is the queryset of attribute objects. If it's prefetch- beforehand along with the values, it saves database queries.+ Note: you have to prefetch the below M2M fields.+ - product_type -> attribute[rel] -> [rel]assignments -> values+ - product_type -> attribute[rel] -> attribute"""- attributes_map = OrderedDict() # type: Dict[str, models.Attribute]- values_map = {} # type: Dict[str, models.AttributeValue]- for attr in attributes_qs:- attributes_map[str(attr.pk)] = attr- for val in attr.values.all():- values_map[str(val.pk)] = val-- attributes_list = []- for attr_pk, attr in attributes_map.items():- values = attributes_json.get(attr_pk, [])- values = [values_map[v_pk] for v_pk in values if v_pk in values_map]- value = values[0] if values else None- attributes_list.append(- SelectedAttribute(attribute=attr, value=value, values=values)+ resolved_attributes = []++ # Retrieve the product type+ if isinstance(instance, models.Product):+ product_type = instance.product_type+ product_type_attributes_assoc_field = "attributeproduct"+ assigned_attribute_instance_field = "productassignments"+ assigned_attribute_instance_filters = {"product_id": instance.pk}+ elif isinstance(instance, models.ProductVariant):+ product_type = instance.product.product_type+ product_type_attributes_assoc_field = "attributevariant"+ assigned_attribute_instance_field = "variantassignments"+ assigned_attribute_instance_filters = {"variant_id": instance.pk}+ else:+ raise AssertionError(f"{instance.__class__.__name__} is unsupported")++ # Retrieve all the product attributes assigned to this product type+ attributes_qs = getattr(product_type, product_type_attributes_assoc_field)+ attributes_qs = attributes_qs.get_visible_to_user(user)++ # An empty QuerySet for unresolved values+ empty_qs = models.AttributeValue.objects.none()++ # Goes through all the attributes assigned to the product type+ # The assigned values are returned as a QuerySet, but will assign a+ # dummy empty QuerySet if no values are assigned to the given instance.+ for attr_data_rel in attributes_qs:+ attr_instance_data = getattr(attr_data_rel, assigned_attribute_instance_field)++ # Retrieve the instance's associated data+ attr_data = attr_instance_data.filter(**assigned_attribute_instance_filters)+ attr_data = attr_data.first()++ # Return the instance's attribute values if the assignment was found,+ # otherwise it sets the values as an empty QuerySet+ values = attr_data.values.all() if attr_data is not None else empty_qs+ resolved_attributes.append(+ SelectedAttribute(attribute=attr_data_rel.attribute, values=values))- return attributes_list+ return resolved_attributesclass ProductOrder(graphene.InputObjectType):@@ -283,15 +306,11 @@ class ProductVariant(CountableDjangoObjectType, MetadataObjectType):return root.quantity_available@staticmethod- @gql_optimizer.resolver_hints("product__product_type__variant_attributes__values")+ @gql_optimizer.resolver_hints(+ prefetch_related=["attributes__values", "attributes__assignment__attribute"]+ )def resolve_attributes(root: models.ProductVariant, info):- attr_qs = (- root.product.product_type.variant_attributes.prefetch_related("values")- .get_visible_to_user(info.context.user)- .variant_attributes_sorted()- )- attr_qs = gql_optimizer.query(attr_qs, info)- return resolve_attribute_list(root.attributes, attr_qs)+ return resolve_attribute_list(root, user=info.context.user)@staticmethod@permission_required("product.manage_products")@@ -542,16 +561,13 @@ class Product(CountableDjangoObjectType, MetadataObjectType):@staticmethod@gql_optimizer.resolver_hints(- prefetch_related="product_type__product_attributes__values"+ prefetch_related=[+ "product_type__attributeproduct__productassignments__values",+ "product_type__attributeproduct__attribute",+ ])def resolve_attributes(root: models.Product, info):- attr_qs = (- root.product_type.product_attributes.prefetch_related("values")- .get_visible_to_user(info.context.user)- .product_attributes_sorted()- )- attr_qs = gql_optimizer.query(attr_qs, info)- return resolve_attribute_list(root.attributes, attr_qs)+ return resolve_attribute_list(root, user=info.context.user)@staticmethod@permission_required("product.manage_products")diff --git a/saleor/graphql/product/utils.py b/saleor/graphql/product/utils.pyindex 302ccaeffb..fd1275021c 100644--- a/saleor/graphql/product/utils.py+++ b/saleor/graphql/product/utils.py@@ -1,110 +1,32 @@-from collections import defaultdict-from typing import Dict, List+from typing import List-import graphene-from django.utils.text import slugify+from django.core.exceptions import ValidationErrorfrom ...product import AttributeInputType, models-from .interfaces import ResolvedAttributeInput-attribute_input_type = List[ResolvedAttributeInput]-attribute_map_type = Dict[str, models.Attribute]--def validate_attribute_input(instance: models.Attribute, values: List[str]):+def validate_attribute_input_for_product(instance: models.Attribute, values: List[str]):if not values:if not instance.value_required:return- raise ValueError(f"{instance.slug} expects a value but none were given")+ raise ValidationError(f"{instance.slug} expects a value but none were given")if instance.input_type != AttributeInputType.MULTISELECT and len(values) != 1:- raise ValueError(f"A {instance.input_type} attribute must take only one value")---def _resolve_attributes_input(- attribute_input: List[dict],- attributes_map_by_slug: attribute_map_type,- attributes_map_by_id: attribute_map_type,-) -> attribute_input_type:- """Resolve a raw GraphQL input to proper attribute.-- Its job is to ensure a backward compatibility with passing attributes by slug.- """-- resolved_input = [] # type: List[ResolvedAttributeInput]-- for attribute_input in attribute_input:- if "slug" in attribute_input:- attribute = attributes_map_by_slug.get(attribute_input["slug"])- elif "id" in attribute_input:- type_, attribute_id = graphene.Node.from_global_id(attribute_input["id"])- if type_ != "Attribute":- raise ValueError(f"Couldn't resolve to a node: {attribute_input['id']}")- attribute = attributes_map_by_id.get(attribute_id)- else:- raise ValueError("The value ID or slug was not provided")-- if not attribute:- raise ValueError(- "The given attribute doesn't belong to given product type."- )-- values = attribute_input.get("values")- validate_attribute_input(attribute, values)-- resolved_input.append(ResolvedAttributeInput(instance=attribute, values=values))-- return resolved_input+ raise ValidationError(+ f"A {instance.input_type} attribute must take only one value"+ )+ for value in values:+ if not value.strip():+ raise ValidationError("Attribute values cannot be blank")-def attributes_to_json(- raw_input: List[dict], attributes_queryset-) -> Dict[str, List[str]]:- """Transform attributes to the HStore representation.- Attributes configuration per product is stored in a HStore field as- a dict of IDs. This function transforms the list of `AttributeValueInput`- objects to this format.- """-- attributes_json = defaultdict(list)- passed_slugs = set()-- attributes_map_by_slug = {} # type: attribute_map_type- attributes_map_by_id = {} # type: attribute_map_type-- for attr in attributes_queryset:- attributes_map_by_slug[attr.slug] = attr- attributes_map_by_id[str(attr.id)] = attr-- resolved_input = _resolve_attributes_input(- raw_input, attributes_map_by_slug, attributes_map_by_id- )-- values_map = {}- for attr in attributes_queryset:- for value in attr.values.all():- values_map[value.slug] = value.id-- for item in resolved_input:- passed_slugs.add(item.instance.slug)-- for value in item.values:- value_id = values_map.get(value)-- if value_id is None:- # `value_id` was not found; create a new AttributeValue- # instance from the provided `value`.- obj = item.instance.values.get_or_create(- name=value, slug=slugify(value)- )[0]- value_id = obj.pk-- attributes_json[str(item.instance.pk)].append(str(value_id))+def validate_attribute_input_for_variant(instance: models.Attribute, values: List[str]):+ if not values:+ raise ValidationError(f"{instance.slug} expects a value but none were given")- # Check that all required attributes were passed- for missing_slug in attributes_map_by_slug.keys() ^ passed_slugs:- attribute = attributes_map_by_slug[missing_slug] # type: models.Attribute- validate_attribute_input(attribute, [])+ if len(values) != 1:+ raise ValidationError(f"A variant attribute cannot take more than one value")- return attributes_json+ if not values[0].strip():+ raise ValidationError("Attribute values cannot be blank")diff --git a/saleor/page/migrations/0008_raw_html_to_json.py b/saleor/page/migrations/0008_raw_html_to_json.pyindex 90b9708337..dec71f1ece 100644--- a/saleor/page/migrations/0008_raw_html_to_json.py+++ b/saleor/page/migrations/0008_raw_html_to_json.py@@ -3,7 +3,7 @@ from django.db import migrationsfrom draftjs_sanitizer import clean_draft_jsfrom html_to_draftjs import html_to_draftjs-from ...core.fields import SanitizedJSONField+from ...core.db.fields import SanitizedJSONFieldfrom ...core.utils.draftjs import json_content_to_raw_textdiff --git a/saleor/page/models.py b/saleor/page/models.pyindex 29f26ff845..a8e7da8ded 100644--- a/saleor/page/models.py+++ b/saleor/page/models.py@@ -5,7 +5,7 @@ from django.utils.html import strip_tagsfrom django.utils.translation import pgettext_lazyfrom draftjs_sanitizer import clean_draft_js-from ..core.fields import SanitizedJSONField+from ..core.db.fields import SanitizedJSONFieldfrom ..core.models import PublishableModel, PublishedQuerySetfrom ..core.utils import build_absolute_urifrom ..core.utils.draftjs import json_content_to_raw_textdiff --git a/saleor/product/filters.py b/saleor/product/filters.pyindex 6280343113..1f904291d0 100644--- a/saleor/product/filters.py+++ b/saleor/product/filters.py@@ -1,7 +1,10 @@-from collections import OrderedDict+import functools+import operator+from collections import OrderedDict, defaultdictfrom itertools import chain+from typing import Dict, Iterable-from django.db.models import Q+from django.db.models import Q, QuerySetfrom django.forms import CheckboxSelectMultiplefrom django.utils.translation import pgettext_lazyfrom django_filters import MultipleChoiceFilter, OrderingFilter, RangeFilter@@ -21,13 +24,29 @@ SORT_BY_FIELDS = OrderedDict()-class JSONBArrayFilter(MultipleChoiceFilter):- def get_filter_predicate(self, v):- operator = f"{self.field_name}__has_key"- try:- return {operator: getattr(v, self.field.to_field_name)}- except (AttributeError, TypeError):- return {operator: v}+T_PRODUCT_FILTER_QUERIES = Dict[int, Iterable[int]]+++def filter_products_by_attributes_values(qs, queries: T_PRODUCT_FILTER_QUERIES):+ # Combine filters of the same attribute with OR operator+ # and then combine full query with AND operator.+ combine_and = [+ Q(**{"attributes__values__pk__in": values_pk})+ | Q(**{"variants__attributes__values__pk__in": values_pk})+ for _, values_pk in queries.items()+ ]+ query = functools.reduce(operator.and_, combine_and)+ qs = qs.filter(query).distinct()+ return qs+++class AttributeValuesFilter(MultipleChoiceFilter):+ """A filter that is only there for rendering the attribute fields.++ The attributes will then be filtered in ``ProductFilter#filter_queryset``.++ This is a temporary work-around for: https://github.com/django/django/pull/8119+ """class ProductFilter(SortedFilterSet):@@ -50,8 +69,7 @@ class ProductFilter(SortedFilterSet):attributes = self._get_attributes()filters = {}for attribute in attributes:- filters[attribute.slug] = JSONBArrayFilter(- field_name=f"attributes__from_key_{attribute.pk}",+ filters[attribute.slug] = AttributeValuesFilter(label=attribute.translated.name,widget=CheckboxSelectMultiple,choices=self._get_attribute_choices(attribute),@@ -91,6 +109,38 @@ class ProductFilter(SortedFilterSet):(choice.pk, choice.translated.name) for choice in attribute.values.all()]+ def filter_queryset(self, queryset):+ """Temporary workaround for filtering products by their attributes values.++ Refer to https://code.djangoproject.com/ticket/25367.++ Filter the queryset with the underlying form's `cleaned_data`. You must+ call `is_valid()` or `errors` before calling this method.++ This method should be overridden if additional filtering needs to be+ applied to the queryset before it is cached.+ """++ attribute_values = defaultdict(set)+ for name, value in self.form.cleaned_data.items():+ filter_field = self.filters[name]+ if isinstance(filter_field, AttributeValuesFilter):+ value = {int(pk) for pk in value}+ if value:+ attribute_values[name].update(value)+ continue++ # Imported from django_filters.filterset.BaseFilterSet#filter_queryset.+ queryset = filter_field.filter(queryset, value)+ assert isinstance(queryset, QuerySet), (+ "Expected '%s.%s' to return a QuerySet, but got a %s instead."+ % (type(self).__name__, name, type(queryset).__name__)+ )++ if attribute_values:+ queryset = filter_products_by_attributes_values(queryset, attribute_values)+ return queryset+class ProductCategoryFilter(ProductFilter):def __init__(self, *args, **kwargs):diff --git a/saleor/product/migrations/0059_generate_variant_name_from_attrs.py b/saleor/product/migrations/0059_generate_variant_name_from_attrs.pyindex 2f1a061089..1e26473c93 100644--- a/saleor/product/migrations/0059_generate_variant_name_from_attrs.py+++ b/saleor/product/migrations/0059_generate_variant_name_from_attrs.py@@ -1,7 +1,31 @@# Generated by Django 2.0.2 on 2018-03-11 18:54+from collections import defaultdict+from typing import List+from django.db import migrations-from saleor.product.utils.attributes import get_attributes_display_map++def get_attributes_display_map(obj, attributes):+ """Return attributes associated with an object, as dict of AttrPK: AttributeValue.++ Args:+ obj: The variant or product.+ attributes: Attribute Iterable++ """+ display_map = defaultdict(str)+ for attribute in attributes:+ attribute_values = obj.attributes.get(str(attribute.pk)) # type: List+ if attribute_values:+ choices = {str(a.pk): a.translated for a in attribute.values.all()}+ for value in attribute_values:+ current_display_value = display_map[attribute.pk]+ if not current_display_value:+ current_display_value = choices[value]+ else:+ current_display_value = f"{current_display_value}, {choices[value]}"+ display_map[attribute.pk] = current_display_value+ return display_mapdef get_name_from_attributes(variant):diff --git a/saleor/product/migrations/0096_raw_html_to_json.py b/saleor/product/migrations/0096_raw_html_to_json.pyindex 1a8225ae62..350673778d 100644--- a/saleor/product/migrations/0096_raw_html_to_json.py+++ b/saleor/product/migrations/0096_raw_html_to_json.py@@ -3,7 +3,7 @@ from django.db import migrationsfrom draftjs_sanitizer import clean_draft_jsfrom html_to_draftjs import html_to_draftjs-from ...core.fields import SanitizedJSONField+from ...core.db.fields import SanitizedJSONFieldfrom ...core.utils.draftjs import json_content_to_raw_textdiff --git a/saleor/product/migrations/0103_schema_data_enterprise_grade_attributes.py b/saleor/product/migrations/0103_schema_data_enterprise_grade_attributes.pyindex 5ba2e09eff..71394a00dd 100644--- a/saleor/product/migrations/0103_schema_data_enterprise_grade_attributes.py+++ b/saleor/product/migrations/0103_schema_data_enterprise_grade_attributes.py@@ -1,7 +1,28 @@+from django.contrib.postgres.fields import jsonb+from django.core import exceptionsfrom django.db import migrations, models-from saleor.core.fields import FilterableJSONBField-from saleor.product.models import validate_attribute_json++def validate_attribute_json(value):+ for k, values in value.items():+ if not isinstance(k, str):+ raise exceptions.ValidationError(+ f"The key {k!r} should be of type str (got {type(k)})",+ params={"k": k, "values": values},+ )+ if not isinstance(values, list):+ raise exceptions.ValidationError(+ f"The values of {k!r} should be of type list (got {type(values)})",+ params={"k": k, "values": values},+ )++ for value_pk in values:+ if not isinstance(value_pk, str):+ raise exceptions.ValidationError(+ f"The values inside {value_pk!r} should be of type str "+ f"(got {type(value_pk)})",+ params={"k": k, "values": values, "value_pk": value_pk},+ )def migrate_fk_to_m2m(product_type_related_field):@@ -41,14 +62,14 @@ ATTRIBUTE_NEW_FIELDS = [migrations.AlterField(model_name="product",name="attributes",- field=FilterableJSONBField(+ field=jsonb.JSONField(blank=True, default=dict, validators=[validate_attribute_json]),),migrations.AlterField(model_name="productvariant",name="attributes",- field=FilterableJSONBField(+ field=jsonb.JSONField(blank=True, default=dict, validators=[validate_attribute_json]),),diff --git a/saleor/product/migrations/0107_attributes_map_to_m2m.py b/saleor/product/migrations/0107_attributes_map_to_m2m.pynew file mode 100644index 0000000000..31bb424a60--- /dev/null+++ b/saleor/product/migrations/0107_attributes_map_to_m2m.py@@ -0,0 +1,192 @@+# Generated by Django 2.2.4 on 2019-08-19 12:02+from django.db import migrations, models+++def migrate_product_attribute_map_to_m2m(apps, schema):+ """Migrate the JSONB attribute map to a M2M relation."""+ Product = apps.get_model("product", "Product")+ AssignedProductAttribute = apps.get_model("product", "AssignedProductAttribute")+ product_qs = Product.objects.prefetch_related(+ "product_type__attributeproduct__attribute__values"+ )++ for product in product_qs:+ attribute_map = product.old_attributes++ # Skip if no attribute is assigned to this product+ if not attribute_map:+ continue++ product_type = product.product_type++ for attribute_pk, values_pk in attribute_map.items():+ attribute_rel = product_type.attributeproduct.filter(+ attribute_id=attribute_pk+ ).first()++ # Skip the assigned attribute if it is not assigned to the product type+ if attribute_rel is None:+ continue++ values = list(attribute_rel.attribute.values.filter(pk__in=values_pk))++ # If no values are associated, skip+ if not values:+ continue++ assignment = AssignedProductAttribute.objects.create(+ product=product, assignment=attribute_rel+ )+ assignment.values.set(values)+++def migrate_variant_attribute_map_to_m2m(apps, schema):+ """Migrate the JSONB attribute map to a M2M relation."""+ ProductVariant = apps.get_model("product", "ProductVariant")+ AssignedVariantAttribute = apps.get_model("product", "AssignedVariantAttribute")+ variants_qs = ProductVariant.objects.prefetch_related(+ "product__product_type__attributevariant__attribute__values"+ )++ for variant in variants_qs:+ attribute_map = variant.old_attributes++ # Skip if no attribute is assigned to this variant+ if not attribute_map:+ continue++ product_type = variant.product.product_type++ for attribute_pk, values_pk in attribute_map.items():+ attribute_rel = product_type.attributevariant.filter(+ attribute_id=attribute_pk+ ).first()++ # Skip the assigned attribute if it is not assigned to the product type+ if attribute_rel is None:+ continue++ values = list(attribute_rel.attribute.values.filter(pk__in=values_pk))++ # If no values are associated, skip+ if not values:+ continue++ assignment = AssignedVariantAttribute.objects.create(+ variant=variant, assignment=attribute_rel+ )+ assignment.values.set(values)+++class Migration(migrations.Migration):++ dependencies = [("product", "0106_django_prices_2")]++ operations = [+ # Temporary renaming of the attribute map to migrate the data+ migrations.RenameField(+ model_name="product", old_name="attributes", new_name="old_attributes"+ ),+ migrations.RenameField(+ model_name="productvariant",+ old_name="attributes",+ new_name="old_attributes",+ ),+ # Add the new attribute relation instead of the JSONB mapping+ migrations.CreateModel(+ name="AssignedProductAttribute",+ fields=[+ (+ "id",+ models.AutoField(+ auto_created=True,+ primary_key=True,+ serialize=False,+ verbose_name="ID",+ ),+ ),+ ("values", models.ManyToManyField(to="product.AttributeValue")),+ (+ "product",+ models.ForeignKey(+ on_delete=models.deletion.CASCADE,+ related_name="attributes",+ to="product.Product",+ ),+ ),+ (+ "assignment",+ models.ForeignKey(+ on_delete=models.deletion.CASCADE,+ related_name="productassignments",+ to="product.AttributeProduct",+ ),+ ),+ ],+ options={"unique_together": {("product", "assignment")}},+ ),+ migrations.CreateModel(+ name="AssignedVariantAttribute",+ fields=[+ (+ "id",+ models.AutoField(+ auto_created=True,+ primary_key=True,+ serialize=False,+ verbose_name="ID",+ ),+ ),+ ("values", models.ManyToManyField(to="product.AttributeValue")),+ (+ "variant",+ models.ForeignKey(+ on_delete=models.deletion.CASCADE,+ related_name="attributes",+ to="product.ProductVariant",+ ),+ ),+ (+ "assignment",+ models.ForeignKey(+ on_delete=models.deletion.CASCADE,+ related_name="variantassignments",+ to="product.AttributeVariant",+ ),+ ),+ ],+ options={"unique_together": {("variant", "assignment")}},+ ),+ migrations.AddField(+ model_name="attributeproduct",+ name="assigned_products",+ field=models.ManyToManyField(+ blank=True,+ through="product.AssignedProductAttribute",+ to="product.Product",+ related_name="attributesrelated",+ ),+ ),+ migrations.AddField(+ model_name="attributevariant",+ name="assigned_variants",+ field=models.ManyToManyField(+ blank=True,+ through="product.AssignedVariantAttribute",+ to="product.ProductVariant",+ related_name="attributesrelated",+ ),+ ),+ migrations.AlterModelOptions(+ name="attributeproduct", options={"ordering": ("sort_order",)}+ ),+ migrations.AlterModelOptions(+ name="attributevariant", options={"ordering": ("sort_order",)}+ ),+ # Migrate the JSONB mapping to M2M+ migrations.RunPython(migrate_product_attribute_map_to_m2m),+ migrations.RunPython(migrate_variant_attribute_map_to_m2m),+ # Remove the JSONB mapping+ migrations.RemoveField(model_name="product", name="old_attributes"),+ migrations.RemoveField(model_name="productvariant", name="old_attributes"),+ ]diff --git a/saleor/product/models.py b/saleor/product/models.pyindex da349c2757..7a7bed9e87 100644--- a/saleor/product/models.py+++ b/saleor/product/models.py@@ -4,7 +4,6 @@ from uuid import uuid4from django.conf import settingsfrom django.contrib.postgres.fields import JSONField-from django.core import exceptionsfrom django.core.validators import MinValueValidatorfrom django.db import modelsfrom django.db.models import F, Q@@ -24,8 +23,8 @@ from prices import MoneyRangefrom text_unidecode import unidecodefrom versatileimagefield.fields import PPOIField, VersatileImageField+from ..core.db.fields import SanitizedJSONFieldfrom ..core.exceptions import InsufficientStock-from ..core.fields import FilterableJSONBField, SanitizedJSONFieldfrom ..core.models import (ModelWithMetadata,PublishableModel,@@ -42,28 +41,6 @@ from ..seo.models import SeoModel, SeoModelTranslationfrom . import AttributeInputType-def validate_attribute_json(value):- for k, values in value.items():- if not isinstance(k, str):- raise exceptions.ValidationError(- f"The key {k!r} should be of type str (got {type(k)})",- params={"k": k, "values": values},- )- if not isinstance(values, list):- raise exceptions.ValidationError(- f"The values of {k!r} should be of type list (got {type(values)})",- params={"k": k, "values": values},- )-- for value_pk in values:- if not isinstance(value_pk, str):- raise exceptions.ValidationError(- f"The values inside {value_pk!r} should be of type str "- f"(got {type(value_pk)})",- params={"k": k, "values": values, "value_pk": value_pk},- )--class Category(MPTTModel, ModelWithMetadata, SeoModel):name = models.CharField(max_length=128)slug = models.SlugField(max_length=128)@@ -212,10 +189,6 @@ class Product(SeoModel, ModelWithMetadata, PublishableModel):minimal_variant_price = MoneyField(amount_field="minimal_variant_price_amount", currency_field="currency")-- attributes = FilterableJSONBField(- default=dict, blank=True, validators=[validate_attribute_json]- )updated_at = models.DateTimeField(auto_now=True, null=True)charge_taxes = models.BooleanField(default=True)weight = MeasurementField(@@ -374,9 +347,6 @@ class ProductVariant(ModelWithMetadata):product = models.ForeignKey(Product, related_name="variants", on_delete=models.CASCADE)- attributes = FilterableJSONBField(- default=dict, blank=True, validators=[validate_attribute_json]- )images = models.ManyToManyField("ProductImage", through="VariantImage")track_inventory = models.BooleanField(default=True)quantity = models.IntegerField(@@ -548,6 +518,68 @@ class DigitalContentUrl(models.Model):return build_absolute_uri(url)+class BaseAttributeQuerySet(models.QuerySet):+ @staticmethod+ def user_has_access_to_all(user):+ return user.is_active and user.has_perm("product.manage_products")++ def get_public_attributes(self):+ raise NotImplementedError++ def get_visible_to_user(self, user):+ if self.user_has_access_to_all(user):+ return self.all()+ return self.get_public_attributes()+++class AssignedProductAttribute(models.Model):+ """Associate a product type attribute and selected values to a given product."""++ product = models.ForeignKey(+ Product, related_name="attributes", on_delete=models.CASCADE+ )+ assignment = models.ForeignKey(+ "AttributeProduct", on_delete=models.CASCADE, related_name="productassignments"+ )+ values = models.ManyToManyField("AttributeValue")++ class Meta:+ unique_together = (("product", "assignment"),)++ @property+ def attribute(self):+ """Return the attribute assigned to this relation."""+ return self.assignment.attribute+++class AssignedVariantAttribute(models.Model):+ """Associate a product type attribute and selected values to a given variant."""++ variant = models.ForeignKey(+ ProductVariant, related_name="attributes", on_delete=models.CASCADE+ )+ assignment = models.ForeignKey(+ "AttributeVariant", on_delete=models.CASCADE, related_name="variantassignments"+ )+ values = models.ManyToManyField("AttributeValue")++ class Meta:+ unique_together = (("variant", "assignment"),)++ @property+ def attribute(self):+ return self.assignment.attribute++ @property+ def attribute_pk(self):+ return self.assignment.attribute_id+++class AssociatedAttributeQuerySet(BaseAttributeQuerySet):+ def get_public_attributes(self):+ return self.filter(attribute__visible_in_storefront=True)++class AttributeProduct(SortableModel):attribute = models.ForeignKey("Attribute", related_name="attributeproduct", on_delete=models.CASCADE@@ -555,9 +587,19 @@ class AttributeProduct(SortableModel):product_type = models.ForeignKey(ProductType, related_name="attributeproduct", on_delete=models.CASCADE)+ assigned_products = models.ManyToManyField(+ Product,+ blank=True,+ through=AssignedProductAttribute,+ through_fields=["assignment", "product"],+ related_name="attributesrelated",+ )++ objects = AssociatedAttributeQuerySet.as_manager()class Meta:unique_together = (("attribute", "product_type"),)+ ordering = ("sort_order",)def get_ordering_queryset(self):return self.product_type.attributeproduct.all()@@ -570,15 +612,25 @@ class AttributeVariant(SortableModel):product_type = models.ForeignKey(ProductType, related_name="attributevariant", on_delete=models.CASCADE)+ assigned_variants = models.ManyToManyField(+ ProductVariant,+ blank=True,+ through=AssignedVariantAttribute,+ through_fields=["assignment", "variant"],+ related_name="attributesrelated",+ )++ objects = AssociatedAttributeQuerySet.as_manager()class Meta:unique_together = (("attribute", "product_type"),)+ ordering = ("sort_order",)def get_ordering_queryset(self):return self.product_type.attributevariant.all()-class AttributeQuerySet(models.QuerySet):+class AttributeQuerySet(BaseAttributeQuerySet):def get_unassigned_attributes(self, product_type_pk: int):return self.exclude(Q(attributeproduct__product_type_id=product_type_pk)@@ -591,18 +643,9 @@ class AttributeQuerySet(models.QuerySet):| Q(attributevariant__product_type_id=product_type_pk))- @staticmethod- def user_has_access_to_all(user):- return user.is_active and user.has_perm("product.manage_products")-def get_public_attributes(self):return self.filter(visible_in_storefront=True)- def get_visible_to_user(self, user):- if self.user_has_access_to_all(user):- return self.all()- return self.get_public_attributes()-def _get_sorted_m2m_field(self, m2m_field_name: str, asc: bool):sort_order_field = F(f"{m2m_field_name}__sort_order")id_field = F(f"{m2m_field_name}__id")diff --git a/saleor/product/tasks.py b/saleor/product/tasks.pyindex 85a5f298d6..9ad2e7c35c 100644--- a/saleor/product/tasks.py+++ b/saleor/product/tasks.py@@ -1,7 +1,7 @@from ..celeryconf import appfrom ..discount.models import Salefrom .models import Attribute, Product, ProductType, ProductVariant-from .utils.attributes import get_name_from_attributes+from .utils.attributes import generate_name_for_variantfrom .utils.variant_prices import (update_product_minimal_variant_price,update_products_minimal_variant_prices,@@ -25,11 +25,10 @@ def _update_variants_names(instance, saved_attributes):product__product_type__variant_attributes__in=attributes_changed,)variants_to_be_updated = variants_to_be_updated.prefetch_related(- "product__product_type__variant_attributes__values"+ "attributes__values__translations").all()- attributes = instance.variant_attributes.prefetch_related("values__translations")for variant in variants_to_be_updated:- variant.name = get_name_from_attributes(variant, attributes)+ variant.name = generate_name_for_variant(variant)variant.save(update_fields=["name"])diff --git a/saleor/product/utils/__init__.py b/saleor/product/utils/__init__.pyindex 0385ac6c7c..314e54137c 100644--- a/saleor/product/utils/__init__.py+++ b/saleor/product/utils/__init__.py@@ -30,10 +30,13 @@ def products_with_details(user):"category__translations","collections__translations","images",- "variants__variant_images__image",- "attributes__values__translations","product_type__product_attributes__translations","product_type__product_attributes__values__translations",+ "attributes__values__translations",+ "attributes__assignment__attribute__translations",+ "variants__variant_images__image",+ "variants__attributes__values__translations",+ "variants__attributes__assignment__attribute__translations",)return productsdiff --git a/saleor/product/utils/attributes.py b/saleor/product/utils/attributes.pyindex 85af2c18b0..f6d2084be3 100644--- a/saleor/product/utils/attributes.py+++ b/saleor/product/utils/attributes.py@@ -1,70 +1,66 @@-from collections import defaultdict-from typing import List+from typing import Union+from ..models import (+ AssignedProductAttribute,+ AssignedVariantAttribute,+ Attribute,+ AttributeValue,+ Product,+ ProductVariant,+)-def get_product_attributes_data(product):- """Return the attributes associated with the product.+T_ASSIGNMENT_REL = Union[AssignedProductAttribute, AssignedVariantAttribute]- It is returned as a dict of Attribute: AttributeValue values.- """- attributes = product.product_type.product_attributes.exclude(- visible_in_storefront=False- ).product_attributes_sorted()-- attributes_map = {attribute.pk: attribute.translated for attribute in attributes}- values_map = get_attributes_display_map(product, attributes)- product_attributes = {}-- for attr_pk, value_obj in values_map.items():- key = attributes_map[attr_pk]- if not isinstance(value_obj, str):- value_obj = value_obj.translated- product_attributes[key] = value_obj- return product_attributes---def get_name_from_attributes(variant, attributes):+def generate_name_for_variant(variant: ProductVariant) -> str:"""Generate ProductVariant's name based on its attributes."""- values = get_attributes_display_map(variant, attributes)- return generate_name_from_values(values)+ attributes_display = []+ for attribute_rel in variant.attributes.all(): # type: AssignedVariantAttribute+ values_qs = attribute_rel.values.all() # FIXME: this should be sorted+ translated_values = [str(value.translated) for value in values_qs]+ attributes_display.append(", ".join(translated_values))-def get_attributes_display_map(obj, attributes):- """Return attributes associated with an object, as dict of AttrPK: AttributeValue.+ return " / ".join(attributes_display)- Args:- obj: The variant or product.- attributes: Attribute Iterable- """- display_map = defaultdict(str)- for attribute in attributes:- attribute_values = obj.attributes.get(str(attribute.pk)) # type: List- if attribute_values:- choices = {str(a.pk): a.translated for a in attribute.values.all()}- for value in attribute_values:- current_display_value = display_map[attribute.pk]- if not current_display_value:- current_display_value = choices[value]- else:- current_display_value = f"{current_display_value}, {choices[value]}"- display_map[attribute.pk] = current_display_value- return display_map+def _associate_attribute_to_instance(+ instance: Union[Product, ProductVariant], attribute_pk: Attribute+) -> T_ASSIGNMENT_REL:+ """Associate a given attribute to an instance."""+ if isinstance(instance, Product):+ attribute_rel = instance.product_type.attributeproduct.get(+ attribute_id=attribute_pk+ )++ assignment, _ = AssignedProductAttribute.objects.get_or_create(+ product=instance, assignment=attribute_rel+ )+ elif isinstance(instance, ProductVariant):+ attribute_rel = instance.product.product_type.attributevariant.get(+ attribute_id=attribute_pk+ )+ assignment, _ = AssignedVariantAttribute.objects.get_or_create(+ variant=instance, assignment=attribute_rel+ )+ else:+ raise AssertionError(f"{instance.__class__.__name__} is unsupported")-def generate_name_from_values(attributes_dict):- """Generate name from AttributeValues.+ return assignment- Attributes dict is sorted, as attributes order should be kept within each save.- Args:- attributes_dict: dict of attribute_pk: AttributeValue values+def associate_attribute_values_to_instance(+ instance: Union[Product, ProductVariant],+ attribute: Attribute,+ *values: AttributeValue,+) -> T_ASSIGNMENT_REL:+ """Assign given attribute values to a product or variant.+ Note: be award this function invokes the ``set`` method on the instance's+ attribute association. Meaning any values already assigned or concurrently+ assigned will be overridden by this call."""- return " / ".join(- str(attribute_value)- for attribute_pk, attribute_value in sorted(- attributes_dict.items(), key=lambda x: x[0]- )- )+ assignment = _associate_attribute_to_instance(instance, attribute.pk)+ assignment.values.set(values)+ return assignmentdiff --git a/saleor/product/utils/variants_picker.py b/saleor/product/utils/variants_picker.pyindex 5d273d2bf0..ecff672717 100644--- a/saleor/product/utils/variants_picker.py+++ b/saleor/product/utils/variants_picker.py@@ -1,7 +1,8 @@from collections import defaultdictfrom decimal import Decimal-from typing import Dict, Iterable, List+from typing import Dict, Iterable+from django.db.models import Count, Qfrom django_prices.templatetags import pricesfrom ...core.taxes import display_gross_prices@@ -9,26 +10,31 @@ from ...core.utils import to_local_currencyfrom ...discount import DiscountInfofrom ...extensions.manager import get_extensions_managerfrom ...seo.schema.product import variant_json_ld+from ..models import AssignedVariantAttribute, ProductVariantfrom .availability import get_product_availability-def _attributes_to_single(attributes: Dict[str, List[str]]) -> Dict[str, str]:- """Convert nested attributes to a flat attribute ({attr_pk: val_pk}).+def _attributes_to_map(instance: ProductVariant) -> Dict[str, str]:+ """Convert a variant's attributes to a flat attribute dict ({attr_pk: val_pk}).This is used for backward compatibility between the storefront 1.0and dashboard 2.0's new attribute mechanism."""- new_attributes = {}+ attribute_map = {}- for attr_pk, values in attributes.items():- if len(values) != 1:- # Skip multiple values - which should have been denied by the dashboard- continue+ # Skip multiple values - which should have been denied by the dashboard+ # FIXME: make sure Count(...) is hitting the prefetch+ attributes_qs = instance.attributes.annotate(Count("values")).exclude(+ ~Q(values__count=1)+ )- new_attributes[attr_pk] = values[0]+ for attribute_rel in attributes_qs: # type: AssignedVariantAttribute+ value = attribute_rel.values.first()+ attribute_pk = attribute_rel.attribute_pk+ attribute_map[str(attribute_pk)] = str(value.pk)- return new_attributes+ return attribute_mapdef get_variant_picker_data(@@ -66,22 +72,20 @@ def get_variant_picker_data(price_local_currency = Nonein_stock = variant.is_in_stock()schema_data = variant_json_ld(price.net, variant, in_stock)+ attributes_map = _attributes_to_map(variant)variant_data = {"id": variant.id,"availability": in_stock,"price": price_as_dict(price),"priceUndiscounted": price_as_dict(price_undiscounted),- "attributes": _attributes_to_single(variant.attributes),+ "attributes": attributes_map,"priceLocalCurrency": price_as_dict(price_local_currency),"schemaData": schema_data,}data["variants"].append(variant_data)- for variant_key, variant_values in variant.attributes.items():- if len(variant_values) != 1:- # Skip multiple values - which should have been denied by the dashboard- continue- filter_available_variants[int(variant_key)].append(variant_values[0])+ for variant_key, variant_value in attributes_map.items():+ filter_available_variants[int(variant_key)].append(variant_value)for attribute in variant_attributes:available_variants = filter_available_variants.get(attribute.pk, None)diff --git a/saleor/product/views.py b/saleor/product/views.pyindex 9cf61a9469..5d8c0464d8 100644--- a/saleor/product/views.py+++ b/saleor/product/views.py@@ -29,7 +29,6 @@ from .utils import (products_for_products_list,products_with_details,)-from .utils.attributes import get_product_attributes_datafrom .utils.availability import get_product_availabilityfrom .utils.digital_products import (digital_content_url_is_valid,@@ -91,10 +90,9 @@ def product_details(request, slug, product_id, form=None):request.currency,request.country,)- product_attributes = get_product_attributes_data(product)# show_variant_picker determines if variant picker is used or select inputshow_variant_picker = all([v.attributes for v in product.variants.all()])- json_ld_data = product_json_ld(product, product_attributes)+ json_ld_data = product_json_ld(product)ctx = {"description_json": product.translated.description_json,"description_html": product.translated.description,@@ -102,7 +100,6 @@ def product_details(request, slug, product_id, form=None):"form": form,"availability": availability,"product": product,- "product_attributes": product_attributes,"product_images": product_images,"show_variant_picker": show_variant_picker,"variant_picker_data": json.dumps(diff --git a/saleor/seo/schema/product.py b/saleor/seo/schema/product.pyindex 06235209ca..ca8e9cd4ed 100644--- a/saleor/seo/schema/product.py+++ b/saleor/seo/schema/product.py@@ -1,24 +1,27 @@+from typing import Optional++from django.db.models import Q, QuerySetfrom django.utils.encoding import smart_text+from ...product.models import Product+IN_STOCK = "http://schema.org/InStock"OUT_OF_STOCK = "http://schema.org/OutOfStock"-def get_brand_from_attributes(attributes):- if attributes is None:- return- brand = ""- for key in attributes:- if key.name == "brand":- brand = attributes[key].name- break- elif key.name == "publisher":- brand = attributes[key].name- return brand+BRAND_SLUGS = ["brand", "publisher"]+++def get_brand_from_attributes(attributes: QuerySet) -> Optional[str]:+ qs_filter_conditions = Q(assignment__attribute__slug__in=BRAND_SLUGS)+ qs = attributes.filter(qs_filter_conditions).prefetch_related("values")+ attribute = qs.first()+ if attribute is not None:+ return ", ".join([str(value) for value in attribute.values.all()])+ return None-def product_json_ld(product, attributes=None):- # type: (saleor.product.models.Product, saleor.product.utils.ProductAvailability, dict) -> dict # noqa+def product_json_ld(product: Product):"""Generate JSON-LD data for product."""data = {"@context": "http://schema.org/",@@ -37,7 +40,7 @@ def product_json_ld(product, attributes=None):variant_data = variant_json_ld(price, variant, in_stock)data["offers"].append(variant_data)- brand = get_brand_from_attributes(attributes)+ brand = get_brand_from_attributes(product.attributes)if brand:data["brand"] = {"@type": "Thing", "name": brand}return datadiff --git a/saleor/static/populatedb_data.json b/saleor/static/populatedb_data.jsonindex 17a85e0656..764cdcfd6b 100644--- a/saleor/static/populatedb_data.json+++ b/saleor/static/populatedb_data.json@@ -3,6 +3,8 @@"model": "product.category","pk": 7,"fields": {+ "private_meta": {},+ "meta": {},"seo_title": "","seo_description": "","name": "Accessories",@@ -23,7 +25,7 @@"entityMap": {}},"parent": null,- "background_image": "category-backgrounds/accessories.jpg",+ "background_image": "category-backgrounds/accessories_yoPWyIR.jpg","background_image_alt": "","lft": 1,"rght": 2,@@ -35,6 +37,8 @@"model": "product.category","pk": 8,"fields": {+ "private_meta": {},+ "meta": {},"seo_title": "","seo_description": "","name": "Groceries",@@ -55,7 +59,7 @@"entityMap": {}},"parent": null,- "background_image": "category-backgrounds/groceries_HagDCol.jpg",+ "background_image": "category-backgrounds/groceries_Sh4JKDD.jpg","background_image_alt": "","lft": 1,"rght": 2,@@ -67,6 +71,8 @@"model": "product.category","pk": 9,"fields": {+ "private_meta": {},+ "meta": {},"seo_title": "","seo_description": "","name": "Apparel",@@ -87,7 +93,7 @@"entityMap": {}},"parent": null,- "background_image": "category-backgrounds/apparel.jpg",+ "background_image": "category-backgrounds/apparel_K34bGKL.jpg","background_image_alt": "","lft": 1,"rght": 2,@@ -99,10 +105,19 @@"model": "product.producttype","pk": 7,"fields": {+ "private_meta": {},+ "meta": {+ "taxes": {+ "vatlayer": {+ "code": "standard",+ "description": ""+ }+ }+ },"name": "Paint","has_variants": true,"is_shipping_required": true,- "meta": {"taxes":{"vatlayer": {"code": "standard", "description": ""}}},+ "is_digital": false,"weight": "1.0 kg"}},@@ -110,10 +125,19 @@"model": "product.producttype","pk": 8,"fields": {+ "private_meta": {},+ "meta": {+ "taxes": {+ "vatlayer": {+ "code": "standard",+ "description": ""+ }+ }+ },"name": "Music","has_variants": true,"is_shipping_required": true,- "meta": {"taxes":{"vatlayer": {"code": "standard", "description": ""}}},+ "is_digital": false,"weight": "0.2 kg"}},@@ -121,10 +145,19 @@"model": "product.producttype","pk": 9,"fields": {+ "private_meta": {},+ "meta": {+ "taxes": {+ "vatlayer": {+ "code": "standard",+ "description": ""+ }+ }+ },"name": "Juice","has_variants": true,"is_shipping_required": true,- "meta": {"taxes":{"vatlayer": {"code": "standard", "description": ""}}},+ "is_digital": false,"weight": "1.0 kg"}},@@ -132,10 +165,19 @@"model": "product.producttype","pk": 10,"fields": {+ "private_meta": {},+ "meta": {+ "taxes": {+ "vatlayer": {+ "code": "standard",+ "description": ""+ }+ }+ },"name": "Wine","has_variants": false,"is_shipping_required": true,- "meta": {"taxes":{"vatlayer": {"code": "standard", "description": ""}}},+ "is_digital": false,"weight": "1.0 kg"}},@@ -143,10 +185,19 @@"model": "product.producttype","pk": 11,"fields": {+ "private_meta": {},+ "meta": {+ "taxes": {+ "vatlayer": {+ "code": "standard",+ "description": ""+ }+ }+ },"name": "Beer","has_variants": false,"is_shipping_required": true,- "meta": {"taxes":{"vatlayer": {"code": "standard", "description": ""}}},+ "is_digital": false,"weight": "1.0 kg"}},@@ -154,10 +205,19 @@"model": "product.producttype","pk": 12,"fields": {+ "private_meta": {},+ "meta": {+ "taxes": {+ "vatlayer": {+ "code": "standard",+ "description": ""+ }+ }+ },"name": "Cushion","has_variants": true,"is_shipping_required": true,- "meta": {"taxes":{"vatlayer": {"code": "standard", "description": ""}}},+ "is_digital": false,"weight": "0.5 kg"}},@@ -165,10 +225,19 @@"model": "product.producttype","pk": 13,"fields": {+ "private_meta": {},+ "meta": {+ "taxes": {+ "vatlayer": {+ "code": "standard",+ "description": ""+ }+ }+ },"name": "Shoe","has_variants": true,"is_shipping_required": true,- "meta": {"taxes":{"vatlayer": {"code": "standard", "description": ""}}},+ "is_digital": false,"weight": "1.0 kg"}},@@ -176,10 +245,19 @@"model": "product.producttype","pk": 14,"fields": {+ "private_meta": {},+ "meta": {+ "taxes": {+ "vatlayer": {+ "code": "standard",+ "description": ""+ }+ }+ },"name": "Top (clothing)","has_variants": true,"is_shipping_required": true,- "meta": {"taxes":{"vatlayer": {"code": "standard", "description": ""}}},+ "is_digital": false,"weight": "1.0 kg"}},@@ -189,6 +267,15 @@"fields": {"publication_date": null,"is_published": true,+ "private_meta": {},+ "meta": {+ "taxes": {+ "vatlayer": {+ "code": "standard",+ "description": ""+ }+ }+ },"seo_title": "","seo_description": "Tonight, my love, let us take fat brushes and paint the skies with the shades of nebula tides. Get the dark, moody shades of the ether.","product_type": 7,@@ -209,12 +296,11 @@"entityMap": {}},"category": 7,- "price_amount": "15.00","currency": "USD",- "attributes": "{}",- "updated_at": "2019-03-06T12:47:35.666Z",+ "price_amount": "15.00",+ "minimal_variant_price_amount": "15.00",+ "updated_at": "2019-08-27T10:54:00.076Z","charge_taxes": true,- "meta": {"taxes":{"vatlayer": {"code": "standard", "description": ""}}},"weight": "0.0 kg"}},@@ -224,6 +310,15 @@"fields": {"publication_date": null,"is_published": true,+ "private_meta": {},+ "meta": {+ "taxes": {+ "vatlayer": {+ "code": "standard",+ "description": ""+ }+ }+ },"seo_title": "","seo_description": "The rich, deep hue of space dust. Vacuum packed and airlocked for long-lasting freshness of color.","product_type": 7,@@ -244,12 +339,11 @@"entityMap": {}},"category": 7,- "price_amount": "15.00","currency": "USD",- "attributes": "{}",- "updated_at": "2019-03-06T12:47:35.878Z",+ "price_amount": "15.00",+ "minimal_variant_price_amount": "15.00",+ "updated_at": "2019-08-27T10:54:00.305Z","charge_taxes": true,- "meta": {"taxes":{"vatlayer": {"code": "standard", "description": ""}}},"weight": "1.0 kg"}},@@ -259,17 +353,26 @@"fields": {"publication_date": null,"is_published": true,+ "private_meta": {},+ "meta": {+ "taxes": {+ "vatlayer": {+ "code": "standard",+ "description": ""+ }+ }+ },"seo_title": "","seo_description": "","product_type": 7,"name": "Red Dwarf Red Paint",- "description": "We are all connected to the universe, because every cell in our bodies was cooked in the hearts of dying stars. Red Dwarf Paint: the color of Carl Sagan\u2019s dreams.",+ "description": "We are all connected to the universe, because every cell in our bodies was cooked in the hearts of dying stars. Red Dwarf Paint: the color of Carl Sagan’s dreams.","description_json": {"blocks": [{"key": "","data": {},- "text": "We are all connected to the universe, because every cell in our bodies was cooked in the hearts of dying stars. Red Dwarf Paint: the color of Carl Sagan\u2019s dreams.",+ "text": "We are all connected to the universe, because every cell in our bodies was cooked in the hearts of dying stars. Red Dwarf Paint: the color of Carl Sagan’s dreams.","type": "unstyled","depth": 0,"entityRanges": [],@@ -279,12 +382,11 @@"entityMap": {}},"category": 7,- "price_amount": "15.00","currency": "USD",- "attributes": "{}",- "updated_at": "2019-03-06T12:47:36.096Z",+ "price_amount": "15.00",+ "minimal_variant_price_amount": "15.00",+ "updated_at": "2019-08-27T10:54:00.536Z","charge_taxes": true,- "meta": {"taxes":{"vatlayer": {"code": "standard", "description": ""}}},"weight": "0.0 kg"}},@@ -294,6 +396,15 @@"fields": {"publication_date": null,"is_published": true,+ "private_meta": {},+ "meta": {+ "taxes": {+ "vatlayer": {+ "code": "standard",+ "description": ""+ }+ }+ },"seo_title": "","seo_description": "There is life in outer space. This vibrant light speed yellow paint brings life to any surface. Goes on easy and dries at light speed.","product_type": 7,@@ -314,12 +425,11 @@"entityMap": {}},"category": 7,- "price_amount": "15.00","currency": "USD",- "attributes": "{}",- "updated_at": "2019-03-06T12:47:36.309Z",+ "price_amount": "15.00",+ "minimal_variant_price_amount": "15.00",+ "updated_at": "2019-08-27T10:54:00.753Z","charge_taxes": true,- "meta": {"taxes":{"vatlayer": {"code": "standard", "description": ""}}},"weight": "0.0 kg"}},@@ -329,6 +439,15 @@"fields": {"publication_date": null,"is_published": true,+ "private_meta": {},+ "meta": {+ "taxes": {+ "vatlayer": {+ "code": "standard",+ "description": ""+ }+ }+ },"seo_title": "","seo_description": "Turquoise is the new black. No more gloomy night skies, brighten up your evenings with hyperspace paint.","product_type": 7,@@ -349,12 +468,11 @@"entityMap": {}},"category": 7,- "price_amount": "15.00","currency": "USD",- "attributes": "{}",- "updated_at": "2019-03-06T12:47:36.514Z",+ "price_amount": "15.00",+ "minimal_variant_price_amount": "15.00",+ "updated_at": "2019-08-27T10:54:00.961Z","charge_taxes": true,- "meta": {"taxes":{"vatlayer": {"code": "standard", "description": ""}}},"weight": "1.0 kg"}},@@ -364,6 +482,15 @@"fields": {"publication_date": null,"is_published": true,+ "private_meta": {},+ "meta": {+ "taxes": {+ "vatlayer": {+ "code": "standard",+ "description": ""+ }+ }+ },"seo_title": "","seo_description": "Fell from a tree straight into the bottle. No additives, no preservatives, just the refreshing taste of pure sun-kissed Californian oranges.","product_type": 9,@@ -384,12 +511,11 @@"entityMap": {}},"category": 8,- "price_amount": "3.00","currency": "USD",- "attributes": "{\"16\": [\"49\"]}",- "updated_at": "2019-03-06T12:47:36.727Z",+ "price_amount": "3.00",+ "minimal_variant_price_amount": "3.00",+ "updated_at": "2019-08-27T10:54:01.181Z","charge_taxes": true,- "meta": {"taxes":{"vatlayer": {"code": "standard", "description": ""}}},"weight": "1.0 kg"}},@@ -399,17 +525,26 @@"fields": {"publication_date": null,"is_published": true,+ "private_meta": {},+ "meta": {+ "taxes": {+ "vatlayer": {+ "code": "standard",+ "description": ""+ }+ }+ },"seo_title": "",- "seo_description": "Fell straight from the tree, on to Newton\u2019s head, then into the bottle. The autumn taste of English apples. Brought to you by gravity.",+ "seo_description": "Fell straight from the tree, on to Newton’s head, then into the bottle. The autumn taste of English apples. Brought to you by gravity.","product_type": 9,"name": "Apple Juice",- "description": "Fell straight from the tree, on to Newton\u2019s head, then into the bottle. The autumn taste of English apples. Brought to you by gravity.",+ "description": "Fell straight from the tree, on to Newton’s head, then into the bottle. The autumn taste of English apples. Brought to you by gravity.","description_json": {"blocks": [{"key": "","data": {},- "text": "Fell straight from the tree, on to Newton\u2019s head, then into the bottle. The autumn taste of English apples. Brought to you by gravity.",+ "text": "Fell straight from the tree, on to Newton’s head, then into the bottle. The autumn taste of English apples. Brought to you by gravity.","type": "unstyled","depth": 0,"entityRanges": [],@@ -419,12 +554,11 @@"entityMap": {}},"category": 8,- "price_amount": "3.00","currency": "USD",- "attributes": "{\"16\": [\"3\"]}",- "updated_at": "2019-03-06T12:47:36.885Z",+ "price_amount": "3.00",+ "minimal_variant_price_amount": "3.00",+ "updated_at": "2019-08-27T10:54:01.340Z","charge_taxes": true,- "meta": {"taxes":{"vatlayer": {"code": "standard", "description": ""}}},"weight": "1.0 kg"}},@@ -434,6 +568,15 @@"fields": {"publication_date": null,"is_published": true,+ "private_meta": {},+ "meta": {+ "taxes": {+ "vatlayer": {+ "code": "standard",+ "description": ""+ }+ }+ },"seo_title": "","seo_description": "Improve your eyesight the natural way with 100% pure, squeezed carrot juice. The sweet, orange nectar of Mother Earth.","product_type": 9,@@ -454,12 +597,11 @@"entityMap": {}},"category": 8,- "price_amount": "3.00","currency": "USD",- "attributes": "{\"16\": [\"52\"]}",- "updated_at": "2019-03-06T12:47:37.040Z",+ "price_amount": "3.00",+ "minimal_variant_price_amount": "3.00",+ "updated_at": "2019-08-27T10:54:01.498Z","charge_taxes": true,- "meta": {"taxes":{"vatlayer": {"code": "standard", "description": ""}}},"weight": "1.0 kg"}},@@ -469,6 +611,15 @@"fields": {"publication_date": null,"is_published": true,+ "private_meta": {},+ "meta": {+ "taxes": {+ "vatlayer": {+ "code": "standard",+ "description": ""+ }+ }+ },"seo_title": "","seo_description": "Build your protein the natural way, with exotic banana juice made from ripe fruit and packed with all the goodness of the tropical sun.","product_type": 9,@@ -489,12 +640,11 @@"entityMap": {}},"category": 8,- "price_amount": "3.00","currency": "USD",- "attributes": "{\"16\": [\"50\"]}",- "updated_at": "2019-03-06T12:47:37.201Z",+ "price_amount": "3.00",+ "minimal_variant_price_amount": "3.00",+ "updated_at": "2019-08-27T10:54:01.659Z","charge_taxes": true,- "meta": {"taxes":{"vatlayer": {"code": "standard", "description": ""}}},"weight": "1.0 kg"}},@@ -504,17 +654,26 @@"fields": {"publication_date": null,"is_published": true,+ "private_meta": {},+ "meta": {+ "taxes": {+ "vatlayer": {+ "code": "standard",+ "description": ""+ }+ }+ },"seo_title": "",- "seo_description": "I can\u2019t stand pineapples, so this one is not for me. They have a weird, fluffy, tangy taste. But if it is your kind of thing, then knock yourself out.",+ "seo_description": "I can’t stand pineapples, so this one is not for me. They have a weird, fluffy, tangy taste. But if it is your kind of thing, then knock yourself out.","product_type": 9,"name": "Pineapple Juice",- "description": "I can\u2019t stand pineapples, so this one is not for me. They have a weird, fluffy, tangy taste. But if it is your kind of thing, then knock yourself out.",+ "description": "I can’t stand pineapples, so this one is not for me. They have a weird, fluffy, tangy taste. But if it is your kind of thing, then knock yourself out.","description_json": {"blocks": [{"key": "","data": {},- "text": "I can\u2019t stand pineapples, so this one is not for me. They have a weird, fluffy, tangy taste. But if it is your kind of thing, then knock yourself out.",+ "text": "I can’t stand pineapples, so this one is not for me. They have a weird, fluffy, tangy taste. But if it is your kind of thing, then knock yourself out.","type": "unstyled","depth": 0,"entityRanges": [],@@ -524,12 +683,11 @@"entityMap": {}},"category": 8,- "price_amount": "3.00","currency": "USD",- "attributes": "{\"16\": [\"1\"]}",- "updated_at": "2019-03-06T12:47:37.363Z",+ "price_amount": "3.00",+ "minimal_variant_price_amount": "3.00",+ "updated_at": "2019-08-27T10:54:01.816Z","charge_taxes": true,- "meta": {"taxes":{"vatlayer": {"code": "standard", "description": ""}}},"weight": "1.0 kg"}},@@ -539,6 +697,15 @@"fields": {"publication_date": null,"is_published": true,+ "private_meta": {},+ "meta": {+ "taxes": {+ "vatlayer": {+ "code": "standard",+ "description": ""+ }+ }+ },"seo_title": "","seo_description": "Did you know falling coconuts kill 150 people a year? But did you know that coconut juice is the new superfood? You win some, you lose some.","product_type": 9,@@ -559,12 +726,11 @@"entityMap": {}},"category": 8,- "price_amount": "3.00","currency": "USD",- "attributes": "{\"16\": [\"2\"]}",- "updated_at": "2019-03-06T12:47:37.517Z",+ "price_amount": "3.00",+ "minimal_variant_price_amount": "3.00",+ "updated_at": "2019-08-27T10:54:01.975Z","charge_taxes": true,- "meta": {"taxes":{"vatlayer": {"code": "standard", "description": ""}}},"weight": "1.0 kg"}},@@ -574,17 +740,26 @@"fields": {"publication_date": null,"is_published": true,+ "private_meta": {},+ "meta": {+ "taxes": {+ "vatlayer": {+ "code": "standard",+ "description": ""+ }+ }+ },"seo_title": "",- "seo_description": "Is it a bird? Is it a plane? No! It\u2019s some jacked dude who just sucked down a bottle of our brand new power juice! Look at him go!",+ "seo_description": "Is it a bird? Is it a plane? No! It’s some jacked dude who just sucked down a bottle of our brand new power juice! Look at him go!","product_type": 9,"name": "Power Juice",- "description": "Is it a bird? Is a plane? No! It\u2019s some jacked dude who just sucked down a bottle of our brand new power juice! Look at him go!",+ "description": "Is it a bird? Is a plane? No! It’s some jacked dude who just sucked down a bottle of our brand new power juice! Look at him go!","description_json": {"blocks": [{"key": "","data": {},- "text": "Is it a bird? Is a plane? No! It\u2019s some jacked dude who just sucked down a bottle of our brand new power juice! Look at him go!",+ "text": "Is it a bird? Is a plane? No! It’s some jacked dude who just sucked down a bottle of our brand new power juice! Look at him go!","type": "unstyled","depth": 0,"entityRanges": [],@@ -594,12 +769,11 @@"entityMap": {}},"category": 8,- "price_amount": "3.00","currency": "USD",- "attributes": "{\"16\": [\"54\"]}",- "updated_at": "2019-03-06T12:47:37.679Z",+ "price_amount": "3.00",+ "minimal_variant_price_amount": "3.00",+ "updated_at": "2019-08-27T10:54:02.125Z","charge_taxes": true,- "meta": {"taxes":{"vatlayer": {"code": "standard", "description": ""}}},"weight": "1.0 kg"}},@@ -609,17 +783,26 @@"fields": {"publication_date": null,"is_published": true,+ "private_meta": {},+ "meta": {+ "taxes": {+ "vatlayer": {+ "code": "standard",+ "description": ""+ }+ }+ },"seo_title": "",- "seo_description": "Brussel sprouts, spinach, peas, kale, lettuce, cabbage, zucchini, more brussel sprouts. All the greens you\u2019ll ever need in one delicious juice.",+ "seo_description": "Brussel sprouts, spinach, peas, kale, lettuce, cabbage, zucchini, more brussel sprouts. All the greens you’ll ever need in one delicious juice.","product_type": 9,"name": "Green Juice",- "description": "Brussel sprouts, spinach, peas, kale, lettuce, cabbage, zucchini, more brussel sprouts. All the greens you\u2019ll ever need in one delicious juice.",+ "description": "Brussel sprouts, spinach, peas, kale, lettuce, cabbage, zucchini, more brussel sprouts. All the greens you’ll ever need in one delicious juice.","description_json": {"blocks": [{"key": "","data": {},- "text": "Brussel sprouts, spinach, peas, kale, lettuce, cabbage, zucchini, more brussel sprouts. All the greens you\u2019ll ever need in one delicious juice.",+ "text": "Brussel sprouts, spinach, peas, kale, lettuce, cabbage, zucchini, more brussel sprouts. All the greens you’ll ever need in one delicious juice.","type": "unstyled","depth": 0,"entityRanges": [],@@ -629,12 +812,11 @@"entityMap": {}},"category": 8,- "price_amount": "3.00","currency": "USD",- "attributes": "{\"16\": [\"53\"]}",- "updated_at": "2019-03-06T12:47:37.844Z",+ "price_amount": "3.00",+ "minimal_variant_price_amount": "3.00",+ "updated_at": "2019-08-27T10:54:02.280Z","charge_taxes": true,- "meta": {"taxes":{"vatlayer": {"code": "standard", "description": ""}}},"weight": "1.0 kg"}},@@ -644,6 +826,15 @@"fields": {"publication_date": null,"is_published": true,+ "private_meta": {},+ "meta": {+ "taxes": {+ "vatlayer": {+ "code": "standard",+ "description": ""+ }+ }+ },"seo_title": "","seo_description": "Bean there, drunk that! The energy drink for the health-conscious. Brand new bean juice; from allotment to bottle in under 8 hours.","product_type": 9,@@ -664,12 +855,11 @@"entityMap": {}},"category": 8,- "price_amount": "3.00","currency": "USD",- "attributes": "{\"16\": [\"51\"]}",- "updated_at": "2019-03-06T12:47:38.007Z",+ "price_amount": "3.00",+ "minimal_variant_price_amount": "3.00",+ "updated_at": "2019-08-27T10:54:02.436Z","charge_taxes": true,- "meta": {"taxes":{"vatlayer": {"code": "standard", "description": ""}}},"weight": "1.0 kg"}},@@ -679,6 +869,15 @@"fields": {"publication_date": null,"is_published": true,+ "private_meta": {},+ "meta": {+ "taxes": {+ "vatlayer": {+ "code": "",+ "description": ""+ }+ }+ },"seo_title": "","seo_description": "A fine, mature red with a hint of blackberry, an undertone of the alkaline Burgundy soil, a delicate aftertaste of burnt garlic, and a whole lot of grapes.","product_type": 10,@@ -699,12 +898,11 @@"entityMap": {}},"category": 8,- "price_amount": "15.00","currency": "USD",- "attributes": "{\"20\": [\"67\"]}",- "updated_at": "2019-03-06T12:47:38.171Z",+ "price_amount": "15.00",+ "minimal_variant_price_amount": "15.00",+ "updated_at": "2019-08-27T10:54:02.601Z","charge_taxes": true,- "meta": {"taxes":{"vatlayer": {"code": "", "description": ""}}},"weight": "0.0 kg"}},@@ -714,6 +912,15 @@"fields": {"publication_date": null,"is_published": true,+ "private_meta": {},+ "meta": {+ "taxes": {+ "vatlayer": {+ "code": "",+ "description": ""+ }+ }+ },"seo_title": "","seo_description": "Watch the slow setting sun of a wild summer evening sink into the horizon as you sip white wine that tastes like bittersweet memories of halcyon days.","product_type": 10,@@ -734,12 +941,11 @@"entityMap": {}},"category": 8,- "price_amount": "15.00","currency": "USD",- "attributes": "{\"20\": [\"67\"]}",- "updated_at": "2019-03-06T12:47:38.362Z",+ "price_amount": "15.00",+ "minimal_variant_price_amount": "15.00",+ "updated_at": "2019-08-27T10:54:02.803Z","charge_taxes": true,- "meta": {"taxes":{"vatlayer": {"code": "", "description": ""}}},"weight": "0.0 kg"}},@@ -749,17 +955,26 @@"fields": {"publication_date": null,"is_published": true,+ "private_meta": {},+ "meta": {+ "taxes": {+ "vatlayer": {+ "code": "standard",+ "description": ""+ }+ }+ },"seo_title": "",- "seo_description": "Find your sea legs and then lose the power to use them with extra strong seaman\u2019s lager. Don\u2019t drink and sail, me hearties!",+ "seo_description": "Find your sea legs and then lose the power to use them with extra strong seaman’s lager. Don’t drink and sail, me hearties!","product_type": 11,"name": "Seaman Lager",- "description": "Find your sea legs and then lose the power to use them with extra strong seaman\u2019s lager. Don\u2019t drink and sail, me hearties!",+ "description": "Find your sea legs and then lose the power to use them with extra strong seaman’s lager. Don’t drink and sail, me hearties!","description_json": {"blocks": [{"key": "","data": {},- "text": "Find your sea legs and then lose the power to use them with extra strong seaman\u2019s lager. Don\u2019t drink and sail, me hearties!",+ "text": "Find your sea legs and then lose the power to use them with extra strong seaman’s lager. Don’t drink and sail, me hearties!","type": "unstyled","depth": 0,"entityRanges": [],@@ -769,12 +984,11 @@"entityMap": {}},"category": 8,- "price_amount": "3.00","currency": "USD",- "attributes": "{\"15\": [\"46\"], \"21\": [\"68\"]}",- "updated_at": "2019-03-06T12:47:38.530Z",+ "price_amount": "3.00",+ "minimal_variant_price_amount": "3.00",+ "updated_at": "2019-08-27T10:54:02.971Z","charge_taxes": true,- "meta": {"taxes":{"vatlayer": {"code": "standard", "description": ""}}},"weight": "1.0 kg"}},@@ -784,6 +998,15 @@"fields": {"publication_date": null,"is_published": true,+ "private_meta": {},+ "meta": {+ "taxes": {+ "vatlayer": {+ "code": "standard",+ "description": ""+ }+ }+ },"seo_title": "","seo_description": "Best beer on the seven seas. A dark ale for when the dark clouds gather overhead. The nutty nautical taste that sailors love.","product_type": 11,@@ -804,12 +1027,11 @@"entityMap": {}},"category": 8,- "price_amount": "3.20","currency": "USD",- "attributes": "{\"15\": [\"46\"], \"21\": [\"69\"]}",- "updated_at": "2019-03-06T12:47:38.875Z",+ "price_amount": "3.20",+ "minimal_variant_price_amount": "3.20",+ "updated_at": "2019-08-27T10:54:03.300Z","charge_taxes": true,- "meta": {"taxes":{"vatlayer": {"code": "standard", "description": ""}}},"weight": "1.0 kg"}},@@ -819,6 +1041,15 @@"fields": {"publication_date": null,"is_published": true,+ "private_meta": {},+ "meta": {+ "taxes": {+ "vatlayer": {+ "code": "standard",+ "description": ""+ }+ }+ },"seo_title": "","seo_description": "Add a little color to your life with a Saleor parrot cushion. Turns any old sofa into a rainbow of classy interior design.","product_type": 12,@@ -839,12 +1070,11 @@"entityMap": {}},"category": 7,- "price_amount": "20.00","currency": "USD",- "attributes": "{\"23\": [\"72\"]}",- "updated_at": "2019-03-06T12:47:39.256Z",+ "price_amount": "20.00",+ "minimal_variant_price_amount": "20.00",+ "updated_at": "2019-08-27T10:54:03.637Z","charge_taxes": true,- "meta": {"taxes":{"vatlayer": {"code": "standard", "description": ""}}},"weight": "0.0 kg"}},@@ -854,17 +1084,26 @@"fields": {"publication_date": null,"is_published": true,+ "private_meta": {},+ "meta": {+ "taxes": {+ "vatlayer": {+ "code": "standard",+ "description": ""+ }+ }+ },"seo_title": "",- "seo_description": "Minimalist interiors need simple, sleek soft furnishings. Don\u2019t parrot what others do, set your own monochrome trends with Saleor designs.",+ "seo_description": "Minimalist interiors need simple, sleek soft furnishings. Don’t parrot what others do, set your own monochrome trends with Saleor designs.","product_type": 12,"name": "White Parrot Cushion",- "description": "Minimalist interiors need simple, sleek soft furnishings. Don\u2019t parrot what others do, set your own monochrome trends with Saleor designs.",+ "description": "Minimalist interiors need simple, sleek soft furnishings. Don’t parrot what others do, set your own monochrome trends with Saleor designs.","description_json": {"blocks": [{"key": "","data": {},- "text": "Minimalist interiors need simple, sleek soft furnishings. Don\u2019t parrot what others do, set your own monochrome trends with Saleor designs.",+ "text": "Minimalist interiors need simple, sleek soft furnishings. Don’t parrot what others do, set your own monochrome trends with Saleor designs.","type": "unstyled","depth": 0,"entityRanges": [],@@ -874,12 +1113,11 @@"entityMap": {}},"category": 7,- "price_amount": "20.00","currency": "USD",- "attributes": "{\"23\": [\"72\"]}",- "updated_at": "2019-03-06T12:47:39.501Z",+ "price_amount": "20.00",+ "minimal_variant_price_amount": "20.00",+ "updated_at": "2019-08-27T10:54:03.894Z","charge_taxes": true,- "meta": {"taxes":{"vatlayer": {"code": "standard", "description": ""}}},"weight": "0.0 kg"}},@@ -889,6 +1127,15 @@"fields": {"publication_date": null,"is_published": true,+ "private_meta": {},+ "meta": {+ "taxes": {+ "vatlayer": {+ "code": "standard",+ "description": ""+ }+ }+ },"seo_title": "","seo_description": "Mellow yellow. Step into summer with Saleor. Every time your head goes down, you see these beauties, and your mood bounces right back up.","product_type": 13,@@ -909,12 +1156,11 @@"entityMap": {}},"category": 9,- "price_amount": "59.00","currency": "USD",- "attributes": "{}",- "updated_at": "2019-03-06T12:47:39.769Z",+ "price_amount": "59.00",+ "minimal_variant_price_amount": "59.00",+ "updated_at": "2019-08-27T10:54:04.162Z","charge_taxes": true,- "meta": {"taxes":{"vatlayer": {"code": "standard", "description": ""}}},"weight": "0.0 kg"}},@@ -924,17 +1170,26 @@"fields": {"publication_date": null,"is_published": true,+ "private_meta": {},+ "meta": {+ "taxes": {+ "vatlayer": {+ "code": "standard",+ "description": ""+ }+ }+ },"seo_title": "",- "seo_description": "PE at school wouldn\u2019t have been such a drag with these on your feet. Slip on the style and stride tall with Saleor branded plimsolls. PE now stands for pretty elegant.",+ "seo_description": "PE at school wouldn’t have been such a drag with these on your feet. Slip on the style and stride tall with Saleor branded plimsolls. PE now stands for pretty elegant.","product_type": 13,"name": "White Plimsolls",- "description": "PE at school wouldn\u2019t have been such a drag with these on your feet. Slip on the style and stride tall with Saleor branded plimsolls. PE now stands for pretty elegant.",+ "description": "PE at school wouldn’t have been such a drag with these on your feet. Slip on the style and stride tall with Saleor branded plimsolls. PE now stands for pretty elegant.","description_json": {"blocks": [{"key": "","data": {},- "text": "PE at school wouldn\u2019t have been such a drag with these on your feet. Slip on the style and stride tall with Saleor branded plimsolls. PE now stands for pretty elegant.",+ "text": "PE at school wouldn’t have been such a drag with these on your feet. Slip on the style and stride tall with Saleor branded plimsolls. PE now stands for pretty elegant.","type": "unstyled","depth": 0,"entityRanges": [],@@ -944,12 +1199,11 @@"entityMap": {}},"category": 9,- "price_amount": "49.00","currency": "USD",- "attributes": "{}",- "updated_at": "2019-03-06T12:47:40.537Z",+ "price_amount": "49.00",+ "minimal_variant_price_amount": "49.00",+ "updated_at": "2019-08-27T10:54:04.885Z","charge_taxes": true,- "meta": {"taxes":{"vatlayer": {"code": "standard", "description": ""}}},"weight": "1.0 kg"}},@@ -959,6 +1213,15 @@"fields": {"publication_date": null,"is_published": true,+ "private_meta": {},+ "meta": {+ "taxes": {+ "vatlayer": {+ "code": "standard",+ "description": ""+ }+ }+ },"seo_title": "","seo_description": "Pay homage to the music and art of Joy Division and Peter Saville, but with a Mirumee twist. Perfect live transmission apparel for dead souls.","product_type": 14,@@ -979,12 +1242,11 @@"entityMap": {}},"category": 9,- "price_amount": "30.00","currency": "USD",- "attributes": "{\"25\": [\"82\"]}",- "updated_at": "2019-03-06T12:47:41.280Z",+ "price_amount": "30.00",+ "minimal_variant_price_amount": "30.00",+ "updated_at": "2019-08-27T10:54:05.671Z","charge_taxes": true,- "meta": {"taxes":{"vatlayer": {"code": "standard", "description": ""}}},"weight": "0.0 kg"}},@@ -994,6 +1256,15 @@"fields": {"publication_date": null,"is_published": true,+ "private_meta": {},+ "meta": {+ "taxes": {+ "vatlayer": {+ "code": "standard",+ "description": ""+ }+ }+ },"seo_title": "","seo_description": "Ever have those days where you feel a bit geometric? Can't quite shape yourself up right? Show your different sides with a Saleor styles.","product_type": 14,@@ -1014,12 +1285,11 @@"entityMap": {}},"category": 9,- "price_amount": "30.00","currency": "USD",- "attributes": "{\"25\": [\"82\"]}",- "updated_at": "2019-03-06T12:47:41.681Z",+ "price_amount": "30.00",+ "minimal_variant_price_amount": "30.00",+ "updated_at": "2019-08-27T10:54:06.047Z","charge_taxes": true,- "meta": {"taxes":{"vatlayer": {"code": "standard", "description": ""}}},"weight": "0.0 kg"}},@@ -1029,17 +1299,26 @@"fields": {"publication_date": null,"is_published": true,+ "private_meta": {},+ "meta": {+ "taxes": {+ "vatlayer": {+ "code": "standard",+ "description": ""+ }+ }+ },"seo_title": "",- "seo_description": "Polo? Yolo\u2026 so don\u2019t waste time on the wrong apparel. Choose a polo shirt that looks as good as you feel.",+ "seo_description": "Polo? Yolo… so don’t waste time on the wrong apparel. Choose a polo shirt that looks as good as you feel.","product_type": 14,"name": "Polo Shirt",- "description": "Polo? Yolo\u2026 so don\u2019t waste time on the wrong apparel. Choose a polo shirt that looks as good as you feel.",+ "description": "Polo? Yolo… so don’t waste time on the wrong apparel. Choose a polo shirt that looks as good as you feel.","description_json": {"blocks": [{"key": "","data": {},- "text": "Polo? Yolo\u2026 so don\u2019t waste time on the wrong apparel. Choose a polo shirt that looks as good as you feel.",+ "text": "Polo? Yolo… so don’t waste time on the wrong apparel. Choose a polo shirt that looks as good as you feel.","type": "unstyled","depth": 0,"entityRanges": [],@@ -1049,12 +1328,11 @@"entityMap": {}},"category": 9,- "price_amount": "30.00","currency": "USD",- "attributes": "{\"25\": [\"82\"]}",- "updated_at": "2019-03-06T12:47:41.972Z",+ "price_amount": "30.00",+ "minimal_variant_price_amount": "30.00",+ "updated_at": "2019-08-27T10:54:06.341Z","charge_taxes": true,- "meta": {"taxes":{"vatlayer": {"code": "standard", "description": ""}}},"weight": "0.0 kg"}},@@ -1064,6 +1342,15 @@"fields": {"publication_date": null,"is_published": true,+ "private_meta": {},+ "meta": {+ "taxes": {+ "vatlayer": {+ "code": "standard",+ "description": ""+ }+ }+ },"seo_title": "","seo_description": "Wondering if this will look as good on you as it does on the screen? The answer is yes. A quality polo with smart styling.","product_type": 14,@@ -1084,12 +1371,11 @@"entityMap": {}},"category": 9,- "price_amount": "30.00","currency": "USD",- "attributes": "{\"25\": [\"82\"]}",- "updated_at": "2019-03-06T12:47:42.283Z",+ "price_amount": "30.00",+ "minimal_variant_price_amount": "30.00",+ "updated_at": "2019-08-27T10:54:06.642Z","charge_taxes": true,- "meta": {"taxes":{"vatlayer": {"code": "standard", "description": ""}}},"weight": "0.0 kg"}},@@ -1099,6 +1385,15 @@"fields": {"publication_date": null,"is_published": true,+ "private_meta": {},+ "meta": {+ "taxes": {+ "vatlayer": {+ "code": "standard",+ "description": ""+ }+ }+ },"seo_title": "","seo_description": "They say polo is the sport of kings. Or was that stamp collecting? Either way, this shirt is fit for a king of Saturday night.","product_type": 14,@@ -1119,12 +1414,11 @@"entityMap": {}},"category": 9,- "price_amount": "30.00","currency": "USD",- "attributes": "{\"25\": [\"82\"]}",- "updated_at": "2019-03-06T12:47:42.524Z",+ "price_amount": "30.00",+ "minimal_variant_price_amount": "30.00",+ "updated_at": "2019-08-27T10:54:06.890Z","charge_taxes": true,- "meta": {"taxes":{"vatlayer": {"code": "standard", "description": ""}}},"weight": "0.0 kg"}},@@ -1134,6 +1428,15 @@"fields": {"publication_date": null,"is_published": true,+ "private_meta": {},+ "meta": {+ "taxes": {+ "vatlayer": {+ "code": "standard",+ "description": ""+ }+ }+ },"seo_title": "","seo_description": "One style fits all. Get a look that works even when you are taking it easy. Relaxed wear for the masses.","product_type": 14,@@ -1154,12 +1457,11 @@"entityMap": {}},"category": 9,- "price_amount": "30.00","currency": "USD",- "attributes": "{\"25\": [\"82\"]}",- "updated_at": "2019-03-06T12:47:42.771Z",+ "price_amount": "30.00",+ "minimal_variant_price_amount": "30.00",+ "updated_at": "2019-08-27T10:54:07.131Z","charge_taxes": true,- "meta": {"taxes":{"vatlayer": {"code": "standard", "description": ""}}},"weight": "0.0 kg"}},@@ -1169,6 +1471,15 @@"fields": {"publication_date": null,"is_published": true,+ "private_meta": {},+ "meta": {+ "taxes": {+ "vatlayer": {+ "code": "standard",+ "description": ""+ }+ }+ },"seo_title": "","seo_description": "A classic tee for a timeless look, at a great price. Feel like a million bucks without breaking the bank.","product_type": 14,@@ -1189,12 +1500,11 @@"entityMap": {}},"category": 9,- "price_amount": "30.00","currency": "USD",- "attributes": "{\"25\": [\"82\"]}",- "updated_at": "2019-03-06T12:47:43.640Z",+ "price_amount": "30.00",+ "minimal_variant_price_amount": "30.00",+ "updated_at": "2019-08-27T10:54:08.137Z","charge_taxes": true,- "meta": {"taxes":{"vatlayer": {"code": "standard", "description": ""}}},"weight": "0.0 kg"}},@@ -1204,6 +1514,15 @@"fields": {"publication_date": null,"is_published": true,+ "private_meta": {},+ "meta": {+ "taxes": {+ "vatlayer": {+ "code": "standard",+ "description": ""+ }+ }+ },"seo_title": "","seo_description": "Want to look like you just fell out of bed? Sometimes style can be effortless. Throw it on get on with having a good day.","product_type": 14,@@ -1224,12 +1543,11 @@"entityMap": {}},"category": 9,- "price_amount": "30.00","currency": "USD",- "attributes": "{\"25\": [\"82\"]}",- "updated_at": "2019-03-06T12:47:44.067Z",+ "price_amount": "30.00",+ "minimal_variant_price_amount": "30.00",+ "updated_at": "2019-08-27T10:54:08.586Z","charge_taxes": true,- "meta": {"taxes":{"vatlayer": {"code": "standard", "description": ""}}},"weight": "0.0 kg"}},@@ -1239,17 +1557,26 @@"fields": {"publication_date": null,"is_published": true,+ "private_meta": {},+ "meta": {+ "taxes": {+ "vatlayer": {+ "code": "standard",+ "description": ""+ }+ }+ },"seo_title": "",- "seo_description": "Your t-shirt is your second skin. It\u2019s the version of you that you show to the world. Wear one that flows with your movements and is built to last.",+ "seo_description": "Your t-shirt is your second skin. It’s the version of you that you show to the world. Wear one that flows with your movements and is built to last.","product_type": 14,"name": "T-shirt",- "description": "Your t-shirt is your second skin. It\u2019s the version of you that you show to the world. Wear one that flows with your movements and is built to last.",+ "description": "Your t-shirt is your second skin. It’s the version of you that you show to the world. Wear one that flows with your movements and is built to last.","description_json": {"blocks": [{"key": "","data": {},- "text": "Your t-shirt is your second skin. It\u2019s the version of you that you show to the world. Wear one that flows with your movements and is built to last.",+ "text": "Your t-shirt is your second skin. It’s the version of you that you show to the world. Wear one that flows with your movements and is built to last.","type": "unstyled","depth": 0,"entityRanges": [],@@ -1259,12 +1586,11 @@"entityMap": {}},"category": 9,- "price_amount": "30.00","currency": "USD",- "attributes": "{\"25\": [\"82\"]}",- "updated_at": "2019-03-06T12:47:44.582Z",+ "price_amount": "30.00",+ "minimal_variant_price_amount": "30.00",+ "updated_at": "2019-08-27T10:54:09.084Z","charge_taxes": true,- "meta": {"taxes":{"vatlayer": {"code": "standard", "description": ""}}},"weight": "0.0 kg"}},@@ -1274,6 +1600,15 @@"fields": {"publication_date": null,"is_published": true,+ "private_meta": {},+ "meta": {+ "taxes": {+ "vatlayer": {+ "code": "standard",+ "description": ""+ }+ }+ },"seo_title": "","seo_description": "Special offer. Buy a hood and get a free jet black sweater attached. Perfect for when you are up to no good.","product_type": 14,@@ -1294,12 +1629,11 @@"entityMap": {}},"category": 9,- "price_amount": "30.00","currency": "USD",- "attributes": "{\"25\": [\"82\"]}",- "updated_at": "2019-03-06T12:47:45.080Z",+ "price_amount": "30.00",+ "minimal_variant_price_amount": "30.00",+ "updated_at": "2019-08-27T10:54:09.586Z","charge_taxes": true,- "meta": {"taxes":{"vatlayer": {"code": "standard", "description": ""}}},"weight": "0.0 kg"}},@@ -1309,6 +1643,15 @@"fields": {"publication_date": null,"is_published": true,+ "private_meta": {},+ "meta": {+ "taxes": {+ "vatlayer": {+ "code": "standard",+ "description": ""+ }+ }+ },"seo_title": "","seo_description": "Special offer. Buy a superhero blue sweater and get a free hood attached. Ideal for when you are out saving the world.","product_type": 14,@@ -1329,12 +1672,11 @@"entityMap": {}},"category": 9,- "price_amount": "30.00","currency": "USD",- "attributes": "{\"25\": [\"82\"]}",- "updated_at": "2019-03-06T12:47:45.376Z",+ "price_amount": "30.00",+ "minimal_variant_price_amount": "30.00",+ "updated_at": "2019-08-27T10:54:09.871Z","charge_taxes": true,- "meta": {"taxes":{"vatlayer": {"code": "standard", "description": ""}}},"weight": "0.0 kg"}},@@ -1344,6 +1686,15 @@"fields": {"publication_date": null,"is_published": true,+ "private_meta": {},+ "meta": {+ "taxes": {+ "vatlayer": {+ "code": "standard",+ "description": ""+ }+ }+ },"seo_title": "","seo_description": "Who dunnit? It was Colonel Mustard, in the dining room, with the lead piping, wearing this hot as mustard hoodie.","product_type": 14,@@ -1364,12 +1715,11 @@"entityMap": {}},"category": 9,- "price_amount": "30.00","currency": "USD",- "attributes": "{\"25\": [\"82\"]}",- "updated_at": "2019-03-06T12:47:45.669Z",+ "price_amount": "30.00",+ "minimal_variant_price_amount": "30.00",+ "updated_at": "2019-08-27T10:54:10.164Z","charge_taxes": true,- "meta": {"taxes":{"vatlayer": {"code": "standard", "description": ""}}},"weight": "0.0 kg"}},@@ -1379,17 +1729,26 @@"fields": {"publication_date": null,"is_published": true,+ "private_meta": {},+ "meta": {+ "taxes": {+ "vatlayer": {+ "code": "standard",+ "description": ""+ }+ }+ },"seo_title": "",- "seo_description": "Get your slouch on and be seen with a whiter than white hoodie straight from the streets. Relaxed stylin\u2019 and profilin\u2019 with flair.",+ "seo_description": "Get your slouch on and be seen with a whiter than white hoodie straight from the streets. Relaxed stylin’ and profilin’ with flair.","product_type": 14,"name": "White Hoodie",- "description": "Get your slouch on and be seen with a whiter than white hoodie straight from the streets. Relaxed stylin\u2019 and profilin\u2019 with flair.",+ "description": "Get your slouch on and be seen with a whiter than white hoodie straight from the streets. Relaxed stylin’ and profilin’ with flair.","description_json": {"blocks": [{"key": "","data": {},- "text": "Get your slouch on and be seen with a whiter than white hoodie straight from the streets. Relaxed stylin\u2019 and profilin\u2019 with flair.",+ "text": "Get your slouch on and be seen with a whiter than white hoodie straight from the streets. Relaxed stylin’ and profilin’ with flair.","type": "unstyled","depth": 0,"entityRanges": [],@@ -1399,12 +1758,11 @@"entityMap": {}},"category": 9,- "price_amount": "30.00","currency": "USD",- "attributes": "{\"25\": [\"82\"]}",- "updated_at": "2019-03-06T12:47:45.937Z",+ "price_amount": "30.00",+ "minimal_variant_price_amount": "30.00",+ "updated_at": "2019-08-27T10:54:10.463Z","charge_taxes": true,- "meta": {"taxes":{"vatlayer": {"code": "standard", "description": ""}}},"weight": "0.0 kg"}},@@ -1412,16 +1770,17 @@"model": "product.productvariant","pk": 171,"fields": {+ "private_meta": {},+ "meta": {},"sku": "546451996","name": "1l",+ "currency": "USD","price_override_amount": "15.00","product": 61,- "attributes": "{\"18\": [\"60\"]}","track_inventory": true,- "quantity": 113,- "quantity_allocated": 14,+ "quantity": 114,+ "quantity_allocated": 15,"cost_price_amount": "5.00",- "currency": "USD","weight": "1.0 kg"}},@@ -1429,16 +1788,17 @@"model": "product.productvariant","pk": 172,"fields": {+ "private_meta": {},+ "meta": {},"sku": "546451997","name": "2.5l",+ "currency": "USD","price_override_amount": "35.00","product": 61,- "attributes": "{\"18\": [\"61\"]}","track_inventory": true,"quantity": 21,"quantity_allocated": 2,"cost_price_amount": "10.00",- "currency": "USD","weight": "2.5 kg"}},@@ -1446,16 +1806,17 @@"model": "product.productvariant","pk": 173,"fields": {+ "private_meta": {},+ "meta": {},"sku": "546451999","name": "5l",+ "currency": "USD","price_override_amount": "49.00","product": 61,- "attributes": "{\"18\": [\"62\"]}","track_inventory": true,"quantity": 11,"quantity_allocated": 11,"cost_price_amount": "20.00",- "currency": "USD","weight": "5.0 kg"}},@@ -1463,16 +1824,17 @@"model": "product.productvariant","pk": 174,"fields": {+ "private_meta": {},+ "meta": {},"sku": "998223591","name": "1l",+ "currency": "USD","price_override_amount": "15.00","product": 62,- "attributes": "{\"18\": [\"60\"]}","track_inventory": true,"quantity": 43,"quantity_allocated": 19,"cost_price_amount": "5.00",- "currency": "USD","weight": "1.0 kg"}},@@ -1480,16 +1842,17 @@"model": "product.productvariant","pk": 175,"fields": {+ "private_meta": {},+ "meta": {},"sku": "998223599","name": "2.5l",+ "currency": "USD","price_override_amount": "25.00","product": 62,- "attributes": "{\"18\": [\"61\"]}","track_inventory": true,"quantity": 110,"quantity_allocated": 0,"cost_price_amount": "10.00",- "currency": "USD","weight": "0.0 kg"}},@@ -1497,16 +1860,17 @@"model": "product.productvariant","pk": 176,"fields": {+ "private_meta": {},+ "meta": {},"sku": "998223594","name": "5l",+ "currency": "USD","price_override_amount": "49.00","product": 62,- "attributes": "{\"18\": [\"62\"]}","track_inventory": true,"quantity": 125,"quantity_allocated": 14,"cost_price_amount": "25.00",- "currency": "USD","weight": "0.0 kg"}},@@ -1514,16 +1878,17 @@"model": "product.productvariant","pk": 177,"fields": {+ "private_meta": {},+ "meta": {},"sku": "998223582","name": "1l",+ "currency": "USD","price_override_amount": "15.00","product": 63,- "attributes": "{\"18\": [\"60\"]}","track_inventory": true,"quantity": 1235,"quantity_allocated": 4,"cost_price_amount": "5.00",- "currency": "USD","weight": "1.0 kg"}},@@ -1531,16 +1896,17 @@"model": "product.productvariant","pk": 178,"fields": {+ "private_meta": {},+ "meta": {},"sku": "998223583","name": "2.5l",+ "currency": "USD","price_override_amount": "25.00","product": 63,- "attributes": "{\"18\": [\"61\"]}","track_inventory": true,"quantity": 1222,"quantity_allocated": 11,"cost_price_amount": "10.00",- "currency": "USD","weight": "2.5 kg"}},@@ -1548,16 +1914,17 @@"model": "product.productvariant","pk": 179,"fields": {+ "private_meta": {},+ "meta": {},"sku": "998223584","name": "5l",+ "currency": "USD","price_override_amount": "49.00","product": 63,- "attributes": "{\"18\": [\"62\"]}","track_inventory": true,"quantity": 472,"quantity_allocated": 27,"cost_price_amount": "20.00",- "currency": "USD","weight": "5.0 kg"}},@@ -1565,16 +1932,17 @@"model": "product.productvariant","pk": 180,"fields": {+ "private_meta": {},+ "meta": {},"sku": "998323582","name": "1l",+ "currency": "USD","price_override_amount": "15.00","product": 64,- "attributes": "{\"18\": [\"60\"]}","track_inventory": true,- "quantity": 991,- "quantity_allocated": 5,+ "quantity": 994,+ "quantity_allocated": 8,"cost_price_amount": "5.00",- "currency": "USD","weight": "1.0 kg"}},@@ -1582,16 +1950,17 @@"model": "product.productvariant","pk": 181,"fields": {+ "private_meta": {},+ "meta": {},"sku": "998323583","name": "2.5l",+ "currency": "USD","price_override_amount": "30.00","product": 64,- "attributes": "{\"18\": [\"61\"]}","track_inventory": true,"quantity": 760,"quantity_allocated": 9,"cost_price_amount": "10.00",- "currency": "USD","weight": "2.5 kg"}},@@ -1599,16 +1968,17 @@"model": "product.productvariant","pk": 182,"fields": {+ "private_meta": {},+ "meta": {},"sku": "998323584","name": "5l",+ "currency": "USD","price_override_amount": "49.00","product": 64,- "attributes": "{\"18\": [\"62\"]}","track_inventory": true,- "quantity": 578,- "quantity_allocated": 7,+ "quantity": 583,+ "quantity_allocated": 12,"cost_price_amount": "15.00",- "currency": "USD","weight": "5.0 kg"}},@@ -1616,16 +1986,17 @@"model": "product.productvariant","pk": 183,"fields": {+ "private_meta": {},+ "meta": {},"sku": "998423582","name": "1l",+ "currency": "USD","price_override_amount": "15.00","product": 65,- "attributes": "{\"18\": [\"60\"]}","track_inventory": true,"quantity": 427,"quantity_allocated": 16,"cost_price_amount": "5.00",- "currency": "USD","weight": "1.0 kg"}},@@ -1633,16 +2004,17 @@"model": "product.productvariant","pk": 184,"fields": {+ "private_meta": {},+ "meta": {},"sku": "998423583","name": "2.5l",+ "currency": "USD","price_override_amount": "30.00","product": 65,- "attributes": "{\"18\": [\"61\"]}","track_inventory": true,"quantity": 513,"quantity_allocated": 2,"cost_price_amount": "10.00",- "currency": "USD","weight": "2.5 kg"}},@@ -1650,16 +2022,17 @@"model": "product.productvariant","pk": 185,"fields": {+ "private_meta": {},+ "meta": {},"sku": "998423585","name": "5l",+ "currency": "USD","price_override_amount": "49.00","product": 65,- "attributes": "{\"18\": [\"62\"]}","track_inventory": true,- "quantity": 155,- "quantity_allocated": 14,+ "quantity": 156,+ "quantity_allocated": 15,"cost_price_amount": "15.00",- "currency": "USD","weight": "5.0 kg"}},@@ -1667,16 +2040,17 @@"model": "product.productvariant","pk": 190,"fields": {+ "private_meta": {},+ "meta": {},"sku": "988323582","name": "500ml",+ "currency": "USD","price_override_amount": null,"product": 71,- "attributes": "{\"15\": [\"46\"]}","track_inventory": true,"quantity": 1221,"quantity_allocated": 10,"cost_price_amount": "1.00",- "currency": "USD","weight": "1.0 kg"}},@@ -1684,16 +2058,17 @@"model": "product.productvariant","pk": 191,"fields": {+ "private_meta": {},+ "meta": {},"sku": "938323582","name": "1l",+ "currency": "USD","price_override_amount": "5.00","product": 71,- "attributes": "{\"15\": [\"47\"]}","track_inventory": true,"quantity": 177,"quantity_allocated": 2,"cost_price_amount": "1.50",- "currency": "USD","weight": "1.0 kg"}},@@ -1701,16 +2076,17 @@"model": "product.productvariant","pk": 192,"fields": {+ "private_meta": {},+ "meta": {},"sku": "988323522","name": "2l",+ "currency": "USD","price_override_amount": "7.00","product": 71,- "attributes": "{\"15\": [\"48\"]}","track_inventory": true,"quantity": 221,"quantity_allocated": 10,"cost_price_amount": "2.00",- "currency": "USD","weight": "2.0 kg"}},@@ -1718,11 +2094,13 @@"model": "product.productvariant","pk": 193,"fields": {+ "private_meta": {},+ "meta": {},"sku": "12312312321","name": "",+ "currency": "USD","price_override_amount": null,"product": 81,- "attributes": "{}","track_inventory": true,"quantity": 21244,"quantity_allocated": 13,@@ -1734,11 +2112,13 @@"model": "product.productvariant","pk": 194,"fields": {+ "private_meta": {},+ "meta": {},"sku": "1231998121","name": "",+ "currency": "USD","price_override_amount": null,"product": 82,- "attributes": "{}","track_inventory": true,"quantity": 12157,"quantity_allocated": 26,@@ -1750,11 +2130,13 @@"model": "product.productvariant","pk": 195,"fields": {+ "private_meta": {},+ "meta": {},"sku": "98616712","name": "",+ "currency": "USD","price_override_amount": null,"product": 83,- "attributes": "{}","track_inventory": true,"quantity": 12136,"quantity_allocated": 15,@@ -1766,11 +2148,13 @@"model": "product.productvariant","pk": 196,"fields": {+ "private_meta": {},+ "meta": {},"sku": "98616713","name": "",+ "currency": "USD","price_override_amount": null,"product": 84,- "attributes": "{}","track_inventory": true,"quantity": 975527,"quantity_allocated": 10,@@ -1782,16 +2166,17 @@"model": "product.productvariant","pk": 197,"fields": {+ "private_meta": {},+ "meta": {},"sku": "698223582","name": "45cm x 45cm",+ "currency": "USD","price_override_amount": "20.00","product": 85,- "attributes": "{\"22\": [\"70\"]}","track_inventory": true,"quantity": 9869,"quantity_allocated": 8,"cost_price_amount": "11.00",- "currency": "USD","weight": "0.0 kg"}},@@ -1799,16 +2184,17 @@"model": "product.productvariant","pk": 198,"fields": {+ "private_meta": {},+ "meta": {},"sku": "698223581","name": "55cm x 55cm",+ "currency": "USD","price_override_amount": null,"product": 85,- "attributes": "{\"22\": [\"71\"]}","track_inventory": true,"quantity": 687,"quantity_allocated": 16,"cost_price_amount": "12.00",- "currency": "USD","weight": "0.0 kg"}},@@ -1816,16 +2202,17 @@"model": "product.productvariant","pk": 199,"fields": {+ "private_meta": {},+ "meta": {},"sku": "987126191","name": "45cm x 45cm",+ "currency": "USD","price_override_amount": null,"product": 86,- "attributes": "{\"22\": [\"70\"]}","track_inventory": true,"quantity": 572,"quantity_allocated": 1,"cost_price_amount": "13.00",- "currency": "USD","weight": "0.0 kg"}},@@ -1833,16 +2220,17 @@"model": "product.productvariant","pk": 200,"fields": {+ "private_meta": {},+ "meta": {},"sku": "998223590","name": "55cm x 55cm",+ "currency": "USD","price_override_amount": null,"product": 86,- "attributes": "{\"22\": [\"71\"]}","track_inventory": true,"quantity": 1020,"quantity_allocated": 21,"cost_price_amount": "13.00",- "currency": "USD","weight": "0.0 kg"}},@@ -1850,16 +2238,17 @@"model": "product.productvariant","pk": 202,"fields": {+ "private_meta": {},+ "meta": {},"sku": "93855755","name": "500ml",+ "currency": "USD","price_override_amount": null,"product": 72,- "attributes": "{\"15\": [\"46\"]}","track_inventory": true,- "quantity": 1218,- "quantity_allocated": 7,+ "quantity": 1222,+ "quantity_allocated": 11,"cost_price_amount": "1.00",- "currency": "USD","weight": "1.0 kg"}},@@ -1867,16 +2256,17 @@"model": "product.productvariant","pk": 203,"fields": {+ "private_meta": {},+ "meta": {},"sku": "43226647","name": "1l",+ "currency": "USD","price_override_amount": "5.00","product": 72,- "attributes": "{\"15\": [\"47\"]}","track_inventory": true,- "quantity": 178,- "quantity_allocated": 3,+ "quantity": 179,+ "quantity_allocated": 4,"cost_price_amount": "1.50",- "currency": "USD","weight": "1.0 kg"}},@@ -1884,16 +2274,17 @@"model": "product.productvariant","pk": 204,"fields": {+ "private_meta": {},+ "meta": {},"sku": "80884671","name": "2l",+ "currency": "USD","price_override_amount": "7.00","product": 72,- "attributes": "{\"15\": [\"48\"]}","track_inventory": true,- "quantity": 224,- "quantity_allocated": 13,+ "quantity": 227,+ "quantity_allocated": 16,"cost_price_amount": "2.00",- "currency": "USD","weight": "2.0 kg"}},@@ -1901,16 +2292,17 @@"model": "product.productvariant","pk": 205,"fields": {+ "private_meta": {},+ "meta": {},"sku": "67882967","name": "500ml",+ "currency": "USD","price_override_amount": null,"product": 73,- "attributes": "{\"15\": [\"46\"]}","track_inventory": true,"quantity": 1214,"quantity_allocated": 3,"cost_price_amount": "1.00",- "currency": "USD","weight": "1.0 kg"}},@@ -1918,16 +2310,17 @@"model": "product.productvariant","pk": 206,"fields": {+ "private_meta": {},+ "meta": {},"sku": "14925419","name": "1l",+ "currency": "USD","price_override_amount": "5.00","product": 73,- "attributes": "{\"15\": [\"47\"]}","track_inventory": true,"quantity": 181,"quantity_allocated": 6,"cost_price_amount": "1.50",- "currency": "USD","weight": "1.0 kg"}},@@ -1935,16 +2328,17 @@"model": "product.productvariant","pk": 207,"fields": {+ "private_meta": {},+ "meta": {},"sku": "62426105","name": "2l",+ "currency": "USD","price_override_amount": "7.00","product": 73,- "attributes": "{\"15\": [\"48\"]}","track_inventory": true,"quantity": 223,"quantity_allocated": 12,"cost_price_amount": "2.00",- "currency": "USD","weight": "2.0 kg"}},@@ -1952,16 +2346,17 @@"model": "product.productvariant","pk": 208,"fields": {+ "private_meta": {},+ "meta": {},"sku": "45328412","name": "500ml",+ "currency": "USD","price_override_amount": null,"product": 74,- "attributes": "{\"15\": [\"46\"]}","track_inventory": true,"quantity": 1214,"quantity_allocated": 3,"cost_price_amount": "1.00",- "currency": "USD","weight": "1.0 kg"}},@@ -1969,16 +2364,17 @@"model": "product.productvariant","pk": 209,"fields": {+ "private_meta": {},+ "meta": {},"sku": "27512590","name": "1l",+ "currency": "USD","price_override_amount": "5.00","product": 74,- "attributes": "{\"15\": [\"47\"]}","track_inventory": true,"quantity": 185,"quantity_allocated": 10,"cost_price_amount": "1.50",- "currency": "USD","weight": "1.0 kg"}},@@ -1986,16 +2382,17 @@"model": "product.productvariant","pk": 210,"fields": {+ "private_meta": {},+ "meta": {},"sku": "40636347","name": "2l",+ "currency": "USD","price_override_amount": "7.00","product": 74,- "attributes": "{\"15\": [\"48\"]}","track_inventory": true,"quantity": 225,"quantity_allocated": 14,"cost_price_amount": "2.00",- "currency": "USD","weight": "2.0 kg"}},@@ -2003,16 +2400,17 @@"model": "product.productvariant","pk": 211,"fields": {+ "private_meta": {},+ "meta": {},"sku": "43200242","name": "500ml",+ "currency": "USD","price_override_amount": null,"product": 75,- "attributes": "{\"15\": [\"46\"]}","track_inventory": true,"quantity": 1216,"quantity_allocated": 5,"cost_price_amount": "1.00",- "currency": "USD","weight": "1.0 kg"}},@@ -2020,16 +2418,17 @@"model": "product.productvariant","pk": 212,"fields": {+ "private_meta": {},+ "meta": {},"sku": "79129513","name": "1l",+ "currency": "USD","price_override_amount": "5.00","product": 75,- "attributes": "{\"15\": [\"47\"]}","track_inventory": true,- "quantity": 187,- "quantity_allocated": 12,+ "quantity": 191,+ "quantity_allocated": 16,"cost_price_amount": "1.50",- "currency": "USD","weight": "1.0 kg"}},@@ -2037,16 +2436,17 @@"model": "product.productvariant","pk": 213,"fields": {+ "private_meta": {},+ "meta": {},"sku": "75799450","name": "2l",+ "currency": "USD","price_override_amount": "7.00","product": 75,- "attributes": "{\"15\": [\"48\"]}","track_inventory": true,"quantity": 225,"quantity_allocated": 14,"cost_price_amount": "2.00",- "currency": "USD","weight": "2.0 kg"}},@@ -2054,16 +2454,17 @@"model": "product.productvariant","pk": 214,"fields": {+ "private_meta": {},+ "meta": {},"sku": "3944859","name": "500ml",+ "currency": "USD","price_override_amount": null,"product": 76,- "attributes": "{\"15\": [\"46\"]}","track_inventory": true,"quantity": 1214,"quantity_allocated": 3,"cost_price_amount": "1.00",- "currency": "USD","weight": "1.0 kg"}},@@ -2071,16 +2472,17 @@"model": "product.productvariant","pk": 215,"fields": {+ "private_meta": {},+ "meta": {},"sku": "5829405","name": "1l",+ "currency": "USD","price_override_amount": "5.00","product": 76,- "attributes": "{\"15\": [\"47\"]}","track_inventory": true,- "quantity": 179,- "quantity_allocated": 4,+ "quantity": 182,+ "quantity_allocated": 7,"cost_price_amount": "1.50",- "currency": "USD","weight": "1.0 kg"}},@@ -2088,16 +2490,17 @@"model": "product.productvariant","pk": 216,"fields": {+ "private_meta": {},+ "meta": {},"sku": "84725784","name": "2l",+ "currency": "USD","price_override_amount": "7.00","product": 76,- "attributes": "{\"15\": [\"48\"]}","track_inventory": true,"quantity": 238,"quantity_allocated": 27,"cost_price_amount": "2.00",- "currency": "USD","weight": "2.0 kg"}},@@ -2105,16 +2508,17 @@"model": "product.productvariant","pk": 217,"fields": {+ "private_meta": {},+ "meta": {},"sku": "70058446","name": "500ml",+ "currency": "USD","price_override_amount": null,"product": 77,- "attributes": "{\"15\": [\"46\"]}","track_inventory": true,"quantity": 1222,"quantity_allocated": 11,"cost_price_amount": "1.00",- "currency": "USD","weight": "1.0 kg"}},@@ -2122,16 +2526,17 @@"model": "product.productvariant","pk": 218,"fields": {+ "private_meta": {},+ "meta": {},"sku": "94044081","name": "1l",+ "currency": "USD","price_override_amount": "5.00","product": 77,- "attributes": "{\"15\": [\"47\"]}","track_inventory": true,"quantity": 177,"quantity_allocated": 2,"cost_price_amount": "1.50",- "currency": "USD","weight": "1.0 kg"}},@@ -2139,16 +2544,17 @@"model": "product.productvariant","pk": 219,"fields": {+ "private_meta": {},+ "meta": {},"sku": "80696397","name": "2l",+ "currency": "USD","price_override_amount": "7.00","product": 77,- "attributes": "{\"15\": [\"48\"]}","track_inventory": true,- "quantity": 221,- "quantity_allocated": 10,+ "quantity": 224,+ "quantity_allocated": 13,"cost_price_amount": "2.00",- "currency": "USD","weight": "2.0 kg"}},@@ -2156,16 +2562,17 @@"model": "product.productvariant","pk": 220,"fields": {+ "private_meta": {},+ "meta": {},"sku": "60752428","name": "500ml",+ "currency": "USD","price_override_amount": null,"product": 78,- "attributes": "{\"15\": [\"46\"]}","track_inventory": true,"quantity": 1216,"quantity_allocated": 5,"cost_price_amount": "1.00",- "currency": "USD","weight": "1.0 kg"}},@@ -2173,16 +2580,17 @@"model": "product.productvariant","pk": 221,"fields": {+ "private_meta": {},+ "meta": {},"sku": "81470859","name": "1l",+ "currency": "USD","price_override_amount": "5.00","product": 78,- "attributes": "{\"15\": [\"47\"]}","track_inventory": true,"quantity": 181,"quantity_allocated": 6,"cost_price_amount": "1.50",- "currency": "USD","weight": "1.0 kg"}},@@ -2190,16 +2598,17 @@"model": "product.productvariant","pk": 222,"fields": {+ "private_meta": {},+ "meta": {},"sku": "30635751","name": "2l",+ "currency": "USD","price_override_amount": "7.00","product": 78,- "attributes": "{\"15\": [\"48\"]}","track_inventory": true,- "quantity": 228,- "quantity_allocated": 17,+ "quantity": 232,+ "quantity_allocated": 21,"cost_price_amount": "2.00",- "currency": "USD","weight": "2.0 kg"}},@@ -2207,16 +2616,17 @@"model": "product.productvariant","pk": 223,"fields": {+ "private_meta": {},+ "meta": {},"sku": "57211177","name": "500ml",+ "currency": "USD","price_override_amount": null,"product": 79,- "attributes": "{\"15\": [\"46\"]}","track_inventory": true,"quantity": 1221,"quantity_allocated": 10,"cost_price_amount": "1.00",- "currency": "USD","weight": "1.0 kg"}},@@ -2224,16 +2634,17 @@"model": "product.productvariant","pk": 224,"fields": {+ "private_meta": {},+ "meta": {},"sku": "57423879","name": "1l",+ "currency": "USD","price_override_amount": "5.00","product": 79,- "attributes": "{\"15\": [\"47\"]}","track_inventory": true,"quantity": 179,"quantity_allocated": 4,"cost_price_amount": "1.50",- "currency": "USD","weight": "1.0 kg"}},@@ -2241,16 +2652,17 @@"model": "product.productvariant","pk": 225,"fields": {+ "private_meta": {},+ "meta": {},"sku": "21438542","name": "2l",+ "currency": "USD","price_override_amount": "7.00","product": 79,- "attributes": "{\"15\": [\"48\"]}","track_inventory": true,"quantity": 229,"quantity_allocated": 18,"cost_price_amount": "2.00",- "currency": "USD","weight": "2.0 kg"}},@@ -2258,16 +2670,17 @@"model": "product.productvariant","pk": 242,"fields": {+ "private_meta": {},+ "meta": {},"sku": "398323583","name": "39",+ "currency": "USD","price_override_amount": null,"product": 87,- "attributes": "{\"24\": [\"75\"]}","track_inventory": true,"quantity": 9125,"quantity_allocated": 4,"cost_price_amount": "20.00",- "currency": "USD","weight": "0.0 kg"}},@@ -2275,16 +2688,17 @@"model": "product.productvariant","pk": 243,"fields": {+ "private_meta": {},+ "meta": {},"sku": "398323584","name": "40",+ "currency": "USD","price_override_amount": null,"product": 87,- "attributes": "{\"24\": [\"76\"]}","track_inventory": true,"quantity": 1,"quantity_allocated": 0,"cost_price_amount": "20.00",- "currency": "USD","weight": "0.0 kg"}},@@ -2292,16 +2706,17 @@"model": "product.productvariant","pk": 244,"fields": {+ "private_meta": {},+ "meta": {},"sku": "398323585","name": "41",+ "currency": "USD","price_override_amount": null,"product": 87,- "attributes": "{\"24\": [\"77\"]}","track_inventory": true,- "quantity": 1,- "quantity_allocated": 0,+ "quantity": 2,+ "quantity_allocated": 1,"cost_price_amount": "20.00",- "currency": "USD","weight": "0.0 kg"}},@@ -2309,16 +2724,17 @@"model": "product.productvariant","pk": 245,"fields": {+ "private_meta": {},+ "meta": {},"sku": "398323586","name": "42",+ "currency": "USD","price_override_amount": null,"product": 87,- "attributes": "{\"24\": [\"78\"]}","track_inventory": true,- "quantity": 131,- "quantity_allocated": 0,+ "quantity": 132,+ "quantity_allocated": 1,"cost_price_amount": "20.00",- "currency": "USD","weight": "0.0 kg"}},@@ -2326,16 +2742,17 @@"model": "product.productvariant","pk": 246,"fields": {+ "private_meta": {},+ "meta": {},"sku": "398323588","name": "43",+ "currency": "USD","price_override_amount": null,"product": 87,- "attributes": "{\"24\": [\"79\"]}","track_inventory": true,- "quantity": 882,- "quantity_allocated": 21,+ "quantity": 884,+ "quantity_allocated": 23,"cost_price_amount": "20.00",- "currency": "USD","weight": "0.0 kg"}},@@ -2343,16 +2760,17 @@"model": "product.productvariant","pk": 247,"fields": {+ "private_meta": {},+ "meta": {},"sku": "993223583","name": "40",+ "currency": "USD","price_override_amount": null,"product": 88,- "attributes": "{\"24\": [\"76\"]}","track_inventory": true,- "quantity": 7611,- "quantity_allocated": 0,+ "quantity": 7619,+ "quantity_allocated": 8,"cost_price_amount": "10.00",- "currency": "USD","weight": "1.0 kg"}},@@ -2360,16 +2778,17 @@"model": "product.productvariant","pk": 248,"fields": {+ "private_meta": {},+ "meta": {},"sku": "978223582","name": "41",+ "currency": "USD","price_override_amount": null,"product": 88,- "attributes": "{\"24\": [\"77\"]}","track_inventory": true,"quantity": 977,"quantity_allocated": 6,"cost_price_amount": "20.00",- "currency": "USD","weight": "1.0 kg"}},@@ -2377,11 +2796,13 @@"model": "product.productvariant","pk": 249,"fields": {+ "private_meta": {},+ "meta": {},"sku": "918323583","name": "40",+ "currency": "USD","price_override_amount": null,"product": 88,- "attributes": "{\"24\": [\"76\"]}","track_inventory": true,"quantity": 0,"quantity_allocated": 0,@@ -2393,16 +2814,17 @@"model": "product.productvariant","pk": 250,"fields": {+ "private_meta": {},+ "meta": {},"sku": "918223582","name": "45",+ "currency": "USD","price_override_amount": null,"product": 88,- "attributes": "{\"24\": [\"81\"]}","track_inventory": true,- "quantity": 15,- "quantity_allocated": 15,+ "quantity": 19,+ "quantity_allocated": 19,"cost_price_amount": "20.00",- "currency": "USD","weight": "2.0 kg"}},@@ -2410,16 +2832,17 @@"model": "product.productvariant","pk": 251,"fields": {+ "private_meta": {},+ "meta": {},"sku": "988323583","name": "S",+ "currency": "USD","price_override_amount": null,"product": 89,- "attributes": "{\"13\": [\"36\"]}","track_inventory": true,"quantity": 1213,"quantity_allocated": 0,"cost_price_amount": "10.00",- "currency": "USD","weight": "0.0 kg"}},@@ -2427,16 +2850,17 @@"model": "product.productvariant","pk": 252,"fields": {+ "private_meta": {},+ "meta": {},"sku": "338223582","name": "M",+ "currency": "USD","price_override_amount": null,"product": 89,- "attributes": "{\"13\": [\"37\"]}","track_inventory": true,"quantity": 7,"quantity_allocated": 6,"cost_price_amount": "10.00",- "currency": "USD","weight": "0.0 kg"}},@@ -2444,16 +2868,17 @@"model": "product.productvariant","pk": 253,"fields": {+ "private_meta": {},+ "meta": {},"sku": "118223591","name": "L",+ "currency": "USD","price_override_amount": null,"product": 89,- "attributes": "{\"13\": [\"38\"]}","track_inventory": true,"quantity": 9818,"quantity_allocated": 0,"cost_price_amount": "10.00",- "currency": "USD","weight": "0.0 kg"}},@@ -2461,16 +2886,17 @@"model": "product.productvariant","pk": 254,"fields": {+ "private_meta": {},+ "meta": {},"sku": "448323583","name": "XL",+ "currency": "USD","price_override_amount": null,"product": 89,- "attributes": "{\"13\": [\"39\"]}","track_inventory": true,- "quantity": 1,- "quantity_allocated": 0,+ "quantity": 2,+ "quantity_allocated": 1,"cost_price_amount": "10.00",- "currency": "USD","weight": "0.0 kg"}},@@ -2478,16 +2904,17 @@"model": "product.productvariant","pk": 255,"fields": {+ "private_meta": {},+ "meta": {},"sku": "3128223583","name": "XXL",+ "currency": "USD","price_override_amount": null,"product": 89,- "attributes": "{\"13\": [\"40\"]}","track_inventory": true,"quantity": 5802,"quantity_allocated": 11,"cost_price_amount": "10.00",- "currency": "USD","weight": "0.0 kg"}},@@ -2495,16 +2922,17 @@"model": "product.productvariant","pk": 256,"fields": {+ "private_meta": {},+ "meta": {},"sku": "29716755","name": "S",+ "currency": "USD","price_override_amount": null,"product": 107,- "attributes": "{\"13\": [\"36\"]}","track_inventory": true,"quantity": 1227,"quantity_allocated": 14,"cost_price_amount": "10.00",- "currency": "USD","weight": "0.0 kg"}},@@ -2512,16 +2940,17 @@"model": "product.productvariant","pk": 257,"fields": {+ "private_meta": {},+ "meta": {},"sku": "66594736","name": "M",+ "currency": "USD","price_override_amount": null,"product": 107,- "attributes": "{\"13\": [\"37\"]}","track_inventory": true,- "quantity": 8,- "quantity_allocated": 7,+ "quantity": 9,+ "quantity_allocated": 8,"cost_price_amount": "10.00",- "currency": "USD","weight": "0.0 kg"}},@@ -2529,16 +2958,17 @@"model": "product.productvariant","pk": 258,"fields": {+ "private_meta": {},+ "meta": {},"sku": "50269944","name": "L",+ "currency": "USD","price_override_amount": null,"product": 107,- "attributes": "{\"13\": [\"38\"]}","track_inventory": true,- "quantity": 9818,- "quantity_allocated": 0,+ "quantity": 9822,+ "quantity_allocated": 4,"cost_price_amount": "10.00",- "currency": "USD","weight": "0.0 kg"}},@@ -2546,16 +2976,17 @@"model": "product.productvariant","pk": 259,"fields": {+ "private_meta": {},+ "meta": {},"sku": "31352185","name": "XL",+ "currency": "USD","price_override_amount": null,"product": 107,- "attributes": "{\"13\": [\"39\"]}","track_inventory": true,"quantity": 1,"quantity_allocated": 0,"cost_price_amount": "10.00",- "currency": "USD","weight": "0.0 kg"}},@@ -2563,16 +2994,17 @@"model": "product.productvariant","pk": 260,"fields": {+ "private_meta": {},+ "meta": {},"sku": "85364796","name": "XXL",+ "currency": "USD","price_override_amount": null,"product": 107,- "attributes": "{\"13\": [\"40\"]}","track_inventory": true,- "quantity": 5817,- "quantity_allocated": 26,+ "quantity": 5823,+ "quantity_allocated": 32,"cost_price_amount": "10.00",- "currency": "USD","weight": "0.0 kg"}},@@ -2580,16 +3012,17 @@"model": "product.productvariant","pk": 261,"fields": {+ "private_meta": {},+ "meta": {},"sku": "44026421","name": "S",+ "currency": "USD","price_override_amount": null,"product": 108,- "attributes": "{\"13\": [\"36\"]}","track_inventory": true,"quantity": 1217,"quantity_allocated": 4,"cost_price_amount": "10.00",- "currency": "USD","weight": "0.0 kg"}},@@ -2597,16 +3030,17 @@"model": "product.productvariant","pk": 262,"fields": {+ "private_meta": {},+ "meta": {},"sku": "90892602","name": "M",+ "currency": "USD","price_override_amount": null,"product": 108,- "attributes": "{\"13\": [\"37\"]}","track_inventory": true,- "quantity": 4,- "quantity_allocated": 3,+ "quantity": 8,+ "quantity_allocated": 7,"cost_price_amount": "10.00",- "currency": "USD","weight": "0.0 kg"}},@@ -2614,16 +3048,17 @@"model": "product.productvariant","pk": 263,"fields": {+ "private_meta": {},+ "meta": {},"sku": "59014392","name": "L",+ "currency": "USD","price_override_amount": null,"product": 108,- "attributes": "{\"13\": [\"38\"]}","track_inventory": true,"quantity": 9818,"quantity_allocated": 0,"cost_price_amount": "10.00",- "currency": "USD","weight": "0.0 kg"}},@@ -2631,16 +3066,17 @@"model": "product.productvariant","pk": 264,"fields": {+ "private_meta": {},+ "meta": {},"sku": "43659438","name": "XL",+ "currency": "USD","price_override_amount": null,"product": 108,- "attributes": "{\"13\": [\"39\"]}","track_inventory": true,"quantity": 1,"quantity_allocated": 0,"cost_price_amount": "10.00",- "currency": "USD","weight": "0.0 kg"}},@@ -2648,16 +3084,17 @@"model": "product.productvariant","pk": 265,"fields": {+ "private_meta": {},+ "meta": {},"sku": "60597697","name": "XXL",+ "currency": "USD","price_override_amount": null,"product": 108,- "attributes": "{\"13\": [\"40\"]}","track_inventory": true,"quantity": 5820,"quantity_allocated": 29,"cost_price_amount": "10.00",- "currency": "USD","weight": "0.0 kg"}},@@ -2665,16 +3102,17 @@"model": "product.productvariant","pk": 266,"fields": {+ "private_meta": {},+ "meta": {},"sku": "26592266","name": "S",+ "currency": "USD","price_override_amount": null,"product": 109,- "attributes": "{\"13\": [\"36\"]}","track_inventory": true,"quantity": 1220,"quantity_allocated": 7,"cost_price_amount": "10.00",- "currency": "USD","weight": "0.0 kg"}},@@ -2682,16 +3120,17 @@"model": "product.productvariant","pk": 267,"fields": {+ "private_meta": {},+ "meta": {},"sku": "36260498","name": "M",+ "currency": "USD","price_override_amount": null,"product": 109,- "attributes": "{\"13\": [\"37\"]}","track_inventory": true,"quantity": 2,"quantity_allocated": 1,"cost_price_amount": "10.00",- "currency": "USD","weight": "0.0 kg"}},@@ -2699,16 +3138,17 @@"model": "product.productvariant","pk": 268,"fields": {+ "private_meta": {},+ "meta": {},"sku": "37558859","name": "L",+ "currency": "USD","price_override_amount": null,"product": 109,- "attributes": "{\"13\": [\"38\"]}","track_inventory": true,- "quantity": 9818,- "quantity_allocated": 0,+ "quantity": 9822,+ "quantity_allocated": 4,"cost_price_amount": "10.00",- "currency": "USD","weight": "0.0 kg"}},@@ -2716,16 +3156,17 @@"model": "product.productvariant","pk": 269,"fields": {+ "private_meta": {},+ "meta": {},"sku": "19402012","name": "XL",+ "currency": "USD","price_override_amount": null,"product": 109,- "attributes": "{\"13\": [\"39\"]}","track_inventory": true,- "quantity": 1,- "quantity_allocated": 0,+ "quantity": 7,+ "quantity_allocated": 6,"cost_price_amount": "10.00",- "currency": "USD","weight": "0.0 kg"}},@@ -2733,16 +3174,17 @@"model": "product.productvariant","pk": 270,"fields": {+ "private_meta": {},+ "meta": {},"sku": "17570141","name": "XXL",+ "currency": "USD","price_override_amount": null,"product": 109,- "attributes": "{\"13\": [\"40\"]}","track_inventory": true,"quantity": 5817,"quantity_allocated": 26,"cost_price_amount": "10.00",- "currency": "USD","weight": "0.0 kg"}},@@ -2750,16 +3192,17 @@"model": "product.productvariant","pk": 271,"fields": {+ "private_meta": {},+ "meta": {},"sku": "98530976","name": "S",+ "currency": "USD","price_override_amount": null,"product": 110,- "attributes": "{\"13\": [\"36\"]}","track_inventory": true,"quantity": 1221,"quantity_allocated": 8,"cost_price_amount": "10.00",- "currency": "USD","weight": "0.0 kg"}},@@ -2767,16 +3210,17 @@"model": "product.productvariant","pk": 272,"fields": {+ "private_meta": {},+ "meta": {},"sku": "46806935","name": "M",+ "currency": "USD","price_override_amount": null,"product": 110,- "attributes": "{\"13\": [\"37\"]}","track_inventory": true,"quantity": 6,"quantity_allocated": 5,"cost_price_amount": "10.00",- "currency": "USD","weight": "0.0 kg"}},@@ -2784,16 +3228,17 @@"model": "product.productvariant","pk": 273,"fields": {+ "private_meta": {},+ "meta": {},"sku": "71103052","name": "L",+ "currency": "USD","price_override_amount": null,"product": 110,- "attributes": "{\"13\": [\"38\"]}","track_inventory": true,"quantity": 9818,"quantity_allocated": 0,"cost_price_amount": "10.00",- "currency": "USD","weight": "0.0 kg"}},@@ -2801,16 +3246,17 @@"model": "product.productvariant","pk": 274,"fields": {+ "private_meta": {},+ "meta": {},"sku": "84812015","name": "XL",+ "currency": "USD","price_override_amount": null,"product": 110,- "attributes": "{\"13\": [\"39\"]}","track_inventory": true,- "quantity": 1,- "quantity_allocated": 0,+ "quantity": 5,+ "quantity_allocated": 4,"cost_price_amount": "10.00",- "currency": "USD","weight": "0.0 kg"}},@@ -2818,16 +3264,17 @@"model": "product.productvariant","pk": 275,"fields": {+ "private_meta": {},+ "meta": {},"sku": "89820261","name": "XXL",+ "currency": "USD","price_override_amount": null,"product": 110,- "attributes": "{\"13\": [\"40\"]}","track_inventory": true,"quantity": 5816,"quantity_allocated": 25,"cost_price_amount": "10.00",- "currency": "USD","weight": "0.0 kg"}},@@ -2835,16 +3282,17 @@"model": "product.productvariant","pk": 276,"fields": {+ "private_meta": {},+ "meta": {},"sku": "81115323","name": "S",+ "currency": "USD","price_override_amount": null,"product": 111,- "attributes": "{\"13\": [\"36\"]}","track_inventory": true,- "quantity": 1215,- "quantity_allocated": 2,+ "quantity": 1217,+ "quantity_allocated": 4,"cost_price_amount": "10.00",- "currency": "USD","weight": "0.0 kg"}},@@ -2852,16 +3300,17 @@"model": "product.productvariant","pk": 277,"fields": {+ "private_meta": {},+ "meta": {},"sku": "38254631","name": "M",+ "currency": "USD","price_override_amount": null,"product": 111,- "attributes": "{\"13\": [\"37\"]}","track_inventory": true,"quantity": 5,"quantity_allocated": 4,"cost_price_amount": "10.00",- "currency": "USD","weight": "0.0 kg"}},@@ -2869,16 +3318,17 @@"model": "product.productvariant","pk": 278,"fields": {+ "private_meta": {},+ "meta": {},"sku": "11511539","name": "L",+ "currency": "USD","price_override_amount": null,"product": 111,- "attributes": "{\"13\": [\"38\"]}","track_inventory": true,"quantity": 9821,"quantity_allocated": 3,"cost_price_amount": "10.00",- "currency": "USD","weight": "0.0 kg"}},@@ -2886,16 +3336,17 @@"model": "product.productvariant","pk": 279,"fields": {+ "private_meta": {},+ "meta": {},"sku": "84192227","name": "XL",+ "currency": "USD","price_override_amount": null,"product": 111,- "attributes": "{\"13\": [\"39\"]}","track_inventory": true,- "quantity": 1,- "quantity_allocated": 0,+ "quantity": 2,+ "quantity_allocated": 1,"cost_price_amount": "10.00",- "currency": "USD","weight": "0.0 kg"}},@@ -2903,16 +3354,17 @@"model": "product.productvariant","pk": 280,"fields": {+ "private_meta": {},+ "meta": {},"sku": "91642659","name": "XXL",+ "currency": "USD","price_override_amount": null,"product": 111,- "attributes": "{\"13\": [\"40\"]}","track_inventory": true,"quantity": 5807,"quantity_allocated": 16,"cost_price_amount": "10.00",- "currency": "USD","weight": "0.0 kg"}},@@ -2920,16 +3372,17 @@"model": "product.productvariant","pk": 281,"fields": {+ "private_meta": {},+ "meta": {},"sku": "76491340","name": "S",+ "currency": "USD","price_override_amount": null,"product": 112,- "attributes": "{\"13\": [\"36\"]}","track_inventory": true,"quantity": 1217,"quantity_allocated": 4,"cost_price_amount": "10.00",- "currency": "USD","weight": "0.0 kg"}},@@ -2937,16 +3390,17 @@"model": "product.productvariant","pk": 282,"fields": {+ "private_meta": {},+ "meta": {},"sku": "55101176","name": "M",+ "currency": "USD","price_override_amount": null,"product": 112,- "attributes": "{\"13\": [\"37\"]}","track_inventory": true,"quantity": 3,"quantity_allocated": 2,"cost_price_amount": "10.00",- "currency": "USD","weight": "0.0 kg"}},@@ -2954,16 +3408,17 @@"model": "product.productvariant","pk": 283,"fields": {+ "private_meta": {},+ "meta": {},"sku": "28094954","name": "L",+ "currency": "USD","price_override_amount": null,"product": 112,- "attributes": "{\"13\": [\"38\"]}","track_inventory": true,"quantity": 9819,"quantity_allocated": 1,"cost_price_amount": "10.00",- "currency": "USD","weight": "0.0 kg"}},@@ -2971,16 +3426,17 @@"model": "product.productvariant","pk": 284,"fields": {+ "private_meta": {},+ "meta": {},"sku": "40232182","name": "XL",+ "currency": "USD","price_override_amount": null,"product": 112,- "attributes": "{\"13\": [\"39\"]}","track_inventory": true,"quantity": 1,"quantity_allocated": 0,"cost_price_amount": "10.00",- "currency": "USD","weight": "0.0 kg"}},@@ -2988,16 +3444,17 @@"model": "product.productvariant","pk": 285,"fields": {+ "private_meta": {},+ "meta": {},"sku": "21522631","name": "XXL",+ "currency": "USD","price_override_amount": null,"product": 112,- "attributes": "{\"13\": [\"40\"]}","track_inventory": true,- "quantity": 5809,- "quantity_allocated": 18,+ "quantity": 5810,+ "quantity_allocated": 19,"cost_price_amount": "10.00",- "currency": "USD","weight": "0.0 kg"}},@@ -3005,16 +3462,17 @@"model": "product.productvariant","pk": 286,"fields": {+ "private_meta": {},+ "meta": {},"sku": "29810068","name": "S",+ "currency": "USD","price_override_amount": null,"product": 113,- "attributes": "{\"13\": [\"36\"]}","track_inventory": true,"quantity": 1220,"quantity_allocated": 7,"cost_price_amount": "10.00",- "currency": "USD","weight": "0.0 kg"}},@@ -3022,16 +3480,17 @@"model": "product.productvariant","pk": 287,"fields": {+ "private_meta": {},+ "meta": {},"sku": "57917658","name": "M",+ "currency": "USD","price_override_amount": null,"product": 113,- "attributes": "{\"13\": [\"37\"]}","track_inventory": true,"quantity": 6,"quantity_allocated": 5,"cost_price_amount": "10.00",- "currency": "USD","weight": "0.0 kg"}},@@ -3039,16 +3498,17 @@"model": "product.productvariant","pk": 288,"fields": {+ "private_meta": {},+ "meta": {},"sku": "42680611","name": "L",+ "currency": "USD","price_override_amount": null,"product": 113,- "attributes": "{\"13\": [\"38\"]}","track_inventory": true,"quantity": 9818,"quantity_allocated": 0,"cost_price_amount": "10.00",- "currency": "USD","weight": "0.0 kg"}},@@ -3056,16 +3516,17 @@"model": "product.productvariant","pk": 289,"fields": {+ "private_meta": {},+ "meta": {},"sku": "72289815","name": "XL",+ "currency": "USD","price_override_amount": null,"product": 113,- "attributes": "{\"13\": [\"39\"]}","track_inventory": true,- "quantity": 1,- "quantity_allocated": 0,+ "quantity": 2,+ "quantity_allocated": 1,"cost_price_amount": "10.00",- "currency": "USD","weight": "0.0 kg"}},@@ -3073,16 +3534,17 @@"model": "product.productvariant","pk": 290,"fields": {+ "private_meta": {},+ "meta": {},"sku": "98653891","name": "XXL",+ "currency": "USD","price_override_amount": null,"product": 113,- "attributes": "{\"13\": [\"40\"]}","track_inventory": true,"quantity": 5817,"quantity_allocated": 26,"cost_price_amount": "10.00",- "currency": "USD","weight": "0.0 kg"}},@@ -3090,16 +3552,17 @@"model": "product.productvariant","pk": 291,"fields": {+ "private_meta": {},+ "meta": {},"sku": "77306807","name": "S",+ "currency": "USD","price_override_amount": null,"product": 114,- "attributes": "{\"13\": [\"36\"]}","track_inventory": true,"quantity": 1213,"quantity_allocated": 0,"cost_price_amount": "10.00",- "currency": "USD","weight": "0.0 kg"}},@@ -3107,16 +3570,17 @@"model": "product.productvariant","pk": 292,"fields": {+ "private_meta": {},+ "meta": {},"sku": "68848129","name": "M",+ "currency": "USD","price_override_amount": null,"product": 114,- "attributes": "{\"13\": [\"37\"]}","track_inventory": true,"quantity": 1,"quantity_allocated": 0,"cost_price_amount": "10.00",- "currency": "USD","weight": "0.0 kg"}},@@ -3124,16 +3588,17 @@"model": "product.productvariant","pk": 293,"fields": {+ "private_meta": {},+ "meta": {},"sku": "35342696","name": "L",+ "currency": "USD","price_override_amount": null,"product": 114,- "attributes": "{\"13\": [\"38\"]}","track_inventory": true,"quantity": 9818,"quantity_allocated": 0,"cost_price_amount": "10.00",- "currency": "USD","weight": "0.0 kg"}},@@ -3141,16 +3606,17 @@"model": "product.productvariant","pk": 294,"fields": {+ "private_meta": {},+ "meta": {},"sku": "98935349","name": "XL",+ "currency": "USD","price_override_amount": null,"product": 114,- "attributes": "{\"13\": [\"39\"]}","track_inventory": true,- "quantity": 1,- "quantity_allocated": 0,+ "quantity": 4,+ "quantity_allocated": 3,"cost_price_amount": "10.00",- "currency": "USD","weight": "0.0 kg"}},@@ -3158,16 +3624,17 @@"model": "product.productvariant","pk": 295,"fields": {+ "private_meta": {},+ "meta": {},"sku": "45179543","name": "XXL",+ "currency": "USD","price_override_amount": null,"product": 114,- "attributes": "{\"13\": [\"40\"]}","track_inventory": true,- "quantity": 5805,- "quantity_allocated": 14,+ "quantity": 5806,+ "quantity_allocated": 15,"cost_price_amount": "10.00",- "currency": "USD","weight": "0.0 kg"}},@@ -3175,16 +3642,17 @@"model": "product.productvariant","pk": 296,"fields": {+ "private_meta": {},+ "meta": {},"sku": "62783187","name": "S",+ "currency": "USD","price_override_amount": null,"product": 115,- "attributes": "{\"13\": [\"36\"]}","track_inventory": true,"quantity": 1216,"quantity_allocated": 3,"cost_price_amount": "10.00",- "currency": "USD","weight": "0.0 kg"}},@@ -3192,16 +3660,17 @@"model": "product.productvariant","pk": 297,"fields": {+ "private_meta": {},+ "meta": {},"sku": "91406604","name": "M",+ "currency": "USD","price_override_amount": null,"product": 115,- "attributes": "{\"13\": [\"37\"]}","track_inventory": true,"quantity": 3,"quantity_allocated": 2,"cost_price_amount": "10.00",- "currency": "USD","weight": "0.0 kg"}},@@ -3209,16 +3678,17 @@"model": "product.productvariant","pk": 298,"fields": {+ "private_meta": {},+ "meta": {},"sku": "22119503","name": "L",+ "currency": "USD","price_override_amount": null,"product": 115,- "attributes": "{\"13\": [\"38\"]}","track_inventory": true,- "quantity": 9818,- "quantity_allocated": 0,+ "quantity": 9819,+ "quantity_allocated": 1,"cost_price_amount": "10.00",- "currency": "USD","weight": "0.0 kg"}},@@ -3226,409 +3696,2249 @@"model": "product.productvariant","pk": 299,"fields": {+ "private_meta": {},+ "meta": {},"sku": "19230637","name": "XL",+ "currency": "USD","price_override_amount": null,"product": 115,- "attributes": "{\"13\": [\"39\"]}","track_inventory": true,"quantity": 1,"quantity_allocated": 0,"cost_price_amount": "10.00",+ "weight": "0.0 kg"+ }+ },+ {+ "model": "product.productvariant",+ "pk": 300,+ "fields": {+ "private_meta": {},+ "meta": {},+ "sku": "61630747",+ "name": "XXL",+ "currency": "USD",+ "price_override_amount": null,+ "product": 115,+ "track_inventory": true,+ "quantity": 5829,+ "quantity_allocated": 38,+ "cost_price_amount": "10.00",+ "weight": "0.0 kg"+ }+ },+ {+ "model": "product.productvariant",+ "pk": 301,+ "fields": {+ "private_meta": {},+ "meta": {},+ "sku": "15744278",+ "name": "S",+ "currency": "USD",+ "price_override_amount": null,+ "product": 116,+ "track_inventory": true,+ "quantity": 1218,+ "quantity_allocated": 5,+ "cost_price_amount": "10.00",+ "weight": "0.0 kg"+ }+ },+ {+ "model": "product.productvariant",+ "pk": 302,+ "fields": {+ "private_meta": {},+ "meta": {},+ "sku": "21599567",+ "name": "M","currency": "USD",+ "price_override_amount": null,+ "product": 116,+ "track_inventory": true,+ "quantity": 4,+ "quantity_allocated": 3,+ "cost_price_amount": "10.00","weight": "0.0 kg"}},{- "model": "product.productvariant",- "pk": 300,+ "model": "product.productvariant",+ "pk": 303,+ "fields": {+ "private_meta": {},+ "meta": {},+ "sku": "65363253",+ "name": "L",+ "currency": "USD",+ "price_override_amount": null,+ "product": 116,+ "track_inventory": true,+ "quantity": 9822,+ "quantity_allocated": 4,+ "cost_price_amount": "10.00",+ "weight": "0.0 kg"+ }+ },+ {+ "model": "product.productvariant",+ "pk": 304,+ "fields": {+ "private_meta": {},+ "meta": {},+ "sku": "51987722",+ "name": "XL",+ "currency": "USD",+ "price_override_amount": null,+ "product": 116,+ "track_inventory": true,+ "quantity": 5,+ "quantity_allocated": 4,+ "cost_price_amount": "10.00",+ "weight": "0.0 kg"+ }+ },+ {+ "model": "product.productvariant",+ "pk": 305,+ "fields": {+ "private_meta": {},+ "meta": {},+ "sku": "43313080",+ "name": "XXL",+ "currency": "USD",+ "price_override_amount": null,+ "product": 116,+ "track_inventory": true,+ "quantity": 5805,+ "quantity_allocated": 14,+ "cost_price_amount": "10.00",+ "weight": "0.0 kg"+ }+ },+ {+ "model": "product.productvariant",+ "pk": 306,+ "fields": {+ "private_meta": {},+ "meta": {},+ "sku": "33963052",+ "name": "S",+ "currency": "USD",+ "price_override_amount": null,+ "product": 117,+ "track_inventory": true,+ "quantity": 1218,+ "quantity_allocated": 5,+ "cost_price_amount": "10.00",+ "weight": "0.0 kg"+ }+ },+ {+ "model": "product.productvariant",+ "pk": 307,+ "fields": {+ "private_meta": {},+ "meta": {},+ "sku": "66846240",+ "name": "M",+ "currency": "USD",+ "price_override_amount": null,+ "product": 117,+ "track_inventory": true,+ "quantity": 15,+ "quantity_allocated": 14,+ "cost_price_amount": "10.00",+ "weight": "0.0 kg"+ }+ },+ {+ "model": "product.productvariant",+ "pk": 308,+ "fields": {+ "private_meta": {},+ "meta": {},+ "sku": "55365141",+ "name": "L",+ "currency": "USD",+ "price_override_amount": null,+ "product": 117,+ "track_inventory": true,+ "quantity": 9823,+ "quantity_allocated": 5,+ "cost_price_amount": "10.00",+ "weight": "0.0 kg"+ }+ },+ {+ "model": "product.productvariant",+ "pk": 309,+ "fields": {+ "private_meta": {},+ "meta": {},+ "sku": "73186143",+ "name": "XL",+ "currency": "USD",+ "price_override_amount": null,+ "product": 117,+ "track_inventory": true,+ "quantity": 1,+ "quantity_allocated": 0,+ "cost_price_amount": "10.00",+ "weight": "0.0 kg"+ }+ },+ {+ "model": "product.productvariant",+ "pk": 310,+ "fields": {+ "private_meta": {},+ "meta": {},+ "sku": "42651772",+ "name": "XXL",+ "currency": "USD",+ "price_override_amount": null,+ "product": 117,+ "track_inventory": true,+ "quantity": 5809,+ "quantity_allocated": 18,+ "cost_price_amount": "10.00",+ "weight": "0.0 kg"+ }+ },+ {+ "model": "product.productvariant",+ "pk": 311,+ "fields": {+ "private_meta": {},+ "meta": {},+ "sku": "70760297",+ "name": "S",+ "currency": "USD",+ "price_override_amount": null,+ "product": 118,+ "track_inventory": true,+ "quantity": 1213,+ "quantity_allocated": 0,+ "cost_price_amount": "10.00",+ "weight": "0.0 kg"+ }+ },+ {+ "model": "product.productvariant",+ "pk": 312,+ "fields": {+ "private_meta": {},+ "meta": {},+ "sku": "36334412",+ "name": "M",+ "currency": "USD",+ "price_override_amount": null,+ "product": 118,+ "track_inventory": true,+ "quantity": 10,+ "quantity_allocated": 9,+ "cost_price_amount": "10.00",+ "weight": "0.0 kg"+ }+ },+ {+ "model": "product.productvariant",+ "pk": 313,+ "fields": {+ "private_meta": {},+ "meta": {},+ "sku": "35994675",+ "name": "L",+ "currency": "USD",+ "price_override_amount": null,+ "product": 118,+ "track_inventory": true,+ "quantity": 9818,+ "quantity_allocated": 0,+ "cost_price_amount": "10.00",+ "weight": "0.0 kg"+ }+ },+ {+ "model": "product.productvariant",+ "pk": 314,+ "fields": {+ "private_meta": {},+ "meta": {},+ "sku": "10404946",+ "name": "XL",+ "currency": "USD",+ "price_override_amount": null,+ "product": 118,+ "track_inventory": true,+ "quantity": 3,+ "quantity_allocated": 2,+ "cost_price_amount": "10.00",+ "weight": "0.0 kg"+ }+ },+ {+ "model": "product.productvariant",+ "pk": 315,+ "fields": {+ "private_meta": {},+ "meta": {},+ "sku": "45507483",+ "name": "XXL",+ "currency": "USD",+ "price_override_amount": null,+ "product": 118,+ "track_inventory": true,+ "quantity": 5818,+ "quantity_allocated": 27,+ "cost_price_amount": "10.00",+ "weight": "0.0 kg"+ }+ },+ {+ "model": "product.assignedproductattribute",+ "pk": 1,+ "fields": {+ "product": 72,+ "assignment": 1,+ "values": [+ 3+ ]+ }+ },+ {+ "model": "product.assignedproductattribute",+ "pk": 2,+ "fields": {+ "product": 74,+ "assignment": 1,+ "values": [+ 50+ ]+ }+ },+ {+ "model": "product.assignedproductattribute",+ "pk": 3,+ "fields": {+ "product": 79,+ "assignment": 1,+ "values": [+ 51+ ]+ }+ },+ {+ "model": "product.assignedproductattribute",+ "pk": 4,+ "fields": {+ "product": 115,+ "assignment": 5,+ "values": [+ 82+ ]+ }+ },+ {+ "model": "product.assignedproductattribute",+ "pk": 5,+ "fields": {+ "product": 116,+ "assignment": 5,+ "values": [+ 82+ ]+ }+ },+ {+ "model": "product.assignedproductattribute",+ "pk": 6,+ "fields": {+ "product": 73,+ "assignment": 1,+ "values": [+ 52+ ]+ }+ },+ {+ "model": "product.assignedproductattribute",+ "pk": 7,+ "fields": {+ "product": 76,+ "assignment": 1,+ "values": [+ 2+ ]+ }+ },+ {+ "model": "product.assignedproductattribute",+ "pk": 8,+ "fields": {+ "product": 89,+ "assignment": 5,+ "values": [+ 82+ ]+ }+ },+ {+ "model": "product.assignedproductattribute",+ "pk": 9,+ "fields": {+ "product": 85,+ "assignment": 4,+ "values": [+ 72+ ]+ }+ },+ {+ "model": "product.assignedproductattribute",+ "pk": 10,+ "fields": {+ "product": 78,+ "assignment": 1,+ "values": [+ 53+ ]+ }+ },+ {+ "model": "product.assignedproductattribute",+ "pk": 11,+ "fields": {+ "product": 117,+ "assignment": 5,+ "values": [+ 82+ ]+ }+ },+ {+ "model": "product.assignedproductattribute",+ "pk": 12,+ "fields": {+ "product": 71,+ "assignment": 1,+ "values": [+ 49+ ]+ }+ },+ {+ "model": "product.assignedproductattribute",+ "pk": 13,+ "fields": {+ "product": 75,+ "assignment": 1,+ "values": [+ 1+ ]+ }+ },+ {+ "model": "product.assignedproductattribute",+ "pk": 14,+ "fields": {+ "product": 107,+ "assignment": 5,+ "values": [+ 82+ ]+ }+ },+ {+ "model": "product.assignedproductattribute",+ "pk": 15,+ "fields": {+ "product": 110,+ "assignment": 5,+ "values": [+ 82+ ]+ }+ },+ {+ "model": "product.assignedproductattribute",+ "pk": 16,+ "fields": {+ "product": 109,+ "assignment": 5,+ "values": [+ 82+ ]+ }+ },+ {+ "model": "product.assignedproductattribute",+ "pk": 17,+ "fields": {+ "product": 108,+ "assignment": 5,+ "values": [+ 82+ ]+ }+ },+ {+ "model": "product.assignedproductattribute",+ "pk": 18,+ "fields": {+ "product": 77,+ "assignment": 1,+ "values": [+ 54+ ]+ }+ },+ {+ "model": "product.assignedproductattribute",+ "pk": 19,+ "fields": {+ "product": 81,+ "assignment": 2,+ "values": [+ 67+ ]+ }+ },+ {+ "model": "product.assignedproductattribute",+ "pk": 20,+ "fields": {+ "product": 84,+ "assignment": 3,+ "values": [+ 69+ ]+ }+ },+ {+ "model": "product.assignedproductattribute",+ "pk": 21,+ "fields": {+ "product": 83,+ "assignment": 3,+ "values": [+ 68+ ]+ }+ },+ {+ "model": "product.assignedproductattribute",+ "pk": 22,+ "fields": {+ "product": 114,+ "assignment": 5,+ "values": [+ 82+ ]+ }+ },+ {+ "model": "product.assignedproductattribute",+ "pk": 23,+ "fields": {+ "product": 111,+ "assignment": 5,+ "values": [+ 82+ ]+ }+ },+ {+ "model": "product.assignedproductattribute",+ "pk": 24,+ "fields": {+ "product": 112,+ "assignment": 5,+ "values": [+ 82+ ]+ }+ },+ {+ "model": "product.assignedproductattribute",+ "pk": 25,+ "fields": {+ "product": 113,+ "assignment": 5,+ "values": [+ 82+ ]+ }+ },+ {+ "model": "product.assignedproductattribute",+ "pk": 26,+ "fields": {+ "product": 118,+ "assignment": 5,+ "values": [+ 82+ ]+ }+ },+ {+ "model": "product.assignedproductattribute",+ "pk": 27,+ "fields": {+ "product": 86,+ "assignment": 4,+ "values": [+ 72+ ]+ }+ },+ {+ "model": "product.assignedproductattribute",+ "pk": 28,+ "fields": {+ "product": 82,+ "assignment": 2,+ "values": [+ 67+ ]+ }+ },+ {+ "model": "product.assignedvariantattribute",+ "pk": 1,+ "fields": {+ "variant": 172,+ "assignment": 3,+ "values": [+ 61+ ]+ }+ },+ {+ "model": "product.assignedvariantattribute",+ "pk": 2,+ "fields": {+ "variant": 173,+ "assignment": 3,+ "values": [+ 62+ ]+ }+ },+ {+ "model": "product.assignedvariantattribute",+ "pk": 3,+ "fields": {+ "variant": 174,+ "assignment": 3,+ "values": [+ 60+ ]+ }+ },+ {+ "model": "product.assignedvariantattribute",+ "pk": 4,+ "fields": {+ "variant": 175,+ "assignment": 3,+ "values": [+ 61+ ]+ }+ },+ {+ "model": "product.assignedvariantattribute",+ "pk": 5,+ "fields": {+ "variant": 176,+ "assignment": 3,+ "values": [+ 62+ ]+ }+ },+ {+ "model": "product.assignedvariantattribute",+ "pk": 6,+ "fields": {+ "variant": 177,+ "assignment": 3,+ "values": [+ 60+ ]+ }+ },+ {+ "model": "product.assignedvariantattribute",+ "pk": 7,+ "fields": {+ "variant": 178,+ "assignment": 3,+ "values": [+ 61+ ]+ }+ },+ {+ "model": "product.assignedvariantattribute",+ "pk": 8,+ "fields": {+ "variant": 179,+ "assignment": 3,+ "values": [+ 62+ ]+ }+ },+ {+ "model": "product.assignedvariantattribute",+ "pk": 9,+ "fields": {+ "variant": 181,+ "assignment": 3,+ "values": [+ 61+ ]+ }+ },+ {+ "model": "product.assignedvariantattribute",+ "pk": 10,+ "fields": {+ "variant": 183,+ "assignment": 3,+ "values": [+ 60+ ]+ }+ },+ {+ "model": "product.assignedvariantattribute",+ "pk": 11,+ "fields": {+ "variant": 184,+ "assignment": 3,+ "values": [+ 61+ ]+ }+ },+ {+ "model": "product.assignedvariantattribute",+ "pk": 12,+ "fields": {+ "variant": 190,+ "assignment": 2,+ "values": [+ 46+ ]+ }+ },+ {+ "model": "product.assignedvariantattribute",+ "pk": 13,+ "fields": {+ "variant": 191,+ "assignment": 2,+ "values": [+ 47+ ]+ }+ },+ {+ "model": "product.assignedvariantattribute",+ "pk": 14,+ "fields": {+ "variant": 192,+ "assignment": 2,+ "values": [+ 48+ ]+ }+ },+ {+ "model": "product.assignedvariantattribute",+ "pk": 15,+ "fields": {+ "variant": 197,+ "assignment": 5,+ "values": [+ 70+ ]+ }+ },+ {+ "model": "product.assignedvariantattribute",+ "pk": 16,+ "fields": {+ "variant": 198,+ "assignment": 5,+ "values": [+ 71+ ]+ }+ },+ {+ "model": "product.assignedvariantattribute",+ "pk": 17,+ "fields": {+ "variant": 199,+ "assignment": 5,+ "values": [+ 70+ ]+ }+ },+ {+ "model": "product.assignedvariantattribute",+ "pk": 18,+ "fields": {+ "variant": 200,+ "assignment": 5,+ "values": [+ 71+ ]+ }+ },+ {+ "model": "product.assignedvariantattribute",+ "pk": 19,+ "fields": {+ "variant": 205,+ "assignment": 2,+ "values": [+ 46+ ]+ }+ },+ {+ "model": "product.assignedvariantattribute",+ "pk": 20,+ "fields": {+ "variant": 206,+ "assignment": 2,+ "values": [+ 47+ ]+ }+ },+ {+ "model": "product.assignedvariantattribute",+ "pk": 21,+ "fields": {+ "variant": 207,+ "assignment": 2,+ "values": [+ 48+ ]+ }+ },+ {+ "model": "product.assignedvariantattribute",+ "pk": 22,+ "fields": {+ "variant": 208,+ "assignment": 2,+ "values": [+ 46+ ]+ }+ },+ {+ "model": "product.assignedvariantattribute",+ "pk": 23,+ "fields": {+ "variant": 209,+ "assignment": 2,+ "values": [+ 47+ ]+ }+ },+ {+ "model": "product.assignedvariantattribute",+ "pk": 24,+ "fields": {+ "variant": 210,+ "assignment": 2,+ "values": [+ 48+ ]+ }+ },+ {+ "model": "product.assignedvariantattribute",+ "pk": 25,+ "fields": {+ "variant": 211,+ "assignment": 2,+ "values": [+ 46+ ]+ }+ },+ {+ "model": "product.assignedvariantattribute",+ "pk": 26,+ "fields": {+ "variant": 213,+ "assignment": 2,+ "values": [+ 48+ ]+ }+ },+ {+ "model": "product.assignedvariantattribute",+ "pk": 27,+ "fields": {+ "variant": 214,+ "assignment": 2,+ "values": [+ 46+ ]+ }+ },+ {+ "model": "product.assignedvariantattribute",+ "pk": 28,+ "fields": {+ "variant": 216,+ "assignment": 2,+ "values": [+ 48+ ]+ }+ },+ {+ "model": "product.assignedvariantattribute",+ "pk": 29,+ "fields": {+ "variant": 217,+ "assignment": 2,+ "values": [+ 46+ ]+ }+ },+ {+ "model": "product.assignedvariantattribute",+ "pk": 30,+ "fields": {+ "variant": 218,+ "assignment": 2,+ "values": [+ 47+ ]+ }+ },+ {+ "model": "product.assignedvariantattribute",+ "pk": 31,+ "fields": {+ "variant": 220,+ "assignment": 2,+ "values": [+ 46+ ]+ }+ },+ {+ "model": "product.assignedvariantattribute",+ "pk": 32,+ "fields": {+ "variant": 221,+ "assignment": 2,+ "values": [+ 47+ ]+ }+ },+ {+ "model": "product.assignedvariantattribute",+ "pk": 33,+ "fields": {+ "variant": 223,+ "assignment": 2,+ "values": [+ 46+ ]+ }+ },+ {+ "model": "product.assignedvariantattribute",+ "pk": 34,+ "fields": {+ "variant": 224,+ "assignment": 2,+ "values": [+ 47+ ]+ }+ },+ {+ "model": "product.assignedvariantattribute",+ "pk": 35,+ "fields": {+ "variant": 225,+ "assignment": 2,+ "values": [+ 48+ ]+ }+ },+ {+ "model": "product.assignedvariantattribute",+ "pk": 36,+ "fields": {+ "variant": 242,+ "assignment": 6,+ "values": [+ 75+ ]+ }+ },+ {+ "model": "product.assignedvariantattribute",+ "pk": 37,+ "fields": {+ "variant": 243,+ "assignment": 6,+ "values": [+ 76+ ]+ }+ },+ {+ "model": "product.assignedvariantattribute",+ "pk": 38,+ "fields": {+ "variant": 248,+ "assignment": 6,+ "values": [+ 77+ ]+ }+ },+ {+ "model": "product.assignedvariantattribute",+ "pk": 39,+ "fields": {+ "variant": 249,+ "assignment": 6,+ "values": [+ 76+ ]+ }+ },+ {+ "model": "product.assignedvariantattribute",+ "pk": 40,+ "fields": {+ "variant": 251,+ "assignment": 1,+ "values": [+ 36+ ]+ }+ },+ {+ "model": "product.assignedvariantattribute",+ "pk": 41,+ "fields": {+ "variant": 252,+ "assignment": 1,+ "values": [+ 37+ ]+ }+ },+ {+ "model": "product.assignedvariantattribute",+ "pk": 42,+ "fields": {+ "variant": 253,+ "assignment": 1,+ "values": [+ 38+ ]+ }+ },+ {+ "model": "product.assignedvariantattribute",+ "pk": 43,+ "fields": {+ "variant": 180,+ "assignment": 3,+ "values": [+ 60+ ]+ }+ },+ {+ "model": "product.assignedvariantattribute",+ "pk": 44,+ "fields": {+ "variant": 202,+ "assignment": 2,+ "values": [+ 46+ ]+ }+ },+ {+ "model": "product.assignedvariantattribute",+ "pk": 45,+ "fields": {+ "variant": 250,+ "assignment": 6,+ "values": [+ 81+ ]+ }+ },+ {+ "model": "product.assignedvariantattribute",+ "pk": 46,+ "fields": {+ "variant": 212,+ "assignment": 2,+ "values": [+ 47+ ]+ }+ },+ {+ "model": "product.assignedvariantattribute",+ "pk": 47,+ "fields": {+ "variant": 244,+ "assignment": 6,+ "values": [+ 77+ ]+ }+ },+ {+ "model": "product.assignedvariantattribute",+ "pk": 48,+ "fields": {+ "variant": 204,+ "assignment": 2,+ "values": [+ 48+ ]+ }+ },+ {+ "model": "product.assignedvariantattribute",+ "pk": 49,+ "fields": {+ "variant": 215,+ "assignment": 2,+ "values": [+ 47+ ]+ }+ },+ {+ "model": "product.assignedvariantattribute",+ "pk": 50,+ "fields": {+ "variant": 171,+ "assignment": 3,+ "values": [+ 60+ ]+ }+ },+ {+ "model": "product.assignedvariantattribute",+ "pk": 51,+ "fields": {+ "variant": 245,+ "assignment": 6,+ "values": [+ 78+ ]+ }+ },+ {+ "model": "product.assignedvariantattribute",+ "pk": 52,+ "fields": {+ "variant": 247,+ "assignment": 6,+ "values": [+ 76+ ]+ }+ },+ {+ "model": "product.assignedvariantattribute",+ "pk": 53,+ "fields": {+ "variant": 203,+ "assignment": 2,+ "values": [+ 47+ ]+ }+ },+ {+ "model": "product.assignedvariantattribute",+ "pk": 54,+ "fields": {+ "variant": 219,+ "assignment": 2,+ "values": [+ 48+ ]+ }+ },+ {+ "model": "product.assignedvariantattribute",+ "pk": 55,+ "fields": {+ "variant": 255,+ "assignment": 1,+ "values": [+ 40+ ]+ }+ },+ {+ "model": "product.assignedvariantattribute",+ "pk": 56,+ "fields": {+ "variant": 256,+ "assignment": 1,+ "values": [+ 36+ ]+ }+ },+ {+ "model": "product.assignedvariantattribute",+ "pk": 57,+ "fields": {+ "variant": 259,+ "assignment": 1,+ "values": [+ 39+ ]+ }+ },+ {+ "model": "product.assignedvariantattribute",+ "pk": 58,+ "fields": {+ "variant": 261,+ "assignment": 1,+ "values": [+ 36+ ]+ }+ },+ {+ "model": "product.assignedvariantattribute",+ "pk": 59,+ "fields": {+ "variant": 263,+ "assignment": 1,+ "values": [+ 38+ ]+ }+ },+ {+ "model": "product.assignedvariantattribute",+ "pk": 60,+ "fields": {+ "variant": 264,+ "assignment": 1,+ "values": [+ 39+ ]+ }+ },+ {+ "model": "product.assignedvariantattribute",+ "pk": 61,+ "fields": {+ "variant": 265,+ "assignment": 1,+ "values": [+ 40+ ]+ }+ },+ {+ "model": "product.assignedvariantattribute",+ "pk": 62,+ "fields": {+ "variant": 266,+ "assignment": 1,+ "values": [+ 36+ ]+ }+ },+ {+ "model": "product.assignedvariantattribute",+ "pk": 63,+ "fields": {+ "variant": 267,+ "assignment": 1,+ "values": [+ 37+ ]+ }+ },+ {+ "model": "product.assignedvariantattribute",+ "pk": 64,+ "fields": {+ "variant": 270,+ "assignment": 1,+ "values": [+ 40+ ]+ }+ },+ {+ "model": "product.assignedvariantattribute",+ "pk": 65,+ "fields": {+ "variant": 271,+ "assignment": 1,+ "values": [+ 36+ ]+ }+ },+ {+ "model": "product.assignedvariantattribute",+ "pk": 66,+ "fields": {+ "variant": 272,+ "assignment": 1,+ "values": [+ 37+ ]+ }+ },+ {+ "model": "product.assignedvariantattribute",+ "pk": 67,+ "fields": {+ "variant": 273,+ "assignment": 1,+ "values": [+ 38+ ]+ }+ },+ {+ "model": "product.assignedvariantattribute",+ "pk": 68,+ "fields": {+ "variant": 275,+ "assignment": 1,+ "values": [+ 40+ ]+ }+ },+ {+ "model": "product.assignedvariantattribute",+ "pk": 69,+ "fields": {+ "variant": 277,+ "assignment": 1,+ "values": [+ 37+ ]+ }+ },+ {+ "model": "product.assignedvariantattribute",+ "pk": 70,+ "fields": {+ "variant": 278,+ "assignment": 1,+ "values": [+ 38+ ]+ }+ },+ {+ "model": "product.assignedvariantattribute",+ "pk": 71,+ "fields": {+ "variant": 280,+ "assignment": 1,+ "values": [+ 40+ ]+ }+ },+ {+ "model": "product.assignedvariantattribute",+ "pk": 72,+ "fields": {+ "variant": 281,+ "assignment": 1,+ "values": [+ 36+ ]+ }+ },+ {+ "model": "product.assignedvariantattribute",+ "pk": 73,+ "fields": {+ "variant": 282,+ "assignment": 1,+ "values": [+ 37+ ]+ }+ },+ {+ "model": "product.assignedvariantattribute",+ "pk": 74,+ "fields": {+ "variant": 283,+ "assignment": 1,+ "values": [+ 38+ ]+ }+ },+ {+ "model": "product.assignedvariantattribute",+ "pk": 75,+ "fields": {+ "variant": 284,+ "assignment": 1,+ "values": [+ 39+ ]+ }+ },+ {+ "model": "product.assignedvariantattribute",+ "pk": 76,+ "fields": {+ "variant": 286,+ "assignment": 1,+ "values": [+ 36+ ]+ }+ },+ {+ "model": "product.assignedvariantattribute",+ "pk": 77,+ "fields": {+ "variant": 287,+ "assignment": 1,+ "values": [+ 37+ ]+ }+ },+ {+ "model": "product.assignedvariantattribute",+ "pk": 78,+ "fields": {+ "variant": 288,+ "assignment": 1,+ "values": [+ 38+ ]+ }+ },+ {+ "model": "product.assignedvariantattribute",+ "pk": 79,+ "fields": {+ "variant": 290,+ "assignment": 1,+ "values": [+ 40+ ]+ }+ },+ {+ "model": "product.assignedvariantattribute",+ "pk": 80,+ "fields": {+ "variant": 291,+ "assignment": 1,+ "values": [+ 36+ ]+ }+ },+ {+ "model": "product.assignedvariantattribute",+ "pk": 81,+ "fields": {+ "variant": 292,+ "assignment": 1,+ "values": [+ 37+ ]+ }+ },+ {+ "model": "product.assignedvariantattribute",+ "pk": 82,+ "fields": {+ "variant": 293,+ "assignment": 1,+ "values": [+ 38+ ]+ }+ },+ {+ "model": "product.assignedvariantattribute",+ "pk": 83,+ "fields": {+ "variant": 296,+ "assignment": 1,+ "values": [+ 36+ ]+ }+ },+ {+ "model": "product.assignedvariantattribute",+ "pk": 84,+ "fields": {+ "variant": 297,+ "assignment": 1,+ "values": [+ 37+ ]+ }+ },+ {+ "model": "product.assignedvariantattribute",+ "pk": 85,+ "fields": {+ "variant": 299,+ "assignment": 1,+ "values": [+ 39+ ]+ }+ },+ {+ "model": "product.assignedvariantattribute",+ "pk": 86,+ "fields": {+ "variant": 302,+ "assignment": 1,+ "values": [+ 37+ ]+ }+ },+ {+ "model": "product.assignedvariantattribute",+ "pk": 87,+ "fields": {+ "variant": 305,+ "assignment": 1,+ "values": [+ 40+ ]+ }+ },+ {+ "model": "product.assignedvariantattribute",+ "pk": 88,+ "fields": {+ "variant": 306,+ "assignment": 1,+ "values": [+ 36+ ]+ }+ },+ {+ "model": "product.assignedvariantattribute",+ "pk": 89,+ "fields": {+ "variant": 308,+ "assignment": 1,+ "values": [+ 38+ ]+ }+ },+ {+ "model": "product.assignedvariantattribute",+ "pk": 90,+ "fields": {+ "variant": 309,+ "assignment": 1,+ "values": [+ 39+ ]+ }+ },+ {+ "model": "product.assignedvariantattribute",+ "pk": 91,+ "fields": {+ "variant": 311,+ "assignment": 1,+ "values": [+ 36+ ]+ }+ },+ {+ "model": "product.assignedvariantattribute",+ "pk": 92,+ "fields": {+ "variant": 312,+ "assignment": 1,+ "values": [+ 37+ ]+ }+ },+ {+ "model": "product.assignedvariantattribute",+ "pk": 93,+ "fields": {+ "variant": 313,+ "assignment": 1,+ "values": [+ 38+ ]+ }+ },+ {+ "model": "product.assignedvariantattribute",+ "pk": 94,+ "fields": {+ "variant": 314,+ "assignment": 1,+ "values": [+ 39+ ]+ }+ },+ {+ "model": "product.assignedvariantattribute",+ "pk": 95,+ "fields": {+ "variant": 315,+ "assignment": 1,+ "values": [+ 40+ ]+ }+ },+ {+ "model": "product.assignedvariantattribute",+ "pk": 96,+ "fields": {+ "variant": 185,+ "assignment": 3,+ "values": [+ 62+ ]+ }+ },+ {+ "model": "product.assignedvariantattribute",+ "pk": 97,+ "fields": {+ "variant": 254,+ "assignment": 1,+ "values": [+ 39+ ]+ }+ },+ {+ "model": "product.assignedvariantattribute",+ "pk": 98,+ "fields": {+ "variant": 260,+ "assignment": 1,+ "values": [+ 40+ ]+ }+ },+ {+ "model": "product.assignedvariantattribute",+ "pk": 99,+ "fields": {+ "variant": 274,+ "assignment": 1,+ "values": [+ 39+ ]+ }+ },+ {+ "model": "product.assignedvariantattribute",+ "pk": 100,+ "fields": {+ "variant": 262,+ "assignment": 1,+ "values": [+ 37+ ]+ }+ },+ {+ "model": "product.assignedvariantattribute",+ "pk": 101,+ "fields": {+ "variant": 310,+ "assignment": 1,+ "values": [+ 40+ ]+ }+ },+ {+ "model": "product.assignedvariantattribute",+ "pk": 102,+ "fields": {+ "variant": 289,+ "assignment": 1,+ "values": [+ 39+ ]+ }+ },+ {+ "model": "product.assignedvariantattribute",+ "pk": 103,+ "fields": {+ "variant": 304,+ "assignment": 1,+ "values": [+ 39+ ]+ }+ },+ {+ "model": "product.assignedvariantattribute",+ "pk": 104,+ "fields": {+ "variant": 268,+ "assignment": 1,+ "values": [+ 38+ ]+ }+ },+ {+ "model": "product.assignedvariantattribute",+ "pk": 105,+ "fields": {+ "variant": 301,+ "assignment": 1,+ "values": [+ 36+ ]+ }+ },+ {+ "model": "product.assignedvariantattribute",+ "pk": 106,+ "fields": {+ "variant": 269,+ "assignment": 1,+ "values": [+ 39+ ]+ }+ },+ {+ "model": "product.assignedvariantattribute",+ "pk": 107,+ "fields": {+ "variant": 303,+ "assignment": 1,+ "values": [+ 38+ ]+ }+ },+ {+ "model": "product.assignedvariantattribute",+ "pk": 108,+ "fields": {+ "variant": 279,+ "assignment": 1,+ "values": [+ 39+ ]+ }+ },+ {+ "model": "product.assignedvariantattribute",+ "pk": 109,+ "fields": {+ "variant": 294,+ "assignment": 1,+ "values": [+ 39+ ]+ }+ },+ {+ "model": "product.assignedvariantattribute",+ "pk": 110,+ "fields": {+ "variant": 300,+ "assignment": 1,+ "values": [+ 40+ ]+ }+ },+ {+ "model": "product.assignedvariantattribute",+ "pk": 111,+ "fields": {+ "variant": 257,+ "assignment": 1,+ "values": [+ 37+ ]+ }+ },+ {+ "model": "product.assignedvariantattribute",+ "pk": 112,+ "fields": {+ "variant": 276,+ "assignment": 1,+ "values": [+ 36+ ]+ }+ },+ {+ "model": "product.assignedvariantattribute",+ "pk": 113,+ "fields": {+ "variant": 298,+ "assignment": 1,+ "values": [+ 38+ ]+ }+ },+ {+ "model": "product.assignedvariantattribute",+ "pk": 114,+ "fields": {+ "variant": 307,+ "assignment": 1,+ "values": [+ 37+ ]+ }+ },+ {+ "model": "product.assignedvariantattribute",+ "pk": 115,"fields": {- "sku": "61630747",- "name": "XXL",- "price_override_amount": null,- "product": 115,- "attributes": "{\"13\": [\"40\"]}",- "track_inventory": true,- "quantity": 5825,- "quantity_allocated": 34,- "cost_price_amount": "10.00",- "currency": "USD",- "weight": "0.0 kg"+ "variant": 258,+ "assignment": 1,+ "values": [+ 38+ ]}},{- "model": "product.productvariant",- "pk": 301,+ "model": "product.assignedvariantattribute",+ "pk": 116,"fields": {- "sku": "15744278",- "name": "S",- "price_override_amount": null,- "product": 116,- "attributes": "{\"13\": [\"36\"]}",- "track_inventory": true,- "quantity": 1213,- "quantity_allocated": 0,- "cost_price_amount": "10.00",- "currency": "USD",- "weight": "0.0 kg"+ "variant": 285,+ "assignment": 1,+ "values": [+ 40+ ]}},{- "model": "product.productvariant",- "pk": 302,+ "model": "product.assignedvariantattribute",+ "pk": 117,"fields": {- "sku": "21599567",- "name": "M",- "price_override_amount": null,- "product": 116,- "attributes": "{\"13\": [\"37\"]}",- "track_inventory": true,- "quantity": 4,- "quantity_allocated": 3,- "cost_price_amount": "10.00",- "currency": "USD",- "weight": "0.0 kg"+ "variant": 295,+ "assignment": 1,+ "values": [+ 40+ ]}},{- "model": "product.productvariant",- "pk": 303,+ "model": "product.assignedvariantattribute",+ "pk": 118,"fields": {- "sku": "65363253",- "name": "L",- "price_override_amount": null,- "product": 116,- "attributes": "{\"13\": [\"38\"]}",- "track_inventory": true,- "quantity": 9820,- "quantity_allocated": 2,- "cost_price_amount": "10.00",- "currency": "USD",- "weight": "0.0 kg"+ "variant": 246,+ "assignment": 6,+ "values": [+ 79+ ]}},{- "model": "product.productvariant",- "pk": 304,+ "model": "product.assignedvariantattribute",+ "pk": 119,"fields": {- "sku": "51987722",- "name": "XL",- "price_override_amount": null,- "product": 116,- "attributes": "{\"13\": [\"39\"]}",- "track_inventory": true,- "quantity": 1,- "quantity_allocated": 0,- "cost_price_amount": "10.00",- "currency": "USD",- "weight": "0.0 kg"+ "variant": 222,+ "assignment": 2,+ "values": [+ 48+ ]}},{- "model": "product.productvariant",- "pk": 305,+ "model": "product.assignedvariantattribute",+ "pk": 120,"fields": {- "sku": "43313080",- "name": "XXL",- "price_override_amount": null,- "product": 116,- "attributes": "{\"13\": [\"40\"]}",- "track_inventory": true,- "quantity": 5805,- "quantity_allocated": 14,- "cost_price_amount": "10.00",- "currency": "USD",- "weight": "0.0 kg"+ "variant": 182,+ "assignment": 3,+ "values": [+ 62+ ]}},{- "model": "product.productvariant",- "pk": 306,+ "model": "product.attributeproduct",+ "pk": 1,"fields": {- "sku": "33963052",- "name": "S",- "price_override_amount": null,- "product": 117,- "attributes": "{\"13\": [\"36\"]}",- "track_inventory": true,- "quantity": 1218,- "quantity_allocated": 5,- "cost_price_amount": "10.00",- "currency": "USD",- "weight": "0.0 kg"+ "sort_order": null,+ "attribute": 16,+ "product_type": 9}},{- "model": "product.productvariant",- "pk": 307,+ "model": "product.attributeproduct",+ "pk": 2,"fields": {- "sku": "66846240",- "name": "M",- "price_override_amount": null,- "product": 117,- "attributes": "{\"13\": [\"37\"]}",- "track_inventory": true,- "quantity": 11,- "quantity_allocated": 10,- "cost_price_amount": "10.00",- "currency": "USD",- "weight": "0.0 kg"+ "sort_order": null,+ "attribute": 20,+ "product_type": 10}},{- "model": "product.productvariant",- "pk": 308,+ "model": "product.attributeproduct",+ "pk": 3,"fields": {- "sku": "55365141",- "name": "L",- "price_override_amount": null,- "product": 117,- "attributes": "{\"13\": [\"38\"]}",- "track_inventory": true,- "quantity": 9823,- "quantity_allocated": 5,- "cost_price_amount": "10.00",- "currency": "USD",- "weight": "0.0 kg"+ "sort_order": null,+ "attribute": 21,+ "product_type": 11}},{- "model": "product.productvariant",- "pk": 309,+ "model": "product.attributeproduct",+ "pk": 4,"fields": {- "sku": "73186143",- "name": "XL",- "price_override_amount": null,- "product": 117,- "attributes": "{\"13\": [\"39\"]}",- "track_inventory": true,- "quantity": 1,- "quantity_allocated": 0,- "cost_price_amount": "10.00",- "currency": "USD",- "weight": "0.0 kg"+ "sort_order": null,+ "attribute": 23,+ "product_type": 12}},{- "model": "product.productvariant",- "pk": 310,+ "model": "product.attributeproduct",+ "pk": 5,"fields": {- "sku": "42651772",- "name": "XXL",- "price_override_amount": null,- "product": 117,- "attributes": "{\"13\": [\"40\"]}",- "track_inventory": true,- "quantity": 5805,- "quantity_allocated": 14,- "cost_price_amount": "10.00",- "currency": "USD",- "weight": "0.0 kg"+ "sort_order": null,+ "attribute": 25,+ "product_type": 14}},{- "model": "product.productvariant",- "pk": 311,+ "model": "product.attributevariant",+ "pk": 1,"fields": {- "sku": "70760297",- "name": "S",- "price_override_amount": null,- "product": 118,- "attributes": "{\"13\": [\"36\"]}",- "track_inventory": true,- "quantity": 1213,- "quantity_allocated": 0,- "cost_price_amount": "10.00",- "currency": "USD",- "weight": "0.0 kg"+ "sort_order": null,+ "attribute": 13,+ "product_type": 14}},{- "model": "product.productvariant",- "pk": 312,+ "model": "product.attributevariant",+ "pk": 2,"fields": {- "sku": "36334412",- "name": "M",- "price_override_amount": null,- "product": 118,- "attributes": "{\"13\": [\"37\"]}",- "track_inventory": true,- "quantity": 10,- "quantity_allocated": 9,- "cost_price_amount": "10.00",- "currency": "USD",- "weight": "0.0 kg"+ "sort_order": null,+ "attribute": 15,+ "product_type": 9}},{- "model": "product.productvariant",- "pk": 313,+ "model": "product.attributevariant",+ "pk": 3,"fields": {- "sku": "35994675",- "name": "L",- "price_override_amount": null,- "product": 118,- "attributes": "{\"13\": [\"38\"]}",- "track_inventory": true,- "quantity": 9818,- "quantity_allocated": 0,- "cost_price_amount": "10.00",- "currency": "USD",- "weight": "0.0 kg"+ "sort_order": null,+ "attribute": 18,+ "product_type": 7}},{- "model": "product.productvariant",- "pk": 314,+ "model": "product.attributevariant",+ "pk": 4,"fields": {- "sku": "10404946",- "name": "XL",- "price_override_amount": null,- "product": 118,- "attributes": "{\"13\": [\"39\"]}",- "track_inventory": true,- "quantity": 3,- "quantity_allocated": 2,- "cost_price_amount": "10.00",- "currency": "USD",- "weight": "0.0 kg"+ "sort_order": null,+ "attribute": 19,+ "product_type": 8}},{- "model": "product.productvariant",- "pk": 315,+ "model": "product.attributevariant",+ "pk": 5,"fields": {- "sku": "45507483",- "name": "XXL",- "price_override_amount": null,- "product": 118,- "attributes": "{\"13\": [\"40\"]}",- "track_inventory": true,- "quantity": 5818,- "quantity_allocated": 27,- "cost_price_amount": "10.00",- "currency": "USD",- "weight": "0.0 kg"+ "sort_order": null,+ "attribute": 22,+ "product_type": 12+ }+ },+ {+ "model": "product.attributevariant",+ "pk": 6,+ "fields": {+ "sort_order": null,+ "attribute": 24,+ "product_type": 13}},{"model": "product.attribute","pk": 13,"fields": {+ "private_meta": {},+ "meta": {},"slug": "size","name": "Size",- "product_type": null,- "product_variant_type": 14+ "input_type": "dropdown",+ "value_required": false,+ "is_variant_only": false,+ "visible_in_storefront": true,+ "filterable_in_storefront": true,+ "filterable_in_dashboard": true,+ "storefront_search_position": 0,+ "available_in_grid": true}},{"model": "product.attribute","pk": 14,"fields": {+ "private_meta": {},+ "meta": {},"slug": "color","name": "Color",- "product_type": null,- "product_variant_type": null+ "input_type": "dropdown",+ "value_required": false,+ "is_variant_only": false,+ "visible_in_storefront": true,+ "filterable_in_storefront": true,+ "filterable_in_dashboard": true,+ "storefront_search_position": 0,+ "available_in_grid": true}},{"model": "product.attribute","pk": 15,"fields": {+ "private_meta": {},+ "meta": {},"slug": "bottle-size","name": "Size",- "product_type": null,- "product_variant_type": 9+ "input_type": "dropdown",+ "value_required": false,+ "is_variant_only": false,+ "visible_in_storefront": true,+ "filterable_in_storefront": true,+ "filterable_in_dashboard": true,+ "storefront_search_position": 0,+ "available_in_grid": true}},{"model": "product.attribute","pk": 16,"fields": {+ "private_meta": {},+ "meta": {},"slug": "flavor","name": "Flavor",- "product_type": 9,- "product_variant_type": null+ "input_type": "dropdown",+ "value_required": false,+ "is_variant_only": false,+ "visible_in_storefront": true,+ "filterable_in_storefront": true,+ "filterable_in_dashboard": true,+ "storefront_search_position": 0,+ "available_in_grid": true}},{"model": "product.attribute","pk": 18,"fields": {+ "private_meta": {},+ "meta": {},"slug": "bucket-size","name": "Size",- "product_type": null,- "product_variant_type": 7+ "input_type": "dropdown",+ "value_required": false,+ "is_variant_only": false,+ "visible_in_storefront": true,+ "filterable_in_storefront": true,+ "filterable_in_dashboard": true,+ "storefront_search_position": 0,+ "available_in_grid": true}},{"model": "product.attribute","pk": 19,"fields": {+ "private_meta": {},+ "meta": {},"slug": "medium","name": "Medium",- "product_type": null,- "product_variant_type": 8+ "input_type": "dropdown",+ "value_required": false,+ "is_variant_only": false,+ "visible_in_storefront": true,+ "filterable_in_storefront": true,+ "filterable_in_dashboard": true,+ "storefront_search_position": 0,+ "available_in_grid": true}},{"model": "product.attribute","pk": 20,"fields": {+ "private_meta": {},+ "meta": {},"slug": "volume","name": "Volume",- "product_type": 10,- "product_variant_type": null+ "input_type": "dropdown",+ "value_required": false,+ "is_variant_only": false,+ "visible_in_storefront": true,+ "filterable_in_storefront": true,+ "filterable_in_dashboard": true,+ "storefront_search_position": 0,+ "available_in_grid": true}},{"model": "product.attribute","pk": 21,"fields": {+ "private_meta": {},+ "meta": {},"slug": "abv","name": "ABV",- "product_type": 11,- "product_variant_type": null+ "input_type": "dropdown",+ "value_required": false,+ "is_variant_only": false,+ "visible_in_storefront": true,+ "filterable_in_storefront": true,+ "filterable_in_dashboard": true,+ "storefront_search_position": 0,+ "available_in_grid": true}},{"model": "product.attribute","pk": 22,"fields": {+ "private_meta": {},+ "meta": {},"slug": "cushion-size","name": "Size",- "product_type": null,- "product_variant_type": 12+ "input_type": "dropdown",+ "value_required": false,+ "is_variant_only": false,+ "visible_in_storefront": true,+ "filterable_in_storefront": true,+ "filterable_in_dashboard": true,+ "storefront_search_position": 0,+ "available_in_grid": true}},{"model": "product.attribute","pk": 23,"fields": {+ "private_meta": {},+ "meta": {},"slug": "material","name": "Material",- "product_type": 12,- "product_variant_type": null+ "input_type": "dropdown",+ "value_required": false,+ "is_variant_only": false,+ "visible_in_storefront": true,+ "filterable_in_storefront": true,+ "filterable_in_dashboard": true,+ "storefront_search_position": 0,+ "available_in_grid": true}},{"model": "product.attribute","pk": 24,"fields": {+ "private_meta": {},+ "meta": {},"slug": "shoe-size","name": "Shoe size",- "product_type": null,- "product_variant_type": 13+ "input_type": "dropdown",+ "value_required": false,+ "is_variant_only": false,+ "visible_in_storefront": true,+ "filterable_in_storefront": true,+ "filterable_in_dashboard": true,+ "storefront_search_position": 0,+ "available_in_grid": true}},{"model": "product.attribute","pk": 25,"fields": {+ "private_meta": {},+ "meta": {},"slug": "shirt-material","name": "Material",- "product_type": 14,- "product_variant_type": null+ "input_type": "dropdown",+ "value_required": false,+ "is_variant_only": false,+ "visible_in_storefront": true,+ "filterable_in_storefront": true,+ "filterable_in_dashboard": true,+ "storefront_search_position": 0,+ "available_in_grid": true}},{@@ -4132,7 +6442,7 @@"fields": {"sort_order": 0,"product": 61,- "image": "products/saleordemoproduct_paints_01_oDLxDCy.png",+ "image": "products/saleordemoproduct_paints_01_7vI9FvB.png","ppoi": "0.5x0.5","alt": ""}@@ -4143,7 +6453,7 @@"fields": {"sort_order": 0,"product": 62,- "image": "products/saleordemoproduct_paints_02_dYeeCcU.png",+ "image": "products/saleordemoproduct_paints_02_nHXdsQn.png","ppoi": "0.5x0.5","alt": ""}@@ -4154,7 +6464,7 @@"fields": {"sort_order": 0,"product": 63,- "image": "products/saleordemoproduct_paints_03_ecuGs1J.png",+ "image": "products/saleordemoproduct_paints_03_MGZrCRQ.png","ppoi": "0.5x0.5","alt": ""}@@ -4165,7 +6475,7 @@"fields": {"sort_order": 0,"product": 64,- "image": "products/saleordemoproduct_paints_04_I0scMFo.png",+ "image": "products/saleordemoproduct_paints_04_uDFksth.png","ppoi": "0.5x0.5","alt": ""}@@ -4176,7 +6486,7 @@"fields": {"sort_order": 0,"product": 65,- "image": "products/saleordemoproduct_paints_05_uUmCypw.png",+ "image": "products/saleordemoproduct_paints_05_KU5gJYl.png","ppoi": "0.5x0.5","alt": ""}@@ -4187,7 +6497,7 @@"fields": {"sort_order": 0,"product": 71,- "image": "products/saleordemoproduct_fd_juice_06_HmbdNY4.png",+ "image": "products/saleordemoproduct_fd_juice_06_cuGnbia.png","ppoi": "0.5x0.5","alt": ""}@@ -4198,7 +6508,7 @@"fields": {"sort_order": 0,"product": 72,- "image": "products/saleordemoproduct_fd_juice_06_6xzhMf1.png",+ "image": "products/saleordemoproduct_fd_juice_06_EteAThX.png","ppoi": "0.5x0.5","alt": ""}@@ -4209,7 +6519,7 @@"fields": {"sort_order": 0,"product": 73,- "image": "products/saleordemoproduct_fd_juice_05_IJL7VJy.png",+ "image": "products/saleordemoproduct_fd_juice_05_9Zvpe9Q.png","ppoi": "0.5x0.5","alt": ""}@@ -4220,7 +6530,7 @@"fields": {"sort_order": 0,"product": 74,- "image": "products/saleordemoproduct_fd_juice_01_YXqoj52.png",+ "image": "products/saleordemoproduct_fd_juice_01_2lJ7TV6.png","ppoi": "0.5x0.5","alt": ""}@@ -4231,7 +6541,7 @@"fields": {"sort_order": 0,"product": 75,- "image": "products/saleordemoproduct_fd_juice_03_daLOjXa.png",+ "image": "products/saleordemoproduct_fd_juice_03_ZWOta7i.png","ppoi": "0.5x0.5","alt": ""}@@ -4242,7 +6552,7 @@"fields": {"sort_order": 0,"product": 76,- "image": "products/saleordemoproduct_fd_juice_02_Bom9fYH.png",+ "image": "products/saleordemoproduct_fd_juice_02_Pg3tafK.png","ppoi": "0.5x0.5","alt": ""}@@ -4253,7 +6563,7 @@"fields": {"sort_order": 0,"product": 77,- "image": "products/saleordemoproduct_fd_juice_03_9VGzlb8.png",+ "image": "products/saleordemoproduct_fd_juice_03_bSfwNS7.png","ppoi": "0.5x0.5","alt": ""}@@ -4264,7 +6574,7 @@"fields": {"sort_order": 0,"product": 78,- "image": "products/saleordemoproduct_fd_juice_04_EBNnBub.png",+ "image": "products/saleordemoproduct_fd_juice_04_gvugtVI.png","ppoi": "0.5x0.5","alt": ""}@@ -4275,7 +6585,7 @@"fields": {"sort_order": 0,"product": 79,- "image": "products/saleordemoproduct_fd_juice_02_7aTGENJ.png",+ "image": "products/saleordemoproduct_fd_juice_02_LBxwBFY.png","ppoi": "0.5x0.5","alt": ""}@@ -4286,7 +6596,7 @@"fields": {"sort_order": 0,"product": 81,- "image": "products/saleordemoproduct_wine-red_L78mDRW.png",+ "image": "products/saleordemoproduct_wine-red_P3mkIbz.png","ppoi": "0.5x0.5","alt": ""}@@ -4297,7 +6607,7 @@"fields": {"sort_order": 0,"product": 82,- "image": "products/saleordemoproduct_wine-white_1MuPoeA.png",+ "image": "products/saleordemoproduct_wine-white_BHDQUdV.png","ppoi": "0.5x0.5","alt": ""}@@ -4308,7 +6618,7 @@"fields": {"sort_order": 0,"product": 83,- "image": "products/saleordemoproduct_beer-02_1_oN44DoF.png",+ "image": "products/saleordemoproduct_beer-02_1_QYSPIp8.png","ppoi": "0.5x0.5","alt": ""}@@ -4319,7 +6629,7 @@"fields": {"sort_order": 1,"product": 83,- "image": "products/saleordemoproduct_beer-02_2_QTLg6Ak.png",+ "image": "products/saleordemoproduct_beer-02_2_815xJtF.png","ppoi": "0.5x0.5","alt": ""}@@ -4330,7 +6640,7 @@"fields": {"sort_order": 0,"product": 84,- "image": "products/saleordemoproduct_beer-01_1_4L2SEHt.png",+ "image": "products/saleordemoproduct_beer-01_1_bZ3wodn.png","ppoi": "0.5x0.5","alt": ""}@@ -4341,7 +6651,7 @@"fields": {"sort_order": 1,"product": 84,- "image": "products/saleordemoproduct_beer-01_2_7EIUR1Y.png",+ "image": "products/saleordemoproduct_beer-01_2_01ew0Ui.png","ppoi": "0.5x0.5","alt": ""}@@ -4352,7 +6662,7 @@"fields": {"sort_order": 0,"product": 85,- "image": "products/saleordemoproduct_cuschion01_oH3nVyE.png",+ "image": "products/saleordemoproduct_cuschion01_sfLrKRT.png","ppoi": "0.5x0.5","alt": ""}@@ -4363,7 +6673,7 @@"fields": {"sort_order": 0,"product": 86,- "image": "products/saleordemoproduct_cuschion02_0Ffs5uM.png",+ "image": "products/saleordemoproduct_cuschion02_TwaTBbL.png","ppoi": "0.5x0.5","alt": ""}@@ -4374,7 +6684,7 @@"fields": {"sort_order": 0,"product": 87,- "image": "products/saleordemoproduct_sneakers_01_1_XvwtpKL.png",+ "image": "products/saleordemoproduct_sneakers_01_1_jFoyZg5.png","ppoi": "0.5x0.5","alt": ""}@@ -4385,7 +6695,7 @@"fields": {"sort_order": 1,"product": 87,- "image": "products/saleordemoproduct_sneakers_01_2_MGs9tPf.png",+ "image": "products/saleordemoproduct_sneakers_01_2_BbSZmMc.png","ppoi": "0.5x0.5","alt": ""}@@ -4396,7 +6706,7 @@"fields": {"sort_order": 2,"product": 87,- "image": "products/saleordemoproduct_sneakers_01_3_Ashbw90.png",+ "image": "products/saleordemoproduct_sneakers_01_3_AJ3AcpX.png","ppoi": "0.5x0.5","alt": ""}@@ -4407,7 +6717,7 @@"fields": {"sort_order": 3,"product": 87,- "image": "products/saleordemoproduct_sneakers_01_4_Nsfi7nb.png",+ "image": "products/saleordemoproduct_sneakers_01_4_58U6yFU.png","ppoi": "0.5x0.5","alt": ""}@@ -4418,7 +6728,7 @@"fields": {"sort_order": 0,"product": 88,- "image": "products/saleordemoproduct_sneakers_02_1_0NmWUHZ.png",+ "image": "products/saleordemoproduct_sneakers_02_1_Cx0U1J2.png","ppoi": "0.5x0.5","alt": ""}@@ -4429,7 +6739,7 @@"fields": {"sort_order": 1,"product": 88,- "image": "products/saleordemoproduct_sneakers_02_2_YhRTBfj.png",+ "image": "products/saleordemoproduct_sneakers_02_2_93xpuCe.png","ppoi": "0.5x0.5","alt": ""}@@ -4440,7 +6750,7 @@"fields": {"sort_order": 2,"product": 88,- "image": "products/saleordemoproduct_sneakers_02_3_08YgqUk.png",+ "image": "products/saleordemoproduct_sneakers_02_3_o70p10x.png","ppoi": "0.5x0.5","alt": ""}@@ -4451,7 +6761,7 @@"fields": {"sort_order": 3,"product": 88,- "image": "products/saleordemoproduct_sneakers_02_4_w8mSSO0.png",+ "image": "products/saleordemoproduct_sneakers_02_4_wvAHwA6.png","ppoi": "0.5x0.5","alt": ""}@@ -4462,7 +6772,7 @@"fields": {"sort_order": 0,"product": 89,- "image": "products/saleordemoproduct_cl_boot07_1_e8sCf37.png",+ "image": "products/saleordemoproduct_cl_boot07_1_UPTyhEY.png","ppoi": "0.5x0.5","alt": ""}@@ -4473,7 +6783,7 @@"fields": {"sort_order": 1,"product": 89,- "image": "products/saleordemoproduct_cl_boot07_2_AKDlzhy.png",+ "image": "products/saleordemoproduct_cl_boot07_2_3vgqnlJ.png","ppoi": "0.5x0.5","alt": ""}@@ -4484,7 +6794,7 @@"fields": {"sort_order": 0,"product": 107,- "image": "products/saleordemoproduct_cl_polo01_QW0gy1O.png",+ "image": "products/saleordemoproduct_cl_polo01_qZTBa1O.png","ppoi": "0.5x0.5","alt": ""}@@ -4495,7 +6805,7 @@"fields": {"sort_order": 0,"product": 108,- "image": "products/saleordemoproduct_cl_polo02_v8M2QAi.png",+ "image": "products/saleordemoproduct_cl_polo02_p6dCEu7.png","ppoi": "0.5x0.5","alt": ""}@@ -4506,7 +6816,7 @@"fields": {"sort_order": 0,"product": 109,- "image": "products/saleordemoproduct_cl_polo03-woman_oRoDSw5.png",+ "image": "products/saleordemoproduct_cl_polo03-woman_Ofwi9A2.png","ppoi": "0.5x0.5","alt": ""}@@ -4517,7 +6827,7 @@"fields": {"sort_order": 0,"product": 110,- "image": "products/saleordemoproduct_cl_polo04-woman_yGAtCeK.png",+ "image": "products/saleordemoproduct_cl_polo04-woman_4PdB3Og.png","ppoi": "0.5x0.5","alt": ""}@@ -4528,7 +6838,7 @@"fields": {"sort_order": 0,"product": 111,- "image": "products/saleordemoproduct_cl_boot01_1_jI02bAX.png",+ "image": "products/saleordemoproduct_cl_boot01_1_1GR5f4z.png","ppoi": "0.5x0.5","alt": ""}@@ -4539,7 +6849,7 @@"fields": {"sort_order": 1,"product": 111,- "image": "products/saleordemoproduct_cl_boot01_2_KLnOyhb.png",+ "image": "products/saleordemoproduct_cl_boot01_2_hDLbJKA.png","ppoi": "0.5x0.5","alt": ""}@@ -4550,7 +6860,7 @@"fields": {"sort_order": 2,"product": 111,- "image": "products/saleordemoproduct_cl_boot01_3_Xjg8APp.png",+ "image": "products/saleordemoproduct_cl_boot01_3_SsARVuB.png","ppoi": "0.5x0.5","alt": ""}@@ -4561,7 +6871,7 @@"fields": {"sort_order": 0,"product": 112,- "image": "products/saleordemoproduct_cl_boot03_1_ywqz7uH.png",+ "image": "products/saleordemoproduct_cl_boot03_1_DV27DC4.png","ppoi": "0.5x0.5","alt": ""}@@ -4572,7 +6882,7 @@"fields": {"sort_order": 1,"product": 112,- "image": "products/saleordemoproduct_cl_boot03_2_wV7k4pO.png",+ "image": "products/saleordemoproduct_cl_boot03_2_84NrkDb.png","ppoi": "0.5x0.5","alt": ""}@@ -4583,7 +6893,7 @@"fields": {"sort_order": 0,"product": 113,- "image": "products/saleordemoproduct_cl_boot06_1_4bsW9kx.png",+ "image": "products/saleordemoproduct_cl_boot06_1_v8cLcP3.png","ppoi": "0.5x0.5","alt": ""}@@ -4594,7 +6904,7 @@"fields": {"sort_order": 1,"product": 113,- "image": "products/saleordemoproduct_cl_boot06_2_0RCGicU.png",+ "image": "products/saleordemoproduct_cl_boot06_2_3xLmb6u.png","ppoi": "0.5x0.5","alt": ""}@@ -4605,7 +6915,7 @@"fields": {"sort_order": 0,"product": 114,- "image": "products/saleordemoproduct_cl_boot06_1_cYlPLAW.png",+ "image": "products/saleordemoproduct_cl_boot06_1_7tQP2Hq.png","ppoi": "0.5x0.5","alt": ""}@@ -4616,7 +6926,7 @@"fields": {"sort_order": 1,"product": 114,- "image": "products/saleordemoproduct_cl_boot06_2_N2UbilJ.png",+ "image": "products/saleordemoproduct_cl_boot06_2_tZGlON1.png","ppoi": "0.5x0.5","alt": ""}@@ -4627,7 +6937,7 @@"fields": {"sort_order": 0,"product": 115,- "image": "products/saleordemoproduct_cl_bogo01_1_CyHpJvU.png",+ "image": "products/saleordemoproduct_cl_bogo01_1_koZxYUl.png","ppoi": "0.5x0.5","alt": ""}@@ -4638,7 +6948,7 @@"fields": {"sort_order": 0,"product": 116,- "image": "products/saleordemoproduct_cl_bogo02_1_HaTZ5us.png",+ "image": "products/saleordemoproduct_cl_bogo02_1_pBkAz77.png","ppoi": "0.5x0.5","alt": ""}@@ -4649,7 +6959,7 @@"fields": {"sort_order": 0,"product": 117,- "image": "products/saleordemoproduct_cl_bogo03_1_Zt5it75.png",+ "image": "products/saleordemoproduct_cl_bogo03_1_2X74Yts.png","ppoi": "0.5x0.5","alt": ""}@@ -4660,7 +6970,7 @@"fields": {"sort_order": 0,"product": 118,- "image": "products/saleordemoproduct_cl_bogo04_1_QZj7pyB.png",+ "image": "products/saleordemoproduct_cl_bogo04_1_7jooy9G.png","ppoi": "0.5x0.5","alt": ""}@@ -4671,22 +6981,96 @@"fields": {"sort_order": 1,"product": 118,- "image": "products/saleordemoproduct_cl_bogo04_2_NxSedt9.png",+ "image": "products/saleordemoproduct_cl_bogo04_2_boRk0JG.png","ppoi": "0.5x0.5","alt": ""}},+ {+ "model": "product.collectionproduct",+ "pk": 1,+ "fields": {+ "sort_order": null,+ "collection": 1,+ "product": 73+ }+ },+ {+ "model": "product.collectionproduct",+ "pk": 2,+ "fields": {+ "sort_order": null,+ "collection": 1,+ "product": 83+ }+ },+ {+ "model": "product.collectionproduct",+ "pk": 3,+ "fields": {+ "sort_order": null,+ "collection": 1,+ "product": 110+ }+ },+ {+ "model": "product.collectionproduct",+ "pk": 4,+ "fields": {+ "sort_order": null,+ "collection": 1,+ "product": 86+ }+ },+ {+ "model": "product.collectionproduct",+ "pk": 5,+ "fields": {+ "sort_order": null,+ "collection": 2,+ "product": 83+ }+ },+ {+ "model": "product.collectionproduct",+ "pk": 6,+ "fields": {+ "sort_order": null,+ "collection": 2,+ "product": 84+ }+ },+ {+ "model": "product.collectionproduct",+ "pk": 7,+ "fields": {+ "sort_order": null,+ "collection": 2,+ "product": 61+ }+ },+ {+ "model": "product.collectionproduct",+ "pk": 8,+ "fields": {+ "sort_order": null,+ "collection": 2,+ "product": 110+ }+ },{"model": "product.collection","pk": 1,"fields": {"publication_date": null,"is_published": true,+ "private_meta": {},+ "meta": {},"seo_title": null,"seo_description": null,"name": "Summer collection","slug": "summer-collection",- "background_image": "collection-backgrounds/summer_O96Ivuv.jpg",+ "background_image": "collection-backgrounds/summer_yGCFxQS.jpg","background_image_alt": "","description": "The Saleor Summer Collection features a range of products that feel the heat of the market. A demo store for all seasons. Saleor captures the open source, e-commerce sun.","description_json": {@@ -4702,8 +7086,7 @@}],"entityMap": {}- },- "products": [73, 110, 83, 86]+ }}},{@@ -4712,11 +7095,13 @@"fields": {"publication_date": null,"is_published": true,+ "private_meta": {},+ "meta": {},"seo_title": null,"seo_description": null,"name": "Winter sale","slug": "winter-sale",- "background_image": "collection-backgrounds/clothing_TuZmZFT.jpg",+ "background_image": "collection-backgrounds/clothing_ex4tR4i.jpg","background_image_alt": "","description": "The Saleor Winter Sale is snowed under with seasonal offers. Unreal products at unreal prices. Literally, they are not real products, but the Saleor demo store is a genuine e-commerce leader.","description_json": {@@ -4732,8 +7117,7 @@}],"entityMap": {}- },- "products": [61, 110, 84, 83]+ }}}]diff --git a/templates/product/details.html b/templates/product/details.htmlindex bcfcccae59..8f39bce5ac 100644--- a/templates/product/details.html+++ b/templates/product/details.html@@ -198,11 +198,19 @@</div><hr><table>- {% for attribute, value in product_attributes.items %}- <tr>- <td>{{ attribute.translated }}:</td>- <td><strong>{{ value }}</strong></td>- </tr>+ {% for attribute_rel in product.attributes.all %}+ {% with attribute=attribute_rel.attribute %}+ <tr>+ <td>{{ attribute.translated }}:</td>+ <td>+ <strong>+ {% for value in attribute_rel.values.all %}+ {{ value.translated }}{% if not forloop.last %},{% endif %}+ {% endfor %}+ </strong>+ </td>+ </tr>+ {% endwith %}{% endfor %}</table></div>diff --git a/tests/api/conftest.py b/tests/api/conftest.pyindex 2c825eaac8..df14a22dce 100644--- a/tests/api/conftest.py+++ b/tests/api/conftest.py@@ -21,6 +21,8 @@ class ApiClient(Client):def __init__(self, *args, **kwargs):user = kwargs.pop("user", AnonymousUser())service_account = kwargs.pop("service_account", None)+ self._user = None+ self.token = Noneself.user = userself.service_token = Noneif not user.is_anonymous:@@ -32,11 +34,21 @@ class ApiClient(Client):def _base_environ(self, **request):environ = super()._base_environ(**request)if not self.user.is_anonymous:- environ.update({"HTTP_AUTHORIZATION": "JWT %s" % self.token})+ environ["HTTP_AUTHORIZATION"] = f"JWT {self.token}"elif self.service_token:- environ.update({"HTTP_AUTHORIZATION": "Bearer %s" % self.service_token})+ environ["HTTP_AUTHORIZATION"] = f"Bearer {self.service_token}"return environ+ @property+ def user(self):+ return self._user++ @user.setter+ def user(self, user):+ self._user = user+ if not user.is_anonymous:+ self.token = get_token(user)+def post(self, data=None, **kwargs):"""Send a POST request.diff --git a/tests/api/test_attributes.py b/tests/api/test_attributes.pyindex e6a616014d..c2b1123b22 100644--- a/tests/api/test_attributes.py+++ b/tests/api/test_attributes.py@@ -11,8 +11,6 @@ from saleor.graphql.core.utils import snake_to_camel_casefrom saleor.graphql.product.enums import AttributeTypeEnum, AttributeValueTypefrom saleor.graphql.product.mutations.attributes import validate_value_is_uniquefrom saleor.graphql.product.types.attributes import resolve_attribute_value_type-from saleor.graphql.product.types.products import resolve_attribute_list-from saleor.graphql.product.utils import attributes_to_jsonfrom saleor.product import AttributeInputTypefrom saleor.product.models import (Attribute,@@ -20,8 +18,11 @@ from saleor.product.models import (AttributeValue,AttributeVariant,Category,+ Product,ProductType,+ ProductVariant,)+from saleor.product.utils.attributes import associate_attribute_values_to_instancefrom tests.api.utils import get_graphql_content@@ -41,148 +42,6 @@ def test_validate_value_is_unique(color_attribute):validate_value_is_unique(color_attribute, value)-def test_attributes_to_json(product, color_attribute, size_attribute):- attribute_values_count = AttributeValue.objects.count()-- attribute_id = graphene.Node.to_global_id("Attribute", color_attribute.id)- color_value = color_attribute.values.first()-- # test transforming slugs of existing attributes to IDs- input_data = [{"id": attribute_id, "values": [color_value.slug]}]- attrs_qs = product.product_type.product_attributes.all()- ids = attributes_to_json(input_data, attrs_qs)- assert str(color_attribute.pk) in ids- assert ids[str(color_attribute.pk)] == [str(color_value.pk)]- assert (- AttributeValue.objects.count() == attribute_values_count- ), "No new values should been created"-- # test creating a new attribute value- input_data = [{"id": attribute_id, "values": ["Space Grey"]}]- ids = attributes_to_json(input_data, attrs_qs)- new_value = AttributeValue.objects.get(slug="space-grey")- attribute_values_count += 1- assert str(color_attribute.pk) in ids- assert ids[str(color_attribute.pk)] == [str(new_value.pk)]-- # test passing the newly created value by slug- input_data = [{"id": attribute_id, "values": ["space-grey"]}]- attributes_to_json(input_data, attrs_qs)- assert (- AttributeValue.objects.count() == attribute_values_count- ), "Only one new value should have been created"---# WARNING: Passing by slug will be dropped in a future release-# This test can be safely removed on the field is dropped.-def test_attributes_to_json_passing_by_slug(product, color_attribute):- color_value = color_attribute.values.first()-- # test transforming slugs of existing attributes to IDs- input_data = [{"slug": color_attribute.slug, "values": [color_value.slug]}]- attrs_qs = product.product_type.product_attributes.all()- ids = attributes_to_json(input_data, attrs_qs)- assert str(color_attribute.pk) in ids- assert ids[str(color_attribute.pk)] == [str(color_value.pk)]-- # test creating a new attribute value- input_data = [{"slug": color_attribute.slug, "values": ["Space Grey"]}]- ids = attributes_to_json(input_data, attrs_qs)- new_value = AttributeValue.objects.get(slug="space-grey")- assert str(color_attribute.pk) in ids- assert ids[str(color_attribute.pk)] == [str(new_value.pk)]-- # test passing an attribute that doesn't belong to this product raises- # an error- input_data = [{"slug": "no-existing", "values": ["not-a-value"]}]- with pytest.raises(ValueError) as exc:- attributes_to_json(input_data, attrs_qs)- assert exc.value.args == (- "The given attribute doesn't belong to given product type.",- )--[email protected]("input", ([{"slug": "color", "values": []}], []))-def test_attributes_to_json_missing_required_value(product, color_attribute, input):- # A value is required- color_attribute.value_required = True- color_attribute.save(update_fields=["value_required"])-- # test transforming slugs of existing attributes to IDs- attrs_qs = product.product_type.product_attributes.all()-- with pytest.raises(ValueError) as exc:- attributes_to_json(input, attrs_qs)- assert exc.value.args == ("color expects a value but none were given",)---def test_attributes_to_json_id_not_in_product_type(product, size_attribute):- attrs_qs = product.product_type.product_attributes.all()-- # Pass an id not belonging to the product type- input_data = [- {- "id": graphene.Node.to_global_id("Attribute", size_attribute.pk),- "values": ["a-value"],- }- ]- with pytest.raises(ValueError) as exc:- attributes_to_json(input_data, attrs_qs)- assert exc.value.args == (- "The given attribute doesn't belong to given product type.",- )---def test_attributes_to_json_invalid_id_type(product):- attrs_qs = product.product_type.product_attributes.all()- invalid_id = graphene.Node.to_global_id("Invalid", 1)-- # Pass an id of invalid type- input_data = [{"id": invalid_id, "values": ["a-value"]}]- with pytest.raises(ValueError) as exc:- attributes_to_json(input_data, attrs_qs)- assert exc.value.args == (f"Couldn't resolve to a node: {invalid_id}",)---def test_attributes_to_json_without_values(product, color_attribute):- attribute_id = graphene.Node.to_global_id("Attribute", color_attribute.id)- input_data = [{"id": attribute_id, "values": []}]- attrs_qs = product.product_type.product_attributes.all()-- # The attribute should be ignored and raise no error as the value is not required- assert not attributes_to_json(input_data, attrs_qs)---def test_attributes_to_json_duplicated_slug(product, color_attribute, size_attribute):- # It's possible to have a value with the same slug but for a different attribute.- # Ensure that `attributes_to_json` works in that case.-- attribute_id = graphene.Node.to_global_id("Attribute", color_attribute.id)- color_value = color_attribute.values.first()-- # Create a fake duplicated value.- AttributeValue.objects.create(- slug=color_value.slug, name="Duplicated value", attribute=size_attribute- )-- input_data = [{"id": attribute_id, "values": [color_value.slug]}]- attrs_qs = product.product_type.product_attributes.all()- ids = attributes_to_json(input_data, attrs_qs)- assert str(color_attribute.pk) in ids- assert ids[str(color_attribute.pk)] == [str(color_value.pk)]---def test_attributes_to_json_missing_value_getter_raises_error(product):- # test transforming slugs of existing attributes to IDs- input_data = [{"values": []}]- attrs_qs = product.product_type.product_attributes.all()-- with pytest.raises(ValueError) as exc:- assert not attributes_to_json(input_data, attrs_qs)-- assert exc.value.args == ("The value ID or slug was not provided",)--def test_get_single_attribute_by_pk(user_api_client, color_attribute_without_values):attribute_gql_id = graphene.Node.to_global_id("Attribute", color_attribute_without_values.id@@ -276,14 +135,33 @@ def test_attributes_query_hidden_attribute_as_staff_user(assert len(attributes_data) == attribute_count-QUERY_PRODUCT_ATTRIBUTES = """+QUERY_PRODUCT_AND_VARIANTS_ATTRIBUTES = """{products(first: 1) {edges {node {attributes {attribute {- name+ slug+ }+ values {+ slug+ }+ value {+ slug+ }+ }+ variants {+ attributes {+ attribute {+ slug+ }+ values {+ slug+ }+ value {+ slug+ }}}}@@ -293,89 +171,143 @@ QUERY_PRODUCT_ATTRIBUTES = """"""-def test_resolve_product_attributes_with_hidden(- user_api_client, product, color_attribute[email protected]("is_staff", (False, True))+def test_resolve_attributes_with_hidden(+ user_api_client,+ product,+ color_attribute,+ size_attribute,+ staff_user,+ is_staff,+ permission_manage_products,):- query = QUERY_PRODUCT_ATTRIBUTES+ """Ensure non-staff users don't see hidden attributes, and staff users having+ the 'manage product' permission can.+ """+ query = QUERY_PRODUCT_AND_VARIANTS_ATTRIBUTES+ api_client = user_api_client- # Hide one attribute from the storefront- color_attribute.visible_in_storefront = False- color_attribute.save(update_fields=["visible_in_storefront"])+ variant = product.variants.first()- gql_attrs = get_graphql_content(user_api_client.post_graphql(query))["data"][- "products"- ]["edges"][0]["node"]["attributes"]- assert len(gql_attrs) == len(product.attributes) - 1+ product_attribute = color_attribute+ variant_attribute = size_attribute+ expected_product_attribute_count = product.attributes.count() - 1+ expected_variant_attribute_count = variant.attributes.count() - 1-def test_resolve_product_attributes_with_hidden_as_staff_user(- staff_api_client, product, color_attribute, permission_manage_products-):- query = QUERY_PRODUCT_ATTRIBUTES+ if is_staff:+ api_client.user = staff_user+ expected_product_attribute_count += 1+ expected_variant_attribute_count += 1+ staff_user.user_permissions.add(permission_manage_products)- # Hide one attribute from the storefront- color_attribute.visible_in_storefront = False- color_attribute.save(update_fields=["visible_in_storefront"])+ # Hide one product and variant attribute from the storefront+ for attribute in (product_attribute, variant_attribute):+ attribute.visible_in_storefront = False+ attribute.save(update_fields=["visible_in_storefront"])- # Add proper permissions- staff_api_client.user.user_permissions.add(permission_manage_products)+ product = get_graphql_content(api_client.post_graphql(query))["data"]["products"][+ "edges"+ ][0]["node"]- gql_attrs = get_graphql_content(staff_api_client.post_graphql(query))["data"][- "products"- ]["edges"][0]["node"]["attributes"]- assert len(gql_attrs) == len(product.attributes)+ assert len(product["attributes"]) == expected_product_attribute_count+ assert len(product["variants"][0]["attributes"]) == expected_variant_attribute_count-QUERY_VARIANT_ATTRIBUTES = """- {- products(first: 1) {- edges {- node {- variants {- attributes {- attribute {- name- }- }- }- }- }- }- }-"""+def test_resolve_attribute_values(user_api_client, product, staff_user):+ """Ensure the attribute values are properly resolved."""+ query = QUERY_PRODUCT_AND_VARIANTS_ATTRIBUTES+ api_client = user_api_client+ variant = product.variants.first()-def test_resolve_variant_attributes_with_hidden(- user_api_client, product, size_attribute-):- query = QUERY_VARIANT_ATTRIBUTES+ assert product.attributes.count() == 1+ assert variant.attributes.count() == 1++ product_attribute_values = list(+ product.attributes.first().values.values_list("slug", flat=True)+ )+ variant_attribute_values = list(+ variant.attributes.first().values.values_list("slug", flat=True)+ )++ assert len(product_attribute_values) == 1+ assert len(variant_attribute_values) == 1++ product = get_graphql_content(api_client.post_graphql(query))["data"]["products"][+ "edges"+ ][0]["node"]- # Hide one attribute from the storefront- size_attribute.visible_in_storefront = False- size_attribute.save(update_fields=["visible_in_storefront"])+ product_attributes = product["attributes"]+ variant_attributes = product["variants"][0]["attributes"]- gql_attrs = get_graphql_content(user_api_client.post_graphql(query))["data"][- "products"- ]["edges"][0]["node"]["variants"][0]["attributes"]- assert len(gql_attrs) == len(product.variants.first().attributes) - 1+ assert len(product_attributes) == len(product_attribute_values)+ assert len(variant_attributes) == len(variant_attribute_values)+ assert product_attributes[0]["attribute"]["slug"] == "color"+ assert product_attributes[0]["values"][0]["slug"] == product_attribute_values[0]+ assert product_attributes[0]["value"]["slug"] == product_attribute_values[0]-def test_resolve_variant_attributes_with_hidden_as_staff_user(- staff_api_client, product, size_attribute, permission_manage_products+ assert variant_attributes[0]["attribute"]["slug"] == "size"+ assert variant_attributes[0]["values"][0]["slug"] == variant_attribute_values[0]+ assert variant_attributes[0]["value"]["slug"] == variant_attribute_values[0]+++def test_resolve_attribute_values_non_assigned_to_node(+ user_api_client, product, staff_user):- query = QUERY_VARIANT_ATTRIBUTES+ """Ensure the attribute values are properly resolved when an attribute is part+ of the product type but not of the node (product/variant), thus no values should be+ resolved.+ """+ query = QUERY_PRODUCT_AND_VARIANTS_ATTRIBUTES+ api_client = user_api_client- # Hide one attribute from the storefront- size_attribute.visible_in_storefront = False- size_attribute.save(update_fields=["visible_in_storefront"])+ variant = product.variants.first()+ product_type = product.product_type- # Add proper permissions- staff_api_client.user.user_permissions.add(permission_manage_products)+ # Create dummy attributes+ unassigned_product_attribute = Attribute.objects.create(name="P", slug="product")+ unassigned_variant_attribute = Attribute.objects.create(name="V", slug="variant")++ # Create a value for each dummy attribute to ensure they are not returned+ # by the product or variant as they are not associated to them+ AttributeValue.objects.bulk_create(+ [+ AttributeValue(slug="a", name="A", attribute=unassigned_product_attribute),+ AttributeValue(slug="b", name="B", attribute=unassigned_product_attribute),+ ]+ )++ # Assign the dummy attributes to the product type and push them at the top+ # through a sort_order=0 as the other attributes have sort_order=null+ AttributeProduct.objects.create(+ attribute=unassigned_product_attribute, product_type=product_type, sort_order=0+ )+ AttributeVariant.objects.create(+ attribute=unassigned_variant_attribute, product_type=product_type, sort_order=0+ )++ assert product.attributes.count() == 1+ assert variant.attributes.count() == 1++ product = get_graphql_content(api_client.post_graphql(query))["data"]["products"][+ "edges"+ ][0]["node"]- gql_attrs = get_graphql_content(staff_api_client.post_graphql(query))["data"][- "products"- ]["edges"][0]["node"]["variants"][0]["attributes"]- assert len(gql_attrs) == len(product.variants.first().attributes)+ product_attributes = product["attributes"]+ variant_attributes = product["variants"][0]["attributes"]++ assert len(product_attributes) == 2, "Non-assigned attr from the PT may be missing"+ assert len(variant_attributes) == 2, "Non-assigned attr from the PT may be missing"++ assert product_attributes[0]["attribute"]["slug"] == "product"+ assert product_attributes[0]["values"] == []+ assert variant_attributes[0]["value"] is None++ assert variant_attributes[0]["attribute"]["slug"] == "variant"+ assert variant_attributes[0]["values"] == []+ assert variant_attributes[0]["value"] is Nonedef test_attributes_in_category_query(user_api_client, product):@@ -923,53 +855,16 @@ def test_resolve_attribute_value_type(raw_value, expected_type):assert resolve_attribute_value_type(raw_value) == expected_type-def test_resolve_attribute_list(color_attribute):- value = color_attribute.values.first()- attributes_json = {str(color_attribute.pk): [str(value.pk)]}- res = resolve_attribute_list(attributes_json, Attribute.objects.all())- assert len(res) == 1- assert len(res[0].values) == 1- assert res[0].attribute.name == color_attribute.name- assert res[0].values[0].name == value.name-- # test passing invalid json should resolve to empty list- attr_pk = str(Attribute.objects.order_by("pk").last().pk + 1)- val_pk = str(AttributeValue.objects.order_by("pk").last().pk + 1)- attributes_json = {attr_pk: [val_pk]}- res = resolve_attribute_list(attributes_json, Attribute.objects.all())- assert len(res) == 1- assert res[0].attribute.pk == color_attribute.pk- assert res[0].values == []---# FIXME: this field (value) is deprecated-def test_resolve_attribute_list_deprecated_single_value(color_attribute):- value = color_attribute.values.first()-- # Test passing a value- attributes_json = {str(color_attribute.pk): [str(value.pk)]}- res = resolve_attribute_list(attributes_json, Attribute.objects.all())- assert len(res) == 1- assert len(res[0].values) == 1- assert res[0].value.pk == value.pk-- # Test passing no values- attributes_json = {str(color_attribute.pk): []}- res = resolve_attribute_list(attributes_json, Attribute.objects.all())- assert len(res) == 1- assert res[0].values == []- assert res[0].value is None--def test_resolve_assigned_attribute_without_values(api_client, product_type, product):- # Remove all attributes and values from product- product.attributes = {}- product.save(update_fields=["attributes"])-- # Remove all attributes and values from variant+ """Ensure the attributes assigned to a product type are resolved even if+ the product doesn't provide any value for it or is not directly associated to it.+ """+ # Retrieve the product's variantvariant = product.variants.get()- variant.attributes = {}- variant.save(update_fields=["attributes"])++ # Remove all attributes and values from the product and its variant+ product.attributesrelated.clear()+ variant.attributesrelated.clear()# Retrieve the product and variant's attributesproducts = get_graphql_content(@@ -1884,11 +1779,11 @@ def test_attributes_of_products_are_sorted(m2m_rel_other_attr.save(update_fields=["sort_order"])# Assign attributes to the product- node = variant if is_variant else product- node.attributes = {- str(color_attribute.pk): [str(color_attribute.values.first().pk)]- }- node.save(update_fields=["attributes"])+ node = variant if is_variant else product # type: Union[Product, ProductVariant]+ node.attributesrelated.clear()+ associate_attribute_values_to_instance(+ node, color_attribute, color_attribute.values.first()+ )# Sort the database attributes by their sort order and ID (when None)expected_order = [other_attribute.pk, color_attribute.pk]diff --git a/tests/api/test_base_mutation.py b/tests/api/test_base_mutation.pyindex 5ab6785c7b..790d4dda27 100644--- a/tests/api/test_base_mutation.py+++ b/tests/api/test_base_mutation.py@@ -81,7 +81,7 @@ def test_user_error_nonexistent_id(schema_context):user_errors = result.data["test"]["errors"]assert user_errorsassert user_errors[0]["field"] == "productId"- assert "Couldn't resolve to a node" in user_errors[0]["message"]+ assert "Invalid base64 global ID" in user_errors[0]["message"]def test_user_error_id_of_different_type(product, schema_context):diff --git a/tests/api/test_checkout.py b/tests/api/test_checkout.pyindex dd3a4a9ea1..2e5bda34c4 100644--- a/tests/api/test_checkout.py+++ b/tests/api/test_checkout.py@@ -1131,8 +1131,7 @@ def test_checkout_complete_invalid_checkout_id(user_api_client):response = user_api_client.post_graphql(MUTATION_CHECKOUT_COMPLETE, variables)content = get_graphql_content(response)data = content["data"]["checkoutComplete"]- error_message = "Couldn't resolve to a node: %s" % checkout_id- assert data["errors"][0]["message"] == error_message+ assert data["errors"][0]["message"] == "Invalid base64 global ID"assert data["errors"][0]["field"] == "checkoutId"assert orders_count == Order.objects.count()diff --git a/tests/api/test_product.py b/tests/api/test_product.pyindex 6990697723..8b36bfa2dd 100644--- a/tests/api/test_product.py+++ b/tests/api/test_product.py@@ -6,7 +6,6 @@ from unittest.mock import Mock, patchimport grapheneimport pytestfrom django.utils.dateparse import parse_datetime-from django.utils.encoding import smart_textfrom django.utils.text import slugifyfrom graphql_relay import to_global_idfrom prices import Money@@ -27,6 +26,7 @@ from saleor.product.models import (ProductVariant,)from saleor.product.tasks import update_variants_names+from saleor.product.utils.attributes import associate_attribute_values_to_instancefrom tests.api.utils import get_graphql_contentfrom tests.utils import create_image, create_pdf_file_with_image_ext@@ -256,8 +256,8 @@ def test_products_query_with_filter_attributes(second_product = productsecond_product.id = Nonesecond_product.product_type = product_type- second_product.attributes = {smart_text(attribute.pk): [smart_text(attr_value.pk)]}second_product.save()+ associate_attribute_values_to_instance(second_product, attribute, attr_value)variables = {"filter": {"attributes": [{"slug": attribute.slug, "value": attr_value.slug}]}@@ -559,10 +559,13 @@ def test_filter_products_by_attributes(user_api_client, product):""" % {"filter_by": filter_by}+response = user_api_client.post_graphql(query)content = get_graphql_content(response)- product_data = content["data"]["products"]["edges"][0]["node"]- assert product_data["name"] == product.name+ products = content["data"]["products"]["edges"]++ assert len(products) == 1+ assert products[0]["node"]["name"] == product.namedef test_filter_products_by_categories(user_api_client, categories_tree, product):@@ -1283,6 +1286,128 @@ def test_update_product_can_only_assign_multiple_values_to_valid_input_types(assert not data["errors"]+def test_update_product_with_existing_attribute_value(+ staff_api_client, product, permission_manage_products, color_attribute+):+ """Ensure assigning an existing value to a product doesn't create a new+ attribute value."""++ staff_api_client.user.user_permissions.add(permission_manage_products)++ expected_attribute_values_count = color_attribute.values.count()+ color_attribute_id = graphene.Node.to_global_id("Attribute", color_attribute.id)+ color = color_attribute.values.only("name").first()++ # Try to assign multiple values from an attribute that does not support such things+ variables = {+ "productId": graphene.Node.to_global_id("Product", product.pk),+ "attributes": [{"id": color_attribute_id, "values": [color.name]}],+ }++ data = get_graphql_content(+ staff_api_client.post_graphql(SET_ATTRIBUTES_TO_PRODUCT_QUERY, variables)+ )["data"]["productUpdate"]+ assert not data["errors"]++ assert (+ color_attribute.values.count() == expected_attribute_values_count+ ), "A new attribute value shouldn't have been created"+++def test_update_product_without_supplying_required_product_attribute(+ staff_api_client, product, permission_manage_products, color_attribute+):+ """Ensure assigning an existing value to a product doesn't create a new+ attribute value."""++ staff_api_client.user.user_permissions.add(permission_manage_products)++ product_type = product.product_type++ # Create and assign a new attribute requiring a value to be always supplied+ required_attribute = Attribute.objects.create(+ name="Required One", slug="required-one", value_required=True+ )+ product_type.product_attributes.add(required_attribute)++ # Try to assign multiple values from an attribute that does not support such things+ variables = {+ "productId": graphene.Node.to_global_id("Product", product.pk),+ "attributes": [{"slug": color_attribute.slug, "values": ["Blue"]}],+ }++ data = get_graphql_content(+ staff_api_client.post_graphql(SET_ATTRIBUTES_TO_PRODUCT_QUERY, variables)+ )["data"]["productUpdate"]+ assert data["errors"] == [+ {+ "field": "attributes",+ "message": (+ "All attributes flagged as having a value required must be supplied."+ ),+ }+ ]+++ "attributes_input, expected_message",+ (+ (+ [{"id": "QXR0cmlidXRlOjA=", "values": ["hello"]}], # no such ID (id=0)+ "Could not resolve to a node: ids=['QXR0cmlidXRlOjA='] and slugs=[]",+ ),+ (+ [{"slug": "Oopsie.", "values": ["hello"]}], # no such slug+ "Could not resolve to a node: ids=[] and slugs=['Oopsie.']",+ ),+ ),+)+def test_update_product_with_non_existing_attribute(+ staff_api_client,+ product,+ permission_manage_products,+ color_attribute,+ attributes_input,+ expected_message,+):+ """Ensure assigning an existing value to a product doesn't create a new+ attribute value."""++ staff_api_client.user.user_permissions.add(permission_manage_products)++ # Try to assign multiple values from an attribute that does not support such things+ variables = {+ "productId": graphene.Node.to_global_id("Product", product.pk),+ "attributes": attributes_input,+ }++ data = get_graphql_content(+ staff_api_client.post_graphql(SET_ATTRIBUTES_TO_PRODUCT_QUERY, variables)+ )["data"]["productUpdate"]+ assert data["errors"] == [{"field": "attributes", "message": expected_message}]+++def test_update_product_with_no_attribute_slug_or_id(+ staff_api_client, product, permission_manage_products, color_attribute+):+ """Ensure only supplying values triggers a validation error."""++ staff_api_client.user.user_permissions.add(permission_manage_products)++ # Try to assign multiple values from an attribute that does not support such things+ variables = {+ "productId": graphene.Node.to_global_id("Product", product.pk),+ "attributes": [{"values": ["Oopsie!"]}],+ }++ data = get_graphql_content(+ staff_api_client.post_graphql(SET_ATTRIBUTES_TO_PRODUCT_QUERY, variables)+ )["data"]["productUpdate"]+ assert data["errors"] == [+ {"field": "attributes", "message": "You must whether supply an ID or a slug"}+ ]++def test_update_product_without_variants(staff_api_client, product_with_default_variant, permission_manage_products):diff --git a/tests/api/test_variant.py b/tests/api/test_variant.pyindex a3d5f64f7a..013c2184ff 100644--- a/tests/api/test_variant.py+++ b/tests/api/test_variant.py@@ -188,9 +188,10 @@ def test_create_product_variant_not_all_attributes()content = get_graphql_content(response)assert content["data"]["productVariantCreate"]["errors"]- assert content["data"]["productVariantCreate"]["errors"][0]["field"] == (- "attributes:color"- )+ assert content["data"]["productVariantCreate"]["errors"][0] == {+ "field": "attributes",+ "message": "All attributes must take a value",+ }assert not product.variants.filter(sku=sku).exists()@@ -336,6 +337,26 @@ def test_update_product_variant(staff_api_client, product, permission_manage_proassert data["sku"] == sku+QUERY_UPDATE_VARIANT_ATTRIBUTES = """+ mutation updateVariant (+ $id: ID!,+ $sku: String!,+ $attributes: [AttributeValueInput]!) {+ productVariantUpdate(+ id: $id,+ input: {+ sku: $sku,+ attributes: $attributes+ }) {+ errors {+ field+ message+ }+ }+ }+"""++def test_update_product_variant_not_all_attributes(staff_api_client, product, product_type, color_attribute, permission_manage_products):@@ -343,25 +364,7 @@ def test_update_product_variant_not_all_attributes(be provided) raises an error. We expect the color attributeto be flagged as missing."""- query = """- mutation updateVariant (- $id: ID!,- $sku: String!,- $attributes: [AttributeValueInput]!) {- productVariantUpdate(- id: $id,- input: {- sku: $sku,- attributes: $attributes- }) {- errors {- field- message- }- }- }-- """+ query = QUERY_UPDATE_VARIANT_ATTRIBUTESvariant = product.variants.first()variant_id = graphene.Node.to_global_id("ProductVariant", variant.pk)sku = "test sku"@@ -382,13 +385,61 @@ def test_update_product_variant_not_all_attributes()variant.refresh_from_db()content = get_graphql_content(response)- assert content["data"]["productVariantUpdate"]["errors"]- assert content["data"]["productVariantUpdate"]["errors"][0]["field"] == (- "attributes:color"- )+ assert len(content["data"]["productVariantUpdate"]["errors"]) == 1+ assert content["data"]["productVariantUpdate"]["errors"][0] == {+ "field": "attributes",+ "message": "All attributes must take a value",+ }assert not product.variants.filter(sku=sku).exists()+ "values, message",+ (+ ([], "size expects a value but none were given"),+ (["one", "two"], "A variant attribute cannot take more than one value"),+ ([" "], "Attribute values cannot be blank"),+ ),+)+def test_update_product_variant_requires_values(+ staff_api_client, variant, product_type, permission_manage_products, values, message+):+ """Ensures updating a variant with invalid values raise an error.++ - No values+ - Blank value+ - More than one value+ """++ sku = "updated"++ query = QUERY_UPDATE_VARIANT_ATTRIBUTES+ variant_id = graphene.Node.to_global_id("ProductVariant", variant.pk)+ attr_id = graphene.Node.to_global_id(+ "Attribute", product_type.variant_attributes.first().id+ )++ variables = {+ "id": variant_id,+ "attributes": [{"id": attr_id, "values": values}],+ "sku": sku,+ }++ response = staff_api_client.post_graphql(+ query, variables, permissions=[permission_manage_products]+ )+ variant.refresh_from_db()+ content = get_graphql_content(response)+ assert (+ len(content["data"]["productVariantUpdate"]["errors"]) == 1+ ), f"expected: {message}"+ assert content["data"]["productVariantUpdate"]["errors"][0] == {+ "field": "attributes",+ "message": message,+ }+ assert not variant.product.variants.filter(sku=sku).exists()++def test_delete_variant(staff_api_client, product, permission_manage_products):query = """mutation variantDelete($id: ID!) {diff --git a/tests/conftest.py b/tests/conftest.pyindex c70469eb96..535f5a6424 100644--- a/tests/conftest.py+++ b/tests/conftest.py@@ -11,7 +11,6 @@ from django.core.files import Filefrom django.core.files.uploadedfile import SimpleUploadedFilefrom django.forms import ModelFormfrom django.test.client import Client-from django.utils.encoding import smart_textfrom django_countries import countriesfrom PIL import Imagefrom prices import Money, TaxedMoney@@ -48,6 +47,7 @@ from saleor.product.models import (ProductType,ProductVariant,)+from saleor.product.utils.attributes import associate_attribute_values_to_instancefrom saleor.shipping.models import ShippingMethod, ShippingMethodType, ShippingZonefrom saleor.site import AuthenticationBackendsfrom saleor.site.models import AuthorizationKey, SiteSettings@@ -388,16 +388,15 @@ def categories_tree(db, product_type): # pylint: disable=W0613product_attr = product_type.product_attributes.first()attr_value = product_attr.values.first()- attributes = {smart_text(product_attr.pk): [smart_text(attr_value.pk)]}- Product.objects.create(+ product = Product.objects.create(name="Test product",- price=Money("10.00", "USD"),+ price=Money(10, "USD"),product_type=product_type,- attributes=attributes,category=child,)+ associate_attribute_values_to_instance(product, product_attr, attr_value)return parent@@ -452,31 +451,29 @@ def product_type_without_variant():@pytest.fixturedef product(product_type, category):product_attr = product_type.product_attributes.first()- attr_value = product_attr.values.first()- attributes = {smart_text(product_attr.pk): [smart_text(attr_value.pk)]}+ product_attr_value = product_attr.values.first()product = Product.objects.create(name="Test product",price=Money("10.00", "USD"),product_type=product_type,- attributes=attributes,category=category,)+ associate_attribute_values_to_instance(product, product_attr, product_attr_value)+variant_attr = product_type.variant_attributes.first()variant_attr_value = variant_attr.values.first()- variant_attributes = {- smart_text(variant_attr.pk): [smart_text(variant_attr_value.pk)]- }- ProductVariant.objects.create(+ variant = ProductVariant.objects.create(product=product,sku="123",- attributes=variant_attributes,cost_price=Money("1.00", "USD"),quantity=10,quantity_allocated=1,)++ associate_attribute_values_to_instance(variant, variant_attr, variant_attr_value)return product@@ -497,10 +494,7 @@ def product_with_multiple_values_attributes(product, product_type, category) ->product_type.product_attributes.clear()product_type.product_attributes.add(attribute)- product.attributes = {- smart_text(attribute.pk): [smart_text(attr_val_1.pk), smart_text(attr_val_2.pk)]- }- product.save(update_fields=["attributes"])+ associate_attribute_values_to_instance(product, attribute, attr_val_1, attr_val_2)return product@@ -508,7 +502,7 @@ def product_with_multiple_values_attributes(product, product_type, category) ->def product_with_default_variant(product_type_without_variant, category):product = Product.objects.create(name="Test product",- price=Money("10.00", "USD"),+ price=Money(10, "USD"),product_type=product_type_without_variant,category=category,)@@ -562,38 +556,36 @@ def product_without_shipping(category):def product_list(product_type, category):product_attr = product_type.product_attributes.first()attr_value = product_attr.values.first()- attributes = {smart_text(product_attr.pk): [smart_text(attr_value.pk)]}- products = Product.objects.bulk_create(- [- Product(- pk=1486,- name="Test product 1",- price=Money("10.00", "USD"),- category=category,- product_type=product_type,- attributes=attributes,- is_published=True,- ),- Product(- pk=1487,- name="Test product 2",- price=Money("20.00", "USD"),- category=category,- product_type=product_type,- attributes=attributes,- is_published=False,- ),- Product(- pk=1489,- name="Test product 3",- price=Money("20.00", "USD"),- category=category,- product_type=product_type,- attributes=attributes,- is_published=True,- ),- ]+ products = list(+ Product.objects.bulk_create(+ [+ Product(+ pk=1486,+ name="Test product 1",+ price=Money(10, "USD"),+ category=category,+ product_type=product_type,+ is_published=True,+ ),+ Product(+ pk=1487,+ name="Test product 2",+ price=Money(20, "USD"),+ category=category,+ product_type=product_type,+ is_published=False,+ ),+ Product(+ pk=1489,+ name="Test product 3",+ price=Money(20, "USD"),+ category=category,+ product_type=product_type,+ is_published=True,+ ),+ ]+ ))ProductVariant.objects.bulk_create([@@ -617,6 +609,10 @@ def product_list(product_type, category):),])++ for product in products:+ associate_attribute_values_to_instance(product, product_attr, attr_value)+return products@@ -679,19 +675,16 @@ def unavailable_product_with_variant(product_type, category):variant_attr = product_type.variant_attributes.first()variant_attr_value = variant_attr.values.first()- variant_attributes = {- smart_text(variant_attr.pk): [smart_text(variant_attr_value.pk)]- }- ProductVariant.objects.create(+ variant = ProductVariant.objects.create(product=product,sku="123",- attributes=variant_attributes,- cost_price=Money("1.00", "USD"),+ cost_price=Money(1, "USD"),quantity=10,quantity_allocated=1,)+ associate_attribute_values_to_instance(variant, variant_attr, variant_attr_value)return productdiff --git a/tests/dashboard/test_product.py b/tests/dashboard/test_product.pyindex bde8a75028..6e0e27f5de 100644--- a/tests/dashboard/test_product.py+++ b/tests/dashboard/test_product.py@@ -18,7 +18,7 @@ from saleor.product.models import (ProductType,ProductVariant,)-from tests.utils import get_redirect_location+from tests.utils import generate_attribute_map, get_redirect_locationfrom ..utils import create_image@@ -1108,11 +1108,16 @@ def test_product_form_change_attributes(db, product, color_attribute):assert form.is_valid()product = form.save()- assert product.attributes[str(color_attribute.pk)] == [str(color_value.pk)]+ db_attributes_map = generate_attribute_map(product)- # Check that new attribute was created for author- author_value = AttributeValue.objects.get(name=new_author)- assert product.attributes[str(text_attribute.pk)] == [str(author_value.pk)]+ author_value = AttributeValue.objects.filter(name=new_author).first()+ assert author_value is not None, "The author value was not created"++ expected_attribute_map = {+ color_attribute.pk: {color_value.pk},+ text_attribute.pk: {author_value.pk},+ }+ assert db_attributes_map == expected_attribute_mapdef test_product_form_assign_collection_to_product(product):diff --git a/tests/test_core.py b/tests/test_core.pyindex 3a777efea4..76bb1cbc80 100644--- a/tests/test_core.py+++ b/tests/test_core.py@@ -4,11 +4,9 @@ from unittest.mock import Mock, patchfrom urllib.parse import urljoinimport pytest-from django.db import connectionfrom django.shortcuts import reversefrom django.templatetags.static import staticfrom django.test import Client, RequestFactory, override_settings-from django.test.utils import CaptureQueriesContextfrom django.urls import translate_urlfrom measurement.measures import Weightfrom prices import Money@@ -32,7 +30,7 @@ from saleor.core.weight import WeightUnits, convert_weightfrom saleor.discount.models import Sale, Voucherfrom saleor.giftcard.models import GiftCardfrom saleor.order.models import Order-from saleor.product.models import Product, ProductImage+from saleor.product.models import ProductImagefrom saleor.shipping.models import ShippingZonetype_schema = {@@ -332,28 +330,3 @@ def test_csrf_middleware_is_enabled():def test_get_country_name_by_code():country_name = get_country_name_by_code("PL")assert country_name == "Poland"--- "key, expected",- (- ("test", ".\"attributes\" -> 'test') = '\"a\"'"),- (- "'test'); select current_date;",- (- "\"product_product\".\"attributes\" -> '''test''); "- "select current_date;') = '\"a\"'"- ),- ),- ("15", ".\"attributes\" -> '15') = '\"a\"'"),- ),-)-def test_filterable_json(key, expected):- with CaptureQueriesContext(connection) as queries:- Product.objects.only("pk").filter(- **{f"attributes__from_key_{key}": "a"}- ).first()-- queries = list(queries)- assert len(queries) == 1- assert expected in queries[0]["sql"]diff --git a/tests/test_product.py b/tests/test_product.pyindex e6cbe2dace..7877c44d74 100644--- a/tests/test_product.py+++ b/tests/test_product.py@@ -1,11 +1,11 @@import datetimeimport os+import refrom decimal import Decimalfrom unittest.mock import patchimport pytestfrom bs4 import BeautifulSoup, Tag-from django.core.exceptions import ValidationErrorfrom django.http import JsonResponsefrom django.template.response import TemplateResponsefrom django.urls import reverse@@ -19,6 +19,7 @@ from saleor.checkout.utils import add_variant_to_checkoutfrom saleor.menu.models import MenuItemTranslationfrom saleor.menu.utils import update_menufrom saleor.product import AttributeInputType, ProductAvailabilityStatus, models+from saleor.product.filters import filter_products_by_attributes_valuesfrom saleor.product.models import (Attribute,AttributeTranslation,@@ -26,7 +27,6 @@ from saleor.product.models import (AttributeValueTranslation,DigitalContentUrl,Product,- validate_attribute_json,)from saleor.product.thumbnails import create_product_thumbnailsfrom saleor.product.utils import (@@ -35,14 +35,12 @@ from saleor.product.utils import (decrease_stock,increase_stock,)-from saleor.product.utils.attributes import get_product_attributes_data+from saleor.product.utils.attributes import associate_attribute_values_to_instancefrom saleor.product.utils.availability import get_product_availability_statusfrom saleor.product.utils.costs import get_margin_for_variantfrom saleor.product.utils.digital_products import increment_download_countfrom saleor.product.utils.variants_picker import get_variant_picker_data-from .utils import filter_products_by_attribute-@pytest.mark.parametrize("func, expected_quantity, expected_quantity_allocated",@@ -109,29 +107,36 @@ def test_filtering_by_attribute(db, color_attribute, category, settings):variant_b = models.ProductVariant.objects.create(product=product_b, sku="12345")color = color_attribute.values.first()color_2 = color_attribute.values.last()- product_a.attributes[str(color_attribute.pk)] = [str(color.pk)]- product_a.save()- variant_b.attributes[str(color_attribute.pk)] = [str(color.pk)]- variant_b.save()- filtered = filter_products_by_attribute(- models.Product.objects.all(), color_attribute.pk, color.pk- )- assert product_a in list(filtered)- assert product_b in list(filtered)+ # Associate color to a product and a variant+ associate_attribute_values_to_instance(product_a, color_attribute, color)+ associate_attribute_values_to_instance(variant_b, color_attribute, color)- product_a.attributes[str(color_attribute.pk)] = [str(color_2.pk)]- product_a.save()- filtered = filter_products_by_attribute(- models.Product.objects.all(), color_attribute.pk, color.pk- )- assert product_a not in list(filtered)- assert product_b in list(filtered)- filtered = filter_products_by_attribute(- models.Product.objects.all(), color_attribute.pk, color_2.pk- )- assert product_a in list(filtered)- assert product_b not in list(filtered)+ product_qs = models.Product.objects.all().values_list("pk", flat=True)++ filters = {color_attribute.pk: [color.pk]}+ filtered = filter_products_by_attributes_values(product_qs, filters)+ assert product_a.pk in list(filtered)+ assert product_b.pk in list(filtered)++ associate_attribute_values_to_instance(product_a, color_attribute, color_2)++ filters = {color_attribute.pk: [color.pk]}+ filtered = filter_products_by_attributes_values(product_qs, filters)++ assert product_a.pk not in list(filtered)+ assert product_b.pk in list(filtered)++ filters = {color_attribute.pk: [color_2.pk]}+ filtered = filter_products_by_attributes_values(product_qs, filters)+ assert product_a.pk in list(filtered)+ assert product_b.pk not in list(filtered)++ # Filter by multiple values, should trigger a OR condition+ filters = {color_attribute.pk: [color.pk, color_2.pk]}+ filtered = filter_products_by_attributes_values(product_qs, filters)+ assert product_a.pk in list(filtered)+ assert product_b.pk in list(filtered)def test_render_home_page(client, product, site_settings, settings):@@ -457,8 +462,8 @@ def test_product_filter_multi_values_attribute(assert list(response.context["filter_set"].qs) == [product]# Try filtering with no occurrence- product.attributes[str(attribute.pk)].remove(str(data["modes"][0]))- product.save(update_fields=["attributes"])+ attr_product_assoc = product.attributes.get(assignment__attribute_id=attribute.pk)+ attr_product_assoc.values.remove(data["modes"][0])response = authorized_client.get(url, data)assert list(response.context["filter_set"].qs) == []@@ -490,6 +495,29 @@ def test_product_filter_non_filterable(assert list(response.context["filter_set"].qs) == list(Product.objects.all())+def test_product_filter_handles_garbage_input(+ authorized_client,+ product_with_multiple_values_attributes,+ category,+ product_list_published,+):+ """Ensure filtering products through an invalid ID (non integer input) doesn't+ trigger any crash or error.+ """++ url = reverse(+ "product:category", kwargs={"slug": category.slug, "category_id": category.pk}+ )++ # Try selecting by the disabled attribute+ data = {"modes": "123-invalid-pk"}+ response = authorized_client.get(url, data)+ assert response.status_code == 200++ # Nothing should have been filtered, thus returning all the products+ assert list(response.context["filter_set"].qs) == list(Product.objects.all())++def test_product_filter_product_does_not_exist(authorized_client, product, category):url = reverse("product:category", kwargs={"slug": category.slug, "category_id": category.pk}@@ -575,10 +603,9 @@ def test_get_variant_picker_data_no_nested_attributes(variant, product_type, catproduct_type.variant_attributes.clear()product_type.variant_attributes.add(variant_attr)- variant.attributes = {- str(variant_attr.pk): [str(attr_val_1.pk), str(attr_val_2.pk)]- }- variant.save(update_fields=["attributes"])+ associate_attribute_values_to_instance(+ variant, variant_attr, attr_val_1, attr_val_2+ )product = variant.productdata = get_variant_picker_data(product, discounts=None, local_currency=None)@@ -629,10 +656,7 @@ def test_product_page_renders_attributes_properly(# Assign the dropdown attribute to the productproduct.product_type.product_attributes.add(color_attribute)- product.attributes[str(color_attribute.pk)] = [- str(color_attribute.values.first().pk)- ]- product.save(update_fields=["attributes"])+ associate_attribute_values_to_instance(product, color_attribute, red)# Create the attribute name translationsAttributeTranslation.objects.bulk_create(@@ -681,16 +705,16 @@ def test_product_page_renders_attributes_properly(assert attribute_table, "Did not find the attribute table"# Retrieve the table rows- expected_attributes = {- "Multiple Valeurs:Mode économique, Mode performance",- "Couleur:Rouge",- }- actual_attributes = [- row.get_text(strip=True) for row in attribute_table.select("tr")- ]+ expected_attributes_re = re.compile(+ r"Multiple Valeurs:Mode économique,\s+Mode performance\n\s*" # noqa: no black!+ r"Couleur:Rouge"+ )++ attribute_rows = attribute_table.select("tr")+ actual_attributes = "\n".join(row.get_text(strip=True) for row in attribute_rows)- assert len(actual_attributes) == 2- assert set(actual_attributes) == expected_attributes+ assert len(attribute_rows) == 2+ assert expected_attributes_re.match(actual_attributes)def test_include_products_from_subcategories_in_main_view(@@ -843,44 +867,6 @@ def test_variant_picker_data_with_translations(assert attribute["name"] == translated_variant_fr.name-def test_get_product_attributes_data_translation(- product, settings, translated_attribute-):- settings.LANGUAGE_CODE = "fr"- attributes_data = get_product_attributes_data(product)- attributes_keys = [attr.name for attr in attributes_data.keys()]- assert translated_attribute.name in attributes_keys---def test_get_product_attributes_data_excludes_hidden_attributes(- product, color_attribute-):- """Ensures hidden attributes are ignored."""-- attributes_data = get_product_attributes_data(product)- assert attributes_data-- color_attribute.visible_in_storefront = False- color_attribute.save(update_fields=["visible_in_storefront"])- attributes_data = get_product_attributes_data(product)- assert not attributes_data---def test_get_product_attributes_data_multi_values_attribute(- product_with_multiple_values_attributes-):- """Ensures attributes with multiple values are properly resolved and handled."""-- product = product_with_multiple_values_attributes- attribute = product.product_type.product_attributes.first()-- attributes_data = get_product_attributes_data(product)- values = list(attributes_data.values())-- assert len(values) == 1- assert values[0] == ", ".join([v.name for v in attribute.values.all()])--def test_homepage_collection_render(client, site_settings, collection, product_list):collection.products.add(*product_list)site_settings.homepage_collection = collection@@ -1019,28 +1005,3 @@ def test_costs_get_margin_for_variant(variant, price, cost):variant.cost_price = costvariant.price_override = priceassert not get_margin_for_variant(variant)--- "value, error",- (- ({123: []}, ["The key 123 should be of type str (got <class 'int'>)"]),- (- {"123": 111},- ["The values of '123' should be of type list (got <class 'int'>)"],- ),- (- {"123": [111]},- ["The values inside 111 should be of type str (got <class 'int'>)"],- ),- ),-)-def test_product_attributes_validator_invalid_values(value, error):- with pytest.raises(ValidationError) as exc_info:- validate_attribute_json(value)- assert exc_info.value.args[0] == error--[email protected]("value", ({"123": []}, {"123": ["111"]}))-def test_product_attributes_validator_accept_valid_values(value):- validate_attribute_json(value)diff --git a/tests/test_product_attributes.py b/tests/test_product_attributes.pyindex 1e78ce0b3b..cca7f471f0 100644--- a/tests/test_product_attributes.py+++ b/tests/test_product_attributes.py@@ -3,76 +3,81 @@ from unittest.mock import MagicMock, Mockimport pytestfrom prices import Money-from saleor.product.models import Attribute, AttributeValue, Product, ProductType+from saleor.product import AttributeInputType+from saleor.product.models import (+ Attribute,+ AttributeValue,+ Product,+ ProductType,+ ProductVariant,+)from saleor.product.tasks import _update_variants_namesfrom saleor.product.utils.attributes import (- generate_name_from_values,- get_attributes_display_map,- get_name_from_attributes,+ associate_attribute_values_to_instance,+ generate_name_for_variant,)@pytest.fixture()-def product_with_no_attributes(product_type, category):+def variant_with_no_attributes(category):+ """Create a variant having no attributes, the same for the parent product."""+ product_type = ProductType.objects.create(+ name="Test product type", has_variants=True, is_shipping_required=True+ )product = Product.objects.create(name="Test product",price=Money(10, "USD"),product_type=product_type,category=category,)- return product---def test_get_attributes_display_map(product):- attributes = product.product_type.product_attributes.all()- attributes_display_map = get_attributes_display_map(product, attributes)+ variant = ProductVariant.objects.create(product=product, sku="123")+ return variant- product_attr = product.product_type.product_attributes.first()- attr_value = product_attr.values.first()- assert len(attributes_display_map) == 1- assert {k: v.pk for k, v in attributes_display_map.items()} == {- product_attr.pk: attr_value.translated.pk- }+def test_generate_name_for_variant(+ variant_with_no_attributes, color_attribute_without_values, size_attribute+):+ """Test the name generation from a given variant containing multiple attributes and+ different input types (dropdown and multiselect).+ """+ variant = variant_with_no_attributes+ color_attribute = color_attribute_without_values-def test_get_attributes_display_map_empty(product_with_no_attributes):- product = product_with_no_attributes- attributes = product.product_type.product_attributes.all()- assert get_attributes_display_map(product, attributes) == {}---def test_get_name_from_attributes(product):- variant = product.variants.first()- attributes = variant.product.product_type.variant_attributes.all()- name = get_name_from_attributes(variant, attributes)- assert name == "Small"-+ # Assign the attributes to the product type+ variant.product.product_type.variant_attributes.set(+ (color_attribute, size_attribute)+ )-def test_get_name_from_attributes_no_attributes(product_with_no_attributes):- variant_without_attributes = product_with_no_attributes.variants.create(- sku="example-sku"+ # Set the color attribute to a multi-value attribute+ color_attribute.input_type = AttributeInputType.MULTISELECT+ color_attribute.save(update_fields=["input_type"])++ # Create colors+ colors = AttributeValue.objects.bulk_create(+ [+ AttributeValue(attribute=color_attribute, name="Yellow", slug="yellow"),+ AttributeValue(attribute=color_attribute, name="Blue", slug="blue"),+ AttributeValue(attribute=color_attribute, name="Red", slug="red"),+ ])- variant = variant_without_attributes- attributes = variant.product.product_type.variant_attributes.all()- name = get_name_from_attributes(variant, attributes)- assert name == ""+ # Retrieve the size attribute value "Big"+ size = size_attribute.values.get(slug="big")-def test_generate_name_from_values():- attribute = Attribute.objects.create(slug="color", name="Color")- red = AttributeValue.objects.create(attribute=attribute, name="Red", slug="red")- blue = AttributeValue.objects.create(attribute=attribute, name="Blue", slug="blue")- yellow = AttributeValue.objects.create(- attribute=attribute, name="Yellow", slug="yellow"- )- values = {"3": red, "2": blue, "1": yellow}- name = generate_name_from_values(values)- assert name == "Yellow / Blue / Red"+ # Associate the colors and size to variant attributes+ associate_attribute_values_to_instance(variant, color_attribute, *tuple(colors))+ associate_attribute_values_to_instance(variant, size_attribute, size)+ # Generate the variant name from the attributes+ name = generate_name_for_variant(variant)+ assert name == "Yellow, Blue, Red / Big"-def test_generate_name_from_values_empty():- name = generate_name_from_values({})++def test_generate_name_from_values_empty(variant_with_no_attributes):+ """Ensure generate a variant name from a variant without any attributes assigned+ returns an empty string."""+ name = generate_name_for_variant(variant_with_no_attributes)assert name == ""@@ -94,3 +99,14 @@ def test_update_variants_changed_does_nothing_with_no_attributes():product_type.variant_attributes.all = Mock(return_value=[])saved_attributes = []assert _update_variants_names(product_type, saved_attributes) is None+++def test_associate_attribute_to_non_product_instance():+ instance = ProductType()+ attribute = Attribute()+ value = AttributeValue()++ with pytest.raises(AssertionError) as exc:+ associate_attribute_values_to_instance(instance, attribute, value)++ assert exc.value.args == ("ProductType is unsupported",)diff --git a/tests/test_seo_schema.py b/tests/test_seo_schema.pyindex f54f134b03..a0eac4712d 100644--- a/tests/test_seo_schema.py+++ b/tests/test_seo_schema.py@@ -2,11 +2,15 @@ import jsonimport pytest+from saleor.product import AttributeInputType+from saleor.product.models import Attribute, AttributeValue+from saleor.product.utils.attributes import associate_attribute_values_to_instancefrom saleor.seo.schema.email import (get_order_confirmation_markup,get_organization,get_product_data,)+from saleor.seo.schema.product import get_brand_from_attributesdef test_get_organization(site_settings):@@ -51,3 +55,35 @@ def test_get_order_confirmation_markup(order_with_lines):json.loads(result)except ValueError:pytest.fail("Response is not a valid json")+++def test_get_brand_from_attributes(product):+ attribute = Attribute.objects.create(+ slug="brand", name="Brand", input_type=AttributeInputType.MULTISELECT+ )+ product.product_type.product_attributes.add(attribute)++ # Set the brand attribute as a multi-value attribute+ attribute.input_type = AttributeInputType.MULTISELECT+ attribute.save(update_fields=["input_type"])++ # Add some brands names+ brands = AttributeValue.objects.bulk_create(+ [+ AttributeValue(attribute=attribute, name="Saleor", slug="saleor"),+ AttributeValue(attribute=attribute, name="Mirumee", slug="mirumee"),+ ]+ )++ # Associate the brand names to the product+ associate_attribute_values_to_instance(product, attribute, *tuple(brands))++ # Retrieve the brand names from the product attributes+ brand_names_str = get_brand_from_attributes(product.attributes)+ assert brand_names_str == "Saleor, Mirumee"+++def test_get_brand_from_attributes_no_brand_associated(product):+ # Retrieve the brand names from the product attributes+ brand_names_str = get_brand_from_attributes(product.attributes)+ assert brand_names_str is Nonediff --git a/tests/utils.py b/tests/utils.pyindex 762599e512..9643274876 100644--- a/tests/utils.py+++ b/tests/utils.py@@ -1,12 +1,13 @@from io import BytesIO+from typing import Dict, Set, Unionfrom urllib.parse import urlparsefrom django.core.files.uploadedfile import SimpleUploadedFile-from django.db.models import Q-from django.utils.encoding import smart_textfrom PIL import Imagefrom prices import Money+from saleor.product.models import Product, ProductVariant+def get_url_path(url):parsed_url = urlparse(url)@@ -18,14 +19,6 @@ def get_redirect_location(response):return get_url_path(response["Location"])-def filter_products_by_attribute(queryset, attribute_id, value):- key = smart_text(attribute_id)- value = smart_text(value)- in_product = Q(**{f"attributes__from_key_{key}__has_key": value})- in_variant = Q(**{f"variants__attributes__from_key_{key}__has_key": value})- return queryset.filter(in_product | in_variant)--def get_form_errors(response, form_name="form"):errors = response.context.get(form_name).errorsreturn errors.get("__all__") if errors else []@@ -48,3 +41,23 @@ def create_pdf_file_with_image_ext():def money(amount):return Money(amount, "USD")+++def generate_attribute_map(obj: Union[Product, ProductVariant]) -> Dict[int, Set[int]]:+ """Generate a map from a product or variant instance, useful to quickly compare+ the assigned attribute values against expected IDs.++ The below association map will be returned.+ {+ attribute_pk (int) => {attribute_value_pk (int), ...}+ ...+ }+ """++ qs = obj.attributes.select_related("assignment__attribute")+ qs = qs.prefetch_related("values")++ return {+ assignment.attribute.pk: {value.pk for value in assignment.values.all()}+ for assignment in qs+ }