Version Notes
Fixed p:recommended attribute in feed to include SKUs instead of magento ids.
Download this release
Release Info
Developer | Peerius |
Extension | Peerius_Connect |
Version | 1.0.7 |
Comparing to | |
See all releases |
Code changes from version 1.0.4 to 1.0.7
- app/code/community/Peerius/Smartrecs/.DS_Store +0 -0
- app/code/community/Peerius/Smartrecs/Block/Template.php +127 -127
- app/code/community/Peerius/Smartrecs/Block/Tracking.php +7 -6
- app/code/community/Peerius/Smartrecs/Model/.DS_Store +0 -0
- app/code/community/Peerius/Smartrecs/Model/Feed/Creator.php +509 -504
- app/code/community/Peerius/Smartrecs/controllers/InfoController.php +265 -193
- app/code/community/Peerius/Smartrecs/etc/config.xml +1 -1
- app/design/frontend/base/default/template/smartrecs/smartrecs.phtml +2 -2
- package.xml +8 -8
app/code/community/Peerius/Smartrecs/.DS_Store
DELETED
Binary file
|
app/code/community/Peerius/Smartrecs/Block/Template.php
CHANGED
@@ -1,127 +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 |
-
$
|
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 |
-
|
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 |
+
$skus = false;
|
25 |
+
$max = 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
CHANGED
@@ -152,10 +152,11 @@ class Peerius_Smartrecs_Block_Tracking extends Mage_Core_Block_Template {
|
|
152 |
if ($item->getParentItem()) {
|
153 |
continue;
|
154 |
}
|
|
|
155 |
$newItem = array(
|
156 |
'refCode' => $item->getSku(),
|
157 |
'qty' => $item->getQty(),
|
158 |
-
'price' => $
|
159 |
);
|
160 |
$pixel['basket']['items'][] = $newItem;
|
161 |
}
|
@@ -184,10 +185,11 @@ class Peerius_Smartrecs_Block_Tracking extends Mage_Core_Block_Template {
|
|
184 |
if ($item->getParentItem()) {
|
185 |
continue;
|
186 |
}
|
|
|
187 |
$newItem = array(
|
188 |
'refCode' => $item->getSku(),
|
189 |
'qty' => (int) $item->getQty(),
|
190 |
-
'price' => $
|
191 |
);
|
192 |
$pixel['checkout']['items'][] = $newItem;
|
193 |
}
|
@@ -227,10 +229,11 @@ class Peerius_Smartrecs_Block_Tracking extends Mage_Core_Block_Template {
|
|
227 |
if ($item->getParentItem()) {
|
228 |
continue;
|
229 |
}
|
|
|
230 |
$newItem = array(
|
231 |
'refCode' => $item->getSku(),
|
232 |
'qty' => (int) $item->getQtyOrdered(),
|
233 |
-
'price' => $
|
234 |
);
|
235 |
$pixel['order']['items'][] = $newItem;
|
236 |
}
|
@@ -393,7 +396,5 @@ class Peerius_Smartrecs_Block_Tracking extends Mage_Core_Block_Template {
|
|
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 |
-
|
152 |
if ($item->getParentItem()) {
|
153 |
continue;
|
154 |
}
|
155 |
+
$priceIncTax = Mage::helper('tax')->getPrice($item, $item->getPrice(), true);
|
156 |
$newItem = array(
|
157 |
'refCode' => $item->getSku(),
|
158 |
'qty' => $item->getQty(),
|
159 |
+
'price' => $priceIncTax
|
160 |
);
|
161 |
$pixel['basket']['items'][] = $newItem;
|
162 |
}
|
185 |
if ($item->getParentItem()) {
|
186 |
continue;
|
187 |
}
|
188 |
+
$priceIncTax = Mage::helper('tax')->getPrice($item, $item->getPrice(), true);
|
189 |
$newItem = array(
|
190 |
'refCode' => $item->getSku(),
|
191 |
'qty' => (int) $item->getQty(),
|
192 |
+
'price' => $priceIncTax
|
193 |
);
|
194 |
$pixel['checkout']['items'][] = $newItem;
|
195 |
}
|
229 |
if ($item->getParentItem()) {
|
230 |
continue;
|
231 |
}
|
232 |
+
$priceIncTax = Mage::helper('tax')->getPrice($item, $item->getPrice(), true);
|
233 |
$newItem = array(
|
234 |
'refCode' => $item->getSku(),
|
235 |
'qty' => (int) $item->getQtyOrdered(),
|
236 |
+
'price' => $priceIncTax
|
237 |
);
|
238 |
$pixel['order']['items'][] = $newItem;
|
239 |
}
|
396 |
}
|
397 |
return '<script type="text/JavaScript" src="//'.$this->escapeHtml(Mage::getStoreConfig('peerius/general/client_name')).'.peerius.com/tracker/peerius.page" charset="UTF-8"></script>';
|
398 |
}
|
|
|
399 |
|
400 |
+
}
|
|
app/code/community/Peerius/Smartrecs/Model/.DS_Store
DELETED
Binary file
|
app/code/community/Peerius/Smartrecs/Model/Feed/Creator.php
CHANGED
@@ -1,505 +1,510 @@
|
|
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 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
->
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
//
|
153 |
-
|
154 |
-
//
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
try {
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
$categoryBreadcrumbs = $
|
184 |
-
}
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
$rss .= '<
|
196 |
-
$rss .= '<
|
197 |
-
|
198 |
-
|
199 |
-
$
|
200 |
-
|
201 |
-
|
202 |
-
<p:
|
203 |
-
</p:
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
$
|
211 |
-
|
212 |
-
$
|
213 |
-
|
214 |
-
|
215 |
-
->
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
//$
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
$rss .= '<p:attribute name="
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
$
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
$rss .= $categoryBreadcrumbs;
|
246 |
-
}
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
$rss .= '<
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
$rss .= '<p:
|
258 |
-
$rss .= '<p:
|
259 |
-
$rss .= '<p:
|
260 |
-
$rss .= '<p:
|
261 |
-
$rss .= $
|
262 |
-
$rss .= $this->
|
263 |
-
$rss .=
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
$this->log(
|
269 |
-
}
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
$this->log(
|
281 |
-
$this->log('Memory ' . memory_get_peak_usage() / 1048576 . 'MB');
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
*
|
288 |
-
* @
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
->
|
297 |
-
->
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
->
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
*
|
321 |
-
* @
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
$
|
326 |
-
$
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
$
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
*
|
340 |
-
* @
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
->
|
346 |
-
->
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
*
|
354 |
-
* @
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
->
|
387 |
-
->
|
388 |
-
|
389 |
-
|
390 |
-
|
391 |
-
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
-
|
397 |
-
|
398 |
-
|
399 |
-
|
400 |
-
|
401 |
-
|
402 |
-
|
403 |
-
|
404 |
-
|
405 |
-
|
406 |
-
|
407 |
-
|
408 |
-
|
409 |
-
|
410 |
-
|
411 |
-
|
412 |
-
|
413 |
-
|
414 |
-
|
415 |
-
|
416 |
-
|
417 |
-
|
418 |
-
|
419 |
-
|
420 |
-
|
421 |
-
|
422 |
-
|
423 |
-
|
424 |
-
|
425 |
-
|
426 |
-
|
427 |
-
|
428 |
-
|
429 |
-
|
430 |
-
|
431 |
-
|
432 |
-
|
433 |
-
|
434 |
-
|
435 |
-
if ($
|
436 |
-
|
437 |
-
|
438 |
-
|
439 |
-
|
440 |
-
|
441 |
-
return
|
442 |
-
}
|
443 |
-
|
444 |
-
|
445 |
-
|
446 |
-
|
447 |
-
|
448 |
-
|
449 |
-
|
450 |
-
|
451 |
-
|
452 |
-
|
453 |
-
|
454 |
-
|
455 |
-
|
456 |
-
|
457 |
-
|
458 |
-
|
459 |
-
|
460 |
-
|
461 |
-
|
462 |
-
|
463 |
-
|
464 |
-
|
465 |
-
|
466 |
-
|
467 |
-
|
468 |
-
|
469 |
-
|
470 |
-
|
471 |
-
|
472 |
-
$this->log("
|
473 |
-
|
474 |
-
|
475 |
-
|
476 |
-
|
477 |
-
$
|
478 |
-
$
|
479 |
-
|
480 |
-
|
481 |
-
|
482 |
-
$
|
483 |
-
$
|
484 |
-
|
485 |
-
|
486 |
-
|
487 |
-
|
488 |
-
|
489 |
-
|
490 |
-
|
491 |
-
|
492 |
-
|
493 |
-
|
494 |
-
|
495 |
-
|
496 |
-
|
497 |
-
|
498 |
-
|
499 |
-
|
500 |
-
|
501 |
-
|
502 |
-
|
503 |
-
|
504 |
-
|
|
|
|
|
|
|
|
|
|
|
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 |
+
//###################### DEBUG CODE :MG #####################
|
132 |
+
$debugMode = Mage::app()->getRequest()->getParam('debug') == 1 ? true : false;
|
133 |
+
$debugProducts = Mage::app()->getRequest()->getParam('items') ? Mage::app()->getRequest()->getParam('items') : 10;
|
134 |
+
$this->log('~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~');
|
135 |
+
$this->log('DEBUG MODE : '.($debugMode == true ? 'enabled. Creating feed for '. $debugProducts. ' products.' :'disabled'));
|
136 |
+
//###################### DEBUG CODE :MG #####################
|
137 |
+
|
138 |
+
$this->log('Feed creation STARTED');
|
139 |
+
|
140 |
+
$this->_changeTheme(Mage::getStoreConfig('design/package/name', $website->getDefaultStore()->getCode()), Mage::getStoreConfig('design/package/theme', $website->getDefaultStore()->getCode()));
|
141 |
+
|
142 |
+
$rss = '';
|
143 |
+
|
144 |
+
$productCollection = Mage::getModel('catalog/product')
|
145 |
+
->getCollection()
|
146 |
+
->addWebsiteFilter($website->getWebsiteId())
|
147 |
+
->joinField("qty", $_catalogInventoryTable, 'qty', 'product_id=entity_id', null, 'left')
|
148 |
+
->addAttributeToSelect('*')
|
149 |
+
->addCategoryIds()
|
150 |
+
//->addAttributeToFilter('type_id', array('eq' => 'configurable'))
|
151 |
+
->addAttributeToFilter('visibility', $visiblityCondition)
|
152 |
+
// ->joinTable('catalog/product_relation', 'child_id=entity_id', array('parent_id' => 'parent_id'), null, 'left')
|
153 |
+
->addPriceData(Mage_Customer_Model_Group::NOT_LOGGED_IN_ID, $website->getWebsiteId());
|
154 |
+
// ->load();
|
155 |
+
|
156 |
+
$productsCount = $productCollection->getSize();
|
157 |
+
$this->log('Total products found : ' . $productsCount);
|
158 |
+
|
159 |
+
$ctr = 0;
|
160 |
+
|
161 |
+
try {
|
162 |
+
foreach ($productCollection as $product) {
|
163 |
+
|
164 |
+
//###################### DEBUG CODE :MG #####################
|
165 |
+
if ($debugMode && $ctr > $debugProducts) break;
|
166 |
+
//###################### DEBUG CODE :MG #####################
|
167 |
+
|
168 |
+
$categoryIds = $product->getCategoryIds();
|
169 |
+
$parentCategoryBreadcrumbs = false;
|
170 |
+
$parent = false;
|
171 |
+
|
172 |
+
// don't export unavailable products
|
173 |
+
if (!$product->isAvailable()) {
|
174 |
+
$productsCount--;
|
175 |
+
continue;
|
176 |
+
}
|
177 |
+
|
178 |
+
// if a product is not in a category skip it also
|
179 |
+
if ($product->getTypeId() == Mage_Catalog_Model_Product_Type::TYPE_SIMPLE) {
|
180 |
+
$parent = $this->_getParent($product);
|
181 |
+
if ($parent) {
|
182 |
+
$parentCategoryBreadcrumbs = $this->_getParentCategoryBreadcrumbs($product);
|
183 |
+
$categoryBreadcrumbs = $parentCategoryBreadcrumbs;
|
184 |
+
} else {
|
185 |
+
$categoryBreadcrumbs = $this->_getCategoryBreadcrumbs($product->getCategoryIds());
|
186 |
+
}
|
187 |
+
}
|
188 |
+
|
189 |
+
// is the product or it's product in any category? If not, skip it
|
190 |
+
if (!$categoryIds AND !$parentCategoryBreadcrumbs) {
|
191 |
+
$productsCount--;
|
192 |
+
continue;
|
193 |
+
}
|
194 |
+
|
195 |
+
$rss .= '<item>';
|
196 |
+
$rss .= '<title><![CDATA[' . $product->getName() . ']]></title>';
|
197 |
+
$rss .= '<link>' . $product->getProductUrl() . '</link>';
|
198 |
+
$rss .= '<guid>' . $product->getSku() . '</guid>';
|
199 |
+
if ($product->getThumbnail())
|
200 |
+
$rss .= '<p:imageLink>' . Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA) . 'catalog/product' . $product->getThumbnail() . '</p:imageLink>';
|
201 |
+
$rss .= '<p:price>
|
202 |
+
<p:unitPrice>' . number_format($product->getPrice(), 2, '.', '') . '</p:unitPrice>
|
203 |
+
<p:salePrice>' . number_format($product->getFinalPrice(), 2, '.', '') . '</p:salePrice>
|
204 |
+
<p:currency>' . Mage::app()->getStore($website->getDefaultStore())->getCurrentCurrencyCode() . '</p:currency>
|
205 |
+
</p:price>';
|
206 |
+
|
207 |
+
|
208 |
+
if ($product->getTypeId() == Mage_Catalog_Model_Product_Type::TYPE_CONFIGURABLE) {
|
209 |
+
$rss .= $this->_getCategoryBreadcrumbs($categoryIds);
|
210 |
+
$rss .= '<p:attribute name="minimal_price">' . number_format($product->getMinimalPrice(), 2, '.', '') . '</p:attribute>';
|
211 |
+
|
212 |
+
$attrArr = Mage::getModel('catalog/product_type_configurable')->getConfigurableAttributesAsArray($product);
|
213 |
+
|
214 |
+
$childProducts = Mage::getModel('catalog/product_type_configurable')->getUsedProductCollection($product)
|
215 |
+
->addAttributeToSelect('thumbnail')
|
216 |
+
->addAttributeToSelect('name')
|
217 |
+
->joinAttribute('visibility', 'catalog_product/visibility', 'entity_id', null, 'inner', 1);
|
218 |
+
foreach ($attrArr as $attr) {
|
219 |
+
$childProducts->addAttributeToSelect($attr['attribute_code']);
|
220 |
+
}
|
221 |
+
|
222 |
+
foreach ($childProducts as $childProduct) {
|
223 |
+
if ($childProduct->getData('visibility') == Mage_Catalog_Model_Product_Visibility::VISIBILITY_NOT_VISIBLE) {
|
224 |
+
//$p = Mage::getModel('catalog/product')->load($childProduct->getId());
|
225 |
+
$rss .= '<p:variant>';
|
226 |
+
//$rss .= '<p:title><![CDATA[' . $childProduct->getName() . ']]></p:title>';
|
227 |
+
foreach ($attrArr as $attr) {
|
228 |
+
$rss .= '<p:attribute name="' . $attr['attribute_code'] . '"><![CDATA[' . $childProduct->getAttributeText($attr['attribute_code']) . ']]></p:attribute>';
|
229 |
+
}
|
230 |
+
$rss .= '<p:attribute name="link">' . $childProduct->getProductUrl() . '</p:attribute>';
|
231 |
+
$rss .= '<p:attribute name="guid">' . $childProduct->getSku() . '</p:attribute>';
|
232 |
+
$rss .= '<p:attribute name="magento_id">' . $childProduct->getId() . '</p:attribute>';
|
233 |
+
if ($product->getThumbnail())
|
234 |
+
$rss .= '<p:imageLink>' . Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA) . 'catalog/product' . $childProduct->getThumbnail() . '</p:imageLink>';
|
235 |
+
$stockItem = $childProduct->getStockItem();
|
236 |
+
$stockQty = ($stockItem instanceof Mage_CatalogInventory_Model_Stock_Item) ?
|
237 |
+
((int) $stockItem->getQty() > 0 ? (int) $stockItem->getQty() : 0) : 0;
|
238 |
+
$rss .= '<p:stock>' . $stockQty . '</p:stock>';
|
239 |
+
$rss .= '</p:variant>';
|
240 |
+
}
|
241 |
+
}
|
242 |
+
} else {
|
243 |
+
if ($parent) {
|
244 |
+
$rss .= $parent;
|
245 |
+
$rss .= $categoryBreadcrumbs;
|
246 |
+
} else {
|
247 |
+
$rss .= $categoryBreadcrumbs;
|
248 |
+
}
|
249 |
+
}
|
250 |
+
|
251 |
+
$rss .= '<pubDate>' . $product->getcreated_at() . '</pubDate>';
|
252 |
+
$rss .= '<description><![CDATA[' . $product->getDescription() . ']]></description>';
|
253 |
+
|
254 |
+
if ($product->getAttribute('manufacturer') instanceof Mage_Eav_Model_Entity_Attribute_Abstract) {
|
255 |
+
$rss .= '<p:brand><![CDATA[' . $product->getAttributeText('manufacturer') . ']]></p:brand>';
|
256 |
+
}
|
257 |
+
$rss .= '<p:inStock>' . $this->_getStockStatus($product) . '</p:inStock>';
|
258 |
+
$rss .= '<p:stock>' . ((int) $product->getQty() > 0 ? (int) $product->getQty() : 0) . '</p:stock>';
|
259 |
+
$rss .= '<p:recommend>Y</p:recommend>';
|
260 |
+
$rss .= '<p:recommended>' . $this->_getRecommended($product) . '</p:recommended>';
|
261 |
+
$rss .= '<p:attribute name="magento_id">' . $product->getId() . '</p:attribute>';
|
262 |
+
$rss .= $this->_getAttributes($product);
|
263 |
+
$rss .= $this->_getTags($product);
|
264 |
+
$rss .= '</item>';
|
265 |
+
$ctr++;
|
266 |
+
}
|
267 |
+
|
268 |
+
$this->log('Total entries created : ' . ($ctr - 1) );
|
269 |
+
} catch (Exception $e) {
|
270 |
+
$this->log("an error occured: " . $e->getMessage());
|
271 |
+
}
|
272 |
+
|
273 |
+
|
274 |
+
if ($productsCount == 0) {
|
275 |
+
$this->log("no products found");
|
276 |
+
throw new Exception("no products found");
|
277 |
+
}
|
278 |
+
|
279 |
+
$now = microtime(true);
|
280 |
+
$this->log("Feed creation COMPLETED in " . date("H:i:s", ($now - $profilingStart)));
|
281 |
+
$this->log('Memory used : ' . round(memory_get_peak_usage() / 1048576) . 'MB');
|
282 |
+
$this->log('===================================================');
|
283 |
+
return $rss;
|
284 |
+
}
|
285 |
+
|
286 |
+
/**
|
287 |
+
* generate breadcrumb style categories
|
288 |
+
* @param array $currentCatIds
|
289 |
+
* @return string
|
290 |
+
*/
|
291 |
+
protected function _getCategoryBreadcrumbs($currentCatIds) {
|
292 |
+
$rss = '';
|
293 |
+
|
294 |
+
if ($currentCatIds) {
|
295 |
+
$categoryCollection = Mage::getResourceModel('catalog/category_collection')
|
296 |
+
->addAttributeToSelect('path')
|
297 |
+
->addAttributeToFilter('entity_id', $currentCatIds)
|
298 |
+
->addIsActiveFilter();
|
299 |
+
|
300 |
+
foreach ($categoryCollection as $cat) {
|
301 |
+
$p = explode('/', $cat->getPath());
|
302 |
+
|
303 |
+
$fullPath = array();
|
304 |
+
foreach ($p as $treeCat) {
|
305 |
+
// Root-Kategorie 1 überspringen
|
306 |
+
if ($treeCat <= 2)
|
307 |
+
continue;
|
308 |
+
$category = Mage::getModel('catalog/category')
|
309 |
+
->setStoreId(Mage::app()->getStore()->getId())
|
310 |
+
->load($treeCat);
|
311 |
+
$fullPath[] = $category->getName();
|
312 |
+
}
|
313 |
+
$rss .= '<category><![CDATA[' . implode('>', $fullPath) . ']]></category>';
|
314 |
+
}
|
315 |
+
}
|
316 |
+
return $rss;
|
317 |
+
}
|
318 |
+
|
319 |
+
/**
|
320 |
+
* generate breadcrumb style categories
|
321 |
+
* @param product $product
|
322 |
+
* @return string
|
323 |
+
*/
|
324 |
+
protected function _getParentCategoryBreadcrumbs($product) {
|
325 |
+
$rss = '';
|
326 |
+
$parentIds = $this->_getParent($product, true);
|
327 |
+
$categoryIds = array();
|
328 |
+
|
329 |
+
foreach ($parentIds as $parentId) {
|
330 |
+
$product = Mage::getModel('catalog/product')->load($parentId);
|
331 |
+
$categoryIds = array_merge($categoryIds, $product->getCategoryIds());
|
332 |
+
}
|
333 |
+
|
334 |
+
$rss = $this->_getCategoryBreadcrumbs($categoryIds);
|
335 |
+
return $rss;
|
336 |
+
}
|
337 |
+
|
338 |
+
/**
|
339 |
+
* retreive the product stock statuss
|
340 |
+
* @param Mage_Core_Catalog_Product $product
|
341 |
+
* @return string
|
342 |
+
*/
|
343 |
+
protected function _getStockStatus($product) {
|
344 |
+
$stockStatus = Mage::getModel('cataloginventory/stock_item')
|
345 |
+
->getCollection()
|
346 |
+
->addFieldToFilter('product_id', $product->getId())
|
347 |
+
->getFirstItem();
|
348 |
+
|
349 |
+
return $stockStatus ? 'Y' : 'N';
|
350 |
+
}
|
351 |
+
|
352 |
+
/**
|
353 |
+
* write the products
|
354 |
+
* @param Mage_Core_Catalog_Product $product
|
355 |
+
* @return string
|
356 |
+
*/
|
357 |
+
protected function _getRecommended($product) {
|
358 |
+
$all = array();
|
359 |
+
$related = $product->getRelatedProductIds();
|
360 |
+
foreach ($related as $id) {
|
361 |
+
$all[$id] = Mage::getModel('catalog/product')->load($id)->getSku();
|
362 |
+
//$this->log("Related Product is :".$all[$id]);
|
363 |
+
}
|
364 |
+
|
365 |
+
$crosssell = $product->getCrossSellProducts();
|
366 |
+
foreach ($crosssell as $_item) {
|
367 |
+
$all[$_item->getId()] = $_item->getSku();
|
368 |
+
//$this->log("Cross Selling Product is :".$all[$_item->getId()]);
|
369 |
+
}
|
370 |
+
$upsell = $product->getUpSellProductCollection();
|
371 |
+
foreach ($upsell as $_item) {
|
372 |
+
$all[$_item->getId()] = $_item->getSku();
|
373 |
+
//$this->log("Up Selling Product is :".$all[$_item->getId()]);
|
374 |
+
}
|
375 |
+
return implode(',', $all);
|
376 |
+
}
|
377 |
+
|
378 |
+
/**
|
379 |
+
* generate comma-separated list of product tags
|
380 |
+
* @param Mage_Core_Catalog_Product $product
|
381 |
+
* @return string
|
382 |
+
*/
|
383 |
+
protected function _getTags($product) {
|
384 |
+
$tag_model = Mage::getModel('tag/tag');
|
385 |
+
$tag_collection = $tag_model->getResourceCollection()
|
386 |
+
->addPopularity()
|
387 |
+
// ->addStatusFilter($model->getApprovedStatus())
|
388 |
+
->addProductFilter($product->getId())
|
389 |
+
->setFlag('relation', true)
|
390 |
+
->addStoreFilter(Mage::app()->getStore()->getId())
|
391 |
+
->setActiveFilter()
|
392 |
+
->load();
|
393 |
+
|
394 |
+
$mytags = $tag_collection->getItems();
|
395 |
+
|
396 |
+
$tagArr = array();
|
397 |
+
if (!$tag_collection->getSize()) {
|
398 |
+
return '';
|
399 |
+
}
|
400 |
+
|
401 |
+
foreach ($mytags as $tag) {
|
402 |
+
$tagArr[] = $tag->getName();
|
403 |
+
}
|
404 |
+
return '<p:tags>' . implode(',', $tagArr) . '</p:tags>';
|
405 |
+
}
|
406 |
+
|
407 |
+
/**
|
408 |
+
* crate front-end attributes rss string
|
409 |
+
* @param Mage_Core_Catalog_Product $product
|
410 |
+
* @return string
|
411 |
+
*/
|
412 |
+
protected function _getAttributes($product) {
|
413 |
+
$attributes = $product->getAttributes();
|
414 |
+
$rss = '';
|
415 |
+
foreach ($attributes as $attribute) {
|
416 |
+
if ($attribute->getIsVisibleOnFront()) {
|
417 |
+
$attributeCode = $attribute->getAttributeCode();
|
418 |
+
$label = $attribute->getFrontend()->getLabel($product);
|
419 |
+
$value = $attribute->getFrontend()->getValue($product);
|
420 |
+
$rss .= '<p:attribute name="' . $attributeCode . '"><![CDATA[' . $value . ']]></p:attribute>';
|
421 |
+
}
|
422 |
+
}
|
423 |
+
return $rss;
|
424 |
+
}
|
425 |
+
|
426 |
+
/**
|
427 |
+
* returns parent product ID if available
|
428 |
+
* @param Mage_Core_Catalog_Product $product
|
429 |
+
* @param bool return the ids
|
430 |
+
* @return int
|
431 |
+
*/
|
432 |
+
protected function _getParent($product, $ids = false) {
|
433 |
+
$rss = '';
|
434 |
+
$parentIds = false;
|
435 |
+
if ($product->getTypeId() == "simple") {
|
436 |
+
$parentIds = Mage::getModel('catalog/product_type_grouped')->getParentIdsByChild($product->getId()); // check for grouped product
|
437 |
+
if (!$parentIds)
|
438 |
+
$parentIds = Mage::getModel('catalog/product_type_configurable')->getParentIdsByChild($product->getId()); //check for config product
|
439 |
+
}
|
440 |
+
if ($ids) {
|
441 |
+
return $parentIds;
|
442 |
+
}
|
443 |
+
if ($parentIds) {
|
444 |
+
$rss = '<p:attribute name="parent_magento_id">' . implode(',', $parentIds) . '</p:attribute>';
|
445 |
+
} else {
|
446 |
+
return false;
|
447 |
+
}
|
448 |
+
return $rss;
|
449 |
+
}
|
450 |
+
|
451 |
+
/**
|
452 |
+
* the client name used in the rss feed
|
453 |
+
* @return string
|
454 |
+
*/
|
455 |
+
protected function _getClientName() {
|
456 |
+
return Mage::getStoreConfig('peerius/general/client_name');
|
457 |
+
}
|
458 |
+
|
459 |
+
/**
|
460 |
+
* @param $content
|
461 |
+
* @return bool
|
462 |
+
*/
|
463 |
+
protected function _appendToFile($content) {
|
464 |
+
try {
|
465 |
+
$f = new Varien_Io_File();
|
466 |
+
$validator = new Zend_Validate_File_Exists();
|
467 |
+
|
468 |
+
if (!$validator->isValid($this->fileName)) {
|
469 |
+
$this->log("could not create the smartrec file");
|
470 |
+
return false;
|
471 |
+
}
|
472 |
+
$this->log("SMART-recs file created");
|
473 |
+
|
474 |
+
fclose($f);
|
475 |
+
return true;
|
476 |
+
} catch (Exception $ex) {
|
477 |
+
$this->log("error during file creation");
|
478 |
+
$this->log($ex->getMessage());
|
479 |
+
return false;
|
480 |
+
}
|
481 |
+
try {
|
482 |
+
$f = new Varien_Io_File();
|
483 |
+
$f->write($this->fileName, $content);
|
484 |
+
//if (file_put_contents($this->fileName, $content, FILE_APPEND)) {
|
485 |
+
return true;
|
486 |
+
} catch (Exception $ex) {
|
487 |
+
$this->log("error while writing to the feed file");
|
488 |
+
$this->log($ex->getMessage());
|
489 |
+
return false;
|
490 |
+
}
|
491 |
+
}
|
492 |
+
|
493 |
+
public function checkToken() {
|
494 |
+
$token = Mage::getStoreConfig('peerius/general/token');
|
495 |
+
|
496 |
+
if (!$token OR !Mage::app()->getRequest()->getParam('token') OR (Mage::app()->getRequest()->getParam('token') != sha1($token))) {
|
497 |
+
$this->log("token error");
|
498 |
+
return false;
|
499 |
+
}
|
500 |
+
return true;
|
501 |
+
}
|
502 |
+
|
503 |
+
/**
|
504 |
+
* @param string $message
|
505 |
+
*/
|
506 |
+
protected function log($message) {
|
507 |
+
Mage::helper('peerius_smartrecs')->log(Zend_Log::DEBUG, $message);
|
508 |
+
}
|
509 |
+
|
510 |
}
|
app/code/community/Peerius/Smartrecs/controllers/InfoController.php
CHANGED
@@ -1,193 +1,265 @@
|
|
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 |
-
|
13 |
-
*
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
$
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
$
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
$
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
}
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
/*
|
13 |
+
* returns the parameters of the created peerius SMARTrecs widgets
|
14 |
+
* @return string
|
15 |
+
*/
|
16 |
+
public function allconfigAction() {
|
17 |
+
if ($this->checkToken()) {
|
18 |
+
|
19 |
+
$modules = Mage::getConfig()->getNode('modules')->children();
|
20 |
+
$modulesArray = (array)$modules;
|
21 |
+
$connectVersion = 'unknown';
|
22 |
+
//foreach ($modulesArray as $module) {
|
23 |
+
// $this->log($module->getName()." is on version ".$module->version);
|
24 |
+
//}
|
25 |
+
|
26 |
+
if($modulesArray['Peerius_Smartrecs']->is('active')) {
|
27 |
+
$connectVersion = $modulesArray['Peerius_Smartrecs']->version;
|
28 |
+
$this->log("Peerius_Connect version is ".$connectVersion);
|
29 |
+
} else {
|
30 |
+
$this->log("Peerius_Connect is not available");
|
31 |
+
}
|
32 |
+
|
33 |
+
$configs = Mage::getModel('core/config_data')->getCollection()->addFieldToFilter('path',array('like'=>'peerius%'))->setOrder('config_id',Varien_Data_Collection::SORT_ORDER_ASC);
|
34 |
+
$siteName = Mage::getStoreConfig('peerius/general/client_name',Mage::app()->getStore());
|
35 |
+
$response = '<!doctype html><html lang=\'en-gb\'><head><meta charset=\'utf-8\'><title> CONFIG: '.$siteName.'</title>'.$this->getCSS().'</head><body style="font-family:Arial;">';
|
36 |
+
$response .= '<section><h1>Peerius Connect Configuration : '. $siteName . '</h1> (v ' .$connectVersion. ')';
|
37 |
+
|
38 |
+
$sec1 = "";
|
39 |
+
$sec2 = "";
|
40 |
+
foreach ($configs as $config) {
|
41 |
+
$path = str_replace('max','number_of_products', $config->getPath());
|
42 |
+
|
43 |
+
$name_arr = explode ("/", $path);
|
44 |
+
$sec1 = $name_arr[1];
|
45 |
+
$secName = ($sec1 != $sec2) ? $sec1 : "";
|
46 |
+
$sec2 = $sec1;
|
47 |
+
if($secName!="") {
|
48 |
+
$response .= '<div class=\'secTitle\'>'.ucfirst($secName). ' Config: </div>';
|
49 |
+
}
|
50 |
+
$paramName = $name_arr[2];
|
51 |
+
$paramValue = $config->getValue();
|
52 |
+
$dispName = $paramName;
|
53 |
+
$dispValue = $paramValue;
|
54 |
+
|
55 |
+
switch ($paramName) {
|
56 |
+
case "token":
|
57 |
+
$dispValue = $dispValue.' (ENCODED: '.sha1($dispValue).')';
|
58 |
+
break;
|
59 |
+
case "enableall":
|
60 |
+
$dispName = 'Are Recs anabled for site?';
|
61 |
+
$dispValue = ($dispValue == 1) ? 'Yes' : 'No';
|
62 |
+
break;
|
63 |
+
case "disable":
|
64 |
+
$dispName = 'Are Recs enabled for page?';
|
65 |
+
$dispValue = ($dispValue == 0) ? 'Yes' : 'No';
|
66 |
+
break;
|
67 |
+
case "cronjob":
|
68 |
+
$dispName = 'Feed scheduled at?';
|
69 |
+
break;
|
70 |
+
case "testmode":
|
71 |
+
$dispName = 'Is test mode enabled?';
|
72 |
+
$dispValue = ($dispValue == 1) ? 'Yes' : 'No';
|
73 |
+
break;
|
74 |
+
case "registrationstatus":
|
75 |
+
$dispName = 'Registration status?';
|
76 |
+
$dispValue = ($dispValue == 1) ? 'Registered' : 'Something happend that shouldn\'t have!';
|
77 |
+
break;
|
78 |
+
case "headline":
|
79 |
+
$dispName = 'Widget title';
|
80 |
+
break;
|
81 |
+
case "success":
|
82 |
+
$dispName = 'Show recs for all search?';
|
83 |
+
$dispValue = ($dispValue == 0) ? 'No, only for zero search' : 'Yes';
|
84 |
+
break;
|
85 |
+
default:
|
86 |
+
break;
|
87 |
+
}
|
88 |
+
|
89 |
+
$response .= '<div class=\'boxA\'>'.ucfirst($dispName).' </div><div class=\'boxB\'> '.$dispValue . "</div><br />";
|
90 |
+
}
|
91 |
+
|
92 |
+
$collection = Mage::getModel('widget/widget_instance')->getCollection();
|
93 |
+
$collection->addFieldToFilter('instance_type', 'smartrecs/recommendations');
|
94 |
+
|
95 |
+
if($collection->getSize()>0)
|
96 |
+
{
|
97 |
+
$response .= '<h1>Widget Instance Manager</h1>';
|
98 |
+
foreach($collection as $item)
|
99 |
+
{
|
100 |
+
$response .= $item->title.'<hr>';
|
101 |
+
$response .= $item->widget_parameters;
|
102 |
+
$response .= '<br><br><br>';
|
103 |
+
}
|
104 |
+
}
|
105 |
+
|
106 |
+
$response .= '</section></body></html>';
|
107 |
+
$this->getResponse()->setHeader('Content-Type', 'text/html')->setBody($response);
|
108 |
+
|
109 |
+
}
|
110 |
+
}
|
111 |
+
|
112 |
+
/**
|
113 |
+
* when is the cron executed?
|
114 |
+
* @return int
|
115 |
+
*/
|
116 |
+
public function createtimeAction() {
|
117 |
+
if ($this->checkToken()) {
|
118 |
+
$response = (int) Mage::getStoreConfig('peerius/general/cronjob');
|
119 |
+
|
120 |
+
$this->getResponse()
|
121 |
+
->setHeader('Content-Type', 'text/html')
|
122 |
+
->setBody($response);
|
123 |
+
}
|
124 |
+
}
|
125 |
+
|
126 |
+
/**
|
127 |
+
* what registration status has the shop
|
128 |
+
* @return int
|
129 |
+
*/
|
130 |
+
public function registrationstatusAction() {
|
131 |
+
if ($this->checkToken()) {
|
132 |
+
$response = (int) Mage::getStoreConfig('peerius/general/registrationstatus');
|
133 |
+
|
134 |
+
$this->getResponse()
|
135 |
+
->setHeader('Content-Type', 'text/html')
|
136 |
+
->setBody($response);
|
137 |
+
}
|
138 |
+
}
|
139 |
+
|
140 |
+
/**
|
141 |
+
* what registration status has the shop
|
142 |
+
* @return int
|
143 |
+
*/
|
144 |
+
public function registrationerrorAction() {
|
145 |
+
if ($this->checkToken()) {
|
146 |
+
$response = (int) Mage::getStoreConfig('peerius/general/registrationerror');
|
147 |
+
|
148 |
+
$this->getResponse()
|
149 |
+
->setHeader('Content-Type', 'text/html')
|
150 |
+
->setBody($response);
|
151 |
+
}
|
152 |
+
}
|
153 |
+
|
154 |
+
/*
|
155 |
+
* returns the parameters of the created peerius SMARTrecs widgets
|
156 |
+
* @return string
|
157 |
+
*/
|
158 |
+
public function widgetsAction() {
|
159 |
+
if ($this->checkToken()) {
|
160 |
+
$response = '';
|
161 |
+
$collection = Mage::getModel('widget/widget_instance')->getCollection();
|
162 |
+
$collection->addFieldToFilter('instance_type', 'smartrecs/recommendations');
|
163 |
+
|
164 |
+
foreach($collection as $item)
|
165 |
+
{
|
166 |
+
$response .= $item->title.'<hr>';
|
167 |
+
$response .= $item->widget_parameters;
|
168 |
+
$response .= '<br><br><br>';
|
169 |
+
}
|
170 |
+
|
171 |
+
$this->getResponse()
|
172 |
+
->setHeader('Content-Type', 'text/html')
|
173 |
+
->setBody($response);
|
174 |
+
}
|
175 |
+
}
|
176 |
+
|
177 |
+
/*
|
178 |
+
* resets the registration status
|
179 |
+
* @return string
|
180 |
+
*/
|
181 |
+
public function registrationstatusresetAction() {
|
182 |
+
if ($this->checkToken()) {
|
183 |
+
Mage::getModel('core/config')->saveConfig('peerius/general/registrationstatus', '0');
|
184 |
+
Mage::getModel('core/config')->saveConfig('peerius/general/registrationerror', '0');
|
185 |
+
}
|
186 |
+
}
|
187 |
+
|
188 |
+
/*
|
189 |
+
* deletes the configuration
|
190 |
+
* @return string
|
191 |
+
*/
|
192 |
+
public function resetconfigAction() {
|
193 |
+
if ($this->checkToken()) {
|
194 |
+
$configs = Mage::getModel('core/config_data')->getCollection()->addFieldToFilter('path',array('like'=>'peerius%'));
|
195 |
+
|
196 |
+
foreach ($configs as $config) {
|
197 |
+
$config->delete($config);
|
198 |
+
}
|
199 |
+
$response = count($configs) . ' entries deleted';
|
200 |
+
|
201 |
+
$this->getResponse()
|
202 |
+
->setHeader('Content-Type', 'text/html')
|
203 |
+
->setBody($response);
|
204 |
+
}
|
205 |
+
}
|
206 |
+
|
207 |
+
/*
|
208 |
+
* sets the admin IP to preview recommendations in test mode
|
209 |
+
* @return string
|
210 |
+
*/
|
211 |
+
public function adminipAction() {
|
212 |
+
if ($this->checkToken()) {
|
213 |
+
if (!filter_var($this->getRequest()->getParam('ip'), FILTER_VALIDATE_IP) === false) {
|
214 |
+
Mage::getModel('core/config')->saveConfig('peerius/general/adminip', $this->getRequest()->getParam('ip'));
|
215 |
+
}
|
216 |
+
}
|
217 |
+
}
|
218 |
+
|
219 |
+
/*
|
220 |
+
* reads the admin IP
|
221 |
+
* @return string
|
222 |
+
*/
|
223 |
+
public function adminipreadAction() {
|
224 |
+
if ($this->checkToken()) {
|
225 |
+
$response = Mage::getStoreConfig('peerius/general/adminip');
|
226 |
+
|
227 |
+
$this->getResponse()
|
228 |
+
->setHeader('Content-Type', 'text/html')
|
229 |
+
->setBody($response);
|
230 |
+
}
|
231 |
+
}
|
232 |
+
|
233 |
+
/*
|
234 |
+
* checks for the valid token to prevent URL manipulation
|
235 |
+
* @return bool
|
236 |
+
*/
|
237 |
+
public function checkToken() {
|
238 |
+
$token = Mage::getStoreConfig('peerius/general/token');
|
239 |
+
|
240 |
+
if (!$token OR !$this->getRequest()->getParam('token') OR ($this->getRequest()->getParam('token') != sha1($token))) {
|
241 |
+
$this->log("token error");
|
242 |
+
return false;
|
243 |
+
}
|
244 |
+
return true;
|
245 |
+
}
|
246 |
+
|
247 |
+
/**
|
248 |
+
* @param string $message
|
249 |
+
*/
|
250 |
+
protected function log($message) {
|
251 |
+
Mage::helper('peerius_smartrecs')->log(Zend_Log::DEBUG, $message);
|
252 |
+
}
|
253 |
+
|
254 |
+
/**
|
255 |
+
* return CSS
|
256 |
+
*/
|
257 |
+
protected function getCSS() {
|
258 |
+
return "<style type='text/css'>
|
259 |
+
.secTitle {clear:both;display:block;float:left;padding:5px;margin:10px 0 5px 0;width:100%;color:#808080;font-weight:bold; font-size:20px;}
|
260 |
+
.boxA { clear:left;display:block;float:left;padding:2px 0 0 4px;margin:1px;background-color: #60b346 ; width:200px; height:22px; }
|
261 |
+
.boxB { float:left;display:in-line;padding:2px 0 0 4px;margin:1px;background-color: #A9Ae99; width:650px; height:22px;color:#000; }
|
262 |
+
</style>";
|
263 |
+
}
|
264 |
+
|
265 |
+
}
|
app/code/community/Peerius/Smartrecs/etc/config.xml
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
<config>
|
3 |
<modules>
|
4 |
<Peerius_Smartrecs>
|
5 |
-
<version>1.0.
|
6 |
</Peerius_Smartrecs>
|
7 |
</modules>
|
8 |
<frontend>
|
2 |
<config>
|
3 |
<modules>
|
4 |
<Peerius_Smartrecs>
|
5 |
+
<version>1.0.7</version>
|
6 |
</Peerius_Smartrecs>
|
7 |
</modules>
|
8 |
<frontend>
|
app/design/frontend/base/default/template/smartrecs/smartrecs.phtml
CHANGED
@@ -8,7 +8,7 @@
|
|
8 |
*/
|
9 |
|
10 |
?>
|
11 |
-
<!-- Peerius SMART-recs tracking and rendering -->
|
12 |
|
13 |
<?php
|
14 |
$renderActive = (file_exists(dirname(__FILE__).'/render.phtml')) ? true:false;
|
@@ -18,7 +18,7 @@ if (Mage::helper('peerius_smartrecs')->isActive()) {
|
|
18 |
if ($trackingPixel) {
|
19 |
?>
|
20 |
|
21 |
-
<script type="text/JavaScript" src="
|
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';?>;
|
8 |
*/
|
9 |
|
10 |
?>
|
11 |
+
<!-- Peerius SMART-recs tracking and rendering [<?php echo $this->escapeHtml(Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB))?>]-->
|
12 |
|
13 |
<?php
|
14 |
$renderActive = (file_exists(dirname(__FILE__).'/render.phtml')) ? true:false;
|
18 |
if ($trackingPixel) {
|
19 |
?>
|
20 |
|
21 |
+
<script type="text/JavaScript" src="<?php echo $this->escapeHtml(Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB))?>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';?>;
|
package.xml
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>Peerius_Connect</name>
|
4 |
-
<version>1.0.
|
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>
|
@@ -9,15 +9,15 @@
|
|
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:
|
11 |

|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
</description>
|
16 |
-
<notes>
|
17 |
<authors><author><name>Peerius</name><user>Peerius</user><email>extensions@peerius.com</email></author></authors>
|
18 |
-
<date>
|
19 |
-
<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="
|
21 |
<compatible/>
|
22 |
<dependencies><required><php><min>5.3.0</min><max>6.0.0</max></php></required></dependencies>
|
23 |
</package>
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>Peerius_Connect</name>
|
4 |
+
<version>1.0.7</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>
|
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:
|
11 |

|
12 |
+
Creates a feed containing product and category information from your site catalogue.
|
13 |
+
Adds a tracking script that allows Peerius to track user behaviour on your site.
|
14 |
+
Renders recommendations that you enable on pre-configured pages.
|
15 |
</description>
|
16 |
+
<notes>Fixed p:recommended attribute in feed to include SKUs instead of magento ids.</notes>
|
17 |
<authors><author><name>Peerius</name><user>Peerius</user><email>extensions@peerius.com</email></author></authors>
|
18 |
+
<date>2016-01-15</date>
|
19 |
+
<time>15:03:51</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="dc187f312b64fa7db93e34bf40291773"/></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="41c2c55bc80a1291c49080cdd533d86b"/></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"/></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></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>
|