Web4pro_Googlemerchants - Version 1.0.3

Version Notes

Add functionallity for store selection

Download this release

Release Info

Developer Alex
Extension Web4pro_Googlemerchants
Version 1.0.3
Comparing to
See all releases


Code changes from version 1.0.2 to 1.0.3

app/code/community/Web4pro/Googlemerchants/Block/Adminhtml/Editfeed/Edit/Form.php CHANGED
@@ -41,7 +41,7 @@ class Web4pro_Googlemerchants_Block_Adminhtml_Editfeed_Edit_Form extends Mage_Ad
41
 
42
  public function getSelectHtml($nameIndex = 0, $selectedVal = '')
43
  {
44
- $retStr = '<select class="required-entry select" name="attribute-select[' . $nameIndex . ']">';
45
  $retStr .= $this->getOptionsHtml($selectedVal);
46
  $retStr .= '</select>';
47
  return $retStr;
@@ -78,12 +78,15 @@ class Web4pro_Googlemerchants_Block_Adminhtml_Editfeed_Edit_Form extends Mage_Ad
78
  $index = 0;
79
  $resStr = '';
80
  foreach ($data as $val) {
81
- if (!isset($val['value']) || !isset($val['selected'])) {
 
82
  continue;
83
  }
84
- $resStr .= '<tr id="table-row-' . $index . '">';
85
  $resStr .= '<td><input class="required-entry" name="feed-col-name[' . $index . ']" value="' . $val['value'] . '"/></td>';
86
- $resStr .= '<td>' . $this->getSelectHtml($index, $val['selected']) . '</td>';
 
 
87
  $resStr .= '<td>' . $this->getRemoveRowButtonHtml($index) . '</td>';
88
  $resStr .= '</tr>';
89
  $index++;
@@ -91,6 +94,23 @@ class Web4pro_Googlemerchants_Block_Adminhtml_Editfeed_Edit_Form extends Mage_Ad
91
  return $resStr;
92
  }
93
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
94
  /**
95
  * @param int $nameIndex
96
  * @return string
41
 
42
  public function getSelectHtml($nameIndex = 0, $selectedVal = '')
43
  {
44
+ $retStr = '<select class="required-entry select select-googlefeed" name="attribute-select[' . $nameIndex . ']">';
45
  $retStr .= $this->getOptionsHtml($selectedVal);
46
  $retStr .= '</select>';
47
  return $retStr;
78
  $index = 0;
79
  $resStr = '';
80
  foreach ($data as $val) {
81
+ $attributeExists = $this->_isAttributeExists($val['selected']['value']);
82
+ if (!isset($val['value']) || !isset($val['selected']) || !$attributeExists) {
83
  continue;
84
  }
85
+ $resStr .= '<tr id="table-row-' . $index . '" class="table-row-googlefeed">';
86
  $resStr .= '<td><input class="required-entry" name="feed-col-name[' . $index . ']" value="' . $val['value'] . '"/></td>';
87
+ $resStr .= '<td><input name="feed-pref-name[' . $index . ']" value="' . $val['selected']['pref'] . '" class="prefix-postfix-input-field"/></td>';
88
+ $resStr .= '<td>' . $this->getSelectHtml($index, $val['selected']['value']) . '</td>';
89
+ $resStr .= '<td><input name="feed-postf-name[' . $index . ']" value="' . $val['selected']['postf'] . '" class="prefix-postfix-input-field"/></td>';
90
  $resStr .= '<td>' . $this->getRemoveRowButtonHtml($index) . '</td>';
91
  $resStr .= '</tr>';
92
  $index++;
94
  return $resStr;
95
  }
96
 
97
+ /**
98
+ * Check if attribute exists
99
+ * @param $attributeCode
100
+ */
101
+
102
+ protected function _isAttributeExists($attributeCode)
103
+ {
104
+ $entity = 'catalog_product';
105
+ $attr = Mage::getResourceModel('catalog/eav_attribute')
106
+ ->loadByCode($entity,$attributeCode);
107
+ $isDefaultAttr = Mage::getModel('googlemerchants/googlefeed')->isDefaultAttributeCode($attributeCode);
108
+ if($attr->getId() || $isDefaultAttr){
109
+ return true;
110
+ }
111
+ return false;
112
+ }
113
+
114
  /**
115
  * @param int $nameIndex
116
  * @return string
app/code/community/Web4pro/Googlemerchants/Block/Adminhtml/Googlecategory/Edit/Form.php CHANGED
@@ -28,8 +28,8 @@ class Web4pro_Googlemerchants_Block_Adminhtml_Googlecategory_Edit_Form extends M
28
  $form->setUseAjax(true);
29
  $form->setUseContainer(true);
30
  $this->setForm($form);
31
- $fieldset = $form->addFieldset('googlemerchants_form', array('legend' => Mage::helper('googlemerchants')->__('Related store category')));
32
 
 
33
  $fieldset->addField('category_to_linking', 'select', array(
34
  'label' => Mage::helper('googlemerchants')->__('Select store category'),
35
  'required' => false,
@@ -38,11 +38,8 @@ class Web4pro_Googlemerchants_Block_Adminhtml_Googlecategory_Edit_Form extends M
38
  'disabled' => true,
39
  ));
40
 
41
- $fieldset->addField('category_to_linking_submit', 'button', array(
42
- 'required' => true,
43
- 'value' => 'Save',
44
- 'onclick' => 'saveGCategoryLink()',
45
- 'disabled' => true,
46
  ));
47
  return parent::_prepareForm();
48
  }
@@ -52,9 +49,11 @@ class Web4pro_Googlemerchants_Block_Adminhtml_Googlecategory_Edit_Form extends M
52
  */
53
  protected function _getStoreCategoriesOptions()
54
  {
55
- $rootCatIds = Mage::helper('googlemerchants')->getRootCategoriesIds();
 
56
  $categoriesCollection = Mage::getSingleton('catalog/category')->getCollection()
57
  ->addAttributeToSelect('*')
 
58
  ->addIsActiveFilter();
59
  $retArray = array();
60
  $retArray[0] = '';
@@ -64,7 +63,7 @@ class Web4pro_Googlemerchants_Block_Adminhtml_Googlecategory_Edit_Form extends M
64
  if (in_array($catId, $rootCatIds)) {
65
  continue;
66
  }
67
- $retArray[$catId] = $catName;
68
  }
69
  return $retArray;
70
  }
28
  $form->setUseAjax(true);
29
  $form->setUseContainer(true);
30
  $this->setForm($form);
 
31
 
32
+ $fieldset = $form->addFieldset('googlemerchants_form', array('legend' => Mage::helper('googlemerchants')->__('Related store category')));
33
  $fieldset->addField('category_to_linking', 'select', array(
34
  'label' => Mage::helper('googlemerchants')->__('Select store category'),
35
  'required' => false,
38
  'disabled' => true,
39
  ));
40
 
41
+ $fieldset->addField('category_to_linking_submit', 'label', array(
42
+ 'after_element_html' => "<button id=\"category_to_linking_submit\" disabled type=\"button\" class=\"scalable save\" onclick=\"saveGCategoryLink(); return false;\" type=\"button\" title=\"Save\">Save</button>",
 
 
 
43
  ));
44
  return parent::_prepareForm();
45
  }
49
  */
50
  protected function _getStoreCategoriesOptions()
51
  {
52
+ $helper = Mage::helper('googlemerchants');
53
+ $rootCatIds = $helper->getRootCategoriesIds();
54
  $categoriesCollection = Mage::getSingleton('catalog/category')->getCollection()
55
  ->addAttributeToSelect('*')
56
+ ->setOrder('name','ASC')
57
  ->addIsActiveFilter();
58
  $retArray = array();
59
  $retArray[0] = '';
63
  if (in_array($catId, $rootCatIds)) {
64
  continue;
65
  }
66
+ $retArray[$catId] = $catName." (".$helper->__("Category")." ID: ".$catId.")";
67
  }
