Version Notes
Optimisation for category
Download this release
Release Info
| Developer | nToklo |
| Extension | ntoklo_recommendations |
| Version | 1.0.7 |
| Comparing to | |
| See all releases | |
Code changes from version 1.0.6 to 1.0.7
- app/code/community/Ntoklo/Recommendations/Block/UniversalVariable.php +1 -1
- app/code/community/Ntoklo/Recommendations/Helper/Data.php +95 -32
- app/code/community/Ntoklo/Recommendations/Model/Service.php +5 -1
- app/code/community/Ntoklo/Recommendations/etc/config.xml +1 -1
- app/code/community/Ntoklo/Recommendations/sql/ntoklo_setup/{mysql4-install-1.0.6.php → mysql4-install-1.0.7.php} +0 -0
- app/design/frontend/base/default/template/ntoklo/recommendations/universal_variable.phtml +1 -1
- app/design/frontend/base/default/template/ntoklo/recommendations/widget/chart_horisontal.phtml +7 -5
- app/design/frontend/base/default/template/ntoklo/recommendations/widget/chart_vertical.phtml +6 -5
- app/locale/en_US/ntoklo_recommendations.csv +0 -16
- js/ntoklo/util.js +1 -44
- package.xml +10 -12
app/code/community/Ntoklo/Recommendations/Block/UniversalVariable.php
CHANGED
|
@@ -65,7 +65,7 @@ class Ntoklo_Recommendations_Block_UniversalVariable extends Mage_Core_Block_Tem
|
|
| 65 |
$pageCategory = Mage::helper('ntoklo_recommendations')->getPageCategory();
|
| 66 |
|
| 67 |
$universalVariable = new Ntoklo_Recommendations_Model_UniversalVariable(array(
|
| 68 |
-
'version' => '1.
|
| 69 |
'magento_version' => Mage::getVersion(),
|
| 70 |
'ntoklo_version' => Mage::helper('ntoklo_recommendations')->getExtensionVersion(),
|
| 71 |
'user' => Mage::helper('ntoklo_recommendations')->getUvMapUser()
|
| 65 |
$pageCategory = Mage::helper('ntoklo_recommendations')->getPageCategory();
|
| 66 |
|
| 67 |
$universalVariable = new Ntoklo_Recommendations_Model_UniversalVariable(array(
|
| 68 |
+
'version' => '1.2',
|
| 69 |
'magento_version' => Mage::getVersion(),
|
| 70 |
'ntoklo_version' => Mage::helper('ntoklo_recommendations')->getExtensionVersion(),
|
| 71 |
'user' => Mage::helper('ntoklo_recommendations')->getUvMapUser()
|
app/code/community/Ntoklo/Recommendations/Helper/Data.php
CHANGED
|
@@ -69,6 +69,13 @@ class Ntoklo_Recommendations_Helper_Data extends Mage_Core_Helper_Abstract {
|
|
| 69 |
private $_activationCode;
|
| 70 |
|
| 71 |
private $_usesNewWidgets;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 72 |
|
| 73 |
/**
|
| 74 |
* @return bool
|
|
@@ -237,19 +244,45 @@ class Ntoklo_Recommendations_Helper_Data extends Mage_Core_Helper_Abstract {
|
|
| 237 |
} else {
|
| 238 |
// Regular page category events
|
| 239 |
$item = new Ntoklo_Recommendations_Model_UniversalVariable(array(
|
| 240 |
-
|
|
|
|
| 241 |
));
|
| 242 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 243 |
// Recommendation click events
|
| 244 |
-
if ($
|
| 245 |
-
|
| 246 |
-
|
| 247 |
-
|
| 248 |
-
|
| 249 |
-
|
|
|
|
| 250 |
}
|
| 251 |
-
|
| 252 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 253 |
|
| 254 |
return $object;
|
| 255 |
}
|
|
@@ -320,14 +353,16 @@ class Ntoklo_Recommendations_Helper_Data extends Mage_Core_Helper_Abstract {
|
|
| 320 |
* @return Ntoklo_Recommendations_Model_UniversalVariable
|
| 321 |
*/
|
| 322 |
public function getUvMapPage() {
|
|
|
|
|
|
|
| 323 |
$pageCategory = $this->getPageCategory();
|
| 324 |
|
| 325 |
$object = new Ntoklo_Recommendations_Model_UniversalVariable(array(
|
| 326 |
-
'
|
| 327 |
));
|
| 328 |
|
| 329 |
if ($pageCategory == self::PAGE_CATEGORY_CATEGORY || $pageCategory == self::PAGE_CATEGORY_PRODUCT) {
|
| 330 |
-
$object->
|
| 331 |
}
|
| 332 |
return $object;
|
| 333 |
}
|
|
@@ -362,6 +397,10 @@ class Ntoklo_Recommendations_Helper_Data extends Mage_Core_Helper_Abstract {
|
|
| 362 |
if ($this->getPageCategory() == self::PAGE_CATEGORY_CATEGORY) {
|
| 363 |
$query = $this->getCategoryPath();
|
| 364 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
| 365 |
|
| 366 |
// Build Items part - search context
|
| 367 |
// If it's a search result page than get the items from Search engine
|
|
@@ -369,7 +408,7 @@ class Ntoklo_Recommendations_Helper_Data extends Mage_Core_Helper_Abstract {
|
|
| 369 |
/** @var $listBlock Mage_Catalog_Block_Product_List */
|
| 370 |
$listBlock = Mage::app()->getLayout()->getBlockSingleton('catalog/product_list');
|
| 371 |
foreach ($listBlock->getLoadedProductCollection() as $product) {
|
| 372 |
-
array_push($items, $this->getUvMapProduct($product));
|
| 373 |
}
|
| 374 |
|
| 375 |
}
|
|
@@ -388,7 +427,7 @@ class Ntoklo_Recommendations_Helper_Data extends Mage_Core_Helper_Abstract {
|
|
| 388 |
* Creates the product UV object
|
| 389 |
* @return Ntoklo_Recommendations_Model_UniversalVariable
|
| 390 |
*/
|
| 391 |
-
public function getUvMapProduct($product = false) {
|
| 392 |
|
| 393 |
if (!$product) {
|
| 394 |
$product = Mage::registry('current_product');
|
|
@@ -417,14 +456,18 @@ class Ntoklo_Recommendations_Helper_Data extends Mage_Core_Helper_Abstract {
|
|
| 417 |
'stock' => (int) Mage::getModel('cataloginventory/stock_item')->loadByProduct($product)->getQty()
|
| 418 |
));
|
| 419 |
|
| 420 |
-
|
| 421 |
-
|
| 422 |
-
|
| 423 |
-
|
| 424 |
-
|
| 425 |
-
|
| 426 |
-
|
| 427 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 428 |
}
|
| 429 |
|
| 430 |
return $object;
|
|
@@ -558,16 +601,14 @@ class Ntoklo_Recommendations_Helper_Data extends Mage_Core_Helper_Abstract {
|
|
| 558 |
* @return string
|
| 559 |
*/
|
| 560 |
public function getCategoryPath() {
|
| 561 |
-
|
| 562 |
-
$breadcrumbs = Mage::helper('catalog')->getBreadcrumbPath();
|
| 563 |
-
|
| 564 |
-
|
| 565 |
-
|
| 566 |
-
foreach ($breadcrumbs as $element) {
|
| 567 |
-
$label = strtolower(str_replace('>', ' ', $element['label']));
|
| 568 |
-
$path .= ($path == '') ? $label : ' > '. $label;
|
| 569 |
}
|
| 570 |
-
|
|
|
|
| 571 |
}
|
| 572 |
|
| 573 |
/**
|
|
@@ -610,4 +651,26 @@ class Ntoklo_Recommendations_Helper_Data extends Mage_Core_Helper_Abstract {
|
|
| 610 |
public function getExtensionVersion() {
|
| 611 |
return (string) $modules = Mage::getConfig()->getNode()->modules->Ntoklo_Recommendations->version;
|
| 612 |
}
|
| 613 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 69 |
private $_activationCode;
|
| 70 |
|
| 71 |
private $_usesNewWidgets;
|
| 72 |
+
|
| 73 |
+
/**
|
| 74 |
+
* Contains Tracker_id
|
| 75 |
+
*/
|
| 76 |
+
|
| 77 |
+
private $tracker_id = null;
|
| 78 |
+
private $widget_type = null;
|
| 79 |
|
| 80 |
/**
|
| 81 |
* @return bool
|
| 244 |
} else {
|
| 245 |
// Regular page category events
|
| 246 |
$item = new Ntoklo_Recommendations_Model_UniversalVariable(array(
|
| 247 |
+
'category' => self::PAGE_CATEGORY_CONVERSION_FUNNEL,
|
| 248 |
+
'action' => Mage::helper('ntoklo_recommendations')->getEventType($this->getPageCategory())
|
| 249 |
));
|
| 250 |
+
|
| 251 |
+
array_push($object, $item);
|
| 252 |
+
|
| 253 |
+
|
| 254 |
+
|
| 255 |
+
|
| 256 |
+
|
| 257 |
+
$tracker_id = Mage::helper('ntoklo_recommendations')->getTrackerId();
|
| 258 |
// Recommendation click events
|
| 259 |
+
if (!empty($_GET['nt_chrt'])) {
|
| 260 |
+
array_push($object, new Ntoklo_Recommendations_Model_UniversalVariable(
|
| 261 |
+
array('category' => 'clickthrough_goals',
|
| 262 |
+
'action' => 'chart-click',
|
| 263 |
+
'tracker_id' => $_GET['nt_chrt'] )));
|
| 264 |
+
|
| 265 |
+
|
| 266 |
}
|
| 267 |
+
|
| 268 |
+
if (!empty($_GET['nt_rec'])) {
|
| 269 |
+
array_push($object, new Ntoklo_Recommendations_Model_UniversalVariable(
|
| 270 |
+
array('category' => 'clickthrough_goals',
|
| 271 |
+
'action' => 'recommendation-click',
|
| 272 |
+
'tracker_id' => $_GET['nt_rec'] )));
|
| 273 |
+
|
| 274 |
+
|
| 275 |
+
}
|
| 276 |
+
|
| 277 |
+
|
| 278 |
+
if(!empty($tracker_id)){
|
| 279 |
+
array_push($object, new Ntoklo_Recommendations_Model_UniversalVariable(
|
| 280 |
+
array('category' => 'clickthrough_goals',
|
| 281 |
+
'action' => $this->widget_type . '-impr',
|
| 282 |
+
'tracker_id' => $tracker_id )));
|
| 283 |
+
}
|
| 284 |
+
}
|
| 285 |
+
|
| 286 |
|
| 287 |
return $object;
|
| 288 |
}
|
| 353 |
* @return Ntoklo_Recommendations_Model_UniversalVariable
|
| 354 |
*/
|
| 355 |
public function getUvMapPage() {
|
| 356 |
+
$object = array();
|
| 357 |
+
|
| 358 |
$pageCategory = $this->getPageCategory();
|
| 359 |
|
| 360 |
$object = new Ntoklo_Recommendations_Model_UniversalVariable(array(
|
| 361 |
+
'type' => $pageCategory
|
| 362 |
));
|
| 363 |
|
| 364 |
if ($pageCategory == self::PAGE_CATEGORY_CATEGORY || $pageCategory == self::PAGE_CATEGORY_PRODUCT) {
|
| 365 |
+
$object->breadcrumb = $this->getCategoryPath();
|
| 366 |
}
|
| 367 |
return $object;
|
| 368 |
}
|
| 397 |
if ($this->getPageCategory() == self::PAGE_CATEGORY_CATEGORY) {
|
| 398 |
$query = $this->getCategoryPath();
|
| 399 |
}
|
| 400 |
+
|
| 401 |
+
|
| 402 |
+
$pathCategory = $this->getCategoryPath();
|
| 403 |
+
$last = count($pathCategory) - 1;
|
| 404 |
|
| 405 |
// Build Items part - search context
|
| 406 |
// If it's a search result page than get the items from Search engine
|
| 408 |
/** @var $listBlock Mage_Catalog_Block_Product_List */
|
| 409 |
$listBlock = Mage::app()->getLayout()->getBlockSingleton('catalog/product_list');
|
| 410 |
foreach ($listBlock->getLoadedProductCollection() as $product) {
|
| 411 |
+
array_push($items, $this->getUvMapProduct($product, $pathCategory[$last]));
|
| 412 |
}
|
| 413 |
|
| 414 |
}
|
| 427 |
* Creates the product UV object
|
| 428 |
* @return Ntoklo_Recommendations_Model_UniversalVariable
|
| 429 |
*/
|
| 430 |
+
public function getUvMapProduct($product = false, $category = false) {
|
| 431 |
|
| 432 |
if (!$product) {
|
| 433 |
$product = Mage::registry('current_product');
|
| 456 |
'stock' => (int) Mage::getModel('cataloginventory/stock_item')->loadByProduct($product)->getQty()
|
| 457 |
));
|
| 458 |
|
| 459 |
+
if($category){
|
| 460 |
+
$object->setProperties(array('category' => $category ));
|
| 461 |
+
}else{
|
| 462 |
+
$categoryNames = array();
|
| 463 |
+
if ($categories = $product->getCategoryIds()) {
|
| 464 |
+
foreach ($categories as $categoryId) {
|
| 465 |
+
array_push($categoryNames, Mage::getModel('catalog/category')->load($categoryId)->getName());
|
| 466 |
+
}
|
| 467 |
+
}
|
| 468 |
+
if (!empty($categoryNames)) {
|
| 469 |
+
$object->setProperties(array('category' => implode(', ', $categoryNames)));
|
| 470 |
+
}
|
| 471 |
}
|
| 472 |
|
| 473 |
return $object;
|
| 601 |
* @return string
|
| 602 |
*/
|
| 603 |
public function getCategoryPath() {
|
| 604 |
+
|
| 605 |
+
$breadcrumbs = Mage::helper('catalog')->getBreadcrumbPath();
|
| 606 |
+
|
| 607 |
+
foreach ($breadcrumbs as $element) {
|
| 608 |
+
$label[] = $element['label'];
|
|
|
|
|
|
|
|
|
|
| 609 |
}
|
| 610 |
+
|
| 611 |
+
return $label;
|
| 612 |
}
|
| 613 |
|
| 614 |
/**
|
| 651 |
public function getExtensionVersion() {
|
| 652 |
return (string) $modules = Mage::getConfig()->getNode()->modules->Ntoklo_Recommendations->version;
|
| 653 |
}
|
| 654 |
+
|
| 655 |
+
public function setTrackerId($tracker_id, $widget_type){
|
| 656 |
+
$this->tracker_id = $tracker_id;
|
| 657 |
+
$this->widget_type = $widget_type;
|
| 658 |
+
|
| 659 |
+
}
|
| 660 |
+
|
| 661 |
+
public function getTrackerId(){
|
| 662 |
+
return $this->tracker_id;
|
| 663 |
+
}
|
| 664 |
+
|
| 665 |
+
public function getWidgetType(){
|
| 666 |
+
|
| 667 |
+
if($this->widget_type == 'recommendation'){
|
| 668 |
+
return 'nt_rec';
|
| 669 |
+
}
|
| 670 |
+
|
| 671 |
+
if($this->widget_type){
|
| 672 |
+
return 'nt_chrt';
|
| 673 |
+
}
|
| 674 |
+
|
| 675 |
+
}
|
| 676 |
+
}
|
app/code/community/Ntoklo/Recommendations/Model/Service.php
CHANGED
|
@@ -143,7 +143,9 @@ class Ntoklo_Recommendations_Model_Service extends Mage_Core_Model_Abstract {
|
|
| 143 |
|
| 144 |
switch ($chart->getData('widget_type')) {
|
| 145 |
case self::CALL_METHOD_CHART:
|
| 146 |
-
|
|
|
|
|
|
|
| 147 |
if (array_key_exists('product', $item) && array_key_exists('id', $item['product'])) {
|
| 148 |
$ids[] = $item['product']['id'];
|
| 149 |
} else {
|
|
@@ -152,8 +154,10 @@ class Ntoklo_Recommendations_Model_Service extends Mage_Core_Model_Abstract {
|
|
| 152 |
}
|
| 153 |
break;
|
| 154 |
case self::CALL_METHOD_RECOMMENDATIONS:
|
|
|
|
| 155 |
if (array_key_exists('items', $response)) {
|
| 156 |
foreach ($response['items'] as $item) {
|
|
|
|
| 157 |
if (array_key_exists('id', $item)) {
|
| 158 |
$ids[] = $item['id'];
|
| 159 |
} else {
|
| 143 |
|
| 144 |
switch ($chart->getData('widget_type')) {
|
| 145 |
case self::CALL_METHOD_CHART:
|
| 146 |
+
|
| 147 |
+
foreach ($response['items'] as $item) {
|
| 148 |
+
Mage::helper('ntoklo_recommendations')->setTrackerId($response['tracker_id'], $chart->getData('widget_type'));
|
| 149 |
if (array_key_exists('product', $item) && array_key_exists('id', $item['product'])) {
|
| 150 |
$ids[] = $item['product']['id'];
|
| 151 |
} else {
|
| 154 |
}
|
| 155 |
break;
|
| 156 |
case self::CALL_METHOD_RECOMMENDATIONS:
|
| 157 |
+
|
| 158 |
if (array_key_exists('items', $response)) {
|
| 159 |
foreach ($response['items'] as $item) {
|
| 160 |
+
Mage::helper('ntoklo_recommendations')->setTrackerId($response['tracker_id'], $chart->getData('widget_type'));
|
| 161 |
if (array_key_exists('id', $item)) {
|
| 162 |
$ids[] = $item['id'];
|
| 163 |
} else {
|
app/code/community/Ntoklo/Recommendations/etc/config.xml
CHANGED
|
@@ -20,7 +20,7 @@
|
|
| 20 |
<config>
|
| 21 |
<modules>
|
| 22 |
<Ntoklo_Recommendations>
|
| 23 |
-
<version>1.0.
|
| 24 |
</Ntoklo_Recommendations>
|
| 25 |
</modules>
|
| 26 |
<global>
|
| 20 |
<config>
|
| 21 |
<modules>
|
| 22 |
<Ntoklo_Recommendations>
|
| 23 |
+
<version>1.0.7</version>
|
| 24 |
</Ntoklo_Recommendations>
|
| 25 |
</modules>
|
| 26 |
<global>
|
app/code/community/Ntoklo/Recommendations/sql/ntoklo_setup/{mysql4-install-1.0.6.php → mysql4-install-1.0.7.php}
RENAMED
|
File without changes
|
app/design/frontend/base/default/template/ntoklo/recommendations/universal_variable.phtml
CHANGED
|
@@ -19,7 +19,7 @@
|
|
| 19 |
<!-- nToklo Start -->
|
| 20 |
<script type="text/javascript">
|
| 21 |
//<