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.9 |
Comparing to | |
See all releases |
Code changes from version 2.0.8 to 2.0.9
- package.xml +4 -4
- productapi.php +0 -181
package.xml
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>Feed_Manager_Version_1_1_2</name>
|
4 |
-
<version>2.0.
|
5 |
<stability>stable</stability>
|
6 |
<license uri="http://www.opensource.org/licenses/academic.php">Academic Free License (AFL)</license>
|
7 |
<channel>community</channel>
|
@@ -27,8 +27,8 @@
|
|
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>
|
31 |
-
<contents><target name="mage"><dir name="."><file name="productapi.php" hash="
|
32 |
<compatible/>
|
33 |
-
<dependencies><required><php><min>
|
34 |
</package>
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>Feed_Manager_Version_1_1_2</name>
|
4 |
+
<version>2.0.9</version>
|
5 |
<stability>stable</stability>
|
6 |
<license uri="http://www.opensource.org/licenses/academic.php">Academic Free License (AFL)</license>
|
7 |
<channel>community</channel>
|
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>15:26:57</time>
|
31 |
+
<contents><target name="mage"><dir name="."><file name="productapi.php" hash=""/></dir></target></contents>
|
32 |
<compatible/>
|
33 |
+
<dependencies><required><php><min>4.1.1</min><max>5.5.1</max></php></required></dependencies>
|
34 |
</package>
|
productapi.php
DELETED
@@ -1,181 +0,0 @@
|
|
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 |
-
|
95 |
-
$products->load();
|
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 |
-
|
180 |
-
|
181 |
-
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|