68
  return $retArray;
69
  }
app/code/community/Web4pro/Googlemerchants/Block/Adminhtml/Googlecategory/Tree.php CHANGED
@@ -129,4 +129,5 @@ class Web4pro_Googlemerchants_Block_Adminhtml_Googlecategory_Tree extends Mage_A
129
  return Mage::helper("adminhtml")->getUrl('googlemerchants/googlemerchants/edit');
130
  }
131
 
 
132
  }
129
  return Mage::helper("adminhtml")->getUrl('googlemerchants/googlemerchants/edit');
130
  }
131
 
132
+
133
  }
app/code/community/Web4pro/Googlemerchants/Block/Adminhtml/System/Instruction.php CHANGED
@@ -20,7 +20,8 @@ class Web4pro_Googlemerchants_Block_Adminhtml_System_Instruction extends Mage_Ad
20
  <li><p>And the last step is setting up feed. You need to choose necessary attributes, which you would like to import.</p>
21
  <p>Go to <a href="' . $this->_getFeedSettingsUrl() . '">Web4pro → Manage Google Merchants settings → Configure Feed settings </a>:
22
  and setup all necessary attributes according to <a href="https://support.google.com/merchants/answer/188494" target="_blank">feed specification</a>:</p>
23
- <img src="https://docs.google.com/drawings/d/1_e2PsWJTsMIDuFt0Mgp6hWHGLyvWnD7rfh84gRMlfwk/pub?w=650&h=370" alt="Set up feed settings" width="650">
 
24
  </li>
25
 
26
  <li>Set up necessary settings of importing products (Web4pro → Manage Google Merchants settings → Manage Google Merchants settings -> Manage Google Feed settings) ↓ :
20
  <li><p>And the last step is setting up feed. You need to choose necessary attributes, which you would like to import.</p>
21
  <p>Go to <a href="' . $this->_getFeedSettingsUrl() . '">Web4pro → Manage Google Merchants settings → Configure Feed settings </a>:
22
  and setup all necessary attributes according to <a href="https://support.google.com/merchants/answer/188494" target="_blank">feed specification</a>:</p>
23
+ <p><b>Please Note:</b> some fields in google feen need the postfix or the prefix to be setted.</p>
24
+ <img src="https://docs.google.com/drawings/d/1ZDkUUOBwtkLoFHrifmgSgzM87wln1qNlAuwJ6M5vzJw/pub?w=854&h=615" alt="Set up feed settings" width="650">
25
  </li>
26
 
27
  <li>Set up necessary settings of importing products (Web4pro → Manage Google Merchants settings → Manage Google Merchants settings -> Manage Google Feed settings) ↓ :
app/code/community/Web4pro/Googlemerchants/Block/Adminhtml/Upload/Link/Renderer.php CHANGED
@@ -28,7 +28,7 @@ class Web4pro_Googlemerchants_Block_Adminhtml_Upload_Link_Renderer extends Varie
28
  $html = '<div>
29
  <h3>Import google categories in two easy steps:</h3>
30
  <ul style="list-style-type: circle;">
31
- <li><p>1. Download file with google merchants categories <a href="https://support.google.com/merchants/answer/160081">here:</a></p>
32
  <div id="upload-hint-image">
33
  <img src="https://docs.google.com/drawings/d/1WB73TBx5S7Q9gfRzzh98BR_qLaHWGn8zJ-1KrKXhcvA/pub?w=749&h=462" alt="Download file with categories">
34
  </div>
28
  $html = '<div>
29
  <h3>Import google categories in two easy steps:</h3>
30
  <ul style="list-style-type: circle;">
31
+ <li><p>1. Download file with google merchants categories <a href="https://support.google.com/merchants/answer/160081" target="_blank">here:</a></p>
32
  <div id="upload-hint-image">
33
  <img src="https://docs.google.com/drawings/d/1WB73TBx5S7Q9gfRzzh98BR_qLaHWGn8zJ-1KrKXhcvA/pub?w=749&h=462" alt="Download file with categories">
34
  </div>
app/code/community/Web4pro/Googlemerchants/Helper/Data.php CHANGED
@@ -238,4 +238,11 @@ class Web4pro_Googlemerchants_Helper_Data extends Mage_Core_Helper_Abstract
238
  return $postParam;
239
  }
240
 
 
 
 
 
 
 
 
241
  }
238
  return $postParam;
239
  }
240
 
241
+ public function getCurrentStoreId()
242
+ {
243
+ $storeId = Mage::app()->getRequest()->getParam('store');
244
+ return $storeId;
245
+ }
246
+
247
+
248
  }
app/code/community/Web4pro/Googlemerchants/Model/Googlefeed.php CHANGED
@@ -12,26 +12,12 @@
12
  */
13
  class Web4pro_Googlemerchants_Model_Googlefeed extends Mage_Core_Model_Abstract
14
  {
15
- protected $_attributesArray = NULL, $_productCollection = NULL, $_helper = NULL, $_byCron = false,
16
  $_path = 'googlemerchants_options/general/google_feed_prameters',
17
  $_notAttachedCategoriesExists = false, $_attributesCollection,
18
- $_defaultParameters = array(
19
- array('value' => 'id', 'selected' => 'product_id'),
20
- array('value' => 'title', 'selected' => 'name'),
21
- array('value' => 'description', 'selected' => 'description'),
22
- array('value' => 'price', 'selected' => 'price'),
23
- array('value' => 'condition', 'selected' => 'condition_google'),
24
- array('value' => 'image link', 'selected' => 'image'),
25
- array('value' => 'gtin', 'selected' => 'gtin_google'),
26
- array('value' => 'color', 'selected' => 'color'),
27
- array('value' => 'size', 'selected' => 'size'),
28
- array('value' => 'mpn', 'selected' => 'mpn_google'),
29
- array('value' => 'category', 'selected' => 'google_category'),
30
- array('value' => 'tax', 'selected' => 'google_tax'),
31
- array('value' => 'link', 'selected' => 'google_product_link'),
32
- array('value' => 'availability', 'selected' => 'google_availability')),
33
 
34
- $_defaultOptionValues = array(
35
  array('code' => 'product_id', 'label' => 'Product ID'),
36
  array('code' => 'google_category', 'label' => 'Google Category'),
37
  array('code' => 'shipping_cost', 'label' => 'Shipping Cost'),
@@ -49,6 +35,37 @@ class Web4pro_Googlemerchants_Model_Googlefeed extends Mage_Core_Model_Abstract
49
  $this->_helper = Mage::helper('googlemerchants');
50
  $this->_setProductsCollection();
51
  $this->_appendStoreFilter();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
52
  }
53
 
54
  /**
@@ -58,12 +75,35 @@ class Web4pro_Googlemerchants_Model_Googlefeed extends Mage_Core_Model_Abstract
58
  {
59
  if ($this->_productCollection === NULL) {
60
  $collection = Mage::getResourceModel('catalog/product_collection')->addAttributeToFilter('visibility', array('in' => array(1, 2, 3, 4)))->addAttributeToSelect('*');
61
- //$collection->setStoreId();
62
  $this->_productCollection = $collection;
63
  }
64
  $this->_setCollectionConfigConditions();
65
  }
66
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
67
  /**
68
  * @return null
69
  */
@@ -110,21 +150,24 @@ class Web4pro_Googlemerchants_Model_Googlefeed extends Mage_Core_Model_Abstract
110
  foreach ($this->_productCollection as $product) {
111
  $productArray = array();
112
  foreach ($attributes as $attribute) {
113
- $attributeCode = $attribute['selected'];
 
 
114
  switch ($attributeCode) {
115
  case 'product_id' :
116
  $attributeCode = 'entity_id';
117
- $productArray [] = $product->getData($attributeCode);
 
118
  break;
119
  case 'google_category' :
120
  $categoriesStr = $googleCategoriesModel->getCategoriesStr($product->getCategoryIds());
121
  if (empty($categoriesStr)) {
122
  $this->_notAttachedCategoriesExists = true;
123
  }
124
- $productArray [] = $categoriesStr;
125
  break;
126
  case 'shipping_cost' :
127
- $productArray [] = $googleShippingModel->getShippingCost($product);
128
  break;
129
  case 'image' :
130
  $image = '';
@@ -137,26 +180,30 @@ class Web4pro_Googlemerchants_Model_Googlefeed extends Mage_Core_Model_Abstract
137
  Mage::logException($e);
138
  }
139
  if(is_string($image)) {
140
- $productArray [] = $image;
141
  }
142
  else {
143
- $productArray [] = '';
144
  }
145
  break;
146
  case 'parent_name' :
147
- $productArray [] = $this->_helper->getParentName($product);
 
148
  break;
149
  case 'google_tax' :
150
- $productArray [] = Mage::getModel('googlemerchants/googletax')->getTaxValue($product);
 
151
  break;
152
  case 'google_product_link':
153
- $productArray [] = $this->_helper->getProductUrl($product);
 
154
  break;
155
  case 'none':
156
- $productArray [] = '';
157
  break;
158
  case 'price':
159
- $productArray [] = $this->_helper->getMinPrice($product);
 
160
  break;
161
  case 'google_availability':
162
 
@@ -166,12 +213,14 @@ class Web4pro_Googlemerchants_Model_Googlefeed extends Mage_Core_Model_Abstract
166
  } else {
167
  $stockStatus = 'out of stock';
168
  }
169
- $productArray [] = $stockStatus;
170
  break;
171
  default :
172
  $attribute = $product->getResource()->getAttribute($attributeCode);
173
  if ($attribute instanceof Mage_Catalog_Model_Resource_Eav_Attribute) {
174
- $productArray [] = $attribute->getFrontend()->getValue($product);
 
 
175
  }
176
  break;
177
  }
@@ -189,6 +238,22 @@ class Web4pro_Googlemerchants_Model_Googlefeed extends Mage_Core_Model_Abstract
189
  fclose($file);
190
  }
