Peerius_Connect - Version 1.0.4

Version Notes

Show search result recommendations only on empty search results if not set in config.

Download this release

Release Info

Developer Peerius
Extension Peerius_Connect
Version 1.0.4
Comparing to
See all releases


Version 1.0.4

Files changed (54) hide show
  1. app/code/community/Peerius/Smartrecs/.DS_Store +0 -0
  2. app/code/community/Peerius/Smartrecs/Block/Config.php +17 -0
  3. app/code/community/Peerius/Smartrecs/Block/Recommendations.php +146 -0
  4. app/code/community/Peerius/Smartrecs/Block/Template.php +127 -0
  5. app/code/community/Peerius/Smartrecs/Block/Tracking.php +399 -0
  6. app/code/community/Peerius/Smartrecs/Helper/Data.php +136 -0
  7. app/code/community/Peerius/Smartrecs/Helper/Feedhelper.php +10 -0
  8. app/code/community/Peerius/Smartrecs/Model/.DS_Store +0 -0
  9. app/code/community/Peerius/Smartrecs/Model/Feed/Creator.php +505 -0
  10. app/code/community/Peerius/Smartrecs/Model/Max.php +23 -0
  11. app/code/community/Peerius/Smartrecs/Model/SearchLayer.php +25 -0
  12. app/code/community/Peerius/Smartrecs/Model/System/Config/Source/Dropdown/Values.php +15 -0
  13. app/code/community/Peerius/Smartrecs/Model/System/Config/Source/Yesno.php +29 -0
  14. app/code/community/Peerius/Smartrecs/Model/Templates.php +39 -0
  15. app/code/community/Peerius/Smartrecs/Model/Templates/Basket.php +12 -0
  16. app/code/community/Peerius/Smartrecs/Model/Templates/Category.php +12 -0
  17. app/code/community/Peerius/Smartrecs/Model/Templates/Checkout.php +12 -0
  18. app/code/community/Peerius/Smartrecs/Model/Templates/Home.php +12 -0
  19. app/code/community/Peerius/Smartrecs/Model/Templates/Order.php +12 -0
  20. app/code/community/Peerius/Smartrecs/Model/Templates/Other.php +12 -0
  21. app/code/community/Peerius/Smartrecs/Model/Templates/Product1.php +12 -0
  22. app/code/community/Peerius/Smartrecs/Model/Templates/Product2.php +12 -0
  23. app/code/community/Peerius/Smartrecs/Model/Templates/Search.php +12 -0
  24. app/code/community/Peerius/Smartrecs/Model/Templates/Wishlist.php +12 -0
  25. app/code/community/Peerius/Smartrecs/Model/Token.php +30 -0
  26. app/code/community/Peerius/Smartrecs/controllers/Adminhtml/PeeriusController.php +90 -0
  27. app/code/community/Peerius/Smartrecs/controllers/FeedController.php +145 -0
  28. app/code/community/Peerius/Smartrecs/controllers/InfoController.php +193 -0
  29. app/code/community/Peerius/Smartrecs/controllers/RenderController.php +82 -0
  30. app/code/community/Peerius/Smartrecs/etc/adminhtml.xml +29 -0
  31. app/code/community/Peerius/Smartrecs/etc/config.xml +97 -0
  32. app/code/community/Peerius/Smartrecs/etc/system.xml +653 -0
  33. app/code/community/Peerius/Smartrecs/etc/system_ft.xml +81 -0
  34. app/code/community/Peerius/Smartrecs/etc/widget.xml +40 -0
  35. app/design/adminhtml/default/default/layout/smartrecs.xml +21 -0
  36. app/design/adminhtml/default/default/template/smartrecs/aclreloadbutton.phtml +24 -0
  37. app/design/adminhtml/default/default/template/smartrecs/config.phtml +101 -0
  38. app/design/frontend/base/default/layout/smartrecs.xml +140 -0
  39. app/design/frontend/base/default/template/smartrecs/recs/basket.phtml +40 -0
  40. app/design/frontend/base/default/template/smartrecs/recs/category.phtml +40 -0
  41. app/design/frontend/base/default/template/smartrecs/recs/home.phtml +40 -0
  42. app/design/frontend/base/default/template/smartrecs/recs/product-1.phtml +40 -0
  43. app/design/frontend/base/default/template/smartrecs/recs/product-2.phtml +40 -0
  44. app/design/frontend/base/default/template/smartrecs/recs/search.phtml +40 -0
  45. app/design/frontend/base/default/template/smartrecs/render.phtml +13 -0
  46. app/design/frontend/base/default/template/smartrecs/smartrecs.phtml +55 -0
  47. app/etc/modules/Peerius_Smartrecs.xml +12 -0
  48. js/peerius/smartrecs/smartrecs.js +39 -0
  49. package.xml +23 -0
  50. skin/adminhtml/default/default/peerius/smartrecs/css/config.css +89 -0
  51. skin/adminhtml/default/default/peerius/smartrecs/img/logo-rollover.png +0 -0
  52. skin/adminhtml/default/default/peerius/smartrecs/img/navigation.png +0 -0
  53. skin/adminhtml/default/default/peerius/smartrecs/js/smartrecs.js +11 -0
  54. skin/frontend/base/default/css/peerius_smartrecs/style.css +21 -0
