Feed_Manager_Version_1_1_2 - Version 2.1.4

Version Notes

It is optimized to display paginated products and will load faster

Download this release

Release Info

Developer RetailTower
Extension Feed_Manager_Version_1_1_2
Version 2.1.4
Comparing to
See all releases


Code changes from version 2.1.3 to 2.1.4

Files changed (2) hide show
  1. package.xml +11 -26
  2. productapi.php +206 -164
package.xml CHANGED
@@ -1,35 +1,20 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Feed_Manager_Version_1_1_2</name>
4
- <version>2.1.3</version>
5
  <stability>stable</stability>
6
  <license uri="http://www.opensource.org/licenses/academic.php">Academic Free License (AFL)</license>
7
  <channel>community</channel>
8
  <extends/>
9
- <summary>Easily create datafeeds for your Magento store for various shopping engines and marketplaces like Google, Shopzilla, TheFind, Bing Shopping etc&#xD;
10
- </summary>
11
- <description>&lt;p&gt;&lt;span&gt;&lt;strong&gt;Its a 2 in 1 package&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;&#xD;
12
- &lt;p&gt;1. Submit your products to&lt;strong&gt; shopping comparison engines&lt;/strong&gt; using our &lt;strong&gt;Feed Manager&lt;/strong&gt; feature&lt;/p&gt;&#xD;
13
- &lt;p&gt;2. Create &lt;strong&gt;Facebook fanpage stores&lt;/strong&gt; with our new Shop Plus feature.&lt;/p&gt;&#xD;
14
- &lt;p&gt;Seamless integration with Magento and shopping comparison engines to provide a solution to list your store on shopping engines. You can create, optimize, and manage your shopping data feed and automatically list your products on shopping comparison engines such as &lt;strong&gt;Google Product Search&lt;/strong&gt;, &lt;strong&gt;TheFind.com&lt;/strong&gt;, &lt;strong&gt;Become.com&lt;/strong&gt;, &lt;strong&gt;Nextag&lt;/strong&gt;, &lt;strong&gt;Shopping.com&lt;/strong&gt;, &lt;strong&gt;Pricegrabber&lt;/strong&gt;, &lt;strong&gt;Shopzilla&lt;/strong&gt;, &lt;strong&gt;Shopmania&lt;/strong&gt;, etc.&lt;/p&gt;&#xD;
15
- &lt;p&gt;It is faster and automates datafeeds process&lt;/p&gt;&#xD;
16
- &lt;p&gt; Sell your high perfoming products on shopping engines&lt;/p&gt;&#xD;
17
- &lt;p&gt;&#xA0;&lt;/p&gt;&#xD;
18
- &lt;p&gt;How-to use it:&lt;/p&gt;&#xD;
19
- &lt;p&gt;1. Install this extension&lt;/p&gt;&#xD;
20
- &lt;p&gt;2. Change the permission of file &lt;b&gt;productapi.php&lt;/b&gt; to 644. The file can be located in your root of your web folder after installation&lt;/p&gt;&#xD;
21
- &lt;p&gt;3. Register at &lt;a href="http://app.retailtower.com/signup"&gt;http://app.retailtower.com/signup&lt;/a&gt; and register.&lt;/p&gt;&#xD;
22
- &lt;p&gt;4. If there are any problems with installation, contact us at support@retailtower.com and we will help set you up immediately.&lt;/p&gt;&#xD;
23
- &lt;p&gt;&#xA0;&lt;/p&gt;&#xD;
24
- &lt;p&gt;Note:&lt;/p&gt;&#xD;
25
- &lt;p&gt;1. Feed Manager Version 1.1.2 works with magento 1.4x and above. &lt;/p&gt;&#xD;
26
- &lt;p&gt;2. Please back-up your store and database before installing this extension as we will not be responsible for any errors or problems that may occur with this open source extension.&lt;/p&gt;&#xD;
27
- &lt;p&gt;3. RetailTower does not provide extensive Magento support or other related Magento installation services for this open source extension. Please read our documentation and help file for assistance.&lt;/p&gt;</description>
28
- <notes>It is optimized to display more products and the last updated parameter added for faster product download. It will pull dynamic product attributes and supports product options.</notes>
29
- <authors><author><name>Rinkart Osei Asibey</name><user>rinkarto</user><email>rinkarto2000@gmail.com</email></author><author><name>Retailtower</name><user>RetailTower</user><email>support@retailtower.com</email></author></authors>
30
- <date>2015-02-02</date>
31
- <time>15:33:58</time>
32
- <contents><target name="mage"><dir name="."><file name="productapi.php" hash="1ca239c9cee1925c33a489acae0cfdd7"/></dir></target></contents>
33
  <compatible/>