191
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
192
  /**
193
  * @param $path
194
  * @return mixed
@@ -216,13 +281,11 @@ class Web4pro_Googlemerchants_Model_Googlefeed extends Mage_Core_Model_Abstract
216
  {
217
  $selectionStore = $this->_helper->getSelectedStore();
218
  $feedConfig = Mage::getStoreConfig('googlemerchants_options/general/google_feed_prameters', $selectionStore);
 
219
  $feedConfig = unserialize($feedConfig);
220
  if (empty($feedConfig)) {
221
  return $this->_defaultParameters;
222
  }
223
- if (empty($feedConfig)) {
224
- return $this->_defaultParameters;
225
- }
226
  $resArr = array();
227
  foreach ($feedConfig as $key => $field) {
228
  $resArr [] = array('value' => $key, 'selected' => $field);
@@ -254,19 +317,18 @@ class Web4pro_Googlemerchants_Model_Googlefeed extends Mage_Core_Model_Abstract
254
  */
255
  protected function _setCollectionConfigConditions()
256
  {
257
- $inStockCondition = Mage::getStoreConfig('googlemerchants_options/general/google_feed_export_outofstock');
258
- $enabledCondition = Mage::getStoreConfig('googlemerchants_options/general/google_feed_export_disabled');
259
  $unvisibleCondition = Mage::getStoreConfig('googlemerchants_options/general/google_feed_export_unvisible');
260
- if ($enabledCondition == 1) {
261
  $this->_productCollection->addAttributeToFilter('status', array('eq' => Mage_Catalog_Model_Product_Status::STATUS_ENABLED));
262
  }
263
- if ($inStockCondition == 1) {
264
  Mage::getSingleton('cataloginventory/stock')->addInStockFilterToCollection($this->_productCollection);
265
  }
266
  if ($unvisibleCondition != 1) {
267
  $this->_productCollection->addAttributeToFilter('visibility', 4);
268
  }
269
-
270
  }
271
 
272
  /**
@@ -292,7 +354,9 @@ class Web4pro_Googlemerchants_Model_Googlefeed extends Mage_Core_Model_Abstract
292
  public function generateFeedByCron()
293
  {
294
  $this->_byCron = true;
295
- $this->generateFeed();
 
 
296
  }
297
 
298
  /**
@@ -303,7 +367,9 @@ class Web4pro_Googlemerchants_Model_Googlefeed extends Mage_Core_Model_Abstract
303
  if ($this->_attributesCollection === NULL)
304
  $this->_attributesCollection = Mage::getResourceModel('eav/entity_attribute_collection')
305
  ->setItemObjectClass('catalog/resource_eav_attribute')
306
- ->setEntityTypeFilter(Mage::getResourceModel('catalog/product')->getTypeId());
 
 
307
  return $this->_attributesCollection;
308
  }
309
 
@@ -317,8 +383,6 @@ class Web4pro_Googlemerchants_Model_Googlefeed extends Mage_Core_Model_Abstract
317
  $selectedStore = Mage::getModel("core/store")->load($storeCode);
318
  }
319
  $this->_productCollection->setStore($selectedStore->getId());
320
- $this->_productCollection->setPageSize(20)
321
- ->setCurPage(1);
322
  }
323
 
324
  }
12
  */
13
  class Web4pro_Googlemerchants_Model_Googlefeed extends Mage_Core_Model_Abstract