app/code/community/Peerius/Smartrecs/.DS_Store ADDED
Binary file
app/code/community/Peerius/Smartrecs/Block/Config.php ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * @category Peerius
5
+ * @package Peerius_Smartrecs
6
+ * @author Peerius Ltd
7
+ */
8
+ class Peerius_Smartrecs_Block_Config extends Mage_Core_Block_Template {
9
+
10
+ protected function _toHtml() {
11
+ if (strpos(Mage::helper('core/url')->getCurrentUrl(), '/section/peerius/') !== false) {
12
+ Mage::getModel('core/config')->saveConfig('peerius/general/adminip', Mage::helper('core/http')->getRemoteAddr(true));
13
+ return parent::_toHtml();
14
+ }
15
+ }
16
+ }
17
+
app/code/community/Peerius/Smartrecs/Block/Recommendations.php ADDED
@@ -0,0 +1,146 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * @category Peerius
5
+ * @package Peerius_Smartrecs
6
+ * @author Peerius Ltd
7
+ */
8
+ class Peerius_Smartrecs_Block_Recommendations extends Mage_Core_Block_Template implements Mage_Widget_Block_Interface {
9
+ const DEFAULT_ITEM_NUM = 3;
10
+
11
+ protected $_fixTemplates = array(
12
+ 'peerius-smartrecs-left' => 'sidebar.phtml',
13
+ 'peerius-smartrecs-right' => 'sidebar.phtml',
14
+ 'peerius-smartrecs-footer' => 'other.phtml'
15
+ );
16
+
17
+ protected function _toHtml() {
18
+
19
+ $helper = Mage::helper('peerius_smartrecs');
20
+ $headline = '';
21
+ $showDiv = false;
22
+ $page = null;
23
+
24
+ if ($this->getElementId() and $this->getElementId() == 'peerius-smartrecs-productwidget2') {
25
+ $page = 'product2';
26
+ }
27
+
28
+ $dontShow = false;
29
+ if (($helper->getPageType() == 'search') AND !Mage::getStoreConfig('peerius/search/success')) {
30
+ // show recommendations on successful search results only if the specific config flag is 'yes'
31
+ $searchResults = Mage::registry('peerius_smartrecs_searchresults');
32
+ $dontShow = count($searchResults) ? true : false;
33
+ }
34
+
35
+
36
+
37
+ if (!$helper->getPageDisabled($page) OR !$this->getElementId()) {
38
+ // standard recs will not show when disabled per page in configuration,
39
+ // but widgets created with magento widget instance manager will still show
40
+ if ($this->getElementId()) {
41
+ $id = $this->getElementId();
42
+ } else {
43
+
44
+ $type = $this->getRectype()?:'widgetinstance';
45
+ $id = 'peerius-smartrecs-'.$type;
46
+
47
+ // automatically increase widgetinstance id number
48
+ // $widgetCounter = Mage::registry('peerius_smartrecs');
49
+ //
50
+ // if (isset($widgetCounter)) {
51
+ // $counter = $widgetCounter + 1;
52
+ // $id = 'peerius-smartrecs-widgetinstance'.$counter;
53
+ // } else {
54
+ // $counter = 0;
55
+ // $id = 'peerius-smartrecs-widgetinstance';
56
+ // }
57
+ //
58
+ // Mage::register($id, $counter);
59
+ // Mage::unregister('peerius_smartrecs');
60
+ // Mage::register('peerius_smartrecs', $counter);
61
+ }
62
+
63
+ if ($this->getRequest()->getParam('template')) {
64
+ $template = $this->getRequest()->getParam('template');
65
+ } elseif($this->getWtemplate()) {
66
+ $template = $this->getWtemplate();
67
+ } else {
68
+ if (array_key_exists($id, $this->_fixTemplates)) {
69
+ $template = $this->_fixTemplates[$id];
70
+ } else {
71
+ if ($id == 'peerius-smartrecs-productwidget2') {
72
+ $templateSetting = 'peerius/product2/template';
73
+ $headlineSetting = 'peerius/product2/headline';
74
+ $maxSetting = 'peerius/product2/max';
75
+ } else {
76
+ $templateSetting = 'peerius/'.$helper::getPageType(). '/template';
77
+ $headlineSetting = 'peerius/'.$helper::getPageType(). '/headline';
78
+ $maxSetting = 'peerius/'.$helper::getPageType(). '/max';
79
+ }
80
+ $template = Mage::getStoreConfig($templateSetting);
81
+ $headline = Mage::getStoreConfig($headlineSetting);
82
+ $max = Mage::getStoreConfig($maxSetting);
83
+ $template = $template?:Mage::getStoreConfig('peerius/'.$helper::getPageType(). '/template');
84
+ }
85
+ }
86
+
87
+ $template = $template?:'other.phtml';
88
+
89
+ if ($template) {
90
+ $template = (strpos($template, DS) === false) ? 'smartrecs/recs/'.$template : $template;
91
+
92
+ if ($this->getRequest()->getParam('peeriuslocalpreview') AND !array_key_exists($id, $this->_fixTemplates)) {
93
+ return Mage::getSingleton('core/layout')
94
+ ->createBlock('smartrecs/template')
95
+ ->setTemplate($template)
96
+ ->toHtml();
97
+ } else {
98
+ $html = '';
99
+
100
+ // store height of recommendations div
101
+ // $configHeight = Mage::getStoreConfig('peerius/general/widgetheight');
102
+ // if ($configHeight) {
103
+ // $configHeight = unserialize($configHeight);
104
+ // }
105
+ //$page = $helper::getPageType();
106
+ // if (isset($configHeight[$id])) {
107
+ // $height = $configHeight[$id].'px';
108
+ // } else {
109
+ // //$html .= '<script type="text/javascript">var peeriusPage = \''.$page.'\';</script>';
110
+ // $height = "'auto'";
111
+ // }
112
+ //
113
+ // // widget type
114
+ // $type = $this->getRectype()?:'widgetinstance';
115
+
116
+ // if ($type == 'standard') {
117
+ // $type = $helper::getPageType();
118
+ // }
119
+
120
+ $headline = $this->getHeadline()?:$headline;
121
+ if (!$max) {
122
+ $max = (int) $this->getMax()?:self::DEFAULT_ITEM_NUM;
123
+ }
124
+
125
+ if (!$dontShow) $html .= '<div id="'.$id.'" template="'.$template.'" headline="'.$headline.'" max="'.$max.'" class="block block-recommendations"></div>';
126
+ return $html;
127
+ }
128
+ }
129
+ }
130
+ }
131
+
132
+
133
+
134
+ /**
135
+ * Return the id of the element. If none is defined in the layout xml,
136
+ * then set a default one.
137
+ *
138
+ * @return string
139
+ */
140
+ public function getElementId() {
141
+ $id = $this->getDivId();
142
+ return $id;
143
+ }
144
+
145
+ }
146
+
app/code/community/Peerius/Smartrecs/Block/Template.php ADDED
@@ -0,0 +1,127 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * @category Peerius
5
+ * @package Peerius_Smartrecs
6
+ * @author Peerius Ltd
7
+ */
8
+ class Peerius_Smartrecs_Block_Template extends Mage_Catalog_Block_Product_List {
9
+
10
+ const DEFAULT_ITEM_NUM = 3;
11
+
12
+ const MAX_ITEM_NUM = 10;
13
+
14
+ protected $_columnCount = 4;
15
+
16
+ protected $_i = 0;
17
+
18
+ protected function _prepareData() {
19
+ $this->_productCollection = Mage::getModel('catalog/product')
20
+ ->getCollection()
21
+ ->addAttributeToSelect('*');
22
+
23
+ $num = false;
24
+
25
+ $skus = false;
26
+
27
+ if ($this->getRequest()->getParam('skus')) {
28
+ $skus = explode(',',$this->getRequest()->getParam('skus'));
29
+ }
30
+
31
+ if ($this->getRequest()->getParam('recs')) {
32
+ $recs = json_decode($this->getRequest()->getParam('recs'));
33
+ $num = count($recs);
34
+ $skus = array();
35
+ for ($i = 0; $i < $num; $i++) {
36
+ $skus[] = $recs[$i]->refCode;
37
+ }
38
+ }
39
+
40
+ if ($skus) {
41
+ $this->_productCollection->addAttributeToFilter('SKU', array('in'=>$skus));
42
+ $this->_productCollection->getSelect()->order("find_in_set(SKU,'".implode(',',$skus)."')");
43
+ }
44
+
45
+
46
+ if (!$max) {
47
+ $max = (int) $this->getRequest()->getParam('max') ?: self::DEFAULT_ITEM_NUM;
48
+ }
49
+
50
+ if ($max > self::MAX_ITEM_NUM) {
51
+ $max = self::MAX_ITEM_NUM;
52
+ }
53
+
54
+ $this->_productCollection->getSelect()->limit($max);
55
+
56
+ $this->_productCollection->load();
57
+
58
+ return $this;
59
+ }
60
+
61
+ protected function _beforeToHtml() {
62
+ $this->_prepareData();
63
+ parent::_beforeToHtml();
64
+ }
65
+
66
+ public function getItems() {
67
+ return $this->_productCollection;
68
+ }
69
+
70
+ /**
71
+ * Count items
72
+ *
73
+ * @return int
74
+ */
75
+ public function getItemCount()
76
+ {
77
+ return count($this->getItems());
78
+ }
79
+
80
+ public function getItemCollection() {
81
+ return $this->_productCollection;
82
+ }
83
+
84
+
85
+ public function getRowCount()
86
+ {
87
+ return ceil(count($this->getItemCollection()->getItems())/$this->getColumnCount());
88
+ }
89
+
90
+ public function setColumnCount($columns)
91
+ {
92
+ if (intval($columns) > 0) {
93
+ $this->_columnCount = intval($columns);
94
+ }
95
+ return $this;
96
+ }
97
+
98
+ public function getColumnCount()
99
+ {
100
+ return $this->_columnCount;
101
+ }
102
+
103
+ public function resetItemsIterator()
104
+ {
105
+ $this->getItems();
106
+ reset($this->_productCollection);
107
+ }
108
+
109
+ public function getIterableItem()
110
+ {
111
+ if (is_array($this->_productCollection)) {
112
+ $item = current($this->_productCollection);
113
+ next($this->_productCollection);
114
+ return $item;
115
+ }
116
+
117
+ // the iterator on an object doesn't work like this
118
+ $i = 0;
119
+ foreach ($this->_productCollection as $item) {
120
+ if ($this->_i == $i++) {
121
+ $this->_i++;
122
+ return $item;
123
+ }
124
+ }
125
+ }
126
+ }
127
+
app/code/community/Peerius/Smartrecs/Block/Tracking.php ADDED
@@ -0,0 +1,399 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * @category Peerius
5
+ * @package Peerius_Smartrecs
6
+ * @author Peerius Ltd
7
+ */
8
+ class Peerius_Smartrecs_Block_Tracking extends Mage_Core_Block_Template {
9
+
10
+ protected $_pageType;
11
+ /*
12
+ * getter for page type
13
+ */
14
+ public function getPageType() {
15
+ return $this->_pageType;
16
+ }
17
+
18
+ /*
19
+ * guess the page type and call the method to generate the pixel
20
+ * @return string
21
+ */
22
+ public function getTrackingPixel() {
23
+ $fullActionName = Mage::app()->getFrontController()->getAction()->getFullActionName();
24
+
25
+ switch ($fullActionName) {
26
+ case 'cms_index_index':
27
+ $routeName = Mage::app()->getRequest()->getRouteName();
28
+ $identifier = Mage::getSingleton('cms/page')->getIdentifier();
29
+ if($routeName == 'cms' && $identifier == 'home') {
30
+ $this->_pageType = 'home';
31
+ return $this->getHomePixel();
32
+ } else {
33
+ return $this->getOtherPixel();
34
+ }
35
+ break;
36
+ case 'catalog_category_view':
37
+ $this->_pageType = 'category';
38
+ return $this->getCategoryPixel();
39
+ case 'catalog_product_view':
40
+ $this->_pageType = 'product';
41
+ return $this->getProductPixel();
42
+ case 'checkout_cart_index':
43
+ $this->_pageType = 'basket';
44
+ return $this->getBasketPixel();
45
+ case 'checkout_onepage_index':
46
+ $this->_pageType = 'checkout';
47
+ return $this->getCheckoutPixel();
48
+ case 'checkout_onepage_success':
49
+ $this->_pageType = 'order';
50
+ return $this->getOrderPixel();
51
+ default:
52
+ if (0 === strpos($fullActionName, 'catalogsearch_')) {
53
+ $this->_pageType = 'search';
54
+ return $this->getSearchResultsPixel();
55
+ }
56
+ if (0 === strpos($fullActionName, 'wishlist_')) {
57
+ $this->_pageType = 'wishlist';
58
+ return $this->getWishlistPixel();
59
+ }
60
+ $this->_pageType = 'other';
61
+ return $this->getOtherPixel();
62
+ }
63
+ }
64
+
65
+ protected function _getLang() {
66
+ return substr(Mage::app()->getLocale()->getLocaleCode(), 0, 2);
67
+ }
68
+
69
+ /**
70
+ * make the pixel for the home page
71
+ *
72
+ * @return string
73
+ */
74
+ public function getHomePixel() {
75
+ $pixel = array(
76
+ 'type' => 'home',
77
+ 'lang' => $this->_getLang(),
78
+ 'recContent' => 'refCodeOnly'
79
+ );
80
+ $user = $this->_getUser();
81
+ if ($user) {
82
+ $pixel['user'] = $user;
83
+ }
84
+ return json_encode($pixel);
85
+ }
86
+
87
+ /**
88
+ * make the pixel for the product page
89
+ *
90
+ * @return string
91
+ */
92
+ public function getProductPixel() {
93
+ $pixel = array(
94
+ 'type' => 'product',
95
+ 'lang' => $this->_getLang(),
96
+ 'recContent' => 'refCodeOnly'
97
+ );
98
+ $user = $this->_getUser();
99
+ if ($user) {
100
+ $pixel['user'] = $user;
101
+ }
102
+ $product = Mage::registry('current_product');
103
+ if ($product AND $product->getId()) {
104
+ $pixel['product'] = array(
105
+ 'refCode' => $product->getSku());
106
+ }
107
+ return json_encode($pixel);
108
+ }
109
+
110
+ /**
111
+ * make the pixel for the category page
112
+ *
113
+ * @return string
114
+ */
115
+ public function getCategoryPixel() {
116
+ $pixel = array(
117
+ 'type' => 'category',
118
+ 'lang' => $this->_getLang(),
119
+ 'recContent' => 'refCodeOnly'
120
+ );
121
+ $user = $this->_getUser();
122
+ if ($user) {
123
+ $pixel['user'] = $user;
124
+ }
125
+ $category = $this->escapeHtml(Mage::registry('current_category'));
126
+ if ($category AND $category->getId()) {
127
+ $pixel['category'] = $this->_getCategoryBreadcrumb($category->getId());
128
+ }
129
+ return json_encode($pixel);
130
+ }
131
+
132
+
133
+ /**
134
+ * make the pixel for the basket page
135
+ *
136
+ * @return string
137
+ */
138
+ public function getBasketPixel() {
139
+ $pixel = array(
140
+ 'type' => 'basket',
141
+ 'lang' => $this->_getLang(),
142
+ 'recContent' => 'refCodeOnly'
143
+ );
144
+ $user = $this->_getUser();
145
+ if ($user) {
146
+ $pixel['user'] = $user;
147
+ }
148
+ $cart = Mage::getModel('checkout/cart')->getQuote();
149
+ $items = $cart->getAllItems();
150
+ $pixel['basket']['items'] = array();
151
+ foreach ($items as $item) {
152
+ if ($item->getParentItem()) {
153
+ continue;
154
+ }
155
+ $newItem = array(
156
+ 'refCode' => $item->getSku(),
157
+ 'qty' => $item->getQty(),
158
+ 'price' => $item->getPrice()
159
+ );
160
+ $pixel['basket']['items'][] = $newItem;
161
+ }
162
+ $pixel['basket']['currency'] = Mage::app()->getStore()->getCurrentCurrencyCode();
163
+ return json_encode($pixel);
164
+ }
165
+
166
+ /**
167
+ * makes the pixel for the checkout page
168
+ *
169
+ * @return string
170
+ */
171
+ public function getCheckoutPixel() {
172
+ $pixel = array(
173
+ 'type' => 'checkout',
174
+ 'lang' => $this->_getLang(),
175
+ 'recContent' => 'refCodeOnly'
176
+ );
177
+ $user = $this->_getUser();
178
+ if ($user) {
179
+ $pixel['user'] = $user;
180
+ }
181
+ $cart = Mage::getModel('checkout/cart')->getQuote();
182
+ $items = $cart->getAllItems();
183
+ foreach ($items as $item) {
184
+ if ($item->getParentItem()) {
185
+ continue;
186
+ }
187
+ $newItem = array(
188
+ 'refCode' => $item->getSku(),
189
+ 'qty' => (int) $item->getQty(),
190
+ 'price' => $item->getPrice()
191
+ );
192
+ $pixel['checkout']['items'][] = $newItem;
193
+ }
194
+ $pixel['checkout']['currency'] = Mage::app()->getStore()->getCurrentCurrencyCode();
195
+ // $totals = $cart->getTotals();
196
+ if ($cart->getSubtotal()) {
197
+ $pixel['checkout']['subtotal'] = $cart->getSubtotal();
198
+ }
199
+ if ($cart->getShippingAmount()) {
200
+ $pixel['checkout']['shipping'] = $cart->getShippingAmount();
201
+ }
202
+ $pixel['checkout']['total'] = $cart->getGrandTotal();
203
+ return json_encode($pixel);
204
+ }
205
+
206
+
207
+ /**
208
+ * makes the order confirmation pixel
209
+ *
210
+ * @return string
211
+ */
212
+ public function getOrderPixel() {
213
+ $pixel = array(
214
+ 'type' => 'order',
215
+ 'lang' => $this->_getLang(),
216
+ 'recContent' => 'refCodeOnly'
217
+ );
218
+ $user = $this->_getUser();
219
+ if ($user) {
220
+ $pixel['user'] = $user;
221
+ }
222
+ $orderId = Mage::getSingleton('checkout/session')->getLastOrderId();
223
+ $order = Mage::getModel('sales/order')->load($orderId);
224
+ $pixel['order']['orderNo'] = $order->getIncrementId();
225
+ $items = $order->getAllItems();
226
+ foreach ($items as $item) {
227
+ if ($item->getParentItem()) {
228
+ continue;
229
+ }
230
+ $newItem = array(
231
+ 'refCode' => $item->getSku(),
232
+ 'qty' => (int) $item->getQtyOrdered(),
233
+ 'price' => $item->getPrice()
234
+ );
235
+ $pixel['order']['items'][] = $newItem;
236
+ }
237
+ $pixel['order']['currency'] = Mage::app()->getStore()->getCurrentCurrencyCode();
238
+ // $totals = $order->getTotals();
239
+ if ($order->getSubtotal()) {
240
+ $pixel['order']['subtotal'] = $order->getSubtotal();
241
+ }
242
+ if ($order->getShippingAmount()) {
243
+ $pixel['order']['shipping'] = $order->getShippingAmount();
244
+ }
245
+ $pixel['order']['total'] = $order->getGrandTotal();
246
+ return json_encode($pixel);
247
+ }
248
+
249
+ /**
250
+ * makes the pixel for the search page
251
+ *
252
+ * @return string
253
+ */
254
+ public function getSearchResultsPixel() {
255
+ $pixel = array(
256
+ 'type' => 'searchresults',
257
+ 'lang' => $this->_getLang(),
258
+ 'recContent' => 'refCodeOnly'
259
+ );
260
+ $user = $this->_getUser();
261
+ if ($user) {
262
+ $pixel['user'] = $user;
263
+ }
264
+ $term = Mage::helper('catalogsearch')->getQueryText();
265
+ $pixel['searchResults']['term'] = $this->escapeHtml($term);
266
+ $searchResult = array_slice(Mage::registry('peerius_smartrecs_searchresults'), 0, 10);
267
+ $pixel['searchResults']['results'] = $searchResult;
268
+ return json_encode($pixel);
269
+ }
270
+
271
+ /**
272
+ * makes the pixel for the wishlist page
273
+ *
274
+ * @return string
275
+ */
276
+ public function getWishlistPixel() {
277
+ $pixel = array(
278
+ 'type' => 'wishlist',
279
+ 'lang' => $this->_getLang(),
280
+ 'recContent' => 'refCodeOnly'
281
+ );
282
+ $user = $this->_getUser();
283
+ if ($user) {
284
+ $pixel['user'] = $user;
285
+ }
286
+ $collection = Mage::helper('wishlist')->getWishlistItemCollection();
287
+ $pixel['wishList']['items'] = array();
288
+ foreach ($collection as $item) {
289
+ $product = $item->getProduct();
290
+ $newProduct = array('refCode' => $product->getSku());
291
+ $pixel['wishList']['items'][] = $newProduct;
292
+ }
293
+ return json_encode($pixel);
294
+ }
295
+
296
+ /**
297
+ * makes the pixel for other pages
298
+ *
299
+ * @return string
300
+ */
301
+ public function getOtherPixel() {
302
+ $pixel = array(
303
+ 'type' => 'other',
304
+ 'lang' => $this->_getLang(),
305
+ 'recContent' => 'refCodeOnly'
306
+ );
307
+ $user = $this->_getUser();
308
+ if ($user) {
309
+ $pixel['user'] = $user;
310
+ }
311
+ return json_encode($pixel);
312
+ }
313
+
314
+
315
+ /**
316
+ * generate breadcrumb style category
317
+ * @param array $currentCatId
318
+ * @return string
319
+ */
320
+ protected function _getCategoryBreadcrumb($currentCatId) {
321
+
322
+ if ($currentCatId) {
323
+ $categoryCollection = Mage::getResourceModel('catalog/category_collection')
324
+ ->addAttributeToSelect('path')
325
+ ->addAttributeToFilter('entity_id', $currentCatId)
326
+ ->addIsActiveFilter();
327
+
328
+ foreach ($categoryCollection as $cat) {
329
+ $p = explode('/', $cat->getPath());
330
+
331
+ $fullPath = array();
332
+ foreach ($p as $treeCat) {
333
+ // Root-Kategorie 1 überspringen
334
+ if ($treeCat <= 2)
335
+ continue;
336
+ $category = Mage::getModel('catalog/category')
337
+ ->setStoreId(Mage::app()->getStore()->getId())
338
+ ->load($treeCat);
339
+ $fullPath[] = $category->getName();
340
+ }
341
+ return implode('>', $fullPath);
342
+ }
343
+ }
344
+ return false;
345
+ }
346
+
347
+ /*
348
+ * if available the user name and email is returned
349
+ * @return array
350
+ *
351
+ */
352
+ protected function _getUser() {
353
+ $session = Mage::getSingleton('customer/session');
354
+ $user = array('email'=>'');
355
+ if($session->isLoggedIn()) {
356
+ $customer = $session->getCustomer();
357
+ //$user['name'] = $customer->getName();
358
+ $user['email'] = $customer->getEmail();
359
+ $user['name'] = $customer->getEmail();
360
+ } else {
361
+ $checkout = Mage::getSingleton('checkout/session')->getQuote();
362
+ $billAddress = $checkout->getBillingAddress();
363
+ if ($billAddress->getEmail()) {
364
+ $user['email'] = $billAddress->getEmail();
365
+ //$user['name'] = $billAddress->getFirstname() . ' ' . $billAddress->getLastname();
366
+ $user['name'] = $billAddress->getEmail();
367
+ }
368
+ }
369
+ if (!$user['email']) {
370
+ $lastOrderId = Mage::getSingleton('checkout/session')->getLastOrderId() ?:
371
+ Mage::getSingleton('checkout/session')->getRealOrderId();
372
+ $order = Mage::getModel('sales/order')->load($lastOrderId);
373
+
374
+ if ($order->getBillingAddress()) {
375
+ $custname = $order->getBillingAddress()->getName();
376
+ $email = $order->getBillingAddress()->getEmail();
377
+ $user['email'] = $email;
378
+ //$user['name'] = $custname;
379
+ $user['name'] = $email;
380
+ }
381
+ }
382
+ return $user['email']?$user:false;
383
+ }
384
+
385
+ /**
386
+ * return the peerius tracking tag depending on mode (test or live)
387
+ *
388
+ * @return string html tracking tag
389
+ */
390
+ public function getTrackingTag() {
391
+ if (Mage::helper('peerius_smartrecs')->isTestMode()) {
392
+ return '<script type="text/JavaScript" src="//uat.peerius.com/tracker/peerius.page" charset="UTF-8"></script>';
393
+ }
394
+ return '<script type="text/JavaScript" src="//'.$this->escapeHtml(Mage::getStoreConfig('peerius/general/client_name')).'.peerius.com/tracker/peerius.page" charset="UTF-8"></script>';
395
+ }
396
+ // alert(JSON.stringify(PeeriusCallbacks))
397
+
398
+ }
399
+
app/code/community/Peerius/Smartrecs/Helper/Data.php ADDED
@@ -0,0 +1,136 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * @category Peerius
5
+ * @package Peerius_Smartrecs
6
+ * @author Peerius Ltd
7
+ */
8
+ class Peerius_Smartrecs_Helper_Data extends Mage_Core_Helper_Abstract {
9
+
10
+ const LOG_FILE = "peerius_smartrec.log";
11
+
12
+ /**
13
+ * is the module enabled?
14
+ *
15
+ * @return bool isActive
16
+ */
17
+ public function isActive()
18
+ {
19
+ return ! Mage::getStoreConfig('peerius/general/disabled');
20
+ }
21
+
22
+ /**
23
+ * are we running in test mode=?
24
+ *
25
+ * @return bool isTestMode
26
+ */
27
+ public function isTestMode()
28
+ {
29
+ return Mage::getStoreConfig('peerius/general/testmode');
30
+ }
31
+
32
+ /**
33
+ * is it the admin lookin at the page?
34
+ *
35
+ * @return bool isAdminIP
36
+ */
37
+ public function isAdminIP()
38
+ {
39
+ return (Mage::getStoreConfig('peerius/general/adminip') == Mage::helper('core/http')->getRemoteAddr(true));
40
+ }
41
+
42
+ /**
43
+ * Method to log
44
+ *
45
+ * @param int $level
46
+ * @param string $message
47
+ */
48
+ public function log($level, $message) {
49
+ Mage::log('PEERIUS: ' . $message, $level, static::LOG_FILE, true);
50
+ }
51
+
52
+ /*
53
+ * guess the page type
54
+ * @return string
55
+ */
56
+ public static function getPageType() {
57
+ $fullActionName = Mage::app()->getFrontController()->getAction()->getFullActionName();
58
+
59
+ switch ($fullActionName) {
60
+ case 'cms_index_index':
61
+ // if (Mage::getModel('core/url')->getUrl('') == Mage::getModel('core/url')->getUrl('*/*/*', array('_current' => true, '_use_rewrite' => true))) {
62
+ $routeName = Mage::app()->getRequest()->getRouteName();
63
+ $identifier = Mage::getSingleton('cms/page')->getIdentifier();
64
+
65
+ if($routeName == 'cms' && $identifier == 'home') {
66
+ $_pageType = 'home';
67
+ } else {
68
+ $_pageType = 'other';
69
+ }
70
+ break;
71
+ case 'catalog_category_view':
72
+ $_pageType = 'category';
73
+ break;
74
+ case 'catalog_product_view':
75
+ $_pageType = 'product';
76
+ break;
77
+ case 'checkout_cart_index':
78
+ $_pageType = 'basket';
79
+ break;
80
+ case 'checkout_onepage_index':
81
+ $_pageType = 'checkout';
82
+ break;
83
+ case 'checkout_onepage_success':
84
+ $_pageType = 'order';
85
+ break;
86
+ default:
87
+ if (0 === strpos($fullActionName, 'catalogsearch_')) {
88
+ $_pageType = 'search';
89
+ } else if (0 === strpos($fullActionName, 'wishlist_')) {
90
+ $_pageType = 'wishlist';
91
+ } else {
92
+ $_pageType = 'other';
93
+ }
94
+ break;
95
+ }
96
+
97
+ return $_pageType;
98
+ }
99
+
100
+ /*
101
+ * read the plugin settings to see if recommendations are disabled
102
+ * @return bool
103
+ */
104
+ public function getDisabled() {
105
+ if ($this->isTestMode() AND (null !== Mage::app()->getRequest()->getParam('peeriuspreview')) AND (null !== Mage::app()->getRequest()->getParam('peeriuslocalpreview'))) {
106
+ return true;
107
+ }
108
+
109
+ if (Mage::getStoreConfig('peerius/general/enableall') != 1) {
110
+ return true;
111
+ }
112
+
113
+ return false;
114
+
115
+ }
116
+
117
+ /*
118
+ * read the plugin settings to see if recommendations are disabled for this page
119
+ * @return bool
120
+ */
121
+ public function getPageDisabled($page = null) {
122
+
123
+ $pageType = $page ?:$this->getPageType();
124
+
125
+ // if ($pageType == 'order' OR $pageType == 'basket') {
126
+ // $pageType = 'checkout';
127
+ // }
128
+
129
+ if (Mage::getStoreConfig('peerius/'.$pageType.'/disable') == 1) {
130
+ return true;
131
+ }
132
+
133
+ return false;
134
+
135
+ }
136
+ }
app/code/community/Peerius/Smartrecs/Helper/Feedhelper.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * @category Peerius
5
+ * @package Peerius_Smartrecs
6
+ * @author Peerius Ltd
7
+ */
8
+ class Peerius_Smartrecs_Helper_Feedhelper extends Peerius_Smartrecs_Helper_Data
9
+ {
10
+ }
app/code/community/Peerius/Smartrecs/Model/.DS_Store ADDED
Binary file
app/code/community/Peerius/Smartrecs/Model/Feed/Creator.php ADDED
@@ -0,0 +1,505 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * @category Peerius
5
+ * @package Peerius_Smartrecs
6
+ * @author Peerius Ltd
7
+ */
8
+ class Peerius_Smartrecs_Model_Feed_Creator {
9
+
10
+ protected $fileName;
11
+ protected $secretKey;
12
+ protected $clientName;
13
+ protected $token;
14
+
15
+ /**
16
+ * method to create the feed
17
+ * */
18
+ public function process(Mage_Core_Model_Website $website) {
19
+ $this->fileName = Mage::getBaseDir('tmp') . DS . str_replace(' ', '_', $website->getName()) .
20
+ "_PeeriusFeed" . ".xml";
21
+ $clientName = Mage::getStoreConfig('peerius/general/client_name');
22
+ $this->secretKey = Mage::getStoreConfig('peerius/general/secret_key');
23
+ $this->clientName = Mage::getStoreConfig('peerius/general/client_name');
24
+ $this->token = Mage::getStoreConfig('peerius/general/token');
25
+
26
+ if ($this->_createFile()) {
27
+ if (!$this->_writeFeed($website)) {
28
+ return false;
29
+ }
30
+ } else {
31
+ return false;
32
+ }
33
+ return true;
34
+ }
35
+
36
+ /**
37
+ * @param Mage_Core_Model_Website $website
38
+ * @return bool
39
+ */
40
+ protected function _writeFeed(Mage_Core_Model_Website $website) {
41
+
42
+ try {
43
+ $f = new Varien_Io_File();
44
+ $f->write($this->fileName, $this->_getHeader($website) .
45
+ $this->_getProducts($website) . $this->_getFooter());
46
+
47
+ $f->close();
48
+ return true;
49
+ } catch (Exception $ex) {
50
+ $this->log("error writing the feed");
51
+ $this->log($ex->getMessage());
52
+ return false;
53
+ }
54
+ }
55
+
56
+ /**
57
+ * @param $file
58
+ * @return bool
59
+ */
60
+ protected function _createFile() {
61
+ return true;
62
+ // try {
63
+ // $f = new Varien_Io_File();
64
+ // $validator = new Zend_Validate_File_Exists();
65
+ //
66
+ // if (!$validator->isValid($this->fileName)) {
67
+ // $this->log("could not create the smartrec file");
68
+ // return false;
69
+ // }
70
+ // $this->log("SMART-recs file created");
71
+ //
72
+ // fclose($f);
73
+ // return true;
74
+ // } catch (Exception $ex) {
75
+ // $this->log("error during file creation");
76
+ // $this->log($ex->getMessage());
77
+ // return false;
78
+ // }
79
+ }
80
+
81
+ /**
82
+ * generate the rss file header
83
+ * @param Mage_Core_Model_Website $website
84
+ * @return string
85
+ */
86
+ protected function _getHeader(Mage_Core_Model_Website $website) {
87
+ $clientName = $this->_getClientName();
88
+ $rss = '';
89
+ $rss .= '<?xml version="1.0" encoding="UTF-8"?>';
90
+ $rss .= '<rss version="2.0" xmlns:p="http://www.peerius.com/feeds/PeeriusRSS20.xsd">';
91
+ $rss .= '<channel>';
92
+ $rss .= '<title><![CDATA[Rss 2.0 ' . $clientName . ' product catalogue feed]]></title>';
93
+ $rss .= '<link>' . Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB) . '</link>';
94
+ $rss .= '<description><![CDATA[The latest product catalogue feed of ' . $clientName . '.]]></description>';
95
+ return $rss;
96
+ }
97
+
98
+ /**
99
+ * generate the rss file footer
100
+ * @return string
101
+ */
102
+ protected function _getFooter() {
103
+ $rss = '';
104
+ $rss .= '</channel>';
105
+ $rss .= '</rss>';
106
+ return $rss;
107
+ }
108
+
109
+ /**
110
+ * sets the layout
111
+ * @param string $packageName
112
+ * @param string $themeName
113
+ */
114
+ protected function _changeTheme($packageName, $themeName) {
115
+ Mage::getDesign()->setArea('frontend')
116
+ ->setPackageName($packageName)
117
+ ->setTheme($themeName);
118
+ }
119
+
120
+ /**
121
+ * write the products
122
+ * @param Mage_Core_Model_Website $website
123
+ * @return string
124
+ */
125
+ protected function _getProducts(Mage_Core_Model_Website $website) {
126
+ $profilingStart = microtime(true);
127
+ $adapter = Mage::getSingleton("core/resource");
128
+ $visiblityCondition = array('in' => array(2, 3, 4));
129
+ $_catalogInventoryTable = method_exists($adapter, 'getTableName') ? $adapter->getTableName('cataloginventory_stock_item') : 'catalog_category_product_index';
130
+
131
+ $this->log('started writing products');
132
+
133
+ $this->_changeTheme(Mage::getStoreConfig('design/package/name', $website->getDefaultStore()->getCode()), Mage::getStoreConfig('design/package/theme', $website->getDefaultStore()->getCode()));
134
+
135
+ $rss = '';
136
+
137
+ $productCollection = Mage::getModel('catalog/product')
138
+ ->getCollection()
139
+ ->addWebsiteFilter($website->getWebsiteId())
140
+ ->joinField("qty", $_catalogInventoryTable, 'qty', 'product_id=entity_id', null, 'left')
141
+ ->addAttributeToSelect('*')
142
+ ->addCategoryIds()
143
+ //->addAttributeToFilter('type_id', array('eq' => 'configurable'))
144
+ ->addAttributeToFilter('visibility', $visiblityCondition)
145
+ // ->joinTable('catalog/product_relation', 'child_id=entity_id', array(
146
+ // 'parent_id' => 'parent_id'
147
+ // ), null, 'left')
148
+ ->addPriceData(Mage_Customer_Model_Group::NOT_LOGGED_IN_ID, $website->getWebsiteId());
149
+ // ->load();
150
+
151
+ // if (Mage::app()->getRequest()->getParam('skus')) {
152
+ // $skus = explode(',', Mage::app()->getRequest()->getParam('skus'));
153
+ // $productCollection->addAttributeToFilter('SKU', array('like' => $skus));
154
+ // }
155
+
156
+ //Mage::getSingleton('catalog/product_status')->addVisibleFilterToCollection($productCollection);
157
+ //Mage::getModel('cataloginventory/stock_status')->addStockStatusToProducts($productCollection);
158
+
159
+ $productsCount = $productCollection->getSize();
160
+
161
+ try {
162
+
163
+ foreach ($productCollection as $product) {
164
+ // if ($rCnt++ > 500) continue;
165
+ $categoryIds = $product->getCategoryIds();
166
+ $parentCategoryBreadcrumbs = false;
167
+ $parent = false;
168
+
169
+ // don't export unavailable products
170
+ if (!$product->isAvailable()) {
171
+ $productsCount--;
172
+ continue;
173
+ }
174
+
175
+
176
+ // if a product is not in a category skip it also
177
+ if ($product->getTypeId() == Mage_Catalog_Model_Product_Type::TYPE_SIMPLE) {
178
+ $parent = $this->_getParent($product);
179
+ if ($parent) {
180
+ $parentCategoryBreadcrumbs = $this->_getParentCategoryBreadcrumbs($product);
181
+ $categoryBreadcrumbs = $parentCategoryBreadcrumbs;
182
+ } else {
183
+ $categoryBreadcrumbs = $this->_getCategoryBreadcrumbs($product->getCategoryIds());
184
+ }
185
+ }
186
+
187
+ // is the product or it's product in any category? If not, skip it
188
+ if (!$categoryIds AND !$parentCategoryBreadcrumbs) {
189
+ $productsCount--;
190
+ continue;
191
+ }
192
+
193
+ $rss .= '<item>';
194
+ $rss .= '<title><![CDATA[' . $product->getName() . ']]></title>';
195
+ $rss .= '<link>' . $product->getProductUrl() . '</link>';
196
+ $rss .= '<guid>' . $product->getSku() . '</guid>';
197
+ if ($product->getThumbnail())
198
+ $rss .= '<p:imageLink>' . Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA) . 'catalog/product' . $product->getThumbnail() . '</p:imageLink>';
199
+ $rss .= '<p:price>
200
+ <p:unitPrice>' . number_format($product->getPrice(), 2, '.', '') . '</p:unitPrice>
201
+ <p:salePrice>' . number_format($product->getFinalPrice(), 2, '.', '') . '</p:salePrice>
202
+ <p:currency>' . Mage::app()->getStore($website->getDefaultStore())->getCurrentCurrencyCode() . '</p:currency>
203
+ </p:price>';
204
+
205
+
206
+ if ($product->getTypeId() == Mage_Catalog_Model_Product_Type::TYPE_CONFIGURABLE) {
207
+ $rss .= $this->_getCategoryBreadcrumbs($categoryIds);
208
+ $rss .= '<p:attribute name="minimal_price">' . number_format($product->getMinimalPrice(), 2, '.', '') . '</p:attribute>';
209
+
210
+ $attrArr = Mage::getModel('catalog/product_type_configurable')->getConfigurableAttributesAsArray($product);
211
+
212
+ $childProducts = Mage::getModel('catalog/product_type_configurable')->getUsedProductCollection($product)
213
+ ->addAttributeToSelect('thumbnail')
214
+ ->addAttributeToSelect('name')
215
+ ->joinAttribute('visibility', 'catalog_product/visibility', 'entity_id', null, 'inner', 1);
216
+ foreach ($attrArr as $attr) {
217
+ $childProducts->addAttributeToSelect($attr['attribute_code']);
218
+ }
219
+
220
+ foreach ($childProducts as $childProduct) {
221
+ if ($childProduct->getData('visibility') == Mage_Catalog_Model_Product_Visibility::VISIBILITY_NOT_VISIBLE) {
222
+ //$p = Mage::getModel('catalog/product')->load($childProduct->getId());
223
+ $rss .= '<p:variant>';
224
+ //$rss .= '<p:title><![CDATA[' . $childProduct->getName() . ']]></p:title>';
225
+ foreach ($attrArr as $attr) {
226
+ $rss .= '<p:attribute name="' . $attr['attribute_code'] . '"><![CDATA[' . $childProduct->getAttributeText($attr['attribute_code']) . ']]></p:attribute>';
227
+ }
228
+ $rss .= '<p:attribute name="link">' . $childProduct->getProductUrl() . '</p:attribute>';
229
+ $rss .= '<p:attribute name="guid">' . $childProduct->getSku() . '</p:attribute>';
230
+ $rss .= '<p:attribute name="magento_id">' . $childProduct->getId() . '</p:attribute>';
231
+ if ($product->getThumbnail())
232
+ $rss .= '<p:imageLink>' . Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA) . 'catalog/product' . $childProduct->getThumbnail() . '</p:imageLink>';
233
+ $stockItem = $childProduct->getStockItem();
234
+ $stockQty = ($stockItem instanceof Mage_CatalogInventory_Model_Stock_Item) ?
235
+ (int) $stockItem->getQty() : 0;
236
+ $rss .= '<p:stock>' . $stockQty . '</p:stock>';
237
+ $rss .= '</p:variant>';
238
+ }
239
+ }
240
+ } else {
241
+ if ($parent) {
242
+ $rss .= $parent;
243
+ $rss .= $categoryBreadcrumbs;
244
+ } else {
245
+ $rss .= $categoryBreadcrumbs;
246
+ }
247
+ }
248
+
249
+
250
+ $rss .= '<pubDate>' . $product->getcreated_at() . '</pubDate>';
251
+ $rss .= '<description><![CDATA[' . $product->getDescription() . ']]></description>';
252
+
253
+ if ($product->getAttribute('manufacturer') instanceof Mage_Eav_Model_Entity_Attribute_Abstract) {
254
+ $rss .= '<p:brand><![CDATA[' . $product->getAttributeText('manufacturer') . ']]></p:brand>';
255
+ }
256
+ $rss .= '<p:inStock>' . $this->_getStockStatus($product) . '</p:inStock>';
257
+ $rss .= '<p:stock>' . (int) $product->getQty() . '</p:stock>';
258
+ $rss .= '<p:recommend>Y</p:recommend>';
259
+ $rss .= '<p:recommended>' . $this->_getRecommended($product) . '</p:recommended>';
260
+ $rss .= '<p:attribute name="magento_id">' . $product->getId() . '</p:attribute>';
261
+ $rss .= $this->_getAttributes($product);
262
+ $rss .= $this->_getTags($product);
263
+ $rss .= '</item>';
264
+ }
265
+
266
+ $this->log($productsCount . " items");
267
+ } catch (Exception $e) {
268
+ $this->log("an error occured: " . $e->getMessage());
269
+ }
270
+ $this->log("done");
271
+
272
+
273
+ if ($productsCount == 0) {
274
+ $this->log("no products found");
275
+ throw new Exception("no products found");
276
+ }
277
+
278
+ $now = microtime(true);
279
+
280
+ $this->log('Elapsed ' . date("H:i:s", ($now - $profilingStart)));
281
+ $this->log('Memory ' . memory_get_peak_usage() / 1048576 . 'MB');
282
+ return $rss;
283
+ }
284
+
285
+ /**
286
+ * generate breadcrumb style categories
287
+ * @param array $currentCatIds
288
+ * @return string
289
+ */
290
+ protected function _getCategoryBreadcrumbs($currentCatIds) {
291
+ $rss = '';
292
+
293
+ if ($currentCatIds) {
294
+ $categoryCollection = Mage::getResourceModel('catalog/category_collection')
295
+ ->addAttributeToSelect('path')
296
+ ->addAttributeToFilter('entity_id', $currentCatIds)
297
+ ->addIsActiveFilter();
298
+
299
+ foreach ($categoryCollection as $cat) {
300
+ $p = explode('/', $cat->getPath());
301
+
302
+ $fullPath = array();
303
+ foreach ($p as $treeCat) {
304
+ // Root-Kategorie 1 überspringen
305
+ if ($treeCat <= 2)
306
+ continue;
307
+ $category = Mage::getModel('catalog/category')
308
+ ->setStoreId(Mage::app()->getStore()->getId())
309
+ ->load($treeCat);
310
+ $fullPath[] = $category->getName();
311
+ }
312
+ $rss .= '<category><![CDATA[' . implode('>', $fullPath) . ']]></category>';
313
+ }
314
+ }
315
+ return $rss;
316
+ }
317
+
318
+ /**
319
+ * generate breadcrumb style categories
320
+ * @param product $product
321
+ * @return string
322
+ */
323
+ protected function _getParentCategoryBreadcrumbs($product) {
324
+ $rss = '';
325
+ $parentIds = $this->_getParent($product, true);
326
+ $categoryIds = array();
327
+
328
+ foreach ($parentIds as $parentId) {
329
+ $product = Mage::getModel('catalog/product')->load($parentId);
330
+ $categoryIds = array_merge($categoryIds, $product->getCategoryIds());
331
+ }
332
+
333
+ $rss = $this->_getCategoryBreadcrumbs($categoryIds);
334
+ return $rss;
335
+ }
336
+
337
+ /**
338
+ * retreive the product stock statuss
339
+ * @param Mage_Core_Catalog_Product $product
340
+ * @return string
341
+ */
342
+ protected function _getStockStatus($product) {
343
+ $stockStatus = Mage::getModel('cataloginventory/stock_item')
344
+ ->getCollection()
345
+ ->addFieldToFilter('product_id', $product->getId())
346
+ ->getFirstItem();
347
+
348
+ return $stockStatus ? 'Y' : 'N';
349
+ }
350
+
351
+ /**
352
+ * write the products
353
+ * @param Mage_Core_Catalog_Product $product
354
+ * @return string
355
+ */
356
+ protected function _getRecommended($product) {
357
+ $all = array();
358
+ $related = $product->getRelatedProductIds();
359
+ foreach ($related as $id) {
360
+ $all[$id] = $id;
361
+ }
362
+ $crosssell = $product->getCrossSellProducts();
363
+ foreach ($crosssell as $_item) {
364
+ $all[$_item->getId()] = $_item->getId();
365
+ }
366
+ $upsell = $product->getUpSellProductCollection();
367
+ foreach ($upsell as $_item) {
368
+ $all[$_item->getId()] = $_item->getId();
369
+ }
370
+ return implode(',', $all);
371
+ }
372
+
373
+ /**
374
+ * generate comma-separated list of product tags
375
+ * @param Mage_Core_Catalog_Product $product
376
+ * @return string
377
+ */
378
+ protected function _getTags($product) {
379
+ $tag_model = Mage::getModel('tag/tag');
380
+ $tag_collection = $tag_model->getResourceCollection()
381
+ ->addPopularity()
382
+ // ->addStatusFilter($model->getApprovedStatus())
383
+ ->addProductFilter($product->getId())
384
+ ->setFlag('relation', true)
385
+ ->addStoreFilter(Mage::app()->getStore()->getId())
386
+ ->setActiveFilter()
387
+ ->load();
388
+
389
+ $mytags = $tag_collection->getItems();
390
+
391
+ $tagArr = array();
392
+ if (!$tag_collection->getSize()) {
393
+ return '';
394
+ }
395
+
396
+ foreach ($mytags as $tag) {
397
+ $tagArr[] = $tag->getName();
398
+ }
399
+ return '<p:tags>' . implode(',', $tagArr) . '</p:tags>';
400
+ }
401
+
402
+ /**
403
+ * crate front-end attributes rss string
404
+ * @param Mage_Core_Catalog_Product $product
405
+ * @return string
406
+ */
407
+ protected function _getAttributes($product) {
408
+ $attributes = $product->getAttributes();
409
+ $rss = '';
410
+ foreach ($attributes as $attribute) {
411
+ if ($attribute->getIsVisibleOnFront()) {
412
+ $attributeCode = $attribute->getAttributeCode();
413
+ $label = $attribute->getFrontend()->getLabel($product);
414
+ $value = $attribute->getFrontend()->getValue($product);
415
+ $rss .= '<p:attribute name="' . $attributeCode . '"><![CDATA[' . $value . ']]></p:attribute>';
416
+ }
417
+ }
418
+ return $rss;
419
+ }
420
+
421
+ /**
422
+ * returns parent product ID if available
423
+ * @param Mage_Core_Catalog_Product $product
424
+ * @param bool return the ids
425
+ * @return int
426
+ */
427
+ protected function _getParent($product, $ids = false) {
428
+ $rss = '';
429
+ $parentIds = false;
430
+ if ($product->getTypeId() == "simple") {
431
+ $parentIds = Mage::getModel('catalog/product_type_grouped')->getParentIdsByChild($product->getId()); // check for grouped product
432
+ if (!$parentIds)
433
+ $parentIds = Mage::getModel('catalog/product_type_configurable')->getParentIdsByChild($product->getId()); //check for config product
434
+ }
435
+ if ($ids) {
436
+ return $parentIds;
437
+ }
438
+ if ($parentIds) {
439
+ $rss = '<p:attribute name="parent_magento_id">' . implode(',', $parentIds) . '</p:attribute>';
440
+ } else {
441
+ return false;
442
+ }
443
+ return $rss;
444
+ }
445
+
446
+ /**
447
+ * the client name used in the rss feed
448
+ * @return string
449
+ */
450
+ protected function _getClientName() {
451
+ return Mage::getStoreConfig('peerius/general/client_name');
452
+ }
453
+
454
+ /**
455
+ * @param $content
456
+ * @return bool
457
+ */
458
+ protected function _appendToFile($content) {
459
+ try {
460
+ $f = new Varien_Io_File();
461
+ $validator = new Zend_Validate_File_Exists();
462
+
463
+ if (!$validator->isValid($this->fileName)) {
464
+ $this->log("could not create the smartrec file");
465
+ return false;
466
+ }
467
+ $this->log("SMART-recs file created");
468
+
469
+ fclose($f);
470
+ return true;
471
+ } catch (Exception $ex) {
472
+ $this->log("error during file creation");
473
+ $this->log($ex->getMessage());
474
+ return false;
475
+ }
476
+ try {
477
+ $f = new Varien_Io_File();
478
+ $f->write($this->fileName, $content);
479
+ //if (file_put_contents($this->fileName, $content, FILE_APPEND)) {
480
+ return true;
481
+ } catch (Exception $ex) {
482
+ $this->log("error while writing to the feed file");
483
+ $this->log($ex->getMessage());
484
+ return false;
485
+ }
486
+ }
487
+
488
+ public function checkToken() {
489
+ $token = Mage::getStoreConfig('peerius/general/token');
490
+
491
+ if (!$token OR !Mage::app()->getRequest()->getParam('token') OR (Mage::app()->getRequest()->getParam('token') != sha1($token))) {
492
+ $this->log("token error");
493
+ return false;
494
+ }
495
+ return true;
496
+ }
497
+
498
+ /**
499
+ * @param string $message
500
+ */
501
+ protected function log($message) {
502
+ Mage::helper('peerius_smartrecs')->log(Zend_Log::DEBUG, $message);
503
+ }
504
+
505
+ }
app/code/community/Peerius/Smartrecs/Model/Max.php ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * @category Peerius
5
+ * @package Peerius_Smartrecs
6
+ * @author Peerius Ltd
7
+ */
8
+ class Peerius_Smartrecs_Model_Max {
9
+
10
+ protected $_options;
11
+ protected $_default = 3;
12
+
13
+ public function toOptionArray() {
14
+ if (!$this->_options) {
15
+ for ($i = 1; $i <= 10; $i++) {
16
+ $this->_options[$i] = $i;
17
+ }
18
+ }
19
+
20
+ return $this->_options;
21
+ }
22
+
23
+ }
app/code/community/Peerius/Smartrecs/Model/SearchLayer.php ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * @category Peerius
5
+ * @package Peerius_Smartrecs
6
+ * @author Peerius Ltd
7
+ */
8
+ class Peerius_Smartrecs_Model_SearchLayer extends Mage_CatalogSearch_Model_Layer {
9
+
10
+ /**
11
+ * get the found product for the tracking
12
+ * @return $this
13
+ */
14
+ public function prepareProductCollection($collection) {
15
+ parent::prepareProductCollection($collection);
16
+ $sku = array();
17
+ $coll = clone $collection;
18
+ foreach ($coll as $item) {
19
+ $data = $item->getData();
20
+ $sku[] = array('refCode' => $data['sku']);
21
+ }
22
+ Mage::register('peerius_smartrecs_searchresults', $sku);
23
+ return $this;
24
+ }
25
+ }
app/code/community/Peerius/Smartrecs/Model/System/Config/Source/Dropdown/Values.php ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Peerius_Smartrecs_Model_System_Config_Source_Dropdown_Values {
4
+
5
+ public function toOptionArray() {
6
+ for($i = 0;$i <= 18;$i++) {
7
+ $arr[] = array(
8
+ 'value' => $i,
9
+ 'label' => str_pad($i, 2, '0', STR_PAD_LEFT).':00'
10
+ );
11
+ }
12
+ return $arr;
13
+ }
14
+
15
+ }
app/code/community/Peerius/Smartrecs/Model/System/Config/Source/Yesno.php ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Peerius_Smartrecs_Model_System_Config_Source_Yesno {
4
+
5
+ /**
6
+ * Options getter
7
+ *
8
+ * @return array
9
+ */
10
+ public function toOptionArray() {
11
+ return array(
12
+ array('value' => 0, 'label' => Mage::helper('adminhtml')->__('Yes')),
13
+ array('value' => 1, 'label' => Mage::helper('adminhtml')->__('No')),
14
+ );
15
+ }
16
+
17
+ /**
18
+ * Get options in "key-value" format
19
+ *
20
+ * @return array
21
+ */
22
+ public function toArray() {
23
+ return array(
24
+ 1 => Mage::helper('adminhtml')->__('No'),
25
+ 0 => Mage::helper('adminhtml')->__('Yes'),
26
+ );
27
+ }
28
+
29
+ }
app/code/community/Peerius/Smartrecs/Model/Templates.php ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * @category Peerius
5
+ * @package Peerius_Smartrecs
6
+ * @author Peerius Ltd
7
+ */
8
+ class Peerius_Smartrecs_Model_Templates {
9
+
10
+ protected $_options;
11
+ protected $_default = 'horizontal.phtml';
12
+
13
+ protected $_file = array(
14
+ 'home.phtml',
15
+ 'search.phtml',
16
+ 'product-1.phtml',
17
+ 'product-2.phtml',
18
+ 'basket.phtml',
19
+ 'category.phtml',
20
+ 'custom-1.phtml',
21
+ 'custom-2.phtml',
22
+ 'custom-3.phtml',
23
+ 'custom-4.phtml',
24
+ 'custom-5.phtml'
25
+ );
26
+
27
+ public function toOptionArray() {
28
+ if (!$this->_options) {
29
+
30
+ $this->_options[] = '---';
31
+ $this->_options[$this->_default] = $this->_default;
32
+ foreach ($this->_file as $entry) {
33
+ $this->_options[$entry] = $entry;
34
+ }
35
+ }
36
+ return $this->_options;
37
+ }
38
+
39
+ }
app/code/community/Peerius/Smartrecs/Model/Templates/Basket.php ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * @category Peerius
5
+ * @package Peerius_Smartrecs
6
+ * @author Peerius Ltd
7
+ */
8
+ class Peerius_Smartrecs_Model_Templates_Basket extends Peerius_Smartrecs_Model_Templates {
9
+
10
+ protected $_default = 'basket.phtml';
11
+
12
+ }
app/code/community/Peerius/Smartrecs/Model/Templates/Category.php ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * @category Peerius
5
+ * @package Peerius_Smartrecs
6
+ * @author Peerius Ltd
7
+ */
8
+ class Peerius_Smartrecs_Model_Templates_Category extends Peerius_Smartrecs_Model_Templates {
9
+
10
+ protected $_default = 'category.phtml';
11
+
12
+ }
app/code/community/Peerius/Smartrecs/Model/Templates/Checkout.php ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * @category Peerius
5
+ * @package Peerius_Smartrecs
6
+ * @author Peerius Ltd
7
+ */
8
+ class Peerius_Smartrecs_Model_Templates_Checkout extends Peerius_Smartrecs_Model_Templates {
9
+
10
+ protected $_default = 'checkout.phtml';
11
+
12
+ }
app/code/community/Peerius/Smartrecs/Model/Templates/Home.php ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * @category Peerius
5
+ * @package Peerius_Smartrecs
6
+ * @author Peerius Ltd
7
+ */
8
+ class Peerius_Smartrecs_Model_Templates_Home extends Peerius_Smartrecs_Model_Templates {
9
+
10
+ protected $_default = 'home.phtml';
11
+
12
+ }
app/code/community/Peerius/Smartrecs/Model/Templates/Order.php ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * @category Peerius
5
+ * @package Peerius_Smartrecs
6
+ * @author Peerius Ltd
7
+ */
8
+ class Peerius_Smartrecs_Model_Templates_Order extends Peerius_Smartrecs_Model_Templates {
9
+
10
+ protected $_default = 'order.phtml';
11
+
12
+ }
app/code/community/Peerius/Smartrecs/Model/Templates/Other.php ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * @category Peerius
5
+ * @package Peerius_Smartrecs
6
+ * @author Peerius Ltd
7
+ */
8
+ class Peerius_Smartrecs_Model_Templates_Other extends Peerius_Smartrecs_Model_Templates {
9
+
10
+ protected $_default = 'other.phtml';
11
+
12
+ }
app/code/community/Peerius/Smartrecs/Model/Templates/Product1.php ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * @category Peerius
5
+ * @package Peerius_Smartrecs
6
+ * @author Peerius Ltd
7
+ */
8
+ class Peerius_Smartrecs_Model_Templates_Product1 extends Peerius_Smartrecs_Model_Templates {
9
+
10
+ protected $_default = 'product-1.phtml';
11
+
12
+ }
app/code/community/Peerius/Smartrecs/Model/Templates/Product2.php ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * @category Peerius
5
+ * @package Peerius_Smartrecs
6
+ * @author Peerius Ltd
7
+ */
8
+ class Peerius_Smartrecs_Model_Templates_Product2 extends Peerius_Smartrecs_Model_Templates {
9
+
10
+ protected $_default = 'product-2.phtml';
11
+
12
+ }
app/code/community/Peerius/Smartrecs/Model/Templates/Search.php ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * @category Peerius
5
+ * @package Peerius_Smartrecs
6
+ * @author Peerius Ltd
7
+ */
8
+ class Peerius_Smartrecs_Model_Templates_Search extends Peerius_Smartrecs_Model_Templates {
9
+
10
+ protected $_default = 'search.phtml';
11
+
12
+ }
app/code/community/Peerius/Smartrecs/Model/Templates/Wishlist.php ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * @category Peerius
5
+ * @package Peerius_Smartrecs
6
+ * @author Peerius Ltd
7
+ */
8
+ class Peerius_Smartrecs_Model_Templates_Wishlist extends Peerius_Smartrecs_Model_Templates {
9
+
10
+ protected $_default = 'wishlist.phtml';
11
+
12
+ }
app/code/community/Peerius/Smartrecs/Model/Token.php ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * @category Peerius
5
+ * @package Peerius_Smartrecs
6
+ * @author Peerius Ltd
7
+ */
8
+ class Peerius_Smartrecs_Model_Token extends Mage_Core_Model_Config_Data {
9
+
10
+ public function save() {
11
+ $token = $this->getValue(); //get the value from our config
12
+ if ($token AND !preg_match("/^[a-zA-Z0-9]+$/", $token)) {
13
+ Mage::throwException("Token allows only alphanumeric characters.");
14
+ }
15
+
16
+ return parent::save(); //call original save method so whatever happened
17
+ //before still happens (the value saves)
18
+ }
19
+
20
+ /**
21
+ * Retrieve adminhtml session model object
22
+ *
23
+ * @return Mage_Adminhtml_Model_Session
24
+ */
25
+ protected function _getSession() {
26
+ return Mage::getSingleton('adminhtml/session');
27
+ }
28
+
29
+
30
+ }
app/code/community/Peerius/Smartrecs/controllers/Adminhtml/PeeriusController.php ADDED
@@ -0,0 +1,90 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * admin configuration controller
5
+ * @category Peerius
6
+ * @package Peerius_Smartrecs
7
+ * @author Peerius Ltd
8
+ */
9
+ class Peerius_Smartrecs_Adminhtml_PeeriusController extends Mage_Adminhtml_Controller_Action {
10
+
11
+ public $_publicActions = array('config');
12
+
13
+ const EMAIL_TRIES = 5;
14
+
15
+ public function configAction() {
16
+ $token = Mage::getStoreConfig('peerius/general/token');
17
+
18
+ if (!$token) {
19
+ $session = Mage::getSingleton('admin/session');
20
+ $session->setAcl(Mage::getResourceModel('admin/acl')->loadAcl());
21
+ //Mage::getSingleton('adminhtml/session')->addSuccess($this->__('ACL reloaded'));
22
+ }
23
+ $this->_redirect("adminhtml/system_config/edit", array("section" => "peerius"));
24
+ }
25
+
26
+ public function registerAction() {
27
+ $registrationStatus = Mage::getStoreConfig('peerius/general/registrationstatus');
28
+ $registrationError = Mage::getStoreConfig('peerius/general/registrationerror');
29
+ $body = "Hi there,
30
+
31
+ a new client (" . Mage::app()->getRequest()->getParam('email') . ") wants to register for SMART-recs.
32
+
33
+ Shop-URL:
34
+ " . Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB) . "
35
+
36
+ Name of the Store:
37
+ " . Mage::getStoreConfig('general/store_information/name') . "
38
+
39
+ Phone Number:
40
+ " . Mage::getStoreConfig('general/store_information/phone') . "
41
+
42
+ Address:
43
+ " . Mage::getStoreConfig('general/store_information/address') . "
44
+
45
+ The message:
46
+ " . Mage::app()->getRequest()->getParam('message');
47
+ $mail = Mage::getModel('core/email');
48
+ $mail->setToName('Admin');
49
+ $mail->setToEmail('extensions@peerius.com');
50
+ $mail->setBody($body);
51
+ $mail->setSubject('New Magento Connect Registration');
52
+ $mail->setFromEmail(Mage::app()->getRequest()->getParam('email'));
53
+ $mail->setFromName(Mage::app()->getRequest()->getParam('email'));
54
+ $mail->setType('text'); // You can use 'html' or 'text'
55
+
56
+ try {
57
+ $mail->send();
58
+ $this->_getSession()->addNotice('Thank you for registering your Peerius SMART-recs extension. The Peerius Extensions Team will get back to you within the next 24-48 hours with information you require to progress with your setup.');
59
+ // Mage::getSingleton('core/session')->addSuccess('Your request has been sent');
60
+ // $this->_redirect('');
61
+ Mage::getModel('core/config')->saveConfig('peerius/general/registrationstatus', 1);
62
+ } catch (Exception $e) {
63
+ Mage::getModel('core/config')->saveConfig('peerius/general/registrationerror', ++$registrationError);
64
+ if ($registrationError <= self::EMAIL_TRIES) {
65
+ $message = 'Unable to send.';
66
+ } else {
67
+ $message = 'Unfortunately, there is some problem with sending an email to Peerius. Please contact
68
+ the <a href="mailto:extensions@peerius.com">Peerius Extensions Team</a> about this issue
69
+ and they will contact you to help you complete the registration process.';
70
+ }
71
+ Mage::getSingleton('core/session')->addError($message);
72
+ $this->_redirect('');
73
+ }
74
+
75
+ $this->_redirect("adminhtml/system_config/edit", array("section" => "peerius", "register" => "done"));
76
+ }
77
+
78
+ public function aclreloadAction() {
79
+ $session = Mage::getSingleton('admin/session');
80
+ $session->setAcl(Mage::getResourceModel('admin/acl')->loadAcl());
81
+ Mage::getSingleton('adminhtml/session')->addSuccess($this->__('ACL reloaded'));
82
+ $this->_redirectReferer();
83
+ }
84
+
85
+ protected function _isAllowed()
86
+ {
87
+ return true;
88
+ }
89
+
90
+ }
app/code/community/Peerius/Smartrecs/controllers/FeedController.php ADDED
@@ -0,0 +1,145 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * create the product feed
5
+ * @category Peerius
6
+ * @package Peerius_Smartrecs
7
+ * @author Peerius Ltd
8
+ */
9
+ class Peerius_Smartrecs_FeedController extends Mage_Core_Controller_Front_Action {
10
+
11
+ /**
12
+ * Smartrecs helper
13
+ * @return Peerius_Smartrecs_Helper_Confighelper
14
+ */
15
+ protected function _helper() {
16
+ return Mage::helper("peerius_smartrecs/feedhelper");
17
+ }
18
+
19
+ /**
20
+ * create the product feed
21
+ * @return null
22
+ */
23
+ public function createAction() {
24
+ if (Mage::app()->getRequest()->getParam('version') AND Mage::app()->getRequest()->getParam('version') == 3) {
25
+ $creator = Mage::getSingleton('peerius_smartrecs/feed_creatorsql');
26
+ } else {
27
+ $creator = Mage::getSingleton('peerius_smartrecs/feed_creator');
28
+ }
29
+
30
+ if ($creator->checkToken()) {
31
+ $website = $this->_checkSite();
32
+ if (is_null($website)) {
33
+ $website = Mage::app()->getWebsite(1);
34
+ }
35
+ set_time_limit(0);
36
+ ignore_user_abort(true);
37
+ if ($this->getRequest()->getParam('debug')==1) {
38
+ error_reporting(E_ALL);
39
+ ini_set('display_errors','on');
40
+ }
41
+
42
+ $creator->process($website);
43
+ }
44
+ }
45
+
46
+ /**
47
+ * return the product feed
48
+ * @return null
49
+ */
50
+ public function showAction() {
51
+ if (Mage::app()->getRequest()->getParam('version') AND Mage::app()->getRequest()->getParam('version') == 3) {
52
+ $creator = Mage::getSingleton('peerius_smartrecs/feed_creatorsql');
53
+ } else {
54
+ $creator = Mage::getSingleton('peerius_smartrecs/feed_creator');
55
+ }
56
+
57
+ if ($creator->checkToken()) {
58
+ $website = $this->_checkSite();
59
+ if (is_null($website)) {
60
+ $website = Mage::app()->getWebsite(1);
61
+ }
62
+ $this->fileName = Mage::getBaseDir('tmp') . DS . str_replace(' ', '_', $website->getName()) .
63
+ "_PeeriusFeed" . ".xml";
64
+
65
+ $this->getResponse()->setHeader('Cache-Control', 'no-cache, must-revalidate');
66
+ $this->getResponse()->setHeader('Expires', 'Mon, 26 Jul 1997 05:00:00 GMT');
67
+ $this->getResponse()->setHeader('Content-Type', 'application/rss+xml; charset=UTF-8');
68
+
69
+ $file = new Varien_Io_File();
70
+ $this->_prepareDownloadResponse($this->fileName, $file->read($this->fileName), 'application/rss+xml');
71
+ }
72
+ }
73
+
74
+ /**
75
+ * create and show the product feed
76
+ * @return null
77
+ */
78
+ public function createAndShowAction() {
79
+ $website = $this->_checkSite();
80
+ if (is_null($website)) {
81
+ $website = Mage::app()->getWebsite(1);
82
+ }
83
+ set_time_limit(0);
84
+ ignore_user_abort(true);
85
+ if ($this->getRequest()->getParam('debug')==1) {
86
+ error_log(E_ALL);
87
+ ini_set('display_errors','on');
88
+ }
89
+ if (Mage::app()->getRequest()->getParam('version') AND Mage::app()->getRequest()->getParam('version') == 3) {
90
+ $creator = Mage::getSingleton('peerius_smartrecs/feed_creatorsql');
91
+ } else {
92
+ $creator = Mage::getSingleton('peerius_smartrecs/feed_creator');
93
+ }
94
+
95
+ if ($creator->checkToken()) {
96
+ $creator->process($website);
97
+
98
+ // ---
99
+
100
+
101
+ $this->fileName = Mage::getBaseDir('tmp') . DS . str_replace(' ', '_', $website->getName()) .
102
+ "_PeeriusFeed" . ".xml";
103
+
104
+ $this->getResponse()->setHeader('Cache-Control', 'no-cache, must-revalidate');
105
+ $this->getResponse()->setHeader('Expires', 'Mon, 26 Jul 1997 05:00:00 GMT');
106
+ $this->getResponse()->setHeader('Content-Type', 'application/rss+xml; charset=UTF-8');
107
+
108
+ $file = new Varien_Io_File();
109
+ $this->_prepareDownloadResponse($this->fileName, $file->read($this->fileName), 'application/rss+xml');
110
+ }
111
+ }
112
+
113
+ /**
114
+ * @param $websiteName
115
+ * @return mixed
116
+ */
117
+ protected function _getWebsiteByName($websiteName) {
118
+ return Mage::getResourceModel('core/website_collection')
119
+ ->addFieldToFilter('name', $websiteName)
120
+ ->getFirstItem();
121
+ }
122
+
123
+ /**
124
+ * the website to create the feed for, e.g. Main Website
125
+ * @return Mage_Core_Model_Website
126
+ */
127
+ protected function _checkSite() {
128
+ if ($this->getRequest()->getParam('site')) {
129
+ $website = $this->_getWebsiteByName($this->getRequest()->getParam('site'));
130
+ }
131
+
132
+ if (!isset($website) || !$website->hasData("website_id")) {
133
+ return null;
134
+ }
135
+ return $website;
136
+ }
137
+
138
+ public function unlockAction() {
139
+ $creator = Mage::getSingleton('peerius_smartrecs/feed_creator');
140
+ if ($creator->checkToken()) {
141
+ Mage::getModel('core/config')->saveConfig('peerius/general/creatingfeed', 0);
142
+ }
143
+ }
144
+
145
+ }
app/code/community/Peerius/Smartrecs/controllers/InfoController.php ADDED
@@ -0,0 +1,193 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * syncing the products to the peerius server
5
+ * @category Peerius
6
+ * @package Peerius_Smartrecs
7
+ * @author Peerius Ltd
8
+ */
9
+ class Peerius_Smartrecs_InfoController extends Mage_Core_Controller_Front_Action {
10
+
11
+ /**
12
+ * when is the cron executed?
13
+ * @return int
14
+ */
15
+ public function createtimeAction() {
16
+ if ($this->checkToken()) {
17
+ $response = (int) Mage::getStoreConfig('peerius/general/cronjob');
18
+
19
+ $this->getResponse()
20
+ ->setHeader('Content-Type', 'text/html')
21
+ ->setBody($response);
22
+ }
23
+ }
24
+
25
+ /**
26
+ * what registration status has the shop
27
+ * @return int
28
+ */
29
+ public function registrationstatusAction() {
30
+ if ($this->checkToken()) {
31
+ $response = (int) Mage::getStoreConfig('peerius/general/registrationstatus');
32
+
33
+ $this->getResponse()
34
+ ->setHeader('Content-Type', 'text/html')
35
+ ->setBody($response);
36
+ }
37
+ }
38
+
39
+ /**
40
+ * what registration status has the shop
41
+ * @return int
42
+ */
43
+ public function registrationerrorAction() {
44
+ if ($this->checkToken()) {
45
+ $response = (int) Mage::getStoreConfig('peerius/general/registrationerror');
46
+
47
+ $this->getResponse()
48
+ ->setHeader('Content-Type', 'text/html')
49
+ ->setBody($response);
50
+ }
51
+ }
52
+
53
+ /*
54
+ * returns the parameters of the created peerius SMARTrecs widgets
55
+ * @return string
56
+ */
57
+ public function widgetsAction() {
58
+ if ($this->checkToken()) {
59
+ $response = '';
60
+ $collection = Mage::getModel('widget/widget_instance')->getCollection();
61
+ $collection->addFieldToFilter('instance_type', 'smartrecs/recommendations');
62
+
63
+ foreach($collection as $item)
64
+ {
65
+ $response .= $item->title.'<hr>';
66
+ $response .= $item->widget_parameters;
67
+ $response .= '<br><br><br>';
68
+ }
69
+
70
+ $this->getResponse()
71
+ ->setHeader('Content-Type', 'text/html')
72
+ ->setBody($response);
73
+ }
74
+ }
75
+
76
+ /*
77
+ * returns the parameters of the created peerius SMARTrecs widgets
78
+ * @return string
79
+ */
80
+ public function allconfigAction() {
81
+ if ($this->checkToken()) {
82
+ $response = '';
83
+
84
+ $response .= '<h1>Standard Widgets</h1>';
85
+ $configs = Mage::getModel('core/config_data')->getCollection()->addFieldToFilter('path',array('like'=>'peerius%'))->setOrder('path');
86
+
87
+ foreach ($configs as $config) {
88
+ $path = str_replace('max','number_of_products', $config->getPath());
89
+ $value = $config->getValue();
90
+ $response .= 'Config: ' . $path.'<br>';
91
+ $response .= 'Value: ' . $value;
92
+ $response .= '<hr>';
93
+ }
94
+
95
+ $response .= '<h1>Widget Instance Manager</h1>';
96
+
97
+
98
+ $collection = Mage::getModel('widget/widget_instance')->getCollection();
99
+ $collection->addFieldToFilter('instance_type', 'smartrecs/recommendations');
100
+
101
+ foreach($collection as $item)
102
+ {
103
+ $response .= $item->title.'<hr>';
104
+ $response .= $item->widget_parameters;
105
+ $response .= '<br><br><br>';
106
+ }
107
+
108
+
109
+ $this->getResponse()
110
+ ->setHeader('Content-Type', 'text/html')
111
+ ->setBody($response);
112
+ }
113
+ }
114
+
115
+ /*
116
+ * resets the registration status
117
+ * @return string
118
+ */
119
+ public function registrationstatusresetAction() {
120
+ if ($this->checkToken()) {
121
+ Mage::getModel('core/config')->saveConfig('peerius/general/registrationstatus', '0');
122
+ Mage::getModel('core/config')->saveConfig('peerius/general/registrationerror', '0');
123
+ }
124
+ }
125
+
126
+
127
+ /*
128
+ * deletes the configuration
129
+ * @return string
130
+ */
131
+ public function resetconfigAction() {
132
+ if ($this->checkToken()) {
133
+ $configs = Mage::getModel('core/config_data')->getCollection()->addFieldToFilter('path',array('like'=>'peerius%'));
134
+
135
+ foreach ($configs as $config) {
136
+ $config->delete($config);
137
+ }
138
+ $response = count($configs) . ' entries deleted';
139
+
140
+ $this->getResponse()
141
+ ->setHeader('Content-Type', 'text/html')
142
+ ->setBody($response);
143
+ }
144
+ }
145
+
146
+ /*
147
+ * sets the admin IP to preview recommendations in test mode
148
+ * @return string
149
+ */
150
+ public function adminipAction() {
151
+ if ($this->checkToken()) {
152
+ if (!filter_var($this->getRequest()->getParam('ip'), FILTER_VALIDATE_IP) === false) {
153
+ Mage::getModel('core/config')->saveConfig('peerius/general/adminip', $this->getRequest()->getParam('ip'));
154
+ }
155
+ }
156
+ }
157
+
158
+ /*
159
+ * reads the admin IP
160
+ * @return string
161
+ */
162
+ public function adminipreadAction() {
163
+ if ($this->checkToken()) {
164
+ $response = Mage::getStoreConfig('peerius/general/adminip');
165
+
166
+ $this->getResponse()
167
+ ->setHeader('Content-Type', 'text/html')
168
+ ->setBody($response);
169
+ }
170
+ }
171
+
172
+ /*
173
+ * checks for the valid token to prevent URL manipulation
174
+ * @return bool
175
+ */
176
+ public function checkToken() {
177
+ $token = Mage::getStoreConfig('peerius/general/token');
178
+
179
+ if (!$token OR !$this->getRequest()->getParam('token') OR ($this->getRequest()->getParam('token') != sha1($token))) {
180
+ $this->log("token error");
181
+ return false;
182
+ }
183
+ return true;
184
+ }
185
+
186
+ /**
187
+ * @param string $message
188
+ */
189
+ protected function log($message) {
190
+ Mage::helper('peerius_smartrecs')->log(Zend_Log::DEBUG, $message);
191
+ }
192
+
193
+ }
app/code/community/Peerius/Smartrecs/controllers/RenderController.php ADDED
@@ -0,0 +1,82 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * show recommendations using a specific theme
5
+ * @category Peerius
6
+ * @package Peerius_Smartrecs
7
+ * @author Peerius Ltd
8
+ */
9
+ class Peerius_Smartrecs_RenderController extends Mage_Core_Controller_Front_Action {
10
+ protected $_pageType = '';
11
+
12
+ /**
13
+ */
14
+ public function indexAction() {
15
+ $myHtml = '';
16
+
17
+ $helper = Mage::helper('peerius_smartrecs');
18
+ //$template = $this->getRequest()->getParam('template') ?: 'catalog/product/list/related.phtml';
19
+ $template = $this->getRequest()->getParam('template') ?: 'other.phtml';
20
+ $template = (strpos($template, DS) === false) ? 'smartrecs/recs/'.$template : $template;
21
+
22
+ $this->loadLayout();
23
+ $myBlock = $this->getLayout()->createBlock('smartrecs/template');
24
+
25
+ $myBlock->setTemplate($template);
26
+ $myHtml .= $myBlock->toHtml(); //also consider $myBlock->renderView();
27
+
28
+ if (strpos($template, 'smartrecs/recs/') !== 0) {
29
+ // is not a peerius template!
30
+
31
+ // do some stuff to add the proper click event to existing templates
32
+ $title = $this->getRequest()->getParam('title') ?: $this->__('Recommended Products');
33
+ $myHtml = str_replace($this->__('Related Products'), $title, $myHtml);
34
+ if ($this->getRequest()->getParam('recs')) {
35
+ $recs = json_decode($this->getRequest()->getParam('recs'));
36
+ $num = count($recs);
37
+ $skuArr = array();
38
+ for ($i = 0; $i < $num; $i++) {
39
+ $skuArr[] = $recs[$i]->refCode;
40
+ $idArr[] = $recs[$i]->id;
41
+ $sku2id[$recs[$i]->refCode] = $recs[$i]->id;
42
+ }
43
+ }
44
+
45
+ $myHtml .= $myBlock->toHtml(); //also consider $myBlock->renderView();
46
+
47
+ // replace the title
48
+ $myHtml = str_replace($this->__('Related Products'), $title, $myHtml);
49
+
50
+
51
+ $search = '<a\s+(?:[^>]*?\s+)?href="([^"]*)"';
52
+ $doc = new DOMDocument();
53
+ $doc->loadHTML($myHtml);
54
+ $xpath = new DOMXPath($doc);
55
+ $nodeList = $xpath->query('//a');
56
+ for ($i = 0; $i < $nodeList->length; $i++) {
57
+ foreach ($sku2id as $sku => $id) {
58
+ if (strpos($nodeList->item($i)->getAttribute('href'), strtolower($sku)) !== false) {
59
+ $nodeList->item($i)->setAttribute('onClick', 'smartRecsClick('.$id.')');
60
+ }
61
+ }
62
+ }
63
+ $myHtml .= $doc->saveXml();
64
+
65
+ }
66
+
67
+ $this->getResponse()
68
+ ->setHeader('Content-Type', 'text/html')
69
+ ->setBody($myHtml);
70
+ }
71
+
72
+ /*
73
+ * reset the heights of all widgets
74
+ */
75
+ public function resetHeightAction() {
76
+ Mage::getModel('core/config')->saveConfig('peerius/general/widgetheight', '');
77
+ $this->getResponse()
78
+ ->setHeader('Content-Type', 'text/html')
79
+ ->setBody('done');
80
+ }
81
+
82
+ }
app/code/community/Peerius/Smartrecs/etc/adminhtml.xml ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <menu>
4
+ <smartrecs translate="title">
5
+ <title>Peerius</title>
6
+ <sort_order>500</sort_order>
7
+ <action>adminhtml/peerius/config</action>
8
+ </smartrecs>
9
+ </menu>
10
+ <acl>
11
+ <resources>
12
+ <admin>
13
+ <children>
14
+ <system>
15
+ <children>
16
+ <config>
17
+ <children>
18
+ <peerius>
19
+ <title>SMART-recs</title> <!-- Used in resources tree -->
20
+ </peerius>
21
+ </children>
22
+ </config>
23
+ </children>
24
+ </system>
25
+ </children>
26
+ </admin>
27
+ </resources>
28
+ </acl>
29
+ </config>
app/code/community/Peerius/Smartrecs/etc/config.xml ADDED
@@ -0,0 +1,97 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Peerius_Smartrecs>
5
+ <version>1.0.2</version>
6
+ </Peerius_Smartrecs>
7
+ </modules>
8
+ <frontend>
9
+ <routers>
10
+ <peerius_smartrecs>
11
+ <use>standard</use>
12
+ <args>
13
+ <module>Peerius_Smartrecs</module>
14
+ <frontName>peerius</frontName>
15
+ </args>
16
+ </peerius_smartrecs>
17
+ </routers>
18
+ <layout>
19
+ <updates>
20
+ <peerius_smartrecs>
21
+ <file>smartrecs.xml</file>
22
+ </peerius_smartrecs>
23
+ </updates>
24
+ </layout>
25
+ </frontend>
26
+ <global>
27
+ <models>
28
+ <peerius_smartrecs>
29
+ <class>Peerius_Smartrecs_Model</class>
30
+ </peerius_smartrecs>
31
+ <catalogsearch>
32
+ <rewrite>
33
+ <layer>Peerius_Smartrecs_Model_SearchLayer</layer>
34
+ </rewrite>
35
+ </catalogsearch>
36
+ </models>
37
+ <blocks>
38
+ <smartrecs>
39
+ <class>Peerius_Smartrecs_Block</class>
40
+ </smartrecs>
41
+ </blocks>
42
+ <helpers>
43
+ <peerius_smartrecs>
44
+ <class>Peerius_Smartrecs_Helper</class>
45
+ </peerius_smartrecs>
46
+ </helpers>
47
+ </global>
48
+ <adminhtml>
49
+ <layout>
50
+ <updates>
51
+ <peerius_smartrecs>
52
+ <file>smartrecs.xml</file>
53
+ </peerius_smartrecs>
54
+ </updates>
55
+ </layout>
56
+ </adminhtml>
57
+ <admin>
58
+ <routers>
59
+ <adminhtml>
60
+ <args>
61
+ <modules>
62
+ <peerius_smartrecs after="Mage_Adminhtml">Peerius_Smartrecs_Adminhtml</peerius_smartrecs>
63
+ </modules>
64
+ </args>
65
+ </adminhtml>
66
+ </routers>
67
+ </admin>
68
+ <default>
69
+ <peerius>
70
+ <general>
71
+ <client_name></client_name>
72
+ <cronjob>4</cronjob>
73
+ <testmode>1</testmode>
74
+ <registrationstatus>0</registrationstatus>
75
+ <registrationerror>0</registrationerror>
76
+ </general>
77
+ <home>
78
+ <max>3</max>
79
+ </home>
80
+ <category>
81
+ <max>3</max>
82
+ </category>
83
+ <product>
84
+ <max>3</max>
85
+ </product>
86
+ <product2>
87
+ <max>3</max>
88
+ </product2>
89
+ <search>
90
+ <max>3</max>
91
+ </search>
92
+ <basket>
93
+ <max>3</max>
94
+ </basket>
95
+ </peerius>
96
+ </default>
97
+ </config>
app/code/community/Peerius/Smartrecs/etc/system.xml ADDED
@@ -0,0 +1,653 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <tabs>
4
+ <peerius translate="label">
5
+ <label>Peerius</label>
6
+ <sort_order>15</sort_order>
7
+ </peerius>
8
+ </tabs>
9
+ <sections>
10
+ <peerius translate="Peerius" module="adminhtml">
11
+ <label>SMART-recs</label>
12
+ <tab>peerius</tab>
13
+ <sort_order>10</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
+ <general translate="General">
19
+ <label>General</label>
20
+ <sort_order>50</sort_order>
21
+ <show_in_default>1</show_in_default>
22
+ <show_in_website>1</show_in_website>
23
+ <show_in_store>1</show_in_store>
24
+ <fields>
25
+ <client_name translate="Client Name">
26
+ <label>Client Name</label>
27
+ <comment>The Peerius client name</comment>
28
+ <frontend_type>text</frontend_type>
29
+ <sort_order>10</sort_order>
30
+ <show_in_default>1</show_in_default>
31
+ <show_in_website>1</show_in_website>
32
+ <show_in_store>1</show_in_store>
33
+ </client_name>
34
+ <token translate="Client Token">
35
+ <backend_model>peerius_smartrecs/token</backend_model>
36
+ <label>Client Token</label>
37
+ <comment>The Peerius client token</comment>
38
+ <frontend_type>text</frontend_type>
39
+ <sort_order>20</sort_order>
40
+ <show_in_default>1</show_in_default>
41
+ <show_in_website>1</show_in_website>
42
+ <show_in_store>1</show_in_store>
43
+ </token>
44
+ <testmode translate="Test Mode">
45
+ <label>Test Mode</label>
46
+ <frontend_type>select</frontend_type>
47
+ <sort_order>30</sort_order>
48
+ <source_model>adminhtml/system_config_source_enabledisable</source_model>
49
+ <show_in_default>1</show_in_default>
50
+ <show_in_website>1</show_in_website>
51
+ <show_in_store>1</show_in_store>
52
+ <tooltip><![CDATA[Enable Test Mode if you would like to test recommendations from the IP address of the PC or laptop that you are currently logged on. If you would like to test from a different machine, please use the 'peeriuspreview' parameter as shown:, e.g. www.yourshop.com/?peeriuspreview.<br><br>Only Disable Test Mode if you are ready to go live with Peerius SMART-recs.]]></tooltip>
53
+ <comment>If Test Mode is enabled recommendations are only visible to you</comment>
54
+ </testmode>
55
+ <cronjob translate="Feed generation">
56
+ <label>Feed generation</label>
57
+ <tooltip>Specify the time when Peerius should create and import the feed</tooltip>
58
+ <frontend_type>select</frontend_type>
59
+ <source_model>peerius_smartrecs/system_config_source_dropdown_values</source_model>
60
+ <sort_order>40</sort_order>
61
+ <show_in_default>1</show_in_default>
62
+ <show_in_website>1</show_in_website>
63
+ <show_in_store>1</show_in_store>
64
+ </cronjob>
65
+ <widgetheight translate="Recommendation widget heights">
66
+ <label>Recommendation widget heights</label>
67
+ <comment>The heights of each individual recommendation widget</comment>
68
+ <frontend_type>text</frontend_type>
69
+ <depends>
70
+ <field_name>1</field_name>
71
+ </depends>
72
+ <sort_order>50</sort_order>
73
+ <show_in_default>1</show_in_default>
74
+ <show_in_website>1</show_in_website>
75
+ <show_in_store>1</show_in_store>
76
+ </widgetheight>
77
+ <registrationstatus translate="registrationstatus">
78
+ <frontend_type>text</frontend_type>
79
+ <sort_order>60</sort_order>
80
+ <depends>
81
+ <field_name>1</field_name>
82
+ </depends>
83
+ <show_in_default>1</show_in_default>
84
+ <show_in_website>1</show_in_website>
85
+ <show_in_store>1</show_in_store>
86
+ </registrationstatus>
87
+ <registrationerror translate="registrationerror">
88
+ <frontend_type>text</frontend_type>
89
+ <sort_order>60</sort_order>
90
+ <depends>
91
+ <field_name>1</field_name>
92
+ </depends>
93
+ <show_in_default>1</show_in_default>
94
+ <show_in_website>1</show_in_website>
95
+ <show_in_store>1</show_in_store>
96
+ </registrationerror>
97
+ <enableall translate="Disable All">
98
+ <label>Enable recommendations</label>
99
+ <frontend_type>select</frontend_type>
100
+ <source_model>adminhtml/system_config_source_yesno</source_model>
101
+ <sort_order>70</sort_order>
102
+ <show_in_default>1</show_in_default>
103
+ <show_in_website>1</show_in_website>
104
+ <show_in_store>1</show_in_store>
105
+ </enableall>
106
+ <adminip translate="adminip">
107
+ <frontend_type>text</frontend_type>
108
+ <depends>
109
+ <field_name>1</field_name>
110
+ </depends>
111
+ <sort_order>80</sort_order>
112
+ <show_in_default>1</show_in_default>
113
+ <show_in_website>1</show_in_website>
114
+ <show_in_store>1</show_in_store>
115
+ </adminip>
116
+ <creatingfeed translate="creatingfeed">
117
+ <frontend_type>text</frontend_type>
118
+ <sort_order>90</sort_order>
119
+ <depends>
120
+ <field_name>1</field_name>
121
+ </depends>
122
+ <show_in_default>1</show_in_default>
123
+ <show_in_website>1</show_in_website>
124
+ <show_in_store>1</show_in_store>
125
+ </creatingfeed>
126
+ </fields>
127
+ </general>
128
+ <home translate="Home">
129
+ <label>Home</label>
130
+ <sort_order>80</sort_order>
131
+ <show_in_default>1</show_in_default>
132
+ <show_in_website>1</show_in_website>
133
+ <show_in_store>1</show_in_store>
134
+ <fields>
135
+ <template>
136
+ <label>Template</label>
137
+ <frontend_type>select</frontend_type>
138
+ <sort_order>81</sort_order>
139
+ <show_in_default>1</show_in_default>
140
+ <show_in_website>1</show_in_website>
141
+ <show_in_store>1</show_in_store>
142
+ <source_model>peerius_smartrecs/templates_home</source_model>
143
+ <tooltip>Edit template files in /frontend/base/default/template/smartrecs/recs/</tooltip>
144
+ <depends>
145
+ <disable>0</disable>
146
+ </depends>
147
+ </template>
148
+ <headline translate="Headline">
149
+ <label>Title</label>
150
+ <frontend_type>text</frontend_type>
151
+ <sort_order>82</sort_order>
152
+ <show_in_default>1</show_in_default>
153
+ <show_in_website>1</show_in_website>
154
+ <show_in_store>1</show_in_store>
155
+ <tooltip>This will be used as the title of your widget</tooltip>
156
+ <depends>
157
+ <disable>0</disable>
158
+ </depends>
159
+ </headline>
160
+ <max translate="Max number of products">
161
+ <label>Number of products</label>
162
+ <frontend_type>select</frontend_type>
163
+ <sort_order>83</sort_order>
164
+ <show_in_default>1</show_in_default>
165
+ <show_in_website>1</show_in_website>
166
+ <show_in_store>1</show_in_store>
167
+ <source_model>peerius_smartrecs/max</source_model>
168
+ <tooltip>Number of products that should be displayed</tooltip>
169
+ <depends>
170
+ <disable>0</disable>
171
+ </depends>
172
+ </max>
173
+ <disable translate="Enable recommendations">
174
+ <label>Enable recommendations</label>
175
+ <frontend_type>select</frontend_type>
176
+ <source_model>peerius_smartrecs/system_config_source_yesno</source_model>
177
+ <sort_order>84</sort_order>
178
+ <show_in_default>1</show_in_default>
179
+ <show_in_website>1</show_in_website>
180
+ <show_in_store>1</show_in_store>
181
+ </disable>
182
+ </fields>
183
+ </home>
184
+ <category translate="Category">
185
+ <label>Category</label>
186
+ <sort_order>90</sort_order>
187
+ <show_in_default>1</show_in_default>
188
+ <show_in_website>1</show_in_website>
189
+ <show_in_store>1</show_in_store>
190
+ <fields>
191
+ <template>
192
+ <label>Template</label>
193
+ <frontend_type>select</frontend_type>
194
+ <sort_order>91</sort_order>
195
+ <show_in_default>1</show_in_default>
196
+ <show_in_website>1</show_in_website>
197
+ <show_in_store>1</show_in_store>
198
+ <source_model>peerius_smartrecs/templates_category</source_model>
199
+ <tooltip>Edit template files in /frontend/base/default/template/smartrecs/recs/</tooltip>
200
+ <depends>
201
+ <disable>0</disable>
202
+ </depends>
203
+ </template>
204
+ <headline translate="Headline">
205
+ <label>Title</label>
206
+ <frontend_type>text</frontend_type>
207
+ <sort_order>92</sort_order>
208
+ <show_in_default>1</show_in_default>
209
+ <show_in_website>1</show_in_website>
210
+ <show_in_store>1</show_in_store>
211
+ <tooltip>This will be used as the title of your widget</tooltip>
212
+ <depends>
213
+ <disable>0</disable>
214
+ </depends>
215
+ </headline>
216
+ <max translate="Number of products">
217
+ <label>Number of products</label>
218
+ <frontend_type>select</frontend_type>
219
+ <sort_order>93</sort_order>
220
+ <show_in_default>1</show_in_default>
221
+ <show_in_website>1</show_in_website>
222
+ <show_in_store>1</show_in_store>
223
+ <source_model>peerius_smartrecs/max</source_model>
224
+ <tooltip>Number of products that should be displayed</tooltip>
225
+ <depends>
226
+ <disable>0</disable>
227
+ </depends>
228
+ </max>
229
+ <disable translate="Enable recommendations">
230
+ <label>Enable recommendations</label>
231
+ <frontend_type>select</frontend_type>
232
+ <source_model>peerius_smartrecs/system_config_source_yesno</source_model>
233
+ <sort_order>94</sort_order>
234
+ <show_in_default>1</show_in_default>
235
+ <show_in_website>1</show_in_website>
236
+ <show_in_store>1</show_in_store>
237
+ </disable>
238
+ </fields>
239
+ </category>
240
+ <product>
241
+ <label>Product Widget 1</label>
242
+ <sort_order>101</sort_order>
243
+ <show_in_default>1</show_in_default>
244
+ <show_in_website>1</show_in_website>
245
+ <show_in_store>1</show_in_store>
246
+ <!--<comment><![CDATA[<a href="/index.php/?peeriuspreview" target="_blank"><em>Preview</em></a>]]></comment>-->
247
+ <fields>
248
+ <template>
249
+ <label>Template</label>
250
+ <frontend_type>select</frontend_type>
251
+ <sort_order>102</sort_order>
252
+ <show_in_default>1</show_in_default>
253
+ <show_in_website>1</show_in_website>
254
+ <show_in_store>1</show_in_store>
255
+ <source_model>peerius_smartrecs/templates_product1</source_model>
256
+ <tooltip>Edit template files in /frontend/base/default/template/smartrecs/recs/</tooltip>
257
+ <depends>
258
+ <disable>0</disable>
259
+ </depends>
260
+ </template>
261
+ <headline translate="Headline">
262
+ <label>Title</label>
263
+ <frontend_type>text</frontend_type>
264
+ <sort_order>103</sort_order>
265
+ <show_in_default>1</show_in_default>
266
+ <show_in_website>1</show_in_website>
267
+ <show_in_store>1</show_in_store>
268
+ <tooltip>This will be used as the title of your widget</tooltip>
269
+ <depends>
270
+ <disable>0</disable>
271
+ </depends>
272
+ </headline>
273
+ <max translate="Number of products">
274
+ <label>Number of products</label>
275
+ <frontend_type>select</frontend_type>
276
+ <sort_order>104</sort_order>
277
+ <show_in_default>1</show_in_default>
278
+ <show_in_website>1</show_in_website>
279
+ <show_in_store>1</show_in_store>
280
+ <source_model>peerius_smartrecs/max</source_model>
281
+ <tooltip>Number of products that should be displayed</tooltip>
282
+ <depends>
283
+ <disable>0</disable>
284
+ </depends>
285
+ </max>
286
+ <disable translate="Enable recommendations">
287
+ <label>Enable recommendations</label>
288
+ <frontend_type>select</frontend_type>
289
+ <source_model>peerius_smartrecs/system_config_source_yesno</source_model>
290
+ <sort_order>105</sort_order>
291
+ <show_in_default>1</show_in_default>
292
+ <show_in_website>1</show_in_website>
293
+ <show_in_store>1</show_in_store>
294
+ </disable>
295
+ </fields>
296
+ </product>
297
+ <product2>
298
+ <label>Product Widget 2</label>
299
+ <sort_order>110</sort_order>
300
+ <show_in_default>1</show_in_default>
301
+ <show_in_website>1</show_in_website>
302
+ <show_in_store>1</show_in_store>
303
+ <!--<comment><![CDATA[<a href="/index.php/?peeriuspreview" target="_blank"><em>Preview</em></a>]]></comment>-->
304
+ <fields>
305
+ <template>
306
+ <label>Template</label>
307
+ <frontend_type>select</frontend_type>
308
+ <sort_order>113</sort_order>
309
+ <show_in_default>1</show_in_default>
310
+ <show_in_website>1</show_in_website>
311
+ <show_in_store>1</show_in_store>
312
+ <source_model>peerius_smartrecs/templates_product2</source_model>
313
+ <tooltip>Edit template files in /frontend/base/default/template/smartrecs/recs/</tooltip>
314
+ <depends>
315
+ <disable>0</disable>
316
+ </depends>
317
+ </template>
318
+ <headline translate="Headline">
319
+ <label>Title</label>
320
+ <frontend_type>text</frontend_type>
321
+ <sort_order>114</sort_order>
322
+ <show_in_default>1</show_in_default>
323
+ <show_in_website>1</show_in_website>
324
+ <show_in_store>1</show_in_store>
325
+ <tooltip>This will be used as the title of your widget</tooltip>
326
+ <depends>
327
+ <disable>0</disable>
328
+ </depends>
329
+ </headline>
330
+ <max translate="Number of products">
331
+ <label>Number of products</label>
332
+ <frontend_type>select</frontend_type>
333
+ <sort_order>115</sort_order>
334
+ <show_in_default>1</show_in_default>
335
+ <show_in_website>1</show_in_website>
336
+ <show_in_store>1</show_in_store>
337
+ <source_model>peerius_smartrecs/max</source_model>
338
+ <tooltip>Number of products that should be displayed</tooltip>
339
+ <depends>
340
+ <disable>0</disable>
341
+ </depends>
342
+ </max>
343
+ <disable translate="Enable recommendations">
344
+ <label>Enable recommendations</label>
345
+ <frontend_type>select</frontend_type>
346
+ <source_model>peerius_smartrecs/system_config_source_yesno</source_model>
347
+ <sort_order>116</sort_order>
348
+ <show_in_default>1</show_in_default>
349
+ <show_in_website>1</show_in_website>
350
+ <show_in_store>1</show_in_store>
351
+ </disable>
352
+ </fields>
353
+ </product2>
354
+ <!--<wishlist>
355
+ <label>Wishlist</label>
356
+ <sort_order>110</sort_order>
357
+ <show_in_default>1</show_in_default>
358
+ <show_in_website>1</show_in_website>
359
+ <show_in_store>1</show_in_store>
360
+ <fields>
361
+ <template>
362
+ <label>Template</label>
363
+ <frontend_type>select</frontend_type>
364
+ <sort_order>111</sort_order>
365
+ <show_in_default>1</show_in_default>
366
+ <show_in_website>1</show_in_website>
367
+ <show_in_store>1</show_in_store>
368
+ <source_model>peerius_smartrecs/templates_wishlist</source_model>
369
+ <tooltip>Edit template files in /frontend/base/default/template/smartrecs/recs/</tooltip>
370
+ <depends>
371
+ <disable>0</disable>
372
+ </depends>
373
+ </template>
374
+ <headline translate="Headline">
375
+ <label>Title</label>
376
+ <frontend_type>text</frontend_type>
377
+ <sort_order>112</sort_order>
378
+ <show_in_default>1</show_in_default>
379
+ <show_in_website>1</show_in_website>
380
+ <show_in_store>1</show_in_store>
381
+ <depends>
382
+ <disable>0</disable>
383
+ </depends>
384
+ </headline>
385
+ <disable translate="Enable recommendations">
386
+ <label>Enable recommendations</label>
387
+ <frontend_type>select</frontend_type>
388
+ <source_model>peerius_smartrecs/system_config_source_yesno</source_model>
389
+ <sort_order>113</sort_order>
390
+ <show_in_default>1</show_in_default>
391
+ <show_in_website>1</show_in_website>
392
+ <show_in_store>1</show_in_store>
393
+ <depends>
394
+ <disable>0</disable>
395
+ </depends>
396
+ </disable>
397
+ </fields>
398
+ </wishlist>-->
399
+ <search>
400
+ <label>Search</label>
401
+ <sort_order>120</sort_order>
402
+ <show_in_default>1</show_in_default>
403
+ <show_in_website>1</show_in_website>
404
+ <show_in_store>1</show_in_store>
405
+ <fields>
406
+ <template>
407
+ <label>Template</label>
408
+ <frontend_type>select</frontend_type>
409
+ <sort_order>121</sort_order>
410
+ <show_in_default>1</show_in_default>
411
+ <show_in_website>1</show_in_website>
412
+ <show_in_store>1</show_in_store>
413
+ <source_model>peerius_smartrecs/templates_search</source_model>
414
+ <tooltip>Edit template files in /frontend/base/default/template/smartrecs/recs/</tooltip>
415
+ <depends>
416
+ <disable>0</disable>
417
+ </depends>
418
+ </template>
419
+ <headline translate="Headline">
420
+ <label>Title</label>
421
+ <frontend_type>text</frontend_type>
422
+ <sort_order>122</sort_order>
423
+ <show_in_default>1</show_in_default>
424
+ <show_in_website>1</show_in_website>
425
+ <show_in_store>1</show_in_store>
426
+ <tooltip>This will be used as title of your widget</tooltip>
427
+ <depends>
428
+ <disable>0</disable>
429
+ </depends>
430
+ </headline>
431
+ <max translate="Number of products">
432
+ <label>Number of products</label>
433
+ <frontend_type>select</frontend_type>
434
+ <sort_order>123</sort_order>
435
+ <show_in_default>1</show_in_default>
436
+ <show_in_website>1</show_in_website>
437
+ <show_in_store>1</show_in_store>
438
+ <source_model>peerius_smartrecs/max</source_model>
439
+ <tooltip>Number of products that should be displayed</tooltip>
440
+ <depends>
441
+ <disable>0</disable>
442
+ </depends>
443
+ </max>
444
+ <success translate="Show for successful search results">
445
+ <label>Show for successful search results</label>
446
+ <frontend_type>select</frontend_type>
447
+ <source_model>adminhtml/system_config_source_yesno</source_model>
448
+ <sort_order>124</sort_order>
449
+ <show_in_default>1</show_in_default>
450
+ <show_in_website>1</show_in_website>
451
+ <show_in_store>1</show_in_store>
452
+ <tooltip>If this is set to "Yes", the search widget will be displayed on the search page. Default is "No", which displays the search widget only if the search results are empty</tooltip>
453
+ <depends>
454
+ <disable>0</disable>
455
+ </depends>
456
+ </success>
457
+ <disable translate="Enable recommendations">
458
+ <label>Enable recommendations</label>
459
+ <frontend_type>select</frontend_type>
460
+ <source_model>peerius_smartrecs/system_config_source_yesno</source_model>
461
+ <sort_order>125</sort_order>
462
+ <show_in_default>1</show_in_default>
463
+ <show_in_website>1</show_in_website>
464
+ <show_in_store>1</show_in_store>
465
+ </disable>
466
+ </fields>
467
+ </search>
468
+ <!--<checkout>
469
+ <label>Checkout</label>
470
+ <sort_order>130</sort_order>
471
+ <show_in_default>1</show_in_default>
472
+ <show_in_website>1</show_in_website>
473
+ <show_in_store>1</show_in_store>
474
+ <fields>
475
+ <template>
476
+ <label>Template</label>
477
+ <frontend_type>select</frontend_type>
478
+ <sort_order>131</sort_order>
479
+ <show_in_default>1</show_in_default>
480
+ <show_in_website>1</show_in_website>
481
+ <show_in_store>1</show_in_store>
482
+ <source_model>peerius_smartrecs/templates_checkout</source_model>
483
+ <tooltip>Edit template files in /frontend/base/default/template/smartrecs/recs/</tooltip>
484
+ <depends>
485
+ <disable>0</disable>
486
+ </depends>
487
+ </template>
488
+ <headline translate="Headline">
489
+ <label>Title</label>
490
+ <frontend_type>text</frontend_type>
491
+ <sort_order>132</sort_order>
492
+ <show_in_default>1</show_in_default>
493
+ <show_in_website>1</show_in_website>
494
+ <show_in_store>1</show_in_store>
495
+ <depends>
496
+ <disable>0</disable>
497
+ </depends>
498
+ </headline>
499
+ <disable translate="Enable recommendations">
500
+ <label>Enable recommendations</label>
501
+ <frontend_type>select</frontend_type>
502
+ <source_model>peerius_smartrecs/system_config_source_yesno</source_model>
503
+ <sort_order>133</sort_order>
504
+ <show_in_default>1</show_in_default>
505
+ <show_in_website>1</show_in_website>
506
+ <show_in_store>1</show_in_store>
507
+ </disable>
508
+ </fields>
509
+ </checkout>-->
510
+ <basket>
511
+ <label>Basket</label>
512
+ <sort_order>140</sort_order>
513
+ <show_in_default>1</show_in_default>
514
+ <show_in_website>1</show_in_website>
515
+ <show_in_store>1</show_in_store>
516
+ <fields>
517
+ <template>
518
+ <label>Template</label>
519
+ <frontend_type>select</frontend_type>
520
+ <sort_order>141</sort_order>
521
+ <show_in_default>1</show_in_default>
522
+ <show_in_website>1</show_in_website>
523
+ <show_in_store>1</show_in_store>
524
+ <source_model>peerius_smartrecs/templates_basket</source_model>
525
+ <tooltip>Edit template files in /frontend/base/default/template/smartrecs/recs/</tooltip>
526
+ <depends>
527
+ <disable>0</disable>
528
+ </depends>
529
+ </template>
530
+ <headline translate="Headline">
531
+ <label>Title</label>
532
+ <frontend_type>text</frontend_type>
533
+ <sort_order>142</sort_order>
534
+ <show_in_default>1</show_in_default>
535
+ <show_in_website>1</show_in_website>
536
+ <show_in_store>1</show_in_store>
537
+ <tooltip>This will be used as title of your widget</tooltip>
538
+ <depends>
539
+ <disable>0</disable>
540
+ </depends>
541
+ </headline>
542
+ <max translate="Number of products">
543
+ <label>Number of products</label>
544
+ <frontend_type>select</frontend_type>
545
+ <sort_order>143</sort_order>
546
+ <show_in_default>1</show_in_default>
547
+ <show_in_website>1</show_in_website>
548
+ <show_in_store>1</show_in_store>
549
+ <source_model>peerius_smartrecs/max</source_model>
550
+ <tooltip>Number of products that should be displayed</tooltip>
551
+ <depends>
552
+ <disable>0</disable>
553
+ </depends>
554
+ </max>
555
+ <disable translate="Enable recommendations">
556
+ <label>Enable recommendations</label>
557
+ <frontend_type>select</frontend_type>
558
+ <source_model>peerius_smartrecs/system_config_source_yesno</source_model>
559
+ <sort_order>144</sort_order>
560
+ <show_in_default>1</show_in_default>
561
+ <show_in_website>1</show_in_website>
562
+ <show_in_store>1</show_in_store>
563
+ </disable>
564
+ </fields>
565
+ </basket>
566
+ <!--<order>
567
+ <label>Order</label>
568
+ <sort_order>150</sort_order>
569
+ <show_in_default>1</show_in_default>
570
+ <show_in_website>1</show_in_website>
571
+ <show_in_store>1</show_in_store>
572
+ <fields>
573
+ <template>
574
+ <label>Template</label>
575
+ <frontend_type>select</frontend_type>
576
+ <sort_order>151</sort_order>
577
+ <show_in_default>1</show_in_default>
578
+ <show_in_website>1</show_in_website>
579
+ <show_in_store>1</show_in_store>
580
+ <source_model>peerius_smartrecs/templates_order</source_model>
581
+ <tooltip>Edit template files in /frontend/base/default/template/smartrecs/recs/</tooltip>
582
+ <depends>
583
+ <disable>0</disable>
584
+ </depends>
585
+ </template>
586
+ <headline translate="Headline">
587
+ <label>Title</label>
588
+ <frontend_type>text</frontend_type>
589
+ <sort_order>152</sort_order>
590
+ <show_in_default>1</show_in_default>
591
+ <show_in_website>1</show_in_website>
592
+ <show_in_store>1</show_in_store>
593
+ <depends>
594
+ <disable>0</disable>
595
+ </depends>
596
+ </headline>
597
+ <disable translate="Enable recommendations">
598
+ <label>Enable recommendations</label>
599
+ <frontend_type>select</frontend_type>
600
+ <source_model>peerius_smartrecs/system_config_source_yesno</source_model>
601
+ <sort_order>153</sort_order>
602
+ <show_in_default>1</show_in_default>
603
+ <show_in_website>1</show_in_website>
604
+ <show_in_store>1</show_in_store>
605
+ </disable>
606
+ </fields>
607
+ </order>-->
608
+ <!--<other>
609
+ <label>Other</label>
610
+ <sort_order>160</sort_order>
611
+ <show_in_default>1</show_in_default>
612
+ <show_in_website>1</show_in_website>
613
+ <show_in_store>1</show_in_store>
614
+ <fields>
615
+ <template>
616
+ <label>Template</label>
617
+ <frontend_type>select</frontend_type>
618
+ <sort_order>161</sort_order>
619
+ <show_in_default>1</show_in_default>
620
+ <show_in_website>1</show_in_website>
621
+ <show_in_store>1</show_in_store>
622
+ <source_model>peerius_smartrecs/templates_other</source_model>
623
+ <tooltip>Edit template files in /frontend/base/default/template/smartrecs/recs/</tooltip>
624
+ <depends>
625
+ <disable>0</disable>
626
+ </depends>
627
+ </template>
628
+ <headline translate="Headline">
629
+ <label>Title</label>
630
+ <frontend_type>text</frontend_type>
631
+ <sort_order>162</sort_order>
632
+ <show_in_default>1</show_in_default>
633
+ <show_in_website>1</show_in_website>
634
+ <show_in_store>1</show_in_store>
635
+ <depends>
636
+ <disable>0</disable>
637
+ </depends>
638
+ </headline>
639
+ <disable translate="Enable recommendations">
640
+ <label>Enable recommendations</label>
641
+ <frontend_type>select</frontend_type>
642
+ <source_model>peerius_smartrecs/system_config_source_yesno</source_model>
643
+ <sort_order>163</sort_order>
644
+ <show_in_default>1</show_in_default>
645
+ <show_in_website>1</show_in_website>
646
+ <show_in_store>1</show_in_store>
647
+ </disable>
648
+ </fields>
649
+ </other>-->
650
+ </groups>
651
+ </peerius>
652
+ </sections>
653
+ </config>
app/code/community/Peerius/Smartrecs/etc/system_ft.xml ADDED
@@ -0,0 +1,81 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <tabs>
4
+ <peerius translate="label">
5
+ <label>Peerius</label>
6
+ <sort_order>15</sort_order>
7
+ </peerius>
8
+ </tabs>
9
+ <sections>
10
+ <peerius translate="Peerius" module="adminhtml">
11
+ <label>SMART-recs</label>
12
+ <tab>peerius</tab>
13
+ <sort_order>10</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
+ <general translate="label comment">
19
+ <label>General</label>
20
+ <sort_order>50</sort_order>
21
+ <show_in_default>1</show_in_default>
22
+ <show_in_website>1</show_in_website>
23
+ <show_in_store>1</show_in_store>
24
+ <fields>
25
+ <client_name translate="Client Name">
26
+ <backend_model>peerius_smartrecs/token</backend_model>
27
+ <label>Client Name</label>
28
+ <comment>The Peerius client name</comment>
29
+ <frontend_type>text</frontend_type>
30
+ <sort_order>10</sort_order>
31
+ <show_in_default>1</show_in_default>
32
+ <show_in_website>1</show_in_website>
33
+ <show_in_store>1</show_in_store>
34
+ </client_name>
35
+ <token translate="Client Token">
36
+ <backend_model>peerius_smartrecs/token</backend_model>
37
+ <label>Client Token</label>
38
+ <comment>The Peerius client token</comment>
39
+ <frontend_type>text</frontend_type>
40
+ <sort_order>10</sort_order>
41
+ <show_in_default>1</show_in_default>
42
+ <show_in_website>1</show_in_website>
43
+ <show_in_store>1</show_in_store>
44
+ </token>
45
+ <testmode translate="Test Mode">
46
+ <label>Test Mode</label>
47
+ <frontend_type>select</frontend_type>
48
+ <sort_order>30</sort_order>
49
+ <source_model>adminhtml/system_config_source_enabledisable</source_model>
50
+ <show_in_default>1</show_in_default>
51
+ <show_in_website>1</show_in_website>
52
+ <show_in_store>1</show_in_store>
53
+ </testmode>
54
+ <cronjob translate="Feed generation">
55
+ <label>Feed generation</label>
56
+ <comment>Schedule the feed generation</comment>
57
+ <frontend_type>select</frontend_type>
58
+ <source_model>peerius_smartrecs/system_config_source_dropdown_values</source_model>
59
+ <sort_order>40</sort_order>
60
+ <show_in_default>1</show_in_default>
61
+ <show_in_website>1</show_in_website>
62
+ <show_in_store>1</show_in_store>
63
+ </cronjob>
64
+ <widgetheight translate="Recommendation widget heights">
65
+ <label>Recommendation widget heights</label>
66
+ <comment>The heights of each individual recommendation widget</comment>
67
+ <frontend_type>text</frontend_type>
68
+ <depends>
69
+ <field_name>1</field_name>
70
+ </depends>
71
+ <sort_order>50</sort_order>
72
+ <show_in_default>1</show_in_default>
73
+ <show_in_website>1</show_in_website>
74
+ <show_in_store>1</show_in_store>
75
+ </widgetheight>
76
+ </fields>
77
+ </general>
78
+ </groups>
79
+ </peerius>
80
+ </sections>
81
+ </config>
app/code/community/Peerius/Smartrecs/etc/widget.xml ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+
3
+
4
+ <widgets>
5
+ <smartrecs_recommendations type="smartrecs/recommendations">
6
+ <name>Peerius SMART-recs</name>
7
+ <description type="desc">List the Peerius recommendations</description>
8
+ <parameters>
9
+ <rectype>
10
+ <label>Peerius Widget ID</label>
11
+ <visible>1</visible>
12
+ <required>1</required>
13
+ <type>text</type>
14
+ <value>widgetinstance</value>
15
+ <!--<description>with only one widget per page "standard" is fine</description>-->
16
+ </rectype>
17
+ <wtemplate>
18
+ <label>Template</label>
19
+ <visible>1</visible>
20
+ <required>1</required>
21
+ <type>select</type>
22
+ <default>horizontal.phtml</default>
23
+ <source_model>peerius_smartrecs/templates</source_model>
24
+ <description>folder: /frontend/base/default/template/smartrecs/recs/</description>
25
+ </wtemplate>
26
+ <headline>
27
+ <label>Headline</label>
28
+ <visible>1</visible>
29
+ <type>text</type>
30
+ <default></default>
31
+ </headline>
32
+ <max>
33
+ <label>Number of products</label>
34
+ <visible>1</visible>
35
+ <type>text</type>
36
+ <default>3</default>
37
+ </max>
38
+ </parameters>
39
+ </smartrecs_recommendations>
40
+ </widgets>
app/design/adminhtml/default/default/layout/smartrecs.xml ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <adminhtml_system_config_edit>
4
+ <!--Set active menu item-->
5
+ <reference name="menu">
6
+ <action method="setActive">
7
+ <menupath>nosto/index</menupath>
8
+ </action>
9
+ </reference>
10
+ <!-- Page content -->
11
+ <reference name="content">
12
+ <block type="smartrecs/config" name="peerius.config" template="smartrecs/config.phtml">
13
+ </block>
14
+ </reference>
15
+ </adminhtml_system_config_edit>
16
+ <adminhtml_noroute>
17
+ <reference name="content">
18
+ <block type="adminhtml/template" name="content.aclReload" after="content.noRoute" template="smartrecs/aclreloadbutton.phtml" />
19
+ </reference>
20
+ </adminhtml_noroute>
21
+ </config>
app/design/adminhtml/default/default/template/smartrecs/aclreloadbutton.phtml ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * to reload acl after 404 error message
5
+ * @category Peerius
6
+ * @package Peerius_Smartrecs
7
+ * @author Peerius Ltd
8
+ */
9
+
10
+ ?>
11
+
12
+ <!-- Peerius SMART-recs acl reload button -->
13
+
14
+ <?php
15
+ Mage::register('peerius_404', 1);
16
+ ?>
17
+
18
+ <a href="<?php echo $this->getUrl('adminhtml/peerius/aclreload'); ?>">
19
+ <?php echo $this->__('Reload ACL'); ?>
20
+ </a>
21
+
22
+
23
+
24
+
app/design/adminhtml/default/default/template/smartrecs/config.phtml ADDED
@@ -0,0 +1,101 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * for the rendering
4
+ * @category Peerius
5
+ * @package Peerius_Smartrecs
6
+ * @author Peerius Ltd
7
+ */
8
+ ?>
9
+ <!-- Peerius SMART-recs config -->
10
+ <script>
11
+ if (document.getElementById("nav")) // don't even try if an element with id nav doesn't exist
12
+ {
13
+ var peeriusMenuElem = document.getElementById("nav").lastElementChild; //last element should be the Peerius menu element
14
+ var menuItems = document.getElementById("nav").children;
15
+ for (var i = 0; i < menuItems.length; i++) // loop through all the menu elements until you find one that has a class "active"
16
+ {
17
+ if (menuItems.item(i).className.indexOf("active"))
18
+ menuItems.item(i).className = menuItems.item(i).className.replace(/\bactive\b/, ''); //remove highlight from System menu element
19
+ }
20
+ peeriusMenuElem.className += " active"; //highlight Peerius menu element
21
+ }
22
+
23
+ function togglePeeriusSections(show) {
24
+ var sections = $$('.section-config');
25
+ var sectionCnt = sections.length;
26
+ if (!show)
27
+ {
28
+ for (i = 1; i < sectionCnt; i++) {
29
+ sections[i].hide();
30
+ }
31
+ }
32
+ else
33
+ {
34
+ for (i = 1; i < sectionCnt; i++) {
35
+ sections[i].show();
36
+ }
37
+ }
38
+ }
39
+
40
+ document.observe('dom:loaded', function() {
41
+ var enAllSelect = document.getElementById("peerius_general_enableall");
42
+ var areRecsEnabled = enAllSelect.options[enAllSelect.selectedIndex].value == 1 ? true : false;
43
+ togglePeeriusSections(areRecsEnabled);
44
+ enAllSelect.addEventListener("change", enableDisable);
45
+ function enableDisable(e) {
46
+ var areRecsEnabled = enAllSelect.options[enAllSelect.selectedIndex].value == 1 ? true : false;
47
+ togglePeeriusSections(areRecsEnabled);
48
+ }
49
+ });
50
+ </script>
51
+
52
+ <?php
53
+ if (!Mage::registry('peerius_404')) {
54
+ $skinUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_SKIN, Mage::app()->getFrontController()->getRequest()->isSecure()) . "/adminhtml/default/default/";
55
+ ?>
56
+ <link rel="stylesheet" type="text/css"
57
+ href="<?php echo $skinUrl; ?>peerius/smartrecs/css/config.css"
58
+ media="all">
59
+
60
+ <div style="background: #e9eaeb none repeat scroll 0 0;box-shadow:0 0 50px 0 #fff inset">
61
+ <div class="navbar-inner"><a class="brand" style="float:left;margin:0;" href="https://www.peerius.com/">Peerius.com</a></div></div>
62
+ <br style="clear:both"><br><p>
63
+
64
+ <?php if (Mage::getStoreConfig('peerius/general/registrationstatus') < 1) { ?>
65
+ <script>
66
+ document.observe('dom:loaded', function() {
67
+ var header = $$('.content-header')[0];
68
+ header.hide();
69
+ var sections = $$('.section-config');
70
+ sections[0].hide();
71
+ });
72
+
73
+ </script>
74
+
75
+ <h2>Registration</h2>
76
+ <p>Please provide your email address and some details about your website to register this extension. Peerius will then send you further instruction on how to activate the extension, once your registration is successful.<br><br></p>
77
+ <div class="subscribe">
78
+ <form method="get" action="<?php echo Mage::helper("adminhtml")->getUrl("adminhtml/peerius/register") ?>"><input type="hidden" name="ip" value="<?php echo Mage::helper('core/http')->getRemoteAddr(true) ?>" /><p>
79
+ <input type="text" name="email" id="s2email" value="Enter email address..." size="255" onfocus="if (this.value == 'Enter email address...') {
80
+ this.value = '<?php echo Mage::getStoreConfig('trans_email/ident_general/email') ?>';
81
+ }" onblur="if (this.value == '') {
82
+ this.value = 'Enter email address...';
83
+ }" />
84
+ </p><p>
85
+ <!--<input type="text" name="company" id="company" value="Company name..." size="255" onfocus="if (this.value == 'Company name...') {this.value = '<?php echo Mage::getStoreConfig('general/store_information/name') ?>';}" onblur="if (this.value == '') {this.value = 'Company name...';}" /><br>-->
86
+
87
+ <input type="text" name="message" id="message" value="Tell us about your request..." size="255" onfocus="if (this.value == 'Tell us about your request...') {
88
+ this.value = '';
89
+ }" onblur="if (this.value == '') {
90
+ this.value = 'Tell us about your request...';
91
+ }" />
92
+
93
+ </p>
94
+
95
+ <p><input type="submit" name="register" value="Register" />
96
+
97
+ </p></form><br><br><br><br>
98
+ </div>
99
+ <?php } ?></p><br style="clear:both"><br><br>
100
+
101
+ <?php } ?>
app/design/frontend/base/default/layout/smartrecs.xml ADDED
@@ -0,0 +1,140 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+
3
+ <layout version="1.0.0">
4
+ <default><!--
5
+ <reference name="content">
6
+ <block type="smartrecs/recommendations" name="peerius.page.top" before="-"
7
+ template="smartrecs/render.phtml">
8
+ <action method="setData">
9
+ <name>div_id</name>
10
+ <value>peerius-smartrecs-top</value>
11
+ </action>
12
+ </block>
13
+ </reference>
14
+ <reference name="left">
15
+ <block type="smartrecs/recommendations" name="peerius.column.left" before="-"
16
+ template="smartrecs/render.phtml">
17
+ <action method="setData">
18
+ <name>div_id</name>
19
+ <value>peerius-smartrecs-left</value>
20
+ </action>
21
+ </block>
22
+ </reference>
23
+ <reference name="right">
24
+ <block type="smartrecs/recommendations" name="peerius.column.right" after=""
25
+ template="smartrecs/render.phtml">
26
+ <action method="setData">
27
+ <name>div_id</name>
28
+ <value>peerius-smartrecs-right</value>
29
+ </action>
30
+ </block>
31
+ </reference>-->
32
+ <reference name="before_body_end">
33
+ <!-- <action method="addJs">
34
+ <script>peerius/smartrecs/smartrecs.js</script>
35
+ </action>-->
36
+ <block type="smartrecs/tracking" name="smartrecs.tracking" template="smartrecs/smartrecs.phtml" />
37
+ <!-- disable again if necessary -->
38
+ <action method="unsetChild" ifconfig="peerius/general/disabled">
39
+ <name>smartrecs.tracking</name>
40
+ </action>
41
+ </reference>
42
+ <reference name="head">
43
+ <action method="addCss">
44
+ <stylesheet>css/peerius_smartrecs/style.css</stylesheet>
45
+ </action>
46
+ </reference>
47
+ </default>
48
+
49
+ <!-- Custom handle for displaying a content placeholder last in page content section -->
50
+ <!--<peerius_tagging_page_default_footer>
51
+ <reference name="content">
52
+ <block type="smartrecs/recommendations" name="peerius.page.footer" after="-"
53
+ template="smartrecs/render.phtml">
54
+ <action method="setData">
55
+ <name>div_id</name>
56
+ <value>peerius-smartrecs-footer</value>
57
+ </action>
58
+ </block>
59
+ </reference>
60
+ </peerius_tagging_page_default_footer>-->
61
+
62
+ <!-- Home page -->
63
+ <cms_index_index>
64
+ <!-- Add a content placeholders after the home page content -->
65
+ <reference name="content">
66
+ <block type="smartrecs/recommendations" name="peerius.page.home" after="-"
67
+ template="smartrecs/render.phtml">
68
+ <action method="setData">
69
+ <name>div_id</name>
70
+ <value>peerius-smartrecs-homewidget1</value>
71
+ </action>
72
+ </block>
73
+ </reference>
74
+ </cms_index_index>
75
+
76
+ <!-- Shopping cart checkout page -->
77
+ <checkout_cart_index>
78
+ <reference name="content">
79
+ <block type="smartrecs/recommendations" name="peerius.page.cart" after="checkout.cart"
80
+ template="smartrecs/render.phtml">
81
+ <action method="setData">
82
+ <name>div_id</name>
83
+ <value>peerius-smartrecs-basketwidget1</value>
84
+ </action>
85
+ </block>
86
+ </reference>
87
+ </checkout_cart_index>
88
+
89
+ <!-- Product page -->
90
+ <catalog_product_view>
91
+ <reference name="content">
92
+ <block type="smartrecs/recommendations" name="peerius.page.product" after="product.info"
93
+ template="smartrecs/render.phtml">
94
+ <action method="setData">
95
+ <name>div_id</name>
96
+ <value>peerius-smartrecs-productwidget1</value>
97
+ </action>
98
+ </block>
99
+ <block type="smartrecs/recommendations" name="peerius.page.product1" after="peerius.page.product1"
100
+ template="smartrecs/render.phtml">
101
+ <action method="setData">
102
+ <name>div_id</name>
103
+ <value>peerius-smartrecs-productwidget2</value>
104
+ </action>
105
+ </block>
106
+ </reference>
107
+ </catalog_product_view>
108
+
109
+ <!-- Category page -->
110
+ <catalog_category_default>
111
+ <update handle="peerius_tagging_catalog_category" />
112
+ </catalog_category_default>
113
+ <catalog_category_layered>
114
+ <update handle="peerius_tagging_catalog_category" />
115
+ </catalog_category_layered>
116
+ <peerius_tagging_catalog_category>
117
+ <reference name="content">
118
+ <block type="smartrecs/recommendations" name="peerius.page.category" before="category.products"
119
+ template="smartrecs/render.phtml">
120
+ <action method="setData">
121
+ <name>div_id</name>
122
+ <value>peerius-smartrecs-categorywidget1</value>
123
+ </action>
124
+ </block>
125
+ </reference>
126
+ </peerius_tagging_catalog_category>
127
+
128
+ <!-- Search result page -->
129
+ <catalogsearch_result_index>
130
+ <reference name="content">
131
+ <block type="smartrecs/recommendations" name="peerius.page.search" before="search.result"
132
+ template="smartrecs/render.phtml">
133
+ <action method="setData">
134
+ <name>div_id</name>
135
+ <value>peerius-smartrecs-searchwidget1</value>
136
+ </action>
137
+ </block>
138
+ </reference>
139
+ </catalogsearch_result_index>
140
+ </layout>
app/design/frontend/base/default/template/smartrecs/recs/basket.phtml ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ($this->getRequest()->getParam('recs')) {
4
+ $recs = json_decode($this->getRequest()->getParam('recs'));
5
+ $num = count($recs);
6
+ $idArr = array();
7
+ for ($i = 0; $i < $num; $i++) {
8
+ $refCodeArr[] = $recs[$i]->refCode;
9
+ $idArr[] = $recs[$i]->id;
10
+ $refCode2id[$recs[$i]->refCode] = $recs[$i]->id;
11
+ }
12
+ }
13
+
14
+ $title = $this->getRequest()->getParam('title') ?: $this->__('Recommended Products');
15
+ ?>
16
+ <?php if($this->getItems()->getSize()): ?>
17
+ <div class="block block-recommendations">
18
+ <div class="block-title">
19
+ <strong><span><?php echo $this->escapeHtml($title) ?></span></strong>
20
+ </div>
21
+ <div class="block-content">
22
+ <ul class="peerius-products-grid">
23
+ <?php foreach($this->getItems() as $_item): ?>
24
+ <li class="peerius-item">
25
+ <a onClick="Peerius.smartRecsClick(<?php echo $refCode2id[$_item->getSku()]?>)" href="<?php echo $_item->getProductUrl() ?>" title="<?php echo $this->escapeHtml($_item->getName()) ?>" class="peerius-product-image"><img src="<?php echo $this->helper('catalog/image')->init($_item, 'thumbnail')->resize(135) ?>" width="135" height="135" alt="<?php echo $this->escapeHtml($_item->getName()) ?>" /></a>
26
+ <h2 class="product-name"><p class="product-name"><a onClick="Peerius.smartRecsClick(<?php echo $refCode2id[$_item->getSku()]?>)" href="<?php echo $_item->getProductUrl() ?>"><?php echo $this->escapeHtml($_item->getName()) ?></a></h2>
27
+ <div class="product-details">
28
+ </p>
29
+ <?php echo $this->getPriceHtml($_item, true, '-recommendations') ?>
30
+ <!--<?php if ($this->helper('wishlist')->isAllow()) : ?>
31
+ <a onClick="Peerius.smartRecsClick(<?php echo $refCode2id[$_item->getSku()]?>)" href="<?php echo $this->getAddToWishlistUrl($_item) ?>" class="link-wishlist"><?php echo $this->__('Add to Wishlist') ?></a>-->
32
+ <?php endif; ?>
33
+ </div>
34
+ </li>
35
+ <?php endforeach ?>
36
+ </ul>
37
+ <script type="text/javascript">decorateList('block-recommendations', 'none-recursive')</script>
38
+ </div>
39
+ </div>
40
+ <?php endif ?>
app/design/frontend/base/default/template/smartrecs/recs/category.phtml ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ($this->getRequest()->getParam('recs')) {
4
+ $recs = json_decode($this->getRequest()->getParam('recs'));
5
+ $num = count($recs);
6
+ $idArr = array();
7
+ for ($i = 0; $i < $num; $i++) {
8
+ $refCodeArr[] = $recs[$i]->refCode;
9
+ $idArr[] = $recs[$i]->id;
10
+ $refCode2id[$recs[$i]->refCode] = $recs[$i]->id;
11
+ }
12
+ }
13
+
14
+ $title = $this->getRequest()->getParam('title') ?: $this->__('Recommended Products');
15
+ ?>
16
+ <?php if($this->getItems()->getSize()): ?>
17
+ <div class="block block-recommendations">
18
+ <div class="block-title">
19
+ <strong><span><?php echo $this->escapeHtml($title) ?></span></strong>
20
+ </div>
21
+ <div class="block-content">
22
+ <ul class="peerius-products-grid">
23
+ <?php foreach($this->getItems() as $_item): ?>
24
+ <li class="peerius-item">
25
+ <a onClick="Peerius.smartRecsClick(<?php echo $refCode2id[$_item->getSku()]?>)" href="<?php echo $_item->getProductUrl() ?>" title="<?php echo $this->escapeHtml($_item->getName()) ?>" class="peerius-product-image"><img src="<?php echo $this->helper('catalog/image')->init($_item, 'thumbnail')->resize(135) ?>" width="135" height="135" alt="<?php echo $this->escapeHtml($_item->getName()) ?>" /></a>
26
+ <h2 class="product-name"><p class="product-name"><a onClick="Peerius.smartRecsClick(<?php echo $refCode2id[$_item->getSku()]?>)" href="<?php echo $_item->getProductUrl() ?>"><?php echo $this->escapeHtml($_item->getName()) ?></a></h2>
27
+ <div class="product-details">
28
+ </p>
29
+ <?php echo $this->getPriceHtml($_item, true, '-recommendations') ?>
30
+ <!--<?php if ($this->helper('wishlist')->isAllow()) : ?>
31
+ <a onClick="Peerius.smartRecsClick(<?php echo $refCode2id[$_item->getSku()]?>)" href="<?php echo $this->getAddToWishlistUrl($_item) ?>" class="link-wishlist"><?php echo $this->__('Add to Wishlist') ?></a>-->
32
+ <?php endif; ?>
33
+ </div>
34
+ </li>
35
+ <?php endforeach ?>
36
+ </ul>
37
+ <script type="text/javascript">decorateList('block-recommendations', 'none-recursive')</script>
38
+ </div>
39
+ </div>
40
+ <?php endif ?>
app/design/frontend/base/default/template/smartrecs/recs/home.phtml ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ($this->getRequest()->getParam('recs')) {
4
+ $recs = json_decode($this->getRequest()->getParam('recs'));
5
+ $num = count($recs);
6
+ $idArr = array();
7
+ for ($i = 0; $i < $num; $i++) {
8
+ $refCodeArr[] = $recs[$i]->refCode;
9
+ $idArr[] = $recs[$i]->id;
10
+ $refCode2id[$recs[$i]->refCode] = $recs[$i]->id;
11
+ }
12
+ }
13
+
14
+ $title = $this->getRequest()->getParam('title') ?: $this->__('Recommended Products');
15
+ ?>
16
+ <?php if($this->getItems()->getSize()): ?>
17
+ <div class="block block-recommendations">
18
+ <div class="block-title">
19
+ <strong><span><?php echo $this->escapeHtml($title) ?></span></strong>
20
+ </div>
21
+ <div class="block-content">
22
+ <ul class="peerius-products-grid">
23
+ <?php foreach($this->getItems() as $_item): ?>
24
+ <li class="peerius-item">
25
+ <a onClick="Peerius.smartRecsClick(<?php echo $refCode2id[$_item->getSku()]?>)" href="<?php echo $_item->getProductUrl() ?>" title="<?php echo $this->escapeHtml($_item->getName()) ?>" class="peerius-product-image"><img src="<?php echo $this->helper('catalog/image')->init($_item, 'thumbnail')->resize(135) ?>" width="135" height="135" alt="<?php echo $this->escapeHtml($_item->getName()) ?>" /></a>
26
+ <h2 class="product-name"><p class="product-name"><a onClick="Peerius.smartRecsClick(<?php echo $refCode2id[$_item->getSku()]?>)" href="<?php echo $_item->getProductUrl() ?>"><?php echo $this->escapeHtml($_item->getName()) ?></a></h2>
27
+ <div class="product-details">
28
+ </p>
29
+ <?php echo $this->getPriceHtml($_item, true, '-recommendations') ?>
30
+ <!--<?php if ($this->helper('wishlist')->isAllow()) : ?>
31
+ <a onClick="Peerius.smartRecsClick(<?php echo $refCode2id[$_item->getSku()]?>)" href="<?php echo $this->getAddToWishlistUrl($_item) ?>" class="link-wishlist"><?php echo $this->__('Add to Wishlist') ?></a>-->
32
+ <?php endif; ?>
33
+ </div>
34
+ </li>
35
+ <?php endforeach ?>
36
+ </ul>
37
+ <script type="text/javascript">decorateList('block-recommendations', 'none-recursive')</script>
38
+ </div>
39
+ </div>
40
+ <?php endif ?>
app/design/frontend/base/default/template/smartrecs/recs/product-1.phtml ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ($this->getRequest()->getParam('recs')) {
4
+ $recs = json_decode($this->getRequest()->getParam('recs'));
5
+ $num = count($recs);
6
+ $idArr = array();
7
+ for ($i = 0; $i < $num; $i++) {
8
+ $refCodeArr[] = $recs[$i]->refCode;
9
+ $idArr[] = $recs[$i]->id;
10
+ $refCode2id[$recs[$i]->refCode] = $recs[$i]->id;
11
+ }
12
+ }
13
+
14
+ $title = $this->getRequest()->getParam('title') ?: $this->__('Recommended Products');
15
+ ?>
16
+ <?php if($this->getItems()->getSize()): ?>
17
+ <div class="block block-recommendations">
18
+ <div class="block-title">
19
+ <strong><span><?php echo $this->escapeHtml($title) ?></span></strong>
20
+ </div>
21
+ <div class="block-content">
22
+ <ul class="peerius-products-grid">
23
+ <?php foreach($this->getItems() as $_item): ?>
24
+ <li class="peerius-item">
25
+ <a onClick="Peerius.smartRecsClick(<?php echo $refCode2id[$_item->getSku()]?>)" href="<?php echo $_item->getProductUrl() ?>" title="<?php echo $this->escapeHtml($_item->getName()) ?>" class="peerius-product-image"><img src="<?php echo $this->helper('catalog/image')->init($_item, 'thumbnail')->resize(135) ?>" width="135" height="135" alt="<?php echo $this->escapeHtml($_item->getName()) ?>" /></a>
26
+ <h2 class="product-name"><p class="product-name"><a onClick="Peerius.smartRecsClick(<?php echo $refCode2id[$_item->getSku()]?>)" href="<?php echo $_item->getProductUrl() ?>"><?php echo $this->escapeHtml($_item->getName()) ?></a></h2>
27
+ <div class="product-details">
28
+ </p>
29
+ <?php echo $this->getPriceHtml($_item, true, '-recommendations') ?>
30
+ <!--<?php if ($this->helper('wishlist')->isAllow()) : ?>
31
+ <a onClick="Peerius.smartRecsClick(<?php echo $refCode2id[$_item->getSku()]?>)" href="<?php echo $this->getAddToWishlistUrl($_item) ?>" class="link-wishlist"><?php echo $this->__('Add to Wishlist') ?></a>-->
32
+ <?php endif; ?>
33
+ </div>
34
+ </li>
35
+ <?php endforeach ?>
36
+ </ul>
37
+ <script type="text/javascript">decorateList('block-recommendations', 'none-recursive')</script>
38
+ </div>
39
+ </div>
40
+ <?php endif ?>
app/design/frontend/base/default/template/smartrecs/recs/product-2.phtml ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ($this->getRequest()->getParam('recs')) {
4
+ $recs = json_decode($this->getRequest()->getParam('recs'));
5
+ $num = count($recs);
6
+ $idArr = array();
7
+ for ($i = 0; $i < $num; $i++) {
8
+ $refCodeArr[] = $recs[$i]->refCode;
9
+ $idArr[] = $recs[$i]->id;
10
+ $refCode2id[$recs[$i]->refCode] = $recs[$i]->id;
11
+ }
12
+ }
13
+
14
+ $title = $this->getRequest()->getParam('title') ?: $this->__('Recommended Products');
15
+ ?>
16
+ <?php if($this->getItems()->getSize()): ?>
17
+ <div class="block block-recommendations">
18
+ <div class="block-title">
19
+ <strong><span><?php echo $this->escapeHtml($title) ?></span></strong>
20
+ </div>
21
+ <div class="block-content">
22
+ <ul class="peerius-products-grid">
23
+ <?php foreach($this->getItems() as $_item): ?>
24
+ <li class="peerius-item">
25
+ <a onClick="Peerius.smartRecsClick(<?php echo $refCode2id[$_item->getSku()]?>)" href="<?php echo $_item->getProductUrl() ?>" title="<?php echo $this->escapeHtml($_item->getName()) ?>" class="peerius-product-image"><img src="<?php echo $this->helper('catalog/image')->init($_item, 'thumbnail')->resize(135) ?>" width="135" height="135" alt="<?php echo $this->escapeHtml($_item->getName()) ?>" /></a>
26
+ <h2 class="product-name"><p class="product-name"><a onClick="Peerius.smartRecsClick(<?php echo $refCode2id[$_item->getSku()]?>)" href="<?php echo $_item->getProductUrl() ?>"><?php echo $this->escapeHtml($_item->getName()) ?></a></h2>
27
+ <div class="product-details">
28
+ </p>
29
+ <?php echo $this->getPriceHtml($_item, true, '-recommendations') ?>
30
+ <!--<?php if ($this->helper('wishlist')->isAllow()) : ?>
31
+ <a onClick="Peerius.smartRecsClick(<?php echo $refCode2id[$_item->getSku()]?>)" href="<?php echo $this->getAddToWishlistUrl($_item) ?>" class="link-wishlist"><?php echo $this->__('Add to Wishlist') ?></a>-->
32
+ <?php endif; ?>
33
+ </div>
34
+ </li>
35
+ <?php endforeach ?>
36
+ </ul>
37
+ <script type="text/javascript">decorateList('block-recommendations', 'none-recursive')</script>
38
+ </div>
39
+ </div>
40
+ <?php endif ?>
app/design/frontend/base/default/template/smartrecs/recs/search.phtml ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ($this->getRequest()->getParam('recs')) {
4
+ $recs = json_decode($this->getRequest()->getParam('recs'));
5
+ $num = count($recs);
6
+ $idArr = array();
7
+ for ($i = 0; $i < $num; $i++) {
8
+ $refCodeArr[] = $recs[$i]->refCode;
9
+ $idArr[] = $recs[$i]->id;
10
+ $refCode2id[$recs[$i]->refCode] = $recs[$i]->id;
11
+ }
12
+ }
13
+
14
+ $title = $this->getRequest()->getParam('title') ?: $this->__('Recommended Products');
15
+ ?>
16
+ <?php if($this->getItems()->getSize()): ?>
17
+ <div class="block block-recommendations">
18
+ <div class="block-title">
19
+ <strong><span><?php echo $this->escapeHtml($title) ?></span></strong>
20
+ </div>
21
+ <div class="block-content">
22
+ <ul class="peerius-products-grid">
23
+ <?php foreach($this->getItems() as $_item): ?>
24
+ <li class="peerius-item">
25
+ <a onClick="Peerius.smartRecsClick(<?php echo $refCode2id[$_item->getSku()]?>)" href="<?php echo $_item->getProductUrl() ?>" title="<?php echo $this->escapeHtml($_item->getName()) ?>" class="peerius-product-image"><img src="<?php echo $this->helper('catalog/image')->init($_item, 'thumbnail')->resize(135) ?>" width="135" height="135" alt="<?php echo $this->escapeHtml($_item->getName()) ?>" /></a>
26
+ <h2 class="product-name"><p class="product-name"><a onClick="Peerius.smartRecsClick(<?php echo $refCode2id[$_item->getSku()]?>)" href="<?php echo $_item->getProductUrl() ?>"><?php echo $this->escapeHtml($_item->getName()) ?></a></h2>
27
+ <div class="product-details">
28
+ </p>
29
+ <?php echo $this->getPriceHtml($_item, true, '-recommendations') ?>
30
+ <!--<?php if ($this->helper('wishlist')->isAllow()) : ?>
31
+ <a onClick="Peerius.smartRecsClick(<?php echo $refCode2id[$_item->getSku()]?>)" href="<?php echo $this->getAddToWishlistUrl($_item) ?>" class="link-wishlist"><?php echo $this->__('Add to Wishlist') ?></a>-->
32
+ <?php endif; ?>
33
+ </div>
34
+ </li>
35
+ <?php endforeach ?>
36
+ </ul>
37
+ <script type="text/javascript">decorateList('block-recommendations', 'none-recursive')</script>
38
+ </div>
39
+ </div>
40
+ <?php endif ?>
app/design/frontend/base/default/template/smartrecs/render.phtml ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * for the rendering
5
+ * @category Peerius
6
+ * @package Peerius_Smartrecs
7
+ * @author Peerius Ltd
8
+ */
9
+
10
+ ?>
11
+ <!-- Peerius SMART-recs recommendations rendering -->
12
+
13
+
app/design/frontend/base/default/template/smartrecs/smartrecs.phtml ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * for the tracking and rendering
5
+ * @category Peerius
6
+ * @package Peerius_Smartrecs
7
+ * @author Peerius Ltd
8
+ */
9
+
10
+ ?>
11
+ <!-- Peerius SMART-recs tracking and rendering -->
12
+
13
+ <?php
14
+ $renderActive = (file_exists(dirname(__FILE__).'/render.phtml')) ? true:false;
15
+
16
+ if (Mage::helper('peerius_smartrecs')->isActive()) {
17
+ $trackingPixel = $this->getTrackingPixel();
18
+ if ($trackingPixel) {
19
+ ?>
20
+
21
+ <script type="text/JavaScript" src="/js/peerius/smartrecs/smartrecs.js"></script>
22
+ <script type="text/JavaScript">
23
+ var peeriusPage = '<?php echo $this->escapeHtml(Mage::helper('peerius_smartrecs')->getPageType());?>';
24
+ var peeriusDisabled = <?php echo Mage::helper('peerius_smartrecs')->getDisabled() ? 'true':'false';?>;
25
+ var renderRoute = '<?php echo $this->escapeHtml(Mage::getUrl('peerius/Render'))?>';
26
+
27
+ function parsePeeriusJson(jsonData) {
28
+ // render recommendations ...
29
+ <?php if ($renderActive):?>
30
+ if (!peeriusDisabled) {
31
+ jsonData.forEach(function (widget) {
32
+ if (null !== $('peerius-smartrecs-'+widget.position)) {
33
+ renderRec(widget);
34
+ } else {
35
+ console.debug('div peerius-smartrecs-'+widget.position + ' not found');
36
+ }
37
+ });
38
+ }
39
+ <?php endif;?>
40
+ }
41
+
42
+ var PeeriusCallbacks={
43
+ track:<?php echo $trackingPixel; ?>,
44
+ smartRecs:function(jsonData) {
45
+ parsePeeriusJson(jsonData);
46
+ }
47
+ }
48
+ </script>
49
+ <?php }} ?>
50
+
51
+ <?php
52
+ if (Mage::helper('peerius_smartrecs')->isActive()) {
53
+ echo $this->getTrackingTag();
54
+ }
55
+ ?>
app/etc/modules/Peerius_Smartrecs.xml ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Peerius_Smartrecs>
5
+ <active>true</active>
6
+ <codePool>community</codePool>
7
+ <depends>
8
+ <Mage_Widget />
9
+ </depends>
10
+ </Peerius_Smartrecs>
11
+ </modules>
12
+ </config>
js/peerius/smartrecs/smartrecs.js ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ function renderRec(widget) {
2
+ if (!peeriusDisabled) {
3
+ target = $('peerius-smartrecs-'+widget.position);
4
+ if (target !== null) {
5
+ targetContainer = $('peerius_smartrecs_container');
6
+ //target.hide();
7
+ var peeriusWidgetHeight = 0;
8
+ new Ajax.Updater(target, renderRoute, {
9
+ parameters: {
10
+ recs: JSON.stringify(widget.recs),
11
+ title: target.getAttribute('headline'),
12
+ template: target.getAttribute('template'),
13
+ max: target.getAttribute('max')
14
+ },
15
+ onSuccess: function(e) {
16
+ new Effect.Appear(target, {
17
+ afterFinishInternal: function(e) {
18
+ if (targetContainer != null) {
19
+ if (peeriusWidgetHeight !== targetContainer.getHeight()) {
20
+ storeWidgetHeight('peerius-smartrecs-'+widget.position, targetContainer.getHeight());
21
+ }
22
+ }
23
+ }
24
+ });
25
+ if (targetContainer != null) {
26
+ peeriusWidgetHeight = targetContainer.getHeight();
27
+ }
28
+ }
29
+ });
30
+ function storeWidgetHeight(id, height) {
31
+ new Ajax.Request('/index.php/peerius/Render/storeHeight', {
32
+ method: 'get',
33
+ parameters: {page: id, height: height}
34
+ });
35
+ }
36
+ }
37
+ }
38
+ }
39
+
package.xml ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>Peerius_Connect</name>
4
+ <version>1.0.4</version>
5
+ <stability>stable</stability>
6
+ <license uri="http://opensource.org/licenses/osl-3.0.php#sthash.1eAD3rgO.dpuf">OSL v3.0</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>The trusted partner for personalisation.</summary>
10
+ <description>The Peerius Connect extension allows you to add personalised product recommendations to your website. This extension performs the following key functions:&#xD;
11
+ &#xD;
12
+ Creates a feed containing product and category information from your site catalogue.&#xD;
13
+ Adds a tracking script that allows Peerius to track user behaviour on your site.&#xD;
14
+ Renders recommendations that you enable on pre-configured pages.&#xD;
15
+ </description>
16
+ <notes>Show search result recommendations only on empty search results if not set in config.</notes>
17
+ <authors><author><name>Peerius</name><user>Peerius</user><email>extensions@peerius.com</email></author></authors>
18
+ <date>2015-12-20</date>
19
+ <time>21:05:08</time>
20
+ <contents><target name="magecommunity"><dir name="Peerius"><dir name="Smartrecs"><dir name="Block"><file name="Config.php" hash="5d81508e9cf3061d6f34458bbdafff9b"/><file name="Recommendations.php" hash="cc8f955efbd6835d890b8efb864c0cac"/><file name="Template.php" hash="e9431386180c113cfa4660f8ce2c220b"/><file name="Tracking.php" hash="e096d0cfc453614464a6b82525bbd834"/></dir><dir name="Helper"><file name="Data.php" hash="07a1c36598d89c28a5c9f902707cb02e"/><file name="Feedhelper.php" hash="5c981f753a3f139dd0798855ec2e51f4"/></dir><dir name="Model"><dir name="Feed"><file name="Creator.php" hash="4e1f88e9a6ac56f4c5b16a61a6734808"/></dir><file name="Max.php" hash="a3c7eb408d59c3a0b71b9f5f8d85dfa9"/><file name="SearchLayer.php" hash="4457eb768fc387d08700d67b5e1bb55b"/><dir name="System"><dir name="Config"><dir name="Source"><dir name="Dropdown"><file name="Values.php" hash="bc71d86dcc6fdb046222c0a051b323b4"/></dir><file name="Yesno.php" hash="4f6cb1392c1496837cc6021cb263aad5"/></dir></dir></dir><dir name="Templates"><file name="Basket.php" hash="96eb28e5977acd90ee8bf38f4e938274"/><file name="Category.php" hash="7882da9cd0026ed5bde0360189d593ae"/><file name="Checkout.php" hash="d46564549391af35da90a4a10c9a8093"/><file name="Home.php" hash="44a09df724298154d2f8671572c7f5ea"/><file name="Order.php" hash="3525a61a41f63c4133549254c31c842a"/><file name="Other.php" hash="2cb2c3d3de6d3155b5e33f1f3f8ade00"/><file name="Product1.php" hash="b3f3f27b3b319290f4ce7238b12e77d7"/><file name="Product2.php" hash="65170140bc75324cb0e216a9ba4f2597"/><file name="Search.php" hash="aa1e063656bd5b93a6ea1764dd317bd0"/><file name="Wishlist.php" hash="49daf0c47250b9512d285340c53af644"/></dir><file name="Templates.php" hash="b44ee8b39cf9d2166307ae6eb1500dc8"/><file name="Token.php" hash="2361e10a26b9beb9f066d6ad4827261c"/><file name=".DS_Store" hash="121fcc7ffb2eda1059e7fd2cba768368"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="PeeriusController.php" hash="6d72ba380fa0ef6d618a97fc3124cdb7"/></dir><file name="FeedController.php" hash="7b21a1c6a9a8e27314d9b317f94a2e07"/><file name="InfoController.php" hash="915a4388f9cc72c917d6804ac38408c7"/><file name="RenderController.php" hash="e9f46140cb254a24ce9d21288ee9a250"/></dir><dir name="etc"><file name="adminhtml.xml" hash="468dbed05f1cb0be9a4062c85e388e04"/><file name="config.xml" hash="e64216f70b3a67775c93966b412ffb13"/><file name="system.xml" hash="580dfd7e143413dc71f2ffc5f5f1de63"/><file name="system_ft.xml" hash="a42d9bf6de1df48c246057a4ef3c3a71"/><file name="widget.xml" hash="2a2a7c7097a33bb761c97d21c4d373f7"/></dir><file name=".DS_Store" hash="c9ad824fadf49b3c7a9e0648d7cdac61"/></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Peerius_Smartrecs.xml" hash="e5c77ca4bb1474945191f4be23a0b390"/></dir></target><target name="mageweb"><dir name="js"><dir name="peerius"><dir name="smartrecs"><file name="smartrecs.js" hash="344e4abf974c5d834afbbd5ec22a6785"/></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="template"><dir name="smartrecs"><file name="smartrecs.phtml" hash="eb191cbebb3729fe54294db5981e5a21"/><file name="render.phtml" hash="b508a2f71675d7a37b942cc41d2c5692"/><file name="render.phtml" hash="b508a2f71675d7a37b942cc41d2c5692"/><dir name="recs"><file name="home.phtml" hash="9179ca699b638cc8fb6d9755b8f0ebe2"/><file name="category.phtml" hash="9179ca699b638cc8fb6d9755b8f0ebe2"/><file name="product-1.phtml" hash="9179ca699b638cc8fb6d9755b8f0ebe2"/><file name="product-2.phtml" hash="9179ca699b638cc8fb6d9755b8f0ebe2"/><file name="search.phtml" hash="9179ca699b638cc8fb6d9755b8f0ebe2"/><file name="basket.phtml" hash="9179ca699b638cc8fb6d9755b8f0ebe2"/></dir></dir></dir><dir name="layout"><file name="smartrecs.xml" hash="f52a4fba91d0a70e676ea2b92c7814ba"/></dir></dir></dir></dir><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="smartrecs.xml" hash="b18cea41c87596b4a391060772d62036"/></dir><dir name="template"><dir name="smartrecs"><file name="config.phtml" hash="e1592ad4495ef3e6b9061e348b35ed1d"/><file name="aclreloadbutton.phtml" hash="5a1baf33dff410aeef3de6811d3c8777"/></dir></dir></dir></dir></dir></target><target name="mageskin"><dir><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="peerius"><dir name="smartrecs"><dir><dir name="css"><file name="config.css" hash="bc6e8f257e82345829fa4ab40cd6e73a"/></dir><dir name="img"><file name="logo-rollover.png" hash="d47a12d82bc3b271f343f590f7de260a"/><file name="navigation.png" hash="02fb819ba8faf2b9df42345e6f71463c"/></dir><dir name="js"><file name="smartrecs.js" hash="e9fc66f04761d7c0de868f031b592e50"/></dir></dir></dir></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="css"><dir name="peerius_smartrecs"><file name="style.css" hash="54f4d88777c86d9b2951183e0323f026"/></dir></dir></dir></dir></dir></target></contents>
21
+ <compatible/>
22
+ <dependencies><required><php><min>5.3.0</min><max>6.0.0</max></php></required></dependencies>
23
+ </package>
skin/adminhtml/default/default/peerius/smartrecs/css/config.css ADDED
@@ -0,0 +1,89 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .navbar-inner {
2
+ background: transparent url("../img/navigation.png") repeat-x scroll 0 15px;
3
+ height:130px;
4
+ }
5
+
6
+ .brand {
7
+ background: transparent url("../img/logo-rollover.png") repeat-x scroll 0 0px;
8
+ display:block;
9
+ font-size: 0;
10
+ height: 130px;
11
+ line-height: 0;
12
+ overflow: hidden;
13
+ padding: 0;
14
+ position: relative;
15
+ width: 130px;
16
+ z-index: 3;
17
+ margin-left: 100px;
18
+ }
19
+
20
+ .container {
21
+ width:940px;
22
+ margin-left: auto;
23
+ margin-right:auto;
24
+ }
25
+
26
+ a.brand:hover {
27
+ background-position: 0 -130px;
28
+ }
29
+
30
+ .content-header {
31
+ margin-top: -68px;
32
+ overflow: visible !important;
33
+ background: #fff none repeat scroll 0 0;
34
+ }
35
+
36
+ .subscribe {
37
+ padding-left:20px;
38
+ margin-top: 5px;
39
+ }
40
+
41
+ .subscribe form {
42
+ margin: 0;
43
+ }
44
+
45
+ .subscribe form p {
46
+ float: left;
47
+ margin-bottom: 3px;
48
+ }
49
+
50
+ .subscribe input[type=text] {
51
+ background-color: #fff;
52
+ border: 1px solid #ccc;
53
+ box-shadow: 0 1px 1px rgba(0, 0, 0, 0.075) inset;
54
+ transition: border 0.2s linear 0s, box-shadow 0.2s linear 0s;
55
+ width: 180px;
56
+ border-radius: 4px;
57
+ color: #555;
58
+ display: inline-block;
59
+ font-size: 14px;
60
+ height: 20px;
61
+ line-height: 20px;
62
+ margin-bottom: 10px;
63
+ padding: 6px 6px;
64
+ vertical-align: middle;
65
+ }
66
+
67
+ .subscribe input[type=submit] {
68
+ background: #794FA0;
69
+ cursor: pointer;
70
+ font-size: 14px;
71
+ }
72
+
73
+ .subscribe input[type="submit"] {
74
+ background: #52a746 none repeat scroll 0 0;
75
+ border: medium none;
76
+ border-radius: 3px;
77
+ color: #fff;
78
+ font-family: "PT Sans","PTSansBold",helvetica,arial,sans-serif;
79
+ margin: 0px 10px 0 5px;
80
+ padding: 6px 10px;
81
+ }
82
+
83
+ .subscribe input[type="submit"]:hover {
84
+ color: #000;
85
+ }
86
+
87
+ .entry-edit-head {
88
+ background: #52a746 none repeat scroll 0 0 !important;
89
+ }
skin/adminhtml/default/default/peerius/smartrecs/img/logo-rollover.png ADDED
Binary file
skin/adminhtml/default/default/peerius/smartrecs/img/navigation.png ADDED
Binary file
skin/adminhtml/default/default/peerius/smartrecs/js/smartrecs.js ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ var enAllSelect = document.getElementById("peerius_general_enableall");
2
+ enAllSelect.addEventListener("change", enableDisable);
3
+ function enableDisable(e){
4
+ alert(enAllSelect.options[enAllSelect.selectedIndex].value);
5
+ //var peeriusMenuElem = document.getElementById("peerius_home-head").parentNode.parentNode;
6
+ //peeriusMenuElem.style.display = 'none';
7
+
8
+ }
9
+
10
+
11
+
skin/frontend/base/default/css/peerius_smartrecs/style.css ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .block-recommendations {
2
+ background:none;
3
+ }
4
+
5
+ .block-recommendations .block-content {
6
+ background:none;
7
+ }
8
+
9
+ .block-recommendations .peerius-products-grid .peerius-item {
10
+ width: 16.8%;
11
+ display:inline-block;
12
+ min-width: 135px;
13
+ text-align: center;
14
+ padding: 10px 9px 5px;
15
+ vertical-align: top;
16
+ }
17
+
18
+ .block-recommendations .peerius-product-image {
19
+ display: block;
20
+ margin: 0 0 5px;
21
+ }