Version Notes
Stable release. Compatible with older versions. Feed creation has been optimized to handle larger loads. The option to choose the store is now available. Can retrieve associated products for grouped types.Bug fixes.Has support for PHP V5.2. Quantity script has now been added.
Download this release
Release Info
Developer | Magento Core Team |
Extension | Intelligent_Reach |
Version | 1.0.18 |
Comparing to | |
See all releases |
Code changes from version 1.0.17 to 1.0.18
- intelligentreach_integration.php +202 -239
- intelligentreach_integration_qty.php +162 -0
- package.xml +7 -7
intelligentreach_integration.php
CHANGED
@@ -1,261 +1,224 @@
|
|
1 |
-
<?php
|
2 |
-
/** Version 1.0.16 Last updated by Kire on 24/02/2014 **/
|
3 |
|
|
|
4 |
ini_set('display_errors', 1);
|
5 |
ini_set('max_execution_time', 1800);
|
6 |
include_once 'app/Mage.php';
|
7 |
umask(0);
|
8 |
Mage::app();
|
9 |
|
10 |
-
// Check if a storeid parameter has been set, returns a boolean.
|
11 |
-
function storeIsSelected()
|
12 |
-
{
|
13 |
-
if(isset($_GET["storeid"]))
|
14 |
-
return true;
|
15 |
-
else
|
16 |
-
return false;
|
17 |
-
}
|
18 |
-
|
19 |
-
// Gets all the stores on the current website,
|
20 |
-
// returns a table containing Store Ids and Store Names.
|
21 |
-
function getStores()
|
22 |
-
{
|
23 |
-
$websiteStores = Mage::app()->getWebsite()->getStores();
|
24 |
-
echo "<table cellspacing='2px;' border='1px;' cellpadding='8px;'>";
|
25 |
-
echo "<tr><th>Store Id</th><th>Store Name</th></tr>";
|
26 |
-
foreach ($websiteStores as $store)
|
27 |
-
{
|
28 |
-
echo "<tr><td>".$store->getId()."</td><td><a href='?storeid=".$store->getId()."&splitby=100&amountofproducts=100'>".$store->getName()."</a></td></tr>";
|
29 |
-
}
|
30 |
-
echo "</table>";
|
31 |
-
}
|
32 |
|
33 |
-
|
34 |
-
|
35 |
-
$pages = $lastPageNumber;
|
36 |
-
echo "<table cellspacing='2px;' border='1px;' cellpadding='8px;'>";
|
37 |
-
echo "<tr><th>Section</th><th>Pages</th></tr>";
|
38 |
-
for($i=$sections; $i>0; $i--)
|
39 |
-
{
|
40 |
-
$startingPage = $pages-$splitBy + 1;
|
41 |
-
if($startingPage <= 0){
|
42 |
-
$startingPage = 0;
|
43 |
-
}
|
44 |
-
echo "<tr><td><a href='?storeid=".$_GET["storeid"]."&startingpage=".$startingPage."&endpage=".$pages."'>".$i."</a></td><td>".$startingPage."-".$pages."</td></tr>";
|
45 |
-
$pages = $startingPage - 1;
|
46 |
-
}
|
47 |
-
echo "</table>";
|
48 |
-
}
|
49 |
|
50 |
-
|
51 |
-
// returns an array of products and their details.
|
52 |
-
function getProducts($page)
|
53 |
{
|
54 |
-
|
55 |
-
|
56 |
-
$amountOfProductsPerPage = $_GET["amountofproducts"];
|
57 |
-
|
58 |
-
$products = Mage::getModel('catalog/product')->getCollection()->addStoreFilter($_GET["storeid"]);
|
59 |
-
$products->setPage($page, $amountOfProductsPerPage);
|
60 |
-
$products->addAttributeToSelect('*');
|
61 |
-
$products->addAttributeToFilter('status', array('eq' => Mage_Catalog_Model_Product_Status::STATUS_ENABLED));
|
62 |
-
|
63 |
-
return $products;
|
64 |
-
}
|
65 |
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
//echo '<currentPages>'.$page." - ".$lastPageNumber.'</currentPages>';
|
73 |
-
while ($page <= $lastPageNumber)
|
74 |
-
{
|
75 |
-
$products = getProducts($page);
|
76 |
-
printProducts($products);
|
77 |
-
$page = $page + 1;
|
78 |
-
unset($products);
|
79 |
-
flush();
|
80 |
-
}
|
81 |
-
echo '</products>';
|
82 |
-
}
|
83 |
|
84 |
-
//
|
85 |
-
|
86 |
-
{
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
if($product->getTypeId() == 'simple'){
|
102 |
-
$parentIds = Mage::getModel('catalog/product_type_grouped')->getParentIdsByChild($product->getId());
|
103 |
-
if(!$parentIds)
|
104 |
-
$parentIds = Mage::getModel('catalog/product_type_configurable')->getParentIdsByChild($product->getId());
|
105 |
-
if(isset($parentIds[0])){
|
106 |
-
$parentProduct = Mage::getModel('catalog/product')->load($parentIds[0]);
|
107 |
-
}
|
108 |
-
}
|
109 |
-
foreach ($product->getdata() as $key=>$value)
|
110 |
-
{
|
111 |
-
|
112 |
-
if ($key!=='stock_item')
|
113 |
-
{
|
114 |
-
if ($product->getResource()->getAttribute($key) != null)
|
115 |
-
{
|
116 |
-
$value = $product->getResource()->getAttribute($key)->getFrontend()->getValue($product);
|
117 |
-
}
|
118 |
-
|
119 |
-
$url = $product->getProductUrl();
|
120 |
-
|
121 |
-
if (($key == 'url_path') || ($key =='url_key'))
|
122 |
-
{
|
123 |
-
$value = $url;
|
124 |
-
$value = str_replace('/intelligentreach_integration.php','',$value);
|
125 |
-
$value = trim ($value);
|
126 |
-
}
|
127 |
-
|
128 |
-
if ($key == 'image')
|
129 |
-
{
|
130 |
-
$value = $baseUrl."media/catalog/product".$value;
|
131 |
-
}
|
132 |
-
|
133 |
-
if ($key == 'thumbnail')
|
134 |
-
{
|
135 |
-
$value = $baseUrl."media/catalog/product".$value;
|
136 |
-
}
|
137 |
-
|
138 |
-
if(($value == '') && (isset($parentProduct)))
|
139 |
-
{
|
140 |
-
$attr = $parentProduct->getResource()->getAttribute($key);
|
141 |
-
if(!is_object($attr)){
|
142 |
-
continue;
|
143 |
-
}
|
144 |
-
$value = $attr->getFrontend()->getValue($parentProduct);
|
145 |
-
}
|
146 |
-
|
147 |
-
$value = "<![CDATA[$value]]>";
|
148 |
-
|
149 |
-
$key = str_replace('"','',$key);
|
150 |
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
|
|
|
|
157 |
|
158 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
159 |
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
$cat_parentCategories = array_reverse($_category->getParentCategories(), true);
|
169 |
-
$output = '<category_path><![CDATA[';
|
170 |
-
|
171 |
-
foreach($cat_parentCategories as $parent)
|
172 |
-
{
|
173 |
-
if($parent->getName() == end($cat_parentCategories)->getName())
|
174 |
-
{
|
175 |
-
$output .= $parent->getName();
|
176 |
-
}
|
177 |
-
else
|
178 |
-
{
|
179 |
-
$output .= $parent->getName().' > ';
|
180 |
-
}
|
181 |
-
}
|
182 |
-
|
183 |
-
$output .= ']]></category_path>';
|
184 |
-
$firstCategoryPath = false;
|
185 |
-
echo $output;
|
186 |
-
}
|
187 |
-
}
|
188 |
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
|
|
201 |
}
|
202 |
-
|
203 |
-
|
204 |
-
{
|
205 |
-
$uniqueStack = array_unique($stack);
|
206 |
-
for($i=0; $i<=count($uniqueStack);$i++)
|
207 |
-
{
|
208 |
-
$associatedProductsPop = array_pop($uniqueStack);
|
209 |
-
printProducts($associatedProductsPop);
|
210 |
-
}
|
211 |
-
}
|
212 |
-
}
|
213 |
|
214 |
-
|
215 |
-
if(storeIsSelected())
|
216 |
-
{
|
217 |
-
$page = 1;
|
218 |
-
$products = getProducts($page);
|
219 |
-
$lastPageNumber = $products->getLastPageNumber();
|
220 |
-
if(isset($_GET["splitby"]))
|
221 |
-
$splitBy = $_GET["splitby"];
|
222 |
-
else
|
223 |
-
$splitBy = 100;
|
224 |
-
if($lastPageNumber < 10)
|
225 |
{
|
226 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
227 |
}
|
228 |
-
|
|
|
|
|
|
|
229 |
{
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
getSections($lastPageNumber, $sections, $splitBy);
|
240 |
-
echo "</div>";
|
241 |
-
echo "<div class='instructions' style='float:left; padding-left:100px;'>";
|
242 |
-
echo "<h3>Instructions</h3>";
|
243 |
-
echo "<p>The parameter <strong>'splitby'</strong> in the URL splits pages into sections, each page contains unless specified otherwise the default amount of 100 products.</p>";
|
244 |
-
echo "<p>So setting <strong>'splitby'</strong> to equal 100 will bring back 1,000 products per page and 10,000 products per section, if there are 40,000 products in the store then this will return 4 sections. </p>";
|
245 |
-
echo "<strong>e.g.</strong> http://www.exampledomain.com/intelligentreach_integration.php?storeid=1&<strong>splitby=100</strong></p>";
|
246 |
-
echo "<p>You can also set the value of the number of products per page that is returned, by setting the parameter <strong>'amountofproducts'</strong> in the URL</p>";
|
247 |
-
echo "<strong>e.g.</strong> http://www.exampledomain.com/intelligentreach_integration.php?storeid=1&splitby=100&<strong>amountofproducts=100</strong></p>";
|
248 |
-
echo "<p><strong>NB:</strong> The default value for <strong>'splitby'</strong> is 100 and for <strong>'amountofproducts'</strong> is 100.</p>";
|
249 |
-
echo "</div>";
|
250 |
-
}
|
251 |
}
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
|
|
2 |
|
3 |
+
/** Version 1.0.16 Last updated by Kire on 24/02/2014 * */
|
4 |
ini_set('display_errors', 1);
|
5 |
ini_set('max_execution_time', 1800);
|
6 |
include_once 'app/Mage.php';
|
7 |
umask(0);
|
8 |
Mage::app();
|
9 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
10 |
|
11 |
+
$ir = new IntelligentReach();
|
12 |
+
$ir->run();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
13 |
|
14 |
+
class IntelligentReach
|
|
|
|
|
15 |
{
|
16 |
+
private $_splitby = 100;
|
17 |
+
private $_lastPageNumber = 0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
18 |
|
19 |
+
public function run()
|
20 |
+
{
|
21 |
+
$prodcoll = $this->getProducts(1);
|
22 |
+
$this->_lastPageNumber = $prodcoll->getLastPageNumber();
|
23 |
+
if (isset($_GET["splitby"]))
|
24 |
+
$this->_splitby = $_GET["splitby"];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
25 |
|
26 |
+
// If a store id was provided then print the products to the output.
|
27 |
+
if ($this->storeIsSelected())
|
28 |
+
{
|
29 |
+
if ((isset($_GET["startingpage"]) && isset($_GET["endpage"])) || isset($_GET["getall"]))
|
30 |
+
{
|
31 |
+
header("Content-Type: text/xml; charset=UTF-8");
|
32 |
+
echo '<?xml version="1.0" encoding="utf-8"?>
|
33 |
+
<products>';
|
34 |
+
$this->runTheTask(isset($_GET["getall"]) ? 1 : $_GET["startingpage"], isset($_GET["getall"]) ? $this->_lastPageNumber : $_GET["endpage"]);
|
35 |
+
echo '</products>';
|
36 |
+
}
|
37 |
+
else
|
38 |
+
$this->printSections();
|
39 |
+
}
|
40 |
+
else
|
41 |
+
$this->printStores();
|
42 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
43 |
|
44 |
+
// Check if a storeid parameter has been set, returns a boolean.
|
45 |
+
public function storeIsSelected()
|
46 |
+
{
|
47 |
+
if (isset($_GET["storeid"]))
|
48 |
+
return true;
|
49 |
+
else
|
50 |
+
return false;
|
51 |
+
}
|
52 |
|
53 |
+
// Gets all the stores on the current website,
|
54 |
+
// returns a table containing Store Ids and Store Names.
|
55 |
+
public function getStores()
|
56 |
+
{
|
57 |
+
$websiteStores = Mage::app()->getWebsite()->getStores();
|
58 |
+
echo "<table cellspacing='2px;' border='1px;' cellpadding='8px;'>";
|
59 |
+
echo "<tr><th>Store Id</th><th>Store Name</th></tr>";
|
60 |
+
foreach ($websiteStores as $store)
|
61 |
+
echo "<tr><td>" . $store->getId() . "</td><td><a href='?storeid=" . $store->getId() . "&splitby=100&amountofproducts=100'>" . $store->getName() . "</a></td></tr>";
|
62 |
+
echo "</table>";
|
63 |
+
}
|
64 |
|
65 |
+
public function printStores()
|
66 |
+
{
|
67 |
+
echo "<p>Sorry a Store Id was not provided, please choose a store from the options below.</p>";
|
68 |
+
$this->getStores();
|
69 |
+
echo "<p>If you want to skip this step in the future, you can manually enter the Store Id in the URL.<br />";
|
70 |
+
echo "e.g. http://www.exampledomain.com/intelligentreach_integration.php?storeid=1</p>";
|
71 |
+
echo "<p><strong>NB:</strong> The Store Id parameter name is case sensitive. Only use \"storeid=\" not another variation.</p>";
|
72 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
73 |
|
74 |
+
public function getSections($sections)
|
75 |
+
{
|
76 |
+
$pages = $this->_lastPageNumber;
|
77 |
+
echo "<table cellspacing='2px;' border='1px;' cellpadding='8px;'>";
|
78 |
+
echo "<tr><th>Section</th><th>Pages</th></tr>";
|
79 |
+
for ($i = $sections; $i > 0; $i--)
|
80 |
+
{
|
81 |
+
$startingPage = $pages - $this->_splitby + 1;
|
82 |
+
if ($startingPage < 1)
|
83 |
+
$startingPage = 1;
|
84 |
+
|
85 |
+
echo "<tr><td><a href='?storeid=" . $_GET["storeid"] . "&startingpage=" . $startingPage . "&endpage=" . $pages . "'>" . $i . "</a></td><td>" . $startingPage . "-" . $pages . "</td></tr>";
|
86 |
+
$pages = $startingPage - 1;
|
87 |
}
|
88 |
+
echo "</table>";
|
89 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
90 |
|
91 |
+
public function printSections()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
92 |
{
|
93 |
+
$sections = ceil($this->_lastPageNumber / $this->_splitby);
|
94 |
+
echo "<h2>Please select a section to return the products.</h2>";
|
95 |
+
echo "<div class='sections' style='float:left;'>";
|
96 |
+
$this->getSections($sections);
|
97 |
+
echo "</div>";
|
98 |
+
echo "<div class='instructions' style='float:left; padding-left:100px;'>";
|
99 |
+
echo "<h3>Instructions</h3>";
|
100 |
+
echo "<p>The parameter <strong>'splitby'</strong> in the URL splits pages into sections, each page contains (unless specified otherwise) the default amount of 100 products.</p>";
|
101 |
+
echo "<p>So setting <strong>'splitby'</strong> to equal 100 will bring back 1,000 products per page and 10,000 products per section, if there are 40,000 products in the store then this will return 4 sections. </p>";
|
102 |
+
echo "<strong>e.g.</strong> http://www.exampledomain.com/intelligentreach_integration.php?storeid=1&<strong>splitby=100</strong></p>";
|
103 |
+
echo "<p>You can also set the value of the number of products per page that is returned, by setting the parameter <strong>'amountofproducts'</strong> in the URL</p>";
|
104 |
+
echo "<strong>e.g.</strong> http://www.exampledomain.com/intelligentreach_integration.php?storeid=1&splitby=100&<strong>amountofproducts=100</strong></p>";
|
105 |
+
echo "<p><strong>NB:</strong> The default value for <strong>'splitby'</strong> is 100 and for <strong>'amountofproducts'</strong> is 100.</p>";
|
106 |
+
echo "<p>You can also retrieve all products but using the 'getall' parameter</p>";
|
107 |
+
echo "<strong>e.g.</strong> http://www.exampledomain.com/intelligentreach_integration.php?storeid=1&<strong>getall=1</strong></p>";
|
108 |
+
echo "</div>";
|
109 |
}
|
110 |
+
|
111 |
+
// Gets all the products in the catalog in the specific store view,
|
112 |
+
// returns an array of products and their details.
|
113 |
+
public function getProducts($page)
|
114 |
{
|
115 |
+
$amountOfProductsPerPage = 100;
|
116 |
+
if (isset($_GET["amountofproducts"]))
|
117 |
+
$amountOfProductsPerPage = $_GET["amountofproducts"];
|
118 |
+
|
119 |
+
$products = Mage::getModel('catalog/product')->getCollection()->addStoreFilter($_GET["storeid"]);
|
120 |
+
$products->setPage($page, $amountOfProductsPerPage);
|
121 |
+
$products->addAttributeToSelect('*');
|
122 |
+
$products->addAttributeToFilter('status', array('eq' => Mage_Catalog_Model_Product_Status::STATUS_ENABLED));
|
123 |
+
return $products;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
124 |
}
|
125 |
+
|
126 |
+
// Run the task
|
127 |
+
public function runTheTask($startPage, $endPage)
|
128 |
+
{
|
129 |
+
while ($startPage <= $endPage)
|
130 |
+
{
|
131 |
+
$products = $this->getProducts($startPage);
|
132 |
+
if ($products->count() == 0)
|
133 |
+
$this->_log('There are no products to export', true);
|
134 |
+
else
|
135 |
+
{
|
136 |
+
Mage::getSingleton('core/resource_iterator')
|
137 |
+
->walk($products->getSelect(), array(array($this, 'printProducts')));
|
138 |
+
}
|
139 |
+
$startPage = $startPage + 1;
|
140 |
+
unset($products);
|
141 |
+
flush();
|
142 |
+
}
|
143 |
+
}
|
144 |
+
|
145 |
+
public function printProducts($args)
|
146 |
+
{
|
147 |
+
$baseUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
|
148 |
+
|
149 |
+
$product = Mage::getModel('catalog/product')->load($args['row']['entity_id']);
|
150 |
+
echo'<product>';
|
151 |
+
if ($product->getTypeId() == 'simple')
|
152 |
+
{
|
153 |
+
$parentIds = Mage::getModel('catalog/product_type_grouped')->getParentIdsByChild($product->getId());
|
154 |
+
if (!$parentIds)
|
155 |
+
$parentIds = Mage::getModel('catalog/product_type_configurable')->getParentIdsByChild($product->getId());
|
156 |
+
if (isset($parentIds[0]))
|
157 |
+
$parentProduct = Mage::getModel('catalog/product')->load($parentIds[0]);
|
158 |
+
}
|
159 |
+
foreach ($product->getdata() as $key => $value)
|
160 |
+
{
|
161 |
+
if ($key !== 'stock_item')
|
162 |
+
{
|
163 |
+
if ($product->getResource()->getAttribute($key) != null)
|
164 |
+
$value = $product->getResource()->getAttribute($key)->getFrontend()->getValue($product);
|
165 |
+
|
166 |
+
$url = $product->getProductUrl();
|
167 |
+
|
168 |
+
if (($key == 'url_path') || ($key == 'url_key'))
|
169 |
+
$value = trim(str_replace('/intelligentreach_integration.php', '', $url));
|
170 |
+
|
171 |
+
if ($key == 'image')
|
172 |
+
$value = $baseUrl . "media/catalog/product" . $value;
|
173 |
+
|
174 |
+
if ($key == 'thumbnail')
|
175 |
+
$value = $baseUrl . "media/catalog/product" . $value;
|
176 |
+
|
177 |
+
if (($value == '') && (isset($parentProduct)))
|
178 |
+
{
|
179 |
+
$attr = $parentProduct->getResource()->getAttribute($key);
|
180 |
+
if (!is_object($attr))
|
181 |
+
continue;
|
182 |
+
$value = $attr->getFrontend()->getValue($parentProduct);
|
183 |
+
}
|
184 |
+
|
185 |
+
$value = "<![CDATA[$value]]>";
|
186 |
+
|
187 |
+
$key = str_replace('"', '', $key);
|
188 |
+
|
189 |
+
echo '<' . $key . '>' . $value . '</' . $key . '>';
|
190 |
+
}
|
191 |
+
}
|
192 |
+
|
193 |
+
$categories = $product->getCategoryIds();
|
194 |
+
$output = "";
|
195 |
+
$firstCategoryPath = true;
|
196 |
+
|
197 |
+
foreach ($categories as $k => $_category_id)
|
198 |
+
{
|
199 |
+
if ($firstCategoryPath)
|
200 |
+
{
|
201 |
+
$_category = Mage::getModel('catalog/category')->setStoreId($_GET["storeid"])->load($_category_id);
|
202 |
+
$cat_parentCategories = array_reverse($_category->getParentCategories(), true);
|
203 |
+
$output = '<category_path><![CDATA[';
|
204 |
+
|
205 |
+
foreach ($cat_parentCategories as $parent)
|
206 |
+
{
|
207 |
+
if ($parent->getName() == end($cat_parentCategories)->getName())
|
208 |
+
$output .= $parent->getName();
|
209 |
+
else
|
210 |
+
$output .= $parent->getName() . ' > ';
|
211 |
+
}
|
212 |
+
|
213 |
+
$output .= ']]></category_path>';
|
214 |
+
$firstCategoryPath = false;
|
215 |
+
echo $output;
|
216 |
+
}
|
217 |
+
}
|
218 |
+
echo '</product>';
|
219 |
+
if (is_object($parentIds))
|
220 |
+
$parentIds->clearInstance();
|
221 |
+
|
222 |
+
$product->clearInstance();
|
223 |
+
}
|
224 |
+
}
|
intelligentreach_integration_qty.php
ADDED
@@ -0,0 +1,162 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/** Version 1.0.16 Last updated by Kire on 24/02/2014 * */
|
4 |
+
ini_set('display_errors', 1);
|
5 |
+
ini_set('max_execution_time', 1800);
|
6 |
+
include_once 'app/Mage.php';
|
7 |
+
umask(0);
|
8 |
+
Mage::app();
|
9 |
+
|
10 |
+
|
11 |
+
$ir = new IntelligentReach();
|
12 |
+
$ir->run();
|
13 |
+
|
14 |
+
class IntelligentReach
|
15 |
+
{
|
16 |
+
private $_splitby = 100;
|
17 |
+
private $_lastPageNumber = 0;
|
18 |
+
|
19 |
+
public function run()
|
20 |
+
{
|
21 |
+
$prodcoll = $this->getProducts(1);
|
22 |
+
$this->_lastPageNumber = $prodcoll->getLastPageNumber();
|
23 |
+
if (isset($_GET["splitby"]))
|
24 |
+
$this->_splitby = $_GET["splitby"];
|
25 |
+
|
26 |
+
// If a store id was provided then print the products to the output.
|
27 |
+
if ($this->storeIsSelected())
|
28 |
+
{
|
29 |
+
if ((isset($_GET["startingpage"]) && isset($_GET["endpage"])) || isset($_GET["getall"]))
|
30 |
+
{
|
31 |
+
header("Content-Type: text/xml; charset=UTF-8");
|
32 |
+
echo '<?xml version="1.0" encoding="utf-8"?>
|
33 |
+
<products>';
|
34 |
+
$this->runTheTask(isset($_GET["getall"]) ? 1 : $_GET["startingpage"], isset($_GET["getall"]) ? $this->_lastPageNumber : $_GET["endpage"]);
|
35 |
+
echo '</products>';
|
36 |
+
}
|
37 |
+
else
|
38 |
+
$this->printSections();
|
39 |
+
}
|
40 |
+
else
|
41 |
+
$this->printStores();
|
42 |
+
}
|
43 |
+
|
44 |
+
// Check if a storeid parameter has been set, returns a boolean.
|
45 |
+
public function storeIsSelected()
|
46 |
+
{
|
47 |
+
if (isset($_GET["storeid"]))
|
48 |
+
return true;
|
49 |
+
else
|
50 |
+
return false;
|
51 |
+
}
|
52 |
+
|
53 |
+
// Gets all the stores on the current website,
|
54 |
+
// returns a table containing Store Ids and Store Names.
|
55 |
+
public function getStores()
|
56 |
+
{
|
57 |
+
$websiteStores = Mage::app()->getWebsite()->getStores();
|
58 |
+
echo "<table cellspacing='2px;' border='1px;' cellpadding='8px;'>";
|
59 |
+
echo "<tr><th>Store Id</th><th>Store Name</th></tr>";
|
60 |
+
foreach ($websiteStores as $store)
|
61 |
+
echo "<tr><td>" . $store->getId() . "</td><td><a href='?storeid=" . $store->getId() . "&splitby=100&amountofproducts=100'>" . $store->getName() . "</a></td></tr>";
|
62 |
+
echo "</table>";
|
63 |
+
}
|
64 |
+
|
65 |
+
public function printStores()
|
66 |
+
{
|
67 |
+
echo "<p>Sorry a Store Id was not provided, please choose a store from the options below.</p>";
|
68 |
+
$this->getStores();
|
69 |
+
echo "<p>If you want to skip this step in the future, you can manually enter the Store Id in the URL.<br />";
|
70 |
+
echo "e.g. http://www.exampledomain.com/intelligentreach_integration.php?storeid=1</p>";
|
71 |
+
echo "<p><strong>NB:</strong> The Store Id parameter name is case sensitive. Only use \"storeid=\" not another variation.</p>";
|
72 |
+
}
|
73 |
+
|
74 |
+
public function getSections($sections)
|
75 |
+
{
|
76 |
+
$pages = $this->_lastPageNumber;
|
77 |
+
echo "<table cellspacing='2px;' border='1px;' cellpadding='8px;'>";
|
78 |
+
echo "<tr><th>Section</th><th>Pages</th></tr>";
|
79 |
+
for ($i = $sections; $i > 0; $i--)
|
80 |
+
{
|
81 |
+
$startingPage = $pages - $this->_splitby + 1;
|
82 |
+
if ($startingPage < 1)
|
83 |
+
$startingPage = 1;
|
84 |
+
|
85 |
+
echo "<tr><td><a href='?storeid=" . $_GET["storeid"] . "&startingpage=" . $startingPage . "&endpage=" . $pages . "'>" . $i . "</a></td><td>" . $startingPage . "-" . $pages . "</td></tr>";
|
86 |
+
$pages = $startingPage - 1;
|
87 |
+
}
|
88 |
+
echo "</table>";
|
89 |
+
}
|
90 |
+
|
91 |
+
public function printSections()
|
92 |
+
{
|
93 |
+
$sections = ceil($this->_lastPageNumber / $this->_splitby);
|
94 |
+
echo "<h2>Please select a section to return the product quantities.</h2>";
|
95 |
+
echo "<div class='sections' style='float:left;'>";
|
96 |
+
$this->getSections($sections);
|
97 |
+
echo "</div>";
|
98 |
+
echo "<div class='instructions' style='float:left; padding-left:100px;'>";
|
99 |
+
echo "<h3>Instructions</h3>";
|
100 |
+
echo "<p>The parameter <strong>'splitby'</strong> in the URL splits pages into sections, each page contains (unless specified otherwise) the default amount of 100 products.</p>";
|
101 |
+
echo "<p>So setting <strong>'splitby'</strong> to equal 100 will bring back 1,000 products per page and 10,000 products per section, if there are 40,000 products in the store then this will return 4 sections. </p>";
|
102 |
+
echo "<strong>e.g.</strong> http://www.exampledomain.com/intelligentreach_integration.php?storeid=1&<strong>splitby=100</strong></p>";
|
103 |
+
echo "<p>You can also set the value of the number of products per page that is returned, by setting the parameter <strong>'amountofproducts'</strong> in the URL</p>";
|
104 |
+
echo "<strong>e.g.</strong> http://www.exampledomain.com/intelligentreach_integration.php?storeid=1&splitby=100&<strong>amountofproducts=100</strong></p>";
|
105 |
+
echo "<p><strong>NB:</strong> The default value for <strong>'splitby'</strong> is 100 and for <strong>'amountofproducts'</strong> is 100.</p>";
|
106 |
+
echo "<p>You can also retrieve all product quantities but using the 'getall' parameter</p>";
|
107 |
+
echo "<strong>e.g.</strong> http://www.exampledomain.com/intelligentreach_integration.php?storeid=1&<strong>getall=1</strong></p>";
|
108 |
+
echo "</div>";
|
109 |
+
}
|
110 |
+
|
111 |
+
// Gets all the products in the catalog in the specific store view,
|
112 |
+
// returns an array of products and their details.
|
113 |
+
public function getProducts($page)
|
114 |
+
{
|
115 |
+
$amountOfProductsPerPage = 100;
|
116 |
+
if (isset($_GET["amountofproducts"]))
|
117 |
+
$amountOfProductsPerPage = $_GET["amountofproducts"];
|
118 |
+
|
119 |
+
$products = Mage::getModel('catalog/product')->getCollection()->addStoreFilter($_GET["storeid"]);
|
120 |
+
$products->setPage($page, $amountOfProductsPerPage);
|
121 |
+
$products->addAttributeToSelect('*');
|
122 |
+
$products->addAttributeToFilter('status', array('eq' => Mage_Catalog_Model_Product_Status::STATUS_ENABLED));
|
123 |
+
return $products;
|
124 |
+
}
|
125 |
+
|
126 |
+
// Run the task
|
127 |
+
public function runTheTask($startPage, $endPage)
|
128 |
+
{
|
129 |
+
while ($startPage <= $endPage)
|
130 |
+
{
|
131 |
+
$products = $this->getProducts($startPage);
|
132 |
+
if ($products->count() == 0)
|
133 |
+
$this->_log('There are no products to export', true);
|
134 |
+
else
|
135 |
+
{
|
136 |
+
Mage::getSingleton('core/resource_iterator')
|
137 |
+
->walk($products->getSelect(), array(array($this, 'printProducts')));
|
138 |
+
}
|
139 |
+
$startPage = $startPage + 1;
|
140 |
+
unset($products);
|
141 |
+
flush();
|
142 |
+
}
|
143 |
+
}
|
144 |
+
|
145 |
+
public function printProducts($args)
|
146 |
+
{
|
147 |
+
$baseUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
|
148 |
+
$product = Mage::getModel('catalog/product')->load($args['row']['entity_id']);
|
149 |
+
|
150 |
+
$inventoryProduct = Mage::getModel('cataloginventory/stock_item')->loadByProduct($product);
|
151 |
+
echo'<product>';
|
152 |
+
echo '<entity_id><![CDATA['.$inventoryProduct->getProductId().']]></entity_id>';
|
153 |
+
echo '<qty><![CDATA['.(int)$inventoryProduct->getQty().']]></qty>';
|
154 |
+
echo '<is_in_stock><![CDATA['.(int)$inventoryProduct->getIsInStock().']]></is_in_stock>';
|
155 |
+
echo '</product>';
|
156 |
+
|
157 |
+
if(is_object($parentIds))
|
158 |
+
$parentIds->clearInstance();
|
159 |
+
|
160 |
+
$product->clearInstance();
|
161 |
+
}
|
162 |
+
}
|
package.xml
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>Intelligent_Reach</name>
|
4 |
-
<version>1.0.
|
5 |
<stability>stable</stability>
|
6 |
<license uri="http://opensource.org/licenses/OSL-3.0">OSL</license>
|
7 |
<channel>community</channel>
|
@@ -15,11 +15,11 @@ Our market leading merchant platform allows you to control every element of your
|
|
15 |
Via tools such as the Network Affiliate Centre, we provide affiliates with innovative yet simple tools, empowering efficiency and engagement. This platform allows merchants to really drive affiliate engagement and take full advantage of publisher networks.
|
16 |
Intelligent reach also offers advanced insight and trading services; whilst ensuring our customers are agile enough to adapt to new opportunities or challenges from the ever changing and increasingly sophisticated consumer. 
|
17 |
Contact us to arrange a free E-commerce therapy session. Get advice about e-privacy compliance, tag management, analytics or BI implementations and Data quality as well as any key pain points or challenges which are hampering your growth.</description>
|
18 |
-
<notes>Stable release. Compatible with older versions. Feed creation has been optimized to handle larger loads. The option to choose the store is now available. Can retrieve associated products for grouped types.Bug fixes.Has support for PHP V5.2
|
19 |
-
<authors><author><name>Intelligent Reach</name><user>
|
20 |
-
<date>2014-10-
|
21 |
-
<time>
|
22 |
-
<contents><target name="mage"><dir name="
|
23 |
<compatible/>
|
24 |
-
<dependencies
|
25 |
</package>
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>Intelligent_Reach</name>
|
4 |
+
<version>1.0.18</version>
|
5 |
<stability>stable</stability>
|
6 |
<license uri="http://opensource.org/licenses/OSL-3.0">OSL</license>
|
7 |
<channel>community</channel>
|
15 |
Via tools such as the Network Affiliate Centre, we provide affiliates with innovative yet simple tools, empowering efficiency and engagement. This platform allows merchants to really drive affiliate engagement and take full advantage of publisher networks.
|
16 |
Intelligent reach also offers advanced insight and trading services; whilst ensuring our customers are agile enough to adapt to new opportunities or challenges from the ever changing and increasingly sophisticated consumer. 
|
17 |
Contact us to arrange a free E-commerce therapy session. Get advice about e-privacy compliance, tag management, analytics or BI implementations and Data quality as well as any key pain points or challenges which are hampering your growth.</description>
|
18 |
+
<notes>Stable release. Compatible with older versions. Feed creation has been optimized to handle larger loads. The option to choose the store is now available. Can retrieve associated products for grouped types.Bug fixes.Has support for PHP V5.2. Quantity script has now been added.</notes>
|
19 |
+
<authors><author><name>Intelligent Reach</name><user>auto-converted</user><email>development@intelligentreach.com</email></author></authors>
|
20 |
+
<date>2014-10-31</date>
|
21 |
+
<time>17:38:23</time>
|
22 |
+
<contents><target name="mage"><dir name="app"><dir name="etc"><dir name="modules"><file name="IntelligentReach_Integration.xml" hash="6cdd19a11572e7073dbb3d746b6b57b6"/><file name="IntelligentReach_AmazonPayment.xml" hash="10faf651f19ea2298217be1a95707b7c"/><file name="IntelligentReach_EbayPayment.xml" hash="eb9acbd1b55da29e10b09981f0b7af8f"/></dir></dir><dir name="code"><dir name="local"><dir name="IntelligentReach"><dir name="Integration"><dir name="etc"><file name="config.xml" hash="a9244662abbf57f766826a21fce30d8e"/></dir></dir><dir name="AmazonPayment"><dir name="etc"><file name="config.xml" hash="9b3b3b1b3a5331a576f3f1f137465618"/><file name="system.xml" hash="7b236978b8022dc4deda628640ea8689"/></dir><dir name="Helper"><file name="Data.php" hash="2e4ef89b210d0f992cd25b8ef5f4b96e"/></dir><dir name="Model"><file name="Pay.php" hash="cb9c59584f6bd3290620cd11ba44018a"/></dir></dir><dir name="EbayPayment"><dir name="etc"><file name="config.xml" hash="47311b20d05ffdd1f2768000d6d7ad6d"/><file name="system.xml" hash="7246fbf64d238328f74bd6445cc05b29"/></dir><dir name="Helper"><file name="Data.php" hash="0e112e22a4786f3624216628dee796a0"/></dir><dir name="Model"><file name="Pay.php" hash="35d0697bcd84250cc4e39ca108a8ecad"/></dir></dir></dir></dir></dir><dir name="design"><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="intelligentreach_integration.xml" hash="c45eb729e1e4b5025b25c20ac2723eeb"/></dir><dir name="template"><dir name="intelligentreach_integration"><dir name="product"><file name="intelligentreach_integration.phtml" hash="0d1f3ce4a57d977d8955176b01e2f87d"/></dir><dir name="basket"><file name="intelligentreach_integration.phtml" hash="983743acab4cd1c2819ea4fb6eebe0b5"/></dir><dir name="checkout"><dir name="onepage"><file name="intelligentreach_integration.phtml" hash="dfcfe625fadaf06fb3b069cb9257b4cc"/></dir><dir name="multishipping"><file name="intelligentreach_integration.phtml" hash="818d2226ed607d78b709d72cb6c05538"/></dir></dir><file name="intelligentreach_integration.phtml" hash="cfcf6e1c2de50fa66258a820fb296775"/></dir></dir></dir></dir><dir name="enterprise"><dir name="default"><dir name="layout"><file name="intelligentreach_integration.xml" hash="c45eb729e1e4b5025b25c20ac2723eeb"/></dir><dir name="template"><dir name="intelligentreach_integration"><dir name="product"><file name="intelligentreach_integration.phtml" hash="0d1f3ce4a57d977d8955176b01e2f87d"/></dir><dir name="basket"><file name="intelligentreach_integration.phtml" hash="983743acab4cd1c2819ea4fb6eebe0b5"/></dir><dir name="checkout"><dir name="onepage"><file name="intelligentreach_integration.phtml" hash="dfcfe625fadaf06fb3b069cb9257b4cc"/></dir><dir name="multishipping"><file name="intelligentreach_integration.phtml" hash="818d2226ed607d78b709d72cb6c05538"/></dir></dir><file name="intelligentreach_integration.phtml" hash="cfcf6e1c2de50fa66258a820fb296775"/></dir></dir></dir></dir><dir name="default"><dir name="default"><dir name="layout"><file name="intelligentreach_integration.xml" hash="c45eb729e1e4b5025b25c20ac2723eeb"/></dir><dir name="template"><dir name="intelligentreach_integration"><dir name="product"><file name="intelligentreach_integration.phtml" hash="0d1f3ce4a57d977d8955176b01e2f87d"/></dir><dir name="basket"><file name="intelligentreach_integration.phtml" hash="983743acab4cd1c2819ea4fb6eebe0b5"/></dir><dir name="checkout"><dir name="onepage"><file name="intelligentreach_integration.phtml" hash="dfcfe625fadaf06fb3b069cb9257b4cc"/></dir><dir name="multishipping"><file name="intelligentreach_integration.phtml" hash="818d2226ed607d78b709d72cb6c05538"/></dir></dir><file name="intelligentreach_integration.phtml" hash="cfcf6e1c2de50fa66258a820fb296775"/></dir></dir></dir></dir></dir></dir></dir><dir name="."><file name="intelligentreach_integration.php" hash="e8d2f930b4615ef31661554d30ff0a78"/><file name="intelligentreach_integration_qty.php" hash="008425a81c39adc7c5c941ccca2e3950"/></dir></target></contents>
|
23 |
<compatible/>
|
24 |
+
<dependencies/>
|
25 |
</package>
|