14
  {
15
+ protected $_attributesArray = NULL, $_productCollection = NULL, $_helper = NULL, $_shouldGenerateFeedByCron = false, $_byCron = false,
16
  $_path = 'googlemerchants_options/general/google_feed_prameters',
17
  $_notAttachedCategoriesExists = false, $_attributesCollection,
18
+ $_defaultParameters = array();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
19
 
20
+ protected $_defaultOptionValues = array(
21
  array('code' => 'product_id', 'label' => 'Product ID'),
22
  array('code' => 'google_category', 'label' => 'Google Category'),
23
  array('code' => 'shipping_cost', 'label' => 'Shipping Cost'),
35
  $this->_helper = Mage::helper('googlemerchants');
36
  $this->_setProductsCollection();
37
  $this->_appendStoreFilter();
38
+ $this->_shouldGenerateFeedByCron = Mage::getStoreConfig('googlemerchants_options/general/google_generate_feed_by_cron');
39
+ $countryPref = $this->_getCountryPrefix();
40
+ $this->_defaultParameters = array(
41
+ array('value' => 'id', 'selected' => array('value' => 'product_id', 'pref' => '', 'postf' => '')),
42
+ array('value' => 'title', 'selected' => array('value' => 'name', 'pref' => '', 'postf' => '')),
43
+ array('value' => 'description', 'selected' => array('value' => 'description', 'pref' => '', 'postf' => '')),
44
+ array('value' => 'price', 'selected' => array('value' => 'price', 'pref' => '', 'postf' => '')),
45
+ array('value' => 'condition', 'selected' => array('value' => 'condition_google', 'pref' => '', 'postf' => '')),
46
+ array('value' => 'image link', 'selected' => array('value' => 'image', 'pref' => '', 'postf' => '')),
47
+ array('value' => 'gtin', 'selected' => array('value' => 'gtin_google', 'pref' => '', 'postf' => '')),
48
+ array('value' => 'color', 'selected' => array('value' => 'color', 'pref' => '', 'postf' => '')),
49
+ array('value' => 'size', 'selected' => array('value' => 'size', 'pref' => '', 'postf' => '')),
50
+ array('value' => 'mpn', 'selected' => array('value' => 'mpn_google', 'pref' => '', 'postf' => '')),
51
+ array('value' => 'category', 'selected' => array('value' => 'google_category', 'pref' => '', 'postf' => '')),
52
+ array('value' => 'tax', 'selected' => array('value' => 'google_tax', 'pref' => $countryPref, 'postf' => '')),
53
+ array('value' => 'link', 'selected' => array('value' => 'google_product_link', 'pref' => '', 'postf' => '')),
54
+ array('value' => 'availability', 'selected' => array('value' => 'google_availability', 'pref' => '', 'postf' => '')),
55
+ array('value' => 'shipping', 'selected' => array('value' => 'shipping_cost', 'pref' => $countryPref, 'postf' => '')));
56
+
57
+ }
58
+
59
+ /**
60
+ * Getting default country code
61
+ * @return string
62
+ */
63
+
64
+ protected function _getCountryPrefix()
65
+ {
66
+ $storeId = $this->_helper->getCurrentStoreId();
67
+ $countryCode = Mage::getStoreConfig('general/country/default', $storeId);
68
+ return $countryCode.'::';
69
  }
70
 
71
  /**
75
  {
76
  if ($this->_productCollection === NULL) {
77
  $collection = Mage::getResourceModel('catalog/product_collection')->addAttributeToFilter('visibility', array('in' => array(1, 2, 3, 4)))->addAttributeToSelect('*');
 
78
  $this->_productCollection = $collection;
79
  }
80
  $this->_setCollectionConfigConditions();
81
  }
82
 
83
+ /**
84
+ * Checking if attribute is default
85
+ * @param $attributeCode
86
+ * @return bool
87
+ */
88
+
89
+ public function isDefaultAttributeCode($attributeCode)
90
+ {
91
+ $isDefaultOptionValue = false;
92
+ $isDefaultParameter = false;
93
+ foreach($this->_defaultOptionValues as $val){
94
+ if($val['code'] == $attributeCode){
95
+ $isDefaultOptionValue = true;
96
+ }
97
+ }
98
+
99
+ foreach($this->_defaultParameters as $param){
100
+ if($param['selected'] == $attributeCode){
101
+ $isDefaultParameter = true;
102
+ }
103
+ }
104
+ return ($isDefaultParameter || $isDefaultOptionValue);
105
+ }
106
+
107
  /**
108
  * @return null
109
  */
150
  foreach ($this->_productCollection as $product) {
151
  $productArray = array();
152
  foreach ($attributes as $attribute) {
153
+ $attributeCode = $attribute['selected']['value'];
154
+ $pref = $attribute['selected']['pref'];
155
+ $postf = $attribute['selected']['postf'];
156
  switch ($attributeCode) {
157
  case 'product_id' :
158
  $attributeCode = 'entity_id';
159
+ $entityId = $product->getData($attributeCode);
160
+ $productArray [] = $this->_appendPrefPostf($pref, $postf, $entityId);
161
  break;
162
  case 'google_category' :
163
  $categoriesStr = $googleCategoriesModel->getCategoriesStr($product->getCategoryIds());
164
  if (empty($categoriesStr)) {
165
  $this->_notAttachedCategoriesExists = true;
166
  }
167
+ $productArray [] = $this->_appendPrefPostf($pref, $postf,$categoriesStr);
168
  break;
169
  case 'shipping_cost' :
170
+ $productArray [] = $this->_appendPrefPostf($pref, $postf, $googleShippingModel->getShippingCost($product));
171
  break;
172
  case 'image' :
173
  $image = '';
180
  Mage::logException($e);
181
  }
182
  if(is_string($image)) {
183
+ $productArray [] = $this->_appendPrefPostf($pref, $postf, $image);
184
  }
185
  else {
186
+ $productArray [] = $this->_appendPrefPostf($pref, $postf, '');
187
  }
188
  break;
189
  case 'parent_name' :
190
+ $parentName = $this->_helper->getParentName($product);
191
+ $productArray [] = $this->_appendPrefPostf($pref, $postf, $parentName);
192
  break;
193
  case 'google_tax' :
194
+ $taxValue = Mage::getModel('googlemerchants/googletax')->getTaxValue($product);
195
+ $productArray [] = $this->_appendPrefPostf($pref, $postf, $taxValue);
196
  break;
197
  case 'google_product_link':
198
+ $productUrl = $this->_helper->getProductUrl($product);
199
+ $productArray [] = $this->_appendPrefPostf($pref, $postf, $productUrl);
200
  break;
201
  case 'none':
202
+ $productArray [] = $this->_appendPrefPostf($pref, $postf, '');
203
  break;
204
  case 'price':
205
+ $minPrice = $this->_helper->getMinPrice($product);
206
+ $productArray [] = $this->_appendPrefPostf($pref, $postf, $minPrice);
207
  break;
208
  case 'google_availability':
209
 
213
  } else {
214
  $stockStatus = 'out of stock';
215
  }
216
+ $productArray [] = $this->_appendPrefPostf($pref, $postf, $stockStatus);
217
  break;
218
  default :
219
  $attribute = $product->getResource()->getAttribute($attributeCode);
220
  if ($attribute instanceof Mage_Catalog_Model_Resource_Eav_Attribute) {
221
+ $attributeValue = $attribute->getFrontend()->getValue($product);
222
+ $value = $this->_appendPrefPostf($pref, $postf, $attributeValue);
223
+ $productArray [] = $value;
224
  }
225
  break;
226
  }
238
  fclose($file);
239
  }
240
 
241
+ /**
242
+ *
243
+ * @param $prefix
244
+ * @param $postfix
245
+ * @param $value
246
+ * @return string
247
+ */
248
+
249
+ protected function _appendPrefPostf($prefix, $postfix, $value)
250
+ {
251
+ if(is_array($value)){
252
+ $value = implode('',$value);
253
+ }
254
+ return $prefix.$value.$postfix;
255
+ }
256
+
257
  /**
258
  * @param $path
259
  * @return mixed
281
  {
282
  $selectionStore = $this->_helper->getSelectedStore();
283
  $feedConfig = Mage::getStoreConfig('googlemerchants_options/general/google_feed_prameters', $selectionStore);
284
+ $feedConfig = trim($feedConfig);
285
  $feedConfig = unserialize($feedConfig);
286
  if (empty($feedConfig)) {
287
  return $this->_defaultParameters;
288
  }
 
 
 
289
  $resArr = array();
290
  foreach ($feedConfig as $key => $field) {
291
  $resArr [] = array('value' => $key, 'selected' => $field);
317
  */
318
  protected function _setCollectionConfigConditions()
319
  {
320
+ $onlyInStockCondition = Mage::getStoreConfig('googlemerchants_options/general/google_feed_export_outofstock');
321
+ $onlyEabledCondition = Mage::getStoreConfig('googlemerchants_options/general/google_feed_export_disabled');
322
  $unvisibleCondition = Mage::getStoreConfig('googlemerchants_options/general/google_feed_export_unvisible');
323
+ if ($onlyEabledCondition == 0) {
324
  $this->_productCollection->addAttributeToFilter('status', array('eq' => Mage_Catalog_Model_Product_Status::STATUS_ENABLED));
325
  }
326
+ if ($onlyInStockCondition == 0) {
327
  Mage::getSingleton('cataloginventory/stock')->addInStockFilterToCollection($this->_productCollection);
328
  }
329
  if ($unvisibleCondition != 1) {
330
  $this->_productCollection->addAttributeToFilter('visibility', 4);
331
  }
 
332
  }
333
 
