Rees46_Personalization - Version 3.2.4

Version Notes

Install module in one click.
Recommendations settings.

Download this release

Release Info

Developer REES46
Extension Rees46_Personalization
Version 3.2.4
Comparing to
See all releases


Version 3.2.4

Files changed (22) hide show
  1. app/code/community/Rees46/Personalization/Helper/Admin.php +19 -0
  2. app/code/community/Rees46/Personalization/Helper/Data.php +61 -0
  3. app/code/community/Rees46/Personalization/Helper/Event.php +54 -0
  4. app/code/community/Rees46/Personalization/Model/Observer.php +105 -0
  5. app/code/community/Rees46/Personalization/controllers/Adminhtml/PersonalizationController.php +58 -0
  6. app/code/community/Rees46/Personalization/controllers/BlockController.php +71 -0
  7. app/code/community/Rees46/Personalization/etc/adminhtml.xml +43 -0
  8. app/code/community/Rees46/Personalization/etc/config.xml +143 -0
  9. app/code/community/Rees46/Personalization/etc/system.xml +62 -0
  10. app/design/adminhtml/default/default/layout/rees46_personalization.xml +15 -0
  11. app/design/adminhtml/default/default/template/rees46/personalization/index.phtml +3 -0
  12. app/design/frontend/base/default/layout/rees46_personalization.xml +46 -0
  13. app/design/frontend/base/default/template/rees46/personalization/blocks/cart.phtml +1 -0
  14. app/design/frontend/base/default/template/rees46/personalization/blocks/category.phtml +3 -0
  15. app/design/frontend/base/default/template/rees46/personalization/blocks/home.phtml +3 -0
  16. app/design/frontend/base/default/template/rees46/personalization/blocks/product.phtml +3 -0
  17. app/design/frontend/base/default/template/rees46/personalization/css.phtml +3 -0
  18. app/design/frontend/base/default/template/rees46/personalization/init.phtml +114 -0
  19. app/etc/modules/Rees46_Personalization.xml +19 -0
  20. app/locale/en_US/Rees46_Personalization.csv +8 -0
  21. app/locale/ru_RU/Rees46_Personalization.csv +8 -0
  22. package.xml +20 -0
