Version Notes
Kick-start emails have been enabled.
Possibility to disable Lipscore completely for individual stores has been added.
Download this release
Release Info
Developer | Henning Frettem |
Extension | lipscore |
Version | 1.4.0 |
Comparing to | |
See all releases |
Code changes from version 1.3.4 to 1.4.0
- app/code/community/Lipscore/RatingsReviews/Block/Catalog/Product/Reviews.php +0 -0
- app/code/community/Lipscore/RatingsReviews/Block/Catalog/Product/View.php +2 -2
- app/code/community/Lipscore/RatingsReviews/Block/Init.php +12 -8
- app/code/community/Lipscore/RatingsReviews/Block/Purchase/Abstract.php +0 -42
- app/code/community/Lipscore/RatingsReviews/Block/Purchase/Multishipping.php +0 -49
- app/code/community/Lipscore/RatingsReviews/Block/Purchase/Onepage.php +0 -52
- app/code/community/Lipscore/RatingsReviews/Block/Review/Helper.php +0 -0
- app/code/community/Lipscore/RatingsReviews/Block/Review/Single.php +0 -0
- app/code/community/Lipscore/RatingsReviews/Block/Review/Tabtitle.php +0 -0
- app/code/community/Lipscore/RatingsReviews/Block/System/Config/Form/Coupons.php +0 -0
- app/code/community/Lipscore/RatingsReviews/Block/System/Config/Form/Field/Abstract.php +0 -0
- app/code/community/Lipscore/RatingsReviews/Block/System/Config/Form/Field/Apikey.php +6 -7
- app/code/community/Lipscore/RatingsReviews/Block/System/Config/Form/Field/Emailstext.php +0 -0
- app/code/community/Lipscore/RatingsReviews/Block/System/Config/Form/Field/Reminderperiod.php +112 -41
- app/code/community/Lipscore/RatingsReviews/Block/System/Config/Form/Fieldset/Coupons.php +0 -0
- app/code/community/Lipscore/RatingsReviews/Block/System/Config/Form/Fieldset/Dashboardlink.php +1 -1
- app/code/community/Lipscore/RatingsReviews/Helper/Abstract.php +0 -0
- app/code/community/Lipscore/RatingsReviews/Helper/Config.php +1 -1
- app/code/community/Lipscore/RatingsReviews/Helper/Coupon.php +21 -16
- app/code/community/Lipscore/RatingsReviews/Helper/Data.php +0 -0
- app/code/community/Lipscore/RatingsReviews/Helper/Kickstart.php +60 -0
- app/code/community/Lipscore/RatingsReviews/Helper/Locale.php +0 -0
- app/code/community/Lipscore/RatingsReviews/Helper/Module.php +8 -4
- app/code/community/Lipscore/RatingsReviews/Helper/Price.php +0 -0
- app/code/community/Lipscore/RatingsReviews/Helper/Product.php +6 -1
- app/code/community/Lipscore/RatingsReviews/Helper/Purchase.php +6 -31
- app/code/community/Lipscore/RatingsReviews/Helper/Reminder.php +67 -50
- app/code/community/Lipscore/RatingsReviews/Helper/Widget.php +6 -6
- app/code/community/Lipscore/RatingsReviews/Logger.php +18 -0
- app/code/community/Lipscore/RatingsReviews/Model/Api/Request.php +0 -0
- app/code/community/Lipscore/RatingsReviews/Model/Config.php +31 -56
- app/code/community/Lipscore/RatingsReviews/Model/Config/Abstract.php +63 -0
- app/code/community/Lipscore/RatingsReviews/Model/Config/Env.php +0 -0
- app/code/community/Lipscore/RatingsReviews/Model/Config/Kickstart.php +34 -0
- app/code/community/Lipscore/RatingsReviews/Model/Coupon/Generator.php +11 -11
- app/code/community/Lipscore/RatingsReviews/Model/Observer/Abstract.php +29 -2
- app/code/community/Lipscore/RatingsReviews/Model/Observer/Module.php +17 -9
- app/code/community/Lipscore/RatingsReviews/Model/Observer/Order/Status.php +19 -34
- app/code/community/Lipscore/RatingsReviews/Model/Observer/Output.php +6 -45
- app/code/community/Lipscore/RatingsReviews/Model/Purchase/Reminder.php +29 -12
- app/code/community/Lipscore/RatingsReviews/Model/Shop.php +0 -0
- app/code/community/Lipscore/RatingsReviews/Model/System/Config/Backend/Apikey.php +0 -0
- app/code/community/Lipscore/RatingsReviews/Model/System/Config/Backend/Module.php +35 -0
- app/code/community/Lipscore/RatingsReviews/Model/System/Config/Source/Active.php +12 -0
- app/code/community/Lipscore/RatingsReviews/Model/System/Config/Source/Locale.php +0 -0
- app/code/community/Lipscore/RatingsReviews/Model/System/Config/Source/Order/Status.php +0 -30
- app/code/community/Lipscore/RatingsReviews/Model/System/Config/Source/Order/Status/Abstract.php +0 -0
- app/code/community/Lipscore/RatingsReviews/Model/System/Config/Source/Order/Status/Reminder.php +0 -0
- app/code/community/Lipscore/RatingsReviews/Model/System/Config/Source/Order/Status/Reminders.php +0 -0
- app/code/community/Lipscore/RatingsReviews/Model/System/Config/Source/Pricerule.php +0 -0
- app/code/community/Lipscore/RatingsReviews/Model/System/Config/Source/Productattr/Brand.php +0 -0
- app/code/community/Lipscore/RatingsReviews/Model/System/Config/Source/Reminderperiod.php +0 -0
- app/code/community/Lipscore/RatingsReviews/Model/Tracker/Action.php +0 -0
- app/code/community/Lipscore/RatingsReviews/Model/Tracker/Installation.php +0 -0
- app/code/community/Lipscore/RatingsReviews/controllers/Purchases/RemindersController.php +178 -64
- app/code/community/Lipscore/RatingsReviews/data/lipscore_ratingsreviews_setup/data-install-1.2.21.0.php +0 -0
- app/code/community/Lipscore/RatingsReviews/etc/adminhtml.xml +0 -0
- app/code/community/Lipscore/RatingsReviews/etc/config.xml +17 -19
- app/code/community/Lipscore/RatingsReviews/etc/environments/production.xml +0 -0
- app/code/community/Lipscore/RatingsReviews/etc/system.xml +27 -4
- app/design/adminhtml/default/default/layout/lipscore_ratingsreviews.xml +0 -0
- app/design/frontend/base/default/layout/lipscore_ratingsreviews.xml +0 -0
- app/design/frontend/base/default/template/lipscore/init.phtml +1 -1
- app/design/frontend/base/default/template/lipscore/purchase/view.phtml +0 -15
- app/design/frontend/base/default/template/lipscore/rating/view.phtml +2 -2
- app/design/frontend/base/default/template/lipscore/reviews/tab_title.phtml +0 -0
- app/design/frontend/base/default/template/lipscore/reviews/view.phtml +0 -0
- app/design/frontend/base/default/template/lipscore/reviews/view_single.phtml +0 -0
- app/etc/modules/Lipscore_RatingsReviews.xml +0 -0
- package.xml +8 -5
- skin/adminhtml/default/default/js/lipscore.js +182 -11
- skin/adminhtml/default/default/lipscore.css +7 -2
- skin/frontend/base/default/css/lipscore.css +3 -0
- skin/frontend/base/default/js/lipscore.js +0 -0
app/code/community/Lipscore/RatingsReviews/Block/Catalog/Product/Reviews.php
CHANGED
File without changes
|
app/code/community/Lipscore/RatingsReviews/Block/Catalog/Product/View.php
CHANGED
@@ -13,6 +13,6 @@ class Lipscore_RatingsReviews_Block_Catalog_Product_View extends Mage_Catalog_Bl
|
|
13 |
public function getReviewsSummaryHtml(Mage_Catalog_Model_Product $product, $templateType = false,
|
14 |
$displayIfNoReviews = false)
|
15 |
{
|
16 |
-
return parent::getReviewsSummaryHtml($product, 'long',
|
17 |
-
}
|
18 |
}
|
13 |
public function getReviewsSummaryHtml(Mage_Catalog_Model_Product $product, $templateType = false,
|
14 |
$displayIfNoReviews = false)
|
15 |
{
|
16 |
+
return parent::getReviewsSummaryHtml($product, 'long', true);
|
17 |
+
}
|
18 |
}
|
app/code/community/Lipscore/RatingsReviews/Block/Init.php
CHANGED
@@ -6,35 +6,39 @@ class Lipscore_RatingsReviews_Block_Init extends Mage_Core_Block_Template
|
|
6 |
* @var Lipscore_RatingsReviews_Model_Config
|
7 |
*/
|
8 |
protected $_lipscoreConfig;
|
9 |
-
|
10 |
/**
|
11 |
* @var Lipscore_RatingsReviews_Model_Config_Env
|
12 |
*/
|
13 |
protected $_envConfig;
|
14 |
-
|
|
|
|
|
15 |
public function __construct()
|
16 |
{
|
17 |
$this->_lipscoreConfig = Mage::getModel('lipscore_ratingsreviews/config');
|
18 |
$this->_envConfig = Mage::getModel('lipscore_ratingsreviews/config_env');
|
19 |
-
|
|
|
20 |
parent::_construct();
|
21 |
}
|
22 |
-
|
23 |
protected function _beforeToHtml()
|
24 |
{
|
25 |
try {
|
26 |
$this->setLipscoreApiKey($this->_lipscoreConfig->apiKey());
|
27 |
$this->setAssetsUrl($this->_envConfig->assetsUrl());
|
|
|
28 |
} catch (Exception $e) {
|
29 |
Lipscore_RatingsReviews_Logger::logException($e);
|
30 |
}
|
31 |
-
|
32 |
return parent::_beforeToHtml();
|
33 |
-
}
|
34 |
-
|
35 |
protected function getLipscoreLocale()
|
36 |
{
|
37 |
-
$locale = null;
|
38 |
try {
|
39 |
$locale = Mage::helper('lipscore_ratingsreviews/locale')->getLipscoreLocale();
|
40 |
} catch (Exception $e) {
|
6 |
* @var Lipscore_RatingsReviews_Model_Config
|
7 |
*/
|
8 |
protected $_lipscoreConfig;
|
9 |
+
|
10 |
/**
|
11 |
* @var Lipscore_RatingsReviews_Model_Config_Env
|
12 |
*/
|
13 |
protected $_envConfig;
|
14 |
+
|
15 |
+
protected $_moduleHelper;
|
16 |
+
|
17 |
public function __construct()
|
18 |
{
|
19 |
$this->_lipscoreConfig = Mage::getModel('lipscore_ratingsreviews/config');
|
20 |
$this->_envConfig = Mage::getModel('lipscore_ratingsreviews/config_env');
|
21 |
+
$this->_moduleHelper = Mage::helper('lipscore_ratingsreviews/module');
|
22 |
+
|
23 |
parent::_construct();
|
24 |
}
|
25 |
+
|
26 |
protected function _beforeToHtml()
|
27 |
{
|
28 |
try {
|
29 |
$this->setLipscoreApiKey($this->_lipscoreConfig->apiKey());
|
30 |
$this->setAssetsUrl($this->_envConfig->assetsUrl());
|
31 |
+
$this->setIsLipscoreActive($this->_moduleHelper->isLipscoreActive());
|
32 |
} catch (Exception $e) {
|
33 |
Lipscore_RatingsReviews_Logger::logException($e);
|
34 |
}
|
35 |
+
|
36 |
return parent::_beforeToHtml();
|
37 |
+
}
|
38 |
+
|
39 |
protected function getLipscoreLocale()
|
40 |
{
|
41 |
+
$locale = null;
|
42 |
try {
|
43 |
$locale = Mage::helper('lipscore_ratingsreviews/locale')->getLipscoreLocale();
|
44 |
} catch (Exception $e) {
|
app/code/community/Lipscore/RatingsReviews/Block/Purchase/Abstract.php
DELETED
@@ -1,42 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
abstract class Lipscore_RatingsReviews_Block_Purchase_Abstract extends Mage_Core_Block_Template
|
4 |
-
{
|
5 |
-
protected function _beforeToHtml()
|
6 |
-
{
|
7 |
-
try {
|
8 |
-
$this->_prepareProductsInOrder();
|
9 |
-
$this->_preparePurchaseInfo();
|
10 |
-
} catch (Exception $e) {
|
11 |
-
Lipscore_RatingsReviews_Logger::logException($e);
|
12 |
-
}
|
13 |
-
|
14 |
-
return parent::_beforeToHtml();
|
15 |
-
}
|
16 |
-
|
17 |
-
protected abstract function _prepareProductsInOrder();
|
18 |
-
protected abstract function _preparePurchaseInfo();
|
19 |
-
|
20 |
-
protected function _prepareCouponInfo()
|
21 |
-
{
|
22 |
-
$couponHelper = $this->helper('lipscore_ratingsreviews/coupon');
|
23 |
-
$coupon = $couponHelper->generateCoupon();
|
24 |
-
|
25 |
-
if ($coupon) {
|
26 |
-
$this->setCouponCode($coupon->getCode());
|
27 |
-
$this->setCouponDescription($couponHelper->getCouponDescription());
|
28 |
-
}
|
29 |
-
}
|
30 |
-
|
31 |
-
protected function _getProductFromOrderItem($item)
|
32 |
-
{
|
33 |
-
$superProductConfig = $item->getBuyRequest()->getSuperProductConfig();
|
34 |
-
if (!empty($superProductConfig['product_id'])) {
|
35 |
-
$productId = $superProductConfig['product_id'];
|
36 |
-
} else {
|
37 |
-
$productId = $item->getProductId();
|
38 |
-
}
|
39 |
-
|
40 |
-
return Mage::getModel('catalog/product')->load($productId);
|
41 |
-
}
|
42 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/community/Lipscore/RatingsReviews/Block/Purchase/Multishipping.php
DELETED
@@ -1,49 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class Lipscore_RatingsReviews_Block_Purchase_Multishipping extends Lipscore_RatingsReviews_Block_Purchase_Abstract
|
4 |
-
{
|
5 |
-
protected $_orders = array();
|
6 |
-
|
7 |
-
protected function _construct()
|
8 |
-
{
|
9 |
-
try {
|
10 |
-
$orderIds = Mage::getSingleton('checkout/type_multishipping')->getOrderIds();
|
11 |
-
if ($orderIds) {
|
12 |
-
$this->_orders = Mage::getModel('sales/order')
|
13 |
-
->getCollection()
|
14 |
-
->addFieldToFilter('entity_id', array('in' => $orderIds));
|
15 |
-
}
|
16 |
-
} catch (Exception $e) {
|
17 |
-
Lipscore_RatingsReviews_Logger::logException($e);
|
18 |
-
}
|
19 |
-
|
20 |
-
parent::_construct();
|
21 |
-
}
|
22 |
-
|
23 |
-
protected function _prepareProductsInOrder()
|
24 |
-
{
|
25 |
-
$productsData = array();
|
26 |
-
|
27 |
-
$productHelper = $this->helper('lipscore_ratingsreviews/product');
|
28 |
-
|
29 |
-
foreach ($this->_orders as $order) {
|
30 |
-
$orderItems = $order->getAllVisibleItems();
|
31 |
-
foreach ($orderItems as $item) {
|
32 |
-
$product = $this->_getProductFromOrderItem($item);
|
33 |
-
$productsData[$product->getId()] = $productHelper->getProductData($product);
|
34 |
-
}
|
35 |
-
}
|
36 |
-
|
37 |
-
$this->setProductsData($productsData);
|
38 |
-
}
|
39 |
-
|
40 |
-
protected function _preparePurchaseInfo()
|
41 |
-
{
|
42 |
-
$purchaseHelper = $this->helper('lipscore_ratingsreviews/purchase');
|
43 |
-
$this->setCustomerEmail($purchaseHelper->getEmail());
|
44 |
-
$this->setCustomerName($purchaseHelper->getName());
|
45 |
-
|
46 |
-
// coupon
|
47 |
-
$this->_prepareCouponInfo();
|
48 |
-
}
|
49 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/community/Lipscore/RatingsReviews/Block/Purchase/Onepage.php
DELETED
@@ -1,52 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class Lipscore_RatingsReviews_Block_Purchase_Onepage extends Lipscore_RatingsReviews_Block_Purchase_Abstract
|
4 |
-
{
|
5 |
-
protected $_order = null;
|
6 |
-
|
7 |
-
protected function _construct()
|
8 |
-
{
|
9 |
-
try {
|
10 |
-
$orderId = Mage::getSingleton('checkout/session')->getLastOrderId();
|
11 |
-
if ($orderId) {
|
12 |
-
$this->_order = Mage::getModel('sales/order')->load($orderId);
|
13 |
-
}
|
14 |
-
} catch (Exception $e) {
|
15 |
-
Lipscore_RatingsReviews_Logger::logException($e);
|
16 |
-
}
|
17 |
-
|
18 |
-
parent::_construct();
|
19 |
-
}
|
20 |
-
|
21 |
-
protected function _prepareProductsInOrder()
|
22 |
-
{
|
23 |
-
$productsData = array();
|
24 |
-
|
25 |
-
if ($this->_order) {
|
26 |
-
$productHelper = $this->helper('lipscore_ratingsreviews/product');
|
27 |
-
|
28 |
-
$orderItems = $this->_order->getAllVisibleItems();
|
29 |
-
foreach ($orderItems as $item) {
|
30 |
-
$product = $this->_getProductFromOrderItem($item);
|
31 |
-
$productsData[$product->getId()] = $productHelper->getProductData($product);
|
32 |
-
}
|
33 |
-
}
|
34 |
-
|
35 |
-
$this->setProductsData($productsData);
|
36 |
-
}
|
37 |
-
|
38 |
-
protected function _preparePurchaseInfo()
|
39 |
-
{
|
40 |
-
if (!$this->_order) {
|
41 |
-
return;
|
42 |
-
}
|
43 |
-
|
44 |
-
$purchaseHelper = $this->helper('lipscore_ratingsreviews/purchase');
|
45 |
-
|
46 |
-
$this->setCustomerEmail($purchaseHelper->getEmail($this->_order));
|
47 |
-
$this->setCustomerName($purchaseHelper->getName($this->_order));
|
48 |
-
|
49 |
-
// coupon
|
50 |
-
$this->_prepareCouponInfo();
|
51 |
-
}
|
52 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/community/Lipscore/RatingsReviews/Block/Review/Helper.php
CHANGED
File without changes
|
app/code/community/Lipscore/RatingsReviews/Block/Review/Single.php
CHANGED
File without changes
|
app/code/community/Lipscore/RatingsReviews/Block/Review/Tabtitle.php
CHANGED
File without changes
|
app/code/community/Lipscore/RatingsReviews/Block/System/Config/Form/Coupons.php
CHANGED
File without changes
|
app/code/community/Lipscore/RatingsReviews/Block/System/Config/Form/Field/Abstract.php
CHANGED
File without changes
|
app/code/community/Lipscore/RatingsReviews/Block/System/Config/Form/Field/Apikey.php
CHANGED
@@ -4,16 +4,15 @@ class Lipscore_RatingsReviews_Block_System_Config_Form_Field_Apikey
|
|
4 |
{
|
5 |
public function render(Varien_Data_Form_Element_Abstract $element)
|
6 |
{
|
7 |
-
|
8 |
-
try {
|
9 |
-
$
|
10 |
-
$demoApiKey = $this->getLipscoreConfig()->demoApiKey();
|
11 |
} catch (Exception $e) {
|
12 |
Lipscore_RatingsReviews_Logger::logException($e);
|
13 |
return parent::render($element);
|
14 |
-
}
|
15 |
-
$comment =
|
16 |
-
|
17 |
return parent::render($element) . $comment;
|
18 |
}
|
19 |
|
4 |
{
|
5 |
public function render(Varien_Data_Form_Element_Abstract $element)
|
6 |
{
|
7 |
+
$isDemoKey = false;
|
8 |
+
try {
|
9 |
+
$isDemoKey = $this->getLipscoreConfig()->isDemoKey();
|
|
|
10 |
} catch (Exception $e) {
|
11 |
Lipscore_RatingsReviews_Logger::logException($e);
|
12 |
return parent::render($element);
|
13 |
+
}
|
14 |
+
$comment = $isDemoKey ? $this->_commentHtml() : '';
|
15 |
+
|
16 |
return parent::render($element) . $comment;
|
17 |
}
|
18 |
|
app/code/community/Lipscore/RatingsReviews/Block/System/Config/Form/Field/Emailstext.php
CHANGED
File without changes
|
app/code/community/Lipscore/RatingsReviews/Block/System/Config/Form/Field/Reminderperiod.php
CHANGED
@@ -1,46 +1,48 @@
|
|
1 |
<?php
|
|
|
2 |
class Lipscore_RatingsReviews_Block_System_Config_Form_Field_Reminderperiod
|
3 |
extends Lipscore_RatingsReviews_Block_System_Config_Form_Field_Abstract
|
4 |
{
|
5 |
protected static $_statusSelect = 'order_status';
|
6 |
-
|
7 |
public function render(Varien_Data_Form_Element_Abstract $element)
|
8 |
{
|
9 |
$text = '';
|
10 |
try {
|
11 |
-
$text =
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
|
|
17 |
} catch (Exception $e) {
|
18 |
Lipscore_RatingsReviews_Logger::logException($e);
|
19 |
-
}
|
20 |
-
return $text;
|
21 |
}
|
22 |
-
|
23 |
public function getLabel($targetId, $title)
|
24 |
{
|
25 |
return '<label for="' . $targetId . '" class="ls-reminder-label">' . $this->__($title) . '</label>';
|
26 |
}
|
27 |
-
|
28 |
public function getStatusField()
|
29 |
{
|
30 |
$label = $this->getLabel(self::$_statusSelect, '<span>Include orders in these statuses<br/>(Ctrl+click to add more)</span>');
|
31 |
-
|
32 |
-
$opts = Mage::getSingleton('lipscore_ratingsreviews/
|
33 |
-
|
34 |
$select = $this->getLayout()->createBlock('adminhtml/html_select')
|
35 |
->setName(self::$_statusSelect . '[]')
|
36 |
->setId(self::$_statusSelect)
|
37 |
->setClass('select multiselect')
|
38 |
->setOptions($opts)
|
39 |
->setExtraParams('multiple="multiple"');
|
40 |
-
|
41 |
return $label . $select->getHtml();
|
42 |
}
|
43 |
-
|
44 |
public function getDateFields()
|
45 |
{
|
46 |
$html = $this->getLabel($this->dateFieldId('from'), 'Include orders made between');
|
@@ -49,7 +51,7 @@ class Lipscore_RatingsReviews_Block_System_Config_Form_Field_Reminderperiod
|
|
49 |
$html .= $this->getDateField('to', time());
|
50 |
return $html;
|
51 |
}
|
52 |
-
|
53 |
public function getDateField($name, $defaultValue)
|
54 |
{
|
55 |
$element = new Varien_Data_Form_Element_Date(
|
@@ -63,45 +65,114 @@ class Lipscore_RatingsReviews_Block_System_Config_Form_Field_Reminderperiod
|
|
63 |
$element->setValue($defaultValue);
|
64 |
$element->setForm(new Varien_Data_Form());
|
65 |
$element->setId($this->dateFieldId($name));
|
66 |
-
|
67 |
return $element->getElementHtml();
|
68 |
}
|
69 |
-
|
70 |
public function dateFieldId($name)
|
71 |
{
|
72 |
return 'remind_' . $name;
|
73 |
}
|
74 |
-
|
75 |
-
|
|
|
76 |
{
|
77 |
-
$
|
78 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
79 |
$apiKey = $this->getLipscoreConfig()->apiKey();
|
80 |
$button = $this->getLayout()->createBlock('adminhtml/widget_button')
|
81 |
->setData(array(
|
82 |
-
'label' => $this->__('Send emails'),
|
83 |
'disabled' => empty($apiKey),
|
84 |
-
'title' => $this->__('Send
|
85 |
-
'onclick' => "
|
86 |
-
'id' => 'ls-reminder-button'
|
87 |
));
|
88 |
-
return $button->toHtml();
|
89 |
}
|
90 |
-
|
91 |
-
|
92 |
{
|
93 |
-
$
|
94 |
-
$
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
100 |
}
|
101 |
-
|
102 |
-
protected function
|
103 |
{
|
104 |
-
$
|
105 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
106 |
}
|
107 |
}
|
1 |
<?php
|
2 |
+
|
3 |
class Lipscore_RatingsReviews_Block_System_Config_Form_Field_Reminderperiod
|
4 |
extends Lipscore_RatingsReviews_Block_System_Config_Form_Field_Abstract
|
5 |
{
|
6 |
protected static $_statusSelect = 'order_status';
|
7 |
+
|
8 |
public function render(Varien_Data_Form_Element_Abstract $element)
|
9 |
{
|
10 |
$text = '';
|
11 |
try {
|
12 |
+
$text = "<div id='ls-reminder' data-result='{$this->reminderResult()}'>" .
|
13 |
+
$this->getNote() .
|
14 |
+
$this->getStatusField() .
|
15 |
+
$this->getDateFields() .
|
16 |
+
$this->previewButton() .
|
17 |
+
'</div>' .
|
18 |
+
$this->reminderPreview();
|
19 |
} catch (Exception $e) {
|
20 |
Lipscore_RatingsReviews_Logger::logException($e);
|
21 |
+
}
|
22 |
+
return $text;
|
23 |
}
|
24 |
+
|
25 |
public function getLabel($targetId, $title)
|
26 |
{
|
27 |
return '<label for="' . $targetId . '" class="ls-reminder-label">' . $this->__($title) . '</label>';
|
28 |
}
|
29 |
+
|
30 |
public function getStatusField()
|
31 |
{
|
32 |
$label = $this->getLabel(self::$_statusSelect, '<span>Include orders in these statuses<br/>(Ctrl+click to add more)</span>');
|
33 |
+
|
34 |
+
$opts = Mage::getSingleton('lipscore_ratingsreviews/system_config_source_order_status_reminders')->toOptionArray();
|
35 |
+
|
36 |
$select = $this->getLayout()->createBlock('adminhtml/html_select')
|
37 |
->setName(self::$_statusSelect . '[]')
|
38 |
->setId(self::$_statusSelect)
|
39 |
->setClass('select multiselect')
|
40 |
->setOptions($opts)
|
41 |
->setExtraParams('multiple="multiple"');
|
42 |
+
|
43 |
return $label . $select->getHtml();
|
44 |
}
|
45 |
+
|
46 |
public function getDateFields()
|
47 |
{
|
48 |
$html = $this->getLabel($this->dateFieldId('from'), 'Include orders made between');
|
51 |
$html .= $this->getDateField('to', time());
|
52 |
return $html;
|
53 |
}
|
54 |
+
|
55 |
public function getDateField($name, $defaultValue)
|
56 |
{
|
57 |
$element = new Varien_Data_Form_Element_Date(
|
65 |
$element->setValue($defaultValue);
|
66 |
$element->setForm(new Varien_Data_Form());
|
67 |
$element->setId($this->dateFieldId($name));
|
68 |
+
|
69 |
return $element->getElementHtml();
|
70 |
}
|
71 |
+
|
72 |
public function dateFieldId($name)
|
73 |
{
|
74 |
return 'remind_' . $name;
|
75 |
}
|
76 |
+
|
77 |
+
|
78 |
+
public function getNote()
|
79 |
{
|
80 |
+
$linkToDasboard = 'https://members.lipscore.com/';
|
81 |
+
$linkToCoupons = Mage::getModel('adminhtml/url')->getUrl('*/*/*', array('section' => 'lipscore_coupons'));
|
82 |
+
|
83 |
+
$msg = "After installation of Lipscore you can send emails to recent customers asking them to write reviews of the purchases they have done. This is done automatically for all future customers but customers from before Lipscore was installed will not get these emails unless you invoke it below. They will be delivered according to <a href='$linkToDasboard'>reminder delay settings</a> and will only be done once.";
|
84 |
+
$coupons = "To increase the chance of getting reviews you can also add coupons to these emails. Set up coupons <a href='$linkToCoupons'>here</a>.";
|
85 |
+
$settings = "<p>NOTE: Please make sure that your email settings are set up correctly in your <a href='$linkToDasboard'>Lipscore Dashboard</a> before invoking the Kickstart-feature!</p>";
|
86 |
+
$heading = '<h4>Send review emails to these customers:</h4>';
|
87 |
+
return "<p>$msg $coupons<p>$settings $heading";
|
88 |
+
}
|
89 |
+
|
90 |
+
public function previewButton()
|
91 |
+
{
|
92 |
+
$url = $this->getReminderUrl('preview');
|
93 |
$apiKey = $this->getLipscoreConfig()->apiKey();
|
94 |
$button = $this->getLayout()->createBlock('adminhtml/widget_button')
|
95 |
->setData(array(
|
96 |
+
'label' => $this->__('Send emails'),
|
97 |
'disabled' => empty($apiKey),
|
98 |
+
'title' => $this->__('Send emails'),
|
99 |
+
'onclick' => "previewLsReminder('$url');",
|
100 |
+
'id' => 'ls-reminder-preview-button'
|
101 |
));
|
102 |
+
return $button->toHtml();
|
103 |
}
|
104 |
+
|
105 |
+
protected function sendButton()
|
106 |
{
|
107 |
+
$url = $this->getReminderUrl('send');
|
108 |
+
$button = $this->getLayout()->createBlock('adminhtml/widget_button')
|
109 |
+
->setData(array(
|
110 |
+
'label' => $this->__('Continue'),
|
111 |
+
'title' => $this->__('Continue'),
|
112 |
+
'onclick' => "sendLsReminder('$url');",
|
113 |
+
'id' => 'ls-reminder-send-button'
|
114 |
+
));
|
115 |
+
return $button->toHtml();
|
116 |
+
}
|
117 |
+
|
118 |
+
protected function cancelButton()
|
119 |
+
{
|
120 |
+
$button = $this->getLayout()->createBlock('adminhtml/widget_button')
|
121 |
+
->setData(array(
|
122 |
+
'label' => $this->__('Cancel'),
|
123 |
+
'title' => $this->__('Cancel'),
|
124 |
+
'onclick' => 'closeLsPreviewPopup();',
|
125 |
+
'id' => 'ls-reminder-cancel-button'
|
126 |
+
));
|
127 |
+
return $button->toHtml();
|
128 |
+
}
|
129 |
+
|
130 |
+
protected function reminderPreview()
|
131 |
+
{
|
132 |
+
$cancelLabel = $this->__('Cancel');
|
133 |
+
$popup =
|
134 |
+
<<<EOT
|
135 |
+
<div id='message-popup-window-mask' class='ls-preview-popup-mask' style='display:none;'></div>
|
136 |
+
<div id='message-popup-window' class='message-popup ls-preview-popup'>
|
137 |
+
<div class='message-popup-head'>
|
138 |
+
<a href='#' onclick='closeLsPreviewPopup(); return false;' title='$cancelLabel'><span>$cancelLabel</span></a>
|
139 |
+
<h2>Kick-start summary</h2>
|
140 |
+
</div>
|
141 |
+
<div class='message-popup-content'>
|
142 |
+
<div class='message'>
|
143 |
+
<p id='ls-reminder-preview-text'></p>
|
144 |
+
</div>
|
145 |
+
{$this->cancelButton()}{$this->sendButton()}
|
146 |
+
</div>
|
147 |
+
</div>
|
148 |
+
EOT;
|
149 |
+
return $popup;
|
150 |
+
}
|
151 |
+
|
152 |
+
protected function getReminderUrl($action)
|
153 |
+
{
|
154 |
+
$scopeParams = "section/{$this->getSection()}/website/{$this->getWebsite()}/store/{$this->getStore()}";
|
155 |
+
return Mage::getModel('adminhtml/url')->getUrl("*/purchases_reminders/$action/$scopeParams");
|
156 |
}
|
157 |
+
|
158 |
+
protected function reminderResult()
|
159 |
{
|
160 |
+
$config = Mage::getModel('lipscore_ratingsreviews/config_kickstart');
|
161 |
+
$resultJson = $config->resultJson();
|
162 |
+
if (!$resultJson) {
|
163 |
+
return null;
|
164 |
+
}
|
165 |
+
|
166 |
+
$result = Zend_Json::decode($resultJson);
|
167 |
+
if ($result['completed']) {
|
168 |
+
$config->clearResult();
|
169 |
+
} else {
|
170 |
+
$timeSinceLastUpdate = time() - (int) $result['updated_at'];
|
171 |
+
if ($timeSinceLastUpdate > (5 * 60)) {
|
172 |
+
$resultJson = null;
|
173 |
+
}
|
174 |
+
}
|
175 |
+
|
176 |
+
return $resultJson;
|
177 |
}
|
178 |
}
|
app/code/community/Lipscore/RatingsReviews/Block/System/Config/Form/Fieldset/Coupons.php
CHANGED
File without changes
|
app/code/community/Lipscore/RatingsReviews/Block/System/Config/Form/Fieldset/Dashboardlink.php
CHANGED
@@ -4,6 +4,6 @@ class Lipscore_RatingsReviews_Block_System_Config_Form_Fieldset_Dashboardlink ex
|
|
4 |
{
|
5 |
public function render(Varien_Data_Form_Element_Abstract $element)
|
6 |
{
|
7 |
-
return 'Advanced settings are available on <a href="https://members.lipscore.com/">your Lipscore.com dashboard</a
|
8 |
}
|
9 |
}
|
4 |
{
|
5 |
public function render(Varien_Data_Form_Element_Abstract $element)
|
6 |
{
|
7 |
+
return '<p>Advanced settings are available on <a href="https://members.lipscore.com/">your Lipscore.com dashboard</a></p><br/>';
|
8 |
}
|
9 |
}
|
app/code/community/Lipscore/RatingsReviews/Helper/Abstract.php
CHANGED
File without changes
|
app/code/community/Lipscore/RatingsReviews/Helper/Config.php
CHANGED
@@ -6,7 +6,7 @@ class Lipscore_RatingsReviews_Helper_Config extends Lipscore_RatingsReviews_Help
|
|
6 |
{
|
7 |
$website = $websiteCode ? Mage::getModel('core/website')->load($websiteCode) : null;
|
8 |
$store = $storeCode ? Mage::getModel('core/store')->load($storeCode) : null;
|
9 |
-
|
10 |
return Mage::getModel('lipscore_ratingsreviews/config', array('store' => $store, 'website' => $website));
|
11 |
}
|
12 |
}
|
6 |
{
|
7 |
$website = $websiteCode ? Mage::getModel('core/website')->load($websiteCode) : null;
|
8 |
$store = $storeCode ? Mage::getModel('core/store')->load($storeCode) : null;
|
9 |
+
|
10 |
return Mage::getModel('lipscore_ratingsreviews/config', array('store' => $store, 'website' => $website));
|
11 |
}
|
12 |
}
|
app/code/community/Lipscore/RatingsReviews/Helper/Coupon.php
CHANGED
@@ -4,25 +4,21 @@ class Lipscore_RatingsReviews_Helper_Coupon extends Lipscore_RatingsReviews_Help
|
|
4 |
{
|
5 |
protected $_rule;
|
6 |
protected $_ruleModel;
|
7 |
-
|
8 |
public function __construct()
|
9 |
{
|
10 |
parent::__construct();
|
11 |
-
|
12 |
$this->_ruleModel = Mage::getModel('salesrule/rule');
|
13 |
-
$ruleId = $this->_lipscoreConfig->get('rule_id', 'coupon');
|
14 |
-
if ($ruleId) {
|
15 |
-
$this->_rule = $this->_ruleModel->load($ruleId);
|
16 |
-
}
|
17 |
}
|
18 |
-
|
19 |
function generateCoupon()
|
20 |
{
|
21 |
$coupon = null;
|
22 |
-
|
23 |
-
|
|
|
24 |
$params = array(
|
25 |
-
'rule_id' => $
|
26 |
'qty' => 1,
|
27 |
'length' => $this->_lipscoreConfig->get('length', 'coupon'),
|
28 |
'format' => $this->_lipscoreConfig->get('format', 'coupon'),
|
@@ -30,19 +26,28 @@ class Lipscore_RatingsReviews_Helper_Coupon extends Lipscore_RatingsReviews_Help
|
|
30 |
'suffix' => $this->_lipscoreConfig->get('suffix', 'coupon'),
|
31 |
'dash' => $this->_lipscoreConfig->get('dash', 'coupon'),
|
32 |
);
|
33 |
-
|
34 |
$generator = Mage::getModel('lipscore_ratingsreviews/coupon_generator');
|
35 |
-
$coupon = $generator->generate($
|
36 |
-
}
|
37 |
|
38 |
return $coupon;
|
39 |
}
|
40 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
41 |
public function getCouponDescription()
|
42 |
{
|
43 |
-
|
|
|
44 |
}
|
45 |
-
|
46 |
public function isAutoGenerationSupported()
|
47 |
{
|
48 |
return method_exists($this->_ruleModel, 'getCouponMassGenerator');
|
4 |
{
|
5 |
protected $_rule;
|
6 |
protected $_ruleModel;
|
7 |
+
|
8 |
public function __construct()
|
9 |
{
|
10 |
parent::__construct();
|
|
|
11 |
$this->_ruleModel = Mage::getModel('salesrule/rule');
|
|
|
|
|
|
|
|
|
12 |
}
|
13 |
+
|
14 |
function generateCoupon()
|
15 |
{
|
16 |
$coupon = null;
|
17 |
+
|
18 |
+
$rule = $this->getRule();
|
19 |
+
if ($rule) {
|
20 |
$params = array(
|
21 |
+
'rule_id' => $rule->getId(),
|
22 |
'qty' => 1,
|
23 |
'length' => $this->_lipscoreConfig->get('length', 'coupon'),
|
24 |
'format' => $this->_lipscoreConfig->get('format', 'coupon'),
|
26 |
'suffix' => $this->_lipscoreConfig->get('suffix', 'coupon'),
|
27 |
'dash' => $this->_lipscoreConfig->get('dash', 'coupon'),
|
28 |
);
|
29 |
+
|
30 |
$generator = Mage::getModel('lipscore_ratingsreviews/coupon_generator');
|
31 |
+
$coupon = $generator->generate($rule, $params);
|
32 |
+
}
|
33 |
|
34 |
return $coupon;
|
35 |
}
|
36 |
+
|
37 |
+
public function getRule()
|
38 |
+
{
|
39 |
+
$ruleId = $this->_lipscoreConfig->get('rule_id', 'coupon');
|
40 |
+
if ($ruleId) {
|
41 |
+
return $this->_ruleModel->load($ruleId);
|
42 |
+
}
|
43 |
+
}
|
44 |
+
|
45 |
public function getCouponDescription()
|
46 |
{
|
47 |
+
$rule = $this->getRule();
|
48 |
+
return $rule ? $rule->getDescription() : '';
|
49 |
}
|
50 |
+
|
51 |
public function isAutoGenerationSupported()
|
52 |
{
|
53 |
return method_exists($this->_ruleModel, 'getCouponMassGenerator');
|
app/code/community/Lipscore/RatingsReviews/Helper/Data.php
CHANGED
File without changes
|
app/code/community/Lipscore/RatingsReviews/Helper/Kickstart.php
ADDED
@@ -0,0 +1,60 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Lipscore_RatingsReviews_Helper_Kickstart extends Lipscore_RatingsReviews_Helper_Abstract
|
4 |
+
{
|
5 |
+
const CRON_STRING_PATH = 'crontab/jobs/send_kickstart_orders/schedule/cron_expr';
|
6 |
+
protected $kickstartConfig;
|
7 |
+
|
8 |
+
public function dateFormat()
|
9 |
+
{
|
10 |
+
return Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT);
|
11 |
+
}
|
12 |
+
|
13 |
+
public function getOrders($store, $period, $statuses)
|
14 |
+
{
|
15 |
+
return Mage::getModel('sales/order')->getCollection()
|
16 |
+
->addAttributeToFilter('created_at', $period)
|
17 |
+
->addAttributeToFilter('status', array('in' => $statuses))
|
18 |
+
->addAttributeToFilter('store_id', array('eq' => $store->getId()));
|
19 |
+
}
|
20 |
+
|
21 |
+
public function resultData($storeName, $count, $error)
|
22 |
+
{
|
23 |
+
return array('store' => $storeName, 'err' => $error, 'count' => $count);
|
24 |
+
}
|
25 |
+
|
26 |
+
public function period($from, $to)
|
27 |
+
{
|
28 |
+
$from->setTime('00:00:00');
|
29 |
+
$to->setTime('23:59:59');
|
30 |
+
return array('datetime' => true, 'from' => $from, 'to' => $to);
|
31 |
+
}
|
32 |
+
|
33 |
+
public function saveTempResult($processed)
|
34 |
+
{
|
35 |
+
return $this->saveResult($processed, array(), false);
|
36 |
+
}
|
37 |
+
|
38 |
+
public function saveFinalResult($processed, $results)
|
39 |
+
{
|
40 |
+
return $this->saveResult($processed, $results, true);
|
41 |
+
}
|
42 |
+
|
43 |
+
protected function saveResult($processed, $results, $completed)
|
44 |
+
{
|
45 |
+
$result = array(
|
46 |
+
'processed' => $processed,
|
47 |
+
'stores' => $results,
|
48 |
+
'completed' => $completed
|
49 |
+
);
|
50 |
+
return $this->kickstartConfig()->setResult($result);
|
51 |
+
}
|
52 |
+
|
53 |
+
protected function kickstartConfig()
|
54 |
+
{
|
55 |
+
if (!$this->kickstartConfig) {
|
56 |
+
$this->kickstartConfig = Mage::getModel('lipscore_ratingsreviews/config_kickstart');
|
57 |
+
}
|
58 |
+
return $this->kickstartConfig;
|
59 |
+
}
|
60 |
+
}
|
app/code/community/Lipscore/RatingsReviews/Helper/Locale.php
CHANGED
File without changes
|
app/code/community/Lipscore/RatingsReviews/Helper/Module.php
CHANGED
@@ -39,14 +39,18 @@ class Lipscore_RatingsReviews_Helper_Module extends Lipscore_RatingsReviews_Help
|
|
39 |
}
|
40 |
}
|
41 |
|
42 |
-
|
43 |
{
|
44 |
-
|
|
|
|
|
|
|
|
|
|
|
45 |
}
|
46 |
|
47 |
protected function isLipscoreEnabledByConfig()
|
48 |
{
|
49 |
-
|
50 |
-
return true;
|
51 |
}
|
52 |
}
|
39 |
}
|
40 |
}
|
41 |
|
42 |
+
public function isLipscoreOutputEnabled()
|
43 |
{
|
44 |
+
try {
|
45 |
+
return $this->isModuleOutputEnabled(self::MODULE_NAME) && $this->isLipscoreEnabledByConfig();
|
46 |
+
} catch (Exception $e) {
|
47 |
+
Lipscore_RatingsReviews_Logger::logException($e);
|
48 |
+
return false;
|
49 |
+
}
|
50 |
}
|
51 |
|
52 |
protected function isLipscoreEnabledByConfig()
|
53 |
{
|
54 |
+
return $this->_lipscoreConfig->isModuleActive();
|
|
|
55 |
}
|
56 |
}
|
app/code/community/Lipscore/RatingsReviews/Helper/Price.php
CHANGED
File without changes
|
app/code/community/Lipscore/RatingsReviews/Helper/Product.php
CHANGED
@@ -41,7 +41,7 @@ class Lipscore_RatingsReviews_Helper_Product extends Lipscore_RatingsReviews_Hel
|
|
41 |
'brand' => $this->getAttributeValue($product, $brandAttr),
|
42 |
'sku_values' => array($this->getSku($product)),
|
43 |
'internal_id' => "{$product->getId()}",
|
44 |
-
'url' => $
|
45 |
'image_url' => $this->getImageUrl($product),
|
46 |
'price' => $this->getPrice($product),
|
47 |
'currency' => $this->getCurrency(),
|
@@ -59,6 +59,11 @@ class Lipscore_RatingsReviews_Helper_Product extends Lipscore_RatingsReviews_Hel
|
|
59 |
);
|
60 |
}
|
61 |
|
|
|
|
|
|
|
|
|
|
|
62 |
protected function getImageUrl(Mage_Catalog_Model_Product $product)
|
63 |
{
|
64 |
$url = '';
|
41 |
'brand' => $this->getAttributeValue($product, $brandAttr),
|
42 |
'sku_values' => array($this->getSku($product)),
|
43 |
'internal_id' => "{$product->getId()}",
|
44 |
+
'url' => $this->getUrl($product),
|
45 |
'image_url' => $this->getImageUrl($product),
|
46 |
'price' => $this->getPrice($product),
|
47 |
'currency' => $this->getCurrency(),
|
59 |
);
|
60 |
}
|
61 |
|
62 |
+
public function getUrl(Mage_Catalog_Model_Product $product)
|
63 |
+
{
|
64 |
+
return $product->getProductUrl(false);
|
65 |
+
}
|
66 |
+
|
67 |
protected function getImageUrl(Mage_Catalog_Model_Product $product)
|
68 |
{
|
69 |
$url = '';
|
app/code/community/Lipscore/RatingsReviews/Helper/Purchase.php
CHANGED
@@ -1,59 +1,34 @@
|
|
1 |
<?php
|
2 |
|
3 |
class Lipscore_RatingsReviews_Helper_Purchase extends Lipscore_RatingsReviews_Helper_Abstract
|
4 |
-
{
|
5 |
public function getEmail(Mage_Sales_Model_Order $order = null)
|
6 |
{
|
7 |
$email = null;
|
8 |
-
|
9 |
if ($order) {
|
10 |
$email = $order->getBillingAddress()->getEmail();
|
11 |
if (!$email) {
|
12 |
$email = $order->getCustomerEmail();
|
13 |
-
}
|
14 |
-
} else {
|
15 |
-
$customer = $this->getCustomer();
|
16 |
-
if ($customer) {
|
17 |
-
$email = $customer->getEmail();
|
18 |
}
|
19 |
}
|
20 |
|
21 |
return $email;
|
22 |
}
|
23 |
-
|
24 |
public function getName(Mage_Sales_Model_Order $order = null)
|
25 |
{
|
26 |
$name = null;
|
27 |
-
|
28 |
if ($order) {
|
29 |
$addr = $order->getBillingAddress();
|
30 |
$name = $addr->getFirstname() . ' ' . $addr->getLastname();
|
31 |
-
|
32 |
if (!trim($name)) {
|
33 |
$name = $order->getCustomerFirstname() . ' ' . $order->getCustomerLastname();
|
34 |
}
|
35 |
-
} else {
|
36 |
-
$customer = $this->getCustomer();
|
37 |
-
if ($customer) {
|
38 |
-
$name = $customer->getName();
|
39 |
-
}
|
40 |
}
|
41 |
-
|
42 |
return $name;
|
43 |
}
|
44 |
-
|
45 |
-
protected function getCustomer()
|
46 |
-
{
|
47 |
-
return Mage::getSingleton('customer/session')->getCustomer();
|
48 |
-
}
|
49 |
-
|
50 |
-
public function getWidget($type)
|
51 |
-
{
|
52 |
-
$layout = $this->getLayout();
|
53 |
-
|
54 |
-
$layout->getUpdate()->load("checkout_{$type}_success");
|
55 |
-
$layout->generateXml()->generateBlocks();
|
56 |
-
|
57 |
-
return $layout->getBlock("lipscore.purchase.$type")->toHtml();
|
58 |
-
}
|
59 |
}
|
1 |
<?php
|
2 |
|
3 |
class Lipscore_RatingsReviews_Helper_Purchase extends Lipscore_RatingsReviews_Helper_Abstract
|
4 |
+
{
|
5 |
public function getEmail(Mage_Sales_Model_Order $order = null)
|
6 |
{
|
7 |
$email = null;
|
8 |
+
|
9 |
if ($order) {
|
10 |
$email = $order->getBillingAddress()->getEmail();
|
11 |
if (!$email) {
|
12 |
$email = $order->getCustomerEmail();
|
|
|
|
|
|
|
|
|
|
|
13 |
}
|
14 |
}
|
15 |
|
16 |
return $email;
|
17 |
}
|
18 |
+
|
19 |
public function getName(Mage_Sales_Model_Order $order = null)
|
20 |
{
|
21 |
$name = null;
|
22 |
+
|
23 |
if ($order) {
|
24 |
$addr = $order->getBillingAddress();
|
25 |
$name = $addr->getFirstname() . ' ' . $addr->getLastname();
|
26 |
+
|
27 |
if (!trim($name)) {
|
28 |
$name = $order->getCustomerFirstname() . ' ' . $order->getCustomerLastname();
|
29 |
}
|
|
|
|
|
|
|
|
|
|
|
30 |
}
|
31 |
+
|
32 |
return $name;
|
33 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
34 |
}
|
app/code/community/Lipscore/RatingsReviews/Helper/Reminder.php
CHANGED
@@ -2,11 +2,12 @@
|
|
2 |
|
3 |
class Lipscore_RatingsReviews_Helper_Reminder extends Lipscore_RatingsReviews_Helper_Abstract
|
4 |
{
|
5 |
-
protected static $complexProductTypes = array(
|
6 |
-
Mage_Catalog_Model_Product_Type::TYPE_CONFIGURABLE,
|
7 |
-
Mage_Catalog_Model_Product_Type::
|
|
|
8 |
);
|
9 |
-
|
10 |
protected $productHelper = null;
|
11 |
protected $purchaseHelper = null;
|
12 |
protected $couponHelper = null;
|
@@ -22,70 +23,86 @@ class Lipscore_RatingsReviews_Helper_Reminder extends Lipscore_RatingsReviews_He
|
|
22 |
parent::__construct();
|
23 |
}
|
24 |
|
25 |
-
public function
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
26 |
{
|
27 |
$this->initConfig($order->getStoreId());
|
28 |
return array(
|
29 |
-
'purchase' => $this->
|
30 |
-
'products' => $this->
|
31 |
);
|
32 |
}
|
33 |
|
34 |
-
protected function
|
35 |
{
|
|
|
|
|
36 |
$orderItems = $order->getAllVisibleItems();
|
37 |
-
$productIds = array();
|
38 |
-
foreach ($orderItems as $item) {
|
39 |
-
$productIds[] = $this->getProductIdFromOrderItem($item);
|
40 |
-
}
|
41 |
|
42 |
-
$
|
43 |
-
|
44 |
-
|
45 |
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
50 |
}
|
51 |
|
52 |
-
return $productsData;
|
53 |
}
|
54 |
-
|
55 |
-
protected function
|
56 |
-
{
|
57 |
-
$
|
58 |
-
|
59 |
-
|
60 |
-
if (in_array($product->getTypeId(), static::$complexProductTypes)) {
|
61 |
-
return $productId;
|
62 |
}
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
return (int) $superProductConfig['product_id'];
|
67 |
}
|
68 |
-
|
69 |
-
$
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
$
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
|
|
|
|
78 |
}
|
79 |
-
|
80 |
-
return $productId;
|
81 |
-
}
|
82 |
|
83 |
-
|
84 |
-
{
|
85 |
-
return $this->productHelper->getProductData($product);
|
86 |
}
|
87 |
|
88 |
-
protected function
|
89 |
{
|
90 |
$coupon = $this->couponHelper->generateCoupon();
|
91 |
$email = $this->purchaseHelper->getEmail($order);
|
@@ -97,7 +114,7 @@ class Lipscore_RatingsReviews_Helper_Reminder extends Lipscore_RatingsReviews_He
|
|
97 |
'buyer_name' => $name,
|
98 |
'discount_descr' => $coupon ? $this->couponHelper->getCouponDescription() : '',
|
99 |
'discount_voucher' => $coupon ? $coupon->getCode() : '',
|
100 |
-
'purchased_at' =>
|
101 |
'lang' => $lang
|
102 |
);
|
103 |
}
|
2 |
|
3 |
class Lipscore_RatingsReviews_Helper_Reminder extends Lipscore_RatingsReviews_Helper_Abstract
|
4 |
{
|
5 |
+
protected static $complexProductTypes = array(
|
6 |
+
Mage_Catalog_Model_Product_Type::TYPE_CONFIGURABLE,
|
7 |
+
Mage_Catalog_Model_Product_Type::TYPE_GROUPED,
|
8 |
+
Mage_Catalog_Model_Product_Type::TYPE_BUNDLE
|
9 |
);
|
10 |
+
|
11 |
protected $productHelper = null;
|
12 |
protected $purchaseHelper = null;
|
13 |
protected $couponHelper = null;
|
23 |
parent::__construct();
|
24 |
}
|
25 |
|
26 |
+
public function singleReminderData(Mage_Sales_Model_Order $order)
|
27 |
+
{
|
28 |
+
$data = $this->orderData($order);
|
29 |
+
unset($data['purchase']['purchased_at']);
|
30 |
+
return $data;
|
31 |
+
}
|
32 |
+
|
33 |
+
public function multipleReminderData(Mage_Sales_Model_Order $order)
|
34 |
+
{
|
35 |
+
return $this->orderData($order);
|
36 |
+
}
|
37 |
+
|
38 |
+
protected function orderData(Mage_Sales_Model_Order $order)
|
39 |
{
|
40 |
$this->initConfig($order->getStoreId());
|
41 |
return array(
|
42 |
+
'purchase' => $this->purchaseData($order),
|
43 |
+
'products' => $this->productsData($order)
|
44 |
);
|
45 |
}
|
46 |
|
47 |
+
protected function productsData($order)
|
48 |
{
|
49 |
+
$productsData = array();
|
50 |
+
$storeId = $order->getStoreId();
|
51 |
$orderItems = $order->getAllVisibleItems();
|
|
|
|
|
|
|
|
|
52 |
|
53 |
+
foreach ($orderItems as $orderItem) {
|
54 |
+
$productId = $orderItem->getProductId();
|
55 |
+
$product = Mage::getModel('catalog/product')->load($productId);
|
56 |
|
57 |
+
$parentProductId = $this->getParentProductId($product, $orderItem);
|
58 |
+
if ($parentProductId) {
|
59 |
+
$product = Mage::getModel('catalog/product')->load($parentProductId);
|
60 |
+
}
|
61 |
+
|
62 |
+
$product->setStoreId($storeId);
|
63 |
+
$data = $this->productHelper->getProductData($product);
|
64 |
+
|
65 |
+
if (!$product->isVisibleInSiteVisibility() && !$parentProductId) {
|
66 |
+
$store = Mage::getModel('core/store')->load($storeId);
|
67 |
+
$data['url'] = $store->getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK);
|
68 |
+
}
|
69 |
+
|
70 |
+
$productsData[$product->getId()] = $data;
|
71 |
+
|
72 |
+
gc_collect_cycles();
|
73 |
}
|
74 |
|
75 |
+
return array_values($productsData);
|
76 |
}
|
77 |
+
|
78 |
+
protected function getParentProductId($product, $item)
|
79 |
+
{
|
80 |
+
$superProductConfig = $item->getBuyRequest()->getSuperProductConfig();
|
81 |
+
if (!empty($superProductConfig['product_id'])) {
|
82 |
+
return (int) $superProductConfig['product_id'];
|
|
|
|
|
83 |
}
|
84 |
+
|
85 |
+
if ($product->isVisibleInSiteVisibility()) {
|
86 |
+
return;
|
|
|
87 |
}
|
88 |
+
|
89 |
+
$parentId = null;
|
90 |
+
$childId = $product->getId();
|
91 |
+
$productEmulator = new Varien_Object();
|
92 |
+
foreach (static::$complexProductTypes as $key => $typeId) {
|
93 |
+
$productEmulator->setTypeId($typeId);
|
94 |
+
$productType = Mage::getSingleton('catalog/product_type')->factory($productEmulator);
|
95 |
+
$parentIds = $productType->getParentIdsByChild($childId);
|
96 |
+
if (!empty($parentIds[0])) {
|
97 |
+
$parentId = $parentIds[0];
|
98 |
+
break;
|
99 |
+
}
|
100 |
}
|
|
|
|
|
|
|
101 |
|
102 |
+
return $parentId;
|
|
|
|
|
103 |
}
|
104 |
|
105 |
+
protected function purchaseData(Mage_Sales_Model_Order $order)
|
106 |
{
|
107 |
$coupon = $this->couponHelper->generateCoupon();
|
108 |
$email = $this->purchaseHelper->getEmail($order);
|
114 |
'buyer_name' => $name,
|
115 |
'discount_descr' => $coupon ? $this->couponHelper->getCouponDescription() : '',
|
116 |
'discount_voucher' => $coupon ? $coupon->getCode() : '',
|
117 |
+
'purchased_at' => (int) $order->getCreatedAtDate()->get(),
|
118 |
'lang' => $lang
|
119 |
);
|
120 |
}
|
app/code/community/Lipscore/RatingsReviews/Helper/Widget.php
CHANGED
@@ -12,7 +12,7 @@ class Lipscore_RatingsReviews_Helper_Widget extends Lipscore_RatingsReviews_Help
|
|
12 |
}
|
13 |
return $attrs;
|
14 |
}
|
15 |
-
|
16 |
public function getRichsnippetPproductAttrs($productData)
|
17 |
{
|
18 |
$attrs = '';
|
@@ -20,10 +20,10 @@ class Lipscore_RatingsReviews_Helper_Widget extends Lipscore_RatingsReviews_Help
|
|
20 |
$attrs = $this->_getRichsnippetPproductAttrs($productData);
|
21 |
} catch (Exception $e) {
|
22 |
Lipscore_RatingsReviews_Logger::logException($e);
|
23 |
-
}
|
24 |
return $attrs;
|
25 |
}
|
26 |
-
|
27 |
protected function _getProductAttrs($productData)
|
28 |
{
|
29 |
$attrs = array(
|
@@ -38,7 +38,7 @@ class Lipscore_RatingsReviews_Helper_Widget extends Lipscore_RatingsReviews_Help
|
|
38 |
);
|
39 |
return $this->_toString($attrs);
|
40 |
}
|
41 |
-
|
42 |
protected function _getRichsnippetPproductAttrs($productData)
|
43 |
{
|
44 |
$attrs = array(
|
@@ -47,14 +47,14 @@ class Lipscore_RatingsReviews_Helper_Widget extends Lipscore_RatingsReviews_Help
|
|
47 |
);
|
48 |
return $this->_toString($attrs);
|
49 |
}
|
50 |
-
|
51 |
protected function _toString($attrs)
|
52 |
{
|
53 |
$strAttrs = array();
|
54 |
foreach ($attrs as $attr => $value) {
|
55 |
$value = htmlspecialchars($value);
|
56 |
$strAttrs[] = "$attr=\"$value\"";
|
57 |
-
}
|
58 |
return implode($strAttrs, ' ');
|
59 |
}
|
60 |
}
|
12 |
}
|
13 |
return $attrs;
|
14 |
}
|
15 |
+
|
16 |
public function getRichsnippetPproductAttrs($productData)
|
17 |
{
|
18 |
$attrs = '';
|
20 |
$attrs = $this->_getRichsnippetPproductAttrs($productData);
|
21 |
} catch (Exception $e) {
|
22 |
Lipscore_RatingsReviews_Logger::logException($e);
|
23 |
+
}
|
24 |
return $attrs;
|
25 |
}
|
26 |
+
|
27 |
protected function _getProductAttrs($productData)
|
28 |
{
|
29 |
$attrs = array(
|
38 |
);
|
39 |
return $this->_toString($attrs);
|
40 |
}
|
41 |
+
|
42 |
protected function _getRichsnippetPproductAttrs($productData)
|
43 |
{
|
44 |
$attrs = array(
|
47 |
);
|
48 |
return $this->_toString($attrs);
|
49 |
}
|
50 |
+
|
51 |
protected function _toString($attrs)
|
52 |
{
|
53 |
$strAttrs = array();
|
54 |
foreach ($attrs as $attr => $value) {
|
55 |
$value = htmlspecialchars($value);
|
56 |
$strAttrs[] = "$attr=\"$value\"";
|
57 |
+
}
|
58 |
return implode($strAttrs, ' ');
|
59 |
}
|
60 |
}
|
app/code/community/Lipscore/RatingsReviews/Logger.php
CHANGED
@@ -2,8 +2,14 @@
|
|
2 |
|
3 |
class Lipscore_RatingsReviews_Logger
|
4 |
{
|
|
|
|
|
5 |
public static function logException(Exception $e)
|
6 |
{
|
|
|
|
|
|
|
|
|
7 |
Mage::logException($e);
|
8 |
|
9 |
$store = null;
|
@@ -63,4 +69,16 @@ class Lipscore_RatingsReviews_Logger
|
|
63 |
->setBody($msg)
|
64 |
->send();
|
65 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
66 |
}
|
2 |
|
3 |
class Lipscore_RatingsReviews_Logger
|
4 |
{
|
5 |
+
protected static $ignoredWords = array('SQLSTATE');
|
6 |
+
|
7 |
public static function logException(Exception $e)
|
8 |
{
|
9 |
+
if (static::isIgnoredException($e)) {
|
10 |
+
return;
|
11 |
+
}
|
12 |
+
|
13 |
Mage::logException($e);
|
14 |
|
15 |
$store = null;
|
69 |
->setBody($msg)
|
70 |
->send();
|
71 |
}
|
72 |
+
|
73 |
+
protected static function isIgnoredException($e)
|
74 |
+
{
|
75 |
+
$found = false;
|
76 |
+
foreach (static::$ignoredWords as $key => $word) {
|
77 |
+
$found = strpos($e->getMessage(), $word) !== false;
|
78 |
+
if ($found) {
|
79 |
+
break;
|
80 |
+
}
|
81 |
+
}
|
82 |
+
return $found;
|
83 |
+
}
|
84 |
}
|
app/code/community/Lipscore/RatingsReviews/Model/Api/Request.php
CHANGED
File without changes
|
app/code/community/Lipscore/RatingsReviews/Model/Config.php
CHANGED
@@ -1,8 +1,9 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
class Lipscore_RatingsReviews_Model_Config
|
4 |
{
|
5 |
-
const
|
|
|
6 |
|
7 |
protected static $_systemConfigs = array(
|
8 |
'coupon' => 'lipscore_coupons/coupons/',
|
@@ -10,54 +11,10 @@ class Lipscore_RatingsReviews_Model_Config
|
|
10 |
'apiKey' => 'lipscore_general/api_key/',
|
11 |
'locale' => 'lipscore_general/locale/',
|
12 |
'emails' => 'lipscore_general/emails/',
|
13 |
-
'
|
|
|
14 |
);
|
15 |
|
16 |
-
protected $store = null;
|
17 |
-
protected $website = null;
|
18 |
-
|
19 |
-
public function __construct($params = array())
|
20 |
-
{
|
21 |
-
!empty($params['store']) and $this->store = $params['store'];
|
22 |
-
!empty($params['website']) and $this->website = $params['website'];
|
23 |
-
}
|
24 |
-
|
25 |
-
public function get($param, $type)
|
26 |
-
{
|
27 |
-
$key = $this->getKey($param, $type);
|
28 |
-
return $this->getMageConfig($key);
|
29 |
-
}
|
30 |
-
|
31 |
-
public function set($param, $type, $value)
|
32 |
-
{
|
33 |
-
$key = $this->getKey($param, $type);
|
34 |
-
return $this->setMageConfig($key, $value);
|
35 |
-
}
|
36 |
-
|
37 |
-
public function getMageConfig($path)
|
38 |
-
{
|
39 |
-
if ($this->store) {
|
40 |
-
return $this->store->getConfig($path);
|
41 |
-
}
|
42 |
-
if ($this->website) {
|
43 |
-
return $this->website->getConfig($path);
|
44 |
-
}
|
45 |
-
return Mage::getStoreConfig($path);
|
46 |
-
}
|
47 |
-
|
48 |
-
public function setMageConfig($path, $value)
|
49 |
-
{
|
50 |
-
if ($this->website) {
|
51 |
-
$scope = 'websites';
|
52 |
-
$scopeId = $this->website->getId();
|
53 |
-
} else {
|
54 |
-
$scope = 'stores';
|
55 |
-
$store = $this->store ? $this->store : Mage::app()->getStore();
|
56 |
-
$scopeId = $store->getId();
|
57 |
-
}
|
58 |
-
return Mage::getConfig()->saveConfig($path, $value, $scope, $scopeId);
|
59 |
-
}
|
60 |
-
|
61 |
public function apiKey()
|
62 |
{
|
63 |
return $this->get('api_key', 'apiKey');
|
@@ -88,15 +45,38 @@ class Lipscore_RatingsReviews_Model_Config
|
|
88 |
return $this->get('plugin_installation_id', 'tracking');
|
89 |
}
|
90 |
|
|
|
|
|
|
|
|
|
|
|
91 |
public function singleReminderTimeout()
|
92 |
{
|
93 |
$timeout = getenv('SINGLE_REMINDER_TIMEOUT');
|
94 |
-
return $timeout ? $timeout : static::
|
95 |
}
|
96 |
|
97 |
-
public function
|
98 |
{
|
99 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
100 |
}
|
101 |
|
102 |
public function setLastTrackedVersion($value)
|
@@ -108,9 +88,4 @@ class Lipscore_RatingsReviews_Model_Config
|
|
108 |
{
|
109 |
return $this->set('plugin_installation_id', 'tracking', $value);
|
110 |
}
|
111 |
-
|
112 |
-
protected function getKey($param, $type)
|
113 |
-
{
|
114 |
-
return self::$_systemConfigs[$type] . $param;
|
115 |
-
}
|
116 |
}
|
1 |
<?php
|
2 |
|
3 |
+
class Lipscore_RatingsReviews_Model_Config extends Lipscore_RatingsReviews_Model_Config_Abstract
|
4 |
{
|
5 |
+
const SINGLE_REMINDER_TIMEOUT = 10;
|
6 |
+
const MULTIPLE_REMINDER_TIMEOUT = 1800;
|
7 |
|
8 |
protected static $_systemConfigs = array(
|
9 |
'coupon' => 'lipscore_coupons/coupons/',
|
11 |
'apiKey' => 'lipscore_general/api_key/',
|
12 |
'locale' => 'lipscore_general/locale/',
|
13 |
'emails' => 'lipscore_general/emails/',
|
14 |
+
'module' => 'lipscore_general/module/',
|
15 |
+
'tracking' => 'lipscore_plugin/'
|
16 |
);
|
17 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
18 |
public function apiKey()
|
19 |
{
|
20 |
return $this->get('api_key', 'apiKey');
|
45 |
return $this->get('plugin_installation_id', 'tracking');
|
46 |
}
|
47 |
|
48 |
+
public function singleReminderStatus()
|
49 |
+
{
|
50 |
+
return $this->get('order_status', 'emails');
|
51 |
+
}
|
52 |
+
|
53 |
public function singleReminderTimeout()
|
54 |
{
|
55 |
$timeout = getenv('SINGLE_REMINDER_TIMEOUT');
|
56 |
+
return $timeout ? $timeout : static::SINGLE_REMINDER_TIMEOUT;
|
57 |
}
|
58 |
|
59 |
+
public function multipleReminderTimeout()
|
60 |
{
|
61 |
+
$timeout = getenv('MULTIPLE_REMINDER_TIMEOUT');
|
62 |
+
return $timeout ? $timeout : static::MULTIPLE_REMINDER_TIMEOUT;
|
63 |
+
}
|
64 |
+
|
65 |
+
public function isModuleActive()
|
66 |
+
{
|
67 |
+
return $this->get('active', 'module');
|
68 |
+
}
|
69 |
+
|
70 |
+
public function isDemoKey()
|
71 |
+
{
|
72 |
+
$currentKey = $this->apiKey();
|
73 |
+
$demokey = $this->demoApiKey();
|
74 |
+
return $currentKey == $demokey;
|
75 |
+
}
|
76 |
+
|
77 |
+
public function isValidApiKey()
|
78 |
+
{
|
79 |
+
return $this->apiKey() && !$this->isDemoKey();
|
80 |
}
|
81 |
|
82 |
public function setLastTrackedVersion($value)
|
88 |
{
|
89 |
return $this->set('plugin_installation_id', 'tracking', $value);
|
90 |
}
|
|
|
|
|
|
|
|
|
|
|
91 |
}
|
app/code/community/Lipscore/RatingsReviews/Model/Config/Abstract.php
ADDED
@@ -0,0 +1,63 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
abstract class Lipscore_RatingsReviews_Model_Config_Abstract
|
4 |
+
{
|
5 |
+
protected static $_systemConfigs = array();
|
6 |
+
|
7 |
+
protected $store = null;
|
8 |
+
protected $website = null;
|
9 |
+
|
10 |
+
public function __construct($params = array())
|
11 |
+
{
|
12 |
+
!empty($params['store']) and $this->store = $params['store'];
|
13 |
+
!empty($params['website']) and $this->website = $params['website'];
|
14 |
+
}
|
15 |
+
|
16 |
+
public function get($param, $type)
|
17 |
+
{
|
18 |
+
$key = $this->getKey($param, $type);
|
19 |
+
return $this->getMageConfig($key);
|
20 |
+
}
|
21 |
+
|
22 |
+
public function set($param, $type, $value)
|
23 |
+
{
|
24 |
+
$key = $this->getKey($param, $type);
|
25 |
+
return $this->setMageConfig($key, $value);
|
26 |
+
}
|
27 |
+
|
28 |
+
public function getMageConfig($path)
|
29 |
+
{
|
30 |
+
if ($this->store) {
|
31 |
+
return $this->store->getConfig($path);
|
32 |
+
}
|
33 |
+
if ($this->website) {
|
34 |
+
return $this->website->getConfig($path);
|
35 |
+
}
|
36 |
+
return Mage::getStoreConfig($path);
|
37 |
+
}
|
38 |
+
|
39 |
+
public function setMageConfig($path, $value)
|
40 |
+
{
|
41 |
+
if ($this->website) {
|
42 |
+
$scope = 'websites';
|
43 |
+
$scopeId = $this->website->getId();
|
44 |
+
} else {
|
45 |
+
$scope = 'stores';
|
46 |
+
$store = $this->store ? $this->store : Mage::app()->getStore();
|
47 |
+
$scopeId = $store->getId();
|
48 |
+
}
|
49 |
+
return $this->saveConfig($path, $value, $scope, $scopeId);
|
50 |
+
}
|
51 |
+
|
52 |
+
protected function saveConfig($path, $value, $scope, $scopeId)
|
53 |
+
{
|
54 |
+
$result = Mage::getConfig()->saveConfig($path, $value, $scope, $scopeId);
|
55 |
+
Mage::getConfig()->cleanCache();
|
56 |
+
return $result;
|
57 |
+
}
|
58 |
+
|
59 |
+
protected function getKey($param, $type)
|
60 |
+
{
|
61 |
+
return static::$_systemConfigs[$type] . $param;
|
62 |
+
}
|
63 |
+
}
|
app/code/community/Lipscore/RatingsReviews/Model/Config/Env.php
CHANGED
File without changes
|
app/code/community/Lipscore/RatingsReviews/Model/Config/Kickstart.php
ADDED
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Lipscore_RatingsReviews_Model_Config_Kickstart extends Lipscore_RatingsReviews_Model_Config_Abstract
|
4 |
+
{
|
5 |
+
protected static $_systemConfigs = array(
|
6 |
+
'kikstart' => 'lipscore_reminder/kikstart/'
|
7 |
+
);
|
8 |
+
|
9 |
+
public function resultJson()
|
10 |
+
{
|
11 |
+
return $this->get('result', 'kikstart');
|
12 |
+
}
|
13 |
+
|
14 |
+
public function setResult($data)
|
15 |
+
{
|
16 |
+
$data['updated_at'] = time();
|
17 |
+
return $this->set('result', 'kikstart', Zend_Json::encode($data));
|
18 |
+
}
|
19 |
+
|
20 |
+
public function clearResult()
|
21 |
+
{
|
22 |
+
return $this->set('result', 'kikstart', null);
|
23 |
+
}
|
24 |
+
|
25 |
+
public function getMageConfig($path)
|
26 |
+
{
|
27 |
+
return Mage::getConfig()->getNode($path, 'default');
|
28 |
+
}
|
29 |
+
|
30 |
+
public function setMageConfig($path, $value)
|
31 |
+
{
|
32 |
+
return $this->saveConfig($path, $value, 'default', 0);
|
33 |
+
}
|
34 |
+
}
|
app/code/community/Lipscore/RatingsReviews/Model/Coupon/Generator.php
CHANGED
@@ -5,24 +5,24 @@ class Lipscore_RatingsReviews_Model_Coupon_Generator
|
|
5 |
public function generate($rule, $data)
|
6 |
{
|
7 |
$generator = $rule->getCouponMassGenerator();
|
8 |
-
|
9 |
if (!$generator->validateData($data)) {
|
10 |
-
return null;
|
11 |
}
|
12 |
|
13 |
$generator->setData($data);
|
14 |
$size = $generator->getQty();
|
15 |
-
|
16 |
$maxProbability = $generator->getMaxProbability() ? $generator->getMaxProbability() : $generator::MAX_PROBABILITY_OF_GUESSING;
|
17 |
$maxAttempts = $generator->getMaxAttempts() ? $generator->getMaxAttempts() : $generator::MAX_GENERATE_ATTEMPTS;
|
18 |
-
|
19 |
$coupon = Mage::getModel('salesrule/coupon');
|
20 |
-
|
21 |
$chars = count(Mage::helper('salesrule/coupon')->getCharset($generator->getFormat()));
|
22 |
$length = (int) $generator->getLength();
|
23 |
$maxCodes = pow($chars, $length);
|
24 |
$probability = $size / $maxCodes;
|
25 |
-
|
26 |
//increase the length of Code if probability is low
|
27 |
if ($probability > $maxProbability) {
|
28 |
do {
|
@@ -32,11 +32,11 @@ class Lipscore_RatingsReviews_Model_Coupon_Generator
|
|
32 |
} while ($probability > $maxProbability);
|
33 |
$generator->setLength($length);
|
34 |
}
|
35 |
-
|
36 |
$now = $generator->getResource()->formatDate(
|
37 |
Mage::getSingleton('core/date')->gmtTimestamp()
|
38 |
);
|
39 |
-
|
40 |
$attempt = 0;
|
41 |
do {
|
42 |
if ($attempt >= $maxAttempts) {
|
@@ -45,12 +45,12 @@ class Lipscore_RatingsReviews_Model_Coupon_Generator
|
|
45 |
$code = $generator->generateCode();
|
46 |
$attempt++;
|
47 |
} while ($generator->getResource()->exists($code));
|
48 |
-
|
49 |
$expirationDate = $generator->getToDate();
|
50 |
if ($expirationDate instanceof Zend_Date) {
|
51 |
$expirationDate = $expirationDate->toString(Varien_Date::DATETIME_INTERNAL_FORMAT);
|
52 |
}
|
53 |
-
|
54 |
$coupon->setId(null)
|
55 |
->setRuleId($generator->getRuleId())
|
56 |
->setUsageLimit($generator->getUsesPerCoupon())
|
@@ -60,7 +60,7 @@ class Lipscore_RatingsReviews_Model_Coupon_Generator
|
|
60 |
->setType(Mage_SalesRule_Helper_Coupon::COUPON_TYPE_SPECIFIC_AUTOGENERATED)
|
61 |
->setCode($code)
|
62 |
->save();
|
63 |
-
|
64 |
return $coupon;
|
65 |
}
|
66 |
}
|
5 |
public function generate($rule, $data)
|
6 |
{
|
7 |
$generator = $rule->getCouponMassGenerator();
|
8 |
+
|
9 |
if (!$generator->validateData($data)) {
|
10 |
+
return null;
|
11 |
}
|
12 |
|
13 |
$generator->setData($data);
|
14 |
$size = $generator->getQty();
|
15 |
+
|
16 |
$maxProbability = $generator->getMaxProbability() ? $generator->getMaxProbability() : $generator::MAX_PROBABILITY_OF_GUESSING;
|
17 |
$maxAttempts = $generator->getMaxAttempts() ? $generator->getMaxAttempts() : $generator::MAX_GENERATE_ATTEMPTS;
|
18 |
+
|
19 |
$coupon = Mage::getModel('salesrule/coupon');
|
20 |
+
|
21 |
$chars = count(Mage::helper('salesrule/coupon')->getCharset($generator->getFormat()));
|
22 |
$length = (int) $generator->getLength();
|
23 |
$maxCodes = pow($chars, $length);
|
24 |
$probability = $size / $maxCodes;
|
25 |
+
|
26 |
//increase the length of Code if probability is low
|
27 |
if ($probability > $maxProbability) {
|
28 |
do {
|
32 |
} while ($probability > $maxProbability);
|
33 |
$generator->setLength($length);
|
34 |
}
|
35 |
+
|
36 |
$now = $generator->getResource()->formatDate(
|
37 |
Mage::getSingleton('core/date')->gmtTimestamp()
|
38 |
);
|
39 |
+
|
40 |
$attempt = 0;
|
41 |
do {
|
42 |
if ($attempt >= $maxAttempts) {
|
45 |
$code = $generator->generateCode();
|
46 |
$attempt++;
|
47 |
} while ($generator->getResource()->exists($code));
|
48 |
+
|
49 |
$expirationDate = $generator->getToDate();
|
50 |
if ($expirationDate instanceof Zend_Date) {
|
51 |
$expirationDate = $expirationDate->toString(Varien_Date::DATETIME_INTERNAL_FORMAT);
|
52 |
}
|
53 |
+
|
54 |
$coupon->setId(null)
|
55 |
->setRuleId($generator->getRuleId())
|
56 |
->setUsageLimit($generator->getUsesPerCoupon())
|
60 |
->setType(Mage_SalesRule_Helper_Coupon::COUPON_TYPE_SPECIFIC_AUTOGENERATED)
|
61 |
->setCode($code)
|
62 |
->save();
|
63 |
+
|
64 |
return $coupon;
|
65 |
}
|
66 |
}
|
app/code/community/Lipscore/RatingsReviews/Model/Observer/Abstract.php
CHANGED
@@ -2,6 +2,8 @@
|
|
2 |
|
3 |
abstract class Lipscore_RatingsReviews_Model_Observer_Abstract
|
4 |
{
|
|
|
|
|
5 |
protected $moduleHelper;
|
6 |
|
7 |
public function __construct()
|
@@ -10,8 +12,33 @@ abstract class Lipscore_RatingsReviews_Model_Observer_Abstract
|
|
10 |
}
|
11 |
|
12 |
public function __call($method, $arguments) {
|
13 |
-
|
14 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
}
|
16 |
}
|
17 |
}
|
2 |
|
3 |
abstract class Lipscore_RatingsReviews_Model_Observer_Abstract
|
4 |
{
|
5 |
+
protected static $logFile = 'observer';
|
6 |
+
|
7 |
protected $moduleHelper;
|
8 |
|
9 |
public function __construct()
|
12 |
}
|
13 |
|
14 |
public function __call($method, $arguments) {
|
15 |
+
try {
|
16 |
+
$this->log($method);
|
17 |
+
if ($this->methodAvailable($method)) {
|
18 |
+
return call_user_func_array(array($this, $method), $arguments);
|
19 |
+
}
|
20 |
+
} catch (Exception $e) {
|
21 |
+
Lipscore_RatingsReviews_Logger::logException($e);
|
22 |
+
}
|
23 |
+
}
|
24 |
+
|
25 |
+
abstract protected function methodAvailable($method);
|
26 |
+
|
27 |
+
protected function log($message)
|
28 |
+
{
|
29 |
+
if (!getenv('LIPSCORE_LOG_OBSERVER')) {
|
30 |
+
return;
|
31 |
+
}
|
32 |
+
|
33 |
+
$filePath = Mage::getBaseDir('var') . DS . 'log' . DS . static::$logFile . '.log';
|
34 |
+
file_put_contents($filePath, print_r($message, true) . "\n", FILE_APPEND);
|
35 |
+
}
|
36 |
+
|
37 |
+
protected function disableModuleOutput($moduleName)
|
38 |
+
{
|
39 |
+
$outputPath = 'advanced/modules_disable_output/' . $moduleName;
|
40 |
+
if (!Mage::getStoreConfig($outputPath)) {
|
41 |
+
Mage::app()->getStore()->setConfig($outputPath, true);
|
42 |
}
|
43 |
}
|
44 |
}
|
app/code/community/Lipscore/RatingsReviews/Model/Observer/Module.php
CHANGED
@@ -2,16 +2,9 @@
|
|
2 |
|
3 |
class Lipscore_RatingsReviews_Model_Observer_Module extends Lipscore_RatingsReviews_Model_Observer_Abstract
|
4 |
{
|
5 |
-
|
6 |
-
{
|
7 |
-
try {
|
8 |
-
$this->_checkVersion($observer);
|
9 |
-
} catch (Exception $e) {
|
10 |
-
Lipscore_RatingsReviews_Logger::logException($e);
|
11 |
-
}
|
12 |
-
}
|
13 |
|
14 |
-
|
15 |
{
|
16 |
if ($this->moduleHelper->isNewVersion()) {
|
17 |
$website = Mage::app()->getWebsite();
|
@@ -19,4 +12,19 @@ class Lipscore_RatingsReviews_Model_Observer_Module extends Lipscore_RatingsRevi
|
|
19 |
$tracker->trackUpgrade($website);
|
20 |
}
|
21 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
22 |
}
|
2 |
|
3 |
class Lipscore_RatingsReviews_Model_Observer_Module extends Lipscore_RatingsReviews_Model_Observer_Abstract
|
4 |
{
|
5 |
+
const MODULE = 'Lipscore_RatingsReviews';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6 |
|
7 |
+
protected function checkVersion(Varien_Event_Observer $observer)
|
8 |
{
|
9 |
if ($this->moduleHelper->isNewVersion()) {
|
10 |
$website = Mage::app()->getWebsite();
|
12 |
$tracker->trackUpgrade($website);
|
13 |
}
|
14 |
}
|
15 |
+
|
16 |
+
protected function disableOutput(Varien_Event_Observer $observer)
|
17 |
+
{
|
18 |
+
if (!$this->moduleHelper->isLipscoreOutputEnabled()) {
|
19 |
+
$this->disableModuleOutput(self::MODULE);
|
20 |
+
}
|
21 |
+
}
|
22 |
+
|
23 |
+
protected function methodAvailable($method)
|
24 |
+
{
|
25 |
+
if ($method == 'disableOutput') {
|
26 |
+
return true;
|
27 |
+
}
|
28 |
+
return $this->moduleHelper->isLipscoreModuleEnabled();
|
29 |
+
}
|
30 |
}
|
app/code/community/Lipscore/RatingsReviews/Model/Observer/Order/Status.php
CHANGED
@@ -2,16 +2,9 @@
|
|
2 |
|
3 |
class Lipscore_RatingsReviews_Model_Observer_Order_Status extends Lipscore_RatingsReviews_Model_Observer_Abstract
|
4 |
{
|
5 |
-
|
6 |
-
{
|
7 |
-
try {
|
8 |
-
$this->_fetch($observer);
|
9 |
-
} catch (Exception $e) {
|
10 |
-
Lipscore_RatingsReviews_Logger::logException($e);
|
11 |
-
}
|
12 |
-
}
|
13 |
|
14 |
-
|
15 |
{
|
16 |
$this->log(date('Y-m-d H:i:s') . ' start fetch');
|
17 |
$order = $observer->getEvent()->getOrder();
|
@@ -23,24 +16,19 @@ class Lipscore_RatingsReviews_Model_Observer_Order_Status extends Lipscore_Ratin
|
|
23 |
}
|
24 |
}
|
25 |
|
26 |
-
|
27 |
-
{
|
28 |
-
try {
|
29 |
-
$this->_check($observer);
|
30 |
-
} catch (Exception $e) {
|
31 |
-
Lipscore_RatingsReviews_Logger::logException($e);
|
32 |
-
}
|
33 |
-
}
|
34 |
-
|
35 |
-
private function _check(Varien_Event_Observer $observer)
|
36 |
{
|
37 |
$this->log(date('Y-m-d H:i:s') . ' start check');
|
38 |
$order = $observer->getEvent()->getOrder();
|
39 |
-
|
|
|
|
|
|
|
|
|
40 |
|
41 |
$oldStatus = $this->fetchFromRegistery($order);
|
42 |
$this->log('old status: ' . $oldStatus);
|
43 |
-
$currentStatus = $
|
44 |
$this->log('current status: ' . $currentStatus);
|
45 |
$statusChanged = ($oldStatus != $currentStatus);
|
46 |
$this->log('status change: ' . (int) $statusChanged);
|
@@ -48,11 +36,11 @@ class Lipscore_RatingsReviews_Model_Observer_Order_Status extends Lipscore_Ratin
|
|
48 |
return;
|
49 |
}
|
50 |
|
51 |
-
$properStatus = $this->isReminderableStatus($currentStatus, $
|
52 |
$this->log('proper status: ' . (int) $properStatus);
|
53 |
if ($properStatus) {
|
54 |
$this->log('SEND!');
|
55 |
-
$res = $this->reminder($
|
56 |
$this->log($res);
|
57 |
}
|
58 |
}
|
@@ -79,9 +67,9 @@ class Lipscore_RatingsReviews_Model_Observer_Order_Status extends Lipscore_Ratin
|
|
79 |
return $orderId ? "lipscore_order_status_$orderId" : '';
|
80 |
}
|
81 |
|
82 |
-
private function isReminderableStatus($status, $
|
83 |
{
|
84 |
-
$reminderableStatus = $
|
85 |
$this->log('reminderable status: ' . $reminderableStatus);
|
86 |
if (!$reminderableStatus) {
|
87 |
return false;
|
@@ -90,21 +78,18 @@ class Lipscore_RatingsReviews_Model_Observer_Order_Status extends Lipscore_Ratin
|
|
90 |
}
|
91 |
}
|
92 |
|
93 |
-
private function reminder($
|
94 |
{
|
95 |
-
return Mage::getModel(
|
96 |
-
'lipscore_ratingsreviews/purchase_reminder',
|
97 |
-
array('timeout' => $this->config($storeId)->singleReminderTimeout())
|
98 |
-
);
|
99 |
}
|
100 |
|
101 |
-
private function config($
|
102 |
{
|
103 |
-
return Mage::
|
104 |
}
|
105 |
|
106 |
-
|
107 |
{
|
108 |
-
|
109 |
}
|
110 |
}
|
2 |
|
3 |
class Lipscore_RatingsReviews_Model_Observer_Order_Status extends Lipscore_RatingsReviews_Model_Observer_Abstract
|
4 |
{
|
5 |
+
protected static $logFile = 'observer_status';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6 |
|
7 |
+
protected function fetch(Varien_Event_Observer $observer)
|
8 |
{
|
9 |
$this->log(date('Y-m-d H:i:s') . ' start fetch');
|
10 |
$order = $observer->getEvent()->getOrder();
|
16 |
}
|
17 |
}
|
18 |
|
19 |
+
protected function check(Varien_Event_Observer $observer)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
20 |
{
|
21 |
$this->log(date('Y-m-d H:i:s') . ' start check');
|
22 |
$order = $observer->getEvent()->getOrder();
|
23 |
+
|
24 |
+
$config = $this->config($order->getStore());
|
25 |
+
if (!$config->isValidApiKey()) {
|
26 |
+
return;
|
27 |
+
}
|
28 |
|
29 |
$oldStatus = $this->fetchFromRegistery($order);
|
30 |
$this->log('old status: ' . $oldStatus);
|
31 |
+
$currentStatus = $order->getStatus();
|
32 |
$this->log('current status: ' . $currentStatus);
|
33 |
$statusChanged = ($oldStatus != $currentStatus);
|
34 |
$this->log('status change: ' . (int) $statusChanged);
|
36 |
return;
|
37 |
}
|
38 |
|
39 |
+
$properStatus = $this->isReminderableStatus($currentStatus, $config);
|
40 |
$this->log('proper status: ' . (int) $properStatus);
|
41 |
if ($properStatus) {
|
42 |
$this->log('SEND!');
|
43 |
+
$res = $this->reminder($config)->sendSingle($order);
|
44 |
$this->log($res);
|
45 |
}
|
46 |
}
|
67 |
return $orderId ? "lipscore_order_status_$orderId" : '';
|
68 |
}
|
69 |
|
70 |
+
private function isReminderableStatus($status, $config)
|
71 |
{
|
72 |
+
$reminderableStatus = $config->singleReminderStatus();
|
73 |
$this->log('reminderable status: ' . $reminderableStatus);
|
74 |
if (!$reminderableStatus) {
|
75 |
return false;
|
78 |
}
|
79 |
}
|
80 |
|
81 |
+
private function reminder($config)
|
82 |
{
|
83 |
+
return Mage::getModel('lipscore_ratingsreviews/purchase_reminder', array('config' => $config));
|
|
|
|
|
|
|
84 |
}
|
85 |
|
86 |
+
private function config($store)
|
87 |
{
|
88 |
+
return Mage::getModel('lipscore_ratingsreviews/config', array('store' => $store));
|
89 |
}
|
90 |
|
91 |
+
protected function methodAvailable($method)
|
92 |
{
|
93 |
+
return $this->moduleHelper->isLipscoreModuleEnabled();
|
94 |
}
|
95 |
}
|
app/code/community/Lipscore/RatingsReviews/Model/Observer/Output.php
CHANGED
@@ -7,16 +7,7 @@ class Lipscore_RatingsReviews_Model_Observer_Output extends Lipscore_RatingsRevi
|
|
7 |
|
8 |
const REVIEW_TITLE_PLACEHOLDER = 'lipscore_reviews_placeholder';
|
9 |
|
10 |
-
|
11 |
-
{
|
12 |
-
try {
|
13 |
-
$this->_manageMageReviewModule($observer);
|
14 |
-
} catch (Exception $e) {
|
15 |
-
Lipscore_RatingsReviews_Logger::logException($e);
|
16 |
-
}
|
17 |
-
}
|
18 |
-
|
19 |
-
protected function _manageMageReviewModule(Varien_Event_Observer $observer)
|
20 |
{
|
21 |
if (!Mage::helper('core/data')->isModuleEnabled(self::REVIEW_MODULE)) {
|
22 |
$nodePath = 'modules/' . self::REVIEW_MODULE . '/active';
|
@@ -33,16 +24,7 @@ class Lipscore_RatingsReviews_Model_Observer_Output extends Lipscore_RatingsRevi
|
|
33 |
Mage::getConfig()->setNode($nodePath, 'Lipscore_RatingsReviews_Block_Catalog_Product_View', true);
|
34 |
}
|
35 |
|
36 |
-
|
37 |
-
{
|
38 |
-
try {
|
39 |
-
$this->_addRatings($observer);
|
40 |
-
} catch (Exception $e) {
|
41 |
-
Lipscore_RatingsReviews_Logger::logException($e);
|
42 |
-
}
|
43 |
-
}
|
44 |
-
|
45 |
-
protected function _addRatings(Varien_Event_Observer $observer)
|
46 |
{
|
47 |
$collection = $observer->getEvent()->getCollection();
|
48 |
if ($collection->count()) {
|
@@ -54,16 +36,7 @@ class Lipscore_RatingsReviews_Model_Observer_Output extends Lipscore_RatingsRevi
|
|
54 |
return $this;
|
55 |
}
|
56 |
|
57 |
-
|
58 |
-
{
|
59 |
-
try {
|
60 |
-
$this->_addReviewsTab($observer);
|
61 |
-
} catch (Exception $e) {
|
62 |
-
Lipscore_RatingsReviews_Logger::logException($e);
|
63 |
-
}
|
64 |
-
}
|
65 |
-
|
66 |
-
protected function _addReviewsTab(Varien_Event_Observer $observer)
|
67 |
{
|
68 |
$layout = $observer->getEvent()->getLayout();
|
69 |
|
@@ -80,16 +53,7 @@ class Lipscore_RatingsReviews_Model_Observer_Output extends Lipscore_RatingsRevi
|
|
80 |
}
|
81 |
}
|
82 |
|
83 |
-
|
84 |
-
{
|
85 |
-
try {
|
86 |
-
$this->_addReviewsFeatures($observer);
|
87 |
-
} catch (Exception $e) {
|
88 |
-
Lipscore_RatingsReviews_Logger::logException($e);
|
89 |
-
}
|
90 |
-
}
|
91 |
-
|
92 |
-
protected function _addReviewsFeatures(Varien_Event_Observer $observer)
|
93 |
{
|
94 |
$block = $observer->getBlock();
|
95 |
$layout = $block->getLayout();
|
@@ -121,11 +85,8 @@ class Lipscore_RatingsReviews_Model_Observer_Output extends Lipscore_RatingsRevi
|
|
121 |
}
|
122 |
}
|
123 |
|
124 |
-
protected function
|
125 |
{
|
126 |
-
|
127 |
-
if (!Mage::getStoreConfig($outputPath)) {
|
128 |
-
Mage::app()->getStore()->setConfig($outputPath, true);
|
129 |
-
}
|
130 |
}
|
131 |
}
|
7 |
|
8 |
const REVIEW_TITLE_PLACEHOLDER = 'lipscore_reviews_placeholder';
|
9 |
|
10 |
+
protected function manageMageReviewModule(Varien_Event_Observer $observer)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
{
|
12 |
if (!Mage::helper('core/data')->isModuleEnabled(self::REVIEW_MODULE)) {
|
13 |
$nodePath = 'modules/' . self::REVIEW_MODULE . '/active';
|
24 |
Mage::getConfig()->setNode($nodePath, 'Lipscore_RatingsReviews_Block_Catalog_Product_View', true);
|
25 |
}
|
26 |
|
27 |
+
protected function addRatings(Varien_Event_Observer $observer)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
28 |
{
|
29 |
$collection = $observer->getEvent()->getCollection();
|
30 |
if ($collection->count()) {
|
36 |
return $this;
|
37 |
}
|
38 |
|
39 |
+
protected function addReviewsTab(Varien_Event_Observer $observer)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
40 |
{
|
41 |
$layout = $observer->getEvent()->getLayout();
|
42 |
|
53 |
}
|
54 |
}
|
55 |
|
56 |
+
protected function addReviewsFeatures(Varien_Event_Observer $observer)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
57 |
{
|
58 |
$block = $observer->getBlock();
|
59 |
$layout = $block->getLayout();
|
85 |
}
|
86 |
}
|
87 |
|
88 |
+
protected function methodAvailable($method)
|
89 |
{
|
90 |
+
return $this->moduleHelper->isLipscoreActive();
|
|
|
|
|
|
|
91 |
}
|
92 |
}
|
app/code/community/Lipscore/RatingsReviews/Model/Purchase/Reminder.php
CHANGED
@@ -3,38 +3,55 @@
|
|
3 |
class Lipscore_RatingsReviews_Model_Purchase_Reminder
|
4 |
{
|
5 |
protected $dataHelper;
|
6 |
-
protected $
|
7 |
|
8 |
public function __construct($params)
|
9 |
{
|
10 |
-
$this->timeout = isset($params['timeout']) ? $params['timeout'] : null;
|
11 |
$this->dataHelper = Mage::helper('lipscore_ratingsreviews/reminder');
|
|
|
12 |
}
|
13 |
|
14 |
public function sendSingle($order)
|
15 |
{
|
16 |
-
|
17 |
-
|
|
|
|
|
|
|
|
|
18 |
return $sender->send($data);
|
19 |
}
|
20 |
|
21 |
-
public function sendMultiple($orders)
|
22 |
{
|
|
|
|
|
|
|
|
|
|
|
23 |
$data = array();
|
24 |
|
25 |
foreach ($orders as $order) {
|
26 |
-
$data[] = $this->dataHelper->
|
|
|
|
|
27 |
}
|
28 |
-
|
29 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
30 |
}
|
31 |
|
32 |
-
protected function sender($
|
33 |
-
|
34 |
return Mage::getModel('lipscore_ratingsreviews/api_request', array(
|
35 |
-
'lipscoreConfig' => $config,
|
36 |
'path' => 'purchases',
|
37 |
-
'timeout' => $
|
38 |
));
|
39 |
}
|
40 |
}
|
3 |
class Lipscore_RatingsReviews_Model_Purchase_Reminder
|
4 |
{
|
5 |
protected $dataHelper;
|
6 |
+
protected $config;
|
7 |
|
8 |
public function __construct($params)
|
9 |
{
|
|
|
10 |
$this->dataHelper = Mage::helper('lipscore_ratingsreviews/reminder');
|
11 |
+
$this->config = $params['config'];
|
12 |
}
|
13 |
|
14 |
public function sendSingle($order)
|
15 |
{
|
16 |
+
if (!$this->config->isValidApiKey()) {
|
17 |
+
return false;
|
18 |
+
}
|
19 |
+
|
20 |
+
$sender = $this->sender($this->config->singleReminderTimeout());
|
21 |
+
$data = $this->dataHelper->singleReminderData($order);
|
22 |
return $sender->send($data);
|
23 |
}
|
24 |
|
25 |
+
public function sendMultiple($orders, $batchNumber, $totalOrderCount, &$processed)
|
26 |
{
|
27 |
+
if (!$this->config->isValidApiKey()) {
|
28 |
+
return false;
|
29 |
+
}
|
30 |
+
|
31 |
+
$kickstartHelper = Mage::helper('lipscore_ratingsreviews/kickstart');
|
32 |
$data = array();
|
33 |
|
34 |
foreach ($orders as $order) {
|
35 |
+
$data[] = $this->dataHelper->multipleReminderData($order);
|
36 |
+
$processed++;
|
37 |
+
$kickstartHelper->saveTempResult($processed);
|
38 |
}
|
39 |
+
|
40 |
+
$sender = $this->sender($this->config->multipleReminderTimeout());
|
41 |
+
return $sender->send(array(
|
42 |
+
'purchases' => $data,
|
43 |
+
'kickstart' => true,
|
44 |
+
'kickstart_batch' => $batchNumber,
|
45 |
+
'kickstart_total_count' => $totalOrderCount
|
46 |
+
));
|
47 |
}
|
48 |
|
49 |
+
protected function sender($timeout)
|
50 |
+
{
|
51 |
return Mage::getModel('lipscore_ratingsreviews/api_request', array(
|
52 |
+
'lipscoreConfig' => $this->config,
|
53 |
'path' => 'purchases',
|
54 |
+
'timeout' => $timeout
|
55 |
));
|
56 |
}
|
57 |
}
|
app/code/community/Lipscore/RatingsReviews/Model/Shop.php
CHANGED
File without changes
|
app/code/community/Lipscore/RatingsReviews/Model/System/Config/Backend/Apikey.php
CHANGED
File without changes
|
app/code/community/Lipscore/RatingsReviews/Model/System/Config/Backend/Module.php
ADDED
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Lipscore_RatingsReviews_Model_System_Config_Backend_Module extends Mage_Core_Model_Config_Data
|
4 |
+
{
|
5 |
+
protected $isChanged = false;
|
6 |
+
|
7 |
+
protected function _afterSave()
|
8 |
+
{
|
9 |
+
parent::_afterSave();
|
10 |
+
|
11 |
+
$this->isChanged = true;
|
12 |
+
|
13 |
+
return $this;
|
14 |
+
}
|
15 |
+
|
16 |
+
public function afterCommitCallback()
|
17 |
+
{
|
18 |
+
parent::afterCommitCallback();
|
19 |
+
|
20 |
+
try {
|
21 |
+
$this->flushCache();
|
22 |
+
} catch (Exception $e) {
|
23 |
+
Lipscore_RatingsReviews_Logger::logException($e);
|
24 |
+
}
|
25 |
+
|
26 |
+
return $this;
|
27 |
+
}
|
28 |
+
|
29 |
+
protected function flushCache()
|
30 |
+
{
|
31 |
+
if ($this->isChanged) {
|
32 |
+
Mage::app()->cleanCache();
|
33 |
+
}
|
34 |
+
}
|
35 |
+
}
|
app/code/community/Lipscore/RatingsReviews/Model/System/Config/Source/Active.php
ADDED
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Lipscore_RatingsReviews_Model_System_Config_Source_Active
|
4 |
+
{
|
5 |
+
public function toOptionArray()
|
6 |
+
{
|
7 |
+
return array(
|
8 |
+
array('value' => 1, 'label'=>Mage::helper('adminhtml')->__('Active')),
|
9 |
+
array('value' => 0, 'label'=>Mage::helper('adminhtml')->__('Inactive')),
|
10 |
+
);
|
11 |
+
}
|
12 |
+
}
|
app/code/community/Lipscore/RatingsReviews/Model/System/Config/Source/Locale.php
CHANGED
File without changes
|
app/code/community/Lipscore/RatingsReviews/Model/System/Config/Source/Order/Status.php
DELETED
@@ -1,30 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
class Lipscore_RatingsReviews_Model_System_Config_Source_Order_Status
|
3 |
-
{
|
4 |
-
public function toOptionArray()
|
5 |
-
{
|
6 |
-
$options = array(
|
7 |
-
array('value' =>'', 'label' => Mage::helper('adminhtml')->__('Disable the Review Request Email'))
|
8 |
-
);
|
9 |
-
|
10 |
-
try {
|
11 |
-
$options = $this->collectStatuses($options);
|
12 |
-
} catch (Exception $e) {
|
13 |
-
Lipscore_RatingsReviews_Logger::logException($e);
|
14 |
-
}
|
15 |
-
|
16 |
-
return $options;
|
17 |
-
}
|
18 |
-
|
19 |
-
protected function collectStatuses($options)
|
20 |
-
{
|
21 |
-
$statuses = Mage::getSingleton('sales/order_config')->getStatuses();
|
22 |
-
foreach ($statuses as $code => $label) {
|
23 |
-
$options[] = array(
|
24 |
-
'value' => $code,
|
25 |
-
'label' => $label
|
26 |
-
);
|
27 |
-
}
|
28 |
-
return $options;
|
29 |
-
}
|
30 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/community/Lipscore/RatingsReviews/Model/System/Config/Source/Order/Status/Abstract.php
CHANGED
File without changes
|
app/code/community/Lipscore/RatingsReviews/Model/System/Config/Source/Order/Status/Reminder.php
CHANGED
File without changes
|
app/code/community/Lipscore/RatingsReviews/Model/System/Config/Source/Order/Status/Reminders.php
CHANGED
File without changes
|
app/code/community/Lipscore/RatingsReviews/Model/System/Config/Source/Pricerule.php
CHANGED
File without changes
|
app/code/community/Lipscore/RatingsReviews/Model/System/Config/Source/Productattr/Brand.php
CHANGED
File without changes
|
app/code/community/Lipscore/RatingsReviews/Model/System/Config/Source/Reminderperiod.php
CHANGED
File without changes
|
app/code/community/Lipscore/RatingsReviews/Model/Tracker/Action.php
CHANGED
File without changes
|
app/code/community/Lipscore/RatingsReviews/Model/Tracker/Installation.php
CHANGED
File without changes
|
app/code/community/Lipscore/RatingsReviews/controllers/Purchases/RemindersController.php
CHANGED
@@ -2,75 +2,169 @@
|
|
2 |
|
3 |
class Lipscore_RatingsReviews_Purchases_RemindersController extends Mage_Adminhtml_Controller_Action
|
4 |
{
|
5 |
-
|
|
|
|
|
6 |
|
7 |
public function preDispatch()
|
8 |
{
|
9 |
Mage::setIsDeveloperMode(true);
|
10 |
-
parent::preDispatch();
|
11 |
-
}
|
12 |
-
|
13 |
-
public function sendAction()
|
14 |
-
{
|
15 |
if (!$this->getRequest()->isAjax()) {
|
16 |
Lipscore_RatingsReviews_Logger::logException(new Exception('Non-ajax request to sending reminders action'));
|
17 |
$this->_forward('noRoute');
|
18 |
return;
|
19 |
}
|
|
|
|
|
20 |
|
|
|
|
|
21 |
try {
|
22 |
-
$this->
|
23 |
} catch (Exception $e) {
|
24 |
Lipscore_RatingsReviews_Logger::logException($e);
|
25 |
-
$this->response(false, $e->getMessage() .
|
26 |
}
|
27 |
}
|
28 |
|
29 |
-
|
30 |
{
|
31 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
32 |
|
|
|
|
|
33 |
$period = $this->getPeriod();
|
34 |
$statuses = $this->getStatuses();
|
35 |
|
36 |
-
$
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
$store = $this->getStore();
|
41 |
-
if ($store) {
|
42 |
-
$orders->addAttributeToFilter('store_id', array('eq' => $store->getId()));
|
43 |
}
|
|
|
44 |
|
45 |
-
|
46 |
-
|
47 |
-
|
|
|
|
|
|
|
48 |
|
49 |
-
$
|
50 |
-
'websiteCode' => $this->getWebsiteCode(),
|
51 |
-
'storeCode' => $this->getStoreCode()
|
52 |
-
));
|
53 |
|
54 |
-
$
|
55 |
-
|
56 |
-
$
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
57 |
} else {
|
58 |
-
$this->response(false,
|
59 |
}
|
60 |
}
|
61 |
|
62 |
-
protected function
|
63 |
{
|
64 |
-
$
|
65 |
-
|
66 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
67 |
}
|
68 |
}
|
69 |
|
70 |
protected function getPeriod()
|
71 |
{
|
72 |
$data = $this->getRequest()->getParams();
|
73 |
-
$format =
|
74 |
|
75 |
try {
|
76 |
$startDate = empty($data['from']) ? false : new Zend_Date($data['from'], $format);
|
@@ -80,34 +174,45 @@ class Lipscore_RatingsReviews_Purchases_RemindersController extends Mage_Adminht
|
|
80 |
$endDate = false;
|
81 |
}
|
82 |
|
83 |
-
$correctPeriod = $startDate && $endDate
|
84 |
if (!$correctPeriod) {
|
85 |
$this->response(false, 'Please set a correct period.');
|
86 |
}
|
87 |
-
|
88 |
-
$result = array('datetime' => true);
|
89 |
-
if ($startDate) {
|
90 |
-
$result['from'] = $startDate;
|
91 |
-
}
|
92 |
-
if ($endDate) {
|
93 |
-
$result['to'] = $endDate;
|
94 |
-
}
|
95 |
-
|
96 |
-
return $result;
|
97 |
}
|
98 |
|
99 |
protected function getStatuses()
|
100 |
{
|
101 |
$statuses = $this->getRequest()->getParam('status', array());
|
102 |
if (empty($statuses)) {
|
103 |
-
$this->response(false, 'Please select order status.');
|
104 |
}
|
105 |
return $statuses;
|
106 |
}
|
107 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
108 |
protected function response($result, $response)
|
109 |
{
|
110 |
-
$body = Zend_Json::encode(array('
|
111 |
$this->getResponse()
|
112 |
->setHeader('Content-Type', 'application/json')
|
113 |
->setBody($body);
|
@@ -121,32 +226,41 @@ class Lipscore_RatingsReviews_Purchases_RemindersController extends Mage_Adminht
|
|
121 |
exit(0);
|
122 |
}
|
123 |
|
124 |
-
protected function
|
125 |
{
|
126 |
-
|
127 |
-
$websiteCode = $this->getWebsiteCode();
|
128 |
-
$storeCode = $this->getStoreCode();
|
129 |
-
|
130 |
-
$this->lipscoreConfig = Mage::helper('lipscore_ratingsreviews/config')->getScoped($websiteCode, $storeCode);
|
131 |
-
}
|
132 |
-
return $this->lipscoreConfig;
|
133 |
}
|
134 |
|
135 |
-
protected function
|
136 |
{
|
137 |
-
|
138 |
-
|
139 |
-
return Mage::getModel('core/store')->load($code);
|
140 |
}
|
|
|
141 |
}
|
|
|
142 |
|
143 |
-
|
144 |
-
|
145 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
146 |
}
|
147 |
|
148 |
-
|
149 |
-
|
150 |
-
|
|
|
151 |
}
|
152 |
}
|
2 |
|
3 |
class Lipscore_RatingsReviews_Purchases_RemindersController extends Mage_Adminhtml_Controller_Action
|
4 |
{
|
5 |
+
const BATCH_SIZE = 25;
|
6 |
+
|
7 |
+
protected $kickstartHelper;
|
8 |
|
9 |
public function preDispatch()
|
10 |
{
|
11 |
Mage::setIsDeveloperMode(true);
|
|
|
|
|
|
|
|
|
|
|
12 |
if (!$this->getRequest()->isAjax()) {
|
13 |
Lipscore_RatingsReviews_Logger::logException(new Exception('Non-ajax request to sending reminders action'));
|
14 |
$this->_forward('noRoute');
|
15 |
return;
|
16 |
}
|
17 |
+
parent::preDispatch();
|
18 |
+
}
|
19 |
|
20 |
+
public function previewAction()
|
21 |
+
{
|
22 |
try {
|
23 |
+
$this->preview();
|
24 |
} catch (Exception $e) {
|
25 |
Lipscore_RatingsReviews_Logger::logException($e);
|
26 |
+
$this->response(false, $e->getMessage() . "\n" . $e->getTraceAsString());
|
27 |
}
|
28 |
}
|
29 |
|
30 |
+
public function sendAction()
|
31 |
{
|
32 |
+
try {
|
33 |
+
$this->send();
|
34 |
+
} catch (Exception $e) {
|
35 |
+
Lipscore_RatingsReviews_Logger::logException($e);
|
36 |
+
$this->response(false, $e->getMessage() . "\n" . $e->getTraceAsString());
|
37 |
+
}
|
38 |
+
}
|
39 |
|
40 |
+
protected function preview()
|
41 |
+
{
|
42 |
$period = $this->getPeriod();
|
43 |
$statuses = $this->getStatuses();
|
44 |
|
45 |
+
$statusNames = array();
|
46 |
+
foreach ($statuses as $key => $statusCode) {
|
47 |
+
$statusNames[] = Mage::getSingleton('sales/order_config')->getStatusLabel($statusCode);
|
|
|
|
|
|
|
|
|
48 |
}
|
49 |
+
$format = $this->kickstartHelper()->dateFormat();
|
50 |
|
51 |
+
$results = array(
|
52 |
+
'statuses' => $statusNames,
|
53 |
+
'from' => $period['from']->toString($format),
|
54 |
+
'to' => $period['to']->toString($format),
|
55 |
+
'stores' => array()
|
56 |
+
);
|
57 |
|
58 |
+
$moduleHelper = Mage::helper('lipscore_ratingsreviews/module');
|
|
|
|
|
|
|
59 |
|
60 |
+
$stores = $this->getStores();
|
61 |
+
foreach ($stores as $key => $store) {
|
62 |
+
$storeName = $store->getName();
|
63 |
+
$config = $this->config($store);
|
64 |
+
$moduleHelper->setLipscoreConfig($config);
|
65 |
+
if (!$moduleHelper->isLipscoreModuleEnabled()) {
|
66 |
+
$results['stores'][] = $this->kickstartHelper()->resultData($storeName, 0, 'disabled');
|
67 |
+
continue;
|
68 |
+
}
|
69 |
+
if (!$config->apiKey()) {
|
70 |
+
$results['stores'][] = $this->kickstartHelper()->resultData($storeName, 0, 'invalid_key');
|
71 |
+
continue;
|
72 |
+
}
|
73 |
+
if ($config->isDemoKey()) {
|
74 |
+
$results['stores'][] = $this->kickstartHelper()->resultData($storeName, 0, 'demo_key');
|
75 |
+
continue;
|
76 |
+
}
|
77 |
+
$storeOrders = $this->kickstartHelper()->getOrders($store, $period, $statuses);
|
78 |
+
$ordersCount = count($storeOrders);
|
79 |
+
if ($ordersCount) {
|
80 |
+
$results['stores'][] = $this->kickstartHelper()->resultData($storeName, $ordersCount, null);
|
81 |
+
} else {
|
82 |
+
$results['stores'][] = $this->kickstartHelper()->resultData($storeName, 0, 'no_orders');
|
83 |
+
}
|
84 |
+
}
|
85 |
+
if ($results) {
|
86 |
+
$this->response(true, $results);
|
87 |
} else {
|
88 |
+
$this->response(false, 'No orders found.');
|
89 |
}
|
90 |
}
|
91 |
|
92 |
+
protected function send()
|
93 |
{
|
94 |
+
$period = $this->getPeriod();
|
95 |
+
$statuses = $this->getStatuses();
|
96 |
+
|
97 |
+
$results = array();
|
98 |
+
$processed = 0;
|
99 |
+
|
100 |
+
session_write_close();
|
101 |
+
set_time_limit(0);
|
102 |
+
ignore_user_abort(true);
|
103 |
+
register_shutdown_function('logLsKickstartAbort');
|
104 |
+
|
105 |
+
$moduleHelper = Mage::helper('lipscore_ratingsreviews/module');
|
106 |
+
|
107 |
+
$stores = $this->getStores();
|
108 |
+
foreach ($stores as $key => $store) {
|
109 |
+
$storeName = $store->getName();
|
110 |
+
$config = $this->config($store);
|
111 |
+
$moduleHelper->setLipscoreConfig($config);
|
112 |
+
if (!$moduleHelper->isLipscoreModuleEnabled()) {
|
113 |
+
$results[] = $this->kickstartHelper()->resultData($storeName, 0, 'disabled');
|
114 |
+
continue;
|
115 |
+
}
|
116 |
+
if (!$config->apiKey()) {
|
117 |
+
$results[] = $this->kickstartHelper()->resultData($storeName, 0, 'invalid_key');
|
118 |
+
continue;
|
119 |
+
}
|
120 |
+
if ($config->isDemoKey()) {
|
121 |
+
$results[] = $this->kickstartHelper()->resultData($storeName, 0, 'demo_key');
|
122 |
+
continue;
|
123 |
+
}
|
124 |
+
|
125 |
+
$storeOrders = $this->kickstartHelper()->getOrders($store, $period, $statuses);
|
126 |
+
$totalOrderCount = $storeOrders->getSize();
|
127 |
+
if ($totalOrderCount) {
|
128 |
+
$config = Mage::getModel('lipscore_ratingsreviews/config', array('store' => $store));
|
129 |
+
$sender = Mage::getModel('lipscore_ratingsreviews/purchase_reminder', array('config' => $config));
|
130 |
+
|
131 |
+
$storeOrders->setPageSize(static::BATCH_SIZE);
|
132 |
+
$pages = $storeOrders->getLastPageNumber();
|
133 |
+
$currentPage = 1;
|
134 |
+
$scheduled = 0;
|
135 |
+
|
136 |
+
$this->kickstartHelper()->saveTempResult($processed);
|
137 |
+
|
138 |
+
do {
|
139 |
+
$storeOrders->setCurPage($currentPage)->load();
|
140 |
+
|
141 |
+
$result = $sender->sendMultiple($storeOrders, $currentPage, $totalOrderCount, $processed);
|
142 |
+
if ($result) {
|
143 |
+
$scheduled += is_array($result) ? count($result) : 0;
|
144 |
+
}
|
145 |
+
|
146 |
+
$currentPage++;
|
147 |
+
$storeOrders->clear();
|
148 |
+
gc_collect_cycles();
|
149 |
+
} while ($currentPage <= $pages);
|
150 |
+
$results[] = $this->kickstartHelper()->resultData($store->getName(), $scheduled, null);
|
151 |
+
} else {
|
152 |
+
$results[] = $this->kickstartHelper()->resultData($storeName, 0, 'no_orders');
|
153 |
+
}
|
154 |
+
}
|
155 |
+
$this->kickstartHelper()->saveFinalResult($processed, $results);
|
156 |
+
|
157 |
+
if ($results) {
|
158 |
+
$this->response(true, $results);
|
159 |
+
} else {
|
160 |
+
$this->response(false, 'No orders found.');
|
161 |
}
|
162 |
}
|
163 |
|
164 |
protected function getPeriod()
|
165 |
{
|
166 |
$data = $this->getRequest()->getParams();
|
167 |
+
$format = $this->kickstartHelper()->dateFormat();
|
168 |
|
169 |
try {
|
170 |
$startDate = empty($data['from']) ? false : new Zend_Date($data['from'], $format);
|
174 |
$endDate = false;
|
175 |
}
|
176 |
|
177 |
+
$correctPeriod = $startDate && $endDate && $startDate->compare($endDate) <= 0;
|
178 |
if (!$correctPeriod) {
|
179 |
$this->response(false, 'Please set a correct period.');
|
180 |
}
|
181 |
+
return $this->kickstartHelper()->period($startDate, $endDate);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
182 |
}
|
183 |
|
184 |
protected function getStatuses()
|
185 |
{
|
186 |
$statuses = $this->getRequest()->getParam('status', array());
|
187 |
if (empty($statuses)) {
|
188 |
+
$this->response(false, 'Please select order status(es).');
|
189 |
}
|
190 |
return $statuses;
|
191 |
}
|
192 |
|
193 |
+
protected function getStores()
|
194 |
+
{
|
195 |
+
$stores = array();
|
196 |
+
|
197 |
+
$websiteCode = $this->getRequest()->getParam('website');
|
198 |
+
$storeCode = $this->getRequest()->getParam('store');
|
199 |
+
|
200 |
+
if ($storeCode) {
|
201 |
+
$store = Mage::getModel('core/store')->load($storeCode);
|
202 |
+
$stores = array($store);
|
203 |
+
} elseif ($websiteCode) {
|
204 |
+
$website = Mage::getModel('core/website')->load($websiteCode);
|
205 |
+
$stores = $website->getStores();
|
206 |
+
} else {
|
207 |
+
$stores = Mage::app()->getStores();
|
208 |
+
}
|
209 |
+
|
210 |
+
return $stores ? $stores : array();
|
211 |
+
}
|
212 |
+
|
213 |
protected function response($result, $response)
|
214 |
{
|
215 |
+
$body = Zend_Json::encode(array('data' => $response));
|
216 |
$this->getResponse()
|
217 |
->setHeader('Content-Type', 'application/json')
|
218 |
->setBody($body);
|
226 |
exit(0);
|
227 |
}
|
228 |
|
229 |
+
protected function config($store)
|
230 |
{
|
231 |
+
return Mage::getModel('lipscore_ratingsreviews/config', array('store' => $store));
|
|
|
|
|
|
|
|
|
|
|
|
|
232 |
}
|
233 |
|
234 |
+
protected function kickstartHelper()
|
235 |
{
|
236 |
+
if (!$this->kickstartHelper) {
|
237 |
+
$this->kickstartHelper = Mage::helper('lipscore_ratingsreviews/kickstart');
|
|
|
238 |
}
|
239 |
+
return $this->kickstartHelper;
|
240 |
}
|
241 |
+
}
|
242 |
|
243 |
+
function logLsKickstartAbort()
|
244 |
+
{
|
245 |
+
$status = connection_status();
|
246 |
+
|
247 |
+
switch ($status) {
|
248 |
+
case CONNECTION_ABORTED:
|
249 |
+
$state = 'aborted';
|
250 |
+
break;
|
251 |
+
case CONNECTION_TIMEOUT:
|
252 |
+
$state = 'timed out';
|
253 |
+
break;
|
254 |
+
case (CONNECTION_ABORTED + CONNECTION_TIMEOUT):
|
255 |
+
$state = 'aborted and timed out';
|
256 |
+
break;
|
257 |
+
default:
|
258 |
+
$state = '';
|
259 |
}
|
260 |
|
261 |
+
if ($state) {
|
262 |
+
$e = new Exception("Connection $state during Lipscore emails scheduling");
|
263 |
+
Mage::setIsDeveloperMode(true);
|
264 |
+
Lipscore_RatingsReviews_Logger::logException($e);
|
265 |
}
|
266 |
}
|
app/code/community/Lipscore/RatingsReviews/data/lipscore_ratingsreviews_setup/data-install-1.2.21.0.php
CHANGED
File without changes
|
app/code/community/Lipscore/RatingsReviews/etc/adminhtml.xml
CHANGED
File without changes
|
app/code/community/Lipscore/RatingsReviews/etc/config.xml
CHANGED
@@ -11,7 +11,7 @@
|
|
11 |
<config>
|
12 |
<modules>
|
13 |
<Lipscore_RatingsReviews>
|
14 |
-
<version>1.
|
15 |
</Lipscore_RatingsReviews>
|
16 |
</modules>
|
17 |
|
@@ -30,16 +30,6 @@
|
|
30 |
<lipscore_ratingsreviews>
|
31 |
<class>Lipscore_RatingsReviews_Block</class>
|
32 |
</lipscore_ratingsreviews>
|
33 |
-
<review>
|
34 |
-
<rewrite>
|
35 |
-
<helper>Lipscore_RatingsReviews_Block_Review_Helper</helper>
|
36 |
-
</rewrite>
|
37 |
-
</review>
|
38 |
-
<catalog>
|
39 |
-
<rewrite>
|
40 |
-
<product_view>Lipscore_RatingsReviews_Block_Catalog_Product_View</product_view>
|
41 |
-
</rewrite>
|
42 |
-
</catalog>
|
43 |
</blocks>
|
44 |
|
45 |
<models>
|
@@ -55,6 +45,18 @@
|
|
55 |
</helpers>
|
56 |
|
57 |
<events>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
58 |
<controller_action_layout_load_before>
|
59 |
<observers>
|
60 |
<lipscore_ratingsreviews>
|
@@ -87,14 +89,6 @@
|
|
87 |
</lipscore_ratingsreviews>
|
88 |
</observers>
|
89 |
</core_block_abstract_to_html_after>
|
90 |
-
<http_response_send_before>
|
91 |
-
<observers>
|
92 |
-
<lipscore_ratingsreviews>
|
93 |
-
<class>lipscore_ratingsreviews/observer_module</class>
|
94 |
-
<method>checkVersion</method>
|
95 |
-
</lipscore_ratingsreviews>
|
96 |
-
</observers>
|
97 |
-
</http_response_send_before>
|
98 |
<sales_order_load_after>
|
99 |
<observers>
|
100 |
<lipscore_ratingsreviews>
|
@@ -170,10 +164,14 @@
|
|
170 |
<emails>
|
171 |
<order_status>pending</order_status>
|
172 |
</emails>
|
|
|
|
|
|
|
173 |
</lipscore_general>
|
174 |
<lipscore_coupons>
|
175 |
<coupons>
|
176 |
<length>12</length>
|
|
|
177 |
</coupons>
|
178 |
</lipscore_coupons>
|
179 |
</default>
|
11 |
<config>
|
12 |
<modules>
|
13 |
<Lipscore_RatingsReviews>
|
14 |
+
<version>1.4.0</version>
|
15 |
</Lipscore_RatingsReviews>
|
16 |
</modules>
|
17 |
|
30 |
<lipscore_ratingsreviews>
|
31 |
<class>Lipscore_RatingsReviews_Block</class>
|
32 |
</lipscore_ratingsreviews>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
33 |
</blocks>
|
34 |
|
35 |
<models>
|
45 |
</helpers>
|
46 |
|
47 |
<events>
|
48 |
+
<controller_action_predispatch>
|
49 |
+
<observers>
|
50 |
+
<lipscore_ratingsreviews_output>
|
51 |
+
<class>lipscore_ratingsreviews/observer_module</class>
|
52 |
+
<method>disableOutput</method>
|
53 |
+
</lipscore_ratingsreviews_output>
|
54 |
+
<lipscore_ratingsreviews_version>
|
55 |
+
<class>lipscore_ratingsreviews/observer_module</class>
|
56 |
+
<method>checkVersion</method>
|
57 |
+
</lipscore_ratingsreviews_version>
|
58 |
+
</observers>
|
59 |
+
</controller_action_predispatch>
|
60 |
<controller_action_layout_load_before>
|
61 |
<observers>
|
62 |
<lipscore_ratingsreviews>
|
89 |
</lipscore_ratingsreviews>
|
90 |
</observers>
|
91 |
</core_block_abstract_to_html_after>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
92 |
<sales_order_load_after>
|
93 |
<observers>
|
94 |
<lipscore_ratingsreviews>
|
164 |
<emails>
|
165 |
<order_status>pending</order_status>
|
166 |
</emails>
|
167 |
+
<module>
|
168 |
+
<active>1</active>
|
169 |
+
</module>
|
170 |
</lipscore_general>
|
171 |
<lipscore_coupons>
|
172 |
<coupons>
|
173 |
<length>12</length>
|
174 |
+
<format>alphanum</format>
|
175 |
</coupons>
|
176 |
</lipscore_coupons>
|
177 |
</default>
|
app/code/community/Lipscore/RatingsReviews/etc/environments/production.xml
CHANGED
File without changes
|
app/code/community/Lipscore/RatingsReviews/etc/system.xml
CHANGED
@@ -91,7 +91,7 @@
|
|
91 |
</locale>
|
92 |
|
93 |
<emails translate="label">
|
94 |
-
<label>
|
95 |
<frontend_type>text</frontend_type>
|
96 |
<sort_order>400</sort_order>
|
97 |
<show_in_default>1</show_in_default>
|
@@ -114,7 +114,7 @@
|
|
114 |
<comment>Send emails for orders in this status</comment>
|
115 |
<frontend_type>select</frontend_type>
|
116 |
<source_model>
|
117 |
-
lipscore_ratingsreviews/
|
118 |
</source_model>
|
119 |
<sort_order>20</sort_order>
|
120 |
<show_in_default>1</show_in_default>
|
@@ -124,7 +124,6 @@
|
|
124 |
</fields>
|
125 |
</emails>
|
126 |
|
127 |
-
<!--
|
128 |
<reminder translate="label">
|
129 |
<label>Kick-start your Lipscore integration!</label>
|
130 |
<frontend_type>text</frontend_type>
|
@@ -145,7 +144,6 @@
|
|
145 |
</period>
|
146 |
</fields>
|
147 |
</reminder>
|
148 |
-
-->
|
149 |
|
150 |
<dashboard_link translate="label">
|
151 |
<label>Advanced settings</label>
|
@@ -157,6 +155,31 @@
|
|
157 |
<show_in_store>1</show_in_store>
|
158 |
<expanded>1</expanded>
|
159 |
</dashboard_link>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
160 |
</groups>
|
161 |
</lipscore_general>
|
162 |
|
91 |
</locale>
|
92 |
|
93 |
<emails translate="label">
|
94 |
+
<label>Review Request Emails</label>
|
95 |
<frontend_type>text</frontend_type>
|
96 |
<sort_order>400</sort_order>
|
97 |
<show_in_default>1</show_in_default>
|
114 |
<comment>Send emails for orders in this status</comment>
|
115 |
<frontend_type>select</frontend_type>
|
116 |
<source_model>
|
117 |
+
lipscore_ratingsreviews/system_config_source_order_status_reminder
|
118 |
</source_model>
|
119 |
<sort_order>20</sort_order>
|
120 |
<show_in_default>1</show_in_default>
|
124 |
</fields>
|
125 |
</emails>
|
126 |
|
|
|
127 |
<reminder translate="label">
|
128 |
<label>Kick-start your Lipscore integration!</label>
|
129 |
<frontend_type>text</frontend_type>
|
144 |
</period>
|
145 |
</fields>
|
146 |
</reminder>
|
|
|
147 |
|
148 |
<dashboard_link translate="label">
|
149 |
<label>Advanced settings</label>
|
155 |
<show_in_store>1</show_in_store>
|
156 |
<expanded>1</expanded>
|
157 |
</dashboard_link>
|
158 |
+
|
159 |
+
<module translate="label">
|
160 |
+
<label>Disable Lipscore for this store view</label>
|
161 |
+
<frontend_type>text</frontend_type>
|
162 |
+
<sort_order>700</sort_order>
|
163 |
+
<show_in_default>1</show_in_default>
|
164 |
+
<show_in_website>1</show_in_website>
|
165 |
+
<show_in_store>1</show_in_store>
|
166 |
+
<expanded>0</expanded>
|
167 |
+
<fields>
|
168 |
+
<active translate="label comment">
|
169 |
+
<label>Current status</label>
|
170 |
+
<comment>'Inactive' will completely disable the extension</comment>
|
171 |
+
<frontend_type>select</frontend_type>
|
172 |
+
<source_model>
|
173 |
+
lipscore_ratingsreviews/system_config_source_active
|
174 |
+
</source_model>
|
175 |
+
<backend_model>lipscore_ratingsreviews/system_config_backend_module</backend_model>
|
176 |
+
<sort_order>10</sort_order>
|
177 |
+
<show_in_default>1</show_in_default>
|
178 |
+
<show_in_website>1</show_in_website>
|
179 |
+
<show_in_store>1</show_in_store>
|
180 |
+
</active>
|
181 |
+
</fields>
|
182 |
+
</module>
|
183 |
</groups>
|
184 |
</lipscore_general>
|
185 |
|
app/design/adminhtml/default/default/layout/lipscore_ratingsreviews.xml
CHANGED
File without changes
|
app/design/frontend/base/default/layout/lipscore_ratingsreviews.xml
CHANGED
File without changes
|
app/design/frontend/base/default/template/lipscore/init.phtml
CHANGED
@@ -6,7 +6,7 @@
|
|
6 |
*/
|
7 |
?>
|
8 |
|
9 |
-
<?php if ($this->lipscoreApiKey) { ?>
|
10 |
<script type="text/javascript">
|
11 |
//<![CDATA[
|
12 |
window.lipscoreInit = function() {
|
6 |
*/
|
7 |
?>
|
8 |
|
9 |
+
<?php if ($this->isLipscoreActive && $this->lipscoreApiKey) { ?>
|
10 |
<script type="text/javascript">
|
11 |
//<![CDATA[
|
12 |
window.lipscoreInit = function() {
|
app/design/frontend/base/default/template/lipscore/purchase/view.phtml
DELETED
@@ -1,15 +0,0 @@
|
|
1 |
-
<?php $productsData = $this->getProductsData() ?>
|
2 |
-
<?php $widgetHelper = $this->helper('lipscore_ratingsreviews/widget'); ?>
|
3 |
-
|
4 |
-
<?php if ($productsData) { ?>
|
5 |
-
<?php foreach ($productsData as $data) { ?>
|
6 |
-
<div class="lipscore-purchase"
|
7 |
-
ls-email="<?php echo $this->getCustomerEmail() ?>"
|
8 |
-
ls-name="<?php echo $this->getCustomerName() ?>"
|
9 |
-
ls-product-url="<?php echo $data['url'] ?>"
|
10 |
-
ls-voucher-code="<?php echo $this->getCouponCode() ?>"
|
11 |
-
ls-voucher-descr="<?php echo $this->getCouponDescription() ?>"
|
12 |
-
<?php echo $widgetHelper->getProductAttrs($data)?>>
|
13 |
-
</div>
|
14 |
-
<?php } ?>
|
15 |
-
<?php } ?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/design/frontend/base/default/template/lipscore/rating/view.phtml
CHANGED
@@ -1,10 +1,10 @@
|
|
1 |
<?php if ($this->getLsProductAttrs()) { ?>
|
2 |
<div class="ratings mg-lipscore-rating-wrapper">
|
3 |
-
<div <?php echo $this->getRatingType() ?>
|
4 |
<?php echo $this->getLsProductAttrs() ?>
|
5 |
<?php echo $this->getRichsnippetAttrs() ?>>
|
6 |
</div>
|
7 |
-
</div>
|
8 |
<?php } else { ?>
|
9 |
<div style="display: none !important;">Lipscore: empty product data</div>
|
10 |
<?php } ?>
|
1 |
<?php if ($this->getLsProductAttrs()) { ?>
|
2 |
<div class="ratings mg-lipscore-rating-wrapper">
|
3 |
+
<div <?php echo $this->getRatingType() ?>
|
4 |
<?php echo $this->getLsProductAttrs() ?>
|
5 |
<?php echo $this->getRichsnippetAttrs() ?>>
|
6 |
</div>
|
7 |
+
</div>
|
8 |
<?php } else { ?>
|
9 |
<div style="display: none !important;">Lipscore: empty product data</div>
|
10 |
<?php } ?>
|
app/design/frontend/base/default/template/lipscore/reviews/tab_title.phtml
CHANGED
File without changes
|
app/design/frontend/base/default/template/lipscore/reviews/view.phtml
CHANGED
File without changes
|
app/design/frontend/base/default/template/lipscore/reviews/view_single.phtml
CHANGED
File without changes
|
app/etc/modules/Lipscore_RatingsReviews.xml
CHANGED
File without changes
|
package.xml
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>lipscore</name>
|
4 |
-
<version>1.
|
5 |
<stability>stable</stability>
|
6 |
<license uri="https://lipscore.com/signup">Terms of use</license>
|
7 |
<channel>community</channel>
|
@@ -11,11 +11,14 @@
|
|
11 |
Lipscore has a range of great features that will
|
12 |
take all the hassle out of collecting product reviews, and help convert more
|
13 |
visitors in to profitable customers.</description>
|
14 |
-
<notes>
|
|
|
|
|
|
|
15 |
<authors><author><name>Henning Frettem</name><user>Lipscore</user><email>henning@lipscore.com</email></author><author><name>Olga Ivanova</name><user>oivanova</user><email>o.ivanova@datacrafts.io</email></author></authors>
|
16 |
-
<date>2016-
|
17 |
-
<time>
|
18 |
-
<contents><target name="magecommunity"><dir name="Lipscore"><dir name="RatingsReviews"><dir name="Block"><dir name="Catalog"><dir name="Product"><file name="Reviews.php" hash="e42b5b73a1b0f108818e4e8dad529d65"/><file name="View.php" hash="
|
19 |
<compatible/>
|
20 |
<dependencies><required><php><min>5.2.13</min><max>6.0.0</max></php></required></dependencies>
|
21 |
</package>
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>lipscore</name>
|
4 |
+
<version>1.4.0</version>
|
5 |
<stability>stable</stability>
|
6 |
<license uri="https://lipscore.com/signup">Terms of use</license>
|
7 |
<channel>community</channel>
|
11 |
Lipscore has a range of great features that will
|
12 |
take all the hassle out of collecting product reviews, and help convert more
|
13 |
visitors in to profitable customers.</description>
|
14 |
+
<notes>Kick-start emails have been enabled.
|
15 |
+
Possibility to disable Lipscore completely for individual stores has been added.
|
16 |
+

|
17 |
+
</notes>
|
18 |
<authors><author><name>Henning Frettem</name><user>Lipscore</user><email>henning@lipscore.com</email></author><author><name>Olga Ivanova</name><user>oivanova</user><email>o.ivanova@datacrafts.io</email></author></authors>
|
19 |
+
<date>2016-04-20</date>
|
20 |
+
<time>07:32:45</time>
|
21 |
+
<contents><target name="magecommunity"><dir name="Lipscore"><dir name="RatingsReviews"><dir name="Block"><dir name="Catalog"><dir name="Product"><file name="Reviews.php" hash="e42b5b73a1b0f108818e4e8dad529d65"/><file name="View.php" hash="64d1e7a6a79a2c69f5fcc7f93b600947"/></dir></dir><file name="Init.php" hash="5537b142d273b6e5948e0e3bc7c2dc84"/><dir name="Review"><file name="Helper.php" hash="d9f5a39a6e432b5ea58f7b3ed08084e4"/><file name="Single.php" hash="1828a165516557d36820851da6a4fd6a"/><file name="Tabtitle.php" hash="20dfc5f3dc63c5b341c98ac1652b81d9"/></dir><dir name="System"><dir name="Config"><dir name="Form"><file name="Coupons.php" hash="75b2d3c48d10ef77c2a9e5b560767be0"/><dir name="Field"><file name="Abstract.php" hash="d3aacaca28c50d77b4766b35a98cb064"/><file name="Apikey.php" hash="213fd68e66912f5e4d0930e595aee9c6"/><file name="Emailstext.php" hash="0f850db8a26e3dfecc429b2ed0850052"/><file name="Reminderperiod.php" hash="06e032dbd4319123fc20806e8357b77a"/></dir><dir name="Fieldset"><file name="Coupons.php" hash="ea3b6a086bf35810492a89103c81c3c5"/><file name="Dashboardlink.php" hash="7b35ae95cd4f55f6e18b1819a17ae57c"/></dir></dir></dir></dir></dir><dir name="Helper"><file name="Abstract.php" hash="4715d026440f1bb1cda70d56a69a2513"/><file name="Config.php" hash="e252d8f075fd27417293027beb6eb85d"/><file name="Coupon.php" hash="c44e0a938edccb05e733f40955a8a179"/><file name="Data.php" hash="d4a2ee7e1dbdd277e5a6eff4927fe4b2"/><file name="Kickstart.php" hash="606cd0b7efc96758a71decad671302ad"/><file name="Locale.php" hash="1cfc0eb4dc3ede4aa07fbf1bba7ff104"/><file name="Module.php" hash="e1842e7db598288f6c2ac1a706a5956b"/><file name="Price.php" hash="a18d38d97b10f2bf7ab4e1cd0a9e83a4"/><file name="Product.php" hash="09ea9f1d7cacd16ad663ebd1588df46a"/><file name="Purchase.php" hash="30991d1ae641b9a3ea3dcf72c0da53d7"/><file name="Reminder.php" hash="f7b0e91e3fafd000765ac1c3dc21409f"/><file name="Widget.php" hash="fe913158ac4075f107286b08fed57d47"/></dir><file name="Logger.php" hash="29c5f230b560c3008b5e3ac64f291d91"/><dir name="Model"><dir name="Api"><file name="Request.php" hash="b61017066275ec132bf94e1997896bde"/></dir><dir name="Config"><file name="Abstract.php" hash="3dc2509e1ed5efa45d24e402dcb4e285"/><file name="Env.php" hash="6d541047b5f1366271d4ac92d4cd65b5"/><file name="Kickstart.php" hash="0c876e326ff864aea25e036cf5a5f89a"/></dir><file name="Config.php" hash="5c041889edbc7a9614ea65f9d62ef253"/><dir name="Coupon"><file name="Generator.php" hash="39700bbd52697c3e12a3953d9007282a"/></dir><dir name="Observer"><file name="Abstract.php" hash="25d275ebb7a0802aff0fee93a2d49169"/><file name="Module.php" hash="4abd870492ed134a8694cb57d2109b4c"/><dir name="Order"><file name="Status.php" hash="f1ed8507c85c5d21a09be0de16ebe51f"/></dir><file name="Output.php" hash="ecd322dfb36b9d2c5d74aeac2a9b7ed9"/></dir><dir name="Purchase"><file name="Reminder.php" hash="c03f3b15c7a67528059d6803083c8785"/></dir><file name="Shop.php" hash="b23d54688fc733ea672d427072a675af"/><dir name="System"><dir name="Config"><dir name="Backend"><file name="Apikey.php" hash="53385393e0e6c6320878f06929424581"/><file name="Module.php" hash="1e72a92489834742460f9f97cc5f82aa"/></dir><dir name="Source"><file name="Active.php" hash="c60478c02a6c1a8bc54bd4682d694843"/><file name="Locale.php" hash="6cb71dca2b2e76a756fc794a136cc9c5"/><dir name="Order"><dir name="Status"><file name="Abstract.php" hash="cf141cb1baae94f3214af72196418773"/><file name="Reminder.php" hash="9a48a5d055ad5bff4d0bd2b9d0346b74"/><file name="Reminders.php" hash="7b3fc04193f846838a58d0148d9def23"/></dir></dir><file name="Pricerule.php" hash="5204f6c341f8adc8a6b8c77888e40396"/><dir name="Productattr"><file name="Brand.php" hash="fc166f0faa7304b4bc861d50e7b9a8e7"/></dir><file name="Reminderperiod.php" hash="1c6a9df19b5507ab2d706af46c96f4d5"/></dir></dir></dir><dir name="Tracker"><file name="Action.php" hash="94a353059f272207491baa05dd7686f5"/><file name="Installation.php" hash="15a0823b0fd346fba58a313c711c4103"/></dir></dir><dir name="controllers"><dir name="Purchases"><file name="RemindersController.php" hash="29856cfcba2ce85e53b7200f5559df72"/></dir></dir><dir name="data"><dir name="lipscore_ratingsreviews_setup"><file name="data-install-1.2.21.0.php" hash="0ebbbd1f815ef325cee95311bc4023f8"/></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="c3a5ed358f97a2119bcaf3a6c1d6c026"/><file name="config.xml" hash="573eee1293ec69ea4cc867905ec92af6"/><dir name="environments"><file name="production.xml" hash="a519f9130a42c2bc04a30c23eeb3adaf"/></dir><file name="system.xml" hash="57a826b3ab33ab373dcb042d89f3598b"/></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="template"><dir name="lipscore"><file name="init.phtml" hash="95a4ccca599b03ae9ab5142299434c43"/><dir name="rating"><file name="view.phtml" hash="91139825141bf5ce3f7c5d13d72c13dc"/></dir><dir name="reviews"><file name="tab_title.phtml" hash="716d399499e80fa1cb61dd83295be1f7"/><file name="view.phtml" hash="37b2a4de52536e0632bad412a80a21fc"/><file name="view_single.phtml" hash="3675bcf396c750b63e01dd56b576a676"/></dir></dir></dir><dir name="layout"><file name="lipscore_ratingsreviews.xml" hash="c41ae9b0c0add978cbec4b9ea07b293a"/></dir></dir></dir></dir><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="lipscore_ratingsreviews.xml" hash="3e6353dfc81756e37494941ef6eb8bee"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Lipscore_RatingsReviews.xml" hash="9422ff014d7fcbd68274ffd97182de1d"/></dir></target><target name="mageskin"><dir name="frontend"><dir name="base"><dir name="default"><dir name="css"><file name="lipscore.css" hash="550a3270e8fd600f032b4e3f39cfe431"/></dir><dir name="js"><file name="lipscore.js" hash="0ac6084e3d815ef75855fe2c2ebcae06"/></dir></dir></dir></dir><dir name="adminhtml"><dir name="default"><dir name="default"><file name="lipscore.css" hash="334ed799b7c5dcdf6752cbbd0baf45c7"/><dir name="js"><file name="lipscore.js" hash="2e02504dc2065d9915b4717908d28f69"/></dir></dir></dir></dir></target></contents>
|
22 |
<compatible/>
|
23 |
<dependencies><required><php><min>5.2.13</min><max>6.0.0</max></php></required></dependencies>
|
24 |
</package>
|
skin/adminhtml/default/default/js/lipscore.js
CHANGED
@@ -1,8 +1,27 @@
|
|
1 |
-
function
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
$statusEl = $('order_status');
|
3 |
$fromEl = $('remind_from');
|
4 |
$toEl = $('remind_to');
|
5 |
-
|
6 |
new Ajax.Request(url, {
|
7 |
method: 'post',
|
8 |
parameters: {
|
@@ -11,15 +30,46 @@ function sendLipscoreReminder(url) {
|
|
11 |
to: $toEl.getValue(),
|
12 |
},
|
13 |
onSuccess: function(response) {
|
14 |
-
|
|
|
15 |
},
|
16 |
onFailure: function(response) {
|
17 |
-
|
18 |
}
|
19 |
});
|
20 |
};
|
21 |
|
22 |
-
function
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
23 |
var txt = '';
|
24 |
var type = 'error';
|
25 |
var commonErr = "We're sorry, but something went wrong with reminders, please try again or contact support.<br/><br/>";
|
@@ -28,11 +78,11 @@ function showReminderMessage(response) {
|
|
28 |
return commonErr + response.status + ': ' + response.request.url + '.<br/> Params: ' +
|
29 |
response.request.body + '.<br/> Text: ' + response.responseText;
|
30 |
};
|
31 |
-
|
32 |
switch(response.status) {
|
33 |
case 200:
|
34 |
-
if (response.responseJSON && '
|
35 |
-
txt = response.responseJSON.
|
36 |
type = 'success';
|
37 |
} else {
|
38 |
txt = errMessage(response);
|
@@ -45,16 +95,137 @@ function showReminderMessage(response) {
|
|
45 |
txt = commonErr + '404 Not Found: ' + response.request.url;
|
46 |
break;
|
47 |
case 422:
|
48 |
-
txt = response.responseJSON.
|
49 |
break;
|
50 |
case 408:
|
51 |
txt = 'The server timed out waiting for the request.';
|
52 |
break;
|
|
|
|
|
|
|
|
|
53 |
default:
|
54 |
txt = errMessage(response);
|
55 |
break;
|
56 |
}
|
57 |
-
|
58 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
59 |
$('messages').update(html);
|
60 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
document.observe('dom:loaded', function () {
|
2 |
+
reminder = $('ls-reminder');
|
3 |
+
if (reminder) {
|
4 |
+
result = reminder.readAttribute('data-result');
|
5 |
+
|
6 |
+
if (!result) {
|
7 |
+
return;
|
8 |
+
}
|
9 |
+
|
10 |
+
result = JSON.parse(result);
|
11 |
+
if (result.completed) {
|
12 |
+
msg = sendingResultMessage(result.stores);
|
13 |
+
} else {
|
14 |
+
msg = 'Emails scheduling is in progress... ' + result.processed + ' emails have been processed.'
|
15 |
+
}
|
16 |
+
renderLsReminderMessage('success', msg);
|
17 |
+
}
|
18 |
+
});
|
19 |
+
|
20 |
+
function previewLsReminder(url) {
|
21 |
$statusEl = $('order_status');
|
22 |
$fromEl = $('remind_from');
|
23 |
$toEl = $('remind_to');
|
24 |
+
|
25 |
new Ajax.Request(url, {
|
26 |
method: 'post',
|
27 |
parameters: {
|
30 |
to: $toEl.getValue(),
|
31 |
},
|
32 |
onSuccess: function(response) {
|
33 |
+
var msg = previewMessage(response);
|
34 |
+
openLsPreviewPopup(msg);
|
35 |
},
|
36 |
onFailure: function(response) {
|
37 |
+
showLsReminderMessage(response);
|
38 |
}
|
39 |
});
|
40 |
};
|
41 |
|
42 |
+
function sendLsReminder(url) {
|
43 |
+
$statusEl = $('order_status');
|
44 |
+
$fromEl = $('remind_from');
|
45 |
+
$toEl = $('remind_to');
|
46 |
+
|
47 |
+
request = new Ajax.Request(url, {
|
48 |
+
method: 'post',
|
49 |
+
parameters: {
|
50 |
+
'status[]': $statusEl.getValue(),
|
51 |
+
from: $fromEl.getValue(),
|
52 |
+
to: $toEl.getValue(),
|
53 |
+
},
|
54 |
+
onCreate: function(request) {
|
55 |
+
request.timeoutId = window.setTimeout(function() {
|
56 |
+
request.transport.abort();
|
57 |
+
}, 5000);
|
58 |
+
},
|
59 |
+
onSuccess: function(response) {
|
60 |
+
showLsReminderMessage(response);
|
61 |
+
},
|
62 |
+
onFailure: function(response) {
|
63 |
+
showLsReminderMessage(response);
|
64 |
+
},
|
65 |
+
onComplete : function(request) {
|
66 |
+
window.clearTimeout(request.timeoutId);
|
67 |
+
}
|
68 |
+
});
|
69 |
+
closeLsPreviewPopup();
|
70 |
+
};
|
71 |
+
|
72 |
+
function showLsReminderMessage(response) {
|
73 |
var txt = '';
|
74 |
var type = 'error';
|
75 |
var commonErr = "We're sorry, but something went wrong with reminders, please try again or contact support.<br/><br/>";
|
78 |
return commonErr + response.status + ': ' + response.request.url + '.<br/> Params: ' +
|
79 |
response.request.body + '.<br/> Text: ' + response.responseText;
|
80 |
};
|
81 |
+
|
82 |
switch(response.status) {
|
83 |
case 200:
|
84 |
+
if (response.responseJSON && 'data' in response.responseJSON) {
|
85 |
+
txt = sendingResultMessage(response.responseJSON.data);
|
86 |
type = 'success';
|
87 |
} else {
|
88 |
txt = errMessage(response);
|
95 |
txt = commonErr + '404 Not Found: ' + response.request.url;
|
96 |
break;
|
97 |
case 422:
|
98 |
+
txt = response.responseJSON.data;
|
99 |
break;
|
100 |
case 408:
|
101 |
txt = 'The server timed out waiting for the request.';
|
102 |
break;
|
103 |
+
case 0:
|
104 |
+
txt = 'Emails scheduling is in progress... It might take some time, please refresh page to check results.';
|
105 |
+
type = 'success';
|
106 |
+
break;
|
107 |
default:
|
108 |
txt = errMessage(response);
|
109 |
break;
|
110 |
}
|
111 |
+
|
112 |
+
renderLsReminderMessage(type, txt);
|
113 |
+
}
|
114 |
+
|
115 |
+
function renderLsReminderMessage(type, txt) {
|
116 |
+
var html = '<ul class="messages"><li class="' + type + '-msg"><ul><li>' + txt + '</li></ul>';
|
117 |
+
if (type == 'success') {
|
118 |
+
html += '<ul><li><br/>Scheduled emails can be found in <a href="https://members.lipscore.com/purchases">Lipscore Emails page</a></li></ul>';
|
119 |
+
}
|
120 |
+
html += '</li></ul>';
|
121 |
$('messages').update(html);
|
122 |
}
|
123 |
+
|
124 |
+
function previewMessage(response) {
|
125 |
+
var data = response.responseJSON.data;
|
126 |
+
var statuses = data.statuses.join(', ');
|
127 |
+
|
128 |
+
html = '<h3>Include orders in statuses:</h3>' + statuses +
|
129 |
+
'<h3>Orders from period:</h3>' + data.from + ' - ' + data.to +
|
130 |
+
'<h3>Stores:</h3>';
|
131 |
+
|
132 |
+
var storesMessage = resultMessageByStores(data.stores);
|
133 |
+
var total = totalEmails(data.stores);
|
134 |
+
var totalRowHtml = '<h3>Total:</h3><b>' + total + '</b> emails will be scheduled for sending by clicking Continue.';
|
135 |
+
|
136 |
+
return html + storesMessage + totalRowHtml;
|
137 |
+
}
|
138 |
+
|
139 |
+
function sendingResultMessage(stores) {
|
140 |
+
var total = totalEmails(stores);
|
141 |
+
var html = '<h3 class="ls-reminder-result-header">' + total + ' emails were scheduled successfully:</h3>';
|
142 |
+
var storesMessage = resultMessageByStores(stores);
|
143 |
+
|
144 |
+
return html + storesMessage;
|
145 |
+
}
|
146 |
+
|
147 |
+
function resultMessageByStores(stores) {
|
148 |
+
resMsg = function(storeName, isError, msg) {
|
149 |
+
var msgClass = isError ? 'ls-reminder-err' : 'ls-reminder-succsess';
|
150 |
+
return '<b>' + storeName + ':</b> ' + '<span class="' + msgClass + '">' + msg + '</span>';
|
151 |
+
}
|
152 |
+
|
153 |
+
var storeRows = [];
|
154 |
+
var total = 0;
|
155 |
+
stores.each(function(store) {
|
156 |
+
var msg = '';
|
157 |
+
switch(store.err) {
|
158 |
+
case 'invalid_key':
|
159 |
+
msg = resMsg(store.store, true, 'invalid Lipscore API key.');
|
160 |
+
break;
|
161 |
+
case 'demo_key':
|
162 |
+
msg = resMsg(store.store, true, 'demo Lipscore API key found, please set up a correct key.');
|
163 |
+
break;
|
164 |
+
case 'no_orders':
|
165 |
+
msg = resMsg(store.store, true, 'no orders found.');
|
166 |
+
break;
|
167 |
+
case 'disabled':
|
168 |
+
msg = resMsg(store.store, true, 'Lipscore is disabled for the shop.');
|
169 |
+
break;
|
170 |
+
default:
|
171 |
+
msg = resMsg(store.store, false, store.count + ' emails.');
|
172 |
+
total += store.count;
|
173 |
+
break;
|
174 |
+
}
|
175 |
+
storeRows.push(msg);
|
176 |
+
});
|
177 |
+
return storeRows.join('<br/>');
|
178 |
+
}
|
179 |
+
|
180 |
+
function totalEmails(stores) {
|
181 |
+
var total = 0;
|
182 |
+
stores.each(function(store) {
|
183 |
+
if (!store.err) {
|
184 |
+
total += store.count;
|
185 |
+
}
|
186 |
+
});
|
187 |
+
return total;
|
188 |
+
}
|
189 |
+
|
190 |
+
var lsPreviewPopupClosed = false;
|
191 |
+
function openLsPreviewPopup(text) {
|
192 |
+
$('ls-reminder-preview-text').update(text);
|
193 |
+
|
194 |
+
var $mask = $$('.ls-preview-popup-mask')[0];
|
195 |
+
var height = $('html-body').getHeight();
|
196 |
+
$mask.setStyle({'height':height+'px'});
|
197 |
+
toggleSelectsUnderBlock($mask, false);
|
198 |
+
$mask.show();
|
199 |
+
|
200 |
+
var $popup = $$('.ls-preview-popup')[0];
|
201 |
+
var vpHeight = $(document).viewport.getHeight();
|
202 |
+
var height = $popup.getLayout().get('margin-box-height');
|
203 |
+
var scrollTop = $(document).viewport.getScrollOffsets().top;
|
204 |
+
var avTop = (vpHeight / 2) - (height / 2) + scrollTop;
|
205 |
+
$popup.style.top = avTop+ 'px';
|
206 |
+
$popup.show();
|
207 |
+
|
208 |
+
lsPreviewPopupClosed = false;
|
209 |
+
}
|
210 |
+
|
211 |
+
function closeLsPreviewPopup() {
|
212 |
+
toggleSelectsUnderBlock($$('.ls-preview-popup-mask')[0], true);
|
213 |
+
$$('.ls-preview-popup-mask')[0].hide();
|
214 |
+
$$('.ls-preview-popup')[0].hide();
|
215 |
+
lsPreviewPopupClosed = true;
|
216 |
+
}
|
217 |
+
|
218 |
+
Event.observe(window, 'keyup', function(evt) {
|
219 |
+
if (lsPreviewPopupClosed) {
|
220 |
+
return;
|
221 |
+
}
|
222 |
+
var code;
|
223 |
+
if (evt.keyCode) {
|
224 |
+
code = evt.keyCode;
|
225 |
+
} else if (evt.which) {
|
226 |
+
code = evt.which;
|
227 |
+
}
|
228 |
+
if (code == Event.KEY_ESC) {
|
229 |
+
closeLsPreviewPopup();
|
230 |
+
}
|
231 |
+
});
|
skin/adminhtml/default/default/lipscore.css
CHANGED
@@ -1,5 +1,10 @@
|
|
1 |
.ls-reminder-label { margin-right: 10px; display: inline-block; vertical-align: middle; }
|
2 |
#ls-reminder img { margin-right: 7px; }
|
3 |
-
#ls-reminder-button { margin-left: 8px }
|
4 |
-
#order_status {margin-right: 15px; }
|
5 |
.lipscore-notice-msg { background: url(images/warning_msg_icon.gif) no-repeat; padding: 2px 0 0 20px; }
|
|
|
|
|
|
|
|
|
|
1 |
.ls-reminder-label { margin-right: 10px; display: inline-block; vertical-align: middle; }
|
2 |
#ls-reminder img { margin-right: 7px; }
|
3 |
+
#ls-reminder-send-button { margin-left: 8px }
|
4 |
+
#order_status { margin-right: 15px; }
|
5 |
.lipscore-notice-msg { background: url(images/warning_msg_icon.gif) no-repeat; padding: 2px 0 0 20px; }
|
6 |
+
#ls-reminder-preview-text { margin-bottom: 15px }
|
7 |
+
#ls-reminder-preview-text > h3 { margin-top: 0.5em }
|
8 |
+
#ls-reminder-preview-text > h3:first-child { margin-top: -0.5em }
|
9 |
+
.ls-reminder-err { color: #df280a }
|
10 |
+
.ls-reminder-result-header { color: inherit; }
|
skin/frontend/base/default/css/lipscore.css
CHANGED
@@ -4,3 +4,6 @@ img.lipscore-rating-small-image { display: inline; }
|
|
4 |
display: block;
|
5 |
margin-top: 15px;
|
6 |
}
|
|
|
|
|
|
4 |
display: block;
|
5 |
margin-top: 15px;
|
6 |
}
|
7 |
+
.ls-demo-mode-label {
|
8 |
+
color: #e92631;
|
9 |
+
}
|
skin/frontend/base/default/js/lipscore.js
CHANGED
File without changes
|