334
  /**
354
  public function generateFeedByCron()
355
  {
356
  $this->_byCron = true;
357
+ if($this->_shouldGenerateFeedByCron){
358
+ $this->generateFeed();
359
+ }
360
  }
361
 
362
  /**
367
  if ($this->_attributesCollection === NULL)
368
  $this->_attributesCollection = Mage::getResourceModel('eav/entity_attribute_collection')
369
  ->setItemObjectClass('catalog/resource_eav_attribute')
370
+ ->setEntityTypeFilter(Mage::getResourceModel('catalog/product')->getTypeId())
371
+ ->setOrder('frontend_label','ASC');
372
+
373
  return $this->_attributesCollection;
374
  }
375
 
383
  $selectedStore = Mage::getModel("core/store")->load($storeCode);
384
  }
385
  $this->_productCollection->setStore($selectedStore->getId());
 
 
386
  }
387
 
388
  }
app/code/community/Web4pro/Googlemerchants/controllers/Adminhtml/GooglemerchantsController.php CHANGED
@@ -40,6 +40,7 @@ class Web4pro_Googlemerchants_Adminhtml_GooglemerchantsController extends Mage_A
40
  }
41
  $this->_redirect('adminhtml/googlemerchants/downloadtxt');
42
  }
 
43
  $this->_initAction();
44
  $this->renderLayout();
45
 
@@ -136,11 +137,12 @@ class Web4pro_Googlemerchants_Adminhtml_GooglemerchantsController extends Mage_A
136
  $googleCategory = $model->load($post['google_category_id']);
137
  $googleCategoryName = $googleCategory->getTitle();
138
  $googleCategory->setStoreCatId($post['store_category_id']);
 
139
  $storeCategory = Mage::getModel('catalog/category')->load($post['store_category_id']);
140
  $storeCategoryName = $storeCategory->getName();
141
  $googleCategory->save();
142
- $this->getResponse()->setBody(Mage::helper('core')->jsonEncode(array('error' => 'false')));
143
- Mage::getSingleton('core/session')->addSuccess('Google category "' . $googleCategoryName . '" has been attached to store category "' . $storeCategoryName . '."');
144
  }
145
  }
146
  } else {
@@ -171,6 +173,7 @@ class Web4pro_Googlemerchants_Adminhtml_GooglemerchantsController extends Mage_A
171
  $responce['store_category_id'] = $storeCatId;
172
  $responce['is_root'] = false;
173
  }
 
174
  }
175
  $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($responce));
176
  } else {
@@ -213,8 +216,10 @@ class Web4pro_Googlemerchants_Adminhtml_GooglemerchantsController extends Mage_A
213
  $valuesToSave = array();
214
  $names = $post['feed-col-name'];
215
  $values = $post['attribute-select'];
 
 
216
  foreach ($names as $key => $value) {
217
- $valuesToSave [$value] = $values[$key];
218
  }
219
  Mage::getModel('googlemerchants/googlefeed')->setFeedConfig($valuesToSave, $storeCode);
220
  $result['error'] = false;
@@ -227,7 +232,7 @@ class Web4pro_Googlemerchants_Adminhtml_GooglemerchantsController extends Mage_A
227
  if ($this->getRequest()->isAjax()) {
228
  $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
229
  } else {
230
- $this->_redirect('adminhtml/googlemerchants/feed');
231
  if(!$result['error'])
232
  {
233
  Mage::getSingleton('core/session')->addSuccess('Feed configuration has been saved.');
@@ -273,6 +278,8 @@ class Web4pro_Googlemerchants_Adminhtml_GooglemerchantsController extends Mage_A
273
 
274
  public function clearGoogleCategoriesAction()
275
  {
 
 
276
  Mage::getModel('googlemerchants/googlecategory')->truncateCategoriesTable();
277
  $this->_redirect('adminhtml/googlemerchants/downloadtxt');
278
  }
40
  }
41
  $this->_redirect('adminhtml/googlemerchants/downloadtxt');
42
  }
43
+ Mage::getSingleton('core/session')->addNotice('Please append all store categories to google categories.');
44
  $this->_initAction();
45
  $this->renderLayout();
46
 
137
  $googleCategory = $model->load($post['google_category_id']);
138
  $googleCategoryName = $googleCategory->getTitle();
139
  $googleCategory->setStoreCatId($post['store_category_id']);
140
+
141
  $storeCategory = Mage::getModel('catalog/category')->load($post['store_category_id']);
142
  $storeCategoryName = $storeCategory->getName();
143
  $googleCategory->save();
144
+ $messageBlockHtml = $this->getLayout()->createBlock('core/messages')->addSuccess('Google category "' . $googleCategoryName . '" has been attached to store category "' . $storeCategoryName . '."')->toHtml();
145
+ $this->getResponse()->setBody(Mage::helper('core')->jsonEncode(array('error' => 'false', 'message_block_html' => '<div class="ajax-msg">'.$messageBlockHtml.'</div>')));
146
  }
147
  }
148
  } else {
173
  $responce['store_category_id'] = $storeCatId;
174
  $responce['is_root'] = false;
175
  }
176
+
177
  }
178
  $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($responce));
179
  } else {
216
  $valuesToSave = array();
217
  $names = $post['feed-col-name'];
218
  $values = $post['attribute-select'];
219
+ $prefixes = $post['feed-pref-name'];
220
+ $postfixes = $post['feed-postf-name'];
221
  foreach ($names as $key => $value) {
222
+ $valuesToSave [$value] = array('value' => $values[$key], 'pref' => $prefixes[$key], 'postf' => $postfixes[$key]);
223
  }
224
  Mage::getModel('googlemerchants/googlefeed')->setFeedConfig($valuesToSave, $storeCode);
225
  $result['error'] = false;
232
  if ($this->getRequest()->isAjax()) {
233
  $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
234
  } else {
235
+ $this->_redirect('adminhtml/googlemerchants/feed/store/'.$storeCode);
236
  if(!$result['error'])
237
  {
238
  Mage::getSingleton('core/session')->addSuccess('Feed configuration has been saved.');
278
 
279
  public function clearGoogleCategoriesAction()
280
  {
281
+ Mage::getSingleton('adminhtml/session')->setLatestSelectedGoogleCategoryId(NULL);
282
+ Mage::getSingleton('adminhtml/session')->setLatestSelectedStoreCategoryId(NULL);
283
  Mage::getModel('googlemerchants/googlecategory')->truncateCategoriesTable();
284
  $this->_redirect('adminhtml/googlemerchants/downloadtxt');
285
  }
app/code/community/Web4pro/Googlemerchants/etc/adminhtml.xml CHANGED
@@ -13,7 +13,7 @@
13
  -->
14
  <config>
15
  <menu>
16
- <web4pro_attachments module="googlemerchants">
17
  <title>Web4pro</title>
18
  <sort_order>71</sort_order>
19
  <children>
@@ -27,7 +27,7 @@
27
  <action>adminhtml/googlemerchants/index</action>
28
  </googlecategories>
29
  <googleshipping>
30
- <title>Manage Google Feed settings</title>
31
  <sort_order>1</sort_order>
32
  <action>adminhtml/system_config/edit/section/googlemerchants_options</action>
33
  </googleshipping>
13
  -->
14
  <config>
15
  <menu>
16
+ <web4pro_attachments>
17
  <title>Web4pro</title>
18
  <sort_order>71</sort_order>
19
  <children>
27
  <action>adminhtml/googlemerchants/index</action>
28
  </googlecategories>
29
  <googleshipping>
30
+ <title>Google merchant options</title>
31
  <sort_order>1</sort_order>
32
  <action>adminhtml/system_config/edit/section/googlemerchants_options</action>
33
  </googleshipping>
app/code/community/Web4pro/Googlemerchants/etc/system.xml CHANGED
@@ -96,15 +96,24 @@
96
  <show_in_website>1</show_in_website>
97
  <show_in_store>1</show_in_store>
98
  </google_feed_export_unvisible>
99
- <google_selected_store_for_feed>
100
- <label>Select store foor feed generation by cron</label>
 
101
  <frontend_type>select</frontend_type>
102
- <source_model>googlemerchants/storefeedconfig</source_model>
103
  <sort_order>6</sort_order>
104
  <show_in_default>1</show_in_default>
105
  <show_in_website>1</show_in_website>
106
  <show_in_store>1</show_in_store>
107
- </google_selected_store_for_feed>
 
 
 
 
 
 
 
 
 
108
 
109
  <google_shiping_html_notes translate="label">
110
  <comment>
96
  <show_in_website>1</show_in_website>
97
  <show_in_store>1</show_in_store>
98
  </google_feed_export_unvisible>
99
+ <google_feed_export_unvisible translate="label">
100
+ <label>Generate feed by cron</label>
101
+ <source_model>adminhtml/system_config_source_yesno</source_model>
102
  <frontend_type>select</frontend_type>
 
103
  <sort_order>6</sort_order>
104
  <show_in_default>1</show_in_default>
105
  <show_in_website>1</show_in_website>
106
  <show_in_store>1</show_in_store>
107
+ </google_feed_export_unvisible>
108
+ <google_generate_feed_by_cron>
109
+ <label>Select store for feed generation by cron</label>
110
+ <frontend_type>select</frontend_type>
111
+ <source_model>googlemerchants/storefeedconfig</source_model>
112
+ <sort_order>7</sort_order>
113
+ <show_in_default>1</show_in_default>
114
+ <show_in_website>1</show_in_website>
115
+ <show_in_store>1</show_in_store>
116
+ </google_generate_feed_by_cron>
117
 
118
  <google_shiping_html_notes translate="label">
119
  <comment>
app/design/adminhtml/default/default/layout/googlemerchants.xml CHANGED
@@ -2,6 +2,7 @@
2
  <layout>
3
  <adminhtml_googlemerchants_index>
4
  <reference name="head">
 
5
  <action method="addItem">
6
  <type>js</type>
7
  <name>extjs/ext-tree.js</name>
@@ -48,8 +49,11 @@
48
  </reference>
49
  </adminhtml_googlemerchants_downloadtxt>
50
  <adminhtml_googlemerchants_feed>
 
 
 
51
  <reference name="left">
52
- <block type="adminhtml/system_config_switcher" name="adminhtml.system.config.switcher" before="-"/>
53
  </reference>
54
  <reference name="content">
55
  <block type="googlemerchants/adminhtml_editfeed">
2
  <layout>
3
  <adminhtml_googlemerchants_index>
4
  <reference name="head">
5
+ <action method="addCss"><name>web4pro_googlemerchants/googlemerchants.css</name></action>
6
  <action method="addItem">
7
  <type>js</type>
8
  <name>extjs/ext-tree.js</name>
49
  </reference>
50
  </adminhtml_googlemerchants_downloadtxt>
51
  <adminhtml_googlemerchants_feed>
52
+ <reference name="head">
53
+ <action method="addCss"><name>web4pro_googlemerchants/googlemerchants.css</name></action>
54
+ </reference>
55
  <reference name="left">
56
+ <block type="adminhtml/store_switcher" name="store_switcher" as="store_switcher" />
57
  </reference>
58
  <reference name="content">
59
  <block type="googlemerchants/adminhtml_editfeed">
app/design/adminhtml/default/default/template/web4pro_googlemerchants/feed/form.phtml CHANGED
@@ -22,16 +22,18 @@
22
  </select>
23
  </div>
24
  */ ?>