app/code/community/Rees46/Personalization/Helper/Admin.php ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Personalizaton Admin helper
4
+ *
5
+ * @author Magento
6
+ */
7
+ class Rees46_Personalization_Helper_Admin extends Mage_Core_Helper_Abstract
8
+ {
9
+ /**
10
+ * Check permission for passed action
11
+ *
12
+ * @param string $action
13
+ * @return bool
14
+ */
15
+ public function isActionAllowed($action)
16
+ {
17
+ return Mage::getSingleton('admin/session')->isAllowed('personalization/manage/' . $action);
18
+ }
19
+ }
app/code/community/Rees46/Personalization/Helper/Data.php ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Personalization Data helper
4
+ *
5
+ * @author REES46
6
+ */
7
+ class Rees46_Personalization_Helper_Data extends Mage_Core_Helper_Data
8
+ {
9
+ /**
10
+ * Path to store config if front-end output is enabled
11
+ *
12
+ * @var string
13
+ */
14
+ const XML_PATH_ENABLED = 'personalization/view/enabled';
15
+
16
+
17
+ /**
18
+ * REES46 API Key
19
+ * @var string
20
+ */
21
+ const XML_PATH_API_KEY = 'personalization/view/api_key';
22
+
23
+ /**
24
+ * REES46 Secret Key
25
+ * @var string
26
+ */
27
+ const XML_PATH_SECRET_KEY = 'personalization/view/secret_key';
28
+
29
+
30
+ /**
31
+ * Checks whether news can be displayed in the frontend
32
+ *
33
+ * @param integer|string|Mage_Core_Model_Store $store
34
+ * @return boolean
35
+ */
36
+ public function isEnabled($store = null)
37
+ {
38
+ return Mage::getStoreConfigFlag(self::XML_PATH_ENABLED, $store);
39
+ }
40
+
41
+ /**
42
+ * Return REES46 API Key
43
+ * @param integer|string|Mage_Core_Model_Store $store
44
+ * @return string
45
+ */
46
+ public function getAPIKey($store = null) {
47
+ $api_key = Mage::getStoreConfig(self::XML_PATH_API_KEY, $store);
48
+ return $api_key ? $api_key : false;
49
+ }
50
+
51
+
52
+ /**
53
+ * Возвращает массив идентификаторов товаров, лежащих у пользователя в корзине
54
+ * @return array
55
+ */
56
+ public function getCartProductIds() {
57
+ $cart = Mage::getModel('checkout/cart')->getQuote();
58
+ return array_map(function($element){ return $element->getProductId(); }, $cart->getAllItems());
59
+ }
60
+
61
+ }
app/code/community/Rees46/Personalization/Helper/Event.php ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * News Image Helper
4
+ *
5
+ * @author Magento
6
+ */
7
+ class Rees46_Personalization_Helper_Event extends Mage_Core_Helper_Abstract
8
+ {
9
+
10
+ const REES46_SESSION_KEY_IDENTIFIER = 'rees46_events';
11
+
12
+ /**
13
+ * Помещает информацию о событии в буфер для последующей отрисовки их в шаблоне
14
+ * @param $name
15
+ * @param $data
16
+ */
17
+ public function pushEvent($name, $data) {
18
+ $events = $this->getEventsQueue();
19
+ array_push($events, array(
20
+ 'name' => $name,
21
+ 'data' => $data
22
+ ));
23
+ Mage::getSingleton('core/session')->setData(self::REES46_SESSION_KEY_IDENTIFIER, $events);
24
+ // var_dump($events);
25
+ }
26
+
27
+
28
+ /**
29
+ * Return array of REES46 events storage
30
+ * @param bool $and_clear_queue Clear events if set to true
31
+ * @return array
32
+ */
33
+ public function getEventsQueue($and_clear_queue = false) {
34
+ $events = Mage::getSingleton('core/session')->getData(self::REES46_SESSION_KEY_IDENTIFIER);
35
+ if(!is_array($events)) {
36
+ $events = array();
37
+ }
38
+ if($and_clear_queue) {
39
+ $this->clearEventsQueue();
40
+ }
41
+ return $events;
42
+ }
43
+
44
+
45
+ /**
46
+ * Clear REES46 events storage
47
+ */
48
+ public function clearEventsQueue() {
49
+ Mage::getSingleton('core/session')->unsetData(self::REES46_SESSION_KEY_IDENTIFIER);
50
+ }
51
+
52
+
53
+
54
+ }
app/code/community/Rees46/Personalization/Model/Observer.php ADDED
@@ -0,0 +1,105 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Personalizatoin module observer
4
+ *
5
+ * @author Magento
6
+ */
7
+ class Rees46_Personalization_Model_Observer
8
+ {
9
+ /**
10
+ * Event after show product.
11
+ * Used to track product views
12
+ *
13
+ * @param Varien_Event_Observer $observer
14
+ */
15
+ public function productViewed(Varien_Event_Observer $observer)
16
+ {
17
+ $product = $observer->getEvent()->getData('product');
18
+ if(!is_null($product)) {
19
+ $product_data = $this->_prepareCommonProductInfo($product);
20
+ Mage::helper('rees46_personalization/event')->pushEvent('view', $product_data);
21
+ }
22
+ }
23
+
24
+
25
+ /**
26
+ * Event after product added to cart.
27
+ * Used to track product carts
28
+ *
29
+ * @param Varien_Event_Observer $observer
30
+ */
31
+ public function productAddedToCart(Varien_Event_Observer $observer)
32
+ {
33
+ $product = $observer->getEvent()->getData('product');
34
+ if(!is_null($product)) {
35
+ $product_data = $this->_prepareCommonProductInfo($product);
36
+ Mage::helper('rees46_personalization/event')->pushEvent('cart', $product_data);
37
+ }
38
+ }
39
+
40
+
41
+ /**
42
+ * Event after product removed from cart.
43
+ * Used to track product carts
44
+ *
45
+ * @param Varien_Event_Observer $observer
46
+ */
47
+ public function productRemovedFromCart(Varien_Event_Observer $observer)
48
+ {
49
+ $product = $observer->getEvent()->getQuoteItem()->getProduct();
50
+ if(!is_null($product)) {
51
+ $product_data = $this->_prepareCommonProductInfo($product);
52
+ Mage::helper('rees46_personalization/event')->pushEvent('remove_from_cart', $product_data);
53
+ }
54
+ }
55
+
56
+ /**
57
+ * Event after order created.
58
+ *
59
+ * @param Varien_Event_Observer $observer
60
+ */
61
+ public function purchaseHappened(Varien_Event_Observer $observer)
62
+ {
63
+ $order = $observer->getEvent()->getOrder();
64
+ if(!is_null($order)) {
65
+ $order_data = array(
66
+ 'order_id' => $order->getIncrementId(),
67
+ 'products' => array()
68
+ );
69
+ $items = $order->getItemsCollection();
70
+ foreach($items as $item) {
71
+ $product = $item->getProduct();
72
+ $product_data = $this->_prepareCommonProductInfo($product);
73
+ $product_data['amount'] = $item->getQtyToShip();
74
+ $order_data['products'][] = $product_data;
75
+ }
76
+ Mage::helper('rees46_personalization/event')->pushEvent('purchase', $order_data);
77
+ }
78
+ }
79
+
80
+
81
+
82
+
83
+
84
+ /**
85
+ * Подготавливает базовый массив данных о товаре для трекинга
86
+ * @param Mage_Catalog_Model_Product $product
87
+ * @return array
88
+ */
89
+ private function _prepareCommonProductInfo(Mage_Catalog_Model_Product $product) {
90
+ return array(
91
+ 'item_id' => $product->getId(),
92
+ 'name' => $product->getName(),
93
+ 'description' => $product->getDescription(),
94
+ 'categories' => $product->getCategoryIds(),
95
+ 'price' => $product->getPrice(),
96
+ 'is_available' => $product->isAvailable(),
97
+ 'locations' => null,
98
+ 'url' => null,
99
+ 'image_url' => null,
100
+ 'tags' => null,
101
+ // @todo: не забыть трекинг рекомендера
102
+ 'recommended_by' => null
103
+ );
104
+ }
105
+ }
app/code/community/Rees46/Personalization/controllers/Adminhtml/PersonalizationController.php ADDED
@@ -0,0 +1,58 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Personalization Overview Controller
4
+ *
5
+ * @author REES46
6
+ */
7
+ class Rees46_Personalization_Adminhtml_PersonalizationController extends Mage_Adminhtml_Controller_Action
8
+ {
9
+ /**
10
+ * Init actions
11
+ *
12
+ * @return Magentostudy_News_Adminhtml_NewsController
13
+ */
14
+ protected function _initAction()
15
+ {
16
+ // load layout, set active menu and breadcrumbs
17
+ $this->loadLayout()
18
+ ->_setActiveMenu('personalization/overview')
19
+ ->_addBreadcrumb(
20
+ Mage::helper('rees46_personalization')->__('Personalization'),
21
+ Mage::helper('rees46_personalization')->__('Personalization')
22
+ )
23
+ ->_addBreadcrumb(
24
+ Mage::helper('rees46_personalization')->__('Overview'),
25
+ Mage::helper('rees46_personalization')->__('Overview')
26
+ )
27
+ ;
28
+ $this->_addContent($this->getLayout()->createBlock('adminhtml/template')->setTemplate('rees46/personalization/index.phtml'));
29
+ return $this;
30
+ }
31
+
32
+ /**
33
+ * Index action
34
+ */
35
+ public function indexAction()
36
+ {
37
+ $this->_title($this->__('Personalization'))
38
+ ->_title($this->__('Overview'));
39
+
40
+ $this->_initAction();
41
+ $this->renderLayout();
42
+ }
43
+
44
+ /**
45
+ * Check the permission to run it
46
+ *
47
+ * @return boolean
48
+ */
49
+ protected function _isAllowed()
50
+ {
51
+ switch ($this->getRequest()->getActionName()) {
52
+ default:
53
+ return Mage::getSingleton('admin/session')->isAllowed('personalization/overview');
54
+ break;
55
+ }
56
+ }
57
+
58
+ }
app/code/community/Rees46/Personalization/controllers/BlockController.php ADDED
@@ -0,0 +1,71 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * News frontend controller
4
+ *
5
+ * @author Magento
6
+ */
7
+ class Rees46_Personalization_BlockController extends Mage_Core_Controller_Front_Action
8
+ {
9
+ /**
10
+ * Pre dispatch action that allows to redirect to no route page in case of disabled extension through admin panel
11
+ */
12
+ public function preDispatch()
13
+ {
14
+ parent::preDispatch();
15
+
16
+ if (!Mage::helper('rees46_personalization')->isEnabled()) {
17
+ $this->setFlag('', 'no-dispatch', true);
18
+ $this->_redirect('noRoute');
19
+ }
20
+ }
21
+
22
+ /**
23
+ * Render recommended products as block
24
+ */
25
+ public function indexAction()
26
+ {
27
+ $this->loadLayout();
28
+ $product_ids = $this->getRequest()->getParam('ids');
29
+ $recommender_type = $this->getRequest()->getParam('type');
30
+ $minimum_recommended_products = intval($this->getRequest()->getParam('minimum'));
31
+ $products = array();
32
+
33
+ $attributes = Mage::getSingleton('catalog/config')->getProductAttributes();
34
+ $collection = Mage::getModel('catalog/product')
35
+ ->getCollection()
36
+ ->addAttributeToFilter('entity_id', array('in' => $product_ids))
37
+ ->addAttributeToSelect($attributes);
38
+
39
+ // Сортируем товары так, как вернул REES46
40
+ foreach($product_ids as $id) {
41
+ foreach($collection as $product) {
42
+ if($product->getId() == $id) {
43
+ $products[] = $product;
44
+ }
45
+ }
46
+ }
47
+
48
+ if( $minimum_recommended_products > 0 && count($products) >= $minimum_recommended_products ) {
49
+ $html = '<div class="rees46 rees46-recommend"><div class="recommender-block-title">' . Mage::helper('rees46_personalization')->__($recommender_type) . '</div><div class="recommended-items">';
50
+ foreach($products as $product) {
51
+ $product_url = $product->getProductUrl() . '?recommended_by=' . $recommender_type;
52
+ $html .= '<div class="recommended-item">
53
+ <div class="recommended-item-photo">
54
+ <a href="' . $product_url . '"><img src="' . $product->getImageUrl() . '"></a></div>
55
+ <div class="recommended-item-title">
56
+ <a href="' . $product_url . '">' . $product->getName() . '</a>
57
+ </div>
58
+ <div class="recommended-item-price">' . $product->getFormatedPrice() . '</div>
59
+ <div class="recommended-item-action"><a href="' . $product_url . '">' . Mage::helper('rees46_personalization')->__('More info') . '</a></div>
60
+ </div>';
61
+ }
62
+ $html .= '</div></div>';
63
+ echo $html;
64
+ } else {
65
+ echo '';
66
+ }
67
+
68
+ }
69
+
70
+
71
+ }
app/code/community/Rees46/Personalization/etc/adminhtml.xml ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * Magento admin config
5
+ *
6
+ * @author Magento
7
+ */
8
+ -->
9
+ <config>
10
+ <menu>
11
+ <personalization translate="title" module="rees46_personalization">
12
+ <title>Personalization</title>
13
+ <sort_order>65</sort_order>
14
+ <children>
15
+ <overview translate="title" module="rees46_personalization">
16
+ <title>Overview</title>
17
+ <action>adminhtml/personalization</action>
18
+ <sort_order>50</sort_order>
19
+ </overview>
20
+ </children>
21
+ </personalization>
22
+ </menu>
23
+
24
+ <acl>
25
+ <resources>
26
+ <admin>
27
+ <children>
28
+ <system>
29
+ <children>
30
+ <config>
31
+ <children>
32
+ <personalization translate="title" module="rees46_personalization">
33
+ <title>Overview</title>
34
+ </personalization>
35
+ </children>
36
+ </config>
37
+ </children>
38
+ </system>
39
+ </children>
40
+ </admin>
41
+ </resources>
42
+ </acl>
43
+ </config>
app/code/community/Rees46/Personalization/etc/config.xml ADDED
@@ -0,0 +1,143 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Rees46_Personalization>
5
+ <version>3.2.4</version>
6
+ </Rees46_Personalization>
7
+ </modules>
8
+ <global>
9
+ <models>
10
+ <rees46_personalization>
11
+ <class>Rees46_Personalization_Model</class>
12
+ <resourceModel>personalization_resource</resourceModel>
13
+ </rees46_personalization>
14
+ <personalization_resource>
15
+ <class>Rees46_Personalization_Model_Resource</class>
16
+ <entities>
17
+ <personalization>
18
+ <table>rees46_personalization</table>
19
+ </personalization>
20
+ </entities>
21
+ </personalization_resource>
22
+ </models>
23
+ <helpers>
24
+ <rees46_personalization>
25
+ <class>Rees46_Personalization_Helper</class>
26
+ </rees46_personalization>
27
+ </helpers>
28
+ <blocks>
29
+ <rees46_personalization>
30
+ <class>Rees46_Personalization_Block</class>
31
+ </rees46_personalization>
32
+ </blocks>
33
+ <resources>
34
+ <rees46_personalization_setup>
35
+ <setup>
36
+ <module>Rees46_Personalization</module>
37
+ <class>Mage_Core_Model_Resource_Setup</class>
38
+ </setup>
39
+ </rees46_personalization_setup>
40
+ </resources>
41
+ <events>
42
+ <catalog_controller_product_view>
43
+ <observers>
44
+ <rees46_personalization>
45
+ <class>rees46_personalization/observer</class>
46
+ <method>productViewed</method>
47
+ </rees46_personalization>
48
+ </observers>
49
+ </catalog_controller_product_view>
50
+ <checkout_cart_add_product_complete>
51
+ <observers>
52
+ <rees46_personalization>
53
+ <class>rees46_personalization/observer</class>
54
+ <method>productAddedToCart</method>
55
+ </rees46_personalization>
56
+ </observers>
57
+ </checkout_cart_add_product_complete>
58
+ <sales_quote_remove_item>
59
+ <observers>
60
+ <rees46_personalization>
61
+ <class>rees46_personalization/observer</class>
62
+ <method>productRemovedFromCart</method>
63
+ </rees46_personalization>
64
+ </observers>
65
+ </sales_quote_remove_item>
66
+ <sales_order_place_after>
67
+ <observers>
68
+ <rees46_personalization>
69
+ <class>rees46_personalization/observer</class>
70
+ <method>purchaseHappened</method>
71
+ </rees46_personalization>
72
+ </observers>
73
+ </sales_order_place_after>
74
+ </events>
75
+ </global>
76
+ <frontend>
77
+ <translate>
78
+ <modules>
79
+ <Rees46_Personalization>
80
+ <files>
81
+ <default>Rees46_Personalization.csv</default>
82
+ </files>
83
+ </Rees46_Personalization>
84
+ </modules>
85
+ </translate>
86
+ <routers>
87
+ <rees46_personalization>
88
+ <use>standard</use>
89
+ <args>
90
+ <module>Rees46_Personalization</module>
91
+ <frontName>personalization</frontName>
92
+ </args>
93
+ </rees46_personalization>
94
+ </routers>
95
+ <layout>
96
+ <updates>
97
+ <rees46_personalization>
98
+ <file>rees46_personalization.xml</file>
99
+ </rees46_personalization>
100
+ </updates>
101
+ </layout>
102
+ </frontend>
103
+ <admin>
104
+ <translate>
105
+ <modules>
106
+ <Rees46_Personalization>
107
+ <files>
108
+ <default>Rees46_Personalization.csv</default>
109
+ </files>
110
+ </Rees46_Personalization>
111
+ </modules>
112
+ </translate>
113
+ <routers>
114
+ <adminhtml>
115
+ <args>
116
+ <modules>
117
+ <Rees46_Personalization before="Mage_Adminhtml">Rees46_Personalization_Adminhtml</Rees46_Personalization>
118
+ </modules>
119
+ </args>
120
+ </adminhtml>
121
+ </routers>
122
+ </admin>
123
+ <adminhtml>
124
+ <layout>
125
+ <updates>
126
+ <rees46_personalization>
127
+ <file>rees46_personalization.xml</file>
128
+ </rees46_personalization>
129
+ </updates>
130
+ </layout>
131
+ </adminhtml>
132
+ <default>
133
+ <personalization>
134
+ <view>
135
+ <enabled>1</enabled>
136
+ <api_key></api_key>
137
+ <secret_key></secret_key>
138
+ </view>
139
+ </personalization>
140
+ </default>
141
+ </config>
142
+
143
+
app/code/community/Rees46/Personalization/etc/system.xml ADDED
@@ -0,0 +1,62 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * Magento admin configuratuib section config
5
+ *
6
+ * @author Magento
7
+ */
8
+ -->
9
+ <config>
10
+ <sections>
11
+ <personalization>
12
+ <class>separator-top</class>
13
+ <label>Personalization</label>
14
+ <tab>general</tab>
15
+ <frontend_type>text</frontend_type>
16
+ <sort_order>500</sort_order>
17
+ <show_in_default>1</show_in_default>
18
+ <show_in_website>1</show_in_website>
19
+ <show_in_store>1</show_in_store>
20
+
21
+ <groups>
22
+ <view translate="label">
23
+ <label>REES46 Settings</label>
24
+ <frontend_type>text</frontend_type>
25
+ <sort_order>10</sort_order>
26
+ <show_in_default>1</show_in_default>
27
+ <show_in_website>1</show_in_website>
28
+ <show_in_store>1</show_in_store>
29
+ <fields>
30
+ <enabled translate="label">
31
+ <label>Enable Personalization On Frontend</label>
32
+ <frontend_type>select</frontend_type>
33
+ <source_model>adminhtml/system_config_source_yesno</source_model>
34
+ <sort_order>10</sort_order>
35
+ <show_in_default>1</show_in_default>
36
+ <show_in_website>1</show_in_website>
37
+ <show_in_store>1</show_in_store>
38
+ </enabled>
39
+ <api_key translate="label">
40
+ <label>API Key</label>
41
+ <comment>Put API key taken after registration in rees46.com here.</comment>
42
+ <sort_order>30</sort_order>
43
+ <depends><enabled>1</enabled></depends>
44
+ <show_in_default>1</show_in_default>
45
+ <show_in_website>1</show_in_website>
46
+ <show_in_store>1</show_in_store>
47
+ </api_key>
48
+ <secret_key translate="label">
49
+ <label>Secret Key</label>
50
+ <comment>Put secret key taken after registration in rees46.com here.</comment>
51
+ <sort_order>50</sort_order>
52
+ <depends><enabled>1</enabled></depends>
53
+ <show_in_default>1</show_in_default>
54
+ <show_in_website>1</show_in_website>
55
+ <show_in_store>1</show_in_store>
56
+ </secret_key>
57
+ </fields>
58
+ </view>
59
+ </groups>
60
+ </personalization>
61
+ </sections>
62
+ </config>
app/design/adminhtml/default/default/layout/rees46_personalization.xml ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * Magento backend layout
5
+ *
6
+ * @author @rees46
7
+ */
8
+ -->
9
+ <layout>
10
+ <adminhtml_personalization_index>
11
+ <reference name="content">
12
+ <block type="rees46_personalization/adminhtml_personalization" name="personalization" />
13
+ </reference>
14
+ </adminhtml_personalization_index>
15
+ </layout>
app/design/adminhtml/default/default/template/rees46/personalization/index.phtml ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ <!-- @rees46 -->
2
+ <h1>REES46 Personalization Overview</h1>
3
+ <p>Get results personalized recommendations in <a href="http://rees46.com" target="_blank">REES46.com Dashboard</a>.</p>
app/design/frontend/base/default/layout/rees46_personalization.xml ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <layout version="0.1.0">
3
+ <!-- @rees46 -->
4
+
5
+ <!-- All pages tracking -->
6
+ <default>
7
+ <reference name="before_body_end">
8
+ <block type="core/template" name="rees46_init" after="-" template="rees46/personalization/init.phtml"/>
9
+ </reference>
10
+ <reference name="before_body_end">
11
+ <block type="core/template" name="rees46_css" before="-" template="rees46/personalization/css.phtml"/>
12
+ </reference>
13
+ </default>
14
+
15
+ <!-- Home-->
16
+ <cms_index_index>
17
+ <reference name="content">
18
+ <block type="core/template" name="rees46_home" after="-" template="rees46/personalization/blocks/home.phtml" />
19
+ </reference>
20
+ </cms_index_index>
21
+
22
+
23
+ <!-- Category -->
24
+ <catalog_category_view translate="label">
25
+ <reference name="content">
26
+ <block type="core/template" name="rees46_category" after="category.products" template="rees46/personalization/blocks/category.phtml" />
27
+ </reference>
28
+ </catalog_category_view>
29
+
30
+ <!-- Product -->
31
+ <catalog_product_view translate="label">
32
+ <reference name="content">
33
+ <block type="core/template" name="rees46_product" after="-" template="rees46/personalization/blocks/product.phtml" />
34
+ </reference>
35
+ </catalog_product_view>
36
+
37
+ <!-- Cart -->
38
+ <checkout_cart_index translate="label">
39
+ <reference name="content">
40
+ <block type="core/template" name="rees46_cart" after="-" template="rees46/personalization/blocks/cart.phtml" />
41
+ </reference>
42
+ </checkout_cart_index>
43
+
44
+ </layout>
45
+
46
+
app/design/frontend/base/default/template/rees46/personalization/blocks/cart.phtml ADDED
@@ -0,0 +1 @@
 
