Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Add brand field docs and getter
Krzysztof Wolski05aa02cf0941
diff --git a/docs/integrations.rst b/docs/integrations.rstindex 6dd8b17731..cf0f84ff95 100644--- a/docs/integrations.rst+++ b/docs/integrations.rst@@ -117,10 +117,12 @@ To generate feed use command:$ python manage.py update_feeds-It's recommended to run this command periodically.+It's recommended to run this command periodically.Merchant Center has few country dependent settings, so please validate your feed at Google dashboard. You can also specify there your shipping cost, which is required feed parameter in many countries. More info be found at `Google Support pages <https://support.google.com/merchants>`_.+One of required by Google fields is *brand* attribute. Feed generator checks for it in variant attribute named *brand* or *publisher* (if not, checks in product).+Feed can be downloaded from url: ``http://<yourserver>/feeds/google/``diff --git a/saleor/data_feeds/google_merchant.py b/saleor/data_feeds/google_merchant.pyindex fbd4f7c541..f4eedba8e5 100644--- a/saleor/data_feeds/google_merchant.py+++ b/saleor/data_feeds/google_merchant.py@@ -2,7 +2,6 @@ from __future__ import unicode_literalsimport gzipimport csv-from os import pathfrom django.conf import settingsfrom django.contrib.sites.models import Site@@ -72,15 +71,26 @@ def item_condition(item):return 'new'-def item_brand(item, brand_attribute_pk):+def item_brand(item, attributes_dict):"""This field is required.Read more:https://support.google.com/merchants/answer/6324351?hl=en&ref_topic=6324338"""- brand = item.get_attribute(brand_attribute_pk)- if brand is None:- brand = item.product.get_attribute(brand_attribute_pk)+ brand = None+ brand_attribute_pk = attributes_dict.get('brand')+ publisher_attribute_pk = attributes_dict.get('publisher')++ if brand_attribute_pk:+ brand = item.get_attribute(brand_attribute_pk)+ if brand is None:+ brand = item.product.get_attribute(brand_attribute_pk)++ if brand is None and publisher_attribute_pk is not None:+ brand = item.get_attribute(publisher_attribute_pk)+ if brand is None:+ brand = item.product.get_attribute(publisher_attribute_pk)+return brand@@ -171,11 +181,9 @@ def item_attributes(item, categories, category_paths, current_site,if tax:product_data['tax'] = tax- brand_attribute_pk = attributes_dict.get('brand')- if brand_attribute_pk:- brand = item_brand(item, brand_attribute_pk)- if brand:- product_data['brand'] = brand+ brand = item_brand(item, attributes_dict)+ if brand:+ product_data['brand'] = brandreturn product_data