Version Notes
Add functionallity for store selection
Download this release
Release Info
Developer | Alex |
Extension | Web4pro_Googlemerchants |
Version | 1.0.2 |
Comparing to | |
See all releases |
Code changes from version 1.0.1 to 1.0.2
- app/code/community/Web4pro/Googlemerchants/Block/Adminhtml/Editfeed.php +7 -8
- app/code/community/Web4pro/Googlemerchants/Block/Adminhtml/Editfeed/Edit/Form.php +12 -6
- app/code/community/Web4pro/Googlemerchants/Block/Adminhtml/System/Instruction.php +0 -14
- app/code/community/Web4pro/Googlemerchants/Block/Adminhtml/Upload/Form/Container.php +1 -1
- app/code/community/Web4pro/Googlemerchants/Block/Adminhtml/Upload/Link/Renderer.php +3 -0
- app/code/community/Web4pro/Googlemerchants/Helper/Data.php +46 -0
- app/code/community/Web4pro/Googlemerchants/Model/Googlecategory.php +12 -0
- app/code/community/Web4pro/Googlemerchants/Model/Googlefeed.php +52 -28
- app/code/community/Web4pro/Googlemerchants/Model/Googleshipping.php +2 -1
- app/code/community/Web4pro/Googlemerchants/Model/Storefeedconfig.php +8 -0
- app/code/community/Web4pro/Googlemerchants/controllers/Adminhtml/GooglemerchantsController.php +14 -7
- app/code/community/Web4pro/Googlemerchants/etc/system.xml +11 -2
- app/design/adminhtml/default/default/template/web4pro_googlemerchants/feed/form.phtml +28 -20
- package.xml +6 -6
- skin/adminhtml/default/default/web4pro_googlemerchants/custom.css +0 -11
app/code/community/Web4pro/Googlemerchants/Block/Adminhtml/Editfeed.php
CHANGED
@@ -14,18 +14,15 @@ class Web4pro_Googlemerchants_Block_Adminhtml_Editfeed extends Mage_Adminhtml_Bl
|
|
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',
|
@@ -37,6 +34,7 @@ class Web4pro_Googlemerchants_Block_Adminhtml_Editfeed extends Mage_Adminhtml_Bl
|
|
37 |
|
38 |
|
39 |
/**
|
|
|
40 |
* @return mixed
|
41 |
*/
|
42 |
public function getSaveUrl()
|
@@ -49,7 +47,6 @@ class Web4pro_Googlemerchants_Block_Adminhtml_Editfeed extends Mage_Adminhtml_Bl
|
|
49 |
*/
|
50 |
public function getValidationUrl()
|
51 |
{
|
52 |
-
//return false;
|
53 |
return $this->getSaveUrl();
|
54 |
}
|
55 |
|
@@ -58,7 +55,7 @@ class Web4pro_Googlemerchants_Block_Adminhtml_Editfeed extends Mage_Adminhtml_Bl
|
|
58 |
*/
|
59 |
public function getGenerateFeedUrl()
|
60 |
{
|
61 |
-
return Mage::helper("adminhtml")->getUrl('adminhtml/googlemerchants/generatefeed');
|
62 |
}
|
63 |
|
64 |
/**
|
@@ -68,4 +65,6 @@ class Web4pro_Googlemerchants_Block_Adminhtml_Editfeed extends Mage_Adminhtml_Bl
|
|
68 |
{
|
69 |
return Mage::helper("adminhtml")->getUrl('adminhtml/googlemerchants/resetfeed');
|
70 |
}
|
|
|
|
|
71 |
}
|
14 |
{
|
15 |
protected $_headerText = 'Manage feed settings';
|
16 |
|
17 |
+
/**
|
18 |
+
* class constructor
|
19 |
+
*/
|
20 |
public function __construct()
|
21 |
{
|
22 |
parent::__construct();
|
23 |
$this->_objectId = 'id';
|
24 |
$this->_blockGroup = 'googlemerchants';
|
25 |
$this->_controller = 'adminhtml_editfeed';
|
|
|
|
|
|
|
|
|
|
|
|
|
26 |
$this->_addButton('generate_feed', array(
|
27 |
'label' => Mage::helper('adminhtml')->__('Generate feed .csv'),
|
28 |
'class' => 'save',
|
34 |
|
35 |
|
36 |
/**
|
37 |
+
*
|
38 |
* @return mixed
|
39 |
*/
|
40 |
public function getSaveUrl()
|
47 |
*/
|
48 |
public function getValidationUrl()
|
49 |
{
|
|
|
50 |
return $this->getSaveUrl();
|
51 |
}
|
52 |
|
55 |
*/
|
56 |
public function getGenerateFeedUrl()
|
57 |
{
|
58 |
+
return Mage::helper("adminhtml")->getUrl('adminhtml/googlemerchants/generatefeed', array('store' => Mage::helper('googlemerchants')->getStoreCodeFromPost()));
|
59 |
}
|
60 |
|
61 |
/**
|
65 |
{
|
66 |
return Mage::helper("adminhtml")->getUrl('adminhtml/googlemerchants/resetfeed');
|
67 |
}
|
68 |
+
|
69 |
+
|
70 |
}
|
app/code/community/Web4pro/Googlemerchants/Block/Adminhtml/Editfeed/Edit/Form.php
CHANGED
@@ -22,7 +22,7 @@ class Web4pro_Googlemerchants_Block_Adminhtml_Editfeed_Edit_Form extends Mage_Ad
|
|
22 |
{
|
23 |
$form = new Varien_Data_Form(array(
|
24 |
'id' => 'edit_form',
|
25 |
-
'action' => $this->getUrl('adminhtml/googlemerchants/savefeed', array('store' => Mage::
|
26 |
'method' => 'post',
|
27 |
)
|
28 |
);
|
@@ -33,6 +33,7 @@ class Web4pro_Googlemerchants_Block_Adminhtml_Editfeed_Edit_Form extends Mage_Ad
|
|
33 |
}
|
34 |
|
35 |
/**
|
|
|
36 |
* @param int $nameIndex
|
37 |
* @param string $selectedVal
|
38 |
* @return string
|
@@ -40,13 +41,14 @@ class Web4pro_Googlemerchants_Block_Adminhtml_Editfeed_Edit_Form extends Mage_Ad
|
|
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 |
*/
|
@@ -54,7 +56,7 @@ class Web4pro_Googlemerchants_Block_Adminhtml_Editfeed_Edit_Form extends Mage_Ad
|
|
54 |
public function getOptionsHtml($selectedVal = '')
|
55 |
{
|
56 |
$options = Mage::getModel('googlemerchants/googlefeed')->getAttributesOptions();
|
57 |
-
$retStr = '<option value="
|
58 |
foreach ($options as $option) {
|
59 |
if ($option['code'] == $selectedVal) {
|
60 |
$retStr .= '<option value="' . addslashes($option['code']) . '" selected>' . addslashes($option['label']) . '</option>';
|
@@ -66,6 +68,7 @@ class Web4pro_Googlemerchants_Block_Adminhtml_Editfeed_Edit_Form extends Mage_Ad
|
|
66 |
}
|
67 |
|
68 |
/**
|
|
|
69 |
* @return string
|
70 |
*/
|
71 |
|
@@ -79,13 +82,12 @@ class Web4pro_Googlemerchants_Block_Adminhtml_Editfeed_Edit_Form extends Mage_Ad
|
|
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 |
|
@@ -96,7 +98,7 @@ class Web4pro_Googlemerchants_Block_Adminhtml_Editfeed_Edit_Form extends Mage_Ad
|
|
96 |
|
97 |
protected function getRemoveRowButtonHtml($nameIndex = 0)
|
98 |
{
|
99 |
-
return '<button onclick="removeRow(' . $nameIndex . ')">Remove</button>';
|
100 |
}
|
101 |
|
102 |
/**
|
@@ -124,4 +126,8 @@ class Web4pro_Googlemerchants_Block_Adminhtml_Editfeed_Edit_Form extends Mage_Ad
|
|
124 |
return Mage::helper("adminhtml")->getUrl('adminhtml/googlemerchants/feedajax');
|
125 |
}
|
126 |
|
|
|
|
|
|
|
|
|
127 |
}
|
22 |
{
|
23 |
$form = new Varien_Data_Form(array(
|
24 |
'id' => 'edit_form',
|
25 |
+
'action' => $this->getUrl('adminhtml/googlemerchants/savefeed', array('store' => Mage::helper('googlemerchants')->getStoreCodeFromPost(), 'isAjax' => true)),
|
26 |
'method' => 'post',
|
27 |
)
|
28 |
);
|
33 |
}
|
34 |
|
35 |
/**
|
36 |
+
* render select html fields for feed configuration
|
37 |
* @param int $nameIndex
|
38 |
* @param string $selectedVal
|
39 |
* @return string
|
41 |
|
42 |
public function getSelectHtml($nameIndex = 0, $selectedVal = '')
|
43 |
{
|
44 |
+
$retStr = '<select class="required-entry select" name="attribute-select[' . $nameIndex . ']">';
|
45 |
$retStr .= $this->getOptionsHtml($selectedVal);
|
46 |
$retStr .= '</select>';
|
47 |
return $retStr;
|
48 |
}
|
49 |
|
50 |
/**
|
51 |
+
* render options html fields for select fields
|
52 |
* @param string $selectedVal
|
53 |
* @return string
|
54 |
*/
|
56 |
public function getOptionsHtml($selectedVal = '')
|
57 |
{
|
58 |
$options = Mage::getModel('googlemerchants/googlefeed')->getAttributesOptions();
|
59 |
+
$retStr = '<option value=""></option>';
|
60 |
foreach ($options as $option) {
|
61 |
if ($option['code'] == $selectedVal) {
|
62 |
$retStr .= '<option value="' . addslashes($option['code']) . '" selected>' . addslashes($option['label']) . '</option>';
|
68 |
}
|
69 |
|
70 |
/**
|
71 |
+
* rendering the table body for feed table
|
72 |
* @return string
|
73 |
*/
|
74 |
|
82 |
continue;
|
83 |
}
|
84 |
$resStr .= '<tr id="table-row-' . $index . '">';
|
85 |
+
$resStr .= '<td><input class="required-entry" name="feed-col-name[' . $index . ']" value="' . $val['value'] . '"/></td>';
|
86 |
$resStr .= '<td>' . $this->getSelectHtml($index, $val['selected']) . '</td>';
|
87 |
$resStr .= '<td>' . $this->getRemoveRowButtonHtml($index) . '</td>';
|
88 |
$resStr .= '</tr>';
|
89 |
$index++;
|
90 |
}
|
|
|
91 |
return $resStr;
|
92 |
}
|
93 |
|
98 |
|
99 |
protected function getRemoveRowButtonHtml($nameIndex = 0)
|
100 |
{
|
101 |
+
return '<button onclick="removeRow(' . $nameIndex . '); " class="delete delete-option">Remove</button>';
|
102 |
}
|
103 |
|
104 |
/**
|
126 |
return Mage::helper("adminhtml")->getUrl('adminhtml/googlemerchants/feedajax');
|
127 |
}
|
128 |
|
129 |
+
public function getAvailableStores()
|
130 |
+
{
|
131 |
+
return Mage::helper('googlemerchants')->getStoresAssocArray();
|
132 |
+
}
|
133 |
}
|
app/code/community/Web4pro/Googlemerchants/Block/Adminhtml/System/Instruction.php
CHANGED
@@ -2,21 +2,7 @@
|
|
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 = '
|
2 |
|
3 |
class Web4pro_Googlemerchants_Block_Adminhtml_System_Instruction extends Mage_Adminhtml_Block_System_Config_Form_Field
|
4 |
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
|
|
|
|
|
6 |
public function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
|
7 |
{
|
8 |
$html = '
|
app/code/community/Web4pro/Googlemerchants/Block/Adminhtml/Upload/Form/Container.php
CHANGED
@@ -15,7 +15,7 @@ class Web4pro_Googlemerchants_Block_Adminhtml_Upload_Form_Container extends Mage
|
|
15 |
protected $_headerText = 'Upload file with google categories';
|
16 |
|
17 |
/**
|
18 |
-
* @return
|
19 |
*/
|
20 |
protected function _prepareLayout()
|
21 |
{
|
15 |
protected $_headerText = 'Upload file with google categories';
|
16 |
|
17 |
/**
|
18 |
+
* @return Web4pro_Googlemerchants_Block_Adminhtml_Upload_Form_Container
|
19 |
*/
|
20 |
protected function _prepareLayout()
|
21 |
{
|
app/code/community/Web4pro/Googlemerchants/Block/Adminhtml/Upload/Link/Renderer.php
CHANGED
@@ -20,6 +20,9 @@ class Web4pro_Googlemerchants_Block_Adminhtml_Upload_Link_Renderer extends Varie
|
|
20 |
return '';
|
21 |
}
|
22 |
|
|
|
|
|
|
|
23 |
public function getLabelHtml()
|
24 |
{
|
25 |
$html = '<div>
|
20 |
return '';
|
21 |
}
|
22 |
|
23 |
+
/**
|
24 |
+
* @return string
|
25 |
+
*/
|
26 |
public function getLabelHtml()
|
27 |
{
|
28 |
$html = '<div>
|
app/code/community/Web4pro/Googlemerchants/Helper/Data.php
CHANGED
@@ -17,6 +17,7 @@ class Web4pro_Googlemerchants_Helper_Data extends Mage_Core_Helper_Abstract
|
|
17 |
*/
|
18 |
protected $_defaultStoreId = NULL;
|
19 |
|
|
|
20 |
/**
|
21 |
* @param Web4pro_Googlemerchants_Model_Googlecategory $entity
|
22 |
* @return array
|
@@ -115,6 +116,11 @@ class Web4pro_Googlemerchants_Helper_Data extends Mage_Core_Helper_Abstract
|
|
115 |
return '';
|
116 |
}
|
117 |
|
|
|
|
|
|
|
|
|
|
|
118 |
public function getParentIds($product)
|
119 |
{
|
120 |
$parentIds = array();
|
@@ -127,6 +133,10 @@ class Web4pro_Googlemerchants_Helper_Data extends Mage_Core_Helper_Abstract
|
|
127 |
return $parentIds;
|
128 |
}
|
129 |
|
|
|
|
|
|
|
|
|
130 |
public function getProductUrl($product)
|
131 |
{
|
132 |
$productVisibility = $product->getVisibility();
|
@@ -140,6 +150,10 @@ class Web4pro_Googlemerchants_Helper_Data extends Mage_Core_Helper_Abstract
|
|
140 |
return $urlKey;
|
141 |
}
|
142 |
|
|
|
|
|
|
|
|
|
143 |
public function getMinPrice($product)
|
144 |
{
|
145 |
$productType = $product->getTypeID();
|
@@ -192,4 +206,36 @@ class Web4pro_Googlemerchants_Helper_Data extends Mage_Core_Helper_Abstract
|
|
192 |
}
|
193 |
return $priseStr;
|
194 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
195 |
}
|
17 |
*/
|
18 |
protected $_defaultStoreId = NULL;
|
19 |
|
20 |
+
const CONFIG_DEFAULT_FRONTEND_STORE_CODE = 'googlemerchants_options/general/google_selected_store_for_feed';
|
21 |
/**
|
22 |
* @param Web4pro_Googlemerchants_Model_Googlecategory $entity
|
23 |
* @return array
|
116 |
return '';
|
117 |
}
|
118 |
|
119 |
+
/**
|
120 |
+
* returns children product ids for grouped configurable and bundle products
|
121 |
+
* @param $product
|
122 |
+
* @return array
|
123 |
+
*/
|
124 |
public function getParentIds($product)
|
125 |
{
|
126 |
$parentIds = array();
|
133 |
return $parentIds;
|
134 |
}
|
135 |
|
136 |
+
/**
|
137 |
+
* @param $product
|
138 |
+
* @return mixed
|
139 |
+
*/
|
140 |
public function getProductUrl($product)
|
141 |
{
|
142 |
$productVisibility = $product->getVisibility();
|
150 |
return $urlKey;
|
151 |
}
|
152 |
|
153 |
+
/**
|
154 |
+
* @param $product
|
155 |
+
* @return mixed|string
|
156 |
+
*/
|
157 |
public function getMinPrice($product)
|
158 |
{
|
159 |
$productType = $product->getTypeID();
|
206 |
}
|
207 |
return $priseStr;
|
208 |
}
|
209 |
+
|
210 |
+
public function getStoresAssocArray()
|
211 |
+
{
|
212 |
+
$availableStores = array();
|
213 |
+
foreach (Mage::app()->getWebsites() as $website) {
|
214 |
+
foreach ($website->getGroups() as $group) {
|
215 |
+
$stores = $group->getStores();
|
216 |
+
foreach ($stores as $store) {
|
217 |
+
$availableStores[] = array('value' => $store->getId(), 'label' => $store->getName());
|
218 |
+
}
|
219 |
+
}
|
220 |
+
}
|
221 |
+
return $availableStores;
|
222 |
+
}
|
223 |
+
|
224 |
+
public function getDefaultFrontendStoreView()
|
225 |
+
{
|
226 |
+
$storeInConfig = Mage::getStoreConfig(self::CONFIG_DEFAULT_FRONTEND_STORE_CODE);
|
227 |
+
$defaultStore = Mage::getModel("core/store")->load(Mage_Core_Model_Store::DEFAULT_CODE);
|
228 |
+
$retValue = (empty($storeInConfig) ? $storeInConfig : $defaultStore);
|
229 |
+
return $retValue;
|
230 |
+
}
|
231 |
+
|
232 |
+
public function getStoreCodeFromPost()
|
233 |
+
{
|
234 |
+
$postParam = Mage::app()->getRequest()->getParam('store');
|
235 |
+
if(empty($postParam)){
|
236 |
+
$postParam = Mage_Core_Model_Store::DEFAULT_CODE;
|
237 |
+
}
|
238 |
+
return $postParam;
|
239 |
+
}
|
240 |
+
|
241 |
}
|
app/code/community/Web4pro/Googlemerchants/Model/Googlecategory.php
CHANGED
@@ -125,6 +125,10 @@ class Web4pro_Googlemerchants_Model_Googlecategory extends Mage_Core_Model_Abstr
|
|
125 |
}
|
126 |
}
|
127 |
|
|
|
|
|
|
|
|
|
128 |
public function getChildrenCategories($parentCategory)
|
129 |
{
|
130 |
$children = array();
|
@@ -138,6 +142,10 @@ class Web4pro_Googlemerchants_Model_Googlecategory extends Mage_Core_Model_Abstr
|
|
138 |
return $children;
|
139 |
}
|
140 |
|
|
|
|
|
|
|
|
|
141 |
public function getCategoriesStr($storeCatIds)
|
142 |
{
|
143 |
$categoriesStr = '';
|
@@ -159,6 +167,10 @@ class Web4pro_Googlemerchants_Model_Googlecategory extends Mage_Core_Model_Abstr
|
|
159 |
return implode('>', $categoriesArr);
|
160 |
}
|
161 |
|
|
|
|
|
|
|
|
|
162 |
public function isRootCategory($categoryId)
|
163 |
{
|
164 |
$category = $this->load($categoryId);
|
125 |
}
|
126 |
}
|
127 |
|
128 |
+
/**
|
129 |
+
* @param $parentCategory
|
130 |
+
* @return array
|
131 |
+
*/
|
132 |
public function getChildrenCategories($parentCategory)
|
133 |
{
|
134 |
$children = array();
|
142 |
return $children;
|
143 |
}
|
144 |
|
145 |
+
/**
|
146 |
+
* @param $storeCatIds
|
147 |
+
* @return string
|
148 |
+
*/
|
149 |
public function getCategoriesStr($storeCatIds)
|
150 |
{
|
151 |
$categoriesStr = '';
|
167 |
return implode('>', $categoriesArr);
|
168 |
}
|
169 |
|
170 |
+
/**
|
171 |
+
* @param $categoryId
|
172 |
+
* @return bool
|
173 |
+
*/
|
174 |
public function isRootCategory($categoryId)
|
175 |
{
|
176 |
$category = $this->load($categoryId);
|
app/code/community/Web4pro/Googlemerchants/Model/Googlefeed.php
CHANGED
@@ -12,7 +12,9 @@
|
|
12 |
*/
|
13 |
class Web4pro_Googlemerchants_Model_Googlefeed extends Mage_Core_Model_Abstract
|
14 |
{
|
15 |
-
protected $_attributesArray = NULL, $_productCollection = NULL, $
|
|
|
|
|
16 |
$_defaultParameters = array(
|
17 |
array('value' => 'id', 'selected' => 'product_id'),
|
18 |
array('value' => 'title', 'selected' => 'name'),
|
@@ -27,7 +29,16 @@ class Web4pro_Googlemerchants_Model_Googlefeed extends Mage_Core_Model_Abstract
|
|
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 |
|
@@ -35,7 +46,9 @@ class Web4pro_Googlemerchants_Model_Googlefeed extends Mage_Core_Model_Abstract
|
|
35 |
{
|
36 |
parent::_construct();
|
37 |
$this->_init('googlemerchants/googlefeed');
|
|
|
38 |
$this->_setProductsCollection();
|
|
|
39 |
}
|
40 |
|
41 |
/**
|
@@ -45,6 +58,7 @@ class Web4pro_Googlemerchants_Model_Googlefeed extends Mage_Core_Model_Abstract
|
|
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();
|
@@ -84,7 +98,6 @@ class Web4pro_Googlemerchants_Model_Googlefeed extends Mage_Core_Model_Abstract
|
|
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)) {
|
@@ -93,7 +106,7 @@ class Web4pro_Googlemerchants_Model_Googlefeed extends Mage_Core_Model_Abstract
|
|
93 |
$fileName = $pathToSave . '/' . $fileNameInConfig . '.csv';
|
94 |
$file = fopen($fileName, "w");
|
95 |
fputcsv($file, $headerRow);
|
96 |
-
$storeCode =
|
97 |
foreach ($this->_productCollection as $product) {
|
98 |
$productArray = array();
|
99 |
foreach ($attributes as $attribute) {
|
@@ -131,19 +144,19 @@ class Web4pro_Googlemerchants_Model_Googlefeed extends Mage_Core_Model_Abstract
|
|
131 |
}
|
132 |
break;
|
133 |
case 'parent_name' :
|
134 |
-
$productArray [] =
|
135 |
break;
|
136 |
case 'google_tax' :
|
137 |
$productArray [] = Mage::getModel('googlemerchants/googletax')->getTaxValue($product);
|
138 |
break;
|
139 |
case 'google_product_link':
|
140 |
-
$productArray [] =
|
141 |
break;
|
142 |
case 'none':
|
143 |
$productArray [] = '';
|
144 |
break;
|
145 |
case 'price':
|
146 |
-
$productArray [] = $
|
147 |
break;
|
148 |
case 'google_availability':
|
149 |
|
@@ -201,15 +214,15 @@ class Web4pro_Googlemerchants_Model_Googlefeed extends Mage_Core_Model_Abstract
|
|
201 |
*/
|
202 |
public function getFeedConfig()
|
203 |
{
|
204 |
-
$
|
|
|
|
|
205 |
if (empty($feedConfig)) {
|
206 |
return $this->_defaultParameters;
|
207 |
}
|
208 |
-
|
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);
|
@@ -223,18 +236,14 @@ class Web4pro_Googlemerchants_Model_Googlefeed extends Mage_Core_Model_Abstract
|
|
223 |
* @return $this
|
224 |
* @throws Exception
|
225 |
*/
|
226 |
-
public function setFeedConfig($value, $storeCode
|
227 |
{
|
228 |
-
|
229 |
-
$config
|
230 |
-
$config->setValue(serialize($value));
|
231 |
$config->setPath($this->_path);
|
232 |
$config->setScope('stores');
|
233 |
-
$
|
234 |
-
|
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;
|
@@ -267,14 +276,8 @@ class Web4pro_Googlemerchants_Model_Googlefeed extends Mage_Core_Model_Abstract
|
|
267 |
public function getAttributesOptions()
|
268 |
{
|
269 |
$collection = $this->_getAttributesCollection();
|
270 |
-
|
271 |
-
$options
|
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();
|
@@ -286,6 +289,12 @@ class Web4pro_Googlemerchants_Model_Googlefeed extends Mage_Core_Model_Abstract
|
|
286 |
return $this->_attributeSelectOptions;
|
287 |
}
|
288 |
|
|
|
|
|
|
|
|
|
|
|
|
|
289 |
/**
|
290 |
* @return mixed
|
291 |
*/
|
@@ -297,4 +306,19 @@ class Web4pro_Googlemerchants_Model_Googlefeed extends Mage_Core_Model_Abstract
|
|
297 |
->setEntityTypeFilter(Mage::getResourceModel('catalog/product')->getTypeId());
|
298 |
return $this->_attributesCollection;
|
299 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
300 |
}
|
12 |
*/
|
13 |
class Web4pro_Googlemerchants_Model_Googlefeed extends Mage_Core_Model_Abstract
|
14 |
{
|
15 |
+
protected $_attributesArray = NULL, $_productCollection = NULL, $_helper = NULL, $_byCron = false,
|
16 |
+
$_path = 'googlemerchants_options/general/google_feed_prameters',
|
17 |
+
$_notAttachedCategoriesExists = false, $_attributesCollection,
|
18 |
$_defaultParameters = array(
|
19 |
array('value' => 'id', 'selected' => 'product_id'),
|
20 |
array('value' => 'title', 'selected' => 'name'),
|
29 |
array('value' => 'category', 'selected' => 'google_category'),
|
30 |
array('value' => 'tax', 'selected' => 'google_tax'),
|
31 |
array('value' => 'link', 'selected' => 'google_product_link'),
|
32 |
+
array('value' => 'availability', 'selected' => 'google_availability')),
|
33 |
+
|
34 |
+
$_defaultOptionValues = array(
|
35 |
+
array('code' => 'product_id', 'label' => 'Product ID'),
|
36 |
+
array('code' => 'google_category', 'label' => 'Google Category'),
|
37 |
+
array('code' => 'shipping_cost', 'label' => 'Shipping Cost'),
|
38 |
+
array('code' => 'parent_name', 'label' => 'Parent Name'),
|
39 |
+
array('code' => 'google_tax', 'label' => 'Tax'),
|
40 |
+
array('code' => 'google_product_link', 'label' => 'Product URL'),
|
41 |
+
array('code' => 'google_availability', 'label' => 'Availability (in/out of stock)'));
|
42 |
|
43 |
const PATH_TO_GENERATE = 'var/productsfeed';
|
44 |
|
46 |
{
|
47 |
parent::_construct();
|
48 |
$this->_init('googlemerchants/googlefeed');
|
49 |
+
$this->_helper = Mage::helper('googlemerchants');
|
50 |
$this->_setProductsCollection();
|
51 |
+
$this->_appendStoreFilter();
|
52 |
}
|
53 |
|
54 |
/**
|
58 |
{
|
59 |
if ($this->_productCollection === NULL) {
|
60 |
$collection = Mage::getResourceModel('catalog/product_collection')->addAttributeToFilter('visibility', array('in' => array(1, 2, 3, 4)))->addAttributeToSelect('*');
|
61 |
+
//$collection->setStoreId();
|
62 |
$this->_productCollection = $collection;
|
63 |
}
|
64 |
$this->_setCollectionConfigConditions();
|
98 |
$googleCategoriesModel = Mage::getModel('googlemerchants/googlecategory');
|
99 |
$googleShippingModel = Mage::getModel('googlemerchants/googleshipping');
|
100 |
$stockModel = Mage::getModel('cataloginventory/stock_item');
|
|
|
101 |
$headerRow = $this->_getHeaderRow();
|
102 |
$fileNameInConfig = Mage::getStoreConfig('googlemerchants_options/general/google_feedfilename');
|
103 |
if (empty($fileNameInConfig)) {
|
106 |
$fileName = $pathToSave . '/' . $fileNameInConfig . '.csv';
|
107 |
$file = fopen($fileName, "w");
|
108 |
fputcsv($file, $headerRow);
|
109 |
+
$storeCode = $this->_helper->getSelectedStore();
|
110 |
foreach ($this->_productCollection as $product) {
|
111 |
$productArray = array();
|
112 |
foreach ($attributes as $attribute) {
|
144 |
}
|
145 |
break;
|
146 |
case 'parent_name' :
|
147 |
+
$productArray [] = $this->_helper->getParentName($product);
|
148 |
break;
|
149 |
case 'google_tax' :
|
150 |
$productArray [] = Mage::getModel('googlemerchants/googletax')->getTaxValue($product);
|
151 |
break;
|
152 |
case 'google_product_link':
|
153 |
+
$productArray [] = $this->_helper->getProductUrl($product);
|
154 |
break;
|
155 |
case 'none':
|
156 |
$productArray [] = '';
|
157 |
break;
|
158 |
case 'price':
|
159 |
+
$productArray [] = $this->_helper->getMinPrice($product);
|
160 |
break;
|
161 |
case 'google_availability':
|
162 |
|
214 |
*/
|
215 |
public function getFeedConfig()
|
216 |
{
|
217 |
+
$selectionStore = $this->_helper->getSelectedStore();
|
218 |
+
$feedConfig = Mage::getStoreConfig('googlemerchants_options/general/google_feed_prameters', $selectionStore);
|
219 |
+
$feedConfig = unserialize($feedConfig);
|
220 |
if (empty($feedConfig)) {
|
221 |
return $this->_defaultParameters;
|
222 |
}
|
223 |
+
if (empty($feedConfig)) {
|
|
|
224 |
return $this->_defaultParameters;
|
225 |
}
|
|
|
226 |
$resArr = array();
|
227 |
foreach ($feedConfig as $key => $field) {
|
228 |
$resArr [] = array('value' => $key, 'selected' => $field);
|
236 |
* @return $this
|
237 |
* @throws Exception
|
238 |
*/
|
239 |
+
public function setFeedConfig($value, $storeCode)
|
240 |
{
|
241 |
+
$config = Mage::getModel('adminhtml/system_config_backend_serialized_array');
|
242 |
+
$config->setValue($value);
|
|
|
243 |
$config->setPath($this->_path);
|
244 |
$config->setScope('stores');
|
245 |
+
$storeId = Mage::app()->getStore($storeCode)->getId();
|
246 |
+
$config->setScopeId($storeId);
|
|
|
|
|
|
|
247 |
$config->save();
|
248 |
Mage::getConfig()->reinit();
|
249 |
return $this;
|
276 |
public function getAttributesOptions()
|
277 |
{
|
278 |
$collection = $this->_getAttributesCollection();
|
279 |
+
|
280 |
+
$options = $this->_defaultOptionValues;
|
|
|
|
|
|
|
|
|
|
|
|
|
281 |
|
282 |
foreach ($collection as $item) {
|
283 |
$frontendLabel = $item->getFrontendLabel();
|
289 |
return $this->_attributeSelectOptions;
|
290 |
}
|
291 |
|
292 |
+
public function generateFeedByCron()
|
293 |
+
{
|
294 |
+
$this->_byCron = true;
|
295 |
+
$this->generateFeed();
|
296 |
+
}
|
297 |
+
|
298 |
/**
|
299 |
* @return mixed
|
300 |
*/
|
306 |
->setEntityTypeFilter(Mage::getResourceModel('catalog/product')->getTypeId());
|
307 |
return $this->_attributesCollection;
|
308 |
}
|
309 |
+
|
310 |
+
protected function _appendStoreFilter()
|
311 |
+
{
|
312 |
+
if($this->_byCron){
|
313 |
+
$selectedStore = $this->_helper->getDefaultFrontendStoreView();
|
314 |
+
}
|
315 |
+
else{
|
316 |
+
$storeCode = $this->_helper->getStoreCodeFromPost();
|
317 |
+
$selectedStore = Mage::getModel("core/store")->load($storeCode);
|
318 |
+
}
|
319 |
+
$this->_productCollection->setStore($selectedStore->getId());
|
320 |
+
$this->_productCollection->setPageSize(20)
|
321 |
+
->setCurPage(1);
|
322 |
+
}
|
323 |
+
|
324 |
}
|
app/code/community/Web4pro/Googlemerchants/Model/Googleshipping.php
CHANGED
@@ -59,9 +59,10 @@ class Web4pro_Googlemerchants_Model_Googleshipping
|
|
59 |
}
|
60 |
|
61 |
/**
|
|
|
62 |
* @param $product
|
63 |
* @return string
|
64 |
-
*
|
65 |
*/
|
66 |
public function getShippingCost($product)
|
67 |
{
|
59 |
}
|
60 |
|
61 |
/**
|
62 |
+
* method for calculating shipping cost
|
63 |
* @param $product
|
64 |
* @return string
|
65 |
+
*
|
66 |
*/
|
67 |
public function getShippingCost($product)
|
68 |
{
|
app/code/community/Web4pro/Googlemerchants/Model/Storefeedconfig.php
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Web4pro_Googlemerchants_Model_Storefeedconfig
|
4 |
+
{
|
5 |
+
public function toOptionArray() {
|
6 |
+
return Mage::helper('googlemerchants')->getStoresAssocArray();
|
7 |
+
}
|
8 |
+
}
|
app/code/community/Web4pro/Googlemerchants/controllers/Adminhtml/GooglemerchantsController.php
CHANGED
@@ -34,6 +34,10 @@ class Web4pro_Googlemerchants_Adminhtml_GooglemerchantsController extends Mage_A
|
|
34 |
{
|
35 |
$googleCategoriesCount = Mage::getModel('googlemerchants/googlecategory')->getCollection()->count();
|
36 |
if ($googleCategoriesCount == 0) {
|
|
|
|
|
|
|
|
|
37 |
$this->_redirect('adminhtml/googlemerchants/downloadtxt');
|
38 |
}
|
39 |
$this->_initAction();
|
@@ -59,7 +63,7 @@ class Web4pro_Googlemerchants_Adminhtml_GooglemerchantsController extends Mage_A
|
|
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');
|
@@ -204,27 +208,30 @@ class Web4pro_Googlemerchants_Adminhtml_GooglemerchantsController extends Mage_A
|
|
204 |
$result = array();
|
205 |
try {
|
206 |
$post = $this->getRequest()->getPost();
|
207 |
-
$
|
208 |
-
$storeCode = '
|
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, $
|
217 |
$result['error'] = false;
|
218 |
} catch (Exception $e) {
|
219 |
-
$result['error'] =
|
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 |
|
34 |
{
|
35 |
$googleCategoriesCount = Mage::getModel('googlemerchants/googlecategory')->getCollection()->count();
|
36 |
if ($googleCategoriesCount == 0) {
|
37 |
+
if(ini_get('safe_mode'))
|
38 |
+
{
|
39 |
+
Mage::getSingleton('adminhtml/session')->addWarning('Please note, that PHP is running in safe mode. For correct import please increase the parameter "max_execution_time" in the php.ini file.');
|
40 |
+
}
|
41 |
$this->_redirect('adminhtml/googlemerchants/downloadtxt');
|
42 |
}
|
43 |
$this->_initAction();
|
63 |
*/
|
64 |
public function savetxtAction()
|
65 |
{
|
66 |
+
set_time_limit (10000);
|
67 |
if (isset($_FILES['fileinputname']['name']) && $_FILES['fileinputname']['name'] != '') {
|
68 |
try {
|
69 |
$uploader = new Varien_File_Uploader('fileinputname');
|
208 |
$result = array();
|
209 |
try {
|
210 |
$post = $this->getRequest()->getPost();
|
211 |
+
$storeCode = Mage::helper('googlemerchants')->getStoreCodeFromPost();
|
212 |
+
$storeCode = empty($storeCode) ? Mage::helper('googlemerchants')->getDefaultFrontendStoreView() : $storeCode;
|
|
|
213 |
$valuesToSave = array();
|
214 |
$names = $post['feed-col-name'];
|
215 |
$values = $post['attribute-select'];
|
216 |
foreach ($names as $key => $value) {
|
217 |
$valuesToSave [$value] = $values[$key];
|
218 |
}
|
219 |
+
Mage::getModel('googlemerchants/googlefeed')->setFeedConfig($valuesToSave, $storeCode);
|
220 |
$result['error'] = false;
|
221 |
} catch (Exception $e) {
|
222 |
+
$result['error'] = true;
|
223 |
$result['message'] = $e->getMessage();
|
224 |
Mage::getSingleton('core/session')->addError($e->getMessage());
|
|
|
225 |
}
|
226 |
+
|
227 |
if ($this->getRequest()->isAjax()) {
|
228 |
$this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
|
229 |
} else {
|
230 |
$this->_redirect('adminhtml/googlemerchants/feed');
|
231 |
+
if(!$result['error'])
|
232 |
+
{
|
233 |
+
Mage::getSingleton('core/session')->addSuccess('Feed configuration has been saved.');
|
234 |
+
}
|
235 |
}
|
236 |
}
|
237 |
|
app/code/community/Web4pro/Googlemerchants/etc/system.xml
CHANGED
@@ -24,8 +24,6 @@
|
|
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>
|
@@ -64,6 +62,7 @@
|
|
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>
|
@@ -97,6 +96,16 @@
|
|
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[
|
24 |
<tab>web4pro</tab>
|
25 |
<sort_order>600</sort_order>
|
26 |
<show_in_default>1</show_in_default>
|
|
|
|
|
27 |
<groups>
|
28 |
<general translate="label">
|
29 |
<label>Options for importing products</label>
|
62 |
</google_feedfilename>
|
63 |
<google_feed_prameters translate="label">
|
64 |
<label>Feed parameters</label>
|
65 |
+
<backend_model>adminhtml/system_config_backend_serialized_array</backend_model>
|
66 |
<frontend_type>label</frontend_type>
|
67 |
<sort_order>0</sort_order>
|
68 |
<show_in_default>0</show_in_default>
|
96 |
<show_in_website>1</show_in_website>
|
97 |
<show_in_store>1</show_in_store>
|
98 |
</google_feed_export_unvisible>
|
99 |
+
<google_selected_store_for_feed>
|
100 |
+
<label>Select store foor feed generation by cron</label>
|
101 |
+
<frontend_type>select</frontend_type>
|
102 |
+
<source_model>googlemerchants/storefeedconfig</source_model>
|
103 |
+
<sort_order>6</sort_order>
|
104 |
+
<show_in_default>1</show_in_default>
|
105 |
+
<show_in_website>1</show_in_website>
|
106 |
+
<show_in_store>1</show_in_store>
|
107 |
+
</google_selected_store_for_feed>
|
108 |
+
|
109 |
<google_shiping_html_notes translate="label">
|
110 |
<comment>
|
111 |
<![CDATA[
|
app/design/adminhtml/default/default/template/web4pro_googlemerchants/feed/form.phtml
CHANGED
@@ -4,20 +4,30 @@
|
|
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')
|
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')
|
19 |
-
<th width="40%"><?php echo $this->__('Value')
|
20 |
-
<th style="width:40%;"><?php echo $this->__('Action')
|
21 |
</tr>
|
22 |
</thead>
|
23 |
<tbody id="mapping-table-body">
|
@@ -36,33 +46,31 @@
|
|
36 |
var lastIndex = getLastIndex();
|
37 |
|
38 |
function removeRow(index) {
|
39 |
-
var
|
40 |
-
|
41 |
-
|
42 |
-
}
|
43 |
}
|
44 |
-
|
|
|
|
|
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 + ');
|
51 |
var lastRowId = "table-row-" + lastIndex;
|
52 |
var elementToAppend = $(lastRowId);
|
53 |
-
if
|
54 |
-
|
|
|
55 |
lastIndex++;
|
56 |
}
|
57 |
}
|
58 |
-
function getLastIndex()
|
59 |
-
|
60 |
-
|
61 |
-
var lastElId = lastEl.id;
|
62 |
-
var laseFreeNum = lastElId.replace('table-row-', '');
|
63 |
-
return parseInt(laseFreeNum);
|
64 |
}
|
65 |
|
66 |
</script>
|
67 |
</div>
|
68 |
-
</div>
|
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 |
+
<?php /* <div>
|
16 |
+
<?php $availableStores = $this->getAvailableStores();?>
|
17 |
+
<label for="select_store_name"><?php echo $this->__('Please choose the store view for generating feed:'); ?></label>
|
18 |
+
<select name="select_store_name">
|
19 |
+
<?php foreach($availableStores as $store):?>
|
20 |
+
<option value="<?php echo $store['value']?>"><?php echo $store['label']?></option>
|
21 |
+
<?php endforeach; ?>
|
22 |
+
</select>
|
23 |
+
</div>
|
24 |
+
*/ ?>
|
25 |
<table cellspacing="0" cellpadding="0" class="dynamic-grid" style="width:70%;" align="center">
|
26 |
<thead>
|
27 |
<tr class="headings">
|
28 |
+
<th style="width:160px;"><?php echo $this->__('Field Name')?></th>
|
29 |
+
<th width="40%"><?php echo $this->__('Value')?></th>
|
30 |
+
<th style="width:40%;"><?php echo $this->__('Action')?></th>
|
31 |
</tr>
|
32 |
</thead>
|
33 |
<tbody id="mapping-table-body">
|
46 |
var lastIndex = getLastIndex();
|
47 |
|
48 |
function removeRow(index) {
|
49 |
+
var currentRow = $('table-row-' + index);
|
50 |
+
currentRow.remove();
|
51 |
+
lastIndex = getLastIndex();
|
|
|
52 |
}
|
53 |
+
|
54 |
+
function addRow()
|
55 |
+
{
|
56 |
var indexTAppend = lastIndex + 1;
|
57 |
var rowHtml = '<tr id="table-row-' + indexTAppend + '"><td><input name="feed-col-name[' + indexTAppend + ']"/></td>';
|
58 |
rowHtml += '<td><select name="attribute-select[' + indexTAppend + ']">';
|
59 |
rowHtml += '<?php echo $this->getOptionsHtml()?>';
|
60 |
rowHtml += '</select></td>';
|
61 |
+
rowHtml += '<td><button type="button" onclick="removeRow(' + indexTAppend + ');" class="delete delete-option">Remove</button></td>';
|
62 |
var lastRowId = "table-row-" + lastIndex;
|
63 |
var elementToAppend = $(lastRowId);
|
64 |
+
if(elementToAppend != null)
|
65 |
+
{
|
66 |
+
$(lastRowId).insert({after:rowHtml});
|
67 |
lastIndex++;
|
68 |
}
|
69 |
}
|
70 |
+
function getLastIndex()
|
71 |
+
{
|
72 |
+
return $('mapping-table-body').getElementsByTagName("tr").length - 1;
|
|
|
|
|
|
|
73 |
}
|
74 |
|
75 |
</script>
|
76 |
</div>
|
|
package.xml
CHANGED
@@ -1,18 +1,18 @@
|
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>Web4pro_Googlemerchants</name>
|
4 |
-
<version>1.0.
|
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>
|
12 |
-
<authors><author><name>Alex</name><user>
|
13 |
-
<date>2015-
|
14 |
-
<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="
|
16 |
<compatible/>
|
17 |
<dependencies><required><php><min>5.3.0</min><max>5.6.0</max></php></required></dependencies>
|
18 |
</package>
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>Web4pro_Googlemerchants</name>
|
4 |
+
<version>1.0.2</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>Add functionallity for store selection</notes>
|
12 |
+
<authors><author><name>Alex</name><user>achernyshev</user><email>achernyshev@corp.web4pro.com.ua</email></author></authors>
|
13 |
+
<date>2015-07-27</date>
|
14 |
+
<time>13:39:10</time>
|
15 |
+
<contents><target name="magecommunity"><dir name="Web4pro"><dir name="Googlemerchants"><dir name="Block"><dir name="Adminhtml"><dir name="Editfeed"><dir name="Edit"><file name="Form.php" hash="ef474a89d705108aa3141c80e41e9658"/></dir></dir><file name="Editfeed.php" hash="7d7eba9ef562402d40ad86a288771c51"/><dir name="Googlecategory"><dir name="Edit"><file name="Form.php" hash="e5448f951de4c52e568b08ac2a0f24d0"/></dir><file name="Edit.php" hash="35cc7d98dc229a4a02a38a837a499c09"/><file name="Tree.php" hash="2448621a21e9c77095fdc3c80200edb0"/></dir><dir name="System"><file name="Instruction.php" hash="a8db391b4a26d5becdaf9376f9b298e1"/></dir><dir name="Upload"><file name="File.php" hash="0d40ad6ce19b1ee072c5cf2114057d2e"/><dir name="Form"><file name="Container.php" hash="e1a4e0128a8c7399c6137bbf22415372"/></dir><dir name="Link"><file name="Renderer.php" hash="037e9d54bc46bae1be5a5b9d3b415ced"/></dir></dir></dir></dir><dir name="Helper"><file name="Data.php" hash="f4aea9b6bfba5f6d8495058d14eef018"/></dir><dir name="Model"><file name="Googlecategory.php" hash="9332b02d2d38315f769fd6a693287af2"/><file name="Googlefeed.php" hash="c7bf0b893a50bf1543634d4213db5ebb"/><file name="Googleshipping.php" hash="1fd02059b0bdb80c31c815f3cb75e937"/><file name="Googletax.php" hash="4535e853784f82d4a99315c721ad10a9"/><dir name="Mysql4"><dir name="Googlecategory"><file name="Collection.php" hash="0520040012ab2f78bb1728e8ab81eb42"/></dir><file name="Googlecategory.php" hash="b306fdb04cb24eb03a66c39ffa9c3325"/><file name="Googlefeed.php" hash="b19462cd7eda2437d28efb1198e53453"/></dir><file name="Storefeedconfig.php" hash="0b838449a979e05a4a863430ceab0188"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="GooglemerchantsController.php" hash="5e91b8980d5fd449721d768859b17c30"/></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="704eab9384927a53ba001111dded1b9c"/><file name="config.xml" hash="76b6483a3e63fbda9c71cfcf76a3be49"/><file name="system.xml" hash="6cafd483de4db1ec00667ea6ca99279b"/></dir><dir name="sql"><dir name="googlemerchants_setup"><file name="install-1.0.0.0.php" hash="62d572474a1e3673c66b9d7c1252ec09"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Web4pro_Googlemerchants.xml" hash="06bfb3dcc824e3b4b9fa607cdc05fd1e"/></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="googlemerchants.xml" hash="8090e9b0941e4f9ba787e87ced18bded"/></dir><dir name="template"><dir name="web4pro_googlemerchants"><dir name="feed"><file name="form.phtml" hash="d4cc7600eeb0a48dbd3deebd4c91449d"/></dir><dir name="googlecategory"><file name="edit.phtml" hash="2ccd1585fc12031d4c51ad230120d2db"/><file name="tree.phtml" hash="21331415dbb96f1c2a58e7f22ae163f0"/></dir></dir></dir></dir></dir></dir></target></contents>
|
16 |
<compatible/>
|
17 |
<dependencies><required><php><min>5.3.0</min><max>5.6.0</max></php></required></dependencies>
|
18 |
</package>
|
skin/adminhtml/default/default/web4pro_googlemerchants/custom.css
DELETED
@@ -1,11 +0,0 @@
|
|
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 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|