25
- <table cellspacing="0" cellpadding="0" class="dynamic-grid" style="width:70%;" align="center">
26
  <thead>
27
  <tr class="headings">
28
  <th style="width:160px;"><?php echo $this->__('Field Name')?></th>
29
- <th width="40%"><?php echo $this->__('Value')?></th>
 
 
30
  <th style="width:40%;"><?php echo $this->__('Action')?></th>
31
  </tr>
32
  </thead>
33
  <tbody id="mapping-table-body">
34
- <?php echo $this->getTableBodyHtml() ?>
35
  </tbody>
36
  </table>
37
  </br>
@@ -47,17 +49,29 @@
47
 
48
  function removeRow(index) {
49
  var currentRow = $('table-row-' + index);
50
- currentRow.remove();
 
 
 
 
 
 
 
 
 
 
51
  lastIndex = getLastIndex();
52
  }
53
 
54
  function addRow()
55
  {
56
  var indexTAppend = lastIndex + 1;
57
- var rowHtml = '<tr id="table-row-' + indexTAppend + '"><td><input name="feed-col-name[' + indexTAppend + ']"/></td>';
58
- rowHtml += '<td><select name="attribute-select[' + indexTAppend + ']">';
 
59
  rowHtml += '<?php echo $this->getOptionsHtml()?>';
60
  rowHtml += '</select></td>';
 
61
  rowHtml += '<td><button type="button" onclick="removeRow(' + indexTAppend + ');" class="delete delete-option">Remove</button></td>';
62
  var lastRowId = "table-row-" + lastIndex;
63
  var elementToAppend = $(lastRowId);
22
  </select>
23
  </div>
24
  */ ?>
25
+ <table cellspacing="0" cellpadding="0" class="dynamic-grid" style="width:100%;" align="center">
26
  <thead>
27
  <tr class="headings">
28
  <th style="width:160px;"><?php echo $this->__('Field Name')?></th>
29
+ <th width="40%"><?php echo $this->__('Prefix')?></th>
30
+ <th width="40%"><?php echo $this->__('Value for Google Feed')?></th>
31
+ <th width="40%"><?php echo $this->__('Postfix')?></th>
32
  <th style="width:40%;"><?php echo $this->__('Action')?></th>
33
  </tr>
34
  </thead>
35
  <tbody id="mapping-table-body">
36
+ <?php echo $this->getTableBodyHtml() ?>
37
  </tbody>
38
  </table>
39
  </br>
49
 
50
  function removeRow(index) {
51
  var currentRow = $('table-row-' + index);
52
+ var currentSelects = $$('#table-row-' + index + ' .required-entry');
53
+ for(i = 0; i < currentSelects.length; i ++){
54
+ currentSelects[i].setAttribute('disabled', 'disabled');
55
+ }
56
+
57
+ var currentPrefixInputs = $$('#table-row-' + index + ' .prefix-postfix-input-field');
58
+ for(i = 0; i < currentPrefixInputs.length; i ++){
59
+ currentPrefixInputs[i].setAttribute('disabled', 'disabled');
60
+ }
61
+
62
+ currentRow.hide();
63
  lastIndex = getLastIndex();
64
  }
65
 
66
  function addRow()
67
  {
68
  var indexTAppend = lastIndex + 1;
69
+ var rowHtml = '<tr id="table-row-' + indexTAppend + '" class="table-row-googlefeed"><td><input name="feed-col-name[' + indexTAppend + ']" class="required-entry"/></td>';
70
+ rowHtml += '<td><input name="feed-pref-name[' + indexTAppend + ']" class="prefix-postfix-input-field"/></td>';
71
+ rowHtml += '<td><select name="attribute-select[' + indexTAppend + ']" class="required-entry select select-googlefeed">';
72
  rowHtml += '<?php echo $this->getOptionsHtml()?>';
73
  rowHtml += '</select></td>';
74
+ rowHtml += '<td><input name="feed-postf-name[' + indexTAppend + ']" class="prefix-postfix-input-field"/></td>';
75
  rowHtml += '<td><button type="button" onclick="removeRow(' + indexTAppend + ');" class="delete delete-option">Remove</button></td>';
76
  var lastRowId = "table-row-" + lastIndex;
77
  var elementToAppend = $(lastRowId);
app/design/adminhtml/default/default/template/web4pro_googlemerchants/googlecategory/edit.phtml CHANGED
@@ -20,20 +20,43 @@
20
  location.href = url;
21
  }
22
  }
23
- function saveGCategoryLink() {
 
 
 
 
24
  var googleCatId = tree.currentNodeId;
25
- var storeCatId = $('category_to_linking').selectedIndex;
26
  var url = '<?php echo $this->getSaveStoreCategoryLinkUrl()?>';
27
  var params = {google_category_id: googleCatId, store_category_id: storeCatId};
 
28
  new Ajax.Request(url + (url.match(new RegExp('\\?')) ? '&isAjax=true' : '?isAjax=true' ), {
29
  parameters: params,
30
  onComplete: function (responce) {
31
- if (responce.responseJSON.error) {
 
 
 
32
  window.location.reload();
33
  }
34
  }
35
  });
36
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
37
 
38
  function updateContent(url, params, refreshTree) {
39
  if (!params) {
@@ -79,14 +102,15 @@
79
  if (transport.responseText.length > 0) {
80
  var respObj = transport.responseText.evalJSON();
81
  if (respObj.store_category_id != null) {
82
- $('category_to_linking').selectedIndex = respObj.store_category_id;
83
  }
84
  else {
85
- $('category_to_linking').selectedIndex = 0;
86
  }
87
  if (respObj.is_root) {
88
  $('category_to_linking_submit').setAttribute('disabled', 'disabled');
89
  $('category_to_linking').setAttribute('disabled', 'disabled');
 
90
  }
91
  else {
92
  $('category_to_linking_submit').removeAttribute('disabled');
@@ -101,6 +125,17 @@
101
  });
102
  }
103
 
 
 
 
 
 
 
 
 
 
 
 
104
  /**
105
  * Refresh tree nodes after saving or deleting a category
106
  */
20
  location.href = url;
21
  }
22
  }
