Feed_Manager_Version_1_1_2 - Version 2.0.8

Version Notes

This is faster and effecients. It now returns products in Json and has the last updated parameter added for fetching products

Download this release

Release Info

Developer Rinkart Osei Asibey
Extension Feed_Manager_Version_1_1_2
Version 2.0.8
Comparing to
See all releases


Code changes from version 2.0.7 to 2.0.8

Files changed (2) hide show
  1. package.xml +26 -10
  2. productapi.php +153 -106
package.xml CHANGED
@@ -1,18 +1,34 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Feed_Manager_Version_1_1_2</name>
4
- <version>2.0.7</version>
5
  <stability>stable</stability>
6
- <license uri="http://www.opensource.org/licenses/osl-3.0.php">Extension license name (OSL v3.0)</license>
7
  <channel>community</channel>
8
  <extends/>
9
- <summary>This extension creates xml files to retailtower for further distribution to price engines.</summary>
10
- <description>This extension creates xml files to retailtower for further distribution to price engines.</description>
11
- <notes>Stable version</notes>
12
- <authors><author><name>rinkart</name><user>rinkarto</user><email>rinkarto2000@gmail.com</email></author></authors>
13
- <date>2012-07-05</date>
14
- <time>11:15:38</time>
15
- <contents><target name="mageweb"><dir><dir><file name="productapi.php" hash="96392969c21b2c3cf628065478154771"/></dir></dir></target></contents>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
16
  <compatible/>
17
- <dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
18
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Feed_Manager_Version_1_1_2</name>
4
+ <version>2.0.8</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</summary>
10
+ <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;
11
+ &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;
12
+ &lt;p&gt;2. Create &lt;strong&gt;Facebook fanpage stores&lt;/strong&gt; with our new Shop Plus feature.&lt;/p&gt;&#xD;
13
+ &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;
14
+ &lt;p&gt;It is faster and automates datafeeds process&lt;/p&gt;&#xD;
15
+ &lt;p&gt; Sell your high perfoming products on shopping engines&lt;/p&gt;&#xD;
16
+ &lt;p&gt;&#xA0;&lt;/p&gt;&#xD;
17
+ &lt;p&gt;How-to use it:&lt;/p&gt;&#xD;
18
+ &lt;p&gt;1. Install this extension&lt;/p&gt;&#xD;
19
+ &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;
20
+ &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;
21
+ &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;
22
+ &lt;p&gt;&#xA0;&lt;/p&gt;&#xD;
23
+ &lt;p&gt;Note:&lt;/p&gt;&#xD;
24
+ &lt;p&gt;1. Feed Manager Version 1.1.2 works with magento 1.4x and above. &lt;/p&gt;&#xD;
25
+ &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;
26
+ &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>
27
+ <notes>This is faster and effecients. It now returns products in Json and has the last updated parameter added for fetching products</notes>
28
+ <authors><author><name>Rinkart Osei Asibey</name><user>rinkarto</user><email>rinkarto2000@gmail.com</email></author><author><name>Rinkart Osei Asibey</name><user>RetailTower</user><email>support@retailtower.com</email></author></authors>
29
+ <date>2014-12-22</date>
30
+ <time>14:55:20</time>
31
+ <contents><target name="mage"><dir name="."><file name="productapi.php" hash="c9e52eb956f04a3caa6f0cb79748f4f2"/></dir></target></contents>
32
  <compatible/>
33
+ <dependencies><required><php><min>5.4.1</min><max>5.5.1</max></php></required></dependencies>
34
  </package>
productapi.php CHANGED
@@ -1,24 +1,94 @@
1
  <?php
2
- set_time_limit(1600);
3
- ini_set('memory_limit', '-1');
4
- include_once 'app/Mage.php';
5
- umask(0);
6
- Mage::app();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7
 
8
 
9
- $products = Mage::getModel('catalog/product')->getCollection();
10
  $products->addAttributeToSelect('*');
11
- $products->addAttributeToFilter('status', array('eq' => Mage_Catalog_Model_Product_Status::STATUS_ENABLED));
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12
 
13
  $visibility = array(
14
  Mage_Catalog_Model_Product_Visibility::VISIBILITY_BOTH,
15
  Mage_Catalog_Model_Product_Visibility::VISIBILITY_IN_CATALOG
16
  );
17
- $products->addAttributeToFilter('visibility', $visibility);
 
18
 
19
- $collection = Mage::getModel('catalog/product')->getCollection();
20
- $collection->addAttributeToSelect('manufacturer');
21
- $collection->addFieldToFilter(array(
 
 
22
  array('attribute' => 'manufacturer', 'eq' =>$designer_id),
23
  ));
24
 
@@ -26,107 +96,84 @@ Mage::app();
26
 
27
  $baseUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
28
 
