Version Notes
* Edit A/B test processing.
Download this release
Release Info
Developer | Favizone |
Extension | Favizone_Recommender |
Version | 1.0.7 |
Comparing to | |
See all releases |
Code changes from version 1.0.6 to 1.0.7
- app/code/community/Favizone/Recommender/Block/Adminhtml/AdminConfig.php +5 -4
- app/code/community/Favizone/Recommender/Helper/Category.php +2 -2
- app/code/community/Favizone/Recommender/Helper/Common.php +10 -14
- app/code/community/Favizone/Recommender/Helper/Data.php +0 -1
- app/code/community/Favizone/Recommender/Helper/Export.php +41 -0
- app/code/community/Favizone/Recommender/Helper/Product.php +87 -51
- app/code/community/Favizone/Recommender/Model/Meta/Product.php +232 -1
- app/code/community/Favizone/Recommender/Model/Observer.php +15 -9
- app/code/community/Favizone/Recommender/Model/Product.php +8 -2
- app/code/community/Favizone/Recommender/Model/Resource/Product/Collection.php +12 -0
- app/code/community/Favizone/Recommender/controllers/Adminhtml/FavizoneController.php +22 -2
- app/code/community/Favizone/Recommender/controllers/IndexController.php +3 -1
- app/code/community/Favizone/Recommender/etc/config.xml +1 -1
- app/design/adminhtml/default/default/template/favizonerecommender/adminconfig.phtml +1 -1
- package.xml +5 -5
app/code/community/Favizone/Recommender/Block/Adminhtml/AdminConfig.php
CHANGED
@@ -31,9 +31,9 @@ class Favizone_Recommender_Block_Adminhtml_AdminConfig extends Mage_Adminhtml_Bl
|
|
31 |
*/
|
32 |
public function getAbTest()
|
33 |
{
|
34 |
-
$
|
35 |
-
|
36 |
-
|
37 |
}
|
38 |
|
39 |
/**
|
@@ -58,7 +58,8 @@ class Favizone_Recommender_Block_Adminhtml_AdminConfig extends Mage_Adminhtml_Bl
|
|
58 |
$store = Favizone_Recommender_Block_Common::getSelectedStore();
|
59 |
if(isset($store)){
|
60 |
$store_data = Mage::getModel('favizone_recommender/accessKey')->load($store->getId(), 'store_id');
|
61 |
-
|
|
|
62 |
}
|
63 |
return false;
|
64 |
}
|
31 |
*/
|
32 |
public function getAbTest()
|
33 |
{
|
34 |
+
$store = Favizone_Recommender_Block_Common::getSelectedStore();
|
35 |
+
$element = Mage::helper('favizone_recommender/common')->getStoreInfo($store->getId());
|
36 |
+
return $element->getAbTest();
|
37 |
}
|
38 |
|
39 |
/**
|
58 |
$store = Favizone_Recommender_Block_Common::getSelectedStore();
|
59 |
if(isset($store)){
|
60 |
$store_data = Mage::getModel('favizone_recommender/accessKey')->load($store->getId(), 'store_id');
|
61 |
+
$key_data = $store_data->getData();
|
62 |
+
return (!empty($key_data));
|
63 |
}
|
64 |
return false;
|
65 |
}
|
app/code/community/Favizone/Recommender/Helper/Category.php
CHANGED
@@ -68,7 +68,6 @@ class Favizone_Recommender_Helper_Category extends Mage_Core_Helper_Abstract
|
|
68 |
"key"=>$access_key,
|
69 |
"categories"=>$this ->getAllCategories($store_id)
|
70 |
);
|
71 |
-
|
72 |
$sender->postRequest($data->getCategoryUrl(), $data_to_send);
|
73 |
}
|
74 |
|
@@ -83,6 +82,7 @@ class Favizone_Recommender_Helper_Category extends Mage_Core_Helper_Abstract
|
|
83 |
$rootCategoryId = Mage::app()->getStore($store_id)->getRootCategoryId();
|
84 |
$categoriesCollection = Mage::getModel('catalog/category')
|
85 |
->getCollection()
|
|
|
86 |
->addFieldToFilter('is_active', 1)
|
87 |
->addAttributeToFilter('path', array('like' => "1/{$rootCategoryId}/%"))
|
88 |
->addAttributeToSelect('*');
|
@@ -106,7 +106,7 @@ class Favizone_Recommender_Helper_Category extends Mage_Core_Helper_Abstract
|
|
106 |
}
|
107 |
|
108 |
//Root category
|
109 |
-
$rootCategory = Mage::getModel('catalog/category')->load($rootCategoryId);
|
110 |
array_push($categories, array(
|
111 |
"idLang"=>$store_id,
|
112 |
"isoCode"=>$isoCode,
|
68 |
"key"=>$access_key,
|
69 |
"categories"=>$this ->getAllCategories($store_id)
|
70 |
);
|
|
|
71 |
$sender->postRequest($data->getCategoryUrl(), $data_to_send);
|
72 |
}
|
73 |
|
82 |
$rootCategoryId = Mage::app()->getStore($store_id)->getRootCategoryId();
|
83 |
$categoriesCollection = Mage::getModel('catalog/category')
|
84 |
->getCollection()
|
85 |
+
->setStore($store_id)
|
86 |
->addFieldToFilter('is_active', 1)
|
87 |
->addAttributeToFilter('path', array('like' => "1/{$rootCategoryId}/%"))
|
88 |
->addAttributeToSelect('*');
|
106 |
}
|
107 |
|
108 |
//Root category
|
109 |
+
$rootCategory = Mage::getModel('catalog/category')->setStoreId($store_id)->load($rootCategoryId);
|
110 |
array_push($categories, array(
|
111 |
"idLang"=>$store_id,
|
112 |
"isoCode"=>$isoCode,
|
app/code/community/Favizone/Recommender/Helper/Common.php
CHANGED
@@ -31,8 +31,8 @@ class Favizone_Recommender_Helper_Common extends Mage_Core_Helper_Abstract
|
|
31 |
$store = Mage::app()->getStore();
|
32 |
$store_id = $store->getId();
|
33 |
}
|
34 |
-
|
35 |
-
if($cookie->get('favizone_connection_identifier_'.$store_id) && !empty($
|
36 |
return $cookie->get('favizone_connection_identifier_'.$store_id);
|
37 |
return "anonymous";
|
38 |
}
|
@@ -221,7 +221,8 @@ class Favizone_Recommender_Helper_Common extends Mage_Core_Helper_Abstract
|
|
221 |
public function validateContext(){
|
222 |
|
223 |
$store = $this->getStoreInfo( Mage::app()->getStore()->getId());
|
224 |
-
|
|
|
225 |
return true;
|
226 |
}
|
227 |
return false;
|
@@ -246,8 +247,8 @@ class Favizone_Recommender_Helper_Common extends Mage_Core_Helper_Abstract
|
|
246 |
$cookie->delete('favizone_preview');
|
247 |
return false;
|
248 |
}
|
249 |
-
|
250 |
-
if(!empty($
|
251 |
return true;
|
252 |
|
253 |
return false;
|
@@ -309,7 +310,6 @@ class Favizone_Recommender_Helper_Common extends Mage_Core_Helper_Abstract
|
|
309 |
$sender->postRequest($data->getInitABTestUrl(), $data_to_send);
|
310 |
else
|
311 |
$sender->postRequest($data->getEndABTestUrl(), $data_to_send);
|
312 |
-
|
313 |
}
|
314 |
|
315 |
|
@@ -320,13 +320,9 @@ class Favizone_Recommender_Helper_Common extends Mage_Core_Helper_Abstract
|
|
320 |
* @return Array() the categories list
|
321 |
*/
|
322 |
public function resetData($store_id){
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
$
|
327 |
-
$transaction->commit();
|
328 |
-
} catch (Exception $e) {
|
329 |
-
$transaction->rollBack(); // if anything goes wrong, this will undo all changes you made to your database
|
330 |
-
}
|
331 |
}
|
332 |
}
|
31 |
$store = Mage::app()->getStore();
|
32 |
$store_id = $store->getId();
|
33 |
}
|
34 |
+
$cookie_data = $cookie->get('favizone_connection_identifier_'.$store_id);
|
35 |
+
if($cookie->get('favizone_connection_identifier_'.$store_id) && !empty($cookie_data))
|
36 |
return $cookie->get('favizone_connection_identifier_'.$store_id);
|
37 |
return "anonymous";
|
38 |
}
|
221 |
public function validateContext(){
|
222 |
|
223 |
$store = $this->getStoreInfo( Mage::app()->getStore()->getId());
|
224 |
+
$store_data = $store->getData();
|
225 |
+
if(!empty($store_data)){
|
226 |
return true;
|
227 |
}
|
228 |
return false;
|
247 |
$cookie->delete('favizone_preview');
|
248 |
return false;
|
249 |
}
|
250 |
+
$preview_data = $cookie->get('favizone_preview');
|
251 |
+
if(!empty($preview_data))
|
252 |
return true;
|
253 |
|
254 |
return false;
|
310 |
$sender->postRequest($data->getInitABTestUrl(), $data_to_send);
|
311 |
else
|
312 |
$sender->postRequest($data->getEndABTestUrl(), $data_to_send);
|
|
|
313 |
}
|
314 |
|
315 |
|
320 |
* @return Array() the categories list
|
321 |
*/
|
322 |
public function resetData($store_id){
|
323 |
+
|
324 |
+
$element = $this->getStoreInfo($store_id);
|
325 |
+
if($element)
|
326 |
+
$element->delete();
|
|
|
|
|
|
|
|
|
327 |
}
|
328 |
}
|
app/code/community/Favizone/Recommender/Helper/Data.php
CHANGED
@@ -17,7 +17,6 @@
|
|
17 |
class Favizone_Recommender_Helper_Data extends Mage_Core_Helper_Abstract
|
18 |
|
19 |
{
|
20 |
-
|
21 |
private $host = "https://api.favizone.com";
|
22 |
private $accountUrl = "/user/add-account";
|
23 |
private $initOrderUrl = "/order/init";
|
17 |
class Favizone_Recommender_Helper_Data extends Mage_Core_Helper_Abstract
|
18 |
|
19 |
{
|
|
|
20 |
private $host = "https://api.favizone.com";
|
21 |
private $accountUrl = "/user/add-account";
|
22 |
private $initOrderUrl = "/order/init";
|
app/code/community/Favizone/Recommender/Helper/Export.php
ADDED
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* 2016 Favizone Solutions Ltd
|
4 |
+
*
|
5 |
+
*
|
6 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
7 |
+
* versions in the future. If you wish to customize Magento for your
|
8 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
9 |
+
*
|
10 |
+
*
|
11 |
+
* @category Favizone
|
12 |
+
* @package Favizone_Recommender
|
13 |
+
* @author Favizone Solutions Ltd <contact@favizone.com>
|
14 |
+
* @copyright 2015-2016 Favizone Solutions Ltd
|
15 |
+
*
|
16 |
+
*/
|
17 |
+
class Favizone_Recommender_Helper_Export extends Mage_Core_Helper_Abstract
|
18 |
+
{
|
19 |
+
|
20 |
+
/**
|
21 |
+
* @param $store
|
22 |
+
* @param $product_collection
|
23 |
+
*/
|
24 |
+
public function exportDataToCsv($store, $product_collection) {
|
25 |
+
|
26 |
+
$fopen = fopen('var/export/favizone_products_catalog_'.$store->getId().'_'.$store->getName().'.csv', 'w');
|
27 |
+
$csvHeader = array("id_shop","identifier","reference", "description",
|
28 |
+
"shortDescription","price","wholesale_price","cover",
|
29 |
+
"currency","url","stock","available_for_order",
|
30 |
+
"active","brand","published_date",
|
31 |
+
"categoriesNames","categories","tags",
|
32 |
+
"lang","title","isNew","isNew_from_date","isNew_to_date",
|
33 |
+
"isReduced","reduction_type","price_without_reduction",
|
34 |
+
"reduction","reduction_from_date","reduction_expiry_date","reduction_tax",
|
35 |
+
"hasDeclination","facets");
|
36 |
+
|
37 |
+
fputcsv( $fopen , $csvHeader,",");
|
38 |
+
fwrite($fopen, $product_collection);
|
39 |
+
fclose($fopen);
|
40 |
+
}
|
41 |
+
}
|
app/code/community/Favizone/Recommender/Helper/Product.php
CHANGED
@@ -19,7 +19,7 @@ class Favizone_Recommender_Helper_Product extends Mage_Core_Helper_Abstract
|
|
19 |
/**
|
20 |
* @var int the limit of items to fetch.
|
21 |
*/
|
22 |
-
public $limit =
|
23 |
|
24 |
/**
|
25 |
* @var int the offset of items to fetch.
|
@@ -33,29 +33,42 @@ class Favizone_Recommender_Helper_Product extends Mage_Core_Helper_Abstract
|
|
33 |
|
34 |
$init_done = false;
|
35 |
$number_products= $this->getCountAvailableProducts( $store->getId());
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
|
56 |
return "done";
|
57 |
}
|
58 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
59 |
/**
|
60 |
* Sends product's event data
|
61 |
*
|
@@ -104,24 +117,47 @@ class Favizone_Recommender_Helper_Product extends Mage_Core_Helper_Abstract
|
|
104 |
* gets paginated products data
|
105 |
*
|
106 |
*/
|
107 |
-
protected function getPaginatedProducts($store_id){
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
125 |
|
126 |
|
127 |
return $products;
|
@@ -130,19 +166,19 @@ class Favizone_Recommender_Helper_Product extends Mage_Core_Helper_Abstract
|
|
130 |
/**
|
131 |
* Gets all available products number
|
132 |
*/
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
}
|
147 |
|
148 |
|
19 |
/**
|
20 |
* @var int the limit of items to fetch.
|
21 |
*/
|
22 |
+
public $limit = 500;
|
23 |
|
24 |
/**
|
25 |
* @var int the offset of items to fetch.
|
33 |
|
34 |
$init_done = false;
|
35 |
$number_products= $this->getCountAvailableProducts( $store->getId());
|
36 |
+
$pagination = $number_products/$this->limit;
|
37 |
+
$pagination = (int)$pagination;
|
38 |
+
if($number_products%$this->limit>0)
|
39 |
+
$pagination += 1;
|
40 |
+
$meta = Mage::getModel('favizone_recommender/meta_product');
|
41 |
+
/** Sending paginated products data **/
|
42 |
+
while($this->offset <= $pagination){
|
43 |
+
$products_collection = array();
|
44 |
+
foreach ($this->getPaginatedProducts($store->getId()) as $product){
|
45 |
+
|
46 |
+
$favizone_product= $meta->loadProductData($product, $store);
|
47 |
+
array_push($products_collection, $favizone_product);
|
48 |
+
}
|
49 |
+
|
50 |
+
$this->offset += 1;
|
51 |
+
if($this->offset > $pagination)
|
52 |
+
$init_done = true;
|
53 |
+
$this -> sendInitProductData($products_collection, $store->getId(), $init_done);
|
54 |
+
}
|
55 |
|
56 |
return "done";
|
57 |
}
|
58 |
|
59 |
+
public function exportProducts($store, $limit, $offset){
|
60 |
+
|
61 |
+
$meta = Mage::getModel('favizone_recommender/meta_product');
|
62 |
+
//$products_collection = array();
|
63 |
+
$products_collection = "";
|
64 |
+
foreach ($this->getPaginatedProducts($store->getId(), $limit, $offset) as $product){
|
65 |
+
$favizone_product= $meta->loadProductDataToCsv($product, $store);
|
66 |
+
//array_push($products_collection, implode(",", $favizone_product));
|
67 |
+
$products_collection .= $favizone_product."\r\n";
|
68 |
+
}
|
69 |
+
return $products_collection;
|
70 |
+
}
|
71 |
+
|
72 |
/**
|
73 |
* Sends product's event data
|
74 |
*
|
117 |
* gets paginated products data
|
118 |
*
|
119 |
*/
|
120 |
+
protected function getPaginatedProducts($store_id , $limitProducts = null, $offsetProducts = null){
|
121 |
+
if($limitProducts == null){
|
122 |
+
$limitProducts = $this->limit;
|
123 |
+
}
|
124 |
+
if($offsetProducts == null){
|
125 |
+
$offsetProducts = $this->offset;
|
126 |
+
}
|
127 |
+
$collection = Mage::getModel('favizone_recommender/product')->getCollection();
|
128 |
+
$products = $collection
|
129 |
+
->setStore($store_id)
|
130 |
+
->addStoreFilter($store_id)
|
131 |
+
->addAttributeToSelect('*')
|
132 |
+
->addAttributeToFilter(
|
133 |
+
'status', array(
|
134 |
+
'eq' => Mage_Catalog_Model_Product_Status::STATUS_ENABLED
|
135 |
+
)
|
136 |
+
)
|
137 |
+
->addFieldToFilter(
|
138 |
+
'visibility',
|
139 |
+
Mage_Catalog_Model_Product_Visibility::VISIBILITY_BOTH
|
140 |
+
)
|
141 |
+
->addUrlRewrite()
|
142 |
+
->setPageSize($limitProducts)
|
143 |
+
->setCurPage($offsetProducts);
|
144 |
+
|
145 |
+
/* $products = Mage::getResourceModel('catalog/product_collection')
|
146 |
+
->setStoreId($store_id)
|
147 |
+
->addAttributeToSelect('*')
|
148 |
+
->addAttributeToFilter(
|
149 |
+
'status', array(
|
150 |
+
'eq' => Mage_Catalog_Model_Product_Status::STATUS_ENABLED
|
151 |
+
)
|
152 |
+
)
|
153 |
+
->addFieldToFilter(
|
154 |
+
'visibility',
|
155 |
+
Mage_Catalog_Model_Product_Visibility::VISIBILITY_BOTH
|
156 |
+
)
|
157 |
+
|
158 |
+
->addUrlRewrite()
|
159 |
+
->setPageSize($limitProducts)
|
160 |
+
->setCurPage($offsetProducts);*/
|
161 |
|
162 |
|
163 |
return $products;
|
166 |
/**
|
167 |
* Gets all available products number
|
168 |
*/
|
169 |
+
public function getCountAvailableProducts($store_id){
|
170 |
+
|
171 |
+
$collection = Mage::getModel('favizone_recommender/product')->getCollection();
|
172 |
+
return $collection->addStoreFilter($store_id)
|
173 |
+
->addAttributeToFilter(
|
174 |
+
'status', array(
|
175 |
+
'eq' => Mage_Catalog_Model_Product_Status::STATUS_ENABLED
|
176 |
+
)
|
177 |
+
)
|
178 |
+
->addFieldToFilter(
|
179 |
+
'visibility',
|
180 |
+
Mage_Catalog_Model_Product_Visibility::VISIBILITY_BOTH
|
181 |
+
)->count();
|
182 |
}
|
183 |
|
184 |
|
app/code/community/Favizone/Recommender/Model/Meta/Product.php
CHANGED
@@ -115,7 +115,8 @@ class Favizone_Recommender_Model_Meta_Product extends Mage_Core_Model_Abstract{
|
|
115 |
}
|
116 |
}
|
117 |
$product_rule = $this->getProductRule($product, $store);
|
118 |
-
|
|
|
119 |
|
120 |
$product_data['isReduced'] = true;
|
121 |
$product_data['reduction_type'] = 'amount';
|
@@ -209,6 +210,236 @@ class Favizone_Recommender_Model_Meta_Product extends Mage_Core_Model_Abstract{
|
|
209 |
return $product_data;
|
210 |
}
|
211 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
212 |
protected function getProductPriceRule($product, $store){
|
213 |
$discounted_price = Mage::getResourceModel('catalogrule/rule')->getRulePrice(
|
214 |
Mage::app()->getLocale()->storeTimeStamp($store->getId()),
|
115 |
}
|
116 |
}
|
117 |
$product_rule = $this->getProductRule($product, $store);
|
118 |
+
$special_price = $product->getSpecialPrice();
|
119 |
+
if(!is_null($special_price) && !empty($special_price)){
|
120 |
|
121 |
$product_data['isReduced'] = true;
|
122 |
$product_data['reduction_type'] = 'amount';
|
210 |
return $product_data;
|
211 |
}
|
212 |
|
213 |
+
public function loadProductDataToCsv(Mage_Catalog_Model_Product $product, Mage_Core_Model_Store $store, $wholeSale = true){
|
214 |
+
|
215 |
+
$product_data = array();
|
216 |
+
$utcTz = new DateTimeZone("UTC");
|
217 |
+
|
218 |
+
//Store identifier
|
219 |
+
array_push($product_data, $store->getId());
|
220 |
+
|
221 |
+
//product's identifier
|
222 |
+
array_push($product_data, $product->getId());
|
223 |
+
|
224 |
+
//product's reference
|
225 |
+
array_push($product_data, $product->getSku());
|
226 |
+
|
227 |
+
//description
|
228 |
+
$description = strip_tags($product->getDescription());
|
229 |
+
$description = str_replace(","," ", $description);
|
230 |
+
$description = str_replace('"'," ", $description);
|
231 |
+
array_push($product_data, $description);
|
232 |
+
|
233 |
+
//short description
|
234 |
+
$short_description = strip_tags($product->getShortDescription());
|
235 |
+
$short_description = str_replace(","," ", $short_description);
|
236 |
+
$short_description = str_replace('"'," ", $short_description);
|
237 |
+
array_push($product_data, $short_description);
|
238 |
+
|
239 |
+
//Price
|
240 |
+
array_push($product_data,$this->getProductPrice($product));
|
241 |
+
|
242 |
+
//wholesale
|
243 |
+
if($wholeSale) {
|
244 |
+
$wholesalePrice = $this->getProductWholeSalePrice($product, $store);
|
245 |
+
if(!is_null($wholesalePrice))
|
246 |
+
array_push($product_data,(float)$wholesalePrice);
|
247 |
+
else
|
248 |
+
array_push($product_data,"");
|
249 |
+
}
|
250 |
+
//Cover image
|
251 |
+
array_push($product_data, $this->getProductImageUrl($product, $store));
|
252 |
+
|
253 |
+
//Currency
|
254 |
+
array_push($product_data, $store->getCurrentCurrencyCode());
|
255 |
+
|
256 |
+
//Url
|
257 |
+
$product_url = $product->getUrlInStore(array('_ignore_category' => true, '_store' => $store->getCode(),));
|
258 |
+
array_push($product_data, $product_url);
|
259 |
+
|
260 |
+
|
261 |
+
//Is product is in stock
|
262 |
+
//$product_data['stock'] = $product->isAvailable();
|
263 |
+
$product_stock = "false";
|
264 |
+
if( $product->getStockItem()->getQty()>0)
|
265 |
+
$product_stock = "true";
|
266 |
+
array_push($product_data, $product_stock);
|
267 |
+
|
268 |
+
//If product is available for sale
|
269 |
+
$available_for_order = "false";
|
270 |
+
if($product->isSalable()==1 || $product->isSalable()=="1"||$product->isSalable()==true||$product->isSalable()=="true")
|
271 |
+
$available_for_order = "true" ;
|
272 |
+
array_push($product_data, $available_for_order);
|
273 |
+
|
274 |
+
//Is product active
|
275 |
+
$product_active = ($product->getStatus() == Mage_Catalog_Model_Product_Status::STATUS_ENABLED)? 'true' : 'false';;
|
276 |
+
array_push($product_data, $product_active);
|
277 |
+
|
278 |
+
//Manufacturer
|
279 |
+
if ($product->hasData('manufacturer'))
|
280 |
+
array_push($product_data, $product->getAttributeText('manufacturer'));
|
281 |
+
else
|
282 |
+
array_push($product_data, "");
|
283 |
+
|
284 |
+
if ($product->hasData('created_at')) {
|
285 |
+
array_push($product_data, $product->getData('created_at'));
|
286 |
+
} else
|
287 |
+
array_push($product_data, "");
|
288 |
+
|
289 |
+
//Categories
|
290 |
+
$categories = $this->getProductCategories($product);
|
291 |
+
array_push($product_data, implode(";", $categories['categories_names']));
|
292 |
+
array_push($product_data, implode(";", $categories['categories_ids']));
|
293 |
+
|
294 |
+
//Tags
|
295 |
+
array_push($product_data, implode(";", $this ->getProductTags($product, $store)));
|
296 |
+
|
297 |
+
//Default language
|
298 |
+
$product_lang = substr(Mage::getStoreConfig('general/locale/code', $store->getId()),0,2);
|
299 |
+
array_push($product_data, $product_lang);
|
300 |
+
|
301 |
+
//Product's names
|
302 |
+
array_push($product_data, $product->getName());
|
303 |
+
|
304 |
+
$product_new = $this->isProductNew($product)? "true":"false";
|
305 |
+
array_push($product_data, $product_new);
|
306 |
+
if($product_new){
|
307 |
+
if($product->getNewsFromDate()){
|
308 |
+
$newFromDate = (new DateTime($product->getNewsFromDate()))->setTimezone($utcTz)->format(self::DATE_FORMAT) ;
|
309 |
+
array_push($product_data, $newFromDate);
|
310 |
+
} else {
|
311 |
+
array_push($product_data, "");
|
312 |
+
}
|
313 |
+
if($product->getNewsToDate()){
|
314 |
+
$newToDate = (new DateTime( $product->getNewsToDate()))->setTimezone($utcTz)->format(self::DATE_FORMAT);
|
315 |
+
array_push($product_data, $newToDate);
|
316 |
+
} else{
|
317 |
+
array_push($product_data, "");
|
318 |
+
}
|
319 |
+
}
|
320 |
+
$product_rule = $this->getProductRule($product, $store);
|
321 |
+
$product_reduced = false;
|
322 |
+
$special_price = $product->getSpecialPrice();
|
323 |
+
if(!is_null($product->getSpecialPrice()) && !empty($special_price)){
|
324 |
+
|
325 |
+
$product_reduced = true;
|
326 |
+
$product_reduction_type = 'amount';
|
327 |
+
//replace old price
|
328 |
+
$product_reduction_price = Mage::helper('tax')
|
329 |
+
->getPrice($product, $product->getSpecialPrice());
|
330 |
+
$product_price_without_reduction =Mage::helper('tax')
|
331 |
+
->getPrice($product, $product->getPrice());
|
332 |
+
$product_reduction = $product_price_without_reduction - $product_reduction_price;
|
333 |
+
|
334 |
+
if($product->getSpecialFromDate()){
|
335 |
+
|
336 |
+
$product_reduction_from_date = (new DateTime($product->getSpecialFromDate()))->setTimezone($utcTz)->format(self::DATE_FORMAT);
|
337 |
+
}
|
338 |
+
|
339 |
+
if($product->getSpecialToDate()){
|
340 |
+
|
341 |
+
$product_reduction_expiry_date = (new DateTime($product->getSpecialToDate()))->setTimezone($utcTz)->format(self::DATE_FORMAT);
|
342 |
+
}
|
343 |
+
|
344 |
+
$product_reduction_tax = "true";//TTC
|
345 |
+
}else{
|
346 |
+
if(count($product_rule)>0){
|
347 |
+
|
348 |
+
$product_rule = $product_rule[0];
|
349 |
+
$product_reduced = true;
|
350 |
+
$product_reduction = $product_rule ['action_amount'];
|
351 |
+
$product_reduction_type = 'amount';
|
352 |
+
if($product_rule ['action_amount']=='by_percent'){
|
353 |
+
$product_reduction_type = 'percentage';
|
354 |
+
}
|
355 |
+
if($product_rule['from_time'] != 0 && $product_rule['from_time'] != '0'){
|
356 |
+
$from_time = new DateTime('@'.$product_rule['from_time']);
|
357 |
+
$product_reduction_from_date = $from_time->setTimezone($utcTz)->format(self::DATE_FORMAT);
|
358 |
+
}
|
359 |
+
if($product_rule['to_time'] != 0 && $product_rule['to_time'] != '0'){
|
360 |
+
$to_date = new DateTime('@'.$product_rule['to_time']);
|
361 |
+
$product_reduction_expiry_date = $to_date->setTimezone($utcTz)->format(self::DATE_FORMAT);
|
362 |
+
}
|
363 |
+
|
364 |
+
$product_reduction_tax = "true";//TTC
|
365 |
+
$product_price_without_reduction = Mage::helper('tax')
|
366 |
+
->getPrice($product, $product->getPrice());
|
367 |
+
|
368 |
+
$product_reduction_price = $this->getProductPriceRule($product, $store);
|
369 |
+
}
|
370 |
+
}
|
371 |
+
array_push($product_data, $product_reduced?"true":"false");
|
372 |
+
if($product_reduced){
|
373 |
+
array_push($product_data, $product_reduction_type);
|
374 |
+
array_push($product_data, $product_price_without_reduction);
|
375 |
+
array_push($product_data, $product_reduction);
|
376 |
+
if(isset($product_reduction_from_date))
|
377 |
+
array_push($product_data, $product_reduction_from_date);
|
378 |
+
else
|
379 |
+
array_push($product_data, "");
|
380 |
+
if(isset($product_reduction_expiry_date))
|
381 |
+
array_push($product_data, $product_reduction_expiry_date);
|
382 |
+
else
|
383 |
+
array_push($product_data, "");
|
384 |
+
array_push($product_data, $product_reduction_tax);
|
385 |
+
|
386 |
+
//replace old price
|
387 |
+
} else{
|
388 |
+
foreach (range(1, 6) as $index) {
|
389 |
+
array_push($product_data, "");
|
390 |
+
}
|
391 |
+
}
|
392 |
+
|
393 |
+
//product's facets
|
394 |
+
$facets = array();
|
395 |
+
$attributes = Mage::getModel('catalog/product_attribute_api')->items($product->getAttributeSetId());
|
396 |
+
$notFacetAttributes = Mage::helper('favizone_recommender/data')->getAttributes();
|
397 |
+
foreach($attributes as $_attribute){
|
398 |
+
|
399 |
+
if(!in_array($_attribute['code'], $notFacetAttributes)){
|
400 |
+
if($product->getData($_attribute['code'])){
|
401 |
+
if(!is_a($product->getData($_attribute['code']), 'array')) {
|
402 |
+
$attribute = Mage::getSingleton('eav/config')->getAttribute(Mage_Catalog_Model_Product::ENTITY, $_attribute['code']);
|
403 |
+
|
404 |
+
if($_attribute['type']== "textarea" || $_attribute['type']== "textfield")
|
405 |
+
$facets[$attribute->getFrontend()->getLabel()] = $product->getData($_attribute['code']);
|
406 |
+
else
|
407 |
+
$facets[$attribute->getFrontend()->getLabel()] = $product->getAttributeText($_attribute['code']);
|
408 |
+
}
|
409 |
+
}
|
410 |
+
}
|
411 |
+
}
|
412 |
+
if($product->getTypeId() == "simple")
|
413 |
+
$product_has_declination = "false";
|
414 |
+
else
|
415 |
+
$product_has_declination = "true";
|
416 |
+
array_push($product_data, $product_has_declination);
|
417 |
+
|
418 |
+
if ($product->getData('type_id') == "configurable"){
|
419 |
+
//get the configurable data from the product
|
420 |
+
$config = $product->getTypeInstance(true);
|
421 |
+
$configAttributes = array();
|
422 |
+
//loop through the attributes
|
423 |
+
foreach($config->getConfigurableAttributesAsArray($product) as $attributes)
|
424 |
+
{
|
425 |
+
$configAttributes[$attributes['store_label']] = array();
|
426 |
+
foreach($attributes['values'] as $value){
|
427 |
+
array_push($configAttributes[$attributes['store_label']], $value['store_label']);
|
428 |
+
}
|
429 |
+
}
|
430 |
+
$facets = array_merge($facets, $configAttributes);
|
431 |
+
}
|
432 |
+
$facets = json_encode($facets);
|
433 |
+
$facets = str_replace('"', '""', $facets);
|
434 |
+
array_push($product_data, $facets);
|
435 |
+
|
436 |
+
$product_structure = "";
|
437 |
+
foreach ($product_data as $p) {
|
438 |
+
$product_structure .= '"'.$p.'",';
|
439 |
+
}
|
440 |
+
return $product_structure;
|
441 |
+
}
|
442 |
+
|
443 |
protected function getProductPriceRule($product, $store){
|
444 |
$discounted_price = Mage::getResourceModel('catalogrule/rule')->getRulePrice(
|
445 |
Mage::app()->getLocale()->storeTimeStamp($store->getId()),
|
app/code/community/Favizone/Recommender/Model/Observer.php
CHANGED
@@ -37,8 +37,8 @@ class Favizone_Recommender_Model_Observer
|
|
37 |
$meta = Mage::getModel('favizone_recommender/meta_product');
|
38 |
foreach ($product->getStoreIds() as $storeId) {
|
39 |
$store = Mage::app()->getStore($storeId);
|
40 |
-
|
41 |
-
if(!empty(
|
42 |
|
43 |
|
44 |
// Load the product model for this particular store view.
|
@@ -67,7 +67,8 @@ class Favizone_Recommender_Model_Observer
|
|
67 |
/** @var Mage_Catalog_Model_Product $product */
|
68 |
$product = $observer->getEvent()->getProduct();
|
69 |
foreach (Mage::app()->getStores() as $store) {
|
70 |
-
|
|
|
71 |
Mage::helper('favizone_recommender/product')->updateTaggingProductData($product, 'delete', $store->getId());
|
72 |
}
|
73 |
}
|
@@ -85,7 +86,8 @@ class Favizone_Recommender_Model_Observer
|
|
85 |
if (Mage::helper('favizone_recommender')->isModuleEnabled()) {
|
86 |
$category = $observer->getEvent()->getCategory();
|
87 |
foreach ($category->getStoreIds() as $storeId) {
|
88 |
-
|
|
|
89 |
|
90 |
Mage::helper('favizone_recommender/category')->sendCategoryData((int)$category->getId(), 'update', (int)$storeId);
|
91 |
}
|
@@ -103,8 +105,9 @@ class Favizone_Recommender_Model_Observer
|
|
103 |
if (Mage::helper('favizone_recommender')->isModuleEnabled()) {
|
104 |
|
105 |
$category = $observer->getEvent()->getCategory();
|
|
|
106 |
foreach ($category->getStoreIds() as $storeId) {
|
107 |
-
if(!empty(
|
108 |
|
109 |
Mage::helper('favizone_recommender/category')->sendCategoryData($category->getId(), 'delete', $storeId);
|
110 |
}
|
@@ -133,7 +136,8 @@ class Favizone_Recommender_Model_Observer
|
|
133 |
public function sendAddToCartEvent(Varien_Event_Observer $observer){
|
134 |
if (Mage::helper('favizone_recommender')->isModuleEnabled()) {
|
135 |
$store = Mage::app()->getStore();
|
136 |
-
|
|
|
137 |
|
138 |
if (!$store->isAdmin()) {
|
139 |
$item = $observer->getEvent()->getQuoteItem();
|
@@ -161,7 +165,8 @@ class Favizone_Recommender_Model_Observer
|
|
161 |
if (Mage::helper('favizone_recommender')->isModuleEnabled()) {
|
162 |
$order = $observer->getEvent()->getOrder();
|
163 |
$store = Mage::app()->getStore();
|
164 |
-
|
|
|
165 |
|
166 |
Mage::helper('favizone_recommender/order')->sendOrderData($order, $order->getStoreId(), $store->getId());
|
167 |
}
|
@@ -183,9 +188,10 @@ class Favizone_Recommender_Model_Observer
|
|
183 |
$stores = Mage::getModel('core/store')->getCollection()->addFieldToFilter('group_id',$groupId);
|
184 |
$customer = $observer->getEvent()->getCustomer();
|
185 |
foreach($stores as $store) {
|
186 |
-
|
|
|
187 |
if($common_helper->getSessionIdentifier($store->getId()) != "anonymous")
|
188 |
-
|
189 |
}
|
190 |
}
|
191 |
}
|
37 |
$meta = Mage::getModel('favizone_recommender/meta_product');
|
38 |
foreach ($product->getStoreIds() as $storeId) {
|
39 |
$store = Mage::app()->getStore($storeId);
|
40 |
+
$store_data = Mage::helper('favizone_recommender/common')->getStoreInfo($store->getId())->getData();
|
41 |
+
if(!empty($store_data)){
|
42 |
|
43 |
|
44 |
// Load the product model for this particular store view.
|
67 |
/** @var Mage_Catalog_Model_Product $product */
|
68 |
$product = $observer->getEvent()->getProduct();
|
69 |
foreach (Mage::app()->getStores() as $store) {
|
70 |
+
$store_info = Mage::helper('favizone_recommender/common')->getStoreInfo($store->getId())->getData();
|
71 |
+
if(!empty($store_info))
|
72 |
Mage::helper('favizone_recommender/product')->updateTaggingProductData($product, 'delete', $store->getId());
|
73 |
}
|
74 |
}
|
86 |
if (Mage::helper('favizone_recommender')->isModuleEnabled()) {
|
87 |
$category = $observer->getEvent()->getCategory();
|
88 |
foreach ($category->getStoreIds() as $storeId) {
|
89 |
+
$store_info = Mage::helper('favizone_recommender/common')->getStoreInfo($storeId)->getData();
|
90 |
+
if(!empty($store_info)){
|
91 |
|
92 |
Mage::helper('favizone_recommender/category')->sendCategoryData((int)$category->getId(), 'update', (int)$storeId);
|
93 |
}
|
105 |
if (Mage::helper('favizone_recommender')->isModuleEnabled()) {
|
106 |
|
107 |
$category = $observer->getEvent()->getCategory();
|
108 |
+
$store_info = Mage::helper('favizone_recommender/common')->getStoreInfo($storeId)->getData();
|
109 |
foreach ($category->getStoreIds() as $storeId) {
|
110 |
+
if(!empty($store_info)){
|
111 |
|
112 |
Mage::helper('favizone_recommender/category')->sendCategoryData($category->getId(), 'delete', $storeId);
|
113 |
}
|
136 |
public function sendAddToCartEvent(Varien_Event_Observer $observer){
|
137 |
if (Mage::helper('favizone_recommender')->isModuleEnabled()) {
|
138 |
$store = Mage::app()->getStore();
|
139 |
+
$store_info = Mage::helper('favizone_recommender/common')->getStoreInfo($store->getId())->getData();
|
140 |
+
if(!empty($store_info)){
|
141 |
|
142 |
if (!$store->isAdmin()) {
|
143 |
$item = $observer->getEvent()->getQuoteItem();
|
165 |
if (Mage::helper('favizone_recommender')->isModuleEnabled()) {
|
166 |
$order = $observer->getEvent()->getOrder();
|
167 |
$store = Mage::app()->getStore();
|
168 |
+
$store_info = Mage::helper('favizone_recommender/common')->getStoreInfo($order->getStoreId())->getData();
|
169 |
+
if(!empty($store_info)){
|
170 |
|
171 |
Mage::helper('favizone_recommender/order')->sendOrderData($order, $order->getStoreId(), $store->getId());
|
172 |
}
|
188 |
$stores = Mage::getModel('core/store')->getCollection()->addFieldToFilter('group_id',$groupId);
|
189 |
$customer = $observer->getEvent()->getCustomer();
|
190 |
foreach($stores as $store) {
|
191 |
+
$store_info = $common_helper->getStoreInfo($store->getId())->getData();
|
192 |
+
if(!empty($store_info)){
|
193 |
if($common_helper->getSessionIdentifier($store->getId()) != "anonymous")
|
194 |
+
Mage::helper('favizone_recommender/customer')->sendCustomerData($customer->getId(), $store->getId());
|
195 |
}
|
196 |
}
|
197 |
}
|
app/code/community/Favizone/Recommender/Model/Product.php
CHANGED
@@ -14,7 +14,13 @@
|
|
14 |
* @author Favizone Solutions Ltd <contact@favizone.com>
|
15 |
* @copyright 2015-2016 Favizone Solutions Ltd
|
16 |
*/
|
17 |
-
class Favizone_Recommender_Model_Product
|
18 |
{
|
19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
20 |
}
|
14 |
* @author Favizone Solutions Ltd <contact@favizone.com>
|
15 |
* @copyright 2015-2016 Favizone Solutions Ltd
|
16 |
*/
|
17 |
+
class Favizone_Recommender_Model_Product extends Mage_Catalog_Model_Product
|
18 |
{
|
19 |
+
/**
|
20 |
+
* @inheritdoc
|
21 |
+
*/
|
22 |
+
protected function _construct()
|
23 |
+
{
|
24 |
+
$this->_init('favizone_recommender/product');
|
25 |
+
}
|
26 |
}
|
app/code/community/Favizone/Recommender/Model/Resource/Product/Collection.php
ADDED
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Favizone_Recommender_Model_Resource_Product_Collection extends Mage_Catalog_Model_Resource_Product_Collection
|
3 |
+
{
|
4 |
+
/**
|
5 |
+
* @inheritdoc
|
6 |
+
*/
|
7 |
+
public function isEnabledFlat()
|
8 |
+
{
|
9 |
+
// Never use the flat collection.
|
10 |
+
return false;
|
11 |
+
}
|
12 |
+
}
|
app/code/community/Favizone/Recommender/controllers/Adminhtml/FavizoneController.php
CHANGED
@@ -22,7 +22,6 @@ class Favizone_Recommender_Adminhtml_FavizoneController extends Mage_Adminhtml_C
|
|
22 |
*/
|
23 |
public function indexAction()
|
24 |
{
|
25 |
-
$customer = Mage::getModel('customer/customer')->load(135);
|
26 |
if (!Favizone_Recommender_Block_Common::getSelectedStore()) {
|
27 |
// If we are not under a store view, then redirect to the first
|
28 |
// found one because Favizone is configured per store.
|
@@ -69,7 +68,6 @@ class Favizone_Recommender_Adminhtml_FavizoneController extends Mage_Adminhtml_C
|
|
69 |
$element = Mage::helper('favizone_recommender/common')->getStoreInfo($store->getId());
|
70 |
$ab_test_new_status = $this->getRequest()->getParam('ab_test');
|
71 |
$ab_test_old_status = $element->getAbTest();
|
72 |
-
|
73 |
if($ab_test_new_status == 'true'){
|
74 |
if($ab_test_old_status != $ab_test_new_status) {
|
75 |
$element->setAbTest($ab_test_new_status);
|
@@ -113,6 +111,7 @@ class Favizone_Recommender_Adminhtml_FavizoneController extends Mage_Adminhtml_C
|
|
113 |
Mage::helper('favizone_recommender/order')->sendOrdersData($store->getId());
|
114 |
//products
|
115 |
Mage::helper('favizone_recommender/product')->initTaggingProductData($store);
|
|
|
116 |
//categories
|
117 |
Mage::helper('favizone_recommender/category')->sendCategoriesData($store->getId());
|
118 |
}
|
@@ -137,6 +136,7 @@ class Favizone_Recommender_Adminhtml_FavizoneController extends Mage_Adminhtml_C
|
|
137 |
* Reset Extension data
|
138 |
*/
|
139 |
public function resetDataAction(){
|
|
|
140 |
$this->getResponse()->setHeader('Content-type', 'application/json');
|
141 |
$store = Favizone_Recommender_Block_Common::getSelectedStore();
|
142 |
Mage::helper('favizone_recommender/common')->resetData($store->getId());
|
@@ -148,6 +148,26 @@ class Favizone_Recommender_Adminhtml_FavizoneController extends Mage_Adminhtml_C
|
|
148 |
$this->getResponse()->setBody(json_encode($responseData));
|
149 |
}
|
150 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
151 |
/**
|
152 |
* Returns the currently selected store view identifier.
|
153 |
*
|
22 |
*/
|
23 |
public function indexAction()
|
24 |
{
|
|
|
25 |
if (!Favizone_Recommender_Block_Common::getSelectedStore()) {
|
26 |
// If we are not under a store view, then redirect to the first
|
27 |
// found one because Favizone is configured per store.
|
68 |
$element = Mage::helper('favizone_recommender/common')->getStoreInfo($store->getId());
|
69 |
$ab_test_new_status = $this->getRequest()->getParam('ab_test');
|
70 |
$ab_test_old_status = $element->getAbTest();
|
|
|
71 |
if($ab_test_new_status == 'true'){
|
72 |
if($ab_test_old_status != $ab_test_new_status) {
|
73 |
$element->setAbTest($ab_test_new_status);
|
111 |
Mage::helper('favizone_recommender/order')->sendOrdersData($store->getId());
|
112 |
//products
|
113 |
Mage::helper('favizone_recommender/product')->initTaggingProductData($store);
|
114 |
+
|
115 |
//categories
|
116 |
Mage::helper('favizone_recommender/category')->sendCategoriesData($store->getId());
|
117 |
}
|
136 |
* Reset Extension data
|
137 |
*/
|
138 |
public function resetDataAction(){
|
139 |
+
|
140 |
$this->getResponse()->setHeader('Content-type', 'application/json');
|
141 |
$store = Favizone_Recommender_Block_Common::getSelectedStore();
|
142 |
Mage::helper('favizone_recommender/common')->resetData($store->getId());
|
148 |
$this->getResponse()->setBody(json_encode($responseData));
|
149 |
}
|
150 |
|
151 |
+
public function exportProductsToCsv(){
|
152 |
+
$limit = 500;
|
153 |
+
$store = Favizone_Recommender_Block_Common::getSelectedStore();
|
154 |
+
$products_count = Mage::helper('favizone_recommender/product')->getCountAvailableProducts($store->getId()) ;
|
155 |
+
$pagination = (int) ($products_count / $limit);
|
156 |
+
if($products_count%$limit>0)
|
157 |
+
$pagination += 1;
|
158 |
+
//$products_collections = array();
|
159 |
+
$products_collections = "";
|
160 |
+
|
161 |
+
foreach (range(1, $pagination) as $offset) {
|
162 |
+
$products = Mage::helper('favizone_recommender/product')->exportProducts($store, $limit, $offset);
|
163 |
+
// $products_collections = array_merge($products_collections, $products);
|
164 |
+
$products_collections .= $products;
|
165 |
+
}
|
166 |
+
|
167 |
+
Mage::helper('favizone_recommender/export')
|
168 |
+
->exportDataToCsv($store, $products_collections);
|
169 |
+
}
|
170 |
+
|
171 |
/**
|
172 |
* Returns the currently selected store view identifier.
|
173 |
*
|
app/code/community/Favizone/Recommender/controllers/IndexController.php
CHANGED
@@ -19,6 +19,8 @@ class Favizone_Recommender_IndexController extends Mage_Core_Controller_Front_Ac
|
|
19 |
{
|
20 |
public function indexAction()
|
21 |
{
|
22 |
-
|
|
|
|
|
23 |
}
|
24 |
}
|
19 |
{
|
20 |
public function indexAction()
|
21 |
{
|
22 |
+
echo $this->getRequest()->getParam('limit');
|
23 |
+
// echo Mage::app()->getStore()->getId();
|
24 |
+
// echo "Favizone Recommender index";
|
25 |
}
|
26 |
}
|
app/code/community/Favizone/Recommender/etc/config.xml
CHANGED
@@ -26,7 +26,7 @@
|
|
26 |
names, with directory separators replaced by underscores
|
27 |
-->
|
28 |
<Favizone_Recommender>
|
29 |
-
<version>1.0.
|
30 |
</Favizone_Recommender>
|
31 |
</modules>
|
32 |
<global>
|
26 |
names, with directory separators replaced by underscores
|
27 |
-->
|
28 |
<Favizone_Recommender>
|
29 |
+
<version>1.0.7</version>
|
30 |
</Favizone_Recommender>
|
31 |
</modules>
|
32 |
<global>
|
app/design/adminhtml/default/default/template/favizonerecommender/adminconfig.phtml
CHANGED
@@ -56,7 +56,7 @@
|
|
56 |
<?php echo $this->__('Enable A/B Testing');?> </label>
|
57 |
<div class="col-lg-3 ">
|
58 |
<span class="switch prestashop-switch fixed-width-lg">
|
59 |
-
<?php
|
60 |
<input type="radio" name="ab_test" id="ab_test_on" value="true" checked="checked" />
|
61 |
<?php } else { ?>
|
62 |
<input type="radio" name="ab_test" id="ab_test_on" value="true" />
|
56 |
<?php echo $this->__('Enable A/B Testing');?> </label>
|
57 |
<div class="col-lg-3 ">
|
58 |
<span class="switch prestashop-switch fixed-width-lg">
|
59 |
+
<?php if ($this->getAbTest()=="true") { ?>
|
60 |
<input type="radio" name="ab_test" id="ab_test_on" value="true" checked="checked" />
|
61 |
<?php } else { ?>
|
62 |
<input type="radio" name="ab_test" id="ab_test_on" value="true" />
|
package.xml
CHANGED
@@ -1,19 +1,19 @@
|
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>Favizone_Recommender</name>
|
4 |
-
<version>1.0.
|
5 |
<stability>stable</stability>
|
6 |
<license uri="http://opensource.org/licenses/osl-3.0.php">Favizone</license>
|
7 |
<channel>community</channel>
|
8 |
<extends/>
|
9 |
<summary>Personalization for Magento</summary>
|
10 |
<description>Favizone Increase your conversion rate and average order value by delivering your customers personalized product recommendations throughout their shopping journey.e_Recommender</description>
|
11 |
-
<notes>*
|
12 |
</notes>
|
13 |
<authors><author><name>Favizone</name><user>favizone</user><email>contact@favizone.com</email></author></authors>
|
14 |
-
<date>2016-
|
15 |
-
<time>
|
16 |
-
<contents><target name="mageetc"><dir name="modules"><file name="Favizone_Recommender.xml" hash="7457b857a4a6fb30905081c9c87fee60"/></dir></target><target name="magecommunity"><dir name="Favizone"><dir name="Recommender"><dir name="Block"><dir name="Adminhtml"><file name="AdminConfig.php" hash="
|
17 |
<compatible/>
|
18 |
<dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
|
19 |
</package>
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>Favizone_Recommender</name>
|
4 |
+
<version>1.0.7</version>
|
5 |
<stability>stable</stability>
|
6 |
<license uri="http://opensource.org/licenses/osl-3.0.php">Favizone</license>
|
7 |
<channel>community</channel>
|
8 |
<extends/>
|
9 |
<summary>Personalization for Magento</summary>
|
10 |
<description>Favizone Increase your conversion rate and average order value by delivering your customers personalized product recommendations throughout their shopping journey.e_Recommender</description>
|
11 |
+
<notes>* Edit A/B test processing.
|
12 |
</notes>
|
13 |
<authors><author><name>Favizone</name><user>favizone</user><email>contact@favizone.com</email></author></authors>
|
14 |
+
<date>2016-11-18</date>
|
15 |
+
<time>11:04:46</time>
|
16 |
+
<contents><target name="mageetc"><dir name="modules"><file name="Favizone_Recommender.xml" hash="7457b857a4a6fb30905081c9c87fee60"/></dir></target><target name="magecommunity"><dir name="Favizone"><dir name="Recommender"><dir name="Block"><dir name="Adminhtml"><file name="AdminConfig.php" hash="141fcf73ddb9a82818a65021d74a01a8"/></dir><file name="Common.php" hash="e53f8700fcf0fde9353a571d71272547"/><file name="Custom.php" hash="b904e161cc0100d7518f09bec7cf04ac"/><file name="Renderer.php" hash="6e97d9d908b47e7f59b288b35fe3d18d"/><file name="Tracker.php" hash="c099c9ff1e207aa5d0f868bf12434280"/></dir><dir name="Helper"><file name="Account.php" hash="62eda9b2b7bb7db618e117d9ba002b7b"/><file name="Category.php" hash="30cf71f08be4f4ff265652633c2c5876"/><file name="Common.php" hash="062d1cdf8c1403b3a02b9562af761328"/><file name="Customer.php" hash="d964c01b0feee83dd279115deaa8b209"/><file name="Data.php" hash="dc837e04dd9c0ebed5ef6946b909417f"/><file name="Export.php" hash="3f0623bf1ad76991ca5229938d957586"/><file name="Order.php" hash="d4023b65bf902b7ef202b91b7d0629e7"/><file name="Product.php" hash="57451c4180b61aee7cc4530b1e402e22"/><file name="Sender.php" hash="24f9459a7eefcaa5f3a13e90f932dab2"/></dir><dir name="Model"><file name="AccessKey.php" hash="c0fabf3617b346543bcca6f36fe98e1a"/><dir name="Meta"><file name="Customer.php" hash="de62cf990ba2d3b1e83759919f6f9cfc"/><file name="Order.php" hash="9ebb1a57b41bee5db8c3463f241d872f"/><file name="Product.php" hash="871d458c611d563950083a8e40b148d5"/></dir><file name="Observer.php" hash="6347d192cc5fd52aed37d206a5192166"/><file name="Product.php" hash="d480f4a105cba555b23831dbc4a25e1b"/><dir name="Resource"><dir name="AccessKey"><file name="Collection.php" hash="5255134124dc54701b4942cc0c29f018"/></dir><file name="AccessKey.php" hash="5e4d06afae4261e6f7e1da929a3c4d09"/><dir name="Product"><file name="Collection.php" hash="52bed2df792fe0562e3c2e777ffc3767"/></dir><file name="Setup.php" hash="5e0685b4baad75a3e84223fad4c1e3b9"/></dir></dir><dir name="controllers"><dir name="Adminhtml"><file name="FavizoneController.php" hash="c26e28b6650c3150a68ba8bc822bd8c2"/></dir><file name="IndexController.php" hash="d6609e50ac68ad29a3a952bcf6b88ef9"/></dir><dir name="etc"><file name="adminhtml.xml" hash="abe94fe89c2635eae6b0c46c27601982"/><file name="config.xml" hash="731ec78e2ab035f7d70d9da8582e6db4"/></dir><dir name="sql"><dir name="favizone_recommender_setup"><file name="mysql4-install-1.0.0.php" hash="b2b0bf8d6a50ea30808e284fe6e6d956"/><file name="mysql4-upgrade-1.0.0-1.0.3.php" hash="13a8f4614e43b2a65f854e6c51ae3e04"/></dir></dir></dir></dir></target><target name="mageskin"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="favizone"><file name="admin-custom-style.css" hash="f278f55ed46d78600f7613fa4ad494f4"/><file name="font-awesome.min.css" hash="7aa7a0865ce6f38d0e854d3dd4623e3d"/><dir name="fonts"><file name="FontAwesome.otf" hash="87d8ca3ddc57e7d2da6226e480f90457"/><file name="fontawesome-webfont.eot" hash="32400f4e08932a94d8bfd2422702c446"/><file name="fontawesome-webfont.svg" hash="f775f9cca88e21d45bebe185b27c0e5b"/><file name="fontawesome-webfont.ttf" hash="a3de2170e4e9df77161ea5d3f31b2668"/><file name="fontawesome-webfont.woff" hash="a35720c2fed2c7f043bc7e4ffb45e073"/><file name="fontawesome-webfont.woff2" hash="db812d8a70a4e88e888744c1c9a27e89"/></dir></dir><dir name="images"><dir name="favizone"><file name="close.png" hash="8177fd73492c9b00de9d8e39ce518352"/><file name="logo-favizone.png" hash="f4ba18ee390b6080b5660a0102c817e8"/><file name="minimize.png" hash="beff58e92474b2ff1365107c75747e63"/></dir></dir></dir></dir></dir></target><target name="mageweb"><dir name="js"><dir name="favizone"><file name="favizone-auto-appender.js" hash="5d76d6c235b07ee68b73909d1c048a3a"/><file name="favizone-helper.js" hash="ad8fbad529e8e4d803949d860ae67ad8"/><file name="favizone-preview-manager.js" hash="76802c9d3e38cb8ec3c700754d40fd8f"/><file name="favizone-renderer.js" hash="86f672087f479cc113f66bc97227e3aa"/><file name="favizone-tracker.js" hash="dbd2e4d131911b41f220ff880e1df23c"/><file name="internal-sender.js" hash="79f6501b98c3fa279bcaf1bb885e663f"/></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="favizonerecommender.xml" hash="accc4ea6c5ec649f9c990508196399f5"/></dir><dir name="template"><dir name="favizonerecommender"><file name="adminconfig.phtml" hash="98c71b89a37ce684398ecf9fe8f9d651"/></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="favizonerecommender.xml" hash="761e78aad6a8b28baba9ceb008755732"/></dir><dir name="template"><dir name="favizonerecommender"><file name="bottom.phtml" hash="0a4c338723bbdc8753f4536cc69a7284"/><file name="common.phtml" hash="d9f906e6eb81892361b5bd5c0e88b8ed"/><file name="custom.phtml" hash="b4c5c3492a1eca27c59510b642a1f837"/><file name="event.phtml" hash="8da220d74a265c722edfa43f02b21a4e"/><file name="footer.phtml" hash="f080c361ceff1aed3010e9aad9c07251"/><file name="index.phtml" hash="17e341f9b39c20030ce03bced05fd091"/><file name="preview.phtml" hash="c205c5d2ed8dc98877f6d8d0f6a356ac"/><file name="renderer.phtml" hash="b269e1e7f9e4dfd57e6806e581e887f0"/><file name="tracker.phtml" hash="d3e3ee4ebaf6042f37c1366811bbad7f"/></dir></dir></dir></dir></dir></target><target name="magelocale"><dir name="en_US"><file name="Favizone_Recommender.csv" hash="9832f3a28ed8c6af16ddb29d23444131"/></dir><dir name="fr_FR"><file name="Favizone_Recommender.csv" hash="af5908d502a8d2356e86f6a1729a7309"/></dir></target></contents>
|
17 |
<compatible/>
|
18 |
<dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
|
19 |
</package>
|