Version Notes
[New] BrainSINSData now receives Magento's purchase ID in the thankYou page.
[Fix] onPayment now sends Magento's idPurchase to the API.
Download this release
Release Info
Developer | BrainSINS |
Extension | Brainsins_Recommender |
Version | 2.1.2 |
Comparing to | |
See all releases |
Code changes from version 2.0.4 to 2.1.2
- app/code/community/Brainsins/Recommender/.DS_Store +0 -0
- app/code/community/Brainsins/Recommender/Helper/Data.php +878 -778
- app/code/community/Brainsins/Recommender/Model/Adminhtml/System/Config/Source/Configurableproducttracking.php +34 -0
- app/code/community/Brainsins/Recommender/Model/Adminhtml/System/Config/Source/Currencies.php +58 -0
- app/code/community/Brainsins/Recommender/Model/Adminhtml/System/Config/Source/Emailtracking.php +1 -1
- app/code/community/Brainsins/Recommender/Model/Adminhtml/System/Config/Source/Totalamounttrackingoptions.php +34 -0
- app/code/community/Brainsins/Recommender/Model/Observer.php +9 -0
- app/code/community/Brainsins/Recommender/controllers/.DS_Store +0 -0
- app/code/community/Brainsins/Recommender/controllers/FeedController.php +539 -0
- app/code/community/Brainsins/Recommender/controllers/FeedsController.php +0 -390
- app/code/community/Brainsins/Recommender/controllers/LoginController.php +1 -1
- app/code/community/Brainsins/Recommender/controllers/PurchaseController.php +72 -0
- app/code/community/Brainsins/Recommender/controllers/TrackingController.php +3 -3
- app/code/community/Brainsins/Recommender/etc/config.xml +15 -12
- app/code/community/Brainsins/Recommender/etc/system.xml +474 -428
- app/design/frontend/base/default/layout/brainsins_recommender.xml +18 -9
- app/design/frontend/base/default/template/brainsins/recommender/.DS_Store +0 -0
- app/design/frontend/base/default/template/brainsins/recommender/header.phtml +116 -0
- app/design/frontend/base/default/template/brainsins/recommender/js.phtml +230 -411
- package.xml +7 -6
app/code/community/Brainsins/Recommender/.DS_Store
CHANGED
Binary file
|
app/code/community/Brainsins/Recommender/Helper/Data.php
CHANGED
@@ -32,580 +32,587 @@
|
|
32 |
* Abandono de carrito - 6
|
33 |
* Categoría - 7
|
34 |
*/
|
35 |
-
|
36 |
class Brainsins_Recommender_Helper_Data extends Mage_Core_Helper_Abstract
|
37 |
{
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
250 |
recommenders: [';
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
$_position = 'replace';
|
263 |
-
}
|
264 |
-
$recommenders_js .= "
|
265 |
{
|
266 |
-
recommenderId: "
|
267 |
detailsLevel : 'high',
|
268 |
-
location: '"
|
269 |
-
position: '"
|
270 |
},
|
271 |
";
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
->addAttributeToSelect('entity_id')
|
327 |
-
->addFieldToFilter('status', Mage_Catalog_Model_Product_Status::STATUS_ENABLED)
|
328 |
-
->addFieldToFilter('visibility', Mage_Catalog_Model_Product_Visibility::VISIBILITY_BOTH)
|
329 |
-
->addAttributeToSort('entity_id','asc'); //Tablas flat
|
330 |
-
|
331 |
-
if(!$desc_attribute || $desc_attribute == '')
|
332 |
-
$desc_attribute = 'description';
|
333 |
-
|
334 |
-
foreach ($products as $key => $entity)
|
335 |
-
{
|
336 |
-
try {
|
337 |
-
$product = Mage::getModel('catalog/product')->load($entity->getId());
|
338 |
-
if(Mage::app()->getRequest()->getControllerName() != 'feeds')
|
339 |
-
{
|
340 |
-
$offline_stock_status = Mage::getModel('cataloginventory/stock_item') ->loadByProduct($product)->getIsInStock();
|
341 |
-
if($include_oos_products == '0' && $offline_stock_status == '0')
|
342 |
-
continue;
|
343 |
-
}
|
344 |
-
else
|
345 |
-
{
|
346 |
-
if($include_oos_products == '0' && !$product->isSaleable())
|
347 |
-
continue;
|
348 |
-
}
|
349 |
-
$pEntity = $pDomBrain->createElement('entity');
|
350 |
-
$pEntity->setAttribute('name', 'product');
|
351 |
-
$pEntities->appendChild($pEntity);
|
352 |
-
|
353 |
-
$pIDProd = $pDomBrain->createElement('property');
|
354 |
-
$pIDProd->setAttribute('name', 'idProduct');
|
355 |
-
$cdata = $pDomBrain->createTextNode($product->getId());
|
356 |
-
$pIDProd->appendChild($cdata);
|
357 |
-
$pEntity->appendChild($pIDProd);
|
358 |
-
|
359 |
-
$pMPName = $pDomBrain->createElement('multi_property');
|
360 |
-
$pMPName->setAttribute('name', 'name');
|
361 |
-
|
362 |
-
$pMPDesc = $pDomBrain->createElement('multi_property');
|
363 |
-
$pMPDesc->setAttribute('name', 'description');
|
364 |
-
|
365 |
-
$pMPUrl = $pDomBrain->createElement('multi_property');
|
366 |
-
$pMPUrl->setAttribute('name', 'url');
|
367 |
-
|
368 |
-
foreach ($languages as $store_id => $lang_code) {
|
369 |
-
$product_lang = Mage::getModel('catalog/product')
|
370 |
-
->setStoreId($store_id)
|
371 |
-
->load($product->getId());
|
372 |
-
//$lang_code = explode('_', $lang_code);
|
373 |
-
$pLangName = $pDomBrain->createElement('property');
|
374 |
-
$pLangName->setAttribute('lang', $lang_code);
|
375 |
-
$cdata = $pDomBrain->createCDATASection($product_lang->getName());
|
376 |
-
$pLangName->appendChild($cdata);
|
377 |
-
$pMPName->appendChild($pLangName);
|
378 |
-
|
379 |
-
$pLangDesc = $pDomBrain->createElement('property');
|
380 |
-
$pLangDesc->setAttribute('lang', $lang_code);
|
381 |
-
$cdata = $pDomBrain->createCDATASection(Mage::getResourceModel('catalog/product')
|
382 |
-
->getAttributeRawValue($product_lang->getId(), $desc_attribute, $store_id));
|
383 |
-
$pLangDesc->appendChild($cdata);
|
384 |
-
$pMPDesc->appendChild($pLangDesc);
|
385 |
-
|
386 |
-
$pLangLink = $pDomBrain->createElement('property');
|
387 |
-
$pLangLink->setAttribute('lang', $lang_code);
|
388 |
-
$product_link = preg_replace("/[\?&]?___store=[^\?&]*/", "", $product_lang->getProductUrl());
|
389 |
-
$cdata = $pDomBrain->createCDATASection($product_link);
|
390 |
-
$pLangLink->appendChild($cdata);
|
391 |
-
$pMPUrl->appendChild($pLangLink);
|
392 |
-
}
|
393 |
-
$pEntity->appendChild($pMPName);
|
394 |
-
$pEntity->appendChild($pMPDesc);
|
395 |
-
$pEntity->appendChild($pMPUrl);
|
396 |
-
|
397 |
-
$pPrice = $pDomBrain->createElement('property');
|
398 |
-
$pPrice->setAttribute('name', 'price');
|
399 |
-
|
400 |
-
if($tax_included == '1' && $special_price == '1')
|
401 |
-
$product_price = Mage::helper('tax')->getPrice($product, $product->getFinalPrice(), true, null, null, null, null, false);
|
402 |
-
elseif($tax_included == '1' && $special_price == '0')
|
403 |
-
$product_price = Mage::helper('tax')->getPrice($product, $product->getPrice(), true, null, null, null, null, false);
|
404 |
-
if($tax_included == '0' && $special_price == '1')
|
405 |
-
$product_price = Mage::helper('tax')->getPrice($product, $product->getFinalPrice(), true, null, null, null, null, true);
|
406 |
-
elseif($tax_included == '0' && $special_price == '0')
|
407 |
-
$product_price = Mage::helper('tax')->getPrice($product, $product->getPrice(), true, null, null, null, null, true);
|
408 |
-
|
409 |
-
if($product->getTypeId() == Mage_Catalog_Model_Product_Type::TYPE_BUNDLE)
|
410 |
-
{
|
411 |
-
if($tax_included == '1' && $special_price == '1')
|
412 |
-
$product_price = Mage::helper('tax')->getPrice($product, $this->getBundlePrice($product, 'min', 1), true, null, null, null, null, false);
|
413 |
-
elseif($tax_included == '1' && $special_price == '0')
|
414 |
-
$product_price = Mage::helper('tax')->getPrice($product, $this->getBundlePrice($product, 'min', 1), true, null, null, null, null, false);
|
415 |
-
if($tax_included == '0' && $special_price == '1')
|
416 |
-
$product_price = Mage::helper('tax')->getPrice($product, $this->getBundlePrice($product, 'min', 0), true, null, null, null, null, true);
|
417 |
-
elseif($tax_included == '0' && $special_price == '0')
|
418 |
-
$product_price = Mage::helper('tax')->getPrice($product, $this->getBundlePrice($product, 'min', 0), true, null, null, null, null, true);
|
419 |
-
}
|
420 |
-
|
421 |
-
$cdata = $pDomBrain->createTextNode(number_format($product_price, 2, '.', ''));
|
422 |
-
$pPrice->appendChild($cdata);
|
423 |
-
$pEntity->appendChild($pPrice);
|
424 |
-
|
425 |
-
if($product->getTypeId() == Mage_Catalog_Model_Product_Type::TYPE_BUNDLE)
|
426 |
-
{
|
427 |
-
$product_final_price = $this->getBundlePrice($product, 'min', 1);
|
428 |
-
$product_regular_price = $this->getBundlePrice($product, 'min', 1);
|
429 |
-
}
|
430 |
-
else
|
431 |
-
{
|
432 |
-
$product_final_price = $product->getFinalPrice();
|
433 |
-
$product_regular_price = $product->getPrice();
|
434 |
-
}
|
435 |
-
|
436 |
-
try
|
437 |
-
{
|
438 |
-
$pMPCur = $pDomBrain->createElement('multi_property');
|
439 |
-
$pMPCur->setAttribute('name', 'multiprice');
|
440 |
-
|
441 |
-
foreach ($currencies as $k => $curr){
|
442 |
-
$baseCurrency = Mage::app()->getStore()->getBaseCurrencyCode();
|
443 |
-
$targetCurrency = Mage::getModel('directory/currency')->load($curr);
|
444 |
-
$pPrice = $pDomBrain->createElement('property');
|
445 |
-
$pPrice->setAttribute('currency', $curr);
|
446 |
-
$price_converted = number_format(Mage::helper('directory')->currencyConvert($product_final_price, $baseCurrency, $targetCurrency), 2, '.', '');
|
447 |
-
$cdata = $pDomBrain->createTextNode($price_converted);
|
448 |
-
$pPrice->appendChild($cdata);
|
449 |
-
$pMPCur->appendChild($pPrice);
|
450 |
-
}
|
451 |
-
$pEntity->appendChild($pMPCur);
|
452 |
-
unset($targetCurrency);
|
453 |
-
|
454 |
-
$pOPCur = $pDomBrain->createElement('multi_property');
|
455 |
-
$pOPCur->setAttribute('name', 'originalPrice');
|
456 |
-
|
457 |
-
foreach ($currencies as $k => $curr){
|
458 |
-
$baseCurrency = Mage::app()->getStore()->getBaseCurrencyCode();
|
459 |
-
$targetCurrency = Mage::getModel('directory/currency')->load($curr);
|
460 |
-
$pPrice = $pDomBrain->createElement('property');
|
461 |
-
$pPrice->setAttribute('currency', $curr);
|
462 |
-
$price_converted = number_format(Mage::helper('directory')->currencyConvert($product_regular_price, $baseCurrency, $targetCurrency), 2, '.', '');
|
463 |
-
$cdata = $pDomBrain->createTextNode($price_converted);
|
464 |
-
$pPrice->appendChild($cdata);
|
465 |
-
$pOPCur->appendChild($pPrice);
|
466 |
-
}
|
467 |
-
$pEntity->appendChild($pOPCur);
|
468 |
-
unset($targetCurrency);
|
469 |
-
}
|
470 |
-
catch(Exception $e)
|
471 |
-
{
|
472 |
-
Mage::throwException(Mage::helper('brainsins_recommender')->__('ERROR IN CURRENCY CONVERT. ALL CURRENCY RATES ARE DEFINED?'));
|
473 |
-
}
|
474 |
-
|
475 |
-
$imageUrl = null;
|
476 |
-
|
477 |
-
$image_width = Mage::getStoreConfig('brainsins_recommender_options/product_feed/product_image_resize_width', Mage::app()->getStore()->getStoreId());
|
478 |
-
$image_height = Mage::getStoreConfig('brainsins_recommender_options/product_feed/product_image_resize_height', Mage::app()->getStore()->getStoreId());
|
479 |
-
|
480 |
-
if (!$image_width || $image_width == "" || $image_width == "0" || !is_numeric($image_width)) {
|
481 |
-
$image_width = null;
|
482 |
-
}
|
483 |
-
|
484 |
-
if (!$image_height || $image_height == "" || $image_height == "0" || !is_numeric($image_height)) {
|
485 |
-
$image_height = null;
|
486 |
-
}
|
487 |
-
|
488 |
-
|
489 |
-
if (!$image_width && !$image_height) {
|
490 |
-
$imageUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA).'catalog/product'.$product->getImage();
|
491 |
-
} else {
|
492 |
-
$imageUrl = (string) Mage::helper('catalog/image')->init($product, "image")->resize($image_width, $image_height);
|
493 |
-
}
|
494 |
-
|
495 |
-
// $url = (string) Mage::helper('catalog/image')->init($product, "small_image")->resize($width, $height);
|
496 |
-
|
497 |
-
|
498 |
-
|
499 |
-
//$imageUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA).'catalog/product'.$product->getImage();
|
500 |
-
$pImage = $pDomBrain->createElement('property');
|
501 |
-
$pImage->setAttribute('name', 'imageUrl');
|
502 |
-
$cdata = $pDomBrain->createCDATASection($imageUrl);
|
503 |
-
$pImage->appendChild($cdata);
|
504 |
-
$pEntity->appendChild($pImage);
|
505 |
-
|
506 |
-
$pCategory = $pDomBrain->createElement('property');
|
507 |
-
$pCategory->setAttribute('name', 'categories');
|
508 |
-
$cdata = $pDomBrain->createTextNode(implode(",", $product->getCategoryIds()));
|
509 |
-
$pCategory->appendChild($cdata);
|
510 |
-
$pEntity->appendChild($pCategory);
|
511 |
-
|
512 |
-
$rows++;
|
513 |
-
$image = null;
|
514 |
-
unset($image);
|
515 |
-
|
516 |
-
$imageObj = null;
|
517 |
-
unset($imageObj);
|
518 |
-
|
519 |
-
unset($product);
|
520 |
-
} catch (Exception $e2) {
|
521 |
-
$pEntity = $pDomBrain->createElement('entity-error');
|
522 |
-
$pEntity->setAttribute('name', 'product-error');
|
523 |
-
$pEntities->appendChild($pEntity);
|
524 |
-
}
|
525 |
-
}
|
526 |
-
$feed = $pDomBrain->saveXML();
|
527 |
-
$products = null;unset($products);unset($pDomBrain);
|
528 |
-
|
529 |
-
} catch (Exception $e3) {
|
530 |
-
return $e3;
|
531 |
-
}
|
532 |
-
|
533 |
-
return $feed;
|
534 |
-
}
|
535 |
-
|
536 |
-
public function updateCartInBrainsins($cart, $special = false)
|
537 |
-
{
|
538 |
-
if (!is_object($cart))
|
539 |
-
return;
|
540 |
-
|
541 |
-
$cartId = $cart->getId();
|
542 |
-
|
543 |
-
if (!$cartId) {
|
544 |
-
return;
|
545 |
-
}
|
546 |
-
|
547 |
-
$ruta = "order/trackOrder.xml?";
|
548 |
-
$url = self::getApiUrl().$ruta."token=".Mage::getStoreConfig('brainsins_recommender_options/brainsins_recommender_general/bs_key', Mage::app()->getStore()->getStoreId());
|
549 |
-
|
550 |
-
$cartXML = new DOMDocument('1.0','UTF-8');
|
551 |
-
$cartXML->xmlStandalone = true;
|
552 |
|
553 |
-
|
554 |
-
|
555 |
-
$cartXML->appendChild($pRecsins);
|
556 |
|
557 |
-
|
558 |
-
|
559 |
-
$pOrder = $cartXML->createElement('order');
|
560 |
-
$pIdBuyer = $cartXML->createElement('idBuyer', $this->_getUser());
|
561 |
-
$pOrder->appendChild($pIdBuyer);
|
562 |
|
563 |
-
|
564 |
-
$pOrder->appendChild($pCurrency);
|
565 |
|
566 |
-
|
567 |
|
568 |
-
|
|
|
569 |
|
570 |
-
$pProducts = $cartXML->createElement('products');
|
571 |
-
$pOrder->appendChild($pProducts);
|
572 |
|
573 |
-
|
574 |
-
|
575 |
-
|
576 |
-
|
577 |
-
|
578 |
-
|
579 |
-
|
580 |
-
|
|
|
581 |
|
582 |
$cartItem = Array();
|
583 |
|
584 |
$price = $item->getPriceInclTax();
|
585 |
|
586 |
-
|
587 |
-
|
588 |
-
|
589 |
-
|
590 |
-
|
591 |
-
|
592 |
-
|
593 |
-
|
594 |
-
//
|
595 |
-
|
596 |
-
|
597 |
-
|
598 |
-
|
599 |
-
//get parent if exists -> ensure not single products that belong to configurable exist
|
600 |
-
$configurable_product_model = Mage::getModel('catalog/product_type_configurable');
|
601 |
-
$parentIdArray = $configurable_product_model->getParentIdsByChild($id);
|
602 |
-
|
603 |
-
|
604 |
-
if (count($parentIdArray) > 0) {
|
605 |
-
$id = $parentIdArray[0];
|
606 |
-
}
|
607 |
-
|
608 |
-
|
609 |
// Mage::log("-----");
|
610 |
// Mage::log($item->getProductId());
|
611 |
// Mage::log("type : " . $item->getProductType());
|
@@ -620,240 +627,333 @@ class Brainsins_Recommender_Helper_Data extends Mage_Core_Helper_Abstract
|
|
620 |
|
621 |
$cartItems[] = $cartItem;
|
622 |
|
623 |
-
|
624 |
// $cartItems[$id] = $cartItems[$id] + $qty;
|
625 |
-
|
626 |
-
|
627 |
-
|
628 |
-
|
|
|
|
|
|
|
|
|
629 |
|
630 |
-
|
631 |
-
|
632 |
-
foreach ($cartItems as $cartItem) {
|
633 |
-
$pProduct = $cartXML->createElement('product');
|
634 |
|
635 |
-
|
636 |
-
|
637 |
|
638 |
-
|
639 |
-
|
640 |
|
641 |
-
|
642 |
-
|
643 |
|
644 |
-
|
645 |
-
|
646 |
-
}
|
647 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
648 |
|
|
|
|
|
649 |
|
650 |
-
|
|
|
|
|
|
|
|
|
|
|
651 |
// Mage::log($cartId);
|
652 |
-
|
653 |
-
|
654 |
-
|
655 |
-
|
656 |
-
|
657 |
-
|
658 |
-
|
659 |
-
//
|
660 |
-
|
661 |
// Mage::log($result);
|
662 |
-
|
663 |
-
|
664 |
-
|
665 |
-
|
666 |
-
|
667 |
-
|
668 |
-
|
669 |
-
|
670 |
-
|
671 |
-
|
672 |
-
|
673 |
-
|
674 |
-
|
675 |
-
|
676 |
-
|
677 |
-
|
678 |
-
|
679 |
-
|
680 |
-
|
681 |
-
|
682 |
-
|
683 |
-
|
684 |
-
|
685 |
-
|
686 |
-
|
687 |
-
|
688 |
-
|
689 |
-
|
690 |
-
|
691 |
-
|
692 |
-
|
693 |
-
|
694 |
-
|
695 |
-
|
696 |
-
|
697 |
-
|
698 |
-
|
699 |
-
|
700 |
-
|
701 |
-
|
702 |
-
|
703 |
-
|
704 |
-
|
705 |
-
|
706 |
-
|
707 |
-
|
708 |
-
|
709 |
-
|
710 |
-
|
711 |
-
|
712 |
-
|
713 |
-
|
714 |
-
|
715 |
-
|
716 |
-
|
717 |
-
|
718 |
-
|
719 |
-
|
720 |
-
|
721 |
-
|
722 |
-
|
723 |
-
|
724 |
-
|
725 |
-
|
726 |
-
|
727 |
-
|
728 |
-
|
729 |
-
|
730 |
-
|
731 |
-
|
732 |
-
|
733 |
-
|
734 |
-
|
735 |
-
|
736 |
-
|
737 |
-
|
738 |
-
|
739 |
-
|
740 |
-
|
741 |
-
|
742 |
-
|
743 |
-
|
744 |
-
|
745 |
-
|
746 |
-
|
747 |
-
|
748 |
-
|
749 |
-
|
750 |
-
|
751 |
-
|
752 |
-
|
753 |
-
|
754 |
-
|
755 |
-
|
756 |
-
|
757 |
-
|
758 |
-
|
759 |
-
|
760 |
-
|
761 |
-
|
762 |
-
|
763 |
-
|
764 |
-
|
765 |
-
|
766 |
-
|
767 |
-
|
768 |
-
|
769 |
-
|
770 |
-
|
771 |
-
|
772 |
-
|
773 |
-
|
774 |
-
|
775 |
-
|
776 |
-
|
777 |
-
|
778 |
-
|
779 |
-
|
780 |
-
|
781 |
-
|
782 |
-
|
783 |
-
|
784 |
-
|
785 |
-
|
786 |
-
|
787 |
-
|
788 |
-
|
789 |
-
|
790 |
-
|
791 |
-
|
792 |
-
|
793 |
-
|
794 |
-
|
795 |
-
|
796 |
-
|
797 |
-
|
798 |
-
|
799 |
-
|
800 |
-
|
801 |
-
|
802 |
-
|
803 |
-
|
804 |
-
|
805 |
-
|
806 |
-
|
807 |
-
|
808 |
-
|
809 |
-
|
810 |
-
|
811 |
-
|
812 |
-
|
813 |
-
|
814 |
-
|
815 |
-
|
816 |
-
|
817 |
-
|
818 |
-
|
819 |
-
|
820 |
-
|
821 |
-
|
822 |
-
|
823 |
-
|
824 |
-
|
825 |
-
|
826 |
-
|
827 |
-
|
828 |
-
|
829 |
-
|
830 |
-
|
831 |
-
|
832 |
-
|
833 |
-
|
834 |
-
|
835 |
-
|
836 |
-
|
837 |
-
|
838 |
-
|
839 |
-
|
840 |
-
|
841 |
-
|
842 |
-
|
843 |
-
|
844 |
-
|
845 |
-
|
846 |
-
|
847 |
-
|
848 |
-
|
849 |
-
|
850 |
-
|
851 |
-
|
852 |
-
|
853 |
-
|
854 |
-
|
855 |
-
|
856 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
857 |
|
858 |
|
859 |
}
|
32 |
* Abandono de carrito - 6
|
33 |
* Categoría - 7
|
34 |
*/
|
|
|
35 |
class Brainsins_Recommender_Helper_Data extends Mage_Core_Helper_Abstract
|
36 |
{
|
37 |
+
protected static $_api_url = 'http://durotar-api.brainsins.com/RecSinsAPI/api/';
|
38 |
+
protected static $_pages = 'home,product,category,cart,checkout'; //-->Not needed yet
|
39 |
+
|
40 |
+
public static function getApiUrl()
|
41 |
+
{
|
42 |
+
return 'http://api.brainsins.com/RecSinsAPI/api/';
|
43 |
+
|
44 |
+
}
|
45 |
+
|
46 |
+
public function configuredTaxPrice(Mage_Sales_Model_Quote_Item $cartItem) {
|
47 |
+
$config = Mage::getStoreConfig('brainsins_recommender_options/brainsins_recommender_advanced/tracking_tax', Mage::app()->getStore()->getStoreId());
|
48 |
+
$price = $cartItem->getPrice();
|
49 |
+
//echo("<h1>xxx $config xxx </h1>");
|
50 |
+
if ($config == "1") {
|
51 |
+
return Mage::helper('tax')->getPrice($cartItem->getProduct(), $price, true);
|
52 |
+
} else {
|
53 |
+
return Mage::helper('tax')->getPrice($cartItem->getProduct(), $price, false);
|
54 |
+
}
|
55 |
+
}
|
56 |
+
|
57 |
+
public function priceForTracking(Mage_Sales_Model_Quote_Item $cartItem)
|
58 |
+
{
|
59 |
+
// product price is in catalog base currency, so we use base currency instead
|
60 |
+
// of current currency
|
61 |
+
return $this->toBaseCurrency($this->configuredTaxPrice($cartItem), true);
|
62 |
+
}
|
63 |
+
|
64 |
+
public function displayPriceForTracking(Mage_Sales_Model_Quote_Item $cartItem)
|
65 |
+
{
|
66 |
+
return $cartItem->getPriceInclTax();
|
67 |
+
}
|
68 |
+
|
69 |
+
public function productIdForTracking($product) {
|
70 |
+
$idAttr = Mage::getStoreConfig('brainsins_recommender_options/brainsins_recommender_advanced/product_id_field', Mage::app()->getStore()->getStoreId());
|
71 |
+
|
72 |
+
if ($product->hasData($idAttr)) {
|
73 |
+
return $product->getData($idAttr);
|
74 |
+
} else {
|
75 |
+
return $product->getId();
|
76 |
+
}
|
77 |
+
}
|
78 |
+
|
79 |
+
public function categoryIdForTracking($category) {
|
80 |
+
$idAttr = Mage::getStoreConfig('brainsins_recommender_options/brainsins_recommender_advanced/category_id_field', Mage::app()->getStore()->getStoreId());
|
81 |
+
|
82 |
+
if ($category->hasData($idAttr)) {
|
83 |
+
return $category->getData($idAttr);
|
84 |
+
} else {
|
85 |
+
return $category->getId();
|
86 |
+
}
|
87 |
+
}
|
88 |
+
|
89 |
+
public function toBaseCurrency($price, $useBaseCurrencyCode = false)
|
90 |
+
{
|
91 |
+
$currentCurrencyCode = null;
|
92 |
+
|
93 |
+
if ($useBaseCurrencyCode) {
|
94 |
+
$currentCurrencyCode = Mage::app()->getStore()->getBaseCurrencyCode();
|
95 |
+
} else {
|
96 |
+
$currentCurrencyCode = Mage::app()->getStore()->getCurrentCurrencyCode();
|
97 |
+
}
|
98 |
+
|
99 |
+
$baseCurrencyCode = Mage::getStoreConfig('brainsins_recommender_options/brainsins_recommender_general/base_currency', Mage::app()->getStore()->getStoreId());
|
100 |
+
|
101 |
+
if ($baseCurrencyCode == "") {
|
102 |
+
$baseCurrencyCode = Mage::app()->getStore()->getBaseCurrencyCode();
|
103 |
+
}
|
104 |
+
|
105 |
+
if ($baseCurrencyCode == $currentCurrencyCode) {
|
106 |
+
return $price;
|
107 |
+
} else {
|
108 |
+
|
109 |
+
$allowedCurrencies = Mage::getModel('directory/currency')->getConfigAllowCurrencies();
|
110 |
+
if (in_array($baseCurrencyCode, $allowedCurrencies)) {
|
111 |
+
$rates1 = Mage::getModel('directory/currency')->getCurrencyRates($baseCurrencyCode, array_values($allowedCurrencies));
|
112 |
+
$rates2 = Mage::getModel('directory/currency')->getCurrencyRates($currentCurrencyCode, array_values($allowedCurrencies));
|
113 |
+
|
114 |
+
if (array_key_exists($baseCurrencyCode, $rates1)) {
|
115 |
+
return round($price/$rates1[$currentCurrencyCode], 2);
|
116 |
+
} else if (array_key_exists($baseCurrencyCode, $rates2)) {
|
117 |
+
return round($price * $rates2[$currentCurrencyCode], 2);
|
118 |
+
} else {
|
119 |
+
return $price;
|
120 |
+
}
|
121 |
+
|
122 |
+
} else {
|
123 |
+
return $price;
|
124 |
+
}
|
125 |
+
//return number_format(Mage::helper('directory')
|
126 |
+
//->currencyConvert($price, $currentCurrencyCode, $baseCurrencyCode), 2, '.', '');
|
127 |
+
}
|
128 |
+
}
|
129 |
+
|
130 |
+
public function processItem(Mage_Sales_Model_Quote_Item $item)
|
131 |
+
{
|
132 |
+
$configurable_tracking = Mage::getStoreConfig('brainsins_recommender_options/brainsins_recommender_advanced/configurable_tracking', Mage::app()->getStore()->getStoreId());
|
133 |
+
|
134 |
+
$type = $item->getProductType();
|
135 |
+
$parent = $item->getParentItem();
|
136 |
+
$id = null;
|
137 |
+
$price = null;
|
138 |
+
$displayPrice = null;
|
139 |
+
$qty = null;
|
140 |
+
|
141 |
+
if ($configurable_tracking == "0") {
|
142 |
+
//track simple products
|
143 |
+
if ($parent && $parent->getProductType() == "configurable") {
|
144 |
+
$id = $item->getProductId();
|
145 |
+
$id = $this->productIdForTracking($item->getProduct());
|
146 |
+
$qty = $parent->getQty();
|
147 |
+
$price = $this->priceForTracking($parent);
|
148 |
+
$displayPrice = $this->displayPriceForTracking($parent);
|
149 |
+
} else if (!$parent && $type != "configurable") {
|
150 |
+
$id = $item->getProductId();
|
151 |
+
$qty = $item->getQty();
|
152 |
+
$price = $this->priceForTracking($item);
|
153 |
+
$displayPrice = $this->displayPriceForTracking($item);
|
154 |
+
}
|
155 |
+
} else {
|
156 |
+
//track configurable products
|
157 |
+
if ($type == "simple" && $parent && $parent->GetProductType() == "configurable") {
|
158 |
+
return null;
|
159 |
+
}
|
160 |
+
|
161 |
+
$id = $item->getProductId();
|
162 |
+
$qty = $item->getQty();
|
163 |
+
$price = $this->priceForTracking($item);
|
164 |
+
$displayPrice = $this->displayPriceForTracking($item);
|
165 |
+
}
|
166 |
+
|
167 |
+
if ($id) {
|
168 |
+
$product = Array();
|
169 |
+
$product["id"] = $id;
|
170 |
+
$product["quantity"] = $qty;
|
171 |
+
$product["type"] = $type;
|
172 |
+
$product["parentId"] = $parent ? $this->productIdForTracking($parent->getProduct()) : null;
|
173 |
+
|
174 |
+
$product["price"] = $price;
|
175 |
+
$product["displayPrice"] = $displayPrice;
|
176 |
+
|
177 |
+
return $product;
|
178 |
+
}
|
179 |
+
|
180 |
+
return null;
|
181 |
+
}
|
182 |
+
|
183 |
+
public function processQuote(Mage_Sales_Model_Quote $quote)
|
184 |
+
{
|
185 |
+
$configurable_tracking = Mage::getStoreConfig('brainsins_recommender_options/brainsins_recommender_advanced/configurable_tracking', Mage::app()->getStore()->getStoreId());
|
186 |
+
$taxConfig = Mage::getStoreConfig('brainsins_recommender_options/brainsins_recommender_advanced/tracking_tax', Mage::app()->getStore()->getStoreId());
|
187 |
+
|
188 |
+
$cart = Array();
|
189 |
+
$cart["products"] = Array();
|
190 |
+
|
191 |
+
$items = $quote->getAllItems();
|
192 |
+
|
193 |
+
$totals = $quote->getTotals();
|
194 |
+
|
195 |
+
$tax = 0;
|
196 |
+
$cart["totals"] = Array();
|
197 |
+
|
198 |
+
foreach($totals as $total) {
|
199 |
+
|
200 |
+
$code = $total->getCode();
|
201 |
+
$value = $total->getValue();
|
202 |
+
|
203 |
+
$cart["totals"][$code] = $this->toBaseCurrency($value);
|
204 |
+
|
205 |
+
if ($code == "tax") {
|
206 |
+
$tax = $value;
|
207 |
+
} else if ($code == "discount") {
|
208 |
+
$cart["discount"] = - $value;
|
209 |
+
}
|
210 |
+
}
|
211 |
+
|
212 |
+
if ($taxConfig == "1") {
|
213 |
+
$cart["totalAmount"] = $this->toBaseCurrency($quote->getGrandTotal());
|
214 |
+
} else {
|
215 |
+
$cart["totalAmount"] = $this->toBaseCurrency($quote->getGrandTotal() - $tax);
|
216 |
+
}
|
217 |
+
|
218 |
+
if (count($items) > 0) {
|
219 |
+
|
220 |
+
for ($i = 0; $i < sizeof($items); $i++) {
|
221 |
+
|
222 |
+
$item = $items[$i];
|
223 |
+
$product = $this->processItem($item);
|
224 |
+
if ($product) {
|
225 |
+
$cart["products"][] = $product;
|
226 |
+
}
|
227 |
+
|
228 |
+
/*$type = $item->getProductType();
|
229 |
+
$parent = $item->getParentItem();
|
230 |
+
|
231 |
+
if ($configurable_tracking == "1") {
|
232 |
+
|
233 |
+
} else {
|
234 |
+
|
235 |
+
}
|
236 |
+
|
237 |
+
if ($parent) {
|
238 |
+
|
239 |
+
if ($parent->getProductType() == "bundle") {
|
240 |
+
continue;
|
241 |
+
} else if ($parent->getProductType() == "configurable") {
|
242 |
+
$product = Array();
|
243 |
+
$product["id"] = $item->getProductId();
|
244 |
+
$product["quantity"] = $item->getQty();
|
245 |
+
$product["type"] = $type;
|
246 |
+
$product["parent"] = $parent;
|
247 |
+
|
248 |
+
$product["price"] = $this->priceForTracking($parent);
|
249 |
+
$product["displayPrice"] = $this->displayPriceForTracking($parent);
|
250 |
+
|
251 |
+
|
252 |
+
$cart["products"][] = $product;
|
253 |
+
}
|
254 |
+
|
255 |
+
} else {
|
256 |
+
|
257 |
+
if ($type == "configurable") {
|
258 |
+
continue;
|
259 |
+
}
|
260 |
+
|
261 |
+
$product = Array();
|
262 |
+
$product["id"] = $item->getProductId();
|
263 |
+
$product["quantity"] = $item->getQty();
|
264 |
+
$product["type"] = $type;
|
265 |
+
$product["parent"] = $parent;
|
266 |
+
|
267 |
+
$product["price"] = $this->priceForTracking($item);
|
268 |
+
$product["displayPrice"] = $this->displayPriceForTracking($item);
|
269 |
+
|
270 |
+
$cart["products"][] = $product;
|
271 |
+
}*/
|
272 |
+
|
273 |
+
}
|
274 |
+
}
|
275 |
+
|
276 |
+
return $cart;
|
277 |
+
}
|
278 |
+
|
279 |
+
public function getRecommenders($page)
|
280 |
+
{
|
281 |
+
$recommenders = array();
|
282 |
+
$extension_enabled = Mage::getStoreConfigFlag('brainsins_recommender_options/brainsins_recommender_general/enabled', Mage::app()->getStore()->getStoreId());
|
283 |
+
$bskey = Mage::getStoreConfig('brainsins_recommender_options/brainsins_recommender_general/bs_key', Mage::app()->getStore()->getStoreId());
|
284 |
+
$msg_not_available = Mage::helper('brainsins_recommender')->__('No available recommenders in this page');
|
285 |
+
|
286 |
+
if (!$extension_enabled || $bskey == '')
|
287 |
+
return array('value' => '', 'label' => $msg_not_available);
|
288 |
+
|
289 |
+
$response = @file_get_contents(self::getApiUrl() . "recommender/retrieve.xml?token=" . $bskey);
|
290 |
+
|
291 |
+
if ($response !== false) {
|
292 |
+
$xmlData = simplexml_load_string($response);
|
293 |
+
$jsonData = json_decode(json_encode((array)$xmlData), true);
|
294 |
+
$recommenders[] = array('value' => '', 'label' => Mage::helper('brainsins_recommender')->__('--- Recommender name ---'));
|
295 |
+
foreach ($jsonData['recommenders']['recommender'] as $recommender) {
|
296 |
+
if ($recommender['page'] == $page)
|
297 |
+
$recommenders[] = array('value' => $recommender['id_recommender'], 'label' => $recommender['name']);
|
298 |
+
}
|
299 |
+
return $recommenders;
|
300 |
+
} else
|
301 |
+
$recommenders[0] = array('value' => '', 'label' => $msg_not_available);
|
302 |
+
|
303 |
+
return $recommenders;
|
304 |
+
}
|
305 |
+
|
306 |
+
public function getPositions($page)
|
307 |
+
{
|
308 |
+
$positions = array();
|
309 |
+
$positions[] = array('value' => '', 'label' => Mage::helper('brainsins_recommender')->__('--- Recommender position ---'));
|
310 |
+
|
311 |
+
switch ($page) {
|
312 |
+
case '1':
|
313 |
+
$positions[] = array('value' => 'after_body_start', 'label' => Mage::helper('brainsins_recommender')->__('Top'));
|
314 |
+
$positions[] = array('value' => 'header', 'label' => Mage::helper('brainsins_recommender')->__('Header'));
|
315 |
+
$positions[] = array('value' => 'content', 'label' => Mage::helper('brainsins_recommender')->__('Main content'));
|
316 |
+
$positions[] = array('value' => 'right', 'label' => Mage::helper('brainsins_recommender')->__('Right column'));
|
317 |
+
$positions[] = array('value' => 'left', 'label' => Mage::helper('brainsins_recommender')->__('Left column'));
|
318 |
+
$positions[] = array('value' => 'footer', 'label' => Mage::helper('brainsins_recommender')->__('Footer'));
|
319 |
+
$positions[] = array('value' => 'before_body_end', 'label' => Mage::helper('brainsins_recommender')->__('Bottom'));
|
320 |
+
$positions[] = array('value' => 'custom', 'label' => Mage::helper('brainsins_recommender')->__('Custom position'));
|
321 |
+
$positions[] = array('value' => '-', 'label' => Mage::helper('brainsins_recommender')->__('--- Other positions ---'));
|
322 |
+
$positions[] = array('value' => 'catalog.topnav', 'label' => Mage::helper('brainsins_recommender')->__('Navigation bar'));
|
323 |
+
$positions[] = array('value' => 'breadcrumbs', 'label' => Mage::helper('brainsins_recommender')->__('Breadcrumb'));
|
324 |
+
$positions[] = array('value' => 'cart_sidebar', 'label' => Mage::helper('brainsins_recommender')->__('Cart sidebar'));
|
325 |
+
$positions[] = array('value' => 'catalog.compare.sidebar', 'label' => Mage::helper('brainsins_recommender')->__('Product compare sidebar'));
|
326 |
+
$positions[] = array('value' => 'left.reports.product.viewed', 'label' => Mage::helper('brainsins_recommender')->__('Left column recently viewed'));
|
327 |
+
$positions[] = array('value' => 'right.reports.product.viewed', 'label' => Mage::helper('brainsins_recommender')->__('Right column recently viewed'));
|
328 |
+
break;
|
329 |
+
case '2':
|
330 |
+
$positions[] = array('value' => 'product.info', 'label' => Mage::helper('brainsins_recommender')->__('Main content'));
|
331 |
+
$positions[] = array('value' => 'right', 'label' => Mage::helper('brainsins_recommender')->__('Right column'));
|
332 |
+
$positions[] = array('value' => 'left', 'label' => Mage::helper('brainsins_recommender')->__('Left column'));
|
333 |
+
$positions[] = array('value' => 'description', 'label' => Mage::helper('brainsins_recommender')->__('Product description'));
|
334 |
+
$positions[] = array('value' => 'additional', 'label' => Mage::helper('brainsins_recommender')->__('Product attributes'));
|
335 |
+
$positions[] = array('value' => 'product_options', 'label' => Mage::helper('brainsins_recommender')->__('Product options'));
|
336 |
+
$positions[] = array('value' => 'prices', 'label' => Mage::helper('brainsins_recommender')->__('Product prices'));
|
337 |
+
$positions[] = array('value' => 'product_additional_data', 'label' => Mage::helper('brainsins_recommender')->__('Product additional information'));
|
338 |
+
$positions[] = array('value' => 'upsell_products', 'label' => Mage::helper('brainsins_recommender')->__('Upsell products'));
|
339 |
+
$positions[] = array('value' => 'custom', 'label' => Mage::helper('brainsins_recommender')->__('Custom position'));
|
340 |
+
$positions[] = array('value' => '-', 'label' => Mage::helper('brainsins_recommender')->__('------------- Other positions -------------'));
|
341 |
+
$positions[] = array('value' => 'catalog.product.related', 'label' => Mage::helper('brainsins_recommender')->__('Related products'));
|
342 |
+
$positions[] = array('value' => 'media', 'label' => Mage::helper('brainsins_recommender')->__('Product media gallery'));
|
343 |
+
$positions[] = array('value' => 'product_tag_list', 'label' => Mage::helper('brainsins_recommender')->__('Product tag list'));
|
344 |
+
$positions[] = array('value' => 'extrahint', 'label' => Mage::helper('brainsins_recommender')->__('Product extra hint'));
|
345 |
+
$positions[] = array('value' => 'product.info.addtocart', 'label' => Mage::helper('brainsins_recommender')->__('Product add to cart'));
|
346 |
+
$positions[] = array('value' => 'product.info.addto', 'label' => Mage::helper('brainsins_recommender')->__('Product other "add to" options'));
|
347 |
+
$positions[] = array('value' => 'cart_sidebar', 'label' => Mage::helper('brainsins_recommender')->__('Cart sidebar'));
|
348 |
+
$positions[] = array('value' => 'catalog.compare.sidebar', 'label' => Mage::helper('brainsins_recommender')->__('Product compare sidebar'));
|
349 |
+
$positions[] = array('value' => 'left.reports.product.viewed', 'label' => Mage::helper('brainsins_recommender')->__('Left column recently viewed'));
|
350 |
+
$positions[] = array('value' => 'right.reports.product.viewed', 'label' => Mage::helper('brainsins_recommender')->__('Right column recently viewed'));
|
351 |
+
$positions[] = array('value' => 'after_body_start', 'label' => Mage::helper('brainsins_recommender')->__('Top'));
|
352 |
+
$positions[] = array('value' => 'header', 'label' => Mage::helper('brainsins_recommender')->__('Header'));
|
353 |
+
$positions[] = array('value' => 'catalog.topnav', 'label' => Mage::helper('brainsins_recommender')->__('Navigation bar'));
|
354 |
+
$positions[] = array('value' => 'breadcrumbs', 'label' => Mage::helper('brainsins_recommender')->__('Breadcrumb'));
|
355 |
+
$positions[] = array('value' => 'footer', 'label' => Mage::helper('brainsins_recommender')->__('Footer'));
|
356 |
+
$positions[] = array('value' => 'before_body_end', 'label' => Mage::helper('brainsins_recommender')->__('Bottom'));
|
357 |
+
break;
|
358 |
+
case '3':
|
359 |
+
$positions[] = array('value' => 'content', 'label' => Mage::helper('brainsins_recommender')->__('Main content'));
|
360 |
+
$positions[] = array('value' => 'crosssell', 'label' => Mage::helper('brainsins_recommender')->__('Cross sell area'));
|
361 |
+
$positions[] = array('value' => 'totals', 'label' => Mage::helper('brainsins_recommender')->__('Totals area'));
|
362 |
+
$positions[] = array('value' => 'custom', 'label' => Mage::helper('brainsins_recommender')->__('Custom position'));
|
363 |
+
$positions[] = array('value' => '-', 'label' => Mage::helper('brainsins_recommender')->__('------------- Other positions -------------'));
|
364 |
+
$positions[] = array('value' => 'coupon', 'label' => Mage::helper('brainsins_recommender')->__('Discount code area'));
|
365 |
+
$positions[] = array('value' => 'shipping', 'label' => Mage::helper('brainsins_recommender')->__('Shipping estimation area'));
|
366 |
+
$positions[] = array('value' => 'after_body_start', 'label' => Mage::helper('brainsins_recommender')->__('Top'));
|
367 |
+
$positions[] = array('value' => 'header', 'label' => Mage::helper('brainsins_recommender')->__('Header'));
|
368 |
+
$positions[] = array('value' => 'catalog.topnav', 'label' => Mage::helper('brainsins_recommender')->__('Navigation bar'));
|
369 |
+
$positions[] = array('value' => 'breadcrumbs', 'label' => Mage::helper('brainsins_recommender')->__('Breadcrumb'));
|
370 |
+
$positions[] = array('value' => 'footer', 'label' => Mage::helper('brainsins_recommender')->__('Footer'));
|
371 |
+
$positions[] = array('value' => 'before_body_end', 'label' => Mage::helper('brainsins_recommender')->__('Bottom'));
|
372 |
+
break;
|
373 |
+
/*
|
374 |
+
case '4':
|
375 |
+
$positions[] = array('value' => 'content', 'label' => Mage::helper('brainsins_recommender')->__('Main content'));
|
376 |
+
$positions[] = array('value' => 'right', 'label' => Mage::helper('brainsins_recommender')->__('Right column'));
|
377 |
+
$positions[] = array('value' => 'left', 'label' => Mage::helper('brainsins_recommender')->__('Left column'));
|
378 |
+
$positions[] = array('value' => 'checkout.progress', 'label' => Mage::helper('brainsins_recommender')->__('Checkout progress'));
|
379 |
+
$positions[] = array('value' => 'login', 'label' => Mage::helper('brainsins_recommender')->__('Login'));
|
380 |
+
$positions[] = array('value' => 'billing', 'label' => Mage::helper('brainsins_recommender')->__('Billing information'));
|
381 |
+
$positions[] = array('value' => 'shipping', 'label' => Mage::helper('brainsins_recommender')->__('Shipping information'));
|
382 |
+
$positions[] = array('value' => 'shipping_method', 'label' => Mage::helper('brainsins_recommender')->__('Shipping method'));
|
383 |
+
$positions[] = array('value' => 'payment', 'label' => Mage::helper('brainsins_recommender')->__('Payment information'));
|
384 |
+
$positions[] = array('value' => 'review', 'label' => Mage::helper('brainsins_recommender')->__('Order review'));
|
385 |
+
$positions[] = array('value' => 'custom', 'label' => Mage::helper('brainsins_recommender')->__('Custom position'));
|
386 |
+
$positions[] = array('value' => '-', 'label' => Mage::helper('brainsins_recommender')->__('------------- Other positions -------------'));
|
387 |
+
$positions[] = array('value' => 'billing.progress', 'label' => Mage::helper('brainsins_recommender')->__('Billing progress'));
|
388 |
+
$positions[] = array('value' => 'shipping.progress', 'label' => Mage::helper('brainsins_recommender')->__('Shipping progress'));
|
389 |
+
$positions[] = array('value' => 'shipping_method.progress', 'label' => Mage::helper('brainsins_recommender')->__('Shipping method progress'));
|
390 |
+
$positions[] = array('value' => 'payment.progress', 'label' => Mage::helper('brainsins_recommender')->__('Payment progress'));
|
391 |
+
$positions[] = array('value' => 'after_body_start', 'label' => Mage::helper('brainsins_recommender')->__('Top'));
|
392 |
+
$positions[] = array('value' => 'header', 'label' => Mage::helper('brainsins_recommender')->__('Header'));
|
393 |
+
$positions[] = array('value' => 'catalog.topnav', 'label' => Mage::helper('brainsins_recommender')->__('Navigation bar'));
|
394 |
+
$positions[] = array('value' => 'breadcrumbs', 'label' => Mage::helper('brainsins_recommender')->__('Breadcrumb'));
|
395 |
+
$positions[] = array('value' => 'footer', 'label' => Mage::helper('brainsins_recommender')->__('Footer'));
|
396 |
+
$positions[] = array('value' => 'before_body_end', 'label' => Mage::helper('brainsins_recommender')->__('Bottom'));
|
397 |
+
break;
|
398 |
+
*/
|
399 |
+
case '4':
|
400 |
+
$positions[] = array('value' => 'content', 'label' => Mage::helper('brainsins_recommender')->__('Main content'));
|
401 |
+
$positions[] = array('value' => 'right', 'label' => Mage::helper('brainsins_recommender')->__('Right column'));
|
402 |
+
$positions[] = array('value' => 'left', 'label' => Mage::helper('brainsins_recommender')->__('Left column'));
|
403 |
+
$positions[] = array('value' => 'custom', 'label' => Mage::helper('brainsins_recommender')->__('Custom position'));
|
404 |
+
$positions[] = array('value' => '-', 'label' => Mage::helper('brainsins_recommender')->__('------------- Other positions -------------'));
|
405 |
+
$positions[] = array('value' => 'after_body_start', 'label' => Mage::helper('brainsins_recommender')->__('Top'));
|
406 |
+
$positions[] = array('value' => 'header', 'label' => Mage::helper('brainsins_recommender')->__('Header'));
|
407 |
+
$positions[] = array('value' => 'catalog.topnav', 'label' => Mage::helper('brainsins_recommender')->__('Navigation bar'));
|
408 |
+
$positions[] = array('value' => 'breadcrumbs', 'label' => Mage::helper('brainsins_recommender')->__('Breadcrumb'));
|
409 |
+
$positions[] = array('value' => 'footer', 'label' => Mage::helper('brainsins_recommender')->__('Footer'));
|
410 |
+
$positions[] = array('value' => 'before_body_end', 'label' => Mage::helper('brainsins_recommender')->__('Bottom'));
|
411 |
+
break;
|
412 |
+
case '7':
|
413 |
+
$positions[] = array('value' => 'after_body_start', 'label' => Mage::helper('brainsins_recommender')->__('Top'));
|
414 |
+
$positions[] = array('value' => 'header', 'label' => Mage::helper('brainsins_recommender')->__('Header'));
|
415 |
+
$positions[] = array('value' => 'content', 'label' => Mage::helper('brainsins_recommender')->__('Main content'));
|
416 |
+
$positions[] = array('value' => 'product_list', 'label' => Mage::helper('brainsins_recommender')->__('Product list'));
|
417 |
+
$positions[] = array('value' => 'right', 'label' => Mage::helper('brainsins_recommender')->__('Right column'));
|
418 |
+
$positions[] = array('value' => 'left', 'label' => Mage::helper('brainsins_recommender')->__('Left column'));
|
419 |
+
$positions[] = array('value' => 'footer', 'label' => Mage::helper('brainsins_recommender')->__('Footer'));
|
420 |
+
$positions[] = array('value' => 'before_body_end', 'label' => Mage::helper('brainsins_recommender')->__('Bottom'));
|
421 |
+
$positions[] = array('value' => 'custom', 'label' => Mage::helper('brainsins_recommender')->__('Custom position'));
|
422 |
+
$positions[] = array('value' => '-', 'label' => Mage::helper('brainsins_recommender')->__('------------- Other positions -------------'));
|
423 |
+
$positions[] = array('value' => 'catalog.topnav', 'label' => Mage::helper('brainsins_recommender')->__('Navigation bar'));
|
424 |
+
$positions[] = array('value' => 'breadcrumbs', 'label' => Mage::helper('brainsins_recommender')->__('Breadcrumb'));
|
425 |
+
$positions[] = array('value' => 'toolbar', 'label' => Mage::helper('brainsins_recommender')->__('Toolbar'));
|
426 |
+
break;
|
427 |
+
default:
|
428 |
+
$positions[] = array('value' => 'top', 'label' => Mage::helper('brainsins_recommender')->__('No available positions in this page'));
|
429 |
+
break;
|
430 |
+
}
|
431 |
+
return $positions;
|
432 |
+
}
|
433 |
+
|
434 |
+
public function getConfiguration($page, $store = null)
|
435 |
+
{
|
436 |
+
if ($store == null)
|
437 |
+
$store = Mage::app()->getStore()->getStoreId();
|
438 |
+
$jSonRecommendersConfig = '';
|
439 |
+
$config = array();
|
440 |
+
if ($page == 'all') {
|
441 |
+
$pages = explode(',', self::$_pages);
|
442 |
+
foreach ($pages as $key => $_page) {
|
443 |
+
$jSonRecommendersConfig = Mage::getStoreConfig('brainsins_recommender_options/brainsins_recommender_recommenders_' . $_page . '/recommenders_' . $_page, $store);
|
444 |
+
$arrayDatas = unserialize($jSonRecommendersConfig);
|
445 |
+
foreach ($arrayDatas as $key => $arrayData) {
|
446 |
+
foreach ($arrayData as $key => $data) {
|
447 |
+
$config[$key][] = $data;
|
448 |
+
}
|
449 |
+
}
|
450 |
+
}
|
451 |
+
} else {
|
452 |
+
$jSonRecommendersConfig = Mage::getStoreConfig('brainsins_recommender_options/brainsins_recommender_recommenders_' . $page . '/recommenders_' . $page, $store);
|
453 |
+
$arrayDatas = unserialize($jSonRecommendersConfig);
|
454 |
+
$config = array();
|
455 |
+
if ($arrayDatas) {
|
456 |
+
foreach ($arrayDatas as $key => $arrayData) {
|
457 |
+
foreach ($arrayData as $key => $data) {
|
458 |
+
$config[$key][] = $data;
|
459 |
+
}
|
460 |
+
}
|
461 |
+
}
|
462 |
+
}
|
463 |
+
|
464 |
+
return $this->_cleanEmpties($config);
|
465 |
+
}
|
466 |
+
|
467 |
+
public function getPageRecommenders($page)
|
468 |
+
{
|
469 |
+
$recommenders = $this->getConfiguration($page, Mage::app()->getStore()->getStoreId());
|
470 |
+
$result = Array();
|
471 |
+
|
472 |
+
if ($recommenders && count($recommenders) > 0) {
|
473 |
+
foreach ($recommenders as $key => $_value) {
|
474 |
+
if ($_value[0] == '' || !is_numeric($_value[0]))
|
475 |
+
continue;
|
476 |
+
|
477 |
+
if ($_value[4] != '') {
|
478 |
+
$_location = $_value[4];
|
479 |
+
$_position = $_value[3];
|
480 |
+
} else {
|
481 |
+
$_location = 'brainSINS_recommender_' . $_value[0];
|
482 |
+
$_position = 'replace';
|
483 |
+
}
|
484 |
+
$recommender = Array();
|
485 |
+
$recommender["recommenderId"] = $_value[0];
|
486 |
+
$recommender["location"] = $_location;
|
487 |
+
$recommender["position"] = $_position;
|
488 |
+
$recommender["detailsLevel"] = "high";
|
489 |
+
|
490 |
+
$result [] = $recommender;
|
491 |
+
}
|
492 |
+
}
|
493 |
+
|
494 |
+
return $result;
|
495 |
+
}
|
496 |
+
|
497 |
+
public function getRecommendersJs($recommenders)
|
498 |
+
{
|
499 |
+
$recommenders_js = '';
|
500 |
+
if ($recommenders && count($recommenders) > 0) {
|
501 |
+
$recommenders_js .= ',
|
502 |
recommenders: [';
|
503 |
+
foreach ($recommenders as $key => $_value) {
|
504 |
+
if ($_value[0] == '' || !is_numeric($_value[0]))
|
505 |
+
continue;
|
506 |
+
if ($_value[4] != '') {
|
507 |
+
$_location = $_value[4];
|
508 |
+
$_position = $_value[3];
|
509 |
+
} else {
|
510 |
+
$_location = 'brainSINS_recommender_' . $_value[0];
|
511 |
+
$_position = 'replace';
|
512 |
+
}
|
513 |
+
$recommenders_js .= "
|
|
|
|
|
|
|
514 |
{
|
515 |
+
recommenderId: " . $_value[0] . ",
|
516 |
detailsLevel : 'high',
|
517 |
+
location: '" . $_location . "',
|
518 |
+
position: '" . $_position . "'
|
519 |
},
|
520 |
";
|
521 |
+
}
|
522 |
+
$recommenders_js .= ']';
|
523 |
+
}
|
524 |
+
return $recommenders_js;
|
525 |
+
}
|
526 |
+
|
527 |
+
protected function _cleanEmpties($data)
|
528 |
+
{
|
529 |
+
$cleanedData = array();
|
530 |
+
foreach ($data as $key => $value) {
|
531 |
+
if ($value[0] == '')
|
532 |
+
continue;
|
533 |
+
else
|
534 |
+
$cleanedData[] = $value;
|
535 |
+
}
|
536 |
+
|
537 |
+
return array_map('unserialize', array_unique(array_map('serialize', $cleanedData)));
|
538 |
+
}
|
539 |
+
|
540 |
+
public function getProductsFeed($key = '')
|
541 |
+
{
|
542 |
+
return "";
|
543 |
+
}
|
544 |
+
|
545 |
+
public function updateCartInBrainsins($cart, $special = false)
|
546 |
+
{
|
547 |
+
if (!is_object($cart))
|
548 |
+
return;
|
549 |
+
|
550 |
+
$cartId = $cart->getId();
|
551 |
+
|
552 |
+
if (!$cartId) {
|
553 |
+
return;
|
554 |
+
}
|
555 |
+
|
556 |
+
$cartData = $this->processQuote($cart);
|
557 |
+
|
558 |
+
$ruta = "order/trackOrder.xml?";
|
559 |
+
$url = self::getApiUrl() . $ruta . "token=" . Mage::getStoreConfig('brainsins_recommender_options/brainsins_recommender_general/bs_key', Mage::app()->getStore()->getStoreId());
|
560 |
+
|
561 |
+
$cartXML = new DOMDocument('1.0', 'UTF-8');
|
562 |
+
$cartXML->xmlStandalone = true;
|
563 |
+
|
564 |
+
$pRecsins = $cartXML->createElement('recsins');
|
565 |
+
$pRecsins->setAttribute('version', '0.1');
|
566 |
+
$cartXML->appendChild($pRecsins);
|
567 |
+
|
568 |
+
$pOrders = $cartXML->createElement('orders');
|
569 |
+
|
570 |
+
$pOrder = $cartXML->createElement('order');
|
571 |
+
$pIdBuyer = $cartXML->createElement('idBuyer', $this->_getUser());
|
572 |
+
$pOrder->appendChild($pIdBuyer);
|
573 |
+
|
574 |
+
// $pLanguage =
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
575 |
|
576 |
+
//$pCurrency = $cartXML->createElement('idCurrency', Mage::app()->getStore()->getCurrentCurrencyCode());
|
577 |
+
//$pOrder->appendChild($pCurrency);
|
|
|
578 |
|
579 |
+
$pTotal = $cartXML->createElement('totalAmount', $cartData["totalAmount"]);
|
580 |
+
$pOrder->appendChild($pTotal);
|
|
|
|
|
|
|
581 |
|
582 |
+
$pOrders->appendChild($pOrder);
|
|
|
583 |
|
584 |
+
$pRecsins->appendChild($pOrders);
|
585 |
|
586 |
+
$pProducts = $cartXML->createElement('products');
|
587 |
+
$pOrder->appendChild($pProducts);
|
588 |
|
|
|
|
|
589 |
|
590 |
+
/*
|
591 |
+
if ($special)
|
592 |
+
$items = $cart->getAllVisibleItems();
|
593 |
+
else
|
594 |
+
$items = $cart->getItems();
|
595 |
+
|
596 |
+
$cartItems = Array();
|
597 |
+
|
598 |
+
foreach ($items as $item) {
|
599 |
|
600 |
$cartItem = Array();
|
601 |
|
602 |
$price = $item->getPriceInclTax();
|
603 |
|
604 |
+
if ($item->getParentItem()) {
|
605 |
+
$item = $item->getParentItem();
|
606 |
+
}
|
607 |
+
|
608 |
+
$id = $item->getProductId();
|
609 |
+
|
610 |
+
$qty = $item->getQty();
|
611 |
+
|
612 |
+
//get parent if exists -> ensure not single products that belong to configurable exist
|
613 |
+
$configurable_product_model = Mage::getModel('catalog/product_type_configurable');
|
614 |
+
$parentIdArray = $configurable_product_model->getParentIdsByChild($id);
|
615 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
616 |
// Mage::log("-----");
|
617 |
// Mage::log($item->getProductId());
|
618 |
// Mage::log("type : " . $item->getProductType());
|
627 |
|
628 |
$cartItems[] = $cartItem;
|
629 |
|
630 |
+
//if (array_key_exists($id, $cartItems)) {
|
631 |
// $cartItems[$id] = $cartItems[$id] + $qty;
|
632 |
+
//} else {
|
633 |
+
// $cartItems[$id] = $qty;
|
634 |
+
//}
|
635 |
+
}
|
636 |
+
|
637 |
+
//Mage::log($cartItems);
|
638 |
+
|
639 |
+
*/
|
640 |
|
641 |
+
$cartItems = $cartData["products"];
|
|
|
|
|
|
|
642 |
|
643 |
+
foreach ($cartItems as $cartItem) {
|
644 |
+
$pProduct = $cartXML->createElement('product');
|
645 |
|
646 |
+
$pIdProduct = $cartXML->createElement('idProduct', $cartItem["id"]);
|
647 |
+
$pProduct->appendChild($pIdProduct);
|
648 |
|
649 |
+
$pPrice = $cartXML->createElement('price', number_format($cartItem["price"], 2, '.', ''));
|
650 |
+
$pProduct->appendChild($pPrice);
|
651 |
|
652 |
+
$pDisplayPrice = $cartXML->createElement('displayPrice', $cartItem["displayPrice"]);
|
653 |
+
$pProduct->appendChild($pDisplayPrice);
|
|
|
654 |
|
655 |
+
$pParentId = null;
|
656 |
+
if ($cartItem["parentId"]) {
|
657 |
+
$pParentId = $cartXML->createElement('parentId', $cartItem["parentId"]);
|
658 |
+
} else {
|
659 |
+
$pParentId = $cartXML->createElement('parentId', '');
|
660 |
+
}
|
661 |
+
$pProduct->appendChild($pParentId);
|
662 |
|
663 |
+
$pQuantity = $cartXML->createElement('quantity', $cartItem["quantity"]);
|
664 |
+
$pProduct->appendChild($pQuantity);
|
665 |
|
666 |
+
$pProducts->appendChild($pProduct);
|
667 |
+
$cartId .= ":" . $cartItem["id"] . ":" . $cartItem["quantity"] . ":" . $cartItem["price"];
|
668 |
+
}
|
669 |
+
|
670 |
+
|
671 |
+
$lastTrackedCart = Mage::getSingleton('core/session')->getBrainsinsLastCartTracked();
|
672 |
// Mage::log($cartId);
|
673 |
+
if ($cartId == $lastTrackedCart) {
|
674 |
+
return;
|
675 |
+
} else {
|
676 |
+
Mage::getSingleton('core/session')->setBrainsinsLastCartTracked($cartId);
|
677 |
+
}
|
678 |
+
|
679 |
+
$content = $cartXML->saveXML($cartXML->documentElement);
|
680 |
+
//Mage::log($content);
|
681 |
+
$result = $this->_sendBrainsinsWS($url, $content);
|
682 |
// Mage::log($result);
|
683 |
+
return $result;
|
684 |
+
}
|
685 |
+
|
686 |
+
public function getTotalAmount(Mage_Sales_Model_Order $order) {
|
687 |
+
$taxConfig = Mage::getStoreConfig('brainsins_recommender_options/brainsins_recommender_advanced/tracking_tax', Mage::app()->getStore()->getStoreId());
|
688 |
+
$trackingAmountconfig = Mage::getStoreConfig('brainsins_recommender_options/brainsins_recommender_advanced/tracking_amount', Mage::app()->getStore()->getStoreId());
|
689 |
+
|
690 |
+
$idsMultipleArray = Mage::getSingleton('core/session')->getOrderIds(true);
|
691 |
+
$total = 0;
|
692 |
+
|
693 |
+
$quote = $order->getQuote();
|
694 |
+
if (!$quote) {
|
695 |
+
$quoteId = $order->getQuoteId();
|
696 |
+
$quote = Mage::getModel('sales/quote')->load($quoteId);
|
697 |
+
}
|
698 |
+
|
699 |
+
if ($trackingAmountconfig !== "1") {
|
700 |
+
if ($idsMultipleArray && is_array($idsMultipleArray)) {
|
701 |
+
foreach ($idsMultipleArray as $id) {
|
702 |
+
$order = Mage::getModel('sales/order')->loadByIncrementId($id);
|
703 |
+
|
704 |
+
if ($taxConfig == "1") {
|
705 |
+
//$total += $order->getBaseSubtotalInclTax();
|
706 |
+
} else {
|
707 |
+
//$total += $order->getBaseSubtotal();
|
708 |
+
}
|
709 |
+
|
710 |
+
|
711 |
+
if ($taxConfig == "1") {
|
712 |
+
$total += $this->toBaseCurrency($quote->getGrandTotal());
|
713 |
+
} else {
|
714 |
+
|
715 |
+
$totals = $quote->getTotals();
|
716 |
+
$tax = 0;
|
717 |
+
|
718 |
+
foreach ($totals as $total) {
|
719 |
+
|
720 |
+
$code = $total->getCode();
|
721 |
+
$value = $total->getValue();
|
722 |
+
|
723 |
+
if ($code == "tax") {
|
724 |
+
$tax = $value;
|
725 |
+
} else if ($code == "discount") {
|
726 |
+
$cart["discount"] = -$value;
|
727 |
+
}
|
728 |
+
}
|
729 |
+
|
730 |
+
$total += $this->toBaseCurrency($quote->getGrandTotal() - $tax);
|
731 |
+
}
|
732 |
+
}
|
733 |
+
} else {
|
734 |
+
if ($taxConfig == "1") {
|
735 |
+
$total = $order->getBaseSubtotalInclTax();
|
736 |
+
} else {
|
737 |
+
$total = $order->getBaseSubtotal();
|
738 |
+
}
|
739 |
+
|
740 |
+
if ($taxConfig == "1") {
|
741 |
+
$total = $this->toBaseCurrency($quote->getGrandTotal());
|
742 |
+
} else {
|
743 |
+
|
744 |
+
$tax = 0;
|
745 |
+
$totals = $quote->getTotals();
|
746 |
+
|
747 |
+
foreach ($totals as $total) {
|
748 |
+
|
749 |
+
$code = $total->getCode();
|
750 |
+
$value = $total->getValue();
|
751 |
+
|
752 |
+
if ($code == "tax") {
|
753 |
+
$tax = $value;
|
754 |
+
} else if ($code == "discount") {
|
755 |
+
$cart["discount"] = -$value;
|
756 |
+
}
|
757 |
+
}
|
758 |
+
|
759 |
+
$total = $this->toBaseCurrency($quote->getGrandTotal() - $tax);
|
760 |
+
}
|
761 |
+
}
|
762 |
+
}
|
763 |
+
|
764 |
+
return $total;
|
765 |
+
}
|
766 |
+
|
767 |
+
public function onEndCheckout(Mage_Sales_Model_Order $order)
|
768 |
+
{
|
769 |
+
$taxConfig = Mage::getStoreConfig('brainsins_recommender_options/brainsins_recommender_advanced/tracking_tax', Mage::app()->getStore()->getStoreId());
|
770 |
+
$trackingAmountconfig = Mage::getStoreConfig('brainsins_recommender_options/brainsins_recommender_advanced/tracking_amount', Mage::app()->getStore()->getStoreId());
|
771 |
+
|
772 |
+
$idsMultipleArray = Mage::getSingleton('core/session')->getOrderIds(true);
|
773 |
+
$firstElement = true;
|
774 |
+
$total = $this->getTotalAmount($order);
|
775 |
+
|
776 |
+
$ruta = "purchase/close?";
|
777 |
+
$url = self::getApiUrl() . $ruta . "token=" . Mage::getStoreConfig('brainsins_recommender_options/brainsins_recommender_general/bs_key', Mage::app()->getStore()->getStoreId());
|
778 |
+
|
779 |
+
$email = $order->getCustomerEmail();
|
780 |
+
|
781 |
+
$purchaseId = $order->getIncrementId();
|
782 |
+
|
783 |
+
$url .= "&email=$email&idPurchase=$purchaseId";
|
784 |
+
|
785 |
+
if ($total) {
|
786 |
+
$url .= "&amount=$total";
|
787 |
+
}
|
788 |
+
|
789 |
+
if (array_key_exists("bsCoId", $_COOKIE)) {
|
790 |
+
$coId = $_COOKIE['bsCoId'];
|
791 |
+
if ($coId) {
|
792 |
+
$url .= "&cookieId=$coId";
|
793 |
+
}
|
794 |
+
}
|
795 |
+
$result = $this->_sendBrainsinsWS($url);
|
796 |
+
|
797 |
+
return $result;
|
798 |
+
}
|
799 |
+
|
800 |
+
public function onPayment($order)
|
801 |
+
{
|
802 |
+
$idsMultipleArray = Mage::getSingleton('core/session')->getOrderIds(true);
|
803 |
+
$firstElement = true;
|
804 |
+
$total = $this->getTotalAmount($order);
|
805 |
+
|
806 |
+
$ruta = "purchase/payment.json?";
|
807 |
+
$url = self::getApiUrl() . $ruta . "token=" . Mage::getStoreConfig('brainsins_recommender_options/brainsins_recommender_general/bs_key', Mage::app()->getStore()->getStoreId());
|
808 |
+
|
809 |
+
$email = $order->getCustomerEmail();
|
810 |
+
$purchaseId = $order->getIncrementId();
|
811 |
+
$url .= "&email=$email&amount=$total&idPurchase=$purchaseId";
|
812 |
+
$result = $this->_sendBrainsinsWS($url);
|
813 |
+
return $result;
|
814 |
+
}
|
815 |
+
|
816 |
+
public function onOrderCancel($order) {
|
817 |
+
|
818 |
+
$id = $order->getIncrementId();
|
819 |
+
$ruta = "purchase/cancel.json?";
|
820 |
+
$url = self::getApiUrl() . $ruta . "token=" . Mage::getStoreConfig('brainsins_recommender_options/brainsins_recommender_general/bs_key', Mage::app()->getStore()->getStoreId());
|
821 |
+
$url .= "&idPurchase=" . $id;
|
822 |
+
$this->_sendBrainsinsWS($url, null, "application/json", true);
|
823 |
+
}
|
824 |
+
|
825 |
+
protected function _sendBrainsinsWS($url, $content = "", $contentType = "application/xml", $post = true)
|
826 |
+
{
|
827 |
+
|
828 |
+
if (function_exists('curl_init')) {
|
829 |
+
$ch = curl_init($url);
|
830 |
+
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
|
831 |
+
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
|
832 |
+
|
833 |
+
if ($post) {
|
834 |
+
curl_setopt($ch, CURLOPT_POST, 1);
|
835 |
+
}
|
836 |
+
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: ' . $contentType));
|
837 |
+
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
838 |
+
curl_setopt($ch, CURLOPT_POSTFIELDS, $content);
|
839 |
+
curl_setopt($ch, CURLOPT_VERBOSE, true);
|
840 |
+
curl_setopt($ch, CURLOPT_TIMEOUT_MS, 5000);
|
841 |
+
|
842 |
+
$response = curl_exec($ch);
|
843 |
+
curl_close($ch);
|
844 |
+
} else {
|
845 |
+
$opts = array('http' =>
|
846 |
+
array(
|
847 |
+
'method' => 'POST',
|
848 |
+
'header' => 'Content-type: text/xml',
|
849 |
+
'content' => $content
|
850 |
+
)
|
851 |
+
);
|
852 |
+
$context = stream_context_create($opts);
|
853 |
+
$response = file_get_contents($url, false, $context);
|
854 |
+
}
|
855 |
+
|
856 |
+
return $response;
|
857 |
+
}
|
858 |
+
|
859 |
+
protected function _getUser()
|
860 |
+
{
|
861 |
+
if (isset($_COOKIE['bsUl']) && $_COOKIE['bsUl'] == 1)
|
862 |
+
return $_COOKIE['bsUId'];
|
863 |
+
elseif (isset($_COOKIE['bsUl']) && $_COOKIE['bsUl'] == 0)
|
864 |
+
return $_COOKIE['bsCoId'];
|
865 |
+
else
|
866 |
+
return;
|
867 |
+
}
|
868 |
+
|
869 |
+
public function getStores($key)
|
870 |
+
{
|
871 |
+
$stores = Mage::app()->getStores();
|
872 |
+
$store_ids = array();
|
873 |
+
foreach ($stores as $k => $store) {
|
874 |
+
$_storeId = $store->getStoreId();
|
875 |
+
$bskey = Mage::getStoreConfig('brainsins_recommender_options/brainsins_recommender_general/bs_key', $_storeId);
|
876 |
+
if ($key == $bskey) {
|
877 |
+
//$store_ids[$_storeId] = Mage::getStoreConfig('general/locale/code', $_storeId);
|
878 |
+
$store_ids[$_storeId] = $store->getCode();
|
879 |
+
}
|
880 |
+
}
|
881 |
+
|
882 |
+
/*
|
883 |
+
$website = Mage::app()->getWebsite($website_id);
|
884 |
+
foreach ($website->getGroups() as $group)
|
885 |
+
{
|
886 |
+
$stores = $group->getStores();
|
887 |
+
foreach ($stores as $store)
|
888 |
+
{
|
889 |
+
if($store->getIsActive())
|
890 |
+
$store_ids[Mage::getStoreConfig('general/locale/code', $store->getId())] = $store->getId();
|
891 |
+
}
|
892 |
+
}
|
893 |
+
*/
|
894 |
+
return $store_ids;
|
895 |
+
}
|
896 |
+
|
897 |
+
protected function getCurrencies($key)
|
898 |
+
{
|
899 |
+
$stores = Mage::app()->getStores();
|
900 |
+
$currencies_ids = array();
|
901 |
+
foreach ($stores as $k => $store) {
|
902 |
+
$_storeId = $store->getStoreId();
|
903 |
+
$bskey = Mage::getStoreConfig('brainsins_recommender_options/brainsins_recommender_general/bs_key', $_storeId);
|
904 |
+
if ($key == $bskey) {
|
905 |
+
|
906 |
+
$currencies_ids[$_storeId] = Mage::app()->getStore($_storeId)->getCurrentCurrencyCode();
|
907 |
+
}
|
908 |
+
}
|
909 |
+
return $currencies_ids;
|
910 |
+
}
|
911 |
+
|
912 |
+
public function getBundlePrice($_product, $return_type, $tax)
|
913 |
+
{
|
914 |
+
return Mage::getModel('bundle/product_price')->getTotalPrices($_product, $return_type, $tax);
|
915 |
+
}
|
916 |
+
|
917 |
+
public function getProductImage($product, $width = false, $height = false)
|
918 |
+
{
|
919 |
+
$imageUrl = null;
|
920 |
+
$image_width = null;
|
921 |
+
$image_height = null;
|
922 |
+
|
923 |
+
if (!$width) {
|
924 |
+
$image_width = Mage::getStoreConfig('brainsins_recommender_options/brainsins_recommender_feed/product_image_resize_width', Mage::app()->getStore()->getStoreId());
|
925 |
+
} else {
|
926 |
+
$image_width = $width;
|
927 |
+
}
|
928 |
+
|
929 |
+
if (!$height) {
|
930 |
+
$image_height = Mage::getStoreConfig('brainsins_recommender_options/brainsins_recommender_feed/product_image_resize_height', Mage::app()->getStore()->getStoreId());
|
931 |
+
} else {
|
932 |
+
$image_height = $height;
|
933 |
+
}
|
934 |
+
|
935 |
+
if (!$image_width || $image_width == "" || $image_width == "0" || !is_numeric($image_width)) {
|
936 |
+
$image_width = null;
|
937 |
+
}
|
938 |
+
|
939 |
+
if (!$image_height || $image_height == "" || $image_height == "0" || !is_numeric($image_height)) {
|
940 |
+
$image_height = null;
|
941 |
+
}
|
942 |
+
|
943 |
+
|
944 |
+
if (!$image_width && !$image_height) {
|
945 |
+
$imageUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA) . 'catalog/product' . $product->getImage();
|
946 |
+
} else {
|
947 |
+
$imageUrl = (string)Mage::helper('catalog/image')->init($product, "image")->resize($image_width, $image_height);
|
948 |
+
}
|
949 |
+
|
950 |
+
return $imageUrl;
|
951 |
+
}
|
952 |
+
|
953 |
+
public function getExtensionVersion()
|
954 |
+
{
|
955 |
+
return (string) Mage::getConfig()->getNode()->modules->Brainsins_Recommender->version;
|
956 |
+
}
|
957 |
|
958 |
|
959 |
}
|
app/code/community/Brainsins/Recommender/Model/Adminhtml/System/Config/Source/Configurableproducttracking.php
ADDED
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* BrainSINS' Magento Extension allows to integrate the BrainSINS
|
4 |
+
* personalized product recommendations into a Magento Store.
|
5 |
+
* Copyright (c) 2014 Social Gaming Platform S.R.L.
|
6 |
+
*
|
7 |
+
* This file is part of BrainSINS' Magento Extension.
|
8 |
+
*
|
9 |
+
* BrainSINS' Magento Extension is free software: you can redistribute it
|
10 |
+
* and/or modify it under the terms of the GNU General Public License
|
11 |
+
* as published by the Free Software Foundation, either version 3 of the
|
12 |
+
* License, or (at your option) any later version.
|
13 |
+
*
|
14 |
+
* Foobar is distributed in the hope that it will be useful,
|
15 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
16 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
17 |
+
* GNU General Public License for more details.
|
18 |
+
*
|
19 |
+
* You should have received a copy of the GNU General Public License
|
20 |
+
* along with Foobar. If not, see <http://www.gnu.org/licenses/>.
|
21 |
+
*
|
22 |
+
* Please do not hesitate to contact us at info@brainsins.com
|
23 |
+
*/
|
24 |
+
|
25 |
+
class Brainsins_Recommender_Model_Adminhtml_System_Config_Source_Configurableproducttracking
|
26 |
+
{
|
27 |
+
public function toOptionArray()
|
28 |
+
{
|
29 |
+
return array(
|
30 |
+
array('value' => 0, 'label'=>Mage::helper('brainsins_recommender')->__('Track Simple Products')),
|
31 |
+
array('value' => 1, 'label'=>Mage::helper('brainsins_recommender')->__('Track Configurable Products'))
|
32 |
+
);
|
33 |
+
}
|
34 |
+
}
|
app/code/community/Brainsins/Recommender/Model/Adminhtml/System/Config/Source/Currencies.php
ADDED
@@ -0,0 +1,58 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* BrainSINS' Magento Extension allows to integrate the BrainSINS
|
4 |
+
* personalized product recommendations into a Magento Store.
|
5 |
+
* Copyright (c) 2014 Social Gaming Platform S.R.L.
|
6 |
+
*
|
7 |
+
* This file is part of BrainSINS' Magento Extension.
|
8 |
+
*
|
9 |
+
* BrainSINS' Magento Extension is free software: you can redistribute it
|
10 |
+
* and/or modify it under the terms of the GNU General Public License
|
11 |
+
* as published by the Free Software Foundation, either version 3 of the
|
12 |
+
* License, or (at your option) any later version.
|
13 |
+
*
|
14 |
+
* Foobar is distributed in the hope that it will be useful,
|
15 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
16 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
17 |
+
* GNU General Public License for more details.
|
18 |
+
*
|
19 |
+
* You should have received a copy of the GNU General Public License
|
20 |
+
* along with Foobar. If not, see <http://www.gnu.org/licenses/>.
|
21 |
+
*
|
22 |
+
* Please do not hesitate to contact us at info@brainsins.com
|
23 |
+
*/
|
24 |
+
|
25 |
+
class Brainsins_Recommender_Model_Adminhtml_System_Config_Source_Currencies
|
26 |
+
{
|
27 |
+
public function toOptionArray()
|
28 |
+
{
|
29 |
+
$currencies = Array();
|
30 |
+
$result = Array();
|
31 |
+
|
32 |
+
$default = Array();
|
33 |
+
$default["value"] = "";
|
34 |
+
$default["label"] = "use store's base currency";
|
35 |
+
$result[] = $default;
|
36 |
+
|
37 |
+
$stores = Mage::app()->getStore()->getCollection();
|
38 |
+
|
39 |
+
foreach ($stores as $store) {
|
40 |
+
|
41 |
+
$currencies[] = Array();
|
42 |
+
$codes = $store->getAvailableCurrencyCodes(true);
|
43 |
+
foreach ($codes as $code) {
|
44 |
+
if (!in_array($code, $currencies)) {
|
45 |
+
$currencies[] = $code;
|
46 |
+
$codeResult = Array();
|
47 |
+
$codeResult['value'] = $code;
|
48 |
+
$codeResult['label'] = $code;
|
49 |
+
$result[] = $codeResult;
|
50 |
+
}
|
51 |
+
}
|
52 |
+
}
|
53 |
+
|
54 |
+
|
55 |
+
|
56 |
+
return $result;
|
57 |
+
}
|
58 |
+
}
|
app/code/community/Brainsins/Recommender/Model/Adminhtml/System/Config/Source/Emailtracking.php
CHANGED
@@ -30,7 +30,7 @@ class Brainsins_Recommender_Model_Adminhtml_System_Config_Source_Emailtracking
|
|
30 |
array('value' => '', 'label'=>Mage::helper('brainsins_recommender')->__('-- Select --')),
|
31 |
array('value' => 0, 'label'=>Mage::helper('brainsins_recommender')->__('None')),
|
32 |
array('value' => 1, 'label'=>Mage::helper('brainsins_recommender')->__('Subscribed to Newsletter')),
|
33 |
-
array('value' => 2, 'label'=>Mage::helper('brainsins_recommender')->__('All'))
|
34 |
);
|
35 |
}
|
36 |
}
|
30 |
array('value' => '', 'label'=>Mage::helper('brainsins_recommender')->__('-- Select --')),
|
31 |
array('value' => 0, 'label'=>Mage::helper('brainsins_recommender')->__('None')),
|
32 |
array('value' => 1, 'label'=>Mage::helper('brainsins_recommender')->__('Subscribed to Newsletter')),
|
33 |
+
array('value' => 2, 'label'=>Mage::helper('brainsins_recommender')->__('All'))
|
34 |
);
|
35 |
}
|
36 |
}
|
app/code/community/Brainsins/Recommender/Model/Adminhtml/System/Config/Source/Totalamounttrackingoptions.php
ADDED
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* BrainSINS' Magento Extension allows to integrate the BrainSINS
|
4 |
+
* personalized product recommendations into a Magento Store.
|
5 |
+
* Copyright (c) 2014 Social Gaming Platform S.R.L.
|
6 |
+
*
|
7 |
+
* This file is part of BrainSINS' Magento Extension.
|
8 |
+
*
|
9 |
+
* BrainSINS' Magento Extension is free software: you can redistribute it
|
10 |
+
* and/or modify it under the terms of the GNU General Public License
|
11 |
+
* as published by the Free Software Foundation, either version 3 of the
|
12 |
+
* License, or (at your option) any later version.
|
13 |
+
*
|
14 |
+
* Foobar is distributed in the hope that it will be useful,
|
15 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
16 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
17 |
+
* GNU General Public License for more details.
|
18 |
+
*
|
19 |
+
* You should have received a copy of the GNU General Public License
|
20 |
+
* along with Foobar. If not, see <http://www.gnu.org/licenses/>.
|
21 |
+
*
|
22 |
+
* Please do not hesitate to contact us at info@brainsins.com
|
23 |
+
*/
|
24 |
+
|
25 |
+
class Brainsins_Recommender_Model_Adminhtml_System_Config_Source_Totalamounttrackingoptions
|
26 |
+
{
|
27 |
+
public function toOptionArray()
|
28 |
+
{
|
29 |
+
return array(
|
30 |
+
array('value' => 0, 'label'=>Mage::helper('brainsins_recommender')->__('Order Grand Total')),
|
31 |
+
array('value' => 1, 'label'=>Mage::helper('brainsins_recommender')->__('Shopping Cart Total'))
|
32 |
+
);
|
33 |
+
}
|
34 |
+
}
|
app/code/community/Brainsins/Recommender/Model/Observer.php
CHANGED
@@ -154,6 +154,15 @@ class Brainsins_Recommender_Model_Observer extends Mage_Core_Model_Abstract
|
|
154 |
}
|
155 |
}
|
156 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
157 |
protected function _isApiRequest()
|
158 |
{
|
159 |
return Mage::app()->getRequest()->getModuleName() === 'api';
|
154 |
}
|
155 |
}
|
156 |
|
157 |
+
public function onOrderCancel($observer) {
|
158 |
+
try {
|
159 |
+
if(!Mage::getStoreConfigFlag('brainsins_recommender_options/brainsins_recommender_general/enabled', Mage::app()->getStore()->getStoreId()) || $this->_isApiRequest())
|
160 |
+
return;
|
161 |
+
Mage::helper('brainsins_recommender')->onOrderCancel($observer->getEvent()->getOrder());
|
162 |
+
} catch (Exception $e) {
|
163 |
+
}
|
164 |
+
}
|
165 |
+
|
166 |
protected function _isApiRequest()
|
167 |
{
|
168 |
return Mage::app()->getRequest()->getModuleName() === 'api';
|
app/code/community/Brainsins/Recommender/controllers/.DS_Store
ADDED
Binary file
|
app/code/community/Brainsins/Recommender/controllers/FeedController.php
ADDED
@@ -0,0 +1,539 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* BrainSINS' Magento Extension allows to integrate the BrainSINS
|
4 |
+
* personalized product recommendations into a Magento Store.
|
5 |
+
* Copyright (c) 2014 Social Gaming Platform S.R.L.
|
6 |
+
*
|
7 |
+
* This file is part of BrainSINS' Magento Extension.
|
8 |
+
*
|
9 |
+
* BrainSINS' Magento Extension is free software: you can redistribute it
|
10 |
+
* and/or modify it under the terms of the GNU General Public License
|
11 |
+
* as published by the Free Software Foundation, either version 3 of the
|
12 |
+
* License, or (at your option) any later version.
|
13 |
+
*
|
14 |
+
* Foobar is distributed in the hope that it will be useful,
|
15 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
16 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
17 |
+
* GNU General Public License for more details.
|
18 |
+
*
|
19 |
+
* You should have received a copy of the GNU General Public License
|
20 |
+
* along with Foobar. If not, see <http://www.gnu.org/licenses/>.
|
21 |
+
*
|
22 |
+
* Please do not hesitate to contact us at info@brainsins.com
|
23 |
+
*/
|
24 |
+
//error_reporting(E_ALL);
|
25 |
+
//ini_set('display_errors', 1);
|
26 |
+
|
27 |
+
class Brainsins_Recommender_FeedController extends Mage_Core_Controller_Front_Action
|
28 |
+
{
|
29 |
+
|
30 |
+
private $_store;
|
31 |
+
|
32 |
+
private $_status;
|
33 |
+
private $_statusComparator;
|
34 |
+
private $_visibility;
|
35 |
+
private $_visibilityComparator;
|
36 |
+
|
37 |
+
private $_numPage;
|
38 |
+
private $_pageSize;
|
39 |
+
|
40 |
+
private $_oos;
|
41 |
+
private $_tax;
|
42 |
+
private $_width;
|
43 |
+
private $_height;
|
44 |
+
private $_special;
|
45 |
+
private $_debug;
|
46 |
+
private $_pretty;
|
47 |
+
|
48 |
+
private $_attrs;
|
49 |
+
private $_currencies;
|
50 |
+
private $_baseCurrency;
|
51 |
+
|
52 |
+
private function _loadParam($name, $csv = false)
|
53 |
+
{
|
54 |
+
|
55 |
+
$value = $this->getRequest()->getParam($name);
|
56 |
+
if ($value !== null && $csv) {
|
57 |
+
$value = preg_split("/,/", $value);
|
58 |
+
}
|
59 |
+
|
60 |
+
return $value;
|
61 |
+
}
|
62 |
+
|
63 |
+
private function _getConfigParam($store, $path, $provided)
|
64 |
+
{
|
65 |
+
if ($provided !== null) {
|
66 |
+
return $provided;
|
67 |
+
} else {
|
68 |
+
return Mage::getStoreConfig("brainsins_recommender_options/$path", $store);
|
69 |
+
}
|
70 |
+
}
|
71 |
+
|
72 |
+
public function configure()
|
73 |
+
{
|
74 |
+
$this->_store = $this->getRequest()->getParam('store');
|
75 |
+
$this->_status = $this->getRequest()->getParam('status', Mage_Catalog_Model_Product_Status::STATUS_ENABLED);
|
76 |
+
$this->_statusComparator = $this->getRequest()->getParam('statusComparator', 'gteq');
|
77 |
+
$this->_visibility = $this->getRequest()->getParam('visibility', Mage_Catalog_Model_Product_Visibility::VISIBILITY_NOT_VISIBLE);
|
78 |
+
$this->_visibilityComparator = $this->getRequest()->getParam('visibilityComparator', 'gteq');
|
79 |
+
|
80 |
+
$this->_numPage = $this->getRequest()->getParam('page');
|
81 |
+
$this->_pageSize = $this->getRequest()->getParam('size');
|
82 |
+
|
83 |
+
// config override
|
84 |
+
$oosParam = $this->getRequest()->getParam('oos');
|
85 |
+
$taxParam = $this->getRequest()->getParam('tax');
|
86 |
+
$widthParam = $this->getRequest()->getParam('img_width');
|
87 |
+
$heightParam = $this->getRequest()->getParam('img_height');
|
88 |
+
$specialParam = $this->getRequest()->getParam('special');
|
89 |
+
|
90 |
+
$this->_oos = $this->_getConfigParam($this->_store, "brainsins_recommender_feed/include_oos_products", $oosParam);
|
91 |
+
$this->_tax = $this->_getConfigParam($this->_store, "brainsins_recommender_feed/tax_included", $taxParam);
|
92 |
+
$this->_width = $this->_getConfigParam($this->_store, "brainsins_recommender_feed/product_image_resize_width", $widthParam);
|
93 |
+
$this->_height = $this->_getConfigParam($this->_store, "brainsins_recommender_feed/product_image_resize_height", $heightParam);
|
94 |
+
$this->_special = $this->_getConfigParam($this->_store, "brainsins_recommender_feed/special_price", $specialParam);
|
95 |
+
|
96 |
+
$attrParam = $this->getRequest()->getParam('attrs');
|
97 |
+
$extraAttrParam = $this->getRequest()->getParam('extraAttrs');
|
98 |
+
$currenciesParam = $this->getRequest()->getParam('currencies');
|
99 |
+
|
100 |
+
$this->_debug = $this->getRequest()->getParam('debug', false);
|
101 |
+
$this->_pretty = $this->getRequest()->getParam('pretty', false);
|
102 |
+
|
103 |
+
$this->_attrs = Array();
|
104 |
+
if ($attrParam !== null) {
|
105 |
+
$this->_attrs = preg_split("/,/", $attrParam);
|
106 |
+
} else {
|
107 |
+
$this->_attrs = Array("entity_id", "sku", "name", "image", "small_image", "price",
|
108 |
+
"special_price", "special_from_date", "special_to_date", "regular_price", "final_price", "tax_class_id", "is_in_stock", "is_salable",
|
109 |
+
"type_id",
|
110 |
+
"entity_type_id", "status", "url_key", "visibility", "url_path", "minimal_price", "min_price"
|
111 |
+
);
|
112 |
+
}
|
113 |
+
|
114 |
+
if ($extraAttrParam) {
|
115 |
+
$this->_attrs = array_merge($this->_attrs, preg_split("/,/", $extraAttrParam));
|
116 |
+
}
|
117 |
+
|
118 |
+
if ($this->_debug) {
|
119 |
+
$this->attrs = Array("*");
|
120 |
+
}
|
121 |
+
|
122 |
+
$this->_currencies = Array();
|
123 |
+
if ($currenciesParam) {
|
124 |
+
$this->_currencies = preg_split("/,/", $currenciesParam);
|
125 |
+
}
|
126 |
+
|
127 |
+
if ($this->_store) {
|
128 |
+
Mage::app()->setCurrentStore($this->_store);
|
129 |
+
}
|
130 |
+
|
131 |
+
$this->_baseCurrency = Mage::app()->getStore($this->_store)->getBaseCurrency()->getCode();
|
132 |
+
|
133 |
+
}
|
134 |
+
|
135 |
+
public function productCountAction()
|
136 |
+
{
|
137 |
+
$this->configure();
|
138 |
+
$result = Array();
|
139 |
+
|
140 |
+
$result ["count"] = Mage::getModel('catalog/product')
|
141 |
+
->getCollection()
|
142 |
+
->addAttributeToSelect('entity_id')
|
143 |
+
->addFieldToFilter('status', Array($this->_statusComparator => $this->_status))
|
144 |
+
->addFieldToFilter('visibility', Array($this->_visibilityComparator => $this->_visibility))
|
145 |
+
->getSize();
|
146 |
+
|
147 |
+
$output = json_encode($result);
|
148 |
+
$this->getResponse()->clearHeaders()->setHeader('Content-Type', 'application/json')->setBody($output);
|
149 |
+
}
|
150 |
+
|
151 |
+
public function productsAction()
|
152 |
+
{
|
153 |
+
$this->configure();
|
154 |
+
|
155 |
+
// load collection
|
156 |
+
$products = Mage::getModel('catalog/product')
|
157 |
+
->getCollection();
|
158 |
+
|
159 |
+
if ($this->_store) {
|
160 |
+
$products->setStore($this->_store);
|
161 |
+
}
|
162 |
+
|
163 |
+
foreach ($this->_attrs as $attr) {
|
164 |
+
$products->addAttributeToSelect($attr);
|
165 |
+
}
|
166 |
+
|
167 |
+
$products
|
168 |
+
->addFieldToFilter('status', Array($this->_statusComparator => $this->_status))
|
169 |
+
->addFieldToFilter('visibility', Array($this->_visibilityComparator => $this->_visibility))
|
170 |
+
->addAttributeToSort('entity_id', 'asc')
|
171 |
+
->setPage($this->_numPage, $this->_pageSize);
|
172 |
+
|
173 |
+
$result = Array();
|
174 |
+
foreach ($products as $product) {
|
175 |
+
$product_info = $this->_getProduct($product);
|
176 |
+
if ($product_info) {
|
177 |
+
$result [] = $product_info;
|
178 |
+
}
|
179 |
+
}
|
180 |
+
|
181 |
+
$outputOptions = 0;
|
182 |
+
if ($this->_pretty) {
|
183 |
+
$outputOptions = JSON_PRETTY_PRINT;
|
184 |
+
}
|
185 |
+
|
186 |
+
$output = json_encode($result, $outputOptions);
|
187 |
+
|
188 |
+
$this->getResponse()->clearHeaders()->setHeader('Content-Type', 'application/json')->setBody($output);
|
189 |
+
}
|
190 |
+
|
191 |
+
public function productAction()
|
192 |
+
{
|
193 |
+
$this->configure();
|
194 |
+
|
195 |
+
$id = $this->getRequest()->getParam('id');
|
196 |
+
|
197 |
+
$product = Mage::getModel("catalog/product")->load($id);
|
198 |
+
|
199 |
+
$result[$id] = $this->_getProduct($product);
|
200 |
+
$output = json_encode($result);
|
201 |
+
$this->getResponse()->clearHeaders()->setHeader('Content-Type', 'application/json')->setBody($output);
|
202 |
+
}
|
203 |
+
|
204 |
+
public function currenciesAction()
|
205 |
+
{
|
206 |
+
|
207 |
+
$stores = Mage::app()->getStore()->getCollection();
|
208 |
+
$result = Array();
|
209 |
+
foreach ($stores as $store) {
|
210 |
+
$code = $store->getCode();
|
211 |
+
$id = $store->getId();
|
212 |
+
$result[$id] = Array();
|
213 |
+
$currencies = $store->getAvailableCurrencyCodes(true);
|
214 |
+
foreach ($currencies as $currency) {
|
215 |
+
$result[$id][] = $currency;
|
216 |
+
}
|
217 |
+
}
|
218 |
+
|
219 |
+
$output = json_encode($result);
|
220 |
+
$this->getResponse()->clearHeaders()->setHeader('Content-Type', 'application/json')->setBody($output);
|
221 |
+
}
|
222 |
+
|
223 |
+
public function attributesAction()
|
224 |
+
{
|
225 |
+
$ids = Mage::getResourceModel('eav/entity_attribute_collection')->getAllIds();
|
226 |
+
|
227 |
+
$attributes = Array();
|
228 |
+
|
229 |
+
foreach ($ids as $id) {
|
230 |
+
$attributeInfo = Mage::getModel('catalog/resource_eav_attribute')->load($id);
|
231 |
+
$options = $attributeInfo->getSource()->getAllOptions(false);
|
232 |
+
$attribute = Array();
|
233 |
+
$attribute['id'] = $id;
|
234 |
+
$attribute['label'] = $attributeInfo->getData("attribute_code");
|
235 |
+
$attribute['options'] = $options;
|
236 |
+
$attributes[] = $attribute;
|
237 |
+
}
|
238 |
+
|
239 |
+
$output = json_encode($attributes);
|
240 |
+
$this->getResponse()->clearHeaders()->setHeader('Content-Type', 'application/json')->setBody($output);
|
241 |
+
}
|
242 |
+
|
243 |
+
public function attributeAction()
|
244 |
+
{
|
245 |
+
$id = $this->getRequest()->getParam('id');
|
246 |
+
$name = $this->getRequest()->getParam('name');
|
247 |
+
|
248 |
+
$attributeInfo = null;
|
249 |
+
|
250 |
+
if ($name != null && $name != "") {
|
251 |
+
$attributeInfo = Mage::getResourceModel('eav/entity_attribute_collection')->setCodeFilter($name)->getFirstItem();
|
252 |
+
$id = $attributeInfo->getAttributeId();
|
253 |
+
} else {
|
254 |
+
$attributeInfo = Mage::getResourceModel('eav/entity_attribute_collection')->getItemById($id);
|
255 |
+
}
|
256 |
+
|
257 |
+
// $attributeInfo = Mage::getResourceModel('eav/entity_attribute_collection')->getItemById($id);
|
258 |
+
|
259 |
+
$options = $this->_getAttributeOptions($id);
|
260 |
+
$attribute = Array();
|
261 |
+
$attribute['id'] = $id;
|
262 |
+
$attribute['label'] = $attributeInfo->getData("attribute_code");
|
263 |
+
$attribute['options'] = $options;
|
264 |
+
$attributes[] = $attribute;
|
265 |
+
|
266 |
+
$output = json_encode($attributes);
|
267 |
+
$this->getResponse()->clearHeaders()->setHeader('Content-Type', 'application/json')->setBody($output);
|
268 |
+
|
269 |
+
}
|
270 |
+
|
271 |
+
public function storesAction()
|
272 |
+
{
|
273 |
+
$result = $this->_getStoreList();
|
274 |
+
|
275 |
+
$output = json_encode($result);
|
276 |
+
$this->getResponse()->clearHeaders()->setHeader('Content-Type', 'application/json')->setBody($output);
|
277 |
+
}
|
278 |
+
|
279 |
+
public function categoriesAction()
|
280 |
+
{
|
281 |
+
$result = array();
|
282 |
+
$allCats = Mage::getModel('catalog/category')->getCollection();
|
283 |
+
$storeList = $this->_getStoreList();
|
284 |
+
foreach ($allCats as $category) {
|
285 |
+
$category->load($category->getId());
|
286 |
+
$catInfo = Array();
|
287 |
+
|
288 |
+
$catInfo ["id"] = $category->getId();
|
289 |
+
|
290 |
+
$catInfo ["parent_id"] = $category->getParentId();
|
291 |
+
|
292 |
+
$catInfo ["names"] = Array();
|
293 |
+
|
294 |
+
foreach ($category->getStoreIds() as $storeId) {
|
295 |
+
if (!$storeId) {
|
296 |
+
continue;
|
297 |
+
}
|
298 |
+
$storeCat = Mage::getModel('catalog/category')->setStore($storeId)->load($category->getId());
|
299 |
+
$storeCode = $storeList [$storeId];
|
300 |
+
$catInfo ["names"] [$storeCode] = $storeCat->getName();
|
301 |
+
}
|
302 |
+
|
303 |
+
$result [$category->getId()] = $catInfo;
|
304 |
+
}
|
305 |
+
$output = json_encode($result);
|
306 |
+
$this->getResponse()->clearHeaders()->setHeader('Content-Type', 'application/json')->setBody($output);
|
307 |
+
}
|
308 |
+
|
309 |
+
public function configAction() {
|
310 |
+
$result = Array();
|
311 |
+
$idAttr = Mage::getStoreConfig('brainsins_recommender_options/brainsins_recommender_advanced/product_id_field', Mage::app()->getStore()->getStoreId());
|
312 |
+
|
313 |
+
$result["idAttr"] = $idAttr;
|
314 |
+
|
315 |
+
$output = json_encode($result);
|
316 |
+
$this->getResponse()->clearHeaders()->setHeader('Content-Type', 'application/json')->setBody($output);
|
317 |
+
}
|
318 |
+
|
319 |
+
|
320 |
+
private function _getStoreList()
|
321 |
+
{
|
322 |
+
$stores = Mage::app()->getStore()->getCollection();
|
323 |
+
$result = array();
|
324 |
+
foreach ($stores as $store) {
|
325 |
+
$result [$store->getId()] = $store->getCode();
|
326 |
+
}
|
327 |
+
return $result;
|
328 |
+
}
|
329 |
+
|
330 |
+
private function _loadProductBasics($product, &$result)
|
331 |
+
{
|
332 |
+
$stock = Mage::getModel('cataloginventory/stock_item')->loadByProduct($product)->getIsInStock();
|
333 |
+
$url = preg_replace("/[\?&]?SID=[^\?&]*/", "", $product->getProductUrl());
|
334 |
+
//$product->
|
335 |
+
$imageUrl = Mage::helper('brainsins_recommender')->getProductImage($product, $this->_width, $this->_height);
|
336 |
+
|
337 |
+
$result["bs_stock"] = $stock;
|
338 |
+
$result["bs_url"] = $url;
|
339 |
+
$result["bs_image_url"] = $imageUrl;
|
340 |
+
|
341 |
+
$result["bs_categories"] = $product->getCategoryIds();
|
342 |
+
|
343 |
+
$configurable_product_model = Mage::getModel('catalog/product_type_configurable');
|
344 |
+
$parentIdArray = $configurable_product_model->getParentIdsByChild($product->getId());
|
345 |
+
$parentId = "";
|
346 |
+
if (count($parentIdArray) > 0) {
|
347 |
+
$parentId = $parentIdArray[0];
|
348 |
+
}
|
349 |
+
|
350 |
+
$result["bs_parent_id"] = $parentId;
|
351 |
+
}
|
352 |
+
|
353 |
+
private function _loadProductDebug($product, &$result)
|
354 |
+
{
|
355 |
+
foreach ($product->getAttributes() as $attribute) {
|
356 |
+
$attributeCode = $attribute->getAttributeCode();
|
357 |
+
$info [$attributeCode] = $product->getData($attributeCode);
|
358 |
+
$result ["debug"] = $info;
|
359 |
+
}
|
360 |
+
}
|
361 |
+
|
362 |
+
private function _loadProductPrices($product, &$result)
|
363 |
+
{
|
364 |
+
$finalPrice = $product->getFinalPrice();
|
365 |
+
|
366 |
+
|
367 |
+
$result["bs_final_price"] = $finalPrice;
|
368 |
+
$result["bs_final_price_converted"] = $this->_priceForTracking($product, $finalPrice);
|
369 |
+
$result["bs_price"] = $product->getPrice();
|
370 |
+
$result["bs_price_converted"] = $this->_priceForTracking($product, $product->getPrice());
|
371 |
+
$result["bs_price_computed"] = $this->_getProductPrice($product);
|
372 |
+
$result["bs_price_computed_converted"] = $this->_toBaseCurrency($result["bs_price_computed"]);
|
373 |
+
$result["bs_price_tax"] = $this->_priceForTracking($product, $this->_getProductPrice($product));
|
374 |
+
|
375 |
+
$result["prices"] = Array();
|
376 |
+
|
377 |
+
foreach ($this->_currencies as $curr) {
|
378 |
+
|
379 |
+
try {
|
380 |
+
$targetCurrency = $curr;
|
381 |
+
|
382 |
+
if ($this->_baseCurrency == $targetCurrency) {
|
383 |
+
$result ["prices"] [$targetCurrency] = $finalPrice;
|
384 |
+
continue;
|
385 |
+
}
|
386 |
+
|
387 |
+
$price_converted = number_format(Mage::helper('directory')
|
388 |
+
->currencyConvert($finalPrice, $this->_baseCurrency, $targetCurrency), 2, '.', '');
|
389 |
+
$result ["prices"] [$curr] = $price_converted;
|
390 |
+
} catch (Exception $e) {
|
391 |
+
}
|
392 |
+
}
|
393 |
+
}
|
394 |
+
|
395 |
+
private function _getProduct($product)
|
396 |
+
{
|
397 |
+
$result = Array();
|
398 |
+
|
399 |
+
if ($this->_debug) {
|
400 |
+
$this->_loadProductDebug($product, $result);
|
401 |
+
}
|
402 |
+
|
403 |
+
if ($this->_attrs) {
|
404 |
+
foreach ($this->_attrs as $attr) {
|
405 |
+
$result[$attr] = $product->getData($attr);
|
406 |
+
}
|
407 |
+
}
|
408 |
+
|
409 |
+
$this->_loadProductBasics($product, $result);
|
410 |
+
$this->_loadProductPrices($product, $result);
|
411 |
+
|
412 |
+
return $result;
|
413 |
+
}
|
414 |
+
|
415 |
+
private function _getProductPrice($product)
|
416 |
+
{
|
417 |
+
$product_price = 0.0;
|
418 |
+
|
419 |
+
if ($this->_tax == '1' && $this->_special == '1') {
|
420 |
+
$product_price = Mage::helper('tax')->getPrice($product, $product->getFinalPrice(), true, null, null, null, null, false);
|
421 |
+
} elseif ($this->_tax == '1' && $this->_special == '0') {
|
422 |
+
$product_price = Mage::helper('tax')->getPrice($product, $product->getPrice(), true, null, null, null, null, false);
|
423 |
+
}
|
424 |
+
|
425 |
+
if ($this->_tax == '0' && $this->_special == '1') {
|
426 |
+
$product_price = Mage::helper('tax')->getPrice($product, $product->getFinalPrice(), true, null, null, null, null, true);
|
427 |
+
} elseif ($this->_tax == '0' && $this->_special == '0') {
|
428 |
+
$product_price = Mage::helper('tax')->getPrice($product, $product->getPrice(), true, null, null, null, null, true);
|
429 |
+
}
|
430 |
+
|
431 |
+
if ($product->getTypeId() == Mage_Catalog_Model_Product_Type::TYPE_BUNDLE) {
|
432 |
+
if ($this->_tax == '1' && $this->_special == '1') {
|
433 |
+
$product_price = Mage::helper('tax')->getPrice($product, Mage::helper('brainsins_recommender')
|
434 |
+
->getBundlePrice($product, 'min', 1), true, null, null, null, null, false);
|
435 |
+
} elseif ($this->_tax == '1' && $this->_special == '0') {
|
436 |
+
$product_price = Mage::helper('tax')->getPrice($product, Mage::helper('brainsins_recommender')
|
437 |
+
->getBundlePrice($product, 'min', 1), true, null, null, null, null, false);
|
438 |
+
}
|
439 |
+
if ($this->_tax == '0' && $this->_special == '1') {
|
440 |
+
$product_price = Mage::helper('tax')->getPrice($product, Mage::helper('brainsins_recommender')
|
441 |
+
->getBundlePrice($product, 'min', 0), true, null, null, null, null, true);
|
442 |
+
} elseif ($this->_tax == '0' && $this->_special == '0') {
|
443 |
+
$product_price = Mage::helper('tax')->getPrice($product, Mage::helper('brainsins_recommender')
|
444 |
+
->getBundlePrice($product, 'min', 0), true, null, null, null, null, true);
|
445 |
+
}
|
446 |
+
}
|
447 |
+
|
448 |
+
if ($product->getTypeId() == Mage_Catalog_Model_Product_Type::TYPE_BUNDLE) {
|
449 |
+
$product_final_price = Mage::helper('brainsins_recommender')->getBundlePrice($product, 'min', 1);
|
450 |
+
$product_regular_price = Mage::helper('brainsins_recommender')->getBundlePrice($product, 'min', 1);
|
451 |
+
} else {
|
452 |
+
$product_final_price = $product->getFinalPrice();
|
453 |
+
$product_regular_price = $product->getPrice();
|
454 |
+
}
|
455 |
+
|
456 |
+
return number_format($product_price, 2, '.', '');
|
457 |
+
}
|
458 |
+
|
459 |
+
private function _getAttributeOptions($id)
|
460 |
+
{
|
461 |
+
$attribute = Mage::getModel('catalog/resource_eav_attribute')->load($id);
|
462 |
+
$attributeOptions = $attribute->getSource()->getAllOptions(false);
|
463 |
+
return $attributeOptions;
|
464 |
+
}
|
465 |
+
|
466 |
+
private function _getAttributeInfo($id)
|
467 |
+
{
|
468 |
+
|
469 |
+
}
|
470 |
+
|
471 |
+
private function _toBaseCurrency($price)
|
472 |
+
{
|
473 |
+
/*
|
474 |
+
$currentCurrencyCode = Mage::app()->getStore()->getCurrentCurrencyCode();
|
475 |
+
$baseCurrencyCode = Mage::getStoreConfig('brainsins_recommender_options/brainsins_recommender_general/base_currency', Mage::app()->getStore()->getStoreId());
|
476 |
+
|
477 |
+
if ($baseCurrencyCode == "") {
|
478 |
+
$baseCurrencyCode = Mage::app()->getStore()->getBaseCurrencyCode();
|
479 |
+
}
|
480 |
+
|
481 |
+
if ($baseCurrencyCode == $currentCurrencyCode) {
|
482 |
+
return $price;
|
483 |
+
} else {
|
484 |
+
return number_format(Mage::helper('directory')
|
485 |
+
->currencyConvert($price, $currentCurrencyCode, $baseCurrencyCode), 2, '.', '');
|
486 |
+
}
|
487 |
+
*/
|
488 |
+
|
489 |
+
$currentCurrencyCode = null;
|
490 |
+
|
491 |
+
$currentCurrencyCode = Mage::app()->getStore()->getBaseCurrencyCode();
|
492 |
+
|
493 |
+
$baseCurrencyCode = Mage::getStoreConfig('brainsins_recommender_options/brainsins_recommender_general/base_currency', Mage::app()->getStore()->getStoreId());
|
494 |
+
|
495 |
+
if ($baseCurrencyCode == "") {
|
496 |
+
$baseCurrencyCode = Mage::app()->getStore()->getBaseCurrencyCode();
|
497 |
+
}
|
498 |
+
|
499 |
+
if ($baseCurrencyCode == $currentCurrencyCode) {
|
500 |
+
return $price;
|
501 |
+
} else {
|
502 |
+
|
503 |
+
$allowedCurrencies = Mage::getModel('directory/currency')->getConfigAllowCurrencies();
|
504 |
+
if (in_array($baseCurrencyCode, $allowedCurrencies)) {
|
505 |
+
$rates1 = Mage::getModel('directory/currency')->getCurrencyRates($baseCurrencyCode, array_values($allowedCurrencies));
|
506 |
+
$rates2 = Mage::getModel('directory/currency')->getCurrencyRates($currentCurrencyCode, array_values($allowedCurrencies));
|
507 |
+
|
508 |
+
if (array_key_exists($baseCurrencyCode, $rates1)) {
|
509 |
+
return round($price / $rates1[$currentCurrencyCode], 2);
|
510 |
+
} else if (array_key_exists($baseCurrencyCode, $rates2)) {
|
511 |
+
return round($price * $rates2[$currentCurrencyCode], 2);
|
512 |
+
} else {
|
513 |
+
return $price;
|
514 |
+
}
|
515 |
+
|
516 |
+
} else {
|
517 |
+
return $price;
|
518 |
+
}
|
519 |
+
//return number_format(Mage::helper('directory')
|
520 |
+
//->currencyConvert($price, $currentCurrencyCode, $baseCurrencyCode), 2, '.', '');
|
521 |
+
|
522 |
+
}
|
523 |
+
}
|
524 |
+
|
525 |
+
private function _configuredTaxPrice($product, $price)
|
526 |
+
{
|
527 |
+
$config = Mage::getStoreConfig('brainsins_recommender_options/brainsins_recommender_advanced/tracking_tax', Mage::app()->getStore()->getStoreId());
|
528 |
+
if ($config == "1") {
|
529 |
+
return Mage::helper('tax')->getPrice($product, $price, true);
|
530 |
+
} else {
|
531 |
+
return Mage::helper('tax')->getPrice($product, $price, false);
|
532 |
+
}
|
533 |
+
}
|
534 |
+
|
535 |
+
private function _priceForTracking($product, $price)
|
536 |
+
{
|
537 |
+
return $this->_toBaseCurrency($this->_configuredTaxPrice($product, $price));
|
538 |
+
}
|
539 |
+
}
|
app/code/community/Brainsins/Recommender/controllers/FeedsController.php
DELETED
@@ -1,390 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* BrainSINS' Magento Extension allows to integrate the BrainSINS
|
4 |
-
* personalized product recommendations into a Magento Store.
|
5 |
-
* Copyright (c) 2014 Social Gaming Platform S.R.L.
|
6 |
-
*
|
7 |
-
* This file is part of BrainSINS' Magento Extension.
|
8 |
-
*
|
9 |
-
* BrainSINS' Magento Extension is free software: you can redistribute it
|
10 |
-
* and/or modify it under the terms of the GNU General Public License
|
11 |
-
* as published by the Free Software Foundation, either version 3 of the
|
12 |
-
* License, or (at your option) any later version.
|
13 |
-
*
|
14 |
-
* Foobar is distributed in the hope that it will be useful,
|
15 |
-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
16 |
-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
17 |
-
* GNU General Public License for more details.
|
18 |
-
*
|
19 |
-
* You should have received a copy of the GNU General Public License
|
20 |
-
* along with Foobar. If not, see <http://www.gnu.org/licenses/>.
|
21 |
-
*
|
22 |
-
* Please do not hesitate to contact us at info@brainsins.com
|
23 |
-
*/
|
24 |
-
error_reporting(E_ALL);
|
25 |
-
ini_set('display_errors', 1);
|
26 |
-
|
27 |
-
class Brainsins_Recommender_FeedsController extends Mage_Core_Controller_Front_Action
|
28 |
-
{
|
29 |
-
public function productsAction()
|
30 |
-
{
|
31 |
-
$key_param = $this->getRequest()->getParam('key');
|
32 |
-
if (!$key_param || !isset ($key_param)) {
|
33 |
-
echo '[INVALID PARAMETERS]';
|
34 |
-
die ();
|
35 |
-
}
|
36 |
-
$feed = Mage::helper('brainsins_recommender')->getProductsFeed($key_param);
|
37 |
-
$this->getResponse()->clearHeaders()->setHeader('Content-Type', 'application/xml')->setBody($feed);
|
38 |
-
}
|
39 |
-
|
40 |
-
public function productCountAction()
|
41 |
-
{
|
42 |
-
$result = Array();
|
43 |
-
$result ["count"] = Mage::getModel('catalog/product')->getCollection()->addAttributeToSelect('entity_id')->addFieldToFilter('status', Mage_Catalog_Model_Product_Status::STATUS_ENABLED)->addFieldToFilter('visibility', Mage_Catalog_Model_Product_Visibility::VISIBILITY_BOTH)->getSize();
|
44 |
-
$output = json_encode($result);
|
45 |
-
$this->getResponse()->clearHeaders()->setHeader('Content-Type', 'application/json')->setBody($output);
|
46 |
-
}
|
47 |
-
|
48 |
-
public function productListAction()
|
49 |
-
{
|
50 |
-
$numPage = $this->getRequest()->getParam('numPage');
|
51 |
-
$pageSize = $this->getRequest()->getParam('pageSize');
|
52 |
-
$debug = $this->getRequest()->getParam('debug');
|
53 |
-
$oosParam = $this->getRequest()->getParam('oos');
|
54 |
-
$width = $this->getRequest()->getParam('img_width');
|
55 |
-
$height = $this->getRequest()->getParam('img_height');
|
56 |
-
|
57 |
-
$products = Mage::getModel('catalog/product')->getCollection()->addAttributeToSelect('entity_id')->addFieldToFilter('status', Mage_Catalog_Model_Product_Status::STATUS_ENABLED)->addFieldToFilter('visibility', Mage_Catalog_Model_Product_Visibility::VISIBILITY_BOTH)->addAttributeToSort('entity_id', 'asc')->setPage($numPage, $pageSize);
|
58 |
-
|
59 |
-
$include_oos_products = false;
|
60 |
-
|
61 |
-
if ($oosParam === null) {
|
62 |
-
$include_oos_products = true && Mage::getStoreConfig('brainsins_recommender_options/product_feed/include_oos_products', Mage::app()->getStore()->getStoreId());
|
63 |
-
} else {
|
64 |
-
$include_oos_products = $oosParam && true;
|
65 |
-
}
|
66 |
-
|
67 |
-
$result = Array();
|
68 |
-
foreach ($products as $product) {
|
69 |
-
$id = $product->getId();
|
70 |
-
$product_info = $this->_getProduct($id, $debug, $include_oos_products, $width, $height);
|
71 |
-
if ($product_info) {
|
72 |
-
$result [] = $product_info;
|
73 |
-
}
|
74 |
-
}
|
75 |
-
|
76 |
-
$output = json_encode($result);
|
77 |
-
$this->getResponse()->clearHeaders()->setHeader('Content-Type', 'application/json')->setBody($output);
|
78 |
-
}
|
79 |
-
|
80 |
-
private function _getProduct($productId, $debug = false, $include_oos_products = false, $width = false, $height = false)
|
81 |
-
{
|
82 |
-
$tax_included = Mage::getStoreConfig('brainsins_recommender_options/product_feed/tax_included', Mage::app()->getStore()->getStoreId());
|
83 |
-
$special_price = Mage::getStoreConfig('brainsins_recommender_options/product_feed/special_price', Mage::app()->getStore()->getStoreId());
|
84 |
-
|
85 |
-
$storeList = $this->_getStoreList();
|
86 |
-
$currencies = $this->_getCurrencyCodes();
|
87 |
-
$product = Mage::getModel('catalog/product');
|
88 |
-
$product->load($productId);
|
89 |
-
|
90 |
-
$stock = Mage::getModel('cataloginventory/stock_item')->loadByProduct($product)->getIsInStock();
|
91 |
-
|
92 |
-
// check product stock
|
93 |
-
if (!$include_oos_products && !$stock) {
|
94 |
-
return null;
|
95 |
-
}
|
96 |
-
|
97 |
-
$result = Array();
|
98 |
-
|
99 |
-
// just to have id as first field
|
100 |
-
$result ["id"] = "";
|
101 |
-
|
102 |
-
$result ["stock"] = $stock ? "1" : "0";
|
103 |
-
|
104 |
-
// define multiproperties
|
105 |
-
$result ["names"] = Array();
|
106 |
-
$result ["urls"] = Array();
|
107 |
-
$result ["prices"] = Array();
|
108 |
-
|
109 |
-
foreach ($product->getStoreIds() as $storeId) {
|
110 |
-
$storeProduct = Mage::getModel('catalog/product');
|
111 |
-
$storeProduct->setStoreId($storeId);
|
112 |
-
$storeProduct->load($productId);
|
113 |
-
$storeCode = $storeList [$storeId];
|
114 |
-
// NAMES -----
|
115 |
-
$result ["names"] [$storeCode] = $storeProduct->getName();
|
116 |
-
$result ["urls"] [$storeCode] = preg_replace("/[\?&]?___store=[^\?&]*/", "", $storeProduct->getProductUrl());
|
117 |
-
}
|
118 |
-
|
119 |
-
// IMAGE URL -----
|
120 |
-
$imageUrl = Mage::helper('brainsins_recommender')->getProductImage($product, $width, $height);
|
121 |
-
|
122 |
-
// $image_width = Mage::getStoreConfig('brainsins_recommender_options/product_feed/product_image_resize_width', Mage::app()->getStore()->getStoreId());
|
123 |
-
// $image_height = Mage::getStoreConfig('brainsins_recommender_options/product_feed/product_image_resize_height', Mage::app()->getStore()->getStoreId());
|
124 |
-
|
125 |
-
// if (!$image_width || $image_width == "" || $image_width == "0" || !is_numeric($image_width)) {
|
126 |
-
// $image_width = null;
|
127 |
-
// }
|
128 |
-
|
129 |
-
// if (!$image_height || $image_height == "" || $image_height == "0" || !is_numeric($image_height)) {
|
130 |
-
// $image_height = null;
|
131 |
-
// }
|
132 |
-
|
133 |
-
// if (!$image_width && !$image_height) {
|
134 |
-
// $imageUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA).'catalog/product'.$product->getImage();
|
135 |
-
// } else {
|
136 |
-
// $imageUrl = (string) Mage::helper('catalog/image')->init($product, "image")->resize($image_width, $image_height);
|
137 |
-
// }
|
138 |
-
|
139 |
-
$result ["imageUrl"] = $imageUrl;
|
140 |
-
|
141 |
-
// URL ---
|
142 |
-
|
143 |
-
$url = preg_replace("/[\?&]?___store=[^\?&]*/", "", $product->getProductUrl());
|
144 |
-
$result ["url"] = $url;
|
145 |
-
|
146 |
-
// PRICES -----
|
147 |
-
|
148 |
-
$product_price = 0.0;
|
149 |
-
|
150 |
-
if ($tax_included == '1' && $special_price == '1') {
|
151 |
-
$product_price = Mage::helper('tax')->getPrice($product, $product->getFinalPrice(), true, null, null, null, null, false);
|
152 |
-
} elseif ($tax_included == '1' && $special_price == '0') {
|
153 |
-
$product_price = Mage::helper('tax')->getPrice($product, $product->getPrice(), true, null, null, null, null, false);
|
154 |
-
}
|
155 |
-
|
156 |
-
if ($tax_included == '0' && $special_price == '1') {
|
157 |
-
$product_price = Mage::helper('tax')->getPrice($product, $product->getFinalPrice(), true, null, null, null, null, true);
|
158 |
-
} elseif ($tax_included == '0' && $special_price == '0') {
|
159 |
-
$product_price = Mage::helper('tax')->getPrice($product, $product->getPrice(), true, null, null, null, null, true);
|
160 |
-
}
|
161 |
-
|
162 |
-
if ($product->getTypeId() == Mage_Catalog_Model_Product_Type::TYPE_BUNDLE) {
|
163 |
-
if ($tax_included == '1' && $special_price == '1') {
|
164 |
-
$product_price = Mage::helper('tax')->getPrice($product, Mage::helper('brainsins_recommender')->getBundlePrice($product, 'min', 1), true, null, null, null, null, false);
|
165 |
-
} elseif ($tax_included == '1' && $special_price == '0') {
|
166 |
-
$product_price = Mage::helper('tax')->getPrice($product, Mage::helper('brainsins_recommender')->getBundlePrice($product, 'min', 1), true, null, null, null, null, false);
|
167 |
-
}
|
168 |
-
if ($tax_included == '0' && $special_price == '1') {
|
169 |
-
$product_price = Mage::helper('tax')->getPrice($product, Mage::helper('brainsins_recommender')->getBundlePrice($product, 'min', 0), true, null, null, null, null, true);
|
170 |
-
} elseif ($tax_included == '0' && $special_price == '0') {
|
171 |
-
$product_price = Mage::helper('tax')->getPrice($product, Mage::helper('brainsins_recommender')->getBundlePrice($product, 'min', 0), true, null, null, null, null, true);
|
172 |
-
}
|
173 |
-
}
|
174 |
-
|
175 |
-
if ($product->getTypeId() == Mage_Catalog_Model_Product_Type::TYPE_BUNDLE) {
|
176 |
-
$product_final_price = Mage::helper('brainsins_recommender')->getBundlePrice($product, 'min', 1);
|
177 |
-
$product_regular_price = Mage::helper('brainsins_recommender')->getBundlePrice($product, 'min', 1);
|
178 |
-
} else {
|
179 |
-
$product_final_price = $product->getFinalPrice();
|
180 |
-
$product_regular_price = $product->getPrice();
|
181 |
-
}
|
182 |
-
|
183 |
-
$result ["price"] = number_format($product_price, 2, '.', '');
|
184 |
-
$baseCurrency = Mage::app()->getStore()->getBaseCurrencyCode();
|
185 |
-
|
186 |
-
foreach ($currencies as $curr) {
|
187 |
-
|
188 |
-
try {
|
189 |
-
$targetCurrency = Mage::getModel('directory/currency')->load($curr);
|
190 |
-
if ($targetCurrency) {
|
191 |
-
$targetcurrency = $targetCurrency->getCode();
|
192 |
-
} else {
|
193 |
-
continue;
|
194 |
-
}
|
195 |
-
|
196 |
-
if ($baseCurrency == $targetCurrency) {
|
197 |
-
$result ["prices"] [$targetCurrency] = $product_final_price;
|
198 |
-
continue;
|
199 |
-
}
|
200 |
-
|
201 |
-
$price_converted = number_format(Mage::helper('directory')->currencyConvert($product_final_price, $baseCurrency, $targetCurrency), 2, '.', '');
|
202 |
-
$result ["prices"] [$curr] = $price_converted;
|
203 |
-
} catch (Exception $e) {
|
204 |
-
}
|
205 |
-
}
|
206 |
-
|
207 |
-
// easy stuff
|
208 |
-
$result ["id"] = $product->getId();
|
209 |
-
$result ["sku"] = $product->getSku();
|
210 |
-
$result ["categories"] = $product->getCategoryIds();
|
211 |
-
|
212 |
-
if ($debug) {
|
213 |
-
$info = Array();
|
214 |
-
foreach ($product->getAttributes() as $attribute) {
|
215 |
-
$attributeCode = $attribute->getAttributeCode();
|
216 |
-
$info [$attributeCode] = $product->getData($attributeCode);
|
217 |
-
}
|
218 |
-
$result ["debug"] = $info;
|
219 |
-
}
|
220 |
-
|
221 |
-
return $result;
|
222 |
-
}
|
223 |
-
|
224 |
-
public function productAction()
|
225 |
-
{
|
226 |
-
$id = $this->getRequest()->getParam('id');
|
227 |
-
$debug = $this->getRequest()->getParam('debug');
|
228 |
-
$oosParam = $this->getREquest()->getParam('oos');
|
229 |
-
|
230 |
-
$include_oos_products = false;
|
231 |
-
|
232 |
-
if ($oosParam === null) {
|
233 |
-
$include_oos_products = true && Mage::getStoreConfig('brainsins_recommender_options/product_feed/include_oos_products', Mage::app()->getStore()->getStoreId());
|
234 |
-
} else {
|
235 |
-
$include_oos_products = $oosParam && true;
|
236 |
-
}
|
237 |
-
|
238 |
-
$result = $this->_getProduct($id, $debug, $include_oos_products);
|
239 |
-
$output = json_encode($result);
|
240 |
-
$this->getResponse()->clearHeaders()->setHeader('Content-Type', 'application/json')->setBody($output);
|
241 |
-
}
|
242 |
-
|
243 |
-
private function _getCurrencyCodes()
|
244 |
-
{
|
245 |
-
$stores = Mage::app()->getStore()->getCollection();
|
246 |
-
$result = array();
|
247 |
-
foreach ($stores as $store) {
|
248 |
-
$currencies = $store->getAvailableCurrencyCodes(true);
|
249 |
-
foreach ($currencies as $currency) {
|
250 |
-
if (!in_array($currency, $result)) {
|
251 |
-
$result [] = $currency;
|
252 |
-
}
|
253 |
-
}
|
254 |
-
}
|
255 |
-
|
256 |
-
return $result;
|
257 |
-
}
|
258 |
-
|
259 |
-
private function _getAttributeOptions($id) {
|
260 |
-
$attribute = Mage::getModel('catalog/resource_eav_attribute')->load($id);
|
261 |
-
$attributeOptions = $attribute ->getSource()->getAllOptions(false);
|
262 |
-
return $attributeOptions;
|
263 |
-
}
|
264 |
-
|
265 |
-
private function _getAttributeInfo($id) {
|
266 |
-
|
267 |
-
}
|
268 |
-
|
269 |
-
public function attributeListAction()
|
270 |
-
{
|
271 |
-
$ids = Mage::getResourceModel('eav/entity_attribute_collection')->getAllIds();
|
272 |
-
|
273 |
-
$attributes = Array();
|
274 |
-
|
275 |
-
foreach($ids as $id) {
|
276 |
-
$attributeInfo = Mage::getModel('catalog/resource_eav_attribute')->load($id);
|
277 |
-
$options = $attributeInfo ->getSource()->getAllOptions(false);
|
278 |
-
$attribute = Array();
|
279 |
-
$attribute['id'] = $id;
|
280 |
-
$attribute['label'] = $attributeInfo->getData("attribute_code");
|
281 |
-
$attribute['options'] = $options;
|
282 |
-
$attributes[]=$attribute;
|
283 |
-
}
|
284 |
-
|
285 |
-
$output = json_encode($attributes);
|
286 |
-
$this->getResponse()->clearHeaders()->setHeader('Content-Type', 'application/json')->setBody($output);
|
287 |
-
}
|
288 |
-
|
289 |
-
public function attributeAction()
|
290 |
-
{
|
291 |
-
$id = $this->getRequest()->getParam('id');
|
292 |
-
$name = $this->getRequest()->getParam('name');
|
293 |
-
|
294 |
-
$attributeInfo = null;
|
295 |
-
|
296 |
-
if ($name != null && $name != "") {
|
297 |
-
$attributeInfo = Mage::getResourceModel('eav/entity_attribute_collection')->setCodeFilter($name)->getFirstItem();
|
298 |
-
$id = $attributeInfo->getAttributeId();
|
299 |
-
} else {
|
300 |
-
$attributeInfo = Mage::getResourceModel('eav/entity_attribute_collection')->getItemById($id);
|
301 |
-
}
|
302 |
-
|
303 |
-
// $attributeInfo = Mage::getResourceModel('eav/entity_attribute_collection')->getItemById($id);
|
304 |
-
|
305 |
-
$options = $this->_getAttributeOptions($id);
|
306 |
-
$attribute = Array();
|
307 |
-
$attribute['id'] = $id;
|
308 |
-
$attribute['label'] = $attributeInfo->getData("attribute_code");
|
309 |
-
$attribute['options'] = $options;
|
310 |
-
$attributes[]=$attribute;
|
311 |
-
|
312 |
-
$output = json_encode($attributes);
|
313 |
-
$this->getResponse()->clearHeaders()->setHeader('Content-Type', 'application/json')->setBody($output);
|
314 |
-
|
315 |
-
}
|
316 |
-
|
317 |
-
public function currencyListAction()
|
318 |
-
{
|
319 |
-
$result = $this->_getCurrencyCodes();
|
320 |
-
|
321 |
-
$output = json_encode($result);
|
322 |
-
$this->getResponse()->clearHeaders()->setHeader('Content-Type', 'application/json')->setBody($output);
|
323 |
-
}
|
324 |
-
|
325 |
-
private function _getStoreList()
|
326 |
-
{
|
327 |
-
$stores = Mage::app()->getStore()->getCollection();
|
328 |
-
$result = array();
|
329 |
-
foreach ($stores as $store) {
|
330 |
-
$result [$store->getId()] = $store->getCode();
|
331 |
-
}
|
332 |
-
return $result;
|
333 |
-
}
|
334 |
-
|
335 |
-
public function storeListAction()
|
336 |
-
{
|
337 |
-
$result = $this->_getStoreList();
|
338 |
-
|
339 |
-
$output = json_encode($result);
|
340 |
-
$this->getResponse()->clearHeaders()->setHeader('Content-Type', 'application/json')->setBody($output);
|
341 |
-
}
|
342 |
-
|
343 |
-
public function categoriesAction()
|
344 |
-
{
|
345 |
-
$result = array();
|
346 |
-
$allcats = Mage::getModel('catalog/category')->getCollection();
|
347 |
-
$storeList = $this->_getStoreList();
|
348 |
-
foreach ($allcats as $category) {
|
349 |
-
$category->load($category->getId());
|
350 |
-
$catInfo = Array();
|
351 |
-
|
352 |
-
$catInfo ["id"] = $category->getId();
|
353 |
-
|
354 |
-
$catInfo ["parent_id"] = $category->getParentId();
|
355 |
-
|
356 |
-
$catInfo ["names"] = Array();
|
357 |
-
|
358 |
-
foreach ($category->getStoreIds() as $storeId) {
|
359 |
-
if (!$storeId) {
|
360 |
-
continue;
|
361 |
-
}
|
362 |
-
$storeCat = Mage::getModel('catalog/category')->setStore($storeId)->load($category->getId());
|
363 |
-
|
364 |
-
$storeCatInfo = Array();
|
365 |
-
$storeCode = $storeList [$storeId];
|
366 |
-
$catInfo ["names"] [$storeCode] = $storeCat->getName();
|
367 |
-
}
|
368 |
-
|
369 |
-
$result [$category->getId()] = $catInfo;
|
370 |
-
}
|
371 |
-
$output = json_encode($result);
|
372 |
-
$this->getResponse()->clearHeaders()->setHeader('Content-Type', 'application/json')->setBody($output);
|
373 |
-
}
|
374 |
-
|
375 |
-
// getParentId()
|
376 |
-
public function categoryTreeAction()
|
377 |
-
{
|
378 |
-
$categories = Mage::getModel('catalog/category')->getCollection()->addAttributeToSelect('*')->addAttributeToFilter('level', 2);
|
379 |
-
|
380 |
-
$result = Array();
|
381 |
-
|
382 |
-
foreach ($categories as $category) {
|
383 |
-
$id = $category->getId();
|
384 |
-
$name = $category->getName();
|
385 |
-
}
|
386 |
-
|
387 |
-
$output = json_encode($result);
|
388 |
-
$this->getResponse()->clearHeaders()->setHeader('Content-Type', 'application/json')->setBody($output);
|
389 |
-
}
|
390 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/community/Brainsins/Recommender/controllers/LoginController.php
CHANGED
@@ -28,7 +28,7 @@ class Brainsins_Recommender_LoginController extends Mage_Core_Controller_Front_A
|
|
28 |
|
29 |
$bsEnabled = Mage::getStoreConfigFlag('brainsins_recommender_options/brainsins_recommender_general/enabled', Mage::app()->getStore()->getStoreId());
|
30 |
$autologinEnabled = Mage::getStoreConfigFlag('brainsins_recommender_options/brainsins_recommender_autologin/enabled', Mage::app()->getStore()->getStoreId());
|
31 |
-
$autologinSecret = Mage::getStoreConfig('brainsins_recommender_options/
|
32 |
|
33 |
$email = $this->getRequest()->getParam('email');
|
34 |
$token = $this->getRequest()->getParam('token');
|
28 |
|
29 |
$bsEnabled = Mage::getStoreConfigFlag('brainsins_recommender_options/brainsins_recommender_general/enabled', Mage::app()->getStore()->getStoreId());
|
30 |
$autologinEnabled = Mage::getStoreConfigFlag('brainsins_recommender_options/brainsins_recommender_autologin/enabled', Mage::app()->getStore()->getStoreId());
|
31 |
+
$autologinSecret = Mage::getStoreConfig('brainsins_recommender_options/brainsins_recommender_advanced/secret', Mage::app()->getStore()->getStoreId());
|
32 |
|
33 |
$email = $this->getRequest()->getParam('email');
|
34 |
$token = $this->getRequest()->getParam('token');
|
app/code/community/Brainsins/Recommender/controllers/PurchaseController.php
ADDED
@@ -0,0 +1,72 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* BrainSINS' Magento Extension allows to integrate the BrainSINS
|
4 |
+
* personalized product recommendations into a Magento Store.
|
5 |
+
* Copyright (c) 2014 Social Gaming Platform S.R.L.
|
6 |
+
*
|
7 |
+
* This file is part of BrainSINS' Magento Extension.
|
8 |
+
*
|
9 |
+
* BrainSINS' Magento Extension is free software: you can redistribute it
|
10 |
+
* and/or modify it under the terms of the GNU General Public License
|
11 |
+
* as published by the Free Software Foundation, either version 3 of the
|
12 |
+
* License, or (at your option) any later version.
|
13 |
+
*
|
14 |
+
* Foobar is distributed in the hope that it will be useful,
|
15 |
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
16 |
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
17 |
+
* GNU General Public License for more details.
|
18 |
+
*
|
19 |
+
* You should have received a copy of the GNU General Public License
|
20 |
+
* along with Foobar. If not, see <http://www.gnu.org/licenses/>.
|
21 |
+
*
|
22 |
+
* Please do not hesitate to contact us at info@brainsins.com
|
23 |
+
*/
|
24 |
+
|
25 |
+
class Brainsins_Recommender_PurchaseController extends Mage_Core_Controller_Front_Action
|
26 |
+
{
|
27 |
+
|
28 |
+
private function _check($pids, $token) {
|
29 |
+
$autologinSecret = Mage::getStoreConfig('brainsins_recommender_options/brainsins_recommender_advanced/secret', Mage::app()->getStore()->getStoreId());
|
30 |
+
$validation = md5($pids . $autologinSecret) === strtolower($token);
|
31 |
+
return $validation;
|
32 |
+
}
|
33 |
+
|
34 |
+
public function checkAction()
|
35 |
+
{
|
36 |
+
$result = Array();
|
37 |
+
|
38 |
+
if (!Mage::getStoreConfigFlag('brainsins_recommender_options/brainsins_recommender_general/enabled', Mage::app()->getStore()->getStoreId())) {
|
39 |
+
$this->_redirectUrl(Mage::getBaseUrl());
|
40 |
+
$this->setFlag('', self::FLAG_NO_DISPATCH, true);
|
41 |
+
$output = json_encode($result);
|
42 |
+
$this->getResponse()->clearHeaders()->setHeader('Content-Type', 'application/json')->setBody($output);
|
43 |
+
return;
|
44 |
+
}
|
45 |
+
|
46 |
+
$limit = 100;
|
47 |
+
|
48 |
+
$csvPids = $this->getRequest()->getParam('pids');
|
49 |
+
if ($csvPids && $csvPids != "") {
|
50 |
+
$pids = preg_split("/,/", $csvPids);
|
51 |
+
if ($pids && sizeof($pids) > 0) {
|
52 |
+
$pids = array_slice($pids, 0, $limit);
|
53 |
+
$token = $this->getRequest()->getParam('token');
|
54 |
+
if (!$this->_check($csvPids, $token)) {
|
55 |
+
$output = json_encode($result);
|
56 |
+
$this->getResponse()->clearHeaders()->setHeader('Content-Type', 'application/json')->setBody($output);
|
57 |
+
return;
|
58 |
+
}
|
59 |
+
$orderCollection = Mage::getSingleton("sales/order")->getCollection();
|
60 |
+
$orderCollection->addAttributeToSelect("increment_id");
|
61 |
+
$orderCollection->addAttributeToSelect("status");
|
62 |
+
$orderCollection->addAttributeToFilter("increment_id", array("in" => $pids));
|
63 |
+
foreach($orderCollection as $order) {
|
64 |
+
$result[$order->getIncrementId()] = $order->getStatus();
|
65 |
+
}
|
66 |
+
}
|
67 |
+
}
|
68 |
+
|
69 |
+
$output = json_encode($result);
|
70 |
+
$this->getResponse()->clearHeaders()->setHeader('Content-Type', 'application/json')->setBody($output);
|
71 |
+
}
|
72 |
+
}
|
app/code/community/Brainsins/Recommender/controllers/TrackingController.php
CHANGED
@@ -28,8 +28,7 @@ class Brainsins_Recommender_TrackingController extends Mage_Core_Controller_Fron
|
|
28 |
{
|
29 |
try {
|
30 |
|
31 |
-
|
32 |
-
if (!$bdata || $bdata == "") {
|
33 |
$this->getResponse()->setHeader('Content-Type', 'application/json')->setBody("{}");
|
34 |
return;
|
35 |
}
|
@@ -39,7 +38,8 @@ class Brainsins_Recommender_TrackingController extends Mage_Core_Controller_Fron
|
|
39 |
$this->getResponse()->setHeader('Content-Type', 'application/json')->setBody("{}");
|
40 |
return;
|
41 |
}
|
42 |
-
|
|
|
43 |
$response = json_encode($bdata);
|
44 |
|
45 |
} catch (Exception $e) {
|
28 |
{
|
29 |
try {
|
30 |
|
31 |
+
/*if (!$bdata || $bdata == "") {
|
|
|
32 |
$this->getResponse()->setHeader('Content-Type', 'application/json')->setBody("{}");
|
33 |
return;
|
34 |
}
|
38 |
$this->getResponse()->setHeader('Content-Type', 'application/json')->setBody("{}");
|
39 |
return;
|
40 |
}
|
41 |
+
*/
|
42 |
+
$bdata = $this->_completeBdata(Array());
|
43 |
$response = json_encode($bdata);
|
44 |
|
45 |
} catch (Exception $e) {
|
app/code/community/Brainsins/Recommender/etc/config.xml
CHANGED
@@ -15,7 +15,7 @@
|
|
15 |
<config>
|
16 |
<modules>
|
17 |
<Brainsins_Recommender>
|
18 |
-
<version>2.
|
19 |
</Brainsins_Recommender>
|
20 |
</modules>
|
21 |
<global>
|
@@ -59,6 +59,15 @@
|
|
59 |
</brainsins_recommender>
|
60 |
</observers>
|
61 |
</sales_order_invoice_save_after>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
62 |
</events>
|
63 |
</global>
|
64 |
<frontend>
|
@@ -249,22 +258,16 @@
|
|
249 |
<email_tracking>1</email_tracking>
|
250 |
</brainsins_recommender_general>
|
251 |
<brainsins_recommender_feed>
|
252 |
-
<
|
253 |
-
<
|
254 |
</brainsins_recommender_feed>
|
255 |
<brainsins_recommender_advanced>
|
256 |
<ajax_tracking>0</ajax_tracking>
|
257 |
<custom_script>0</custom_script>
|
|
|
|
|
|
|
258 |
</brainsins_recommender_advanced>
|
259 |
</brainsins_recommender_options>
|
260 |
</default>
|
261 |
-
<crontab>
|
262 |
-
<jobs>
|
263 |
-
<brainsins_recommender_feeds_cron>
|
264 |
-
<run>
|
265 |
-
<model>brainsins_recommender/cron::generateOfflineFeeds</model>
|
266 |
-
</run>
|
267 |
-
</brainsins_recommender_feeds_cron>
|
268 |
-
</jobs>
|
269 |
-
</crontab>
|
270 |
</config>
|
15 |
<config>
|
16 |
<modules>
|
17 |
<Brainsins_Recommender>
|
18 |
+
<version>2.1.1</version>
|
19 |
</Brainsins_Recommender>
|
20 |
</modules>
|
21 |
<global>
|
59 |
</brainsins_recommender>
|
60 |
</observers>
|
61 |
</sales_order_invoice_save_after>
|
62 |
+
<order_cancel_after>
|
63 |
+
<observers>
|
64 |
+
<brainsins_recommender>
|
65 |
+
<type>model</type>
|
66 |
+
<class>brainsins_recommender/observer</class>
|
67 |
+
<method>onOrderCancel</method>
|
68 |
+
</brainsins_recommender>
|
69 |
+
</observers>
|
70 |
+
</order_cancel_after>
|
71 |
</events>
|
72 |
</global>
|
73 |
<frontend>
|
258 |
<email_tracking>1</email_tracking>
|
259 |
</brainsins_recommender_general>
|
260 |
<brainsins_recommender_feed>
|
261 |
+
<tax_included>1</tax_included>
|
262 |
+
<special_price>1</special_price>
|
263 |
</brainsins_recommender_feed>
|
264 |
<brainsins_recommender_advanced>
|
265 |
<ajax_tracking>0</ajax_tracking>
|
266 |
<custom_script>0</custom_script>
|
267 |
+
<product_id_field>entity_id</product_id_field>
|
268 |
+
<category_id_field>entity_id</category_id_field>
|
269 |
+
<tracking_tax>1</tracking_tax>
|
270 |
</brainsins_recommender_advanced>
|
271 |
</brainsins_recommender_options>
|
272 |
</default>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
273 |
</config>
|
app/code/community/Brainsins/Recommender/etc/system.xml
CHANGED
@@ -13,442 +13,488 @@
|
|
13 |
<http://www.gnu.org/licenses/>. * * Please do not hesitate to contact us
|
14 |
at info@brainsins.com -->
|
15 |
<config>
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
104 |
<brainsins_recommender_recommenders_link>
|
105 |
-
<label>Check available recommenders
|
106 |
<help_link>https://analytics.brainsins.com/optimization/recommenderslist
|
107 |
</help_link>
|
108 |
<comment></comment>
|
109 |
<frontend_type>button</frontend_type>
|
110 |
-
<frontend_model>brainsins_recommender/adminhtml_system_config_source_recommenders_show
|
|
|
111 |
<sort_order>5</sort_order>
|
112 |
<show_in_default>1</show_in_default>
|
113 |
<show_in_website>1</show_in_website>
|
114 |
<show_in_store>1</show_in_store>
|
115 |
</brainsins_recommender_recommenders_link>
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
-
|
391 |
-
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
-
|
397 |
-
|
398 |
-
|
399 |
-
|
400 |
-
|
401 |
-
|
402 |
-
|
403 |
-
|
404 |
-
|
405 |
-
|
406 |
-
|
407 |
-
|
408 |
-
|
409 |
-
|
410 |
-
|
411 |
-
|
412 |
-
|
413 |
-
|
414 |
-
|
415 |
-
|
416 |
-
|
417 |
-
|
418 |
-
|
419 |
-
|
420 |
-
|
421 |
-
|
422 |
-
|
423 |
-
|
424 |
-
|
425 |
-
|
426 |
-
|
427 |
-
|
428 |
-
|
429 |
-
|
430 |
-
|
431 |
-
|
432 |
-
|
433 |
-
|
434 |
-
|
435 |
-
|
436 |
-
|
437 |
-
|
438 |
-
|
439 |
-
|
440 |
-
|
441 |
-
|
442 |
-
|
443 |
-
|
444 |
-
|
445 |
-
|
446 |
-
|
447 |
-
|
448 |
-
|
449 |
-
|
450 |
-
|
451 |
-
|
452 |
-
|
453 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
454 |
</config>
|
13 |
<http://www.gnu.org/licenses/>. * * Please do not hesitate to contact us
|
14 |
at info@brainsins.com -->
|
15 |
<config>
|
16 |
+
<tabs>
|
17 |
+
<brainsins_recommender_tab translate="label"
|
18 |
+
module="brainsins_recommender">
|
19 |
+
<label>BrainSINS</label>
|
20 |
+
<sort_order>1000</sort_order>
|
21 |
+
<class>tab-brainsins-extensions</class>
|
22 |
+
</brainsins_recommender_tab>
|
23 |
+
</tabs>
|
24 |
+
<sections>
|
25 |
+
<brainsins_recommender_options
|
26 |
+
translate="label" module="brainsins_recommender">
|
27 |
+
<label>Configuration</label>
|
28 |
+
<tab>brainsins_recommender_tab</tab>
|
29 |
+
<frontend_type>text</frontend_type>
|
30 |
+
<sort_order>100</sort_order>
|
31 |
+
<show_in_default>1</show_in_default>
|
32 |
+
<show_in_website>1</show_in_website>
|
33 |
+
<show_in_store>1</show_in_store>
|
34 |
+
<groups>
|
35 |
+
<help translate="label" module="brainsins_recommender">
|
36 |
+
<frontend_model>brainsins_recommender/adminhtml_system_config_fieldset_help
|
37 |
+
</frontend_model>
|
38 |
+
<help_link>http://developers.brainsins.com/plugins/magento.html
|
39 |
+
</help_link>
|
40 |
+
<sort_order>0</sort_order>
|
41 |
+
<show_in_default>1</show_in_default>
|
42 |
+
<show_in_website>1</show_in_website>
|
43 |
+
<show_in_store>1</show_in_store>
|
44 |
+
</help>
|
45 |
+
<brainsins_recommender_general
|
46 |
+
translate="label comment" module="brainsins_recommender">
|
47 |
+
<label>General</label>
|
48 |
+
<comment>
|
49 |
+
<![CDATA[ <button type="button" class="scalable scalable go" onclick="window.open('http://www.brainsins.com')" style="display:none;"><span><span><span>I am not a BrainSINS user yet</span></span></span></button>]]></comment>
|
50 |
+
<frontend_type>text</frontend_type>
|
51 |
+
<sort_order>0</sort_order>
|
52 |
+
<show_in_default>1</show_in_default>
|
53 |
+
<show_in_website>1</show_in_website>
|
54 |
+
<show_in_store>1</show_in_store>
|
55 |
+
<fields>
|
56 |
+
<enabled translate="label comment">
|
57 |
+
<label>Enabled</label>
|
58 |
+
<comment>Enable or disable the extension.</comment>
|
59 |
+
<frontend_type>select</frontend_type>
|
60 |
+
<sort_order>10</sort_order>
|
61 |
+
<show_in_default>1</show_in_default>
|
62 |
+
<show_in_website>1</show_in_website>
|
63 |
+
<show_in_store>1</show_in_store>
|
64 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
65 |
+
</enabled>
|
66 |
+
<bs_key translate="label comment">
|
67 |
+
<label>BS-KEY</label>
|
68 |
+
<comment>BrainSINS KEY format: BS-0123456789-1</comment>
|
69 |
+
<frontend_type>text</frontend_type>
|
70 |
+
<validate>required-entry validate-bskey-format</validate>
|
71 |
+
<sort_order>20</sort_order>
|
72 |
+
<show_in_default>1</show_in_default>
|
73 |
+
<show_in_website>1</show_in_website>
|
74 |
+
<show_in_store>1</show_in_store>
|
75 |
+
<depends>
|
76 |
+
<enabled>1</enabled>
|
77 |
+
</depends>
|
78 |
+
</bs_key>
|
79 |
+
<email_tracking translate="label comment">
|
80 |
+
<label>Customer email tracking</label>
|
81 |
+
<comment>Needed for cart abandonment service.</comment>
|
82 |
+
<frontend_type>select</frontend_type>
|
83 |
+
<source_model>brainsins_recommender/adminhtml_system_config_source_emailtracking
|
84 |
+
</source_model>
|
85 |
+
<sort_order>30</sort_order>
|
86 |
+
<show_in_default>1</show_in_default>
|
87 |
+
<show_in_website>1</show_in_website>
|
88 |
+
<show_in_store>1</show_in_store>
|
89 |
+
<depends>
|
90 |
+
<enabled>1</enabled>
|
91 |
+
</depends>
|
92 |
+
</email_tracking>
|
93 |
+
<base_currency translate="label comment">
|
94 |
+
<label>Base Currency</label>
|
95 |
+
<comment>Select option</comment>
|
96 |
+
<frontend_type>select</frontend_type>
|
97 |
+
<sort_order>40</sort_order>
|
98 |
+
<show_in_default>1</show_in_default>
|
99 |
+
<show_in_website>1</show_in_website>
|
100 |
+
<show_in_store>1</show_in_store>
|
101 |
+
<source_model>brainsins_recommender/adminhtml_system_config_source_currencies
|
102 |
+
</source_model>
|
103 |
+
</base_currency>
|
104 |
+
</fields>
|
105 |
+
</brainsins_recommender_general>
|
106 |
+
<brainsins_recommender_recommenders
|
107 |
+
translate="label comment" module="brainsins_recommender">
|
108 |
+
<label>Recommenders</label>
|
109 |
+
<comment></comment>
|
110 |
+
<frontend_type>text</frontend_type>
|
111 |
+
<sort_order>20</sort_order>
|
112 |
+
<show_in_default>1</show_in_default>
|
113 |
+
<show_in_website>1</show_in_website>
|
114 |
+
<show_in_store>1</show_in_store>
|
115 |
+
<fields>
|
116 |
<brainsins_recommender_recommenders_link>
|
117 |
+
<label>Check available recommenders</label>
|
118 |
<help_link>https://analytics.brainsins.com/optimization/recommenderslist
|
119 |
</help_link>
|
120 |
<comment></comment>
|
121 |
<frontend_type>button</frontend_type>
|
122 |
+
<frontend_model>brainsins_recommender/adminhtml_system_config_source_recommenders_show
|
123 |
+
</frontend_model>
|
124 |
<sort_order>5</sort_order>
|
125 |
<show_in_default>1</show_in_default>
|
126 |
<show_in_website>1</show_in_website>
|
127 |
<show_in_store>1</show_in_store>
|
128 |
</brainsins_recommender_recommenders_link>
|
129 |
+
<brainsins_recommender_recommenders_home
|
130 |
+
type="group" tranlate="label comment">
|
131 |
+
<label>Home page recommenders</label>
|
132 |
+
<comment></comment>
|
133 |
+
<frontend_model>brainsins_recommender/adminhtml_system_config_fieldset_expanded
|
134 |
+
</frontend_model>
|
135 |
+
<frontend_type>text</frontend_type>
|
136 |
+
<sort_order>10</sort_order>
|
137 |
+
<show_in_default>1</show_in_default>
|
138 |
+
<show_in_website>1</show_in_website>
|
139 |
+
<show_in_store>1</show_in_store>
|
140 |
+
<fields>
|
141 |
+
<recommenders_home tranlate="label comment">
|
142 |
+
<label>Enabled recommenders</label>
|
143 |
+
<comment>Recommenders
|
144 |
+
to enable at home page.<![CDATA[<br />]]>Custom
|
145 |
+
pos overrides the recommender position.
|
146 |
+
</comment>
|
147 |
+
<frontend_model>
|
148 |
+
brainsins_recommender/adminhtml_system_config_source_recommenders_home
|
149 |
+
</frontend_model>
|
150 |
+
<backend_model>brainsins_recommender/adminhtml_system_config_backend_serialized
|
151 |
+
</backend_model>
|
152 |
+
<sort_order>10</sort_order>
|
153 |
+
<show_in_default>1</show_in_default>
|
154 |
+
<show_in_website>1</show_in_website>
|
155 |
+
<show_in_store>1</show_in_store>
|
156 |
+
</recommenders_home>
|
157 |
+
</fields>
|
158 |
+
</brainsins_recommender_recommenders_home>
|
159 |
+
<brainsins_recommender_recommenders_product
|
160 |
+
type="group" tranlate="label comment">
|
161 |
+
<label>Product page recommenders</label>
|
162 |
+
<comment></comment>
|
163 |
+
<frontend_model>brainsins_recommender/adminhtml_system_config_fieldset_expanded
|
164 |
+
</frontend_model>
|
165 |
+
<frontend_type>text</frontend_type>
|
166 |
+
<sort_order>20</sort_order>
|
167 |
+
<show_in_default>1</show_in_default>
|
168 |
+
<show_in_website>1</show_in_website>
|
169 |
+
<show_in_store>1</show_in_store>
|
170 |
+
<fields>
|
171 |
+
<recommenders_product tranlate="label comment">
|
172 |
+
<label>Enabled recommenders</label>
|
173 |
+
<comment>Recommenders
|
174 |
+
to enable at product page.<![CDATA[<br />]]>Custom
|
175 |
+
pos overrides the recommender position.
|
176 |
+
</comment>
|
177 |
+
<frontend_model>
|
178 |
+
brainsins_recommender/adminhtml_system_config_source_recommenders_product
|
179 |
+
</frontend_model>
|
180 |
+
<backend_model>brainsins_recommender/adminhtml_system_config_backend_serialized
|
181 |
+
</backend_model>
|
182 |
+
<sort_order>10</sort_order>
|
183 |
+
<show_in_default>1</show_in_default>
|
184 |
+
<show_in_website>1</show_in_website>
|
185 |
+
<show_in_store>1</show_in_store>
|
186 |
+
</recommenders_product>
|
187 |
+
</fields>
|
188 |
+
</brainsins_recommender_recommenders_product>
|
189 |
+
<brainsins_recommender_recommenders_category
|
190 |
+
type="group" tranlate="label comment">
|
191 |
+
<label>Category page recommenders</label>
|
192 |
+
<comment></comment>
|
193 |
+
<frontend_model>brainsins_recommender/adminhtml_system_config_fieldset_expanded
|
194 |
+
</frontend_model>
|
195 |
+
<frontend_type>text</frontend_type>
|
196 |
+
<sort_order>25</sort_order>
|
197 |
+
<show_in_default>1</show_in_default>
|
198 |
+
<show_in_website>1</show_in_website>
|
199 |
+
<show_in_store>1</show_in_store>
|
200 |
+
<fields>
|
201 |
+
<recommenders_category tranlate="label comment">
|
202 |
+
<label>Enabled recommenders</label>
|
203 |
+
<comment>Recommenders
|
204 |
+
to enable at category page.<![CDATA[<br />]]>Custom
|
205 |
+
pos overrides the recommender position.
|
206 |
+
</comment>
|
207 |
+
<frontend_model>
|
208 |
+
brainsins_recommender/adminhtml_system_config_source_recommenders_category
|
209 |
+
</frontend_model>
|
210 |
+
<backend_model>brainsins_recommender/adminhtml_system_config_backend_serialized
|
211 |
+
</backend_model>
|
212 |
+
<sort_order>10</sort_order>
|
213 |
+
<show_in_default>1</show_in_default>
|
214 |
+
<show_in_website>1</show_in_website>
|
215 |
+
<show_in_store>1</show_in_store>
|
216 |
+
</recommenders_category>
|
217 |
+
</fields>
|
218 |
+
</brainsins_recommender_recommenders_category>
|
219 |
+
<brainsins_recommender_recommenders_cart
|
220 |
+
type="group" tranlate="label comment">
|
221 |
+
<label>Cart page recommenders</label>
|
222 |
+
<comment></comment>
|
223 |
+
<frontend_model>brainsins_recommender/adminhtml_system_config_fieldset_expanded
|
224 |
+
</frontend_model>
|
225 |
+
<frontend_type>text</frontend_type>
|
226 |
+
<sort_order>30</sort_order>
|
227 |
+
<show_in_default>1</show_in_default>
|
228 |
+
<show_in_website>1</show_in_website>
|
229 |
+
<show_in_store>1</show_in_store>
|
230 |
+
<fields>
|
231 |
+
<recommenders_cart tranlate="label comment">
|
232 |
+
<label>Enabled recommenders</label>
|
233 |
+
<comment>Recommenders
|
234 |
+
to enable at cart page.<![CDATA[<br />]]>Custom
|
235 |
+
pos overrides the recommender position.
|
236 |
+
</comment>
|
237 |
+
<frontend_model>
|
238 |
+
brainsins_recommender/adminhtml_system_config_source_recommenders_cart
|
239 |
+
</frontend_model>
|
240 |
+
<backend_model>brainsins_recommender/adminhtml_system_config_backend_serialized
|
241 |
+
</backend_model>
|
242 |
+
<sort_order>10</sort_order>
|
243 |
+
<show_in_default>1</show_in_default>
|
244 |
+
<show_in_website>1</show_in_website>
|
245 |
+
<show_in_store>1</show_in_store>
|
246 |
+
</recommenders_cart>
|
247 |
+
</fields>
|
248 |
+
</brainsins_recommender_recommenders_cart>
|
249 |
+
<brainsins_recommender_recommenders_checkout
|
250 |
+
type="group" tranlate="label comment">
|
251 |
+
<label>Thank you page recommenders</label>
|
252 |
+
<comment></comment>
|
253 |
+
<frontend_model>brainsins_recommender/adminhtml_system_config_fieldset_expanded
|
254 |
+
</frontend_model>
|
255 |
+
<frontend_type>text</frontend_type>
|
256 |
+
<sort_order>40</sort_order>
|
257 |
+
<show_in_default>1</show_in_default>
|
258 |
+
<show_in_website>1</show_in_website>
|
259 |
+
<show_in_store>1</show_in_store>
|
260 |
+
<fields>
|
261 |
+
<recommenders_checkout tranlate="label comment">
|
262 |
+
<label>Enabled recommenders</label>
|
263 |
+
<comment>Recommenders
|
264 |
+
to enable at thank you page.<![CDATA[<br />]]>Custom
|
265 |
+
pos overrides the recommender position.
|
266 |
+
</comment>
|
267 |
+
<frontend_model>
|
268 |
+
brainsins_recommender/adminhtml_system_config_source_recommenders_checkout
|
269 |
+
</frontend_model>
|
270 |
+
<backend_model>brainsins_recommender/adminhtml_system_config_backend_serialized
|
271 |
+
</backend_model>
|
272 |
+
<sort_order>10</sort_order>
|
273 |
+
<show_in_default>1</show_in_default>
|
274 |
+
<show_in_website>1</show_in_website>
|
275 |
+
<show_in_store>1</show_in_store>
|
276 |
+
</recommenders_checkout>
|
277 |
+
</fields>
|
278 |
+
</brainsins_recommender_recommenders_checkout>
|
279 |
+
</fields>
|
280 |
+
</brainsins_recommender_recommenders>
|
281 |
+
<brainsins_recommender_feed translate="label comment"
|
282 |
+
module="brainsins_recommender">
|
283 |
+
<label>Feeds</label>
|
284 |
+
<comment></comment>
|
285 |
+
<frontend_type>text</frontend_type>
|
286 |
+
<sort_order>30</sort_order>
|
287 |
+
<show_in_default>1</show_in_default>
|
288 |
+
<show_in_website>1</show_in_website>
|
289 |
+
<show_in_store>1</show_in_store>
|
290 |
+
<fields>
|
291 |
+
<include_oos_products translate="label comment">
|
292 |
+
<label>Include out of stock products</label>
|
293 |
+
<comment></comment>
|
294 |
+
<frontend_type>select</frontend_type>
|
295 |
+
<source_model>adminhtml/system_config_source_yesno
|
296 |
+
</source_model>
|
297 |
+
<sort_order>10</sort_order>
|
298 |
+
<show_in_default>1</show_in_default>
|
299 |
+
<show_in_website>1</show_in_website>
|
300 |
+
<show_in_store>1</show_in_store>
|
301 |
+
</include_oos_products>
|
302 |
+
<tax_included translate="label comment">
|
303 |
+
<label>Display prices include taxes</label>
|
304 |
+
<comment></comment>
|
305 |
+
<frontend_type>select</frontend_type>
|
306 |
+
<source_model>adminhtml/system_config_source_yesno
|
307 |
+
</source_model>
|
308 |
+
<sort_order>20</sort_order>
|
309 |
+
<show_in_default>1</show_in_default>
|
310 |
+
<show_in_website>1</show_in_website>
|
311 |
+
<show_in_store>1</show_in_store>
|
312 |
+
</tax_included>
|
313 |
+
<special_price translate="label comment">
|
314 |
+
<label>Display special price instead normal</label>
|
315 |
+
<comment></comment>
|
316 |
+
<frontend_type>select</frontend_type>
|
317 |
+
<source_model>adminhtml/system_config_source_yesno
|
318 |
+
</source_model>
|
319 |
+
<sort_order>30</sort_order>
|
320 |
+
<show_in_default>1</show_in_default>
|
321 |
+
<show_in_website>1</show_in_website>
|
322 |
+
<show_in_store>1</show_in_store>
|
323 |
+
</special_price>
|
324 |
+
<product_description_attribute
|
325 |
+
translate="label comment">
|
326 |
+
<label>Product description attribute</label>
|
327 |
+
<comment></comment>
|
328 |
+
<frontend_type>select</frontend_type>
|
329 |
+
<source_model>brainsins_recommender/adminhtml_system_config_source_attributes
|
330 |
+
</source_model>
|
331 |
+
<sort_order>40</sort_order>
|
332 |
+
<show_in_default>1</show_in_default>
|
333 |
+
<show_in_website>1</show_in_website>
|
334 |
+
<show_in_store>1</show_in_store>
|
335 |
+
</product_description_attribute>
|
336 |
+
<product_image_resize_width
|
337 |
+
translate="label comment">
|
338 |
+
<label>Custom image width</label>
|
339 |
+
<comment>Leave blank for default width</comment>
|
340 |
+
<frontend_type>text</frontend_type>
|
341 |
+
<sort_order>44</sort_order>
|
342 |
+
<show_in_default>1</show_in_default>
|
343 |
+
<show_in_website>1</show_in_website>
|
344 |
+
<show_in_store>1</show_in_store>
|
345 |
+
</product_image_resize_width>
|
346 |
+
<product_image_resize_height
|
347 |
+
translate="label comment">
|
348 |
+
<label>Custom image height</label>
|
349 |
+
<comment>Leave blank for default height</comment>
|
350 |
+
<frontend_type>text</frontend_type>
|
351 |
+
<sort_order>45</sort_order>
|
352 |
+
<show_in_default>1</show_in_default>
|
353 |
+
<show_in_website>1</show_in_website>
|
354 |
+
<show_in_store>1</show_in_store>
|
355 |
+
</product_image_resize_height>
|
356 |
+
</fields>
|
357 |
+
</brainsins_recommender_feed>
|
358 |
+
<brainsins_recommender_autologin
|
359 |
+
translate="label comment" module="brainsins_recommender">
|
360 |
+
<label>Autologin Configuration</label>
|
361 |
+
<comment>Activate to allow autologin on email retargeting actions</comment>
|
362 |
+
<frontend_type>text</frontend_type>
|
363 |
+
<sort_order>50</sort_order>
|
364 |
+
<show_in_default>1</show_in_default>
|
365 |
+
<show_in_website>1</show_in_website>
|
366 |
+
<show_in_store>1</show_in_store>
|
367 |
+
<fields>
|
368 |
+
<enabled translate="label comment">
|
369 |
+
<label>Enabled</label>
|
370 |
+
<comment>Enable or disable the autologin feature</comment>
|
371 |
+
<frontend_type>select</frontend_type>
|
372 |
+
<sort_order>10</sort_order>
|
373 |
+
<show_in_default>1</show_in_default>
|
374 |
+
<show_in_website>1</show_in_website>
|
375 |
+
<show_in_store>1</show_in_store>
|
376 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
377 |
+
</enabled>
|
378 |
+
</fields>
|
379 |
+
</brainsins_recommender_autologin>
|
380 |
+
<brainsins_recommender_advanced
|
381 |
+
translate="label comment" module="brainsins_recommender">
|
382 |
+
<label>Advanced Configuration</label>
|
383 |
+
<comment>Do not modify these values unless required by BrainSINS
|
384 |
+
</comment>
|
385 |
+
<frontend_type>text</frontend_type>
|
386 |
+
<sort_order>60</sort_order>
|
387 |
+
<show_in_default>1</show_in_default>
|
388 |
+
<show_in_website>1</show_in_website>
|
389 |
+
<show_in_store>1</show_in_store>
|
390 |
+
<fields>
|
391 |
+
<product_id_field translate="label comment">
|
392 |
+
<label>Product Field as Id</label>
|
393 |
+
<comment>default is entity_id</comment>
|
394 |
+
<frontend_type>text</frontend_type>
|
395 |
+
<sort_order>5</sort_order>
|
396 |
+
<show_in_default>1</show_in_default>
|
397 |
+
<show_in_website>1</show_in_website>
|
398 |
+
<show_in_store>1</show_in_store>
|
399 |
+
</product_id_field>
|
400 |
+
<category_id_field translate="label comment">
|
401 |
+
<label>Category Field as Id</label>
|
402 |
+
<comment>default is entity_id</comment>
|
403 |
+
<frontend_type>text</frontend_type>
|
404 |
+
<sort_order>6</sort_order>
|
405 |
+
<show_in_default>1</show_in_default>
|
406 |
+
<show_in_website>1</show_in_website>
|
407 |
+
<show_in_store>1</show_in_store>
|
408 |
+
</category_id_field>
|
409 |
+
<ajax_tracking translate="label comment">
|
410 |
+
<label>use Ajax for tracking generation</label>
|
411 |
+
<comment>Default value is NO</comment>
|
412 |
+
<frontend_type>select</frontend_type>
|
413 |
+
<sort_order>10</sort_order>
|
414 |
+
<show_in_default>1</show_in_default>
|
415 |
+
<show_in_website>1</show_in_website>
|
416 |
+
<show_in_store>1</show_in_store>
|
417 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
418 |
+
</ajax_tracking>
|
419 |
+
<custom_script translate="label comment">
|
420 |
+
<label>use custom tracking script</label>
|
421 |
+
<comment>Default value is NO</comment>
|
422 |
+
<frontend_type>select</frontend_type>
|
423 |
+
<sort_order>20</sort_order>
|
424 |
+
<show_in_default>1</show_in_default>
|
425 |
+
<show_in_website>1</show_in_website>
|
426 |
+
<show_in_store>1</show_in_store>
|
427 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
428 |
+
</custom_script>
|
429 |
+
<configurable_tracking translate="label comment">
|
430 |
+
<label>Configurable product's tracking</label>
|
431 |
+
<comment>Select option</comment>
|
432 |
+
<frontend_type>select</frontend_type>
|
433 |
+
<sort_order>30</sort_order>
|
434 |
+
<show_in_default>1</show_in_default>
|
435 |
+
<show_in_website>1</show_in_website>
|
436 |
+
<show_in_store>1</show_in_store>
|
437 |
+
<source_model>
|
438 |
+
brainsins_recommender/adminhtml_system_config_source_configurableproducttracking
|
439 |
+
</source_model>
|
440 |
+
</configurable_tracking>
|
441 |
+
<tracking_tax translate="label comment">
|
442 |
+
<label>Include tax in tracking prices</label>
|
443 |
+
<comment>Select option</comment>
|
444 |
+
<frontend_type>select</frontend_type>
|
445 |
+
<sort_order>40</sort_order>
|
446 |
+
<show_in_default>1</show_in_default>
|
447 |
+
<show_in_website>1</show_in_website>
|
448 |
+
<show_in_store>1</show_in_store>
|
449 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
450 |
+
</tracking_tax>
|
451 |
+
<tracking_amount translate="label comment">
|
452 |
+
<label>Value for purchases total amount</label>
|
453 |
+
<frontend_type>select</frontend_type>
|
454 |
+
<comment>Value to use as total amount for purchases
|
455 |
+
</comment>
|
456 |
+
<source_model>brainsins_recommender/adminhtml_system_config_source_totalamounttrackingoptions</source_model>
|
457 |
+
<sort_order>50</sort_order>
|
458 |
+
<show_in_default>1</show_in_default>
|
459 |
+
<show_in_website>1</show_in_website>
|
460 |
+
<show_in_store>1</show_in_store>
|
461 |
+
</tracking_amount>
|
462 |
+
<secret translate="label comment">
|
463 |
+
<label>BrainSINS Secret KEY</label>
|
464 |
+
<comment>Secret brainsins password.
|
465 |
+
Place your provided secret password here
|
466 |
+
</comment>
|
467 |
+
<frontend_type>text</frontend_type>
|
468 |
+
<sort_order>60</sort_order>
|
469 |
+
<show_in_default>1</show_in_default>
|
470 |
+
<show_in_website>1</show_in_website>
|
471 |
+
<show_in_store>1</show_in_store>
|
472 |
+
</secret>
|
473 |
+
</fields>
|
474 |
+
</brainsins_recommender_advanced>
|
475 |
+
</groups>
|
476 |
+
</brainsins_recommender_options>
|
477 |
+
<brainsins_recommender_dashboard
|
478 |
+
translate="label" module="brainsins_recommender">
|
479 |
+
<label>Dashboard</label>
|
480 |
+
<tab>brainsins_recommender_tab</tab>
|
481 |
+
<frontend_type>text</frontend_type>
|
482 |
+
<sort_order>101</sort_order>
|
483 |
+
<show_in_default>1</show_in_default>
|
484 |
+
<show_in_website>1</show_in_website>
|
485 |
+
<show_in_store>1</show_in_store>
|
486 |
+
<groups>
|
487 |
+
<dashboard translate="label">
|
488 |
+
<label>BrainSINS Dashboard</label>
|
489 |
+
<frontend_type>text</frontend_type>
|
490 |
+
<frontend_model>brainsins_recommender/adminhtml_system_config_form_fieldset_dashboard_dashboard
|
491 |
+
</frontend_model>
|
492 |
+
<sort_order>1</sort_order>
|
493 |
+
<show_in_default>1</show_in_default>
|
494 |
+
<show_in_website>1</show_in_website>
|
495 |
+
<show_in_store>1</show_in_store>
|
496 |
+
</dashboard>
|
497 |
+
</groups>
|
498 |
+
</brainsins_recommender_dashboard>
|
499 |
+
</sections>
|
500 |
</config>
|
app/design/frontend/base/default/layout/brainsins_recommender.xml
CHANGED
@@ -22,13 +22,22 @@
|
|
22 |
* Please do not hesitate to contact us at info@brainsins.com
|
23 |
-->
|
24 |
<layout version="0.1.0">
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
34 |
</layout>
|
22 |
* Please do not hesitate to contact us at info@brainsins.com
|
23 |
-->
|
24 |
<layout version="0.1.0">
|
25 |
+
<default>
|
26 |
+
<reference name="head">
|
27 |
+
<block type="core/template" name="brainsins_js" after="-">
|
28 |
+
<action method="setTemplate"
|
29 |
+
ifconfig="brainsins_recommender_options/brainsins_recommender_general/enabled" after="-">
|
30 |
+
<template>brainsins/recommender/header.phtml</template>
|
31 |
+
</action>
|
32 |
+
</block>
|
33 |
+
</reference>
|
34 |
+
<reference name="before_body_end">
|
35 |
+
<block type="core/template" name="brainsins_js" after="-">
|
36 |
+
<action method="setTemplate"
|
37 |
+
ifconfig="brainsins_recommender_options/brainsins_recommender_general/enabled" after="-">
|
38 |
+
<template>brainsins/recommender/js.phtml</template>
|
39 |
+
</action>
|
40 |
+
</block>
|
41 |
+
</reference>
|
42 |
+
</default>
|
43 |
</layout>
|
app/design/frontend/base/default/template/brainsins/recommender/.DS_Store
CHANGED
Binary file
|
app/design/frontend/base/default/template/brainsins/recommender/header.phtml
ADDED
@@ -0,0 +1,116 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php $_enabled = Mage::getStoreConfigFlag('brainsins_recommender_options/brainsins_recommender_general/enabled', Mage::app()->getStore()->getStoreId()); ?>
|
2 |
+
<?php if ($_enabled): ?>
|
3 |
+
<?php
|
4 |
+
|
5 |
+
$_bskey = Mage::getStoreConfig('brainsins_recommender_options/brainsins_recommender_general/bs_key', Mage::app()->getStore()->getStoreId());
|
6 |
+
$_bs_ajax_tracking = Mage::getStoreConfig('brainsins_recommender_options/brainsins_recommender_advanced/ajax_tracking', Mage::app()->getStore()->getStoreId());
|
7 |
+
$_script_path = '"/brainsins.js"';
|
8 |
+
$_bs_custom_script = Mage::getStoreConfig('brainsins_recommender_options/brainsins_recommender_advanced/custom_script', Mage::app()->getStore()->getStoreId());
|
9 |
+
$_custom_script_path = "/$_bskey/$_bskey.js";
|
10 |
+
|
11 |
+
?>
|
12 |
+
|
13 |
+
<!-- BrainSINS Code Starts -->
|
14 |
+
<script type='text/javascript'>
|
15 |
+
|
16 |
+
function loadBrainSINSScript(path) {
|
17 |
+
var bs = document.createElement('script');
|
18 |
+
bs.type = 'text/javascript';
|
19 |
+
bs.async = true;
|
20 |
+
bs.src = (document.location.protocol == 'https:' ? 'https://' : 'http://' ) + 'd2xkqxdy6ewr93.cloudfront.net' + path;
|
21 |
+
var head = document.getElementsByTagName('head')[0];
|
22 |
+
head.appendChild(bs);
|
23 |
+
}
|
24 |
+
|
25 |
+
function bsTrackProductCallback() {
|
26 |
+
var cookies = BrainSINS.Cookies;
|
27 |
+
var constants = BrainSINS.Constants;
|
28 |
+
var url = cookies.get(constants.urlNext);
|
29 |
+
self.location = url;
|
30 |
+
return false;
|
31 |
+
}
|
32 |
+
;
|
33 |
+
|
34 |
+
function bsTrackProductClicked(productId, idRecommendation, idPrevPage, url) {
|
35 |
+
var cookies = BrainSINS.Cookies;
|
36 |
+
var constants = BrainSINS.Constants;
|
37 |
+
cookies.set(constants.urlNext, url, constants.daysInCookie);
|
38 |
+
cookies.set(constants.idRecommendation, idRecommendation,
|
39 |
+
constants.daysInCookie);
|
40 |
+
cookies.set(constants.idPrevPage, idPrevPage, constants.daysInCookie);
|
41 |
+
BrainSINSTracker.trackProductview(productId, "bsTrackProductCallback");
|
42 |
+
return false;
|
43 |
+
}
|
44 |
+
;
|
45 |
+
|
46 |
+
function bsGetCookie(name) {
|
47 |
+
var value = "; " + document.cookie;
|
48 |
+
var parts = value.split("; " + name + "=");
|
49 |
+
if (parts.length == 2)
|
50 |
+
return parts.pop().split(";").shift();
|
51 |
+
return "";
|
52 |
+
}
|
53 |
+
|
54 |
+
function bsSetCookie(propertyName, value, domain) {
|
55 |
+
document.cookie = propertyName + "=" + encodeURI(value) + ";path=/"
|
56 |
+
+ ";max-age=31536000" + (domain != null ? ";domain=" + domain : "");
|
57 |
+
}
|
58 |
+
|
59 |
+
function bsUnsetCookie(propertyName, domain) {
|
60 |
+
document.cookie = propertyName + "='';path=/"
|
61 |
+
+ ";max-age=0" + (domain != null ? ";domain=" + domain : "");
|
62 |
+
}
|
63 |
+
|
64 |
+
|
65 |
+
function requestBrainSINSRecommendations(storeUrl, recommenderId, template, div, maxResults, productId, userId, filterCategories, filterLevel, callback, debug) {
|
66 |
+
|
67 |
+
if (productId == null) productId = BrainSINSData.productId;
|
68 |
+
|
69 |
+
if (userId == null) userId = bsGetCookie("bsCoId");
|
70 |
+
|
71 |
+
var url = storeUrl + "/brainsins/recommendation/recommendations";
|
72 |
+
url += "?recommenderId=" + recommenderId;
|
73 |
+
url += "&template=" + template;
|
74 |
+
url += productId == null ? "" : "&productId=" + productId;
|
75 |
+
url += userId == null ? "" : "&userId=" + userId;
|
76 |
+
url += maxResults == null ? "" : "&maxResults=" + maxResults;
|
77 |
+
url += filterCategories == null ? "" : "&filterCategories=" + filterCategories;
|
78 |
+
url += filterLevel == null ? "" : "&filterLevel=" + filterLevel;
|
79 |
+
|
80 |
+
url += "&rnd=" + new Date().getTime();
|
81 |
+
//brainsins/smartecommerce/test.phtml
|
82 |
+
if (debug) {
|
83 |
+
console.log(url);
|
84 |
+
}
|
85 |
+
new Ajax.Request(url,
|
86 |
+
{
|
87 |
+
method: "get",
|
88 |
+
onSuccess: function (transport) {
|
89 |
+
document.getElementById(div).innerHTML = transport.responseText;
|
90 |
+
if (typeof callback == "function") {
|
91 |
+
callback();
|
92 |
+
}
|
93 |
+
}
|
94 |
+
}
|
95 |
+
);
|
96 |
+
|
97 |
+
}
|
98 |
+
|
99 |
+
var brainsins_token = "<?php echo $_bskey ?>";
|
100 |
+
var brainsins_api_mode = "B";
|
101 |
+
var BrainSINSData = {
|
102 |
+
"version" : "magento-<?php echo Mage::helper('brainsins_recommender')->getExtensionVersion() ?>"
|
103 |
+
};
|
104 |
+
|
105 |
+
|
106 |
+
<?php if (!$_bs_ajax_tracking):?>
|
107 |
+
loadBrainSINSScript('/brainsins.js');
|
108 |
+
<?php if ($_bs_custom_script):?>
|
109 |
+
var bs_custom_script = true;
|
110 |
+
loadBrainSINSScript('<?php echo $_bs_custom_script_path ?>');
|
111 |
+
<?php endif;?>
|
112 |
+
<?php endif;?>
|
113 |
+
|
114 |
+
</script>
|
115 |
+
<!-- BrainSINS Code Ends -->
|
116 |
+
<?php endif; ?>
|
app/design/frontend/base/default/template/brainsins/recommender/js.phtml
CHANGED
@@ -1,414 +1,233 @@
|
|
1 |
<?php $_enabled = Mage::getStoreConfigFlag('brainsins_recommender_options/brainsins_recommender_general/enabled', Mage::app()->getStore()->getStoreId()); ?>
|
2 |
-
<?php if($_enabled)
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
if(Mage::getSingleton('core/cookie')->get('brainsins_login'))
|
214 |
-
Mage::getSingleton('core/cookie')->set('brainsins_login', '0', time()+86400, '/');
|
215 |
-
if(Mage::getSingleton('core/cookie')->get('brainsins_logout'))
|
216 |
-
Mage::getSingleton('core/cookie')->set('brainsins_logout', '0', time()+86400, '/');
|
217 |
-
if(Mage::getSingleton('core/cookie')->get('brainsins_news'))
|
218 |
-
Mage::getSingleton('core/cookie')->set('brainsins_news', '0', time()+86400, '/');
|
219 |
-
unset($customer);
|
220 |
-
}
|
221 |
-
?>
|
222 |
-
<?php
|
223 |
-
if(!$_bs_ajax_tracking && $bs_login && $bs_login != '0' && $bs_register == '0')
|
224 |
-
{
|
225 |
-
if($email_tracking == '1')
|
226 |
-
{
|
227 |
-
$customer_id = Mage::getSingleton('core/cookie')->get('brainsins_login');
|
228 |
-
$customer = Mage::getModel('customer/customer')->load($customer_id);
|
229 |
-
$subscriber = Mage::getModel('newsletter/subscriber')->loadByEmail($customer->getEmail());
|
230 |
-
if($subscriber->getId() && $subscriber->getSubscriberStatus() == '1')
|
231 |
-
{
|
232 |
-
Mage::getSingleton('core/cookie')->delete('brainsins_login');
|
233 |
-
$lang = explode('_', Mage::app()->getLocale()->getLocaleCode());
|
234 |
-
echo 'BrainSINSData.userEmail = "' . $customer->getEmail() .'";
|
235 |
-
BrainSINSData.userNewsletter = 1;
|
236 |
-
BrainSINSData.login = 1;';
|
237 |
-
}
|
238 |
-
else
|
239 |
-
{
|
240 |
-
Mage::getSingleton('core/cookie')->delete('brainsins_login');
|
241 |
-
$lang = explode('_', Mage::app()->getLocale()->getLocaleCode());
|
242 |
-
echo 'BrainSINSData.userEmail = "' . $customer->getEmail() .'";
|
243 |
-
BrainSINSData.userNewsletter = 0;
|
244 |
-
BrainSINSData.login = 1;';
|
245 |
}
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
}
|
266 |
-
Mage::getSingleton('core/cookie')->set('brainsins_login', '0', time()+86400, '/');
|
267 |
-
unset($customer);
|
268 |
-
}
|
269 |
-
?>
|
270 |
-
<?php
|
271 |
-
if(!$_bs_ajax_tracking && $bs_logout && $bs_logout != '0' && $bs_register == '0')
|
272 |
-
{
|
273 |
-
echo 'BrainSINSData.logout = 1;';
|
274 |
-
Mage::getSingleton('core/cookie')->set('brainsins_logout', '0', time()+86400, '/');
|
275 |
-
}
|
276 |
-
?>
|
277 |
-
<?php
|
278 |
-
if(!$_bs_ajax_tracking && $bs_news && $bs_news != '0' && $bs_register == '0')
|
279 |
-
{
|
280 |
-
$customer_id = Mage::getSingleton('core/cookie')->get('brainsins_news');
|
281 |
-
$customer = Mage::getModel('customer/customer')->load($customer_id);
|
282 |
-
$subscriber = Mage::getModel('newsletter/subscriber')->loadByEmail($customer->getEmail());
|
283 |
-
$lang = explode('_', Mage::app()->getLocale()->getLocaleCode());
|
284 |
-
if($subscriber->getSubscriberStatus() == '3')
|
285 |
-
{
|
286 |
-
echo 'BrainSINSData.userEmail = "' . $customer->getEmail() .'";
|
287 |
-
BrainSINSData.userNewsletter = 0;
|
288 |
-
BrainSINSData.login = 1;';
|
289 |
-
}
|
290 |
-
elseif($subscriber->getSubscriberStatus() == '1') {
|
291 |
-
echo 'BrainSINSData.userEmail = "' . $customer->getEmail() .'";
|
292 |
-
BrainSINSData.userNewsletter = 1;
|
293 |
-
BrainSINSData.login = 1;';
|
294 |
-
}
|
295 |
-
Mage::getSingleton('core/cookie')->set('brainsins_news', '0', time()+86400, '/');
|
296 |
-
unset($customer);unset($subscriber);
|
297 |
-
}
|
298 |
-
?>
|
299 |
-
<?php
|
300 |
-
if ($_bs_ajax_tracking) {
|
301 |
-
$_url = Mage::getUrl("brainsins/tracking/bdata", array('_secure' => true));
|
302 |
-
?>
|
303 |
-
var bdata_controller_url = "<?php echo $_url?>";
|
304 |
-
bdata_controller_url += "rnd/" + new Date().getTime() + "/";
|
305 |
-
bdata_controller_url += "bdata/" + encodeURIComponent(JSON.stringify(BrainSINSData));
|
306 |
-
|
307 |
-
bdata_controller_url = bdata_controller_url.replace("https:","").replace("http:","");
|
308 |
-
|
309 |
-
new Ajax.Request(bdata_controller_url, {
|
310 |
-
method: "get",
|
311 |
-
onSuccess: function(transport) {
|
312 |
-
var newBdata = transport.responseJSON;
|
313 |
-
if (newBdata) {
|
314 |
-
BrainSINSData = newBdata;
|
315 |
-
}
|
316 |
-
var bs = document.createElement('script');
|
317 |
-
bs.type = 'text/javascript';
|
318 |
-
bs.async = true;
|
319 |
-
bs.src = (document.location.protocol == 'https:' ? 'https://d2xkqxdy6ewr93.cloudfront.net' : 'http://clients.cdn.brainsins.com') + <?php echo $_script_path?> ;
|
320 |
-
var head = document.getElementsByTagName('head')[0];
|
321 |
-
head.appendChild(bs);
|
322 |
-
var domain = "." + window.location.hostname;
|
323 |
-
bsUnsetCookie("brainsins_login", domain);
|
324 |
-
bsUnsetCookie("brainsins_news", domain);
|
325 |
-
bsUnsetCookie("brainsins_register", domain);
|
326 |
-
bsUnsetCookie("brainsins_logout", domain);
|
327 |
-
}
|
328 |
-
});
|
329 |
-
|
330 |
-
<?php
|
331 |
-
}
|
332 |
-
?>
|
333 |
-
<?php if($_bs_custom_script):?>
|
334 |
-
|
335 |
-
var bs = document.createElement('script');
|
336 |
-
bs.type = 'text/javascript';
|
337 |
-
bs.async = true;
|
338 |
-
bs.src = (document.location.protocol == 'https:' ? 'https://d2xkqxdy6ewr93.cloudfront.net' : 'http://clients.cdn.brainsins.com') + '<?php echo $_custom_script_path?>';
|
339 |
-
var head = document.getElementsByTagName('head')[0];
|
340 |
-
head.appendChild(bs);
|
341 |
-
<?php endif; ?>
|
342 |
-
</script>
|
343 |
-
<script type="text/javascript">
|
344 |
-
function bsTrackProductCallback() {
|
345 |
-
var cookies = BrainSINS.Cookies;
|
346 |
-
var constants = BrainSINS.Constants;
|
347 |
-
var url = cookies.get(constants.urlNext);
|
348 |
-
self.location = url;
|
349 |
-
return false;
|
350 |
-
};
|
351 |
-
function bsTrackProductClicked(productId, idRecommendation, idPrevPage, url) {
|
352 |
-
var cookies = BrainSINS.Cookies;
|
353 |
-
var constants = BrainSINS.Constants;
|
354 |
-
cookies.set(constants.urlNext, url, constants.daysInCookie);
|
355 |
-
cookies.set(constants.idRecommendation, idRecommendation,
|
356 |
-
constants.daysInCookie);
|
357 |
-
cookies.set(constants.idPrevPage, idPrevPage, constants.daysInCookie);
|
358 |
-
BrainSINSTracker.trackProductview(productId, "bsTrackProductCallback");
|
359 |
-
return false;
|
360 |
-
};
|
361 |
-
|
362 |
-
function bsGetCookie(name) {
|
363 |
-
var value = "; " + document.cookie;
|
364 |
-
var parts = value.split("; " + name + "=");
|
365 |
-
if (parts.length == 2)
|
366 |
-
return parts.pop().split(";").shift();
|
367 |
-
return "";
|
368 |
-
}
|
369 |
-
|
370 |
-
function bsSetCookie(propertyName, value, domain) {
|
371 |
-
document.cookie = propertyName + "=" + encodeURI(value) + ";path=/"
|
372 |
-
+ ";max-age=31536000" + (domain != null ? ";domain=" + domain : "");
|
373 |
-
}
|
374 |
-
|
375 |
-
function bsUnsetCookie(propertyName, domain) {
|
376 |
-
document.cookie = propertyName + "='';path=/"
|
377 |
-
+ ";max-age=0" + (domain != null ? ";domain=" + domain : "");
|
378 |
-
}
|
379 |
-
|
380 |
-
|
381 |
-
function requestBrainSINSRecommendations(storeUrl, recommenderId, template, div, maxResults, productId, userId, filterCategories, filterLevel, callback, debug) {
|
382 |
-
|
383 |
-
if (productId == null) productId = BrainSINSData.productId;
|
384 |
-
|
385 |
-
if (userId == null) userId = bsGetCookie("bsCoId");
|
386 |
-
|
387 |
-
var url = storeUrl + "/brainsins/recommendation/recommendations";
|
388 |
-
url += "?recommenderId=" + recommenderId;
|
389 |
-
url += "&template=" + template;
|
390 |
-
url += productId == null ? "" : "&productId=" + productId;
|
391 |
-
url += userId == null ? "" : "&userId=" + userId;
|
392 |
-
url += maxResults == null ? "" : "&maxResults=" + maxResults;
|
393 |
-
url += filterCategories == null ? "" : "&filterCategories=" + filterCategories;
|
394 |
-
url += filterLevel == null ? "" : "&filterLevel=" + filterLevel;
|
395 |
-
|
396 |
-
url += "&rnd=" + new Date().getTime();
|
397 |
-
//brainsins/smartecommerce/test.phtml
|
398 |
-
if (debug) {
|
399 |
-
console.log(url);
|
400 |
-
}
|
401 |
-
new Ajax.Request(url,
|
402 |
-
{ method: "get",
|
403 |
-
onSuccess: function(transport) {
|
404 |
-
document.getElementById(div).innerHTML = transport.responseText;
|
405 |
-
if (typeof callback == "function") {
|
406 |
-
callback();
|
407 |
-
}
|
408 |
-
}}
|
409 |
-
);
|
410 |
-
|
411 |
-
}
|
412 |
-
</script>
|
413 |
-
<!-- BrainSINS Code Ends -->
|
414 |
<?php endif; ?>
|
1 |
<?php $_enabled = Mage::getStoreConfigFlag('brainsins_recommender_options/brainsins_recommender_general/enabled', Mage::app()->getStore()->getStoreId()); ?>
|
2 |
+
<?php if ($_enabled):
|
3 |
+
$_bskey = Mage::getStoreConfig('brainsins_recommender_options/brainsins_recommender_general/bs_key', Mage::app()->getStore()->getStoreId());
|
4 |
+
$_bs_ajax_tracking = Mage::getStoreConfig('brainsins_recommender_options/brainsins_recommender_advanced/ajax_tracking', Mage::app()->getStore()->getStoreId());
|
5 |
+
$_bs_custom_script = Mage::getStoreConfig('brainsins_recommender_options/brainsins_recommender_advanced/custom_script', Mage::app()->getStore()->getStoreId());
|
6 |
+
$_apiMode = Mage::getStoreConfig('brainsins_recommender_options/brainsins_recommender_advanced/api_mode', Mage::app()->getStore()->getStoreId());
|
7 |
+
$_script_path = "/brainsins.js";
|
8 |
+
$_custom_script_path = "/$_bskey/$_bskey.js";
|
9 |
+
$_url = Mage::getUrl("brainsins/tracking/bdata", array('_secure' => true));
|
10 |
+
|
11 |
+
function bsIsHomePage()
|
12 |
+
{
|
13 |
+
return Mage::app()->getRequest()->getControllerName() . '/' . Mage::app()->getRequest()->getActionName() . '/' . Mage::app()->getRequest()->getRouteName() == 'index/index/cms';
|
14 |
+
}
|
15 |
+
|
16 |
+
function bsIsProductPage()
|
17 |
+
{
|
18 |
+
return Mage::app()->getRequest()->getControllerName() . '/' . Mage::app()->getRequest()->getActionName() == 'product/view';
|
19 |
+
}
|
20 |
+
|
21 |
+
function bsIsCartPage()
|
22 |
+
{
|
23 |
+
return Mage::app()->getRequest()->getControllerName() . '/' . Mage::app()->getRequest()->getActionName() == 'cart/index';
|
24 |
+
}
|
25 |
+
|
26 |
+
function bsIsCheckoutPage()
|
27 |
+
{
|
28 |
+
return Mage::app()->getRequest()->getControllerName() . '/' . Mage::app()->getRequest()->getActionName() == 'onepage/index' ||
|
29 |
+
Mage::app()->getRequest()->getControllerName() . '/' . Mage::app()->getRequest()->getActionName() == 'multishipping/addresses';
|
30 |
+
}
|
31 |
+
|
32 |
+
function bsIsThankYouPage()
|
33 |
+
{
|
34 |
+
return Mage::app()->getRequest()->getControllerName() . '/' . Mage::app()->getRequest()->getActionName() == 'onepage/success';
|
35 |
+
}
|
36 |
+
|
37 |
+
function bsIsCategoryPage()
|
38 |
+
{
|
39 |
+
return Mage::app()->getRequest()->getControllerName() . '/' . Mage::app()->getRequest()->getActionName() == 'category/view';
|
40 |
+
}
|
41 |
+
|
42 |
+
function bsCurrentProduct()
|
43 |
+
{
|
44 |
+
return Mage::helper('brainsins_recommender')->productIdForTracking(Mage::registry('current_product'));
|
45 |
+
}
|
46 |
+
|
47 |
+
function bsCurrentCategory()
|
48 |
+
{
|
49 |
+
return Mage::helper('brainsins_recommender')->categoryIdForTracking(Mage::registry('current_category'));
|
50 |
+
}
|
51 |
+
|
52 |
+
function bsBuildRecommendationsRequest()
|
53 |
+
{
|
54 |
+
$recommenders = Array();
|
55 |
+
return $recommenders;
|
56 |
+
}
|
57 |
+
|
58 |
+
function bsCartInfo($sendWs = false)
|
59 |
+
{
|
60 |
+
$quote = Mage::getSingleton('checkout/session')->getQuote();
|
61 |
+
//$cart["products"] = Mage::helper('brainsins_recommender')->processQuote($quote);
|
62 |
+
$cart = Mage::helper('brainsins_recommender')->processQuote($quote);
|
63 |
+
return $cart;
|
64 |
+
}
|
65 |
+
|
66 |
+
function bsLoginInfo($bdata)
|
67 |
+
{
|
68 |
+
$bs_register = Mage::getSingleton('core/cookie')->get('brainsins_register');
|
69 |
+
$bs_login = Mage::getSingleton('core/cookie')->get('brainsins_login');
|
70 |
+
$bs_logout = Mage::getSingleton('core/cookie')->get('brainsins_logout');
|
71 |
+
$bs_news = Mage::getSingleton('core/cookie')->get('brainsins_news');
|
72 |
+
|
73 |
+
$email_tracking = Mage::getStoreConfig('brainsins_recommender_options/brainsins_recommender_general/email_tracking', Mage::app()->getStore()->getStoreId());
|
74 |
+
|
75 |
+
if ($bs_register) {
|
76 |
+
$customer_id = Mage::getSingleton('core/cookie')->get('brainsins_register');
|
77 |
+
} else if ($bs_login) {
|
78 |
+
$customer_id = Mage::getSingleton('core/cookie')->get('brainsins_login');
|
79 |
+
} else if ($bs_logout) {
|
80 |
+
$customer_id = Mage::getSingleton('core/cookie')->get('brainsins_logout');
|
81 |
+
}
|
82 |
+
$customer = $customer_id ? Mage::getModel('customer/customer')->load($customer_id) : false;
|
83 |
+
$subscriber = $customer ? Mage::getModel('newsletter/subscriber')->loadByEmail($customer->getEmail()) : false;
|
84 |
+
$subscribed = $subscriber && $subscriber->getId() && $subscriber->getSubscriberStatus() == '1';
|
85 |
+
|
86 |
+
if ($customer && ($bs_register || $bs_login)) {
|
87 |
+
$bdata["login"] = "1";
|
88 |
+
$bdata["userEmail"] = $customer->getEmail();
|
89 |
+
if ($email_tracking == "1") {
|
90 |
+
$bdata["userNewsletter"] = $subscribed ? "1" : "0";
|
91 |
+
} else if ($email_tracking == "2") {
|
92 |
+
$bdata["userNewsletter"] = "1";
|
93 |
+
} else {
|
94 |
+
$bdata["userNewsletter"] = "0";
|
95 |
+
}
|
96 |
+
} else if (Mage::getSingleton('core/cookie')->get('bsUl') === "1") {
|
97 |
+
$bdata["logout"] = 1;
|
98 |
+
}
|
99 |
+
|
100 |
+
return $bdata;
|
101 |
+
|
102 |
+
|
103 |
+
}
|
104 |
+
|
105 |
+
function bsBuildBdata($doLogin)
|
106 |
+
{
|
107 |
+
$bdata = Array();
|
108 |
+
$bdata["language"] = Mage::app()->getStore()->getCode();
|
109 |
+
$bdata["currency"] = Mage::app()->getStore()->getCurrentCurrencyCode();
|
110 |
+
$pageType = "other";
|
111 |
+
|
112 |
+
if (bsIsHomePage()) {
|
113 |
+
$pageType = "home";
|
114 |
+
$bdata["pageType"] = "home";
|
115 |
+
}
|
116 |
+
|
117 |
+
if (bsIsCategoryPage()) {
|
118 |
+
$pageType = "category";
|
119 |
+
$bdata["pageType"] = "category";
|
120 |
+
$bdata["categoryId"] = bsCurrentCategory();
|
121 |
+
}
|
122 |
+
|
123 |
+
if (bsIsProductPage()) {
|
124 |
+
$pageType = "product";
|
125 |
+
$bdata["pageType"] = "product";
|
126 |
+
$bdata["productId"] = bsCurrentProduct();
|
127 |
+
}
|
128 |
+
|
129 |
+
if (bsIsCartPage()) {
|
130 |
+
$pageType = "cart";
|
131 |
+
$bdata["pageType"] = "cart";
|
132 |
+
$bdata["cart"] = bsCartInfo(false);
|
133 |
+
}
|
134 |
+
|
135 |
+
if (bsIsCheckoutPage()) {
|
136 |
+
$pageType = "checkout";
|
137 |
+
$bdata["pageType"] = "checkout";
|
138 |
+
}
|
139 |
+
|
140 |
+
if (bsIsThankYouPage()) {
|
141 |
+
$pageType = "thankYou";
|
142 |
+
$bdata["pageType"] = "thankYou";
|
143 |
+
$orderId = Mage::getSingleton('checkout/session')->getLastOrderId();
|
144 |
+
$order = Mage::getModel('sales/order')->load($orderId);
|
145 |
+
|
146 |
+
$total = Mage::helper('brainsins_recommender')->getTotalAmount($order);
|
147 |
+
if ($total) {
|
148 |
+
$bdata["totalAmount"] = $total;
|
149 |
+
try{
|
150 |
+
$bdata["idPurchase"] = $order->getIncrementId();
|
151 |
+
}catch(Exception $e){
|
152 |
+
error_log("[BrainSINS] Id purchase not found");
|
153 |
+
}
|
154 |
+
}
|
155 |
+
}
|
156 |
+
|
157 |
+
$recommenders = Mage::helper('brainsins_recommender')->getPageRecommenders($pageType);
|
158 |
+
if ($recommenders && count($recommenders > 0)) {
|
159 |
+
$bdata["recommenders"] = $recommenders;
|
160 |
+
}
|
161 |
+
|
162 |
+
if ($doLogin) {
|
163 |
+
$bdata = bsLoginInfo($bdata);
|
164 |
+
}
|
165 |
+
|
166 |
+
return $bdata;
|
167 |
+
}
|
168 |
+
|
169 |
+
|
170 |
+
?>
|
171 |
+
<!-- BrainSINS Code Starts -->
|
172 |
+
<script type='text/javascript'>
|
173 |
+
|
174 |
+
<?php
|
175 |
+
|
176 |
+
$_lang = Mage::app()->getStore()->getCode();
|
177 |
+
$currentCurrencyCode = Mage::app()->getStore()->getCurrentCurrencyCode();
|
178 |
+
|
179 |
+
if ($_bs_ajax_tracking) {
|
180 |
+
$bdata = bsBuildBdata(false);
|
181 |
+
} else {
|
182 |
+
$bdata = bsBuildBdata(true);
|
183 |
+
$bdata["trackingMode"] = "standard";
|
184 |
+
}
|
185 |
+
|
186 |
+
foreach ($bdata as $key => $value) {
|
187 |
+
echo "BrainSINSData.$key = " . json_encode($bdata[$key]) . ";" . PHP_EOL;
|
188 |
+
}
|
189 |
+
|
190 |
+
?>
|
191 |
+
|
192 |
+
<?php if ($_bs_ajax_tracking):?>
|
193 |
+
|
194 |
+
var bdata_controller_url = "<?php echo $_url?>";
|
195 |
+
bdata_controller_url += "rnd/" + new Date().getTime() + "/";
|
196 |
+
//bdata_controller_url += "bdata/" + encodeURIComponent(JSON.stringify(BrainSINSData));
|
197 |
+
bdata_controller_url = bdata_controller_url.replace("https:", "").replace("http:", "");
|
198 |
+
|
199 |
+
new Ajax.Request(bdata_controller_url, {
|
200 |
+
method: "get",
|
201 |
+
onSuccess: function (transport) {
|
202 |
+
var newBdata = transport.responseJSON;
|
203 |
+
if (newBdata) {
|
204 |
+
BrainSINSData.login = newBdata.login;
|
205 |
+
BrainSINSData.userNewsletter = newBdata.userNewsletter;
|
206 |
+
BrainSINSData.userEmail = newBdata.userEmail;
|
207 |
+
BrainSINSData.logout = newBdata.logout;
|
208 |
+
BrainSINSData.trackingMode = "ajax";
|
209 |
+
if (typeof showBsInfo == "function") {
|
210 |
+
setTimeout(function () {
|
211 |
+
showBsInfo();
|
212 |
+
}, 1000)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
213 |
}
|
214 |
+
}
|
215 |
+
|
216 |
+
var domain = "." + window.location.hostname;
|
217 |
+
bsUnsetCookie("brainsins_login", domain);
|
218 |
+
bsUnsetCookie("brainsins_news", domain);
|
219 |
+
bsUnsetCookie("brainsins_register", domain);
|
220 |
+
bsUnsetCookie("brainsins_logout", domain);
|
221 |
+
|
222 |
+
loadBrainSINSScript('/brainsins.js');
|
223 |
+
<?php if ($_bs_custom_script):?>
|
224 |
+
var bs_custom_script = true;
|
225 |
+
loadBrainSINSScript('<?php echo $_bs_custom_script_path ?>');
|
226 |
+
<?php endif;?>
|
227 |
+
|
228 |
+
}
|
229 |
+
});
|
230 |
+
<?php endif;?>
|
231 |
+
</script>
|
232 |
+
<!-- BrainSINS Code Ends -->
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
233 |
<?php endif; ?>
|
package.xml
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>Brainsins_Recommender</name>
|
4 |
-
<version>2.
|
5 |
<stability>stable</stability>
|
6 |
<license uri="http://opensource.org/licenses/gpl-license.php">GPL</license>
|
7 |
<channel>community</channel>
|
@@ -18,11 +18,12 @@ Some key features:
|
|
18 |
* Easily create marketing rules that modify your e-commerce website or interact with your customers according to user behavior.
|
19 |
* Use gamification to engage and cultivate the loyalty of your customers and grow a community of prescribers.
|
20 |
* We provide a full e-commerce analytics solution to help you understand the evolution of your online business.</description>
|
21 |
-
<notes>
|
22 |
-
|
23 |
-
<
|
24 |
-
<
|
25 |
-
<
|
|
|
26 |
<compatible/>
|
27 |
<dependencies><required><php><min>5.2.0</min><max>7.0.0</max></php></required></dependencies>
|
28 |
</package>
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>Brainsins_Recommender</name>
|
4 |
+
<version>2.1.2</version>
|
5 |
<stability>stable</stability>
|
6 |
<license uri="http://opensource.org/licenses/gpl-license.php">GPL</license>
|
7 |
<channel>community</channel>
|
18 |
* Easily create marketing rules that modify your e-commerce website or interact with your customers according to user behavior.
|
19 |
* Use gamification to engage and cultivate the loyalty of your customers and grow a community of prescribers.
|
20 |
* We provide a full e-commerce analytics solution to help you understand the evolution of your online business.</description>
|
21 |
+
<notes>[New] BrainSINSData now receives Magento's purchase ID in the thankYou page.
|
22 |
+
[Fix] onPayment now sends Magento's idPurchase to the API.</notes>
|
23 |
+
<authors><author><name>BrainSINS</name><user>Developer</user><email>support@brainsins.com</email></author></authors>
|
24 |
+
<date>2016-06-28</date>
|
25 |
+
<time>14:52:41</time>
|
26 |
+
<contents><target name="magecommunity"><dir name="Brainsins"><dir name="Recommender"><dir name="Block"><dir name="Adminhtml"><dir name="System"><dir name="Config"><dir name="Fieldset"><file name="Expanded.php" hash="8fb32bbec5454610a8aab055c8891bf7"/><file name="Help.php" hash="df89b5f0a9d7510aa1393c888324e6dd"/></dir><dir name="Form"><dir name="Fieldset"><dir name="Dashboard"><file name="Dashboard.php" hash="7fcdcc0b077e1fcd40f209ada40d183e"/></dir></dir></dir><dir name="Source"><dir name="Feeds"><file name="ProductOffline.php" hash="d2480bf9d3a79f41b5889c46f747c008"/><file name="ProductOnline.php" hash="8a64b9b4cf0b1e57e0afa19889271934"/></dir><dir name="Recommenders"><file name="Cart.php" hash="3c8b3efaa4edfb696483b7e04787f852"/><file name="Category.php" hash="df3bdf28ef21e61d954d561e5bf69e13"/><file name="Checkout.php" hash="a4cf4b2b0df44b8efdc983a2616105c1"/><file name="Home.php" hash="c77c1afbdac04b9eec90e749aa67a6f9"/><file name="Product.php" hash="2ca0f98935197a5f515d0882e4177e00"/><file name="Show.php" hash="108263f746e4650ad46878b97edfd43c"/></dir><file name=".DS_Store" hash="cd13bedbe6a831f3f69fe4edf83e8755"/></dir><file name=".DS_Store" hash="ffb635d260d4dc0cfe910fcfa4678f0b"/></dir><file name=".DS_Store" hash="e76a7d37275624e6d31515a1898a2639"/></dir><file name=".DS_Store" hash="9f70fac690f62d5ca42c10fdf22cec46"/></dir><file name="Recommendations.php" hash="223234fb802b171bc46d4840e9a3e325"/><file name=".DS_Store" hash="4760d19954d6579511c6aa164b4b8b24"/></dir><dir name="Helper"><file name="Data.php" hash="5ad299fc315394812b27ffa060da6e65"/><file name="sendBrainsinsWS.log" hash="3ea4f9e70438ab097c878da3f1929a0f"/></dir><dir name="Model"><dir name="Adminhtml"><dir name="System"><dir name="Config"><dir name="Backend"><file name="Cron.php" hash="f0187336296261795b3163d7da20a24d"/><file name="Serialized.php" hash="c68122c82e7e1fc13a2575ac4e417d78"/></dir><dir name="Source"><file name="Apimode.php" hash="80852b4069d03c7a3b70390d67d2f875"/><file name="Attributes.php" hash="c223fe5451b35bb8779ec8d3e077d4b7"/><file name="Configurableproducttracking.php" hash="3b3c28b4142d90abafeacb3daa13f035"/><file name="Currencies.php" hash="478e4c7a7ca1d3d8d984c37af1d487e6"/><file name="Emailtracking.php" hash="017ec03450cff0317cb390830eca26ef"/><file name="Totalamounttrackingoptions.php" hash="0bba8d100a8a78030dd6a12ffe443c40"/></dir></dir></dir></dir><file name="Brainsins.php" hash="4012634c558c030effa04c92485621ba"/><file name="Cron.php" hash="04e1ed2c59fa488e614fe903abac45d1"/><file name="Observer.php" hash="c5975e7872c5697c0f9b725a92a967b3"/><file name="Recommendation.php" hash="a8918aceeb106b2b5afe8664c87229ef"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="FeedsController.php" hash="d318a3d4ba80b9587229a4f364bd3de3"/></dir><file name="CartController.php" hash="c1e857c1f5dc3f0ecf202bb825f48a84"/><file name="FeedController.php" hash="f537330700e1cc70e4260357af6a2db0"/><file name="LoginController.php" hash="3e2e8ff8564e987ba1550f54246737ed"/><file name="PurchaseController.php" hash="584b0ba37024bb84cf0171fc23fb2a9d"/><file name="RecommendationController.php" hash="1ead8f07f6ff07b5ed2283581a4ad1ab"/><file name="TrackingController.php" hash="04b22c332cdd9ad47dfab42c39bab66b"/><file name=".DS_Store" hash="194577a7e20bdcc7afbb718f502c134c"/></dir><dir name="etc"><file name="config.xml" hash="0a8d9cfb0629d8968d9ffd4f4f1925a6"/><file name="system.xml" hash="7c5e34a435ca19760334398a8f7b5b1b"/></dir><file name=".DS_Store" hash="76dbb01bb4009b0c680f281ddec18943"/></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="brainsins_recommender.xml" hash="a0008aeb7f895e96b60995792d37bed9"/></dir><dir name="template"><dir name="brainsins"><dir name="recommender"><file name="help.phtml" hash="890622a39d07bd9029fbab39e3f7abf7"/></dir></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="brainsins_recommender.xml" hash="6a98a70604110c1fb7596ce0cdc93fb9"/></dir><dir name="template"><dir name="brainsins"><dir name="recommender"><file name="header.phtml" hash="6b62cda99ef2323b7c3f5be40f2fdb55"/><file name="js.phtml" hash="b9861fe7a4af0b2bbd0d05496e8ec541"/><file name="sample.phtml" hash="8ee06704ba1f71a60c771e5e8816912a"/><file name=".DS_Store" hash="9ecdd1266824f3c76319dd992d75e3d1"/></dir></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Brainsins_Recommender.xml" hash="c21aad4e40fa1f6116c385a7a244f459"/></dir></target><target name="magelocale"><dir name="en_US"><file name="Brainsins_Recommender.csv" hash="d41d8cd98f00b204e9800998ecf8427e"/></dir><dir name="es_ES"><file name="Brainsins_Recommender.csv" hash="d41d8cd98f00b204e9800998ecf8427e"/></dir></target><target name="mageskin"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="brainsins"><dir name="recommender"><dir name="css"><file name="brainsins_recommender.css" hash="db420d334316b3d19f013c7d1289e6c8"/></dir><dir name="images"><file name="brainsins.png" hash="98f06e0c5eb7668dd7293fc89614f7bc"/><file name="brainsins_logo.png" hash="cb4086cde3e5eef572159bd9f2ebd298"/><file name="feed_file_nok.gif" hash="e4f28607f075a105e53fa3113d84bd26"/><file name="feed_file_ok.gif" hash="834dfafd5f8b44c4b24a4c00add56fcf"/></dir><dir name="js"><file name="brainsins_recommender.js" hash="e30774992d3a502228863676c187abe7"/></dir></dir></dir></dir></dir></dir></target></contents>
|
27 |
<compatible/>
|
28 |
<dependencies><required><php><min>5.2.0</min><max>7.0.0</max></php></required></dependencies>
|
29 |
</package>
|