aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--docs/integrations.rst4
-rw-r--r--saleor/data_feeds/google_merchant.py28
2 files changed, 21 insertions, 11 deletions
diff --git a/docs/integrations.rst b/docs/integrations.rst
index 6dd8b177..cf0f84ff 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.py
index fbd4f7c5..f4eedba8 100644
--- a/saleor/data_feeds/google_merchant.py
+++ b/saleor/data_feeds/google_merchant.py
@@ -2,7 +2,6 @@ from __future__ import unicode_literals
import gzip
import csv
-from os import path
from django.conf import settings
from 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'] = brand
return product_data