Rees46_Personalization - Version 4.3.0

Version Notes

Added HTTP API product export
Added help section
Added lead tracking
Removed overview page
Fixed output data
Namespace "personalization" renamed to rees46

Download this release

Release Info

Developer REES46
Extension Rees46_Personalization
Version 4.3.0
Comparing to
See all releases


Code changes from version 4.2.1 to 4.3.0

app/code/community/Rees46/Personalization/Helper/Admin.php CHANGED
@@ -12,6 +12,6 @@ class Rees46_Personalization_Helper_Admin extends Mage_Core_Helper_Abstract
12
  */
13
  public function isActionAllowed($action)
14
  {
15
- return Mage::getSingleton('admin/session')->isAllowed('personalization/manage/' . $action);
16
  }
17
  }
12
  */
13
  public function isActionAllowed($action)
14
  {
15
+ return Mage::getSingleton('admin/session')->isAllowed('rees46/manage/' . $action);
16
  }
17
  }
app/code/community/Rees46/Personalization/Helper/Curl.php ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright © 2017 REES46, INC. All rights reserved.
4
+ */
5
+ class Rees46_Personalization_Helper_Curl extends Mage_Core_Helper_Abstract
6
+ {
7
+ public function query($type, $url, $params = null)
8
+ {
9
+ $data = array();
10
+
11
+ $ch = curl_init();
12
+
13
+ curl_setopt($ch, CURLOPT_HEADER, false);
14
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
15
+ curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
16
+ curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
17
+ curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $type);
18
+ curl_setopt($ch, CURLOPT_URL, $url);
19
+
20
+ if (isset($params)) {
21
+ curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
22
+ }
23
+
24
+ $data['result'] = curl_exec($ch);
25
+ $data['info'] = curl_getinfo($ch);
26
+
27
+ curl_close($ch);
28
+
29
+ return $data;
30
+ }
31
+ }
app/code/community/Rees46/Personalization/Helper/Data.php CHANGED
@@ -4,24 +4,21 @@
4
  */
5
  class Rees46_Personalization_Helper_Data extends Mage_Core_Helper_Data
6
  {
7
- /**
8
- * Path to store config if front-end output is enabled
9
- *
10
- * @var string
11
- */
12
- const XML_PATH_ENABLED = 'personalization/view/enabled';
13
 
14
- /**
15
- * REES46 API Key
16
- * @var string
17
- */
18
- const XML_PATH_API_KEY = 'personalization/view/api_key';
19
 
20
- /**
21
- * REES46 Secret Key
22
- * @var string
23
- */
24
- const XML_PATH_SECRET_KEY = 'personalization/view/secret_key';
25
 
26
  /**
27
  * Checks whether news can be displayed in the frontend
@@ -31,7 +28,7 @@ class Rees46_Personalization_Helper_Data extends Mage_Core_Helper_Data
31
  */
32
  public function isEnabled($store = null)
33
  {
34
- return Mage::getStoreConfigFlag(self::XML_PATH_ENABLED, $store);
35
  }
36
 
37
  /**
@@ -40,16 +37,33 @@ class Rees46_Personalization_Helper_Data extends Mage_Core_Helper_Data
40
  * @return string
41
  */
42
  public function getAPIKey($store = null) {
43
- $api_key = Mage::getStoreConfig(self::XML_PATH_API_KEY, $store);
44
  return $api_key ? $api_key : false;
45
  }
46
 
 
 
 
 
 
 
 
 
 
 
47
  /**
48
  * Returns ids array of products in customer's cart
49
  * @return array
50
  */
51
  public function getCartProductIds() {
 
 
52
  $cart = Mage::getModel('checkout/cart')->getQuote();
53
- return array_map(function($element){ return $element->getProductId(); }, $cart->getAllItems());
 
 
 
 
 
54
  }
55
  }
4
  */
5
  class Rees46_Personalization_Helper_Data extends Mage_Core_Helper_Data
6
  {
7
+ const REES46_ACTION_LEAD = 'rees46/actions/action_lead';
8
+ const REES46_ACTION_EXPORT = 'rees46/actions/action_export';
9
+ const REES46_ENABLED = 'rees46/settings/enabled';
10
+ const REES46_API_KEY = 'rees46/settings/api_key';
11
+ const REES46_API_SECRET = 'rees46/settings/secret_key';
 
12
 
13
+ public function isLeadTracking($store = null)
14
+ {
15
+ return Mage::getStoreConfigFlag(self::REES46_ACTION_LEAD, $store);
16
+ }
 
17
 
18
+ public function isExported($store = null)
19
+ {
20
+ return Mage::getStoreConfigFlag(self::REES46_ACTION_EXPORT, $store);
21
+ }
 
22
 
23
  /**
24
  * Checks whether news can be displayed in the frontend
28
  */
29
  public function isEnabled($store = null)
30
  {
31
+ return Mage::getStoreConfigFlag(self::REES46_ENABLED, $store);
32
  }
33
 
34
  /**
37
  * @return string
38
  */
39
  public function getAPIKey($store = null) {
40
+ $api_key = Mage::getStoreConfig(self::REES46_API_KEY, $store);
41
  return $api_key ? $api_key : false;
42
  }
43
 
44
+ /**
45
+ * Return REES46 Secret Key
46
+ * @param integer|string|Mage_Core_Model_Store $store
47
+ * @return string
48
+ */
49
+ public function getSecretKey($store = null) {
50
+ $secret_key = Mage::getStoreConfig(self::REES46_API_SECRET, $store);
51
+ return $secret_key ? $secret_key : false;
52
+ }
53
+
54
  /**
55
  * Returns ids array of products in customer's cart
56
  * @return array
57
  */
58
  public function getCartProductIds() {
59
+ $ids = [];
60
+
61
  $cart = Mage::getModel('checkout/cart')->getQuote();
62
+
63
+ foreach ($cart->getAllVisibleItems() as $product) {
64
+ $ids[] = $product->getProductId();
65
+ }
66
+
67
+ return json_encode($ids);
68
  }
69
  }
app/code/community/Rees46/Personalization/Helper/Event.php CHANGED
@@ -13,10 +13,12 @@ class Rees46_Personalization_Helper_Event extends Mage_Core_Helper_Abstract
13
  */
14
  public function pushEvent($name, $data) {
15
  $events = $this->getEventsQueue();
16
- array_push($events, array(
 
17
  'name' => $name,
18
  'data' => $data
19
- ));
 
20
  Mage::getSingleton('core/session')->setData(self::REES46_SESSION_KEY_IDENTIFIER, $events);
21
  }
22
 
@@ -27,12 +29,15 @@ class Rees46_Personalization_Helper_Event extends Mage_Core_Helper_Abstract
27
  */
28
  public function getEventsQueue($and_clear_queue = false) {
29
  $events = Mage::getSingleton('core/session')->getData(self::REES46_SESSION_KEY_IDENTIFIER);
30
- if(!is_array($events)) {
31
- $events = array();
 
32
  }
33
- if($and_clear_queue) {
 
34
  $this->clearEventsQueue();
35
  }
 
36
  return $events;
37
  }
38
 
13
  */
14
  public function pushEvent($name, $data) {
15
  $events = $this->getEventsQueue();
16
+
17
+ array_push($events, [
18
  'name' => $name,
19
  'data' => $data
20
+ ]);
21
+
22
  Mage::getSingleton('core/session')->setData(self::REES46_SESSION_KEY_IDENTIFIER, $events);
23
  }
24
 
29
  */
30
  public function getEventsQueue($and_clear_queue = false) {
31
  $events = Mage::getSingleton('core/session')->getData(self::REES46_SESSION_KEY_IDENTIFIER);
32
+
33
+ if (!is_array($events)) {
34
+ $events = [];
35
  }
36
+
37
+ if ($and_clear_queue) {
38
  $this->clearEventsQueue();
39
  }
40
+
41
  return $events;
42
  }
43
 