29
- $collection = Mage::getResourceModel('catalog/product_collection');
30
 
31
-
32
 
33
- $output = '<?xml version="1.0" encoding="utf-8"?>
34
- <products>';
35
- if (count($collection)){
36
- //echo "<pre>";
37
- foreach ($products as $product){
38
- //var_dump($product->getdata());die;
39
- $output .= '<product>';
40
- foreach ($product->getdata() as $key=>$value) {
41
- if ($key!=='stock_item') {
42
- //my code start
43
-
44
- $url = $product->getProductUrl();
45
- if (($key == 'url_path') || ($key =='url_key')){
46
- $value = $url;
47
- $value = str_replace('/productapi.php','',$value);
48
- $value = trim ($value);
49
- }
50
-
51
- if ($key == 'image'){
52
- $value = $baseUrl."media/catalog/product".$value;
53
- //$value = str_replace('/productapi.php','',$value);
54
- //$value = trim ($value);
55
- }
56
-
57
- if ($key == 'thumbnail'){
58
- $value = $baseUrl."media/catalog/product".$value;
59
- }
60
- /*if ($key == 'manufacturer'){
61
- $value = $product->getAttributeText('manufacturer');
62
- }
63
-
64
- if ($key == 'brand'){
65
- $value = $product->getAttributeText('manufacturer');
66
- }*/
67
- if ($key == 'manufacturer'){
68
- $value = $product->getResource()->getAttribute('manufacturer')->getFrontend()->getValue($product);
69
- }
70
- if ($key == 'brand'){
71
- $value = $product->getResource()->getAttribute('brand')->getFrontend()->getValue($product);
72
- }
73
-
74
- /*$search = array('&','<','>','"','\'','-','—',"'",'(',')','™','®','©');
75
- $replace = array('&#38;','&lt;','&gt;','&quot;','&apos;','&#45;','&#x2015;','&#39;','&#40;','&#41;','&trade','&#174;','&copy');
76
- $value = str_replace($search,$replace,$value);
77
- $value = str_replace('&','',$value);
78
- $value = str_replace('</br>','',$value);
79
- $value = str_replace('<br/>','',$value);
80
- $value = str_replace('>','',$value);
81
- $value = str_replace('<','',$value);*/
82
- $value = "<![CDATA[$value]]>";
 
 
 
 
 
 
 
 
 
 
 
 
 
 
83
 
84
-
85
-
86
-
87
-
88
- $key = str_replace('"','',$key);
89
- //my code end
90
- /*$search = array('ñ');
91
- $replace = array('hjaja');
92
- $value = str_replace($search,$replace,$value);
93
- */
94
- $output .= '<'.$key.'>'.$value.'</'.$key.'>';
95
-
96
- }
97
-
98
-
99
- }
100
- $categories = $product->getCategoryIds();
101
- $output .= '<categories>';
102
- foreach($categories as $k => $_category_id):
103
- $_category = Mage::getModel('catalog/category')->load($_category_id);
104
- $cat_name = $_category->getName();
105
- $cat_url = $_category->getUrl();
106
-
107
- $cat_name = "<![CDATA[$cat_name]]>";
108
- $cat_url = "<![CDATA[$cat_url]]>";
109
-
110
- $output .= '<category>';
111
- $output .= '<name>'.$cat_name.'</name>';
112
- $output .= '<url>'.$cat_url.'</url>';
113
- $output .= '</category>';
114
- endforeach;
115
- $output .= '</categories>';
116
- $output .= '</product>';
117
- $url = $product->getProductUrl();
118
- //$url = str_replace('/productapi.php','',$url);
119
- // $url = trim ($url);
120
-
121
 
122
- }//endforeach;
123
- $output .= '
124
- </products>';
125
  }//endif;
126
- //header ("Content-Type: text/xml; charset=ISO-8859-1");
127
 
128
- header ("Content-Type: text/xml; charset=UTF-8");
129
- print $output;
 
 
 
130
 
131
 
132
 
1
  <?php
2
+ set_time_limit(1600);
3
+ ini_set('memory_limit', '-1');
4
+ include_once 'app/Mage.php';
5
+ umask(0);
6
+ Mage::app();
7
+
8
+
9
+ if(!empty($_GET['status'])){
10
+
11
+ if($_GET['status'] == 'disabled'){
12
+
13
+ $output = array();
14
+ $data = array();
15
+ $attributes = array();
16
+
17
+ Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);
18
+
19
+ $collection = Mage::getResourceModel('catalog/product_collection')
20
+ ->addAttributeToSelect('*') // select all attributes
21
+ ->addAttributeToFilter('status', array('eq' => Mage_Catalog_Model_Product_Status::STATUS_DISABLED)); //select only disabled products
22
+
23
+ //loop through the list of products to get attribute values
24
+ foreach ($collection as $product) {
25
+
26
+ $attributes['name'] = $product->getName();
27
+ $attributes['id'] = $product->getId();
28
+ $attributes['status'] = $product->getStatus();
29
+
30
+ //build product data array
31
+ $data['product'] = array(
32
+ $attributes
33
+ );
34
+
35
+ //push product data array into output
36
+ array_push($output, $output["products"] = $data);
37
+
38
+ }
39
+ //header to indicate content type
40
+ header('Content-Type: application/json; charset=utf-8');
41
+
42
+ //print disabled products
43
+ print json_encode($output);
44
+ exit();
45
+ }
46
+
47
+
48
+ }
49
+
50
+
51
+ $products = Mage::getModel('catalog/product')->getCollection();
52
 
