Page 1 of 1
How to list Google product categories in product feed
Posted: Thu Sep 08, 2011 9:11 pm
by ogomo
On September 22, 2011 Google Merchant Center will require several items in product feeds, which were previously recommended but not required. I'm having a lot of difficulty implementing one of these, Google Product Category, which uses their own taxonomy.
Here's what Google has to say about it:
Google Product Category: We have added a new required high-level attribute called [google product category] that contains the category of the item in Google’s taxonomy (currently only required for a select number of categories). This is in addition to the current [product type] attribute.
I am using Opencart v 1.4.9.4 and Google Base Improved v1.4.8.
I originally misunderstood this and thought I could just add Google's categories to my existing list of categories, and set their sort order to -1 (to not display on the storefront). This unfortunately just adds these categories to the product_type attribute.
Has anyone figured out how to add google_product_category to their product feeds? I'm hoping there's a way to simply add categories with a sort order of -1 to the feed as the Google category.
Re: How to list Google product categories in product feed
Posted: Fri Sep 09, 2011 2:25 am
by ogomo
So I think I'm half way there. In the file /catalog/controller/feed/google_base_improved.php, I copied the following code:
Code: Select all
$categories = $this->model_catalog_product->getCategories($p['product_id']);
foreach($categories as $c) {
$path = $this->getPath($c['category_id']);
if ($path) {
$cats = array();
foreach (explode('_', $path) as $path_id) {
$category_info = $this->model_catalog_category->getCategory($path_id);
if ($category_info) $cats[] = $category_info['name'];
}
if(count($cats)) $item->appendChild($this->_c('g:product_type', implode(' > ', $cats), false));
}
}
And duplicated it with one small change to the last "if" line:
Code: Select all
$categories = $this->model_catalog_product->getCategories($p['product_id']);
foreach($categories as $c) {
$path = $this->getPath($c['category_id']);
if ($path) {
$cats = array();
foreach (explode('_', $path) as $path_id) {
$category_info = $this->model_catalog_category->getCategory($path_id);
if ($category_info) $cats[] = $category_info['name'];
}
if(count($cats)) $item->appendChild($this->_c('g:google_product_category', implode(' > ', $cats), false));
}
}
Now my feed lists the product categories as both <g:product_type> and <g:google_product_category>.
Now what I need it to do is list only the categories that are visible in my storefront as the <g:product_type>, and the ones that aren't (i.e. the categories with sort order = -1) as <g:google_product_category>.
Any ideas??
Re: How to list Google product categories in product feed
Posted: Fri Sep 09, 2011 2:28 am
by Xsecrets
well the correct way to do this is going to be to add a google taxonomy field to the database. Even then that only gets part of the problem. If you sell aparrel electronics or media I think those are the three then you have to add other attributes as well, and they all have to be listed on different lines, which is going to be a nightmare with opencarts structure, and impossible to do in a standard manner that works for all stores.
Re: How to list Google product categories in product feed
Posted: Fri Sep 09, 2011 2:40 am
by uksitebuilder
The biggest problem as mentioned by X is the variants (or OC product options)
I have overcome all requirements for sinlges item sellers but that with my extension at present, I will find a way to somehow tackle variants too, but it probably wont be for a week or 3
Re: How to list Google product categories in product feed
Posted: Fri Sep 09, 2011 2:43 am
by ogomo
Well I've added the categories according to Google's taxonomy to my database, however those are set to sort order = -1 so they don't display in my store, but display on the product feed.
My store is located at
http://www.ogomo.com and the feed is located at
http://ogomo.com/index.php?route=feed/g ... e_improved
As you can see, the first item lists 6 <g:product_type> entries and 6 identical <g:google_product_category> entries.
The first two are the categories that show up in my storefront, and the remaining ones are correct according to Google's taxonomy. I just need to tell the feed to list <g:product_type> as all categories with the sort order being >=0 and list <g:google_product_category> as all categories with the sort order being = -1.
Re: How to list Google product categories in product feed
Posted: Fri Sep 09, 2011 2:52 am
by uksitebuilder
Google only allows 1 google_product_category per product
Re: How to list Google product categories in product feed
Posted: Fri Sep 09, 2011 3:01 am
by ogomo
Simon,
I just noticed the link to "Google merchant/base xml feed" in your signature. Two questions:
1 - Does this work with the US as the target country?
2 - Does it work with OC 1.4.9.4? (Pretty sure this is yes, but 2x checking)
If so, I'm sold...
Re: How to list Google product categories in product feed
Posted: Fri Sep 09, 2011 3:03 am
by uksitebuilder
1- Yes all countries
2- 1.5.x is fully compliant )apart from variant products) 1.4.9.x Will be by Wednesday next week now that 1.5.x is out and feedback has been positive
[SOLVED] How to list Google product categories in product fe
Posted: Fri Sep 09, 2011 3:20 am
by ogomo
Just set my calendar reminder to purchase this on Wednesday.
Thanks for your help!
Re: How to list Google product categories in product feed
Posted: Thu Sep 15, 2011 4:59 am
by uksitebuilder
1.4.9.x Version is now available.
Re: How to list Google product categories in product feed
Posted: Mon Oct 10, 2011 10:38 am
by hbg
I wish I discovered this earlier. It would have saved a great deal of headaches.
Re: How to list Google product categories in product feed
Posted: Thu Oct 13, 2011 11:55 pm
by sbproduction
Hi here is my product feed:
http://www.livelifesports.co.uk/index.p ... e_improved
right now google say that i need to add availbility. Is this simple or do i need to buy you add on simon? If i do will that answer my problems. I have two shops one runs on 1.4.9.3 and the other on 1.5 does that mean i will need to purchase twice?
Re: How to list Google product categories in product feed
Posted: Tue Oct 18, 2011 7:29 pm
by uksitebuilder
If you have 2 separate installations of OC, then yes, you should buy 2 separate licenses
This is the same for all OC Commercial extensions unless they specifically say otherwise