app/code/community/Rees46/Personalization/Model/Observer.php CHANGED
@@ -4,6 +4,57 @@
4
  */
5
  class Rees46_Personalization_Model_Observer
6
  {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7
  /**
8
  * Event after show product.
9
  * Used to track product views
@@ -13,8 +64,10 @@ class Rees46_Personalization_Model_Observer
13
  public function productViewed(Varien_Event_Observer $observer)
14
  {
15
  $product = $observer->getEvent()->getData('product');
16
- if(!is_null($product)) {
 
17
  $product_data = $this->_prepareCommonProductInfo($product);
 
18
  Mage::helper('rees46_personalization/event')->pushEvent('view', $product_data);
19
  }
20
  }
@@ -28,8 +81,10 @@ class Rees46_Personalization_Model_Observer
28
  public function productAddedToCart(Varien_Event_Observer $observer)
29
  {
30
  $product = $observer->getEvent()->getData('product');
31
- if(!is_null($product)) {
 
32
  $product_data = $this->_prepareCommonProductInfo($product);
 
33
  Mage::helper('rees46_personalization/event')->pushEvent('cart', $product_data);
34
  }
35
  }
@@ -43,8 +98,10 @@ class Rees46_Personalization_Model_Observer
43
  public function productRemovedFromCart(Varien_Event_Observer $observer)
44
  {
45
  $product = $observer->getEvent()->getQuoteItem()->getProduct();
46
- if(!is_null($product)) {
 
47
  $product_data = $this->_prepareCommonProductInfo($product);
 
48
  Mage::helper('rees46_personalization/event')->pushEvent('remove_from_cart', $product_data);
49
  }
50
  }
@@ -57,19 +114,23 @@ class Rees46_Personalization_Model_Observer
57
  public function purchaseHappened(Varien_Event_Observer $observer)
58
  {
59
  $order = $observer->getEvent()->getOrder();
60
- if(!is_null($order)) {
61
- $order_data = array(
 
62
  'order_id' => $order->getIncrementId(),
63
  'order_price' => $order->getBaseGrandTotal(),
64
- 'products' => array()
65
- );
 
66
  $items = $order->getItemsCollection();
67
- foreach($items as $item) {
 
68
  $product = $item->getProduct();
69
  $product_data = $this->_prepareCommonProductInfo($product);
70
  $product_data['amount'] = $item->getQtyToShip();
71
  $order_data['products'][] = $product_data;
72
  }
 
73
  Mage::helper('rees46_personalization/event')->pushEvent('purchase', $order_data);
74
  }
75
  }
@@ -80,9 +141,9 @@ class Rees46_Personalization_Model_Observer
80
  * @return array
81
  */
82
  private function _prepareCommonProductInfo(Mage_Catalog_Model_Product $product) {
83
- return array(
84
  'id' => $product->getId(),
85
  'stock' => $product->isAvailable(),
86
- );
87
  }
88
  }
4
  */
5
  class Rees46_Personalization_Model_Observer
6
  {
7
+ /**
8
+ * Lead tracking and sending a link to export
9
+ *
10
+ * @param Varien_Event_Observer $observer
11
+ */
12
+ public function leadTracking(Varien_Event_Observer $observer)
13
+ {
14
+ $controllerAction = $observer->getEvent()->getAction();
15
+
16
+ if ($controllerAction->getRequest()->getParam('section') == 'rees46') {
17
+ if (!Mage::helper('rees46_personalization/data')->isLeadTracking()) {
18
+ $params = [
19
+ 'website' => Mage::getBaseUrl(),
20
+ 'cms_version' => Mage::getVersion(),
21
+ 'module_version' => (string)Mage::getConfig()->getNode()->modules->Rees46_Personalization->version,
22
+ 'email' => Mage::getStoreConfig('trans_email/ident_general/email'),
23
+ 'first_name' => Mage::getSingleton('admin/session')->getUser()->getFirstname(),
24
+ 'last_name' => Mage::getSingleton('admin/session')->getUser()->getLastname(),
25
+ 'phone' => Mage::getStoreConfig('general/store_information/phone'),
26
+ 'city' => Mage::getStoreConfig('general/store_information/address'),
27
+ 'country' => Mage::getModel('directory/country')->loadByCode(Mage::getStoreConfig('general/country/default'))->getName()
28
+ ];
29
+
30
+ $ch = curl_init();
31
+
32
+ curl_setopt($ch, CURLOPT_HEADER, false);
33
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
34
+ curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET');
35
+ curl_setopt($ch, CURLOPT_URL, 'https://rees46.com/trackcms/magento?' . http_build_query($params));
36
+ curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
37
+
38
+ curl_exec($ch);
39
+ curl_close($ch);
40
+
41
+ Mage::getModel('core/config')->saveConfig('rees46/actions/action_lead', true);
42
+ }
43
+
44
+ if (!Mage::helper('rees46_personalization/data')->isExported()) {
45
+ $curl_data = [
46
+ 'store_key' => Mage::helper('rees46_personalization/data')->getAPIKey(),
47
+ 'store_secret' => Mage::helper('rees46_personalization/data')->getSecretKey(),
48
+ 'yml_file_url' => Mage::helper('core/url')->getHomeUrl() . 'rees46/export'
49
+ ];
50
+
51
+ Mage::helper('rees46_personalization/curl')->query('PUT', 'https://rees46.com/api/shop/set_yml', json_encode($curl_data));
52
+
53
+ Mage::getModel('core/config')->saveConfig('rees46/actions/action_export', true);
54
+ }
55
+ }
56
+ }
57
+
58
  /**
59
  * Event after show product.
60
  * Used to track product views
64
  public function productViewed(Varien_Event_Observer $observer)
65
  {
66
  $product = $observer->getEvent()->getData('product');
67
+
68
+ if (!is_null($product)) {
69
  $product_data = $this->_prepareCommonProductInfo($product);
70
+
71
  Mage::helper('rees46_personalization/event')->pushEvent('view', $product_data);
72
  }
73
  }
81
  public function productAddedToCart(Varien_Event_Observer $observer)
82
  {
83
  $product = $observer->getEvent()->getData('product');
84
+
85
+ if (!is_null($product)) {
86
  $product_data = $this->_prepareCommonProductInfo($product);
87
+
88
  Mage::helper('rees46_personalization/event')->pushEvent('cart', $product_data);
89
  }
90
  }
98
  public function productRemovedFromCart(Varien_Event_Observer $observer)
99
  {
100
  $product = $observer->getEvent()->getQuoteItem()->getProduct();
101
+
102
+ if (!is_null($product)) {
103
  $product_data = $this->_prepareCommonProductInfo($product);
104
+
105
  Mage::helper('rees46_personalization/event')->pushEvent('remove_from_cart', $product_data);
106
  }
107
  }
114
  public function purchaseHappened(Varien_Event_Observer $observer)
115
  {
116
  $order = $observer->getEvent()->getOrder();
117
+
118
+ if (!is_null($order)) {
119
+ $order_data = [
120
  'order_id' => $order->getIncrementId(),
121
  'order_price' => $order->getBaseGrandTotal(),
122
+ 'products' => []
123
+ ];
124
+
125
  $items = $order->getItemsCollection();
126
+
127
+ foreach ($items as $item) {
128
  $product = $item->getProduct();
129
  $product_data = $this->_prepareCommonProductInfo($product);
130
  $product_data['amount'] = $item->getQtyToShip();
131
  $order_data['products'][] = $product_data;
132
  }
133
+
134
  Mage::helper('rees46_personalization/event')->pushEvent('purchase', $order_data);
135
  }
136
  }
141
  * @return array
142
  */
143
  private function _prepareCommonProductInfo(Mage_Catalog_Model_Product $product) {
144
+ return [
145
  'id' => $product->getId(),
146
  'stock' => $product->isAvailable(),
147
+ ];
148
  }
149
  }