34
- <dependencies><required><php><min>5.1.0</min><max>5.5.1</max></php></required></dependencies>
35
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Feed_Manager_Version_1_1_2</name>
4
+ <version>2.1.4</version>
5
  <stability>stable</stability>
6
  <license uri="http://www.opensource.org/licenses/academic.php">Academic Free License (AFL)</license>
7
  <channel>community</channel>
8
  <extends/>
9
+ <summary>Easily list your products with leading shopping engines and marketplaces such as Google, Amazon, Shopzilla, Pricegrabber and Shopbot</summary>
10
+ <description>&lt;p&gt;Reach larger customers by connecting your store to leading shopping engines and marketplaces.&lt;/p&gt;&#xD;
11
+ &lt;p&gt;Optimize the feeds to increase rankings on shopping engines and marketplaces.&lt;/p&gt;&#xD;
12
+ </description>
13
+ <notes>It is optimized to display paginated products and will load faster</notes>
14
+ <authors><author><name>RetailTower</name><user>Rinkart</user><email>suppor@retailtower.com</email></author></authors>
15
+ <date>2016-04-01</date>
16
+ <time>16:16:36</time>
17
+ <contents><target name="mage"><dir name="."><file name="productapi.php" hash="70196e6d54b13736a2b74cdfc0077d73"/></dir></target></contents>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
18
  <compatible/>
19
+ <dependencies><required><php><min>5.1.0</min><max>5.6.0</max></php></required></dependencies>
20
  </package>
productapi.php CHANGED
@@ -1,7 +1,8 @@
1
  <?php
2
  //set_time_limit(1600);
3
- ini_set('max_execution_time', -1);
4
  ini_set('memory_limit', '-1');
 
5
  include_once 'app/Mage.php';
6
  umask(0);
7
  Mage::app();
@@ -46,31 +47,31 @@
46
  }
47
 