23
+ function saveGCategoryLink(needReload) {
24
+ clearAllMessages();
25
+ if(needReload == undefined){
26
+ needReload = false;
27
+ }
28
  var googleCatId = tree.currentNodeId;
29
+ var storeCatId = $('category_to_linking').value;
30
  var url = '<?php echo $this->getSaveStoreCategoryLinkUrl()?>';
31
  var params = {google_category_id: googleCatId, store_category_id: storeCatId};
32
+
33
  new Ajax.Request(url + (url.match(new RegExp('\\?')) ? '&isAjax=true' : '?isAjax=true' ), {
34
  parameters: params,
35
  onComplete: function (responce) {
36
+ if(responce.responseJSON.message_block_html){
37
+ showResponceMessage(responce.responseJSON.message_block_html);
38
+ }
39
+ if (responce.responseJSON.error && needReload) {
40
  window.location.reload();
41
  }
42
  }
43
  });
44
  }
45
+ function showResponceMessage(responceHtml)
46
+ {
47
+ //getting existing message block
48
+ var existingMessageBlock = $('messages');
49
+ existingMessageBlock.innerHTML += responceHtml;
50
+
51
+ }
52
+
53
+ function clearAllMessages()
54
+ {
55
+ var existingMessageBlock = $$('div[class="ajax-msg"]');
56
+ existingMessageBlock.each(function(el){
57
+ el.remove();
58
+ });
59
+ }
60
 
61
  function updateContent(url, params, refreshTree) {
62
  if (!params) {
102
  if (transport.responseText.length > 0) {
103
  var respObj = transport.responseText.evalJSON();
104
  if (respObj.store_category_id != null) {
105
+ $('category_to_linking').value = respObj.store_category_id;
106
  }
107
  else {
108
+ $('category_to_linking').value = 0;
109
  }
110
  if (respObj.is_root) {
111
  $('category_to_linking_submit').setAttribute('disabled', 'disabled');
112
  $('category_to_linking').setAttribute('disabled', 'disabled');
113
+ showRootCategoryMessage();
114
  }
115
  else {
116
  $('category_to_linking_submit').removeAttribute('disabled');
125
  });
126
  }
127
 
128
+ /**
129
+ *
130
+ * Shows message if selected category is root.
131
+ * */
132
+ function showRootCategoryMessage()
133
+ {
134
+ var messageText = 'Please select different from root category!';
135
+ alert(messageText);
136
+ }
137
+
138
+
139
  /**
140
  * Refresh tree nodes after saving or deleting a category
141
  */
app/design/adminhtml/default/default/template/web4pro_googlemerchants/googlecategory/tree.phtml CHANGED
@@ -1,7 +1,6 @@
1
  <?php
2
  /* @var $this Web4pro_Googlemerchants_Block_Adminhtml_Googlecategory_Tree */
3
  ?>
4
-
5
  <?php if ($this->treeCanShow()): ?>
6
  <div class="categories-side-col">
7
  <div class="content-header">
@@ -22,6 +21,7 @@
22
  </div>
23
  </div>
24
  <script type="text/javascript">
 
25
  //<![CDATA[
26
  var tree;
27
 
@@ -74,6 +74,7 @@
74
  this.currentNodeId = parameters['category_id'];
75
  }
76
  this.selectCurrentNode();
 
77
  },
78
 
79
  request: function (url, params) {
@@ -147,6 +148,7 @@
147
  }
148
  var categoryToLinkId = $('category_to_linking').value;
149
  var params = {google_category_id: node.id, store_category_to_link: categoryToLinkId};
 
150
  updateContent(url, params);
151
  }
152
  });
@@ -216,6 +218,7 @@
216
  // try to select current category
217
  var selectedNode = tree.getNodeById(config.parameters.category_id);
218
  if (selectedNode) {
 
219
  tree.currentNodeId = config.parameters.category_id;
220
  }
221
  tree.selectCurrentNode();
@@ -342,7 +345,6 @@
342
  },
343
  data: <?php echo $this->getTreeJson() ?>
344
  };
345
-
346
  reRenderTree();
347
  });
348
 
1
  <?php
2
  /* @var $this Web4pro_Googlemerchants_Block_Adminhtml_Googlecategory_Tree */
3
  ?>
 
4
  <?php if ($this->treeCanShow()): ?>
5
  <div class="categories-side-col">
6
  <div class="content-header">
21
  </div>
22
  </div>
23
  <script type="text/javascript">
24
+
25
  //<![CDATA[
26
  var tree;
27
 
74
  this.currentNodeId = parameters['category_id'];
75
  }
76
  this.selectCurrentNode();
77
+
78
  },
79
 
80
  request: function (url, params) {
148
  }
149
  var categoryToLinkId = $('category_to_linking').value;
150
  var params = {google_category_id: node.id, store_category_to_link: categoryToLinkId};
151
+ clearAllMessages();
152
  updateContent(url, params);
153
  }
154
  });
218
  // try to select current category
219
  var selectedNode = tree.getNodeById(config.parameters.category_id);
220
  if (selectedNode) {
221
+ tree.categoryClick(selectedNode, null);
222
  tree.currentNodeId = config.parameters.category_id;
223
  }
224
  tree.selectCurrentNode();
345
  },
346
  data: <?php echo $this->getTreeJson() ?>
347
  };
 
348
  reRenderTree();
349
  });
350
 
app/etc/modules/Web4pro_Googlemerchants.xml CHANGED
@@ -1,4 +1,15 @@
1
  <?xml version="1.0"?>
 
 
 
 
 
 
 
 
 
 
 
2
  <config>
3
  <modules>
4
  <Web4pro_Googlemerchants>
1
  <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * WEB4PRO - Creating profitable online stores