app/code/community/Rees46/Personalization/controllers/Adminhtml/PersonalizationController.php DELETED
@@ -1,55 +0,0 @@
1
- <?php
2
- /**
3
- * Copyright © 2017 REES46, INC. All rights reserved.
4
- */
5
- class Rees46_Personalization_Adminhtml_PersonalizationController extends Mage_Adminhtml_Controller_Action
6
- {
7
- /**
8
- * Init actions
9
- *
10
- * @return Magentostudy_News_Adminhtml_NewsController
11
- */
12
- protected function _initAction()
13
- {
14
- /* load layout, set active menu and breadcrumbs */
15
- $this->loadLayout()
16
- ->_setActiveMenu('personalization/overview')
17
- ->_addBreadcrumb(
18
- Mage::helper('rees46_personalization')->__('Personalization'),
19
- Mage::helper('rees46_personalization')->__('Personalization')
20
- )
21
- ->_addBreadcrumb(
22
- Mage::helper('rees46_personalization')->__('Overview'),
23
- Mage::helper('rees46_personalization')->__('Overview')
24
- )
25
- ;
26
- $this->_addContent($this->getLayout()->createBlock('adminhtml/template')->setTemplate('rees46/personalization/index.phtml'));
27
- return $this;
28
- }
29
-
30
- /**
31
- * Index action
32
- */
33
- public function indexAction()
34
- {
35
- $this->_title($this->__('Personalization'))
36
- ->_title($this->__('Overview'));
37
-
38
- $this->_initAction();
39
- $this->renderLayout();
40
- }
41
-
42
- /**
43
- * Check the permission to run it
44
- *
45
- * @return boolean
46
- */
47
- protected function _isAllowed()
48
- {
49
- switch ($this->getRequest()->getActionName()) {
50
- default:
51
- return Mage::getSingleton('admin/session')->isAllowed('personalization/overview');
52
- break;
53
- }
54
- }
55
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Rees46/Personalization/controllers/BlockController.php CHANGED
@@ -23,16 +23,16 @@ class Rees46_Personalization_BlockController extends Mage_Core_Controller_Front_
23
  public function indexAction()
24
  {
25
  $this->loadLayout();
26
- $products = array();
27
 
28
  $product_ids = explode(',', $this->getRequest()->getParam('ids'));
29
- $type = $this->getRequest()->getParam('type');
30
  $limit = intval($this->getRequest()->getParam('limit'));
31
 
32
  $attributes = Mage::getSingleton('catalog/config')->getProductAttributes();
33
  $collection = Mage::getModel('catalog/product')
34
  ->getCollection()
35
- ->addAttributeToFilter('entity_id', array('in' => $product_ids))
36
  ->addAttributeToSelect($attributes);
37
 
38
  /* Sort items as REES46 returned */
@@ -55,13 +55,11 @@ class Rees46_Personalization_BlockController extends Mage_Core_Controller_Front_
55
  $title = Mage::helper('rees46_personalization')->__($type);
56
  }
57
 
58
- $html = '<div class="rees46 rees46-recommend"><div class="recommender-block-title">' . $title . '</div><div class="recommended-items">';
59
 
60
  foreach($products as $product) {
61
- /* Specific settings cause problems with large photos, so find it another way */
62
  $productForImage = Mage::getModel('catalog/product')->load($product->getId());
63
 
64
- /* Sometimes Magento adds special attributes to URL's, so add our attributes depending of this situation */
65
  $product_url = $product->getProductUrl(false);
66
 
67
  if (strpos($product_url, '?') !== false) {
23
  public function indexAction()
24
  {
25
  $this->loadLayout();
26
+ $products = [];
27
 
28
  $product_ids = explode(',', $this->getRequest()->getParam('ids'));
29
+ $type = Mage::helper('core')->escapeHtml($this->getRequest()->getParam('type'));
30
  $limit = intval($this->getRequest()->getParam('limit'));
31
 
32
  $attributes = Mage::getSingleton('catalog/config')->getProductAttributes();
33
  $collection = Mage::getModel('catalog/product')
34
  ->getCollection()
35
+ ->addAttributeToFilter('entity_id', ['in' => $product_ids])
36
  ->addAttributeToSelect($attributes);
37
 
38
  /* Sort items as REES46 returned */
55
  $title = Mage::helper('rees46_personalization')->__($type);
56
  }
57
 
58
+ $html = '<div class="rees46 rees46-recommend"><div class="recommender-block-title">' . Mage::helper('core')->escapeHtml($title) . '</div><div class="recommended-items">';
59
 
60
  foreach($products as $product) {
 
61
  $productForImage = Mage::getModel('catalog/product')->load($product->getId());
62
 
 
63
  $product_url = $product->getProductUrl(false);
64
 
65
  if (strpos($product_url, '?') !== false) {
app/code/community/Rees46/Personalization/controllers/ExportController.php ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright © 2017 REES46, INC. All rights reserved.
4
+ */
5
+ class Rees46_Personalization_ExportController extends Mage_Core_Controller_Front_Action
6
+ {
7
+ /**
8
+ * Pre dispatch action that allows to redirect to no route page in case of disabled extension through admin panel
9
+ */
10
+ public function preDispatch()
11
+ {
12
+ parent::preDispatch();
13
+
14
+ if (!Mage::helper('rees46_personalization/data')->isEnabled()
15
+ || !Mage::helper('rees46_personalization/data')->getAPIKey()
16
+ || !Mage::helper('rees46_personalization/data')->getSecretKey()
17
+ ) {
18
+ $this->setFlag('', 'no-dispatch', true);
19
+ $this->_redirect('noRoute');
20
+ }
21
+ }
22
+
23
+ /**
24
+ * Exporting categories via HTTP API
25
+ * Error is written in var/log/system.log
26
+ */
27
+ public function indexAction()
28
+ {
29
+ $categories = [];
30
+
31
+ $curl_data = [
32
+ 'shop_id' => Mage::helper('rees46_personalization/data')->getAPIKey(),
33
+ 'shop_secret' => Mage::helper('rees46_personalization/data')->getSecretKey(),
34
+ 'categories' => []
35
+ ];
36
+
37
+ $categories = Mage::helper('catalog/category')->getStoreCategories(false, true, true);
38
+
39
+ if (count($categories) > 0){
40
+ foreach($categories as $category){
41
+ $curl_data['categories'][] = [
42
+ 'id' => $category->getId(),
43
+ 'name' => $category->getName(),
44
+ 'parent' => $category->getParentId(),
45
+ ];
46
+ }
47
+ }
48
+
49
+ $return = Mage::helper('rees46_personalization/curl')->query('POST', 'http://api.rees46.com/import/categories', json_encode($curl_data));
50
+
51
+ if ($return['info']['http_code'] == 204) {
52
+ $this->_redirect('rees46/exportproduct');
53
+ } else {
54
+ Mage::log('REES46: could not export categories (' . $return['info']['http_code'] . ').');
55
+ }
56
+ }
57
+ }
app/code/community/Rees46/Personalization/controllers/ExportProductController.php ADDED
@@ -0,0 +1,101 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright © 2017 REES46, INC. All rights reserved.
4
+ */
5
+ class Rees46_Personalization_ExportProductController extends Mage_Core_Controller_Front_Action
6
+ {
7
+ const REES46_EXPORT_LIMIT = 1000;
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/data')->isEnabled()
17
+ || !Mage::helper('rees46_personalization/data')->getAPIKey()
18
+ || !Mage::helper('rees46_personalization/data')->getSecretKey()
19
+ ) {
20
+ $this->setFlag('', 'no-dispatch', true);
21
+ $this->_redirect('noRoute');
22
+ }
23
+ }
24
+
25
+ /**
26
+ * Exporting products via HTTP API
27
+ * Error is written in var/log/system.log
28
+ */
29
+ public function indexAction()
30
+ {
31
+ $products = [];
32
+
33
+ if (Mage::app()->getRequest()->getParam('start')) {
34
+ $start = Mage::app()->getRequest()->getParam('start');
35
+ } else {
36
+ $start = 0;
37
+ }
38
+
39
+ $collection = Mage::getModel('catalog/product')
40
+ ->getCollection()
41
+ ->addAttributeToSelect('name')
42
+ ->addAttributeToSelect('description')
43
+ ->addAttributeToSelect('image')
44
+ ->addAttributeToFilter('status', ['eq' => 1])
45
+ ->addUrlRewrite()
46
+ ->addFinalPrice()
47
+ ->addAttributeToSort('entity_id', 'ASC')
48
+ ->joinField(
49
+ 'is_in_stock',
50
+ 'cataloginventory/stock_item',
51
+ 'is_in_stock',
52
+ 'product_id=entity_id',
53
+ '{{table}}.stock_id=1',
54
+ 'left')
55
+ ->addAttributeToFilter('is_in_stock', ['gt' => 0])
56
+ ->setCurPage($start)
57
+ ->setPageSize(self::REES46_EXPORT_LIMIT);
58
+
59
+ foreach ($collection as $product) {
60
+ $products[] = [
61
+ 'id' => $product->getId(),
62
+ 'name' => $product->getName(),
63
+ 'price' => $product->getFinalPrice(),
64
+ 'currency' => Mage::app()->getStore()->getCurrentCurrencyCode(),
65
+ 'url' => $product->getProductUrl(),
66
+ 'picture' => (string)Mage::helper('catalog/image')->init($product, 'image')->resize(300, 300),
67
+ 'available' => $product->getIsInStock(),
68
+ 'categories' => $product->getCategoryIds(),
69
+ 'locations' => [],
70
+ 'brand' => '',
71
+ 'barcode' => '',
72
+ 'price_margin' => 0,
73
+ 'tags' => [],
74
+ 'is_child' => false,
75
+ 'is_fashion' => false
76
+ ];
77
+ }
78
+
79
+ if (count($products) > 0) {
80
+ $curl_data = [
81
+ 'shop_id' => Mage::helper('rees46_personalization/data')->getAPIKey(),
82
+ 'shop_secret' => Mage::helper('rees46_personalization/data')->getSecretKey(),
83
+ 'items' => $products
84
+ ];
85
+
86
+ $return = Mage::helper('rees46_personalization/curl')->query('PUT', 'http://api.rees46.com/import/products', json_encode($curl_data));
87
+
88
+ if ($return['info']['http_code'] == 204) {
89
+ if (count($products) == self::REES46_EXPORT_LIMIT) {
90
+ $this->_redirect('rees46/exportproduct', ['_query' => ['start' => $start + self::REES46_EXPORT_LIMIT]]);
91
+ } else {
92
+ $this->_redirect('rees46/exportsync');
93
+ }
94
+ } else {
95
+ Mage::log('REES46: could not export products ' . $this->get('start') . ' (' . $return['info']['http_code'] . ').');
96
+ }
97
+ } else {
98
+ $this->_redirect('rees46/exportsync');
99
+ }
100
+ }
101
+ }
app/code/community/Rees46/Personalization/controllers/ExportSyncController.php ADDED
@@ -0,0 +1,62 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright © 2017 REES46, INC. All rights reserved.
4
+ */
5
+ class Rees46_Personalization_ExportSyncController extends Mage_Core_Controller_Front_Action
6
+ {
7
+ /**
8
+ * Pre dispatch action that allows to redirect to no route page in case of disabled extension through admin panel
9
+ */
10
+ public function preDispatch()
11
+ {
12
+ parent::preDispatch();
13
+
14
+ if (!Mage::helper('rees46_personalization/data')->isEnabled()
15
+ || !Mage::helper('rees46_personalization/data')->getAPIKey()
16
+ || !Mage::helper('rees46_personalization/data')->getSecretKey()
17
+ ) {
18
+ $this->setFlag('', 'no-dispatch', true);
19
+ $this->_redirect('noRoute');
20
+ }
21
+ }
22
+
23
+ /**
24
+ * Deleting inactive products via HTTP API
25
+ * Error is written in var/log/system.log
26
+ */
27
+ public function indexAction()
28
+ {
29
+ $products = [];
30
+
31
+ $collection = Mage::getModel('catalog/product')
32
+ ->getCollection()
33
+ ->addAttributeToSort('entity_id', 'ASC')
34
+ ->joinField(
35
+ 'is_in_stock',
36
+ 'cataloginventory/stock_item',
37
+ 'is_in_stock',
38
+ 'product_id=entity_id',
39
+ '{{table}}.stock_id=1',
40
+ 'left')
41
+ ->addAttributeToFilter('is_in_stock', ['gt' => 0]);
42
+
43
+ foreach ($collection as $product) {
44
+ $products[] = $product->getId();
45
+ }
46
+
47
+ if (count($products) > 0) {
48
+ $curl_data = [
49
+ 'method' => 'PATCH',
50
+ 'shop_id' => Mage::helper('rees46_personalization/data')->getAPIKey(),
51
+ 'shop_secret' => Mage::helper('rees46_personalization/data')->getSecretKey(),
52
+ 'items' => $products
53
+ ];
54
+
55
+ $return = Mage::helper('rees46_personalization/curl')->query('POST', 'http://api.rees46.com/import/products', json_encode($curl_data));
56
+
57
+ if ($return['info']['http_code'] != 204) {
58
+ Mage::log('REES46: could not sync products (' . $return['info']['http_code'] . ').');
59
+ }
60
+ }
61
+ }
62
+ }
app/code/community/Rees46/Personalization/etc/adminhtml.xml DELETED
@@ -1,40 +0,0 @@
1
- <?xml version="1.0"?>
2
- <!--
3
- /**
4
- * Copyright © 2017 REES46, INC. All rights reserved.
5
- */
6
- -->
7
- <config>
8
- <menu>
9
- <personalization translate="title" module="rees46_personalization">
10
- <title>REES46 Recommendations</title>
11
- <sort_order>65</sort_order>
12
- <children>
13
- <overview translate="title" module="rees46_personalization">
14
- <title>Overview</title>
15
- <action>adminhtml/personalization</action>
16
- <sort_order>50</sort_order>
17
- </overview>
18
- </children>
19
- </personalization>
20
- </menu>
21
- <acl>
22
- <resources>
23
- <admin>
24
- <children>
25
- <system>
26
- <children>
27
- <config>
28
- <children>
29
- <personalization translate="title" module="rees46_personalization">
30
- <title>Overview</title>
31
- </personalization>
32
- </children>
33
- </config>
34
- </children>
35
- </system>
36
- </children>
37
- </admin>
38
- </resources>
39
- </acl>
40
- </config>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Rees46/Personalization/etc/config.xml CHANGED
@@ -7,9 +7,41 @@
7
  <config>
8
  <modules>
9
  <Rees46_Personalization>
10
- <version>4.2.1</version>
11
  </Rees46_Personalization>
12
  </modules>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
13
  <global>
14
  <models>
15
  <rees46_personalization>
@@ -19,9 +51,9 @@
19
  <personalization_resource>
20
  <class>Rees46_Personalization_Model_Resource</class>
21
  <entities>
22
- <personalization>
23
  <table>rees46_personalization</table>
24
- </personalization>
25
  </entities>
26
  </personalization_resource>
27
  </models>
@@ -44,9 +76,17 @@
44
  </rees46_personalization_setup>
45
  </resources>
46
  <events>
47
- <catalog_controller_product_view>
48
  <observers>
49
  <rees46_personalization>
 
 
 
 
 
 
 
 
50
  <class>rees46_personalization/observer</class>
51
  <method>productViewed</method>
52
  </rees46_personalization>
@@ -54,7 +94,7 @@
54
  </catalog_controller_product_view>
55
  <checkout_cart_add_product_complete>
56
  <observers>
57
- <rees46_personalization>
58
  <class>rees46_personalization/observer</class>
59
  <method>productAddedToCart</method>
60
  </rees46_personalization>
@@ -62,7 +102,7 @@
62
  </checkout_cart_add_product_complete>
63
  <sales_quote_remove_item>
64
  <observers>
65
- <rees46_personalization>
66
  <class>rees46_personalization/observer</class>
67
  <method>productRemovedFromCart</method>
68
  </rees46_personalization>
@@ -70,7 +110,7 @@
70
  </sales_quote_remove_item>
71
  <sales_order_place_after>
72
  <observers>
73
- <rees46_personalization>
74
  <class>rees46_personalization/observer</class>
75
  <method>purchaseHappened</method>
76
  </rees46_personalization>
@@ -93,7 +133,7 @@
93
  <use>standard</use>
94
  <args>
95
  <module>Rees46_Personalization</module>
96
- <frontName>personalization</frontName>
97
  </args>
98
  </rees46_personalization>
99
  </routers>
@@ -105,42 +145,13 @@
105
  </updates>
106
  </layout>
107
  </frontend>
108
- <admin>
109
- <translate>
110
- <modules>
111
- <Rees46_Personalization>
112
- <files>
113
- <default>Rees46_Personalization.csv</default>
114
- </files>
115
- </Rees46_Personalization>
116
- </modules>
117
- </translate>
118
- <routers>
119
- <adminhtml>
120
- <args>
121
- <modules>
122
- <Rees46_Personalization before="Mage_Adminhtml">Rees46_Personalization_Adminhtml</Rees46_Personalization>
123
- </modules>
124
- </args>
125
- </adminhtml>
126
- </routers>
127
- </admin>
128
- <adminhtml>
129
- <layout>
130
- <updates>
131
- <rees46_personalization>
132
- <file>rees46_personalization.xml</file>
133
- </rees46_personalization>
134
- </updates>
135
- </layout>
136
- </adminhtml>
137
  <default>
138
- <personalization>
139
- <view>
140
  <enabled>1</enabled>
141
  <api_key></api_key>
142
  <secret_key></secret_key>
143
- </view>
144
- </personalization>
145
  </default>
146
  </config>
7
  <config>
8
  <modules>
9
  <Rees46_Personalization>
10
+ <version>4.3.0</version>
11
  </Rees46_Personalization>
12
  </modules>
13
+ <admin>
14
+ <translate>
15
+ <modules>
16
+ <Rees46_Personalization>
17
+ <files>
18
+ <default>Rees46_Personalization.csv</default>
19
+ </files>
20
+ </Rees46_Personalization>
21
+ </modules>
22
+ </translate>
23
+ </admin>
24
+ <adminhtml>
25
+ <acl>
26
+ <resources>
27
+ <admin>
28
+ <children>
29
+ <system>
30
+ <children>
31
+ <config>
32
+ <children>
33
+ <rees46>
34
+ <title>REES46 eCommerce Marketing Suite</title>
35
+ </rees46>
36
+ </children>
37
+ </config>
38
+ </children>
39
+ </system>
40
+ </children>
41
+ </admin>
42
+ </resources>
43
+ </acl>
44
+ </adminhtml>
45
  <global>
46
  <models>
47
  <rees46_personalization>
51
  <personalization_resource>
52
  <class>Rees46_Personalization_Model_Resource</class>
53
  <entities>
54
+ <rees46>
55
  <table>rees46_personalization</table>
56
+ </rees46>
57
  </entities>
58
  </personalization_resource>
59
  </models>
76
  </rees46_personalization_setup>
77
  </resources>
78
  <events>
79
+ <controller_action_layout_load_before>
80
  <observers>
81
  <rees46_personalization>
82
+ <class>rees46_personalization/observer</class>
83
+ <method>leadTracking</method>
84
+ </rees46_personalization>
85
+ </observers>
86
+ </controller_action_layout_load_before>
87
+ <catalog_controller_product_view>
88
+ <observers>
89
+ <rees46_personalization ifconfig="rees46/settings/enabled">
90
  <class>rees46_personalization/observer</class>
91
  <method>productViewed</method>
92
  </rees46_personalization>
94
  </catalog_controller_product_view>
95
  <checkout_cart_add_product_complete>
96
  <observers>
97
+ <rees46_personalization ifconfig="rees46/settings/enabled">
98
  <class>rees46_personalization/observer</class>
99
  <method>productAddedToCart</method>
100
  </rees46_personalization>
102
  </checkout_cart_add_product_complete>
103
  <sales_quote_remove_item>
104
  <observers>
105
+ <rees46_personalization ifconfig="rees46/settings/enabled">
106
  <class>rees46_personalization/observer</class>
107
  <method>productRemovedFromCart</method>
108
  </rees46_personalization>
110
  </sales_quote_remove_item>
111
  <sales_order_place_after>
112
  <observers>
113
+ <rees46_personalization ifconfig="rees46/settings/enabled">
114
  <class>rees46_personalization/observer</class>
115
  <method>purchaseHappened</method>
116
  </rees46_personalization>
133
  <use>standard</use>
134
  <args>
135
  <module>Rees46_Personalization</module>
136
+ <frontName>rees46</frontName>
137
  </args>
138
  </rees46_personalization>
139
  </routers>
145
  </updates>
146
  </layout>
147
  </frontend>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
148
  <default>
149
+ <rees46>
150
+ <settings>
151
  <enabled>1</enabled>
152
  <api_key></api_key>
153
  <secret_key></secret_key>
154
+ </settings>
155
+ </rees46>
156
  </default>
157
  </config>
app/code/community/Rees46/Personalization/etc/system.xml CHANGED
@@ -6,26 +6,57 @@
6
  -->
7
  <config>
8
  <sections>
9
- <personalization>
10
- <class>separator-top</class>
11
- <label>REES46 Recommendations</label>
12
  <tab>general</tab>
13
  <frontend_type>text</frontend_type>
14
- <sort_order>500</sort_order>
15
  <show_in_default>1</show_in_default>
16
  <show_in_website>1</show_in_website>
17
  <show_in_store>1</show_in_store>
18
  <groups>
19
- <view translate="label">
20
- <label>Settings</label>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21
  <frontend_type>text</frontend_type>
22
  <sort_order>10</sort_order>
23
  <show_in_default>1</show_in_default>
24
  <show_in_website>1</show_in_website>
25
  <show_in_store>1</show_in_store>
 
 
 
 
 
 
 
 
 
 
 
26
  <fields>
27
  <enabled translate="label">
28
- <label>Enable Module</label>
29
  <frontend_type>select</frontend_type>
30
  <source_model>adminhtml/system_config_source_yesno</source_model>
31
  <sort_order>10</sort_order>
@@ -34,8 +65,7 @@
34
  <show_in_store>1</show_in_store>
35
  </enabled>
36
  <api_key translate="label">
37
- <label>API Key</label>
38
- <comment>Put API key taken after registration in rees46.com here.</comment>
39
  <sort_order>20</sort_order>
40
  <depends><enabled>1</enabled></depends>
41
  <show_in_default>1</show_in_default>
@@ -44,7 +74,6 @@
44
  </api_key>
45
  <secret_key translate="label">
46
  <label>Secret Key</label>
47
- <comment>Put secret key taken after registration in rees46.com here.</comment>
48
  <sort_order>30</sort_order>
49
  <depends><enabled>1</enabled></depends>
50
  <show_in_default>1</show_in_default>
@@ -52,8 +81,8 @@
52
  <show_in_store>1</show_in_store>
53
  </secret_key>
54
  </fields>
55
- </view>
56
  </groups>
57
- </personalization>
58
  </sections>
59
  </config>
6
  -->
7
  <config>
8
  <sections>
9
+ <rees46>
10
+ <label>REES46 eCommerce Marketing Suite</label>
 
11
  <tab>general</tab>
12
  <frontend_type>text</frontend_type>
13
+ <sort_order>20</sort_order>
14
  <show_in_default>1</show_in_default>
15
  <show_in_website>1</show_in_website>
16
  <show_in_store>1</show_in_store>
17
  <groups>
18
+ <help translate="label">
19
+ <label>Help</label>
20
+ <comment><![CDATA[
21
+ <table>
22
+ <tr>
23
+ <td>
24
+ Go to your REES46 store dashboard to get the access to:
25
+ <ul style="list-style: disc; padding-left: 40px;">
26
+ <li>Triggered emails</li>
27
+ <li>Email marketing tool</li>
28
+ <li>Personalized search</li>
29
+ <li>Web push triggered notifications</li>
30
+ <li>Instant web push notifications</li>
31
+ <li>Audience segmentation</li>
32
+ <li>Abandoned cart remarketing tool</li>
33
+ </ul><br>
34
+ <button onclick="window.open('https://rees46.com/customers/sign_in', '_blank'); return false;" class="primary">REES46 dashboard</button><br><br>
35
+ Documentation: <a href="http://docs.rees46.com/display/en/Magento+1.9.x+Extension" target="_blank">http://docs.rees46.com/display/en/Magento+1.9.x+Extension</a><br>
36
+ Support: <a href="mailto:support@rees46.com?subject=Support for REES46 Magento 1 extension">support@rees46.com</a>
37
+ </td>
38
+ </tr>
39
+ </table>
40
+ ]]></comment>
41
  <frontend_type>text</frontend_type>
42
  <sort_order>10</sort_order>
43
  <show_in_default>1</show_in_default>
44
  <show_in_website>1</show_in_website>
45
  <show_in_store>1</show_in_store>
46
+ <expanded>1</expanded>
47
+ </help>
48
+ <settings translate="label">
49
+ <label>Settings</label>
50
+ <comment><![CDATA[To authorize, please log in on rees46.com and copy & paste Store Key and Secret Key from Store Settings (Dashboard > Settings > Store Settings) to the fields below.]]></comment>
51
+ <frontend_type>text</frontend_type>
52
+ <sort_order>20</sort_order>
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
+ <expanded>1</expanded>
57
  <fields>
58
  <enabled translate="label">
59
+ <label>Enable</label>
60
  <frontend_type>select</frontend_type>
61
  <source_model>adminhtml/system_config_source_yesno</source_model>
62
  <sort_order>10</sort_order>
65
  <show_in_store>1</show_in_store>
66
  </enabled>
67
  <api_key translate="label">
68
+ <label>Store Key</label>
 
69
  <sort_order>20</sort_order>
70
  <depends><enabled>1</enabled></depends>
71
  <show_in_default>1</show_in_default>
74
  </api_key>
75
  <secret_key translate="label">
76
  <label>Secret Key</label>
 
77
  <sort_order>30</sort_order>
78
  <depends><enabled>1</enabled></depends>
79
  <show_in_default>1</show_in_default>
81
  <show_in_store>1</show_in_store>
82
  </secret_key>
83
  </fields>
84
+ </settings>
85
  </groups>
86
+ </rees46>
87
  </sections>
88
  </config>
app/design/adminhtml/default/default/layout/rees46_personalization.xml DELETED
@@ -1,13 +0,0 @@
1
- <?xml version="1.0"?>
2
- <!--
3
- /**
4
- * Copyright © 2017 REES46, INC. All rights reserved.
5
- */
6
- -->
7
- <layout>
8
- <adminhtml_personalization_index>
9
- <reference name="content">
10
- <block type="rees46_personalization/adminhtml_personalization" name="personalization" />
11
- </reference>
12
- </adminhtml_personalization_index>
13
- </layout>
 
 
 
 
 
 
 
 
 
 
 
 
 
app/design/adminhtml/default/default/template/rees46/personalization/index.phtml DELETED
@@ -1,27 +0,0 @@
1
- <?php
2
- /**
3
- * Copyright © 2017 REES46, INC. All rights reserved.
4
- */
5
- ?>
6
- <table>
7
- <tr>
8
- <td>
9
- <img src="<?php echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA). 'rees46/logo.png'; ?>" alt="REES46">
10
- </td>
11
- <td style="padding-left: 20px">
12
- <h1>REES46 Recommendation Engine Overview</h1>
13
- <p><?php echo __('Go to your REES46 store dashboard to get the access to:'); ?></p>
14
- <ul style="list-style: disc; padding-left: 40px;">
15
- <li><?php echo __('Triggered emails'); ?></li>
16
- <li><?php echo __('Email marketing tool'); ?></li>
17
- <li><?php echo __('Personalized search'); ?></li>
18
- <li><?php echo __('Web push triggered notifications'); ?></li>
19
- <li><?php echo __('Instant web push notifications'); ?></li>
20
- <li><?php echo __('Audience segmentation'); ?></li>
21
- <li><?php echo __('Abandoned cart remarketing tool'); ?></li>
22
- </ul><br>
23
- <button onclick="window.open('https://rees46.com/customers/sign_in', '_blank'); return false;" class="primary"><?php echo __('REES46 dashboard'); ?></button><br><br>
24
- <p><?php echo __('Documentation:'); ?> <a href="<?php echo __('http://docs.rees46.com/display/en/Magento+1.9.x+Extension'); ?>" target="_blank"><?php echo __('http://docs.rees46.com/display/en/Magento+1.9.x+Extension'); ?></a></p>
25
- </td>
26
- </tr>
27
- </table>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/design/frontend/base/default/template/rees46/personalization/init.phtml CHANGED
@@ -3,8 +3,7 @@
3
  * Copyright © 2017 REES46, INC. All rights reserved.
4
  */
5
  ?>
6
- <?php if (Mage::helper('rees46_personalization')->isEnabled() && $this->helper('rees46_personalization')->getAPIKey()): ?>
7
- <!-- BEGIN REES46 INIT -->
8
  <script type="text/javascript">
9
  (function(r){window.r46=window.r46||function(){(r46.q=r46.q||[]).push(arguments)};var s=document.getElementsByTagName(r)[0],rs=document.createElement(r);rs.async=1;rs.src='//cdn.rees46.com/v3.js';s.parentNode.insertBefore(rs,s);})('script');
10
  r46('init', '<?php echo $this->helper('rees46_personalization')->getAPIKey(); ?>');
@@ -12,23 +11,24 @@ r46('add_css', 'recommendations');
12
  <?php if (Mage::getSingleton('customer/session')->isLoggedIn()): ?>
13
  r46('profile', 'set', {id: <?php echo Mage::getSingleton('customer/session')->getCustomer()->getID() ?>, email: '<?php echo Mage::getSingleton('customer/session')->getCustomer()->getEmail() ?>'});
14
  <?php endif; ?>
15
- REES46_CART = <?php echo json_encode($this->helper('rees46_personalization')->getCartProductIds()); ?>;
16
-
 
17
  jQuery(document).ready(function() {
18
- <?php foreach(Mage::helper('rees46_personalization/event')->getEventsQueue(true) as $event): ?>
19
- <?php if ($event['name'] == 'view'): ?>
20
  r46('track', 'view', {
21
  id: <?php echo $event['data']['id'] ?>,
22
  stock: <?php echo intval($event['data']['stock']) ?>
23
  });
24
- <?php endif; ?>
25
- <?php if ($event['name'] == 'cart'): ?>
26
  r46('track', 'cart', <?php echo $event['data']['id'] ?>);
27
- <?php endif; ?>
28
- <?php if ($event['name'] == 'remove_from_cart'): ?>
29
  r46('track', 'remove_from_cart', <?php echo $event['data']['id'] ?>);
30
- <?php endif; ?>
31
- <?php if ($event['name'] == 'purchase'): ?>
32
  r46('track', 'purchase', {
33
  products: [
34
  <?php foreach($event['data']['products'] as $product): ?>
@@ -38,24 +38,22 @@ jQuery(document).ready(function() {
38
  order: '<?php echo $event['data']['order_id'] ?>',
39
  order_price: <?php echo $event['data']['order_price'] ?>
40
  });
41
- <?php endif; ?>
42
- <?php endforeach; ?>
43
- jQuery('.rees46.rees46-recommend').each(function(){
44
  var recommenderBlock = jQuery(this);
45
  var recommenderType = recommenderBlock.data('type');
46
  switch(recommenderType) {
47
  case 'interesting':
48
- case 'also_bought':
49
- case 'similar':
50
  case 'recently_viewed':
51
  case 'buying_now':
52
  case 'supply':
53
- r46('recommend', recommenderType, {item: recommenderBlock.data('item'), cart: [REES46_CART]}, function(results) {
54
  REES46_Recommender_Callback(recommenderType, recommenderBlock, results);
55
  });
56
  break;
57
  case 'popular':
58
- r46('recommend', recommenderType, {category: recommenderBlock.data('category'), cart: [REES46_CART]}, function(results) {
59
  REES46_Recommender_Callback(recommenderType, recommenderBlock, results);
60
  });
61
  break;
@@ -64,13 +62,21 @@ jQuery(document).ready(function() {
64
  REES46_Recommender_Callback(recommenderType, recommenderBlock, results);
65
  });
66
  break;
 
 
 
 
 
 
 
 
67
  }
68
  });
69
 
70
  function REES46_Recommender_Callback(recommenderType, block, data) {
71
  if (data.length > 0) {
72
  REES46RENDER(
73
- '<?php echo Mage::helper('core/url')->getHomeUrl(); ?>personalization/block',
74
  {
75
  ids: data,
76
  type: recommenderType,
@@ -78,7 +84,7 @@ jQuery(document).ready(function() {
78
  title: (block.data('title') || '')
79
  },
80
  function(response) {
81
- if(response) {
82
  block.html(response);
83
  }
84
  }
3
  * Copyright © 2017 REES46, INC. All rights reserved.
4
  */
5
  ?>
6
+ <?php if (Mage::helper('rees46_personalization')->isEnabled() && $this->helper('rees46_personalization')->getAPIKey()): ?><!-- BEGIN REES46 INIT -->
 
7
  <script type="text/javascript">
8
  (function(r){window.r46=window.r46||function(){(r46.q=r46.q||[]).push(arguments)};var s=document.getElementsByTagName(r)[0],rs=document.createElement(r);rs.async=1;rs.src='//cdn.rees46.com/v3.js';s.parentNode.insertBefore(rs,s);})('script');
9
  r46('init', '<?php echo $this->helper('rees46_personalization')->getAPIKey(); ?>');
11
  <?php if (Mage::getSingleton('customer/session')->isLoggedIn()): ?>
12
  r46('profile', 'set', {id: <?php echo Mage::getSingleton('customer/session')->getCustomer()->getID() ?>, email: '<?php echo Mage::getSingleton('customer/session')->getCustomer()->getEmail() ?>'});
13
  <?php endif; ?>
14
+ REES46_CART = <?php echo $this->helper('rees46_personalization')->getCartProductIds(); ?>;
15
+ REES46_PRODUCT = '<?php echo (Mage::registry('current_product') ? Mage::registry('current_product')->getId() : '') ?>';
16
+ REES46_CATEGORY = '<?php echo (Mage::registry('current_category') ? Mage::registry('current_category')->getId() : '') ?>';
17
  jQuery(document).ready(function() {
18
+ <?php foreach (Mage::helper('rees46_personalization/event')->getEventsQueue(true) as $event): ?>
19
+ <?php if ($event['name'] == 'view'): ?>
20
  r46('track', 'view', {
21
  id: <?php echo $event['data']['id'] ?>,
22
  stock: <?php echo intval($event['data']['stock']) ?>
23
  });
24
+ <?php endif; ?>
25
+ <?php if ($event['name'] == 'cart'): ?>
26
  r46('track', 'cart', <?php echo $event['data']['id'] ?>);
27
+ <?php endif; ?>
28
+ <?php if ($event['name'] == 'remove_from_cart'): ?>
29
  r46('track', 'remove_from_cart', <?php echo $event['data']['id'] ?>);
30
+ <?php endif; ?>
31
+ <?php if ($event['name'] == 'purchase'): ?>
32
  r46('track', 'purchase', {
33
  products: [
34
  <?php foreach($event['data']['products'] as $product): ?>
38
  order: '<?php echo $event['data']['order_id'] ?>',
39
  order_price: <?php echo $event['data']['order_price'] ?>
40
  });
41
+ <?php endif; ?>
42
+ <?php endforeach; ?>
43
+ jQuery('.rees46.rees46-recommend').each(function() {
44
  var recommenderBlock = jQuery(this);
45
  var recommenderType = recommenderBlock.data('type');
46
  switch(recommenderType) {
47
  case 'interesting':
 
 
48
  case 'recently_viewed':
49
  case 'buying_now':
50
  case 'supply':
51
+ r46('recommend', recommenderType, {item: REES46_PRODUCT, cart: [REES46_CART]}, function(results) {
52
  REES46_Recommender_Callback(recommenderType, recommenderBlock, results);
53
  });
54
  break;
55
  case 'popular':
56
+ r46('recommend', recommenderType, {category: REES46_CATEGORY, cart: [REES46_CART]}, function(results) {
57
  REES46_Recommender_Callback(recommenderType, recommenderBlock, results);
58
  });
59
  break;
62
  REES46_Recommender_Callback(recommenderType, recommenderBlock, results);
63
  });
64
  break;
65
+ case 'similar':
66
+ case 'also_bought':
67
+ if (REES46_PRODUCT != '') {
68
+ r46('recommend', recommenderType, {item: REES46_PRODUCT, cart: [REES46_CART]}, function(results) {
69
+ REES46_Recommender_Callback(recommenderType, recommenderBlock, results);
70
+ });
71
+ }
72
+ break;
73
  }
74
  });
75
 
76
  function REES46_Recommender_Callback(recommenderType, block, data) {
77
  if (data.length > 0) {
78
  REES46RENDER(
79
+ '<?php echo Mage::helper('core/url')->getHomeUrl(); ?>rees46/block',
80
  {
81
  ids: data,
82
  type: recommenderType,
84
  title: (block.data('title') || '')
85
  },
86
  function(response) {
87
+ if (response) {
88
  block.html(response);
89
  }
90
  }
app/etc/modules/Rees46_Personalization.xml CHANGED
@@ -9,9 +9,6 @@
9
  <Rees46_Personalization>
10
  <active>true</active>
11
  <codePool>community</codePool>
12
- <depends>
13
- <Mage_Adminhtml />
14
- </depends>
15
  </Rees46_Personalization>
16
  </modules>
17
  </config>
9
  <Rees46_Personalization>
10
  <active>true</active>
11
  <codePool>community</codePool>
 
 
 
12
  </Rees46_Personalization>
13
  </modules>
14
  </config>
package.xml CHANGED
@@ -1,12 +1,12 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Rees46_Personalization</name>
4
- <version>4.2.1</version>
5
  <stability>stable</stability>
6
- <license>GNU</license>
7
  <channel>community</channel>
8
  <extends/>
9
- <summary>REES46 is free professional recommender system for e-commerce, with personalized merchandising, trigger and digest mailings, search personalization, etc. analyzes customers activity and recommend them best goods they are willing to buy for greater conversion and ARPPU.</summary>
10
  <description>REES46 is an all-in-one marketing suite that can be applied to an e-commerce store of any size, demographic, or niche. Once set up, you can manage several tools from a central dashboard that will make your basic marketing processes easier to manage and follow up.&#xD;
11
  &#xD;
12
  Using REES46 you can easily:&#xD;
@@ -16,11 +16,16 @@ Convert your visitors into customers using personalized product recommendations
16
  Recover abandoned carts using triggered emails, web push notifications and remarketing.&#xD;
17
  Induce repeat purchases through digest emails and push notifications with individual selections of recommended products.&#xD;
18
  Gain customer feedback, product and store reviews to improve your store credibility and merchant reputation. </description>
19
- <notes>Fixed more product data for tracking</notes>
20
- <authors><author><name>REES46</name><user>mkechinov</user><email>kechinoff@gmail.com</email></author><author><name>REES46</name><user>p0v1n0m</user><email>ay@rees46.com</email></author></authors>
21
- <date>2017-04-13</date>
22
- <time>18:36:44</time>
23
- <contents><target name="magecommunity"><dir name="Rees46"><dir name="Personalization"><dir name="Helper"><file name="Admin.php" hash="a01aceaba456186604b779c5920cafe9"/><file name="Data.php" hash="4896d769e47ba5c0896d0c8b2e7ec92d"/><file name="Event.php" hash="c50e9b22f08a3251602a3372d2622b65"/></dir><dir name="Model"><file name="Observer.php" hash="21d8b84dad94e44aa78135395d5878f0"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="PersonalizationController.php" hash="b3ddd3bb3a8acc4df0034f1dc681b952"/></dir><file name="BlockController.php" hash="b393c157296eb4ffd52af2e69eeac4bc"/></dir><dir name="etc"><file name="adminhtml.xml" hash="051c97f0c45ce97134344590f930cd73"/><file name="config.xml" hash="67a8aa961a1484a06887d2fed7e11314"/><file name="system.xml" hash="7d2293a79736ee4ffa30151cfd4ba28d"/></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="682bbcffec8a0933d64ef2910fc52bb0"/></dir><dir name="template"><dir name="rees46"><dir name="personalization"><file name="index.phtml" hash="f09eeb4522c3b5095591697fa92803af"/></dir></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="rees46_personalization.xml" hash="ec585005bed91c3f5204122d6a9dcbc5"/></dir><dir name="template"><dir name="rees46"><dir name="personalization"><file name="init.phtml" hash="d147a5dc3cbfd626bf79fb820427ceab"/></dir></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Rees46_Personalization.xml" hash="7b0cf94d20b8263561e8b63cf52d22ae"/></dir></target><target name="magelocale"><dir><dir name="de_DE"><file name="Rees46_Personalization.csv" hash="2e2d1d84a165965c5f935ec0b165efb9"/></dir><dir name="en_US"><file name="Rees46_Personalization.csv" hash="eb3790f608f01c384916cc2660820987"/></dir><dir name="es_ES"><file name="Rees46_Personalization.csv" hash="4637871b513318c9dad974677ccec649"/></dir><dir name="fi_FI"><file name="Rees46_Personalization.csv" hash="6d22c1974b7b95ab00ede29d8a72637a"/></dir><dir name="fr_FR"><file name="Rees46_Personalization.csv" hash="16260bf2014d994a68f66f07b816f4ac"/></dir><dir name="it_IT"><file name="Rees46_Personalization.csv" hash="87835f4b09d7c6b6799ba8a0b34ea4d4"/></dir><dir name="pt_PT"><file name="Rees46_Personalization.csv" hash="05eae7af68e37f20ca4b7ed695b41a2b"/></dir><dir name="ru_RU"><file name="Rees46_Personalization.csv" hash="022b43e549a584556d1a68ea7901d7b9"/></dir><dir name="sv_SE"><file name="Rees46_Personalization.csv" hash="c5fc79888c10a9ce1a65b169a2a6313e"/></dir></dir></target></contents>
 
 
 
 
 
24
  <compatible/>
25
  <dependencies><required><php><min>5.2.1</min><max>6.0.0</max></php></required></dependencies>
26
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Rees46_Personalization</name>
4
+ <version>4.3.0</version>
5
  <stability>stable</stability>
6
+ <license>MIT</license>
7
  <channel>community</channel>
8
  <extends/>
9
+ <summary>Marketing automation and progressive personalization suite to attract, convert and retain more customers. Boost your marketing efficiency with REES46.</summary>
10
  <description>REES46 is an all-in-one marketing suite that can be applied to an e-commerce store of any size, demographic, or niche. Once set up, you can manage several tools from a central dashboard that will make your basic marketing processes easier to manage and follow up.&#xD;
11
  &#xD;
12
  Using REES46 you can easily:&#xD;
16
  Recover abandoned carts using triggered emails, web push notifications and remarketing.&#xD;
17
  Induce repeat purchases through digest emails and push notifications with individual selections of recommended products.&#xD;
18
  Gain customer feedback, product and store reviews to improve your store credibility and merchant reputation. </description>
19
+ <notes>Added HTTP API product export&#xD;
20
+ Added help section&#xD;
21
+ Added lead tracking&#xD;
22
+ Removed overview page&#xD;
23
+ Fixed output data&#xD;
24
+ Namespace "personalization" renamed to rees46</notes>
25
+ <authors><author><name>REES46</name><user>p0v1n0m</user><email>ay@rees46.com</email></author></authors>
26
+ <date>2017-06-19</date>
27
+ <time>16:05:54</time>
28
+ <contents><target name="magecommunity"><dir name="Rees46"><dir name="Personalization"><dir name="Helper"><file name="Admin.php" hash="73737bffebd9070ab39b3462617f7d87"/><file name="Curl.php" hash="cf48c393401be175387c756535438651"/><file name="Data.php" hash="5917f35f1afc21ab0a296c451af4b021"/><file name="Event.php" hash="01f3c7ea6b6993b6f465e4e0e53f4f75"/></dir><dir name="Model"><file name="Observer.php" hash="0f725bf5cfc782c8f11e5687c793ef5e"/></dir><dir name="controllers"><file name="BlockController.php" hash="5f914f0ecb3d73547fc201d7cba175e3"/><file name="ExportController.php" hash="99b8ec0cd37a8df60147deb0a4064873"/><file name="ExportProductController.php" hash="690373cf6d3f1a8ede1b13b3e9b6383f"/><file name="ExportSyncController.php" hash="e445e30bf921c7111a43e2414f5ea9e5"/></dir><dir name="etc"><file name="config.xml" hash="b3958f2d71b73f5e8d521ba55fc942d6"/><file name="system.xml" hash="0f10acbc685bd1a8aa4bbf6a02350057"/></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=""/></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="rees46_personalization.xml" hash="ec585005bed91c3f5204122d6a9dcbc5"/></dir><dir name="template"><dir name="rees46"><dir name="personalization"><file name="init.phtml" hash="5cd3b2c502207c3752f6e0b5833e099f"/></dir></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Rees46_Personalization.xml" hash="24d0db1f94527be15dbad225a97f4b89"/></dir></target><target name="magelocale"><dir><dir name="de_DE"><file name="Rees46_Personalization.csv" hash="2e2d1d84a165965c5f935ec0b165efb9"/></dir><dir name="en_US"><file name="Rees46_Personalization.csv" hash="eb3790f608f01c384916cc2660820987"/></dir><dir name="es_ES"><file name="Rees46_Personalization.csv" hash="4637871b513318c9dad974677ccec649"/></dir><dir name="fi_FI"><file name="Rees46_Personalization.csv" hash="6d22c1974b7b95ab00ede29d8a72637a"/></dir><dir name="fr_FR"><file name="Rees46_Personalization.csv" hash="16260bf2014d994a68f66f07b816f4ac"/></dir><dir name="it_IT"><file name="Rees46_Personalization.csv" hash="87835f4b09d7c6b6799ba8a0b34ea4d4"/></dir><dir name="pt_PT"><file name="Rees46_Personalization.csv" hash="05eae7af68e37f20ca4b7ed695b41a2b"/></dir><dir name="ru_RU"><file name="Rees46_Personalization.csv" hash="022b43e549a584556d1a68ea7901d7b9"/></dir><dir name="sv_SE"><file name="Rees46_Personalization.csv" hash="c5fc79888c10a9ce1a65b169a2a6313e"/></dir></dir></target></contents>
29
  <compatible/>
30
  <dependencies><required><php><min>5.2.1</min><max>6.0.0</max></php></required></dependencies>
31
  </package>