48
  if($_GET['attributes'] == 'true'){
49
- //get store attributes
50
- $attribute = Mage::getModel('catalog/product')->getAttributes();
51
- $attributes = array();
52
- $data = array();
53
- $output = array();
54
 
55
- foreach($attribute as $a){
56
 
57
- foreach ($a->getEntityType()->getAttributeCodes() as $attributeName) {
58
 
59
- $attributes[$attributeName] = $attributeName;
60
- }
61
- }
62
 
63
- $data['attributes'] = array(
64
  $attributes
65
  );
66
 
67
- //push product data array into output
68
  array_push($output, $data);
69
 
70
  //header to indicate content type
71
- header('Content-Type: application/json; charset=utf-8');
72
 
73
- //print store attributes
74
  print json_encode($output);
75
  exit();
76
 
@@ -78,207 +79,248 @@
78
 
79
  if($_GET['grouped'] == 'true'){
80
 
81
- $product = Mage::getModel('catalog/product')
82
- ->getCollection()
83
- ->addAttributeToFilter('type_id', array('eq' => 'grouped'))
84
- ->load();
85
 
86
- $parentProductId = array();
87
 
88
- foreach($product as $simpleProducts) {
89
- //$simpleProducts->loadParentProductIds();
90
- //array_push($parentProductId,$simpleProducts->getParentProductIds());
91
- //var_dump($simpleProducts->getParentProductIds());
92
  $values = $simpleProducts->getValues();
93
  var_dump($values);
94
- }
95
- //var_dump($parentProductId);
96
- exit();
97
 
98
  }
99
 
100
 
101
  if($_GET['bundled'] == 'true'){
102
 
103
- $product = Mage::getModel('catalog/product')
104
- ->getCollection()
105
- ->addAttributeToFilter('type_id', array('eq' => 'bundle'))
106
- ->load();
107
 
108
- $parentProductId = array();
109
 
110
- foreach($product as $bundleProduct) {
111
- //$bundleProduct->loadParentProductIds();
112
- //array_push($parentProductId,$bundleProduct->getParentProductIds());
113
  $values = $bundleProduct->getValues();
114
  var_dump($values);
115
-
116
- }
117
- //var_dump($parentProductId);
118
- exit();
119
 
120
  }
121
 
122
 
123
  //get store products
124
- $products = Mage::getModel('catalog/product')->getCollection();
 
125
 
 
126
 
127
- $products->addAttributeToSelect('*');
128
 
129
- if(!empty($_GET['lastupdated'])){
130
-
131
- //Start Date filter
132
 
 
133
 
134
- //Set start date
135
- $fromDate = $_GET['lastupdated'];
136
-
137
- //Set end date
138
- //$toDate = '2040-12-06 11:06:00';
139
-
140
- // Format our dates
141
- $fromDate = date('Y-m-d H:i:s', strtotime($fromDate));
142
- //$toDate = date('Y-m-d H:i:s', strtotime($toDate));
143
-
144
- //Filter products using date ranges
145
- //$products->addAttributeToFilter('updated_at', array('from'=>$fromDate, 'to'=>$toDate, 'datetime'=>true));
146
- $products->addAttributeToFilter('updated_at', array('from'=>$fromDate, 'datetime'=>true));
147
-
148
- //End Date filter
149
- }
150
 
151
-
152
- $products->addAttributeToFilter('status', array('eq' => Mage_Catalog_Model_Product_Status::STATUS_ENABLED));
153
-
154
-
155
- $visibility = array(
156
- Mage_Catalog_Model_Product_Visibility::VISIBILITY_BOTH,
157
- Mage_Catalog_Model_Product_Visibility::VISIBILITY_IN_CATALOG
158
- );
159
 
160
- $products->addAttributeToFilter('visibility', $visibility);
161
-
162
- $collection = Mage::getModel('catalog/product')->getCollection();
163
 
164
- $collection->addAttributeToSelect('manufacturer');
165
 
166
- $collection->addFieldToFilter(array(
167
- array('attribute' => 'manufacturer', 'eq' =>$designer_id),
168
- ));
169
-
170
- $products->load();
171
 
172
- $baseUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
173
 
174
- $collection = Mage::getResourceModel('catalog/product_collection');
175
 
 
176
 
177
- if (count($collection)){
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
178
 
179
- $output = array();
 
 
 
 
180
 
181
- foreach ($products as $product){
182
 
183
- $attributes = array();
184
 
185
- foreach ($product->getdata() as $key => $value) {
186
-
187
- if ($key!=='stock_item') {
188
-
189
- $url = $product->getProductUrl();
190
- if (($key == 'url_path') || ($key =='url_key')){
191
- $value = $url;
192
- $value = str_replace('/productapi.php','',$value);
193
- $value = trim ($value);
194
- }
195
-
196
- if ($key == 'image'){
197
- $value = $baseUrl."media/catalog/product".$value;
198
- }
199
-
200
- if ($key == 'thumbnail'){
201
- $value = $baseUrl."media/catalog/product".$value;
202
- }
203
-
204
- if ($key == 'manufacturer'){
205
- $value = $product->getResource()->getAttribute('manufacturer')->getFrontend()->getValue($product);
206
- }
207
- if ($key == 'brand'){
208
- $value = $product->getResource()->getAttribute('brand')->getFrontend()->getValue($product);
209
- }
210
-
211
-
212
- $attributes[$key] = $value;
213
-
214
- }
215
-
216
-
217
- }
218
 
219
-
220
- $product_options = array();
221
- $opts = array();
222
- //get product options
223
- $options = Mage::getModel('catalog/product_option')->getProductOptionCollection($product);
 
 
 
 
 
 
 
224
 
225
- if($options){
226
 
227
- foreach ($options as $option) {
228
 
229
- //get product option values
230
- $values = $option->getValues();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
231
 
232
- if($values){
233
- foreach ($values as $v) {
234
- foreach ($v->getData() as $key => $value) {
235
- $product_options[$key] = $value;
236
- $product_options['name'] = $option->getDefaultTitle();
237
- $product_options['optiontype'] = $option->getType();
238
- }
239
- array_push($opts, $product_options);
240
- }
241
- }
242
-
243
  }
 
244
 
245
- }
 
 
246
 
 
 
247
 
248
- $categories = $product->getCategoryIds();
249
- $product = array();
250
 
251
- foreach($categories as $k => $_category_id){
252
 
253
- $_category = Mage::getModel('catalog/category')->load($_category_id);
254
- $cat_name = $_category->getName();
255
- $cat_url = $_category->getUrl();
256
-
257
- //build product data array
258
- $product['product'] = array(
259
- $attributes,
260
- array("options" => $opts),
261
- array("category" => array('name' => $cat_name, 'url' => $cat_url))
262
- );
263
-
264
- //push product data array into output
265
- array_push($output, $output["products"] = $product);
266
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
267
 
268
- }
269
-
 
 
 
 
270
 
271
- }//endforeach;
272
-
273
- }//endif;
274
 
275
- //header to indicate content type
276
- header('Content-Type: application/json; charset=utf-8');
277
 
278
- //print products
279
- print json_encode($output);
280
 
281
 
282
 
283
 
284
- ?>
1
  <?php
2
  //set_time_limit(1600);
3
+ ini_set('max_execution_time', -1);
4
  ini_set('memory_limit', '-1');
5
+ error_reporting(E_ALL);
6
  include_once 'app/Mage.php';
7
  umask(0);
8
  Mage::app();
47
  }
