If you’re planning to categorise your products for the Google Merchant Centre (http://www.google.com/merchants) you will need to determine a product category.
Google provides pages such as
http://support.google.com/merchants/bin/answer.py?hl=en-GB&answer=1705911 or
http://support.google.com/merchants/bin/answer.py?hl=es-ES&answer=1705911
I’ve created a widget that enables you to select a category (in various languages) and copies it to a specified input field. Well when I say created I’ve stolen heavily:
It’s based on jquery-option-tree (http://code.google.com/p/jquery-option-tree/) and work done by “topmonkey” (http://www.sitepoint.com/forums/showthread.php?863627-Taxonomy-Tree-Problems) and it includes the fix at (https://code.google.com/p/jquery-option-tree/source/detail?r=15#)
The widget code is attached and to use it
- Enable the widget actions in the controller where it will be used
public function actions() {
return array(
...
'taxonomy.' => 'application.widgets.gTaxonomy',
...
);
}
- Add something similar to this into your view
<input type="text" id="dummyField" size="120" readonly="readonly"/>
<?php
$this->widget('application.widgets.gTaxonomy', array(
'lang' => 'en-GB',
'updatableFieldId' => 'dummyField',
'dialogTitle' => 'Select Google product taxonomy (EN)',
));
?>
<input type="text" id="dummyField2" size="120" readonly="readonly"/>
<?php
$this->widget('application.widgets.gTaxonomy', array(
'lang' => 'es-ES',
'updatableFieldId' => 'dummyField2',
'dialogTitle' => 'Select Google product taxonomy (ES)',
));
?>
I know that the language codes of en-GB, es-ES, nl-NL and en-US work.
It’s very rough and ready and it’s the first thing like this that I’ve tried to contribute and thought it might provide a starting point for someone else.
The known flaws are
-
The taxonomy files are read from Google each time (see getSubTree class) - they could be cached to improve performance.
-
When the dialog box opens it just has the last selections made and not selections based on a current value.
-
Documentation is lacking
-
Styling could be improved
-
There is no internationalisation
-
could be cached rather than read from Google each time and it lacks something in documentation.
-
It would probably be better as an input widget so it can be used more easily with models