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
- package.xml +11 -26
- 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.
|
| 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
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
<p>How-to use it:</p>
|
| 19 |
-
<p>1. Install this extension</p>
|
| 20 |
-
<p>2. Change the permission of file <b>productapi.php</b> to 644. The file can be located in your root of your web folder after installation</p>
|
| 21 |
-
<p>3. Register at <a href="http://app.retailtower.com/signup">http://app.retailtower.com/signup</a> and register.</p>
|
| 22 |
-
<p>4. If there are any problems with installation, contact us at support@retailtower.com and we will help set you up immediately.</p>
|
| 23 |
-
<p> </p>
|
| 24 |
-
<p>Note:</p>
|
| 25 |
-
<p>1. Feed Manager Version 1.1.2 works with magento 1.4x and above. </p>
|
| 26 |
-
<p>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.</p>
|
| 27 |
-
<p>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.</p></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.
|
| 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><p>Reach larger customers by connecting your store to leading shopping engines and marketplaces.</p>
|
| 11 |
+
<p>Optimize the feeds to increase rankings on shopping engines and marketplaces.</p>
|
| 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 |
-
|
| 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 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
|
| 55 |
-
|
| 56 |
|
| 57 |
-
|
| 58 |
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
|
| 63 |
-
|
| 64 |
$attributes
|
| 65 |
);
|
| 66 |
|
| 67 |
-
|
| 68 |
array_push($output, $data);
|
| 69 |
|
| 70 |
//header to indicate content type
|
| 71 |
-
header('Content-Type: application/json; charset=utf-8');
|
| 72 |
|
| 73 |
-
|
| 74 |
print json_encode($output);
|
| 75 |
exit();
|
| 76 |
|
|
@@ -78,207 +79,248 @@
|
|
| 78 |
|
| 79 |
if($_GET['grouped'] == 'true'){
|
| 80 |
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
|
| 85 |
|
| 86 |
-
|
| 87 |
|
| 88 |
-
|
| 89 |
-
|
| 90 |
-
|
| 91 |
-
|
| 92 |
$values = $simpleProducts->getValues();
|
| 93 |
var_dump($values);
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
|
| 97 |
|
| 98 |
}
|
| 99 |
|
| 100 |
|
| 101 |
if($_GET['bundled'] == 'true'){
|
| 102 |
|
| 103 |
-
|
| 104 |
-
|
| 105 |
-
|
| 106 |
-
|
| 107 |
|
| 108 |
-
|
| 109 |
|
| 110 |
-
|
| 111 |
-
|
| 112 |
-
|
| 113 |
$values = $bundleProduct->getValues();
|
| 114 |
var_dump($values);
|
| 115 |
-
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
|
| 119 |
|
| 120 |
}
|
| 121 |
|
| 122 |
|
| 123 |
//get store products
|
| 124 |
-
|
|
|
|
| 125 |
|
|
|
|
| 126 |
|
| 127 |
-
|
| 128 |
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
//Start Date filter
|
| 132 |
|
|
|
|
| 133 |
|
| 134 |
-
|
| 135 |
-
|
| 136 |
-
|
| 137 |
-
|
| 138 |
-
|
| 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 |
-
|
| 165 |
|
| 166 |
-
|
| 167 |
-
array('attribute' => 'manufacturer', 'eq' =>$designer_id),
|
| 168 |
-
));
|
| 169 |
-
|
| 170 |
-
$products->load();
|
| 171 |
|
| 172 |
-
|
| 173 |
|
| 174 |
-
|
| 175 |
|
|
|
|
| 176 |
|
| 177 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 178 |
|
| 179 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 180 |
|
| 181 |
-
|
| 182 |
|
| 183 |
-
|
| 184 |
|
| 185 |
-
|
| 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 |
-
|
| 221 |
-
|
| 222 |
-
|
| 223 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 224 |
|
| 225 |
-
|
| 226 |
|
| 227 |
-
foreach ($options as $option) {
|
| 228 |
|
| 229 |
-
|
| 230 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
-
|
| 249 |
-
$product = array();
|
| 250 |
|
| 251 |
-
|
| 252 |
|
| 253 |
-
|
| 254 |
-
|
| 255 |
-
|
| 256 |
-
|
| 257 |
-
|
| 258 |
-
|
| 259 |
-
|
| 260 |
-
|
| 261 |
-
|
| 262 |
-
|
| 263 |
-
|
| 264 |
-
|
| 265 |
-
|
| 266 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 267 |
|
| 268 |
-
|
| 269 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 270 |
|
| 271 |
-
|
| 272 |
-
|
| 273 |
-
}//endif;
|
| 274 |
|
| 275 |
-
|
| 276 |
-
header('Content-Type: application/json; charset=utf-8');
|
| 277 |
|
| 278 |
-
|
| 279 |
-
print json_encode($
|
| 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 |
+
?>
|
