Version Notes
First preview release
Download this release
Release Info
| Developer | Alex Boone |
| Extension | Web4pro_Googlemerchants |
| Version | 1.0.0 |
| Comparing to | |
| See all releases | |
Version 1.0.0
- app/code/community/Web4pro/Googlemerchants/Block/Adminhtml/Editfeed.php +71 -0
- app/code/community/Web4pro/Googlemerchants/Block/Adminhtml/Editfeed/Edit/Form.php +127 -0
- app/code/community/Web4pro/Googlemerchants/Block/Adminhtml/Googlecategory/Edit.php +57 -0
- app/code/community/Web4pro/Googlemerchants/Block/Adminhtml/Googlecategory/Edit/Form.php +82 -0
- app/code/community/Web4pro/Googlemerchants/Block/Adminhtml/Googlecategory/Tree.php +132 -0
- app/code/community/Web4pro/Googlemerchants/Block/Adminhtml/System/Instruction.php +62 -0
- app/code/community/Web4pro/Googlemerchants/Block/Adminhtml/Upload/File.php +59 -0
- app/code/community/Web4pro/Googlemerchants/Block/Adminhtml/Upload/Form/Container.php +43 -0
- app/code/community/Web4pro/Googlemerchants/Block/Adminhtml/Upload/Link/Renderer.php +42 -0
- app/code/community/Web4pro/Googlemerchants/Helper/Data.php +195 -0
- app/code/community/Web4pro/Googlemerchants/Model/Googlecategory.php +172 -0
- app/code/community/Web4pro/Googlemerchants/Model/Googlefeed.php +300 -0
- app/code/community/Web4pro/Googlemerchants/Model/Googleshipping.php +100 -0
- app/code/community/Web4pro/Googlemerchants/Model/Googletax.php +28 -0
- app/code/community/Web4pro/Googlemerchants/Model/Mysql4/Googlecategory.php +19 -0
- app/code/community/Web4pro/Googlemerchants/Model/Mysql4/Googlecategory/Collection.php +19 -0
- app/code/community/Web4pro/Googlemerchants/Model/Mysql4/Googlefeed.php +19 -0
- app/code/community/Web4pro/Googlemerchants/controllers/Adminhtml/GooglemerchantsController.php +272 -0
- app/code/community/Web4pro/Googlemerchants/etc/adminhtml.xml +71 -0
- app/code/community/Web4pro/Googlemerchants/etc/config.xml +103 -0
- app/code/community/Web4pro/Googlemerchants/etc/system.xml +126 -0
- app/code/community/Web4pro/Googlemerchants/sql/googlemerchants_setup/install-0.0.0.1.php +420 -0
- app/design/adminhtml/default/default/layout/googlemerchants.xml +60 -0
- app/design/adminhtml/default/default/template/web4pro_googlemerchants/feed/form.phtml +68 -0
- app/design/adminhtml/default/default/template/web4pro_googlemerchants/googlecategory/edit.phtml +166 -0
- app/design/adminhtml/default/default/template/web4pro_googlemerchants/googlecategory/tree.phtml +440 -0
- app/etc/modules/Web4pro_Googlemerchants.xml +9 -0
- package.xml +18 -0
- skin/adminhtml/default/default/web4pro_googlemerchants/custom.css +11 -0
app/code/community/Web4pro/Googlemerchants/Block/Adminhtml/Editfeed.php
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
/**
|
| 4 |
+
* WEB4PRO - Creating profitable online stores
|
| 5 |
+
*
|
| 6 |
+
*
|
| 7 |
+
* @author WEB4PRO <achernyshev@web4pro.com.ua>
|
| 8 |
+
* @category WEB4PRO
|
| 9 |
+
* @package Web4pro_Googlemerchants
|
| 10 |
+
* @copyright Copyright (c) 2014 WEB4PRO (http://www.web4pro.net)
|
| 11 |
+
* @license http://www.web4pro.net/license.txt
|
| 12 |
+
*/
|
| 13 |
+
class Web4pro_Googlemerchants_Block_Adminhtml_Editfeed extends Mage_Adminhtml_Block_Widget_Form_Container
|
| 14 |
+
{
|
| 15 |
+
protected $_headerText = 'Manage feed settings';
|
| 16 |
+
|
| 17 |
+
public function __construct()
|
| 18 |
+
{
|
| 19 |
+
parent::__construct();
|
| 20 |
+
$this->_objectId = 'id';
|
| 21 |
+
$this->_blockGroup = 'googlemerchants';
|
| 22 |
+
$this->_controller = 'adminhtml_editfeed';
|
| 23 |
+
$this->_addButton('save', array(
|
| 24 |
+
'label' => Mage::helper('adminhtml')->__('Save'),
|
| 25 |
+
'onclick' => 'editForm.submit();',
|
| 26 |
+
'class' => 'save',
|
| 27 |
+
), 1);
|
| 28 |
+
|
| 29 |
+
$this->_addButton('generate_feed', array(
|
| 30 |
+
'label' => Mage::helper('adminhtml')->__('Generate feed .csv'),
|
| 31 |
+
'class' => 'save',
|
| 32 |
+
'onclick' => 'setLocation(\'' . $this->getGenerateFeedUrl() . '\')'
|
| 33 |
+
), 1);
|
| 34 |
+
$this->_updateButton('reset', 'onclick', 'setLocation(\'' . $this->getResetFeedUrl() . '\')');
|
| 35 |
+
$this->removeButton('back');
|
| 36 |
+
}
|
| 37 |
+
|
| 38 |
+
|
| 39 |
+
/**
|
| 40 |
+
* @return mixed
|
| 41 |
+
*/
|
| 42 |
+
public function getSaveUrl()
|
| 43 |
+
{
|
| 44 |
+
return Mage::helper("adminhtml")->getUrl('adminhtml/googlemerchants/savefeed', array('store' => Mage::app()->getRequest()->getParam('store')));
|
| 45 |
+
}
|
| 46 |
+
|
| 47 |
+
/**
|
| 48 |
+
* @return mixed
|
| 49 |
+
*/
|
| 50 |
+
public function getValidationUrl()
|
| 51 |
+
{
|
| 52 |
+
//return false;
|
| 53 |
+
return $this->getSaveUrl();
|
| 54 |
+
}
|
| 55 |
+
|
| 56 |
+
/**
|
| 57 |
+
* @return mixed
|
| 58 |
+
*/
|
| 59 |
+
public function getGenerateFeedUrl()
|
| 60 |
+
{
|
| 61 |
+
return Mage::helper("adminhtml")->getUrl('adminhtml/googlemerchants/generatefeed');
|
| 62 |
+
}
|
| 63 |
+
|
| 64 |
+
/**
|
| 65 |
+
* @return mixed
|
| 66 |
+
*/
|
| 67 |
+
public function getResetFeedUrl()
|
| 68 |
+
{
|
| 69 |
+
return Mage::helper("adminhtml")->getUrl('adminhtml/googlemerchants/resetfeed');
|
| 70 |
+
}
|
| 71 |
+
}
|
app/code/community/Web4pro/Googlemerchants/Block/Adminhtml/Editfeed/Edit/Form.php
ADDED
|
@@ -0,0 +1,127 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
/**
|
| 4 |
+
* WEB4PRO - Creating profitable online stores
|
| 5 |
+
*
|
| 6 |
+
*
|
| 7 |
+
* @author WEB4PRO <achernyshev@web4pro.com.ua>
|
| 8 |
+
* @category WEB4PRO
|
| 9 |
+
* @package Web4pro_Googlemerchants
|
| 10 |
+
* @copyright Copyright (c) 2014 WEB4PRO (http://www.web4pro.net)
|
| 11 |
+
* @license http://www.web4pro.net/license.txt
|
| 12 |
+
*/
|
| 13 |
+
class Web4pro_Googlemerchants_Block_Adminhtml_Editfeed_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
|
| 14 |
+
{
|
| 15 |
+
protected $_attributesCollection = NULL, $_attributeSelectOptions = NULL;
|
| 16 |
+
|
| 17 |
+
/**
|
| 18 |
+
* @return Mage_Adminhtml_Block_Widget_Form
|
| 19 |
+
*/
|
| 20 |
+
|
| 21 |
+
protected function _prepareForm()
|
| 22 |
+
{
|
| 23 |
+
$form = new Varien_Data_Form(array(
|
| 24 |
+
'id' => 'edit_form',
|
| 25 |
+
'action' => $this->getUrl('adminhtml/googlemerchants/savefeed', array('store' => Mage::app()->getRequest()->getParam('store'), 'isAjax' => true)),
|
| 26 |
+
'method' => 'post',
|
| 27 |
+
)
|
| 28 |
+
);
|
| 29 |
+
$this->setForm($form);
|
| 30 |
+
$this->setTemplate('web4pro_googlemerchants/feed/form.phtml');
|
| 31 |
+
|
| 32 |
+
return parent::_prepareForm();
|
| 33 |
+
}
|
| 34 |
+
|
| 35 |
+
/**
|
| 36 |
+
* @param int $nameIndex
|
| 37 |
+
* @param string $selectedVal
|
| 38 |
+
* @return string
|
| 39 |
+
*/
|
| 40 |
+
|
| 41 |
+
public function getSelectHtml($nameIndex = 0, $selectedVal = '')
|
| 42 |
+
{
|
| 43 |
+
$retStr = '<select name="attribute-select[' . $nameIndex . ']">';
|
| 44 |
+
$retStr .= $this->getOptionsHtml($selectedVal);
|
| 45 |
+
$retStr .= '</select>';
|
| 46 |
+
return $retStr;
|
| 47 |
+
}
|
| 48 |
+
|
| 49 |
+
/**
|
| 50 |
+
* @param string $selectedVal
|
| 51 |
+
* @return string
|
| 52 |
+
*/
|
| 53 |
+
|
| 54 |
+
public function getOptionsHtml($selectedVal = '')
|
| 55 |
+
{
|
| 56 |
+
$options = Mage::getModel('googlemerchants/googlefeed')->getAttributesOptions();
|
| 57 |
+
$retStr = '<option value="none"></option>';
|
| 58 |
+
foreach ($options as $option) {
|
| 59 |
+
if ($option['code'] == $selectedVal) {
|
| 60 |
+
$retStr .= '<option value="' . addslashes($option['code']) . '" selected>' . addslashes($option['label']) . '</option>';
|
| 61 |
+
} else {
|
| 62 |
+
$retStr .= '<option value="' . addslashes($option['code']) . '">' . addslashes($option['label']) . '</option>';
|
| 63 |
+
}
|
| 64 |
+
}
|
| 65 |
+
return $retStr;
|
| 66 |
+
}
|
| 67 |
+
|
| 68 |
+
/**
|
| 69 |
+
* @return string
|
| 70 |
+
*/
|
| 71 |
+
|
| 72 |
+
public function getTableBodyHtml()
|
| 73 |
+
{
|
| 74 |
+
$data = Mage::getModel('googlemerchants/googlefeed')->getFeedConfig();
|
| 75 |
+
$index = 0;
|
| 76 |
+
$resStr = '';
|
| 77 |
+
foreach ($data as $val) {
|
| 78 |
+
if (!isset($val['value']) || !isset($val['selected'])) {
|
| 79 |
+
continue;
|
| 80 |
+
}
|
| 81 |
+
$resStr .= '<tr id="table-row-' . $index . '">';
|
| 82 |
+
$resStr .= '<td><input name="feed-col-name[' . $index . ']" value="' . $val['value'] . '"/></td>';
|
| 83 |
+
$resStr .= '<td>' . $this->getSelectHtml($index, $val['selected']) . '</td>';
|
| 84 |
+
$resStr .= '<td>' . $this->getRemoveRowButtonHtml($index) . '</td>';
|
| 85 |
+
$resStr .= '</tr>';
|
| 86 |
+
$index++;
|
| 87 |
+
}
|
| 88 |
+
|
| 89 |
+
return $resStr;
|
| 90 |
+
}
|
| 91 |
+
|
| 92 |
+
/**
|
| 93 |
+
* @param int $nameIndex
|
| 94 |
+
* @return string
|
| 95 |
+
*/
|
| 96 |
+
|
| 97 |
+
protected function getRemoveRowButtonHtml($nameIndex = 0)
|
| 98 |
+
{
|
| 99 |
+
return '<button onclick="removeRow(' . $nameIndex . ')">Remove</button>';
|
| 100 |
+
}
|
| 101 |
+
|
| 102 |
+
/**
|
| 103 |
+
* @return string
|
| 104 |
+
*/
|
| 105 |
+
|
| 106 |
+
public function getSaveUrl()
|
| 107 |
+
{
|
| 108 |
+
return Mage::helper("adminhtml")->getUrl('adminhtml/googlemerchants/savefeed', array('store' => Mage::app()->getRequest()->getParam('store')));
|
| 109 |
+
}
|
| 110 |
+
|
| 111 |
+
/**
|
| 112 |
+
* @return string
|
| 113 |
+
*/
|
| 114 |
+
public function getValidationUrl()
|
| 115 |
+
{
|
| 116 |
+
return $this->getSaveUrl();
|
| 117 |
+
}
|
| 118 |
+
|
| 119 |
+
/**
|
| 120 |
+
* @return mixed
|
| 121 |
+
*/
|
| 122 |
+
public function getFeedAjaxUrl()
|
| 123 |
+
{
|
| 124 |
+
return Mage::helper("adminhtml")->getUrl('adminhtml/googlemerchants/feedajax');
|
| 125 |
+
}
|
| 126 |
+
|
| 127 |
+
}
|
app/code/community/Web4pro/Googlemerchants/Block/Adminhtml/Googlecategory/Edit.php
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
/**
|
| 4 |
+
* WEB4PRO - Creating profitable online stores
|
| 5 |
+
*
|
| 6 |
+
*
|
| 7 |
+
* @author WEB4PRO <achernyshev@web4pro.com.ua>
|
| 8 |
+
* @category WEB4PRO
|
| 9 |
+
* @package Web4pro_Googlemerchants
|
| 10 |
+
* @copyright Copyright (c) 2014 WEB4PRO (http://www.web4pro.net)
|
| 11 |
+
* @license http://www.web4pro.net/license.txt
|
| 12 |
+
*/
|
| 13 |
+
class Web4pro_Googlemerchants_Block_Adminhtml_Googlecategory_Edit extends Mage_Adminhtml_Block_Widget_Form_Container
|
| 14 |
+
{
|
| 15 |
+
protected $_headerText = 'Attach google categories to store cateogries.';
|
| 16 |
+
|
| 17 |
+
public function __construct()
|
| 18 |
+
{
|
| 19 |
+
parent::__construct();
|
| 20 |
+
$this->_objectId = 'id';
|
| 21 |
+
$this->_blockGroup = 'googlemerchants';
|
| 22 |
+
$this->_controller = 'adminhtml_googlecategory';
|
| 23 |
+
$this->addButton('clear_google_categories', array(
|
| 24 |
+
'label' => Mage::helper('adminhtml')->__('Clear google categories'),
|
| 25 |
+
'class' => 'delete',
|
| 26 |
+
'onclick' => 'setLocation(\'' . $this->getCrearCategoriesUrl() . '\')'
|
| 27 |
+
), 1);
|
| 28 |
+
$this->removeButton('back');
|
| 29 |
+
$this->removeButton('reset');
|
| 30 |
+
$this->removeButton('save');
|
| 31 |
+
}
|
| 32 |
+
|
| 33 |
+
/**
|
| 34 |
+
* @return string
|
| 35 |
+
*/
|
| 36 |
+
protected function _getLinkedCategoryActionUrl()
|
| 37 |
+
{
|
| 38 |
+
return Mage::helper("adminhtml")->getUrl('adminhtml/googlemerchants/getLinkedCategory');
|
| 39 |
+
}
|
| 40 |
+
|
| 41 |
+
/**
|
| 42 |
+
* @return mixed
|
| 43 |
+
*/
|
| 44 |
+
public function getSaveStoreCategoryLinkUrl()
|
| 45 |
+
{
|
| 46 |
+
return Mage::helper("adminhtml")->getUrl('adminhtml/googlemerchants/saveStoreCategoryLink');
|
| 47 |
+
}
|
| 48 |
+
|
| 49 |
+
/**
|
| 50 |
+
* @return mixed
|
| 51 |
+
*/
|
| 52 |
+
public function getCrearCategoriesUrl()
|
| 53 |
+
{
|
| 54 |
+
return Mage::helper("adminhtml")->getUrl('adminhtml/googlemerchants/clearGoogleCategories');
|
| 55 |
+
}
|
| 56 |
+
|
| 57 |
+
}
|
app/code/community/Web4pro/Googlemerchants/Block/Adminhtml/Googlecategory/Edit/Form.php
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
/**
|
| 4 |
+
* WEB4PRO - Creating profitable online stores
|
| 5 |
+
*
|
| 6 |
+
*
|
| 7 |
+
* @author WEB4PRO <achernyshev@web4pro.com.ua>
|
| 8 |
+
* @category WEB4PRO
|
| 9 |
+
* @package Web4pro_Googlemerchants
|
| 10 |
+
* @copyright Copyright (c) 2014 WEB4PRO (http://www.web4pro.net)
|
| 11 |
+
* @license http://www.web4pro.net/license.txt
|
| 12 |
+
*/
|
| 13 |
+
class Web4pro_Googlemerchants_Block_Adminhtml_Googlecategory_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
|
| 14 |
+
{
|
| 15 |
+
/**
|
| 16 |
+
* @return Mage_Adminhtml_Block_Widget_Form
|
| 17 |
+
* @throws Exception
|
| 18 |
+
*/
|
| 19 |
+
|
| 20 |
+
protected function _prepareForm()
|
| 21 |
+
{
|
| 22 |
+
$form = new Varien_Data_Form(array(
|
| 23 |
+
'id' => 'edit_form',
|
| 24 |
+
'action' => $this->getUrl('*/*/save', array('id' => $this->getRequest()->getParam('id'))),
|
| 25 |
+
'method' => 'post',
|
| 26 |
+
)
|
| 27 |
+
);
|
| 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,
|
| 36 |
+
'name' => 'category_to_linking',
|
| 37 |
+
'options' => $this->_getStoreCategoriesOptions(),
|
| 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 |
+
}
|
| 49 |
+
|
| 50 |
+
/**
|
| 51 |
+
* @return array
|
| 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] = '';
|
| 61 |
+
foreach ($categoriesCollection as $category) {
|
| 62 |
+
$catId = $category->getId();
|
| 63 |
+
$catName = $category->getName();
|
| 64 |
+
if (in_array($catId, $rootCatIds)) {
|
| 65 |
+
continue;
|
| 66 |
+
}
|
| 67 |
+
$retArray[$catId] = $catName;
|
| 68 |
+
}
|
| 69 |
+
return $retArray;
|
| 70 |
+
}
|
| 71 |
+
|
| 72 |
+
/**
|
| 73 |
+
* @return string
|
| 74 |
+
*/
|
| 75 |
+
|
| 76 |
+
public function getFormHtml()
|
| 77 |
+
{
|
| 78 |
+
$googleCatCount = Mage::helper('googlemerchants')->getGoogleCategoriesCount();
|
| 79 |
+
return ($googleCatCount > 0) ? parent::getFormHtml() : '';
|
| 80 |
+
}
|
| 81 |
+
|
| 82 |
+
}
|
app/code/community/Web4pro/Googlemerchants/Block/Adminhtml/Googlecategory/Tree.php
ADDED
|
@@ -0,0 +1,132 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
/**
|
| 4 |
+
* WEB4PRO - Creating profitable online stores
|
| 5 |
+
*
|
| 6 |
+
*
|
| 7 |
+
* @author WEB4PRO <achernyshev@web4pro.com.ua>
|
| 8 |
+
* @category WEB4PRO
|
| 9 |
+
* @package Web4pro_Googlemerchants
|
| 10 |
+
* @copyright Copyright (c) 2014 WEB4PRO (http://www.web4pro.net)
|
| 11 |
+
* @license http://www.web4pro.net/license.txt
|
| 12 |
+
*/
|
| 13 |
+
class Web4pro_Googlemerchants_Block_Adminhtml_Googlecategory_Tree extends Mage_Adminhtml_Block_Catalog_Category_Tree
|
| 14 |
+
{
|
| 15 |
+
protected $_model = NULL, $_helper = NULL;
|
| 16 |
+
|
| 17 |
+
/**
|
| 18 |
+
* @param null $parenNodeCategory
|
| 19 |
+
* @return array
|
| 20 |
+
*/
|
| 21 |
+
|
| 22 |
+
public function getTree($parenNodeCategory = null)
|
| 23 |
+
{
|
| 24 |
+
$rootArray = $this->_getNodeJson($this->getRoot($parenNodeCategory));
|
| 25 |
+
$tree = isset($rootArray['children']) ? $rootArray['children'] : array();
|
| 26 |
+
return $tree;
|
| 27 |
+
}
|
| 28 |
+
|
| 29 |
+
/**
|
| 30 |
+
* @param null $parenNodeCategory
|
| 31 |
+
* @return Mage_Core_Model_Abstract
|
| 32 |
+
*/
|
| 33 |
+
|
| 34 |
+
public function getRoot($parenNodeCategory = NULL)
|
| 35 |
+
{
|
| 36 |
+
if ($parenNodeCategory === NULL) {
|
| 37 |
+
return $this->_getModel()->load($this->_getModel()->getRootCategoryId());
|
| 38 |
+
}
|
| 39 |
+
return $this->_getModel()->load($parenNodeCategory->getCategoryId());
|
| 40 |
+
}
|
| 41 |
+
|
| 42 |
+
|
| 43 |
+
/**
|
| 44 |
+
* @return bool
|
| 45 |
+
*/
|
| 46 |
+
|
| 47 |
+
public function treeCanShow()
|
| 48 |
+
{
|
| 49 |
+
$googleCatCount = $this->_getHelper()->getGoogleCategoriesCount();
|
| 50 |
+
return ($googleCatCount > 0) ? true : false;
|
| 51 |
+
}
|
| 52 |
+
|
| 53 |
+
/**
|
| 54 |
+
* @param null $parenNodeCategoryId
|
| 55 |
+
* @return mixed
|
| 56 |
+
*/
|
| 57 |
+
public function getTreeJson($parenNodeCategoryId = NULL)
|
| 58 |
+
{
|
| 59 |
+
|
| 60 |
+
if ($parenNodeCategoryId === NULL) {
|
| 61 |
+
$parenNodeCategoryId = (int)$this->_getModel()->getRootCategoryId();
|
| 62 |
+
}
|
| 63 |
+
$parenNodeCategory = $this->_getModel()->load($parenNodeCategoryId);
|
| 64 |
+
$children = $parenNodeCategory->getChildrenCategories($parenNodeCategory);
|
| 65 |
+
$childrensArr = array();
|
| 66 |
+
foreach ($children as $child) {
|
| 67 |
+
$childArray = $this->_getHelper()->categoryEntityToTreeStd($child);
|
| 68 |
+
$childrensArr [] = $childArray;
|
| 69 |
+
}
|
| 70 |
+
$rootElement = $this->_getHelper()->categoryEntityToTreeStd($parenNodeCategory);
|
| 71 |
+
$rootElement['children'] = $childrensArr;
|
| 72 |
+
$rootElement['expanded'] = false;
|
| 73 |
+
|
| 74 |
+
if ($rootElement['id'] == $this->_getModel()->getRootCategoryId()) {
|
| 75 |
+
$rootElement['expanded'] = true;
|
| 76 |
+
$json = Mage::helper('core')->jsonEncode(array($rootElement));
|
| 77 |
+
} else {
|
| 78 |
+
$rootElement = $childrensArr;
|
| 79 |
+
$json = Mage::helper('core')->jsonEncode($rootElement);
|
| 80 |
+
|
| 81 |
+
}
|
| 82 |
+
|
| 83 |
+
return $json;
|
| 84 |
+
}
|
| 85 |
+
|
| 86 |
+
/**
|
| 87 |
+
* @return false|Mage_Core_Model_Abstract|null
|
| 88 |
+
*/
|
| 89 |
+
|
| 90 |
+
protected function _getModel()
|
| 91 |
+
{
|
| 92 |
+
if ($this->_model === NULL) {
|
| 93 |
+
$this->_model = Mage::getModel('googlemerchants/googlecategory');
|
| 94 |
+
}
|
| 95 |
+
return $this->_model;
|
| 96 |
+
}
|
| 97 |
+
|
| 98 |
+
protected function _prepareLayout()
|
| 99 |
+
{
|
| 100 |
+
parent::_prepareLayout();
|
| 101 |
+
$this->unsetChild('store_switcher');
|
| 102 |
+
}
|
| 103 |
+
|
| 104 |
+
/**
|
| 105 |
+
* @return Web4pro_Googlemerchants_Helper_Data
|
| 106 |
+
*/
|
| 107 |
+
protected function _getHelper()
|
| 108 |
+
{
|
| 109 |
+
if ($this->_helper === NULL) {
|
| 110 |
+
$this->_helper = Mage::helper('googlemerchants');
|
| 111 |
+
}
|
| 112 |
+
return $this->_helper;
|
| 113 |
+
}
|
| 114 |
+
|
| 115 |
+
/**
|
| 116 |
+
* @return mixed
|
| 117 |
+
*/
|
| 118 |
+
|
| 119 |
+
public function getLinkedCategoryActionUrl()
|
| 120 |
+
{
|
| 121 |
+
return Mage::helper("adminhtml")->getUrl('adminhtml/googlemerchants/getLinkedCategory');
|
| 122 |
+
}
|
| 123 |
+
|
| 124 |
+
/**
|
| 125 |
+
* @return mixed
|
| 126 |
+
*/
|
| 127 |
+
public function getEditUrl()
|
| 128 |
+
{
|
| 129 |
+
return Mage::helper("adminhtml")->getUrl('googlemerchants/googlemerchants/edit');
|
| 130 |
+
}
|
| 131 |
+
|
| 132 |
+
}
|
app/code/community/Web4pro/Googlemerchants/Block/Adminhtml/System/Instruction.php
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
class Web4pro_Googlemerchants_Block_Adminhtml_System_Instruction extends Mage_Adminhtml_Block_System_Config_Form_Field
|
| 4 |
+
{
|
| 5 |
+
/*protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
|
| 6 |
+
{
|
| 7 |
+
$block = $this->getLayout()->createBlock('adminhtml/widget_button');
|
| 8 |
+
$block->setLabel($this->__('Fetch New Token'));
|
| 9 |
+
$block->setData('onclick','return getEbaySession();');
|
| 10 |
+
$html = '<div>'.$block->toHtml().'</div>';
|
| 11 |
+
$html.= '<script type=text/javascript>
|
| 12 |
+
function getEbaySession(){
|
| 13 |
+
setLocation("'.$this->helper('adminhtml')->getUrl('web4pro_ebay_admin/adminhtml_system/session').'");
|
| 14 |
+
return false;
|
| 15 |
+
}</script>';
|
| 16 |
+
$element->setAfterElementHtml($html);
|
| 17 |
+
|
| 18 |
+
return parent::_getElementHtml($element);
|
| 19 |
+
}*/
|
| 20 |
+
public function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
|
| 21 |
+
{
|
| 22 |
+
$html = '
|
| 23 |
+
<h3><p>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.</p></h3>
|
| 24 |
+
<h3 align="center">Google merchants extension setting up:</h3>
|
| 25 |
+
<ul style="list-style-type: decimal;">
|
| 26 |
+
<li>See <a href="https://support.google.com/merchants/answer/188494" target="_blank"> the documentation </a> for google feed.</li>
|
| 27 |
+
<li>Set up necessary product attributes on “Google attributes” tab:
|
| 28 |
+
<img src="https://docs.google.com/drawings/d/1BdC5Fj0IgBs0evVO4m_32glUadIIVHAy-em6oeFGpJA/pub?w=960&h=720" alt="Set up google attributes" width="650" height="400">
|
| 29 |
+
</li>
|
| 30 |
+
<li>Go to <a href="' . $this->_getGoogleCategoriesUrl() . '" target="_blank">Web4pro → Manage Google Merchants settings → Manage Google Categories </a> and follow the instructions.</li>
|
| 31 |
+
<li>Attach all categories in your store to Google categories. Just click on google category, select store category and click “Save”:
|
| 32 |
+
<img src="https://docs.google.com/drawings/d/1Y2IYm9WfmFMCU9YRbbrKPdPspinBE1paJoW8nE4n0X8/pub?w=640&h=413" alt="Upload filewith categories">
|
| 33 |
+
</li>
|
| 34 |
+
<li><p>And the last step is setting up feed. You need to choose necessary attributes, which you would like to import.</p>
|
| 35 |
+
<p>Go to <a href="' . $this->_getFeedSettingsUrl() . '">Web4pro → Manage Google Merchants settings → Configure Feed settings </a>:
|
| 36 |
+
and setup all necessary attributes according to <a href="https://support.google.com/merchants/answer/188494" target="_blank">feed specification</a>:</p>
|
| 37 |
+
<img src="https://docs.google.com/drawings/d/1_e2PsWJTsMIDuFt0Mgp6hWHGLyvWnD7rfh84gRMlfwk/pub?w=650&h=370" alt="Set up feed settings" width="650">
|
| 38 |
+
</li>
|
| 39 |
+
|
| 40 |
+
<li>Set up necessary settings of importing products (Web4pro → Manage Google Merchants settings → Manage Google Merchants settings -> Manage Google Feed settings) ↓ :
|
| 41 |
+
</li>
|
| 42 |
+
|
| 43 |
+
<ul>
|
| 44 |
+
</br>
|
| 45 |
+
</br>
|
| 46 |
+
</br>
|
| 47 |
+
<h3 align="center">Set up import settings:</h3>
|
| 48 |
+
';
|
| 49 |
+
return $html;
|
| 50 |
+
}
|
| 51 |
+
|
| 52 |
+
protected function _getGoogleCategoriesUrl()
|
| 53 |
+
{
|
| 54 |
+
return Mage::helper("adminhtml")->getUrl('adminhtml/googlemerchants/index');
|
| 55 |
+
}
|
| 56 |
+
|
| 57 |
+
protected function _getFeedSettingsUrl()
|
| 58 |
+
{
|
| 59 |
+
return Mage::helper("adminhtml")->getUrl('adminhtml/googlemerchants/feed');
|
| 60 |
+
}
|
| 61 |
+
|
| 62 |
+
}
|
app/code/community/Web4pro/Googlemerchants/Block/Adminhtml/Upload/File.php
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
/**
|
| 4 |
+
* WEB4PRO - Creating profitable online stores
|
| 5 |
+
*
|
| 6 |
+
*
|
| 7 |
+
* @author WEB4PRO <achernyshev@web4pro.com.ua>
|
| 8 |
+
* @category WEB4PRO
|
| 9 |
+
* @package Web4pro_Googlemerchants
|
| 10 |
+
* @copyright Copyright (c) 2014 WEB4PRO (http://www.web4pro.net)
|
| 11 |
+
* @license http://www.web4pro.net/license.txt
|
| 12 |
+
*/
|
| 13 |
+
class Web4pro_Googlemerchants_Block_Adminhtml_Upload_File extends Mage_Adminhtml_Block_Widget_Form
|
| 14 |
+
{
|
| 15 |
+
|
| 16 |
+
/**
|
| 17 |
+
* @return Mage_Adminhtml_Block_Widget_Form
|
| 18 |
+
* @throws Exception
|
| 19 |
+
*/
|
| 20 |
+
protected function _prepareForm()
|
| 21 |
+
{
|
| 22 |
+
$form = new Varien_Data_Form(array(
|
| 23 |
+
'id' => 'edit_form',
|
| 24 |
+
'action' => $this->getUrl('*/*/savetxt', array('id' => $this->getRequest()->getParam('id'))),
|
| 25 |
+
'method' => 'post',
|
| 26 |
+
'enctype' => 'multipart/form-data'
|
| 27 |
+
)
|
| 28 |
+
);
|
| 29 |
+
$form->setUseContainer(true);
|
| 30 |
+
|
| 31 |
+
$this->setForm($form);
|
| 32 |
+
|
| 33 |
+
|
| 34 |
+
$fieldset = $form->addFieldset('googlemerchants_form', array('legend' => Mage::helper('googlemerchants')->__('Uploading file with google categories.')));
|
| 35 |
+
$fieldset->addType('extended_link', 'Web4pro_Googlemerchants_Block_Adminhtml_Upload_Link_Renderer');
|
| 36 |
+
|
| 37 |
+
$fieldset->addField('title', 'extended_link', array(
|
| 38 |
+
'class' => 'required-entry',
|
| 39 |
+
//'value' => 'Click <a href="https://support.google.com/merchants/answer/160081" target="_blank">here</a> for downloading google categories file.',
|
| 40 |
+
'disabled' => false,
|
| 41 |
+
'readonly' => true,
|
| 42 |
+
|
| 43 |
+
));
|
| 44 |
+
|
| 45 |
+
$fieldset->addField('fileinputname', 'file', array(
|
| 46 |
+
'required' => true,
|
| 47 |
+
'name' => 'fileinputname',
|
| 48 |
+
'class' => 'form-button-custom'
|
| 49 |
+
));
|
| 50 |
+
$fieldset->addField('submit', 'submit', array(
|
| 51 |
+
'value' => 'Start Import',
|
| 52 |
+
'class' => 'form-button form-button-custom',
|
| 53 |
+
'action' => $this->getUrl('*/*/savetxt'),
|
| 54 |
+
'tabindex' => 1,
|
| 55 |
+
));
|
| 56 |
+
|
| 57 |
+
return parent::_prepareForm();
|
| 58 |
+
}
|
| 59 |
+
}
|
app/code/community/Web4pro/Googlemerchants/Block/Adminhtml/Upload/Form/Container.php
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
/**
|
| 4 |
+
* WEB4PRO - Creating profitable online stores
|
| 5 |
+
*
|
| 6 |
+
*
|
| 7 |
+
* @author WEB4PRO <achernyshev@web4pro.com.ua>
|
| 8 |
+
* @category WEB4PRO
|
| 9 |
+
* @package Web4pro_Googlemerchants
|
| 10 |
+
* @copyright Copyright (c) 2014 WEB4PRO (http://www.web4pro.net)
|
| 11 |
+
* @license http://www.web4pro.net/license.txt
|
| 12 |
+
*/
|
| 13 |
+
class Web4pro_Googlemerchants_Block_Adminhtml_Upload_Form_Container extends Mage_Adminhtml_Block_Widget_Form_Container
|
| 14 |
+
{
|
| 15 |
+
protected $_headerText = 'Upload file with google categories';
|
| 16 |
+
|
| 17 |
+
/**
|
| 18 |
+
* @return $this
|
| 19 |
+
*/
|
| 20 |
+
protected function _prepareLayout()
|
| 21 |
+
{
|
| 22 |
+
foreach ($this->_buttons as $level => $buttons) {
|
| 23 |
+
foreach ($buttons as $id => $data) {
|
| 24 |
+
$childId = $this->_prepareButtonBlockId($id);
|
| 25 |
+
$this->_addButtonChildBlock($childId);
|
| 26 |
+
}
|
| 27 |
+
}
|
| 28 |
+
$this->removeButton('back');
|
| 29 |
+
$this->removeButton('reset');
|
| 30 |
+
$this->removeButton('save');
|
| 31 |
+
return $this;
|
| 32 |
+
}
|
| 33 |
+
|
| 34 |
+
/**
|
| 35 |
+
* @return string
|
| 36 |
+
*/
|
| 37 |
+
public function getFormHtml()
|
| 38 |
+
{
|
| 39 |
+
$form = $this->getLayout()->createBlock('googlemerchants/adminhtml_upload_file');
|
| 40 |
+
return $form->toHtml();
|
| 41 |
+
}
|
| 42 |
+
|
| 43 |
+
}
|
app/code/community/Web4pro/Googlemerchants/Block/Adminhtml/Upload/Link/Renderer.php
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
class Web4pro_Googlemerchants_Block_Adminhtml_Upload_Link_Renderer extends Varien_Data_Form_Element_Abstract
|
| 4 |
+
{
|
| 5 |
+
/**
|
| 6 |
+
* @param array $attributes
|
| 7 |
+
*/
|
| 8 |
+
public function __construct($attributes = array())
|
| 9 |
+
{
|
| 10 |
+
parent::__construct($attributes);
|
| 11 |
+
$this->setType('label');
|
| 12 |
+
}
|
| 13 |
+
|
| 14 |
+
/**
|
| 15 |
+
* @return string
|
| 16 |
+
*/
|
| 17 |
+
|
| 18 |
+
public function getElementHtml()
|
| 19 |
+
{
|
| 20 |
+
return '';
|
| 21 |
+
}
|
| 22 |
+
|
| 23 |
+
public function getLabelHtml()
|
| 24 |
+
{
|
| 25 |
+
$html = '<div>
|
| 26 |
+
<h3>Import google categories in two easy steps:</h3>
|
| 27 |
+
<ul style="list-style-type: circle;">
|
| 28 |
+
<li><p>1. Download file with google merchants categories <a href="https://support.google.com/merchants/answer/160081">here:</a></p>
|
| 29 |
+
<div id="upload-hint-image">
|
| 30 |
+
<img src="https://docs.google.com/drawings/d/1WB73TBx5S7Q9gfRzzh98BR_qLaHWGn8zJ-1KrKXhcvA/pub?w=749&h=462" alt="Download file with categories">
|
| 31 |
+
</div>
|
| 32 |
+
</li>
|
| 33 |
+
<li>
|
| 34 |
+
<span>2. Select downloaded file and click on button "Start import":</span>
|
| 35 |
+
</li>
|
| 36 |
+
</ul>
|
| 37 |
+
</div>
|
| 38 |
+
';
|
| 39 |
+
return $html;
|
| 40 |
+
}
|
| 41 |
+
|
| 42 |
+
}
|
app/code/community/Web4pro/Googlemerchants/Helper/Data.php
ADDED
|
@@ -0,0 +1,195 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
/**
|
| 4 |
+
* WEB4PRO - Creating profitable online stores
|
| 5 |
+
*
|
| 6 |
+
*
|
| 7 |
+
* @author WEB4PRO <achernyshev@web4pro.com.ua>
|
| 8 |
+
* @category WEB4PRO
|
| 9 |
+
* @package Web4pro_Googlemerchants
|
| 10 |
+
* @copyright Copyright (c) 2014 WEB4PRO (http://www.web4pro.net)
|
| 11 |
+
* @license http://www.web4pro.net/license.txt
|
| 12 |
+
*/
|
| 13 |
+
class Web4pro_Googlemerchants_Helper_Data extends Mage_Core_Helper_Abstract
|
| 14 |
+
{
|
| 15 |
+
/**
|
| 16 |
+
* @var null
|
| 17 |
+
*/
|
| 18 |
+
protected $_defaultStoreId = NULL;
|
| 19 |
+
|
| 20 |
+
/**
|
| 21 |
+
* @param Web4pro_Googlemerchants_Model_Googlecategory $entity
|
| 22 |
+
* @return array
|
| 23 |
+
*/
|
| 24 |
+
public function categoryEntityToTreeStd(Web4pro_Googlemerchants_Model_Googlecategory $entity)
|
| 25 |
+
{
|
| 26 |
+
$retObject = new stdClass();
|
| 27 |
+
$categoryName = $entity->getTitle();
|
| 28 |
+
$categoryId = $entity->getCategoryId();
|
| 29 |
+
$childrenCount = Mage::getModel('googlemerchants/googlecategory')->getChildrenCount($categoryId);
|
| 30 |
+
$class = 'folder active-category';
|
| 31 |
+
|
| 32 |
+
$retArray = array('text' => $categoryName, 'id' => $categoryId, 'cls' => $class, 'allowDrop' => false, 'allowDrag' => false,
|
| 33 |
+
'store' => 0, 'expanded' => false);
|
| 34 |
+
|
| 35 |
+
if ($childrenCount > 0) {
|
| 36 |
+
$retArray['children'] = array();
|
| 37 |
+
}
|
| 38 |
+
return $retArray;
|
| 39 |
+
}
|
| 40 |
+
|
| 41 |
+
/**
|
| 42 |
+
* @return array
|
| 43 |
+
*/
|
| 44 |
+
public function getRootCategoriesIds()
|
| 45 |
+
{
|
| 46 |
+
$rootCatIds = array();
|
| 47 |
+
foreach (Mage::app()->getWebsites() as $website) {
|
| 48 |
+
foreach ($website->getGroups() as $group) {
|
| 49 |
+
$stores = $group->getStores();
|
| 50 |
+
foreach ($stores as $store) {
|
| 51 |
+
$rootCatIds [] = $store->getRootCategoryId();
|
| 52 |
+
}
|
| 53 |
+
}
|
| 54 |
+
}
|
| 55 |
+
return array_unique($rootCatIds);
|
| 56 |
+
}
|
| 57 |
+
|
| 58 |
+
/**
|
| 59 |
+
* @return mixed
|
| 60 |
+
*/
|
| 61 |
+
public function getGoogleCategoriesCount()
|
| 62 |
+
{
|
| 63 |
+
return Mage::getModel('googlemerchants/googlecategory')->getCollection()->count();
|
| 64 |
+
}
|
| 65 |
+
|
| 66 |
+
/**
|
| 67 |
+
* @param $code
|
| 68 |
+
* @return bool|Mage_Core_Model_Store
|
| 69 |
+
*/
|
| 70 |
+
public function getStoreByCode($code)
|
| 71 |
+
{
|
| 72 |
+
|
| 73 |
+
$stores = array_keys(Mage::app()->getStores());
|
| 74 |
+
foreach ($stores as $id) {
|
| 75 |
+
$store = Mage::app()->getStore($id);
|
| 76 |
+
if ($store->getCode() == $code) {
|
| 77 |
+
return $store;
|
| 78 |
+
}
|
| 79 |
+
}
|
| 80 |
+
return false;
|
| 81 |
+
}
|
| 82 |
+
|
| 83 |
+
/**
|
| 84 |
+
* @return mixed
|
| 85 |
+
* @throws Mage_Core_Exception
|
| 86 |
+
*/
|
| 87 |
+
public function getSelectedStore()
|
| 88 |
+
{
|
| 89 |
+
$storeCode = Mage::app()->getRequest()->getParam('store');
|
| 90 |
+
if (empty($storeCode)) {
|
| 91 |
+
$defaultStoreId = Mage::app()
|
| 92 |
+
->getWebsite(true)
|
| 93 |
+
->getDefaultGroup()
|
| 94 |
+
->getDefaultStoreId();
|
| 95 |
+
$store = Mage::getModel('core/store')->load($defaultStoreId);
|
| 96 |
+
$storeCode = $store->getCode();
|
| 97 |
+
}
|
| 98 |
+
return $storeCode;
|
| 99 |
+
}
|
| 100 |
+
|
| 101 |
+
/**
|
| 102 |
+
* @param $product
|
| 103 |
+
* @return string
|
| 104 |
+
*/
|
| 105 |
+
public function getParentName($product)
|
| 106 |
+
{
|
| 107 |
+
$parentIds = array();
|
| 108 |
+
if ($product->getTypeId() == "simple") {
|
| 109 |
+
$parentIds = $this->getParentIds($product);
|
| 110 |
+
if (isset($parentIds[0])) {
|
| 111 |
+
$parentProduct = Mage::getModel('catalog/product')->load($parentIds[0]);
|
| 112 |
+
return $parentProduct->getName();
|
| 113 |
+
}
|
| 114 |
+
}
|
| 115 |
+
return '';
|
| 116 |
+
}
|
| 117 |
+
|
| 118 |
+
public function getParentIds($product)
|
| 119 |
+
{
|
| 120 |
+
$parentIds = array();
|
| 121 |
+
if ($product->getTypeId() == "simple") {
|
| 122 |
+
$parentIdsGrouped = Mage::getModel('catalog/product_type_grouped')->getParentIdsByChild($product->getId());
|
| 123 |
+
$parentIdsConfigurable = Mage::getModel('catalog/product_type_configurable')->getParentIdsByChild($product->getId());
|
| 124 |
+
$parentIdsBundle = Mage::getModel('bundle/product_type')->getParentIdsByChild($product->getId());
|
| 125 |
+
$parentIds = array_merge($parentIdsGrouped, $parentIdsConfigurable, $parentIdsBundle);
|
| 126 |
+
}
|
| 127 |
+
return $parentIds;
|
| 128 |
+
}
|
| 129 |
+
|
| 130 |
+
public function getProductUrl($product)
|
| 131 |
+
{
|
| 132 |
+
$productVisibility = $product->getVisibility();
|
| 133 |
+
$urlKey = $product->getProductUrl();
|
| 134 |
+
if ($productVisibility != 4) {
|
| 135 |
+
$parentProductId = $this->getParentIds($product);
|
| 136 |
+
$parentCollection = Mage::getModel('catalog/product')->getCollection()->addAttributeToFilter('visibility', array('eq' => 4));
|
| 137 |
+
$parentProduct = $parentCollection->getFirstItem();
|
| 138 |
+
$urlKey = $parentProduct->getProductUrl();
|
| 139 |
+
}
|
| 140 |
+
return $urlKey;
|
| 141 |
+
}
|
| 142 |
+
|
| 143 |
+
public function getMinPrice($product)
|
| 144 |
+
{
|
| 145 |
+
$productType = $product->getTypeID();
|
| 146 |
+
$priseStr = '';
|
| 147 |
+
switch ($productType) {
|
| 148 |
+
case 'configurable':
|
| 149 |
+
$childProducts = Mage::getModel('catalog/product_type_configurable')->getUsedProducts(null,$product);
|
| 150 |
+
$minPrice = "";
|
| 151 |
+
foreach($childProducts as $child){
|
| 152 |
+
$_child = Mage::getModel('catalog/product')->load($child->getId());
|
| 153 |
+
|
| 154 |
+
if($minPrice == '' || $minPrice > $_child->getPrice() )
|
| 155 |
+
$minPrice = $_child->getPrice();
|
| 156 |
+
|
| 157 |
+
}
|
| 158 |
+
$priseStr = $minPrice;
|
| 159 |
+
break;
|
| 160 |
+
case 'grouped':
|
| 161 |
+
$productIds = $product->getTypeInstance()->getChildrenIds($product->getId());
|
| 162 |
+
$prices = array();
|
| 163 |
+
foreach ($productIds as $ids) {
|
| 164 |
+
foreach ($ids as $id) {
|
| 165 |
+
$aProduct = Mage::getModel('catalog/product')->load($id);
|
| 166 |
+
$prices[] = (float) $aProduct->getPriceModel()->getPrice($aProduct);
|
| 167 |
+
}
|
| 168 |
+
}
|
| 169 |
+
sort($prices);
|
| 170 |
+
if(is_array($prices)) {
|
| 171 |
+
$priseStr = (string) current($prices);
|
| 172 |
+
}
|
| 173 |
+
break;
|
| 174 |
+
case 'bundle':
|
| 175 |
+
$selectionCollection = $product->getTypeInstance(true)->getSelectionsCollection(
|
| 176 |
+
$product->getTypeInstance(true)->getOptionsIds($product), $product);
|
| 177 |
+
foreach ($selectionCollection as $option) {
|
| 178 |
+
if ($option->getPrice() != "0.0000") {
|
| 179 |
+
$bundlePrices [] = $option->getPrice();
|
| 180 |
+
}
|
| 181 |
+
}
|
| 182 |
+
sort($bundlePrices);
|
| 183 |
+
if(is_array($bundlePrices)) {
|
| 184 |
+
$priseStr = current($bundlePrices);
|
| 185 |
+
}
|
| 186 |
+
break;
|
| 187 |
+
case 'downloadable':
|
| 188 |
+
$priseStr = sprintf("%0.2f", $product->getFinalPrice());
|
| 189 |
+
break;
|
| 190 |
+
default:
|
| 191 |
+
$priseStr = sprintf("%0.2f", $product->getFinalPrice());
|
| 192 |
+
}
|
| 193 |
+
return $priseStr;
|
| 194 |
+
}
|
| 195 |
+
}
|
app/code/community/Web4pro/Googlemerchants/Model/Googlecategory.php
ADDED
|
@@ -0,0 +1,172 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
/**
|
| 4 |
+
* WEB4PRO - Creating profitable online stores
|
| 5 |
+
*
|
| 6 |
+
*
|
| 7 |
+
* @author WEB4PRO <achernyshev@web4pro.com.ua>
|
| 8 |
+
* @category WEB4PRO
|
| 9 |
+
* @package Web4pro_Googlemerchants
|
| 10 |
+
* @copyright Copyright (c) 2014 WEB4PRO (http://www.web4pro.net)
|
| 11 |
+
* @license http://www.web4pro.net/license.txt
|
| 12 |
+
*/
|
| 13 |
+
class Web4pro_Googlemerchants_Model_Googlecategory extends Mage_Core_Model_Abstract
|
| 14 |
+
{
|
| 15 |
+
protected $_items = array(), $_iterator = 0, $_collection, $_model = NULL, $_rootCategoryId = NULL;
|
| 16 |
+
const TREE_ROOT_NAME = 'Root google category';
|
| 17 |
+
|
| 18 |
+
public function _construct()
|
| 19 |
+
{
|
| 20 |
+
parent::_construct();
|
| 21 |
+
$this->_init('googlemerchants/googlecategory');
|
| 22 |
+
$this->_collection = $this->getCollection();
|
| 23 |
+
$this->_iterator = 0;
|
| 24 |
+
}
|
| 25 |
+
|
| 26 |
+
/**
|
| 27 |
+
* @param $name
|
| 28 |
+
* @param $parentCatName
|
| 29 |
+
* @return bool
|
| 30 |
+
*/
|
| 31 |
+
public function insertItem($name, $parentCatName)
|
| 32 |
+
{
|
| 33 |
+
$name = trim($name);
|
| 34 |
+
$parentCatName = trim($parentCatName);
|
| 35 |
+
$itemExist = $this->getCollection()->addFieldToFilter('title', array('eq' => $name));
|
| 36 |
+
if ($itemExist->count() > 0) {
|
| 37 |
+
return false;
|
| 38 |
+
}
|
| 39 |
+
$parentId = $this->getRootCategoryId();
|
| 40 |
+
if ($parentCatName !== NULL) {
|
| 41 |
+
$parentItem = $this->getCollection()->addFieldToFilter('title', array('eq' => $parentCatName))->getFirstItem();
|
| 42 |
+
$parentCatId = $parentItem->getCategoryId();
|
| 43 |
+
if (!empty($parentCatId)) {
|
| 44 |
+
$parentId = $parentCatId;
|
| 45 |
+
}
|
| 46 |
+
}
|
| 47 |
+
|
| 48 |
+
$table = Mage::getModel('core/resource')->getTableName('googlemerchants_cats');
|
| 49 |
+
$write = Mage::getModel('core/resource')->getConnection('core_write');
|
| 50 |
+
$write->insert($table, array('title' => $name, 'status' => 0, 'parent_id' => $parentId));
|
| 51 |
+
}
|
| 52 |
+
|
| 53 |
+
/**
|
| 54 |
+
* @param string $rootCatName
|
| 55 |
+
*/
|
| 56 |
+
public function insertRoot($rootCatName = '')
|
| 57 |
+
{
|
| 58 |
+
if (empty($rootCatName)) {
|
| 59 |
+
$rootCatName = Web4pro_Googlemerchants_Model_Googlecategory::TREE_ROOT_NAME;
|
| 60 |
+
}
|
| 61 |
+
$rootItems = $this->getCollection()->addFieldToFilter('title', array('eq' => $rootCatName));
|
| 62 |
+
if ($rootItems->count() > 0) {
|
| 63 |
+
return;
|
| 64 |
+
}
|
| 65 |
+
$table = Mage::getModel('core/resource')->getTableName('googlemerchants_cats');
|
| 66 |
+
$write = Mage::getModel('core/resource')->getConnection('core_write');
|
| 67 |
+
$write->insert($table, array('title' => $rootCatName, 'status' => 0, 'parent_id' => NULL));
|
| 68 |
+
|
| 69 |
+
}
|
| 70 |
+
|
| 71 |
+
/**
|
| 72 |
+
* @return null
|
| 73 |
+
*/
|
| 74 |
+
public function getRootCategoryId()
|
| 75 |
+
{
|
| 76 |
+
if ($this->_rootCategoryId === NULL) {
|
| 77 |
+
$rootCategoryName = Web4pro_Googlemerchants_Model_Googlecategory::TREE_ROOT_NAME;
|
| 78 |
+
$rootCategory = $this->getCollection()->addFieldToFilter('title', array('eq' => $rootCategoryName))->getFirstItem();
|
| 79 |
+
$this->_rootCategoryId = $rootCategory->getCategoryId();
|
| 80 |
+
}
|
| 81 |
+
return $this->_rootCategoryId;
|
| 82 |
+
}
|
| 83 |
+
|
| 84 |
+
/**
|
| 85 |
+
* clearing table with google categories
|
| 86 |
+
*/
|
| 87 |
+
|
| 88 |
+
public function truncateCategoriesTable()
|
| 89 |
+
{
|
| 90 |
+
$coreResourceModel = Mage::getSingleton('core/resource');
|
| 91 |
+
$resource = $coreResourceModel->getConnection('core_read');
|
| 92 |
+
$resource->query("truncate table " . $coreResourceModel->getTableName('googlemerchants_cats'));
|
| 93 |
+
}
|
| 94 |
+
|
| 95 |
+
/**
|
| 96 |
+
* @param null $categoryId
|
| 97 |
+
* @return mixed
|
| 98 |
+
*/
|
| 99 |
+
|
| 100 |
+
public function getChildrenCount($categoryId = NULL)
|
| 101 |
+
{
|
| 102 |
+
if ($categoryId === NULL) {
|
| 103 |
+
$categoryId = $this->getCategoryId();
|
| 104 |
+
}
|
| 105 |
+
$collection = $this->getCollection()->addFieldToFilter('parent_id', array('eq' => $categoryId));
|
| 106 |
+
$count = $collection->count();
|
| 107 |
+
return $count;
|
| 108 |
+
}
|
| 109 |
+
|
| 110 |
+
/**
|
| 111 |
+
* @param $name
|
| 112 |
+
* @return null
|
| 113 |
+
*/
|
| 114 |
+
|
| 115 |
+
protected function _getParentCatIdByName($name)
|
| 116 |
+
{
|
| 117 |
+
if ($name === NULL || empty($name)) {
|
| 118 |
+
return NULL;
|
| 119 |
+
}
|
| 120 |
+
foreach ($this->_items as $item) {
|
| 121 |
+
$itemName = $item->getTitle();
|
| 122 |
+
if ($itemName == $name) {
|
| 123 |
+
return $item->getCategoryId();
|
| 124 |
+
}
|
| 125 |
+
}
|
| 126 |
+
}
|
| 127 |
+
|
| 128 |
+
public function getChildrenCategories($parentCategory)
|
| 129 |
+
{
|
| 130 |
+
$children = array();
|
| 131 |
+
if ($parentCategory instanceof Web4pro_Googlemerchants_Model_Googlecategory) {
|
| 132 |
+
$children = $this->getCollection()->addFieldToFilter('parent_id', array('eq' => $parentCategory->getCategoryId()))
|
| 133 |
+
->addFieldToFilter('category_id', array('neq' => $this->getRootCategoryId()));
|
| 134 |
+
} else if (is_numeric($parentCategory)) {
|
| 135 |
+
$children = $this->getCollection()->addFieldToFilter('parent_id', array('eq' => $parentCategory))
|
| 136 |
+
->addFieldToFilter('category_id', array('neq' => $this->getRootCategoryId()));
|
| 137 |
+
}
|
| 138 |
+
return $children;
|
| 139 |
+
}
|
| 140 |
+
|
| 141 |
+
public function getCategoriesStr($storeCatIds)
|
| 142 |
+
{
|
| 143 |
+
$categoriesStr = '';
|
| 144 |
+
$categoriesArr = array();
|
| 145 |
+
if (!empty($storeCatIds)) {
|
| 146 |
+
if (is_array($storeCatIds)) {
|
| 147 |
+
$storeCatIds = current($storeCatIds);
|
| 148 |
+
}
|
| 149 |
+
$category = $this->load($storeCatIds);
|
| 150 |
+
$categoriesArr [] = $category->getTitle();
|
| 151 |
+
$parentId = $category->getParentId();
|
| 152 |
+
while ($parentId !== NULL) {
|
| 153 |
+
$category = $this->load($parentId);
|
| 154 |
+
$categoriesArr [] = $category->getTitle();
|
| 155 |
+
$parentId = $category->getParrentId();
|
| 156 |
+
}
|
| 157 |
+
|
| 158 |
+
}
|
| 159 |
+
return implode('>', $categoriesArr);
|
| 160 |
+
}
|
| 161 |
+
|
| 162 |
+
public function isRootCategory($categoryId)
|
| 163 |
+
{
|
| 164 |
+
$category = $this->load($categoryId);
|
| 165 |
+
$parentCategoryId = $category->getData('parent_id');
|
| 166 |
+
if ($parentCategoryId === NULL) {
|
| 167 |
+
return true;
|
| 168 |
+
}
|
| 169 |
+
return false;
|
| 170 |
+
}
|
| 171 |
+
|
| 172 |
+
}
|
app/code/community/Web4pro/Googlemerchants/Model/Googlefeed.php
ADDED
|
@@ -0,0 +1,300 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
/**
|
| 4 |
+
* WEB4PRO - Creating profitable online stores
|
| 5 |
+
*
|
| 6 |
+
*
|
| 7 |
+
* @author WEB4PRO <achernyshev@web4pro.com.ua>
|
| 8 |
+
* @category WEB4PRO
|
| 9 |
+
* @package Web4pro_Googlemerchants
|
| 10 |
+
* @copyright Copyright (c) 2014 WEB4PRO (http://www.web4pro.net)
|
| 11 |
+
* @license http://www.web4pro.net/license.txt
|
| 12 |
+
*/
|
| 13 |
+
class Web4pro_Googlemerchants_Model_Googlefeed extends Mage_Core_Model_Abstract
|
| 14 |
+
{
|
| 15 |
+
protected $_attributesArray = NULL, $_productCollection = NULL, $_path = 'googlemerchants_options/general/google_feed_prameters', $_notAttachedCategoriesExists = false, $_attributesCollection,
|
| 16 |
+
$_defaultParameters = array(
|
| 17 |
+
array('value' => 'id', 'selected' => 'product_id'),
|
| 18 |
+
array('value' => 'title', 'selected' => 'name'),
|
| 19 |
+
array('value' => 'description', 'selected' => 'description'),
|
| 20 |
+
array('value' => 'price', 'selected' => 'price'),
|
| 21 |
+
array('value' => 'condition', 'selected' => 'condition_google'),
|
| 22 |
+
array('value' => 'image link', 'selected' => 'image'),
|
| 23 |
+
array('value' => 'gtin', 'selected' => 'gtin_google'),
|
| 24 |
+
array('value' => 'color', 'selected' => 'color'),
|
| 25 |
+
array('value' => 'size', 'selected' => 'size'),
|
| 26 |
+
array('value' => 'mpn', 'selected' => 'mpn_google'),
|
| 27 |
+
array('value' => 'category', 'selected' => 'google_category'),
|
| 28 |
+
array('value' => 'tax', 'selected' => 'google_tax'),
|
| 29 |
+
array('value' => 'link', 'selected' => 'google_product_link'),
|
| 30 |
+
array('value' => 'availability', 'selected' => 'google_availability'));
|
| 31 |
+
|
| 32 |
+
const PATH_TO_GENERATE = 'var/productsfeed';
|
| 33 |
+
|
| 34 |
+
public function _construct()
|
| 35 |
+
{
|
| 36 |
+
parent::_construct();
|
| 37 |
+
$this->_init('googlemerchants/googlefeed');
|
| 38 |
+
$this->_setProductsCollection();
|
| 39 |
+
}
|
| 40 |
+
|
| 41 |
+
/**
|
| 42 |
+
* @param null $collection
|
| 43 |
+
*/
|
| 44 |
+
protected function _setProductsCollection($collection = NULL)
|
| 45 |
+
{
|
| 46 |
+
if ($this->_productCollection === NULL) {
|
| 47 |
+
$collection = Mage::getResourceModel('catalog/product_collection')->addAttributeToFilter('visibility', array('in' => array(1, 2, 3, 4)))->addAttributeToSelect('*');
|
| 48 |
+
$this->_productCollection = $collection;
|
| 49 |
+
}
|
| 50 |
+
$this->_setCollectionConfigConditions();
|
| 51 |
+
}
|
| 52 |
+
|
| 53 |
+
/**
|
| 54 |
+
* @return null
|
| 55 |
+
*/
|
| 56 |
+
public function getProductsCollection()
|
| 57 |
+
{
|
| 58 |
+
return $this->_productCollection;
|
| 59 |
+
}
|
| 60 |
+
|
| 61 |
+
/**
|
| 62 |
+
* @return array
|
| 63 |
+
*/
|
| 64 |
+
protected function _getHeaderRow()
|
| 65 |
+
{
|
| 66 |
+
$attributes = $this->getFeedConfig();
|
| 67 |
+
$retArray = array();
|
| 68 |
+
foreach ($attributes as $attribute) {
|
| 69 |
+
if (!empty($attribute['value'])) {
|
| 70 |
+
$retArray [] = $attribute['value'];
|
| 71 |
+
}
|
| 72 |
+
}
|
| 73 |
+
return $retArray;
|
| 74 |
+
}
|
| 75 |
+
|
| 76 |
+
/**
|
| 77 |
+
* generating feed file
|
| 78 |
+
*/
|
| 79 |
+
public function generateFeed()
|
| 80 |
+
{
|
| 81 |
+
$attributes = $this->getFeedConfig();
|
| 82 |
+
$pathToSave = Mage::getBaseDir() . '/' . self::PATH_TO_GENERATE;
|
| 83 |
+
$pathToSave = $this->_createDirIfNotExists($pathToSave);
|
| 84 |
+
$googleCategoriesModel = Mage::getModel('googlemerchants/googlecategory');
|
| 85 |
+
$googleShippingModel = Mage::getModel('googlemerchants/googleshipping');
|
| 86 |
+
$stockModel = Mage::getModel('cataloginventory/stock_item');
|
| 87 |
+
$helper = Mage::helper('googlemerchants');
|
| 88 |
+
$headerRow = $this->_getHeaderRow();
|
| 89 |
+
$fileNameInConfig = Mage::getStoreConfig('googlemerchants_options/general/google_feedfilename');
|
| 90 |
+
if (empty($fileNameInConfig)) {
|
| 91 |
+
$fileNameInConfig = 'product_feed';
|
| 92 |
+
}
|
| 93 |
+
$fileName = $pathToSave . '/' . $fileNameInConfig . '.csv';
|
| 94 |
+
$file = fopen($fileName, "w");
|
| 95 |
+
fputcsv($file, $headerRow);
|
| 96 |
+
$storeCode = Mage::helper('googlemerchants')->getSelectedStore();
|
| 97 |
+
foreach ($this->_productCollection as $product) {
|
| 98 |
+
$productArray = array();
|
| 99 |
+
foreach ($attributes as $attribute) {
|
| 100 |
+
$attributeCode = $attribute['selected'];
|
| 101 |
+
switch ($attributeCode) {
|
| 102 |
+
case 'product_id' :
|
| 103 |
+
$attributeCode = 'entity_id';
|
| 104 |
+
$productArray [] = $product->getData($attributeCode);
|
| 105 |
+
break;
|
| 106 |
+
case 'google_category' :
|
| 107 |
+
$categoriesStr = $googleCategoriesModel->getCategoriesStr($product->getCategoryIds());
|
| 108 |
+
if (empty($categoriesStr)) {
|
| 109 |
+
$this->_notAttachedCategoriesExists = true;
|
| 110 |
+
}
|
| 111 |
+
$productArray [] = $categoriesStr;
|
| 112 |
+
break;
|
| 113 |
+
case 'shipping_cost' :
|
| 114 |
+
$productArray [] = $googleShippingModel->getShippingCost($product);
|
| 115 |
+
break;
|
| 116 |
+
case 'image' :
|
| 117 |
+
$image = '';
|
| 118 |
+
try {
|
| 119 |
+
$image = Mage::helper('catalog/image')->init($product, 'thumbnail');
|
| 120 |
+
if (empty($image)) {
|
| 121 |
+
$image = $product->getImageUrl();
|
| 122 |
+
}
|
| 123 |
+
} catch (Exception $e) {
|
| 124 |
+
Mage::logException($e);
|
| 125 |
+
}
|
| 126 |
+
if(is_string($image)) {
|
| 127 |
+
$productArray [] = $image;
|
| 128 |
+
}
|
| 129 |
+
else {
|
| 130 |
+
$productArray [] = '';
|
| 131 |
+
}
|
| 132 |
+
break;
|
| 133 |
+
case 'parent_name' :
|
| 134 |
+
$productArray [] = Mage::helper('googlemerchants')->getParentName($product);
|
| 135 |
+
break;
|
| 136 |
+
case 'google_tax' :
|
| 137 |
+
$productArray [] = Mage::getModel('googlemerchants/googletax')->getTaxValue($product);
|
| 138 |
+
break;
|
| 139 |
+
case 'google_product_link':
|
| 140 |
+
$productArray [] = Mage::helper('googlemerchants')->getProductUrl($product);
|
| 141 |
+
break;
|
| 142 |
+
case 'none':
|
| 143 |
+
$productArray [] = '';
|
| 144 |
+
break;
|
| 145 |
+
case 'price':
|
| 146 |
+
$productArray [] = $helper->getMinPrice($product);
|
| 147 |
+
break;
|
| 148 |
+
case 'google_availability':
|
| 149 |
+
|
| 150 |
+
$stockStatus = $stockModel->loadByProduct($product)->getIsInStock();
|
| 151 |
+
if($stockStatus) {
|
| 152 |
+
$stockStatus = 'in stock';
|
| 153 |
+
} else {
|
| 154 |
+
$stockStatus = 'out of stock';
|
| 155 |
+
}
|
| 156 |
+
$productArray [] = $stockStatus;
|
| 157 |
+
break;
|
| 158 |
+
default :
|
| 159 |
+
$attribute = $product->getResource()->getAttribute($attributeCode);
|
| 160 |
+
if ($attribute instanceof Mage_Catalog_Model_Resource_Eav_Attribute) {
|
| 161 |
+
$productArray [] = $attribute->getFrontend()->getValue($product);
|
| 162 |
+
}
|
| 163 |
+
break;
|
| 164 |
+
}
|
| 165 |
+
}
|
| 166 |
+
$productObj = new Varien_Object();
|
| 167 |
+
$productObj->setData($productArray);
|
| 168 |
+
Mage::dispatchEvent('feed_product_generate_data_after', array('product_data' => $productObj));
|
| 169 |
+
$productArray = $productObj->getData();
|
| 170 |
+
fputcsv($file, $productArray);
|
| 171 |
+
}
|
| 172 |
+
|
| 173 |
+
if ($this->_notAttachedCategoriesExists) {
|
| 174 |
+
Mage::getSingleton('adminhtml/session')->addError('Some store categories are not attached to any google category.');
|
| 175 |
+
}
|
| 176 |
+
fclose($file);
|
| 177 |
+
}
|
| 178 |
+
|
| 179 |
+
/**
|
| 180 |
+
* @param $path
|
| 181 |
+
* @return mixed
|
| 182 |
+
* creting directory and for google feed
|
| 183 |
+
*/
|
| 184 |
+
|
| 185 |
+
protected function _createDirIfNotExists($path)
|
| 186 |
+
{
|
| 187 |
+
if (!file_exists($path)) {
|
| 188 |
+
mkdir($path);
|
| 189 |
+
}
|
| 190 |
+
$files = glob($path . '/*');
|
| 191 |
+
foreach ($files as $file) {
|
| 192 |
+
if (is_file($file))
|
| 193 |
+
unlink($file);
|
| 194 |
+
}
|
| 195 |
+
return $path;
|
| 196 |
+
}
|
| 197 |
+
|
| 198 |
+
/**
|
| 199 |
+
* @return array
|
| 200 |
+
* returning feed parameters
|
| 201 |
+
*/
|
| 202 |
+
public function getFeedConfig()
|
| 203 |
+
{
|
| 204 |
+
$feedConfig = Mage::getStoreConfig('googlemerchants_options/general/google_feed_prameters', Mage::helper('googlemerchants')->getSelectedStore());
|
| 205 |
+
if (empty($feedConfig)) {
|
| 206 |
+
return $this->_defaultParameters;
|
| 207 |
+
}
|
| 208 |
+
$unserializedConfig = unserialize($feedConfig);
|
| 209 |
+
if (empty($unserializedConfig)) {
|
| 210 |
+
return $this->_defaultParameters;
|
| 211 |
+
}
|
| 212 |
+
$feedConfig = unserialize($feedConfig);
|
| 213 |
+
$resArr = array();
|
| 214 |
+
foreach ($feedConfig as $key => $field) {
|
| 215 |
+
$resArr [] = array('value' => $key, 'selected' => $field);
|
| 216 |
+
}
|
| 217 |
+
return $resArr;
|
| 218 |
+
}
|
| 219 |
+
|
| 220 |
+
/**
|
| 221 |
+
* @param $value
|
| 222 |
+
* @param string $storeCode
|
| 223 |
+
* @return $this
|
| 224 |
+
* @throws Exception
|
| 225 |
+
*/
|
| 226 |
+
public function setFeedConfig($value, $storeCode = '')
|
| 227 |
+
{
|
| 228 |
+
|
| 229 |
+
$config = Mage::getModel('core/config_data');
|
| 230 |
+
$config->setValue(serialize($value));
|
| 231 |
+
$config->setPath($this->_path);
|
| 232 |
+
$config->setScope('stores');
|
| 233 |
+
$storeCode = Mage::helper('googlemerchants')->getSelectedStore();
|
| 234 |
+
if (empty($storeCode)) {
|
| 235 |
+
$storeCode = Mage::app()->getStore()->getCode();
|
| 236 |
+
}
|
| 237 |
+
$config->setScopeId(Mage::app()->getStore($storeCode)->getId());
|
| 238 |
+
$config->save();
|
| 239 |
+
Mage::getConfig()->reinit();
|
| 240 |
+
return $this;
|
| 241 |
+
}
|
| 242 |
+
|
| 243 |
+
/**
|
| 244 |
+
* add conditions for propducts collection
|
| 245 |
+
*/
|
| 246 |
+
protected function _setCollectionConfigConditions()
|
| 247 |
+
{
|
| 248 |
+
$inStockCondition = Mage::getStoreConfig('googlemerchants_options/general/google_feed_export_outofstock');
|
| 249 |
+
$enabledCondition = Mage::getStoreConfig('googlemerchants_options/general/google_feed_export_disabled');
|
| 250 |
+
$unvisibleCondition = Mage::getStoreConfig('googlemerchants_options/general/google_feed_export_unvisible');
|
| 251 |
+
if ($enabledCondition == 1) {
|
| 252 |
+
$this->_productCollection->addAttributeToFilter('status', array('eq' => Mage_Catalog_Model_Product_Status::STATUS_ENABLED));
|
| 253 |
+
}
|
| 254 |
+
if ($inStockCondition == 1) {
|
| 255 |
+
Mage::getSingleton('cataloginventory/stock')->addInStockFilterToCollection($this->_productCollection);
|
| 256 |
+
}
|
| 257 |
+
if ($unvisibleCondition != 1) {
|
| 258 |
+
$this->_productCollection->addAttributeToFilter('visibility', 4);
|
| 259 |
+
}
|
| 260 |
+
|
| 261 |
+
}
|
| 262 |
+
|
| 263 |
+
/**
|
| 264 |
+
* @return array
|
| 265 |
+
* returns product attributes
|
| 266 |
+
*/
|
| 267 |
+
public function getAttributesOptions()
|
| 268 |
+
{
|
| 269 |
+
$collection = $this->_getAttributesCollection();
|
| 270 |
+
$options = array();
|
| 271 |
+
$options [] = array('code' => 'product_id', 'label' => 'Product ID');
|
| 272 |
+
$options [] = array('code' => 'google_category', 'label' => 'Google Category');
|
| 273 |
+
$options [] = array('code' => 'shipping_cost', 'label' => 'Shipping Cost');
|
| 274 |
+
$options [] = array('code' => 'parent_name', 'label' => 'Parent Name');
|
| 275 |
+
$options [] = array('code' => 'google_tax', 'label' => 'Tax');
|
| 276 |
+
$options [] = array('code' => 'google_product_link', 'label' => 'Product URL');
|
| 277 |
+
$options [] = array('code' => 'google_availability', 'label' => 'Availability (in/out of stock)');
|
| 278 |
+
|
| 279 |
+
foreach ($collection as $item) {
|
| 280 |
+
$frontendLabel = $item->getFrontendLabel();
|
| 281 |
+
if (!empty($frontendLabel)) {
|
| 282 |
+
$options [] = array('code' => $item->getAttributeCode(), 'label' => $item->getFrontendLabel());
|
| 283 |
+
}
|
| 284 |
+
}
|
| 285 |
+
$this->_attributeSelectOptions = $options;
|
| 286 |
+
return $this->_attributeSelectOptions;
|
| 287 |
+
}
|
| 288 |
+
|
| 289 |
+
/**
|
| 290 |
+
* @return mixed
|
| 291 |
+
*/
|
| 292 |
+
protected function _getAttributesCollection()
|
| 293 |
+
{
|
| 294 |
+
if ($this->_attributesCollection === NULL)
|
| 295 |
+
$this->_attributesCollection = Mage::getResourceModel('eav/entity_attribute_collection')
|
| 296 |
+
->setItemObjectClass('catalog/resource_eav_attribute')
|
| 297 |
+
->setEntityTypeFilter(Mage::getResourceModel('catalog/product')->getTypeId());
|
| 298 |
+
return $this->_attributesCollection;
|
| 299 |
+
}
|
| 300 |
+
}
|
app/code/community/Web4pro/Googlemerchants/Model/Googleshipping.php
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
/**
|
| 4 |
+
* WEB4PRO - Creating profitable online stores
|
| 5 |
+
*
|
| 6 |
+
*
|
| 7 |
+
* @author WEB4PRO <achernyshev@web4pro.com.ua>
|
| 8 |
+
* @category WEB4PRO
|
| 9 |
+
* @package Web4pro_Googlemerchants
|
| 10 |
+
* @copyright Copyright (c) 2014 WEB4PRO (http://www.web4pro.net)
|
| 11 |
+
* @license http://www.web4pro.net/license.txt
|
| 12 |
+
*/
|
| 13 |
+
class Web4pro_Googlemerchants_Model_Googleshipping
|
| 14 |
+
{
|
| 15 |
+
protected $_selectedMethod = NULL;
|
| 16 |
+
|
| 17 |
+
/**
|
| 18 |
+
* @return array
|
| 19 |
+
*/
|
| 20 |
+
public function toOptionArray()
|
| 21 |
+
{
|
| 22 |
+
return $this->_getAvailableShippingMethods();
|
| 23 |
+
}
|
| 24 |
+
|
| 25 |
+
/**
|
| 26 |
+
* @return mixed|null
|
| 27 |
+
*/
|
| 28 |
+
protected function _getSelectedMethod()
|
| 29 |
+
{
|
| 30 |
+
if ($this->_selectedMethod === NULL) {
|
| 31 |
+
$this->_selectedMethod = Mage::getStoreConfig('googlemerchants_options/general/google_shiping_options');
|
| 32 |
+
}
|
| 33 |
+
return $this->_selectedMethod;
|
| 34 |
+
}
|
| 35 |
+
|
| 36 |
+
/**
|
| 37 |
+
* @return array
|
| 38 |
+
*/
|
| 39 |
+
protected function _getAvailableShippingMethods()
|
| 40 |
+
{
|
| 41 |
+
$methods = Mage::getSingleton('shipping/config')->getActiveCarriers();
|
| 42 |
+
|
| 43 |
+
$options = array();
|
| 44 |
+
foreach ($methods as $_ccode => $_carrier) {
|
| 45 |
+
$_methodOptions = array();
|
| 46 |
+
if ($_methods = $_carrier->getAllowedMethods()) {
|
| 47 |
+
foreach ($_methods as $_mcode => $_method) {
|
| 48 |
+
$_code = $_mcode;
|
| 49 |
+
$_methodOptions[] = array('value' => $_code, 'label' => $_method);
|
| 50 |
+
}
|
| 51 |
+
|
| 52 |
+
if (!$_title = Mage::getStoreConfig("carriers/$_ccode/title"))
|
| 53 |
+
$_title = $_ccode;
|
| 54 |
+
|
| 55 |
+
$options[] = array('value' => $_methodOptions, 'label' => $_title);
|
| 56 |
+
}
|
| 57 |
+
}
|
| 58 |
+
return $options;
|
| 59 |
+
}
|
| 60 |
+
|
| 61 |
+
/**
|
| 62 |
+
* @param $product
|
| 63 |
+
* @return string
|
| 64 |
+
* method for calculating shipping cost
|
| 65 |
+
*/
|
| 66 |
+
public function getShippingCost($product)
|
| 67 |
+
{
|
| 68 |
+
|
| 69 |
+
$defaultStoreId = Mage::helper('googlemerchants')->getSelectedStore();
|
| 70 |
+
$item = Mage::getModel('sales/quote_item')->setProduct($product)->setQty(1);
|
| 71 |
+
$store = Mage::getModel('core/store')->load($defaultStoreId);
|
| 72 |
+
$methodCode = $this->_getSelectedMethod();
|
| 73 |
+
$request = Mage::getModel('shipping/rate_request')
|
| 74 |
+
->setAllItems(array($item))
|
| 75 |
+
->setDestCountryId('*')
|
| 76 |
+
->setPackageValue($product->getFinalPrice())
|
| 77 |
+
->setPackageValueWithDiscount($product->getFinalPrice())
|
| 78 |
+
->setPackageWeight($product->getWeight())
|
| 79 |
+
->setPackageQty(1)
|
| 80 |
+
->setPackagePhysicalValue($product->getFinalPrice())
|
| 81 |
+
->setFreeMethodWeight(0)
|
| 82 |
+
->setStoreId($store->getId())
|
| 83 |
+
->setWebsiteId($store->getWebsiteId())
|
| 84 |
+
->setFreeShipping(0)
|
| 85 |
+
->setBaseCurrency($store->getBaseCurrency())
|
| 86 |
+
->setBaseSubtotalInclTax($product->getFinalPrice());
|
| 87 |
+
|
| 88 |
+
$model = Mage::getModel('shipping/shipping')->collectRates($request);
|
| 89 |
+
|
| 90 |
+
foreach ($model->getResult()->getAllRates() as $rate) {
|
| 91 |
+
$carrier = $rate->getCarrier();
|
| 92 |
+
if ($carrier == $methodCode) {
|
| 93 |
+
return $rate->getPrice();
|
| 94 |
+
}
|
| 95 |
+
}
|
| 96 |
+
return '';
|
| 97 |
+
}
|
| 98 |
+
|
| 99 |
+
|
| 100 |
+
}
|
app/code/community/Web4pro/Googlemerchants/Model/Googletax.php
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
/**
|
| 4 |
+
* WEB4PRO - Creating profitable online stores
|
| 5 |
+
*
|
| 6 |
+
*
|
| 7 |
+
* @author WEB4PRO <achernyshev@web4pro.com.ua>
|
| 8 |
+
* @category WEB4PRO
|
| 9 |
+
* @package Web4pro_Googlemerchants
|
| 10 |
+
* @copyright Copyright (c) 2014 WEB4PRO (http://www.web4pro.net)
|
| 11 |
+
* @license http://www.web4pro.net/license.txt
|
| 12 |
+
*/
|
| 13 |
+
class Web4pro_Googlemerchants_Model_Googletax
|
| 14 |
+
{
|
| 15 |
+
/**
|
| 16 |
+
* @param $product
|
| 17 |
+
* @return mixed
|
| 18 |
+
* return tax for products for generating feed
|
| 19 |
+
*/
|
| 20 |
+
public function getTaxValue($product)
|
| 21 |
+
{
|
| 22 |
+
$store = Mage::app()->getStore(Mage::helper('googlemerchants')->getSelectedStore());
|
| 23 |
+
$taxCalculation = Mage::getModel('tax/calculation');
|
| 24 |
+
$request = $taxCalculation->getRateRequest(null, null, null, $store);
|
| 25 |
+
$taxClassId = $product->getTaxClassId();
|
| 26 |
+
return $taxCalculation->getRate($request->setProductClassId($taxClassId));
|
| 27 |
+
}
|
| 28 |
+
}
|
app/code/community/Web4pro/Googlemerchants/Model/Mysql4/Googlecategory.php
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
/**
|
| 4 |
+
* WEB4PRO - Creating profitable online stores
|
| 5 |
+
*
|
| 6 |
+
*
|
| 7 |
+
* @author WEB4PRO <achernyshev@web4pro.com.ua>
|
| 8 |
+
* @category WEB4PRO
|
| 9 |
+
* @package Web4pro_Googlemerchants
|
| 10 |
+
* @copyright Copyright (c) 2014 WEB4PRO (http://www.web4pro.net)
|
| 11 |
+
* @license http://www.web4pro.net/license.txt
|
| 12 |
+
*/
|
| 13 |
+
class Web4pro_Googlemerchants_Model_Mysql4_Googlecategory extends Mage_Core_Model_Mysql4_Abstract
|
| 14 |
+
{
|
| 15 |
+
public function _construct()
|
| 16 |
+
{
|
| 17 |
+
$this->_init('googlemerchants/googlemerchants_cats', 'category_id');
|
| 18 |
+
}
|
| 19 |
+
}
|
app/code/community/Web4pro/Googlemerchants/Model/Mysql4/Googlecategory/Collection.php
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
/**
|
| 4 |
+
* WEB4PRO - Creating profitable online stores
|
| 5 |
+
*
|
| 6 |
+
*
|
| 7 |
+
* @author WEB4PRO <achernyshev@web4pro.com.ua>
|
| 8 |
+
* @category WEB4PRO
|
| 9 |
+
* @package Web4pro_Googlemerchants
|
| 10 |
+
* @copyright Copyright (c) 2014 WEB4PRO (http://www.web4pro.net)
|
| 11 |
+
* @license http://www.web4pro.net/license.txt
|
| 12 |
+
*/
|
| 13 |
+
class Web4pro_Googlemerchants_Model_Mysql4_Googlecategory_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
|
| 14 |
+
{
|
| 15 |
+
public function _construct()
|
| 16 |
+
{
|
| 17 |
+
$this->_init('googlemerchants/googlecategory');
|
| 18 |
+
}
|
| 19 |
+
}
|
app/code/community/Web4pro/Googlemerchants/Model/Mysql4/Googlefeed.php
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
/**
|
| 4 |
+
* WEB4PRO - Creating profitable online stores
|
| 5 |
+
*
|
| 6 |
+
*
|
| 7 |
+
* @author WEB4PRO <achernyshev@web4pro.com.ua>
|
| 8 |
+
* @category WEB4PRO
|
| 9 |
+
* @package Web4pro_Googlemerchants
|
| 10 |
+
* @copyright Copyright (c) 2014 WEB4PRO (http://www.web4pro.net)
|
| 11 |
+
* @license http://www.web4pro.net/license.txt
|
| 12 |
+
*/
|
| 13 |
+
class Web4pro_Googlemerchants_Model_Mysql4_Googlefeed extends Mage_Core_Model_Mysql4_Abstract
|
| 14 |
+
{
|
| 15 |
+
public function _construct()
|
| 16 |
+
{
|
| 17 |
+
$this->_init('googlemerchants/googlemerchants_cats', 'category_id');
|
| 18 |
+
}
|
| 19 |
+
}
|
app/code/community/Web4pro/Googlemerchants/controllers/Adminhtml/GooglemerchantsController.php
ADDED
|
@@ -0,0 +1,272 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
/**
|
| 4 |
+
* WEB4PRO - Creating profitable online stores
|
| 5 |
+
*
|
| 6 |
+
*
|
| 7 |
+
* @author WEB4PRO <achernyshev@web4pro.com.ua>
|
| 8 |
+
* @category WEB4PRO
|
| 9 |
+
* @package Web4pro_Googlemerchants
|
| 10 |
+
* @copyright Copyright (c) 2014 WEB4PRO (http://www.web4pro.net)
|
| 11 |
+
* @license http://www.web4pro.net/license.txt
|
| 12 |
+
*/
|
| 13 |
+
class Web4pro_Googlemerchants_Adminhtml_GooglemerchantsController extends Mage_Adminhtml_Controller_Action
|
| 14 |
+
{
|
| 15 |
+
|
| 16 |
+
protected $_fileInputData = NULL;
|
| 17 |
+
protected $_categoriesSimpleArray = array();
|
| 18 |
+
|
| 19 |
+
/**
|
| 20 |
+
* @return $this
|
| 21 |
+
*/
|
| 22 |
+
protected function _initAction()
|
| 23 |
+
{
|
| 24 |
+
$this->loadLayout()
|
| 25 |
+
->_setActiveMenu('googlemerchants/googlemerchants')
|
| 26 |
+
->_addBreadcrumb(Mage::helper('adminhtml')->__('Items Manager'), Mage::helper('adminhtml')->__('Item Manager'));
|
| 27 |
+
return $this;
|
| 28 |
+
}
|
| 29 |
+
|
| 30 |
+
/**
|
| 31 |
+
* renders google categories tree and store categories select
|
| 32 |
+
*/
|
| 33 |
+
public function indexAction()
|
| 34 |
+
{
|
| 35 |
+
$googleCategoriesCount = Mage::getModel('googlemerchants/googlecategory')->getCollection()->count();
|
| 36 |
+
if ($googleCategoriesCount == 0) {
|
| 37 |
+
$this->_redirect('adminhtml/googlemerchants/downloadtxt');
|
| 38 |
+
}
|
| 39 |
+
$this->_initAction();
|
| 40 |
+
$this->renderLayout();
|
| 41 |
+
|
| 42 |
+
}
|
| 43 |
+
|
| 44 |
+
/**
|
| 45 |
+
* downloading file from google and export google categories to store
|
| 46 |
+
*/
|
| 47 |
+
public function downloadtxtAction()
|
| 48 |
+
{
|
| 49 |
+
$googleCategoriesCount = Mage::getModel('googlemerchants/googlecategory')->getCollection()->count();
|
| 50 |
+
if ($googleCategoriesCount != 0) {
|
| 51 |
+
$this->_redirect('adminhtml/googlemerchants/index');
|
| 52 |
+
}
|
| 53 |
+
$this->_initAction();
|
| 54 |
+
$this->renderLayout();
|
| 55 |
+
}
|
| 56 |
+
|
| 57 |
+
/**
|
| 58 |
+
* exporting txt with google categories file to store
|
| 59 |
+
*/
|
| 60 |
+
public function savetxtAction()
|
| 61 |
+
{
|
| 62 |
+
|
| 63 |
+
if (isset($_FILES['fileinputname']['name']) && $_FILES['fileinputname']['name'] != '') {
|
| 64 |
+
try {
|
| 65 |
+
$uploader = new Varien_File_Uploader('fileinputname');
|
| 66 |
+
$uploader->setAllowedExtensions(array('txt'));
|
| 67 |
+
$uploader->setAllowRenameFiles(true);
|
| 68 |
+
$uploader->setFilesDispersion(false);
|
| 69 |
+
$path = Mage::getBaseDir('media') . DS . 'txt' . DS;
|
| 70 |
+
|
| 71 |
+
if (!is_dir($path)) {
|
| 72 |
+
mkdir($path, 0777, true);
|
| 73 |
+
}
|
| 74 |
+
|
| 75 |
+
$files = glob($path . '*');
|
| 76 |
+
foreach ($files as $file) {
|
| 77 |
+
if (is_file($file)) {
|
| 78 |
+
unlink($file);
|
| 79 |
+
}
|
| 80 |
+
}
|
| 81 |
+
$saveResult = $uploader->save($path, $_FILES['fileinputname']['name']);
|
| 82 |
+
$path = $saveResult['path'] . $saveResult['name'];
|
| 83 |
+
$fileContents = file_get_contents($path);
|
| 84 |
+
$rows = explode("\n", $fileContents);
|
| 85 |
+
$model = Mage::getModel('googlemerchants/googlecategory');
|
| 86 |
+
//$model->truncateCategoriesTable();
|
| 87 |
+
$model->insertRoot('');
|
| 88 |
+
foreach ($rows as $row => $data) {
|
| 89 |
+
if ($row == 0) {
|
| 90 |
+
continue;
|
| 91 |
+
}
|
| 92 |
+
$cols = explode('>', $data);
|
| 93 |
+
foreach ($cols as $index => $col) {
|
| 94 |
+
if (!empty($col)) {
|
| 95 |
+
if ($index > 0) {
|
| 96 |
+
$model->insertItem($col, $cols[$index - 1]);
|
| 97 |
+
} else {
|
| 98 |
+
$model->insertItem($col, NULL);
|
| 99 |
+
}
|
| 100 |
+
}
|
| 101 |
+
}
|
| 102 |
+
}
|
| 103 |
+
$this->_redirect('adminhtml/googlemerchants/index');
|
| 104 |
+
|
| 105 |
+
} catch (Exception $e) {
|
| 106 |
+
Mage::getSingleton('core/session')->addError($e->getMessage());
|
| 107 |
+
$this->_redirect('adminhtml/googlemerchants/downloadtxt');
|
| 108 |
+
$error = true;
|
| 109 |
+
}
|
| 110 |
+
} else {
|
| 111 |
+
Mage::getSingleton('core/session')->addError('Please select file with google categories.');
|
| 112 |
+
$this->_redirect('adminhtml/googlemerchants/downloadtxt');
|
| 113 |
+
}
|
| 114 |
+
}
|
| 115 |
+
|
| 116 |
+
/**
|
| 117 |
+
* saving categories attachment
|
| 118 |
+
*/
|
| 119 |
+
|
| 120 |
+
public function saveStoreCategoryLinkAction()
|
| 121 |
+
{
|
| 122 |
+
if ($this->getRequest()->isAjax()) {
|
| 123 |
+
$post = $this->getRequest()->getPost();
|
| 124 |
+
if (isset($post['google_category_id']) && isset($post['store_category_id'])) {
|
| 125 |
+
$model = Mage::getModel('googlemerchants/googlecategory');
|
| 126 |
+
$this->getResponse()->setHeader('Content-type', 'application/json');
|
| 127 |
+
if ($model->isRootCategory($post['google_category_id'])) {
|
| 128 |
+
$attachToRootError = __('Can not attach to store categories to Root google category');
|
| 129 |
+
Mage::getSingleton('core/session')->addError($attachToRootError);
|
| 130 |
+
$this->getResponse()->setBody(Mage::helper('core')->jsonEncode(array('error' => 'true')));
|
| 131 |
+
} else {
|
| 132 |
+
$googleCategory = $model->load($post['google_category_id']);
|
| 133 |
+
$googleCategoryName = $googleCategory->getTitle();
|
| 134 |
+
$googleCategory->setStoreCatId($post['store_category_id']);
|
| 135 |
+
$storeCategory = Mage::getModel('catalog/category')->load($post['store_category_id']);
|
| 136 |
+
$storeCategoryName = $storeCategory->getName();
|
| 137 |
+
$googleCategory->save();
|
| 138 |
+
$this->getResponse()->setBody(Mage::helper('core')->jsonEncode(array('error' => 'false')));
|
| 139 |
+
Mage::getSingleton('core/session')->addSuccess('Google category "' . $googleCategoryName . '" has been attached to store category "' . $storeCategoryName . '."');
|
| 140 |
+
}
|
| 141 |
+
}
|
| 142 |
+
} else {
|
| 143 |
+
exit();
|
| 144 |
+
}
|
| 145 |
+
}
|
| 146 |
+
|
| 147 |
+
/**
|
| 148 |
+
* return name of store category attached to google category
|
| 149 |
+
*/
|
| 150 |
+
|
| 151 |
+
public function getLinkedCategoryAction()
|
| 152 |
+
{
|
| 153 |
+
if ($this->getRequest()->isAjax()) {
|
| 154 |
+
$post = $this->getRequest()->getPost();
|
| 155 |
+
$storeCatId = NULL;
|
| 156 |
+
if (isset($post['google_category_id'])) {
|
| 157 |
+
$responce = array();
|
| 158 |
+
$googleCatId = $post['google_category_id'];
|
| 159 |
+
$model = Mage::getModel('googlemerchants/googlecategory');
|
| 160 |
+
|
| 161 |
+
$googleCategory = $model->load($googleCatId);
|
| 162 |
+
if ($model->isRootCategory($googleCatId)) {
|
| 163 |
+
$responce['store_category_id'] = NULL;
|
| 164 |
+
$responce['is_root'] = true;
|
| 165 |
+
} else {
|
| 166 |
+
$storeCatId = $googleCategory->getStoreCatId();
|
| 167 |
+
$responce['store_category_id'] = $storeCatId;
|
| 168 |
+
$responce['is_root'] = false;
|
| 169 |
+
}
|
| 170 |
+
}
|
| 171 |
+
$this->getResponse()->setBody(Mage::helper('core')->jsonEncode($responce));
|
| 172 |
+
} else {
|
| 173 |
+
exit();
|
| 174 |
+
}
|
| 175 |
+
}
|
| 176 |
+
|
| 177 |
+
public function categoriesJsonAction()
|
| 178 |
+
{
|
| 179 |
+
$this->getResponse()->setBody(
|
| 180 |
+
$this->getLayout()->createBlock('googlemerchants/adminhtml_googlecategory_tree')
|
| 181 |
+
->getTreeJson($this->getRequest()->getParam('id'))
|
| 182 |
+
);
|
| 183 |
+
}
|
| 184 |
+
|
| 185 |
+
/**
|
| 186 |
+
* load settings for feed
|
| 187 |
+
*/
|
| 188 |
+
public function feedAction()
|
| 189 |
+
{
|
| 190 |
+
$googleCategoriesCount = $count = Mage::getModel('googlemerchants/googlecategory')->getCollection()->count();
|
| 191 |
+
$importGoogleCategoriesUrl = Mage::helper("adminhtml")->getUrl('adminhtml/googlemerchants/index');
|
| 192 |
+
if ($googleCategoriesCount == 0) {
|
| 193 |
+
Mage::getSingleton('core/session')->addError('Please <a href="' . $importGoogleCategoriesUrl . '">import</a> google categories and attach them to store categories.');
|
| 194 |
+
}
|
| 195 |
+
$this->_initAction();
|
| 196 |
+
$this->renderLayout();
|
| 197 |
+
}
|
| 198 |
+
|
| 199 |
+
/**
|
| 200 |
+
* saving feed settings
|
| 201 |
+
*/
|
| 202 |
+
public function savefeedAction()
|
| 203 |
+
{
|
| 204 |
+
$result = array();
|
| 205 |
+
try {
|
| 206 |
+
$post = $this->getRequest()->getPost();
|
| 207 |
+
$index = 0;
|
| 208 |
+
$storeCode = 'default';
|
| 209 |
+
|
| 210 |
+
$valuesToSave = array();
|
| 211 |
+
$names = $post['feed-col-name'];
|
| 212 |
+
$values = $post['attribute-select'];
|
| 213 |
+
foreach ($names as $key => $value) {
|
| 214 |
+
$valuesToSave [$value] = $values[$key];
|
| 215 |
+
}
|
| 216 |
+
Mage::getModel('googlemerchants/googlefeed')->setFeedConfig($valuesToSave, $this->getRequest()->getParam('store'));
|
| 217 |
+
$result['error'] = false;
|
| 218 |
+
} catch (Exception $e) {
|
| 219 |
+
$result['error'] = false;
|
| 220 |
+
$result['message'] = $e->getMessage();
|
| 221 |
+
Mage::getSingleton('core/session')->addError($e->getMessage());
|
| 222 |
+
|
| 223 |
+
}
|
| 224 |
+
if ($this->getRequest()->isAjax()) {
|
| 225 |
+
$this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
|
| 226 |
+
} else {
|
| 227 |
+
$this->_redirect('adminhtml/googlemerchants/feed');
|
| 228 |
+
}
|
| 229 |
+
}
|
| 230 |
+
|
| 231 |
+
/**
|
| 232 |
+
* resetting feed setting for selected store
|
| 233 |
+
*
|
| 234 |
+
*/
|
| 235 |
+
|
| 236 |
+
public function resetfeedAction()
|
| 237 |
+
{
|
| 238 |
+
$storeCode = Mage::helper('googlemerchants');
|
| 239 |
+
Mage::getModel('googlemerchants/googlefeed')->setFeedConfig('', $storeCode);
|
| 240 |
+
$this->_redirect('adminhtml/googlemerchants/feed');
|
| 241 |
+
}
|
| 242 |
+
|
| 243 |
+
/**
|
| 244 |
+
* generate feed and put file to diresctory [base]/var/productsfeed/[filename] by default
|
| 245 |
+
*/
|
| 246 |
+
|
| 247 |
+
public function generatefeedAction()
|
| 248 |
+
{
|
| 249 |
+
$model = Mage::getModel('googlemerchants/googlefeed');
|
| 250 |
+
$model->generateFeed();
|
| 251 |
+
$this->_redirect('adminhtml/googlemerchants/feed');
|
| 252 |
+
|
| 253 |
+
}
|
| 254 |
+
|
| 255 |
+
/**
|
| 256 |
+
* loading feed dynamically
|
| 257 |
+
*/
|
| 258 |
+
public function feedAjaxAction()
|
| 259 |
+
{
|
| 260 |
+
$this->getResponse()->setBody($this->getLayout()->createBlock('googlemerchants/adminhtml_editfeed_edit_form')->toHtml());
|
| 261 |
+
}
|
| 262 |
+
|
| 263 |
+
/**
|
| 264 |
+
* return url for clearing google cateogries
|
| 265 |
+
*/
|
| 266 |
+
|
| 267 |
+
public function clearGoogleCategoriesAction()
|
| 268 |
+
{
|
| 269 |
+
Mage::getModel('googlemerchants/googlecategory')->truncateCategoriesTable();
|
| 270 |
+
$this->_redirect('adminhtml/googlemerchants/downloadtxt');
|
| 271 |
+
}
|
| 272 |
+
}
|
app/code/community/Web4pro/Googlemerchants/etc/adminhtml.xml
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0"?>
|
| 2 |
+
<!--
|
| 3 |
+
/**
|
| 4 |
+
* WEB4PRO - Creating profitable online stores
|
| 5 |
+
*
|
| 6 |
+
*
|
| 7 |
+
* @author WEB4PRO <achernyshev@web4pro.com.ua>
|
| 8 |
+
* @category WEB4PRO
|
| 9 |
+
* @package Web4pro_Googlemerchants
|
| 10 |
+
* @copyright Copyright (c) 2014 WEB4PRO (http://www.web4pro.net)
|
| 11 |
+
* @license http://www.web4pro.net/license.txt
|
| 12 |
+
*/
|
| 13 |
+
-->
|
| 14 |
+
<config>
|
| 15 |
+
<menu>
|
| 16 |
+
<web4pro_attachments module="googlemerchants">
|
| 17 |
+
<title>Web4pro</title>
|
| 18 |
+
<sort_order>71</sort_order>
|
| 19 |
+
<children>
|
| 20 |
+
<googlemerchants_settings module="googlemerchants">
|
| 21 |
+
<title>Manage Google Merchants settings</title>
|
| 22 |
+
<sort_order>0</sort_order>
|
| 23 |
+
<children>
|
| 24 |
+
<googlecategories module="googlemerchants">
|
| 25 |
+
<title>Manage Google Categories</title>
|
| 26 |
+
<sort_order>0</sort_order>
|
| 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>
|
| 34 |
+
<googlesfeed>
|
| 35 |
+
<title>Configure Feed settings</title>
|
| 36 |
+
<sort_order>1</sort_order>
|
| 37 |
+
<action>adminhtml/googlemerchants/feed</action>
|
| 38 |
+
</googlesfeed>
|
| 39 |
+
</children>
|
| 40 |
+
</googlemerchants_settings>
|
| 41 |
+
</children>
|
| 42 |
+
</web4pro_attachments>
|
| 43 |
+
</menu>
|
| 44 |
+
<acl>
|
| 45 |
+
<resources>
|
| 46 |
+
<all>
|
| 47 |
+
<title>Allow Everything</title>
|
| 48 |
+
</all>
|
| 49 |
+
<admin>
|
| 50 |
+
<children>
|
| 51 |
+
<web4pro_attachments>
|
| 52 |
+
<title>Web4pro</title>
|
| 53 |
+
<sort_order>0</sort_order>
|
| 54 |
+
</web4pro_attachments>
|
| 55 |
+
<system>
|
| 56 |
+
<children>
|
| 57 |
+
<config>
|
| 58 |
+
<children>
|
| 59 |
+
<googlemerchants_options translate="title">
|
| 60 |
+
<title>Shipping options</title>
|
| 61 |
+
<sort_order>100</sort_order>
|
| 62 |
+
</googlemerchants_options>
|
| 63 |
+
</children>
|
| 64 |
+
</config>
|
| 65 |
+
</children>
|
| 66 |
+
</system>
|
| 67 |
+
</children>
|
| 68 |
+
</admin>
|
| 69 |
+
</resources>
|
| 70 |
+
</acl>
|
| 71 |
+
</config>
|
app/code/community/Web4pro/Googlemerchants/etc/config.xml
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0"?>
|
| 2 |
+
<!--
|
| 3 |
+
/**
|
| 4 |
+
* WEB4PRO - Creating profitable online stores
|
| 5 |
+
*
|
| 6 |
+
*
|
| 7 |
+
* @author WEB4PRO <achernyshev@web4pro.com.ua>
|
| 8 |
+
* @category WEB4PRO
|
| 9 |
+
* @package Web4pro_Googlemerchants
|
| 10 |
+
* @copyright Copyright (c) 2014 WEB4PRO (http://www.web4pro.net)
|
| 11 |
+
* @license http://www.web4pro.net/license.txt
|
| 12 |
+
*/
|
| 13 |
+
-->
|
| 14 |
+
<config>
|
| 15 |
+
<modules>
|
| 16 |
+
<Web4pro_Googlemerchants>
|
| 17 |
+
<version>0.0.0.1</version>
|
| 18 |
+
</Web4pro_Googlemerchants>
|
| 19 |
+
</modules>
|
| 20 |
+
<global>
|
| 21 |
+
<resources>
|
| 22 |
+
<googlemerchants_setup>
|
| 23 |
+
<setup>
|
| 24 |
+
<module>Web4pro_Googlemerchants</module>
|
| 25 |
+
<class>Mage_Eav_Model_Entity_Setup</class>
|
| 26 |
+
</setup>
|
| 27 |
+
</googlemerchants_setup>
|
| 28 |
+
<googlemerchants_write>
|
| 29 |
+
<connection>
|
| 30 |
+
<use>core_write</use>
|
| 31 |
+
</connection>
|
| 32 |
+
</googlemerchants_write>
|
| 33 |
+
<googlemerchants_read>
|
| 34 |
+
<connection>
|
| 35 |
+
<use>core_read</use>
|
| 36 |
+
</connection>
|
| 37 |
+
</googlemerchants_read>
|
| 38 |
+
</resources>
|
| 39 |
+
<models>
|
| 40 |
+
<googlemerchants>
|
| 41 |
+
<class>Web4pro_Googlemerchants_Model</class>
|
| 42 |
+
<resourceModel>googlemerchants_mysql4</resourceModel>
|
| 43 |
+
</googlemerchants>
|
| 44 |
+
<googlemerchants_mysql4>
|
| 45 |
+
<class>Web4pro_Googlemerchants_Model_Mysql4</class>
|
| 46 |
+
<entities>
|
| 47 |
+
<googlemerchants_cats>
|
| 48 |
+
<table>googlemerchants_cats</table>
|
| 49 |
+
</googlemerchants_cats>
|
| 50 |
+
</entities>
|
| 51 |
+
</googlemerchants_mysql4>
|
| 52 |
+
</models>
|
| 53 |
+
<helpers>
|
| 54 |
+
<googlemerchants>
|
| 55 |
+
<class>Web4pro_Googlemerchants_Helper</class>
|
| 56 |
+
</googlemerchants>
|
| 57 |
+
</helpers>
|
| 58 |
+
<blocks>
|
| 59 |
+
<googlemerchants>
|
| 60 |
+
<class>Web4pro_Googlemerchants_Block</class>
|
| 61 |
+
</googlemerchants>
|
| 62 |
+
</blocks>
|
| 63 |
+
</global>
|
| 64 |
+
<admin>
|
| 65 |
+
<routers>
|
| 66 |
+
<adminhtml>
|
| 67 |
+
<args>
|
| 68 |
+
<modules>
|
| 69 |
+
<googlemerchants before="Mage_Adminhtml">Web4pro_Googlemerchants_Adminhtml</googlemerchants>
|
| 70 |
+
</modules>
|
| 71 |
+
</args>
|
| 72 |
+
</adminhtml>
|
| 73 |
+
</routers>
|
| 74 |
+
</admin>
|
| 75 |
+
<adminhtml>
|
| 76 |
+
<layout>
|
| 77 |
+
<updates>
|
| 78 |
+
<googlemerchants>
|
| 79 |
+
<file>googlemerchants.xml</file>
|
| 80 |
+
</googlemerchants>
|
| 81 |
+
</updates>
|
| 82 |
+
</layout>
|
| 83 |
+
</adminhtml>
|
| 84 |
+
<crontab>
|
| 85 |
+
<jobs>
|
| 86 |
+
<web4pro_googlemerchants>
|
| 87 |
+
<schedule>
|
| 88 |
+
<cron_expr>0 1 * * *</cron_expr>
|
| 89 |
+
</schedule>
|
| 90 |
+
<run>
|
| 91 |
+
<model>googlemerchants/googlefeed::generateFeed</model>
|
| 92 |
+
</run>
|
| 93 |
+
</web4pro_googlemerchants>
|
| 94 |
+
</jobs>
|
| 95 |
+
</crontab>
|
| 96 |
+
<default>
|
| 97 |
+
<googlemerchants_options>
|
| 98 |
+
<general>
|
| 99 |
+
<google_feedfilename>product_feed</google_feedfilename>
|
| 100 |
+
</general>
|
| 101 |
+
</googlemerchants_options>
|
| 102 |
+
</default>
|
| 103 |
+
</config>
|
app/code/community/Web4pro/Googlemerchants/etc/system.xml
ADDED
|
@@ -0,0 +1,126 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0"?>
|
| 2 |
+
<!--
|
| 3 |
+
/**
|
| 4 |
+
* WEB4PRO - Creating profitable online stores
|
| 5 |
+
*
|
| 6 |
+
*
|
| 7 |
+
* @author WEB4PRO <achernyshev@web4pro.com.ua>
|
| 8 |
+
* @category WEB4PRO
|
| 9 |
+
* @package Web4pro_Googlemerchants
|
| 10 |
+
* @copyright Copyright (c) 2014 WEB4PRO (http://www.web4pro.net)
|
| 11 |
+
* @license http://www.web4pro.net/license.txt
|
| 12 |
+
*/
|
| 13 |
+
-->
|
| 14 |
+
<config>
|
| 15 |
+
<tabs>
|
| 16 |
+
<web4pro>
|
| 17 |
+
<label>Web4pro</label>
|
| 18 |
+
<sort_order>250</sort_order>
|
| 19 |
+
</web4pro>
|
| 20 |
+
</tabs>
|
| 21 |
+
<sections>
|
| 22 |
+
<googlemerchants_options translate="label" module="googlemerchants">
|
| 23 |
+
<label>Google merchants options</label>
|
| 24 |
+
<tab>web4pro</tab>
|
| 25 |
+
<sort_order>600</sort_order>
|
| 26 |
+
<show_in_default>1</show_in_default>
|
| 27 |
+
<show_in_website>1</show_in_website>
|
| 28 |
+
<show_in_store>1</show_in_store>
|
| 29 |
+
<groups>
|
| 30 |
+
<general translate="label">
|
| 31 |
+
<label>Options for importing products</label>
|
| 32 |
+
<sort_order>10</sort_order>
|
| 33 |
+
<show_in_default>1</show_in_default>
|
| 34 |
+
<show_in_website>1</show_in_website>
|
| 35 |
+
<show_in_store>1</show_in_store>
|
| 36 |
+
<fields>
|
| 37 |
+
<google_shiping_html translate="label">
|
| 38 |
+
<frontend_type>label</frontend_type>
|
| 39 |
+
<frontend_type>label</frontend_type>
|
| 40 |
+
<frontend_model>googlemerchants/adminhtml_system_instruction</frontend_model>
|
| 41 |
+
<source_model>googlemerchants/googleshipping</source_model>
|
| 42 |
+
<sort_order>0</sort_order>
|
| 43 |
+
<show_in_default>1</show_in_default>
|
| 44 |
+
<show_in_website>1</show_in_website>
|
| 45 |
+
<show_in_store>1</show_in_store>
|
| 46 |
+
</google_shiping_html>
|
| 47 |
+
<google_shiping_options translate="label">
|
| 48 |
+
<label>Select shipping method</label>
|
| 49 |
+
<frontend_type>select</frontend_type>
|
| 50 |
+
<source_model>googlemerchants/googleshipping</source_model>
|
| 51 |
+
<sort_order>0</sort_order>
|
| 52 |
+
<show_in_default>1</show_in_default>
|
| 53 |
+
<show_in_website>1</show_in_website>
|
| 54 |
+
<show_in_store>1</show_in_store>
|
| 55 |
+
<comment>Please select offline shipping method</comment>
|
| 56 |
+
</google_shiping_options>
|
| 57 |
+
<google_feedfilename>
|
| 58 |
+
<label>Feed file name to store in 'media/productsfeed/'</label>
|
| 59 |
+
<frontend_type>text</frontend_type>
|
| 60 |
+
<sort_order>2</sort_order>
|
| 61 |
+
<show_in_default>1</show_in_default>
|
| 62 |
+
<show_in_website>1</show_in_website>
|
| 63 |
+
<show_in_store>1</show_in_store>
|
| 64 |
+
</google_feedfilename>
|
| 65 |
+
<google_feed_prameters translate="label">
|
| 66 |
+
<label>Feed parameters</label>
|
| 67 |
+
<frontend_type>label</frontend_type>
|
| 68 |
+
<sort_order>0</sort_order>
|
| 69 |
+
<show_in_default>0</show_in_default>
|
| 70 |
+
<show_in_website>0</show_in_website>
|
| 71 |
+
<show_in_store>0</show_in_store>
|
| 72 |
+
</google_feed_prameters>
|
| 73 |
+
<google_feed_export_outofstock translate="label">
|
| 74 |
+
<label>Export out of stock products</label>
|
| 75 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
| 76 |
+
<frontend_type>select</frontend_type>
|
| 77 |
+
<sort_order>3</sort_order>
|
| 78 |
+
<show_in_default>1</show_in_default>
|
| 79 |
+
<show_in_website>1</show_in_website>
|
| 80 |
+
<show_in_store>1</show_in_store>
|
| 81 |
+
</google_feed_export_outofstock>
|
| 82 |
+
<google_feed_export_disabled translate="label">
|
| 83 |
+
<label>Export disabled products</label>
|
| 84 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
| 85 |
+
<frontend_type>select</frontend_type>
|
| 86 |
+
<sort_order>4</sort_order>
|
| 87 |
+
<show_in_default>1</show_in_default>
|
| 88 |
+
<show_in_website>1</show_in_website>
|
| 89 |
+
<show_in_store>1</show_in_store>
|
| 90 |
+
</google_feed_export_disabled>
|
| 91 |
+
<google_feed_export_unvisible translate="label">
|
| 92 |
+
<label>Export products with status `Not Visible Individually`</label>
|
| 93 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
| 94 |
+
<frontend_type>select</frontend_type>
|
| 95 |
+
<sort_order>5</sort_order>
|
| 96 |
+
<show_in_default>1</show_in_default>
|
| 97 |
+
<show_in_website>1</show_in_website>
|
| 98 |
+
<show_in_store>1</show_in_store>
|
| 99 |
+
</google_feed_export_unvisible>
|
| 100 |
+
<google_shiping_html_notes translate="label">
|
| 101 |
+
<comment>
|
| 102 |
+
<![CDATA[
|
| 103 |
+
|
| 104 |
+
<ul style="list-style-type: circle;">
|
| 105 |
+
<i>
|
| 106 |
+
<li><p>By default .csv file will be generated once a day (if the cron is properly setted up), but you can generate it manually by clicking on button “Generate feed .csv” (Web4pro -> Manage Google Merchants settings -> Configure Feed settings).</p></li>
|
| 107 |
+
<li><p>Also you should set up your <a href="https://support.google.com/merchants/answer/188486" target="_blank">google merchants account</a> for importing products by automatic uploading.</p></li>
|
| 108 |
+
<li><p>By default your file will be located here: [base url]/var/productsfeed/[feed_file_name].csv.
|
| 109 |
+
For example : http://site-name.com/var/productsfeed/product_feed.csv.</p></li>
|
| 110 |
+
</i>
|
| 111 |
+
</ul>
|
| 112 |
+
]]>
|
| 113 |
+
</comment>
|
| 114 |
+
<frontend_type>label</frontend_type>
|
| 115 |
+
<source_model>googlemerchants/googleshipping</source_model>
|
| 116 |
+
<sort_order>10</sort_order>
|
| 117 |
+
<show_in_default>1</show_in_default>
|
| 118 |
+
<show_in_website>1</show_in_website>
|
| 119 |
+
<show_in_store>1</show_in_store>
|
| 120 |
+
</google_shiping_html_notes>
|
| 121 |
+
</fields>
|
| 122 |
+
</general>
|
| 123 |
+
</groups>
|
| 124 |
+
</googlemerchants_options>
|
| 125 |
+
</sections>
|
| 126 |
+
</config>
|
app/code/community/Web4pro/Googlemerchants/sql/googlemerchants_setup/install-0.0.0.1.php
ADDED
|
@@ -0,0 +1,420 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* WEB4PRO - Creating profitable online stores
|
| 4 |
+
*
|
| 5 |
+
*
|
| 6 |
+
* @author WEB4PRO <achernyshev@web4pro.com.ua>
|
| 7 |
+
* @category WEB4PRO
|
| 8 |
+
* @package Web4pro_Googlemerchants
|
| 9 |
+
* @copyright Copyright (c) 2014 WEB4PRO (http://www.web4pro.net)
|
| 10 |
+
* @license http://www.web4pro.net/license.txt
|
| 11 |
+
*/
|
| 12 |
+
$installer = $this;
|
| 13 |
+
/* @var $installer Mage_Eav_Model_Entity_Setup */
|
| 14 |
+
$installer->startSetup();
|
| 15 |
+
|
| 16 |
+
$attributeSet = $installer->addAttributeSet(Mage_Catalog_Model_Product::ENTITY, 'Google Attribute Set');
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
$installer->addAttributeGroup('catalog_product', 'Google Attribute Set', 'Google Attributes', 1000);
|
| 20 |
+
|
| 21 |
+
|
| 22 |
+
$attrSetModel = Mage::getModel('eav/entity_attribute_set');
|
| 23 |
+
|
| 24 |
+
|
| 25 |
+
$installer->addAttribute('catalog_product', 'condition_google', array(
|
| 26 |
+
'group' => 'Google Attributes',
|
| 27 |
+
'type' => 'varchar',
|
| 28 |
+
'backend' => '',
|
| 29 |
+
'position' => 0,
|
| 30 |
+
'frontend' => '',
|
| 31 |
+
'label' => 'Condition',
|
| 32 |
+
'input' => 'select',
|
| 33 |
+
'class' => '',
|
| 34 |
+
'source' => '',
|
| 35 |
+
'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
|
| 36 |
+
'visible' => false,
|
| 37 |
+
'required' => false,
|
| 38 |
+
'user_defined' => true,
|
| 39 |
+
'default' => '',
|
| 40 |
+
'searchable' => false,
|
| 41 |
+
'filterable' => false,
|
| 42 |
+
'comparable' => false,
|
| 43 |
+
'visible_on_front' => false,
|
| 44 |
+
'unique' => false,
|
| 45 |
+
'apply_to' => '',
|
| 46 |
+
'is_configurable' => false,
|
| 47 |
+
'option' => array(
|
| 48 |
+
'values' => array(
|
| 49 |
+
0 => 'new',
|
| 50 |
+
1 => 'used',
|
| 51 |
+
2 => 'refurbished',
|
| 52 |
+
)
|
| 53 |
+
),
|
| 54 |
+
));
|
| 55 |
+
|
| 56 |
+
|
| 57 |
+
$installer->addAttribute('catalog_product', 'brand_google', array(
|
| 58 |
+
'group' => 'Google Attributes',
|
| 59 |
+
'type' => 'varchar',
|
| 60 |
+
'backend' => '',
|
| 61 |
+
'frontend' => '',
|
| 62 |
+
'label' => 'Brand',
|
| 63 |
+
'input' => 'text',
|
| 64 |
+
'class' => '',
|
| 65 |
+
'position' => 1,
|
| 66 |
+
'source' => '',
|
| 67 |
+
'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
|
| 68 |
+
'visible' => false,
|
| 69 |
+
'required' => false,
|
| 70 |
+
'user_defined' => true,
|
| 71 |
+
'default' => '',
|
| 72 |
+
'searchable' => false,
|
| 73 |
+
'filterable' => false,
|
| 74 |
+
'comparable' => false,
|
| 75 |
+
'visible_on_front' => false,
|
| 76 |
+
'unique' => false,
|
| 77 |
+
'apply_to' => '',
|
| 78 |
+
'is_configurable' => false
|
| 79 |
+
));
|
| 80 |
+
|
| 81 |
+
$installer->addAttribute('catalog_product', 'gtin_google', array(
|
| 82 |
+
'group' => 'Google Attributes',
|
| 83 |
+
'type' => 'varchar',
|
| 84 |
+
'backend' => '',
|
| 85 |
+
'frontend' => '',
|
| 86 |
+
'label' => 'GTIN',
|
| 87 |
+
'position' => 2,
|
| 88 |
+
'input' => 'text',
|
| 89 |
+
'class' => '',
|
| 90 |
+
'source' => '',
|
| 91 |
+
'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
|
| 92 |
+
'visible' => false,
|
| 93 |
+
'required' => false,
|
| 94 |
+
'user_defined' => true,
|
| 95 |
+
'default' => '',
|
| 96 |
+
'searchable' => false,
|
| 97 |
+
'filterable' => false,
|
| 98 |
+
'comparable' => false,
|
| 99 |
+
'visible_on_front' => false,
|
| 100 |
+
'unique' => false,
|
| 101 |
+
'apply_to' => '',
|
| 102 |
+
'is_configurable' => false
|
| 103 |
+
));
|
| 104 |
+
|
| 105 |
+
|
| 106 |
+
$installer->addAttribute('catalog_product', 'mpn_google', array(
|
| 107 |
+
'group' => 'Google Attributes',
|
| 108 |
+
'type' => 'varchar',
|
| 109 |
+
'backend' => '',
|
| 110 |
+
'frontend' => '',
|
| 111 |
+
'label' => 'MPN',
|
| 112 |
+
'position' => 3,
|
| 113 |
+
'input' => 'text',
|
| 114 |
+
'class' => '',
|
| 115 |
+
'source' => '',
|
| 116 |
+
'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
|
| 117 |
+
'visible' => false,
|
| 118 |
+
'required' => false,
|
| 119 |
+
'user_defined' => true,
|
| 120 |
+
'default' => '',
|
| 121 |
+
'searchable' => false,
|
| 122 |
+
'filterable' => false,
|
| 123 |
+
'comparable' => false,
|
| 124 |
+
'visible_on_front' => false,
|
| 125 |
+
'unique' => false,
|
| 126 |
+
'apply_to' => '',
|
| 127 |
+
'is_configurable' => false
|
| 128 |
+
));
|
| 129 |
+
|
| 130 |
+
|
| 131 |
+
$installer->addAttribute('catalog_product', 'mpn_google', array(
|
| 132 |
+
'group' => 'Google Attributes',
|
| 133 |
+
'type' => 'varchar',
|
| 134 |
+
'backend' => '',
|
| 135 |
+
'frontend' => '',
|
| 136 |
+
'label' => 'MPN',
|
| 137 |
+
'input' => 'text',
|
| 138 |
+
'position' => 4,
|
| 139 |
+
'class' => '',
|
| 140 |
+
'source' => '',
|
| 141 |
+
'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
|
| 142 |
+
'visible' => false,
|
| 143 |
+
'required' => false,
|
| 144 |
+
'user_defined' => true,
|
| 145 |
+
'default' => '',
|
| 146 |
+
'searchable' => false,
|
| 147 |
+
'filterable' => false,
|
| 148 |
+
'comparable' => false,
|
| 149 |
+
'visible_on_front' => false,
|
| 150 |
+
'unique' => false,
|
| 151 |
+
'apply_to' => '',
|
| 152 |
+
'is_configurable' => false
|
| 153 |
+
|
| 154 |
+
));
|
| 155 |
+
|
| 156 |
+
|
| 157 |
+
$installer->addAttribute('catalog_product', 'identifier_exists', array(
|
| 158 |
+
'group' => 'Google Attributes',
|
| 159 |
+
'type' => 'varchar',
|
| 160 |
+
'backend' => '',
|
| 161 |
+
'frontend' => '',
|
| 162 |
+
'label' => 'Identifier Exists',
|
| 163 |
+
'input' => 'boolean',
|
| 164 |
+
'class' => '',
|
| 165 |
+
'source' => '',
|
| 166 |
+
'position' => 5,
|
| 167 |
+
'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
|
| 168 |
+
'visible' => false,
|
| 169 |
+
'required' => false,
|
| 170 |
+
'user_defined' => true,
|
| 171 |
+
'default' => '',
|
| 172 |
+
'searchable' => false,
|
| 173 |
+
'filterable' => false,
|
| 174 |
+
'comparable' => false,
|
| 175 |
+
'visible_on_front' => false,
|
| 176 |
+
'unique' => false,
|
| 177 |
+
'apply_to' => '',
|
| 178 |
+
'is_configurable' => false,
|
| 179 |
+
));
|
| 180 |
+
|
| 181 |
+
$installer->addAttribute('catalog_product', 'material_google', array(
|
| 182 |
+
'group' => 'Google Attributes',
|
| 183 |
+
'type' => 'varchar',
|
| 184 |
+
'backend' => '',
|
| 185 |
+
'frontend' => '',
|
| 186 |
+
'label' => 'Material',
|
| 187 |
+
'position' => 6,
|
| 188 |
+
'input' => 'text',
|
| 189 |
+
'class' => '',
|
| 190 |
+
'source' => '',
|
| 191 |
+
'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
|
| 192 |
+
'visible' => false,
|
| 193 |
+
'required' => false,
|
| 194 |
+
'user_defined' => true,
|
| 195 |
+
'default' => '',
|
| 196 |
+
'searchable' => false,
|
| 197 |
+
'filterable' => false,
|
| 198 |
+
'comparable' => false,
|
| 199 |
+
'visible_on_front' => false,
|
| 200 |
+
'unique' => false,
|
| 201 |
+
'apply_to' => '',
|
| 202 |
+
'is_configurable' => false
|
| 203 |
+
));
|
| 204 |
+
|
| 205 |
+
|
| 206 |
+
$installer->addAttribute('catalog_product', 'gender_google', array(
|
| 207 |
+
'group' => 'Google Attributes',
|
| 208 |
+
'type' => 'varchar',
|
| 209 |
+
'backend' => '',
|
| 210 |
+
'frontend' => '',
|
| 211 |
+
'label' => 'Gender',
|
| 212 |
+
'input' => 'select',
|
| 213 |
+
'class' => '',
|
| 214 |
+
'position' => 7,
|
| 215 |
+
'source' => '',
|
| 216 |
+
'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
|
| 217 |
+
'visible' => false,
|
| 218 |
+
'required' => false,
|
| 219 |
+
'user_defined' => true,
|
| 220 |
+
'default' => '',
|
| 221 |
+
'searchable' => false,
|
| 222 |
+
'filterable' => false,
|
| 223 |
+
'comparable' => false,
|
| 224 |
+
'visible_on_front' => false,
|
| 225 |
+
'unique' => false,
|
| 226 |
+
'apply_to' => '',
|
| 227 |
+
'is_configurable' => false,
|
| 228 |
+
'option' => array(
|
| 229 |
+
'values' => array(
|
| 230 |
+
0 => 'male',
|
| 231 |
+
1 => 'female',
|
| 232 |
+
2 => 'unisex',
|
| 233 |
+
)
|
| 234 |
+
),
|
| 235 |
+
));
|
| 236 |
+
|
| 237 |
+
$installer->addAttribute('catalog_product', 'age_group_google', array(
|
| 238 |
+
'group' => 'Google Attributes',
|
| 239 |
+
'type' => 'varchar',
|
| 240 |
+
'backend' => '',
|
| 241 |
+
'frontend' => '',
|
| 242 |
+
'label' => 'Age group',
|
| 243 |
+
'position' => 7,
|
| 244 |
+
'input' => 'select',
|
| 245 |
+
'class' => '',
|
| 246 |
+
'source' => '',
|
| 247 |
+
'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
|
| 248 |
+
'visible' => false,
|
| 249 |
+
'required' => false,
|
| 250 |
+
'user_defined' => true,
|
| 251 |
+
'default' => '',
|
| 252 |
+
'searchable' => false,
|
| 253 |
+
'filterable' => false,
|
| 254 |
+
'comparable' => false,
|
| 255 |
+
'visible_on_front' => false,
|
| 256 |
+
'unique' => false,
|
| 257 |
+
'apply_to' => '',
|
| 258 |
+
'is_configurable' => false,
|
| 259 |
+
'option' => array(
|
| 260 |
+
'values' => array(
|
| 261 |
+
0 => 'newborn',
|
| 262 |
+
1 => 'infant',
|
| 263 |
+
2 => 'toddler',
|
| 264 |
+
3 => 'kids',
|
| 265 |
+
4 => 'adult',
|
| 266 |
+
)
|
| 267 |
+
),
|
| 268 |
+
));
|
| 269 |
+
|
| 270 |
+
|
| 271 |
+
$installer->addAttribute('catalog_product', 'color_google', array(
|
| 272 |
+
'group' => 'Google Attributes',
|
| 273 |
+
'type' => 'varchar',
|
| 274 |
+
'backend' => '',
|
| 275 |
+
'frontend' => '',
|
| 276 |
+
'label' => 'Color',
|
| 277 |
+
'input' => 'text',
|
| 278 |
+
'class' => '',
|
| 279 |
+
'position' => 8,
|
| 280 |
+
'source' => '',
|
| 281 |
+
'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
|
| 282 |
+
'visible' => false,
|
| 283 |
+
'required' => false,
|
| 284 |
+
'user_defined' => true,
|
| 285 |
+
'default' => '',
|
| 286 |
+
'searchable' => false,
|
| 287 |
+
'filterable' => false,
|
| 288 |
+
'comparable' => false,
|
| 289 |
+
'visible_on_front' => false,
|
| 290 |
+
'unique' => false,
|
| 291 |
+
'apply_to' => '',
|
| 292 |
+
'is_configurable' => false
|
| 293 |
+
));
|
| 294 |
+
|
| 295 |
+
|
| 296 |
+
$installer->addAttribute('catalog_product', 'size_type_google', array(
|
| 297 |
+
'group' => 'Google Attributes',
|
| 298 |
+
'type' => 'varchar',
|
| 299 |
+
'backend' => '',
|
| 300 |
+
'frontend' => '',
|
| 301 |
+
'label' => 'Size Type',
|
| 302 |
+
'position' => 10,
|
| 303 |
+
'input' => 'select',
|
| 304 |
+
'class' => '',
|
| 305 |
+
'source' => '',
|
| 306 |
+
'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
|
| 307 |
+
'visible' => false,
|
| 308 |
+
'required' => false,
|
| 309 |
+
'user_defined' => true,
|
| 310 |
+
'default' => '',
|
| 311 |
+
'searchable' => false,
|
| 312 |
+
'filterable' => false,
|
| 313 |
+
'comparable' => false,
|
| 314 |
+
'visible_on_front' => false,
|
| 315 |
+
'unique' => false,
|
| 316 |
+
'apply_to' => '',
|
| 317 |
+
'is_configurable' => false,
|
| 318 |
+
'option' => array(
|
| 319 |
+
'values' => array(
|
| 320 |
+
0 => 'regular',
|
| 321 |
+
1 => 'petite',
|
| 322 |
+
2 => 'plus',
|
| 323 |
+
3 => 'big and tall',
|
| 324 |
+
4 => 'maternity',
|
| 325 |
+
)
|
| 326 |
+
),
|
| 327 |
+
));
|
| 328 |
+
|
| 329 |
+
|
| 330 |
+
$installer->addAttribute('catalog_product', 'size_system_google', array(
|
| 331 |
+
'group' => 'Google Attributes',
|
| 332 |
+
'type' => 'varchar',
|
| 333 |
+
'backend' => '',
|
| 334 |
+
'frontend' => '',
|
| 335 |
+
'label' => 'Size System',
|
| 336 |
+
'position' => 10,
|
| 337 |
+
'input' => 'select',
|
| 338 |
+
'class' => '',
|
| 339 |
+
'source' => '',
|
| 340 |
+
'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
|
| 341 |
+
'visible' => false,
|
| 342 |
+
'required' => false,
|
| 343 |
+
'user_defined' => true,
|
| 344 |
+
'default' => '',
|
| 345 |
+
'searchable' => false,
|
| 346 |
+
'filterable' => false,
|
| 347 |
+
'comparable' => false,
|
| 348 |
+
'visible_on_front' => false,
|
| 349 |
+
'unique' => false,
|
| 350 |
+
'apply_to' => '',
|
| 351 |
+
'is_configurable' => false,
|
| 352 |
+
'option' => array(
|
| 353 |
+
'values' => array(
|
| 354 |
+
0 => 'US',
|
| 355 |
+
1 => 'UK',
|
| 356 |
+
2 => 'EU',
|
| 357 |
+
3 => 'DE',
|
| 358 |
+
4 => 'FR',
|
| 359 |
+
5 => 'JP',
|
| 360 |
+
6 => 'CN (China)',
|
| 361 |
+
7 => 'IT',
|
| 362 |
+
8 => 'BR',
|
| 363 |
+
9 => 'MEX',
|
| 364 |
+
10 => 'AU',
|
| 365 |
+
)
|
| 366 |
+
),
|
| 367 |
+
));
|
| 368 |
+
|
| 369 |
+
$installer->addAttribute('catalog_product', 'size_system_google', array(
|
| 370 |
+
'group' => 'Google Attributes',
|
| 371 |
+
'type' => 'varchar',
|
| 372 |
+
'backend' => '',
|
| 373 |
+
'frontend' => '',
|
| 374 |
+
'label' => 'Size System',
|
| 375 |
+
'position' => 10,
|
| 376 |
+
'input' => 'select',
|
| 377 |
+
'class' => '',
|
| 378 |
+
'source' => '',
|
| 379 |
+
'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
|
| 380 |
+
'visible' => false,
|
| 381 |
+
'required' => false,
|
| 382 |
+
'user_defined' => true,
|
| 383 |
+
'default' => '',
|
| 384 |
+
'searchable' => false,
|
| 385 |
+
'filterable' => false,
|
| 386 |
+
'comparable' => false,
|
| 387 |
+
'visible_on_front' => false,
|
| 388 |
+
'unique' => false,
|
| 389 |
+
'apply_to' => '',
|
| 390 |
+
'is_configurable' => false,
|
| 391 |
+
'option' => array(
|
| 392 |
+
'values' => array(
|
| 393 |
+
0 => 'US',
|
| 394 |
+
1 => 'UK',
|
| 395 |
+
2 => 'EU',
|
| 396 |
+
3 => 'DE',
|
| 397 |
+
4 => 'FR',
|
| 398 |
+
5 => 'JP',
|
| 399 |
+
6 => 'CN (China)',
|
| 400 |
+
7 => 'IT',
|
| 401 |
+
8 => 'BR',
|
| 402 |
+
9 => 'MEX',
|
| 403 |
+
10 => 'AU',
|
| 404 |
+
)
|
| 405 |
+
),
|
| 406 |
+
));
|
| 407 |
+
|
| 408 |
+
$installer->run("
|
| 409 |
+
-- DROP TABLE IF EXISTS {$this->getTable('googlemerchants_cats')};
|
| 410 |
+
CREATE TABLE {$this->getTable('googlemerchants_cats')} (
|
| 411 |
+
`category_id` int(11) unsigned NOT NULL auto_increment,
|
| 412 |
+
`title` varchar(255) NOT NULL default '',
|
| 413 |
+
`status` smallint(6) NOT NULL default '0',
|
| 414 |
+
`parent_id` smallint(6) NULL,
|
| 415 |
+
`store_cat_id` smallint(6) NULL,
|
| 416 |
+
PRIMARY KEY (`category_id`)
|
| 417 |
+
) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
|
| 418 |
+
|
| 419 |
+
|
| 420 |
+
$installer->endSetup();
|
app/design/adminhtml/default/default/layout/googlemerchants.xml
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0"?>
|
| 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>
|
| 8 |
+
<params/>
|
| 9 |
+
</action>
|
| 10 |
+
<action method="addItem">
|
| 11 |
+
<type>js</type>
|
| 12 |
+
<name>extjs/fix-defer.js</name>
|
| 13 |
+
<params/>
|
| 14 |
+
</action>
|
| 15 |
+
<action method="addItem">
|
| 16 |
+
<type>js</type>
|
| 17 |
+
<name>extjs/ext-tree-checkbox.js</name>
|
| 18 |
+
<params/>
|
| 19 |
+
</action>
|
| 20 |
+
<action method="addItem">
|
| 21 |
+
<type>js_css</type>
|
| 22 |
+
<name>extjs/resources/css/ext-all.css</name>
|
| 23 |
+
<params/>
|
| 24 |
+
</action>
|
| 25 |
+
</reference>
|
| 26 |
+
<reference name="left">
|
| 27 |
+
<block name="category.tree" type="googlemerchants/adminhtml_googlecategory_tree"
|
| 28 |
+
template="web4pro_googlemerchants/googlecategory/tree.phtml"/>
|
| 29 |
+
</reference>
|
| 30 |
+
<reference name="content">
|
| 31 |
+
<block name="google.category.edit" type="googlemerchants/adminhtml_googlecategory_edit"
|
| 32 |
+
template="web4pro_googlemerchants/googlecategory/edit.phtml">
|
| 33 |
+
</block>
|
| 34 |
+
</reference>
|
| 35 |
+
</adminhtml_googlemerchants_index>
|
| 36 |
+
<adminhtml_googlemerchants_downloadtxt>
|
| 37 |
+
<reference name="head">
|
| 38 |
+
<action method="addItem">
|
| 39 |
+
<type>skin_css</type>
|
| 40 |
+
<name>web4pro_googlemerchants/custom.css</name>
|
| 41 |
+
<params/>
|
| 42 |
+
</action>
|
| 43 |
+
</reference>
|
| 44 |
+
<reference name="content">
|
| 45 |
+
<block type="googlemerchants/adminhtml_upload_form_container">
|
| 46 |
+
<block type="googlemerchants/adminhtml_upload_file" name="downlaod.form" as="downlaod.form"/>
|
| 47 |
+
</block>
|
| 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">
|
| 56 |
+
</block>
|
| 57 |
+
</reference>
|
| 58 |
+
</adminhtml_googlemerchants_feed>
|
| 59 |
+
|
| 60 |
+
</layout>
|
app/design/adminhtml/default/default/template/web4pro_googlemerchants/feed/form.phtml
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/* @var $this Web4pro_Googlemerchants_Block_Adminhtml_Editfeed_Edit_Form */
|
| 3 |
+
?>
|
| 4 |
+
<div id="edit_form_wrap" class="entity-edit">
|
| 5 |
+
<div class="entry-edit">
|
| 6 |
+
<div class="entry-edit-head">
|
| 7 |
+
<h4><?php echo $this->__('Manage google feed') ?></h4>
|
| 8 |
+
</div>
|
| 9 |
+
</div>
|
| 10 |
+
<form id="edit_form" method="post" action="<?php echo $this->getSaveUrl() ?>">
|
| 11 |
+
<input name="form_key" type="hidden" value="<?php echo $this->getFormKey() ?>"/>
|
| 12 |
+
|
| 13 |
+
<div class="box">
|
| 14 |
+
<div class="hor-scroll">
|
| 15 |
+
<table cellspacing="0" cellpadding="0" class="dynamic-grid" style="width:70%;" align="center">
|
| 16 |
+
<thead>
|
| 17 |
+
<tr class="headings">
|
| 18 |
+
<th style="width:160px;"><?php echo $this->__('Field Name') ?></th>
|
| 19 |
+
<th width="40%"><?php echo $this->__('Value') ?></th>
|
| 20 |
+
<th style="width:40%;"><?php echo $this->__('Action') ?></th>
|
| 21 |
+
</tr>
|
| 22 |
+
</thead>
|
| 23 |
+
<tbody id="mapping-table-body">
|
| 24 |
+
<?php echo $this->getTableBodyHtml() ?>
|
| 25 |
+
</tbody>
|
| 26 |
+
</table>
|
| 27 |
+
</br>
|
| 28 |
+
<button id="add_row_btn" onclick="addRow();return false;" class="scalable add" title="Add Option">
|
| 29 |
+
<span>Add Option</span>
|
| 30 |
+
</button>
|
| 31 |
+
</div>
|
| 32 |
+
</div>
|
| 33 |
+
</form>
|
| 34 |
+
|
| 35 |
+
<script type="text/javascript">
|
| 36 |
+
var lastIndex = getLastIndex();
|
| 37 |
+
|
| 38 |
+
function removeRow(index) {
|
| 39 |
+
var elementForDelete = $('table-row-' + index);
|
| 40 |
+
if (elementForDelete != null) {
|
| 41 |
+
elementForDelete.remove();
|
| 42 |
+
}
|
| 43 |
+
}
|
| 44 |
+
function addRow() {
|
| 45 |
+
var indexTAppend = lastIndex + 1;
|
| 46 |
+
var rowHtml = '<tr id="table-row-' + indexTAppend + '"><td><input name="feed-col-name[' + indexTAppend + ']"/></td>';
|
| 47 |
+
rowHtml += '<td><select name="attribute-select[' + indexTAppend + ']">';
|
| 48 |
+
rowHtml += '<?php echo $this->getOptionsHtml()?>';
|
| 49 |
+
rowHtml += '</select></td>';
|
| 50 |
+
rowHtml += '<td><button onclick="removeRow(' + indexTAppend + ');return false;">Remove</button></td>';
|
| 51 |
+
var lastRowId = "table-row-" + lastIndex;
|
| 52 |
+
var elementToAppend = $(lastRowId);
|
| 53 |
+
if (elementToAppend != null) {
|
| 54 |
+
$(lastRowId).insert({after: rowHtml});
|
| 55 |
+
lastIndex++;
|
| 56 |
+
}
|
| 57 |
+
}
|
| 58 |
+
function getLastIndex() {
|
| 59 |
+
var trs = $('mapping-table-body').getElementsByTagName("tr");
|
| 60 |
+
var lastEl = trs[trs.length - 1];
|
| 61 |
+
var lastElId = lastEl.id;
|
| 62 |
+
var laseFreeNum = lastElId.replace('table-row-', '');
|
| 63 |
+
return parseInt(laseFreeNum);
|
| 64 |
+
}
|
| 65 |
+
|
| 66 |
+
</script>
|
| 67 |
+
</div>
|
| 68 |
+
</div>
|
app/design/adminhtml/default/default/template/web4pro_googlemerchants/googlecategory/edit.phtml
ADDED
|
@@ -0,0 +1,166 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/* @var $this Web4pro_Googlemerchants_Block_Adminhtml_Googlecategory_Edit */
|
| 3 |
+
?>
|
| 4 |
+
<div class="content-header">
|
| 5 |
+
<?php echo $this->getHeaderHtml() ?>
|
| 6 |
+
<p class="form-buttons"><?php echo $this->getButtonsHtml('header') ?></p>
|
| 7 |
+
</div>
|
| 8 |
+
|
| 9 |
+
<div id="category-edit-container" class="category-content">
|
| 10 |
+
<?php echo $this->getChildHtml('form') ?>
|
| 11 |
+
</div>
|
| 12 |
+
<script type="text/javascript">
|
| 13 |
+
//<![CDATA[
|
| 14 |
+
|
| 15 |
+
function categoryReset(url, useAjax) {
|
| 16 |
+
if (useAjax) {
|
| 17 |
+
var params = {active_tab_id: false};
|
| 18 |
+
updateContent(url, params);
|
| 19 |
+
} else {
|
| 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) {
|
| 40 |
+
params = {};
|
| 41 |
+
}
|
| 42 |
+
if (!params.form_key) {
|
| 43 |
+
params.form_key = FORM_KEY;
|
| 44 |
+
}
|
| 45 |
+
|
| 46 |
+
toolbarToggle.stop();
|
| 47 |
+
|
| 48 |
+
/*if(params.node_name)
|
| 49 |
+
{
|
| 50 |
+
var currentNode = tree.getNodeById(tree.currentNodeId);
|
| 51 |
+
currentNode.setText(params.node_name);
|
| 52 |
+
}*/
|
| 53 |
+
|
| 54 |
+
var categoryContainer = $('category-edit-container');
|
| 55 |
+
var messagesContainer = $('messages');
|
| 56 |
+
var thisObj = this;
|
| 57 |
+
new Ajax.Request(url + (url.match(new RegExp('\\?')) ? '&isAjax=true' : '?isAjax=true' ), {
|
| 58 |
+
parameters: params,
|
| 59 |
+
evalScripts: true,
|
| 60 |
+
onComplete: function () {
|
| 61 |
+
/**
|
| 62 |
+
* This func depends on variables, that came in response, and were eval'ed in onSuccess() callback.
|
| 63 |
+
* Since prototype's Element.update() evals javascripts in 10 msec, we should exec our func after it.
|
| 64 |
+
*/
|
| 65 |
+
setTimeout(function () {
|
| 66 |
+
try {
|
| 67 |
+
if (refreshTree) {
|
| 68 |
+
thisObj.refreshTreeArea();
|
| 69 |
+
}
|
| 70 |
+
toolbarToggle.start();
|
| 71 |
+
} catch (e) {
|
| 72 |
+
alert(e.message);
|
| 73 |
+
}
|
| 74 |
+
;
|
| 75 |
+
}, 25);
|
| 76 |
+
},
|
| 77 |
+
onSuccess: function (transport) {
|
| 78 |
+
try {
|
| 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');
|
| 93 |
+
$('category_to_linking').removeAttribute('disabled');
|
| 94 |
+
}
|
| 95 |
+
}
|
| 96 |
+
}
|
| 97 |
+
catch (e) {
|
| 98 |
+
$(categoryContainer).update(transport.responseText);
|
| 99 |
+
}
|
| 100 |
+
}
|
| 101 |
+
});
|
| 102 |
+
}
|
| 103 |
+
|
| 104 |
+
/**
|
| 105 |
+
* Refresh tree nodes after saving or deleting a category
|
| 106 |
+
*/
|
| 107 |
+
|
| 108 |
+
//category_to_linking_submit
|
| 109 |
+
function refreshTreeArea(transport) {
|
| 110 |
+
if (tree && window.editingCategoryBreadcrumbs) {
|
| 111 |
+
// category deleted - delete its node
|
| 112 |
+
if (tree.nodeForDelete) {
|
| 113 |
+
var node = tree.getNodeById(tree.nodeForDelete);
|
| 114 |
+
tree.nodeForDelete = false;
|
| 115 |
+
|
| 116 |
+
if (node) { // Check maybe tree became somehow not synced with ajax and we're trying to delete unknown node
|
| 117 |
+
node.parentNode.removeChild(node);
|
| 118 |
+
tree.currentNodeId = false;
|
| 119 |
+
}
|
| 120 |
+
}
|
| 121 |
+
// category created - add its node
|
| 122 |
+
else if (tree.addNodeTo) {
|
| 123 |
+
var parent = tree.getNodeById(tree.addNodeTo);
|
| 124 |
+
tree.addNodeTo = false;
|
| 125 |
+
|
| 126 |
+
if (parent) { // Check maybe tree became somehow not synced with ajax and we're trying to add to unknown node
|
| 127 |
+
var node = new Ext.tree.AsyncTreeNode(editingCategoryBreadcrumbs[editingCategoryBreadcrumbs.length - 1]);
|
| 128 |
+
node.loaded = true;
|
| 129 |
+
tree.currentNodeId = node.id;
|
| 130 |
+
parent.appendChild(node);
|
| 131 |
+
|
| 132 |
+
if (parent.expanded) {
|
| 133 |
+
tree.selectCurrentNode();
|
| 134 |
+
} else {
|
| 135 |
+
var timer;
|
| 136 |
+
parent.expand();
|
| 137 |
+
var f = function () {
|
| 138 |
+
if (parent.expanded) { // done expanding
|
| 139 |
+
clearInterval(timer);
|
| 140 |
+
tree.selectCurrentNode();
|
| 141 |
+
}
|
| 142 |
+
};
|
| 143 |
+
timer = setInterval(f, 200);
|
| 144 |
+
}
|
| 145 |
+
}
|
| 146 |
+
}
|
| 147 |
+
|
| 148 |
+
// update all affected categories nodes names
|
| 149 |
+
for (var i = 0; i < editingCategoryBreadcrumbs.length; i++) {
|
| 150 |
+
var node = tree.getNodeById(editingCategoryBreadcrumbs[i].id);
|
| 151 |
+
if (node) {
|
| 152 |
+
node.setText(editingCategoryBreadcrumbs[i].text);
|
| 153 |
+
}
|
| 154 |
+
}
|
| 155 |
+
}
|
| 156 |
+
}
|
| 157 |
+
|
| 158 |
+
function displayLoadingMask() {
|
| 159 |
+
var loaderArea = $$('#html-body .wrapper')[0]; // Blocks all page
|
| 160 |
+
Position.clone($(loaderArea), $('loading-mask'), {offsetLeft: -2});
|
| 161 |
+
toggleSelectsUnderBlock($('loading-mask'), false);
|
| 162 |
+
Element.show('loading-mask');
|
| 163 |
+
}
|
| 164 |
+
|
| 165 |
+
//]]>
|
| 166 |
+
</script>
|
app/design/adminhtml/default/default/template/web4pro_googlemerchants/googlecategory/tree.phtml
ADDED
|
@@ -0,0 +1,440 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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">
|
| 8 |
+
<h3 class="icon-head head-categories"><?php echo Mage::helper('catalog')->__('Categories') ?></h3>
|
| 9 |
+
|
| 10 |
+
</div>
|
| 11 |
+
<?php echo $this->getStoreSwitcherHtml(); ?>
|
| 12 |
+
<div class="tree-actions">
|
| 13 |
+
<?php if ($this->getRoot()): ?>
|
| 14 |
+
<?php //echo $this->getCollapseButtonHtml() ?>
|
| 15 |
+
<?php //echo $this->getExpandButtonHtml() ?>
|
| 16 |
+
<?php /* <a href="#" onclick="tree.collapseTree(); return false;"><?php echo Mage::helper('catalog')->__('Collapse All'); ?></a> <span class="separator">|</span> <a href="#" onclick="tree.expandTree(); return false;"><?php echo Mage::helper('catalog')->__('Expand All'); ?></a> */ ?>
|
| 17 |
+
<?php endif; ?>
|
| 18 |
+
</div>
|
| 19 |
+
<?php if ($this->getRoot()): ?>
|
| 20 |
+
<div class="tree-holder">
|
| 21 |
+
<div id="tree-div" style="width:100%; overflow:auto;"></div>
|
| 22 |
+
</div>
|
| 23 |
+
</div>
|
| 24 |
+
<script type="text/javascript">
|
| 25 |
+
//<![CDATA[
|
| 26 |
+
var tree;
|
| 27 |
+
|
| 28 |
+
Ext.lib.Event.getTarget = function (e) {
|
| 29 |
+
var ee = e.browserEvent || e;
|
| 30 |
+
return ee.target ? Event.element(ee) : null;
|
| 31 |
+
};
|
| 32 |
+
|
| 33 |
+
Ext.tree.TreePanel.Enhanced = function (el, config) {
|
| 34 |
+
Ext.tree.TreePanel.Enhanced.superclass.constructor.call(this, el, config);
|
| 35 |
+
};
|
| 36 |
+
|
| 37 |
+
Ext.extend(Ext.tree.TreePanel.Enhanced, Ext.tree.TreePanel, {
|
| 38 |
+
|
| 39 |
+
loadTree: function (config, firstLoad) {
|
| 40 |
+
var parameters = config['parameters'];
|
| 41 |
+
var data = config['data'];
|
| 42 |
+
this.storeId = parameters['store_id'];
|
| 43 |
+
|
| 44 |
+
if (this.storeId != 0 && $('add_root_category_button')) {
|
| 45 |
+
$('add_root_category_button').hide();
|
| 46 |
+
}
|
| 47 |
+
|
| 48 |
+
if ((typeof parameters['root_visible']) != 'undefined') {
|
| 49 |
+
this.rootVisible = parameters['root_visible'] * 1;
|
| 50 |
+
}
|
| 51 |
+
|
| 52 |
+
var root = new Ext.tree.TreeNode(parameters);
|
| 53 |
+
|
| 54 |
+
this.nodeHash = {};
|
| 55 |
+
this.setRootNode(root);
|
| 56 |
+
|
| 57 |
+
if (firstLoad) {
|
| 58 |
+
this.addListener('click', this.categoryClick);
|
| 59 |
+
this.addListener('beforenodedrop', categoryMove.createDelegate(this));
|
| 60 |
+
}
|
| 61 |
+
|
| 62 |
+
this.loader.buildCategoryTree(root, data);
|
| 63 |
+
this.el.dom.innerHTML = '';
|
| 64 |
+
// render the tree
|
| 65 |
+
this.render();
|
| 66 |
+
if (parameters['expanded']) {
|
| 67 |
+
this.expandAll();
|
| 68 |
+
} else {
|
| 69 |
+
root.expand();
|
| 70 |
+
}
|
| 71 |
+
|
| 72 |
+
var selectedNode = this.getNodeById(parameters['category_id']);
|
| 73 |
+
if (selectedNode) {
|
| 74 |
+
this.currentNodeId = parameters['category_id'];
|
| 75 |
+
}
|
| 76 |
+
this.selectCurrentNode();
|
| 77 |
+
},
|
| 78 |
+
|
| 79 |
+
request: function (url, params) {
|
| 80 |
+
if (!params) {
|
| 81 |
+
if (category_info_tabsJsTabs.activeTab) {
|
| 82 |
+
var params = {active_tab_id: category_info_tabsJsTabs.activeTab.id};
|
| 83 |
+
}
|
| 84 |
+
else {
|
| 85 |
+
var params = {};
|
| 86 |
+
}
|
| 87 |
+
}
|
| 88 |
+
if (!params.form_key) {
|
| 89 |
+
params.form_key = FORM_KEY;
|
| 90 |
+
}
|
| 91 |
+
var result = new Ajax.Request(
|
| 92 |
+
url + (url.match(new RegExp('\\?')) ? '&isAjax=true' : '?isAjax=true' ),
|
| 93 |
+
{
|
| 94 |
+
parameters: params,
|
| 95 |
+
method: 'post'
|
| 96 |
+
}
|
| 97 |
+
);
|
| 98 |
+
|
| 99 |
+
return result;
|
| 100 |
+
},
|
| 101 |
+
|
| 102 |
+
selectCurrentNode: function () {
|
| 103 |
+
if (this.currentNodeId) {
|
| 104 |
+
var selectedNode = this.getNodeById(this.currentNodeId);
|
| 105 |
+
if ((typeof selectedNode.attributes.path) != 'undefined') {
|
| 106 |
+
var path = selectedNode.attributes.path;
|
| 107 |
+
if (!this.storeId) {
|
| 108 |
+
path = '0/' + path;
|
| 109 |
+
}
|
| 110 |
+
this.selectPath(path);
|
| 111 |
+
} else {
|
| 112 |
+
this.getSelectionModel().select(selectedNode);
|
| 113 |
+
}
|
| 114 |
+
}
|
| 115 |
+
},
|
| 116 |
+
|
| 117 |
+
collapseTree: function () {
|
| 118 |
+
this.collapseAll();
|
| 119 |
+
|
| 120 |
+
this.selectCurrentNode();
|
| 121 |
+
|
| 122 |
+
if (!this.collapsed) {
|
| 123 |
+
this.collapsed = true;
|
| 124 |
+
this.loader.dataUrl = '<?php echo $this->getLoadTreeUrl(false) ?>';
|
| 125 |
+
this.request(this.loader.dataUrl, false);
|
| 126 |
+
}
|
| 127 |
+
},
|
| 128 |
+
|
| 129 |
+
expandTree: function () {
|
| 130 |
+
this.expandAll();
|
| 131 |
+
if (this.collapsed) {
|
| 132 |
+
this.collapsed = false;
|
| 133 |
+
this.loader.dataUrl = '<?php echo $this->getLoadTreeUrl(true) ?>';
|
| 134 |
+
this.request(this.loader.dataUrl, false);
|
| 135 |
+
}
|
| 136 |
+
},
|
| 137 |
+
|
| 138 |
+
categoryClick: function (node, e) {
|
| 139 |
+
var baseUrl = '<?php echo $this->getLinkedCategoryActionUrl() ?>';
|
| 140 |
+
var urlExt = (this.storeId ? 'store/' + this.storeId + '/' : '') + 'id/' + node.id + '/';
|
| 141 |
+
var url = parseSidUrl(baseUrl, urlExt);
|
| 142 |
+
|
| 143 |
+
this.currentNodeId = node.id;
|
| 144 |
+
if (!this.useAjax) {
|
| 145 |
+
setLocation(url);
|
| 146 |
+
return;
|
| 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 |
+
});
|
| 153 |
+
|
| 154 |
+
function reRenderTree(event, switcher) {
|
| 155 |
+
// re-render tree by store switcher
|
| 156 |
+
if (tree && event) {
|
| 157 |
+
var obj = event.target;
|
| 158 |
+
var newStoreId = obj.value * 1;
|
| 159 |
+
var storeParam = newStoreId ? 'store/' + newStoreId + '/' : '';
|
| 160 |
+
|
| 161 |
+
if (obj.switchParams) {
|
| 162 |
+
storeParam += obj.switchParams;
|
| 163 |
+
}
|
| 164 |
+
if (switcher.useConfirm) {
|
| 165 |
+
if (!confirm("<?php echo $this->__('Please confirm site switching. All data that hasn\'t been saved will be lost.') ?>")) {
|
| 166 |
+
obj.value = '<?php echo (int) $this->getStoreId() ?>';
|
| 167 |
+
return false;
|
| 168 |
+
}
|
| 169 |
+
}
|
| 170 |
+
|
| 171 |
+
if ($('add_root_category_button')) {
|
| 172 |
+
if (newStoreId == 0) {
|
| 173 |
+
$('add_root_category_button').show();
|
| 174 |
+
}
|
| 175 |
+
else {
|
| 176 |
+
$('add_root_category_button').hide();
|
| 177 |
+
}
|
| 178 |
+
}
|
| 179 |
+
|
| 180 |
+
// retain current selected category id
|
| 181 |
+
storeParam = storeParam + 'id/' + tree.currentNodeId + '/';
|
| 182 |
+
var url = tree.switchTreeUrl + storeParam;
|
| 183 |
+
|
| 184 |
+
// load from cache
|
| 185 |
+
// load from ajax
|
| 186 |
+
new Ajax.Request(url + (url.match(new RegExp('\\?')) ? '&isAjax=true' : '?isAjax=true' ), {
|
| 187 |
+
parameters: {store: newStoreId, form_key: FORM_KEY},
|
| 188 |
+
method: 'post',
|
| 189 |
+
onComplete: function (transport) {
|
| 190 |
+
var response = eval('(' + transport.responseText + ')');
|
| 191 |
+
if (!response['parameters']) {
|
| 192 |
+
return false;
|
| 193 |
+
}
|
| 194 |
+
|
| 195 |
+
_renderNewTree(response, storeParam);
|
| 196 |
+
}
|
| 197 |
+
});
|
| 198 |
+
}
|
| 199 |
+
// render default tree
|
| 200 |
+
else {
|
| 201 |
+
_renderNewTree();
|
| 202 |
+
}
|
| 203 |
+
}
|
| 204 |
+
|
| 205 |
+
function _renderNewTree(config, storeParam) {
|
| 206 |
+
if (!config) {
|
| 207 |
+
var config = defaultLoadTreeParams;
|
| 208 |
+
}
|
| 209 |
+
if (tree) {
|
| 210 |
+
tree.purgeListeners();
|
| 211 |
+
tree.el.dom.innerHTML = '';
|
| 212 |
+
}
|
| 213 |
+
tree = new Ext.tree.TreePanel.Enhanced('tree-div', newTreeParams);
|
| 214 |
+
tree.loadTree(config, true);
|
| 215 |
+
|
| 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();
|
| 222 |
+
|
| 223 |
+
// update content area
|
| 224 |
+
var url = tree.editUrl;
|
| 225 |
+
if (storeParam) {
|
| 226 |
+
url = url + storeParam;
|
| 227 |
+
}
|
| 228 |
+
<?php if ($this->isClearEdit()):?>
|
| 229 |
+
if (selectedNode) {
|
| 230 |
+
url = url + 'id/' + config.parameters.category_id;
|
| 231 |
+
}
|
| 232 |
+
<?php endif;?>
|
| 233 |
+
//updateContent(url);
|
| 234 |
+
}
|
| 235 |
+
|
| 236 |
+
Ext.onReady(function () {
|
| 237 |
+
categoryLoader = new Ext.tree.TreeLoader({
|
| 238 |
+
dataUrl: '<?php echo $this->getLoadTreeUrl() ?>'
|
| 239 |
+
});
|
| 240 |
+
|
| 241 |
+
categoryLoader.createNode = function (config) {
|
| 242 |
+
var node;
|
| 243 |
+
var _node = Object.clone(config);
|
| 244 |
+
if (config.children && !config.children.length) {
|
| 245 |
+
delete(config.children);
|
| 246 |
+
node = new Ext.tree.AsyncTreeNode(config);
|
| 247 |
+
} else {
|
| 248 |
+
node = new Ext.tree.TreeNode(config);
|
| 249 |
+
}
|
| 250 |
+
|
| 251 |
+
return node;
|
| 252 |
+
};
|
| 253 |
+
|
| 254 |
+
categoryLoader.buildCategoryTree = function (parent, config) {
|
| 255 |
+
if (!config) {
|
| 256 |
+
return null;
|
| 257 |
+
}
|
| 258 |
+
if (parent && config && config.length) {
|
| 259 |
+
for (var i = 0; i < config.length; i++) {
|
| 260 |
+
var node;
|
| 261 |
+
var _node = Object.clone(config[i]);
|
| 262 |
+
if (_node.children && !_node.children.length) {
|
| 263 |
+
delete(_node.children);
|
| 264 |
+
node = new Ext.tree.AsyncTreeNode(_node);
|
| 265 |
+
} else {
|
| 266 |
+
node = new Ext.tree.TreeNode(config[i]);
|
| 267 |
+
}
|
| 268 |
+
parent.appendChild(node);
|
| 269 |
+
node.loader = node.getOwnerTree().loader;
|
| 270 |
+
if (_node.children) {
|
| 271 |
+
this.buildCategoryTree(node, _node.children);
|
| 272 |
+
}
|
| 273 |
+
}
|
| 274 |
+
}
|
| 275 |
+
};
|
| 276 |
+
|
| 277 |
+
categoryLoader.buildHash = function (node) {
|
| 278 |
+
var hash = {};
|
| 279 |
+
|
| 280 |
+
hash = this.toArray(node.attributes);
|
| 281 |
+
|
| 282 |
+
if (node.childNodes.length > 0 || (node.loaded == false && node.loading == false)) {
|
| 283 |
+
hash['children'] = new Array;
|
| 284 |
+
|
| 285 |
+
for (var i = 0, len = node.childNodes.length; i < len; i++) {
|
| 286 |
+
if (!hash['children']) {
|
| 287 |
+
hash['children'] = new Array;
|
| 288 |
+
}
|
| 289 |
+
hash['children'].push(this.buildHash(node.childNodes[i]));
|
| 290 |
+
}
|
| 291 |
+
}
|
| 292 |
+
|
| 293 |
+
return hash;
|
| 294 |
+
};
|
| 295 |
+
|
| 296 |
+
categoryLoader.toArray = function (attributes) {
|
| 297 |
+
var data = {form_key: FORM_KEY};
|
| 298 |
+
for (var key in attributes) {
|
| 299 |
+
var value = attributes[key];
|
| 300 |
+
data[key] = value;
|
| 301 |
+
}
|
| 302 |
+
|
| 303 |
+
return data;
|
| 304 |
+
};
|
| 305 |
+
|
| 306 |
+
categoryLoader.on("beforeload", function (treeLoader, node) {
|
| 307 |
+
treeLoader.baseParams.id = node.attributes.id;
|
| 308 |
+
treeLoader.baseParams.store = node.attributes.store;
|
| 309 |
+
treeLoader.baseParams.form_key = FORM_KEY;
|
| 310 |
+
});
|
| 311 |
+
|
| 312 |
+
categoryLoader.on("load", function (treeLoader, node, config) {
|
| 313 |
+
varienWindowOnload();
|
| 314 |
+
});
|
| 315 |
+
|
| 316 |
+
if ((typeof varienStoreSwitcher) != 'undefined') {
|
| 317 |
+
varienStoreSwitcher.storeSelectorClickCallback = reRenderTree;
|
| 318 |
+
}
|
| 319 |
+
|
| 320 |
+
newTreeParams = {
|
| 321 |
+
animate: false,
|
| 322 |
+
loader: categoryLoader,
|
| 323 |
+
enableDD: true,
|
| 324 |
+
containerScroll: true,
|
| 325 |
+
selModel: new Ext.tree.CheckNodeMultiSelectionModel(),
|
| 326 |
+
rootVisible: '<?php echo $this->getRoot()->getIsVisible() ?>',
|
| 327 |
+
useAjax: <?php echo $this->getUseAjax() ?>,
|
| 328 |
+
switchTreeUrl: '<?php echo $this->getSwitchTreeUrl() ?>',
|
| 329 |
+
editUrl: '<?php echo $this->getEditUrl() ?>',
|
| 330 |
+
currentNodeId: <?php echo (int) $this->getCategoryId() ?>
|
| 331 |
+
};
|
| 332 |
+
|
| 333 |
+
defaultLoadTreeParams = {
|
| 334 |
+
parameters: {
|
| 335 |
+
text: '<?php echo htmlentities($this->getRoot()->getName()) ?>',
|
| 336 |
+
draggable: false,
|
| 337 |
+
allowDrop: <?php if ($this->getRoot()->getIsVisible()): ?>true<?php else : ?>false<?php endif; ?>,
|
| 338 |
+
id: <?php echo (int) $this->getRoot()->getId() ?>,
|
| 339 |
+
expanded: <?php echo (int) $this->getIsWasExpanded() ?>,
|
| 340 |
+
store_id: <?php echo (int) $this->getStore()->getId() ?>,
|
| 341 |
+
category_id: <?php echo (int) $this->getCategoryId() ?>
|
| 342 |
+
},
|
| 343 |
+
data: <?php echo $this->getTreeJson() ?>
|
| 344 |
+
};
|
| 345 |
+
|
| 346 |
+
reRenderTree();
|
| 347 |
+
});
|
| 348 |
+
|
| 349 |
+
function addNew(url, isRoot) {
|
| 350 |
+
if (isRoot) {
|
| 351 |
+
tree.currentNodeId = tree.root.id;
|
| 352 |
+
}
|
| 353 |
+
|
| 354 |
+
if (/store\/\d+/.test(url)) {
|
| 355 |
+
url = url.replace(/store\/\d+/, "store/" + tree.storeId);
|
| 356 |
+
}
|
| 357 |
+
else {
|
| 358 |
+
url += "store/" + tree.storeId + "/";
|
| 359 |
+
}
|
| 360 |
+
|
| 361 |
+
url += 'parent/' + tree.currentNodeId;
|
| 362 |
+
//updateContent(url);
|
| 363 |
+
}
|
| 364 |
+
|
| 365 |
+
function categoryMove(obj) {
|
| 366 |
+
var data = {id: obj.dropNode.id, form_key: FORM_KEY};
|
| 367 |
+
|
| 368 |
+
data.point = obj.point;
|
| 369 |
+
switch (obj.point) {
|
| 370 |
+
case 'above' :
|
| 371 |
+
data.pid = obj.target.parentNode.id;
|
| 372 |
+
data.paid = obj.dropNode.parentNode.id;
|
| 373 |
+
if (obj.target.previousSibling) {
|
| 374 |
+
data.aid = obj.target.previousSibling.id;
|
| 375 |
+
} else {
|
| 376 |
+
data.aid = 0;
|
| 377 |
+
}
|
| 378 |
+
break;
|
| 379 |
+
case 'below' :
|
| 380 |
+
data.pid = obj.target.parentNode.id;
|
| 381 |
+
data.aid = obj.target.id;
|
| 382 |
+
break;
|
| 383 |
+
case 'append' :
|
| 384 |
+
data.pid = obj.target.id;
|
| 385 |
+
data.paid = obj.dropNode.parentNode.id;
|
| 386 |
+
if (obj.target.lastChild) {
|
| 387 |
+
data.aid = obj.target.lastChild.id;
|
| 388 |
+
} else {
|
| 389 |
+
data.aid = 0;
|
| 390 |
+
}
|
| 391 |
+
break;
|
| 392 |
+
default :
|
| 393 |
+
obj.cancel = true;
|
| 394 |
+
return obj;
|
| 395 |
+
}
|
| 396 |
+
|
| 397 |
+
var success = function (o) {
|
| 398 |
+
try {
|
| 399 |
+
if (o.responseText) {
|
| 400 |
+
if (o.responseText === 'SUCCESS') {
|
| 401 |
+
categoryForm.refreshPath();
|
| 402 |
+
} else {
|
| 403 |
+
alert(o.responseText);
|
| 404 |
+
location.reload();
|
| 405 |
+
}
|
| 406 |
+
}
|
| 407 |
+
}
|
| 408 |
+
catch (e) {
|
| 409 |
+
}
|
| 410 |
+
};
|
| 411 |
+
|
| 412 |
+
var failure = function (o) {
|
| 413 |
+
try {
|
| 414 |
+
console.log(o.statusText);
|
| 415 |
+
} catch (e2) {
|
| 416 |
+
alert(o.statusText);
|
| 417 |
+
}
|
| 418 |
+
location.reload();
|
| 419 |
+
};
|
| 420 |
+
|
| 421 |
+
var pd = [];
|
| 422 |
+
for (var key in data) {
|
| 423 |
+
pd.push(encodeURIComponent(key), "=", encodeURIComponent(data[key]), "&");
|
| 424 |
+
}
|
| 425 |
+
pd.splice(pd.length - 1, 1);
|
| 426 |
+
new Ajax.Request(
|
| 427 |
+
'<?php echo $this->getMoveUrl() ?>',
|
| 428 |
+
{
|
| 429 |
+
method: 'POST',
|
| 430 |
+
parameters: pd.join(""),
|
| 431 |
+
onSuccess: success,
|
| 432 |
+
onFailure: failure
|
| 433 |
+
}
|
| 434 |
+
);
|
| 435 |
+
}
|
| 436 |
+
//]]>
|
| 437 |
+
</script>
|
| 438 |
+
<?php endif; ?>
|
| 439 |
+
|
| 440 |
+
<?php endif; ?>
|
app/etc/modules/Web4pro_Googlemerchants.xml
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0"?>
|
| 2 |
+
<config>
|
| 3 |
+
<modules>
|
| 4 |
+
<Web4pro_Googlemerchants>
|
| 5 |
+
<active>false</active>
|
| 6 |
+
<codePool>community</codePool>
|
| 7 |
+
</Web4pro_Googlemerchants>
|
| 8 |
+
</modules>
|
| 9 |
+
</config>
|
package.xml
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0"?>
|
| 2 |
+
<package>
|
| 3 |
+
<name>Web4pro_Googlemerchants</name>
|
| 4 |
+
<version>1.0.0</version>
|
| 5 |
+
<stability>stable</stability>
|
| 6 |
+
<license uri="http://opensource.org/licenses/OSL-3.0">OSL v.3</license>
|
| 7 |
+
<channel>community</channel>
|
| 8 |
+
<extends/>
|
| 9 |
+
<summary>Extension for generation feeds for importing products to google service.</summary>
|
| 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>First preview release</notes>
|
| 12 |
+
<authors><author><name>Alex</name><user>alex</user><email>achernyshev@corp.web4pro.com.ua</email></author></authors>
|
| 13 |
+
<date>2015-05-22</date>
|
| 14 |
+
<time>13:32:17</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="1a8d021dded3e9318bd363c0b5492f9c"/></dir></dir><file name="Editfeed.php" hash="1924d5dc08780fdb432e9e0c2dda2d28"/><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="bf84b27e5a750ef4c24933bf156270f8"/></dir><dir name="Upload"><file name="File.php" hash="0d40ad6ce19b1ee072c5cf2114057d2e"/><dir name="Form"><file name="Container.php" hash="cc23b62251b3dd41634e04dc395be4ed"/></dir><dir name="Link"><file name="Renderer.php" hash="362b3cdc98a95d9f222e11c8e01b762d"/></dir></dir></dir></dir><dir name="Helper"><file name="Data.php" hash="42d34af5a391c0f1cb6ccb00d413ad8a"/></dir><dir name="Model"><file name="Googlecategory.php" hash="ebc58e4c62ec8d0be2edf21f12a0d1e2"/><file name="Googlefeed.php" hash="76f9e1d96602db25d870195ba6cde50e"/><file name="Googleshipping.php" hash="df374e7240529c640c90be2b3239f3df"/><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></dir><dir name="controllers"><dir name="Adminhtml"><file name="GooglemerchantsController.php" hash="805c2d19b3d2b6477c9c898532b92332"/></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="704eab9384927a53ba001111dded1b9c"/><file name="config.xml" hash="a4f8bf72ce0aae8bf255f0ec5595c0fa"/><file name="system.xml" hash="26acf2a296ac92f098064a0dfe5a32fd"/></dir><dir name="sql"><dir name="googlemerchants_setup"><file name="install-0.0.0.1.php" hash="62d572474a1e3673c66b9d7c1252ec09"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Web4pro_Googlemerchants.xml" hash="d8db1e6569a916e188e35fd91841ec46"/></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="6198c32db1e6a55a5cdc7b8c1eb83b1d"/></dir><dir name="googlecategory"><file name="edit.phtml" hash="2ccd1585fc12031d4c51ad230120d2db"/><file name="tree.phtml" hash="21331415dbb96f1c2a58e7f22ae163f0"/></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="custom.css" hash="bcb3ec038f97daee9106c6cdf6ff4d46"/></dir></dir></dir></dir></target></contents>
|
| 16 |
+
<compatible/>
|
| 17 |
+
<dependencies><required><php><min>5.3.0</min><max>5.5.0</max></php></required></dependencies>
|
| 18 |
+
</package>
|
skin/adminhtml/default/default/web4pro_googlemerchants/custom.css
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
.form-button-custom {
|
| 2 |
+
margin-left: -190px;
|
| 3 |
+
}
|
| 4 |
+
|
| 5 |
+
#select-file-hint {
|
| 6 |
+
text-align: right !important;
|
| 7 |
+
}
|
| 8 |
+
|
| 9 |
+
#upload-hint-image {
|
| 10 |
+
margin-left: 10px;
|
| 11 |
+
}
|