5
+ *
6
+ * @author WEB4PRO <achernyshev@corp.web4pro.com.ua>
7
+ * @category WEB4PRO
8
+ * @package Web4pro_Stockstatus
9
+ * @copyright Copyright (c) 2015 WEB4PRO (http://www.web4pro.net)
10
+ * @license http://www.web4pro.net/license.txt
11
+ */
12
+ -->
13
  <config>
14
  <modules>
15
  <Web4pro_Googlemerchants>
package.xml CHANGED
@@ -1,7 +1,7 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Web4pro_Googlemerchants</name>
4
- <version>1.0.2</version>
5
  <stability>stable</stability>
6
  <license uri="http://opensource.org/licenses/OSL-3.0">OSL v.3</license>
7
  <channel>community</channel>
@@ -10,9 +10,9 @@
10
  <description>Google merchants service allows you to improve sales by better indexing of your store products, as well as the availability of goods in the google search results.</description>
11
  <notes>Add functionallity for store selection</notes>
12
  <authors><author><name>Alex</name><user>achernyshev</user><email>achernyshev@corp.web4pro.com.ua</email></author></authors>
13
- <date>2015-07-27</date>
14
- <time>13:39:10</time>
15
- <contents><target name="magecommunity"><dir name="Web4pro"><dir name="Googlemerchants"><dir name="Block"><dir name="Adminhtml"><dir name="Editfeed"><dir name="Edit"><file name="Form.php" hash="ef474a89d705108aa3141c80e41e9658"/></dir></dir><file name="Editfeed.php" hash="7d7eba9ef562402d40ad86a288771c51"/><dir name="Googlecategory"><dir name="Edit"><file name="Form.php" hash="e5448f951de4c52e568b08ac2a0f24d0"/></dir><file name="Edit.php" hash="35cc7d98dc229a4a02a38a837a499c09"/><file name="Tree.php" hash="2448621a21e9c77095fdc3c80200edb0"/></dir><dir name="System"><file name="Instruction.php" hash="a8db391b4a26d5becdaf9376f9b298e1"/></dir><dir name="Upload"><file name="File.php" hash="0d40ad6ce19b1ee072c5cf2114057d2e"/><dir name="Form"><file name="Container.php" hash="e1a4e0128a8c7399c6137bbf22415372"/></dir><dir name="Link"><file name="Renderer.php" hash="037e9d54bc46bae1be5a5b9d3b415ced"/></dir></dir></dir></dir><dir name="Helper"><file name="Data.php" hash="f4aea9b6bfba5f6d8495058d14eef018"/></dir><dir name="Model"><file name="Googlecategory.php" hash="9332b02d2d38315f769fd6a693287af2"/><file name="Googlefeed.php" hash="c7bf0b893a50bf1543634d4213db5ebb"/><file name="Googleshipping.php" hash="1fd02059b0bdb80c31c815f3cb75e937"/><file name="Googletax.php" hash="4535e853784f82d4a99315c721ad10a9"/><dir name="Mysql4"><dir name="Googlecategory"><file name="Collection.php" hash="0520040012ab2f78bb1728e8ab81eb42"/></dir><file name="Googlecategory.php" hash="b306fdb04cb24eb03a66c39ffa9c3325"/><file name="Googlefeed.php" hash="b19462cd7eda2437d28efb1198e53453"/></dir><file name="Storefeedconfig.php" hash="0b838449a979e05a4a863430ceab0188"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="GooglemerchantsController.php" hash="5e91b8980d5fd449721d768859b17c30"/></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="704eab9384927a53ba001111dded1b9c"/><file name="config.xml" hash="76b6483a3e63fbda9c71cfcf76a3be49"/><file name="system.xml" hash="6cafd483de4db1ec00667ea6ca99279b"/></dir><dir name="sql"><dir name="googlemerchants_setup"><file name="install-1.0.0.0.php" hash="62d572474a1e3673c66b9d7c1252ec09"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Web4pro_Googlemerchants.xml" hash="06bfb3dcc824e3b4b9fa607cdc05fd1e"/></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="googlemerchants.xml" hash="8090e9b0941e4f9ba787e87ced18bded"/></dir><dir name="template"><dir name="web4pro_googlemerchants"><dir name="feed"><file name="form.phtml" hash="d4cc7600eeb0a48dbd3deebd4c91449d"/></dir><dir name="googlecategory"><file name="edit.phtml" hash="2ccd1585fc12031d4c51ad230120d2db"/><file name="tree.phtml" hash="21331415dbb96f1c2a58e7f22ae163f0"/></dir></dir></dir></dir></dir></dir></target></contents>
16
  <compatible/>
17
  <dependencies><required><php><min>5.3.0</min><max>5.6.0</max></php></required></dependencies>
18
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Web4pro_Googlemerchants</name>
4
+ <version>1.0.3</version>
5
  <stability>stable</stability>
6
  <license uri="http://opensource.org/licenses/OSL-3.0">OSL v.3</license>
7
  <channel>community</channel>
10
  <description>Google merchants service allows you to improve sales by better indexing of your store products, as well as the availability of goods in the google search results.</description>
11
  <notes>Add functionallity for store selection</notes>
12
  <authors><author><name>Alex</name><user>achernyshev</user><email>achernyshev@corp.web4pro.com.ua</email></author></authors>
13
+ <date>2015-09-24</date>
14
+ <time>07:13:33</time>
15
+ <contents><target name="magecommunity"><dir name="Web4pro"><dir name="Googlemerchants"><dir name="Block"><dir name="Adminhtml"><dir name="Editfeed"><dir name="Edit"><file name="Form.php" hash="963fef9a2d97bde0e270ef5e0370581f"/></dir></dir><file name="Editfeed.php" hash="7d7eba9ef562402d40ad86a288771c51"/><dir name="Googlecategory"><dir name="Edit"><file name="Form.php" hash="4f7a0608d53ba140043295b1e4175cd7"/></dir><file name="Edit.php" hash="35cc7d98dc229a4a02a38a837a499c09"/><file name="Tree.php" hash="b712e33fc9a8de6c395c5fcf91ab8458"/></dir><dir name="System"><file name="Instruction.php" hash="d5a1ec0f8ef3b7a0838a1b97a8bccb90"/></dir><dir name="Upload"><file name="File.php" hash="0d40ad6ce19b1ee072c5cf2114057d2e"/><dir name="Form"><file name="Container.php" hash="e1a4e0128a8c7399c6137bbf22415372"/></dir><dir name="Link"><file name="Renderer.php" hash="cdd7b23b4d5303e9281931293923f64f"/></dir></dir></dir></dir><dir name="Helper"><file name="Data.php" hash="8d886bb08f0209495724f84fef622ab2"/></dir><dir name="Model"><file name="Googlecategory.php" hash="9332b02d2d38315f769fd6a693287af2"/><file name="Googlefeed.php" hash="120cb396b966ff2d1d715e264afe6c7d"/><file name="Googleshipping.php" hash="1fd02059b0bdb80c31c815f3cb75e937"/><file name="Googletax.php" hash="4535e853784f82d4a99315c721ad10a9"/><dir name="Mysql4"><dir name="Googlecategory"><file name="Collection.php" hash="0520040012ab2f78bb1728e8ab81eb42"/></dir><file name="Googlecategory.php" hash="b306fdb04cb24eb03a66c39ffa9c3325"/><file name="Googlefeed.php" hash="b19462cd7eda2437d28efb1198e53453"/></dir><file name="Storefeedconfig.php" hash="0b838449a979e05a4a863430ceab0188"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="GooglemerchantsController.php" hash="52b53045c8e2a8aa276199279b0398de"/></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="02e13dc55c49f47eba97569483c41aa7"/><file name="config.xml" hash="76b6483a3e63fbda9c71cfcf76a3be49"/><file name="system.xml" hash="5492385c8d7677d2b0d26fdfa2bd41b2"/></dir><dir name="sql"><dir name="googlemerchants_setup"><file name="install-1.0.0.0.php" hash="62d572474a1e3673c66b9d7c1252ec09"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Web4pro_Googlemerchants.xml" hash="7df85d7a3fb5bd602ec4c3fc045298b9"/></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="googlemerchants.xml" hash="3d837244c46bac42162f864c9f1dad02"/></dir><dir name="template"><dir name="web4pro_googlemerchants"><dir name="feed"><file name="form.phtml" hash="430ad2308bdf7952265579e0328e4fc6"/></dir><dir name="googlecategory"><file name="edit.phtml" hash="e6b23d9681c2cdb61ddf94f0f4992252"/><file name="tree.phtml" hash="04232fa6dc36c3e4f97c43ec3ea9b601"/></dir></dir></dir></dir></dir></dir></target><target name="mageskin"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="web4pro_googlemerchants"><file name="googlemerchants.css" hash="650eb84495947d3cc371c566781dc97b"/><file name="googlemerchants.css" hash="650eb84495947d3cc371c566781dc97b"/></dir></dir></dir></dir></target></contents>
16
  <compatible/>
17
  <dependencies><required><php><min>5.3.0</min><max>5.6.0</max></php></required></dependencies>
18
  </package>
skin/adminhtml/default/default/web4pro_googlemerchants/googlemerchants.css ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
1
+ .table-row-googlefeed{
2
+ width: 100%;
3
+ }
4
+ .select-googlefeed{
5
+ width: 100%;
6
+ }