1
+ <div class="rees46 rees46-recommend" data-type="see_also" data-title="Не забудьте посмотреть"></div>
app/design/frontend/base/default/template/rees46/personalization/blocks/category.phtml ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ <div class="rees46 rees46-recommend" data-type="popular" data-title="Популярные товары в этой категории" data-category="<?= Mage::registry('current_category')->getId() ?>"></div>
2
+ <div class="rees46 rees46-recommend" data-type="recently_viewed" data-title="Вы недавно смотрели"></div>
3
+ <div class="rees46 rees46-recommend" data-type="interesting" data-title="Возможно, вам это будет интересно"></div>
app/design/frontend/base/default/template/rees46/personalization/blocks/home.phtml ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ <div class="rees46 rees46-recommend" data-type="popular" data-title="Популярные товары"></div>
2
+ <div class="rees46 rees46-recommend" data-type="interesting" data-title="Возможно, вам это будет интересно"></div>
3
+ <div class="rees46 rees46-recommend" data-type="recently_viewed" data-title="Вы недавно смотрели"></div>
app/design/frontend/base/default/template/rees46/personalization/blocks/product.phtml ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ <div class="rees46 rees46-recommend" data-type="also_bought" data-title="С этим товаром покупают" data-item="<?= Mage::registry('current_product')->getId() ?>"></div>
2
+ <div class="rees46 rees46-recommend" data-type="similar" data-title="Похожие товары" data-item="<?= Mage::registry('current_product')->getId() ?>"></div>
3
+ <div class="rees46 rees46-recommend" data-type="interesting" data-title="Возможно, вам это понравится" data-item="<?= Mage::registry('current_product')->getId() ?>"></div>
app/design/frontend/base/default/template/rees46/personalization/css.phtml ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ <?php if (Mage::helper('rees46_personalization')->isEnabled()): ?>
2
+ <link rel="stylesheet" type="text/css" href="http://rees46.com/shop_css/<?= $this->helper('rees46_personalization')->getAPIKey() ?>" media="all" />
3
+ <? endif; ?>
app/design/frontend/base/default/template/rees46/personalization/init.phtml ADDED
@@ -0,0 +1,114 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php if (Mage::helper('rees46_personalization')->isEnabled()): ?>
2
+ <? $rees46_api_key = $this->helper('rees46_personalization')->getAPIKey(); ?>
3
+ <? if($rees46_api_key != false): ?>
4
+ <!-- @rees46 -->
5
+ <script src="http://cdn.rees46.com/rees46_script2.js"></script>
6
+ <script type="text/javascript">
7
+ REES46_CART = <?= json_encode($this->helper('rees46_personalization')->getCartProductIds()); ?>;
8
+ jQuery(document).ready(function(){
9
+ var user_data = null;
10
+ <? if (Mage::getSingleton('customer/session')->isLoggedIn()): ?>
11
+ var user_data = {
12
+ id: <?= Mage::getSingleton('customer/session')->getCustomer()->getID() ?>,
13
+ email: '<?= Mage::getSingleton('customer/session')->getCustomer()->getEmail() ?>'
14
+ };
15
+ <? endif; ?>
16
+ REES46.init('<?= $this->helper('rees46_personalization')->getAPIKey() ?>', user_data, function() {
17
+ <? $events = Mage::helper('rees46_personalization/event')->getEventsQueue(true) ?>
18
+ <? foreach($events as $event): ?>
19
+ <? if($event['name'] == 'view' || $event['name'] == 'cart' || $event['name'] == 'remove_from_cart'): ?>
20
+ REES46.pushData('<?= $event['name'] ?>', {
21
+ item_id: '<?= $event['data']['item_id'] ?>',
22
+ name: '<?= $event['data']['name'] ?>',
23
+ description: '<?= $event['data']['description'] ?>',
24
+ price: '<?= $event['data']['price'] ?>',
25
+ is_available: '<?= intval($event['data']['is_available']) ?>',
26
+ categories: [<?= implode(',', $event['data']['categories']) ?>],
27
+ <? if($event['data']['recommended_by']): ?>
28
+ recommended_by: '<?= $event['data']['recommended_by'] ?>',
29
+ <? endif; ?>
30
+ });
31
+ <? endif; ?>
32
+ <? if($event['name'] == 'purchase'): ?>
33
+ REES46.pushData('purchase', [
34
+ <? foreach($event['data']['products'] as $product): ?>
35
+ {
36
+ item_id: '<?= $product['item_id'] ?>',
37
+ name: '<?= $product['name'] ?>',
38
+ description: '<?= $product['description'] ?>',
39
+ price: '<?= $product['price'] ?>',
40
+ is_available: '<?= intval($product['is_available']) ?>',
41
+ categories: [<?= implode(',', $product['categories']) ?>],
42
+ amount: <?= $product['amount'] ?>,
43
+ <? if($product['recommended_by']): ?>
44
+ recommended_by: '<?= $product['recommended_by'] ?>',
45
+ <? endif; ?>
46
+ },
47
+ <? endforeach; ?>
48
+ ],
49
+ '<?= $event['data']['order_id'] ?>');
50
+ <? endif; ?>
51
+ <? endforeach; ?>
52
+
53
+ jQuery('.rees46.rees46-recommend').each(function(){
54
+ var recommenderBlock = jQuery(this);
55
+ var recommenderType = recommenderBlock.data('type');
56
+ switch(recommenderType) {
57
+ case 'interesting':
58
+ case 'also_bought':
59
+ case 'similar':
60
+ case 'recently_viewed':
61
+ case 'buying_now':
62
+ REES46.recommend({
63
+ recommender_type: recommenderType,
64
+ item: recommenderBlock.data('item'),
65
+ cart: REES46_CART
66
+ }, function(data){
67
+ REES46_Recommender_Callback(recommenderType, recommenderBlock, data);
68
+ });
69
+ break;
70
+ case 'popular':
71
+ REES46.recommend({
72
+ recommender_type: recommenderType,
73
+ category: recommenderBlock.data('category')
74
+ }, function(data){
75
+ REES46_Recommender_Callback(recommenderType, recommenderBlock, data);
76
+ });
77
+ break;
78
+ case 'see_also':
79
+ REES46.recommend({
80
+ recommender_type: recommenderType,
81
+ cart: REES46_CART
82
+ }, function(data){
83
+ REES46_Recommender_Callback(recommenderType, recommenderBlock, data);
84
+ });
85
+ break;
86
+ }
87
+ });
88
+
89
+ function REES46_Recommender_Callback(recommenderType, block, data) {
90
+ // @todo: ввести в настройках параметр минимального количества рекомендаций для отображения
91
+ var min_products = 1;
92
+ if(data.length > min_products) {
93
+ jQuery.get(
94
+ '/personalization/block',
95
+ {
96
+ ids: data,
97
+ type: recommenderType,
98
+ minimum: min_products
99
+ },
100
+ function(response) {
101
+ if(response) {
102
+ block.html(response);
103
+ }
104
+ }
105
+ );
106
+ }
107
+ }
108
+
109
+
110
+ });
111
+ });
112
+ </script>
113
+ <?php endif; ?>
114
+ <?php endif; ?>
app/etc/modules/Rees46_Personalization.xml ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * Personalization module config
5
+ *
6
+ * @author REES46
7
+ */
8
+ -->
9
+ <config>
10
+ <modules>
11
+ <Rees46_Personalization>
12
+ <active>true</active>
13
+ <codePool>community</codePool>
14
+ <depends>
15
+ <Mage_Adminhtml />
16
+ </depends>
17
+ </Rees46_Personalization>
18
+ </modules>
19
+ </config>
app/locale/en_US/Rees46_Personalization.csv ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ "popular","Popular products"
2
+ "interesting","It may be interesting for you"
3
+ "also_bought","People also bought this product"
4
+ "similar","Similar products"
5
+ "see_also","Do not forget to look these products"
6
+ "recently_viewed","Recently viewed"
7
+ "buying_now","People buying it right now"
8
+ "More","More Info"
app/locale/ru_RU/Rees46_Personalization.csv ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ "popular","Популярные товары"
2
+ "interesting","Возможно, вас это заинтересует"
3
+ "also_bought","С этим товаром также покупают"
4
+ "similar","Похожие товары"
5
+ "see_also","Не забудьте посмотреть"
6
+ "recently_viewed","Вы недавно смотрели"
7
+ "buying_now","Люди покупают это прямо сейчас"
8
+ "More","Подробнее"
package.xml ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>Rees46_Personalization</name>
4
+ <version>3.2.4</version>
5
+ <stability>stable</stability>
6
+ <license>GPL</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>REES46 analyzes customers activity and recommend them best goods they are willing to buy. It increases conversion, average sum of order and overall revenues for 24%. Automatically.&#xD;
10
+ </summary>
11
+ <description>&lt;p&gt;Personal recommendations for e-commerce and e-mail notifications. Increases conversion rate and revenue without changing costs for advertisement.&lt;/p&gt;</description>
12
+ <notes>Install module in one click.&#xD;
13
+ Recommendations settings.</notes>
14
+ <authors><author><name>Michael Kechinov</name><user>mkechinov</user><email>kechinoff@gmail.com</email></author></authors>
15
+ <date>2014-09-15</date>
16
+ <time>18:11:44</time>
17
+ <contents><target name="magecommunity"><dir name="Rees46"><dir name="Personalization"><dir name="Helper"><file name="Admin.php" hash="2d31ca47bba5404e8b9d777027f70f48"/><file name="Data.php" hash="cd7edc0ae2af2ee4c85ecf610a58e9ce"/><file name="Event.php" hash="3119c1c87e27183b7f6ca3e97d965609"/></dir><dir name="Model"><file name="Observer.php" hash="b97379be25ff768b9ead4ec74aa716d7"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="PersonalizationController.php" hash="83cf76649e36fdf635836098c73b1310"/></dir><file name="BlockController.php" hash="94e6b11b0993f94b32b34444126fbd5f"/></dir><dir name="etc"><file name="adminhtml.xml" hash="7d8c44125849ee7ba71b633604ee70ff"/><file name="config.xml" hash="c3ea0c09854757721b9ff1d41f89c40d"/><file name="system.xml" hash="cd07b019aaadf90268e6deec809b35db"/></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="rees46_personalization.xml" hash="681cf0907c5d3a99e95102b317ab7d4b"/></dir><dir name="template"><dir name="rees46"><dir name="personalization"><file name="index.phtml" hash="87026c52a8d199d83d065c576679ebb6"/></dir></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="rees46_personalization.xml" hash="55c2cd3a5a293270896c3c1e4ad3b677"/></dir><dir name="template"><dir name="rees46"><dir name="personalization"><dir name="blocks"><file name="cart.phtml" hash="8157483c8fb43e14a9ad9b1090c735ef"/><file name="category.phtml" hash="dbe8787250e0c4b4d54ba994c227ac75"/><file name="home.phtml" hash="054fc0f13eba6109850aa25ac28faca9"/><file name="product.phtml" hash="8600869aa6d7722daa69c62028e2e54e"/></dir><file name="css.phtml" hash="9c15add205c1288fb79f9eab0a6bbac3"/><file name="init.phtml" hash="b1bb0f4b01e56fec8934988f6a1ef61d"/></dir></dir></dir></dir></dir></dir></target><target name="magelocale"><dir><dir name="en_US"><file name="Rees46_Personalization.csv" hash="0169f9749d80016235f9c69c245f0976"/></dir><dir name="ru_RU"><file name="Rees46_Personalization.csv" hash="9a71f4c9cb704beb7bf698595ee9db13"/></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Rees46_Personalization.xml" hash="67bdc8c38ce74e98dda5d70a0943f2fe"/></dir></target></contents>
18
+ <compatible/>
19
+ <dependencies><required><php><min>5.2.1</min><max>5.5.15</max></php></required></dependencies>
20
+ </package>