48
 
49
  if($_GET['attributes'] == 'true'){
50
+ //get store attributes
51
+ $attribute = Mage::getModel('catalog/product')->getAttributes();
52
+ $attributes = array();
53
+ $data = array();
54
+ $output = array();
55
 
56
+ foreach($attribute as $a){
57
 
58
+ foreach ($a->getEntityType()->getAttributeCodes() as $attributeName) {
59
 
60
+ $attributes[$attributeName] = $attributeName;
61
+ }
62
+ }
63
 
64
+ $data['attributes'] = array(
65
  $attributes
66
  );
67
 
68
+ //push product data array into output
69
  array_push($output, $data);
70
 
71
  //header to indicate content type
72
+ //header('Content-Type: application/json; charset=utf-8');
73
 
74
+ //print store attributes
75
  print json_encode($output);
76
  exit();
77
 
79
 
80
  if($_GET['grouped'] == 'true'){
81
 
82
+ $product = Mage::getModel('catalog/product')
83
+ ->getCollection()
84
+ ->addAttributeToFilter('type_id', array('eq' => 'grouped'))
85
+ ->load();
86
 
87
+ $parentProductId = array();
88
 
89
+ foreach($product as $simpleProducts) {
90
+ //$simpleProducts->loadParentProductIds();
91
+ //array_push($parentProductId,$simpleProducts->getParentProductIds());
92
+ //var_dump($simpleProducts->getParentProductIds());
93
  $values = $simpleProducts->getValues();
94
  var_dump($values);
95
+ }
96
+ //var_dump($parentProductId);
97
+ exit();
98
 
99
  }
100
 
101
 
102
  if($_GET['bundled'] == 'true'){
103
 
104
+ $product = Mage::getModel('catalog/product')
105
+ ->getCollection()
106
+ ->addAttributeToFilter('type_id', array('eq' => 'bundle'))
107
+ ->load();
108
 
109
+ $parentProductId = array();
110
 
111
+ foreach($product as $bundleProduct) {
112
+ //$bundleProduct->loadParentProductIds();
113
+ //array_push($parentProductId,$bundleProduct->getParentProductIds());
114
  $values = $bundleProduct->getValues();
115
  var_dump($values);
116
+
117
+ }
118
+ //var_dump($parentProductId);
119
+ exit();
120
 
121
  }
122
 
123
 
124
  //get store products
125
+ //$products = Mage::getModel('catalog/product')->getCollection();
126
+ //$catalog = array();
127
 
128
+ function readProducts($products){
129
 
130
+ //global $catalog;
131
 
132
+ $collection = Mage::getModel('catalog/product')->getCollection();
 
 
133
 
134
+ $collection->addAttributeToSelect('manufacturer');
135
 
136
+ $collection->addFieldToFilter(
137
+ array(
138
+ array('attribute' => 'manufacturer', 'eq' =>$designer_id),
139
+ )
140
+ );
 
 
 
 
 
 
 
 
 
 
 
141
 
142
+ $collection = Mage::getResourceModel('catalog/product_collection');
 
 
 
 
 
 
 
143
 
 
 
 
144
 
145
+ if (count($collection)){
146
 
147
+ $output = array();
 
 
 
 
148
 
149
+ foreach ($products as $product){
150
 
151
+ $attributes = array();
152
 
153
+ foreach ($product->getdata() as $key => $value) {
154
 
155
+ if ($key!=='stock_item') {
156
+
157
+ $url = $product->getProductUrl();
158
+ if(($key == 'url_path') || ($key =='url_key')){
159
+ $value = $url;
160
+ $value = str_replace('/productapi.php','',$value);
161
+ $value = trim ($value);
162
+ }
163
+
164
+ if ($key == 'image') $value = $baseUrl."media/catalog/product".$value;
165
+ if ($key == 'thumbnail') $value = $baseUrl."media/catalog/product".$value;
166
+ if ($key == 'manufacturer') $value = $product->getResource()->getAttribute('manufacturer')->getFrontend()->getValue($product);
167
+ if ($key == 'brand') $value = $product->getResource()->getAttribute('brand')->getFrontend()->getValue($product);
168
+
169
+ $attributes[$key] = $value;
170
+
171
+ }
172
+
173
+
174
+ }
175
 
176
+
177
+ $product_options = array();
178
+ $opts = array();
179
+ //get product options
180
+ $options = Mage::getModel('catalog/product_option')->getProductOptionCollection($product);
181
 
182
+ if($options){
183
 
184
+ foreach ($options as $option) {
185
 
186
+ //get product option values
187
+ $values = $option->getValues();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
188
 
189
+ if($values){
190
+ foreach ($values as $v) {
191
+ foreach ($v->getData() as $key => $value) {
192
+ $product_options[$key] = $value;
193
+ $product_options['name'] = $option->getDefaultTitle();
194
+ $product_options['optiontype'] = $option->getType();
195
+ }
196
+ array_push($opts, $product_options);
197
+ }
198
+ }
199
+
200
+ }
201
 
202
+ }
203
 
 
204
 
205
+ $categories = $product->getCategoryIds();
206
+ $prod = array();
207
+
208
+ if($categories){
209
+ foreach($categories as $k => $_category_id){
210
+
211
+ $_category = Mage::getModel('catalog/category')->load($_category_id);
212
+ $cat_name = $_category->getName();
213
+ $cat_url = $_category->getUrl();
214
+
215
+ //build product data array
216
+ $prod['product'] = array(
217
+ $attributes,
218
+ array("options" => $opts),
219
+ array("category" => array('name' => $cat_name, 'url' => $cat_url))
220
+ );
221
+
222
+ //push product data array into output
223
+ array_push($output, $prod);
224
+ //array_push($catalog, $prod);
225
+
226
+
227
+
228
+ }
229
+ }else{
230
+
231
+ //build product data array
232
+ $prod['product'] = array(
233
+ $attributes,
234
+ array("options" => $opts),
235
+ array("category" => array('name' => "", 'url' => ""))
236
+ );
237
+
238
+ //push product data array into catalog
239
+ array_push($output, $prod);
240
+ //array_push($catalog, $prod);
241
 
 
 
 
 
 
 
 
 
 
 
 
242
  }
243
+
244
 
245
+ }//endforeach;
246
+ }
247
+ //$catalog = $output;
248
 
249
+ return $output;
250
+ }
251
 
252
+ function getCollectionSize(){
 
253
 
254
+ $collection = Mage::getModel('catalog/product')->getCollection()->addAttributeToFilter('status', array('eq' => Mage_Catalog_Model_Product_Status::STATUS_ENABLED));
255
 
256
+ $collection->getSelect();
257
+
258
+ return $collection->getSize();
259
+ }
260
+
261
+ function paginateCollection($curr_page, $limit){
262
+
263
+ $limit = $limit;
264
+ $curr_page = $curr_page;
265
+
266
+ if(Mage::app()->getRequest()->getParam('p'))
267
+ {
268
+ $curr_page = Mage::app()->getRequest()->getParam('p');
269
+ }
270
+ //Calculate Offset
271
+ $offset = ($curr_page - 1) * $limit;
272
+
273
+ $collection = Mage::getModel('catalog/product')->getCollection()->addAttributeToSelect('*')->addAttributeToFilter('status', array('eq' => Mage_Catalog_Model_Product_Status::STATUS_ENABLED));
274
+
275
+ if(!empty($_GET['lastupdated'])){
276
+
277
+ //Start Date filter
278
+
279
+
280
+ //Set start date
281
+ $fromDate = $_GET['lastupdated'];
282
+
283
+ //Set end date
284
+ //$toDate = '2040-12-06 11:06:00';
285
+
286
+ // Format our dates
287
+ $fromDate = date('Y-m-d H:i:s', strtotime($fromDate));
288
+ //$toDate = date('Y-m-d H:i:s', strtotime($toDate));
289
+
290
+ //Filter products using date ranges
291
+ //$products->addAttributeToFilter('updated_at', array('from'=>$fromDate, 'to'=>$toDate, 'datetime'=>true));
292
+ $collection->addAttributeToFilter('updated_at', array('from'=>$fromDate, 'datetime'=>true));
293
+
294
+ //End Date filter
295
+ }
296
+
297
+ $collection->getSelect()->limit($limit, $offset);
298
+ //echo "Current Page : ".$curr_page." : Offset : ".$offset;
299
+
300
+ return [$collection, $limit, (int)$curr_page];
301
+ }
302
+
303
+ if($_GET['collection']=='true'){
304
+ header('Content-Type: text/plain; charset=utf-8');
305
+ print getCollectionSize();
306
+ exit();
307
+ }
308
 
309
+ $limit = isset($_GET['limit'])? $_GET['limit'] : 200;
310
+ $result = paginateCollection( $_GET['curr_page'], $limit );
311
+ $visibility = array(
312
+ Mage_Catalog_Model_Product_Visibility::VISIBILITY_BOTH,
313
+ Mage_Catalog_Model_Product_Visibility::VISIBILITY_IN_CATALOG
314
+ );
315
 
316
+ $result[0]->addAttributeToFilter('visibility', $visibility);
 
 
317
 
318
+ $result[0]->load();
 
319
 
320
+ header('Content-Type: application/json; charset=utf-8');
321
+ print json_encode( readProducts( $result[0] ) );//print products
322
 
323
 
324
 
325
 
326
+ ?>