53
 
 
54
  $products->addAttributeToSelect('*');
55
+
56
+ if(!empty($_GET['startDate'])){
57
+
58
+ //Start Date filter
59
+
60
+ $date = $_GET['startDate'];
61
+ //Set start date
62
+ $fromDate = $date;
63
+ //Set end date
64
+ $toDate = '2020-12-06 11:06:00';
65
+
66
+ // Format our dates
67
+ $fromDate = date('Y-m-d H:i:s', strtotime($fromDate));
68
+ $toDate = date('Y-m-d H:i:s', strtotime($toDate));
69
+
70
+ //Filter products using date ranges
71
+ $products->addAttributeToFilter('updated_at', array('from'=>$fromDate, 'to'=>$toDate, 'datetime'=>true));
72
+
73
+ //End Date filter
74
+ }
75
+
76
+
77
+ $products->addAttributeToFilter('status', array('eq' => Mage_Catalog_Model_Product_Status::STATUS_ENABLED));
78
+
79
 
80
  $visibility = array(
81
  Mage_Catalog_Model_Product_Visibility::VISIBILITY_BOTH,
82
  Mage_Catalog_Model_Product_Visibility::VISIBILITY_IN_CATALOG
83
  );
84
+
85
+ $products->addAttributeToFilter('visibility', $visibility);
86
 
87
+ $collection = Mage::getModel('catalog/product')->getCollection();
88
+
89
+ $collection->addAttributeToSelect('manufacturer');
90
+
91
+ $collection->addFieldToFilter(array(
92
  array('attribute' => 'manufacturer', 'eq' =>$designer_id),
93
  ));
94
 
96
 
97
  $baseUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
98
 
99
+ $collection = Mage::getResourceModel('catalog/product_collection');
100
 
 
101
 
102
+ if (count($collection)){
103
+
104
+ $output = array();
105
+
106
+ foreach ($products as $product){
107
+
108
+ $attributes = array();
109
+
110
+ foreach ($product->getdata() as $key => $value) {
111
+
112
+ if ($key!=='stock_item') {
113
+
114
+ //my code start
115
+
116
+ $url = $product->getProductUrl();
117
+ if (($key == 'url_path') || ($key =='url_key')){
118
+ $value = $url;
119
+ $value = str_replace('/productapi.php','',$value);
120
+ $value = trim ($value);
121
+ }
122
+
123
+ if ($key == 'image'){
124
+ $value = $baseUrl."media/catalog/product".$value;
125
+ }
126
+
127
+ if ($key == 'thumbnail'){
128
+ $value = $baseUrl."media/catalog/product".$value;
129
+ }
130
+
131
+ if ($key == 'manufacturer'){
132
+ $value = $product->getResource()->getAttribute('manufacturer')->getFrontend()->getValue($product);
133
+ }
134
+ if ($key == 'brand'){
135
+ $value = $product->getResource()->getAttribute('brand')->getFrontend()->getValue($product);
136
+ }
137
+
138
+ $attributes[$key] = $value;
139
+
140
+ }
141
+
142
+
143
+ }
144
+
145
+
146
+ $categories = $product->getCategoryIds();
147
+ $product = array();
148
+
149
+ foreach($categories as $k => $_category_id):
150
+
151
+ $_category = Mage::getModel('catalog/category')->load($_category_id);
152
+ $cat_name = $_category->getName();
153
+ $cat_url = $_category->getUrl();
154
+
155
+ //build product data array
156
+ $product['product'] = array(
157
+ $attributes,
158
+ array("category" => array('name' => $cat_name, 'url' => $cat_url))
159
+ );
160
+
161
+ //push product data array into output
162
+ array_push($output, $output["products"] = $product);
163
+
164
+
165
+ endforeach;
166
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
167
 
168
+ }//endforeach;
169
+
 
170
  }//endif;
 
171
 
172
+ //header to indicate content type
173
+ header('Content-Type: application/json; charset=utf-8');
174
+
175
+ //print products
176
+ print json_encode($output);
177
 
178
 
179