Version Notes
Order and Abandoned Cart diagnostics
Improved logging with advanced settings
Help Page (with list of fields that can be mapped)
API Key validation improvements (a valid key will not be marked invalid during API/Network outages).
Code improvements to make customization easier.
Signup form improvements (works better with Full Page Caching)
Download this release
Release Info
Developer | Magento Core Team |
Extension | EmailDirect_Integration |
Version | 2.0.9 |
Comparing to | |
See all releases |
Code changes from version 2.0.8 to 2.0.9
- app/code/community/EmailDirect/Integration/Block/Adminhtml/Abandoned.php +10 -0
- app/code/community/EmailDirect/Integration/Block/Adminhtml/Abandoned/Details.php +82 -0
- app/{design/adminhtml/default/default/template/emaildirect/abandoned/grid.phtml → code/community/EmailDirect/Integration/Block/Adminhtml/Abandoned/Details/Abstract.php} +0 -0
- app/code/community/EmailDirect/Integration/Block/Adminhtml/Abandoned/Details/Form.php +10 -0
- app/code/community/EmailDirect/Integration/Block/Adminhtml/Abandoned/Details/Tab/Cart.php +37 -0
- app/code/community/EmailDirect/Integration/Block/Adminhtml/Abandoned/Details/Tab/Diagnostics.php +91 -0
- app/code/community/EmailDirect/Integration/Block/Adminhtml/Abandoned/Details/Tab/Diagnostics/Status.php +51 -0
- app/code/community/EmailDirect/Integration/Block/Adminhtml/Abandoned/Grid.php +1 -2
- app/code/community/EmailDirect/Integration/Block/Adminhtml/Abandoned/Tabs.php +31 -0
- app/code/community/EmailDirect/Integration/Block/Adminhtml/Diagnostics/Status/Abstract.php +22 -0
- app/code/community/EmailDirect/Integration/Block/Adminhtml/Order/View/Tab/Diagnostics.php +85 -0
- app/code/community/EmailDirect/Integration/Block/Adminhtml/Order/View/Tab/Diagnostics/Status.php +82 -0
- app/code/community/EmailDirect/Integration/Block/Adminhtml/System/Config/Form/Field/Api.php +30 -0
- app/code/community/EmailDirect/Integration/Block/Adminhtml/System/Config/Form/Field/Diagnostics.php +26 -0
- app/code/community/EmailDirect/Integration/Block/Adminhtml/System/Config/Form/Field/Logging.php +160 -0
- app/code/community/EmailDirect/Integration/Block/Adminhtml/System/Config/Form/Field/Troubleshooting.php +13 -8
- app/code/community/EmailDirect/Integration/Block/Adminhtml/Troubleshooting/Status.php +9 -0
- app/code/community/EmailDirect/Integration/Block/Adminhtml/Troubleshooting/Tabs.php +19 -0
- app/code/community/EmailDirect/Integration/Block/Adminhtml/Troubleshooting/View.php +6 -44
- app/code/community/EmailDirect/Integration/Block/Adminhtml/Troubleshooting/View/Tab/Help.php +77 -0
- app/code/community/EmailDirect/Integration/Block/Adminhtml/Troubleshooting/View/Tab/Info.php +2 -2
- app/code/community/EmailDirect/Integration/Block/Adminhtml/Troubleshooting/View/Tab/Log.php +1 -1
- app/code/community/EmailDirect/Integration/Block/Adminhtml/Troubleshooting/View/Tab/Settings.php +60 -0
- app/code/community/EmailDirect/Integration/Block/Adminhtml/Troubleshooting/View/Tab/Submit.php +26 -1
- app/code/community/EmailDirect/Integration/Block/Checkout/Subscribe.php +1 -1
- app/code/community/EmailDirect/Integration/Block/Signup.php +7 -72
- app/code/community/EmailDirect/Integration/Controller/Front/Abstract.php +35 -0
- app/code/community/EmailDirect/Integration/Helper/Abandoned.php +176 -0
- app/code/community/EmailDirect/Integration/Helper/Data.php +212 -530
- app/code/community/EmailDirect/Integration/Helper/Diagnostic.php +59 -0
- app/code/community/EmailDirect/Integration/Helper/Fields.php +26 -48
- app/code/community/EmailDirect/Integration/Helper/Order.php +678 -0
- app/code/community/EmailDirect/Integration/Helper/Troubleshooting.php +712 -0
- app/code/community/EmailDirect/Integration/Helper/Upgrade.php +0 -29
- app/code/community/EmailDirect/Integration/Model/Abandoned/Observer.php +328 -0
- app/code/community/EmailDirect/Integration/Model/Configuration/Observer.php +86 -0
- app/code/community/EmailDirect/Integration/Model/Customer/Observer.php +263 -0
- app/code/community/EmailDirect/Integration/Model/Mysql4/Abandoned/Collection.php +8 -0
- app/code/community/EmailDirect/Integration/Model/Newsletter/Observer.php +252 -0
- app/code/community/EmailDirect/Integration/Model/Observer.php +8 -1748
- app/code/community/EmailDirect/Integration/Model/Observer/Abstract.php +34 -0
- app/code/community/EmailDirect/Integration/Model/Order/Observer.php +323 -0
- app/code/community/EmailDirect/Integration/Model/Resource/Setup.php +35 -2
- app/code/community/EmailDirect/Integration/Model/System/Config/Source/Abandonedlist.php +2 -2
- app/code/community/EmailDirect/Integration/Model/System/Config/Source/Additionallist.php +2 -2
- app/code/community/EmailDirect/Integration/Model/System/Config/Source/List.php +2 -2
- app/code/community/EmailDirect/Integration/Model/System/Config/Source/Publication.php +2 -2
- app/code/community/EmailDirect/Integration/Model/System/Config/Source/Sequence.php +2 -2
- app/code/community/EmailDirect/Integration/Model/System/Config/Source/Source.php +2 -2
- app/code/community/EmailDirect/Integration/Model/Wrapper/Execute.php +39 -13
- app/code/community/EmailDirect/Integration/Model/Wrapper/Orders.php +3 -3
- app/code/community/EmailDirect/Integration/Model/Wrapper/Publications.php +1 -1
- app/code/community/EmailDirect/Integration/Model/Wrapper/Subscribers.php +4 -4
- app/code/community/EmailDirect/Integration/controllers/AbandonedController.php +6 -4
- app/code/community/EmailDirect/Integration/controllers/Admin/AbandonedController.php +12 -3
- app/code/community/EmailDirect/Integration/controllers/Admin/DiagnosticController.php +486 -0
- app/code/community/EmailDirect/Integration/controllers/Admin/ExportController.php +5 -5
- app/code/community/EmailDirect/Integration/controllers/Admin/TroubleshootingController.php +139 -74
- app/code/community/EmailDirect/Integration/controllers/Customer/AccountController.php +20 -23
- app/code/community/EmailDirect/Integration/controllers/SignupController.php +104 -0
- app/code/community/EmailDirect/Integration/etc/adminhtml.xml +6 -1
- app/code/community/EmailDirect/Integration/etc/cache.xml +12 -0
- app/code/community/EmailDirect/Integration/etc/config.xml +59 -38
- app/code/community/EmailDirect/Integration/etc/system.xml +44 -29
- app/code/community/EmailDirect/Integration/sql/emaildirect_setup/mysql4-install-2.0.0.php +1 -1
- app/code/community/EmailDirect/Integration/sql/emaildirect_setup/mysql4-upgrade-1.5.8-2.0.0.php +1 -1
- app/design/adminhtml/default/default/layout/emaildirect.xml +53 -24
- app/design/adminhtml/default/default/template/emaildirect/abandoned/details.phtml +15 -0
- app/design/adminhtml/default/default/template/emaildirect/abandoned/details/form.phtml +1 -0
- app/design/adminhtml/default/default/template/emaildirect/abandoned/details/tab/cart.phtml +62 -0
- app/design/adminhtml/default/default/template/emaildirect/abandoned/details/tab/diagnostics/status.phtml +52 -0
- app/design/adminhtml/default/default/template/emaildirect/diagnostics.phtml +242 -0
- app/design/adminhtml/default/default/template/emaildirect/order/view/tab/diagnostics/status.phtml +78 -0
- app/design/adminhtml/default/default/template/emaildirect/system/config/fieldset/hint.phtml +3 -2
- app/design/adminhtml/default/default/template/emaildirect/system/config/form/field/api.phtml +62 -0
- app/design/adminhtml/default/default/template/emaildirect/system/config/form/field/diagnostics.phtml +20 -0
- app/design/adminhtml/default/default/template/emaildirect/system/config/form/field/export/date_range.phtml +3 -2
- app/design/adminhtml/default/default/template/emaildirect/system/config/form/field/export/orders.phtml +1 -1
- app/design/adminhtml/default/default/template/emaildirect/system/config/form/field/export/products.phtml +1 -1
- app/design/adminhtml/default/default/template/emaildirect/system/config/form/field/info.phtml +1 -1
- app/design/adminhtml/default/default/template/emaildirect/system/config/form/field/logging.phtml +30 -0
- app/design/adminhtml/default/default/template/emaildirect/system/config/form/field/trouble.phtml +5 -6
- app/design/adminhtml/default/default/template/emaildirect/troubleshooting/status.phtml +199 -0
- app/design/adminhtml/default/default/template/emaildirect/troubleshooting/view.phtml +1 -8
- app/design/adminhtml/default/default/template/emaildirect/troubleshooting/view/tab/download.phtml +1 -1
- app/design/adminhtml/default/default/template/emaildirect/troubleshooting/view/tab/help.phtml +193 -0
- app/design/adminhtml/default/default/template/emaildirect/troubleshooting/view/tab/log.phtml +65 -4
- app/design/adminhtml/default/default/template/emaildirect/troubleshooting/view/tab/settings.phtml +218 -0
- app/design/adminhtml/default/default/template/emaildirect/troubleshooting/view/tab/submit.phtml +11 -11
- app/design/frontend/base/default/layout/emaildirect.xml +11 -11
- app/design/frontend/base/default/template/emaildirect/signup/form.phtml +40 -16
- package.xml +15 -5
- skin/adminhtml/default/default/emaildirect/emaildirect.css +71 -3
- skin/frontend/base/default/emaildirect/emaildirect.css +3 -0
- skin/frontend/base/default/emaildirect/integration.js +0 -1
app/code/community/EmailDirect/Integration/Block/Adminhtml/Abandoned.php
CHANGED
@@ -18,6 +18,11 @@ class EmailDirect_Integration_Block_Adminhtml_Abandoned extends Mage_Adminhtml_B
|
|
18 |
if (Mage::app()->isSingleStoreMode())
|
19 |
$label = 'Run now';
|
20 |
|
|
|
|
|
|
|
|
|
|
|
21 |
$this->_addButton('run_now', array(
|
22 |
'label' => Mage::helper('emaildirect')->__($label),
|
23 |
'onclick' => 'setLocation(\'' . $this->getUrl('*/*/run') .'\')',
|
@@ -26,6 +31,11 @@ class EmailDirect_Integration_Block_Adminhtml_Abandoned extends Mage_Adminhtml_B
|
|
26 |
else
|
27 |
$this->_headerText = "Abandoned Carts - <span class='ab_ng'>Disabled</span>";
|
28 |
|
|
|
|
|
|
|
|
|
|
|
29 |
parent::__construct();
|
30 |
$this->_removeButton('add');
|
31 |
}
|
18 |
if (Mage::app()->isSingleStoreMode())
|
19 |
$label = 'Run now';
|
20 |
|
21 |
+
$this->addButton('refresh', array(
|
22 |
+
'label' => Mage::helper('emaildirect')->__('Refresh'),
|
23 |
+
'onclick' => 'abandonedGridJsObject.reload();return false;',
|
24 |
+
));
|
25 |
+
|
26 |
$this->_addButton('run_now', array(
|
27 |
'label' => Mage::helper('emaildirect')->__($label),
|
28 |
'onclick' => 'setLocation(\'' . $this->getUrl('*/*/run') .'\')',
|
31 |
else
|
32 |
$this->_headerText = "Abandoned Carts - <span class='ab_ng'>Disabled</span>";
|
33 |
|
34 |
+
$data = Mage::helper('emaildirect')->getCronLastRun();
|
35 |
+
|
36 |
+
if ($data['class'] == 'ab_ng')
|
37 |
+
Mage::getSingleton('adminhtml/session')->addWarning("There appears to be a problem with your cron settings. Please make sure that cron is running so that Abandoned Carts can be processed.");
|
38 |
+
|
39 |
parent::__construct();
|
40 |
$this->_removeButton('add');
|
41 |
}
|
app/code/community/EmailDirect/Integration/Block/Adminhtml/Abandoned/Details.php
ADDED
@@ -0,0 +1,82 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class EmailDirect_Integration_Block_Adminhtml_Abandoned_Details extends Mage_Adminhtml_Block_Widget_Form_Container
|
4 |
+
{
|
5 |
+
|
6 |
+
public function __construct()
|
7 |
+
{
|
8 |
+
$this->_blockGroup = "emaildirect";
|
9 |
+
$this->_controller = 'adminhtml_abandoned';
|
10 |
+
$this->_mode = 'details';
|
11 |
+
|
12 |
+
parent::__construct();
|
13 |
+
|
14 |
+
if (!$this->isGuestCustomer())
|
15 |
+
{
|
16 |
+
$this->_addButton('view_customer', array(
|
17 |
+
'label' => Mage::helper('emaildirect')->__('View Customer'),
|
18 |
+
'onclick' => 'setLocation(\'' . $this->getUrl('adminhtml/customer/edit', array('id'=> $this->getCustomerId(), 'active_tab'=>'cart')) . '\')',
|
19 |
+
), 0);
|
20 |
+
}
|
21 |
+
|
22 |
+
$this->_removeButton('delete');
|
23 |
+
$this->_removeButton('reset');
|
24 |
+
$this->_removeButton('save');
|
25 |
+
$this->setId('abandoned_details');
|
26 |
+
}
|
27 |
+
|
28 |
+
public function getCustomerId()
|
29 |
+
{
|
30 |
+
$abandoned_cart = Mage::helper('emaildirect/diagnostic')->getAbandonedCart();
|
31 |
+
|
32 |
+
return $abandoned_cart->getCustomerId();
|
33 |
+
}
|
34 |
+
|
35 |
+
public function isGuestCustomer()
|
36 |
+
{
|
37 |
+
$abandoned_cart = Mage::helper('emaildirect/diagnostic')->getAbandonedCart();
|
38 |
+
|
39 |
+
return $abandoned_cart->getCustomerGroupId() == 0;
|
40 |
+
}
|
41 |
+
|
42 |
+
public function getHeaderText()
|
43 |
+
{
|
44 |
+
$abandoned_cart = Mage::helper('emaildirect/diagnostic')->getAbandonedCart();
|
45 |
+
|
46 |
+
$name = "";
|
47 |
+
$additional = "";
|
48 |
+
|
49 |
+
if ($abandoned_cart->getCustomerGroupId() == 0)
|
50 |
+
{
|
51 |
+
// Guest
|
52 |
+
$email = $abandoned_cart->getEmail();
|
53 |
+
|
54 |
+
$additional = "Guest Customer ({$email})";
|
55 |
+
}
|
56 |
+
else
|
57 |
+
{
|
58 |
+
$email = $abandoned_cart->getCustomerEmail();
|
59 |
+
$name = $abandoned_cart->getCustomerFirstname() . " " . $abandoned_cart->getCustomerLastname();
|
60 |
+
$additional = "{$name} ({$email})";
|
61 |
+
}
|
62 |
+
|
63 |
+
$date = Mage::helper('core')->formatTime($abandoned_cart->getUpdatedAt(), 'medium', true);
|
64 |
+
|
65 |
+
return Mage::helper('emaildirect')->__('Abandoned Cart - ' . $additional . " - Abandoned On: " . $date);
|
66 |
+
}
|
67 |
+
|
68 |
+
public function getUrl($params='', $params2=array())
|
69 |
+
{
|
70 |
+
return parent::getUrl($params, $params2);
|
71 |
+
}
|
72 |
+
|
73 |
+
public function getDownloadUrl()
|
74 |
+
{
|
75 |
+
return $this->getUrl('ed_integration/admin_troubleshooting/download/');
|
76 |
+
}
|
77 |
+
|
78 |
+
public function getBackUrl()
|
79 |
+
{
|
80 |
+
return Mage::helper('emaildirect')->getAdminUrl('*/*/index');
|
81 |
+
}
|
82 |
+
}
|
app/{design/adminhtml/default/default/template/emaildirect/abandoned/grid.phtml → code/community/EmailDirect/Integration/Block/Adminhtml/Abandoned/Details/Abstract.php}
RENAMED
File without changes
|
app/code/community/EmailDirect/Integration/Block/Adminhtml/Abandoned/Details/Form.php
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class EmailDirect_Integration_Block_Adminhtml_Abandoned_Details_Form extends Mage_Adminhtml_Block_Template
|
4 |
+
{
|
5 |
+
protected function _construct()
|
6 |
+
{
|
7 |
+
parent::_construct();
|
8 |
+
$this->setTemplate('emaildirect/abandoned/details/form.phtml');
|
9 |
+
}
|
10 |
+
}
|
app/code/community/EmailDirect/Integration/Block/Adminhtml/Abandoned/Details/Tab/Cart.php
ADDED
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class EmailDirect_Integration_Block_Adminhtml_Abandoned_Details_Tab_Cart
|
4 |
+
extends Mage_Adminhtml_Block_Template
|
5 |
+
implements Mage_Adminhtml_Block_Widget_Tab_Interface
|
6 |
+
{
|
7 |
+
public function getTabLabel()
|
8 |
+
{
|
9 |
+
return Mage::helper('emaildirect')->__('Cart Items');
|
10 |
+
}
|
11 |
+
|
12 |
+
public function getTabTitle()
|
13 |
+
{
|
14 |
+
return Mage::helper('emaildirect')->__('Cart Items');
|
15 |
+
}
|
16 |
+
|
17 |
+
public function canShowTab()
|
18 |
+
{
|
19 |
+
return true;
|
20 |
+
}
|
21 |
+
|
22 |
+
public function isHidden()
|
23 |
+
{
|
24 |
+
return false;
|
25 |
+
}
|
26 |
+
|
27 |
+
public function getCartItems()
|
28 |
+
{
|
29 |
+
return Mage::helper('emaildirect/diagnostic')->getCartItems();
|
30 |
+
}
|
31 |
+
|
32 |
+
public function __construct()
|
33 |
+
{
|
34 |
+
parent::__construct();
|
35 |
+
$this->setTemplate('emaildirect/abandoned/details/tab/cart.phtml');
|
36 |
+
}
|
37 |
+
}
|
app/code/community/EmailDirect/Integration/Block/Adminhtml/Abandoned/Details/Tab/Diagnostics.php
ADDED
@@ -0,0 +1,91 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class EmailDirect_Integration_Block_Adminhtml_Abandoned_Details_Tab_Diagnostics
|
4 |
+
extends Mage_Adminhtml_Block_Sales_Order_Abstract
|
5 |
+
implements Mage_Adminhtml_Block_Widget_Tab_Interface
|
6 |
+
{
|
7 |
+
|
8 |
+
public function getDiagnosticOptions()
|
9 |
+
{
|
10 |
+
$options = array(
|
11 |
+
array('code' => 'abandoned_url', 'label' => 'Restore Cart URL', 'description' => 'Get the URL that customers will use to restore their carts.'),
|
12 |
+
array('code' => 'abandoned_custom_fields', 'label' => 'Custom Fields', 'description' => 'Custom Fields'),
|
13 |
+
array('code' => 'abandoned_request', 'label' => 'Abandoned Request', 'description' => 'Custom Fields'),
|
14 |
+
);
|
15 |
+
|
16 |
+
$full = array(
|
17 |
+
'code' => 'abandoned_request_full',
|
18 |
+
'label' => 'Abandoned Request and Response',
|
19 |
+
'description' => 'Diagnose the request and response for this Cart.',
|
20 |
+
'note' => 'This will send the cart to EmailDirect but it will not mark it as sent.'
|
21 |
+
);
|
22 |
+
|
23 |
+
if (!$this->isEmailDirectEnabled() || !$this->isEmailDirectSetup() || !$this->isAbandonedEnabled())
|
24 |
+
{
|
25 |
+
$full['disabled'] = true;
|
26 |
+
$full['disabled_reason'] = 'EmailDirect must be enabled (and setup to send abandoned carts) to perform this diagnostic.';
|
27 |
+
}
|
28 |
+
|
29 |
+
$options[] = $full;
|
30 |
+
|
31 |
+
return $options;
|
32 |
+
}
|
33 |
+
|
34 |
+
public function getStoreId()
|
35 |
+
{
|
36 |
+
return Mage::app()->getRequest()->getParam('store_id');
|
37 |
+
}
|
38 |
+
|
39 |
+
public function getStore()
|
40 |
+
{
|
41 |
+
$store_id = $this->getStoreId();
|
42 |
+
|
43 |
+
return Mage::getModel('core/store')->load($store_id);
|
44 |
+
}
|
45 |
+
|
46 |
+
public function getItemId()
|
47 |
+
{
|
48 |
+
return Mage::app()->getRequest()->getParam('id');
|
49 |
+
}
|
50 |
+
|
51 |
+
public function isEmailDirectEnabled()
|
52 |
+
{
|
53 |
+
return Mage::helper('emaildirect')->config('active',$this->getOrderStore()) == 1;
|
54 |
+
}
|
55 |
+
|
56 |
+
public function isEmailDirectSetup()
|
57 |
+
{
|
58 |
+
return Mage::helper('emaildirect')->config('setup',$this->getOrderStore()) == 1;
|
59 |
+
}
|
60 |
+
|
61 |
+
public function isAbandonedEnabled()
|
62 |
+
{
|
63 |
+
return Mage::helper('emaildirect')->getAbandonedEnabled();
|
64 |
+
}
|
65 |
+
|
66 |
+
public function getTabLabel()
|
67 |
+
{
|
68 |
+
return Mage::helper('emaildirect')->__('EmailDirect Diagnostics');
|
69 |
+
}
|
70 |
+
|
71 |
+
public function getTabTitle()
|
72 |
+
{
|
73 |
+
return Mage::helper('emaildirect')->__('EmailDirect Diagnostics');
|
74 |
+
}
|
75 |
+
|
76 |
+
public function canShowTab()
|
77 |
+
{
|
78 |
+
return Mage::helper('emaildirect/troubleshooting')->isDiagnosticEnabled();
|
79 |
+
}
|
80 |
+
|
81 |
+
public function isHidden()
|
82 |
+
{
|
83 |
+
return false;
|
84 |
+
}
|
85 |
+
|
86 |
+
public function __construct()
|
87 |
+
{
|
88 |
+
parent::__construct();
|
89 |
+
$this->setTemplate('emaildirect/order/view/tab/diagnostics.phtml');
|
90 |
+
}
|
91 |
+
}
|
app/code/community/EmailDirect/Integration/Block/Adminhtml/Abandoned/Details/Tab/Diagnostics/Status.php
ADDED
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class EmailDirect_Integration_Block_Adminhtml_Abandoned_Details_Tab_Diagnostics_Status extends EmailDirect_Integration_Block_Adminhtml_Diagnostics_Status_Abstract
|
4 |
+
{
|
5 |
+
public function isAbandonedEnabled()
|
6 |
+
{
|
7 |
+
return Mage::helper('emaildirect')->getAbandonedEnabled();
|
8 |
+
}
|
9 |
+
|
10 |
+
public function getStoreId()
|
11 |
+
{
|
12 |
+
return Mage::app()->getRequest()->getParam('store_id');
|
13 |
+
}
|
14 |
+
|
15 |
+
public function getStore()
|
16 |
+
{
|
17 |
+
$store_id = $this->getStoreId();
|
18 |
+
|
19 |
+
return Mage::getModel('core/store')->load($store_id);
|
20 |
+
}
|
21 |
+
|
22 |
+
public function getQuoteId()
|
23 |
+
{
|
24 |
+
return Mage::app()->getRequest()->getParam('id');
|
25 |
+
}
|
26 |
+
|
27 |
+
public function getQuote()
|
28 |
+
{
|
29 |
+
$quote = Mage::getModel('sales/quote')->setStore($this->getStore())->load($this->getQuoteId());
|
30 |
+
|
31 |
+
return $quote;
|
32 |
+
}
|
33 |
+
|
34 |
+
public function getAbandonedQuote()
|
35 |
+
{
|
36 |
+
$abandoned = Mage::getModel('emaildirect/abandoned')->loadByQuoteId($this->getQuoteId());
|
37 |
+
|
38 |
+
return $abandoned;
|
39 |
+
}
|
40 |
+
|
41 |
+
public function getEmailDirectDate()
|
42 |
+
{
|
43 |
+
$abandoned = $this->getAbandonedQuote();
|
44 |
+
|
45 |
+
return $abandoned->getDateSent();
|
46 |
+
//if ($ed_order != null && $ed_order->getDateSent() != null)
|
47 |
+
//return $ed_order->getDateSent();
|
48 |
+
|
49 |
+
return null;
|
50 |
+
}
|
51 |
+
}
|
app/code/community/EmailDirect/Integration/Block/Adminhtml/Abandoned/Grid.php
CHANGED
@@ -259,7 +259,6 @@ class EmailDirect_Integration_Block_Adminhtml_Abandoned_Grid extends Mage_Adminh
|
|
259 |
|
260 |
public function getRowUrl($row)
|
261 |
{
|
262 |
-
|
263 |
-
return $this->getUrl('adminhtml/customer/edit', array('id'=>$row->getCustomerId(), 'active_tab'=>'cart'));
|
264 |
}
|
265 |
}
|
259 |
|
260 |
public function getRowUrl($row)
|
261 |
{
|
262 |
+
return $this->getUrl('*/*/details', array('id'=>$row->getId(),'store_id' => $row->getStoreId(), 'active_tab'=>'cart'));
|
|
|
263 |
}
|
264 |
}
|
app/code/community/EmailDirect/Integration/Block/Adminhtml/Abandoned/Tabs.php
ADDED
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class EmailDirect_Integration_Block_Adminhtml_Abandoned_Tabs extends Mage_Adminhtml_Block_Widget_Tabs
|
4 |
+
{
|
5 |
+
public function __construct()
|
6 |
+
{
|
7 |
+
parent::__construct();
|
8 |
+
$this->setId('abandoned_details_tabs');
|
9 |
+
$this->setDestElementId('abandoned_details');
|
10 |
+
$this->setTitle(Mage::helper('emaildirect')->__('Abandoned Cart Details'));
|
11 |
+
}
|
12 |
+
|
13 |
+
protected function _beforeToHtml()
|
14 |
+
{
|
15 |
+
$this->_updateActiveTab();
|
16 |
+
return parent::_beforeToHtml();
|
17 |
+
}
|
18 |
+
|
19 |
+
protected function _updateActiveTab()
|
20 |
+
{
|
21 |
+
$tabId = $this->getRequest()->getParam('tab');
|
22 |
+
if ($tabId)
|
23 |
+
{
|
24 |
+
$tabId = preg_replace("#{$this->getId()}_#", '', $tabId);
|
25 |
+
if ($tabId)
|
26 |
+
{
|
27 |
+
$this->setActiveTab($tabId);
|
28 |
+
}
|
29 |
+
}
|
30 |
+
}
|
31 |
+
}
|
app/code/community/EmailDirect/Integration/Block/Adminhtml/Diagnostics/Status/Abstract.php
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class EmailDirect_Integration_Block_Adminhtml_Diagnostics_Status_Abstract extends Mage_Adminhtml_Block_Template
|
4 |
+
{
|
5 |
+
protected $_helper = null;
|
6 |
+
|
7 |
+
public function _construct()
|
8 |
+
{
|
9 |
+
$this->_helper = Mage::helper('emaildirect');
|
10 |
+
parent::_construct();
|
11 |
+
}
|
12 |
+
|
13 |
+
public function isEmailDirectEnabled()
|
14 |
+
{
|
15 |
+
return $this->_helper->config('active',$this->_helper->getCurrentStore()) == 1;
|
16 |
+
}
|
17 |
+
|
18 |
+
public function isEmailDirectSetup()
|
19 |
+
{
|
20 |
+
return $this->_helper->config('setup',$this->_helper->getCurrentStore()) == 1;
|
21 |
+
}
|
22 |
+
}
|
app/code/community/EmailDirect/Integration/Block/Adminhtml/Order/View/Tab/Diagnostics.php
ADDED
@@ -0,0 +1,85 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class EmailDirect_Integration_Block_Adminhtml_Order_View_Tab_Diagnostics
|
4 |
+
extends Mage_Adminhtml_Block_Sales_Order_Abstract
|
5 |
+
implements Mage_Adminhtml_Block_Widget_Tab_Interface
|
6 |
+
{
|
7 |
+
|
8 |
+
public function getDiagnosticOptions()
|
9 |
+
{
|
10 |
+
$options = array(
|
11 |
+
array('code' => 'order_custom_fields', 'label' => 'Custom Fields', 'description' => 'Get the custom fields'),
|
12 |
+
array('code' => 'order_last_items', 'label' => 'Order Items', 'description' => 'Test of getting the order items to send'),
|
13 |
+
array('code' => 'order_related_items', 'label' => 'Related Order Items', 'description' => 'Test of the Related Order Items'),
|
14 |
+
array('code' => 'order_full_request', 'label' => 'Full Order Request', 'description' => 'Diagnose the request that will be sent to EmailDirect for this Order.'),
|
15 |
+
|
16 |
+
);
|
17 |
+
|
18 |
+
$full_order = array(
|
19 |
+
'code' => 'order_full',
|
20 |
+
'label' => 'Full Order (Request and Response)',
|
21 |
+
'description' => 'Diagnose the request and response for this Order.',
|
22 |
+
'note' => 'This will send the order to EmailDirect but it will not mark it as sent.'
|
23 |
+
);
|
24 |
+
|
25 |
+
if (!$this->isEmailDirectEnabled() || !$this->isEmailDirectSetup() || !$this->isSendOrdersEnabled())
|
26 |
+
{
|
27 |
+
$full_order['disabled'] = true;
|
28 |
+
$full_order['disabled_reason'] = 'EmailDirect must be enabled (and setup to send orders) to perform this diagnostic.';
|
29 |
+
}
|
30 |
+
|
31 |
+
$options[] = $full_order;
|
32 |
+
return $options;
|
33 |
+
}
|
34 |
+
|
35 |
+
public function getItemId()
|
36 |
+
{
|
37 |
+
return $this->getOrder()->getId();
|
38 |
+
}
|
39 |
+
|
40 |
+
public function getStoreId()
|
41 |
+
{
|
42 |
+
return $this->getOrder()->getStoreId();
|
43 |
+
}
|
44 |
+
|
45 |
+
public function isEmailDirectEnabled()
|
46 |
+
{
|
47 |
+
return Mage::helper('emaildirect')->config('active',$this->getOrderStore()) == 1;
|
48 |
+
}
|
49 |
+
|
50 |
+
public function isEmailDirectSetup()
|
51 |
+
{
|
52 |
+
return Mage::helper('emaildirect')->config('setup',$this->getOrderStore()) == 1;
|
53 |
+
}
|
54 |
+
|
55 |
+
public function isSendOrdersEnabled()
|
56 |
+
{
|
57 |
+
return Mage::helper('emaildirect')->config('sendorder',$this->getOrderStore()) == 1;
|
58 |
+
}
|
59 |
+
|
60 |
+
public function getTabLabel()
|
61 |
+
{
|
62 |
+
return Mage::helper('emaildirect')->__('EmailDirect Diagnostics');
|
63 |
+
}
|
64 |
+
|
65 |
+
public function getTabTitle()
|
66 |
+
{
|
67 |
+
return Mage::helper('emaildirect')->__('EmailDirect Diagnostics');
|
68 |
+
}
|
69 |
+
|
70 |
+
public function canShowTab()
|
71 |
+
{
|
72 |
+
return Mage::helper('emaildirect/troubleshooting')->isDiagnosticEnabled();
|
73 |
+
}
|
74 |
+
|
75 |
+
public function isHidden()
|
76 |
+
{
|
77 |
+
return false;
|
78 |
+
}
|
79 |
+
|
80 |
+
public function __construct()
|
81 |
+
{
|
82 |
+
parent::__construct();
|
83 |
+
//$this->setTemplate('emaildirect/order/view/tab/diagnostics.phtml');
|
84 |
+
}
|
85 |
+
}
|
app/code/community/EmailDirect/Integration/Block/Adminhtml/Order/View/Tab/Diagnostics/Status.php
ADDED
@@ -0,0 +1,82 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class EmailDirect_Integration_Block_Adminhtml_Order_View_Tab_Diagnostics_Status extends EmailDirect_Integration_Block_Adminhtml_Diagnostics_Status_Abstract
|
4 |
+
{
|
5 |
+
public function isSendOrdersEnabled()
|
6 |
+
{
|
7 |
+
return $this->_helper->config('sendorder',$this->_helper->getCurrentStore()) == 1;
|
8 |
+
}
|
9 |
+
|
10 |
+
public function canSendOrders()
|
11 |
+
{
|
12 |
+
if (!$this->isEmailDirectEnabled() || !$this->isEmailDirectSetup() || !$this->isSendOrdersEnabled())
|
13 |
+
return false;
|
14 |
+
|
15 |
+
return true;
|
16 |
+
}
|
17 |
+
|
18 |
+
public function getEmailDirectDate()
|
19 |
+
{
|
20 |
+
$ed_order = Mage::getModel('emaildirect/order')->loadByOrderId($this->getOrder()->getId());
|
21 |
+
|
22 |
+
if ($ed_order != null && $ed_order->getDateSent() != null)
|
23 |
+
return $ed_order->getDateSent();
|
24 |
+
|
25 |
+
return null;
|
26 |
+
}
|
27 |
+
|
28 |
+
public function getStateList()
|
29 |
+
{
|
30 |
+
$state_options = Mage::getSingleton("emaildirect/system_config_source_states")->toOptionArray();
|
31 |
+
|
32 |
+
$set_states = Mage::helper('emaildirect')->config('send_states');
|
33 |
+
$state_list = explode(",",$set_states);
|
34 |
+
|
35 |
+
$display_list = array();
|
36 |
+
|
37 |
+
foreach ($state_options as $option)
|
38 |
+
{
|
39 |
+
if (in_array($option['value'],$state_list))
|
40 |
+
$display_list[] = $option['label'];
|
41 |
+
}
|
42 |
+
|
43 |
+
return $display_list;
|
44 |
+
}
|
45 |
+
|
46 |
+
public function getStatusList()
|
47 |
+
{
|
48 |
+
$sales_config = Mage::getSingleton('sales/order_config');
|
49 |
+
|
50 |
+
$statuses = $sales_config->getStatuses();
|
51 |
+
|
52 |
+
$set_statuses = Mage::helper('emaildirect')->config('send_statuses');
|
53 |
+
$status_list = explode(",",$set_statuses);
|
54 |
+
|
55 |
+
$display_list = array();
|
56 |
+
|
57 |
+
foreach ($statuses as $value => $label)
|
58 |
+
{
|
59 |
+
if (in_array($value,$status_list))
|
60 |
+
$display_list[] = $label;
|
61 |
+
}
|
62 |
+
|
63 |
+
return $display_list;
|
64 |
+
}
|
65 |
+
|
66 |
+
public function getSendField()
|
67 |
+
{
|
68 |
+
return Mage::helper('emaildirect')->config('send_field');
|
69 |
+
}
|
70 |
+
|
71 |
+
public function getOrderState()
|
72 |
+
{
|
73 |
+
$order = $this->getOrder();
|
74 |
+
|
75 |
+
return $order->getConfig()->getStateLabel($order->getState());
|
76 |
+
}
|
77 |
+
|
78 |
+
public function getOrder()
|
79 |
+
{
|
80 |
+
return Mage::registry('current_order');
|
81 |
+
}
|
82 |
+
}
|
app/code/community/EmailDirect/Integration/Block/Adminhtml/System/Config/Form/Field/Api.php
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class EmailDirect_Integration_Block_Adminhtml_System_Config_Form_Field_Api extends Mage_Adminhtml_Block_System_Config_Form_Field
|
4 |
+
{
|
5 |
+
private $_helper = null;
|
6 |
+
|
7 |
+
public function __construct()
|
8 |
+
{
|
9 |
+
parent::__construct();
|
10 |
+
$this->setTemplate('emaildirect/system/config/form/field/api.phtml');
|
11 |
+
$this->_helper = Mage::helper('emaildirect');
|
12 |
+
}
|
13 |
+
|
14 |
+
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
|
15 |
+
{
|
16 |
+
$this->setElement($element);
|
17 |
+
$html = $this->_toHtml();
|
18 |
+
return $html;
|
19 |
+
}
|
20 |
+
|
21 |
+
public function isValid()
|
22 |
+
{
|
23 |
+
return Mage::helper('emaildirect')->config('setup') == 1;
|
24 |
+
}
|
25 |
+
|
26 |
+
public function getCurrentApiKey()
|
27 |
+
{
|
28 |
+
return $this->_helper->getApiKey();
|
29 |
+
}
|
30 |
+
}
|
app/code/community/EmailDirect/Integration/Block/Adminhtml/System/Config/Form/Field/Diagnostics.php
ADDED
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class EmailDirect_Integration_Block_Adminhtml_System_Config_Form_Field_Diagnostics extends Mage_Adminhtml_Block_System_Config_Form_Field
|
4 |
+
{
|
5 |
+
private $_helper = null;
|
6 |
+
private $_status = null;
|
7 |
+
|
8 |
+
public function __construct()
|
9 |
+
{
|
10 |
+
parent::__construct();
|
11 |
+
$this->setTemplate('emaildirect/system/config/form/field/diagnostics.phtml');
|
12 |
+
$this->_helper = Mage::helper('emaildirect');
|
13 |
+
}
|
14 |
+
|
15 |
+
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
|
16 |
+
{
|
17 |
+
$this->setElement($element);
|
18 |
+
$html = $this->_toHtml();
|
19 |
+
return $html;
|
20 |
+
}
|
21 |
+
|
22 |
+
public function getDiagnosticStatus()
|
23 |
+
{
|
24 |
+
return Mage::helper('emaildirect/troubleshooting')->isDiagnosticEnabled();
|
25 |
+
}
|
26 |
+
}
|
app/code/community/EmailDirect/Integration/Block/Adminhtml/System/Config/Form/Field/Logging.php
ADDED
@@ -0,0 +1,160 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class EmailDirect_Integration_Block_Adminhtml_System_Config_Form_Field_Logging extends Mage_Adminhtml_Block_System_Config_Form_Field
|
4 |
+
{
|
5 |
+
private $_helper = null;
|
6 |
+
private $_logger = null;
|
7 |
+
private $_status = null;
|
8 |
+
|
9 |
+
public function __construct()
|
10 |
+
{
|
11 |
+
parent::__construct();
|
12 |
+
$this->setTemplate('emaildirect/system/config/form/field/logging.phtml');
|
13 |
+
$this->_helper = Mage::helper('emaildirect');
|
14 |
+
$this->_logger = Mage::helper('emaildirect/troubleshooting');
|
15 |
+
}
|
16 |
+
|
17 |
+
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
|
18 |
+
{
|
19 |
+
$this->setElement($element);
|
20 |
+
$html = $this->_toHtml();
|
21 |
+
return $html;
|
22 |
+
}
|
23 |
+
|
24 |
+
public function getLoggingStatus()
|
25 |
+
{
|
26 |
+
if ($this->_status == null)
|
27 |
+
$this->_status = Mage::helper('emaildirect/troubleshooting')->getLoggingStatus();
|
28 |
+
|
29 |
+
return $this->_status;
|
30 |
+
}
|
31 |
+
|
32 |
+
public function isEnabledForStore()
|
33 |
+
{
|
34 |
+
try
|
35 |
+
{
|
36 |
+
$store = $this->_helper->getCurrentStore();
|
37 |
+
|
38 |
+
if ($store == 0)
|
39 |
+
return true;
|
40 |
+
|
41 |
+
$status = $this->getLoggingStatus();
|
42 |
+
|
43 |
+
$stores = $status['stores'];
|
44 |
+
|
45 |
+
$current_store = $stores[$store];
|
46 |
+
|
47 |
+
return $current_store['logging_enabled'];
|
48 |
+
|
49 |
+
}
|
50 |
+
catch (Exception $e)
|
51 |
+
{
|
52 |
+
return false;
|
53 |
+
}
|
54 |
+
|
55 |
+
return false;
|
56 |
+
}
|
57 |
+
|
58 |
+
public function getStartDate()
|
59 |
+
{
|
60 |
+
try
|
61 |
+
{
|
62 |
+
$date = $this->_helper->troubleConfig('logging_start_date');
|
63 |
+
|
64 |
+
$date = Mage::helper('core')->formatTime($date, 'long', true);
|
65 |
+
|
66 |
+
$minutes = "<br />(" . $this->_helper->timeElapsed2string(strtotime($date)) . " ago)";
|
67 |
+
|
68 |
+
return "{$date} {$minutes}";
|
69 |
+
}
|
70 |
+
catch (Exception $e)
|
71 |
+
{
|
72 |
+
$this->_logger->logException($e);
|
73 |
+
Mage::logException($e);
|
74 |
+
return "Unknown/Error";
|
75 |
+
}
|
76 |
+
}
|
77 |
+
|
78 |
+
public function getEDirectInfo()
|
79 |
+
{
|
80 |
+
$active = $this->_helper->config('active');
|
81 |
+
$setup = $this->_helper->config('setup');
|
82 |
+
|
83 |
+
$class= 'ab_ok';
|
84 |
+
$msg = "Enabled";
|
85 |
+
|
86 |
+
if (!$setup)
|
87 |
+
{
|
88 |
+
$class = 'ab_ng';
|
89 |
+
$msg = "Invalid API Key";
|
90 |
+
}
|
91 |
+
else if (!$active)
|
92 |
+
{
|
93 |
+
$class = 'ab_ng';
|
94 |
+
$msg = "Disabled";
|
95 |
+
}
|
96 |
+
|
97 |
+
return "<span class='{$class}'>{$msg}</span>";
|
98 |
+
}
|
99 |
+
|
100 |
+
public function getAbandonedInfo()
|
101 |
+
{
|
102 |
+
$active = $this->_helper->config('active');
|
103 |
+
$setup = $this->_helper->config('setup');
|
104 |
+
$sendit = $this->_helper->config('sendabandoned');
|
105 |
+
$abandoned_setup = $this->_helper->config('abandonedsetup');
|
106 |
+
|
107 |
+
$class= 'ab_ok';
|
108 |
+
$msg = "Enabled";
|
109 |
+
|
110 |
+
if (!$setup || !$active || !$sendit || !$abandoned_setup)
|
111 |
+
{
|
112 |
+
$class = 'ab_ng';
|
113 |
+
$msg = "Disabled";
|
114 |
+
}
|
115 |
+
|
116 |
+
return "<span class='{$class}'>{$msg}</span>";
|
117 |
+
}
|
118 |
+
|
119 |
+
public function getLogInfo()
|
120 |
+
{
|
121 |
+
try
|
122 |
+
{
|
123 |
+
$helper = $this->_helper;
|
124 |
+
|
125 |
+
$file_size = Mage::helper('emaildirect/troubleshooting')->getLogFileSize();
|
126 |
+
$formatted_size = $helper->formatSize($file_size);
|
127 |
+
|
128 |
+
$max_size = Mage::helper('emaildirect/troubleshooting')->getMaxLogFileSize();
|
129 |
+
|
130 |
+
if ($file_size > $max_size || $file_size == 0)
|
131 |
+
$formatted_size = "<span class='log_size_warning'>{$formatted_size}</span>";
|
132 |
+
|
133 |
+
$file_date = Mage::helper('emaildirect/troubleshooting')->getLogFilelastUpdate();
|
134 |
+
|
135 |
+
if ($file_date == "")
|
136 |
+
$last_update = "";
|
137 |
+
else
|
138 |
+
$last_update = "<br />" . Mage::helper('core')->formatTime(date(EmailDirect_Integration_Helper_Data::DATE_FORMAT,$file_date), 'long', true);
|
139 |
+
|
140 |
+
$ago = $helper->timeElapsed2string($file_date);
|
141 |
+
|
142 |
+
if ($ago != "")
|
143 |
+
$ago = "<br />({$ago} ago.)";
|
144 |
+
|
145 |
+
return Mage::helper('emaildirect/troubleshooting')->getLogFileName() . " ({$formatted_size}){$last_update}{$ago}";
|
146 |
+
}
|
147 |
+
catch (Exception $e)
|
148 |
+
{
|
149 |
+
$this->_logger->logException($e);
|
150 |
+
Mage::logException($e);
|
151 |
+
return "Unknown/Error";
|
152 |
+
}
|
153 |
+
}
|
154 |
+
|
155 |
+
public function isLoggingEnabled()
|
156 |
+
{
|
157 |
+
return Mage::helper('emaildirect/troubleshooting')->isLoggingEnabled();
|
158 |
+
}
|
159 |
+
|
160 |
+
}
|
app/code/community/EmailDirect/Integration/Block/Adminhtml/System/Config/Form/Field/Troubleshooting.php
CHANGED
@@ -19,6 +19,11 @@ class EmailDirect_Integration_Block_Adminhtml_System_Config_Form_Field_Troublesh
|
|
19 |
return $html;
|
20 |
}
|
21 |
|
|
|
|
|
|
|
|
|
|
|
22 |
public function getStartDate()
|
23 |
{
|
24 |
try
|
@@ -33,7 +38,7 @@ class EmailDirect_Integration_Block_Adminhtml_System_Config_Form_Field_Troublesh
|
|
33 |
}
|
34 |
catch (Exception $e)
|
35 |
{
|
36 |
-
$this->
|
37 |
Mage::logException($e);
|
38 |
return "Unknown/Error";
|
39 |
}
|
@@ -86,31 +91,31 @@ class EmailDirect_Integration_Block_Adminhtml_System_Config_Form_Field_Troublesh
|
|
86 |
{
|
87 |
$helper = $this->_helper;
|
88 |
|
89 |
-
$file_size =
|
90 |
$formatted_size = $helper->formatSize($file_size);
|
91 |
|
92 |
-
$max_size =
|
93 |
|
94 |
if ($file_size > $max_size || $file_size == 0)
|
95 |
$formatted_size = "<span class='log_size_warning'>{$formatted_size}</span>";
|
96 |
|
97 |
-
$file_date =
|
98 |
|
99 |
if ($file_date == "")
|
100 |
$last_update = "";
|
101 |
else
|
102 |
-
$last_update = "<br />" . Mage::helper('core')->formatTime(date(
|
103 |
|
104 |
$ago = $helper->timeElapsed2string($file_date);
|
105 |
|
106 |
if ($ago != "")
|
107 |
$ago = "<br />({$ago} ago.)";
|
108 |
|
109 |
-
return
|
110 |
}
|
111 |
catch (Exception $e)
|
112 |
{
|
113 |
-
$this->
|
114 |
Mage::logException($e);
|
115 |
return "Unknown/Error";
|
116 |
}
|
@@ -118,7 +123,7 @@ class EmailDirect_Integration_Block_Adminhtml_System_Config_Form_Field_Troublesh
|
|
118 |
|
119 |
public function isLoggingEnabled()
|
120 |
{
|
121 |
-
return Mage::helper('emaildirect')->isLoggingEnabled();
|
122 |
}
|
123 |
|
124 |
}
|
19 |
return $html;
|
20 |
}
|
21 |
|
22 |
+
public function getLoggingStatus()
|
23 |
+
{
|
24 |
+
return Mage::helper('emaildirect/troubleshooting')->getLoggingStatus();
|
25 |
+
}
|
26 |
+
|
27 |
public function getStartDate()
|
28 |
{
|
29 |
try
|
38 |
}
|
39 |
catch (Exception $e)
|
40 |
{
|
41 |
+
$this->logException($e);
|
42 |
Mage::logException($e);
|
43 |
return "Unknown/Error";
|
44 |
}
|
91 |
{
|
92 |
$helper = $this->_helper;
|
93 |
|
94 |
+
$file_size = Mage::helper('emaildirect/troubleshooting')->getLogFileSize();
|
95 |
$formatted_size = $helper->formatSize($file_size);
|
96 |
|
97 |
+
$max_size = Mage::helper('emaildirect/troubleshooting')->getMaxLogFileSize();
|
98 |
|
99 |
if ($file_size > $max_size || $file_size == 0)
|
100 |
$formatted_size = "<span class='log_size_warning'>{$formatted_size}</span>";
|
101 |
|
102 |
+
$file_date = Mage::helper('emaildirect/troubleshooting')->getLogFilelastUpdate();
|
103 |
|
104 |
if ($file_date == "")
|
105 |
$last_update = "";
|
106 |
else
|
107 |
+
$last_update = "<br />" . Mage::helper('core')->formatTime(date(EmailDirect_Integration_Helper_Data::DATE_FORMAT,$file_date), 'long', true);
|
108 |
|
109 |
$ago = $helper->timeElapsed2string($file_date);
|
110 |
|
111 |
if ($ago != "")
|
112 |
$ago = "<br />({$ago} ago.)";
|
113 |
|
114 |
+
return Mage::helper('emaildirect/troubleshooting')->getLogFileName() . " ({$formatted_size}){$last_update}{$ago}";
|
115 |
}
|
116 |
catch (Exception $e)
|
117 |
{
|
118 |
+
$this->logException($e);
|
119 |
Mage::logException($e);
|
120 |
return "Unknown/Error";
|
121 |
}
|
123 |
|
124 |
public function isLoggingEnabled()
|
125 |
{
|
126 |
+
return Mage::helper('emaildirect/troubleshooting')->isLoggingEnabled();
|
127 |
}
|
128 |
|
129 |
}
|
app/code/community/EmailDirect/Integration/Block/Adminhtml/Troubleshooting/Status.php
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class EmailDirect_Integration_Block_Adminhtml_Troubleshooting_Status extends Mage_Adminhtml_Block_Template
|
4 |
+
{
|
5 |
+
public function getLoggingStatus()
|
6 |
+
{
|
7 |
+
return Mage::helper('emaildirect/troubleshooting')->getLoggingStatus();
|
8 |
+
}
|
9 |
+
}
|
app/code/community/EmailDirect/Integration/Block/Adminhtml/Troubleshooting/Tabs.php
CHANGED
@@ -9,4 +9,23 @@ class EmailDirect_Integration_Block_Adminhtml_Troubleshooting_Tabs extends Mage_
|
|
9 |
$this->setDestElementId('troubleshooting_view');
|
10 |
$this->setTitle(Mage::helper('emaildirect')->__('Troubleshooting'));
|
11 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
}
|
9 |
$this->setDestElementId('troubleshooting_view');
|
10 |
$this->setTitle(Mage::helper('emaildirect')->__('Troubleshooting'));
|
11 |
}
|
12 |
+
|
13 |
+
protected function _beforeToHtml()
|
14 |
+
{
|
15 |
+
$this->_updateActiveTab();
|
16 |
+
return parent::_beforeToHtml();
|
17 |
+
}
|
18 |
+
|
19 |
+
protected function _updateActiveTab()
|
20 |
+
{
|
21 |
+
$tabId = $this->getRequest()->getParam('tab');
|
22 |
+
if ($tabId)
|
23 |
+
{
|
24 |
+
$tabId = preg_replace("#{$this->getId()}_#", '', $tabId);
|
25 |
+
if ($tabId)
|
26 |
+
{
|
27 |
+
$this->setActiveTab($tabId);
|
28 |
+
}
|
29 |
+
}
|
30 |
+
}
|
31 |
}
|
app/code/community/EmailDirect/Integration/Block/Adminhtml/Troubleshooting/View.php
CHANGED
@@ -2,7 +2,6 @@
|
|
2 |
|
3 |
class EmailDirect_Integration_Block_Adminhtml_Troubleshooting_View extends Mage_Adminhtml_Block_Widget_Form_Container
|
4 |
{
|
5 |
-
|
6 |
public function __construct()
|
7 |
{
|
8 |
$this->_blockGroup = "emaildirect";
|
@@ -15,23 +14,18 @@ class EmailDirect_Integration_Block_Adminhtml_Troubleshooting_View extends Mage_
|
|
15 |
$this->_removeButton('reset');
|
16 |
$this->_removeButton('save');
|
17 |
$this->setId('troubleshooting_view');
|
18 |
-
|
19 |
-
$this->_addButton('info_send', array(
|
20 |
-
'label' => Mage::helper('emaildirect')->__('Send to EmailDirect'),
|
21 |
-
'onclick' => 'ed_form.submit();',
|
22 |
-
));
|
23 |
|
24 |
-
$
|
25 |
-
|
26 |
-
'
|
27 |
-
'onclick' => $onClick,
|
28 |
));
|
|
|
29 |
$this->setTemplate('emaildirect/troubleshooting/view.phtml');
|
30 |
}
|
31 |
|
32 |
public function getHeaderText()
|
33 |
{
|
34 |
-
return Mage::helper('emaildirect')->__('
|
35 |
}
|
36 |
|
37 |
public function getUrl($params='', $params2=array())
|
@@ -39,40 +33,8 @@ class EmailDirect_Integration_Block_Adminhtml_Troubleshooting_View extends Mage_
|
|
39 |
return parent::getUrl($params, $params2);
|
40 |
}
|
41 |
|
42 |
-
public function getDownloadUrl()
|
43 |
-
{
|
44 |
-
return $this->getUrl('emaildirect/admin_troubleshooting/download/');
|
45 |
-
}
|
46 |
-
|
47 |
public function getBackUrl()
|
48 |
{
|
49 |
return Mage::helper('emaildirect')->getAdminUrl('adminhtml/system_config/edit/section/emaildirect');
|
50 |
}
|
51 |
-
|
52 |
-
public function getLogFileName()
|
53 |
-
{
|
54 |
-
return Mage::helper('emaildirect')->getLogFileName();
|
55 |
-
}
|
56 |
-
|
57 |
-
public function getTroubleEmail()
|
58 |
-
{
|
59 |
-
return Mage::helper('emaildirect')->troubleConfig('email');
|
60 |
-
}
|
61 |
-
|
62 |
-
public function getLogFileSize()
|
63 |
-
{
|
64 |
-
return Mage::helper('emaildirect')->getLogFileSize();
|
65 |
-
}
|
66 |
-
|
67 |
-
public function getMaxLogFileSize()
|
68 |
-
{
|
69 |
-
return Mage::helper('emaildirect')->formatSize(Mage::helper('emaildirect')->getMaxLogFileSize());
|
70 |
-
}
|
71 |
-
|
72 |
-
public function isLogFileTooLarge()
|
73 |
-
{
|
74 |
-
if ($this->getLogFileSize() > Mage::helper('emaildirect')->getMaxLogFileSize())
|
75 |
-
return true;
|
76 |
-
return false;
|
77 |
-
}
|
78 |
-
}
|
2 |
|
3 |
class EmailDirect_Integration_Block_Adminhtml_Troubleshooting_View extends Mage_Adminhtml_Block_Widget_Form_Container
|
4 |
{
|
|
|
5 |
public function __construct()
|
6 |
{
|
7 |
$this->_blockGroup = "emaildirect";
|
14 |
$this->_removeButton('reset');
|
15 |
$this->_removeButton('save');
|
16 |
$this->setId('troubleshooting_view');
|
|
|
|
|
|
|
|
|
|
|
17 |
|
18 |
+
$this->_addButton('refresh', array(
|
19 |
+
'label' => Mage::helper('emaildirect')->__('Refresh'),
|
20 |
+
'onclick' => 'window.location.reload();',
|
|
|
21 |
));
|
22 |
+
|
23 |
$this->setTemplate('emaildirect/troubleshooting/view.phtml');
|
24 |
}
|
25 |
|
26 |
public function getHeaderText()
|
27 |
{
|
28 |
+
return Mage::helper('emaildirect')->__('EmailDirect Troubleshooting');
|
29 |
}
|
30 |
|
31 |
public function getUrl($params='', $params2=array())
|
33 |
return parent::getUrl($params, $params2);
|
34 |
}
|
35 |
|
|
|
|
|
|
|
|
|
|
|
36 |
public function getBackUrl()
|
37 |
{
|
38 |
return Mage::helper('emaildirect')->getAdminUrl('adminhtml/system_config/edit/section/emaildirect');
|
39 |
}
|
40 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/community/EmailDirect/Integration/Block/Adminhtml/Troubleshooting/View/Tab/Help.php
ADDED
@@ -0,0 +1,77 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class EmailDirect_Integration_Block_Adminhtml_Troubleshooting_View_Tab_Help
|
4 |
+
extends Mage_Adminhtml_Block_Template
|
5 |
+
implements Mage_Adminhtml_Block_Widget_Tab_Interface
|
6 |
+
{
|
7 |
+
private $_columns = 3;
|
8 |
+
|
9 |
+
public function getTabLabel()
|
10 |
+
{
|
11 |
+
return Mage::helper('emaildirect')->__('Help');
|
12 |
+
}
|
13 |
+
|
14 |
+
public function getTabTitle()
|
15 |
+
{
|
16 |
+
return Mage::helper('emaildirect')->__('Help');
|
17 |
+
}
|
18 |
+
|
19 |
+
public function canShowTab()
|
20 |
+
{
|
21 |
+
return true;
|
22 |
+
}
|
23 |
+
|
24 |
+
public function isHidden()
|
25 |
+
{
|
26 |
+
return false;
|
27 |
+
}
|
28 |
+
|
29 |
+
public function __construct()
|
30 |
+
{
|
31 |
+
parent::__construct();
|
32 |
+
$this->setTemplate('emaildirect/troubleshooting/view/tab/help.phtml');
|
33 |
+
}
|
34 |
+
|
35 |
+
private function getFields($data)
|
36 |
+
{
|
37 |
+
$fields = array();
|
38 |
+
|
39 |
+
foreach ($data as $key => $value)
|
40 |
+
{
|
41 |
+
if (!is_object($value) && !is_array($value))
|
42 |
+
$fields[] = $key;
|
43 |
+
}
|
44 |
+
|
45 |
+
asort($fields);
|
46 |
+
return array_chunk($fields, ceil(count($fields) / $this->_columns));
|
47 |
+
}
|
48 |
+
|
49 |
+
public function getCustomerFields()
|
50 |
+
{
|
51 |
+
$customer = Mage::getModel('customer/customer')->getCollection()->getFirstItem();
|
52 |
+
|
53 |
+
$customer = Mage::getModel('customer/customer')->load($customer->getId());
|
54 |
+
|
55 |
+
return $this->getFields($customer->getData());
|
56 |
+
}
|
57 |
+
|
58 |
+
public function getAddressFields()
|
59 |
+
{
|
60 |
+
$address = Mage::getModel('customer/address')->getCollection()->getFirstItem();
|
61 |
+
|
62 |
+
$address = Mage::getModel('customer/address')->load($address->getId());
|
63 |
+
|
64 |
+
return $this->getFields($address->getData());
|
65 |
+
}
|
66 |
+
|
67 |
+
public function getShippingFields()
|
68 |
+
{
|
69 |
+
//$address = Mage::getModel('customer/address')->getCollection()->getFirstItem();
|
70 |
+
|
71 |
+
//$address = Mage::getModel('customer/address')->load($address->getId());
|
72 |
+
|
73 |
+
$shipping_fields = array('Shipping Code' => 1, 'Shipping Description' => 1, 'Tracking Carrier Code' => 1, 'Tracking Title' => 1, 'Tracking Number' => 1);
|
74 |
+
|
75 |
+
return $this->getFields($shipping_fields);
|
76 |
+
}
|
77 |
+
}
|
app/code/community/EmailDirect/Integration/Block/Adminhtml/Troubleshooting/View/Tab/Info.php
CHANGED
@@ -32,11 +32,11 @@ class EmailDirect_Integration_Block_Adminhtml_Troubleshooting_View_Tab_Info
|
|
32 |
|
33 |
public function getEnvironmentInfo()
|
34 |
{
|
35 |
-
return Mage::helper('emaildirect')->getEnvironmentInfo();
|
36 |
}
|
37 |
|
38 |
public function getConfigurationInfo()
|
39 |
{
|
40 |
-
return Mage::helper('emaildirect')->getConfigurationInfo();
|
41 |
}
|
42 |
}
|
32 |
|
33 |
public function getEnvironmentInfo()
|
34 |
{
|
35 |
+
return Mage::helper('emaildirect/troubleshooting')->getEnvironmentInfo();
|
36 |
}
|
37 |
|
38 |
public function getConfigurationInfo()
|
39 |
{
|
40 |
+
return Mage::helper('emaildirect/troubleshooting')->getConfigurationInfo();
|
41 |
}
|
42 |
}
|
app/code/community/EmailDirect/Integration/Block/Adminhtml/Troubleshooting/View/Tab/Log.php
CHANGED
@@ -33,6 +33,6 @@ class EmailDirect_Integration_Block_Adminhtml_Troubleshooting_View_Tab_Log
|
|
33 |
|
34 |
public function getLogFile()
|
35 |
{
|
36 |
-
return Mage::helper('emaildirect')->getLogFileContents();
|
37 |
}
|
38 |
}
|
33 |
|
34 |
public function getLogFile()
|
35 |
{
|
36 |
+
return Mage::helper('emaildirect/troubleshooting')->getLogFileContents();
|
37 |
}
|
38 |
}
|
app/code/community/EmailDirect/Integration/Block/Adminhtml/Troubleshooting/View/Tab/Settings.php
ADDED
@@ -0,0 +1,60 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class EmailDirect_Integration_Block_Adminhtml_Troubleshooting_View_Tab_Settings
|
4 |
+
extends Mage_Adminhtml_Block_Template
|
5 |
+
implements Mage_Adminhtml_Block_Widget_Tab_Interface
|
6 |
+
{
|
7 |
+
private $_helper = null;
|
8 |
+
|
9 |
+
public function getTabLabel()
|
10 |
+
{
|
11 |
+
return Mage::helper('emaildirect')->__('Settings');
|
12 |
+
}
|
13 |
+
|
14 |
+
public function getTabTitle()
|
15 |
+
{
|
16 |
+
return Mage::helper('emaildirect')->__('Settings');
|
17 |
+
}
|
18 |
+
|
19 |
+
public function canShowTab()
|
20 |
+
{
|
21 |
+
return true;
|
22 |
+
}
|
23 |
+
|
24 |
+
public function isHidden()
|
25 |
+
{
|
26 |
+
return false;
|
27 |
+
}
|
28 |
+
|
29 |
+
public function __construct()
|
30 |
+
{
|
31 |
+
$this->_helper = Mage::helper('emaildirect/troubleshooting');
|
32 |
+
parent::__construct();
|
33 |
+
$this->setTemplate('emaildirect/troubleshooting/view/tab/settings.phtml');
|
34 |
+
}
|
35 |
+
|
36 |
+
public function getLoggingStatus()
|
37 |
+
{
|
38 |
+
return $this->_helper->getLoggingStatus();
|
39 |
+
}
|
40 |
+
|
41 |
+
public function getDurationOptions()
|
42 |
+
{
|
43 |
+
return array(10 => "10 Minutes", 20 => "20 Minutes", 30 => "30 Minutes", 60 => "1 Hour", 1440 => "1 Day");
|
44 |
+
}
|
45 |
+
|
46 |
+
public function getSetting($setting)
|
47 |
+
{
|
48 |
+
return Mage::helper('emaildirect/troubleshooting')->config($setting);
|
49 |
+
}
|
50 |
+
|
51 |
+
public function getArraySetting($setting)
|
52 |
+
{
|
53 |
+
return Mage::helper('emaildirect/troubleshooting')->arrayConfig($setting);
|
54 |
+
}
|
55 |
+
|
56 |
+
public function getCurrentIP()
|
57 |
+
{
|
58 |
+
return Mage::helper('core/http')->getRemoteAddr();
|
59 |
+
}
|
60 |
+
}
|
app/code/community/EmailDirect/Integration/Block/Adminhtml/Troubleshooting/View/Tab/Submit.php
CHANGED
@@ -29,4 +29,29 @@ class EmailDirect_Integration_Block_Adminhtml_Troubleshooting_View_Tab_Submit
|
|
29 |
parent::__construct();
|
30 |
$this->setTemplate('emaildirect/troubleshooting/view/tab/submit.phtml');
|
31 |
}
|
32 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
29 |
parent::__construct();
|
30 |
$this->setTemplate('emaildirect/troubleshooting/view/tab/submit.phtml');
|
31 |
}
|
32 |
+
|
33 |
+
public function getLogFileSize()
|
34 |
+
{
|
35 |
+
return Mage::helper('emaildirect/troubleshooting')->getLogFileSize();
|
36 |
+
}
|
37 |
+
|
38 |
+
public function getMaxLogFileSize()
|
39 |
+
{
|
40 |
+
return Mage::helper('emaildirect')->formatSize(Mage::helper('emaildirect/troubleshooting')->getMaxLogFileSize());
|
41 |
+
}
|
42 |
+
|
43 |
+
public function isLogFileTooLarge()
|
44 |
+
{
|
45 |
+
return Mage::helper('emaildirect/troubleshooting')->isLogFileTooLarge();
|
46 |
+
}
|
47 |
+
|
48 |
+
public function getTroubleEmail()
|
49 |
+
{
|
50 |
+
return Mage::helper('emaildirect')->troubleConfig('email');
|
51 |
+
}
|
52 |
+
|
53 |
+
public function getLogFileName()
|
54 |
+
{
|
55 |
+
return Mage::helper('emaildirect/troubleshooting')->getLogFileName();
|
56 |
+
}
|
57 |
+
}
|
app/code/community/EmailDirect/Integration/Block/Checkout/Subscribe.php
CHANGED
@@ -9,7 +9,7 @@ class EmailDirect_Integration_Block_Checkout_Subscribe extends Mage_Core_Block_T
|
|
9 |
->isSubscribed();
|
10 |
|
11 |
if (!$this->helper('emaildirect')->canCheckoutSubscribe() || $alreadySubscribed)
|
12 |
-
return
|
13 |
|
14 |
return parent::_toHtml();
|
15 |
}
|
9 |
->isSubscribed();
|
10 |
|
11 |
if (!$this->helper('emaildirect')->canCheckoutSubscribe() || $alreadySubscribed)
|
12 |
+
return "";
|
13 |
|
14 |
return parent::_toHtml();
|
15 |
}
|
app/code/community/EmailDirect/Integration/Block/Signup.php
CHANGED
@@ -1,92 +1,27 @@
|
|
1 |
<?php
|
2 |
|
3 |
class EmailDirect_Integration_Block_Signup extends Mage_Core_Block_Template
|
4 |
-
{
|
5 |
-
private $_test_mode = false;
|
6 |
-
private $_signup_width = 0;
|
7 |
-
private $_signup_height = 0;
|
8 |
-
private $_signup_url = "";
|
9 |
-
private $_signup_delay = 0;
|
10 |
-
private $_signup_opacity = 0;
|
11 |
-
|
12 |
-
private $_active = false;
|
13 |
-
|
14 |
-
public function __construct()
|
15 |
-
{
|
16 |
-
if ($this->helper('emaildirect')->canShowSignup())
|
17 |
-
{
|
18 |
-
$this->_active = true;
|
19 |
-
|
20 |
-
if ($this->helper('emaildirect')->isSignupTest())
|
21 |
-
{
|
22 |
-
$this->_test_mode = true;
|
23 |
-
$request = Mage::app()->getRequest();
|
24 |
-
|
25 |
-
$this->_signup_width = $request->getParam('width');
|
26 |
-
$this->_height = $request->getParam('height');
|
27 |
-
$this->_signup_url = $request->getParam('url');
|
28 |
-
$this->_signup_delay = $request->getParam('delay');
|
29 |
-
$this->_signup_opacity = $request->getParam('opacity');
|
30 |
-
}
|
31 |
-
else
|
32 |
-
{
|
33 |
-
$this->_signup_width = $this->helper('emaildirect')->config('signup_width');
|
34 |
-
$this->_height = $this->helper('emaildirect')->config('signup_height');
|
35 |
-
$this->_signup_url = $this->helper('emaildirect')->config('signup_url');
|
36 |
-
$this->_signup_delay = $this->helper('emaildirect')->config('signup_delay');
|
37 |
-
$this->_signup_opacity = $this->helper('emaildirect')->config('signup_opacity');
|
38 |
-
}
|
39 |
-
|
40 |
-
if ($this->_signup_width == "" || $this->_height == "" || $this->_signup_url == "")
|
41 |
-
$this->_active = false;
|
42 |
-
}
|
43 |
-
}
|
44 |
-
|
45 |
protected function _toHtml()
|
46 |
{
|
47 |
-
if (!$this->
|
48 |
return "";
|
49 |
|
50 |
return parent::_toHtml();
|
51 |
}
|
52 |
|
53 |
-
public function
|
54 |
-
{
|
55 |
-
return "{$this->_signup_width}px";
|
56 |
-
}
|
57 |
-
|
58 |
-
public function getSignupHeight()
|
59 |
-
{
|
60 |
-
return "{$this->_height}px";
|
61 |
-
}
|
62 |
-
|
63 |
-
public function getSignupFrameWidth()
|
64 |
-
{
|
65 |
-
return "100%";
|
66 |
-
}
|
67 |
-
|
68 |
-
public function getSignupFrameHeight()
|
69 |
-
{
|
70 |
-
return "100%";
|
71 |
-
}
|
72 |
-
|
73 |
-
public function getSignupUrl()
|
74 |
{
|
75 |
-
return $this->
|
76 |
}
|
77 |
|
78 |
public function getSignupDelay()
|
79 |
{
|
80 |
-
return (int)$this->
|
81 |
-
}
|
82 |
-
|
83 |
-
public function getSignupOpacity()
|
84 |
-
{
|
85 |
-
return (int)$this->_signup_opacity;
|
86 |
}
|
87 |
|
88 |
-
public function
|
89 |
{
|
90 |
-
return $this->
|
91 |
}
|
92 |
}
|
1 |
<?php
|
2 |
|
3 |
class EmailDirect_Integration_Block_Signup extends Mage_Core_Block_Template
|
4 |
+
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
protected function _toHtml()
|
6 |
{
|
7 |
+
if (!$this->helper('emaildirect')->canEdirect() || !$this->helper('emaildirect')->config('signup_enabled'))
|
8 |
return "";
|
9 |
|
10 |
return parent::_toHtml();
|
11 |
}
|
12 |
|
13 |
+
public function isSignupEnabled()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
14 |
{
|
15 |
+
return $this->helper('emaildirect')->isSignupEnabled() ? 'true' : 'false';
|
16 |
}
|
17 |
|
18 |
public function getSignupDelay()
|
19 |
{
|
20 |
+
return (int)$this->helper('emaildirect')->config('signup_delay') * 1000;
|
|
|
|
|
|
|
|
|
|
|
21 |
}
|
22 |
|
23 |
+
public function getSignupCheckUrl()
|
24 |
{
|
25 |
+
return $this->getUrl('emaildirect/signup/check');
|
26 |
}
|
27 |
}
|
app/code/community/EmailDirect/Integration/Controller/Front/Abstract.php
ADDED
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class EmailDirect_Integration_Controller_Front_Abstract extends Mage_Core_Controller_Front_Action
|
4 |
+
{
|
5 |
+
protected $_helper = null;
|
6 |
+
protected $_logger = null;
|
7 |
+
|
8 |
+
public function __construct(Zend_Controller_Request_Abstract $request, Zend_Controller_Response_Abstract $response, array $invokeArgs = array())
|
9 |
+
{
|
10 |
+
$this->_helper = Mage::helper('emaildirect');
|
11 |
+
$this->_logger = Mage::helper('emaildirect/troubleshooting');
|
12 |
+
|
13 |
+
return parent::__construct($request, $response, $invokeArgs);
|
14 |
+
}
|
15 |
+
|
16 |
+
protected function _log($data, $prefix = "")
|
17 |
+
{
|
18 |
+
$this->_logger->log($data, $prefix);
|
19 |
+
}
|
20 |
+
|
21 |
+
protected function _logException($e)
|
22 |
+
{
|
23 |
+
$this->_logger->logException($e);
|
24 |
+
}
|
25 |
+
|
26 |
+
protected function _logReason($data)
|
27 |
+
{
|
28 |
+
$this->_logger->logReason($data);
|
29 |
+
}
|
30 |
+
|
31 |
+
protected function _setLogArea($area)
|
32 |
+
{
|
33 |
+
$this->_logger->setLogArea($area);
|
34 |
+
}
|
35 |
+
}
|
app/code/community/EmailDirect/Integration/Helper/Abandoned.php
ADDED
@@ -0,0 +1,176 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class EmailDirect_Integration_Helper_Abandoned extends EmailDirect_Integration_Helper_Data
|
4 |
+
{
|
5 |
+
private $_sequences = null;
|
6 |
+
private $_current_sequence = 0;
|
7 |
+
private $_sequence_enabled = false;
|
8 |
+
private $_sequence_field = "";
|
9 |
+
|
10 |
+
public function getAbandonedUrl($quote)
|
11 |
+
{
|
12 |
+
// We are using comma separated lists for the ID's and Quantities so that it takes up less
|
13 |
+
// space when we generate the Querystring
|
14 |
+
|
15 |
+
$item_data = array();
|
16 |
+
|
17 |
+
$this->debug("Get Abandoned URL");
|
18 |
+
|
19 |
+
foreach ($quote->getAllItems() as $item)
|
20 |
+
{
|
21 |
+
$product = $this->getProduct($item);
|
22 |
+
$parent_id = $item->getParentItemId();
|
23 |
+
$item_id = $item->getId();
|
24 |
+
|
25 |
+
if ($parent_id != null)
|
26 |
+
{
|
27 |
+
$item_data[$parent_id]['option'] = $product->getId();
|
28 |
+
}
|
29 |
+
else
|
30 |
+
{
|
31 |
+
$item_data[$item_id]['product_id'] = $product->getId();
|
32 |
+
$item_data[$item_id]['qty'] = $item->getQty();
|
33 |
+
|
34 |
+
if ($item->getProductType() == 'grouped')
|
35 |
+
{
|
36 |
+
$option = $item->getOptionByCode('product_type');
|
37 |
+
if ($option)
|
38 |
+
{
|
39 |
+
$product = $option->getProduct();
|
40 |
+
$item_data[$item_id]['option'] = $product->getId();
|
41 |
+
}
|
42 |
+
}
|
43 |
+
else if ($item->getProductType() == 'bundle')
|
44 |
+
{
|
45 |
+
$option = $item->getOptionByCode('info_buyRequest');
|
46 |
+
|
47 |
+
if ($option)
|
48 |
+
{
|
49 |
+
$data = unserialize($option->getValue());
|
50 |
+
|
51 |
+
$bundle_option = "";
|
52 |
+
|
53 |
+
foreach ($data['bundle_option'] as $id => $value)
|
54 |
+
{
|
55 |
+
if ($bundle_option != "")
|
56 |
+
$bundle_option .= "-";
|
57 |
+
|
58 |
+
$bundle_option .= "{$id}=";
|
59 |
+
|
60 |
+
if (is_array($value))
|
61 |
+
{
|
62 |
+
$bundle_option .= implode(":",$value);
|
63 |
+
}
|
64 |
+
else
|
65 |
+
{
|
66 |
+
$qty = $data['bundle_option_qty'][$id];
|
67 |
+
$bundle_option .= "{$value}~{$qty}";
|
68 |
+
}
|
69 |
+
}
|
70 |
+
$item_data[$item_id]['bundle_option'] = $bundle_option;
|
71 |
+
}
|
72 |
+
}
|
73 |
+
}
|
74 |
+
}
|
75 |
+
|
76 |
+
$ids = "";
|
77 |
+
$qtys = "";
|
78 |
+
|
79 |
+
$this->debug("Item Data:");
|
80 |
+
$this->debug($item_data);
|
81 |
+
|
82 |
+
foreach ($item_data as $item)
|
83 |
+
{
|
84 |
+
if ($ids != "")
|
85 |
+
{
|
86 |
+
$ids .= ",";
|
87 |
+
$qtys .= ",";
|
88 |
+
}
|
89 |
+
|
90 |
+
$ids .= $item['product_id'];
|
91 |
+
$qtys .= $item['qty'];
|
92 |
+
|
93 |
+
if (isset($item['bundle_option']))
|
94 |
+
$ids .= "|{$item['bundle_option']}";
|
95 |
+
else if (isset($item['option']))
|
96 |
+
$ids .= "|{$item['option']}";
|
97 |
+
}
|
98 |
+
|
99 |
+
$url_data = array("quote" => $quote->getId(), "id" => $ids, "qty" => $qtys);
|
100 |
+
|
101 |
+
//$this->logAndDebug($url_data, "Abandoned Url Data");
|
102 |
+
$this->debug("URL Data:");
|
103 |
+
$this->debug($url_data);
|
104 |
+
|
105 |
+
$url = base64_encode(serialize($url_data));
|
106 |
+
|
107 |
+
$url = Mage::getUrl('emaildirect/abandoned/restore',array('_secure'=>true)) . "?cart={$url}";
|
108 |
+
|
109 |
+
$this->debug("URL:");
|
110 |
+
$this->debug($url);
|
111 |
+
|
112 |
+
return $url;
|
113 |
+
}
|
114 |
+
|
115 |
+
public function getLastOrder($quote)
|
116 |
+
{
|
117 |
+
$this->logAndDebug("Get Last Order");
|
118 |
+
$customer_id = $quote->getData('customer_id');
|
119 |
+
|
120 |
+
$this->logAndDebug("Customer ID: {$customer_id}");
|
121 |
+
|
122 |
+
$orders = Mage::getResourceModel('sales/order_collection')
|
123 |
+
->addFieldToSelect('*')
|
124 |
+
->addFieldToFilter('customer_id', $customer_id)
|
125 |
+
->addAttributeToSort('created_at', 'DESC')
|
126 |
+
->setPageSize(1);
|
127 |
+
|
128 |
+
$this->logAndDebug("Order Count: " . $orders->getSize());
|
129 |
+
if ($orders->getSize() <= 0)
|
130 |
+
{
|
131 |
+
$this->logAndDebug("No Orders Found");
|
132 |
+
return null;
|
133 |
+
}
|
134 |
+
|
135 |
+
$this->logAndDebug("Order Found");
|
136 |
+
$order = $orders->getFirstItem();
|
137 |
+
|
138 |
+
return $order;
|
139 |
+
}
|
140 |
+
|
141 |
+
public function addSequence(&$merge_vars)
|
142 |
+
{
|
143 |
+
if (!$this->_sequence_enabled)
|
144 |
+
return;
|
145 |
+
|
146 |
+
if (!isset($this->_sequences[$this->_current_sequence]))
|
147 |
+
$this->_current_sequence = 0;
|
148 |
+
|
149 |
+
$merge_vars[$this->_sequence_field] = $this->_sequences[$this->_current_sequence++];
|
150 |
+
}
|
151 |
+
|
152 |
+
public function setupSequence()
|
153 |
+
{
|
154 |
+
$this->_sequence_enabled = $this->config('abandonedsequence_enabled');
|
155 |
+
|
156 |
+
if (!$this->_sequence_enabled)
|
157 |
+
return;
|
158 |
+
|
159 |
+
$sequences = str_replace("\r\n","\n",$this->config('abandonedsequence_options'));
|
160 |
+
$this->_current_sequence = $this->config('abandonedsequence_current');
|
161 |
+
|
162 |
+
if (!is_numeric($this->_current_sequence))
|
163 |
+
$this->_current_sequence = 0;
|
164 |
+
|
165 |
+
$this->_sequences = explode("\n",$sequences);
|
166 |
+
$this->_sequence_field = $this->config('abandonedsequence_field');
|
167 |
+
}
|
168 |
+
|
169 |
+
public function saveCurrentSequence()
|
170 |
+
{
|
171 |
+
if (!$this->_sequence_enabled)
|
172 |
+
return;
|
173 |
+
|
174 |
+
$this->updateConfig('abandonedsequence_current',$this->_current_sequence);
|
175 |
+
}
|
176 |
+
}
|
app/code/community/EmailDirect/Integration/Helper/Data.php
CHANGED
@@ -1,27 +1,124 @@
|
|
1 |
<?php
|
2 |
|
3 |
class EmailDirect_Integration_Helper_Data extends Mage_Core_Helper_Abstract
|
4 |
-
{
|
5 |
-
const
|
6 |
-
const LOG_FILE_EXT = '.log';
|
7 |
-
const LOG_LEVEL_HIGH = 0;
|
8 |
-
const LOG_LEVEL_NORMAL = 5;
|
9 |
-
const LOG_LEVEL_LOW = 100;
|
10 |
-
|
11 |
-
const ABANDONED_CART = "AB";
|
12 |
-
const ORDERS = "OR";
|
13 |
-
const NEWSLETTER = "NL";
|
14 |
-
const CUSTOMER = "CU";
|
15 |
-
const CONFIG = "CG";
|
16 |
-
const IGNORE = "IG";
|
17 |
-
const WISHLIST = "WL";
|
18 |
|
19 |
const DISABLED_REASON_PREFIX = "Skipping";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
20 |
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
25 |
|
26 |
// Used to restore configurable products to the cart
|
27 |
public function getConfigurableOptions($product, $simple_product_id)
|
@@ -62,14 +159,6 @@ class EmailDirect_Integration_Helper_Data extends Mage_Core_Helper_Abstract
|
|
62 |
}
|
63 |
}
|
64 |
|
65 |
-
public function setCurrentStore($store_code, $set_magento_store = true)
|
66 |
-
{
|
67 |
-
$this->_current_store = $store_code;
|
68 |
-
|
69 |
-
if ($set_magento_store)
|
70 |
-
Mage::app()->setCurrentStore($store_code);
|
71 |
-
}
|
72 |
-
|
73 |
public function getAdminStore()
|
74 |
{
|
75 |
$code = Mage::app()->getRequest()->getParam('store');
|
@@ -177,13 +266,8 @@ class EmailDirect_Integration_Helper_Data extends Mage_Core_Helper_Abstract
|
|
177 |
}
|
178 |
}
|
179 |
|
180 |
-
public function
|
181 |
{
|
182 |
-
if ($time == "")
|
183 |
-
return "";
|
184 |
-
|
185 |
-
$timeline = time() - $time;
|
186 |
-
|
187 |
$periods = array('day' => 86400, 'hour' => 3600, 'minute' => 60);
|
188 |
|
189 |
$ret = "";
|
@@ -191,12 +275,29 @@ class EmailDirect_Integration_Helper_Data extends Mage_Core_Helper_Abstract
|
|
191 |
foreach($periods as $name => $seconds)
|
192 |
{
|
193 |
$num = floor($timeline / $seconds);
|
|
|
|
|
|
|
194 |
$timeline -= ($num * $seconds);
|
195 |
$ret .= $num.' '.$name.(($num > 1 || $num == 0) ? 's' : '').' ';
|
|
|
196 |
}
|
197 |
|
198 |
return trim($ret);
|
199 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
200 |
|
201 |
public function getExportFileName($name,$full = true)
|
202 |
{
|
@@ -280,6 +381,8 @@ class EmailDirect_Integration_Helper_Data extends Mage_Core_Helper_Abstract
|
|
280 |
if (is_null($store))
|
281 |
$store = $this->getCurrentStore();
|
282 |
|
|
|
|
|
283 |
$realvalue = Mage::getStoreConfig("emaildirect/{$section}/{$value}", $store);
|
284 |
|
285 |
return $realvalue;
|
@@ -347,161 +450,7 @@ class EmailDirect_Integration_Helper_Data extends Mage_Core_Helper_Abstract
|
|
347 |
{
|
348 |
return $this->config('publication', $storeId);
|
349 |
}
|
350 |
-
|
351 |
-
public function getMergeVars($customer)
|
352 |
-
{
|
353 |
-
$merge_vars = array();
|
354 |
-
$maps = unserialize( $this->config('map_fields', $customer->getStoreId()) );
|
355 |
-
|
356 |
-
if ($maps)
|
357 |
-
$this->processMap($merge_vars, $maps, $customer);
|
358 |
-
|
359 |
-
$address_maps = unserialize( $this->config('address_fields', $customer->getStoreId()) );
|
360 |
-
|
361 |
-
// Process address
|
362 |
-
if ($address_maps)
|
363 |
-
{
|
364 |
-
$address = $customer->getBillingAddress();
|
365 |
-
if ($address)
|
366 |
-
$this->processMap($merge_vars, $address_maps, $address);
|
367 |
-
}
|
368 |
-
|
369 |
-
return $merge_vars;
|
370 |
-
}
|
371 |
-
|
372 |
-
private function getTrackingData($order)
|
373 |
-
{
|
374 |
-
$shipmentCollection = Mage::getResourceModel('sales/order_shipment_collection')
|
375 |
-
->setOrderFilter($order)
|
376 |
-
->load();
|
377 |
-
foreach($shipmentCollection as $_shipment)
|
378 |
-
{
|
379 |
-
foreach($_shipment->getAllTracks() as $tracknum)
|
380 |
-
{
|
381 |
-
return $tracknum->getData();
|
382 |
-
}
|
383 |
-
}
|
384 |
-
|
385 |
-
return null;
|
386 |
-
}
|
387 |
|
388 |
-
private function getShippingData($order)
|
389 |
-
{
|
390 |
-
$data = array();
|
391 |
-
|
392 |
-
$data['shipping_code'] = $order->getData('shipping_method');
|
393 |
-
$data['shipping_description'] = $order->getData('shipping_description');
|
394 |
-
|
395 |
-
$track_data = $this->getTrackingData($order);
|
396 |
-
|
397 |
-
if ($track_data != null)
|
398 |
-
{
|
399 |
-
$data['carrier_code'] = $track_data['carrier_code'];
|
400 |
-
$data['title'] = $track_data['title'];
|
401 |
-
$data['number'] = $track_data['number'];
|
402 |
-
}
|
403 |
-
|
404 |
-
$shipping_data = new Varien_Object();
|
405 |
-
|
406 |
-
$shipping_data->setData($data);
|
407 |
-
|
408 |
-
return $shipping_data;
|
409 |
-
}
|
410 |
-
|
411 |
-
public function getOrderMergeVars(&$merge_vars, $order)
|
412 |
-
{
|
413 |
-
$this->log('getOrderMergeVars');
|
414 |
-
$maps = unserialize( $this->config('shipping_fields', $order->getStoreId()) );
|
415 |
-
|
416 |
-
if ($maps)
|
417 |
-
{
|
418 |
-
$this->log($maps, "Maps");
|
419 |
-
$shipping_data = $this->getShippingData($order);
|
420 |
-
|
421 |
-
$this->log($shipping_data,'Shipping Data');
|
422 |
-
|
423 |
-
$this->processMap($merge_vars, $maps, $shipping_data);
|
424 |
-
}
|
425 |
-
|
426 |
-
return $merge_vars;
|
427 |
-
}
|
428 |
-
|
429 |
-
public function getTrackingMergeVars($track, $order)
|
430 |
-
{
|
431 |
-
$this->log('getTrackingMergeVars Start');
|
432 |
-
|
433 |
-
$merge_vars = array();
|
434 |
-
$maps = unserialize( $this->config('shipping_fields', $order->getStoreId()) );
|
435 |
-
|
436 |
-
if (!$maps)
|
437 |
-
return null;
|
438 |
-
|
439 |
-
$this->log($maps, "Maps");
|
440 |
-
|
441 |
-
$this->log($track->getData(), "Tracking Data");
|
442 |
-
|
443 |
-
$this->processMap($merge_vars, $maps, $track);
|
444 |
-
|
445 |
-
return $merge_vars;
|
446 |
-
}
|
447 |
-
|
448 |
-
private function processMap(&$merge_vars,$maps, $data)
|
449 |
-
{
|
450 |
-
$request = Mage::app()->getRequest();
|
451 |
-
|
452 |
-
foreach($maps as $map)
|
453 |
-
{
|
454 |
-
// Make sure we have values for both
|
455 |
-
if (!isset($map['magento']) || !isset($map['emaildirect']))
|
456 |
-
continue;
|
457 |
-
|
458 |
-
$custom_field = $map['magento'];
|
459 |
-
$emaildirect_field = $map['emaildirect'];
|
460 |
-
|
461 |
-
if ($emaildirect_field && $custom_field)
|
462 |
-
{
|
463 |
-
switch ($custom_field)
|
464 |
-
{
|
465 |
-
case 'state_code':
|
466 |
-
{
|
467 |
-
$region_id = $data->getData('region_id');
|
468 |
-
|
469 |
-
$region = Mage::getModel('directory/region')->load($region_id);
|
470 |
-
|
471 |
-
if (!$region)
|
472 |
-
continue;
|
473 |
-
|
474 |
-
$state_code = $region->getCode();
|
475 |
-
|
476 |
-
if ($state_code != "")
|
477 |
-
$merge_vars[$emaildirect_field] = $state_code;
|
478 |
-
} break;
|
479 |
-
case 'date_of_purchase':
|
480 |
-
{
|
481 |
-
$last_order = Mage::getResourceModel('sales/order_collection')
|
482 |
-
->addFieldToFilter('customer_id', $data->getId())
|
483 |
-
->addFieldToFilter('state', array('in' => Mage::getSingleton('sales/order_config')->getVisibleOnFrontStates()))
|
484 |
-
->setOrder('created_at', 'desc')
|
485 |
-
->getFirstItem();
|
486 |
-
|
487 |
-
if ( $last_order->getId() )
|
488 |
-
{
|
489 |
-
$merge_vars[$emaildirect_field] = Mage::helper('core')->formatDate($last_order->getCreatedAt());
|
490 |
-
}
|
491 |
-
} break;
|
492 |
-
default:
|
493 |
-
{
|
494 |
-
if (($value = (string)$data->getData(strtolower($custom_field)))
|
495 |
-
OR ($value = (string)$request->getPost(strtolower($custom_field))))
|
496 |
-
{
|
497 |
-
$merge_vars[$emaildirect_field] = $value;
|
498 |
-
}
|
499 |
-
} break;
|
500 |
-
}
|
501 |
-
}
|
502 |
-
}
|
503 |
-
}
|
504 |
-
|
505 |
public function isSignupTest()
|
506 |
{
|
507 |
return Mage::app()->getRequest()->getParam('signup_test') == "true";
|
@@ -540,37 +489,43 @@ class EmailDirect_Integration_Helper_Data extends Mage_Core_Helper_Abstract
|
|
540 |
return false;
|
541 |
}
|
542 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
543 |
public function canShowSignup()
|
544 |
{
|
545 |
if ($this->isSignupTest())
|
546 |
return true;
|
547 |
|
548 |
-
if (!$this->
|
549 |
return false;
|
550 |
|
551 |
-
|
552 |
-
|
553 |
-
|
554 |
-
|
555 |
-
|
556 |
-
|
557 |
-
if ($last_closed == "")
|
558 |
-
return true;
|
559 |
-
|
560 |
-
switch ($recurrence)
|
561 |
-
{
|
562 |
-
case "once": return false;
|
563 |
-
default:
|
564 |
-
$last_closed = strtotime("+{$recurrence}",$last_closed); break;
|
565 |
-
}
|
566 |
-
|
567 |
-
if ($last_closed > time())
|
568 |
-
return false;
|
569 |
-
|
570 |
return true;
|
|
|
|
|
|
|
|
|
|
|
|
|
571 |
}
|
572 |
|
573 |
-
|
|
|
|
|
|
|
574 |
}
|
575 |
|
576 |
public function canCheckoutSubscribe()
|
@@ -674,36 +629,55 @@ class EmailDirect_Integration_Helper_Data extends Mage_Core_Helper_Abstract
|
|
674 |
|
675 |
return $abandoned_status;
|
676 |
}
|
677 |
-
|
678 |
-
|
679 |
{
|
680 |
$last_run = $this->config($config, $store);
|
681 |
|
682 |
-
$
|
683 |
|
684 |
if ($last_run != null)
|
685 |
{
|
|
|
|
|
686 |
$minutes = round(abs(time() - strtotime($last_run)) / 60,0);
|
687 |
-
|
688 |
-
$
|
689 |
-
|
690 |
-
$class = 'ab_ok';
|
691 |
|
692 |
if ($minutes > 60)
|
693 |
-
$class = 'ab_ng';
|
694 |
-
|
695 |
-
if ($minutes == 1)
|
696 |
-
$minutes = " ({$minutes} minute ago)";
|
697 |
else
|
698 |
-
$
|
|
|
|
|
|
|
699 |
}
|
700 |
else
|
701 |
{
|
702 |
-
$last_run =
|
703 |
-
$minutes =
|
|
|
|
|
|
|
704 |
}
|
705 |
|
706 |
-
return
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
707 |
}
|
708 |
|
709 |
public function getAbandonedLastRunHtml($store = null)
|
@@ -715,12 +689,10 @@ class EmailDirect_Integration_Helper_Data extends Mage_Core_Helper_Abstract
|
|
715 |
{
|
716 |
return $this->getLastRunHtml(0, 'cron_last_run');
|
717 |
}
|
718 |
-
|
719 |
-
public function
|
720 |
{
|
721 |
$request = Mage::app()->getRequest();
|
722 |
-
|
723 |
-
$params = array();
|
724 |
$url_params = array('website','store');
|
725 |
|
726 |
foreach ($url_params as $up)
|
@@ -729,6 +701,13 @@ class EmailDirect_Integration_Helper_Data extends Mage_Core_Helper_Abstract
|
|
729 |
$params[$up] = $request->getParam($up);
|
730 |
}
|
731 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
732 |
return Mage::helper("adminhtml")->getUrl($url, $params);
|
733 |
}
|
734 |
|
@@ -807,8 +786,8 @@ class EmailDirect_Integration_Helper_Data extends Mage_Core_Helper_Abstract
|
|
807 |
if ($base != "")
|
808 |
return $base;
|
809 |
|
810 |
-
if (!Mage::helper('customer')->isLoggedIn())
|
811 |
-
return "Customer not logged in";
|
812 |
|
813 |
return "Last Login is disabled.";
|
814 |
}
|
@@ -849,203 +828,6 @@ class EmailDirect_Integration_Helper_Data extends Mage_Core_Helper_Abstract
|
|
849 |
return "Sending Abandoned Carts is Disabled";
|
850 |
}
|
851 |
|
852 |
-
// TROUBLESHOOTING
|
853 |
-
|
854 |
-
private function getReportTable($heading, $table, $headings = true)
|
855 |
-
{
|
856 |
-
$output = "<h1>{$heading}</h1>";
|
857 |
-
$output .= "<table cellspacing='0' border='1'>";
|
858 |
-
|
859 |
-
if ($headings)
|
860 |
-
$output .= "<thead>
|
861 |
-
<tr class='headings'>
|
862 |
-
<th>Setting</th>
|
863 |
-
<th>Value</th>
|
864 |
-
</tr>
|
865 |
-
</thead>";
|
866 |
-
|
867 |
-
foreach ($table as $key => $value)
|
868 |
-
{
|
869 |
-
$output .= "<tr class='border'>
|
870 |
-
<td>{$key}</td>
|
871 |
-
<td>{$value}</td>
|
872 |
-
</tr>";
|
873 |
-
}
|
874 |
-
$output .= "</table>";
|
875 |
-
|
876 |
-
return $output;
|
877 |
-
}
|
878 |
-
|
879 |
-
public function getReport($customer = null)
|
880 |
-
{
|
881 |
-
$environment = $this->getEnvironmentInfo();
|
882 |
-
$store_configuration = $this->getConfigurationInfo();
|
883 |
-
|
884 |
-
$output = "<html><head></head><body>";
|
885 |
-
|
886 |
-
if ($customer != null)
|
887 |
-
$output .= $this->getReportTable("Customer Information", $customer, false);
|
888 |
-
|
889 |
-
$output .= $this->getReportTable("General Configuration", $environment);
|
890 |
-
|
891 |
-
foreach ($store_configuration as $code => $configuration)
|
892 |
-
{
|
893 |
-
$output .= $this->getReportTable("Module Configuration for store: {$code}", $configuration);
|
894 |
-
}
|
895 |
-
|
896 |
-
$output .= "<h1>Log File</h1>";
|
897 |
-
$output .= "<pre>" . $this->getLogFileContents() . "</pre>";
|
898 |
-
|
899 |
-
$output .= "</body></html>";
|
900 |
-
|
901 |
-
return $output;
|
902 |
-
}
|
903 |
-
|
904 |
-
private function getArrayData($data)
|
905 |
-
{
|
906 |
-
$output = "<table cellspacing='0' class='data ed-config-subtable'>
|
907 |
-
<thead>
|
908 |
-
<tr class='headings'>
|
909 |
-
<th>Magento</th>
|
910 |
-
<th>EmailDirect</th>
|
911 |
-
</tr>
|
912 |
-
</thead>";
|
913 |
-
|
914 |
-
foreach ($data as $row)
|
915 |
-
{
|
916 |
-
$output .= "<tbody><tr class='border'><td>{$row['magento']}</td><td>{$row['emaildirect']}</td></tr></tbody>";
|
917 |
-
}
|
918 |
-
|
919 |
-
$output .= "</table>";
|
920 |
-
|
921 |
-
return $output;
|
922 |
-
}
|
923 |
-
|
924 |
-
public function getEnvironmentInfo()
|
925 |
-
{
|
926 |
-
$data = array(
|
927 |
-
'Magento Version' => Mage::getVersion(),
|
928 |
-
'EmailDirect Version' => (string) Mage::getConfig()->getNode('modules/EmailDirect_Integration/version'),
|
929 |
-
'Website URL' => Mage::getBaseUrl(),
|
930 |
-
'PHP Version' => phpversion(),
|
931 |
-
'Server Software' => $_SERVER['SERVER_SOFTWARE']
|
932 |
-
);
|
933 |
-
|
934 |
-
if (method_exists("Mage","getEdition"))
|
935 |
-
$data['Magento Edition'] = Mage::getEdition();
|
936 |
-
return $data;
|
937 |
-
}
|
938 |
-
|
939 |
-
public function getConfigurationInfo()
|
940 |
-
{
|
941 |
-
$store_data = array();
|
942 |
-
|
943 |
-
$stores = Mage::app()->getStores();
|
944 |
-
|
945 |
-
foreach ($stores as $store)
|
946 |
-
{
|
947 |
-
$e_config = Mage::getStoreConfig("emaildirect/general", $store);
|
948 |
-
|
949 |
-
$data = array( );
|
950 |
-
|
951 |
-
$data['store id'] = $store->getId();
|
952 |
-
|
953 |
-
foreach ($e_config as $key => $value)
|
954 |
-
{
|
955 |
-
if (is_array($value))
|
956 |
-
{
|
957 |
-
// Skip
|
958 |
-
}
|
959 |
-
else
|
960 |
-
{
|
961 |
-
// Check if the data is serialized
|
962 |
-
$test_data = @unserialize($value);
|
963 |
-
if ($test_data !== false)
|
964 |
-
$data[$key] = $this->getArrayData($test_data);
|
965 |
-
else
|
966 |
-
$data[$key] = $value;;
|
967 |
-
}
|
968 |
-
}
|
969 |
-
|
970 |
-
$store_data[$store->getName()] = $data;
|
971 |
-
}
|
972 |
-
|
973 |
-
return $store_data;
|
974 |
-
}
|
975 |
-
|
976 |
-
public function getLogFileContents()
|
977 |
-
{
|
978 |
-
$log_file = $this->getLogFilePath();
|
979 |
-
|
980 |
-
if (!file_exists($log_file))
|
981 |
-
return "";
|
982 |
-
|
983 |
-
$max_size = $this->getMaxLogFileSize();
|
984 |
-
$log_file_size = filesize($log_file);
|
985 |
-
$offset = 0;
|
986 |
-
|
987 |
-
if ($log_file_size > $max_size)
|
988 |
-
$offset = $log_file_size - $max_size;
|
989 |
-
|
990 |
-
return htmlentities(file_get_contents($log_file,false,null,$offset));
|
991 |
-
}
|
992 |
-
|
993 |
-
public function getLogFilePath()
|
994 |
-
{
|
995 |
-
return Mage::getBaseDir('log') . DS. self::LOG_FILE_NAME . self::LOG_FILE_EXT;
|
996 |
-
}
|
997 |
-
|
998 |
-
public function getLogFileName()
|
999 |
-
{
|
1000 |
-
return self::LOG_FILE_NAME . self::LOG_FILE_EXT;
|
1001 |
-
}
|
1002 |
-
|
1003 |
-
public function getLogFileSize()
|
1004 |
-
{
|
1005 |
-
$log_file = $this->getLogFilePath();
|
1006 |
-
|
1007 |
-
if (file_exists($log_file))
|
1008 |
-
return filesize($log_file);
|
1009 |
-
|
1010 |
-
return 0;
|
1011 |
-
}
|
1012 |
-
|
1013 |
-
public function getLogFilelastUpdate()
|
1014 |
-
{
|
1015 |
-
$log_file = $this->getLogFilePath();
|
1016 |
-
|
1017 |
-
if (file_exists($log_file))
|
1018 |
-
return filemtime($log_file);
|
1019 |
-
|
1020 |
-
return "";
|
1021 |
-
}
|
1022 |
-
|
1023 |
-
public function getMaxLogFileSize()
|
1024 |
-
{
|
1025 |
-
return $this->troubleConfig('max_file_size');
|
1026 |
-
}
|
1027 |
-
|
1028 |
-
public function eraseTroubleshooting($store = null)
|
1029 |
-
{
|
1030 |
-
$this->deleteConfig("start_date",$store,"troubleshooting");
|
1031 |
-
$this->deleteConfig("enabled",$store,"troubleshooting");
|
1032 |
-
}
|
1033 |
-
|
1034 |
-
public function turnOnTroubleshooting($store = null)
|
1035 |
-
{
|
1036 |
-
$date = date(Mage::getModel('core/date')->gmtTimestamp());
|
1037 |
-
$date = date("Y-m-d H:i:s", $date);
|
1038 |
-
|
1039 |
-
$this->updateConfig("start_date",$date,$store,"troubleshooting");
|
1040 |
-
$this->updateConfig("enabled","1",$store,"troubleshooting");
|
1041 |
-
}
|
1042 |
-
|
1043 |
-
public function turnOffTroubleshooting($store = null, $quiet = true)
|
1044 |
-
{
|
1045 |
-
$this->updateConfig("start_date","",$store,"troubleshooting");
|
1046 |
-
$this->updateConfig("enabled","0",$store,"troubleshooting");
|
1047 |
-
}
|
1048 |
-
|
1049 |
// Newsletter
|
1050 |
|
1051 |
private function getSubscriberData($data, $email)
|
@@ -1055,8 +837,6 @@ class EmailDirect_Integration_Helper_Data extends Mage_Core_Helper_Abstract
|
|
1055 |
$list_count = 0;
|
1056 |
$publication_subscribed = false;
|
1057 |
|
1058 |
-
//CHECK THAT THERE ARE PUBLICATIONS?
|
1059 |
-
|
1060 |
if (!isset($properties->Publications->Publication))
|
1061 |
return $data;
|
1062 |
|
@@ -1138,8 +918,8 @@ class EmailDirect_Integration_Helper_Data extends Mage_Core_Helper_Abstract
|
|
1138 |
|
1139 |
public function getSubscriptions($email)
|
1140 |
{
|
1141 |
-
$this->setLogArea(
|
1142 |
-
$this->setLogLevel(
|
1143 |
|
1144 |
$data = array(
|
1145 |
'publication' => array('id' => -1,'name' => 'Unknown', 'subscribed' => false, 'disabled' => true),
|
@@ -1155,7 +935,7 @@ class EmailDirect_Integration_Helper_Data extends Mage_Core_Helper_Abstract
|
|
1155 |
|
1156 |
$data = $this->getSubscriberData($data, $email);
|
1157 |
|
1158 |
-
$this->resetLogLevel();
|
1159 |
|
1160 |
return $data;
|
1161 |
}
|
@@ -1163,106 +943,8 @@ class EmailDirect_Integration_Helper_Data extends Mage_Core_Helper_Abstract
|
|
1163 |
{
|
1164 |
Mage::logException($e);
|
1165 |
$this->logException($e);
|
1166 |
-
$this->resetLogLevel();
|
1167 |
return $data;
|
1168 |
}
|
1169 |
}
|
1170 |
-
|
1171 |
-
public function formatXml($xml_string)
|
1172 |
-
{
|
1173 |
-
try
|
1174 |
-
{
|
1175 |
-
$dom = new DOMDocument('1.0');
|
1176 |
-
$dom->preserveWhiteSpace = false;
|
1177 |
-
$dom->formatOutput = true;
|
1178 |
-
$dom->loadXML($xml_string);
|
1179 |
-
return $dom->saveXML();
|
1180 |
-
}
|
1181 |
-
catch (Exception $e)
|
1182 |
-
{
|
1183 |
-
$this->logException($e);
|
1184 |
-
return $xml_string;
|
1185 |
-
}
|
1186 |
-
}
|
1187 |
-
|
1188 |
-
// LOGGING
|
1189 |
-
|
1190 |
-
public function isLoggingEnabled($store = null)
|
1191 |
-
{
|
1192 |
-
if (!$this->troubleConfig('enabled', $store))
|
1193 |
-
return false;
|
1194 |
-
|
1195 |
-
$date = $this->troubleConfig('start_date');
|
1196 |
-
|
1197 |
-
if ($date == "")
|
1198 |
-
return false;
|
1199 |
-
|
1200 |
-
$minutes = round(abs(time() - strtotime($date)) / 60,0);
|
1201 |
-
|
1202 |
-
$duration = (int)$this->troubleConfig('duration', $store);
|
1203 |
-
|
1204 |
-
if ($minutes > $duration)
|
1205 |
-
{
|
1206 |
-
$this->turnOffTroubleshooting($store);
|
1207 |
-
Mage::app()->reinitStores();
|
1208 |
-
return false;
|
1209 |
-
}
|
1210 |
-
|
1211 |
-
return true;
|
1212 |
-
}
|
1213 |
-
|
1214 |
-
public function log($data, $prefix = "", $area = "")
|
1215 |
-
{
|
1216 |
-
$store = $this->getCurrentStore();
|
1217 |
-
|
1218 |
-
if ($this->isLoggingEnabled($store))
|
1219 |
-
{
|
1220 |
-
if ($area == "")
|
1221 |
-
$area = $this->_log_area;
|
1222 |
-
|
1223 |
-
if ($this->_log_level > $this->_log_level_active)
|
1224 |
-
return;
|
1225 |
-
|
1226 |
-
if (is_array($data) || is_object($data))
|
1227 |
-
{
|
1228 |
-
if (is_object($data) && get_class($data) == "SimpleXMLElement")
|
1229 |
-
$data = $this->formatXml($data->asXml());
|
1230 |
-
else
|
1231 |
-
$data = print_r($data, true);
|
1232 |
-
}
|
1233 |
-
|
1234 |
-
if ($prefix != "")
|
1235 |
-
$prefix .= ": ";
|
1236 |
-
|
1237 |
-
if ($area != "")
|
1238 |
-
$data = "[{$area}] [{$store}] {$prefix}{$data}";
|
1239 |
-
|
1240 |
-
Mage::log($data,null,self::LOG_FILE_NAME . self::LOG_FILE_EXT, true);
|
1241 |
-
}
|
1242 |
-
}
|
1243 |
-
|
1244 |
-
public function logReason($data, $area = "")
|
1245 |
-
{
|
1246 |
-
$this->log($data,self::DISABLED_REASON_PREFIX, $area);
|
1247 |
-
}
|
1248 |
-
|
1249 |
-
public function logException($e, $area = "")
|
1250 |
-
{
|
1251 |
-
$this->log($e->__toString(),"Exception", $area);
|
1252 |
-
}
|
1253 |
-
|
1254 |
-
public function setLogArea($area)
|
1255 |
-
{
|
1256 |
-
$this->_log_area = $area;
|
1257 |
-
}
|
1258 |
-
|
1259 |
-
public function setLogLevel($level)
|
1260 |
-
{
|
1261 |
-
$this->_log_level = $level;
|
1262 |
-
}
|
1263 |
-
|
1264 |
-
public function resetLogLevel()
|
1265 |
-
{
|
1266 |
-
$this->_log_level = self::LOG_LEVEL_NORMAL;
|
1267 |
-
}
|
1268 |
-
}
|
1 |
<?php
|
2 |
|
3 |
class EmailDirect_Integration_Helper_Data extends Mage_Core_Helper_Abstract
|
4 |
+
{
|
5 |
+
const DATE_FORMAT = "Y-m-d H:i:s";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6 |
|
7 |
const DISABLED_REASON_PREFIX = "Skipping";
|
8 |
+
|
9 |
+
protected $_logger = null;
|
10 |
+
|
11 |
+
public function __construct()
|
12 |
+
{
|
13 |
+
$this->_logger = Mage::helper('emaildirect/troubleshooting');
|
14 |
+
}
|
15 |
+
|
16 |
+
protected function logAndDebug($data)
|
17 |
+
{
|
18 |
+
$this->_logger->logAndDebug($data);
|
19 |
+
}
|
20 |
+
|
21 |
+
protected function debug($data)
|
22 |
+
{
|
23 |
+
$this->_logger->debug($data);
|
24 |
+
}
|
25 |
+
|
26 |
+
protected function debugHeader($data, $level = 2)
|
27 |
+
{
|
28 |
+
$this->_logger->debugHeader($data, $level);
|
29 |
+
}
|
30 |
+
|
31 |
+
public function getMergeVars($customer)
|
32 |
+
{
|
33 |
+
$merge_vars = array();
|
34 |
+
$maps = unserialize( $this->config('map_fields', $customer->getStoreId()) );
|
35 |
+
|
36 |
+
if ($maps)
|
37 |
+
{
|
38 |
+
$this->debug("Customer Field Mapping");
|
39 |
+
$this->processMap($merge_vars, $maps, $customer);
|
40 |
+
}
|
41 |
+
|
42 |
+
$address_maps = unserialize( $this->config('address_fields', $customer->getStoreId()) );
|
43 |
+
|
44 |
+
// Process address
|
45 |
+
if ($address_maps)
|
46 |
+
{
|
47 |
+
$address = $customer->getBillingAddress();
|
48 |
+
if ($address)
|
49 |
+
{
|
50 |
+
$this->debug("Address Field Mapping");
|
51 |
+
$this->processMap($merge_vars, $address_maps, $address);
|
52 |
+
}
|
53 |
+
}
|
54 |
+
|
55 |
+
return $merge_vars;
|
56 |
+
}
|
57 |
+
|
58 |
+
protected function processMap(&$merge_vars,$maps, $data)
|
59 |
+
{
|
60 |
+
$request = Mage::app()->getRequest();
|
61 |
+
|
62 |
+
$this->debug("Mappings");
|
63 |
+
$this->debug($maps);
|
64 |
+
|
65 |
+
$this->debug("Map Data");
|
66 |
+
$this->debug($data);
|
67 |
+
|
68 |
+
foreach ($maps as $map)
|
69 |
+
{
|
70 |
+
// Make sure we have values for both
|
71 |
+
if (!isset($map['magento']) || !isset($map['emaildirect']))
|
72 |
+
continue;
|
73 |
+
|
74 |
+
$custom_field = $map['magento'];
|
75 |
+
$emaildirect_field = $map['emaildirect'];
|
76 |
|
77 |
+
if ($emaildirect_field && $custom_field)
|
78 |
+
{
|
79 |
+
switch ($custom_field)
|
80 |
+
{
|
81 |
+
case 'state_code':
|
82 |
+
{
|
83 |
+
$region_id = $data->getData('region_id');
|
84 |
+
|
85 |
+
if (!$region_id)
|
86 |
+
continue;
|
87 |
+
|
88 |
+
$region = Mage::getModel('directory/region')->load($region_id);
|
89 |
+
|
90 |
+
if (!$region)
|
91 |
+
continue;
|
92 |
+
|
93 |
+
$state_code = $region->getCode();
|
94 |
+
|
95 |
+
if ($state_code != "")
|
96 |
+
$merge_vars[$emaildirect_field] = $state_code;
|
97 |
+
} break;
|
98 |
+
default:
|
99 |
+
{
|
100 |
+
if (($value = (string)$data->getData(strtolower($custom_field))) || ($value = (string)$request->getPost(strtolower($custom_field))))
|
101 |
+
$merge_vars[$emaildirect_field] = $value;
|
102 |
+
} break;
|
103 |
+
}
|
104 |
+
}
|
105 |
+
}
|
106 |
+
}
|
107 |
+
|
108 |
+
protected function getProduct($item)
|
109 |
+
{
|
110 |
+
$product_id = $item->getProductId();
|
111 |
+
|
112 |
+
if (!$product_id)
|
113 |
+
return null;
|
114 |
+
|
115 |
+
$product = Mage::getModel('catalog/product')->load($product_id);
|
116 |
+
|
117 |
+
if ($product == null || !$product->getId())
|
118 |
+
return null;
|
119 |
+
|
120 |
+
return $product;
|
121 |
+
}
|
122 |
|
123 |
// Used to restore configurable products to the cart
|
124 |
public function getConfigurableOptions($product, $simple_product_id)
|
159 |
}
|
160 |
}
|
161 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
162 |
public function getAdminStore()
|
163 |
{
|
164 |
$code = Mage::app()->getRequest()->getParam('store');
|
266 |
}
|
267 |
}
|
268 |
|
269 |
+
public function getDuration($timeline, $zero = false)
|
270 |
{
|
|
|
|
|
|
|
|
|
|
|
271 |
$periods = array('day' => 86400, 'hour' => 3600, 'minute' => 60);
|
272 |
|
273 |
$ret = "";
|
275 |
foreach($periods as $name => $seconds)
|
276 |
{
|
277 |
$num = floor($timeline / $seconds);
|
278 |
+
|
279 |
+
if ($num > 0 || ($num == 0 && $zero == true))
|
280 |
+
{
|
281 |
$timeline -= ($num * $seconds);
|
282 |
$ret .= $num.' '.$name.(($num > 1 || $num == 0) ? 's' : '').' ';
|
283 |
+
}
|
284 |
}
|
285 |
|
286 |
return trim($ret);
|
287 |
}
|
288 |
+
|
289 |
+
public function timeElapsed2string($time)
|
290 |
+
{
|
291 |
+
if ($time == "")
|
292 |
+
return "";
|
293 |
+
|
294 |
+
if (is_string($time))
|
295 |
+
$time = strtotime($time);
|
296 |
+
|
297 |
+
$timeline = time() - $time;
|
298 |
+
|
299 |
+
return $this->getDuration($timeline);
|
300 |
+
}
|
301 |
|
302 |
public function getExportFileName($name,$full = true)
|
303 |
{
|
381 |
if (is_null($store))
|
382 |
$store = $this->getCurrentStore();
|
383 |
|
384 |
+
//echo "emaildirect/{$section}/{$value}";
|
385 |
+
|
386 |
$realvalue = Mage::getStoreConfig("emaildirect/{$section}/{$value}", $store);
|
387 |
|
388 |
return $realvalue;
|
450 |
{
|
451 |
return $this->config('publication', $storeId);
|
452 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
453 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
454 |
public function isSignupTest()
|
455 |
{
|
456 |
return Mage::app()->getRequest()->getParam('signup_test') == "true";
|
489 |
return false;
|
490 |
}
|
491 |
|
492 |
+
public function isSignupEnabled()
|
493 |
+
{
|
494 |
+
if (!$this->canEdirect())
|
495 |
+
return false;
|
496 |
+
|
497 |
+
if ((bool)($this->config('signup_enabled') == 0) || (bool)($this->config('signup_activated') == 0))
|
498 |
+
return false;
|
499 |
+
|
500 |
+
return true;
|
501 |
+
}
|
502 |
+
|
503 |
public function canShowSignup()
|
504 |
{
|
505 |
if ($this->isSignupTest())
|
506 |
return true;
|
507 |
|
508 |
+
if (!$this->isSignupEnabled())
|
509 |
return false;
|
510 |
|
511 |
+
$last_closed = Mage::getModel('core/cookie')->get('ed_signup');
|
512 |
+
|
513 |
+
$recurrence = $this->config('signup_recurrence');
|
514 |
+
|
515 |
+
if ($last_closed == "")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
516 |
return true;
|
517 |
+
|
518 |
+
switch ($recurrence)
|
519 |
+
{
|
520 |
+
case "once": return false;
|
521 |
+
default:
|
522 |
+
$last_closed = strtotime("+{$recurrence}",$last_closed); break;
|
523 |
}
|
524 |
|
525 |
+
if ($last_closed > time())
|
526 |
+
return false;
|
527 |
+
|
528 |
+
return true;
|
529 |
}
|
530 |
|
531 |
public function canCheckoutSubscribe()
|
629 |
|
630 |
return $abandoned_status;
|
631 |
}
|
632 |
+
|
633 |
+
public function getCronLastRun($store = null, $config = 'abandoned_last_run')
|
634 |
{
|
635 |
$last_run = $this->config($config, $store);
|
636 |
|
637 |
+
$data = array();
|
638 |
|
639 |
if ($last_run != null)
|
640 |
{
|
641 |
+
$data['last_run'] = $last_run;
|
642 |
+
|
643 |
$minutes = round(abs(time() - strtotime($last_run)) / 60,0);
|
644 |
+
|
645 |
+
$data['minutes'] = $minutes;
|
|
|
|
|
646 |
|
647 |
if ($minutes > 60)
|
648 |
+
$data['class'] = 'ab_ng';
|
|
|
|
|
|
|
649 |
else
|
650 |
+
$data['class'] = 'ab_ok';
|
651 |
+
|
652 |
+
$data['last_run_display'] = Mage::helper('core')->formatTime($last_run, 'long', true);
|
653 |
+
$data['time_elapsed'] = $this->timeElapsed2string($last_run);
|
654 |
}
|
655 |
else
|
656 |
{
|
657 |
+
$data['last_run'] = 'NEVER';
|
658 |
+
$data['minutes'] = -1;
|
659 |
+
$data['last_run_display'] = 'NEVER';
|
660 |
+
$data['time_elapsed'] = "";
|
661 |
+
$data['class'] = 'ab_ng';
|
662 |
}
|
663 |
|
664 |
+
return $data;
|
665 |
+
}
|
666 |
+
|
667 |
+
private function getLastRunHtml($store = null, $config = 'abandoned_last_run')
|
668 |
+
{
|
669 |
+
$data = $this->getCronLastRun($store,$config);
|
670 |
+
$warning_img = "";
|
671 |
+
|
672 |
+
if ($data['class'] == "ab_ng")
|
673 |
+
$warning_img = "<a href='" . $this->getAdminUrl("ed_integration/admin_troubleshooting/index") . "#abandoned_carts' target='_blank'><img src='" . Mage::getDesign()->getSkinUrl('images/warning_msg_icon.gif') . "' class='cron_warning' /></a>";
|
674 |
+
|
675 |
+
$time_elapsed = "";
|
676 |
+
|
677 |
+
if ($data['time_elapsed'] != '')
|
678 |
+
$time_elapsed = "({$data['time_elapsed']})";
|
679 |
+
|
680 |
+
return "<span class='{$data['class']}'>{$data['last_run_display']} {$time_elapsed}</span>{$warning_img}";
|
681 |
}
|
682 |
|
683 |
public function getAbandonedLastRunHtml($store = null)
|
689 |
{
|
690 |
return $this->getLastRunHtml(0, 'cron_last_run');
|
691 |
}
|
692 |
+
|
693 |
+
public function getAdminUrlParams($params = array())
|
694 |
{
|
695 |
$request = Mage::app()->getRequest();
|
|
|
|
|
696 |
$url_params = array('website','store');
|
697 |
|
698 |
foreach ($url_params as $up)
|
701 |
$params[$up] = $request->getParam($up);
|
702 |
}
|
703 |
|
704 |
+
return $params;
|
705 |
+
}
|
706 |
+
|
707 |
+
public function getAdminUrl($url, $params = array())
|
708 |
+
{
|
709 |
+
$params = $this->getAdminUrlParams($params);
|
710 |
+
|
711 |
return Mage::helper("adminhtml")->getUrl($url, $params);
|
712 |
}
|
713 |
|
786 |
if ($base != "")
|
787 |
return $base;
|
788 |
|
789 |
+
//if (!Mage::helper('customer')->isLoggedIn())
|
790 |
+
//return "Customer not logged in";
|
791 |
|
792 |
return "Last Login is disabled.";
|
793 |
}
|
828 |
return "Sending Abandoned Carts is Disabled";
|
829 |
}
|
830 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
831 |
// Newsletter
|
832 |
|
833 |
private function getSubscriberData($data, $email)
|
837 |
$list_count = 0;
|
838 |
$publication_subscribed = false;
|
839 |
|
|
|
|
|
840 |
if (!isset($properties->Publications->Publication))
|
841 |
return $data;
|
842 |
|
918 |
|
919 |
public function getSubscriptions($email)
|
920 |
{
|
921 |
+
$this->_logger->setLogArea(EmailDirect_Integration_Helper_Troubleshooting::CUSTOMER);
|
922 |
+
$this->_logger->setLogLevel(EmailDirect_Integration_Helper_Troubleshooting::LOG_LEVEL_LOW);
|
923 |
|
924 |
$data = array(
|
925 |
'publication' => array('id' => -1,'name' => 'Unknown', 'subscribed' => false, 'disabled' => true),
|
935 |
|
936 |
$data = $this->getSubscriberData($data, $email);
|
937 |
|
938 |
+
$this->_logger->resetLogLevel();
|
939 |
|
940 |
return $data;
|
941 |
}
|
943 |
{
|
944 |
Mage::logException($e);
|
945 |
$this->logException($e);
|
946 |
+
$this->_logger->resetLogLevel();
|
947 |
return $data;
|
948 |
}
|
949 |
}
|
950 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/community/EmailDirect/Integration/Helper/Diagnostic.php
ADDED
@@ -0,0 +1,59 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class EmailDirect_Integration_Helper_Diagnostic extends Mage_Core_Helper_Abstract
|
4 |
+
{
|
5 |
+
private $_quote = null;
|
6 |
+
private $_cart = null;
|
7 |
+
|
8 |
+
public function getCurrentStoreId()
|
9 |
+
{
|
10 |
+
$order = $this->getOrder();
|
11 |
+
if ($order)
|
12 |
+
return $order->getStore()->getId();
|
13 |
+
|
14 |
+
return Mage::app()->getRequest()->getParam('store_id');
|
15 |
+
}
|
16 |
+
|
17 |
+
public function getOrder()
|
18 |
+
{
|
19 |
+
return Mage::registry('current_order');
|
20 |
+
}
|
21 |
+
|
22 |
+
public function getQuote()
|
23 |
+
{
|
24 |
+
if (!$this->_quote)
|
25 |
+
{
|
26 |
+
$quote_id = Mage::app()->getRequest()->getParam('id');
|
27 |
+
$store_id = Mage::app()->getRequest()->getParam('store_id');
|
28 |
+
|
29 |
+
if (!$quote_id || !$store_id)
|
30 |
+
throw Exception("Invalid Parameters");
|
31 |
+
|
32 |
+
$store = Mage::getModel('core/store')->load($store_id);
|
33 |
+
|
34 |
+
$this->_quote = Mage::getModel('sales/quote')->setStore($store)->load($quote_id);
|
35 |
+
}
|
36 |
+
|
37 |
+
return $this->_quote;
|
38 |
+
}
|
39 |
+
|
40 |
+
public function getCartItems()
|
41 |
+
{
|
42 |
+
$quote = $this->getQuote();
|
43 |
+
return $quote->getItemsCollection(false);
|
44 |
+
}
|
45 |
+
|
46 |
+
public function getAbandonedCart($quote_id = null)
|
47 |
+
{
|
48 |
+
if (!$this->_cart)
|
49 |
+
{
|
50 |
+
if (!$quote_id)
|
51 |
+
$quote_id = Mage::app()->getRequest()->getParam('id');
|
52 |
+
|
53 |
+
$collection = Mage::getResourceModel('emaildirect/abandoned_collection')->filterByQuoteId($quote_id);
|
54 |
+
|
55 |
+
$this->_cart = $collection->getFirstItem();
|
56 |
+
}
|
57 |
+
return $this->_cart;
|
58 |
+
}
|
59 |
+
}
|
app/code/community/EmailDirect/Integration/Helper/Fields.php
CHANGED
@@ -35,36 +35,15 @@ class EmailDirect_Integration_Helper_Fields extends Mage_Core_Helper_Abstract
|
|
35 |
for ($i = 1; $i <= $count; $i++)
|
36 |
{
|
37 |
$fields[] =
|
38 |
-
|
39 |
-
'type' => 'Text',
|
40 |
-
'size' => '200');
|
41 |
|
42 |
if ($prefix != 'Related')
|
43 |
-
$fields[] =
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
$fields[] =
|
49 |
-
array('name' => "{$prefix}SKU{$i}",
|
50 |
-
'type' => 'Text',
|
51 |
-
'size' => '50');
|
52 |
-
$fields[] =
|
53 |
-
array('name' => "{$prefix}URL{$i}",
|
54 |
-
'type' => 'Text',
|
55 |
-
'size' => '200');
|
56 |
-
$fields[] =
|
57 |
-
array('name' => "{$prefix}Image{$i}",
|
58 |
-
'type' => 'Text',
|
59 |
-
'size' => '200');
|
60 |
-
$fields[] =
|
61 |
-
array('name' => "{$prefix}Description{$i}",
|
62 |
-
'type' => 'Text',
|
63 |
-
'size' => '200');
|
64 |
-
$fields[] =
|
65 |
-
array('name' => "{$prefix}Cost{$i}",
|
66 |
-
'type' => 'Text',
|
67 |
-
'size' => '20');
|
68 |
}
|
69 |
|
70 |
return $fields;
|
@@ -113,20 +92,25 @@ class EmailDirect_Integration_Helper_Fields extends Mage_Core_Helper_Abstract
|
|
113 |
return $missing;
|
114 |
}
|
115 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
116 |
public function getCustomFields($force_product = false)
|
117 |
{
|
118 |
$fields = array();
|
119 |
|
120 |
if (Mage::helper('emaildirect')->config('save_latest_order') || $force_product)
|
121 |
{
|
122 |
-
$fields[] =
|
123 |
-
|
124 |
-
|
125 |
-
$fields[] = array('name' => 'LastPurchaseDate',
|
126 |
-
'type' => 'Date');
|
127 |
-
$fields[] = array('name' => 'LastPurchaseTotal',
|
128 |
-
'type' => 'Text',
|
129 |
-
'size' => '20');
|
130 |
|
131 |
$fields = $this->getMultiFields($fields);
|
132 |
|
@@ -135,20 +119,14 @@ class EmailDirect_Integration_Helper_Fields extends Mage_Core_Helper_Abstract
|
|
135 |
|
136 |
if (Mage::helper('emaildirect')->config('wishlist_enabled'))
|
137 |
{
|
138 |
-
$fields[] =
|
139 |
-
|
140 |
-
$fields[] = array('name' => 'WishListUrl',
|
141 |
-
'type' => 'Text',
|
142 |
-
'size' => '200');
|
143 |
}
|
144 |
|
145 |
-
$fields[] =
|
146 |
-
|
147 |
-
$fields[] =
|
148 |
-
|
149 |
-
$fields[] = array('name' => 'AbandonedUrl',
|
150 |
-
'type' => 'Text',
|
151 |
-
'size' => '1000');
|
152 |
|
153 |
$fields = $this->getMultiFields($fields,"AB");
|
154 |
|
35 |
for ($i = 1; $i <= $count; $i++)
|
36 |
{
|
37 |
$fields[] =
|
38 |
+
$this->addField("{$prefix}ProductName{$i}", 'Text', '200');
|
|
|
|
|
39 |
|
40 |
if ($prefix != 'Related')
|
41 |
+
$fields[] = $this->addField("{$prefix}ParentName{$i}", 'Text', '200');
|
42 |
+
$fields[] = $this->addField("{$prefix}SKU{$i}", 'Text', '50');
|
43 |
+
$fields[] = $this->addField("{$prefix}URL{$i}", 'Text', '200');
|
44 |
+
$fields[] = $this->addField("{$prefix}Image{$i}", 'Text', '200');
|
45 |
+
$fields[] = $this->addField("{$prefix}Description{$i}", 'Text', '200');
|
46 |
+
$fields[] = $this->addField("{$prefix}Cost{$i}", 'Text', '20');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
47 |
}
|
48 |
|
49 |
return $fields;
|
92 |
return $missing;
|
93 |
}
|
94 |
|
95 |
+
private function addField($name, $type, $size = null)
|
96 |
+
{
|
97 |
+
$new_field = array('name' => $name, 'type' => $type);
|
98 |
+
|
99 |
+
if ($size != null)
|
100 |
+
$new_field['size'] = $size;
|
101 |
+
|
102 |
+
return $new_field;
|
103 |
+
}
|
104 |
+
|
105 |
public function getCustomFields($force_product = false)
|
106 |
{
|
107 |
$fields = array();
|
108 |
|
109 |
if (Mage::helper('emaildirect')->config('save_latest_order') || $force_product)
|
110 |
{
|
111 |
+
$fields[] = $this->addField('LastOrderNumber', 'Text', '30');
|
112 |
+
$fields[] = $this->addField('LastPurchaseDate', 'Date');
|
113 |
+
$fields[] = $this->addField('LastPurchaseTotal', 'Text', '20');
|
|
|
|
|
|
|
|
|
|
|
114 |
|
115 |
$fields = $this->getMultiFields($fields);
|
116 |
|
119 |
|
120 |
if (Mage::helper('emaildirect')->config('wishlist_enabled'))
|
121 |
{
|
122 |
+
$fields[] = $this->addField('WishListDate', 'Date');
|
123 |
+
$fields[] = $this->addField('WishListUrl', 'Text', '200');
|
|
|
|
|
|
|
124 |
}
|
125 |
|
126 |
+
$fields[] = $this->addField('LastLogin', 'Date');
|
127 |
+
|
128 |
+
$fields[] = $this->addField('AbandonedDate', 'Date');
|
129 |
+
$fields[] = $this->addField('AbandonedUrl', 'Text', '1000');
|
|
|
|
|
|
|
130 |
|
131 |
$fields = $this->getMultiFields($fields,"AB");
|
132 |
|
app/code/community/EmailDirect/Integration/Helper/Order.php
ADDED
@@ -0,0 +1,678 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class EmailDirect_Integration_Helper_Order extends EmailDirect_Integration_Helper_Data
|
4 |
+
{
|
5 |
+
protected function getTrackingData($order)
|
6 |
+
{
|
7 |
+
$shipmentCollection = Mage::getResourceModel('sales/order_shipment_collection')
|
8 |
+
->setOrderFilter($order)
|
9 |
+
->load();
|
10 |
+
foreach($shipmentCollection as $_shipment)
|
11 |
+
{
|
12 |
+
foreach($_shipment->getAllTracks() as $tracknum)
|
13 |
+
{
|
14 |
+
return $tracknum->getData();
|
15 |
+
}
|
16 |
+
}
|
17 |
+
|
18 |
+
return null;
|
19 |
+
}
|
20 |
+
|
21 |
+
public function getTrackingMergeVars($track, $order)
|
22 |
+
{
|
23 |
+
$this->_logger->log('getTrackingMergeVars Start');
|
24 |
+
|
25 |
+
$merge_vars = array();
|
26 |
+
$maps = unserialize($this->config('shipping_fields', $order->getStoreId()));
|
27 |
+
|
28 |
+
if (!$maps)
|
29 |
+
return null;
|
30 |
+
|
31 |
+
$this->_logger->log($maps, "Maps");
|
32 |
+
|
33 |
+
$this->_logger->log($track->getData(), "Tracking Data");
|
34 |
+
|
35 |
+
$this->processMap($merge_vars, $maps, $track);
|
36 |
+
|
37 |
+
return $merge_vars;
|
38 |
+
}
|
39 |
+
|
40 |
+
protected function getShippingData($order)
|
41 |
+
{
|
42 |
+
$data = array();
|
43 |
+
|
44 |
+
$data['shipping_code'] = $order->getData('shipping_method');
|
45 |
+
$data['shipping_description'] = $order->getData('shipping_description');
|
46 |
+
|
47 |
+
$track_data = $this->getTrackingData($order);
|
48 |
+
|
49 |
+
if ($track_data != null)
|
50 |
+
{
|
51 |
+
$data['carrier_code'] = $track_data['carrier_code'];
|
52 |
+
$data['title'] = $track_data['title'];
|
53 |
+
$data['number'] = $track_data['number'];
|
54 |
+
}
|
55 |
+
|
56 |
+
$shipping_data = new Varien_Object();
|
57 |
+
|
58 |
+
$shipping_data->setData($data);
|
59 |
+
|
60 |
+
return $shipping_data;
|
61 |
+
}
|
62 |
+
|
63 |
+
protected function getOrderMergeVars(&$merge_vars, $order)
|
64 |
+
{
|
65 |
+
$this->_logger->logAndDebug('getOrderMergeVars (Tracking Data)');
|
66 |
+
$maps = unserialize( $this->config('shipping_fields', $order->getStoreId()) );
|
67 |
+
|
68 |
+
if ($maps)
|
69 |
+
{
|
70 |
+
$this->_logger->log($maps, "Maps");
|
71 |
+
$shipping_data = $this->getShippingData($order);
|
72 |
+
|
73 |
+
$this->_logger->log($shipping_data,'Shipping Data');
|
74 |
+
|
75 |
+
$this->processMap($merge_vars, $maps, $shipping_data);
|
76 |
+
}
|
77 |
+
else
|
78 |
+
$this->debug('No Mappings Found');
|
79 |
+
|
80 |
+
return $merge_vars;
|
81 |
+
}
|
82 |
+
|
83 |
+
public function getOrderCustomer($order)
|
84 |
+
{
|
85 |
+
$customer = null;
|
86 |
+
|
87 |
+
if ($order->getData('customer_is_guest'))
|
88 |
+
{
|
89 |
+
$this->_logger->log("Guest Customer");
|
90 |
+
|
91 |
+
$customer = new Varien_Object;
|
92 |
+
|
93 |
+
$customer->setData('email',$order->getCustomerEmail());
|
94 |
+
$customer->setData('firstname',$order->getData('customer_firstname'));
|
95 |
+
$customer->setData('lastname',$order->getData('customer_lastname'));
|
96 |
+
$customer->setData('store_id',$order->getStoreId());
|
97 |
+
|
98 |
+
$customer->setBillingAddress($order->getBillingAddress());
|
99 |
+
}
|
100 |
+
else
|
101 |
+
{
|
102 |
+
$customer = Mage::getModel('customer/customer')->load($order->getCustomerId());
|
103 |
+
$address = Mage::getModel('customer/address')->load($customer->getDefaultBilling());
|
104 |
+
$customer->setBillingAddress($address);
|
105 |
+
}
|
106 |
+
|
107 |
+
return $customer;
|
108 |
+
}
|
109 |
+
|
110 |
+
public function processOrderItems($order, &$merge_vars)
|
111 |
+
{
|
112 |
+
$this->debugHeader("processOrderItems Start",1);
|
113 |
+
|
114 |
+
$merge_vars = $this->getOrderMergeVars($merge_vars,$order);
|
115 |
+
|
116 |
+
$this->_logger->logAndDebug("Check Save Lastest");
|
117 |
+
if ($this->config('save_latest_order'))
|
118 |
+
{
|
119 |
+
$this->_logger->logAndDebug("Adding Latest Order Information");
|
120 |
+
$merge_vars['LastOrderNumber'] = $order->getIncrementId();
|
121 |
+
$merge_vars['LastPurchaseDate'] = $order->getData('created_at');
|
122 |
+
$merge_vars['LastPurchaseTotal'] = Mage::helper('core')->currency($order->getData('total_paid'), true, false);
|
123 |
+
|
124 |
+
$merge_vars = $this->getMergeOrderItems($order, $merge_vars);
|
125 |
+
$merge_vars = $this->getRelatedOrderItems($order, $merge_vars);
|
126 |
+
$this->_logger->logAndDebug("Finish Save Latest");
|
127 |
+
}
|
128 |
+
else
|
129 |
+
$this->_logger->logAndDebug("Not setup to send latest order info");
|
130 |
+
|
131 |
+
return $merge_vars;
|
132 |
+
}
|
133 |
+
|
134 |
+
protected function getParentOptions($parent_product,$product_id)
|
135 |
+
{
|
136 |
+
$parent_options = $this->getConfigurableOptions($parent_product,$product_id);
|
137 |
+
|
138 |
+
if (count($parent_options) == 0)
|
139 |
+
return "";
|
140 |
+
|
141 |
+
$options = "";
|
142 |
+
|
143 |
+
foreach ($parent_options as $key => $value)
|
144 |
+
{
|
145 |
+
if ($options == "")
|
146 |
+
$options .= "#";
|
147 |
+
else
|
148 |
+
$options .= "&";
|
149 |
+
|
150 |
+
$options .= "{$key}={$value}";
|
151 |
+
}
|
152 |
+
|
153 |
+
return $options;
|
154 |
+
}
|
155 |
+
|
156 |
+
protected function getGroupedPrice($grouped_product)
|
157 |
+
{
|
158 |
+
$min = 0;
|
159 |
+
$products = $grouped_product->getTypeInstance()->getAssociatedProducts();
|
160 |
+
foreach ($products as $product)
|
161 |
+
{
|
162 |
+
if ($min == 0)
|
163 |
+
$min = $product->getPrice();
|
164 |
+
|
165 |
+
$min = min($min, $product->getPrice());
|
166 |
+
}
|
167 |
+
|
168 |
+
return $min;
|
169 |
+
}
|
170 |
+
|
171 |
+
protected function getProductImage($product, $parent_product = null)
|
172 |
+
{
|
173 |
+
try
|
174 |
+
{
|
175 |
+
$image = "";
|
176 |
+
if ($product->getImage() == 'no_selection' || $product->getImage() == "")
|
177 |
+
{
|
178 |
+
if ($parent_product != null && $parent_product->getImage() != "no_selection" && $parent_product->getImage() != "")
|
179 |
+
$image = Mage::getModel('catalog/product_media_config')->getMediaUrl($parent_product->getImage());
|
180 |
+
}
|
181 |
+
else
|
182 |
+
$image = Mage::getModel('catalog/product_media_config')->getMediaUrl($product->getImage());
|
183 |
+
}
|
184 |
+
catch (Exception $e)
|
185 |
+
{
|
186 |
+
Mage::logException($e);
|
187 |
+
$this->_logger->logException($e);
|
188 |
+
}
|
189 |
+
|
190 |
+
return $image;
|
191 |
+
}
|
192 |
+
|
193 |
+
private function addMergeItem($item_data, $pos, $merge_vars, $prefix = "")
|
194 |
+
{
|
195 |
+
$name = "";
|
196 |
+
$parent_name = "";
|
197 |
+
$sku = "";
|
198 |
+
$url = "";
|
199 |
+
$image = "";
|
200 |
+
$cost = "";
|
201 |
+
$description = "";
|
202 |
+
$parent_item = null;
|
203 |
+
$parent_product = null;
|
204 |
+
|
205 |
+
if ($item_data != null)
|
206 |
+
{
|
207 |
+
$product_id = 0;
|
208 |
+
|
209 |
+
if (is_array($item_data))
|
210 |
+
{
|
211 |
+
$item = $item_data['item'];
|
212 |
+
|
213 |
+
if (isset($item_data['parent']))
|
214 |
+
$parent_item = $item_data['parent'];
|
215 |
+
}
|
216 |
+
else
|
217 |
+
$item = $item_data;
|
218 |
+
|
219 |
+
if (is_string($item))
|
220 |
+
{
|
221 |
+
$product_id = $item;
|
222 |
+
|
223 |
+
$product = Mage::getModel('catalog/product')->load($product_id);
|
224 |
+
|
225 |
+
if ($product == null || !$product->getId())
|
226 |
+
return $merge_vars;
|
227 |
+
}
|
228 |
+
else
|
229 |
+
{
|
230 |
+
$product = $this->getProduct($item);
|
231 |
+
if ($product == null)
|
232 |
+
return $merge_vars; // Can't get product so abort
|
233 |
+
}
|
234 |
+
|
235 |
+
if ($parent_item != null)
|
236 |
+
{
|
237 |
+
$parent_product = $this->getProduct($parent_item);
|
238 |
+
if ($parent_product == null)
|
239 |
+
return $merge_vars; // Can't get product so abort
|
240 |
+
|
241 |
+
$parent_name = $parent_product->getName();
|
242 |
+
$url = $parent_product->getProductUrl();
|
243 |
+
|
244 |
+
if ($parent_product->getTypeId() == 'configurable')
|
245 |
+
$url .= $this->getParentOptions($parent_product,$product_id);
|
246 |
+
}
|
247 |
+
else
|
248 |
+
$url = $product->getProductUrl();
|
249 |
+
|
250 |
+
$name = $product->getName();
|
251 |
+
$sku = $product->getSku();
|
252 |
+
|
253 |
+
$image = $this->getProductImage($product, $parent_product);
|
254 |
+
|
255 |
+
if (is_string($item))
|
256 |
+
{
|
257 |
+
if ($product->getTypeId() == 'grouped')
|
258 |
+
$cost = $this->getGroupedPrice($product);
|
259 |
+
else
|
260 |
+
$cost = $product->getPrice();
|
261 |
+
}
|
262 |
+
else
|
263 |
+
$cost = $item->getPrice();
|
264 |
+
|
265 |
+
$cost = Mage::helper('core')->currency($cost,true,false);
|
266 |
+
$description = $product->getShortDescription();
|
267 |
+
}
|
268 |
+
|
269 |
+
$merge_vars["{$prefix}ProductName{$pos}"] = $name;
|
270 |
+
if ($prefix != 'Related')
|
271 |
+
$merge_vars["{$prefix}ParentName{$pos}"] = $parent_name;
|
272 |
+
|
273 |
+
$merge_vars["{$prefix}SKU{$pos}"] = $sku;
|
274 |
+
$merge_vars["{$prefix}URL{$pos}"] = $url;
|
275 |
+
$merge_vars["{$prefix}Image{$pos}"] = $image;
|
276 |
+
|
277 |
+
$merge_vars["{$prefix}Cost{$pos}"] = $cost;
|
278 |
+
$merge_vars["{$prefix}Description{$pos}"] = $description;
|
279 |
+
|
280 |
+
return $merge_vars;
|
281 |
+
}
|
282 |
+
|
283 |
+
protected function getRelatedCollection($id_list, $max_count, $grouped_id_list = null)
|
284 |
+
{
|
285 |
+
$this->debug("getRelatedCollection Start");
|
286 |
+
$collection = Mage::getModel('catalog/product_link')
|
287 |
+
->useRelatedLinks()
|
288 |
+
->getCollection()
|
289 |
+
->addFieldToFilter('product_id', array('in' => $id_list))
|
290 |
+
;
|
291 |
+
|
292 |
+
$this->debug("Collection SQL");
|
293 |
+
$this->debug($collection->getSelect()->__toString());
|
294 |
+
|
295 |
+
// Filter out grouped products from the related list
|
296 |
+
if ($grouped_id_list != null && count($grouped_id_list) > 0)
|
297 |
+
{
|
298 |
+
$this->debug("Merging Grouped ID's to filter");
|
299 |
+
$id_list = array_merge($id_list,$grouped_id_list);
|
300 |
+
|
301 |
+
}
|
302 |
+
|
303 |
+
$this->debug("ID Filters");
|
304 |
+
$this->debug($id_list);
|
305 |
+
|
306 |
+
$product_ids = array();
|
307 |
+
|
308 |
+
// If any of the related products are already in the order we filter them out
|
309 |
+
foreach ($collection as $rp)
|
310 |
+
{
|
311 |
+
$this->debug("");
|
312 |
+
$this->debug("-----------------------------");
|
313 |
+
$this->debug("Related Product");
|
314 |
+
$this->debug($rp->getData());
|
315 |
+
$lp_id = $rp['linked_product_id'];
|
316 |
+
if (!in_array($lp_id,$id_list))
|
317 |
+
{
|
318 |
+
$this->debug("Adding Related Product");
|
319 |
+
$product_ids[] = $lp_id;
|
320 |
+
}
|
321 |
+
else
|
322 |
+
$this->debug("Related product already in order");
|
323 |
+
}
|
324 |
+
|
325 |
+
$this->debug("Product IDs");
|
326 |
+
$this->debug($product_ids);
|
327 |
+
|
328 |
+
$related = Mage::getResourceModel('catalog/product_collection')
|
329 |
+
->addFieldToFilter('entity_id', array('in' => $product_ids))
|
330 |
+
->setPageSize($max_count);
|
331 |
+
|
332 |
+
Mage::getSingleton('catalog/product_visibility')->addVisibleInCatalogFilterToCollection($related);
|
333 |
+
|
334 |
+
$this->debug("Related SQL");
|
335 |
+
$this->debug($related->getSelect()->__toString());
|
336 |
+
|
337 |
+
$related_list = array();
|
338 |
+
|
339 |
+
if (count($related) > 0)
|
340 |
+
{
|
341 |
+
foreach ($related as $rp)
|
342 |
+
{
|
343 |
+
$related_list[] = $rp;
|
344 |
+
}
|
345 |
+
}
|
346 |
+
|
347 |
+
return $related_list;
|
348 |
+
}
|
349 |
+
|
350 |
+
protected function getRelatedProducts($quote)
|
351 |
+
{
|
352 |
+
$id_list = array();
|
353 |
+
$grouped_id_list = array();
|
354 |
+
$filter_id_list = array();
|
355 |
+
|
356 |
+
foreach ($quote->getAllItems() as $item)
|
357 |
+
{
|
358 |
+
$this->debug("");
|
359 |
+
$this->debug("----------------------------------------------------------");
|
360 |
+
$type = $item->getProductType();
|
361 |
+
$this->debug("Item ID: {$item->getId()}");
|
362 |
+
$this->debug("Item Sku: {$item->getSku()}");
|
363 |
+
$this->debug("Item Type: {$type}");
|
364 |
+
|
365 |
+
// if it is a grouped product get the parent ID and add it to the list (if not already added)
|
366 |
+
if ($type == 'grouped')
|
367 |
+
{
|
368 |
+
$grouped_product_id = $this->getGroupedProductId($item);
|
369 |
+
|
370 |
+
$this->debug("Grouped Product ID: {$grouped_product_id}");
|
371 |
+
|
372 |
+
if (!in_array($grouped_product_id, $grouped_id_list))
|
373 |
+
$grouped_id_list[] = $grouped_product_id;
|
374 |
+
}
|
375 |
+
|
376 |
+
if ($product = $this->getProduct($item))
|
377 |
+
{
|
378 |
+
$product_id = $product->getId();
|
379 |
+
if (!in_array($product_id, $id_list))
|
380 |
+
$id_list[] = $product_id;
|
381 |
+
}
|
382 |
+
}
|
383 |
+
|
384 |
+
$this->debug("ID List");
|
385 |
+
$this->debug($id_list);
|
386 |
+
$this->debug("Grouped ID List");
|
387 |
+
$this->debug($grouped_id_list);
|
388 |
+
|
389 |
+
$max_count = $this->config('related_fields');
|
390 |
+
|
391 |
+
$this->debug("Max Related: {$max_count}");
|
392 |
+
|
393 |
+
$this->debug("");
|
394 |
+
$this->debug("--------------------------------------------------------------------------");
|
395 |
+
$this->debug("Get Related Collection (Non Grouped)");
|
396 |
+
$this->debug("");
|
397 |
+
|
398 |
+
$related = $this->getRelatedCollection($id_list, $max_count, $grouped_id_list);
|
399 |
+
|
400 |
+
$this->debug("");
|
401 |
+
$this->debug("# of Related Products Found: " . count($related));
|
402 |
+
|
403 |
+
if (count($related) < $max_count && count($grouped_id_list) > 0)
|
404 |
+
{
|
405 |
+
$this->debug("");
|
406 |
+
$this->debug("--------------------------------------------------------------------------");
|
407 |
+
$this->debug("Get Related Collection (Grouped)");
|
408 |
+
$this->debug("");
|
409 |
+
|
410 |
+
// get grouped related
|
411 |
+
$grouped_related = $this->getRelatedCollection($grouped_id_list, $max_count - count($related), $id_list);
|
412 |
+
|
413 |
+
// Merge the collections
|
414 |
+
if (count($grouped_related) > 0)
|
415 |
+
return array_merge($related, $grouped_related);
|
416 |
+
}
|
417 |
+
|
418 |
+
return $related;
|
419 |
+
}
|
420 |
+
|
421 |
+
public function getRelatedOrderItems($quote, $merge_vars)
|
422 |
+
{
|
423 |
+
$prefix = "Related";
|
424 |
+
$max_count = $this->config('related_fields');
|
425 |
+
|
426 |
+
$this->debug('');
|
427 |
+
$this->debug('Getting Related Products');
|
428 |
+
|
429 |
+
$related_products = $this->getRelatedProducts($quote);
|
430 |
+
|
431 |
+
$count = 0;
|
432 |
+
|
433 |
+
foreach ($related_products as $rp)
|
434 |
+
{
|
435 |
+
$count++;
|
436 |
+
|
437 |
+
if ($count > $max_count)
|
438 |
+
break;
|
439 |
+
|
440 |
+
$merge_vars = $this->addMergeItem($rp->getId(), $count, $merge_vars, $prefix);
|
441 |
+
}
|
442 |
+
|
443 |
+
while ($count < $max_count)
|
444 |
+
{
|
445 |
+
$count++;
|
446 |
+
$merge_vars = $this->addMergeItem(null, $count, $merge_vars, $prefix);
|
447 |
+
}
|
448 |
+
|
449 |
+
return $merge_vars;
|
450 |
+
}
|
451 |
+
|
452 |
+
protected function getGroupedProductId($item)
|
453 |
+
{
|
454 |
+
$this->debug('Get Grouped Product Id');
|
455 |
+
$options = $item->getProductOptions();
|
456 |
+
|
457 |
+
$this->debug('Product Options');
|
458 |
+
$this->debug($options);
|
459 |
+
|
460 |
+
if (isset($options['super_product_config']))
|
461 |
+
{
|
462 |
+
$this->debug('Super config found');
|
463 |
+
if (isset($options['super_product_config']['product_id']))
|
464 |
+
{
|
465 |
+
$this->debug('Product Id Found');
|
466 |
+
$product_id = $options['super_product_config']['product_id'];
|
467 |
+
|
468 |
+
return $product_id;
|
469 |
+
}
|
470 |
+
$this->debug('Product Id Not Found!');
|
471 |
+
}
|
472 |
+
else
|
473 |
+
{
|
474 |
+
$this->debug('Get Option By Code');
|
475 |
+
$option = $item->getOptionByCode('product_type');
|
476 |
+
if ($option)
|
477 |
+
{
|
478 |
+
$this->debug('Option Found');
|
479 |
+
$this->debug($option);
|
480 |
+
return $option->getProductId();
|
481 |
+
}
|
482 |
+
}
|
483 |
+
|
484 |
+
$this->debug('Unable to get Grouped Product ID');
|
485 |
+
|
486 |
+
return false;
|
487 |
+
}
|
488 |
+
|
489 |
+
protected function getGroupedProduct($item)
|
490 |
+
{
|
491 |
+
$this->debug('Get Grouped Product');
|
492 |
+
$product_id = $this->getGroupedProductId($item);
|
493 |
+
|
494 |
+
if ($product_id !== false)
|
495 |
+
{
|
496 |
+
$this->debug('Loading Product');
|
497 |
+
$product = Mage::getModel('catalog/product')->load($product_id);
|
498 |
+
|
499 |
+
if ($product->getId())
|
500 |
+
{
|
501 |
+
$this->debug('Grouped Product Found!');
|
502 |
+
return $product;
|
503 |
+
}
|
504 |
+
}
|
505 |
+
|
506 |
+
$this->debug('Unable to get Grouped Product');
|
507 |
+
|
508 |
+
return false;
|
509 |
+
}
|
510 |
+
|
511 |
+
protected function isItemVisible($item)
|
512 |
+
{
|
513 |
+
$vis_flag = Mage_Catalog_Model_Product_Visibility::VISIBILITY_NOT_VISIBLE;
|
514 |
+
|
515 |
+
if ($item == null)
|
516 |
+
return true;
|
517 |
+
|
518 |
+
$product = $this->getProduct($item);
|
519 |
+
|
520 |
+
if ($product == null)
|
521 |
+
return true;
|
522 |
+
|
523 |
+
if ($product->getVisibility() != $vis_flag)
|
524 |
+
return true;
|
525 |
+
|
526 |
+
return false;
|
527 |
+
}
|
528 |
+
|
529 |
+
protected function processParentItems($quote)
|
530 |
+
{
|
531 |
+
$this->debug("Processing Parent Items");
|
532 |
+
$parent_items = array();
|
533 |
+
|
534 |
+
foreach ($quote->getAllItems() as $item)
|
535 |
+
{
|
536 |
+
$this->debug("");
|
537 |
+
$this->debug("----------------------------------------------------------");
|
538 |
+
$type = $item->getProductType();
|
539 |
+
//Zend_debug::dump($item->getData());
|
540 |
+
$this->debug("Item ID: {$item->getId()}");
|
541 |
+
$this->debug("Item Sku: {$item->getSku()}");
|
542 |
+
$this->debug("Item Type: {$type}");
|
543 |
+
if ($type == "configurable" || $type == "bundle")
|
544 |
+
{
|
545 |
+
$this->debug('*** Adding as Parent Item ***');
|
546 |
+
$parent_items[$item->getId()] = $item;
|
547 |
+
}
|
548 |
+
|
549 |
+
if ($type == "grouped")
|
550 |
+
{
|
551 |
+
$grouped_product = $this->getGroupedProduct($item);
|
552 |
+
|
553 |
+
if ($grouped_product)
|
554 |
+
{
|
555 |
+
$this->debug('*** Adding Grouped Product to Parent Items ***');
|
556 |
+
$parent_item = new Varien_Object;
|
557 |
+
$parent_item->setProduct($grouped_product);
|
558 |
+
$parent_items[$item->getId()] = $parent_item;
|
559 |
+
}
|
560 |
+
}
|
561 |
+
}
|
562 |
+
|
563 |
+
$this->debug('Parent Items Found: ' . count($parent_items));
|
564 |
+
|
565 |
+
if (count($parent_items) > 0)
|
566 |
+
{
|
567 |
+
$this->debug('Parent Items:');
|
568 |
+
|
569 |
+
foreach($parent_items as $key => $item)
|
570 |
+
{
|
571 |
+
$this->debug('-------------------------');
|
572 |
+
$this->debug("ID: {$key}");
|
573 |
+
if ($item->getId())
|
574 |
+
$this->debug("Parent ID: " . $item->getId());
|
575 |
+
else
|
576 |
+
{
|
577 |
+
$parent_product = $this->getProduct($item);
|
578 |
+
if ($parent_product)
|
579 |
+
$this->debug("Parent ID: " . $parent_product->getId());
|
580 |
+
else
|
581 |
+
$this->debug("Parent ID: Failed to load product");
|
582 |
+
}
|
583 |
+
}
|
584 |
+
}
|
585 |
+
|
586 |
+
return $parent_items;
|
587 |
+
}
|
588 |
+
|
589 |
+
public function getMergeOrderItems($quote, $merge_vars, $prefix = "")
|
590 |
+
{
|
591 |
+
$max_count = $this->config('product_fields');
|
592 |
+
|
593 |
+
$count = 0;
|
594 |
+
|
595 |
+
$item_data = array();
|
596 |
+
|
597 |
+
$parent_items = $this->processParentItems($quote);
|
598 |
+
|
599 |
+
$this->debug('');
|
600 |
+
$this->debug('Processing Order Items');
|
601 |
+
|
602 |
+
foreach ($quote->getAllItems() as $item)
|
603 |
+
{
|
604 |
+
$type = $item->getProductType();
|
605 |
+
|
606 |
+
$this->debug('');
|
607 |
+
$this->debug("----------------------------------------------------------");
|
608 |
+
$this->debug('Item Sku: ' . $item->getSku());
|
609 |
+
$this->debug('Item Type: ' . $type);
|
610 |
+
|
611 |
+
if ($type == "configurable" || $type == "bundle")
|
612 |
+
{
|
613 |
+
$this->debug('Skipping Configurable and Bundle Products (this is a parent product)');
|
614 |
+
continue;
|
615 |
+
}
|
616 |
+
|
617 |
+
$item_id = $item->getId();
|
618 |
+
|
619 |
+
if ($item->getProductType() == 'grouped')
|
620 |
+
{
|
621 |
+
$this->debug('Grouped Product');
|
622 |
+
|
623 |
+
$parent_id = $item->getId();
|
624 |
+
}
|
625 |
+
else
|
626 |
+
{
|
627 |
+
$parent_id = $item->getParentItemId();
|
628 |
+
}
|
629 |
+
|
630 |
+
$this->debug("Parent Id: {$parent_id}");
|
631 |
+
|
632 |
+
if ($parent_id != null && isset($parent_items[$parent_id]))
|
633 |
+
{
|
634 |
+
$this->debug('Item has a Parent');
|
635 |
+
$parent_item = $parent_items[$parent_id];
|
636 |
+
|
637 |
+
$this->debug('Checking Visibility of Item and Parent (only one needs to be visible)');
|
638 |
+
if ($this->isItemVisible($item) || $this->isItemVisible($parent_item))
|
639 |
+
{
|
640 |
+
$this->debug('Adding Item to list');
|
641 |
+
$item_data[$item_id] = array('item' => $item, 'parent' => $parent_item);
|
642 |
+
}
|
643 |
+
else
|
644 |
+
$this->debug('Visibility check failed');
|
645 |
+
}
|
646 |
+
else
|
647 |
+
{
|
648 |
+
$this->debug('Checking Visibility of Item');
|
649 |
+
if ($this->isItemVisible($item))
|
650 |
+
{
|
651 |
+
$this->debug('Adding Item to list');
|
652 |
+
$item_data[$item_id] = array('item' => $item);
|
653 |
+
}
|
654 |
+
else
|
655 |
+
$this->debug('Visibility check failed');
|
656 |
+
}
|
657 |
+
}
|
658 |
+
|
659 |
+
foreach ($item_data as $item)
|
660 |
+
{
|
661 |
+
$count++;
|
662 |
+
|
663 |
+
if ($count > $max_count)
|
664 |
+
break;
|
665 |
+
|
666 |
+
$merge_vars = $this->addMergeItem($item, $count, $merge_vars, $prefix);
|
667 |
+
}
|
668 |
+
|
669 |
+
// Blank out other items
|
670 |
+
while ($count < $max_count)
|
671 |
+
{
|
672 |
+
$count++;
|
673 |
+
$merge_vars = $this->addMergeItem(null, $count, $merge_vars, $prefix);
|
674 |
+
}
|
675 |
+
|
676 |
+
return $merge_vars;
|
677 |
+
}
|
678 |
+
}
|
app/code/community/EmailDirect/Integration/Helper/Troubleshooting.php
ADDED
@@ -0,0 +1,712 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class EmailDirect_Integration_Helper_Troubleshooting extends Mage_Core_Helper_Abstract
|
4 |
+
{
|
5 |
+
const LOG_FILE_NAME = 'emaildirect';
|
6 |
+
const LOG_FILE_EXT = '.log';
|
7 |
+
const LOG_LEVEL_HIGH = 0;
|
8 |
+
const LOG_LEVEL_NORMAL = 5;
|
9 |
+
const LOG_LEVEL_LOW = 100;
|
10 |
+
|
11 |
+
const ABANDONED_CART = "AB";
|
12 |
+
const ORDERS = "OR";
|
13 |
+
const NEWSLETTER = "NL";
|
14 |
+
const CUSTOMER = "CU";
|
15 |
+
const CONFIG = "CG";
|
16 |
+
const IGNORE = "IG";
|
17 |
+
const WISHLIST = "WL";
|
18 |
+
const DEFAULT_AREA = "ED";
|
19 |
+
|
20 |
+
const DISABLED_REASON_PREFIX = "Skipping";
|
21 |
+
|
22 |
+
private $_log_level = self::LOG_LEVEL_NORMAL;
|
23 |
+
private $_log_level_active = self::LOG_LEVEL_NORMAL;
|
24 |
+
private $_log_area = self::DEFAULT_AREA;
|
25 |
+
private $_current_store = null;
|
26 |
+
|
27 |
+
private $_output_log = array();
|
28 |
+
|
29 |
+
private $_config_options = null;
|
30 |
+
|
31 |
+
private $_status = array();
|
32 |
+
private $_debug_mode = false;
|
33 |
+
|
34 |
+
private $_debug_execute_mode = "request";
|
35 |
+
|
36 |
+
private $_debug_request = null;
|
37 |
+
private $_debug_response = null;
|
38 |
+
|
39 |
+
protected $_date_format = EmailDirect_Integration_Helper_Data::DATE_FORMAT;
|
40 |
+
|
41 |
+
private $_areas = array(
|
42 |
+
"AB" => "Abandoned Carts",
|
43 |
+
"OR" => "Orders",
|
44 |
+
"NL" => "Newsletter",
|
45 |
+
"CU" => "Customer",
|
46 |
+
//"CG" => "Configuration",
|
47 |
+
"WL" => "Wishlist"
|
48 |
+
);
|
49 |
+
|
50 |
+
public function validateApiKey($apikey, $report_error = false)
|
51 |
+
{
|
52 |
+
$rc = Mage::getSingleton('emaildirect/wrapper_execute')->sendCommandDirect($apikey, 'sources');
|
53 |
+
if (isset($rc->ErrorCode))
|
54 |
+
{
|
55 |
+
if ($report_error)
|
56 |
+
return (string) $rc->Message;
|
57 |
+
return false;
|
58 |
+
}
|
59 |
+
|
60 |
+
return true;
|
61 |
+
}
|
62 |
+
|
63 |
+
public function getDebugExecuteMode()
|
64 |
+
{
|
65 |
+
return $this->_debug_execute_mode;
|
66 |
+
}
|
67 |
+
|
68 |
+
public function setDebugExecuteMode($mode)
|
69 |
+
{
|
70 |
+
$this->_debug_execute_mode = $mode;
|
71 |
+
}
|
72 |
+
|
73 |
+
public function setDebugRequest($request)
|
74 |
+
{
|
75 |
+
$this->_debug_request = $request;
|
76 |
+
}
|
77 |
+
|
78 |
+
public function setDebugResponse($response)
|
79 |
+
{
|
80 |
+
$this->_debug_response = $response;
|
81 |
+
}
|
82 |
+
|
83 |
+
public function getDebugRequest()
|
84 |
+
{
|
85 |
+
return $this->_debug_request;
|
86 |
+
}
|
87 |
+
|
88 |
+
public function getDebugResponse()
|
89 |
+
{
|
90 |
+
return $this->_debug_response;
|
91 |
+
}
|
92 |
+
|
93 |
+
public function getAreas()
|
94 |
+
{
|
95 |
+
return $this->_areas;
|
96 |
+
}
|
97 |
+
|
98 |
+
public function turnOnDebug()
|
99 |
+
{
|
100 |
+
$this->_debug_mode = true;
|
101 |
+
}
|
102 |
+
|
103 |
+
public function turnOffDebug()
|
104 |
+
{
|
105 |
+
$this->_debug_mode = false;
|
106 |
+
}
|
107 |
+
|
108 |
+
public function getDebugData()
|
109 |
+
{
|
110 |
+
return $this->_output_log;
|
111 |
+
}
|
112 |
+
|
113 |
+
public function safeDump($data, $level = 0)
|
114 |
+
{
|
115 |
+
try
|
116 |
+
{
|
117 |
+
$indent = str_repeat(" ",$level);
|
118 |
+
|
119 |
+
$output = "";
|
120 |
+
|
121 |
+
if (is_object($data))
|
122 |
+
{
|
123 |
+
$output = get_class($data) . " Object\n(\n";
|
124 |
+
$output .= $this->safeDump($data->getData(), $level + 1);
|
125 |
+
$output .= ")\n";
|
126 |
+
}
|
127 |
+
|
128 |
+
if (is_array($data))
|
129 |
+
{
|
130 |
+
$output = "{$indent}Array\n{$indent}(\n";
|
131 |
+
//$inner_indent = $indent . " ";
|
132 |
+
$inner_indent = str_repeat(" ",$level + 1);
|
133 |
+
foreach ($data as $key => $value)
|
134 |
+
{
|
135 |
+
$output .= "{$inner_indent}[{$key}] => ";
|
136 |
+
if (is_object($value))
|
137 |
+
$output .= get_class($value) . " Object";
|
138 |
+
else if (is_array($value))
|
139 |
+
$output .= $this->safeDump($value,$level + 1);
|
140 |
+
else
|
141 |
+
$output .= $value;
|
142 |
+
|
143 |
+
$output .= "\n";
|
144 |
+
}
|
145 |
+
|
146 |
+
$output .= "{$indent})\n";
|
147 |
+
}
|
148 |
+
|
149 |
+
return $output;
|
150 |
+
}
|
151 |
+
catch (Exception $e)
|
152 |
+
{
|
153 |
+
return $e->getMessage();
|
154 |
+
}
|
155 |
+
}
|
156 |
+
|
157 |
+
private function formatData($data)
|
158 |
+
{
|
159 |
+
$output = $this->safeDump($data);
|
160 |
+
|
161 |
+
$output = str_replace("\n","<br />",$output);
|
162 |
+
$output = str_replace(" "," ",$output);
|
163 |
+
|
164 |
+
return $output;
|
165 |
+
}
|
166 |
+
|
167 |
+
private function debugFromLog($data)
|
168 |
+
{
|
169 |
+
if (!$this->_debug_mode)
|
170 |
+
return;
|
171 |
+
|
172 |
+
$this->debug($data);
|
173 |
+
}
|
174 |
+
|
175 |
+
public function debug($data)
|
176 |
+
{
|
177 |
+
if (!$this->_debug_mode)
|
178 |
+
return;
|
179 |
+
|
180 |
+
if (!is_string($data))
|
181 |
+
$this->_output_log[] = $this->formatData($data);
|
182 |
+
else
|
183 |
+
$this->_output_log[] = $data;
|
184 |
+
}
|
185 |
+
|
186 |
+
public function debugHeader($header, $level = 2)
|
187 |
+
{
|
188 |
+
$line = str_repeat('==========================================================',$level);
|
189 |
+
//$this->debug($line);
|
190 |
+
$this->debug($header);
|
191 |
+
$this->debug($line);
|
192 |
+
$this->debug('');
|
193 |
+
}
|
194 |
+
|
195 |
+
|
196 |
+
public function debugXml($data)
|
197 |
+
{
|
198 |
+
if (!$this->_debug_mode)
|
199 |
+
return;
|
200 |
+
|
201 |
+
$this->_output_log[] = "<pre>" . htmlentities($this->formatXml($data)) . "</pre>";
|
202 |
+
}
|
203 |
+
|
204 |
+
public function isDebugMode()
|
205 |
+
{
|
206 |
+
return $this->_debug_mode;
|
207 |
+
}
|
208 |
+
|
209 |
+
public function formatXml($xml_string)
|
210 |
+
{
|
211 |
+
try
|
212 |
+
{
|
213 |
+
$dom = new DOMDocument('1.0');
|
214 |
+
$dom->preserveWhiteSpace = false;
|
215 |
+
$dom->formatOutput = true;
|
216 |
+
$dom->loadXML($xml_string);
|
217 |
+
return $dom->saveXML();
|
218 |
+
}
|
219 |
+
catch (Exception $e)
|
220 |
+
{
|
221 |
+
$this->logException($e);
|
222 |
+
return $xml_string;
|
223 |
+
}
|
224 |
+
}
|
225 |
+
|
226 |
+
private function getReportTable($heading, $table, $headings = true)
|
227 |
+
{
|
228 |
+
$output = "<h1>{$heading}</h1>";
|
229 |
+
$output .= "<table cellspacing='0' border='1'>";
|
230 |
+
|
231 |
+
if ($headings)
|
232 |
+
$output .= "<thead>
|
233 |
+
<tr class='headings'>
|
234 |
+
<th>Setting</th>
|
235 |
+
<th>Value</th>
|
236 |
+
</tr>
|
237 |
+
</thead>";
|
238 |
+
|
239 |
+
foreach ($table as $key => $value)
|
240 |
+
{
|
241 |
+
$output .= "<tr class='border'>
|
242 |
+
<td>{$key}</td>
|
243 |
+
<td>{$value}</td>
|
244 |
+
</tr>";
|
245 |
+
}
|
246 |
+
$output .= "</table>";
|
247 |
+
|
248 |
+
return $output;
|
249 |
+
}
|
250 |
+
|
251 |
+
public function getReport($customer = null)
|
252 |
+
{
|
253 |
+
$environment = $this->getEnvironmentInfo();
|
254 |
+
$store_configuration = $this->getConfigurationInfo();
|
255 |
+
|
256 |
+
$output = "<html><head></head><body>";
|
257 |
+
|
258 |
+
if ($customer != null)
|
259 |
+
$output .= $this->getReportTable("Customer Information", $customer, false);
|
260 |
+
|
261 |
+
$output .= $this->getReportTable("General Configuration", $environment);
|
262 |
+
|
263 |
+
foreach ($store_configuration as $code => $configuration)
|
264 |
+
{
|
265 |
+
$output .= $this->getReportTable("Module Configuration for store: {$code}", $configuration);
|
266 |
+
}
|
267 |
+
|
268 |
+
$output .= "<h1>Log File</h1>";
|
269 |
+
$output .= "<pre>" . $this->getLogFileContents() . "</pre>";
|
270 |
+
|
271 |
+
$output .= "</body></html>";
|
272 |
+
|
273 |
+
return $output;
|
274 |
+
}
|
275 |
+
|
276 |
+
private function getArrayData($data)
|
277 |
+
{
|
278 |
+
$output = "<table cellspacing='0' class='data ed-config-subtable'>
|
279 |
+
<thead>
|
280 |
+
<tr class='headings'>
|
281 |
+
<th>Magento</th>
|
282 |
+
<th>EmailDirect</th>
|
283 |
+
</tr>
|
284 |
+
</thead>";
|
285 |
+
|
286 |
+
foreach ($data as $row)
|
287 |
+
{
|
288 |
+
$output .= "<tbody><tr class='border'><td>{$row['magento']}</td><td>{$row['emaildirect']}</td></tr></tbody>";
|
289 |
+
}
|
290 |
+
|
291 |
+
$output .= "</table>";
|
292 |
+
|
293 |
+
return $output;
|
294 |
+
}
|
295 |
+
|
296 |
+
public function getEnvironmentInfo()
|
297 |
+
{
|
298 |
+
$data = array(
|
299 |
+
'Magento Version' => Mage::getVersion(),
|
300 |
+
'EmailDirect Version' => (string) Mage::getConfig()->getNode('modules/EmailDirect_Integration/version'),
|
301 |
+
'Website URL' => Mage::getBaseUrl(),
|
302 |
+
'PHP Version' => phpversion(),
|
303 |
+
'Server Software' => $_SERVER['SERVER_SOFTWARE']
|
304 |
+
);
|
305 |
+
|
306 |
+
if (method_exists("Mage","getEdition"))
|
307 |
+
$data['Magento Edition'] = Mage::getEdition();
|
308 |
+
return $data;
|
309 |
+
}
|
310 |
+
|
311 |
+
public function getConfigurationInfo()
|
312 |
+
{
|
313 |
+
$store_data = array();
|
314 |
+
|
315 |
+
$stores = Mage::app()->getStores();
|
316 |
+
|
317 |
+
foreach ($stores as $store)
|
318 |
+
{
|
319 |
+
$e_config = Mage::getStoreConfig("emaildirect/general", $store);
|
320 |
+
|
321 |
+
$data = array( );
|
322 |
+
|
323 |
+
$data['store id'] = $store->getId();
|
324 |
+
$data['url'] = Mage::getStoreConfig(Mage_Core_Model_Store::XML_PATH_SECURE_BASE_URL, $store);
|
325 |
+
|
326 |
+
foreach ($e_config as $key => $value)
|
327 |
+
{
|
328 |
+
if (is_array($value))
|
329 |
+
{
|
330 |
+
// Skip
|
331 |
+
}
|
332 |
+
else
|
333 |
+
{
|
334 |
+
// Check if the data is serialized
|
335 |
+
$test_data = @unserialize($value);
|
336 |
+
if ($test_data !== false)
|
337 |
+
$data[$key] = $this->getArrayData($test_data);
|
338 |
+
else
|
339 |
+
$data[$key] = $value;;
|
340 |
+
}
|
341 |
+
}
|
342 |
+
|
343 |
+
$store_data[$store->getName()] = $data;
|
344 |
+
}
|
345 |
+
|
346 |
+
return $store_data;
|
347 |
+
}
|
348 |
+
|
349 |
+
public function getLogFileContents()
|
350 |
+
{
|
351 |
+
$log_file = $this->getLogFilePath();
|
352 |
+
|
353 |
+
if (!file_exists($log_file))
|
354 |
+
return "";
|
355 |
+
|
356 |
+
$max_size = $this->getMaxLogFileSize();
|
357 |
+
$log_file_size = filesize($log_file);
|
358 |
+
$offset = 0;
|
359 |
+
|
360 |
+
if ($log_file_size > $max_size)
|
361 |
+
$offset = $log_file_size - $max_size;
|
362 |
+
|
363 |
+
return htmlentities(file_get_contents($log_file,false,null,$offset));
|
364 |
+
}
|
365 |
+
|
366 |
+
public function getLogFilePath()
|
367 |
+
{
|
368 |
+
return Mage::getBaseDir('log') . DS. self::LOG_FILE_NAME . self::LOG_FILE_EXT;
|
369 |
+
}
|
370 |
+
|
371 |
+
public function getLogFileName()
|
372 |
+
{
|
373 |
+
return self::LOG_FILE_NAME . self::LOG_FILE_EXT;
|
374 |
+
}
|
375 |
+
|
376 |
+
public function getLogFileSize()
|
377 |
+
{
|
378 |
+
$log_file = $this->getLogFilePath();
|
379 |
+
|
380 |
+
if (file_exists($log_file))
|
381 |
+
return filesize($log_file);
|
382 |
+
|
383 |
+
return 0;
|
384 |
+
}
|
385 |
+
|
386 |
+
public function isLogFileTooLarge()
|
387 |
+
{
|
388 |
+
if ($this->getLogFileSize() > $this->getMaxLogFileSize())
|
389 |
+
return true;
|
390 |
+
return false;
|
391 |
+
}
|
392 |
+
|
393 |
+
public function getLoggingStatus()
|
394 |
+
{
|
395 |
+
$this->checkTimeout();
|
396 |
+
|
397 |
+
$enabled = $this->config('logging_enabled') == 1;
|
398 |
+
|
399 |
+
$stores = Mage::app()->getStores();
|
400 |
+
$stores_selected = $this->arrayConfig("logging_stores_selected");
|
401 |
+
|
402 |
+
$areas_selected = $this->arrayConfig("logging_areas_selected");
|
403 |
+
|
404 |
+
$date = $this->config('logging_start_date');
|
405 |
+
|
406 |
+
$duration = (int)$this->config('logging_duration') * 60;
|
407 |
+
|
408 |
+
$trouble_status = array(
|
409 |
+
'enabled' => $enabled,
|
410 |
+
'start_date' => "",
|
411 |
+
'seconds' => "",
|
412 |
+
'duration' => $duration,
|
413 |
+
'duration_display' => Mage::helper('emaildirect')->getDuration($duration),
|
414 |
+
'stores' => array()
|
415 |
+
);
|
416 |
+
|
417 |
+
if ($date != "")
|
418 |
+
{
|
419 |
+
$trouble_status['start_date'] = $date;
|
420 |
+
|
421 |
+
$trouble_status['elapsed'] = Mage::helper('emaildirect')->timeElapsed2String($date);
|
422 |
+
$now = Mage::getModel('core/date')->gmtTimestamp();
|
423 |
+
$trouble_status['seconds'] = abs($now - strtotime($date));
|
424 |
+
}
|
425 |
+
|
426 |
+
foreach ($stores as $store)
|
427 |
+
{
|
428 |
+
$data = array();
|
429 |
+
|
430 |
+
$store_id = $store->getId();
|
431 |
+
|
432 |
+
$selected = in_array($store_id,$stores_selected);
|
433 |
+
|
434 |
+
$data['id'] = $store_id;
|
435 |
+
$data['name'] = Mage::helper('emaildirect')->getFullStoreName($store);
|
436 |
+
|
437 |
+
$data['emaildirect_enabled'] = Mage::helper('emaildirect')->config('active',$store) == 1;
|
438 |
+
|
439 |
+
if ($enabled)
|
440 |
+
$data['logging_enabled'] = $this->isLoggingEnabledForStore($store_id);
|
441 |
+
else
|
442 |
+
$data['logging_enabled'] = false;
|
443 |
+
|
444 |
+
$data['selected'] = $selected;
|
445 |
+
|
446 |
+
$trouble_status['stores'][$store_id] = $data;
|
447 |
+
}
|
448 |
+
|
449 |
+
$areas = array();
|
450 |
+
|
451 |
+
foreach ($this->_areas as $area => $label)
|
452 |
+
{
|
453 |
+
|
454 |
+
if ($enabled == false)
|
455 |
+
$area_enabled = false;
|
456 |
+
else
|
457 |
+
$area_enabled = $this->isLoggingEnabledForArea($area);
|
458 |
+
|
459 |
+
$areas[$area] = array(
|
460 |
+
'area' => $area,
|
461 |
+
'label' => $label,
|
462 |
+
'logging_enabled' => $area_enabled,
|
463 |
+
'selected' => in_array($area,$areas_selected)
|
464 |
+
);
|
465 |
+
}
|
466 |
+
|
467 |
+
$trouble_status['areas'] = $areas;
|
468 |
+
|
469 |
+
return $trouble_status;
|
470 |
+
}
|
471 |
+
|
472 |
+
public function getLogFilelastUpdate()
|
473 |
+
{
|
474 |
+
$log_file = $this->getLogFilePath();
|
475 |
+
|
476 |
+
if (file_exists($log_file))
|
477 |
+
return filemtime($log_file);
|
478 |
+
|
479 |
+
return "";
|
480 |
+
}
|
481 |
+
|
482 |
+
public function getMaxLogFileSize()
|
483 |
+
{
|
484 |
+
return $this->config('max_file_size');
|
485 |
+
}
|
486 |
+
|
487 |
+
public function config($value)
|
488 |
+
{
|
489 |
+
return Mage::getStoreConfig("emaildirect/troubleshooting/{$value}", 0);
|
490 |
+
}
|
491 |
+
|
492 |
+
public function arrayConfig($value)
|
493 |
+
{
|
494 |
+
$data = $this->config($value);
|
495 |
+
|
496 |
+
if ($data == "")
|
497 |
+
return array();
|
498 |
+
|
499 |
+
return explode(",",$data);
|
500 |
+
}
|
501 |
+
|
502 |
+
private function updateConfig($path, $value, $scope = "default", $store = 0)
|
503 |
+
{
|
504 |
+
$config = Mage::getConfig();
|
505 |
+
$config->saveConfig("emaildirect/troubleshooting/{$path}",$value,$scope,$store);
|
506 |
+
$config->cleanCache();
|
507 |
+
}
|
508 |
+
|
509 |
+
public function disable()
|
510 |
+
{
|
511 |
+
$this->updateConfig("logging_start_date","");
|
512 |
+
$this->updateConfig("logging_enabled","0");
|
513 |
+
}
|
514 |
+
|
515 |
+
public function isDiagnosticEnabled()
|
516 |
+
{
|
517 |
+
return $this->config('diagnostic_enabled') == 1;
|
518 |
+
}
|
519 |
+
|
520 |
+
private function getConfigOptions()
|
521 |
+
{
|
522 |
+
if ($this->_config_options == null)
|
523 |
+
{
|
524 |
+
$options = $this->config('options');
|
525 |
+
|
526 |
+
if ($options == "")
|
527 |
+
$this->_config_options = "";
|
528 |
+
else
|
529 |
+
$this->_config_options = unserialize($options);
|
530 |
+
}
|
531 |
+
|
532 |
+
return $this->_config_options;
|
533 |
+
}
|
534 |
+
|
535 |
+
private function isLoggingEnabledForArea($area = "")
|
536 |
+
{
|
537 |
+
if ($area == "")
|
538 |
+
$area = $this->_log_area;
|
539 |
+
|
540 |
+
if ($this->config('logging_areas') == "all")
|
541 |
+
return true;
|
542 |
+
|
543 |
+
$areas_selected = $this->arrayConfig("logging_areas_selected");
|
544 |
+
|
545 |
+
return in_array($area,$areas_selected);
|
546 |
+
}
|
547 |
+
|
548 |
+
private function isLoggingEnabledForStore($store = 0)
|
549 |
+
{
|
550 |
+
//if ($this->config('logging_enabled') == 0)
|
551 |
+
//return false;
|
552 |
+
|
553 |
+
if ($this->config('logging_stores') == "all")
|
554 |
+
return true;
|
555 |
+
|
556 |
+
$stores_selected = $this->arrayConfig("logging_stores_selected");
|
557 |
+
|
558 |
+
if (is_object($store))
|
559 |
+
$store = $store->getId();
|
560 |
+
|
561 |
+
return in_array($store,$stores_selected);
|
562 |
+
}
|
563 |
+
|
564 |
+
private function isLoggingEnabledForIP()
|
565 |
+
{
|
566 |
+
//if ($this->config('logging_enabled') == 0)
|
567 |
+
//return false;
|
568 |
+
|
569 |
+
$ip = Mage::helper('core/http')->getRemoteAddr();
|
570 |
+
|
571 |
+
$logging_ip = $this->arrayConfig("logging_ip");
|
572 |
+
|
573 |
+
if (count($logging_ip) == 0)
|
574 |
+
return true;
|
575 |
+
|
576 |
+
return in_array($ip,$logging_ip);
|
577 |
+
}
|
578 |
+
|
579 |
+
public function isLoggingEnabled($store = 0)
|
580 |
+
{
|
581 |
+
// First check the global setting
|
582 |
+
if (!$this->config('logging_enabled'))
|
583 |
+
return false;
|
584 |
+
if (!$this->isLoggingEnabledForIP())
|
585 |
+
return false;
|
586 |
+
if (!$this->isLoggingEnabledForArea())
|
587 |
+
return false;
|
588 |
+
if (!$this->isLoggingEnabledForStore($store))
|
589 |
+
return false;
|
590 |
+
return $this->checkTimeout();
|
591 |
+
}
|
592 |
+
|
593 |
+
private function checkTimeout()
|
594 |
+
{
|
595 |
+
$date = $this->config('logging_start_date');
|
596 |
+
|
597 |
+
if ($date == "" || $date == 0)
|
598 |
+
{
|
599 |
+
$this->disable();
|
600 |
+
return false;
|
601 |
+
}
|
602 |
+
|
603 |
+
$now = Mage::getModel('core/date')->gmtTimestamp();
|
604 |
+
|
605 |
+
$seconds = abs($now - strtotime($date));
|
606 |
+
|
607 |
+
$duration = (int)$this->config('logging_duration');
|
608 |
+
|
609 |
+
$duration *= 60;
|
610 |
+
|
611 |
+
if ($seconds > $duration)
|
612 |
+
{
|
613 |
+
$this->disable();
|
614 |
+
Mage::app()->reinitStores();
|
615 |
+
return false;
|
616 |
+
}
|
617 |
+
|
618 |
+
return true;
|
619 |
+
}
|
620 |
+
|
621 |
+
public function logAndDebug($data)
|
622 |
+
{
|
623 |
+
$this->debug($data);
|
624 |
+
|
625 |
+
$this->log($data);
|
626 |
+
}
|
627 |
+
|
628 |
+
public function log($data, $prefix = "", $area = "")
|
629 |
+
{
|
630 |
+
//$this->debug($data);
|
631 |
+
|
632 |
+
$store = Mage::helper('emaildirect')->getCurrentStore();
|
633 |
+
|
634 |
+
if ($area == "")
|
635 |
+
$area = $this->_log_area;
|
636 |
+
|
637 |
+
if ($this->_log_level > $this->_log_level_active)
|
638 |
+
return;
|
639 |
+
|
640 |
+
if ($this->isLoggingEnabled($store, $area))
|
641 |
+
{
|
642 |
+
if (is_array($data) || is_object($data))
|
643 |
+
{
|
644 |
+
if (is_object($data) && get_class($data) == "SimpleXMLElement")
|
645 |
+
$data = $this->formatXml($data->asXml());
|
646 |
+
else
|
647 |
+
$data = $this->safeDump($data);
|
648 |
+
}
|
649 |
+
|
650 |
+
if ($prefix != "")
|
651 |
+
$prefix .= ": ";
|
652 |
+
|
653 |
+
if ($area != "")
|
654 |
+
$data = "[{$area}] [{$store}] {$prefix}{$data}";
|
655 |
+
|
656 |
+
$this->forceLog($data);
|
657 |
+
}
|
658 |
+
}
|
659 |
+
|
660 |
+
public function forceLog($data)
|
661 |
+
{
|
662 |
+
Mage::log($data,null,self::LOG_FILE_NAME . self::LOG_FILE_EXT, true);
|
663 |
+
}
|
664 |
+
|
665 |
+
public function eraseLog()
|
666 |
+
{
|
667 |
+
try
|
668 |
+
{
|
669 |
+
$log_file = Mage::getBaseDir('var') . DS . 'log' . DS . self::LOG_FILE_NAME . self::LOG_FILE_EXT;
|
670 |
+
|
671 |
+
if (!file_exists($log_file))
|
672 |
+
return true;
|
673 |
+
|
674 |
+
unlink($log_file);
|
675 |
+
return true;
|
676 |
+
}
|
677 |
+
catch (Exception $e)
|
678 |
+
{
|
679 |
+
return false;
|
680 |
+
}
|
681 |
+
}
|
682 |
+
|
683 |
+
public function logReason($data)
|
684 |
+
{
|
685 |
+
$this->log($data,self::DISABLED_REASON_PREFIX);
|
686 |
+
}
|
687 |
+
|
688 |
+
public function logException($e)
|
689 |
+
{
|
690 |
+
$this->log($e->__toString(),"Exception");
|
691 |
+
}
|
692 |
+
|
693 |
+
public function logXml($xml, $prefix = "")
|
694 |
+
{
|
695 |
+
$this->log($this->formatXml($xml),$prefix);
|
696 |
+
}
|
697 |
+
|
698 |
+
public function setLogArea($area)
|
699 |
+
{
|
700 |
+
$this->_log_area = $area;
|
701 |
+
}
|
702 |
+
|
703 |
+
public function setLogLevel($level)
|
704 |
+
{
|
705 |
+
$this->_log_level = $level;
|
706 |
+
}
|
707 |
+
|
708 |
+
public function resetLogLevel()
|
709 |
+
{
|
710 |
+
$this->_log_level = self::LOG_LEVEL_NORMAL;
|
711 |
+
}
|
712 |
+
}
|
app/code/community/EmailDirect/Integration/Helper/Upgrade.php
DELETED
@@ -1,29 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class EmailDirect_Integration_Helper_Upgrade extends Mage_Core_Helper_Abstract
|
4 |
-
{
|
5 |
-
const INSTALL_LOG_FILE_NAME = 'emaildirect_install';
|
6 |
-
|
7 |
-
public function install_log($data)
|
8 |
-
{
|
9 |
-
Mage::log($data,null,self::INSTALL_LOG_FILE_NAME . EmailDirect_Integration_Helper_Data::LOG_FILE_EXT, true);
|
10 |
-
}
|
11 |
-
|
12 |
-
public function renameOld()
|
13 |
-
{
|
14 |
-
try
|
15 |
-
{
|
16 |
-
$local = Mage::getBaseDir('code') . DS . "local" . DS;
|
17 |
-
|
18 |
-
$old = "{$local}EmailDirect";
|
19 |
-
$new = "{$local}EmailDirect_Old";
|
20 |
-
|
21 |
-
if (is_dir($old))
|
22 |
-
rename($old,$new);
|
23 |
-
}
|
24 |
-
catch (Exception $e)
|
25 |
-
{
|
26 |
-
Mage::helper('emaildirect')->logException($e);
|
27 |
-
}
|
28 |
-
}
|
29 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/community/EmailDirect/Integration/Model/Abandoned/Observer.php
ADDED
@@ -0,0 +1,328 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class EmailDirect_Integration_Model_Abandoned_Observer extends EmailDirect_Integration_Model_Observer_Abstract
|
4 |
+
{
|
5 |
+
// START ABANDONED CRON
|
6 |
+
private function getAbandonedTime()
|
7 |
+
{
|
8 |
+
$time = $this->_helper->config('abandonedtime');
|
9 |
+
$time *= 60; // Adjust to seconds.
|
10 |
+
|
11 |
+
$date = date(Mage::getModel('core/date')->gmtTimestamp());
|
12 |
+
|
13 |
+
$date = $date - $time;
|
14 |
+
|
15 |
+
return date($this->_date_format, $date);
|
16 |
+
}
|
17 |
+
|
18 |
+
private function setSentToEmailDirectDate($quote_id, $date)
|
19 |
+
{
|
20 |
+
try
|
21 |
+
{
|
22 |
+
$abandoned = Mage::getModel('emaildirect/abandoned')->loadByQuoteId($quote_id);
|
23 |
+
|
24 |
+
$abandoned->setDateSent($date);
|
25 |
+
$abandoned->save();
|
26 |
+
}
|
27 |
+
catch (Exception $e)
|
28 |
+
{
|
29 |
+
Mage::logException($e);
|
30 |
+
$this->_logException($e);
|
31 |
+
}
|
32 |
+
}
|
33 |
+
|
34 |
+
private function processAbandoned($quote)
|
35 |
+
{
|
36 |
+
$this->_log("ProcessAbandoned Start");
|
37 |
+
$email = $quote->getCustomerEmail();
|
38 |
+
|
39 |
+
if ($email == null)
|
40 |
+
$email = $quote->getEmail();
|
41 |
+
|
42 |
+
$abandonedDate = $quote->getUpdatedAt();
|
43 |
+
|
44 |
+
$merge_vars = array();
|
45 |
+
|
46 |
+
$merge_vars['FirstName'] = $quote->getData('customer_firstname');
|
47 |
+
$merge_vars['LastName'] = $quote->getData('customer_lastname');
|
48 |
+
|
49 |
+
$merge_vars['AbandonedDate'] = $abandonedDate;
|
50 |
+
$merge_vars['AbandonedUrl'] = Mage::helper('emaildirect/abandoned')->getAbandonedUrl($quote);
|
51 |
+
|
52 |
+
Mage::helper('emaildirect/abandoned')->addSequence($merge_vars);
|
53 |
+
|
54 |
+
$merge_vars = Mage::helper('emaildirect/order')->getMergeOrderItems($quote, $merge_vars, "AB");
|
55 |
+
|
56 |
+
if ($this->_helper->config('save_latest_order'))
|
57 |
+
{
|
58 |
+
$this->_log("Processing Last Order");
|
59 |
+
$order = Mage::helper('emaildirect/abandoned')->getLastOrder($quote);
|
60 |
+
|
61 |
+
if ($order != null)
|
62 |
+
$merge_vars = Mage::helper('emaildirect/order')->processOrderItems($order, $merge_vars);
|
63 |
+
else
|
64 |
+
$this->_log("Order not found");
|
65 |
+
}
|
66 |
+
|
67 |
+
$xml = Mage::getSingleton('emaildirect/wrapper_abandoned')->getOneSubscriber($email,$merge_vars);
|
68 |
+
|
69 |
+
$this->_log("ProcessAbandoned End");
|
70 |
+
|
71 |
+
return $xml;
|
72 |
+
}
|
73 |
+
|
74 |
+
private function _abandonedCartsProcessor($collection, $store = null, $mark_time = true)
|
75 |
+
{
|
76 |
+
// Store the time we last run
|
77 |
+
$date = date(Mage::getModel('core/date')->gmtTimestamp());
|
78 |
+
$date = date($this->_date_format, $date);
|
79 |
+
|
80 |
+
if ($mark_time)
|
81 |
+
{
|
82 |
+
$this->_log("Saving Last Run Date: {$date}");
|
83 |
+
$this->_helper->updateConfig("abandoned_last_run", $date, $store);
|
84 |
+
}
|
85 |
+
|
86 |
+
$subscribers = false;
|
87 |
+
|
88 |
+
$xml = "<Subscribers>";
|
89 |
+
|
90 |
+
$quote_list = array();
|
91 |
+
|
92 |
+
// Get the data for each abandoned cart
|
93 |
+
foreach ($collection as $quote)
|
94 |
+
{
|
95 |
+
$quote_list[] = $quote->getId();
|
96 |
+
$xml .= $this->processAbandoned($quote, $date);
|
97 |
+
$subscribers = true;
|
98 |
+
}
|
99 |
+
|
100 |
+
$xml .= "</Subscribers>";
|
101 |
+
|
102 |
+
if (!$subscribers)
|
103 |
+
{
|
104 |
+
$this->_logReason("No Carts Found");
|
105 |
+
return; // No abandoned carts found
|
106 |
+
}
|
107 |
+
|
108 |
+
$this->_log("Sending Abandoned Carts");
|
109 |
+
// Send them all at once
|
110 |
+
$rc = Mage::getSingleton('emaildirect/wrapper_abandoned')->sendSubscribers($xml);
|
111 |
+
|
112 |
+
if (isset($rc->ErrorCode))
|
113 |
+
{
|
114 |
+
$this->_log("EmailDirect Error: (" . (string) $rc->ErrorCode . "): " . (string)$rc->Message);
|
115 |
+
}
|
116 |
+
else
|
117 |
+
{
|
118 |
+
$this->_log("Setting date sent for all quotes Start");
|
119 |
+
$this->setDateSent($quote_list,$date);
|
120 |
+
$this->_log("Setting date sent for all quotes End");
|
121 |
+
}
|
122 |
+
}
|
123 |
+
|
124 |
+
private function setDateSent($quote_list, $date)
|
125 |
+
{
|
126 |
+
foreach ($quote_list as $quote_id)
|
127 |
+
{
|
128 |
+
$this->setSentToEmailDirectDate($quote_id, $date);
|
129 |
+
}
|
130 |
+
}
|
131 |
+
|
132 |
+
public function abandonedStoreProcessor($store, $check_date)
|
133 |
+
{
|
134 |
+
try
|
135 |
+
{
|
136 |
+
$store_code = $store->getCode();
|
137 |
+
|
138 |
+
$this->_log("Processing Store: {$store_code}");
|
139 |
+
|
140 |
+
if (!$this->_helper->getAbandonedEnabled())
|
141 |
+
{
|
142 |
+
$this->_logReason($this->_helper->getAbandonedDisabledReason());
|
143 |
+
return;
|
144 |
+
}
|
145 |
+
|
146 |
+
Mage::helper('emaildirect/fields')->checkFields();
|
147 |
+
|
148 |
+
// Setup sequence for this store
|
149 |
+
Mage::helper('emaildirect/abandoned')->setupSequence();
|
150 |
+
|
151 |
+
// Get abandoned collection
|
152 |
+
$collection = Mage::getResourceModel('emaildirect/abandoned_collection');
|
153 |
+
|
154 |
+
$collection->prepareForAbandonedProcess($check_date, $store->getId());
|
155 |
+
|
156 |
+
$this->_log("SQL: " . $collection->getSelect()->__toString());
|
157 |
+
|
158 |
+
$this->_abandonedCartsProcessor($collection, $store->getId());
|
159 |
+
|
160 |
+
Mage::helper('emaildirect/abandoned')->saveCurrentSequence();
|
161 |
+
|
162 |
+
$this->_log("Finished Processing Store: {$store_code}");
|
163 |
+
}
|
164 |
+
catch (Exception $e)
|
165 |
+
{
|
166 |
+
Mage::logException($e);
|
167 |
+
$this->_logException($e);
|
168 |
+
}
|
169 |
+
}
|
170 |
+
|
171 |
+
public function manualCartsProcessor($store_id = null)
|
172 |
+
{
|
173 |
+
try
|
174 |
+
{
|
175 |
+
Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);
|
176 |
+
$this->_setLogArea(EmailDirect_Integration_Helper_Troubleshooting::ABANDONED_CART);
|
177 |
+
$this->_log("Manual Abandoned Carts Processor Start");
|
178 |
+
|
179 |
+
$check_date = $this->getAbandonedTime();
|
180 |
+
|
181 |
+
$this->_log("Check Date: {$check_date}");
|
182 |
+
|
183 |
+
$stores = Mage::app()->getStores();
|
184 |
+
|
185 |
+
foreach ($stores as $store)
|
186 |
+
{
|
187 |
+
if ($store_id == null || $store_id == $store->getId())
|
188 |
+
{
|
189 |
+
Mage::app()->setCurrentStore($store->getCode());
|
190 |
+
|
191 |
+
$this->abandonedStoreProcessor($store, $check_date);
|
192 |
+
}
|
193 |
+
}
|
194 |
+
|
195 |
+
Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);
|
196 |
+
|
197 |
+
$this->_log("Manual Abandoned Carts Processor End");
|
198 |
+
}
|
199 |
+
catch (Exception $e)
|
200 |
+
{
|
201 |
+
Mage::logException($e);
|
202 |
+
$this->_logException($e);
|
203 |
+
}
|
204 |
+
}
|
205 |
+
|
206 |
+
public function abandonedCartsProcessor()
|
207 |
+
{
|
208 |
+
try
|
209 |
+
{
|
210 |
+
Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);
|
211 |
+
$this->_setLogArea(EmailDirect_Integration_Helper_Troubleshooting::ABANDONED_CART);
|
212 |
+
$this->_log("Abandoned Carts Processor Start");
|
213 |
+
|
214 |
+
$check_date = $this->getAbandonedTime();
|
215 |
+
|
216 |
+
$this->_log("Check Date: {$check_date}");
|
217 |
+
|
218 |
+
$stores = Mage::app()->getStores();
|
219 |
+
|
220 |
+
//$starting_store = Mage::app()->getStore()->getCode();
|
221 |
+
|
222 |
+
foreach ($stores as $store)
|
223 |
+
{
|
224 |
+
Mage::app()->setCurrentStore($store->getCode());
|
225 |
+
|
226 |
+
$this->abandonedStoreProcessor($store, $check_date);
|
227 |
+
}
|
228 |
+
|
229 |
+
Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);
|
230 |
+
|
231 |
+
$date = date(Mage::getModel('core/date')->gmtTimestamp());
|
232 |
+
$date = date($this->_date_format, $date);
|
233 |
+
|
234 |
+
$this->_log("Saving Last Cron Run Date: {$date}");
|
235 |
+
$this->_helper->updateConfig("cron_last_run", $date);
|
236 |
+
|
237 |
+
$this->_log("Abandoned Carts Processor End");
|
238 |
+
}
|
239 |
+
catch (Exception $e)
|
240 |
+
{
|
241 |
+
Mage::logException($e);
|
242 |
+
$this->_logException($e);
|
243 |
+
}
|
244 |
+
}
|
245 |
+
|
246 |
+
public function SendAbandonedCarts($id_list)
|
247 |
+
{
|
248 |
+
try
|
249 |
+
{
|
250 |
+
$count = 0;
|
251 |
+
|
252 |
+
Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);
|
253 |
+
|
254 |
+
$this->_setLogArea(EmailDirect_Integration_Helper_Troubleshooting::ABANDONED_CART);
|
255 |
+
$this->_log("Sending Specific Abandoned Carts Start");
|
256 |
+
|
257 |
+
Mage::helper('emaildirect/fields')->checkFields();
|
258 |
+
|
259 |
+
$this->_log($id_list, "ID LIST");
|
260 |
+
|
261 |
+
$stores = Mage::app()->getStores();
|
262 |
+
|
263 |
+
foreach ($stores as $store)
|
264 |
+
{
|
265 |
+
$this->_log("Checking for valid carts in store: {$store->getName()} ({$store->getId()})");
|
266 |
+
if (!Mage::helper('emaildirect')->getAbandonedEnabled($store->getId()))
|
267 |
+
{
|
268 |
+
$this->_log('Abandoned Carts not enabled...');
|
269 |
+
continue;
|
270 |
+
}
|
271 |
+
|
272 |
+
Mage::app()->setCurrentStore($store->getCode());
|
273 |
+
|
274 |
+
// Get abandoned collection
|
275 |
+
$collection = Mage::getResourceModel('emaildirect/abandoned_collection');
|
276 |
+
|
277 |
+
$collection->prepareForManualAbandonedProcess($id_list, $store->getId());
|
278 |
+
|
279 |
+
$count += count($collection);
|
280 |
+
|
281 |
+
$this->_log("SQL: " . $collection->getSelect()->__toString());
|
282 |
+
|
283 |
+
// Setup sequence for this store
|
284 |
+
Mage::helper('emaildirect/abandoned')->setupSequence();
|
285 |
+
|
286 |
+
$this->_abandonedCartsProcessor($collection, $store, false);
|
287 |
+
|
288 |
+
Mage::helper('emaildirect/abandoned')->saveCurrentSequence();
|
289 |
+
}
|
290 |
+
|
291 |
+
Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);
|
292 |
+
|
293 |
+
$this->_log("Sending Specific Abandoned Carts End");
|
294 |
+
|
295 |
+
return $count;
|
296 |
+
}
|
297 |
+
catch (Exception $e)
|
298 |
+
{
|
299 |
+
Mage::logException($e);
|
300 |
+
$this->_logException($e);
|
301 |
+
}
|
302 |
+
}
|
303 |
+
|
304 |
+
// END ABANDONED CRON
|
305 |
+
|
306 |
+
// START QUOTE SAVE AFTER
|
307 |
+
public function quoteSaveAfter(Varien_Event_Observer $observer)
|
308 |
+
{
|
309 |
+
try
|
310 |
+
{
|
311 |
+
$this->_setLogArea(EmailDirect_Integration_Helper_Troubleshooting::ABANDONED_CART);
|
312 |
+
$this->_logger->setLogLevel(EmailDirect_Integration_Helper_Troubleshooting::LOG_LEVEL_LOW);
|
313 |
+
$this->_log("Quote Save After Start");
|
314 |
+
|
315 |
+
Mage::getSingleton('emaildirect/session')->init();
|
316 |
+
|
317 |
+
$this->_log("Quote Save After End");
|
318 |
+
$this->_logger->resetLogLevel();
|
319 |
+
}
|
320 |
+
catch (Exception $e)
|
321 |
+
{
|
322 |
+
$this->_logger->resetLogLevel();
|
323 |
+
Mage::logException($e);
|
324 |
+
$this->_logException($e);
|
325 |
+
}
|
326 |
+
}
|
327 |
+
// END QUOTE SAVE AFTER
|
328 |
+
}
|
app/code/community/EmailDirect/Integration/Model/Configuration/Observer.php
ADDED
@@ -0,0 +1,86 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class EmailDirect_Integration_Model_Configuration_Observer extends EmailDirect_Integration_Model_Observer_Abstract
|
4 |
+
{
|
5 |
+
private function validateSource($source, $sources, $store)
|
6 |
+
{
|
7 |
+
if ($source == '')
|
8 |
+
{
|
9 |
+
$this->_logger->log("validateSource blank");
|
10 |
+
$source = "Magento";
|
11 |
+
$this->_helper->updateConfig('source', $source, $store);
|
12 |
+
}
|
13 |
+
|
14 |
+
//check if the source exist
|
15 |
+
$source_id = '';
|
16 |
+
foreach($sources as $item)
|
17 |
+
{
|
18 |
+
if($item['name']==$source)
|
19 |
+
{
|
20 |
+
$source_id = $item['id'];
|
21 |
+
break;
|
22 |
+
}
|
23 |
+
}
|
24 |
+
|
25 |
+
if ($source_id == '')
|
26 |
+
{
|
27 |
+
$rc = Mage::getSingleton('emaildirect/wrapper_sources')->addSource($source);
|
28 |
+
if(!isset($rc->SourceID))
|
29 |
+
Mage::throwException("Error adding source");
|
30 |
+
else
|
31 |
+
$this->_helper->updateConfig('sourceid', $rc->SourceID, $store);
|
32 |
+
}
|
33 |
+
else
|
34 |
+
$this->_helper->updateConfig('sourceid', $source_id, $store);
|
35 |
+
}
|
36 |
+
|
37 |
+
public function saveConfig(Varien_Event_Observer $observer)
|
38 |
+
{
|
39 |
+
$this->_logger->setLogArea(EmailDirect_Integration_Helper_Troubleshooting::CONFIG);
|
40 |
+
$this->_logger->setLogLevel(EmailDirect_Integration_Helper_Troubleshooting::LOG_LEVEL_LOW);
|
41 |
+
$store = $this->_helper->getStoreId($observer->getEvent()->getStore());
|
42 |
+
$post = Mage::app()->getRequest()->getPost();
|
43 |
+
|
44 |
+
$fields = $post['groups']['general']['fields'];
|
45 |
+
|
46 |
+
$apikey = isset($fields['apikey']['value']) ? $fields['apikey']['value'] : $this->_helper->config('apikey');
|
47 |
+
|
48 |
+
if ($apikey == '')
|
49 |
+
{
|
50 |
+
$this->_helper->updateConfig('setup', 0, $store);
|
51 |
+
$this->_helper->updateConfig('active', false, $store);
|
52 |
+
return;
|
53 |
+
}
|
54 |
+
|
55 |
+
$oldkey = $fields['old_apikey']['value'];
|
56 |
+
|
57 |
+
$sources = Mage::getSingleton('emaildirect/wrapper_sources')->getSources();
|
58 |
+
|
59 |
+
if (is_string($sources))
|
60 |
+
{
|
61 |
+
// Only mark the api key invalid if it has changed.
|
62 |
+
if ($oldkey != $apikey)
|
63 |
+
$this->_helper->updateConfig('setup', 0, $store);
|
64 |
+
$e = new Exception("Module setup failed: {$sources}");
|
65 |
+
$this->_logger->logException($e);
|
66 |
+
Mage::logException($e);
|
67 |
+
|
68 |
+
Mage::throwException($e->getMessage());
|
69 |
+
}
|
70 |
+
|
71 |
+
$this->_helper->updateConfig('setup', true, $store);
|
72 |
+
|
73 |
+
$source = isset($fields['source']['value']) ? $fields['source']['value'] : $this->_helper->config('source');
|
74 |
+
|
75 |
+
$this->validateSource($source, $sources, $store);
|
76 |
+
|
77 |
+
$force_product = false;
|
78 |
+
if (isset($fields['save_latest_order']['value']) && $fields['save_latest_order']['value'] == true)
|
79 |
+
$force_product = true;
|
80 |
+
|
81 |
+
// Verify all custom fields are present
|
82 |
+
Mage::helper('emaildirect/fields')->verifyFields($force_product);
|
83 |
+
|
84 |
+
$this->_logger->resetLogLevel();
|
85 |
+
}
|
86 |
+
}
|
app/code/community/EmailDirect/Integration/Model/Customer/Observer.php
ADDED
@@ -0,0 +1,263 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class EmailDirect_Integration_Model_Customer_Observer extends EmailDirect_Integration_Model_Observer_Abstract
|
4 |
+
{
|
5 |
+
private function hasCustomerChanged($customer)
|
6 |
+
{
|
7 |
+
$maps = unserialize( $this->_helper->config('map_fields', $customer->getStoreId()) );
|
8 |
+
|
9 |
+
$this->_log('Checking for mapped data changes');
|
10 |
+
|
11 |
+
foreach ($maps as $map)
|
12 |
+
{
|
13 |
+
$field = $map['magento'];
|
14 |
+
$original = $customer->getOrigData($field);
|
15 |
+
$current = $customer->getData($field);
|
16 |
+
|
17 |
+
$this->_log("Original: {$original} - Current: {$current}");
|
18 |
+
|
19 |
+
if ($original != $current)
|
20 |
+
return true;
|
21 |
+
}
|
22 |
+
|
23 |
+
return false;
|
24 |
+
}
|
25 |
+
|
26 |
+
protected function getMergeCustomer($object = NULL)
|
27 |
+
{
|
28 |
+
//Initialize as GUEST customer
|
29 |
+
$customer = new Varien_Object;
|
30 |
+
|
31 |
+
$this->_log("Observer Merge Vars");
|
32 |
+
|
33 |
+
$regCustomer = Mage::registry('current_customer');
|
34 |
+
$guestCustomer = Mage::registry('ed_guest_customer');
|
35 |
+
|
36 |
+
if (Mage::helper('customer')->isLoggedIn())
|
37 |
+
{
|
38 |
+
$this->_log("Logged in Customer");
|
39 |
+
$customer = Mage::helper('customer')->getCustomer();
|
40 |
+
}
|
41 |
+
else if ($regCustomer)
|
42 |
+
{
|
43 |
+
$this->_log("Current Customer");
|
44 |
+
$customer = $regCustomer;
|
45 |
+
}
|
46 |
+
else if ($guestCustomer)
|
47 |
+
{
|
48 |
+
$this->_log("Guest Customer");
|
49 |
+
$customer = $guestCustomer;
|
50 |
+
}
|
51 |
+
else
|
52 |
+
{
|
53 |
+
$this->_log("Parameter Customer");
|
54 |
+
$customer = $object;
|
55 |
+
}
|
56 |
+
|
57 |
+
$address = Mage::getModel('customer/address')->load($customer->getDefaultBilling());
|
58 |
+
if ($address)
|
59 |
+
$customer->setBillingAddress($address);
|
60 |
+
|
61 |
+
return $customer;
|
62 |
+
}
|
63 |
+
|
64 |
+
public function customerLogin(Varien_Event_Observer $observer)
|
65 |
+
{
|
66 |
+
try
|
67 |
+
{
|
68 |
+
$this->_setLogArea(EmailDirect_Integration_Helper_Troubleshooting::CUSTOMER);
|
69 |
+
$this->_log("Customer Login Start");
|
70 |
+
|
71 |
+
if (!$this->_helper->canSendLastLogin())
|
72 |
+
{
|
73 |
+
$this->_logReason($this->_helper->getLastLoginDisabledReason());
|
74 |
+
return;
|
75 |
+
}
|
76 |
+
|
77 |
+
$customer = $observer->getEvent()->getCustomer();
|
78 |
+
|
79 |
+
if (!$customer)
|
80 |
+
{
|
81 |
+
$this->_logReason("Customer not found");
|
82 |
+
return;
|
83 |
+
}
|
84 |
+
|
85 |
+
$date = date(Mage::getModel('core/date')->gmtTimestamp());
|
86 |
+
$date = date($this->_date_format, $date);
|
87 |
+
|
88 |
+
$this->_log("Last Login Date: {$date}");
|
89 |
+
|
90 |
+
$email = $customer->getEmail();
|
91 |
+
|
92 |
+
$this->_log("Email: {$email}");
|
93 |
+
|
94 |
+
Mage::getSingleton('emaildirect/wrapper_subscribers')->sendLastLogin($email, $date);
|
95 |
+
|
96 |
+
$this->_log("Customer Login End");
|
97 |
+
}
|
98 |
+
catch (Exception $e)
|
99 |
+
{
|
100 |
+
Mage::logException($e);
|
101 |
+
$this->_logException($e);
|
102 |
+
}
|
103 |
+
}
|
104 |
+
|
105 |
+
public function updateCustomer(Varien_Event_Observer $observer)
|
106 |
+
{
|
107 |
+
try
|
108 |
+
{
|
109 |
+
$this->_setLogArea(EmailDirect_Integration_Helper_Troubleshooting::CUSTOMER);
|
110 |
+
$this->_log("Update Customer Start");
|
111 |
+
|
112 |
+
if (!$this->_helper->canEdirect())
|
113 |
+
{
|
114 |
+
$this->_logReason($this->_helper->getDisabledReason());
|
115 |
+
Mage::app()->setCurrentStore($starting_store);
|
116 |
+
return;
|
117 |
+
}
|
118 |
+
|
119 |
+
$customer = $observer->getEvent()->getCustomer();
|
120 |
+
|
121 |
+
if (!$customer)
|
122 |
+
{
|
123 |
+
$this->_logReason("Customer not found");
|
124 |
+
return;
|
125 |
+
}
|
126 |
+
|
127 |
+
$customer = $this->getMergeCustomer($customer);
|
128 |
+
|
129 |
+
$merge_vars = $this->_helper->getMergeVars($customer);
|
130 |
+
|
131 |
+
$this->_log($merge_vars,"Merge Vars");
|
132 |
+
|
133 |
+
$api = Mage::getSingleton('emaildirect/wrapper_subscribers');
|
134 |
+
|
135 |
+
$oldEmail = $customer->getOrigData('email');
|
136 |
+
$email = $customer->getEmail();
|
137 |
+
|
138 |
+
if ($oldEmail == '')
|
139 |
+
{
|
140 |
+
$this->_log("Original Email was blank. Adding Subscriber");
|
141 |
+
$rc = $api->subscriberAdd($email,$merge_vars,"",false);
|
142 |
+
}
|
143 |
+
elseif ($oldEmail != $email)
|
144 |
+
{
|
145 |
+
$this->_log("Modifying Email");
|
146 |
+
|
147 |
+
// If this fails we just add the subscriber
|
148 |
+
$rc = $api->mailModify($oldEmail,$email);
|
149 |
+
|
150 |
+
$this->_log("Adding Subscriber");
|
151 |
+
$rc = $api->subscriberAdd($email,$merge_vars,"",false);
|
152 |
+
}
|
153 |
+
else
|
154 |
+
{
|
155 |
+
if ($this->hasCustomerChanged($customer))
|
156 |
+
{
|
157 |
+
$this->_log("Updating Subscriber");
|
158 |
+
$rc = $api->subscriberAdd($email,$merge_vars,"",false);
|
159 |
+
}
|
160 |
+
else
|
161 |
+
$this->_logReason("Neither Email nor Mapped Data changed");
|
162 |
+
}
|
163 |
+
|
164 |
+
$this->_log("Update Customer End");
|
165 |
+
}
|
166 |
+
catch (Exception $e)
|
167 |
+
{
|
168 |
+
Mage::logException($e);
|
169 |
+
$this->_logException($e);
|
170 |
+
}
|
171 |
+
}
|
172 |
+
|
173 |
+
public function updateCustomerAdmin(Varien_Event_Observer $observer)
|
174 |
+
{
|
175 |
+
try
|
176 |
+
{
|
177 |
+
$this->_setLogArea(EmailDirect_Integration_Helper_Troubleshooting::CUSTOMER);
|
178 |
+
$this->_log("Update Customer (Admin) Start");
|
179 |
+
|
180 |
+
$starting_store = Mage::app()->getStore()->getCode();
|
181 |
+
|
182 |
+
$customer = $observer->getEvent()->getCustomer();
|
183 |
+
|
184 |
+
if (!$customer)
|
185 |
+
{
|
186 |
+
$this->_logReason("Customer not found");
|
187 |
+
return;
|
188 |
+
}
|
189 |
+
|
190 |
+
$customer_store = $customer->getStore()->getId();
|
191 |
+
|
192 |
+
$current_store = Mage::app()->getStore()->getId();
|
193 |
+
|
194 |
+
$this->_log("Checking store");
|
195 |
+
|
196 |
+
if ($current_store == 0)
|
197 |
+
{
|
198 |
+
$this->_log("Admin store current");
|
199 |
+
if ($customer_store == 0)
|
200 |
+
{
|
201 |
+
$this->_logReason("Customer store can't be determined");
|
202 |
+
return;
|
203 |
+
}
|
204 |
+
else
|
205 |
+
Mage::app()->setCurrentStore($customer_store);
|
206 |
+
}
|
207 |
+
|
208 |
+
$this->_log("Correct store found");
|
209 |
+
|
210 |
+
if (!$this->_helper->canEdirect())
|
211 |
+
{
|
212 |
+
$this->_logReason($this->_helper->getDisabledReason());
|
213 |
+
Mage::app()->setCurrentStore($starting_store);
|
214 |
+
return;
|
215 |
+
}
|
216 |
+
|
217 |
+
$merge_vars = $this->_helper->getMergeVars($customer);
|
218 |
+
|
219 |
+
$this->_log($merge_vars,"Merge Vars");
|
220 |
+
|
221 |
+
$api = Mage::getSingleton('emaildirect/wrapper_subscribers');
|
222 |
+
|
223 |
+
$oldEmail = $customer->getOrigData('email');
|
224 |
+
$email = $customer->getEmail();
|
225 |
+
|
226 |
+
if ($oldEmail == '')
|
227 |
+
{
|
228 |
+
$this->_log("Original Email was blank. Adding Subscriber");
|
229 |
+
$rc = $api->subscriberAdd($email,$merge_vars,"",false);
|
230 |
+
}
|
231 |
+
elseif ($oldEmail != $email)
|
232 |
+
{
|
233 |
+
$this->_log("Modifying Email");
|
234 |
+
|
235 |
+
// If this fails we just add the subscriber
|
236 |
+
$rc = $api->mailModify($oldEmail,$email);
|
237 |
+
|
238 |
+
$this->_log("Adding Subscriber");
|
239 |
+
$rc = $api->subscriberAdd($email,$merge_vars,"",false);
|
240 |
+
}
|
241 |
+
else
|
242 |
+
{
|
243 |
+
if ($this->hasCustomerChanged($customer))
|
244 |
+
{
|
245 |
+
$this->_log("Updating Subscriber");
|
246 |
+
$rc = $api->subscriberAdd($email,$merge_vars,"",false);
|
247 |
+
}
|
248 |
+
else
|
249 |
+
$this->_logReason("Neither Email nor Mapped Data changed");
|
250 |
+
}
|
251 |
+
|
252 |
+
$this->_log("Update Customer End");
|
253 |
+
}
|
254 |
+
catch (Exception $e)
|
255 |
+
{
|
256 |
+
Mage::logException($e);
|
257 |
+
$this->_logException($e);
|
258 |
+
}
|
259 |
+
|
260 |
+
Mage::app()->setCurrentStore($starting_store);
|
261 |
+
return;
|
262 |
+
}
|
263 |
+
}
|
app/code/community/EmailDirect/Integration/Model/Mysql4/Abandoned/Collection.php
CHANGED
@@ -29,6 +29,14 @@ class EmailDirect_Integration_Model_Mysql4_Abandoned_Collection extends Mage_Sal
|
|
29 |
$this->addFieldToFilter('main_table.store_id', array('in' => $store_ids));
|
30 |
}
|
31 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
32 |
/**
|
33 |
* Prepare for abandoned report
|
34 |
*
|
29 |
$this->addFieldToFilter('main_table.store_id', array('in' => $store_ids));
|
30 |
}
|
31 |
|
32 |
+
public function filterByQuoteId($quote_id)
|
33 |
+
{
|
34 |
+
$this->prepareCollection(array());
|
35 |
+
$this->getSelect()->where("quote_id = {$quote_id}");
|
36 |
+
|
37 |
+
return $this;
|
38 |
+
}
|
39 |
+
|
40 |
/**
|
41 |
* Prepare for abandoned report
|
42 |
*
|
app/code/community/EmailDirect/Integration/Model/Newsletter/Observer.php
ADDED
@@ -0,0 +1,252 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class EmailDirect_Integration_Model_Newsletter_Observer extends EmailDirect_Integration_Model_Observer_Abstract
|
4 |
+
{
|
5 |
+
/**
|
6 |
+
* Handle Subscriber object saving process
|
7 |
+
*/
|
8 |
+
public function handleSubscriber(Varien_Event_Observer $observer)
|
9 |
+
{
|
10 |
+
try
|
11 |
+
{
|
12 |
+
$this->_setLogArea(EmailDirect_Integration_Helper_Troubleshooting::NEWSLETTER);
|
13 |
+
$this->_log('handleSubscriber Start');
|
14 |
+
|
15 |
+
if (!$this->_helper->canEdirect())
|
16 |
+
{
|
17 |
+
$this->_logReason($this->_helper->getDisabledReason());
|
18 |
+
return;
|
19 |
+
}
|
20 |
+
|
21 |
+
$subscriber = $observer->getEvent()->getSubscriber();
|
22 |
+
$subscriber->setImportMode(false);
|
23 |
+
|
24 |
+
$email = $subscriber->getSubscriberEmail();
|
25 |
+
$listId = $this->_helper->getDefaultPublication($subscriber->getStoreId());
|
26 |
+
$isConfirmNeed = (Mage::getStoreConfig(Mage_Newsletter_Model_Subscriber::XML_PATH_CONFIRMATION_FLAG, $subscriber->getStoreId()) == 1) ? TRUE : FALSE;
|
27 |
+
|
28 |
+
//New subscriber, just add
|
29 |
+
if ($subscriber->isObjectNew())
|
30 |
+
{
|
31 |
+
$this->_log("New Subscriber");
|
32 |
+
if (TRUE === $isConfirmNeed)
|
33 |
+
{
|
34 |
+
$this->_log("Confirmation Needed");
|
35 |
+
$subscriber->setSubscriberStatus(Mage_Newsletter_Model_Subscriber::STATUS_UNCONFIRMED);
|
36 |
+
if (!Mage::helper('customer')->isLoggedIn() && Mage::registry('ed_guest_customer'))
|
37 |
+
{
|
38 |
+
$this->_log("Guest Customer");
|
39 |
+
$guestCustomer = Mage::registry('ed_guest_customer');
|
40 |
+
$subscriber->setFirstname($guestCustomer->getFirstname());
|
41 |
+
$subscriber->setLastname($guestCustomer->getLastname());
|
42 |
+
Mage::unregister('ed_guest_customer');
|
43 |
+
$subscriber->save();
|
44 |
+
}
|
45 |
+
else
|
46 |
+
$this->_log("Not a Guest Customer (Doing Nothing?)");
|
47 |
+
}
|
48 |
+
else
|
49 |
+
{
|
50 |
+
$this->_log("Confirmation Not Required");
|
51 |
+
$subscriber->setSubscriberStatus(Mage_Newsletter_Model_Subscriber::STATUS_SUBSCRIBED);
|
52 |
+
$merge_vars = $this->_helper->getMergeVars($subscriber);
|
53 |
+
|
54 |
+
$this->_log($merge_vars,"Merge Vars");
|
55 |
+
|
56 |
+
$rc = Mage::getSingleton('emaildirect/wrapper_subscribers')
|
57 |
+
->subscriberAdd($email,$merge_vars);
|
58 |
+
}
|
59 |
+
}
|
60 |
+
else
|
61 |
+
{
|
62 |
+
$this->_log("Existing Subscriber");
|
63 |
+
$status = (int)$subscriber->getData('subscriber_status');
|
64 |
+
|
65 |
+
$oldSubscriber = Mage::getModel('newsletter/subscriber')
|
66 |
+
->load($subscriber->getId());
|
67 |
+
$oldstatus = (int)$oldSubscriber->getOrigData('subscriber_status');
|
68 |
+
if ($oldstatus == Mage_Newsletter_Model_Subscriber::STATUS_UNCONFIRMED && $status == Mage_Newsletter_Model_Subscriber::STATUS_SUBSCRIBED)
|
69 |
+
{
|
70 |
+
$this->_log("Unconfirmed to Subscribed");
|
71 |
+
$subscriber->setSubscriberStatus(Mage_Newsletter_Model_Subscriber::STATUS_SUBSCRIBED);
|
72 |
+
$merge_vars = $this->_helper->getMergeVars($subscriber);
|
73 |
+
|
74 |
+
$this->_log($merge_vars,"Merge Vars");
|
75 |
+
$rc = Mage::getSingleton('emaildirect/wrapper_subscribers')
|
76 |
+
->subscriberAdd($email,$merge_vars);
|
77 |
+
}
|
78 |
+
elseif( $status !== $oldstatus )
|
79 |
+
{
|
80 |
+
//Status change
|
81 |
+
$this->_log("Status Change");
|
82 |
+
|
83 |
+
//Unsubscribe customer
|
84 |
+
if($status == Mage_Newsletter_Model_Subscriber::STATUS_UNSUBSCRIBED)
|
85 |
+
{
|
86 |
+
$this->_log("Unsubscribed");
|
87 |
+
$rc = Mage::getSingleton('emaildirect/wrapper_publications')
|
88 |
+
->unsubscribe($listId, $email);
|
89 |
+
}
|
90 |
+
else if($status == Mage_Newsletter_Model_Subscriber::STATUS_SUBSCRIBED)
|
91 |
+
{
|
92 |
+
$this->_log("Subscribed");
|
93 |
+
if( $oldstatus == Mage_Newsletter_Model_Subscriber::STATUS_NOT_ACTIVE || $oldstatus == Mage_Newsletter_Model_Subscriber::STATUS_UNSUBSCRIBED )
|
94 |
+
{
|
95 |
+
$this->_log("Changing Status");
|
96 |
+
$rc = Mage::getSingleton('emaildirect/wrapper_publications')
|
97 |
+
->subscribe($listId, $email);
|
98 |
+
}
|
99 |
+
else
|
100 |
+
$this->_log("Status Not Changed");
|
101 |
+
}
|
102 |
+
}
|
103 |
+
}
|
104 |
+
$this->_log('handleSubscriber End');
|
105 |
+
}
|
106 |
+
catch (Exception $e)
|
107 |
+
{
|
108 |
+
Mage::logException($e);
|
109 |
+
$this->_logException($e);
|
110 |
+
}
|
111 |
+
}
|
112 |
+
|
113 |
+
// Remove Unsubscribe option from Newsletter grid
|
114 |
+
public function updateNewsletterMassAction($observer)
|
115 |
+
{
|
116 |
+
try
|
117 |
+
{
|
118 |
+
if (!$this->_helper->canEdirect())
|
119 |
+
return;
|
120 |
+
|
121 |
+
$block = $observer->getEvent()->getBlock();
|
122 |
+
|
123 |
+
if (get_class($block) =='Mage_Adminhtml_Block_Widget_Grid_Massaction'
|
124 |
+
&& $block->getRequest()->getControllerName() == 'newsletter_subscriber')
|
125 |
+
{
|
126 |
+
$block->removeItem('unsubscribe');
|
127 |
+
}
|
128 |
+
}
|
129 |
+
catch (Exception $e)
|
130 |
+
{
|
131 |
+
Mage::logException($e);
|
132 |
+
$this->_logException($e);
|
133 |
+
}
|
134 |
+
}
|
135 |
+
|
136 |
+
/**
|
137 |
+
* Handle Subscriber deletion from Magento, unsubcribes email
|
138 |
+
* and sends the delete_member flag so the subscriber gets deleted.
|
139 |
+
*/
|
140 |
+
public function handleSubscriberDeletion(Varien_Event_Observer $observer)
|
141 |
+
{
|
142 |
+
try
|
143 |
+
{
|
144 |
+
$this->_setLogArea(EmailDirect_Integration_Helper_Troubleshooting::NEWSLETTER);
|
145 |
+
$this->_log("Handle Subscriber Deletion Start");
|
146 |
+
|
147 |
+
if (!$this->_helper->canEdirect())
|
148 |
+
{
|
149 |
+
$this->_logReason($this->_helper->getDisabledReason());
|
150 |
+
return;
|
151 |
+
}
|
152 |
+
|
153 |
+
$subscriber = $observer->getEvent()->getSubscriber();
|
154 |
+
|
155 |
+
$email = $subscriber->getSubscriberEmail();
|
156 |
+
|
157 |
+
$rc = Mage::getSingleton('emaildirect/wrapper_subscribers')
|
158 |
+
->subscriberDelete($email);
|
159 |
+
|
160 |
+
$this->_log("Handle Subscriber Deletion End");
|
161 |
+
}
|
162 |
+
catch (Exception $e)
|
163 |
+
{
|
164 |
+
Mage::logException($e);
|
165 |
+
$this->_logException($e);
|
166 |
+
}
|
167 |
+
}
|
168 |
+
|
169 |
+
public function registerCheckoutSubscribe(Varien_Event_Observer $observer)
|
170 |
+
{
|
171 |
+
try
|
172 |
+
{
|
173 |
+
$this->_setLogArea(EmailDirect_Integration_Helper_Troubleshooting::NEWSLETTER);
|
174 |
+
$this->_log("Register Checkout Subscribe Start");
|
175 |
+
if (!$this->_helper->canEdirect())
|
176 |
+
{
|
177 |
+
$this->_logReason($this->_helper->getDisabledReason());
|
178 |
+
return;
|
179 |
+
}
|
180 |
+
$subscribe = Mage::app()->getRequest()->getPost('emaildirect_subscribe');
|
181 |
+
|
182 |
+
if (!is_null($subscribe) || $this->_helper->forceSubscribe())
|
183 |
+
Mage::getSingleton('core/session')->setEmaildirectCheckout($subscribe);
|
184 |
+
|
185 |
+
$this->_log("Register Checkout Subscribe End");
|
186 |
+
}
|
187 |
+
catch (Exception $e)
|
188 |
+
{
|
189 |
+
Mage::logException($e);
|
190 |
+
$this->_logException($e);
|
191 |
+
}
|
192 |
+
}
|
193 |
+
|
194 |
+
/**
|
195 |
+
* Subscribe customer to Newsletter if flag on session is present
|
196 |
+
*/
|
197 |
+
public function registerCheckoutSuccess(Varien_Event_Observer $observer)
|
198 |
+
{
|
199 |
+
try
|
200 |
+
{
|
201 |
+
$this->_setLogArea(EmailDirect_Integration_Helper_Troubleshooting::NEWSLETTER);
|
202 |
+
$this->_log("Register Checkout Success Start");
|
203 |
+
|
204 |
+
if (!$this->_helper->canEdirect())
|
205 |
+
{
|
206 |
+
$this->_logReason($this->_helper->getDisabledReason());
|
207 |
+
return;
|
208 |
+
}
|
209 |
+
|
210 |
+
$sessionFlag = Mage::getSingleton('core/session')->getEmaildirectCheckout(TRUE);
|
211 |
+
if (!$sessionFlag && !$this->_helper->forceSubscribe())
|
212 |
+
{
|
213 |
+
$this->_logReason("Session flag not found.");
|
214 |
+
return;
|
215 |
+
}
|
216 |
+
|
217 |
+
$order_id = (int)current($observer->getEvent()->getOrderIds());
|
218 |
+
|
219 |
+
if (!$order_id)
|
220 |
+
{
|
221 |
+
$this->_logReason("Order ID not found.");
|
222 |
+
return;
|
223 |
+
}
|
224 |
+
|
225 |
+
$order = Mage::getModel('sales/order')->load($order_id);
|
226 |
+
if (!$order->getId())
|
227 |
+
{
|
228 |
+
$this->_logReason("Failed to Load Order ({$order_id}).");
|
229 |
+
return;
|
230 |
+
}
|
231 |
+
|
232 |
+
$this->_log("Processing Order # " . $order->getIncrementId());
|
233 |
+
|
234 |
+
//Guest Checkout
|
235 |
+
if ((int)$order->getCustomerGroupId() === Mage_Customer_Model_Group::NOT_LOGGED_IN_ID )
|
236 |
+
{
|
237 |
+
$this->_log("Guest Checkout");
|
238 |
+
$this->_helper->registerGuestCustomer($order);
|
239 |
+
}
|
240 |
+
|
241 |
+
$subscriber = Mage::getModel('newsletter/subscriber')
|
242 |
+
->subscribe($order->getCustomerEmail());
|
243 |
+
|
244 |
+
$this->_log("Register Checkout Success End");
|
245 |
+
}
|
246 |
+
catch (Exception $e)
|
247 |
+
{
|
248 |
+
Mage::logException($e);
|
249 |
+
$this->_logException($e);
|
250 |
+
}
|
251 |
+
}
|
252 |
+
}
|
app/code/community/EmailDirect/Integration/Model/Observer.php
CHANGED
@@ -1,63 +1,7 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
class EmailDirect_Integration_Model_Observer
|
4 |
{
|
5 |
-
const ABANDONED_LAST_RUN = 'emaildirect/general/abandoned_last_run';
|
6 |
-
|
7 |
-
private $_helper = null;
|
8 |
-
private $_sequences = null;
|
9 |
-
private $_current_sequence = 0;
|
10 |
-
private $_sequence_enabled = false;
|
11 |
-
private $_sequence_field = "";
|
12 |
-
|
13 |
-
private $_date_format = "Y-m-d H:i:s";
|
14 |
-
|
15 |
-
public function __construct()
|
16 |
-
{
|
17 |
-
$this->_helper = Mage::helper('emaildirect');
|
18 |
-
}
|
19 |
-
|
20 |
-
public function customerLogin(Varien_Event_Observer $observer)
|
21 |
-
{
|
22 |
-
try
|
23 |
-
{
|
24 |
-
$this->_helper->setLogArea(EmailDirect_Integration_Helper_Data::CUSTOMER);
|
25 |
-
$this->_helper->log("Customer Login Start");
|
26 |
-
|
27 |
-
if (!$this->_helper->canSendLastLogin())
|
28 |
-
{
|
29 |
-
$this->_helper->logReason($this->_helper->getLastLoginDisabledReason());
|
30 |
-
return;
|
31 |
-
}
|
32 |
-
|
33 |
-
$customer = $observer->getEvent()->getCustomer();
|
34 |
-
|
35 |
-
if (!$customer)
|
36 |
-
{
|
37 |
-
$this->_helper->logReason("Customer not found");
|
38 |
-
return;
|
39 |
-
}
|
40 |
-
|
41 |
-
$date = date(Mage::getModel('core/date')->gmtTimestamp());
|
42 |
-
$date = date($this->_date_format, $date);
|
43 |
-
|
44 |
-
$this->_helper->log("Last Login Date: {$date}");
|
45 |
-
|
46 |
-
$email = $customer->getEmail();
|
47 |
-
|
48 |
-
$this->_helper->log("Email: {$email}");
|
49 |
-
|
50 |
-
Mage::getSingleton('emaildirect/wrapper_subscribers')->sendLastLogin($email, $date);
|
51 |
-
|
52 |
-
$this->_helper->log("Customer Login End");
|
53 |
-
}
|
54 |
-
catch (Exception $e)
|
55 |
-
{
|
56 |
-
Mage::logException($e);
|
57 |
-
$this->_helper->logException($e);
|
58 |
-
}
|
59 |
-
}
|
60 |
-
|
61 |
//--------------------------------------------------------------------------------------------------
|
62 |
// WISHLIST
|
63 |
|
@@ -65,13 +9,13 @@ class EmailDirect_Integration_Model_Observer
|
|
65 |
{
|
66 |
try
|
67 |
{
|
68 |
-
$this->
|
69 |
-
//$this->_helper->setLogLevel(
|
70 |
-
$this->
|
71 |
|
72 |
if (!$this->_helper->canSendWishlist())
|
73 |
{
|
74 |
-
$this->
|
75 |
return;
|
76 |
}
|
77 |
|
@@ -79,1704 +23,20 @@ class EmailDirect_Integration_Model_Observer
|
|
79 |
|
80 |
$merge_vars = array(
|
81 |
'WishListUrl' => Mage::getUrl('wishlist'),
|
82 |
-
'WishListDate' => Mage::getModel('core/date')->date(
|
83 |
);
|
84 |
|
85 |
$rc = Mage::getSingleton('emaildirect/wrapper_wishlist')->sendWishlist($customer->getEmail(), $merge_vars);
|
86 |
|
87 |
-
$this->
|
88 |
}
|
89 |
catch (Exception $e)
|
90 |
{
|
91 |
Mage::logException($e);
|
92 |
-
$this->
|
93 |
}
|
94 |
}
|
95 |
|
96 |
// WISHLIST END
|
97 |
//--------------------------------------------------------------------------------------------------
|
98 |
-
|
99 |
-
/**
|
100 |
-
* Handle Subscriber object saving process
|
101 |
-
*/
|
102 |
-
public function handleSubscriber(Varien_Event_Observer $observer)
|
103 |
-
{
|
104 |
-
try
|
105 |
-
{
|
106 |
-
$this->_helper->setLogArea(EmailDirect_Integration_Helper_Data::NEWSLETTER);
|
107 |
-
$this->_helper->log('handleSubscriber Start');
|
108 |
-
|
109 |
-
if (!$this->_helper->canEdirect())
|
110 |
-
{
|
111 |
-
$this->_helper->logReason($this->_helper->getDisabledReason());
|
112 |
-
return;
|
113 |
-
}
|
114 |
-
|
115 |
-
$subscriber = $observer->getEvent()->getSubscriber();
|
116 |
-
$subscriber->setImportMode(false);
|
117 |
-
|
118 |
-
$email = $subscriber->getSubscriberEmail();
|
119 |
-
$listId = $this->_helper->getDefaultPublication($subscriber->getStoreId());
|
120 |
-
$isConfirmNeed = (Mage::getStoreConfig(Mage_Newsletter_Model_Subscriber::XML_PATH_CONFIRMATION_FLAG, $subscriber->getStoreId()) == 1) ? TRUE : FALSE;
|
121 |
-
|
122 |
-
//New subscriber, just add
|
123 |
-
if( $subscriber->isObjectNew() )
|
124 |
-
{
|
125 |
-
$this->_helper->log("New Subscriber");
|
126 |
-
if( TRUE === $isConfirmNeed )
|
127 |
-
{
|
128 |
-
$this->_helper->log("Confirmation Needed");
|
129 |
-
$subscriber->setSubscriberStatus(Mage_Newsletter_Model_Subscriber::STATUS_UNCONFIRMED);
|
130 |
-
if( !Mage::helper('customer')->isLoggedIn() && Mage::registry('ed_guest_customer'))
|
131 |
-
{
|
132 |
-
$this->_helper->log("Guest Customer");
|
133 |
-
$guestCustomer = Mage::registry('ed_guest_customer');
|
134 |
-
$subscriber->setFirstname($guestCustomer->getFirstname());
|
135 |
-
$subscriber->setLastname($guestCustomer->getLastname());
|
136 |
-
Mage::unregister('ed_guest_customer');
|
137 |
-
$subscriber->save();
|
138 |
-
}
|
139 |
-
else
|
140 |
-
$this->_helper->log("Not a Guest Customer (Doing Nothing?)");
|
141 |
-
}
|
142 |
-
else
|
143 |
-
{
|
144 |
-
$this->_helper->log("Confirmation Not Required");
|
145 |
-
$subscriber->setSubscriberStatus(Mage_Newsletter_Model_Subscriber::STATUS_SUBSCRIBED);
|
146 |
-
$merge_vars = $this->_mergeVars($subscriber);
|
147 |
-
|
148 |
-
$this->_helper->log($merge_vars,"Merge Vars");
|
149 |
-
|
150 |
-
$rc = Mage::getSingleton('emaildirect/wrapper_subscribers')
|
151 |
-
->subscriberAdd($email,$merge_vars);
|
152 |
-
}
|
153 |
-
}
|
154 |
-
else
|
155 |
-
{
|
156 |
-
$this->_helper->log("Existing Subscriber");
|
157 |
-
$status = (int)$subscriber->getData('subscriber_status');
|
158 |
-
|
159 |
-
$oldSubscriber = Mage::getModel('newsletter/subscriber')
|
160 |
-
->load($subscriber->getId());
|
161 |
-
$oldstatus = (int)$oldSubscriber->getOrigData('subscriber_status');
|
162 |
-
if ($oldstatus == Mage_Newsletter_Model_Subscriber::STATUS_UNCONFIRMED && $status == Mage_Newsletter_Model_Subscriber::STATUS_SUBSCRIBED)
|
163 |
-
{
|
164 |
-
$this->_helper->log("Unconfirmed to Subscribed");
|
165 |
-
$subscriber->setSubscriberStatus(Mage_Newsletter_Model_Subscriber::STATUS_SUBSCRIBED);
|
166 |
-
$merge_vars = $this->_mergeVars($subscriber);
|
167 |
-
|
168 |
-
$this->_helper->log($merge_vars,"Merge Vars");
|
169 |
-
$rc = Mage::getSingleton('emaildirect/wrapper_subscribers')
|
170 |
-
->subscriberAdd($email,$merge_vars);
|
171 |
-
}
|
172 |
-
elseif( $status !== $oldstatus )
|
173 |
-
{
|
174 |
-
//Status change
|
175 |
-
$this->_helper->log("Status Change");
|
176 |
-
|
177 |
-
//Unsubscribe customer
|
178 |
-
if($status == Mage_Newsletter_Model_Subscriber::STATUS_UNSUBSCRIBED)
|
179 |
-
{
|
180 |
-
$this->_helper->log("Unsubscribed");
|
181 |
-
$rc = Mage::getSingleton('emaildirect/wrapper_publications')
|
182 |
-
->unsubscribe($listId, $email);
|
183 |
-
}
|
184 |
-
else if($status == Mage_Newsletter_Model_Subscriber::STATUS_SUBSCRIBED)
|
185 |
-
{
|
186 |
-
$this->_helper->log("Subscribed");
|
187 |
-
if( $oldstatus == Mage_Newsletter_Model_Subscriber::STATUS_NOT_ACTIVE || $oldstatus == Mage_Newsletter_Model_Subscriber::STATUS_UNSUBSCRIBED )
|
188 |
-
{
|
189 |
-
$this->_helper->log("Changing Status");
|
190 |
-
$rc = Mage::getSingleton('emaildirect/wrapper_publications')
|
191 |
-
->subscribe($listId, $email);
|
192 |
-
}
|
193 |
-
else
|
194 |
-
$this->_helper->log("Status Not Changed");
|
195 |
-
}
|
196 |
-
}
|
197 |
-
}
|
198 |
-
$this->_helper->log('handleSubscriber End');
|
199 |
-
}
|
200 |
-
catch (Exception $e)
|
201 |
-
{
|
202 |
-
Mage::logException($e);
|
203 |
-
$this->_helper->logException($e);
|
204 |
-
}
|
205 |
-
}
|
206 |
-
|
207 |
-
// Remove Unsubscribe option from Newsletter grid
|
208 |
-
public function updateNewsletterMassAction($observer)
|
209 |
-
{
|
210 |
-
try
|
211 |
-
{
|
212 |
-
if (!$this->_helper->canEdirect())
|
213 |
-
return;
|
214 |
-
|
215 |
-
$block = $observer->getEvent()->getBlock();
|
216 |
-
|
217 |
-
if (get_class($block) =='Mage_Adminhtml_Block_Widget_Grid_Massaction'
|
218 |
-
&& $block->getRequest()->getControllerName() == 'newsletter_subscriber')
|
219 |
-
{
|
220 |
-
$block->removeItem('unsubscribe');
|
221 |
-
}
|
222 |
-
}
|
223 |
-
catch (Exception $e)
|
224 |
-
{
|
225 |
-
Mage::logException($e);
|
226 |
-
$this->_helper->logException($e);
|
227 |
-
}
|
228 |
-
}
|
229 |
-
|
230 |
-
/**
|
231 |
-
* Handle Subscriber deletion from Magento, unsubcribes email
|
232 |
-
* and sends the delete_member flag so the subscriber gets deleted.
|
233 |
-
*/
|
234 |
-
public function handleSubscriberDeletion(Varien_Event_Observer $observer)
|
235 |
-
{
|
236 |
-
try
|
237 |
-
{
|
238 |
-
$this->_helper->setLogArea(EmailDirect_Integration_Helper_Data::NEWSLETTER);
|
239 |
-
$this->_helper->log("Handle Subscriber Deletion Start");
|
240 |
-
|
241 |
-
if (!$this->_helper->canEdirect())
|
242 |
-
{
|
243 |
-
$this->_helper->logReason($this->_helper->getDisabledReason());
|
244 |
-
return;
|
245 |
-
}
|
246 |
-
|
247 |
-
$subscriber = $observer->getEvent()->getSubscriber();
|
248 |
-
|
249 |
-
$email = $subscriber->getSubscriberEmail();
|
250 |
-
|
251 |
-
$rc = Mage::getSingleton('emaildirect/wrapper_subscribers')
|
252 |
-
->subscriberDelete($email);
|
253 |
-
|
254 |
-
$this->_helper->log("Handle Subscriber Deletion End");
|
255 |
-
}
|
256 |
-
catch (Exception $e)
|
257 |
-
{
|
258 |
-
Mage::logException($e);
|
259 |
-
$this->_helper->logException($e);
|
260 |
-
}
|
261 |
-
}
|
262 |
-
|
263 |
-
private function validateSource($source, $sources, $store)
|
264 |
-
{
|
265 |
-
if ($source == '')
|
266 |
-
{
|
267 |
-
$this->_helper->log("validateSource blank");
|
268 |
-
$source = "Magento";
|
269 |
-
$this->_helper->updateConfig('source', $source, $store);
|
270 |
-
}
|
271 |
-
|
272 |
-
//check if the source exist
|
273 |
-
$source_id = '';
|
274 |
-
foreach($sources as $item)
|
275 |
-
{
|
276 |
-
if($item['name']==$source)
|
277 |
-
{
|
278 |
-
$source_id = $item['id'];
|
279 |
-
break;
|
280 |
-
}
|
281 |
-
}
|
282 |
-
|
283 |
-
if ($source_id == '')
|
284 |
-
{
|
285 |
-
$rc = Mage::getSingleton('emaildirect/wrapper_sources')->addSource($source);
|
286 |
-
if(!isset($rc->SourceID))
|
287 |
-
Mage::throwException("Error adding source");
|
288 |
-
else
|
289 |
-
$this->_helper->updateConfig('sourceid', $rc->SourceID, $store);
|
290 |
-
}
|
291 |
-
else
|
292 |
-
$this->_helper->updateConfig('sourceid', $source_id, $store);
|
293 |
-
}
|
294 |
-
|
295 |
-
private function saveTroubleshooting($store)
|
296 |
-
{
|
297 |
-
$post = Mage::app()->getRequest()->getPost();
|
298 |
-
|
299 |
-
$enabled = $post['groups']['troubleshooting']['fields']['enabled'];
|
300 |
-
|
301 |
-
if (isset($enabled['inherit']))
|
302 |
-
{
|
303 |
-
$inherit = $enabled['inherit'];
|
304 |
-
|
305 |
-
if ($inherit == 1)
|
306 |
-
return $this->_helper->eraseTroubleshooting($store);
|
307 |
-
}
|
308 |
-
$status = $post['groups']['troubleshooting']['fields']['enabled']['value'];
|
309 |
-
|
310 |
-
if ($status)
|
311 |
-
$this->_helper->turnOnTroubleshooting($store);
|
312 |
-
else
|
313 |
-
$this->_helper->turnOffTroubleshooting($store);
|
314 |
-
}
|
315 |
-
|
316 |
-
public function saveConfig(Varien_Event_Observer $observer)
|
317 |
-
{
|
318 |
-
$this->_helper->setLogArea(EmailDirect_Integration_Helper_Data::CONFIG);
|
319 |
-
$this->_helper->setLogLevel(EmailDirect_Integration_Helper_Data::LOG_LEVEL_LOW);
|
320 |
-
$store = $this->_helper->getStoreId($observer->getEvent()->getStore());
|
321 |
-
$post = Mage::app()->getRequest()->getPost();
|
322 |
-
|
323 |
-
$this->saveTroubleshooting($store);
|
324 |
-
|
325 |
-
$fields = $post['groups']['general']['fields'];
|
326 |
-
|
327 |
-
$apiKey = isset($fields['apikey']['value']) ? $fields['apikey']['value'] : $this->_helper->config('apikey');
|
328 |
-
|
329 |
-
if ($apiKey == '')
|
330 |
-
{
|
331 |
-
$this->_helper->updateConfig('setup', 0, $store);
|
332 |
-
$this->_helper->updateConfig('active', false, $store);
|
333 |
-
return;
|
334 |
-
}
|
335 |
-
|
336 |
-
$sources = Mage::getSingleton('emaildirect/wrapper_sources')->getSources();
|
337 |
-
|
338 |
-
if (is_string($sources))
|
339 |
-
{
|
340 |
-
$this->_helper->updateConfig('setup', 0, $store);
|
341 |
-
$e = new Exception("Module setup failed: {$sources}");
|
342 |
-
$this->_helper->logException($e);
|
343 |
-
Mage::logException($e);
|
344 |
-
|
345 |
-
Mage::throwException($e->getMessage());
|
346 |
-
}
|
347 |
-
|
348 |
-
$this->_helper->updateConfig('setup', true, $store);
|
349 |
-
|
350 |
-
$source = isset($fields['source']['value']) ? $fields['source']['value'] : $this->_helper->config('source');
|
351 |
-
|
352 |
-
$this->validateSource($source, $sources, $store);
|
353 |
-
|
354 |
-
$force_product = false;
|
355 |
-
if (isset($fields['save_latest_order']['value']) && $fields['save_latest_order']['value'] == true)
|
356 |
-
$force_product = true;
|
357 |
-
|
358 |
-
// Verify all custom fields are present
|
359 |
-
Mage::helper('emaildirect/fields')->verifyFields($force_product);
|
360 |
-
|
361 |
-
$this->_helper->resetLogLevel();
|
362 |
-
}
|
363 |
-
|
364 |
-
public function _mergeVars($object = NULL)
|
365 |
-
{
|
366 |
-
//Initialize as GUEST customer
|
367 |
-
$customer = new Varien_Object;
|
368 |
-
|
369 |
-
$this->_helper->log("Observer Merge Vars");
|
370 |
-
|
371 |
-
$regCustomer = Mage::registry('current_customer');
|
372 |
-
$guestCustomer = Mage::registry('ed_guest_customer');
|
373 |
-
|
374 |
-
if (Mage::helper('customer')->isLoggedIn())
|
375 |
-
{
|
376 |
-
$this->_helper->log("Logged in Customer");
|
377 |
-
$customer = Mage::helper('customer')->getCustomer();
|
378 |
-
}
|
379 |
-
else if ($regCustomer)
|
380 |
-
{
|
381 |
-
$this->_helper->log("Current Customer");
|
382 |
-
$customer = $regCustomer;
|
383 |
-
}
|
384 |
-
else if ($guestCustomer)
|
385 |
-
{
|
386 |
-
$this->_helper->log("Guest Customer");
|
387 |
-
$customer = $guestCustomer;
|
388 |
-
}
|
389 |
-
else
|
390 |
-
{
|
391 |
-
$this->_helper->log("Parameter Customer");
|
392 |
-
$customer = $object;
|
393 |
-
}
|
394 |
-
|
395 |
-
$address = Mage::getModel('customer/address')->load($customer->getDefaultBilling());
|
396 |
-
if ($address)
|
397 |
-
$customer->setBillingAddress($address);
|
398 |
-
|
399 |
-
$merge_vars = $this->_helper->getMergeVars($customer);
|
400 |
-
|
401 |
-
return $merge_vars;
|
402 |
-
}
|
403 |
-
|
404 |
-
private function getParentOptions($parent_product,$product_id)
|
405 |
-
{
|
406 |
-
$parent_options = $this->_helper->getConfigurableOptions($parent_product,$product_id);
|
407 |
-
|
408 |
-
if (count($parent_options) == 0)
|
409 |
-
return "";
|
410 |
-
|
411 |
-
$options = "";
|
412 |
-
|
413 |
-
foreach ($parent_options as $key => $value)
|
414 |
-
{
|
415 |
-
if ($options == "")
|
416 |
-
$options .= "#";
|
417 |
-
else
|
418 |
-
$options .= "&";
|
419 |
-
|
420 |
-
$options .= "{$key}={$value}";
|
421 |
-
}
|
422 |
-
|
423 |
-
return $options;
|
424 |
-
}
|
425 |
-
|
426 |
-
private function getGroupedPrice($grouped_product)
|
427 |
-
{
|
428 |
-
$min = 0;
|
429 |
-
$products = $grouped_product->getTypeInstance()->getAssociatedProducts();
|
430 |
-
foreach ($products as $product)
|
431 |
-
{
|
432 |
-
if ($min == 0)
|
433 |
-
$min = $product->getPrice();
|
434 |
-
|
435 |
-
$min = min($min, $product->getPrice());
|
436 |
-
}
|
437 |
-
|
438 |
-
return $min;
|
439 |
-
}
|
440 |
-
|
441 |
-
private function getProductImage($product, $parent_product = null)
|
442 |
-
{
|
443 |
-
try
|
444 |
-
{
|
445 |
-
$image = "";
|
446 |
-
if ($product->getImage() == 'no_selection' || $product->getImage() == "")
|
447 |
-
{
|
448 |
-
if ($parent_product != null && $parent_product->getImage() != "no_selection" && $parent_product->getImage() != "")
|
449 |
-
$image = Mage::getModel('catalog/product_media_config')->getMediaUrl($parent_product->getImage());
|
450 |
-
}
|
451 |
-
else
|
452 |
-
$image = Mage::getModel('catalog/product_media_config')->getMediaUrl($product->getImage());
|
453 |
-
}
|
454 |
-
catch (Exception $e)
|
455 |
-
{
|
456 |
-
Mage::logException($e);
|
457 |
-
$this->_helper->logException($e);
|
458 |
-
}
|
459 |
-
|
460 |
-
return $image;
|
461 |
-
}
|
462 |
-
|
463 |
-
private function addMergeItem($item_data, $pos, $merge_vars, $prefix = "")
|
464 |
-
{
|
465 |
-
$name = "";
|
466 |
-
$parent_name = "";
|
467 |
-
$sku = "";
|
468 |
-
$url = "";
|
469 |
-
$image = "";
|
470 |
-
$cost = "";
|
471 |
-
$description = "";
|
472 |
-
$parent_item = null;
|
473 |
-
$parent_product = null;
|
474 |
-
|
475 |
-
if ($item_data != null)
|
476 |
-
{
|
477 |
-
$product_id = 0;
|
478 |
-
|
479 |
-
if (is_array($item_data))
|
480 |
-
{
|
481 |
-
$item = $item_data['item'];
|
482 |
-
|
483 |
-
if (isset($item_data['parent']))
|
484 |
-
$parent_item = $item_data['parent'];
|
485 |
-
}
|
486 |
-
else
|
487 |
-
$item = $item_data;
|
488 |
-
|
489 |
-
if (is_string($item))
|
490 |
-
{
|
491 |
-
$product_id = $item;
|
492 |
-
|
493 |
-
$product = Mage::getModel('catalog/product')->load($product_id);
|
494 |
-
|
495 |
-
if ($product == null || !$product->getId())
|
496 |
-
return $merge_vars;
|
497 |
-
}
|
498 |
-
else
|
499 |
-
{
|
500 |
-
$product = $this->getProduct($item);
|
501 |
-
if ($product == null)
|
502 |
-
return $merge_vars; // Can't get product so abort
|
503 |
-
}
|
504 |
-
|
505 |
-
if ($parent_item != null)
|
506 |
-
{
|
507 |
-
$parent_product = $this->getProduct($parent_item);
|
508 |
-
if ($parent_product == null)
|
509 |
-
return $merge_vars; // Can't get product so abort
|
510 |
-
|
511 |
-
$parent_name = $parent_product->getName();
|
512 |
-
$url = $parent_product->getProductUrl();
|
513 |
-
|
514 |
-
if ($parent_product->getTypeId() == 'configurable')
|
515 |
-
$url .= $this->getParentOptions($parent_product,$product_id);
|
516 |
-
}
|
517 |
-
else
|
518 |
-
$url = $product->getProductUrl();
|
519 |
-
|
520 |
-
$name = $product->getName();
|
521 |
-
$sku = $product->getSku();
|
522 |
-
|
523 |
-
$image = $this->getProductImage($product, $parent_product);
|
524 |
-
|
525 |
-
if (is_string($item))
|
526 |
-
{
|
527 |
-
if ($product->getTypeId() == 'grouped')
|
528 |
-
$cost = $this->getGroupedPrice($product);
|
529 |
-
else
|
530 |
-
$cost = $product->getPrice();
|
531 |
-
}
|
532 |
-
else
|
533 |
-
$cost = $item->getPrice();
|
534 |
-
|
535 |
-
$cost = Mage::helper('core')->currency($cost,true,false);
|
536 |
-
$description = $product->getShortDescription();
|
537 |
-
}
|
538 |
-
|
539 |
-
$merge_vars["{$prefix}ProductName{$pos}"] = $name;
|
540 |
-
if ($prefix != 'Related')
|
541 |
-
$merge_vars["{$prefix}ParentName{$pos}"] = $parent_name;
|
542 |
-
|
543 |
-
$merge_vars["{$prefix}SKU{$pos}"] = $sku;
|
544 |
-
$merge_vars["{$prefix}URL{$pos}"] = $url;
|
545 |
-
$merge_vars["{$prefix}Image{$pos}"] = $image;
|
546 |
-
|
547 |
-
$merge_vars["{$prefix}Cost{$pos}"] = $cost;
|
548 |
-
$merge_vars["{$prefix}Description{$pos}"] = $description;
|
549 |
-
|
550 |
-
return $merge_vars;
|
551 |
-
}
|
552 |
-
|
553 |
-
private function getRelatedCollection($id_list, $max_count, $grouped_id_list = null)
|
554 |
-
{
|
555 |
-
$collection = Mage::getModel('catalog/product_link')
|
556 |
-
->useRelatedLinks()
|
557 |
-
->getCollection()
|
558 |
-
->addFieldToFilter('product_id', array('in' => $id_list))
|
559 |
-
;
|
560 |
-
|
561 |
-
// Filter on grouped products as well
|
562 |
-
if ($grouped_id_list != null)
|
563 |
-
$id_list = array_merge($id_list,$grouped_id_list);
|
564 |
-
|
565 |
-
$product_ids = array();
|
566 |
-
|
567 |
-
foreach ($collection as $rp)
|
568 |
-
{
|
569 |
-
$lp_id = $rp['linked_product_id'];
|
570 |
-
if (!in_array($lp_id,$id_list))
|
571 |
-
$product_ids[] = $lp_id;
|
572 |
-
}
|
573 |
-
|
574 |
-
$related = Mage::getResourceModel('catalog/product_collection')
|
575 |
-
->addFieldToFilter('entity_id', array('in' => $product_ids))
|
576 |
-
->setPageSize($max_count);
|
577 |
-
|
578 |
-
Mage::getSingleton('catalog/product_visibility')->addVisibleInCatalogFilterToCollection($related);
|
579 |
-
|
580 |
-
$related_list = array();
|
581 |
-
|
582 |
-
if (count($related) > 0)
|
583 |
-
{
|
584 |
-
foreach ($related as $rp)
|
585 |
-
{
|
586 |
-
$related_list[] = $rp;
|
587 |
-
}
|
588 |
-
}
|
589 |
-
|
590 |
-
return $related_list;
|
591 |
-
}
|
592 |
-
|
593 |
-
private function getRelatedProducts($quote)
|
594 |
-
{
|
595 |
-
$id_list = array();
|
596 |
-
$grouped_id_list = array();
|
597 |
-
$filter_id_list = array();
|
598 |
-
|
599 |
-
foreach ($quote->getAllItems() as $item)
|
600 |
-
{
|
601 |
-
// if it is a grouped product get the parent ID and add it to the list (if not already added)
|
602 |
-
if ($item->getProductType() == 'grouped')
|
603 |
-
{
|
604 |
-
$grouped_product_id = $this->getGroupedProductId($item);
|
605 |
-
|
606 |
-
if (!in_array($grouped_product_id, $grouped_id_list))
|
607 |
-
$grouped_id_list[] = $grouped_product_id;
|
608 |
-
}
|
609 |
-
|
610 |
-
if ($product = $this->getProduct($item))
|
611 |
-
{
|
612 |
-
$product_id = $product->getId();
|
613 |
-
if (!in_array($product_id, $id_list))
|
614 |
-
$id_list[] = $product_id;
|
615 |
-
}
|
616 |
-
}
|
617 |
-
|
618 |
-
$max_count = $this->_helper->config('related_fields');
|
619 |
-
|
620 |
-
$related = $this->getRelatedCollection($id_list, $max_count);
|
621 |
-
|
622 |
-
if (count($related) < $max_count)
|
623 |
-
{
|
624 |
-
// get grouped related
|
625 |
-
$grouped_related = $this->getRelatedCollection($grouped_id_list, $max_count - count($related), $id_list);
|
626 |
-
|
627 |
-
// Merge the collections
|
628 |
-
if (count($grouped_related) > 0)
|
629 |
-
return array_merge($related, $grouped_related);
|
630 |
-
}
|
631 |
-
|
632 |
-
return $related;
|
633 |
-
}
|
634 |
-
|
635 |
-
private function getRelatedOrderItems($quote, $merge_vars)
|
636 |
-
{
|
637 |
-
$prefix = "Related";
|
638 |
-
$max_count = $this->_helper->config('related_fields');
|
639 |
-
|
640 |
-
$related_products = $this->getRelatedProducts($quote);
|
641 |
-
|
642 |
-
$count = 0;
|
643 |
-
|
644 |
-
foreach ($related_products as $rp)
|
645 |
-
{
|
646 |
-
$count++;
|
647 |
-
|
648 |
-
if ($count > $max_count)
|
649 |
-
break;
|
650 |
-
|
651 |
-
$merge_vars = $this->addMergeItem($rp->getId(), $count, $merge_vars, $prefix);
|
652 |
-
}
|
653 |
-
|
654 |
-
while ($count < $max_count)
|
655 |
-
{
|
656 |
-
$count++;
|
657 |
-
$merge_vars = $this->addMergeItem(null, $count, $merge_vars, $prefix);
|
658 |
-
}
|
659 |
-
|
660 |
-
return $merge_vars;
|
661 |
-
}
|
662 |
-
|
663 |
-
private function getGroupedProductId($item)
|
664 |
-
{
|
665 |
-
$options = $item->getProductOptions();
|
666 |
-
|
667 |
-
if (isset($options['super_product_config']))
|
668 |
-
{
|
669 |
-
if (isset($options['super_product_config']['product_id']))
|
670 |
-
{
|
671 |
-
$product_id = $options['super_product_config']['product_id'];
|
672 |
-
|
673 |
-
return $product_id;
|
674 |
-
}
|
675 |
-
}
|
676 |
-
else
|
677 |
-
{
|
678 |
-
$option = $item->getOptionByCode('product_type');
|
679 |
-
if ($option)
|
680 |
-
return $option->getProductId();
|
681 |
-
}
|
682 |
-
|
683 |
-
return false;
|
684 |
-
}
|
685 |
-
|
686 |
-
private function getGroupedProduct($item)
|
687 |
-
{
|
688 |
-
$product_id = $this->getGroupedProductId($item);
|
689 |
-
|
690 |
-
if ($product_id !== false)
|
691 |
-
{
|
692 |
-
$product = Mage::getModel('catalog/product')->load($product_id);
|
693 |
-
|
694 |
-
if ($product->getId())
|
695 |
-
return $product;
|
696 |
-
}
|
697 |
-
|
698 |
-
return false;
|
699 |
-
}
|
700 |
-
|
701 |
-
private function getProduct($item)
|
702 |
-
{
|
703 |
-
$product = $item->getProduct();
|
704 |
-
|
705 |
-
if ($product == null)
|
706 |
-
{
|
707 |
-
$product_id = $item->getProductId();
|
708 |
-
|
709 |
-
if (!$product_id)
|
710 |
-
return null;
|
711 |
-
|
712 |
-
$product = Mage::getModel('catalog/product')->load($product_id);
|
713 |
-
|
714 |
-
if ($product == null || !$product->getId())
|
715 |
-
return null;
|
716 |
-
}
|
717 |
-
|
718 |
-
return $product;
|
719 |
-
}
|
720 |
-
|
721 |
-
protected function isItemVisible($item)
|
722 |
-
{
|
723 |
-
$vis_flag = Mage_Catalog_Model_Product_Visibility::VISIBILITY_NOT_VISIBLE;
|
724 |
-
|
725 |
-
if ($item == null)
|
726 |
-
return true;
|
727 |
-
|
728 |
-
$product = $this->getProduct($item);
|
729 |
-
|
730 |
-
if ($product == null)
|
731 |
-
return true;
|
732 |
-
|
733 |
-
if ($product->getVisibility() != $vis_flag)
|
734 |
-
return true;
|
735 |
-
|
736 |
-
return false;
|
737 |
-
}
|
738 |
-
|
739 |
-
private function getMergeOrderItems($quote, $merge_vars, $prefix = "")
|
740 |
-
{
|
741 |
-
$max_count = $this->_helper->config('product_fields');
|
742 |
-
|
743 |
-
$count = 0;
|
744 |
-
|
745 |
-
$item_list = array();
|
746 |
-
$item_data = array();
|
747 |
-
|
748 |
-
$parent_items = array();
|
749 |
-
|
750 |
-
foreach ($quote->getAllItems() as $item)
|
751 |
-
{
|
752 |
-
$type = $item->getProductType();
|
753 |
-
if ($type == "configurable" || $type == "bundle")
|
754 |
-
$parent_items[$item->getId()] = $item;
|
755 |
-
|
756 |
-
if ($type == "grouped")
|
757 |
-
{
|
758 |
-
$grouped_product = $this->getGroupedProduct($item);
|
759 |
-
|
760 |
-
if ($grouped_product)
|
761 |
-
{
|
762 |
-
$parent_item = new Varien_Object;
|
763 |
-
$parent_item->setProduct($grouped_product);
|
764 |
-
$parent_items[$item->getId()] = $parent_item;
|
765 |
-
}
|
766 |
-
}
|
767 |
-
}
|
768 |
-
|
769 |
-
foreach ($quote->getAllItems() as $item)
|
770 |
-
{
|
771 |
-
$type = $item->getProductType();
|
772 |
-
if ($type == "configurable" || $type == "bundle")
|
773 |
-
continue;
|
774 |
-
|
775 |
-
$item_id = $item->getId();
|
776 |
-
|
777 |
-
if ($item->getProductType() == 'grouped')
|
778 |
-
$parent_id = $item->getId();
|
779 |
-
else
|
780 |
-
$parent_id = $item->getParentItemId();
|
781 |
-
|
782 |
-
if ($parent_id != null && isset($parent_items[$parent_id]))
|
783 |
-
{
|
784 |
-
$parent_item = $parent_items[$parent_id];
|
785 |
-
|
786 |
-
if ($this->isItemVisible($item) || $this->isItemVisible($parent_item))
|
787 |
-
$item_data[$item_id] = array('item' => $item, 'parent' => $parent_item);
|
788 |
-
}
|
789 |
-
else
|
790 |
-
{
|
791 |
-
if ($this->isItemVisible($item))
|
792 |
-
$item_data[$item_id] = array('item' => $item);
|
793 |
-
}
|
794 |
-
}
|
795 |
-
|
796 |
-
foreach ($item_data as $item)
|
797 |
-
{
|
798 |
-
$count++;
|
799 |
-
|
800 |
-
if ($count > $max_count)
|
801 |
-
break;
|
802 |
-
|
803 |
-
$merge_vars = $this->addMergeItem($item, $count, $merge_vars, $prefix);
|
804 |
-
}
|
805 |
-
|
806 |
-
while ($count < $max_count)
|
807 |
-
{
|
808 |
-
$count++;
|
809 |
-
$merge_vars = $this->addMergeItem(null, $count, $merge_vars, $prefix);
|
810 |
-
}
|
811 |
-
|
812 |
-
return $merge_vars;
|
813 |
-
}
|
814 |
-
|
815 |
-
private function hasCustomerChanged($customer)
|
816 |
-
{
|
817 |
-
$maps = unserialize( $this->_helper->config('map_fields', $customer->getStoreId()) );
|
818 |
-
|
819 |
-
$this->_helper->log('Checking for mapped data changes');
|
820 |
-
|
821 |
-
foreach ($maps as $map)
|
822 |
-
{
|
823 |
-
$field = $map['magento'];
|
824 |
-
|
825 |
-
if ($customer->getOrigData($field) != $customer->getData($field))
|
826 |
-
return true;
|
827 |
-
}
|
828 |
-
|
829 |
-
return false;
|
830 |
-
}
|
831 |
-
|
832 |
-
public function updateCustomer(Varien_Event_Observer $observer)
|
833 |
-
{
|
834 |
-
try
|
835 |
-
{
|
836 |
-
$this->_helper->setLogArea(EmailDirect_Integration_Helper_Data::CUSTOMER);
|
837 |
-
$this->_helper->log("Update Customer Start");
|
838 |
-
|
839 |
-
$starting_store = Mage::app()->getStore()->getCode();
|
840 |
-
|
841 |
-
$customer = $observer->getEvent()->getCustomer();
|
842 |
-
|
843 |
-
if (!$customer)
|
844 |
-
{
|
845 |
-
$this->_helper->logReason("Customer not found");
|
846 |
-
return;
|
847 |
-
}
|
848 |
-
|
849 |
-
$customer_store = $customer->getStore()->getId();
|
850 |
-
|
851 |
-
$current_store = Mage::app()->getStore()->getId();
|
852 |
-
|
853 |
-
$this->_helper->log("Checking store");
|
854 |
-
|
855 |
-
if ($current_store == 0)
|
856 |
-
{
|
857 |
-
$this->_helper->log("Admin store current");
|
858 |
-
if ($customer_store == 0)
|
859 |
-
{
|
860 |
-
$this->_helper->logReason("Customer store can't be determined");
|
861 |
-
return;
|
862 |
-
}
|
863 |
-
else
|
864 |
-
Mage::app()->setCurrentStore($customer_store);
|
865 |
-
}
|
866 |
-
|
867 |
-
$this->_helper->log("Correct store found");
|
868 |
-
|
869 |
-
if (!$this->_helper->canEdirect())
|
870 |
-
{
|
871 |
-
$this->_helper->logReason($this->_helper->getDisabledReason());
|
872 |
-
Mage::app()->setCurrentStore($starting_store);
|
873 |
-
return;
|
874 |
-
}
|
875 |
-
|
876 |
-
$merge_vars = $this->_mergeVars($customer);
|
877 |
-
|
878 |
-
$this->_helper->log($merge_vars,"Merge Vars");
|
879 |
-
|
880 |
-
$api = Mage::getSingleton('emaildirect/wrapper_subscribers');
|
881 |
-
|
882 |
-
$oldEmail = $customer->getOrigData('email');
|
883 |
-
$email = $customer->getEmail();
|
884 |
-
|
885 |
-
if ($oldEmail == '')
|
886 |
-
{
|
887 |
-
$this->_helper->log("Original Email was blank. Adding Subscriber");
|
888 |
-
$rc = $api->subscriberAdd($email,$merge_vars,"",false);
|
889 |
-
}
|
890 |
-
elseif ($oldEmail != $email)
|
891 |
-
{
|
892 |
-
$this->_helper->log("Modifying Email");
|
893 |
-
|
894 |
-
// If this fails we just add the subscriber
|
895 |
-
$rc = $api->mailModify($oldEmail,$email);
|
896 |
-
|
897 |
-
$this->_helper->log("Adding Subscriber");
|
898 |
-
$rc = $api->subscriberAdd($email,$merge_vars,"",false);
|
899 |
-
}
|
900 |
-
else
|
901 |
-
{
|
902 |
-
if ($this->hasCustomerChanged($customer))
|
903 |
-
{
|
904 |
-
$this->_helper->log("Updating Subscriber");
|
905 |
-
$rc = $api->subscriberAdd($email,$merge_vars,"",false);
|
906 |
-
}
|
907 |
-
else
|
908 |
-
$this->_helper->logReason("Neither Email nor Mapped Data changed");
|
909 |
-
}
|
910 |
-
|
911 |
-
$this->_helper->log("Update Customer End");
|
912 |
-
}
|
913 |
-
catch (Exception $e)
|
914 |
-
{
|
915 |
-
Mage::logException($e);
|
916 |
-
$this->_helper->logException($e);
|
917 |
-
}
|
918 |
-
|
919 |
-
Mage::app()->setCurrentStore($starting_store);
|
920 |
-
return;
|
921 |
-
}
|
922 |
-
|
923 |
-
public function registerCheckoutSubscribe(Varien_Event_Observer $observer)
|
924 |
-
{
|
925 |
-
try
|
926 |
-
{
|
927 |
-
$this->_helper->setLogArea(EmailDirect_Integration_Helper_Data::NEWSLETTER);
|
928 |
-
$this->_helper->log("Register Checkout Subscribe Start");
|
929 |
-
if (!$this->_helper->canEdirect())
|
930 |
-
{
|
931 |
-
$this->_helper->logReason($this->_helper->getDisabledReason());
|
932 |
-
return;
|
933 |
-
}
|
934 |
-
$subscribe = Mage::app()->getRequest()->getPost('emaildirect_subscribe');
|
935 |
-
|
936 |
-
if (!is_null($subscribe) || $this->_helper->forceSubscribe())
|
937 |
-
Mage::getSingleton('core/session')->setEmaildirectCheckout($subscribe);
|
938 |
-
|
939 |
-
$this->_helper->log("Register Checkout Subscribe End");
|
940 |
-
}
|
941 |
-
catch (Exception $e)
|
942 |
-
{
|
943 |
-
Mage::logException($e);
|
944 |
-
$this->_helper->logException($e);
|
945 |
-
}
|
946 |
-
}
|
947 |
-
|
948 |
-
/**
|
949 |
-
* Subscribe customer to Newsletter if flag on session is present
|
950 |
-
*/
|
951 |
-
public function registerCheckoutSuccess(Varien_Event_Observer $observer)
|
952 |
-
{
|
953 |
-
try
|
954 |
-
{
|
955 |
-
$this->_helper->setLogArea(EmailDirect_Integration_Helper_Data::NEWSLETTER);
|
956 |
-
$this->_helper->log("Register Checkout Success Start");
|
957 |
-
|
958 |
-
if (!$this->_helper->canEdirect())
|
959 |
-
{
|
960 |
-
$this->_helper->logReason($this->_helper->getDisabledReason());
|
961 |
-
return;
|
962 |
-
}
|
963 |
-
|
964 |
-
$sessionFlag = Mage::getSingleton('core/session')->getEmaildirectCheckout(TRUE);
|
965 |
-
if (!$sessionFlag && !$this->_helper->forceSubscribe())
|
966 |
-
{
|
967 |
-
$this->_helper->logReason("Session flag not found.");
|
968 |
-
return;
|
969 |
-
}
|
970 |
-
|
971 |
-
$order_id = (int)current($observer->getEvent()->getOrderIds());
|
972 |
-
|
973 |
-
if (!$order_id)
|
974 |
-
{
|
975 |
-
$this->_helper->logReason("Order ID not found.");
|
976 |
-
return;
|
977 |
-
}
|
978 |
-
|
979 |
-
$order = Mage::getModel('sales/order')->load($order_id);
|
980 |
-
if (!$order->getId())
|
981 |
-
{
|
982 |
-
$this->_helper->logReason("Failed to Load Order ({$order_id}).");
|
983 |
-
return;
|
984 |
-
}
|
985 |
-
|
986 |
-
$this->_helper->log("Processing Order # " . $order->getIncrementId());
|
987 |
-
|
988 |
-
//Guest Checkout
|
989 |
-
if ((int)$order->getCustomerGroupId() === Mage_Customer_Model_Group::NOT_LOGGED_IN_ID )
|
990 |
-
{
|
991 |
-
$this->_helper->log("Guest Checkout");
|
992 |
-
$this->_helper->registerGuestCustomer($order);
|
993 |
-
}
|
994 |
-
|
995 |
-
$subscriber = Mage::getModel('newsletter/subscriber')
|
996 |
-
->subscribe($order->getCustomerEmail());
|
997 |
-
|
998 |
-
$this->_helper->log("Register Checkout Success End");
|
999 |
-
}
|
1000 |
-
catch (Exception $e)
|
1001 |
-
{
|
1002 |
-
Mage::logException($e);
|
1003 |
-
$this->_helper->logException($e);
|
1004 |
-
}
|
1005 |
-
}
|
1006 |
-
|
1007 |
-
public function salesOrderShipmentTrackSaveAfter(Varien_Event_Observer $observer)
|
1008 |
-
{
|
1009 |
-
try
|
1010 |
-
{
|
1011 |
-
$this->_helper->setLogArea(EmailDirect_Integration_Helper_Data::ORDERS);
|
1012 |
-
$this->_helper->log("Sales Order Shipment Track Save After Start");
|
1013 |
-
if(!$this->_helper->canEdirect())
|
1014 |
-
{
|
1015 |
-
$this->_helper->logReason($this->_helper->getDisabledReason());
|
1016 |
-
return;
|
1017 |
-
}
|
1018 |
-
$track = $observer->getEvent()->getTrack();
|
1019 |
-
|
1020 |
-
$order = $track->getShipment()->getOrder();
|
1021 |
-
$shippingMethod = $order->getShippingMethod(); // String in format of 'carrier_method'
|
1022 |
-
if (!$shippingMethod)
|
1023 |
-
{
|
1024 |
-
$this->_helper->logReason("Shipping Method not found");
|
1025 |
-
return;
|
1026 |
-
}
|
1027 |
-
|
1028 |
-
$email = $order->getCustomerEmail();
|
1029 |
-
|
1030 |
-
$merge_vars = array();
|
1031 |
-
|
1032 |
-
$merge_vars = $this->_helper->getTrackingMergeVars($track, $order);
|
1033 |
-
|
1034 |
-
if ($merge_vars == null)
|
1035 |
-
{
|
1036 |
-
$this->_helper->logReason("No shipping fields setup");
|
1037 |
-
return;
|
1038 |
-
}
|
1039 |
-
|
1040 |
-
$this->_helper->log($merge_vars,"Merge Vars");
|
1041 |
-
|
1042 |
-
$rc = Mage::getSingleton('emaildirect/wrapper_orders')->addSubscriberTracking($email, $merge_vars);
|
1043 |
-
|
1044 |
-
$this->_helper->log("Sales Order Shipment Track Save After Start");
|
1045 |
-
|
1046 |
-
return;
|
1047 |
-
}
|
1048 |
-
catch (Exception $e)
|
1049 |
-
{
|
1050 |
-
Mage::logException($e);
|
1051 |
-
$this->_helper->logException($e);
|
1052 |
-
}
|
1053 |
-
}
|
1054 |
-
|
1055 |
-
private function canSendOrder($order, $batch = false)
|
1056 |
-
{
|
1057 |
-
$ed_order = Mage::getModel('emaildirect/order')->loadByOrderId($order->getId());
|
1058 |
-
|
1059 |
-
if ($ed_order != null && $ed_order->getDateSent() != null)
|
1060 |
-
{
|
1061 |
-
$this->_helper->logReason("Order has already been sent.");
|
1062 |
-
return false;
|
1063 |
-
}
|
1064 |
-
|
1065 |
-
// Check the old data just in case
|
1066 |
-
if ($order->getData('sent_to_emaildirect') != false)
|
1067 |
-
{
|
1068 |
-
$this->_helper->logReason("Order has already been sent. (Older Version)");
|
1069 |
-
$this->setOrderSentToEmailDirect($order, $order->getData('updated_at'));
|
1070 |
-
return false;
|
1071 |
-
}
|
1072 |
-
|
1073 |
-
if ($batch)
|
1074 |
-
{
|
1075 |
-
$this->_helper->log("Batch process. Skipping State/Status Check");
|
1076 |
-
return true;
|
1077 |
-
}
|
1078 |
-
|
1079 |
-
$mode = $this->_helper->config('send_field');
|
1080 |
-
|
1081 |
-
$this->_helper->log("Send Field: {$mode}");
|
1082 |
-
|
1083 |
-
if ($mode == "state")
|
1084 |
-
{
|
1085 |
-
$this->_helper->log("Order State: " . $order->getState());
|
1086 |
-
|
1087 |
-
$states = Mage::helper('emaildirect')->config('send_states');
|
1088 |
-
$state_list = explode(",",$states);
|
1089 |
-
|
1090 |
-
$this->_helper->log("Check States: " . $states);
|
1091 |
-
$this->_helper->log($state_list, "State array");
|
1092 |
-
|
1093 |
-
if (array_search($order->getState(),$state_list) === FALSE)
|
1094 |
-
{
|
1095 |
-
$this->_helper->logReason("State not setup to send (" . $order->getState() . ")");
|
1096 |
-
return false;
|
1097 |
-
}
|
1098 |
-
}
|
1099 |
-
else
|
1100 |
-
{
|
1101 |
-
$this->_helper->log("Order Status: " . $order->getStatus());
|
1102 |
-
|
1103 |
-
$statuses = Mage::helper('emaildirect')->config('send_statuses');
|
1104 |
-
$status_list = explode(",",$statuses);
|
1105 |
-
|
1106 |
-
$this->_helper->log("Check Statuses: " . $statuses);
|
1107 |
-
$this->_helper->log($status_list, "Status array");
|
1108 |
-
|
1109 |
-
if (array_search($order->getStatus(),$status_list) === FALSE)
|
1110 |
-
{
|
1111 |
-
$this->_helper->logReason("Status not setup to send (" . $order->getStatus() . ")");
|
1112 |
-
return false;
|
1113 |
-
}
|
1114 |
-
}
|
1115 |
-
|
1116 |
-
return true;
|
1117 |
-
}
|
1118 |
-
|
1119 |
-
private function processBatchStoreOrders($store)
|
1120 |
-
{
|
1121 |
-
try
|
1122 |
-
{
|
1123 |
-
$store_code = $store->getCode();
|
1124 |
-
|
1125 |
-
$this->_helper->log("Processing Store: {$store_code}");
|
1126 |
-
|
1127 |
-
if (!$this->_helper->getBatchEnabled())
|
1128 |
-
{
|
1129 |
-
$this->_helper->logReason($this->_helper->getBatchDisabledReason());
|
1130 |
-
return;
|
1131 |
-
}
|
1132 |
-
|
1133 |
-
Mage::helper('emaildirect/fields')->checkFields();
|
1134 |
-
|
1135 |
-
// Get order collection
|
1136 |
-
$collection = Mage::getResourceModel('emaildirect/order_collection');
|
1137 |
-
|
1138 |
-
$limit = $this->_helper->config('batch_size');
|
1139 |
-
|
1140 |
-
$this->_helper->log("Batch Size: [{$limit}]");
|
1141 |
-
|
1142 |
-
if ($limit != "")
|
1143 |
-
{
|
1144 |
-
if (!is_numeric($limit))
|
1145 |
-
$limit = 100;
|
1146 |
-
else
|
1147 |
-
$limit = (int)$limit;
|
1148 |
-
}
|
1149 |
-
|
1150 |
-
$collection->getUnsentOrders($store->getId(), $limit);
|
1151 |
-
|
1152 |
-
$this->_helper->log("SQL: " . $collection->getSelect()->__toString());
|
1153 |
-
|
1154 |
-
foreach ($collection as $order)
|
1155 |
-
{
|
1156 |
-
$this->processSavedOrder($order, true);
|
1157 |
-
}
|
1158 |
-
|
1159 |
-
$this->_helper->log("Finished Processing Store: {$store_code}");
|
1160 |
-
}
|
1161 |
-
catch (Exception $e)
|
1162 |
-
{
|
1163 |
-
Mage::logException($e);
|
1164 |
-
$this->_helper->logException($e);
|
1165 |
-
}
|
1166 |
-
}
|
1167 |
-
|
1168 |
-
public function processBatchOrders()
|
1169 |
-
{
|
1170 |
-
try
|
1171 |
-
{
|
1172 |
-
Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);
|
1173 |
-
$this->_helper->setLogArea(EmailDirect_Integration_Helper_Data::ORDERS);
|
1174 |
-
$this->_helper->log("Process Batch Orders Start");
|
1175 |
-
|
1176 |
-
$stores = Mage::app()->getStores();
|
1177 |
-
|
1178 |
-
foreach ($stores as $store)
|
1179 |
-
{
|
1180 |
-
Mage::app()->setCurrentStore($store->getCode());
|
1181 |
-
|
1182 |
-
$this->processBatchStoreOrders($store);
|
1183 |
-
}
|
1184 |
-
|
1185 |
-
Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);
|
1186 |
-
|
1187 |
-
$this->_helper->log("Process Batch Orders End");
|
1188 |
-
}
|
1189 |
-
catch (Exception $e)
|
1190 |
-
{
|
1191 |
-
Mage::logException($e);
|
1192 |
-
$this->_helper->logException($e);
|
1193 |
-
}
|
1194 |
-
}
|
1195 |
-
|
1196 |
-
public function processSavedOrder($order, $batch = false)
|
1197 |
-
{
|
1198 |
-
try
|
1199 |
-
{
|
1200 |
-
$this->_helper->setLogArea(EmailDirect_Integration_Helper_Data::ORDERS);
|
1201 |
-
$this->_helper->log("Process Saved Order Start");
|
1202 |
-
|
1203 |
-
$this->_helper->log("Order ID: " . $order->getIncrementId());
|
1204 |
-
|
1205 |
-
$this->_helper->log("Order Store: " . $order->getStoreId());
|
1206 |
-
$starting_store = Mage::app()->getStore()->getCode();
|
1207 |
-
|
1208 |
-
Mage::app()->setCurrentStore($order->getStoreId());
|
1209 |
-
|
1210 |
-
if (!$this->_helper->getOrdersEnabled())
|
1211 |
-
{
|
1212 |
-
$this->_helper->logReason($this->_helper->getOrdersDisabledReason());
|
1213 |
-
Mage::app()->setCurrentStore($starting_store);
|
1214 |
-
return;
|
1215 |
-
}
|
1216 |
-
|
1217 |
-
if (!$this->canSendOrder($order, $batch))
|
1218 |
-
{
|
1219 |
-
Mage::app()->setCurrentStore($starting_store);
|
1220 |
-
return;
|
1221 |
-
}
|
1222 |
-
|
1223 |
-
$this->_helper->log("Order is ready to send. Processing...");
|
1224 |
-
|
1225 |
-
$email = $order->getCustomerEmail();
|
1226 |
-
|
1227 |
-
if ($order->getData('customer_is_guest'))
|
1228 |
-
{
|
1229 |
-
$this->_helper->log("Guest Customer");
|
1230 |
-
|
1231 |
-
$customer = new Varien_Object;
|
1232 |
-
|
1233 |
-
$customer->setData('email',$email);
|
1234 |
-
$customer->setData('firstname',$order->getData('customer_firstname'));
|
1235 |
-
$customer->setData('lastname',$order->getData('customer_lastname'));
|
1236 |
-
$customer->setData('store_id',$order->getStoreId());
|
1237 |
-
|
1238 |
-
$customer->setBillingAddress($order->getBillingAddress());
|
1239 |
-
}
|
1240 |
-
else
|
1241 |
-
{
|
1242 |
-
$customer = Mage::getModel('customer/customer')->load($order->getCustomerId());
|
1243 |
-
$address = Mage::getModel('customer/address')->load($customer->getDefaultBilling());
|
1244 |
-
$customer->setBillingAddress($address);
|
1245 |
-
}
|
1246 |
-
|
1247 |
-
$merge_vars = $this->_helper->getMergeVars($customer);
|
1248 |
-
$merge_vars = $this->_helper->getOrderMergeVars($merge_vars,$order);
|
1249 |
-
|
1250 |
-
if ($this->_helper->config('save_latest_order'))
|
1251 |
-
{
|
1252 |
-
$this->_helper->log("Getting Latest Order Info");
|
1253 |
-
$merge_vars['LastOrderNumber'] = $order->getIncrementId();
|
1254 |
-
$merge_vars['LastPurchaseDate'] = $order->getData('created_at');
|
1255 |
-
$merge_vars['LastPurchaseTotal'] = Mage::helper('core')->currency($order->getData('total_paid'), true, false);
|
1256 |
-
|
1257 |
-
$merge_vars = $this->getMergeOrderItems($order, $merge_vars);
|
1258 |
-
$merge_vars = $this->getRelatedOrderItems($order, $merge_vars);
|
1259 |
-
}
|
1260 |
-
|
1261 |
-
$this->_helper->log($merge_vars, "Merge Vars");
|
1262 |
-
|
1263 |
-
Mage::helper('emaildirect/fields')->checkFields();
|
1264 |
-
|
1265 |
-
$rc = Mage::getSingleton('emaildirect/wrapper_orders')->addSubscriberOrder($email, $order, $merge_vars);
|
1266 |
-
|
1267 |
-
if (!isset($rc->ErrorCode))
|
1268 |
-
$this->setOrderSentToEmailDirect($order);
|
1269 |
-
|
1270 |
-
$this->_helper->log("Process Saved Order End");
|
1271 |
-
}
|
1272 |
-
catch (Exception $e)
|
1273 |
-
{
|
1274 |
-
Mage::logException($e);
|
1275 |
-
$this->_helper->logException($e);
|
1276 |
-
}
|
1277 |
-
|
1278 |
-
Mage::app()->setCurrentStore($starting_store);
|
1279 |
-
}
|
1280 |
-
|
1281 |
-
public function orderSaveAfter(Varien_Event_Observer $observer)
|
1282 |
-
{
|
1283 |
-
try
|
1284 |
-
{
|
1285 |
-
$this->_helper->setLogArea(EmailDirect_Integration_Helper_Data::ORDERS);
|
1286 |
-
$this->_helper->log("Order Save After Start");
|
1287 |
-
|
1288 |
-
if ($this->_helper->getBatchOnly())
|
1289 |
-
{
|
1290 |
-
$this->_helper->log("Skipping... Batch Processing Only");
|
1291 |
-
return;
|
1292 |
-
}
|
1293 |
-
|
1294 |
-
$order = $observer->getEvent()->getOrder();
|
1295 |
-
|
1296 |
-
$this->processSavedOrder($order);
|
1297 |
-
|
1298 |
-
$this->_helper->log("Order Save After End");
|
1299 |
-
|
1300 |
-
return;
|
1301 |
-
}
|
1302 |
-
catch (Exception $e)
|
1303 |
-
{
|
1304 |
-
Mage::logException($e);
|
1305 |
-
$this->_helper->logException($e);
|
1306 |
-
}
|
1307 |
-
}
|
1308 |
-
|
1309 |
-
// START ABANDONED CRON
|
1310 |
-
private function getAbandonedTime()
|
1311 |
-
{
|
1312 |
-
$time = $this->_helper->config('abandonedtime');
|
1313 |
-
$time *= 60; // Adjust to seconds.
|
1314 |
-
|
1315 |
-
$date = date(Mage::getModel('core/date')->gmtTimestamp());
|
1316 |
-
|
1317 |
-
$date = $date - $time;
|
1318 |
-
|
1319 |
-
return date($this->_date_format, $date);
|
1320 |
-
}
|
1321 |
-
|
1322 |
-
private function getLastOrder($quote)
|
1323 |
-
{
|
1324 |
-
$this->_helper->log("Get Last Order");
|
1325 |
-
$customer_id = $quote->getData('customer_id');
|
1326 |
-
|
1327 |
-
$this->_helper->log("Customer ID: {$customer_id}");
|
1328 |
-
|
1329 |
-
$orders = Mage::getResourceModel('sales/order_collection')
|
1330 |
-
->addFieldToSelect('*')
|
1331 |
-
->addFieldToFilter('customer_id', $customer_id)
|
1332 |
-
->addAttributeToSort('created_at', 'DESC')
|
1333 |
-
->setPageSize(1);
|
1334 |
-
|
1335 |
-
$this->_helper->log("Order Count: " . $orders->getSize());
|
1336 |
-
if ($orders->getSize() <= 0)
|
1337 |
-
return null;
|
1338 |
-
|
1339 |
-
$this->_helper->log("Order Found");
|
1340 |
-
$order = $orders->getFirstItem();
|
1341 |
-
|
1342 |
-
return $order;
|
1343 |
-
}
|
1344 |
-
|
1345 |
-
private function setOrderSentToEmailDirect($order, $date = null)
|
1346 |
-
{
|
1347 |
-
try
|
1348 |
-
{
|
1349 |
-
if ($date == null)
|
1350 |
-
{
|
1351 |
-
$date = date(Mage::getModel('core/date')->gmtTimestamp());
|
1352 |
-
$date = date($this->_date_format, $date);
|
1353 |
-
}
|
1354 |
-
|
1355 |
-
$ed_order = Mage::getModel('emaildirect/order')->saveSent($order, $date);
|
1356 |
-
}
|
1357 |
-
catch (Exception $e)
|
1358 |
-
{
|
1359 |
-
Mage::logException($e);
|
1360 |
-
$this->_helper->logException($e);
|
1361 |
-
}
|
1362 |
-
}
|
1363 |
-
|
1364 |
-
private function setSentToEmailDirectDate($quote, $date)
|
1365 |
-
{
|
1366 |
-
try
|
1367 |
-
{
|
1368 |
-
$abandoned = Mage::getModel('emaildirect/abandoned')->loadByQuoteId($quote->getId());
|
1369 |
-
|
1370 |
-
$abandoned->setDateSent($date);
|
1371 |
-
$abandoned->save();
|
1372 |
-
}
|
1373 |
-
catch (Exception $e)
|
1374 |
-
{
|
1375 |
-
Mage::logException($e);
|
1376 |
-
$this->_helper->logException($e);
|
1377 |
-
}
|
1378 |
-
}
|
1379 |
-
|
1380 |
-
private function addSequence(&$merge_vars)
|
1381 |
-
{
|
1382 |
-
if (!$this->_sequence_enabled)
|
1383 |
-
return;
|
1384 |
-
|
1385 |
-
if (!isset($this->_sequences[$this->_current_sequence]))
|
1386 |
-
$this->_current_sequence = 0;
|
1387 |
-
|
1388 |
-
$merge_vars[$this->_sequence_field] = $this->_sequences[$this->_current_sequence++];
|
1389 |
-
}
|
1390 |
-
|
1391 |
-
private function processAbandoned($quote, $date)
|
1392 |
-
{
|
1393 |
-
$this->_helper->log("ProcessAbandoned Start");
|
1394 |
-
$email = $quote->getCustomerEmail();
|
1395 |
-
|
1396 |
-
if ($email == null)
|
1397 |
-
$email = $quote->getEmail();
|
1398 |
-
|
1399 |
-
$abandonedDate = $quote->getUpdatedAt();
|
1400 |
-
|
1401 |
-
$merge_vars = array();
|
1402 |
-
|
1403 |
-
$merge_vars['FirstName'] = $quote->getData('customer_firstname');
|
1404 |
-
$merge_vars['LastName'] = $quote->getData('customer_lastname');
|
1405 |
-
|
1406 |
-
$merge_vars['AbandonedDate'] = $abandonedDate;
|
1407 |
-
$merge_vars['AbandonedUrl'] = $this->getAbandonedUrl($quote); //$quote->getEmaildirectAbandonedUrl();
|
1408 |
-
|
1409 |
-
$this->addSequence($merge_vars);
|
1410 |
-
|
1411 |
-
$merge_vars = $this->getMergeOrderItems($quote, $merge_vars, "AB");
|
1412 |
-
|
1413 |
-
$order = $this->getLastOrder($quote);
|
1414 |
-
|
1415 |
-
if ($order != null)
|
1416 |
-
{
|
1417 |
-
$this->_helper->log("Processing Last Order");
|
1418 |
-
$merge_vars = $this->_helper->getOrderMergeVars($merge_vars,$order);
|
1419 |
-
|
1420 |
-
$this->_helper->log("Check Save Lastest");
|
1421 |
-
if ($this->_helper->config('save_latest_order'))
|
1422 |
-
{
|
1423 |
-
$this->_helper->log("Adding Latest Order Information");
|
1424 |
-
$merge_vars['LastOrderNumber'] = $order->getIncrementId();
|
1425 |
-
$merge_vars['LastPurchaseDate'] = $order->getData('created_at');
|
1426 |
-
$merge_vars['LastPurchaseTotal'] = Mage::helper('core')->currency($order->getData('total_paid'), true, false);
|
1427 |
-
|
1428 |
-
$merge_vars = $this->getMergeOrderItems($order, $merge_vars);
|
1429 |
-
$merge_vars = $this->getRelatedOrderItems($order, $merge_vars);
|
1430 |
-
$this->_helper->log("Finish Save Latest");
|
1431 |
-
}
|
1432 |
-
else
|
1433 |
-
$this->_helper->log("Don't save latest order information");
|
1434 |
-
}
|
1435 |
-
|
1436 |
-
$xml = Mage::getSingleton('emaildirect/wrapper_abandoned')->getOneSubscriber($email,$merge_vars);
|
1437 |
-
|
1438 |
-
$this->setSentToEmailDirectDate($quote, $date);
|
1439 |
-
|
1440 |
-
$this->_helper->log("ProcessAbandoned End");
|
1441 |
-
|
1442 |
-
return $xml;
|
1443 |
-
}
|
1444 |
-
|
1445 |
-
private function _abandonedCartsProcessor($collection, $store = null, $mark_time = true)
|
1446 |
-
{
|
1447 |
-
// Store the time we last run
|
1448 |
-
$date = date(Mage::getModel('core/date')->gmtTimestamp());
|
1449 |
-
$date = date($this->_date_format, $date);
|
1450 |
-
|
1451 |
-
if ($mark_time)
|
1452 |
-
{
|
1453 |
-
$this->_helper->log("Saving Last Run Date: {$date}");
|
1454 |
-
$this->_helper->updateConfig("abandoned_last_run", $date, $store);
|
1455 |
-
}
|
1456 |
-
|
1457 |
-
$subscribers = false;
|
1458 |
-
|
1459 |
-
$xml = "<Subscribers>";
|
1460 |
-
|
1461 |
-
// Get the data for each abandoned cart
|
1462 |
-
foreach ($collection as $quote)
|
1463 |
-
{
|
1464 |
-
$xml .= $this->processAbandoned($quote, $date);
|
1465 |
-
$subscribers = true;
|
1466 |
-
}
|
1467 |
-
|
1468 |
-
$xml .= "</Subscribers>";
|
1469 |
-
|
1470 |
-
if (!$subscribers)
|
1471 |
-
{
|
1472 |
-
$this->_helper->logReason("No Carts Found");
|
1473 |
-
return; // No abandoned carts found
|
1474 |
-
}
|
1475 |
-
|
1476 |
-
$this->_helper->log("Sending Abandoned Carts");
|
1477 |
-
// Send them all at once
|
1478 |
-
$rc = Mage::getSingleton('emaildirect/wrapper_abandoned')->sendSubscribers($xml);
|
1479 |
-
}
|
1480 |
-
|
1481 |
-
private function setupSequence()
|
1482 |
-
{
|
1483 |
-
$this->_sequence_enabled = $this->_helper->config('abandonedsequence_enabled');
|
1484 |
-
|
1485 |
-
if (!$this->_sequence_enabled)
|
1486 |
-
return;
|
1487 |
-
|
1488 |
-
$sequences = str_replace("\r\n","\n",$this->_helper->config('abandonedsequence_options'));
|
1489 |
-
$this->_current_sequence = $this->_helper->config('abandonedsequence_current');
|
1490 |
-
|
1491 |
-
if (!is_numeric($this->_current_sequence))
|
1492 |
-
$this->_current_sequence = 0;
|
1493 |
-
|
1494 |
-
$this->_sequences = explode("\n",$sequences);
|
1495 |
-
$this->_sequence_field = $this->_helper->config('abandonedsequence_field');
|
1496 |
-
}
|
1497 |
-
|
1498 |
-
public function abandonedStoreProcessor($store, $check_date)
|
1499 |
-
{
|
1500 |
-
try
|
1501 |
-
{
|
1502 |
-
$store_code = $store->getCode();
|
1503 |
-
|
1504 |
-
$this->_helper->log("Processing Store: {$store_code}");
|
1505 |
-
|
1506 |
-
if (!$this->_helper->getAbandonedEnabled())
|
1507 |
-
{
|
1508 |
-
$this->_helper->logReason($this->_helper->getAbandonedDisabledReason());
|
1509 |
-
return;
|
1510 |
-
}
|
1511 |
-
|
1512 |
-
Mage::helper('emaildirect/fields')->checkFields();
|
1513 |
-
|
1514 |
-
// Setup sequence for this store
|
1515 |
-
$this->setupSequence();
|
1516 |
-
|
1517 |
-
// Get abandoned collection
|
1518 |
-
$collection = Mage::getResourceModel('emaildirect/abandoned_collection');
|
1519 |
-
|
1520 |
-
$collection->prepareForAbandonedProcess($check_date, $store->getId());
|
1521 |
-
|
1522 |
-
$this->_helper->log("SQL: " . $collection->getSelect()->__toString());
|
1523 |
-
|
1524 |
-
$this->_abandonedCartsProcessor($collection, $store->getId());
|
1525 |
-
|
1526 |
-
$this->_helper->log("Finished Processing Store: {$store_code}");
|
1527 |
-
}
|
1528 |
-
catch (Exception $e)
|
1529 |
-
{
|
1530 |
-
Mage::logException($e);
|
1531 |
-
$this->_helper->logException($e);
|
1532 |
-
}
|
1533 |
-
}
|
1534 |
-
|
1535 |
-
public function manualCartsProcessor($store_id = null)
|
1536 |
-
{
|
1537 |
-
try
|
1538 |
-
{
|
1539 |
-
Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);
|
1540 |
-
$this->_helper->setLogArea(EmailDirect_Integration_Helper_Data::ABANDONED_CART);
|
1541 |
-
$this->_helper->log("Manual Abandoned Carts Processor Start");
|
1542 |
-
|
1543 |
-
$check_date = $this->getAbandonedTime();
|
1544 |
-
|
1545 |
-
$this->_helper->log("Check Date: {$check_date}");
|
1546 |
-
|
1547 |
-
$stores = Mage::app()->getStores();
|
1548 |
-
|
1549 |
-
foreach ($stores as $store)
|
1550 |
-
{
|
1551 |
-
if ($store_id == null || $store_id == $store->getId())
|
1552 |
-
{
|
1553 |
-
Mage::app()->setCurrentStore($store->getCode());
|
1554 |
-
|
1555 |
-
$this->abandonedStoreProcessor($store, $check_date);
|
1556 |
-
}
|
1557 |
-
}
|
1558 |
-
|
1559 |
-
Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);
|
1560 |
-
|
1561 |
-
$this->_helper->log("Manual Abandoned Carts Processor End");
|
1562 |
-
}
|
1563 |
-
catch (Exception $e)
|
1564 |
-
{
|
1565 |
-
Mage::logException($e);
|
1566 |
-
$this->_helper->logException($e);
|
1567 |
-
}
|
1568 |
-
}
|
1569 |
-
|
1570 |
-
public function abandonedCartsProcessor()
|
1571 |
-
{
|
1572 |
-
try
|
1573 |
-
{
|
1574 |
-
Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);
|
1575 |
-
$this->_helper->setLogArea(EmailDirect_Integration_Helper_Data::ABANDONED_CART);
|
1576 |
-
$this->_helper->log("Abandoned Carts Processor Start");
|
1577 |
-
|
1578 |
-
$check_date = $this->getAbandonedTime();
|
1579 |
-
|
1580 |
-
$this->_helper->log("Check Date: {$check_date}");
|
1581 |
-
|
1582 |
-
$stores = Mage::app()->getStores();
|
1583 |
-
|
1584 |
-
//$starting_store = Mage::app()->getStore()->getCode();
|
1585 |
-
|
1586 |
-
foreach ($stores as $store)
|
1587 |
-
{
|
1588 |
-
Mage::app()->setCurrentStore($store->getCode());
|
1589 |
-
|
1590 |
-
$this->abandonedStoreProcessor($store, $check_date);
|
1591 |
-
}
|
1592 |
-
|
1593 |
-
Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);
|
1594 |
-
|
1595 |
-
$date = date(Mage::getModel('core/date')->gmtTimestamp());
|
1596 |
-
$date = date($this->_date_format, $date);
|
1597 |
-
|
1598 |
-
$this->_helper->log("Saving Last Cron Run Date: {$date}");
|
1599 |
-
$this->_helper->updateConfig("cron_last_run", $date);
|
1600 |
-
|
1601 |
-
$this->_helper->log("Abandoned Carts Processor End");
|
1602 |
-
}
|
1603 |
-
catch (Exception $e)
|
1604 |
-
{
|
1605 |
-
Mage::logException($e);
|
1606 |
-
$this->_helper->logException($e);
|
1607 |
-
}
|
1608 |
-
}
|
1609 |
-
|
1610 |
-
public function SendAbandonedCarts($id_list)
|
1611 |
-
{
|
1612 |
-
try
|
1613 |
-
{
|
1614 |
-
$count = 0;
|
1615 |
-
|
1616 |
-
Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);
|
1617 |
-
|
1618 |
-
$this->_helper->setLogArea(EmailDirect_Integration_Helper_Data::ABANDONED_CART);
|
1619 |
-
$this->_helper->log("Sending Specific Abandoned Carts Start");
|
1620 |
-
|
1621 |
-
Mage::helper('emaildirect/fields')->checkFields();
|
1622 |
-
|
1623 |
-
$this->_helper->log($id_list, "ID LIST");
|
1624 |
-
|
1625 |
-
$stores = Mage::app()->getStores();
|
1626 |
-
|
1627 |
-
foreach ($stores as $store)
|
1628 |
-
{
|
1629 |
-
$this->_helper->log("Checking for valid carts in store: {$store->getName()} ({$store->getId()})");
|
1630 |
-
if (!Mage::helper('emaildirect')->getAbandonedEnabled($store->getId()))
|
1631 |
-
{
|
1632 |
-
$this->_helper->log('Abandoned Carts not enabled...');
|
1633 |
-
continue;
|
1634 |
-
}
|
1635 |
-
|
1636 |
-
Mage::app()->setCurrentStore($store->getCode());
|
1637 |
-
|
1638 |
-
// Get abandoned collection
|
1639 |
-
$collection = Mage::getResourceModel('emaildirect/abandoned_collection');
|
1640 |
-
|
1641 |
-
$collection->prepareForManualAbandonedProcess($id_list, $store->getId());
|
1642 |
-
|
1643 |
-
$count += count($collection);
|
1644 |
-
|
1645 |
-
$this->_helper->log("SQL: " . $collection->getSelect()->__toString());
|
1646 |
-
|
1647 |
-
|
1648 |
-
$this->_abandonedCartsProcessor($collection, $store, false);
|
1649 |
-
}
|
1650 |
-
|
1651 |
-
Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);
|
1652 |
-
|
1653 |
-
$this->_helper->log("Sending Specific Abandoned Carts End");
|
1654 |
-
|
1655 |
-
return $count;
|
1656 |
-
}
|
1657 |
-
catch (Exception $e)
|
1658 |
-
{
|
1659 |
-
Mage::logException($e);
|
1660 |
-
$this->_helper->logException($e);
|
1661 |
-
$this->_helper->resetCurrentStore();
|
1662 |
-
}
|
1663 |
-
}
|
1664 |
-
|
1665 |
-
private function getAbandonedUrl($quote)
|
1666 |
-
{
|
1667 |
-
// We are using comma separated lists for the ID's and Quantities so that it takes up less
|
1668 |
-
// space when we generate the Querystring
|
1669 |
-
|
1670 |
-
$item_data = array();
|
1671 |
-
|
1672 |
-
foreach ($quote->getAllItems() as $item)
|
1673 |
-
{
|
1674 |
-
$product = $this->getProduct($item);
|
1675 |
-
$parent_id = $item->getParentItemId();
|
1676 |
-
|
1677 |
-
if ($parent_id != null)
|
1678 |
-
{
|
1679 |
-
$item_data[$parent_id]['option'] = $product->getId();
|
1680 |
-
}
|
1681 |
-
else
|
1682 |
-
{
|
1683 |
-
$item_data[$item->getId()]['product_id'] = $product->getId();
|
1684 |
-
$item_data[$item->getId()]['qty'] = $item->getQty();
|
1685 |
-
|
1686 |
-
if ($item->getProductType() == 'grouped')
|
1687 |
-
{
|
1688 |
-
$option = $item->getOptionByCode('product_type');
|
1689 |
-
if ($option)
|
1690 |
-
{
|
1691 |
-
$product = $option->getProduct();
|
1692 |
-
$item_data[$item->getId()]['option'] = $product->getId();
|
1693 |
-
}
|
1694 |
-
}
|
1695 |
-
else if ($item->getProductType() == 'bundle')
|
1696 |
-
{
|
1697 |
-
$option = $item->getOptionByCode('info_buyRequest');
|
1698 |
-
|
1699 |
-
if ($option)
|
1700 |
-
{
|
1701 |
-
$data = unserialize($option->getValue());
|
1702 |
-
|
1703 |
-
$bundle_option = "";
|
1704 |
-
|
1705 |
-
foreach ($data['bundle_option'] as $id => $value)
|
1706 |
-
{
|
1707 |
-
if ($bundle_option != "")
|
1708 |
-
$bundle_option .= "-";
|
1709 |
-
|
1710 |
-
$bundle_option .= "{$id}=";
|
1711 |
-
|
1712 |
-
if (is_array($value))
|
1713 |
-
{
|
1714 |
-
$bundle_option .= implode(":",$value);
|
1715 |
-
}
|
1716 |
-
else
|
1717 |
-
{
|
1718 |
-
$qty = $data['bundle_option_qty'][$id];
|
1719 |
-
$bundle_option .= "{$value}~{$qty}";
|
1720 |
-
}
|
1721 |
-
}
|
1722 |
-
$item_data[$item->getId()]['bundle_option'] = $bundle_option;
|
1723 |
-
}
|
1724 |
-
}
|
1725 |
-
}
|
1726 |
-
}
|
1727 |
-
|
1728 |
-
$ids = "";
|
1729 |
-
$qtys = "";
|
1730 |
-
|
1731 |
-
foreach ($item_data as $item)
|
1732 |
-
{
|
1733 |
-
if ($ids != "")
|
1734 |
-
{
|
1735 |
-
$ids .= ",";
|
1736 |
-
$qtys .= ",";
|
1737 |
-
}
|
1738 |
-
|
1739 |
-
$ids .= $item['product_id'];
|
1740 |
-
$qtys .= $item['qty'];
|
1741 |
-
|
1742 |
-
if (isset($item['bundle_option']))
|
1743 |
-
$ids .= "|{$item['bundle_option']}";
|
1744 |
-
else if (isset($item['option']))
|
1745 |
-
$ids .= "|{$item['option']}";
|
1746 |
-
}
|
1747 |
-
|
1748 |
-
$url_data = array("quote" => $quote->getId(), "id" => $ids, "qty" => $qtys);
|
1749 |
-
|
1750 |
-
$this->_helper->log($url_data, "Abandoned Url Data");
|
1751 |
-
|
1752 |
-
$url = base64_encode(serialize($url_data));
|
1753 |
-
|
1754 |
-
$url = Mage::getUrl('emaildirect/abandoned/restore',array('_secure'=>true)) . "?cart={$url}";
|
1755 |
-
|
1756 |
-
return $url;
|
1757 |
-
}
|
1758 |
-
// END ABANDONED CRON
|
1759 |
-
|
1760 |
-
// START QUOTE SAVE AFTER
|
1761 |
-
public function quoteSaveAfter(Varien_Event_Observer $observer)
|
1762 |
-
{
|
1763 |
-
try
|
1764 |
-
{
|
1765 |
-
$this->_helper->setLogArea(EmailDirect_Integration_Helper_Data::ABANDONED_CART);
|
1766 |
-
$this->_helper->setLogLevel(EmailDirect_Integration_Helper_Data::LOG_LEVEL_LOW);
|
1767 |
-
$this->_helper->log("Quote Save After Start");
|
1768 |
-
|
1769 |
-
Mage::getSingleton('emaildirect/session')->init();
|
1770 |
-
|
1771 |
-
$this->_helper->log("Quote Save After End");
|
1772 |
-
$this->_helper->resetLogLevel();
|
1773 |
-
}
|
1774 |
-
catch (Exception $e)
|
1775 |
-
{
|
1776 |
-
$this->_helper->resetLogLevel();
|
1777 |
-
Mage::logException($e);
|
1778 |
-
$this->_helper->logException($e);
|
1779 |
-
}
|
1780 |
-
}
|
1781 |
-
// END QUOTE SAVE AFTER
|
1782 |
}
|
1 |
<?php
|
2 |
|
3 |
+
class EmailDirect_Integration_Model_Observer extends EmailDirect_Integration_Model_Observer_Abstract
|
4 |
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
//--------------------------------------------------------------------------------------------------
|
6 |
// WISHLIST
|
7 |
|
9 |
{
|
10 |
try
|
11 |
{
|
12 |
+
$this->_setLogArea(EmailDirect_Integration_Helper_Troubleshooting::WISHLIST);
|
13 |
+
//$this->_helper->setLogLevel(EmailDirect_Integration_Helper_Troubleshooting::LOG_LEVEL_LOW);
|
14 |
+
$this->_log('onWishlistProductAddAfter Start');
|
15 |
|
16 |
if (!$this->_helper->canSendWishlist())
|
17 |
{
|
18 |
+
$this->_logReason($this->_helper->getWishlistDisabledReason());
|
19 |
return;
|
20 |
}
|
21 |
|
23 |
|
24 |
$merge_vars = array(
|
25 |
'WishListUrl' => Mage::getUrl('wishlist'),
|
26 |
+
'WishListDate' => Mage::getModel('core/date')->date($this->_date_format)
|
27 |
);
|
28 |
|
29 |
$rc = Mage::getSingleton('emaildirect/wrapper_wishlist')->sendWishlist($customer->getEmail(), $merge_vars);
|
30 |
|
31 |
+
$this->_log('onWishlistProductAddAfter End');
|
32 |
}
|
33 |
catch (Exception $e)
|
34 |
{
|
35 |
Mage::logException($e);
|
36 |
+
$this->_logException($e);
|
37 |
}
|
38 |
}
|
39 |
|
40 |
// WISHLIST END
|
41 |
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
42 |
}
|
app/code/community/EmailDirect/Integration/Model/Observer/Abstract.php
ADDED
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class EmailDirect_Integration_Model_Observer_Abstract
|
4 |
+
{
|
5 |
+
protected $_helper = null;
|
6 |
+
protected $_logger = null;
|
7 |
+
protected $_date_format = EmailDirect_Integration_Helper_Data::DATE_FORMAT;
|
8 |
+
|
9 |
+
public function __construct()
|
10 |
+
{
|
11 |
+
$this->_helper = Mage::helper('emaildirect');
|
12 |
+
$this->_logger = Mage::helper('emaildirect/troubleshooting');
|
13 |
+
}
|
14 |
+
|
15 |
+
protected function _log($data, $prefix = "")
|
16 |
+
{
|
17 |
+
$this->_logger->log($data, $prefix);
|
18 |
+
}
|
19 |
+
|
20 |
+
protected function _logException($e)
|
21 |
+
{
|
22 |
+
$this->_logger->logException($e);
|
23 |
+
}
|
24 |
+
|
25 |
+
protected function _logReason($data)
|
26 |
+
{
|
27 |
+
$this->_logger->logReason($data);
|
28 |
+
}
|
29 |
+
|
30 |
+
protected function _setLogArea($area)
|
31 |
+
{
|
32 |
+
$this->_logger->setLogArea($area);
|
33 |
+
}
|
34 |
+
}
|
app/code/community/EmailDirect/Integration/Model/Order/Observer.php
ADDED
@@ -0,0 +1,323 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class EmailDirect_Integration_Model_Order_Observer extends EmailDirect_Integration_Model_Observer_Abstract
|
4 |
+
{
|
5 |
+
|
6 |
+
public function salesOrderShipmentTrackSaveAfter(Varien_Event_Observer $observer)
|
7 |
+
{
|
8 |
+
try
|
9 |
+
{
|
10 |
+
$order_helper = Mage::helper('emaildirect/order');
|
11 |
+
$this->_setLogArea(EmailDirect_Integration_Helper_Troubleshooting::ORDERS);
|
12 |
+
$this->_log("Sales Order Shipment Track Save After Start");
|
13 |
+
if(!$this->_helper->canEdirect())
|
14 |
+
{
|
15 |
+
$this->_logReason($this->_helper->getDisabledReason());
|
16 |
+
return;
|
17 |
+
}
|
18 |
+
$track = $observer->getEvent()->getTrack();
|
19 |
+
|
20 |
+
$order = $track->getShipment()->getOrder();
|
21 |
+
$shippingMethod = $order->getShippingMethod(); // String in format of 'carrier_method'
|
22 |
+
if (!$shippingMethod)
|
23 |
+
{
|
24 |
+
$this->_logReason("Shipping Method not found");
|
25 |
+
return;
|
26 |
+
}
|
27 |
+
|
28 |
+
$email = $order->getCustomerEmail();
|
29 |
+
|
30 |
+
$merge_vars = array();
|
31 |
+
|
32 |
+
$merge_vars = $order_helper->getTrackingMergeVars($track, $order);
|
33 |
+
|
34 |
+
if ($merge_vars == null)
|
35 |
+
{
|
36 |
+
$this->_logReason("No shipping fields setup");
|
37 |
+
return;
|
38 |
+
}
|
39 |
+
|
40 |
+
$this->_log($merge_vars,"Merge Vars");
|
41 |
+
|
42 |
+
$rc = Mage::getSingleton('emaildirect/wrapper_orders')->addSubscriberTracking($email, $merge_vars);
|
43 |
+
|
44 |
+
$this->_log("Sales Order Shipment Track Save After Start");
|
45 |
+
}
|
46 |
+
catch (Exception $e)
|
47 |
+
{
|
48 |
+
Mage::logException($e);
|
49 |
+
$this->_logException($e);
|
50 |
+
}
|
51 |
+
}
|
52 |
+
|
53 |
+
private function canSendOrder($order, $batch = false)
|
54 |
+
{
|
55 |
+
$ed_order = Mage::getModel('emaildirect/order')->loadByOrderId($order->getId());
|
56 |
+
|
57 |
+
if ($ed_order != null && $ed_order->getDateSent() != null)
|
58 |
+
{
|
59 |
+
$this->_logReason("Order has already been sent.");
|
60 |
+
return false;
|
61 |
+
}
|
62 |
+
|
63 |
+
// Check the old data just in case
|
64 |
+
if ($order->getData('sent_to_emaildirect') != false)
|
65 |
+
{
|
66 |
+
$this->_logReason("Order has already been sent. (Older Version)");
|
67 |
+
$this->setOrderSentToEmailDirect($order, $order->getData('updated_at'));
|
68 |
+
return false;
|
69 |
+
}
|
70 |
+
|
71 |
+
if ($batch)
|
72 |
+
{
|
73 |
+
$this->_log("Batch process. Skipping State/Status Check");
|
74 |
+
return true;
|
75 |
+
}
|
76 |
+
|
77 |
+
$mode = $this->_helper->config('send_field');
|
78 |
+
|
79 |
+
$this->_log("Send Field: {$mode}");
|
80 |
+
|
81 |
+
if ($mode == "state")
|
82 |
+
{
|
83 |
+
$this->_log("Order State: " . $order->getState());
|
84 |
+
|
85 |
+
$states = Mage::helper('emaildirect')->config('send_states');
|
86 |
+
$state_list = explode(",",$states);
|
87 |
+
|
88 |
+
$this->_log("Check States: " . $states);
|
89 |
+
$this->_log($state_list, "State array");
|
90 |
+
|
91 |
+
if (array_search($order->getState(),$state_list) === FALSE)
|
92 |
+
{
|
93 |
+
$this->_logReason("State not setup to send (" . $order->getState() . ")");
|
94 |
+
return false;
|
95 |
+
}
|
96 |
+
}
|
97 |
+
else
|
98 |
+
{
|
99 |
+
$this->_log("Order Status: " . $order->getStatus());
|
100 |
+
|
101 |
+
$statuses = Mage::helper('emaildirect')->config('send_statuses');
|
102 |
+
$status_list = explode(",",$statuses);
|
103 |
+
|
104 |
+
$this->_log("Check Statuses: " . $statuses);
|
105 |
+
$this->_log($status_list, "Status array");
|
106 |
+
|
107 |
+
if (array_search($order->getStatus(),$status_list) === FALSE)
|
108 |
+
{
|
109 |
+
$this->_logReason("Status not setup to send (" . $order->getStatus() . ")");
|
110 |
+
return false;
|
111 |
+
}
|
112 |
+
}
|
113 |
+
|
114 |
+
return true;
|
115 |
+
}
|
116 |
+
|
117 |
+
private function processBatchStoreOrders($store)
|
118 |
+
{
|
119 |
+
try
|
120 |
+
{
|
121 |
+
$store_code = $store->getCode();
|
122 |
+
|
123 |
+
$this->_log("Processing Store: {$store_code}");
|
124 |
+
|
125 |
+
if (!$this->_helper->getBatchEnabled())
|
126 |
+
{
|
127 |
+
$this->_logReason($this->_helper->getBatchDisabledReason());
|
128 |
+
return;
|
129 |
+
}
|
130 |
+
|
131 |
+
Mage::helper('emaildirect/fields')->checkFields();
|
132 |
+
|
133 |
+
// Get order collection
|
134 |
+
$collection = Mage::getResourceModel('emaildirect/order_collection');
|
135 |
+
|
136 |
+
$limit = $this->_helper->config('batch_size');
|
137 |
+
|
138 |
+
$this->_log("Batch Size: [{$limit}]");
|
139 |
+
|
140 |
+
if ($limit != "")
|
141 |
+
{
|
142 |
+
if (!is_numeric($limit))
|
143 |
+
$limit = 100;
|
144 |
+
else
|
145 |
+
$limit = (int)$limit;
|
146 |
+
}
|
147 |
+
|
148 |
+
$collection->getUnsentOrders($store->getId(), $limit);
|
149 |
+
|
150 |
+
$this->_log("SQL: " . $collection->getSelect()->__toString());
|
151 |
+
|
152 |
+
foreach ($collection as $order)
|
153 |
+
{
|
154 |
+
$this->processSavedOrder($order, true);
|
155 |
+
}
|
156 |
+
|
157 |
+
$this->_log("Finished Processing Store: {$store_code}");
|
158 |
+
}
|
159 |
+
catch (Exception $e)
|
160 |
+
{
|
161 |
+
Mage::logException($e);
|
162 |
+
$this->_logException($e);
|
163 |
+
}
|
164 |
+
}
|
165 |
+
|
166 |
+
public function processBatchOrders()
|
167 |
+
{
|
168 |
+
try
|
169 |
+
{
|
170 |
+
Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);
|
171 |
+
$this->_setLogArea(EmailDirect_Integration_Helper_Troubleshooting::ORDERS);
|
172 |
+
$this->_log("Process Batch Orders Start");
|
173 |
+
|
174 |
+
$stores = Mage::app()->getStores();
|
175 |
+
|
176 |
+
foreach ($stores as $store)
|
177 |
+
{
|
178 |
+
Mage::app()->setCurrentStore($store->getCode());
|
179 |
+
|
180 |
+
$this->processBatchStoreOrders($store);
|
181 |
+
}
|
182 |
+
|
183 |
+
Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);
|
184 |
+
|
185 |
+
$this->_log("Process Batch Orders End");
|
186 |
+
}
|
187 |
+
catch (Exception $e)
|
188 |
+
{
|
189 |
+
Mage::logException($e);
|
190 |
+
$this->_logException($e);
|
191 |
+
}
|
192 |
+
}
|
193 |
+
|
194 |
+
public function processSavedOrder($order, $batch = false)
|
195 |
+
{
|
196 |
+
try
|
197 |
+
{
|
198 |
+
$this->_setLogArea(EmailDirect_Integration_Helper_Troubleshooting::ORDERS);
|
199 |
+
$this->_log("Process Saved Order Start");
|
200 |
+
|
201 |
+
$this->_log("Order ID: " . $order->getIncrementId());
|
202 |
+
|
203 |
+
$this->_log("Order Store: " . $order->getStoreId());
|
204 |
+
$starting_store = Mage::app()->getStore()->getCode();
|
205 |
+
|
206 |
+
Mage::app()->setCurrentStore($order->getStoreId());
|
207 |
+
|
208 |
+
if (!$this->_helper->getOrdersEnabled())
|
209 |
+
{
|
210 |
+
$this->_logReason($this->_helper->getOrdersDisabledReason());
|
211 |
+
Mage::app()->setCurrentStore($starting_store);
|
212 |
+
return;
|
213 |
+
}
|
214 |
+
|
215 |
+
if (!$this->canSendOrder($order, $batch))
|
216 |
+
{
|
217 |
+
Mage::app()->setCurrentStore($starting_store);
|
218 |
+
return;
|
219 |
+
}
|
220 |
+
|
221 |
+
$this->_log("Order is ready to send. Processing...");
|
222 |
+
|
223 |
+
$customer = Mage::helper('emaildirect/order')->getOrderCustomer($order);
|
224 |
+
|
225 |
+
$merge_vars = $this->_helper->getMergeVars($customer);
|
226 |
+
|
227 |
+
$merge_vars = Mage::helper('emaildirect/order')->processOrderItems($order, $merge_vars);
|
228 |
+
|
229 |
+
$this->_log($merge_vars, "Merge Vars");
|
230 |
+
|
231 |
+
Mage::helper('emaildirect/fields')->checkFields();
|
232 |
+
|
233 |
+
$rc = Mage::getSingleton('emaildirect/wrapper_orders')->addSubscriberOrder($order->getCustomerEmail(), $order, $merge_vars);
|
234 |
+
|
235 |
+
if (!isset($rc->ErrorCode))
|
236 |
+
$this->setOrderSentToEmailDirect($order);
|
237 |
+
|
238 |
+
$this->_log("Process Saved Order End");
|
239 |
+
}
|
240 |
+
catch (Exception $e)
|
241 |
+
{
|
242 |
+
Mage::logException($e);
|
243 |
+
$this->_logException($e);
|
244 |
+
}
|
245 |
+
|
246 |
+
Mage::app()->setCurrentStore($starting_store);
|
247 |
+
}
|
248 |
+
|
249 |
+
public function orderSaveAfter(Varien_Event_Observer $observer)
|
250 |
+
{
|
251 |
+
try
|
252 |
+
{
|
253 |
+
$this->_setLogArea(EmailDirect_Integration_Helper_Troubleshooting::ORDERS);
|
254 |
+
$this->_log("Order Save After Start");
|
255 |
+
|
256 |
+
if ($this->_helper->getBatchOnly())
|
257 |
+
{
|
258 |
+
$this->_log("Skipping... Batch Processing Only");
|
259 |
+
return;
|
260 |
+
}
|
261 |
+
|
262 |
+
$order = $observer->getEvent()->getOrder();
|
263 |
+
|
264 |
+
$this->processSavedOrder($order);
|
265 |
+
|
266 |
+
$this->_log("Order Save After End");
|
267 |
+
|
268 |
+
return;
|
269 |
+
}
|
270 |
+
catch (Exception $e)
|
271 |
+
{
|
272 |
+
Mage::logException($e);
|
273 |
+
$this->_logException($e);
|
274 |
+
}
|
275 |
+
}
|
276 |
+
|
277 |
+
public function orderSaveAfterAdmin(Varien_Event_Observer $observer)
|
278 |
+
{
|
279 |
+
try
|
280 |
+
{
|
281 |
+
$this->_setLogArea(EmailDirect_Integration_Helper_Troubleshooting::ORDERS);
|
282 |
+
$this->_log("Order Save After (Admin) Start");
|
283 |
+
|
284 |
+
if ($this->_helper->getBatchOnly())
|
285 |
+
{
|
286 |
+
$this->_log("Skipping... Batch Processing Only");
|
287 |
+
return;
|
288 |
+
}
|
289 |
+
|
290 |
+
$order = $observer->getEvent()->getOrder();
|
291 |
+
|
292 |
+
$this->processSavedOrder($order);
|
293 |
+
|
294 |
+
$this->_log("Order Save After (Admin) End");
|
295 |
+
|
296 |
+
return;
|
297 |
+
}
|
298 |
+
catch (Exception $e)
|
299 |
+
{
|
300 |
+
Mage::logException($e);
|
301 |
+
$this->_logException($e);
|
302 |
+
}
|
303 |
+
}
|
304 |
+
|
305 |
+
private function setOrderSentToEmailDirect($order, $date = null)
|
306 |
+
{
|
307 |
+
try
|
308 |
+
{
|
309 |
+
if ($date == null)
|
310 |
+
{
|
311 |
+
$date = date(Mage::getModel('core/date')->gmtTimestamp());
|
312 |
+
$date = date($this->_date_format, $date);
|
313 |
+
}
|
314 |
+
|
315 |
+
$ed_order = Mage::getModel('emaildirect/order')->saveSent($order, $date);
|
316 |
+
}
|
317 |
+
catch (Exception $e)
|
318 |
+
{
|
319 |
+
Mage::logException($e);
|
320 |
+
$this->_logException($e);
|
321 |
+
}
|
322 |
+
}
|
323 |
+
}
|
app/code/community/EmailDirect/Integration/Model/Resource/Setup.php
CHANGED
@@ -2,6 +2,8 @@
|
|
2 |
|
3 |
class EmailDirect_Integration_Model_Resource_Setup extends Mage_Core_Model_Resource_Setup
|
4 |
{
|
|
|
|
|
5 |
public function addEmailDirectTables()
|
6 |
{
|
7 |
$this->run("
|
@@ -40,12 +42,38 @@ class EmailDirect_Integration_Model_Resource_Setup extends Mage_Core_Model_Resou
|
|
40 |
|
41 |
public function addNotification($title, $description, $url = "", $severity = Mage_AdminNotification_Model_Inbox::SEVERITY_NOTICE)
|
42 |
{
|
43 |
-
Mage::getSingleton('adminnotification/inbox')
|
|
|
|
|
|
|
|
|
|
|
44 |
$severity,
|
45 |
$title,
|
46 |
$description,
|
47 |
$url
|
48 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
49 |
}
|
50 |
|
51 |
public function renameOld()
|
@@ -72,4 +100,9 @@ class EmailDirect_Integration_Model_Resource_Setup extends Mage_Core_Model_Resou
|
|
72 |
Mage::helper('emaildirect')->logException($e);
|
73 |
}
|
74 |
}
|
|
|
|
|
|
|
|
|
|
|
75 |
}
|
2 |
|
3 |
class EmailDirect_Integration_Model_Resource_Setup extends Mage_Core_Model_Resource_Setup
|
4 |
{
|
5 |
+
const INSTALL_LOG_FILE_NAME = 'emaildirect_install';
|
6 |
+
|
7 |
public function addEmailDirectTables()
|
8 |
{
|
9 |
$this->run("
|
42 |
|
43 |
public function addNotification($title, $description, $url = "", $severity = Mage_AdminNotification_Model_Inbox::SEVERITY_NOTICE)
|
44 |
{
|
45 |
+
$admin_notification = Mage::getSingleton('adminnotification/inbox');
|
46 |
+
|
47 |
+
// Older versions of Magento don't have this method
|
48 |
+
if (method_exists($admin_notification,"add"))
|
49 |
+
{
|
50 |
+
$admin_notification->add(
|
51 |
$severity,
|
52 |
$title,
|
53 |
$description,
|
54 |
$url
|
55 |
+
);
|
56 |
+
}
|
57 |
+
else
|
58 |
+
{
|
59 |
+
$this->addLegacyNotification($title, $description, $url, $severity);
|
60 |
+
}
|
61 |
+
}
|
62 |
+
|
63 |
+
private function addLegacyNotification($title, $description, $url = "", $severity = Mage_AdminNotification_Model_Inbox::SEVERITY_NOTICE)
|
64 |
+
{
|
65 |
+
if (is_array($description))
|
66 |
+
$description = '<ul><li>' . implode('</li><li>', $description) . '</li></ul>';
|
67 |
+
|
68 |
+
$date = date(EmailDirect_Integration_Helper_Troubleshooting::DATE_FORMAT);
|
69 |
+
Mage::getSingleton('adminnotification/inbox')->parse(array(array(
|
70 |
+
'severity' => $severity,
|
71 |
+
'date_added' => $date,
|
72 |
+
'title' => $title,
|
73 |
+
'description' => $description,
|
74 |
+
'url' => $url,
|
75 |
+
'internal' => $isInternal
|
76 |
+
)));
|
77 |
}
|
78 |
|
79 |
public function renameOld()
|
100 |
Mage::helper('emaildirect')->logException($e);
|
101 |
}
|
102 |
}
|
103 |
+
|
104 |
+
public function install_log($data)
|
105 |
+
{
|
106 |
+
Mage::log($data,null,self::INSTALL_LOG_FILE_NAME . EmailDirect_Integration_Helper_Data::LOG_FILE_EXT, true);
|
107 |
+
}
|
108 |
}
|
app/code/community/EmailDirect/Integration/Model/System/Config/Source/Abandonedlist.php
CHANGED
@@ -4,8 +4,8 @@ class EmailDirect_Integration_Model_System_Config_Source_Abandonedlist
|
|
4 |
{
|
5 |
public function toOptionArray()
|
6 |
{
|
7 |
-
Mage::helper('emaildirect')->setLogArea(
|
8 |
-
Mage::helper('emaildirect')->setLogLevel(
|
9 |
|
10 |
$lists = Mage::getSingleton('emaildirect/wrapper_lists')->getLists();
|
11 |
|
4 |
{
|
5 |
public function toOptionArray()
|
6 |
{
|
7 |
+
Mage::helper('emaildirect/troubleshooting')->setLogArea(EmailDirect_Integration_Helper_Troubleshooting::CONFIG);
|
8 |
+
Mage::helper('emaildirect/troubleshooting')->setLogLevel(EmailDirect_Integration_Helper_Troubleshooting::LOG_LEVEL_LOW);
|
9 |
|
10 |
$lists = Mage::getSingleton('emaildirect/wrapper_lists')->getLists();
|
11 |
|
app/code/community/EmailDirect/Integration/Model/System/Config/Source/Additionallist.php
CHANGED
@@ -4,8 +4,8 @@ class EmailDirect_Integration_Model_System_Config_Source_Additionallist
|
|
4 |
{
|
5 |
public function toOptionArray()
|
6 |
{
|
7 |
-
Mage::helper('emaildirect')->setLogArea(
|
8 |
-
Mage::helper('emaildirect')->setLogLevel(
|
9 |
|
10 |
$lists = Mage::getSingleton('emaildirect/wrapper_lists')->getLists();
|
11 |
|
4 |
{
|
5 |
public function toOptionArray()
|
6 |
{
|
7 |
+
Mage::helper('emaildirect/troubleshooting')->setLogArea(EmailDirect_Integration_Helper_Troubleshooting::CONFIG);
|
8 |
+
Mage::helper('emaildirect/troubleshooting')->setLogLevel(EmailDirect_Integration_Helper_Troubleshooting::LOG_LEVEL_LOW);
|
9 |
|
10 |
$lists = Mage::getSingleton('emaildirect/wrapper_lists')->getLists();
|
11 |
|
app/code/community/EmailDirect/Integration/Model/System/Config/Source/List.php
CHANGED
@@ -4,8 +4,8 @@ class EmailDirect_Integration_Model_System_Config_Source_List
|
|
4 |
{
|
5 |
public function toOptionArray()
|
6 |
{
|
7 |
-
Mage::helper('emaildirect')->setLogArea(
|
8 |
-
Mage::helper('emaildirect')->setLogLevel(
|
9 |
|
10 |
$lists = Mage::getSingleton('emaildirect/wrapper_lists')->getLists();
|
11 |
|
4 |
{
|
5 |
public function toOptionArray()
|
6 |
{
|
7 |
+
Mage::helper('emaildirect/troubleshooting')->setLogArea(EmailDirect_Integration_Helper_Troubleshooting::CONFIG);
|
8 |
+
Mage::helper('emaildirect/troubleshooting')->setLogLevel(EmailDirect_Integration_Helper_Troubleshooting::LOG_LEVEL_LOW);
|
9 |
|
10 |
$lists = Mage::getSingleton('emaildirect/wrapper_lists')->getLists();
|
11 |
|
app/code/community/EmailDirect/Integration/Model/System/Config/Source/Publication.php
CHANGED
@@ -4,8 +4,8 @@ class EmailDirect_Integration_Model_System_Config_Source_Publication
|
|
4 |
{
|
5 |
public function toOptionArray()
|
6 |
{
|
7 |
-
Mage::helper('emaildirect')->setLogArea(
|
8 |
-
Mage::helper('emaildirect')->setLogLevel(
|
9 |
|
10 |
$publications = Mage::getSingleton('emaildirect/wrapper_publications')->getPublications();
|
11 |
|
4 |
{
|
5 |
public function toOptionArray()
|
6 |
{
|
7 |
+
Mage::helper('emaildirect/troubleshooting')->setLogArea(EmailDirect_Integration_Helper_Troubleshooting::CONFIG);
|
8 |
+
Mage::helper('emaildirect/troubleshooting')->setLogLevel(EmailDirect_Integration_Helper_Troubleshooting::LOG_LEVEL_LOW);
|
9 |
|
10 |
$publications = Mage::getSingleton('emaildirect/wrapper_publications')->getPublications();
|
11 |
|
app/code/community/EmailDirect/Integration/Model/System/Config/Source/Sequence.php
CHANGED
@@ -4,8 +4,8 @@ class EmailDirect_Integration_Model_System_Config_Source_Sequence
|
|
4 |
{
|
5 |
public function toOptionArray()
|
6 |
{
|
7 |
-
Mage::helper('emaildirect')->setLogArea(
|
8 |
-
Mage::helper('emaildirect')->setLogLevel(
|
9 |
|
10 |
$fields = Mage::helper('emaildirect')->getEmailDirectColumnOptions();
|
11 |
|
4 |
{
|
5 |
public function toOptionArray()
|
6 |
{
|
7 |
+
Mage::helper('emaildirect/troubleshooting')->setLogArea(EmailDirect_Integration_Helper_Troubleshooting::CONFIG);
|
8 |
+
Mage::helper('emaildirect/troubleshooting')->setLogLevel(EmailDirect_Integration_Helper_Troubleshooting::LOG_LEVEL_LOW);
|
9 |
|
10 |
$fields = Mage::helper('emaildirect')->getEmailDirectColumnOptions();
|
11 |
|
app/code/community/EmailDirect/Integration/Model/System/Config/Source/Source.php
CHANGED
@@ -4,8 +4,8 @@ class EmailDirect_Integration_Model_System_Config_Source_Source
|
|
4 |
{
|
5 |
public function toOptionArray()
|
6 |
{
|
7 |
-
Mage::helper('emaildirect')->setLogArea(
|
8 |
-
Mage::helper('emaildirect')->setLogLevel(
|
9 |
|
10 |
$sources = Mage::getSingleton('emaildirect/wrapper_sources')->getSources();
|
11 |
|
4 |
{
|
5 |
public function toOptionArray()
|
6 |
{
|
7 |
+
Mage::helper('emaildirect/troubleshooting')->setLogArea(EmailDirect_Integration_Helper_Troubleshooting::CONFIG);
|
8 |
+
Mage::helper('emaildirect/troubleshooting')->setLogLevel(EmailDirect_Integration_Helper_Troubleshooting::LOG_LEVEL_LOW);
|
9 |
|
10 |
$sources = Mage::getSingleton('emaildirect/wrapper_sources')->getSources();
|
11 |
|
app/code/community/EmailDirect/Integration/Model/Wrapper/Execute.php
CHANGED
@@ -2,6 +2,12 @@
|
|
2 |
|
3 |
class EmailDirect_Integration_Model_Wrapper_Execute
|
4 |
{
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
private function parseHttpResponse($str)
|
6 |
{
|
7 |
try
|
@@ -14,8 +20,8 @@ class EmailDirect_Integration_Model_Wrapper_Execute
|
|
14 |
}
|
15 |
catch (Exception $e)
|
16 |
{
|
17 |
-
|
18 |
-
|
19 |
|
20 |
return array("code" => "0", "msg" => "Failed to parse HTTP Response");
|
21 |
}
|
@@ -23,35 +29,55 @@ class EmailDirect_Integration_Model_Wrapper_Execute
|
|
23 |
|
24 |
public function sendCommand($command, $subcommand = null, $id= null, $xmldata=null, $method = "POST")
|
25 |
{
|
26 |
-
$
|
27 |
|
28 |
-
if (
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
29 |
{
|
30 |
$strxml = "<Response><ErrorCode>0</ErrorCode><Message>EmailDirect not enabled</Message></Response>";
|
31 |
return simplexml_load_string($strxml);
|
32 |
}
|
33 |
|
34 |
-
$apikey =
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
35 |
|
36 |
-
if (!$apikey)
|
37 |
{
|
38 |
-
$strxml = "<Response><ErrorCode>0</ErrorCode><Message>
|
39 |
return simplexml_load_string($strxml);
|
40 |
}
|
41 |
|
42 |
if ($xmldata != null)
|
43 |
-
$
|
44 |
|
45 |
-
$URL = $
|
46 |
-
$urlsuffix = $
|
47 |
$URL .= $urlsuffix;
|
48 |
if ($id)
|
49 |
$URL .= "/$id";
|
50 |
if ($subcommand)
|
51 |
$URL .= "/$subcommand";
|
52 |
|
53 |
-
$
|
54 |
-
$
|
55 |
|
56 |
$header = array('Content-Type: text/xml','ApiKey: '.$apikey,'Accept: application/xml');
|
57 |
$ch = curl_init($URL);
|
@@ -114,7 +140,7 @@ class EmailDirect_Integration_Model_Wrapper_Execute
|
|
114 |
Mage::throwException($e->getMessage());
|
115 |
}
|
116 |
|
117 |
-
$
|
118 |
|
119 |
return $xml;
|
120 |
}
|
2 |
|
3 |
class EmailDirect_Integration_Model_Wrapper_Execute
|
4 |
{
|
5 |
+
public function __construct()
|
6 |
+
{
|
7 |
+
$this->_helper = Mage::helper('emaildirect');
|
8 |
+
$this->_logger = Mage::helper('emaildirect/troubleshooting');
|
9 |
+
}
|
10 |
+
|
11 |
private function parseHttpResponse($str)
|
12 |
{
|
13 |
try
|
20 |
}
|
21 |
catch (Exception $e)
|
22 |
{
|
23 |
+
$this->_logger->log($e->getMessage(),"Failed to parse HTTP Response");
|
24 |
+
$this->_logger->log($str,"HTTP Response");
|
25 |
|
26 |
return array("code" => "0", "msg" => "Failed to parse HTTP Response");
|
27 |
}
|
29 |
|
30 |
public function sendCommand($command, $subcommand = null, $id= null, $xmldata=null, $method = "POST")
|
31 |
{
|
32 |
+
$debug = $this->_logger->isDebugMode();
|
33 |
|
34 |
+
if ($debug)
|
35 |
+
{
|
36 |
+
$this->_logger->setDebugRequest($xmldata);
|
37 |
+
|
38 |
+
if ($this->_logger->getDebugExecuteMode() == 'request_only')
|
39 |
+
return $xmldata;
|
40 |
+
}
|
41 |
+
|
42 |
+
if (!$this->_helper->canEdirect())
|
43 |
{
|
44 |
$strxml = "<Response><ErrorCode>0</ErrorCode><Message>EmailDirect not enabled</Message></Response>";
|
45 |
return simplexml_load_string($strxml);
|
46 |
}
|
47 |
|
48 |
+
$apikey = $this->_helper->getApiKey();
|
49 |
+
|
50 |
+
$response = $this->sendCommandDirect($apikey, $command, $subcommand,$id,$xmldata,$method);
|
51 |
+
|
52 |
+
if ($debug)
|
53 |
+
{
|
54 |
+
$this->_logger->setDebugResponse($response->saveXml());
|
55 |
+
}
|
56 |
+
return $response;
|
57 |
+
}
|
58 |
+
|
59 |
+
public function sendCommandDirect($apikey, $command, $subcommand = null, $id= null, $xmldata=null, $method = "POST")
|
60 |
+
{
|
61 |
|
62 |
+
if (!$apikey || $apikey == "")
|
63 |
{
|
64 |
+
$strxml = "<Response><ErrorCode>0</ErrorCode><Message>Invalid or Missing APIKey</Message></Response>";
|
65 |
return simplexml_load_string($strxml);
|
66 |
}
|
67 |
|
68 |
if ($xmldata != null)
|
69 |
+
$this->_logger->logXml($xmldata,"Xml Data ({$command})");
|
70 |
|
71 |
+
$URL = $this->_helper->config('urls/accesspoint');
|
72 |
+
$urlsuffix = $this->_helper->config("urls/{$command}");
|
73 |
$URL .= $urlsuffix;
|
74 |
if ($id)
|
75 |
$URL .= "/$id";
|
76 |
if ($subcommand)
|
77 |
$URL .= "/$subcommand";
|
78 |
|
79 |
+
$this->_logger->log("API KEY: {$apikey}");
|
80 |
+
$this->_logger->log("URL: {$URL}");
|
81 |
|
82 |
$header = array('Content-Type: text/xml','ApiKey: '.$apikey,'Accept: application/xml');
|
83 |
$ch = curl_init($URL);
|
140 |
Mage::throwException($e->getMessage());
|
141 |
}
|
142 |
|
143 |
+
$this->_logger->log($xml, "Response");
|
144 |
|
145 |
return $xml;
|
146 |
}
|
app/code/community/EmailDirect/Integration/Model/Wrapper/Orders.php
CHANGED
@@ -12,8 +12,8 @@ class EmailDirect_Integration_Model_Wrapper_Orders extends EmailDirect_Integrati
|
|
12 |
$xml = "<Order>";
|
13 |
if ($email != null)
|
14 |
$xml .= "<EmailAddress><![CDATA[{$email}]]></EmailAddress>";
|
15 |
-
$xml .= "<PurchaseDate
|
16 |
-
$xml .= "<OrderNumber
|
17 |
|
18 |
|
19 |
if (is_array($items))
|
@@ -51,7 +51,7 @@ class EmailDirect_Integration_Model_Wrapper_Orders extends EmailDirect_Integrati
|
|
51 |
if ($weight)
|
52 |
$xml .= "<Weight>{$weight}</Weight>";
|
53 |
$status = 'Completed';
|
54 |
-
$xml .= "<Status
|
55 |
$xml .= "</OrderItem>";
|
56 |
}
|
57 |
$xml .= "</Items>";
|
12 |
$xml = "<Order>";
|
13 |
if ($email != null)
|
14 |
$xml .= "<EmailAddress><![CDATA[{$email}]]></EmailAddress>";
|
15 |
+
$xml .= "<PurchaseDate><![CDATA[{$date}]]></PurchaseDate>";
|
16 |
+
$xml .= "<OrderNumber><![CDATA[{$orderNum}]]></OrderNumber>";
|
17 |
|
18 |
|
19 |
if (is_array($items))
|
51 |
if ($weight)
|
52 |
$xml .= "<Weight>{$weight}</Weight>";
|
53 |
$status = 'Completed';
|
54 |
+
$xml .= "<Status><![CDATA[{$status}]]></Status>";
|
55 |
$xml .= "</OrderItem>";
|
56 |
}
|
57 |
$xml .= "</Items>";
|
app/code/community/EmailDirect/Integration/Model/Wrapper/Publications.php
CHANGED
@@ -24,7 +24,7 @@ class EmailDirect_Integration_Model_Wrapper_Publications
|
|
24 |
public function subscribe($id, $email)
|
25 |
{
|
26 |
$xml = "<Subscribers><EmailAddress>{$email}</EmailAddress></Subscribers>";
|
27 |
-
$rc = Mage::getSingleton('emaildirect/wrapper_execute')->sendCommand('publications','
|
28 |
return $rc;
|
29 |
}
|
30 |
public function unsubscribe($id,$email)
|
24 |
public function subscribe($id, $email)
|
25 |
{
|
26 |
$xml = "<Subscribers><EmailAddress>{$email}</EmailAddress></Subscribers>";
|
27 |
+
$rc = Mage::getSingleton('emaildirect/wrapper_execute')->sendCommand('publications','ForceEmails',$id,$xml);
|
28 |
return $rc;
|
29 |
}
|
30 |
public function unsubscribe($id,$email)
|
app/code/community/EmailDirect/Integration/Model/Wrapper/Subscribers.php
CHANGED
@@ -12,9 +12,9 @@ class EmailDirect_Integration_Model_Wrapper_subscribers extends EmailDirect_Inte
|
|
12 |
$xml = "<Subscriber><EmailAddress>{$email}</EmailAddress>{$custom_fields}{$source_data}{$publication_data}{$list_data}</Subscriber>";
|
13 |
|
14 |
$rc = Mage::getSingleton('emaildirect/wrapper_execute')->sendCommand("subscribers","",$email,$xml,"PUT");
|
15 |
-
if(isset($rc->ErrorCode))
|
16 |
return false;
|
17 |
-
|
18 |
return true;
|
19 |
}
|
20 |
|
@@ -112,7 +112,7 @@ class EmailDirect_Integration_Model_Wrapper_subscribers extends EmailDirect_Inte
|
|
112 |
{
|
113 |
$merge_vars = array('LastLogin' => $date);
|
114 |
|
115 |
-
$rc = $this->subscriberAdd($email, $merge_vars);
|
116 |
|
117 |
if (isset($rc->ErrorCode))
|
118 |
{
|
@@ -120,4 +120,4 @@ class EmailDirect_Integration_Model_Wrapper_subscribers extends EmailDirect_Inte
|
|
120 |
Mage::throwException((string)$rc->Message);
|
121 |
}
|
122 |
}
|
123 |
-
}
|
12 |
$xml = "<Subscriber><EmailAddress>{$email}</EmailAddress>{$custom_fields}{$source_data}{$publication_data}{$list_data}</Subscriber>";
|
13 |
|
14 |
$rc = Mage::getSingleton('emaildirect/wrapper_execute')->sendCommand("subscribers","",$email,$xml,"PUT");
|
15 |
+
if(isset($rc->ErrorCode))
|
16 |
return false;
|
17 |
+
|
18 |
return true;
|
19 |
}
|
20 |
|
112 |
{
|
113 |
$merge_vars = array('LastLogin' => $date);
|
114 |
|
115 |
+
$rc = $this->subscriberAdd($email, $merge_vars, "", false);
|
116 |
|
117 |
if (isset($rc->ErrorCode))
|
118 |
{
|
120 |
Mage::throwException((string)$rc->Message);
|
121 |
}
|
122 |
}
|
123 |
+
}
|
app/code/community/EmailDirect/Integration/controllers/AbandonedController.php
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
class EmailDirect_Integration_AbandonedController extends
|
4 |
-
{
|
5 |
public function restoreAction()
|
6 |
{
|
7 |
try
|
@@ -139,7 +139,7 @@ class EmailDirect_Integration_AbandonedController extends Mage_Core_Controller_F
|
|
139 |
if (!$product)
|
140 |
continue;
|
141 |
|
142 |
-
$item_list[
|
143 |
'product_type' => 'simple',
|
144 |
'product' => $product,
|
145 |
'qty' => $qty
|
@@ -233,7 +233,9 @@ class EmailDirect_Integration_AbandonedController extends Mage_Core_Controller_F
|
|
233 |
|
234 |
// Check to see if we need to remove the quote
|
235 |
// if they aren't logged in then we will need to otherwise when they login the items won't match
|
236 |
-
|
|
|
|
|
237 |
$this->removeOldQuote($original_quote_id);
|
238 |
|
239 |
foreach ($quote->getItemsCollection() as $item)
|
1 |
<?php
|
2 |
|
3 |
+
class EmailDirect_Integration_AbandonedController extends EmailDirect_Integration_Controller_Front_Abstract
|
4 |
+
{
|
5 |
public function restoreAction()
|
6 |
{
|
7 |
try
|
139 |
if (!$product)
|
140 |
continue;
|
141 |
|
142 |
+
$item_list[] = array(
|
143 |
'product_type' => 'simple',
|
144 |
'product' => $product,
|
145 |
'qty' => $qty
|
233 |
|
234 |
// Check to see if we need to remove the quote
|
235 |
// if they aren't logged in then we will need to otherwise when they login the items won't match
|
236 |
+
$test_mode = Mage::app()->getRequest()->getParam('test_mode') == "true";
|
237 |
+
|
238 |
+
if ((!$test_mode && $quote->getId() != $original_quote_id))
|
239 |
$this->removeOldQuote($original_quote_id);
|
240 |
|
241 |
foreach ($quote->getItemsCollection() as $item)
|
app/code/community/EmailDirect/Integration/controllers/Admin/AbandonedController.php
CHANGED
@@ -10,6 +10,15 @@ class EmailDirect_Integration_Admin_AbandonedController extends Mage_Adminhtml_C
|
|
10 |
$this->_setActiveMenu('emaildirect');
|
11 |
$this->renderLayout();
|
12 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
13 |
|
14 |
public function gridAction()
|
15 |
{
|
@@ -26,7 +35,7 @@ class EmailDirect_Integration_Admin_AbandonedController extends Mage_Adminhtml_C
|
|
26 |
{
|
27 |
$store_id = $this->getRequest()->getParam('store_id');
|
28 |
|
29 |
-
Mage::getSingleton('emaildirect/
|
30 |
|
31 |
$msg = "The Abandoned Cart process has been run";
|
32 |
|
@@ -46,7 +55,7 @@ class EmailDirect_Integration_Admin_AbandonedController extends Mage_Adminhtml_C
|
|
46 |
else
|
47 |
{
|
48 |
$id_list = array($id);
|
49 |
-
Mage::getSingleton('emaildirect/
|
50 |
$this->_getSession()->addSuccess(Mage::helper('adminhtml')->__("Abandoned Cart has been sent."));
|
51 |
}
|
52 |
$this->_redirect('*/*/index');
|
@@ -66,7 +75,7 @@ class EmailDirect_Integration_Admin_AbandonedController extends Mage_Adminhtml_C
|
|
66 |
{
|
67 |
try
|
68 |
{
|
69 |
-
$count = Mage::getSingleton('emaildirect/
|
70 |
|
71 |
Mage::getSingleton('adminhtml/session')->addSuccess(
|
72 |
Mage::helper('adminhtml')->__('Total of %d carts(s) were sent.', $count));
|
10 |
$this->_setActiveMenu('emaildirect');
|
11 |
$this->renderLayout();
|
12 |
}
|
13 |
+
|
14 |
+
public function detailsAction()
|
15 |
+
{
|
16 |
+
$this->loadLayout();
|
17 |
+
|
18 |
+
$this->getLayout()->getBlock('head')->setTitle($this->__('EmailDirect Abandoned Carts'));
|
19 |
+
$this->_setActiveMenu('emaildirect');
|
20 |
+
$this->renderLayout();
|
21 |
+
}
|
22 |
|
23 |
public function gridAction()
|
24 |
{
|
35 |
{
|
36 |
$store_id = $this->getRequest()->getParam('store_id');
|
37 |
|
38 |
+
Mage::getSingleton('emaildirect/abandoned_observer')->manualCartsProcessor($store_id);
|
39 |
|
40 |
$msg = "The Abandoned Cart process has been run";
|
41 |
|
55 |
else
|
56 |
{
|
57 |
$id_list = array($id);
|
58 |
+
Mage::getSingleton('emaildirect/abandoned_observer')->SendAbandonedCarts($id_list);
|
59 |
$this->_getSession()->addSuccess(Mage::helper('adminhtml')->__("Abandoned Cart has been sent."));
|
60 |
}
|
61 |
$this->_redirect('*/*/index');
|
75 |
{
|
76 |
try
|
77 |
{
|
78 |
+
$count = Mage::getSingleton('emaildirect/abandoned_observer')->SendAbandonedCarts($id_list);
|
79 |
|
80 |
Mage::getSingleton('adminhtml/session')->addSuccess(
|
81 |
Mage::helper('adminhtml')->__('Total of %d carts(s) were sent.', $count));
|
app/code/community/EmailDirect/Integration/controllers/Admin/DiagnosticController.php
ADDED
@@ -0,0 +1,486 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class EmailDirect_Integration_Admin_DiagnosticController extends Mage_Adminhtml_Controller_Action
|
4 |
+
{
|
5 |
+
private $_logger = null;
|
6 |
+
private $_order = null;
|
7 |
+
private $_quote = null;
|
8 |
+
private $_result = array();
|
9 |
+
|
10 |
+
public function downloadAction()
|
11 |
+
{
|
12 |
+
$filename = $this->getRequest()->getParam('filename');
|
13 |
+
|
14 |
+
$output = $this->getRequest()->getParam('output');
|
15 |
+
|
16 |
+
$this->_prepareDownloadResponse($filename, $output);
|
17 |
+
}
|
18 |
+
|
19 |
+
public function ajaxAction()
|
20 |
+
{
|
21 |
+
$this->_logger = Mage::helper('emaildirect/troubleshooting');
|
22 |
+
$this->_logger->turnOnDebug();
|
23 |
+
|
24 |
+
$method = $this->getRequest()->getParam('method');
|
25 |
+
$success = false;
|
26 |
+
|
27 |
+
switch ($method)
|
28 |
+
{
|
29 |
+
// Orders
|
30 |
+
case "order_last_items": $success = $this->lastOrderItems(); break;
|
31 |
+
case "order_related_items": $success = $this->relatedOrderItems(); break;
|
32 |
+
case "order_full": $success = $this->fullOrder(false); break;
|
33 |
+
case "order_full_request": $success = $this->fullOrder(); break;
|
34 |
+
case "order_custom_fields": $success = $this->customFields(); break;
|
35 |
+
case "tracking_info": $success = $this->trackingInfo(); break;
|
36 |
+
|
37 |
+
// Abandoned
|
38 |
+
case "abandoned_url": $success = $this->AbandonedUrl(); break;
|
39 |
+
case "abandoned_custom_fields": $success = $this->AbandonedCustomFields(); break;
|
40 |
+
case "abandoned_request": $success = $this->abandonedFull(); break;
|
41 |
+
case "abandoned_request_full": $success = $this->abandonedFull(false); break;
|
42 |
+
}
|
43 |
+
|
44 |
+
$this->_logger->turnOffDebug();
|
45 |
+
|
46 |
+
if ($success)
|
47 |
+
$this->setSuccess($this->_output, $this->_logger->getDebugData());
|
48 |
+
|
49 |
+
$this->getResponse()->setBody(json_encode($this->_result));
|
50 |
+
}
|
51 |
+
|
52 |
+
private function getCss()
|
53 |
+
{
|
54 |
+
$css = "<style>
|
55 |
+
|
56 |
+
.diagnostic_table { border-collapse: collapse; }
|
57 |
+
.diagnostic_table tr td { border: solid 1px; padding: 4px; }
|
58 |
+
.diagnostic_table tr td:first-child { font-weight: bold; }
|
59 |
+
|
60 |
+
</style>";
|
61 |
+
|
62 |
+
return $css;
|
63 |
+
}
|
64 |
+
|
65 |
+
private function setSuccess($output, $details)
|
66 |
+
{
|
67 |
+
$this->_result['success'] = true;
|
68 |
+
|
69 |
+
if (is_array($details))
|
70 |
+
$this->_result['details'] = implode("<br />",$details) . "<br /><br />";
|
71 |
+
else
|
72 |
+
$this->_result['details'] = $details;
|
73 |
+
|
74 |
+
$this->_result['output'] = $this->getCss() . $output;
|
75 |
+
|
76 |
+
return true;
|
77 |
+
}
|
78 |
+
|
79 |
+
private function setFailure($message)
|
80 |
+
{
|
81 |
+
$this->_result['success'] = false;
|
82 |
+
$this->_result['error'] = true;
|
83 |
+
|
84 |
+
$this->_result['message'] = $message;
|
85 |
+
|
86 |
+
return false;
|
87 |
+
}
|
88 |
+
|
89 |
+
private function debug($data)
|
90 |
+
{
|
91 |
+
$this->_logger->debug($data);
|
92 |
+
}
|
93 |
+
|
94 |
+
private function debugHeader($data, $level = 2)
|
95 |
+
{
|
96 |
+
$this->_logger->debugHeader($data, $level);
|
97 |
+
}
|
98 |
+
|
99 |
+
private function getOrder()
|
100 |
+
{
|
101 |
+
if ($this->_order != null)
|
102 |
+
return $this->_order;
|
103 |
+
|
104 |
+
$order_id = $this->getRequest()->getParam('item_id');
|
105 |
+
|
106 |
+
$this->_order = Mage::getModel('sales/order')->load($order_id);
|
107 |
+
|
108 |
+
if ($this->_order != null && !$this->_order->getId())
|
109 |
+
$this->_order = null;
|
110 |
+
else
|
111 |
+
Mage::app()->setCurrentStore($this->_order->getStoreId());
|
112 |
+
|
113 |
+
return $this->_order;
|
114 |
+
}
|
115 |
+
|
116 |
+
private function getQuote()
|
117 |
+
{
|
118 |
+
if ($this->_quote != null)
|
119 |
+
return $this->_quote;
|
120 |
+
|
121 |
+
$quote_id = $this->getRequest()->getParam('item_id');
|
122 |
+
$store_id = $this->getRequest()->getParam('store_id');
|
123 |
+
|
124 |
+
$store = Mage::getModel('core/store')->load($store_id);
|
125 |
+
|
126 |
+
$this->_quote = Mage::getModel('sales/quote')->setStore($store)->load($quote_id);
|
127 |
+
|
128 |
+
if ($this->_quote != null && !$this->_quote->getId())
|
129 |
+
$this->_quote = null;
|
130 |
+
else
|
131 |
+
Mage::app()->setCurrentStore($store);
|
132 |
+
|
133 |
+
return $this->_quote;
|
134 |
+
}
|
135 |
+
|
136 |
+
private function decorateArray($array)
|
137 |
+
{
|
138 |
+
//Zend_debug::dump($array);
|
139 |
+
$output = "<table class='diagnostic_table'>";
|
140 |
+
$output .= "<tr>";
|
141 |
+
$keys = array_keys($array);
|
142 |
+
|
143 |
+
foreach ($keys as $key)
|
144 |
+
{
|
145 |
+
$output .= "<th>{$key}</th>";
|
146 |
+
}
|
147 |
+
|
148 |
+
$output .= "</tr>";
|
149 |
+
|
150 |
+
foreach ($array as $row)
|
151 |
+
{
|
152 |
+
$output .= "<tr>";
|
153 |
+
|
154 |
+
foreach ($row as $data)
|
155 |
+
{
|
156 |
+
$output .= "<td>{$data}</td>";
|
157 |
+
}
|
158 |
+
|
159 |
+
$output .= "</tr>";
|
160 |
+
}
|
161 |
+
|
162 |
+
$output .= "</table>";
|
163 |
+
|
164 |
+
return $output;
|
165 |
+
}
|
166 |
+
|
167 |
+
private function arrayToTable($array)
|
168 |
+
{
|
169 |
+
$output = "<table class='diagnostic_table' cellspacing='0'>";
|
170 |
+
|
171 |
+
foreach ($array as $key => $value)
|
172 |
+
{
|
173 |
+
$output .= "<tr><td>{$key}</td><td>{$value}</td></tr>";
|
174 |
+
}
|
175 |
+
|
176 |
+
return $output . "</table>";
|
177 |
+
}
|
178 |
+
|
179 |
+
private function getNumberedKeys($array)
|
180 |
+
{
|
181 |
+
$keys = array();
|
182 |
+
|
183 |
+
foreach ($array as $key => $value)
|
184 |
+
{
|
185 |
+
if (strpos($key,"1") === false)
|
186 |
+
return $keys;
|
187 |
+
|
188 |
+
$keys[] = substr($key,0,strlen($key) - 1);
|
189 |
+
}
|
190 |
+
|
191 |
+
return $keys;
|
192 |
+
}
|
193 |
+
|
194 |
+
private function numberedItemsDisplay($array)
|
195 |
+
{
|
196 |
+
$output = "";
|
197 |
+
|
198 |
+
$keys = $this->getNumberedKeys($array);
|
199 |
+
|
200 |
+
$first_key = $keys[0];
|
201 |
+
|
202 |
+
$count = 1;
|
203 |
+
|
204 |
+
while (isset($array["{$first_key}{$count}"]))
|
205 |
+
{
|
206 |
+
$output .= "<h3>Item # {$count}</h3>";
|
207 |
+
|
208 |
+
$output .= "<table class='diagnostic_table' cellspacing='0'>";
|
209 |
+
|
210 |
+
foreach ($keys as $key)
|
211 |
+
{
|
212 |
+
$output .= "<tr><td>{$key}</td><td>" . $array["{$key}{$count}"] . "</td></tr>";
|
213 |
+
}
|
214 |
+
|
215 |
+
$output .= "</table><br />";
|
216 |
+
|
217 |
+
$count++;
|
218 |
+
}
|
219 |
+
|
220 |
+
|
221 |
+
return $output;
|
222 |
+
}
|
223 |
+
|
224 |
+
private function lastOrderItems()
|
225 |
+
{
|
226 |
+
$order = $this->getOrder();
|
227 |
+
|
228 |
+
if ($order == null)
|
229 |
+
return $this->setFailure("Order not found");
|
230 |
+
|
231 |
+
$this->debugHeader('Last Order Items');
|
232 |
+
|
233 |
+
$this->debug('Order #' . $order->getIncrementId());
|
234 |
+
|
235 |
+
$merge_vars = array();
|
236 |
+
|
237 |
+
$order_helper = Mage::helper('emaildirect/order');
|
238 |
+
|
239 |
+
$merge_vars = $order_helper->getMergeOrderItems($order, $merge_vars);
|
240 |
+
|
241 |
+
$this->debug('');
|
242 |
+
$this->debugHeader('Latest Order Items',1);
|
243 |
+
$this->debug($merge_vars);
|
244 |
+
|
245 |
+
$this->debugHeader('Last Order Items Complete!');
|
246 |
+
|
247 |
+
$this->_output = "<h2>Order Items Diagnostic Results</h2>" . $this->numberedItemsDisplay($merge_vars, 3);
|
248 |
+
|
249 |
+
return true;
|
250 |
+
}
|
251 |
+
|
252 |
+
private function relatedOrderItems()
|
253 |
+
{
|
254 |
+
$order = $this->getOrder();
|
255 |
+
|
256 |
+
if ($order == null)
|
257 |
+
return $this->setFailure("Order not found");
|
258 |
+
|
259 |
+
$this->debugHeader('Related Order Items');
|
260 |
+
|
261 |
+
$this->debug('Order #' . $order->getIncrementId());
|
262 |
+
$this->debug('');
|
263 |
+
|
264 |
+
$merge_vars = array();
|
265 |
+
|
266 |
+
$order_helper = Mage::helper('emaildirect/order');
|
267 |
+
|
268 |
+
$merge_vars = $order_helper->getRelatedOrderItems($order, $merge_vars);
|
269 |
+
|
270 |
+
$this->debugHeader('Related Order Items',1);
|
271 |
+
$this->debug($merge_vars);
|
272 |
+
|
273 |
+
$this->debugHeader('Related Order Items Complete!');
|
274 |
+
|
275 |
+
$this->_output = "<h2>Related Items Diagnostic Results</h2>" . $this->numberedItemsDisplay($merge_vars, 3);
|
276 |
+
|
277 |
+
return true;
|
278 |
+
}
|
279 |
+
|
280 |
+
private function fullOrder($request_only = true)
|
281 |
+
{
|
282 |
+
$order = $this->getOrder();
|
283 |
+
|
284 |
+
if ($order == null)
|
285 |
+
return $this->setFailure("Order not found");
|
286 |
+
|
287 |
+
$customer = Mage::helper('emaildirect/order')->getOrderCustomer($order);
|
288 |
+
|
289 |
+
$merge_vars = Mage::helper('emaildirect/order')->getMergeVars($customer);
|
290 |
+
|
291 |
+
$merge_vars = Mage::helper('emaildirect/order')->processOrderItems($order, $merge_vars);
|
292 |
+
|
293 |
+
//$order_xml = Mage::getSingleton('emaildirect/wrapper_orders')->getOrderXml($order);
|
294 |
+
|
295 |
+
//$this->_logger->debugXml($order_xml);
|
296 |
+
|
297 |
+
if ($request_only)
|
298 |
+
$this->_logger->setDebugExecuteMode('request_only');
|
299 |
+
else
|
300 |
+
$this->_logger->setDebugExecuteMode('full');
|
301 |
+
|
302 |
+
Mage::getSingleton('emaildirect/wrapper_orders')->addSubscriberOrder($order->getCustomerEmail(), $order, $merge_vars);
|
303 |
+
|
304 |
+
$this->_output = "<h2>Full Order Diagnostic Results</h2><h3>Request Xml</h3><pre>" . htmlentities($this->_logger->formatXml($this->_logger->getDebugRequest())) . "</pre>";
|
305 |
+
|
306 |
+
if (!$request_only)
|
307 |
+
{
|
308 |
+
$this->_output .= "<br /><h3>Response Xml</h3><pre>" . htmlentities($this->_logger->formatXml($this->_logger->getDebugResponse())) . "</pre>";
|
309 |
+
}
|
310 |
+
|
311 |
+
return true;
|
312 |
+
}
|
313 |
+
|
314 |
+
private function customFields()
|
315 |
+
{
|
316 |
+
$order = $this->getOrder();
|
317 |
+
|
318 |
+
if ($order == null)
|
319 |
+
return $this->setFailure("Order not found");
|
320 |
+
|
321 |
+
$this->debugHeader('Custom Fields Diagnostic Starting');
|
322 |
+
|
323 |
+
$customer = Mage::helper('emaildirect/order')->getOrderCustomer($order);
|
324 |
+
|
325 |
+
$this->debugHeader('Customer Related Merge Vars',1);
|
326 |
+
|
327 |
+
$customer_vars = Mage::helper('emaildirect/order')->getMergeVars($customer);
|
328 |
+
|
329 |
+
$merge_vars = Mage::helper('emaildirect/order')->processOrderItems($order, $merge_vars);
|
330 |
+
|
331 |
+
//$order_xml = Mage::getSingleton('emaildirect/wrapper_orders')->getOrderXml($order);
|
332 |
+
|
333 |
+
//$this->_logger->debugXml($order_xml);
|
334 |
+
|
335 |
+
$this->_output = "<h2>Custom Fields Diagnostic Results</h2><h3>Customer Fields</h3>" . $this->arrayToTable($customer_vars);
|
336 |
+
$this->_output .= "<br /><h3>Order Fields</h3>" . $this->arrayToTable($merge_vars);
|
337 |
+
|
338 |
+
return true;
|
339 |
+
}
|
340 |
+
|
341 |
+
private function abandonedUrl()
|
342 |
+
{
|
343 |
+
$quote = $this->getQuote();
|
344 |
+
|
345 |
+
if ($quote == null)
|
346 |
+
return $this->setFailure("Quote not found");
|
347 |
+
|
348 |
+
$this->debugHeader('Abandoned URL');
|
349 |
+
|
350 |
+
//$customer = Mage::helper('emaildirect/order')->getOrderCustomer($order);
|
351 |
+
|
352 |
+
//$this->debugHeader('Customer Related Merge Vars',1);
|
353 |
+
|
354 |
+
$url = Mage::helper('emaildirect/abandoned')->getAbandonedUrl($quote);
|
355 |
+
|
356 |
+
$this->_output = "<h2>Abandoned Cart Url (Restore Cart)</h2><p>Click on the link to test it (opens in a new window and won't replace customer cart data)</p>URL: <a target='_blank' href='{$url}&test_mode=true'>{$url}</a>";
|
357 |
+
|
358 |
+
return true;
|
359 |
+
}
|
360 |
+
|
361 |
+
private function abandonedCustomFields()
|
362 |
+
{
|
363 |
+
$quote = $this->getQuote();
|
364 |
+
|
365 |
+
if ($quote == null)
|
366 |
+
return $this->setFailure("Quote not found");
|
367 |
+
|
368 |
+
$this->debugHeader('Custom Fields Diagnostic Starting');
|
369 |
+
|
370 |
+
$abandonedDate = $quote->getUpdatedAt();
|
371 |
+
|
372 |
+
$merge_vars = array();
|
373 |
+
|
374 |
+
$merge_vars['FirstName'] = $quote->getData('customer_firstname');
|
375 |
+
$merge_vars['LastName'] = $quote->getData('customer_lastname');
|
376 |
+
|
377 |
+
$merge_vars['AbandonedDate'] = $abandonedDate;
|
378 |
+
$merge_vars['AbandonedUrl'] = Mage::helper('emaildirect/abandoned')->getAbandonedUrl($quote);
|
379 |
+
|
380 |
+
// Setup sequence for this store
|
381 |
+
Mage::helper('emaildirect/abandoned')->setupSequence();
|
382 |
+
|
383 |
+
Mage::helper('emaildirect/abandoned')->addSequence($merge_vars);
|
384 |
+
|
385 |
+
$merge_vars = Mage::helper('emaildirect/order')->getMergeOrderItems($quote, $merge_vars, "AB");
|
386 |
+
|
387 |
+
|
388 |
+
|
389 |
+
if (Mage::helper('emaildirect')->config('save_latest_order'))
|
390 |
+
{
|
391 |
+
$this->debug("Processing Last Order");
|
392 |
+
$order = Mage::helper('emaildirect/abandoned')->getLastOrder($quote);
|
393 |
+
|
394 |
+
if ($order != null)
|
395 |
+
$merge_vars = Mage::helper('emaildirect/order')->processOrderItems($order, $merge_vars);
|
396 |
+
else
|
397 |
+
$this->debug("Order not found");
|
398 |
+
//$this->_log("Order not found");
|
399 |
+
}
|
400 |
+
|
401 |
+
|
402 |
+
//$order_xml = Mage::getSingleton('emaildirect/wrapper_orders')->getOrderXml($order);
|
403 |
+
|
404 |
+
//$this->_logger->debugXml($order_xml);
|
405 |
+
|
406 |
+
$this->_output = "<h2>Custom Fields Diagnostic Results</h2>";
|
407 |
+
$this->_output .= "<br /><h3>Fields</h3>" . $this->arrayToTable($merge_vars);
|
408 |
+
|
409 |
+
return true;
|
410 |
+
}
|
411 |
+
|
412 |
+
private function getQuoteEmail($quote)
|
413 |
+
{
|
414 |
+
$abandoned_cart = Mage::helper('emaildirect/diagnostic')->getAbandonedCart($quote->getId());
|
415 |
+
|
416 |
+
return $abandoned_cart->getEmail();
|
417 |
+
}
|
418 |
+
|
419 |
+
private function abandonedFull($request_only = true)
|
420 |
+
{
|
421 |
+
$quote = $this->getQuote();
|
422 |
+
|
423 |
+
if ($quote == null)
|
424 |
+
return $this->setFailure("Quote not found");
|
425 |
+
|
426 |
+
$abandonedDate = $quote->getUpdatedAt();
|
427 |
+
|
428 |
+
$email = $quote->getCustomerEmail();
|
429 |
+
|
430 |
+
if ($email == null)
|
431 |
+
$email = $this->getQuoteEmail($quote);
|
432 |
+
|
433 |
+
$merge_vars = array();
|
434 |
+
|
435 |
+
$merge_vars['FirstName'] = $quote->getData('customer_firstname');
|
436 |
+
$merge_vars['LastName'] = $quote->getData('customer_lastname');
|
437 |
+
|
438 |
+
$merge_vars['AbandonedDate'] = $abandonedDate;
|
439 |
+
$merge_vars['AbandonedUrl'] = Mage::helper('emaildirect/abandoned')->getAbandonedUrl($quote);
|
440 |
+
|
441 |
+
// Setup sequence for this store
|
442 |
+
Mage::helper('emaildirect/abandoned')->setupSequence();
|
443 |
+
|
444 |
+
Mage::helper('emaildirect/abandoned')->addSequence($merge_vars);
|
445 |
+
|
446 |
+
$merge_vars = Mage::helper('emaildirect/order')->getMergeOrderItems($quote, $merge_vars, "AB");
|
447 |
+
|
448 |
+
if (Mage::helper('emaildirect')->config('save_latest_order'))
|
449 |
+
{
|
450 |
+
$this->debug("Processing Last Order");
|
451 |
+
$order = Mage::helper('emaildirect/abandoned')->getLastOrder($quote);
|
452 |
+
|
453 |
+
if ($order != null)
|
454 |
+
$merge_vars = Mage::helper('emaildirect/order')->processOrderItems($order, $merge_vars);
|
455 |
+
else
|
456 |
+
$this->debug("Order not found");
|
457 |
+
//$this->_log("Order not found");
|
458 |
+
}
|
459 |
+
|
460 |
+
$xml = Mage::getSingleton('emaildirect/wrapper_abandoned')->getOneSubscriber($email,$merge_vars);
|
461 |
+
|
462 |
+
if ($request_only)
|
463 |
+
$this->_logger->setDebugExecuteMode('request_only');
|
464 |
+
else
|
465 |
+
$this->_logger->setDebugExecuteMode('full');
|
466 |
+
|
467 |
+
$xml = "<Subscribers>{$xml}</Subscribers>";
|
468 |
+
|
469 |
+
//Mage::getSingleton('emaildirect/wrapper_orders')->addSubscriberOrder($order->getCustomerEmail(), $order, $merge_vars);
|
470 |
+
$rc = Mage::getSingleton('emaildirect/wrapper_abandoned')->sendSubscribers($xml);
|
471 |
+
|
472 |
+
$this->_output = "<h2>Abandoned Cart Xml</h2><h3>Request Xml</h3><pre>" . htmlentities($this->_logger->formatXml($this->_logger->getDebugRequest())) . "</pre>";
|
473 |
+
|
474 |
+
if (!$request_only)
|
475 |
+
{
|
476 |
+
$this->_output .= "<br /><h3>Response Xml</h3><pre>" . htmlentities($this->_logger->formatXml($this->_logger->getDebugResponse())) . "</pre>";
|
477 |
+
}
|
478 |
+
return true;
|
479 |
+
}
|
480 |
+
|
481 |
+
private function trackingInfo()
|
482 |
+
{
|
483 |
+
|
484 |
+
return true;
|
485 |
+
}
|
486 |
+
}
|
app/code/community/EmailDirect/Integration/controllers/Admin/ExportController.php
CHANGED
@@ -8,6 +8,7 @@ class EmailDirect_Integration_Admin_ExportController extends Mage_Adminhtml_Cont
|
|
8 |
|
9 |
public function countAction()
|
10 |
{
|
|
|
11 |
try
|
12 |
{
|
13 |
$from = $this->getRequest()->getParam('from');
|
@@ -17,13 +18,14 @@ class EmailDirect_Integration_Admin_ExportController extends Mage_Adminhtml_Cont
|
|
17 |
|
18 |
$orders = Mage::helper('emaildirect')->getOrderExportCollection($from, $to, $include, $store);
|
19 |
|
20 |
-
|
21 |
}
|
22 |
catch (Exception $e)
|
23 |
{
|
24 |
Mage::logException($e);
|
25 |
-
echo "Unknown";
|
26 |
}
|
|
|
|
|
27 |
}
|
28 |
|
29 |
private function setConfigValue($name)
|
@@ -319,14 +321,12 @@ class EmailDirect_Integration_Admin_ExportController extends Mage_Adminhtml_Cont
|
|
319 |
'download_link' => $url,
|
320 |
);
|
321 |
|
322 |
-
$ed_url = $this->getUrl('
|
323 |
$api = Mage::getSingleton('emaildirect/wrapper_ftp');
|
324 |
$rc = $api->upload($ed_url,"magento_" . $this->getExportType() . "s_{$file_name}.csv");
|
325 |
|
326 |
if (isset($rc->ErrorCode))
|
327 |
-
{
|
328 |
$result['error'] = "EmailDirect Error: (" . (string) $rc->ErrorCode . "): " . (string)$rc->Message;
|
329 |
-
}
|
330 |
|
331 |
if ($store != 0)
|
332 |
Mage::app()->setCurrentStore($starting_store);
|
8 |
|
9 |
public function countAction()
|
10 |
{
|
11 |
+
$count = "Unknown";
|
12 |
try
|
13 |
{
|
14 |
$from = $this->getRequest()->getParam('from');
|
18 |
|
19 |
$orders = Mage::helper('emaildirect')->getOrderExportCollection($from, $to, $include, $store);
|
20 |
|
21 |
+
$count = $orders->getSize();
|
22 |
}
|
23 |
catch (Exception $e)
|
24 |
{
|
25 |
Mage::logException($e);
|
|
|
26 |
}
|
27 |
+
|
28 |
+
$this->getResponse()->setBody($count);
|
29 |
}
|
30 |
|
31 |
private function setConfigValue($name)
|
321 |
'download_link' => $url,
|
322 |
);
|
323 |
|
324 |
+
$ed_url = $this->getUrl('ed_integration/export/download') . "filename/{$file_name}/export_type/" . $this->getExportType();
|
325 |
$api = Mage::getSingleton('emaildirect/wrapper_ftp');
|
326 |
$rc = $api->upload($ed_url,"magento_" . $this->getExportType() . "s_{$file_name}.csv");
|
327 |
|
328 |
if (isset($rc->ErrorCode))
|
|
|
329 |
$result['error'] = "EmailDirect Error: (" . (string) $rc->ErrorCode . "): " . (string)$rc->Message;
|
|
|
330 |
|
331 |
if ($store != 0)
|
332 |
Mage::app()->setCurrentStore($starting_store);
|
app/code/community/EmailDirect/Integration/controllers/Admin/TroubleshootingController.php
CHANGED
@@ -2,6 +2,9 @@
|
|
2 |
|
3 |
class EmailDirect_Integration_Admin_TroubleshootingController extends Mage_Adminhtml_Controller_Action
|
4 |
{
|
|
|
|
|
|
|
5 |
public function indexAction()
|
6 |
{
|
7 |
$this->loadLayout();
|
@@ -10,6 +13,82 @@ class EmailDirect_Integration_Admin_TroubleshootingController extends Mage_Admin
|
|
10 |
$this->renderLayout();
|
11 |
}
|
12 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
13 |
public function sendAction()
|
14 |
{
|
15 |
$params = $this->getRequest()->getParams();
|
@@ -22,7 +101,7 @@ class EmailDirect_Integration_Admin_TroubleshootingController extends Mage_Admin
|
|
22 |
$customer['Company'] = $params['customer_company'];
|
23 |
$customer['Comments'] = $params['customer_comments'];
|
24 |
|
25 |
-
$message = Mage::helper('emaildirect')->getReport($customer);
|
26 |
|
27 |
$to = Mage::helper('emaildirect')->troubleConfig('email');
|
28 |
$subject = Mage::helper('emaildirect')->troubleConfig('subject');
|
@@ -32,107 +111,93 @@ class EmailDirect_Integration_Admin_TroubleshootingController extends Mage_Admin
|
|
32 |
$headers .= "Content-type: text/html\r\n";
|
33 |
|
34 |
// now lets send the email.
|
35 |
-
$sent = mail($to, $subject, $message, $headers);
|
36 |
|
37 |
if ($sent)
|
38 |
{
|
39 |
Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('emaildirect')->__('Troubleshooting Report was sent to EmailDirect'));
|
40 |
|
41 |
-
if (isset($params['turn_off']))
|
42 |
-
Mage::helper('emaildirect')->turnOffTroubleshooting();
|
43 |
-
|
44 |
$this->_redirect('adminhtml/system_config/edit/',array('section' => 'emaildirect'));
|
45 |
}
|
46 |
else
|
47 |
{
|
48 |
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('emaildirect')->__('Failed to send Report Email'));
|
49 |
-
|
50 |
-
$this->_redirect('
|
51 |
}
|
52 |
}
|
53 |
|
54 |
public function downloadAction()
|
55 |
{
|
56 |
-
$output = Mage::helper('emaildirect')->getReport();
|
57 |
|
58 |
-
$this->_prepareDownloadResponse(Mage::helper('emaildirect')->troubleConfig('report_file'), $output);
|
59 |
}
|
60 |
-
|
61 |
-
/**
|
62 |
-
* Declare headers and content file in responce for file download
|
63 |
-
*
|
64 |
-
* @param string $fileName
|
65 |
-
* @param string|array $content set to null to avoid starting output, $contentLength should be set explicitly in
|
66 |
-
* that case
|
67 |
-
* @param string $contentType
|
68 |
-
* @param int $contentLength explicit content length, if strlen($content) isn't applicable
|
69 |
-
* @return Mage_Core_Controller_Varien_Action
|
70 |
-
*/
|
71 |
-
protected function _prepareDownloadResponse(
|
72 |
-
$fileName,
|
73 |
-
$content,
|
74 |
-
$contentType = 'application/octet-stream',
|
75 |
-
$contentLength = null)
|
76 |
-
{
|
77 |
-
$session = Mage::getSingleton('admin/session');
|
78 |
-
if ($session->isFirstPageAfterLogin())
|
79 |
-
{
|
80 |
-
$this->_redirect($session->getUser()->getStartupPageUrl());
|
81 |
-
return $this;
|
82 |
-
}
|
83 |
-
|
84 |
-
$isFile = false;
|
85 |
-
$file = null;
|
86 |
-
if (is_array($content))
|
87 |
-
{
|
88 |
-
if (!isset($content['type']) || !isset($content['value']))
|
89 |
-
{
|
90 |
-
return $this;
|
91 |
-
}
|
92 |
-
if ($content['type'] == 'filename')
|
93 |
-
{
|
94 |
-
$isFile = true;
|
95 |
-
$file = $content['value'];
|
96 |
-
$contentLength = filesize($file);
|
97 |
-
}
|
98 |
-
}
|
99 |
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
->setHeader('Content-type', $contentType, true)
|
105 |
-
->setHeader('Content-Length', is_null($contentLength) ? strlen($content) : $contentLength)
|
106 |
-
->setHeader('Content-Disposition', 'attachment; filename="'.$fileName.'"')
|
107 |
-
->setHeader('Last-Modified', date('r'));
|
108 |
|
109 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
110 |
{
|
111 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
112 |
{
|
113 |
-
$
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
$
|
118 |
-
$ioAdapter->open(array('path' => $ioAdapter->dirname($file)));
|
119 |
-
$ioAdapter->streamOpen($file, 'r');
|
120 |
-
while ($buffer = $ioAdapter->streamRead())
|
121 |
{
|
122 |
-
|
|
|
123 |
}
|
124 |
-
|
125 |
-
|
|
|
|
|
|
|
|
|
126 |
{
|
127 |
-
|
|
|
128 |
}
|
129 |
-
|
|
|
|
|
130 |
}
|
131 |
-
else
|
132 |
{
|
133 |
-
$this->
|
|
|
134 |
}
|
135 |
}
|
136 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
137 |
}
|
138 |
}
|
2 |
|
3 |
class EmailDirect_Integration_Admin_TroubleshootingController extends Mage_Adminhtml_Controller_Action
|
4 |
{
|
5 |
+
private $_output = array();
|
6 |
+
private $_config = null;
|
7 |
+
|
8 |
public function indexAction()
|
9 |
{
|
10 |
$this->loadLayout();
|
13 |
$this->renderLayout();
|
14 |
}
|
15 |
|
16 |
+
public function validateAction()
|
17 |
+
{
|
18 |
+
$apikey = $this->getRequest()->getParam('apikey');
|
19 |
+
|
20 |
+
$valid = Mage::helper('emaildirect/troubleshooting')->validateApiKey($apikey);
|
21 |
+
|
22 |
+
$result = array('valid' => $valid);
|
23 |
+
$this->getResponse()->setBody(json_encode($result));
|
24 |
+
}
|
25 |
+
|
26 |
+
private function getLogFile()
|
27 |
+
{
|
28 |
+
$empty = false;
|
29 |
+
$too_large = false;
|
30 |
+
$file_size = Mage::helper('emaildirect/troubleshooting')->getLogFileSize();
|
31 |
+
|
32 |
+
if ($file_size == 0)
|
33 |
+
$empty = true;
|
34 |
+
else
|
35 |
+
$too_large = Mage::helper('emaildirect/troubleshooting')->isLogFileTooLarge();
|
36 |
+
|
37 |
+
$max_size = Mage::helper('emaildirect')->formatSize(Mage::helper('emaildirect/troubleshooting')->getMaxLogFileSize());
|
38 |
+
|
39 |
+
$result = array(
|
40 |
+
'success' => true,
|
41 |
+
'empty' => $empty,
|
42 |
+
'too_large' => $too_large,
|
43 |
+
'max_size' => $max_size,
|
44 |
+
'contents' => Mage::helper('emaildirect/troubleshooting')->getLogFileContents());
|
45 |
+
return $result;
|
46 |
+
}
|
47 |
+
|
48 |
+
public function ajaxAction()
|
49 |
+
{
|
50 |
+
$method = $this->getRequest()->getParam('method');
|
51 |
+
|
52 |
+
$result = array('success' => false);
|
53 |
+
|
54 |
+
switch ($method)
|
55 |
+
{
|
56 |
+
case "status": $result = $this->getStatus(); break;
|
57 |
+
case "log_refresh": $result = $this->getLogFile(); break;
|
58 |
+
case "test_logging": $result = $this->testLogging(); break;
|
59 |
+
case "erase_log": $result = $this->eraseLog(); break;
|
60 |
+
}
|
61 |
+
|
62 |
+
$this->getResponse()->setBody(json_encode($result));
|
63 |
+
|
64 |
+
return $result;
|
65 |
+
}
|
66 |
+
|
67 |
+
private function eraseLog()
|
68 |
+
{
|
69 |
+
Mage::helper('emaildirect/troubleshooting')->eraseLog();
|
70 |
+
|
71 |
+
return $this->getLogFile();
|
72 |
+
}
|
73 |
+
|
74 |
+
private function testLogging()
|
75 |
+
{
|
76 |
+
Mage::helper('emaildirect/troubleshooting')->forceLog('======================= LOG TEST =======================');
|
77 |
+
|
78 |
+
return $this->getLogFile();
|
79 |
+
}
|
80 |
+
|
81 |
+
private function getStatus()
|
82 |
+
{
|
83 |
+
$status = Mage::helper('emaildirect/troubleshooting')->getStatus();
|
84 |
+
|
85 |
+
$result = array();
|
86 |
+
$result['success'] = true;
|
87 |
+
$result['status'] = $status;
|
88 |
+
|
89 |
+
return $result;
|
90 |
+
}
|
91 |
+
|
92 |
public function sendAction()
|
93 |
{
|
94 |
$params = $this->getRequest()->getParams();
|
101 |
$customer['Company'] = $params['customer_company'];
|
102 |
$customer['Comments'] = $params['customer_comments'];
|
103 |
|
104 |
+
$message = Mage::helper('emaildirect/troubleshooting')->getReport($customer);
|
105 |
|
106 |
$to = Mage::helper('emaildirect')->troubleConfig('email');
|
107 |
$subject = Mage::helper('emaildirect')->troubleConfig('subject');
|
111 |
$headers .= "Content-type: text/html\r\n";
|
112 |
|
113 |
// now lets send the email.
|
114 |
+
$sent = mail($to, $subject, $message, $headers);
|
115 |
|
116 |
if ($sent)
|
117 |
{
|
118 |
Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('emaildirect')->__('Troubleshooting Report was sent to EmailDirect'));
|
119 |
|
|
|
|
|
|
|
120 |
$this->_redirect('adminhtml/system_config/edit/',array('section' => 'emaildirect'));
|
121 |
}
|
122 |
else
|
123 |
{
|
124 |
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('emaildirect')->__('Failed to send Report Email'));
|
125 |
+
|
126 |
+
$this->_redirect('ed_integration/admin_troubleshooting/');
|
127 |
}
|
128 |
}
|
129 |
|
130 |
public function downloadAction()
|
131 |
{
|
132 |
+
$output = Mage::helper('emaildirect/troubleshooting')->getReport();
|
133 |
|
134 |
+
$this->_prepareDownloadResponse(Mage::helper('emaildirect')->troubleConfig('report_file'), $output);
|
135 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
136 |
|
137 |
+
private function updateConfig($path, $value)
|
138 |
+
{
|
139 |
+
$this->_config->saveConfig("emaildirect/troubleshooting/{$path}",$value,"default",0);
|
140 |
+
}
|
|
|
|
|
|
|
|
|
141 |
|
142 |
+
public function saveAction()
|
143 |
+
{
|
144 |
+
$params = $this->getRequest()->getParams();
|
145 |
+
|
146 |
+
$this->_config = Mage::getConfig();
|
147 |
+
|
148 |
+
$enabled = $params['logging_enabled'];
|
149 |
+
|
150 |
+
if ($enabled == "yes")
|
151 |
{
|
152 |
+
$this->updateConfig('logging_enabled',1);
|
153 |
+
|
154 |
+
$date_format = EmailDirect_Integration_Helper_Data::DATE_FORMAT;
|
155 |
+
$start_date = date($date_format, Mage::getModel('core/date')->gmtTimestamp());
|
156 |
+
|
157 |
+
$this->updateConfig("logging_start_date",$start_date);
|
158 |
+
|
159 |
+
$advanced_enabled = $params['logging_advanced_enabled'];
|
160 |
+
|
161 |
+
if ($advanced_enabled)
|
162 |
{
|
163 |
+
$this->updateConfig("logging_advanced_enabled", 1);
|
164 |
+
|
165 |
+
$logging_stores = $params['logging_stores'];
|
166 |
+
|
167 |
+
if ($logging_stores == "selected")
|
|
|
|
|
|
|
168 |
{
|
169 |
+
if (isset($params['logging_stores_selected']))
|
170 |
+
$this->updateConfig("logging_stores_selected", implode(",",$params['logging_stores_selected']));
|
171 |
}
|
172 |
+
|
173 |
+
$this->updateConfig("logging_stores", $logging_stores);
|
174 |
+
|
175 |
+
$logging_areas = $params['logging_areas'];
|
176 |
+
|
177 |
+
if ($logging_areas == "selected")
|
178 |
{
|
179 |
+
if (isset($params['logging_areas_selected']))
|
180 |
+
$this->updateConfig("logging_areas_selected", implode(",",$params['logging_areas_selected']));
|
181 |
}
|
182 |
+
|
183 |
+
$this->updateConfig("logging_areas", $logging_areas);
|
184 |
+
$this->updateConfig("logging_duration", $params['logging_duration']);
|
185 |
}
|
186 |
+
else
|
187 |
{
|
188 |
+
$this->updateConfig("logging_duration", 10);
|
189 |
+
$this->updateConfig("logging_advanced_enabled", 0);
|
190 |
}
|
191 |
}
|
192 |
+
else
|
193 |
+
$this->updateConfig('logging_enabled',0);
|
194 |
+
|
195 |
+
$this->updateConfig('diagnostic_enabled',$params['diagnostic_enabled']);
|
196 |
+
|
197 |
+
$this->_config->cleanCache();
|
198 |
+
|
199 |
+
Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('emaildirect')->__('Troubleshooting settings updated!'));
|
200 |
+
|
201 |
+
$this->_redirect("*/*/index",Mage::helper('emaildirect')->getAdminUrlParams(array('tab' => 'troubleshooting_view_tabs_trouble_settings')));
|
202 |
}
|
203 |
}
|
app/code/community/EmailDirect/Integration/controllers/Customer/AccountController.php
CHANGED
@@ -1,7 +1,6 @@
|
|
1 |
<?php
|
2 |
-
class EmailDirect_Integration_Customer_AccountController extends
|
3 |
{
|
4 |
-
|
5 |
/**
|
6 |
* Action predispatch
|
7 |
*
|
@@ -44,38 +43,36 @@ class EmailDirect_Integration_Customer_AccountController extends Mage_Core_Contr
|
|
44 |
|
45 |
public function saveadditionalAction()
|
46 |
{
|
47 |
-
$
|
48 |
-
|
49 |
-
$helper->setLogArea(EmailDirect_Integration_Helper_Data::NEWSLETTER);
|
50 |
-
$helper->log('Save Additional Start');
|
51 |
|
52 |
$session = Mage::getSingleton('customer/session');
|
53 |
|
54 |
if ($this->getRequest()->isPost())
|
55 |
{
|
56 |
$state = $this->getRequest()->getPost('state');
|
57 |
-
$
|
58 |
//<state> param is an html serialized field containing the default form state
|
59 |
//before submission, we need to parse it as a request in order to save it to $odata and process it
|
60 |
parse_str($state, $odata);
|
61 |
|
62 |
-
$
|
63 |
|
64 |
$active_lists = (TRUE === array_key_exists('list', $odata)) ? $odata['list'] : array();
|
65 |
$lists = $this->getRequest()->getPost('list', array());
|
66 |
|
67 |
-
$
|
68 |
|
69 |
$customer = Mage::helper('customer')->getCustomer();
|
70 |
$email = $customer->getEmail();
|
71 |
|
72 |
-
$
|
73 |
|
74 |
// Manage the main publication and subscription
|
75 |
$publication = (TRUE === array_key_exists('publication', $odata)) ? $odata['publication'] : array();
|
76 |
$pub_selection = $this->getRequest()->getPost('publication', array());
|
77 |
|
78 |
-
$
|
79 |
$general = Mage::helper('emaildirect')->config('publication');
|
80 |
|
81 |
$subscriber = Mage::getModel('newsletter/subscriber')->loadByEmail($email);
|
@@ -87,7 +84,7 @@ class EmailDirect_Integration_Customer_AccountController extends Mage_Core_Contr
|
|
87 |
|
88 |
if (!$pub_selection)
|
89 |
{
|
90 |
-
$
|
91 |
|
92 |
// Publication is deslected so Unsubscribe from all.
|
93 |
$rc = Mage::getSingleton('emaildirect/wrapper_publications')->unsubscribe($general,$email);
|
@@ -100,24 +97,24 @@ class EmailDirect_Integration_Customer_AccountController extends Mage_Core_Contr
|
|
100 |
|
101 |
$session->addSuccess('Successfully unsubscribed from Newsletter');
|
102 |
|
103 |
-
$
|
104 |
|
105 |
$this->_redirect('*/*/index');
|
106 |
return;
|
107 |
}
|
108 |
elseif ($publication != $pub_selection)
|
109 |
{
|
110 |
-
$
|
111 |
|
112 |
if($subscriber->isObjectNew())
|
113 |
{
|
114 |
// This code happens when ->subscribe is called below
|
115 |
-
$
|
116 |
|
117 |
$additional_lists = Mage::helper('emaildirect')->config('additional_lists');
|
118 |
if ($additional_lists != "")
|
119 |
{
|
120 |
-
$
|
121 |
$temp_lists = explode(",",$additional_lists);
|
122 |
$active_lists = array();
|
123 |
|
@@ -126,14 +123,14 @@ class EmailDirect_Integration_Customer_AccountController extends Mage_Core_Contr
|
|
126 |
$active_lists[$temp_id] = array('subscribed' => $temp_id);
|
127 |
}
|
128 |
|
129 |
-
$
|
130 |
}
|
131 |
|
132 |
$new_subscriber = true;
|
133 |
}
|
134 |
else
|
135 |
{
|
136 |
-
$
|
137 |
$rc = Mage::getSingleton('emaildirect/wrapper_publications')->subscribe($general,$email);
|
138 |
}
|
139 |
$subscriber->subscribe($email);
|
@@ -141,12 +138,12 @@ class EmailDirect_Integration_Customer_AccountController extends Mage_Core_Contr
|
|
141 |
|
142 |
if( !empty($active_lists) )
|
143 |
{
|
144 |
-
$
|
145 |
foreach($active_lists as $listId => $list)
|
146 |
{
|
147 |
if (FALSE === array_key_exists($listId, $lists))
|
148 |
{
|
149 |
-
$
|
150 |
$rc = Mage::getSingleton('emaildirect/wrapper_lists')->listUnsubscribe($listId, $email);
|
151 |
}
|
152 |
}
|
@@ -156,10 +153,10 @@ class EmailDirect_Integration_Customer_AccountController extends Mage_Core_Contr
|
|
156 |
$subscribe = array_diff_key($lists, $active_lists);
|
157 |
if (!empty($subscribe))
|
158 |
{
|
159 |
-
$
|
160 |
foreach($subscribe as $listId => $slist)
|
161 |
{
|
162 |
-
$
|
163 |
$rc = Mage::getSingleton('emaildirect/wrapper_lists')->listSubscribe($listId, $email);
|
164 |
}
|
165 |
}
|
@@ -167,7 +164,7 @@ class EmailDirect_Integration_Customer_AccountController extends Mage_Core_Contr
|
|
167 |
|
168 |
$session->addSuccess('Subscriptions Updated');
|
169 |
|
170 |
-
$
|
171 |
|
172 |
$this->_redirect('*/*/index');
|
173 |
}
|
1 |
<?php
|
2 |
+
class EmailDirect_Integration_Customer_AccountController extends EmailDirect_Integration_Controller_Front_Abstract
|
3 |
{
|
|
|
4 |
/**
|
5 |
* Action predispatch
|
6 |
*
|
43 |
|
44 |
public function saveadditionalAction()
|
45 |
{
|
46 |
+
$this->_setLogArea(EmailDirect_Integration_Helper_Troubleshooting::NEWSLETTER);
|
47 |
+
$this->_log('Save Additional Start');
|
|
|
|
|
48 |
|
49 |
$session = Mage::getSingleton('customer/session');
|
50 |
|
51 |
if ($this->getRequest()->isPost())
|
52 |
{
|
53 |
$state = $this->getRequest()->getPost('state');
|
54 |
+
$this->_log($state, 'State Serialized');
|
55 |
//<state> param is an html serialized field containing the default form state
|
56 |
//before submission, we need to parse it as a request in order to save it to $odata and process it
|
57 |
parse_str($state, $odata);
|
58 |
|
59 |
+
$this->_log($odata, 'State Data');
|
60 |
|
61 |
$active_lists = (TRUE === array_key_exists('list', $odata)) ? $odata['list'] : array();
|
62 |
$lists = $this->getRequest()->getPost('list', array());
|
63 |
|
64 |
+
$this->_log($lists, 'List Selection');
|
65 |
|
66 |
$customer = Mage::helper('customer')->getCustomer();
|
67 |
$email = $customer->getEmail();
|
68 |
|
69 |
+
$this->_log("Email: {$email}");
|
70 |
|
71 |
// Manage the main publication and subscription
|
72 |
$publication = (TRUE === array_key_exists('publication', $odata)) ? $odata['publication'] : array();
|
73 |
$pub_selection = $this->getRequest()->getPost('publication', array());
|
74 |
|
75 |
+
$this->_log($pub_selection, 'Publication Selection');
|
76 |
$general = Mage::helper('emaildirect')->config('publication');
|
77 |
|
78 |
$subscriber = Mage::getModel('newsletter/subscriber')->loadByEmail($email);
|
84 |
|
85 |
if (!$pub_selection)
|
86 |
{
|
87 |
+
$this->_log("Unsubscribe from All");
|
88 |
|
89 |
// Publication is deslected so Unsubscribe from all.
|
90 |
$rc = Mage::getSingleton('emaildirect/wrapper_publications')->unsubscribe($general,$email);
|
97 |
|
98 |
$session->addSuccess('Successfully unsubscribed from Newsletter');
|
99 |
|
100 |
+
$this->_log("Unsubscribe from all success redirect");
|
101 |
|
102 |
$this->_redirect('*/*/index');
|
103 |
return;
|
104 |
}
|
105 |
elseif ($publication != $pub_selection)
|
106 |
{
|
107 |
+
$this->_log("Publication != Publication Selection");
|
108 |
|
109 |
if($subscriber->isObjectNew())
|
110 |
{
|
111 |
// This code happens when ->subscribe is called below
|
112 |
+
$this->_log("New Subscriber");
|
113 |
|
114 |
$additional_lists = Mage::helper('emaildirect')->config('additional_lists');
|
115 |
if ($additional_lists != "")
|
116 |
{
|
117 |
+
$this->_log("Get New Active Lists");
|
118 |
$temp_lists = explode(",",$additional_lists);
|
119 |
$active_lists = array();
|
120 |
|
123 |
$active_lists[$temp_id] = array('subscribed' => $temp_id);
|
124 |
}
|
125 |
|
126 |
+
$this->_log($active_lists,"New Active Lists Data");
|
127 |
}
|
128 |
|
129 |
$new_subscriber = true;
|
130 |
}
|
131 |
else
|
132 |
{
|
133 |
+
$this->_log("Existing Subscriber");
|
134 |
$rc = Mage::getSingleton('emaildirect/wrapper_publications')->subscribe($general,$email);
|
135 |
}
|
136 |
$subscriber->subscribe($email);
|
138 |
|
139 |
if( !empty($active_lists) )
|
140 |
{
|
141 |
+
$this->_log("Active Lists");
|
142 |
foreach($active_lists as $listId => $list)
|
143 |
{
|
144 |
if (FALSE === array_key_exists($listId, $lists))
|
145 |
{
|
146 |
+
$this->_log("Unsubscribe from list {$listId}");
|
147 |
$rc = Mage::getSingleton('emaildirect/wrapper_lists')->listUnsubscribe($listId, $email);
|
148 |
}
|
149 |
}
|
153 |
$subscribe = array_diff_key($lists, $active_lists);
|
154 |
if (!empty($subscribe))
|
155 |
{
|
156 |
+
$this->_log("Subscribe to new lists");
|
157 |
foreach($subscribe as $listId => $slist)
|
158 |
{
|
159 |
+
$this->_log("Subscribe to list {$listId}");
|
160 |
$rc = Mage::getSingleton('emaildirect/wrapper_lists')->listSubscribe($listId, $email);
|
161 |
}
|
162 |
}
|
164 |
|
165 |
$session->addSuccess('Subscriptions Updated');
|
166 |
|
167 |
+
$this->_log('Save Additional End');
|
168 |
|
169 |
$this->_redirect('*/*/index');
|
170 |
}
|
app/code/community/EmailDirect/Integration/controllers/SignupController.php
ADDED
@@ -0,0 +1,104 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class EmailDirect_Integration_SignupController extends EmailDirect_Integration_Controller_Front_Abstract
|
4 |
+
{
|
5 |
+
private $_test_mode = false;
|
6 |
+
private $_signup_width = 0;
|
7 |
+
private $_signup_height = 0;
|
8 |
+
private $_signup_url = "";
|
9 |
+
private $_signup_delay = 0;
|
10 |
+
private $_signup_opacity = 0;
|
11 |
+
|
12 |
+
private $_active = false;
|
13 |
+
|
14 |
+
public function checkAction()
|
15 |
+
{
|
16 |
+
$result = array();
|
17 |
+
try
|
18 |
+
{
|
19 |
+
if ($this->canShow())
|
20 |
+
{
|
21 |
+
$result['can_show'] = true;
|
22 |
+
$result['html_content'] = $this->getSignupHtml();
|
23 |
+
}
|
24 |
+
else
|
25 |
+
$result['can_show'] = false;
|
26 |
+
}
|
27 |
+
catch (Exception $e)
|
28 |
+
{
|
29 |
+
Mage::logException($e);
|
30 |
+
$result['can_show'] = false;
|
31 |
+
$result['error'] = $e->getMessage();
|
32 |
+
}
|
33 |
+
|
34 |
+
$result['test'] = Mage::helper('emaildirect')->isSignupTest();
|
35 |
+
$this->getResponse()->setBody(json_encode($result));
|
36 |
+
}
|
37 |
+
|
38 |
+
private function canShow()
|
39 |
+
{
|
40 |
+
if (Mage::helper('emaildirect')->isSignupTest())
|
41 |
+
{
|
42 |
+
$request = Mage::app()->getRequest();
|
43 |
+
|
44 |
+
$this->_width = $request->getParam('width');
|
45 |
+
$this->_height = $request->getParam('height');
|
46 |
+
$this->_url = $request->getParam('url');
|
47 |
+
$this->_opacity = $request->getParam('opacity');
|
48 |
+
}
|
49 |
+
else if (!Mage::helper('emaildirect')->canShowSignup())
|
50 |
+
return false;
|
51 |
+
else
|
52 |
+
{
|
53 |
+
$this->_width = Mage::helper('emaildirect')->config('signup_width');
|
54 |
+
$this->_height = Mage::helper('emaildirect')->config('signup_height');
|
55 |
+
$this->_url = Mage::helper('emaildirect')->config('signup_url');
|
56 |
+
$this->_opacity = Mage::helper('emaildirect')->config('signup_opacity');
|
57 |
+
}
|
58 |
+
|
59 |
+
if ($this->_width == "" || $this->_height == "" || $this->_url == "")
|
60 |
+
return false;
|
61 |
+
|
62 |
+
return true;
|
63 |
+
}
|
64 |
+
|
65 |
+
private function getSignupHtml()
|
66 |
+
{
|
67 |
+
$html = "<style type='text/css'>
|
68 |
+
#emaildirect_signup_background
|
69 |
+
{
|
70 |
+
background:rgb(0,0,0);
|
71 |
+
background: transparent\9;
|
72 |
+
background:rgba(0,0,0,{$this->getSignupOpacity()});
|
73 |
+
filter:progid:DXImageTransform.Microsoft.gradient(startColorstr={$this->getSignupOpacityHex()},endColorstr={$this->getSignupOpacityHex()});
|
74 |
+
zoom: 1;
|
75 |
+
}
|
76 |
+
.div:nth-child(n) {
|
77 |
+
filter: none;
|
78 |
+
}
|
79 |
+
</style>
|
80 |
+
|
81 |
+
<div id='emaildirect_signup_background'>
|
82 |
+
<div id='emaildirect_signup' style='width: {$this->_width}px; height: {$this->_height}px;'>
|
83 |
+
<a id='emaildirect_signup_close' href='#' onclick='return closeSignup();'></a>
|
84 |
+
<iframe frameborder='0' src='{$this->_url}' id='ed_form' style='width: 100%; height: 100%;'></iframe>
|
85 |
+
</div>
|
86 |
+
</div>";
|
87 |
+
|
88 |
+
return $html;
|
89 |
+
}
|
90 |
+
|
91 |
+
private function getSignupOpacity()
|
92 |
+
{
|
93 |
+
return ((int)$this->_opacity) / 100;
|
94 |
+
}
|
95 |
+
|
96 |
+
private function getSignupOpacityHex()
|
97 |
+
{
|
98 |
+
$opacity = $this->getSignupOpacity();
|
99 |
+
|
100 |
+
$hex_opacity = dechex(255 * $opacity);
|
101 |
+
|
102 |
+
return "#{$hex_opacity}000000";
|
103 |
+
}
|
104 |
+
}
|
app/code/community/EmailDirect/Integration/etc/adminhtml.xml
CHANGED
@@ -8,8 +8,13 @@
|
|
8 |
<emaildirect_abandoned module='emaildirect'>
|
9 |
<title>Abandoned Carts</title>
|
10 |
<sort_order>100</sort_order>
|
11 |
-
<action>
|
12 |
</emaildirect_abandoned>
|
|
|
|
|
|
|
|
|
|
|
13 |
<emaildirect_config module='emaildirect'>
|
14 |
<title>Configuration</title>
|
15 |
<sort_order>1000</sort_order>
|
8 |
<emaildirect_abandoned module='emaildirect'>
|
9 |
<title>Abandoned Carts</title>
|
10 |
<sort_order>100</sort_order>
|
11 |
+
<action>ed_integration/admin_abandoned</action>
|
12 |
</emaildirect_abandoned>
|
13 |
+
<emaildirect_troubleshooting module='emaildirect'>
|
14 |
+
<title>Troubleshooting</title>
|
15 |
+
<sort_order>110</sort_order>
|
16 |
+
<action>ed_integration/admin_troubleshooting</action>
|
17 |
+
</emaildirect_troubleshooting>
|
18 |
<emaildirect_config module='emaildirect'>
|
19 |
<title>Configuration</title>
|
20 |
<sort_order>1000</sort_order>
|
app/code/community/EmailDirect/Integration/etc/cache.xml
ADDED
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<placeholders>
|
4 |
+
<emaildirect_integration_signup>
|
5 |
+
<block>emaildirect/signup</block>
|
6 |
+
<name>emaildirect_signup</name>
|
7 |
+
<placeholder>EMAILDIRECT_INTEGRATION_SIGNUP_CACHE</placeholder>
|
8 |
+
<container>EmailDirect_Integration_Model_Container_Signup</container>
|
9 |
+
<cache_life>1</cache_life>
|
10 |
+
</emaildirect_integration_signup>
|
11 |
+
</placeholders>
|
12 |
+
</config>
|
app/code/community/EmailDirect/Integration/etc/config.xml
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
<config>
|
3 |
<modules>
|
4 |
<EmailDirect_Integration>
|
5 |
-
<version>2.0.
|
6 |
</EmailDirect_Integration>
|
7 |
</modules>
|
8 |
<global>
|
@@ -18,7 +18,7 @@
|
|
18 |
<newsletter_subscriber_save_before>
|
19 |
<observers>
|
20 |
<emaildirect_subscribe_observer>
|
21 |
-
<class>emaildirect/
|
22 |
<method>handleSubscriber</method>
|
23 |
</emaildirect_subscribe_observer>
|
24 |
</observers>
|
@@ -26,27 +26,11 @@
|
|
26 |
<newsletter_subscriber_delete_after>
|
27 |
<observers>
|
28 |
<emaildirect_subscribe_delete_observer>
|
29 |
-
<class>emaildirect/
|
30 |
<method>handleSubscriberDeletion</method>
|
31 |
</emaildirect_subscribe_delete_observer>
|
32 |
</observers>
|
33 |
</newsletter_subscriber_delete_after>
|
34 |
-
<customer_save_after>
|
35 |
-
<observers>
|
36 |
-
<emaildirect_update_customer>
|
37 |
-
<class>emaildirect/observer</class>
|
38 |
-
<method>updateCustomer</method>
|
39 |
-
</emaildirect_update_customer>
|
40 |
-
</observers>
|
41 |
-
</customer_save_after>
|
42 |
-
<sales_order_save_after>
|
43 |
-
<observers>
|
44 |
-
<emaildirect_order_save_after>
|
45 |
-
<class>emaildirect/observer</class>
|
46 |
-
<method>orderSaveAfter</method>
|
47 |
-
</emaildirect_order_save_after>
|
48 |
-
</observers>
|
49 |
-
</sales_order_save_after>
|
50 |
</events>
|
51 |
<models>
|
52 |
<emaildirect>
|
@@ -130,46 +114,62 @@
|
|
130 |
<controller_action_postdispatch_checkout_onepage_saveOrder>
|
131 |
<observers>
|
132 |
<emaildirect_subscribe_checkout>
|
133 |
-
<class>emaildirect/
|
134 |
<method>registerCheckoutSubscribe</method>
|
135 |
</emaildirect_subscribe_checkout>
|
136 |
</observers>
|
137 |
</controller_action_postdispatch_checkout_onepage_saveOrder>
|
138 |
<checkout_onepage_controller_success_action>
|
139 |
-
|
140 |
<emaildirect_subscribe_checkoutsuccess>
|
141 |
-
<class>emaildirect/
|
142 |
<method>registerCheckoutSuccess</method>
|
143 |
</emaildirect_subscribe_checkoutsuccess>
|
144 |
</observers>
|
145 |
</checkout_onepage_controller_success_action>
|
146 |
<sales_quote_save_after>
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
</sales_quote_save_after>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
154 |
<customer_login>
|
155 |
<observers>
|
156 |
<emaildirect_customer_login>
|
157 |
-
<class>emaildirect/
|
158 |
<method>customerLogin</method>
|
159 |
</emaildirect_customer_login>
|
160 |
</observers>
|
161 |
</customer_login>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
162 |
</events>
|
163 |
</frontend>
|
164 |
<admin>
|
165 |
<routers>
|
166 |
-
<
|
167 |
<use>admin</use>
|
168 |
<args>
|
169 |
<module>EmailDirect_Integration</module>
|
170 |
-
<frontName>
|
171 |
</args>
|
172 |
-
</
|
173 |
</routers>
|
174 |
</admin>
|
175 |
<adminhtml>
|
@@ -193,7 +193,7 @@
|
|
193 |
<core_block_abstract_to_html_before>
|
194 |
<observers>
|
195 |
<emaildirect_newsletter_massaction>
|
196 |
-
<class>emaildirect/
|
197 |
<method>updateNewsletterMassAction</method>
|
198 |
</emaildirect_newsletter_massaction>
|
199 |
</observers>
|
@@ -202,7 +202,7 @@
|
|
202 |
<observers>
|
203 |
<emaildirect_track_save_after>
|
204 |
<type>model</type>
|
205 |
-
<class>emaildirect/
|
206 |
<method>salesOrderShipmentTrackSaveAfter</method>
|
207 |
</emaildirect_track_save_after>
|
208 |
</observers>
|
@@ -210,11 +210,27 @@
|
|
210 |
<admin_system_config_changed_section_emaildirect>
|
211 |
<observers>
|
212 |
<emaildirect_save_config>
|
213 |
-
<class>emaildirect/
|
214 |
<method>saveConfig</method>
|
215 |
</emaildirect_save_config>
|
216 |
</observers>
|
217 |
</admin_system_config_changed_section_emaildirect>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
218 |
</events>
|
219 |
</adminhtml>
|
220 |
<default>
|
@@ -262,7 +278,6 @@ C]]></abandonedsequence_options>
|
|
262 |
<batch_size>200</batch_size>
|
263 |
<batch_date_adjust>-1 week</batch_date_adjust>
|
264 |
<wishlist_enabled>0</wishlist_enabled>
|
265 |
-
<lastlogin_enabled>0</lastlogin_enabled>
|
266 |
</general>
|
267 |
<export>
|
268 |
<include_disabled>1</include_disabled>
|
@@ -271,6 +286,12 @@ C]]></abandonedsequence_options>
|
|
271 |
<setup>0</setup>
|
272 |
</export>
|
273 |
<troubleshooting>
|
|
|
|
|
|
|
|
|
|
|
|
|
274 |
<enabled>0</enabled>
|
275 |
<email>Kevinl@EmailDirect.com</email>
|
276 |
<subject>EmailDirect Magento Module Troubleshooting Report</subject>
|
@@ -288,7 +309,7 @@ C]]></abandonedsequence_options>
|
|
288 |
<!--<cron_expr>*/5 * * * *</cron_expr>--><!-- every 5 minutes for testing -->
|
289 |
</schedule>
|
290 |
<run>
|
291 |
-
<model>emaildirect/
|
292 |
</run>
|
293 |
</emaildirect_integration>
|
294 |
<emaildirect_integration_batch_orders>
|
@@ -297,7 +318,7 @@ C]]></abandonedsequence_options>
|
|
297 |
<!--<cron_expr>*/5 * * * *</cron_expr>--><!-- every 5 minutes for testing -->
|
298 |
</schedule>
|
299 |
<run>
|
300 |
-
<model>emaildirect/
|
301 |
</run>
|
302 |
</emaildirect_integration_batch_orders>
|
303 |
</jobs>
|
2 |
<config>
|
3 |
<modules>
|
4 |
<EmailDirect_Integration>
|
5 |
+
<version>2.0.9</version>
|
6 |
</EmailDirect_Integration>
|
7 |
</modules>
|
8 |
<global>
|
18 |
<newsletter_subscriber_save_before>
|
19 |
<observers>
|
20 |
<emaildirect_subscribe_observer>
|
21 |
+
<class>emaildirect/newsletter_observer</class>
|
22 |
<method>handleSubscriber</method>
|
23 |
</emaildirect_subscribe_observer>
|
24 |
</observers>
|
26 |
<newsletter_subscriber_delete_after>
|
27 |
<observers>
|
28 |
<emaildirect_subscribe_delete_observer>
|
29 |
+
<class>emaildirect/newsletter_observer</class>
|
30 |
<method>handleSubscriberDeletion</method>
|
31 |
</emaildirect_subscribe_delete_observer>
|
32 |
</observers>
|
33 |
</newsletter_subscriber_delete_after>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
34 |
</events>
|
35 |
<models>
|
36 |
<emaildirect>
|
114 |
<controller_action_postdispatch_checkout_onepage_saveOrder>
|
115 |
<observers>
|
116 |
<emaildirect_subscribe_checkout>
|
117 |
+
<class>emaildirect/newsletter_observer</class>
|
118 |
<method>registerCheckoutSubscribe</method>
|
119 |
</emaildirect_subscribe_checkout>
|
120 |
</observers>
|
121 |
</controller_action_postdispatch_checkout_onepage_saveOrder>
|
122 |
<checkout_onepage_controller_success_action>
|
123 |
+
<observers>
|
124 |
<emaildirect_subscribe_checkoutsuccess>
|
125 |
+
<class>emaildirect/newsletter_observer</class>
|
126 |
<method>registerCheckoutSuccess</method>
|
127 |
</emaildirect_subscribe_checkoutsuccess>
|
128 |
</observers>
|
129 |
</checkout_onepage_controller_success_action>
|
130 |
<sales_quote_save_after>
|
131 |
+
<observers>
|
132 |
+
<emaildirect_quote_save_after>
|
133 |
+
<class>emaildirect/abandoned_observer</class>
|
134 |
+
<method>quoteSaveAfter</method>
|
135 |
+
</emaildirect_quote_save_after>
|
136 |
+
</observers>
|
137 |
</sales_quote_save_after>
|
138 |
+
<customer_save_after>
|
139 |
+
<observers>
|
140 |
+
<emaildirect_update_customer>
|
141 |
+
<class>emaildirect/customer_observer</class>
|
142 |
+
<method>updateCustomer</method>
|
143 |
+
</emaildirect_update_customer>
|
144 |
+
</observers>
|
145 |
+
</customer_save_after>
|
146 |
<customer_login>
|
147 |
<observers>
|
148 |
<emaildirect_customer_login>
|
149 |
+
<class>emaildirect/customer_observer</class>
|
150 |
<method>customerLogin</method>
|
151 |
</emaildirect_customer_login>
|
152 |
</observers>
|
153 |
</customer_login>
|
154 |
+
<sales_order_save_after>
|
155 |
+
<observers>
|
156 |
+
<emaildirect_order_save_after>
|
157 |
+
<class>emaildirect/order_observer</class>
|
158 |
+
<method>orderSaveAfter</method>
|
159 |
+
</emaildirect_order_save_after>
|
160 |
+
</observers>
|
161 |
+
</sales_order_save_after>
|
162 |
</events>
|
163 |
</frontend>
|
164 |
<admin>
|
165 |
<routers>
|
166 |
+
<ed_integration>
|
167 |
<use>admin</use>
|
168 |
<args>
|
169 |
<module>EmailDirect_Integration</module>
|
170 |
+
<frontName>ed_integration</frontName>
|
171 |
</args>
|
172 |
+
</ed_integration>
|
173 |
</routers>
|
174 |
</admin>
|
175 |
<adminhtml>
|
193 |
<core_block_abstract_to_html_before>
|
194 |
<observers>
|
195 |
<emaildirect_newsletter_massaction>
|
196 |
+
<class>emaildirect/newsletter_observer</class>
|
197 |
<method>updateNewsletterMassAction</method>
|
198 |
</emaildirect_newsletter_massaction>
|
199 |
</observers>
|
202 |
<observers>
|
203 |
<emaildirect_track_save_after>
|
204 |
<type>model</type>
|
205 |
+
<class>emaildirect/order_observer</class>
|
206 |
<method>salesOrderShipmentTrackSaveAfter</method>
|
207 |
</emaildirect_track_save_after>
|
208 |
</observers>
|
210 |
<admin_system_config_changed_section_emaildirect>
|
211 |
<observers>
|
212 |
<emaildirect_save_config>
|
213 |
+
<class>emaildirect/configuration_observer</class>
|
214 |
<method>saveConfig</method>
|
215 |
</emaildirect_save_config>
|
216 |
</observers>
|
217 |
</admin_system_config_changed_section_emaildirect>
|
218 |
+
<customer_save_after>
|
219 |
+
<observers>
|
220 |
+
<emaildirect_update_customer_admin>
|
221 |
+
<class>emaildirect/customer_observer</class>
|
222 |
+
<method>updateCustomerAdmin</method>
|
223 |
+
</emaildirect_update_customer_admin>
|
224 |
+
</observers>
|
225 |
+
</customer_save_after>
|
226 |
+
<sales_order_save_after>
|
227 |
+
<observers>
|
228 |
+
<emaildirect_order_save_after_admin>
|
229 |
+
<class>emaildirect/order_observer</class>
|
230 |
+
<method>orderSaveAfterAdmin</method>
|
231 |
+
</emaildirect_order_save_after_admin>
|
232 |
+
</observers>
|
233 |
+
</sales_order_save_after>
|
234 |
</events>
|
235 |
</adminhtml>
|
236 |
<default>
|
278 |
<batch_size>200</batch_size>
|
279 |
<batch_date_adjust>-1 week</batch_date_adjust>
|
280 |
<wishlist_enabled>0</wishlist_enabled>
|
|
|
281 |
</general>
|
282 |
<export>
|
283 |
<include_disabled>1</include_disabled>
|
286 |
<setup>0</setup>
|
287 |
</export>
|
288 |
<troubleshooting>
|
289 |
+
<logging_enabled>0</logging_enabled>
|
290 |
+
<logging_duration>10</logging_duration>
|
291 |
+
<logging_stores>all</logging_stores>
|
292 |
+
<logging_areas>all</logging_areas>
|
293 |
+
<diagnostic_enabled>0</diagnostic_enabled>
|
294 |
+
|
295 |
<enabled>0</enabled>
|
296 |
<email>Kevinl@EmailDirect.com</email>
|
297 |
<subject>EmailDirect Magento Module Troubleshooting Report</subject>
|
309 |
<!--<cron_expr>*/5 * * * *</cron_expr>--><!-- every 5 minutes for testing -->
|
310 |
</schedule>
|
311 |
<run>
|
312 |
+
<model>emaildirect/abandoned_observer::abandonedCartsProcessor</model>
|
313 |
</run>
|
314 |
</emaildirect_integration>
|
315 |
<emaildirect_integration_batch_orders>
|
318 |
<!--<cron_expr>*/5 * * * *</cron_expr>--><!-- every 5 minutes for testing -->
|
319 |
</schedule>
|
320 |
<run>
|
321 |
+
<model>emaildirect/order_observer::processBatchOrders</model>
|
322 |
</run>
|
323 |
</emaildirect_integration_batch_orders>
|
324 |
</jobs>
|
app/code/community/EmailDirect/Integration/etc/system.xml
CHANGED
@@ -61,6 +61,15 @@
|
|
61 |
<show_in_store>1</show_in_store>
|
62 |
<comment>Enter your EmailDirect API Key here</comment>
|
63 |
</apikey>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
64 |
<apikey_instructions>
|
65 |
<label>Get your API Key</label>
|
66 |
<frontend_model>emaildirect/adminhtml_system_config_form_field_note</frontend_model>
|
@@ -69,6 +78,7 @@
|
|
69 |
<show_in_website>0</show_in_website>
|
70 |
<show_in_store>1</show_in_store>
|
71 |
</apikey_instructions>
|
|
|
72 |
<checkout_subscribe translate="label comment">
|
73 |
<label>Subscribe On Checkout</label>
|
74 |
<frontend_type>select</frontend_type>
|
@@ -77,7 +87,7 @@
|
|
77 |
<show_in_default>1</show_in_default>
|
78 |
<show_in_website>0</show_in_website>
|
79 |
<show_in_store>1</show_in_store>
|
80 |
-
<comment
|
81 |
</checkout_subscribe>
|
82 |
<publication translate="label comment">
|
83 |
<label>Publication</label>
|
@@ -109,7 +119,7 @@
|
|
109 |
<show_in_website>0</show_in_website>
|
110 |
<show_in_store>1</show_in_store>
|
111 |
<can_be_empty>0</can_be_empty>
|
112 |
-
<comment><![CDATA[This is the main source used with the Magento General Subscription.<br/> If you leave this field blank <
|
113 |
</source>
|
114 |
<override_source translate="label">
|
115 |
<label>Override Source</label>
|
@@ -210,7 +220,7 @@
|
|
210 |
<depends><sendorder>1</sendorder><send_field>status</send_field></depends>
|
211 |
</send_statuses>
|
212 |
<batch_enabled>
|
213 |
-
<label>Send orders in background?</label>
|
214 |
<frontend_type>select</frontend_type>
|
215 |
<source_model>adminhtml/system_config_source_yesno</source_model>
|
216 |
<sort_order>230</sort_order>
|
@@ -451,7 +461,7 @@
|
|
451 |
<show_in_website>0</show_in_website>
|
452 |
<show_in_store>1</show_in_store>
|
453 |
<can_be_empty>1</can_be_empty>
|
454 |
-
<comment
|
455 |
<depends><signup_enabled>1</signup_enabled></depends>
|
456 |
</signup_test_button>
|
457 |
<signup_activated>
|
@@ -486,26 +496,6 @@
|
|
486 |
<comment>Send subscriber Wishlist URL and their most recent Wishlist Date to your EmailDirect database.</comment>
|
487 |
</wishlist_enabled>
|
488 |
|
489 |
-
<!-- Customer Last Login -->
|
490 |
-
<heading_lastlogin translate="label">
|
491 |
-
<label>Customer Last Login</label>
|
492 |
-
<frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
|
493 |
-
<sort_order>700</sort_order>
|
494 |
-
<show_in_default>1</show_in_default>
|
495 |
-
<show_in_website>0</show_in_website>
|
496 |
-
<show_in_store>1</show_in_store>
|
497 |
-
</heading_lastlogin>
|
498 |
-
<lastlogin_enabled translate="label">
|
499 |
-
<label>Send Last Login Date?</label>
|
500 |
-
<frontend_type>select</frontend_type>
|
501 |
-
<source_model>adminhtml/system_config_source_yesno</source_model>
|
502 |
-
<sort_order>710</sort_order>
|
503 |
-
<show_in_default>1</show_in_default>
|
504 |
-
<show_in_website>0</show_in_website>
|
505 |
-
<show_in_store>1</show_in_store>
|
506 |
-
<comment>When customer logs in, send the date to EmailDirect</comment>
|
507 |
-
</lastlogin_enabled>
|
508 |
-
|
509 |
</fields>
|
510 |
</general>
|
511 |
<export translate="label comment">
|
@@ -614,15 +604,40 @@
|
|
614 |
<show_in_store>1</show_in_store>
|
615 |
<expanded>1</expanded>
|
616 |
<fields>
|
617 |
-
|
618 |
-
|
619 |
-
|
620 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
621 |
<show_in_default>1</show_in_default>
|
622 |
<show_in_website>0</show_in_website>
|
623 |
<show_in_store>1</show_in_store>
|
624 |
<comment></comment>
|
625 |
-
</
|
626 |
</fields>
|
627 |
</troubleshooting>
|
628 |
</groups>
|
61 |
<show_in_store>1</show_in_store>
|
62 |
<comment>Enter your EmailDirect API Key here</comment>
|
63 |
</apikey>
|
64 |
+
<apikey_validation translate="label">
|
65 |
+
<label>API Key Status</label>
|
66 |
+
<frontend_model>emaildirect/adminhtml_system_config_form_field_api</frontend_model>
|
67 |
+
<sort_order>22</sort_order>
|
68 |
+
<show_in_default>1</show_in_default>
|
69 |
+
<show_in_website>0</show_in_website>
|
70 |
+
<show_in_store>1</show_in_store>
|
71 |
+
<comment></comment>
|
72 |
+
</apikey_validation>
|
73 |
<apikey_instructions>
|
74 |
<label>Get your API Key</label>
|
75 |
<frontend_model>emaildirect/adminhtml_system_config_form_field_note</frontend_model>
|
78 |
<show_in_website>0</show_in_website>
|
79 |
<show_in_store>1</show_in_store>
|
80 |
</apikey_instructions>
|
81 |
+
|
82 |
<checkout_subscribe translate="label comment">
|
83 |
<label>Subscribe On Checkout</label>
|
84 |
<frontend_type>select</frontend_type>
|
87 |
<show_in_default>1</show_in_default>
|
88 |
<show_in_website>0</show_in_website>
|
89 |
<show_in_store>1</show_in_store>
|
90 |
+
<comment><![CDATA[Show Newsletter Subscribe checkbox in the last Checkout Step (Order Review). <span class='warning'>This may not work if your checkout has been customized!</span>]]></comment>
|
91 |
</checkout_subscribe>
|
92 |
<publication translate="label comment">
|
93 |
<label>Publication</label>
|
119 |
<show_in_website>0</show_in_website>
|
120 |
<show_in_store>1</show_in_store>
|
121 |
<can_be_empty>0</can_be_empty>
|
122 |
+
<comment><![CDATA[This is the main source used with the Magento General Subscription.<br/> If you leave this field blank <strong>Magento</strong> is used]]></comment>
|
123 |
</source>
|
124 |
<override_source translate="label">
|
125 |
<label>Override Source</label>
|
220 |
<depends><sendorder>1</sendorder><send_field>status</send_field></depends>
|
221 |
</send_statuses>
|
222 |
<batch_enabled>
|
223 |
+
<label>Send orders in the background?</label>
|
224 |
<frontend_type>select</frontend_type>
|
225 |
<source_model>adminhtml/system_config_source_yesno</source_model>
|
226 |
<sort_order>230</sort_order>
|
461 |
<show_in_website>0</show_in_website>
|
462 |
<show_in_store>1</show_in_store>
|
463 |
<can_be_empty>1</can_be_empty>
|
464 |
+
<comment><![CDATA[Test the signup form popup (opens in new window).<br />Note: "Show EmailDirect Signup form" must be set to "Yes" and the configuration saved in order to perform a signup test.]]></comment>
|
465 |
<depends><signup_enabled>1</signup_enabled></depends>
|
466 |
</signup_test_button>
|
467 |
<signup_activated>
|
496 |
<comment>Send subscriber Wishlist URL and their most recent Wishlist Date to your EmailDirect database.</comment>
|
497 |
</wishlist_enabled>
|
498 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
499 |
</fields>
|
500 |
</general>
|
501 |
<export translate="label comment">
|
604 |
<show_in_store>1</show_in_store>
|
605 |
<expanded>1</expanded>
|
606 |
<fields>
|
607 |
+
<heading_logging translate="label">
|
608 |
+
<label>Logging</label>
|
609 |
+
<frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
|
610 |
+
<sort_order>10</sort_order>
|
611 |
+
<show_in_default>1</show_in_default>
|
612 |
+
<show_in_website>0</show_in_website>
|
613 |
+
<show_in_store>1</show_in_store>
|
614 |
+
</heading_logging>
|
615 |
+
<logging translate="label">
|
616 |
+
<label>Status</label>
|
617 |
+
<frontend_model>emaildirect/adminhtml_system_config_form_field_logging</frontend_model>
|
618 |
+
<sort_order>20</sort_order>
|
619 |
+
<show_in_default>1</show_in_default>
|
620 |
+
<show_in_website>0</show_in_website>
|
621 |
+
<show_in_store>1</show_in_store>
|
622 |
+
<comment></comment>
|
623 |
+
</logging>
|
624 |
+
<heading_diagnostics translate="label">
|
625 |
+
<label>Diagnostics</label>
|
626 |
+
<frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
|
627 |
+
<sort_order>200</sort_order>
|
628 |
+
<show_in_default>1</show_in_default>
|
629 |
+
<show_in_website>0</show_in_website>
|
630 |
+
<show_in_store>1</show_in_store>
|
631 |
+
</heading_diagnostics>
|
632 |
+
<diagnostics translate="label">
|
633 |
+
<label>Status</label>
|
634 |
+
<frontend_model>emaildirect/adminhtml_system_config_form_field_diagnostics</frontend_model>
|
635 |
+
<sort_order>210</sort_order>
|
636 |
<show_in_default>1</show_in_default>
|
637 |
<show_in_website>0</show_in_website>
|
638 |
<show_in_store>1</show_in_store>
|
639 |
<comment></comment>
|
640 |
+
</diagnostics>
|
641 |
</fields>
|
642 |
</troubleshooting>
|
643 |
</groups>
|
app/code/community/EmailDirect/Integration/sql/emaildirect_setup/mysql4-install-2.0.0.php
CHANGED
@@ -18,7 +18,7 @@ try
|
|
18 |
}
|
19 |
catch (Exception $e)
|
20 |
{
|
21 |
-
|
22 |
}
|
23 |
|
24 |
$installer->endSetup();
|
18 |
}
|
19 |
catch (Exception $e)
|
20 |
{
|
21 |
+
$this->install_log($e->getMessage());
|
22 |
}
|
23 |
|
24 |
$installer->endSetup();
|
app/code/community/EmailDirect/Integration/sql/emaildirect_setup/mysql4-upgrade-1.5.8-2.0.0.php
CHANGED
@@ -13,7 +13,7 @@ try
|
|
13 |
}
|
14 |
catch (Exception $e)
|
15 |
{
|
16 |
-
|
17 |
}
|
18 |
|
19 |
$installer->endSetup();
|
13 |
}
|
14 |
catch (Exception $e)
|
15 |
{
|
16 |
+
$this->install_log($e->getMessage());
|
17 |
}
|
18 |
|
19 |
$installer->endSetup();
|
app/design/adminhtml/default/default/layout/emaildirect.xml
CHANGED
@@ -8,8 +8,20 @@
|
|
8 |
<block type="core/template" name="emaildirect_setup_check" before="-" template="emaildirect/system/config/setup_check.phtml" />
|
9 |
</reference>
|
10 |
</adminhtml_system_config_edit>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
|
12 |
-
<
|
13 |
<remove name="root"/>
|
14 |
<block type="adminhtml/page" name="convert_root" output="toHtml" template="page.phtml">
|
15 |
<block type="adminhtml/page_head" name="convert_root_head" as="head" template="page/head.phtml">
|
@@ -22,9 +34,9 @@
|
|
22 |
</block>
|
23 |
<block type="emaildirect/adminhtml_system_convert_profile_export_products" name="system_convert_profile_run" template="emaildirect/system/convert/profile/export.phtml" output="toHtml"/>
|
24 |
</block>
|
25 |
-
</
|
26 |
|
27 |
-
<
|
28 |
<remove name="root"/>
|
29 |
<block type="adminhtml/page" name="convert_root" output="toHtml" template="page.phtml">
|
30 |
<block type="adminhtml/page_head" name="convert_root_head" as="head" template="page/head.phtml">
|
@@ -37,41 +49,58 @@
|
|
37 |
</block>
|
38 |
<block type="emaildirect/adminhtml_system_convert_profile_export_orders" name="system_convert_profile_run" template="emaildirect/system/convert/profile/export.phtml" output="toHtml"/>
|
39 |
</block>
|
40 |
-
</
|
41 |
|
42 |
-
<
|
43 |
<reference name="head">
|
44 |
-
<action method="addCss"><stylesheet>emaildirect/emaildirect.css</stylesheet>
|
45 |
-
</action>
|
46 |
-
|
47 |
</reference>
|
48 |
<reference name="content">
|
49 |
-
|
50 |
-
|
|
|
|
|
|
|
51 |
<reference name="left">
|
52 |
-
<block type="emaildirect/adminhtml_troubleshooting_tabs" name="trouble.tabs" as="trouble.tabs" template="widget/tabs.phtml" >
|
53 |
-
<
|
54 |
-
|
55 |
-
</block>
|
56 |
-
<action method="addTab"><name>trouble_info</name><block>troubleshooting_tab_info</block></action>
|
57 |
<action method="addTab"><name>trouble_log</name><block>emaildirect/adminhtml_troubleshooting_view_tab_log</block></action>
|
58 |
<action method="addTab"><name>trouble_submit</name><block>emaildirect/adminhtml_troubleshooting_view_tab_submit</block></action>
|
59 |
<action method="addTab"><name>trouble_download</name><block>emaildirect/adminhtml_troubleshooting_view_tab_download</block></action>
|
60 |
-
|
61 |
-
</block>
|
62 |
-
<!--<block type="emaildirect/adminhtml_troubleshooting" name="troubleshooting_details" template="emaildirect/troubleshooting/details.phtml" />-->
|
63 |
</reference>
|
64 |
-
</
|
65 |
|
66 |
-
<
|
67 |
<reference name="head">
|
68 |
<action method="addCss"><stylesheet>emaildirect/emaildirect.css</stylesheet></action>
|
69 |
</reference>
|
70 |
<reference name="content">
|
71 |
-
<block type="emaildirect/adminhtml_abandoned" name="
|
72 |
-
|
73 |
-
<!-- <block type="emaildirect/adminhtml_abandoned_status" name="grid.filter.form" as="grid.filter.form" template="emaildirect/abandoned/status.phtml"/>-->
|
74 |
</block>
|
75 |
</reference>
|
76 |
-
</
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
77 |
</layout>
|
8 |
<block type="core/template" name="emaildirect_setup_check" before="-" template="emaildirect/system/config/setup_check.phtml" />
|
9 |
</reference>
|
10 |
</adminhtml_system_config_edit>
|
11 |
+
|
12 |
+
<adminhtml_sales_order_view>
|
13 |
+
<reference name="sales_order_tabs">
|
14 |
+
<block type="emaildirect/adminhtml_order_view_tab_diagnostics" name="order_view_tab_emaildirect" template="emaildirect/diagnostics.phtml">
|
15 |
+
<block type="emaildirect/adminhtml_order_view_tab_diagnostics_status" name="diagnostic_status" template="emaildirect/order/view/tab/diagnostics/status.phtml"></block>
|
16 |
+
</block>
|
17 |
+
<action method="addTab">
|
18 |
+
<name>order_view_tab_emaildirect</name>
|
19 |
+
<block>order_view_tab_emaildirect</block>
|
20 |
+
</action>
|
21 |
+
</reference>
|
22 |
+
</adminhtml_sales_order_view>
|
23 |
|
24 |
+
<ed_integration_admin_export_products>
|
25 |
<remove name="root"/>
|
26 |
<block type="adminhtml/page" name="convert_root" output="toHtml" template="page.phtml">
|
27 |
<block type="adminhtml/page_head" name="convert_root_head" as="head" template="page/head.phtml">
|
34 |
</block>
|
35 |
<block type="emaildirect/adminhtml_system_convert_profile_export_products" name="system_convert_profile_run" template="emaildirect/system/convert/profile/export.phtml" output="toHtml"/>
|
36 |
</block>
|
37 |
+
</ed_integration_admin_export_products>
|
38 |
|
39 |
+
<ed_integration_admin_export_orders>
|
40 |
<remove name="root"/>
|
41 |
<block type="adminhtml/page" name="convert_root" output="toHtml" template="page.phtml">
|
42 |
<block type="adminhtml/page_head" name="convert_root_head" as="head" template="page/head.phtml">
|
49 |
</block>
|
50 |
<block type="emaildirect/adminhtml_system_convert_profile_export_orders" name="system_convert_profile_run" template="emaildirect/system/convert/profile/export.phtml" output="toHtml"/>
|
51 |
</block>
|
52 |
+
</ed_integration_admin_export_orders>
|
53 |
|
54 |
+
<ed_integration_admin_troubleshooting_index>
|
55 |
<reference name="head">
|
56 |
+
<action method="addCss"><stylesheet>emaildirect/emaildirect.css</stylesheet></action>
|
|
|
|
|
57 |
</reference>
|
58 |
<reference name="content">
|
59 |
+
<block type="emaildirect/adminhtml_troubleshooting_view" name="troubleshooting_view">
|
60 |
+
<block type="emaildirect/adminhtml_troubleshooting_status" name="troubleshooting_status" template='emaildirect/troubleshooting/status.phtml'>
|
61 |
+
</block>
|
62 |
+
</block>
|
63 |
+
</reference>
|
64 |
<reference name="left">
|
65 |
+
<block type="emaildirect/adminhtml_troubleshooting_tabs" name="trouble.tabs" as="trouble.tabs" template="widget/tabs.phtml" >
|
66 |
+
<action method="addTab"><name>trouble_help</name><block>emaildirect/adminhtml_troubleshooting_view_tab_help</block></action>
|
67 |
+
<action method="addTab"><name>trouble_settings</name><block>emaildirect/adminhtml_troubleshooting_view_tab_settings</block></action>
|
68 |
+
<action method="addTab"><name>trouble_info</name><block>emaildirect/adminhtml_troubleshooting_view_tab_info</block></action>
|
|
|
69 |
<action method="addTab"><name>trouble_log</name><block>emaildirect/adminhtml_troubleshooting_view_tab_log</block></action>
|
70 |
<action method="addTab"><name>trouble_submit</name><block>emaildirect/adminhtml_troubleshooting_view_tab_submit</block></action>
|
71 |
<action method="addTab"><name>trouble_download</name><block>emaildirect/adminhtml_troubleshooting_view_tab_download</block></action>
|
72 |
+
</block>
|
|
|
|
|
73 |
</reference>
|
74 |
+
</ed_integration_admin_troubleshooting_index>
|
75 |
|
76 |
+
<ed_integration_admin_abandoned_index>
|
77 |
<reference name="head">
|
78 |
<action method="addCss"><stylesheet>emaildirect/emaildirect.css</stylesheet></action>
|
79 |
</reference>
|
80 |
<reference name="content">
|
81 |
+
<block type="emaildirect/adminhtml_abandoned" name="abandoned_cart">
|
|
|
|
|
82 |
</block>
|
83 |
</reference>
|
84 |
+
</ed_integration_admin_abandoned_index>
|
85 |
+
|
86 |
+
<ed_integration_admin_abandoned_details>
|
87 |
+
<reference name="head">
|
88 |
+
<action method="addCss"><stylesheet>emaildirect/emaildirect.css</stylesheet></action>
|
89 |
+
</reference>
|
90 |
+
<reference name="content">
|
91 |
+
<block type="emaildirect/adminhtml_abandoned_details" name="abandoned_details" template="emaildirect/abandoned/details.phtml">
|
92 |
+
</block>
|
93 |
+
</reference>
|
94 |
+
<reference name="left">
|
95 |
+
<block type="emaildirect/adminhtml_abandoned_tabs" name="abandoned.tabs" as="abandoned.tabs" template="widget/tabs.phtml" >
|
96 |
+
<block type="emaildirect/adminhtml_abandoned_details_tab_diagnostics" name="abandoned_tab_details_emaildirect" template="emaildirect/diagnostics.phtml">
|
97 |
+
<block type="emaildirect/adminhtml_abandoned_details_tab_diagnostics_status" name="diagnostic_status" template="emaildirect/abandoned/details/tab/diagnostics/status.phtml"></block>
|
98 |
+
</block>
|
99 |
+
|
100 |
+
<action method="addTab"><name>abandoned_cart</name><block>emaildirect/adminhtml_abandoned_details_tab_cart</block></action>
|
101 |
+
<action method="addTab"><name>abandoned_details</name><block>abandoned_tab_details_emaildirect</block></action>
|
102 |
+
|
103 |
+
</block>
|
104 |
+
</reference>
|
105 |
+
</ed_integration_admin_abandoned_details>
|
106 |
</layout>
|
app/design/adminhtml/default/default/template/emaildirect/abandoned/details.phtml
ADDED
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php echo $this->getFormInitScripts() ?>
|
2 |
+
<div class="content-header">
|
3 |
+
<?php echo $this->getHeaderHtml() ?>
|
4 |
+
<p class="form-buttons"><?php echo $this->getButtonsHtml('header') ?></p>
|
5 |
+
</div>
|
6 |
+
<?php echo $this->getFormHtml() ?>
|
7 |
+
<?php if ($this->hasFooterButtons()): ?>
|
8 |
+
<div class="content-footer">
|
9 |
+
<p class="form-buttons"><?php echo $this->getButtonsHtml('footer') ?></p>
|
10 |
+
</div>
|
11 |
+
<?php endif; ?>
|
12 |
+
<script type="text/javascript">
|
13 |
+
editForm = new varienForm('edit_form', '<?php echo $this->getValidationUrl() ?>');
|
14 |
+
</script>
|
15 |
+
<?php echo $this->getFormScripts() ?>
|
app/design/adminhtml/default/default/template/emaildirect/abandoned/details/form.phtml
ADDED
@@ -0,0 +1 @@
|
|
|
1 |
+
<div class="entry-edit" id="abandoned_details"></div>
|
app/design/adminhtml/default/default/template/emaildirect/abandoned/details/tab/cart.phtml
ADDED
@@ -0,0 +1,62 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php $cart_items = $this->getCartItems(); ?>
|
2 |
+
<?php
|
3 |
+
$_sub_total = 0;
|
4 |
+
$_total = 0;
|
5 |
+
$_qty = 0;
|
6 |
+
?>
|
7 |
+
<div class="entry-edit">
|
8 |
+
<div class="entry-edit-head">
|
9 |
+
<h4 class="icon-head head-products">Cart Items</h4>
|
10 |
+
</div>
|
11 |
+
</div>
|
12 |
+
|
13 |
+
<div class="grid np">
|
14 |
+
<div class="hor-scroll">
|
15 |
+
<table cellspacing="0" class="data order-tables">
|
16 |
+
<colgroup>
|
17 |
+
<col width="1">
|
18 |
+
<col>
|
19 |
+
<col width="1">
|
20 |
+
<col width="1">
|
21 |
+
<col width="1">
|
22 |
+
<col width="1">
|
23 |
+
</colgroup><thead>
|
24 |
+
<tr class="headings">
|
25 |
+
<th>Product ID</th>
|
26 |
+
<th>Product Name</span></th>
|
27 |
+
<th>SKU</th>
|
28 |
+
<th class="a-center">Qty</th>
|
29 |
+
<th>Price</th>
|
30 |
+
<th>Total</th>
|
31 |
+
</tr>
|
32 |
+
</thead>
|
33 |
+
<tbody class="even">
|
34 |
+
|
35 |
+
<?php
|
36 |
+
foreach ($cart_items as $item): ?>
|
37 |
+
<?php
|
38 |
+
$_qty += $item->getQty();
|
39 |
+
$_sub_total += $item->getPrice();
|
40 |
+
$_total += $item->getRowTotal();
|
41 |
+
?>
|
42 |
+
<tr class="border">
|
43 |
+
<td><?php echo $item->getId(); ?></td>
|
44 |
+
<td><?php echo $item->getName(); ?></td>
|
45 |
+
<td><?php echo $item->getSku(); ?></td>
|
46 |
+
<td><?php echo $item->getQty(); ?></td>
|
47 |
+
<td><?php echo Mage::helper('core')->currency($item->getPrice(), true, false); ?></td>
|
48 |
+
<td><?php echo Mage::helper('core')->currency($item->getRowTotal(), true, false); ?></td>
|
49 |
+
</tr>
|
50 |
+
<?php endforeach; ?>
|
51 |
+
<tfoot>
|
52 |
+
<tr>
|
53 |
+
<td colspan="3"></td>
|
54 |
+
<td><?php echo $_qty; ?></td>
|
55 |
+
<td><?php echo Mage::helper('core')->currency($_sub_total, true, false); ?></td>
|
56 |
+
<td><?php echo Mage::helper('core')->currency($_total, true, false); ?></td>
|
57 |
+
</tr>
|
58 |
+
</tfoot>
|
59 |
+
</tbody>
|
60 |
+
</table>
|
61 |
+
</div>
|
62 |
+
</div>
|
app/design/adminhtml/default/default/template/emaildirect/abandoned/details/tab/diagnostics/status.phtml
ADDED
@@ -0,0 +1,52 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
//$_order = $this->getOrder();
|
4 |
+
//$_send_field = $this->getSendField();
|
5 |
+
$_date_sent = $this->getEmailDirectDate();
|
6 |
+
//$_can_send_orders = $this->canSendOrders();
|
7 |
+
|
8 |
+
$cart = Mage::helper('emaildirect/diagnostic')->getAbandonedCart();
|
9 |
+
|
10 |
+
//Zend_debug::dump($quote->getData());
|
11 |
+
|
12 |
+
?>
|
13 |
+
|
14 |
+
<div class="box-left">
|
15 |
+
<!--Diagnostic Information-->
|
16 |
+
<div class="entry-edit">
|
17 |
+
<div class="entry-edit-head">
|
18 |
+
<h4 class="icon-head head-edit-form fieldset-legend">EmailDirect Diagnostics for Abandoned Cart</h4>
|
19 |
+
</div>
|
20 |
+
<div class="fieldset">
|
21 |
+
<table cellspacing="0" class="form-list">
|
22 |
+
<tbody>
|
23 |
+
<tr>
|
24 |
+
<td class="label"><label>Sent to EmailDirect</label></td>
|
25 |
+
<td class="value"><strong>
|
26 |
+
<?php if ($_date_sent == null): ?>
|
27 |
+
<span style='color: red'>Not Sent</span>
|
28 |
+
<?php else: ?>
|
29 |
+
<span style='color: green'><?php echo $this->formatDate($_date_sent, 'medium', true); ?></span>
|
30 |
+
<?php endif; ?>
|
31 |
+
</strong></td>
|
32 |
+
</tr>
|
33 |
+
<tr>
|
34 |
+
<td class="label"><label>EmailDirect Status</label></td>
|
35 |
+
<td class="value"><strong>
|
36 |
+
<?php if (!$this->isEmailDirectEnabled()): ?>
|
37 |
+
<div style='color: red'>Disabled for this Store</div>
|
38 |
+
<?php elseif (!$this->isEmailDirectSetup()): ?>
|
39 |
+
<div style='color: red'>Api Key Missing/Invalid</div>
|
40 |
+
<?php else: ?>
|
41 |
+
<div style='color: green'>Enabled</div>
|
42 |
+
<?php if (1 == 0 || !$this->isAbandonedEnabled()): ?>
|
43 |
+
<div style='color: red'>Abandoned Carts are disabled</div>
|
44 |
+
<?php endif; ?>
|
45 |
+
<?php endif; ?>
|
46 |
+
</strong></td>
|
47 |
+
</tr>
|
48 |
+
</tbody>
|
49 |
+
</table>
|
50 |
+
</div>
|
51 |
+
</div>
|
52 |
+
</div>
|
app/design/adminhtml/default/default/template/emaildirect/diagnostics.phtml
ADDED
@@ -0,0 +1,242 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php $options = $this->getDiagnosticOptions(); ?>
|
2 |
+
<style>
|
3 |
+
|
4 |
+
.diagnostic_table { border-collapse: collapse; }
|
5 |
+
.diagnostic_table tr td { border: solid 1px; padding: 4px; }
|
6 |
+
.diagnostic_table tr td:first-child { font-weight: bold; }
|
7 |
+
|
8 |
+
a.ed_ec {
|
9 |
+
color: #fff;
|
10 |
+
padding-right: 30px;
|
11 |
+
display: block;
|
12 |
+
font-weight: bold;
|
13 |
+
text-decoration: none;
|
14 |
+
}
|
15 |
+
|
16 |
+
#spacer_output { height: 20px; }
|
17 |
+
|
18 |
+
a.ed_contract {
|
19 |
+
background: url(<?php echo $this->getSkinUrl("images/entry_edit_head_arrow_up.gif"); ?>) no-repeat scroll 100% 50% rgba(0, 0, 0, 0);
|
20 |
+
}
|
21 |
+
a.ed_expand {
|
22 |
+
background: url(<?php echo $this->getSkinUrl("images/entry_edit_head_arrow_down.gif"); ?>) no-repeat scroll 100% 50% rgba(0, 0, 0, 0);
|
23 |
+
}
|
24 |
+
|
25 |
+
table.diagnostic-options { width: 100%; }
|
26 |
+
|
27 |
+
.diagnostic-options td {
|
28 |
+
background: none repeat scroll 0 center rgba(0, 0, 0, 0) !important;
|
29 |
+
border: 0 none !important;
|
30 |
+
padding-bottom: 5px !important;
|
31 |
+
padding-left: 5px !important;
|
32 |
+
padding-top: 5px !important;
|
33 |
+
}
|
34 |
+
|
35 |
+
.diagnostic-note div { font-weight: bold; color: red; margin-left: 15px; }
|
36 |
+
|
37 |
+
</style>
|
38 |
+
<div>
|
39 |
+
<?php echo $this->getChildHtml('diagnostic_status') ?>
|
40 |
+
|
41 |
+
<div class="box-right">
|
42 |
+
<!--Account Information-->
|
43 |
+
<div class="entry-edit">
|
44 |
+
<div class="entry-edit-head">
|
45 |
+
<h4 class="icon-head head-account">Run Diagnostics</h4>
|
46 |
+
<div class="tools"></div>
|
47 |
+
</div>
|
48 |
+
<div class="fieldset">
|
49 |
+
<div class="hor-scroll">
|
50 |
+
<table cellspacing="0" class="diagnostic-options">
|
51 |
+
<tbody>
|
52 |
+
<!--<tr>
|
53 |
+
<td class="label"><label for="clear_after">Clear output before each diagnostic?</label></td>
|
54 |
+
<td class="value">
|
55 |
+
<input type='checkbox' id='clear_after' checked='checked' />
|
56 |
+
</td>
|
57 |
+
<td> </td>
|
58 |
+
</tr>-->
|
59 |
+
<?php foreach ($options as $option): ?>
|
60 |
+
<tr>
|
61 |
+
<td class='label'><?php echo $option['label'] ?></td>
|
62 |
+
<td class='diagnostic-button'>
|
63 |
+
<button id='<?php echo $option['code'] ?>_button' <?php if (isset($option['disabled'])) echo "disabled='disabled' class='disabled'"?>onclick="performRequest('<?php echo $option['code'] ?>')">Run Diagnostic</button>
|
64 |
+
</td>
|
65 |
+
<td class='diagnostic-note'>
|
66 |
+
<div>
|
67 |
+
<?php
|
68 |
+
if (isset($option['disabled_reason']))
|
69 |
+
echo "Note: " . $option['disabled_reason'];
|
70 |
+
else if (isset($option['note']))
|
71 |
+
echo "Note: " . $option['note'];
|
72 |
+
?>
|
73 |
+
</div>
|
74 |
+
</td>
|
75 |
+
</tr>
|
76 |
+
<?php endforeach; ?>
|
77 |
+
|
78 |
+
<tr>
|
79 |
+
<td>
|
80 |
+
<form id='download_form' method='post' action='<?php echo $this->getUrl("ed_integration/admin_diagnostic/download") ?>'>
|
81 |
+
<input type='hidden' name='form_key' value='<?php echo $this->getFormKey(); ?>'></input>
|
82 |
+
<input type='hidden' name='output' id='hidden_output' value='' ></input>
|
83 |
+
<input type='hidden' name='filename' value='diagnostic_output.html' ></input>
|
84 |
+
</form>
|
85 |
+
<button id='download' disabled='disabled' class='disabled' onclick='return performDownload()'>Download</button>
|
86 |
+
</td>
|
87 |
+
</tr>
|
88 |
+
</tbody>
|
89 |
+
</table>
|
90 |
+
</div>
|
91 |
+
</div>
|
92 |
+
</div>
|
93 |
+
</div>
|
94 |
+
|
95 |
+
<div class='clear'> </div>
|
96 |
+
<div class="entry-edit">
|
97 |
+
<div class="entry-edit-head">
|
98 |
+
<h4 class="icon-head head-products"><a class='ed_ec ed_contract' id='diagnostic_output_toggle' href="#" onclick="return toggleSection('diagnostic_output');">Diagnostic Output</a></h4>
|
99 |
+
<div class="tools">
|
100 |
+
<a href='#' onclick="return selectText('diagnostic_output');">Select</a>
|
101 |
+
<!--<span> | </span>
|
102 |
+
<a href='#' onclick="return clear('output');">Clear</a>-->
|
103 |
+
|
104 |
+
</div>
|
105 |
+
</div>
|
106 |
+
<div id="emaildirect_diagnostic_output_fieldset" class="fieldset">
|
107 |
+
<div class="hor-scroll">
|
108 |
+
<div id='diagnostic_output' style="height: 500px; overflow: scroll;">
|
109 |
+
</div>
|
110 |
+
</div>
|
111 |
+
</div>
|
112 |
+
</div>
|
113 |
+
<div id='spacer_output' style='display:none'> </div>
|
114 |
+
|
115 |
+
<div class='clear'> </div>
|
116 |
+
<div class="entry-edit">
|
117 |
+
<div class="entry-edit-head">
|
118 |
+
<h4 class="icon-head head-products"><a class='ed_ec ed_expand' id='diagnostic_details_toggle' href="#" onclick="return toggleSection('diagnostic_details');">Diagnostic Details</a></h4>
|
119 |
+
<div class="tools">
|
120 |
+
<a href='#' onclick="return selectText('diagnostic_details');">Select</a>
|
121 |
+
<!--<span> | </span>
|
122 |
+
<a href='#' onclick="return clear('details');">Clear</a>-->
|
123 |
+
|
124 |
+
</div>
|
125 |
+
</div>
|
126 |
+
<div id="emaildirect_diagnostic_details_fieldset" class="fieldset" style='display:none'>
|
127 |
+
<div class="hor-scroll">
|
128 |
+
<div id='diagnostic_details' style="height: 500px; overflow: scroll;">
|
129 |
+
</div>
|
130 |
+
</div>
|
131 |
+
</div>
|
132 |
+
</div>
|
133 |
+
|
134 |
+
</div>
|
135 |
+
|
136 |
+
<script type='text/javascript'>
|
137 |
+
var FORM_KEY = "<?php echo $this->getFormKey();?>";
|
138 |
+
var item_id = <?php echo $this->getItemId(); ?>;
|
139 |
+
var store_id = <?php echo $this->getStoreId(); ?>;
|
140 |
+
|
141 |
+
function clear(section)
|
142 |
+
{
|
143 |
+
$("diagnostic_" + section).update("");
|
144 |
+
return false;
|
145 |
+
}
|
146 |
+
|
147 |
+
function toggleSection(section)
|
148 |
+
{
|
149 |
+
console.log(section);
|
150 |
+
$("emaildirect_" + section + "_fieldset").toggle();
|
151 |
+
|
152 |
+
$(section + "_toggle").toggleClassName("ed_expand");
|
153 |
+
$(section + "_toggle").toggleClassName("ed_contract");
|
154 |
+
|
155 |
+
if (section == 'diagnostic_output')
|
156 |
+
$('spacer_output').toggle();
|
157 |
+
|
158 |
+
return false;
|
159 |
+
}
|
160 |
+
|
161 |
+
function selectText(containerid)
|
162 |
+
{
|
163 |
+
if (document.selection)
|
164 |
+
{
|
165 |
+
var range = document.body.createTextRange();
|
166 |
+
range.moveToElementText(document.getElementById(containerid));
|
167 |
+
range.select();
|
168 |
+
}
|
169 |
+
else if (window.getSelection)
|
170 |
+
{
|
171 |
+
var range = document.createRange();
|
172 |
+
range.selectNode(document.getElementById(containerid));
|
173 |
+
window.getSelection().addRange(range);
|
174 |
+
}
|
175 |
+
|
176 |
+
return false;
|
177 |
+
}
|
178 |
+
|
179 |
+
function showOutput(output)
|
180 |
+
{
|
181 |
+
$("diagnostic_output").insert(output);
|
182 |
+
}
|
183 |
+
|
184 |
+
function showDetails(details)
|
185 |
+
{
|
186 |
+
$("diagnostic_details").insert(details);
|
187 |
+
}
|
188 |
+
|
189 |
+
function showData(output, details)
|
190 |
+
{
|
191 |
+
$("hidden_output").value = "<div>" + output + "</div><hr /><h1>Report Details</h1><div>" + details + "</div>";
|
192 |
+
$("download").removeClassName('disabled');
|
193 |
+
$("download").removeAttribute('disabled');
|
194 |
+
|
195 |
+
showOutput(output);
|
196 |
+
showDetails(details);
|
197 |
+
}
|
198 |
+
|
199 |
+
function performRequest(method)
|
200 |
+
{
|
201 |
+
//if ($("clear_after").checked)
|
202 |
+
{
|
203 |
+
clear('output');
|
204 |
+
clear('details');
|
205 |
+
}
|
206 |
+
|
207 |
+
new Ajax.Request('<?php echo $this->getUrl('ed_integration/admin_diagnostic/ajax') ?>',
|
208 |
+
{
|
209 |
+
parameters: {isAjax: 'true', form_key: FORM_KEY, method: method, item_id: item_id, store_id: store_id},
|
210 |
+
onSuccess: function(transport)
|
211 |
+
{
|
212 |
+
try
|
213 |
+
{
|
214 |
+
if (transport.responseText.isJSON())
|
215 |
+
{
|
216 |
+
var response = transport.responseText.evalJSON()
|
217 |
+
if (response.error)
|
218 |
+
{
|
219 |
+
alert(response.message);
|
220 |
+
}
|
221 |
+
if(response.ajaxExpired && response.ajaxRedirect)
|
222 |
+
{
|
223 |
+
setLocation(response.ajaxRedirect);
|
224 |
+
}
|
225 |
+
|
226 |
+
showData(response.output,response.details);
|
227 |
+
}
|
228 |
+
}
|
229 |
+
catch (e)
|
230 |
+
{
|
231 |
+
showOutput(transport.responseText);
|
232 |
+
}
|
233 |
+
}
|
234 |
+
});
|
235 |
+
}
|
236 |
+
|
237 |
+
function performDownload()
|
238 |
+
{
|
239 |
+
$("download_form").submit();
|
240 |
+
return false;
|
241 |
+
}
|
242 |
+
</script>
|
app/design/adminhtml/default/default/template/emaildirect/order/view/tab/diagnostics/status.phtml
ADDED
@@ -0,0 +1,78 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
$_order = $this->getOrder();
|
4 |
+
$_send_field = $this->getSendField();
|
5 |
+
$_date_sent = $this->getEmailDirectDate();
|
6 |
+
$_can_send_orders = $this->canSendOrders();
|
7 |
+
|
8 |
+
?>
|
9 |
+
|
10 |
+
<div class="box-left">
|
11 |
+
<!--Diagnostic Information-->
|
12 |
+
<div class="entry-edit">
|
13 |
+
<div class="entry-edit-head">
|
14 |
+
<h4 class="icon-head head-edit-form fieldset-legend">EmailDirect Diagnostics for <?php echo Mage::helper('sales')->__('Order # %s', $_order->getRealOrderId()) ?></h4>
|
15 |
+
</div>
|
16 |
+
<div class="fieldset">
|
17 |
+
<table cellspacing="0" class="form-list">
|
18 |
+
<tbody>
|
19 |
+
<tr>
|
20 |
+
<td class="label"><label>Sent to EmailDirect</label></td>
|
21 |
+
<td class="value"><strong>
|
22 |
+
<?php if ($_date_sent == null): ?>
|
23 |
+
<span style='color: red'>Not Sent</span>
|
24 |
+
<?php else: ?>
|
25 |
+
<span style='color: green'><?php echo $this->formatDate($_date_sent, 'medium', true); ?></span>
|
26 |
+
<?php endif; ?>
|
27 |
+
</strong></td>
|
28 |
+
</tr>
|
29 |
+
<?php if ($_send_field == 'status'): ?>
|
30 |
+
<?php $send_status_list = $this->getStatusList(); ?>
|
31 |
+
<tr>
|
32 |
+
<td class="label"><label>Send on Status</label></td>
|
33 |
+
<td class="value"><strong>
|
34 |
+
<span id="send_on_status">
|
35 |
+
<?php echo implode("<br />",$send_status_list); ?>
|
36 |
+
</span></strong>
|
37 |
+
</td>
|
38 |
+
</tr>
|
39 |
+
<tr>
|
40 |
+
<td class="label"><label>Order Status</label></td>
|
41 |
+
<td class="value"><strong><span id="order_status"><?php echo $_order->getStatusLabel() ?></span></strong></td>
|
42 |
+
</tr>
|
43 |
+
<?php else: ?>
|
44 |
+
<?php $send_state_list = $this->getStateList(); ?>
|
45 |
+
<tr>
|
46 |
+
<td class="label"><label>Send on State</label></td>
|
47 |
+
<td class="value"><strong>
|
48 |
+
<span id="send_on_state">
|
49 |
+
<?php echo implode("<br />",$send_state_list); ?>
|
50 |
+
</span></strong>
|
51 |
+
</td>
|
52 |
+
</tr>
|
53 |
+
<tr>
|
54 |
+
<td class="label"><label>Order State</label></td>
|
55 |
+
<td class="value"><strong><span id="order_state"><?php echo $this->getOrderState() ?></span></strong></td>
|
56 |
+
</tr>
|
57 |
+
<?php endif; ?>
|
58 |
+
|
59 |
+
<tr>
|
60 |
+
<td class="label"><label>EmailDirect Status</label></td>
|
61 |
+
<td class="value"><strong>
|
62 |
+
<?php if (!$this->isEmailDirectEnabled()): ?>
|
63 |
+
<div style='color: red'>Disabled for this Store</div>
|
64 |
+
<?php elseif (!$this->isEmailDirectSetup()): ?>
|
65 |
+
<div style='color: red'>Api Key Missing/Invalid</div>
|
66 |
+
<?php else: ?>
|
67 |
+
<div style='color: green'>Enabled</div>
|
68 |
+
<?php if (!$this->isSendOrdersEnabled()): ?>
|
69 |
+
<div style='color: red'>Sending orders is disabled</div>
|
70 |
+
<?php endif; ?>
|
71 |
+
<?php endif; ?>
|
72 |
+
</strong></td>
|
73 |
+
</tr>
|
74 |
+
</tbody>
|
75 |
+
</table>
|
76 |
+
</div>
|
77 |
+
</div>
|
78 |
+
</div>
|
app/design/adminhtml/default/default/template/emaildirect/system/config/fieldset/hint.phtml
CHANGED
@@ -11,9 +11,9 @@ $last_run_label = "Cron Last Run";
|
|
11 |
<div class="emaildirect-notice">
|
12 |
<h4>
|
13 |
<?php if (!$this->isWebsiteConfig()): ?>
|
14 |
-
<div class='abandoned'>Abandoned Cart Processing: <?php if ($ab_enabled) : ?><span class='ab_ok'>Enabled</span><?php else: ?><span class='ab_ng'>Disabled</span><?php endif; ?> - <?php echo $last_run_label ?>: <?php echo $abandoned_status['cron_last_run'] ?> - <button onclick="window.location='<?php echo $this->getUrl('
|
15 |
<?php endif; ?>
|
16 |
-
<strong>EmailDirect Integration v<?php echo $this->getEmaildirectVersion() ?><?php if (!$setup && strlen($api_key) > 0): ?> - <span class='ab_ng'>Invalid API Key
|
17 |
</h4>
|
18 |
</div>
|
19 |
<script type='text/javascript'>
|
@@ -35,6 +35,7 @@ document.observe('dom:loaded', function()
|
|
35 |
var name = id_parts.slice(3).join('_');
|
36 |
switch (name)
|
37 |
{
|
|
|
38 |
case 'heading_general':
|
39 |
case 'info':
|
40 |
case 'apikey':
|
11 |
<div class="emaildirect-notice">
|
12 |
<h4>
|
13 |
<?php if (!$this->isWebsiteConfig()): ?>
|
14 |
+
<div class='abandoned'>Abandoned Cart Processing: <?php if ($ab_enabled) : ?><span class='ab_ok'>Enabled</span><?php else: ?><span class='ab_ng'>Disabled</span><?php endif; ?> - <?php echo $last_run_label ?>: <?php echo $abandoned_status['cron_last_run'] ?> - <button onclick="window.location='<?php echo $this->getUrl('ed_integration/admin_abandoned/index'); ?>'; return false;" id="emaildirect_details">Details</button></div>
|
15 |
<?php endif; ?>
|
16 |
+
<strong>EmailDirect Integration v<?php echo $this->getEmaildirectVersion() ?><?php if (!$setup && strlen($api_key) > 0): ?> - <span class='ab_ng'>Invalid API Key</span><?php endif; ?></strong>
|
17 |
</h4>
|
18 |
</div>
|
19 |
<script type='text/javascript'>
|
35 |
var name = id_parts.slice(3).join('_');
|
36 |
switch (name)
|
37 |
{
|
38 |
+
case 'apikey_validation':
|
39 |
case 'heading_general':
|
40 |
case 'info':
|
41 |
case 'apikey':
|
app/design/adminhtml/default/default/template/emaildirect/system/config/form/field/api.phtml
ADDED
@@ -0,0 +1,62 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
$valid = $this->isValid();
|
3 |
+
|
4 |
+
$element = $this->getElement();
|
5 |
+
|
6 |
+
//$enabled = $this->isLoggingEnabled();
|
7 |
+
?>
|
8 |
+
<div id="<?php echo $this->getElement()->getHtmlId(); ?>" style='display:none'></div>
|
9 |
+
<div class='emaildirect_api_status'>
|
10 |
+
<span id='emaildirect_status_indicator' class='<?php if ($valid) echo "apikey_valid"; else echo "apikey_invalid" ?>'><?php if ($valid) echo "Valid"; else echo "Invalid" ?></span>
|
11 |
+
|
12 |
+
<input type='hidden' name='groups[general][fields][old_apikey][value]' value='<?php echo $this->getCurrentApiKey(); ?>' />
|
13 |
+
<button id='apikey_validator' onclick='return performValidation();'>Validate</button>
|
14 |
+
</div>
|
15 |
+
|
16 |
+
<script type='text/javascript'>
|
17 |
+
|
18 |
+
validate_url = '<?php echo $this->getUrl('ed_integration/admin_troubleshooting/validate'); ?>';
|
19 |
+
|
20 |
+
function performValidation()
|
21 |
+
{
|
22 |
+
var apikey = $("emaildirect_general_apikey").value;
|
23 |
+
|
24 |
+
var indicator = $("emaildirect_status_indicator");
|
25 |
+
|
26 |
+
indicator.update("Validating...");
|
27 |
+
indicator.removeClassName("apikey_valid");
|
28 |
+
indicator.removeClassName("apikey_invalid");
|
29 |
+
indicator.addClassName("apikey_validating");
|
30 |
+
|
31 |
+
new Ajax.Request(validate_url + (validate_url.match(new RegExp('\\?')) ? '&isAjax=true' : '?isAjax=true' ),
|
32 |
+
{
|
33 |
+
parameters : {apikey: apikey},
|
34 |
+
method : 'post',
|
35 |
+
onSuccess : function(transport)
|
36 |
+
{
|
37 |
+
if (transport.responseText.isJSON())
|
38 |
+
{
|
39 |
+
var response = transport.responseText.evalJSON()
|
40 |
+
|
41 |
+
if (response.valid)
|
42 |
+
{
|
43 |
+
indicator.removeClassName("apikey_validating");
|
44 |
+
indicator.addClassName("apikey_valid");
|
45 |
+
|
46 |
+
$("emaildirect_status_indicator").update("Valid");
|
47 |
+
}
|
48 |
+
else
|
49 |
+
{
|
50 |
+
indicator.removeClassName("apikey_validating");
|
51 |
+
indicator.addClassName("apikey_invalid");
|
52 |
+
$("emaildirect_status_indicator").update("Invalid");
|
53 |
+
}
|
54 |
+
|
55 |
+
console.log(response);
|
56 |
+
}
|
57 |
+
}
|
58 |
+
});
|
59 |
+
|
60 |
+
return false;
|
61 |
+
}
|
62 |
+
</script>
|
app/design/adminhtml/default/default/template/emaildirect/system/config/form/field/diagnostics.phtml
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
$element = $this->getElement();
|
3 |
+
|
4 |
+
$enabled = $this->getDiagnosticStatus();
|
5 |
+
?>
|
6 |
+
<div id="<?php echo $this->getElement()->getHtmlId(); ?>" style='display:none'></div>
|
7 |
+
<span class='<?php echo $enabled ? "ab_ok" : "ab_ng" ?>'><?php echo $enabled ? "Enabled" : "Disabled" ?></span>
|
8 |
+
<br />
|
9 |
+
<br />
|
10 |
+
<button id='emaildirect_send_trouble' onClick="view_details(); return false;">Change Troubleshooting Settings</button>
|
11 |
+
<script type='text/javascript'>
|
12 |
+
|
13 |
+
function view_details()
|
14 |
+
{
|
15 |
+
var form = $('config_edit_form');
|
16 |
+
var logging_url = '<?php echo Mage::helper('emaildirect')->getAdminUrl("ed_integration/admin_troubleshooting/", array('tab' => 'troubleshooting_view_tabs_trouble_settings')); ?>';
|
17 |
+
|
18 |
+
window.location = logging_url;
|
19 |
+
}
|
20 |
+
</script>
|
app/design/adminhtml/default/default/template/emaildirect/system/config/form/field/export/date_range.phtml
CHANGED
@@ -59,7 +59,7 @@
|
|
59 |
}
|
60 |
Calendar.setup(calendarSetupObject2);
|
61 |
|
62 |
-
var url = '<?php echo $this->getUrl("
|
63 |
|
64 |
$('emaildirect_export_include_already_sent').observe('change', function(event)
|
65 |
{
|
@@ -129,7 +129,8 @@ function dateRangeChange()
|
|
129 |
loaderArea : false,
|
130 |
onSuccess : function(transport)
|
131 |
{
|
132 |
-
|
|
|
133 |
orders_count = response;
|
134 |
$('orders_found').update(response);
|
135 |
setButtonState();
|
59 |
}
|
60 |
Calendar.setup(calendarSetupObject2);
|
61 |
|
62 |
+
var url = '<?php echo $this->getUrl("ed_integration/admin_export/count/"); ?>';
|
63 |
|
64 |
$('emaildirect_export_include_already_sent').observe('change', function(event)
|
65 |
{
|
129 |
loaderArea : false,
|
130 |
onSuccess : function(transport)
|
131 |
{
|
132 |
+
//console.log(transport.responseText);
|
133 |
+
var response = transport.responseText;
|
134 |
orders_count = response;
|
135 |
$('orders_found').update(response);
|
136 |
setButtonState();
|
app/design/adminhtml/default/default/template/emaildirect/system/config/form/field/export/orders.phtml
CHANGED
@@ -8,7 +8,7 @@ function perform_order_export()
|
|
8 |
var to = form['order_export_to'];
|
9 |
var store = <?php echo Mage::helper('emaildirect')->getAdminStore(); ?>;
|
10 |
var include = form['groups[export][fields][include_already_sent][value]'];
|
11 |
-
var url = '<?php echo $this->getUrl("
|
12 |
|
13 |
url += 'export_from/' + $(from).getValue() + '/export_to/' + $(to).getValue() + '/include_already_sent/' + $(include).getValue() + '/store/' + store + '/';
|
14 |
|
8 |
var to = form['order_export_to'];
|
9 |
var store = <?php echo Mage::helper('emaildirect')->getAdminStore(); ?>;
|
10 |
var include = form['groups[export][fields][include_already_sent][value]'];
|
11 |
+
var url = '<?php echo $this->getUrl("ed_integration/admin_export/orders/"); ?>';
|
12 |
|
13 |
url += 'export_from/' + $(from).getValue() + '/export_to/' + $(to).getValue() + '/include_already_sent/' + $(include).getValue() + '/store/' + store + '/';
|
14 |
|
app/design/adminhtml/default/default/template/emaildirect/system/config/form/field/export/products.phtml
CHANGED
@@ -5,7 +5,7 @@ function perform_product_export()
|
|
5 |
{
|
6 |
var form = $('config_edit_form');
|
7 |
var include_disabled = form['groups[export][fields][include_disabled][value]'];
|
8 |
-
var url = '<?php echo $this->getUrl("
|
9 |
var store = <?php echo Mage::helper('emaildirect')->getAdminStore() ?>;
|
10 |
|
11 |
url += 'include_disabled/' + $(include_disabled).getValue() + '/';
|
5 |
{
|
6 |
var form = $('config_edit_form');
|
7 |
var include_disabled = form['groups[export][fields][include_disabled][value]'];
|
8 |
+
var url = '<?php echo $this->getUrl("ed_integration/admin_export/products/"); ?>';
|
9 |
var store = <?php echo Mage::helper('emaildirect')->getAdminStore() ?>;
|
10 |
|
11 |
url += 'include_disabled/' + $(include_disabled).getValue() + '/';
|
app/design/adminhtml/default/default/template/emaildirect/system/config/form/field/info.phtml
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
<p>Customer Data and Purchase Behavior Sync by <a href='http://www.emaildirect.com' target='_blank'>www.emaildirect.com</a></p>
|
3 |
<p>Copyright ©<?php echo date("Y") ?></p>
|
4 |
<br />
|
5 |
-
<p>Download our <a href='http://emaildirect.com/downloads/papers/magentoSetupGuide.pdf'>Magento Setup Guide</a> for detailed information on each feature.</p>
|
6 |
<p>Please contact support (<a href='mailto:support@emaildirect.com'>support@emaildirect.com</a>) with any questions that you have.</p>
|
7 |
<br />
|
8 |
<?php if ($this->isWebsiteConfig()): ?>
|
2 |
<p>Customer Data and Purchase Behavior Sync by <a href='http://www.emaildirect.com' target='_blank'>www.emaildirect.com</a></p>
|
3 |
<p>Copyright ©<?php echo date("Y") ?></p>
|
4 |
<br />
|
5 |
+
<p>Download our <a href='http://emaildirect.com/downloads/papers/magentoSetupGuide.pdf'>Magento Setup Guide</a> for detailed information on each feature or view the <a href="<?php echo $this->getUrl('ed_integration/admin_troubleshooting/index') ?>">Help</a> page.</p>
|
6 |
<p>Please contact support (<a href='mailto:support@emaildirect.com'>support@emaildirect.com</a>) with any questions that you have.</p>
|
7 |
<br />
|
8 |
<?php if ($this->isWebsiteConfig()): ?>
|
app/design/adminhtml/default/default/template/emaildirect/system/config/form/field/logging.phtml
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
$element = $this->getElement();
|
3 |
+
|
4 |
+
$status = $this->getLoggingStatus();
|
5 |
+
|
6 |
+
//Zend_debug::dump($status);
|
7 |
+
//$enabled = $this->isLoggingEnabled();
|
8 |
+
$enabled_for_store = $this->isEnabledForStore();
|
9 |
+
//$store = Mage::getSingleton('adminhtml/config_data')->getStore();
|
10 |
+
|
11 |
+
|
12 |
+
$enabled = $status['enabled'];
|
13 |
+
?>
|
14 |
+
<div id="<?php echo $this->getElement()->getHtmlId(); ?>" style='display:none'></div>
|
15 |
+
<span class='<?php echo $enabled ? "ab_ok" : "ab_ng" ?>'><?php echo $enabled ? "Enabled" : "Disabled" ?></span>
|
16 |
+
<?php if ($enabled): ?>
|
17 |
+
<?php if (!$enabled_for_store): ?><span class='ab_ng'>(Not for this store!)</span><?php endif; ?>
|
18 |
+
<div id='emaildirect_trouble_details'>
|
19 |
+
<table>
|
20 |
+
<tr>
|
21 |
+
<td>Start Date:</td>
|
22 |
+
<td><?php echo $this->getStartDate() ?></td>
|
23 |
+
</tr>
|
24 |
+
<tr>
|
25 |
+
<td>Log File:</td>
|
26 |
+
<td><?php echo $this->getLogInfo() ?></td>
|
27 |
+
</tr>
|
28 |
+
</table>
|
29 |
+
</div>
|
30 |
+
<?php endif; ?>
|
app/design/adminhtml/default/default/template/emaildirect/system/config/form/field/trouble.phtml
CHANGED
@@ -1,13 +1,12 @@
|
|
1 |
-
<!--<button id='emaildirect_export' onClick="window.open('<?php echo $this->getUrl("emaildirect/admin_export/run/"); ?>'); return false;">Export</button>-->
|
2 |
<?php
|
3 |
$element = $this->getElement();
|
4 |
|
5 |
$enabled = $this->isLoggingEnabled();
|
|
|
|
|
6 |
?>
|
7 |
<div id="<?php echo $this->getElement()->getHtmlId(); ?>" style='display:none'></div>
|
8 |
<span class='trouble_status'>Status: <strong><?php if ($enabled) echo "Enabled"; else echo "Disabled" ?></strong></span>
|
9 |
-
<button id='emaildirect_trouble' onClick="toggle_trouble();"><?php if ($enabled) echo "Disable"; else echo "Enable" ?></button>
|
10 |
-
<input type='hidden' name='<?php echo $this->getElement()->getName() ?>' value='<?php echo $enabled == true ? 1 : 0 ?>'/>
|
11 |
|
12 |
<div id='emaildirect_trouble_details'>
|
13 |
<?php if ($enabled): ?>
|
@@ -35,9 +34,9 @@
|
|
35 |
<strong>Abandoned Carts: </strong>
|
36 |
<ul>
|
37 |
<li>Make sure Abandoned Carts are enabled (see above).</li>
|
38 |
-
<li>Abandon at least one cart in the front end of your store. You must have a logged in account for a cart to be abandoned.</li>
|
39 |
<li>To test whether cron is working, wait at least one hour for the abandoned process to run before sending the report.</li>
|
40 |
-
<li>Go to the <a href='<?php echo $this->getUrl('
|
41 |
</ul>
|
42 |
</p>
|
43 |
<p>
|
@@ -72,7 +71,7 @@ function toggle_trouble()
|
|
72 |
function view_details()
|
73 |
{
|
74 |
var form = $('config_edit_form');
|
75 |
-
var url = '<?php echo Mage::helper('emaildirect')->getAdminUrl("
|
76 |
|
77 |
window.location = url;
|
78 |
}
|
|
|
1 |
<?php
|
2 |
$element = $this->getElement();
|
3 |
|
4 |
$enabled = $this->isLoggingEnabled();
|
5 |
+
|
6 |
+
$enabled = true;
|
7 |
?>
|
8 |
<div id="<?php echo $this->getElement()->getHtmlId(); ?>" style='display:none'></div>
|
9 |
<span class='trouble_status'>Status: <strong><?php if ($enabled) echo "Enabled"; else echo "Disabled" ?></strong></span>
|
|
|
|
|
10 |
|
11 |
<div id='emaildirect_trouble_details'>
|
12 |
<?php if ($enabled): ?>
|
34 |
<strong>Abandoned Carts: </strong>
|
35 |
<ul>
|
36 |
<li>Make sure Abandoned Carts are enabled (see above).</li>
|
37 |
+
<li>Abandon at least one cart in the front end of your store. You must have a logged in account (or captured email) for a cart to be abandoned.</li>
|
38 |
<li>To test whether cron is working, wait at least one hour for the abandoned process to run before sending the report.</li>
|
39 |
+
<li>Go to the <a href='<?php echo $this->getUrl('ed_integration/admin_abandoned/index'); ?>'>Abandoned Carts page</a> and click "Run Now" to see if it works without cron.</li>
|
40 |
</ul>
|
41 |
</p>
|
42 |
<p>
|
71 |
function view_details()
|
72 |
{
|
73 |
var form = $('config_edit_form');
|
74 |
+
var url = '<?php echo Mage::helper('emaildirect')->getAdminUrl("ed_integration/admin_troubleshooting/"); ?>';
|
75 |
|
76 |
window.location = url;
|
77 |
}
|
app/design/adminhtml/default/default/template/emaildirect/troubleshooting/status.phtml
ADDED
@@ -0,0 +1,199 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php $status = $this->getLoggingStatus(); ?>
|
2 |
+
<?php if ($status['enabled']): ?>
|
3 |
+
<div class="emaildirect-status">
|
4 |
+
<table>
|
5 |
+
<tr id='ed_status_row'>
|
6 |
+
<td>Logging: <span id='status_state'>Enabled</span></td>
|
7 |
+
<td>Started On: <span><?php echo $status['start_date'] ?></span></td>
|
8 |
+
<td>Duration: <span><?php echo $status['duration_display'] ?></span></td>
|
9 |
+
<td>Time Remaining: <span id='ed_time_remaining'></span></td>
|
10 |
+
</tr>
|
11 |
+
</table>
|
12 |
+
</div>
|
13 |
+
|
14 |
+
<script type='text/javascript'>
|
15 |
+
|
16 |
+
var FORM_KEY = "<?php echo $this->getFormKey();?>";
|
17 |
+
|
18 |
+
function getStatus()
|
19 |
+
{
|
20 |
+
new Ajax.Request('<?php echo $this->getUrl('ed_integration/admin_troubleshooting/ajax') ?>',
|
21 |
+
{
|
22 |
+
parameters: {isAjax: 'true', form_key: FORM_KEY, method: "status"},
|
23 |
+
loaderArea : false,
|
24 |
+
onSuccess: function(transport)
|
25 |
+
{
|
26 |
+
try
|
27 |
+
{
|
28 |
+
if (transport.responseText.isJSON())
|
29 |
+
{
|
30 |
+
var response = transport.responseText.evalJSON()
|
31 |
+
if (response.error)
|
32 |
+
{
|
33 |
+
alert(response.message);
|
34 |
+
}
|
35 |
+
if(response.ajaxExpired && response.ajaxRedirect)
|
36 |
+
{
|
37 |
+
setLocation(response.ajaxRedirect);
|
38 |
+
}
|
39 |
+
|
40 |
+
var status = response.status;
|
41 |
+
|
42 |
+
if (status.enabled)
|
43 |
+
{
|
44 |
+
$("status_state").update("Enabled");
|
45 |
+
|
46 |
+
seconds = status.duration - status.seconds;
|
47 |
+
|
48 |
+
statusCounter.setSeconds(seconds);
|
49 |
+
statusCounter.start();
|
50 |
+
$('status').value = "yes";
|
51 |
+
}
|
52 |
+
else
|
53 |
+
{
|
54 |
+
$("status_state").update("Disabled");
|
55 |
+
$("ed_status_row").addClassName("disabled");
|
56 |
+
$('status').value = "no";
|
57 |
+
}
|
58 |
+
}
|
59 |
+
}
|
60 |
+
catch (e)
|
61 |
+
{
|
62 |
+
//showOutput(transport.responseText);
|
63 |
+
}
|
64 |
+
}
|
65 |
+
});
|
66 |
+
}
|
67 |
+
|
68 |
+
function Countdown(options)
|
69 |
+
{
|
70 |
+
var timer,
|
71 |
+
instance = this,
|
72 |
+
seconds = options.seconds || 10,
|
73 |
+
updateStatus = options.onUpdateStatus || function () {},
|
74 |
+
counterEnd = options.onCounterEnd || function () {};
|
75 |
+
|
76 |
+
this.setSeconds = function(new_seconds)
|
77 |
+
{
|
78 |
+
options.seconds = new_seconds;
|
79 |
+
}
|
80 |
+
|
81 |
+
function decrementCounter()
|
82 |
+
{
|
83 |
+
//console.log(statusCounter.seconds);
|
84 |
+
updateStatus(seconds);
|
85 |
+
|
86 |
+
if (seconds === 0)
|
87 |
+
{
|
88 |
+
counterEnd();
|
89 |
+
instance.stop();
|
90 |
+
getStatus();
|
91 |
+
}
|
92 |
+
seconds--;
|
93 |
+
}
|
94 |
+
|
95 |
+
this.start = function ()
|
96 |
+
{
|
97 |
+
clearInterval(timer);
|
98 |
+
timer = 0;
|
99 |
+
seconds = options.seconds;
|
100 |
+
timer = setInterval(decrementCounter, 1000);
|
101 |
+
};
|
102 |
+
|
103 |
+
this.stop = function ()
|
104 |
+
{
|
105 |
+
clearInterval(timer);
|
106 |
+
};
|
107 |
+
}
|
108 |
+
|
109 |
+
var statusCounter = new Countdown(
|
110 |
+
{
|
111 |
+
seconds:<?php echo $status['duration'] - $status['seconds'] ?>,
|
112 |
+
onUpdateStatus: function(sec)
|
113 |
+
{
|
114 |
+
var delta = Math.abs(sec);
|
115 |
+
|
116 |
+
// calculate (and subtract) whole days
|
117 |
+
var days = Math.floor(delta / 86400);
|
118 |
+
delta -= days * 86400;
|
119 |
+
|
120 |
+
// calculate (and subtract) whole hours
|
121 |
+
var hours = Math.floor(delta / 3600) % 24;
|
122 |
+
delta -= hours * 3600;
|
123 |
+
|
124 |
+
// calculate (and subtract) whole minutes
|
125 |
+
var minutes = Math.floor(delta / 60) % 60;
|
126 |
+
delta -= minutes * 60;
|
127 |
+
|
128 |
+
// what's left is seconds
|
129 |
+
var seconds = delta % 60;
|
130 |
+
|
131 |
+
var display = "";
|
132 |
+
|
133 |
+
if (days > 0)
|
134 |
+
{
|
135 |
+
display += " " + days + " day";
|
136 |
+
if (days != 1)
|
137 |
+
display += "s";
|
138 |
+
}
|
139 |
+
|
140 |
+
if (hours > 0)
|
141 |
+
{
|
142 |
+
display += " " + hours + " hour";
|
143 |
+
if (hours != 1)
|
144 |
+
display += "s";
|
145 |
+
}
|
146 |
+
|
147 |
+
if (minutes > 0)
|
148 |
+
{
|
149 |
+
display += " " + minutes + " minute";
|
150 |
+
if (minutes != 1)
|
151 |
+
display += "s";
|
152 |
+
}
|
153 |
+
|
154 |
+
display += " " + seconds + " second";
|
155 |
+
|
156 |
+
if (seconds != 1)
|
157 |
+
display += "s";
|
158 |
+
|
159 |
+
$('ed_time_remaining').update(display);
|
160 |
+
}
|
161 |
+
});
|
162 |
+
|
163 |
+
statusCounter.start();
|
164 |
+
|
165 |
+
var last_focus = 0;
|
166 |
+
|
167 |
+
function onBlur()
|
168 |
+
{
|
169 |
+
console.log('window blur');
|
170 |
+
};
|
171 |
+
function onFocus()
|
172 |
+
{
|
173 |
+
if (last_focus != 0)
|
174 |
+
{
|
175 |
+
var current_time = new Date().getTime();
|
176 |
+
if (current_time - last_focus > 60000)
|
177 |
+
{
|
178 |
+
last_focus = current_time;
|
179 |
+
getStatus();
|
180 |
+
}
|
181 |
+
}
|
182 |
+
else
|
183 |
+
last_focus = new Date().getTime();
|
184 |
+
};
|
185 |
+
|
186 |
+
if (/*@cc_on!@*/false)
|
187 |
+
{ // check for Internet Explorer
|
188 |
+
document.onfocusin = onFocus;
|
189 |
+
//document.onfocusout = onBlur;
|
190 |
+
}
|
191 |
+
else
|
192 |
+
{
|
193 |
+
window.onfocus = onFocus;
|
194 |
+
//window.onblur = onBlur;
|
195 |
+
}
|
196 |
+
|
197 |
+
</script>
|
198 |
+
|
199 |
+
<?php endif; ?>
|
app/design/adminhtml/default/default/template/emaildirect/troubleshooting/view.phtml
CHANGED
@@ -1,16 +1,9 @@
|
|
1 |
<?php echo $this->getFormInitScripts() ?>
|
|
|
2 |
<div class="content-header">
|
3 |
<?php echo $this->getHeaderHtml() ?>
|
4 |
<p class="form-buttons"><?php echo $this->getButtonsHtml('header') ?></p>
|
5 |
</div>
|
6 |
-
<?php if ($this->isLogFileTooLarge()): ?>
|
7 |
-
<p class='log_note'><strong>Note:</strong> The log file is too large to send the entire file. Only the last <?php echo $this->getMaxLogFileSize() ?> will be sent.</p>
|
8 |
-
<p>To send the entire log, please compress the file and send it to <a href="mailto:<?php echo $this->getTroubleEmail() ?>?subject=<?php echo $this->getTroubleSubject() ?>"><?php echo $this->getTroubleEmail() ?></a>.<br />This file will be called <strong><?php echo $this->getLogFileName() ?></strong> and will most likely be located in the <strong>var/log</strong> folder in the root of your Magento Installation.</p>
|
9 |
-
<br />
|
10 |
-
<?php elseif ($this->getLogFileSize() == 0): ?>
|
11 |
-
<p class='log_note'><strong>Note:</strong> The log file is currently empty. Sending the report is not recommended until log data has been captured.</p>
|
12 |
-
<br />
|
13 |
-
<?php endif; ?>
|
14 |
<?php echo $this->getFormHtml() ?>
|
15 |
<?php if ($this->hasFooterButtons()): ?>
|
16 |
<div class="content-footer">
|
1 |
<?php echo $this->getFormInitScripts() ?>
|
2 |
+
<?php echo $this->getChildHtml('troubleshooting_status'); ?>
|
3 |
<div class="content-header">
|
4 |
<?php echo $this->getHeaderHtml() ?>
|
5 |
<p class="form-buttons"><?php echo $this->getButtonsHtml('header') ?></p>
|
6 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
7 |
<?php echo $this->getFormHtml() ?>
|
8 |
<?php if ($this->hasFooterButtons()): ?>
|
9 |
<div class="content-footer">
|
app/design/adminhtml/default/default/template/emaildirect/troubleshooting/view/tab/download.phtml
CHANGED
@@ -6,7 +6,7 @@
|
|
6 |
<div class="hor-scroll">
|
7 |
<p>Click the button below to download the troubleshooting report.</p>
|
8 |
<p>You can then send this report along with your contact information and description of the problem you are having to <a href="mailto:<?php echo $this->getTroubleEmail() ?>?subject=<?php echo $this->getTroubleSubject() ?>"><?php echo $this->getTroubleEmail() ?></a>.</p>
|
9 |
-
<button onclick="setLocation('<?php echo $this->getUrl('
|
10 |
</div>
|
11 |
</div>
|
12 |
</div>
|
6 |
<div class="hor-scroll">
|
7 |
<p>Click the button below to download the troubleshooting report.</p>
|
8 |
<p>You can then send this report along with your contact information and description of the problem you are having to <a href="mailto:<?php echo $this->getTroubleEmail() ?>?subject=<?php echo $this->getTroubleSubject() ?>"><?php echo $this->getTroubleEmail() ?></a>.</p>
|
9 |
+
<button onclick="setLocation('<?php echo $this->getUrl('ed_integration/admin_troubleshooting/download/') ?>'); return false;">Download Report</button>
|
10 |
</div>
|
11 |
</div>
|
12 |
</div>
|
app/design/adminhtml/default/default/template/emaildirect/troubleshooting/view/tab/help.phtml
ADDED
@@ -0,0 +1,193 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
$customer_fields = $this->getCustomerFields();
|
3 |
+
$address_fields = $this->getAddressFields();
|
4 |
+
$shipping_fields = $this->getShippingFields();
|
5 |
+
?>
|
6 |
+
|
7 |
+
<div class='emaildirect_help'>
|
8 |
+
<h1>Help</h1>
|
9 |
+
<h2>Configuration</h2>
|
10 |
+
<h3>General Configuration</h3>
|
11 |
+
<h4>Enabled</h4>
|
12 |
+
<p>Must be set to Yes.</p>
|
13 |
+
<h4>API Key</h4>
|
14 |
+
<p>You must enter an API Key that from your EmailDirect account which can be found under the Account Setup,
|
15 |
+
API Key tab.</p>
|
16 |
+
<p>After entering your API Key, press the "Validate" button and once the key has been validated press the "Save Config" button.</p>
|
17 |
+
<h4>Subscribe on Checkout</h4>
|
18 |
+
<p>This will give you the option to choose your subscription type during the checkout process. You can make your subscription an opt-in, opt-out, or force a subscription for everyone.</p>
|
19 |
+
<p>If you have a customized checkout, this feature may not work properly as we cannot display the subscribe checkbox on customized checkouts without modification. </p>
|
20 |
+
<p>The "Force Subscription" option should still work as it does not depend on interacting with your custom checkout. Please contact us if you require assistance integrating EmailDirect with your custom checkout.</p>
|
21 |
+
<h4>Publication</h4>
|
22 |
+
<p>These are all of your Publications from within EmailDirect. Choose which Publication you wish to subscribe your customers too. This is required to be able to email them from your EmailDirect account.</p>
|
23 |
+
<h4>Additional Lists</h4>
|
24 |
+
<p>These are all of the Lists in your EmailDirect account. Selecting one or many list in this table will enable your customers to signup for sub segments, on top of the Publication. These can easily be used to get more information on specifi c topics/categories that your customers are interested in.</p>
|
25 |
+
<h4>Source</h4>
|
26 |
+
<p>This will allow you to defi ne the Source which will be associated with the emails added to your EmailDirect
|
27 |
+
account.</p>
|
28 |
+
<h4>Override Source</h4>
|
29 |
+
<p>Selecting Yes will update the Source for any subscribers that may already be in your EmailDirect
|
30 |
+
account. Selecting No will keep the original Source that they have.</p>
|
31 |
+
<h3>Field Mappings</h3>
|
32 |
+
<h4>Customer Fields</h4>
|
33 |
+
<p>This allows you to setup the customer fields you wish to map to EmailDirect.</p>
|
34 |
+
<?php if (count($customer_fields) == 0): ?>
|
35 |
+
<p>We are unable to find any customers in your database and so we cannot load a list of available fields. Please create a customer and try again.</p>
|
36 |
+
<?php else: ?>
|
37 |
+
<p>Here is a list of potential fields available for you to send as part of the customer mapping. These fields are taken directly from your customer object, but note that not all of them are good candidates to map:</p>
|
38 |
+
<table class='map_field_list'>
|
39 |
+
<tr>
|
40 |
+
<?php foreach ($customer_fields as $field_column): ?>
|
41 |
+
<td>
|
42 |
+
<?php foreach ($field_column as $field): ?>
|
43 |
+
<?php echo $field ?><br />
|
44 |
+
<?php endforeach; ?>
|
45 |
+
</td>
|
46 |
+
<?php endforeach; ?>
|
47 |
+
</tr>
|
48 |
+
</table>
|
49 |
+
<?php endif; ?>
|
50 |
+
<h4>Address Fields</h4>
|
51 |
+
<p>This allows you to setup the address fields you wish to map to EmailDirect.</p>
|
52 |
+
<?php if (count($address_fields) == 0): ?>
|
53 |
+
<p>We are unable to find any customer addresses in your database and so we cannot load a list of available fields. Please create a customer address and try again.</p>
|
54 |
+
<?php else: ?>
|
55 |
+
<p>Here is a list of potential fields available for you to send as part of the billing address mapping. These fields are taken directly from your billing address object, but note that not all of them are good candidates to map:</p>
|
56 |
+
<table class='map_field_list'>
|
57 |
+
<tr>
|
58 |
+
<?php foreach ($address_fields as $field_column): ?>
|
59 |
+
<td>
|
60 |
+
<?php foreach ($field_column as $field): ?>
|
61 |
+
<?php echo $field ?><br />
|
62 |
+
<?php endforeach; ?>
|
63 |
+
</td>
|
64 |
+
<?php endforeach; ?>
|
65 |
+
</tr>
|
66 |
+
</table>
|
67 |
+
<?php endif; ?>
|
68 |
+
<p>The following custom address fields are available:</p>
|
69 |
+
<table class='map_field_custom'>
|
70 |
+
<tr>
|
71 |
+
<td>state_code</td>
|
72 |
+
<td>The region_id field is used to load the 2 character state code for the address.</td>
|
73 |
+
</tr>
|
74 |
+
</table>
|
75 |
+
<h4>Shipping Fields</h4>
|
76 |
+
<p>This allows you to setup the shipping fields you wish to map to EmailDirect.</p>
|
77 |
+
<p>The following fields are available for mapping:</p>
|
78 |
+
<table class='map_field_list'>
|
79 |
+
<tr>
|
80 |
+
<?php foreach ($shipping_fields as $field_column): ?>
|
81 |
+
<td>
|
82 |
+
<?php foreach ($field_column as $field): ?>
|
83 |
+
<?php echo $field ?><br />
|
84 |
+
<?php endforeach; ?>
|
85 |
+
</td>
|
86 |
+
<?php endforeach; ?>
|
87 |
+
</tr>
|
88 |
+
</table>
|
89 |
+
<h3>Orders</h3>
|
90 |
+
<h4>Send orders to EmailDirect</h4>
|
91 |
+
<p>Selecting Yes here will send all orders that are made in Magento to EmailDirect's Purchase Behavior. This will allow you to filter within EmailDirect on Product, Order and Category Parameters.</p>
|
92 |
+
<h4>Send Orders based on</h4>
|
93 |
+
<p>Choose whether orders will be sent based on order State or Status.</p>
|
94 |
+
<h4>State or Status Options</h4>
|
95 |
+
<p>This allows you to choose which order state(s)/statuses will be used to determine when an order will be sent to EmailDirect.</p>
|
96 |
+
<p>This will include all custom states or statuses that you have created within your Magento store and selecting multiple options will not send the order twice.</p>
|
97 |
+
<h4>Save Latest Order Information</h4>
|
98 |
+
<p>Selecting Yes will update a subscribers record with detailed information for up to 3 products per order.</p>
|
99 |
+
<p>For each product, the following fields will be sent:</p>
|
100 |
+
<table class='map_field_list'>
|
101 |
+
<tr>
|
102 |
+
<td>Product Name<br />Parent Name (for complex products)<br />SKU<br />URL<br />ImageURL<br />Description<br />Cost</td>
|
103 |
+
</tr>
|
104 |
+
</table>
|
105 |
+
<p>This information can be used to personalize your emails for Product Review emails, Thank You emails, etc.. Old information
|
106 |
+
will be erased when a new order is made.</p>
|
107 |
+
<h4>Send Orders in the background?</h4><p>Allows you to send orders through a cron process.</p>
|
108 |
+
<h4>Send in background only?</h4><p>Orders will only be sent in the background process.</p>
|
109 |
+
<h3>Abandoned Carts</h3>
|
110 |
+
<h4>Add Abandoned Carts to EmailDirect</h4>
|
111 |
+
<p>Selecting Yes will update a subscribers record with detailed information
|
112 |
+
for up to 3 products per abandoned cart.</p>
|
113 |
+
<p>For each product, the following fields will be sent:</p>
|
114 |
+
<table class='map_field_list'>
|
115 |
+
<tr>
|
116 |
+
<td>Product Name<br />SKU<br />URL<br />ImageURL<br />Description<br />Cost</td>
|
117 |
+
</tr>
|
118 |
+
</table>
|
119 |
+
<p>This information can be used to personalize your emails for Abandoned Cart emails. Old
|
120 |
+
information will be erased when a new cart is abandoned.</p>
|
121 |
+
<h4>Abandoned Time</h4>
|
122 |
+
<p>This is the amount of time before a cart is considered abandoned.</p>
|
123 |
+
<h4>Abandoned Publication</h4>
|
124 |
+
<p>This is the Publication that you will put abandoned shoppers into. Some companies like
|
125 |
+
to make this a separate Publication that a user can unsubscribe from.</p>
|
126 |
+
<h4>Abandoned List</h4>
|
127 |
+
<p>These are all of the Lists in your EmailDirect account. Selecting one of these will add your
|
128 |
+
customers to this list, on top of the abandoned Publication that is chosen. This can be used to easily trigger abandoned
|
129 |
+
cart workflows or for retargeting campaigns by bulk campaigns.</p>
|
130 |
+
<h4>Capture Guest Emails?</h4>
|
131 |
+
<p>When enabled, this feature will capture guest emails from various forms within the site to
|
132 |
+
be used with Abandoned Carts.</p>
|
133 |
+
<h3>Abandoned Cart Sequences</h3>
|
134 |
+
<h4>Add a sequence value to each abandoned cart?</h4>
|
135 |
+
<p>This will allow you to assign a sequence of values to your subscribers, one for each abandoned shopping cart. For every abandoned cart, the next value in the list will be applied and over write any past values that were assigned.</p>
|
136 |
+
<h4>Sequence Database Field</h4>
|
137 |
+
<p>This is the field within EmailDirect that the sequence will be stored in.</p>
|
138 |
+
<h4>Sequence Options</h4>
|
139 |
+
<p>Put a list of sequences that will help you identify and filter for A/B testing your abandoned cart
|
140 |
+
process. This can include any identifying information and can include as many as you want, enter one per line.</p>
|
141 |
+
<p>Example:</p>
|
142 |
+
<div class='sequence_example'>
|
143 |
+
A<br />
|
144 |
+
B<br />
|
145 |
+
C<br />
|
146 |
+
</div>
|
147 |
+
<p>Or</p>
|
148 |
+
<div class='sequence_example'>
|
149 |
+
1<br />2<br />3<br />4<br />5
|
150 |
+
</div>
|
151 |
+
<h3>EmailDirect Signup Form</h3>
|
152 |
+
<h4>Show EmailDirect Signup Form</h4><p>This will allow a pop up on your homepage that shows an EmailDirect form for
|
153 |
+
capturing email addresses.</p>
|
154 |
+
<h4>URL to Signup Form</h4><p>Input the Form URL given to you from within your EmailDirect account. This is given after you
|
155 |
+
design and save a signup form.</p>
|
156 |
+
<h4>Delay before showing</h4><p>This will be the amount of seconds before the popup shows.</p>
|
157 |
+
<h4>Recurrence</h4><p>This is the time until the Signup Form displays again for any particular visitor.</p>
|
158 |
+
<h4>Width of Form</h4><p>Should correlate with your signup page design to properly show your entire message.</p>
|
159 |
+
<h4>Height of Form</h4><p>Should correlate with your signup page design to properly show your entire message.</p>
|
160 |
+
<h4>Opacity of Background</h4><p>this will determine the darkness of the users screen, outside the popup.</p>
|
161 |
+
<h4>Test Signup Form</h4><p>Allows for testing without saving the configuration.</p>
|
162 |
+
<h4>Activate Signup Form</h4><p>Activates the form with the above settings.</p>
|
163 |
+
<h2>Export Options</h2>
|
164 |
+
<h3>Order Exports</h3>
|
165 |
+
<h4>Include Orders already sent?</h4>
|
166 |
+
<p>This will allow you to include orders that may have previously been sent to EmailDirect and may cause duplicates. We recommend leaving this option set to No, unless you have deleted orders within EmailDirect and wish to get them back.</p>
|
167 |
+
<h4>Order Date Range</h4>
|
168 |
+
<p>Select the range of dates that you wish to collect orders from. If the extension is pushing new orders over to EmailDirect, select the date ranges in which this process was not running to avoid duplicate orders.</p>
|
169 |
+
<h4>Export Orders</h4>
|
170 |
+
<p>This will export your orders and present them to you in a .csv file that you can download. It will also add them to your EmailDirect FTP. To import these orders from within EmailDirect, go to the Purchase Behavior tab, then select Orders and next to the Add New Order button, you can select a drop down to choose Import Order File.</p>
|
171 |
+
<p>Once on this page, select the file from the FTP to import your past orders. Be sure to map the fi elds correctly to the
|
172 |
+
correctly named database columns.</p>
|
173 |
+
<h3>Category Exports</h3>
|
174 |
+
<h4>Include Disabled Products</h4><p>This will grab all products in Magento to be passed over to EmailDirect, even those
|
175 |
+
which have been disabled.</p>
|
176 |
+
<h4>Export Products</h4><p>This will export your Products/Categories and present them to you in a .csv fi le that you can
|
177 |
+
download. It will also add them to your EmailDirect FTP. To import these orders from within EmailDirect, go to the
|
178 |
+
Purchase Behavior tab, then select Products and next to the Add New Product button, you can select a drop down
|
179 |
+
to choose Import File. Once on this page, select the fi le from the FTP or the .csv from your desktop to import your
|
180 |
+
categories and products.</p>
|
181 |
+
<!-- ABANDONED CARTS -->
|
182 |
+
<h2><a name='abandoned_carts'></a>Abandoned Carts</h2>
|
183 |
+
<p>In order for abandoned carts to be processed automatically, cron must be running on your server.</p>
|
184 |
+
<p>The Abandoned Cart process is scheduled to run every hour on the hour so if you are seeing a warning icon <img src="<?php echo Mage::getDesign()->getSkinUrl('images/warning_msg_icon.gif') ?>" /> next to your cron Last Run Date (and the module has not just been recently installed) then you need to verify that cron is running properly.</p>
|
185 |
+
<p>Please visit this <a href="http://www.magentocommerce.com/wiki/1_-_installation_and_configuration/how_to_setup_a_cron_job">link</a> for detailed information on cron setup in the Magento Wiki.</p>
|
186 |
+
<h2><a name='diagnostics'></a>Diagnostics</h2>
|
187 |
+
<p>Diagnostics allow you to test specific parts of the EmailDirect process. They can be enabled in the settings tab.</p>
|
188 |
+
<p>If EmailDirect is not enabled or setup for a store, some diagnostics can still be performed but the output may not be 100% accurate depending on what configuration values have been specified.</p>
|
189 |
+
<h3>Orders</h3>
|
190 |
+
<p>To run Diagnostics on an order, go to the Order View page and select the <strong>EmailDirect Diagnostics</strong> tab on the left side of the screen.</p>
|
191 |
+
<h3>Abandoned Carts</h3>
|
192 |
+
<p>To run Diagnostics on an abandoned cart, go to the <a href='<?php echo $this->getUrl('ed_integration/admin_abandoned/index') ?>'>EmailDirect Abandoned Carts Page</a> and click on a row to run diagnostics on that cart.</p>
|
193 |
+
</div>
|
app/design/adminhtml/default/default/template/emaildirect/troubleshooting/view/tab/log.phtml
CHANGED
@@ -1,11 +1,72 @@
|
|
1 |
-
<div class="entry-edit
|
2 |
<div class="entry-edit-head">
|
3 |
<h4 class="icon-head"><?php echo Mage::helper('emaildirect')->__('EmailDirect Log File') ?></h4>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4 |
</div>
|
5 |
<fieldset>
|
6 |
-
<div>
|
7 |
-
|
8 |
<pre><?php echo $this->getLogFile() ?></pre>
|
9 |
</div>
|
10 |
</fieldset>
|
11 |
-
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<div class="entry-edit">
|
2 |
<div class="entry-edit-head">
|
3 |
<h4 class="icon-head"><?php echo Mage::helper('emaildirect')->__('EmailDirect Log File') ?></h4>
|
4 |
+
<div class="tools">
|
5 |
+
<a href='#' onclick="return performRequest('log_refresh',false);">Refresh</a>
|
6 |
+
<span> | </span>
|
7 |
+
<a href='#' onclick="return performRequest('erase_log',true);">Erase Log</a>
|
8 |
+
<span> | </span>
|
9 |
+
<a href='#' onclick="return performRequest('test_logging',false);">Test Logging</a>
|
10 |
+
</div>
|
11 |
</div>
|
12 |
<fieldset>
|
13 |
+
<div class="entry-logfile" id='logfile_contents'>
|
|
|
14 |
<pre><?php echo $this->getLogFile() ?></pre>
|
15 |
</div>
|
16 |
</fieldset>
|
17 |
+
</div>
|
18 |
+
|
19 |
+
<script type='text/javascript'>
|
20 |
+
var FORM_KEY = "<?php echo $this->getFormKey();?>";
|
21 |
+
|
22 |
+
function showLogFile(contents)
|
23 |
+
{
|
24 |
+
$("logfile_contents").update("<pre>" + contents + "</pre>");
|
25 |
+
scrollToBottom();
|
26 |
+
}
|
27 |
+
|
28 |
+
function scrollToBottom()
|
29 |
+
{
|
30 |
+
var container = document.getElementById("logfile_contents");
|
31 |
+
container.scrollTop = container.scrollHeight;
|
32 |
+
}
|
33 |
+
|
34 |
+
function performRequest(method, get_confirmation)
|
35 |
+
{
|
36 |
+
if (get_confirmation == true)
|
37 |
+
{
|
38 |
+
if (!window.confirm("Are you sure?"))
|
39 |
+
return;
|
40 |
+
}
|
41 |
+
new Ajax.Request('<?php echo $this->getUrl('ed_integration/admin_troubleshooting/ajax') ?>',
|
42 |
+
{
|
43 |
+
parameters: {isAjax: 'true', form_key: FORM_KEY, method: method},
|
44 |
+
onSuccess: function(transport)
|
45 |
+
{
|
46 |
+
try
|
47 |
+
{
|
48 |
+
if (transport.responseText.isJSON())
|
49 |
+
{
|
50 |
+
var response = transport.responseText.evalJSON()
|
51 |
+
if (response.error)
|
52 |
+
{
|
53 |
+
alert(response.message);
|
54 |
+
}
|
55 |
+
if(response.ajaxExpired && response.ajaxRedirect)
|
56 |
+
{
|
57 |
+
setLocation(response.ajaxRedirect);
|
58 |
+
}
|
59 |
+
|
60 |
+
showLogFile(response.contents);
|
61 |
+
}
|
62 |
+
}
|
63 |
+
catch (e)
|
64 |
+
{
|
65 |
+
showOutput(transport.responseText);
|
66 |
+
}
|
67 |
+
}
|
68 |
+
});
|
69 |
+
|
70 |
+
return false;
|
71 |
+
}
|
72 |
+
</script>
|
app/design/adminhtml/default/default/template/emaildirect/troubleshooting/view/tab/settings.phtml
ADDED
@@ -0,0 +1,218 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
$status = $this->getLoggingStatus();
|
3 |
+
$areas = Mage::helper('emaildirect/troubleshooting')->getAreas();
|
4 |
+
|
5 |
+
$logging_enabled = $this->getSetting('logging_enabled') == 1;
|
6 |
+
$advanced_enabled = $this->getSetting('logging_advanced_enabled') == 1;
|
7 |
+
|
8 |
+
$diagnostic_enabled = Mage::helper('emaildirect/troubleshooting')->isDiagnosticEnabled();
|
9 |
+
|
10 |
+
?>
|
11 |
+
|
12 |
+
<div class="entry-edit">
|
13 |
+
<div class="entry-edit-head">
|
14 |
+
<h4>Troubleshooting Settings</h4>
|
15 |
+
</div>
|
16 |
+
<div id="_accountbase_fieldset" class="fieldset ">
|
17 |
+
|
18 |
+
|
19 |
+
<div class="hor-scroll">
|
20 |
+
<form id='emaildirect_settings_form' action='<?php echo Mage::helper('emaildirect')->getAdminUrl("ed_integration/admin_troubleshooting/save"); ?>' method='post'>
|
21 |
+
<input type="hidden" name="form_key" value="<? echo $this->getFormKey(); ?>" />
|
22 |
+
|
23 |
+
<table cellspacing="0" class="form-list">
|
24 |
+
<tbody>
|
25 |
+
<tr class="system-fieldset-sub-head"><td colspan="2"><h4>Logging</h4></td></tr>
|
26 |
+
<tr>
|
27 |
+
<td class="label"><label for="logging_enabled">Enabled</label></td>
|
28 |
+
<td class="value">
|
29 |
+
<select id='logging_enabled' name='logging_enabled'>
|
30 |
+
<option value='yes'>Yes</option>
|
31 |
+
<option value='no' <?php if (!$logging_enabled) echo "selected='selected'" ?>>No</option>
|
32 |
+
</select>
|
33 |
+
</td>
|
34 |
+
</tr>
|
35 |
+
<tr id='logging_advanced_row' <?php if (!$logging_enabled) echo "style='display:none'" ?>>
|
36 |
+
<td class="label"><label for="logging_advanced_enabled">Advanced Settings</label></td>
|
37 |
+
<td class="value">
|
38 |
+
<select id='logging_advanced_enabled' name='logging_advanced_enabled'>
|
39 |
+
<option value='enabled'>Enabled</option>
|
40 |
+
<option value='disabled' <?php if (!$advanced_enabled) echo "selected='selected'" ?>>Disabled</option>
|
41 |
+
</select>
|
42 |
+
</td>
|
43 |
+
</tr>
|
44 |
+
</tbody>
|
45 |
+
</table>
|
46 |
+
|
47 |
+
<div id='advanced_settings' <?php if (!$logging_enabled || !$advanced_enabled) echo "style='display:none'" ?>>
|
48 |
+
<table cellspacing="0" class="form-list">
|
49 |
+
<tbody>
|
50 |
+
<tr>
|
51 |
+
<td class="label"><label for="logging_stores">Stores</label></td>
|
52 |
+
<td class="value">
|
53 |
+
<select id='logging_stores' name='logging_stores'>
|
54 |
+
<option value='all'>All</option>
|
55 |
+
<option value='selected' <?php if ($this->getSetting('logging_stores') == "selected") echo "selected='selected'" ?>>Selected</option>
|
56 |
+
</select>
|
57 |
+
</td>
|
58 |
+
</tr>
|
59 |
+
</table>
|
60 |
+
<table cellspacing="0" class='troubleshooting_details' id='troubleshooting_stores' <?php if ($this->getSetting('logging_stores') == "all") echo "style='display:none'" ?>>
|
61 |
+
<tbody>
|
62 |
+
<tr>
|
63 |
+
<th>Store Name</th>
|
64 |
+
<th>Logging</th>
|
65 |
+
</tr>
|
66 |
+
<?php $stores = $this->getArraySetting("logging_stores_selected"); ?>
|
67 |
+
<?php foreach ($status['stores'] as $store): ?>
|
68 |
+
<tr>
|
69 |
+
<td><?php echo $store['name'] ?> <?php if (!$store['emaildirect_enabled']) echo "(disabled)"; ?></td>
|
70 |
+
<td align='center'>
|
71 |
+
<input type='checkbox' value='<?php echo $store['id'] ?>' name='logging_stores_selected[]' id='logging_stores_selected_<?php echo $store['id'] ?>' <?php if ($store['selected']) echo "checked='checked'"; ?> /></td>
|
72 |
+
</tr>
|
73 |
+
<?php endforeach; ?>
|
74 |
+
|
75 |
+
</tbody>
|
76 |
+
</table>
|
77 |
+
|
78 |
+
<table cellspacing="0" class="form-list">
|
79 |
+
<tbody>
|
80 |
+
<tr>
|
81 |
+
<td class="label"><label for="logging_areas">Areas</label></td>
|
82 |
+
<td class="value">
|
83 |
+
<select id='logging_areas' name='logging_areas'>
|
84 |
+
<option value='all'>All</option>
|
85 |
+
<option value='selected' <?php if ($this->getSetting('logging_areas') == "selected") echo "selected='selected'" ?>>Selected</option>
|
86 |
+
</select>
|
87 |
+
|
88 |
+
<table cellspacing="0" class='troubleshooting_details' id='troubleshooting_areas' <?php if ($this->getSetting('logging_areas') == "all") echo "style='display:none'" ?>>
|
89 |
+
<tbody>
|
90 |
+
<?php foreach ($status['areas'] as $key => $area): ?>
|
91 |
+
<tr>
|
92 |
+
<td><?php echo $area['label'] ?></td>
|
93 |
+
<td align='center'><input type='checkbox' value='<?php echo $key ?>' name='logging_areas_selected[]' id='logging_areas_selected_<?php echo $key ?>' <?php if ($area['selected']) echo "checked='checked'"; ?> /></td>
|
94 |
+
</tr>
|
95 |
+
<?php endforeach; ?>
|
96 |
+
|
97 |
+
</tbody>
|
98 |
+
</table>
|
99 |
+
</td>
|
100 |
+
</tr>
|
101 |
+
</table>
|
102 |
+
|
103 |
+
|
104 |
+
<table cellspacing="0" class="form-list">
|
105 |
+
<tbody>
|
106 |
+
<tr>
|
107 |
+
<td class="label"><label for="ip_address">IP Address</label></td>
|
108 |
+
<td class="value">
|
109 |
+
<textarea id='ip_address' name='ip_address'><?php echo $this->getSetting('logging_ip') ?></textarea>
|
110 |
+
<p id="note_ip_address" class="note"><span>Limit logging to specific IP addresses. For multiple addresses use a comma separated list.</span></p>
|
111 |
+
<p class='current_ip'><span class='your_ip'>Your IP:</span><span class='current_ip_address'><?php echo $this->getCurrentIP(); ?></span> <button onclick="return addIP();" class='scalable add'><span>Add</span></button></p>
|
112 |
+
</td>
|
113 |
+
</tr>
|
114 |
+
<tr>
|
115 |
+
<td class="label"><label for="duration">Duration</label></td>
|
116 |
+
<td class="value">
|
117 |
+
<?php $duration_options = $this->getDurationOptions();
|
118 |
+
$duration = $this->getSetting('logging_duration');
|
119 |
+
?>
|
120 |
+
<select name='logging_duration' id='logging_duration'>
|
121 |
+
<?php foreach ($duration_options as $value => $label): ?>
|
122 |
+
<option value='<?php echo $value ?>' <?php if ($value == $duration) echo "selected='selected'" ?>><?php echo $label ?></option>
|
123 |
+
<?php endforeach; ?>
|
124 |
+
</select>
|
125 |
+
</td>
|
126 |
+
</tr>
|
127 |
+
</tbody>
|
128 |
+
</table>
|
129 |
+
|
130 |
+
</div>
|
131 |
+
<table cellspacing="0" class="form-list">
|
132 |
+
<tbody>
|
133 |
+
<tr class="system-fieldset-sub-head"><td colspan="2"><h4>Diagnostics</h4></td></tr>
|
134 |
+
<tr>
|
135 |
+
<td class="label"><label for="diagnostic_enabled">Enabled</label></td>
|
136 |
+
<td class="value">
|
137 |
+
<select id='diagnostic_enabled' name='diagnostic_enabled'>
|
138 |
+
<option value='1'>Yes</option>
|
139 |
+
<option value='0' <?php if (!$diagnostic_enabled) echo "selected='selected'" ?>>No</option>
|
140 |
+
</select>
|
141 |
+
</td>
|
142 |
+
</tr>
|
143 |
+
<tr>
|
144 |
+
<td class="label"></td>
|
145 |
+
<td class="value">
|
146 |
+
<button>Save Settings</button>
|
147 |
+
</td>
|
148 |
+
</tr>
|
149 |
+
</tbody>
|
150 |
+
</table>
|
151 |
+
</form>
|
152 |
+
<script type="text/javascript">
|
153 |
+
|
154 |
+
function addIP()
|
155 |
+
{
|
156 |
+
var current = $('ip_address').value;
|
157 |
+
if (current != "")
|
158 |
+
current += ",";
|
159 |
+
|
160 |
+
current += '<?php echo $this->getCurrentIP(); ?>';
|
161 |
+
|
162 |
+
|
163 |
+
|
164 |
+
console.log(current);
|
165 |
+
|
166 |
+
$('ip_address').value = current;
|
167 |
+
|
168 |
+
return false;
|
169 |
+
}
|
170 |
+
|
171 |
+
function toggle(evt, target, value)
|
172 |
+
{
|
173 |
+
var elem = Event.element(evt);
|
174 |
+
|
175 |
+
if (elem)
|
176 |
+
{
|
177 |
+
if (elem.value == value)
|
178 |
+
$(target).hide();
|
179 |
+
else
|
180 |
+
$(target).show();
|
181 |
+
}
|
182 |
+
}
|
183 |
+
|
184 |
+
function toggleStores(evt)
|
185 |
+
{
|
186 |
+
toggle(evt,'troubleshooting_stores','all');
|
187 |
+
}
|
188 |
+
|
189 |
+
function toggleAreas(evt)
|
190 |
+
{
|
191 |
+
toggle(evt,'troubleshooting_areas','all');
|
192 |
+
}
|
193 |
+
|
194 |
+
function toggleAdvanced(evt)
|
195 |
+
{
|
196 |
+
toggle(evt,'advanced_settings','disabled');
|
197 |
+
}
|
198 |
+
|
199 |
+
function toggleAdvancedRow(evt)
|
200 |
+
{
|
201 |
+
toggle(evt,'logging_advanced_row','no');
|
202 |
+
|
203 |
+
//console.log($('logging_advanced_enabled').value);
|
204 |
+
if ($('logging_advanced_enabled').value == 'enabled')
|
205 |
+
$('advanced_settings').show();
|
206 |
+
}
|
207 |
+
|
208 |
+
Event.observe('logging_stores', 'change', toggleStores);
|
209 |
+
Event.observe('logging_areas', 'change', toggleAreas);
|
210 |
+
Event.observe('logging_advanced_enabled', 'change', toggleAdvanced);
|
211 |
+
Event.observe('logging_enabled', 'change', toggleAdvancedRow);
|
212 |
+
|
213 |
+
// var ed_form = new varienForm('emaildirect_settings_form' );
|
214 |
+
</script>
|
215 |
+
</div>
|
216 |
+
</div>
|
217 |
+
</div>
|
218 |
+
|
app/design/adminhtml/default/default/template/emaildirect/troubleshooting/view/tab/submit.phtml
CHANGED
@@ -1,10 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
<div class="entry-edit">
|
2 |
<div class="entry-edit-head">
|
3 |
<h4>Send Information to EmailDirect</h4>
|
4 |
</div>
|
5 |
<div id="_accountbase_fieldset" class="fieldset ">
|
6 |
<div class="hor-scroll">
|
7 |
-
<form id='emaildirect_submit_form' action='<?php echo $this->getUrl("
|
8 |
<input type="hidden" name="form_key" value="<? echo $this->getFormKey(); ?>" />
|
9 |
<table cellspacing="0" class="form-list">
|
10 |
<tbody>
|
@@ -32,13 +40,6 @@
|
|
32 |
<textarea name='customer_comments' id='customer_comments' class='required-entry'></textarea>
|
33 |
</td>
|
34 |
</tr>
|
35 |
-
<tr>
|
36 |
-
<td class="label"></td>
|
37 |
-
<td class="value">
|
38 |
-
<input type="checkbox" value="off" name="turn_off" id="turn_off">
|
39 |
-
<label for="turn_off">Turn off Troubleshooting after sending?</label>
|
40 |
-
</td>
|
41 |
-
</tr>
|
42 |
<tr>
|
43 |
<td class="label"></td>
|
44 |
<td class="value">
|
@@ -49,9 +50,8 @@
|
|
49 |
</table>
|
50 |
</form>
|
51 |
<script type="text/javascript">
|
52 |
-
|
53 |
</script>
|
54 |
</div>
|
55 |
</div>
|
56 |
-
</div>
|
57 |
-
|
1 |
+
<?php if ($this->isLogFileTooLarge()): ?>
|
2 |
+
<p class='log_note'><strong>Note:</strong> The log file is too large to send the entire file. Only the last <?php echo $this->getMaxLogFileSize() ?> will be sent.</p>
|
3 |
+
<p>To send the entire log, please compress the file and send it to <a href="mailto:<?php echo $this->getTroubleEmail() ?>?subject=<?php echo $this->getTroubleSubject() ?>"><?php echo $this->getTroubleEmail() ?></a>.<br />This file will be called <strong><?php echo $this->getLogFileName() ?></strong> and will most likely be located in the <strong>var/log</strong> folder in the root of your Magento Installation.</p>
|
4 |
+
<br />
|
5 |
+
<?php elseif ($this->getLogFileSize() == 0): ?>
|
6 |
+
<p class='log_note'><strong>Note:</strong> The log file is currently empty. Sending the report is not recommended until log data has been captured.</p>
|
7 |
+
<br />
|
8 |
+
<?php endif; ?>
|
9 |
<div class="entry-edit">
|
10 |
<div class="entry-edit-head">
|
11 |
<h4>Send Information to EmailDirect</h4>
|
12 |
</div>
|
13 |
<div id="_accountbase_fieldset" class="fieldset ">
|
14 |
<div class="hor-scroll">
|
15 |
+
<form id='emaildirect_submit_form' action='<?php echo $this->getUrl("ed_integration/admin_troubleshooting/send"); ?>' method='post'>
|
16 |
<input type="hidden" name="form_key" value="<? echo $this->getFormKey(); ?>" />
|
17 |
<table cellspacing="0" class="form-list">
|
18 |
<tbody>
|
40 |
<textarea name='customer_comments' id='customer_comments' class='required-entry'></textarea>
|
41 |
</td>
|
42 |
</tr>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
43 |
<tr>
|
44 |
<td class="label"></td>
|
45 |
<td class="value">
|
50 |
</table>
|
51 |
</form>
|
52 |
<script type="text/javascript">
|
53 |
+
var ed_form = new varienForm('emaildirect_submit_form' );
|
54 |
</script>
|
55 |
</div>
|
56 |
</div>
|
57 |
+
</div>
|
|
app/design/frontend/base/default/layout/emaildirect.xml
CHANGED
@@ -8,7 +8,7 @@
|
|
8 |
<block type="emaildirect/capture" name="emaildirect_capture" as="emaildirect_capture" template="emaildirect/capture/email.phtml"/>
|
9 |
</reference>
|
10 |
<reference name="head">
|
11 |
-
<action method="addCss"><stylesheet>emaildirect/emaildirect.css</stylesheet></action>
|
12 |
</reference>
|
13 |
</default>
|
14 |
|
@@ -21,15 +21,15 @@
|
|
21 |
<!-- Customer -->
|
22 |
<customer_account>
|
23 |
<reference name="head">
|
24 |
-
<action method="addItem"><type>skin_js</type><name>emaildirect/integration.js</name><params/></action>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
25 |
</reference>
|
26 |
-
<reference name="customer_account_navigation">
|
27 |
-
<action method="addLink" ifconfig="emaildirect/general/active" translate="label" module="emaildirect">
|
28 |
-
<name>emaildirect</name>
|
29 |
-
<path>emaildirect/customer_account/index</path>
|
30 |
-
<label>Newsletter Subscriptions</label>
|
31 |
-
</action>
|
32 |
-
</reference>
|
33 |
</customer_account>
|
34 |
<customer_account_index>
|
35 |
<reference name="my.account.wrapper">
|
@@ -47,8 +47,8 @@
|
|
47 |
<label>Customer My Account Emaildirect</label>
|
48 |
<update handle="customer_account"/>
|
49 |
<reference name="my.account.wrapper">
|
50 |
-
|
51 |
-
|
52 |
</reference>
|
53 |
</emaildirect_customer_account_index>
|
54 |
<!-- Customer -->
|
8 |
<block type="emaildirect/capture" name="emaildirect_capture" as="emaildirect_capture" template="emaildirect/capture/email.phtml"/>
|
9 |
</reference>
|
10 |
<reference name="head">
|
11 |
+
<action method="addCss" ifconfig="emaildirect/general/active"><stylesheet>emaildirect/emaildirect.css</stylesheet></action>
|
12 |
</reference>
|
13 |
</default>
|
14 |
|
21 |
<!-- Customer -->
|
22 |
<customer_account>
|
23 |
<reference name="head">
|
24 |
+
<action method="addItem" ifconfig="emaildirect/general/active"><type>skin_js</type><name>emaildirect/integration.js</name><params/></action>
|
25 |
+
</reference>
|
26 |
+
<reference name="customer_account_navigation">
|
27 |
+
<action method="addLink" ifconfig="emaildirect/general/active" translate="label" module="emaildirect">
|
28 |
+
<name>emaildirect</name>
|
29 |
+
<path>emaildirect/customer_account/index</path>
|
30 |
+
<label>Newsletter Subscriptions</label>
|
31 |
+
</action>
|
32 |
</reference>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
33 |
</customer_account>
|
34 |
<customer_account_index>
|
35 |
<reference name="my.account.wrapper">
|
47 |
<label>Customer My Account Emaildirect</label>
|
48 |
<update handle="customer_account"/>
|
49 |
<reference name="my.account.wrapper">
|
50 |
+
<block type="emaildirect/customer_account_lists" name="emaildirect_additionallists" template="emaildirect/customer/account/lists.phtml" />
|
51 |
+
<block type="customer/account_dashboard" name="customer.account.link.back" template="customer/account/link/back.phtml"/>
|
52 |
</reference>
|
53 |
</emaildirect_customer_account_index>
|
54 |
<!-- Customer -->
|
app/design/frontend/base/default/template/emaildirect/signup/form.phtml
CHANGED
@@ -1,15 +1,21 @@
|
|
1 |
-
<div id=
|
2 |
-
|
3 |
-
<a id='emaildirect_signup_close' href="#" onclick='return closeSignup();'></a>
|
4 |
-
<iframe src='<?php echo $this->getSignupUrl() ?>' id='ed_form' style='width: <?php echo $this->getSignupFrameWidth() ?>; height: <?php echo $this->getSignupFrameHeight(); ?>;'></iframe>
|
5 |
-
</div>
|
6 |
</div>
|
7 |
<script type='text/javascript'>
|
8 |
|
9 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
10 |
{
|
|
|
11 |
$$('body')[0].addClassName('emaildirect_signup_open');
|
12 |
-
|
13 |
}
|
14 |
|
15 |
function closeSignup()
|
@@ -17,18 +23,36 @@ function closeSignup()
|
|
17 |
$$('body')[0].removeClassName('emaildirect_signup_open');
|
18 |
$('emaildirect_signup_background').hide();
|
19 |
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
|
|
27 |
|
28 |
return false;
|
29 |
}
|
30 |
|
31 |
-
|
32 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
33 |
});
|
|
|
34 |
</script>
|
1 |
+
<div id='emaildirect_signup_placeholder'>
|
2 |
+
|
|
|
|
|
|
|
3 |
</div>
|
4 |
<script type='text/javascript'>
|
5 |
|
6 |
+
var params = window.location.search.toQueryParams();
|
7 |
+
|
8 |
+
var signup_enabled = <?php echo $this->isSignupEnabled(); ?>;
|
9 |
+
var test_mode = params.signup_test ? true : false;
|
10 |
+
var signup_delay = params.delay ? params.delay * 1000 : <?php echo $this->getSignupDelay(); ?>;
|
11 |
+
|
12 |
+
console.log(test_mode);
|
13 |
+
|
14 |
+
function showSignup(data)
|
15 |
{
|
16 |
+
$('emaildirect_signup_placeholder').update(data);
|
17 |
$$('body')[0].addClassName('emaildirect_signup_open');
|
18 |
+
//$('emaildirect_signup_background').show();
|
19 |
}
|
20 |
|
21 |
function closeSignup()
|
23 |
$$('body')[0].removeClassName('emaildirect_signup_open');
|
24 |
$('emaildirect_signup_background').hide();
|
25 |
|
26 |
+
if (!test_mode)
|
27 |
+
{
|
28 |
+
var CookieDate = new Date;
|
29 |
+
|
30 |
+
var CurrentDate = Math.round(+new Date()/1000);
|
31 |
+
CookieDate.setFullYear(CookieDate.getFullYear( ) + 5);
|
32 |
+
Mage.Cookies.set('ed_signup', CurrentDate, CookieDate);
|
33 |
+
}
|
34 |
|
35 |
return false;
|
36 |
}
|
37 |
|
38 |
+
function showSignupCheck()
|
39 |
+
{
|
40 |
+
var url = '<?php echo $this->getSignupCheckUrl() ?>' + window.location.search;
|
41 |
+
new Ajax.Request(url, {
|
42 |
+
onSuccess: function(transport)
|
43 |
+
{
|
44 |
+
var json = transport.responseText.evalJSON();
|
45 |
+
|
46 |
+
if (json.can_show == true)
|
47 |
+
showSignup(json.html_content);
|
48 |
+
}
|
49 |
+
});
|
50 |
+
}
|
51 |
+
|
52 |
+
document.observe("dom:loaded", function()
|
53 |
+
{
|
54 |
+
if (signup_enabled || test_mode)
|
55 |
+
window.setTimeout("showSignupCheck()",signup_delay);
|
56 |
});
|
57 |
+
|
58 |
</script>
|
package.xml
CHANGED
@@ -1,18 +1,28 @@
|
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>EmailDirect_Integration</name>
|
4 |
-
<version>2.0.
|
5 |
<stability>stable</stability>
|
6 |
<license/>
|
7 |
<channel>community</channel>
|
8 |
<extends/>
|
9 |
<summary>EmailDirect integration for magento</summary>
|
10 |
<description>EmailDirect integration for magento</description>
|
11 |
-
<notes>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
<authors><author><name>Kevin Linden</name><user>auto-converted</user><email>Kevin@EmailDirect.com</email></author></authors>
|
13 |
-
<date>2014-
|
14 |
-
<time>
|
15 |
-
<contents><target name="magecommunity"><dir name="EmailDirect"><dir name="Integration"><dir name="Block"><dir name="Adminhtml"><dir name="Abandoned"><file name="Grid.php" hash="4a3f8d29d3d8feb13ae124297267ae85"/><file name="Status.php" hash="9a740fd8c63148532bbcf07d19f462df"/></dir><dir name="System"><dir name="Config"><dir name="Fieldset"><file name="Hint.php" hash="d01c241e1c4a42cd08f087ad784ed78e"/></dir><dir name="Form"><dir name="Field"><dir name="Export"><file name="Orders.php" hash="5b101fadb6a64044b276eb07b21cf0a5"/><file name="Products.php" hash="32e13d4b7250890bf84aba87f25de03c"/><file name="Range.php" hash="4adac96fa53fa8e1449bae943a8cca80"/></dir><dir name="Signup"><file name="Test.php" hash="3b773dda25c62bc8cb28031931d67f9f"/></dir><file name="Addressmapfields.php" hash="97b75c8340d561e863a3985ad73ce228"/><file name="Common.php" hash="6a86cce53f6df6857ea79241fa281939"/><file name="Info.php" hash="246de52ea5d2349ecd7f103cbba8cb8f"/><file name="Mapfields.php" hash="16894c5d76df1293e63128e349700e05"/><file name="Note.php" hash="ef99a474bbc3a828c7a618132a80fe66"/><file name="Shippingmapfields.php" hash="589a74260f394a5eae1b57ca89a74a8b"/><file name="Troubleshooting.php" hash="ff6b463004ab037031acea4a6f1d8517"/></dir></dir></dir><dir name="Convert"><dir name="Profile"><dir name="Export"><file name="Orders.php" hash="947af2b0d8e3f7bc47c47b32cd434f18"/><file name="Products.php" hash="3f93e4789dbeb6710cd2742587d61726"/></dir><file name="Export.php" hash="ba879607ac0693e9db6251bbbc1676a1"/></dir></dir></dir><dir name="Troubleshooting"><dir name="View"><dir name="Tab"><file name="Download.php" hash="619916677df7c833e559aae74dae2aa0"/><file name="Info.php" hash="4dad4b18e215d6df8c8e6631b4323b53"/><file name="Log.php" hash="d3dcb67ca284358eaa70db517637da87"/><file name="Submit.php" hash="fe896683680ab10ada6b67e0e803ccce"/></dir><file name="Form.php" hash="e527a3a2335b109c48a69f06c1b0d01f"/></dir><file name="Tabs.php" hash="ab1fdbe561e8572c2c50cdbec9573f82"/><file name="View.php" hash="b2d83536aade45e41039875db85b3018"/></dir><file name="Abandoned.php" hash="515b0c172e093341a2e69cb75570e553"/></dir><dir name="Checkout"><file name="Subscribe.php" hash="ae325e815a54bde93507562cf0d86b8a"/></dir><dir name="Customer"><dir name="Account"><dir name="Dashboard"><file name="Info.php" hash="20e74d9c2b2c02611c8f69b254d81ef5"/></dir><file name="Lists.php" hash="3c3bdb9482ecf4a71740a80395bd5465"/></dir></dir><dir name="Widget"><dir name="Grid"><dir name="Column"><dir name="Renderer"><dir name="Abandoned"><file name="Minutes.php" hash="e311f6de480fd4b63aee7f46ea412372"/></dir><file name="Action.php" hash="bf2243f50c9c6dafca26a5bcb889f372"/></dir></dir></dir></dir><file name="Capture.php" hash="e44034ad875957a566d3ac89abb408ed"/><file name="Signup.php" hash="511c9376560cdc5f63b7dc00bdc205be"/></dir><dir name="Helper"><file name="Data.php" hash="80608a5e064c1292ef14d421f67c01c0"/><file name="Fields.php" hash="9d3df47a02f30ade5372c559e7679107"/><file name="Upgrade.php" hash="407f12bce2c7c06c73a23d8ed853a038"/></dir><dir name="Model"><dir name="Mysql4"><dir name="Abandoned"><file name="Collection.php" hash="5a64b4e8b672f80b4d9b6cc5a0d231eb"/></dir><dir name="Order"><file name="Collection.php" hash="43d343562cf7e54f1b36315aa5d1d4a7"/></dir><dir name="Session"><file name="Collection.php" hash="7d6a8283fdbc1207d709e2bbbc78906d"/></dir><file name="Abandoned.php" hash="485b3771906783d383de75ae9761e55c"/><file name="Order.php" hash="8d538a5737095a1ba0ad448c027b3afb"/><file name="Session.php" hash="516eeeb28038416dc885ed7af6a8a8b0"/></dir><dir name="Resource"><file name="Setup.php" hash="ceb59161dafe7722bec195f5018714dd"/></dir><dir name="System"><dir name="Config"><dir name="Source"><dir name="Export"><file name="Batch.php" hash="96c51fc5c0b947750be4e612e32c83ab"/></dir><dir name="Send"><file name="Field.php" hash="8ecffa8ccce40f3b2db6513b24eb9200"/></dir><dir name="Signup"><file name="Opacity.php" hash="8eabed4c72e7347f0376c3d4cc1023a7"/><file name="Recurrence.php" hash="e11200bbc204b00486c373d8a4e6675e"/></dir><file name="Abandoned.php" hash="9881811b94f38be90bd20a99951a1903"/><file name="Abandonedlist.php" hash="66386003113d8589c9f3de4f03f538a8"/><file name="Additionallist.php" hash="254081820d07a8754a71743ea58a7af4"/><file name="Checkoutsubscribe.php" hash="fd90252a1f19649a420dae136ad2a2ba"/><file name="List.php" hash="d76e36c0198e509a63c663e827cc7940"/><file name="Publication.php" hash="635fae1c20981c0ca7b90007a00e99a7"/><file name="Sequence.php" hash="ec9718c2b5dc35c559e5c09e345eff88"/><file name="Source.php" hash="f3c246959c74f6d378f3e2d7b8148d7f"/><file name="States.php" hash="a746affc786d8165a98801e68cbf80ab"/><file name="Statuses.php" hash="9844a7a9c3b5c68df45c8f6c518acf16"/><file name="Time.php" hash="8acbb5cb33e66de1e408cf55d17a9398"/></dir></dir></dir><dir name="Wrapper"><file name="Abandoned.php" hash="ef81d36a7276737f2d0aa1a5d783a83b"/><file name="Abstract.php" hash="9e97ce6a12e0d074921bb3a1391f3648"/><file name="Database.php" hash="3cceb467358d13584baff58c043762ec"/><file name="Execute.php" hash="5a339e0a5407cf05b161102fc65595bb"/><file name="Ftp.php" hash="d5335cfb68f99761d6902dd390a3d7a8"/><file name="Lists.php" hash="425d64b9256bbdbafa899c4138e78368"/><file name="Orders.php" hash="041ea2cf97c461d670022984e7ff608a"/><file name="Publications.php" hash="815715549df345ccb5b69ed65589aa53"/><file name="Sources.php" hash="c6caf0274f7d0c50114324bc47a490c4"/><file name="Subscribers.php" hash="ed61d6bd944236034bcbc9e68765ff1c"/><file name="Wishlist.php" hash="2ceb111bbeaa06c4f13f61281aaa5b5e"/></dir><file name="Abandoned.php" hash="93bd43b59b143dec15858a6fba6ae568"/><file name="Observer.php" hash="db514d52c55c7e0d50292248fb80e631"/><file name="Order.php" hash="b21426543cd46f799cd0743525120fb8"/><file name="Session.php" hash="c56ecf779dbfb2dae0030935af31911a"/></dir><dir name="controllers"><dir name="Admin"><file name="AbandonedController.php" hash="04be2181a65e505084b324188f1fd64d"/><file name="ExportController.php" hash="e4d3eb0b3a9ef9f3caa0146debc256bc"/><file name="TroubleshootingController.php" hash="3de9950849e08648d8872aea4760c992"/></dir><dir name="Customer"><file name="AccountController.php" hash="ae75c37519f8d9f671509ff9b7fb34a4"/></dir><file name="AbandonedController.php" hash="e915e1b947e62983050a9fdbc0f4d152"/><file name="CaptureController.php" hash="89e043bb3864617a062e915d2209dcf4"/><file name="ExportController.php" hash="7ca147debc5c1436b3bf2d9501592f33"/></dir><dir name="etc"><file name="adminhtml.xml" hash="26c4aa6d38306846a585166d6602b305"/><file name="config.xml" hash="3b8d47eaca4a5b3bf2973f77626158de"/><file name="system.xml" hash="5256bee2d5e034c4ba45770473ab9caf"/></dir><dir name="sql"><dir name="emaildirect_setup"><file name="mysql4-install-2.0.0.php" hash="c1c83d35755641c660c3bc7c5428a98e"/><file name="mysql4-upgrade-1.5.8-2.0.0.php" hash="37094b16cfb3f69b559f5b31aee268c4"/></dir></dir></dir></dir></target><target name="mageskin"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="emaildirect"><file name="emaildirect-tab.png" hash="9ddb077b74a7078ac509d79b024631a1"/><file name="emaildirect.css" hash="cba2c50e351f973a2463e92a91ec5569"/><file name="logo.png" hash="2e7e39ced387c798ef27b77dd69f073e"/></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="emaildirect"><dir name="images"><file name="window_close.png" hash="3af14f053f360bf31f8ba2df73ec7f1e"/></dir><file name="emaildirect.css" hash="5b2c8907468d0d5d013e30c6c5c8c9ed"/><file name="integration.js" hash="72ffc0716bc87ac2c92ba47784b5d33b"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="emaildirect.xml" hash="9eb6f438b54472e217a9f8e99a8e117c"/></dir><dir name="template"><dir name="emaildirect"><dir name="abandoned"><file name="grid.phtml" hash="d41d8cd98f00b204e9800998ecf8427e"/><file name="status.phtml" hash="9e7723dc1fe5f8693345db9cc7cda808"/></dir><dir name="system"><dir name="config"><dir name="fieldset"><file name="hint.phtml" hash="f64073616c5807d5ea32a13cc008ef4d"/></dir><dir name="form"><dir name="field"><dir name="export"><file name="date_range.phtml" hash="d2a91e7ba256fed67745ef1c284889cb"/><file name="orders.phtml" hash="7cc302d6bd638c111ca769ce2d23a1e1"/><file name="products.phtml" hash="b3e91d0fb47f26a3cc989f73f25a1e34"/></dir><dir name="signup"><file name="test.phtml" hash="636501cd90c6ab4231bea54efb16b2ff"/></dir><file name="array.phtml" hash="5415eeff311735624354468c886d39b5"/><file name="info.phtml" hash="19921a9ba4d9abd065ba7ab62e9946ce"/><file name="note.phtml" hash="6625a3771ba10daba5ded5570574716f"/><file name="trouble.phtml" hash="a6cbebe7956299a64c2f5ceab0c28651"/></dir></dir><file name="setup_check.phtml" hash="1814302f58a15fb1629446e074a7e1e0"/></dir><dir name="convert"><dir name="profile"><file name="export.phtml" hash="c829eeccb120ffe4c0b9f0ddf9c7ff9a"/></dir></dir></dir><dir name="troubleshooting"><dir name="view"><dir name="tab"><file name="download.phtml" hash="41dc4cc22f7a1c6fc9048bf936fb7953"/><file name="info.phtml" hash="bd19bb1072ce1d60a4fb7bda660a0ce7"/><file name="log.phtml" hash="c9e2c9493a2dad579bba4ed53795cf5e"/><file name="submit.phtml" hash="c2269f4a6a52d66bff5eac660d0831bd"/></dir><file name="form.phtml" hash="d2338bfe3598e9315ca8f5ac8d9b5516"/></dir><file name="view.phtml" hash="ee6af3fe79d916af764f41e7e8c5cc37"/></dir></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="emaildirect.xml" hash="a2541c4b82ef33c791794344893c0f2d"/></dir><dir name="template"><dir name="emaildirect"><dir name="capture"><file name="email.phtml" hash="fa273ff1a48a12eb386f58f3e3e78f66"/></dir><dir name="checkout"><file name="subscribe.phtml" hash="d57eb93aab4e0f1d58f1ec8b9ed24c50"/></dir><dir name="customer"><dir name="account"><dir name="dashboard"><file name="info.phtml" hash="fb89b2a726be35932de32ec9417ba81a"/></dir><file name="lists.phtml" hash="4c697dcfa63ece1db7885cadb02982d1"/></dir></dir><dir name="signup"><file name="form.phtml" hash="4c7633e518f3374f722ccf22b51158da"/></dir></dir></dir></dir></dir></dir></target><target name="magelocale"><dir name="en_US"><dir name="template"><dir name="email"><file name="newsletter_subscr_success_emaildirect.html" hash="f6afb69d207bbc3f8920e7a72ac9dd07"/><file name="newsletter_unsub_success_emaildirect.html" hash="bd9f97e8f5485180d4420097b5200ef4"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="EmailDirect_Integration.xml" hash="90a441f2d0dff6c247f810274e8a76ab"/></dir></target></contents>
|
16 |
<compatible/>
|
17 |
<dependencies/>
|
18 |
</package>
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>EmailDirect_Integration</name>
|
4 |
+
<version>2.0.9</version>
|
5 |
<stability>stable</stability>
|
6 |
<license/>
|
7 |
<channel>community</channel>
|
8 |
<extends/>
|
9 |
<summary>EmailDirect integration for magento</summary>
|
10 |
<description>EmailDirect integration for magento</description>
|
11 |
+
<notes>Order and Abandoned Cart diagnostics
|
12 |
+

|
13 |
+
Improved logging with advanced settings
|
14 |
+

|
15 |
+
Help Page (with list of fields that can be mapped) 
|
16 |
+

|
17 |
+
API Key validation improvements (a valid key will not be marked invalid during API/Network outages). 
|
18 |
+

|
19 |
+
Code improvements to make customization easier.
|
20 |
+

|
21 |
+
Signup form improvements (works better with Full Page Caching)</notes>
|
22 |
<authors><author><name>Kevin Linden</name><user>auto-converted</user><email>Kevin@EmailDirect.com</email></author></authors>
|
23 |
+
<date>2014-11-21</date>
|
24 |
+
<time>17:48:30</time>
|
25 |
+
<contents><target name="magecommunity"><dir name="EmailDirect"><dir name="Integration"><dir name="Block"><dir name="Adminhtml"><dir name="Abandoned"><dir name="Details"><dir name="Tab"><dir name="Diagnostics"><file name="Status.php" hash="8706487c8f465a5ce762cd923258bb35"/></dir><file name="Cart.php" hash="09e9331f6c72157f581ad7135b7f147c"/><file name="Diagnostics.php" hash="eba18ce04ccb125ce4aa6ed5e473734a"/></dir><file name="Abstract.php" hash="d41d8cd98f00b204e9800998ecf8427e"/><file name="Form.php" hash="dffc6e49eb95db2f83050706eee1fd55"/></dir><file name="Details.php" hash="9f98f4dd9ea741f9f7dd2eb018af0d7d"/><file name="Grid.php" hash="e0a15673636acb7e113fdf6e3bcd8879"/><file name="Status.php" hash="9a740fd8c63148532bbcf07d19f462df"/><file name="Tabs.php" hash="19e184e72777dfc5b0c35b7027a3e1cf"/></dir><dir name="Diagnostics"><dir name="Status"><file name="Abstract.php" hash="4a54d82d748f880fc5bb8263935ddc98"/></dir></dir><dir name="Order"><dir name="View"><dir name="Tab"><dir name="Diagnostics"><file name="Status.php" hash="b4dd8410aa9ce649e603762d5d14f314"/></dir><file name="Diagnostics.php" hash="91bb6af0c9a0e6f41d2575651e8a59ef"/></dir></dir></dir><dir name="System"><dir name="Config"><dir name="Fieldset"><file name="Hint.php" hash="d01c241e1c4a42cd08f087ad784ed78e"/></dir><dir name="Form"><dir name="Field"><dir name="Export"><file name="Orders.php" hash="5b101fadb6a64044b276eb07b21cf0a5"/><file name="Products.php" hash="32e13d4b7250890bf84aba87f25de03c"/><file name="Range.php" hash="4adac96fa53fa8e1449bae943a8cca80"/></dir><dir name="Signup"><file name="Test.php" hash="3b773dda25c62bc8cb28031931d67f9f"/></dir><file name="Addressmapfields.php" hash="97b75c8340d561e863a3985ad73ce228"/><file name="Api.php" hash="77dabda85973dc72227937397392c411"/><file name="Common.php" hash="6a86cce53f6df6857ea79241fa281939"/><file name="Diagnostics.php" hash="7efe5c8b90db90e9c512842388d3263d"/><file name="Info.php" hash="246de52ea5d2349ecd7f103cbba8cb8f"/><file name="Logging.php" hash="53b0b7d28d2680e479bfa89b6884802d"/><file name="Mapfields.php" hash="16894c5d76df1293e63128e349700e05"/><file name="Note.php" hash="ef99a474bbc3a828c7a618132a80fe66"/><file name="Shippingmapfields.php" hash="589a74260f394a5eae1b57ca89a74a8b"/><file name="Troubleshooting.php" hash="ff22589730034e7742978e884766d139"/></dir></dir></dir><dir name="Convert"><dir name="Profile"><dir name="Export"><file name="Orders.php" hash="947af2b0d8e3f7bc47c47b32cd434f18"/><file name="Products.php" hash="3f93e4789dbeb6710cd2742587d61726"/></dir><file name="Export.php" hash="ba879607ac0693e9db6251bbbc1676a1"/></dir></dir></dir><dir name="Troubleshooting"><dir name="View"><dir name="Tab"><file name="Download.php" hash="619916677df7c833e559aae74dae2aa0"/><file name="Help.php" hash="ad4007af59687653f4d6692f2b42b31d"/><file name="Info.php" hash="be5c15da32ef0e042c53d8ac007f8bd6"/><file name="Log.php" hash="a61e66923a287beee5910511b7282a0a"/><file name="Settings.php" hash="f15e57cdc6539c4da84042c98f0ab25c"/><file name="Submit.php" hash="81ae0e0636b66a329cf8f39939788d1d"/></dir><file name="Form.php" hash="e527a3a2335b109c48a69f06c1b0d01f"/></dir><file name="Status.php" hash="d140afcad424ff531bebb412539d6f1c"/><file name="Tabs.php" hash="5d4168cec60212beb87997e6391282e9"/><file name="View.php" hash="1ecabf7011ada6012f761c93343bb097"/></dir><file name="Abandoned.php" hash="1ee964e54b38a6c24c09f7b3aa6ce411"/></dir><dir name="Checkout"><file name="Subscribe.php" hash="12f6e5c467fb632e11c9ced35c82ebe6"/></dir><dir name="Customer"><dir name="Account"><dir name="Dashboard"><file name="Info.php" hash="20e74d9c2b2c02611c8f69b254d81ef5"/></dir><file name="Lists.php" hash="3c3bdb9482ecf4a71740a80395bd5465"/></dir></dir><dir name="Widget"><dir name="Grid"><dir name="Column"><dir name="Renderer"><dir name="Abandoned"><file name="Minutes.php" hash="e311f6de480fd4b63aee7f46ea412372"/></dir><file name="Action.php" hash="bf2243f50c9c6dafca26a5bcb889f372"/></dir></dir></dir></dir><file name="Capture.php" hash="e44034ad875957a566d3ac89abb408ed"/><file name="Signup.php" hash="441f7fc6e1162ed1a0de6e527c37dea1"/></dir><dir name="Controller"><dir name="Front"><file name="Abstract.php" hash="48d93179d5f8a6b416fd82dd8763daf9"/></dir></dir><dir name="Helper"><file name="Abandoned.php" hash="7910bd8db8a030ae22adae9469d91fe7"/><file name="Data.php" hash="01ae2fc7bb1eea8911dc2dda3673ef6a"/><file name="Diagnostic.php" hash="68867fd906405a6be98e14c1568437b6"/><file name="Fields.php" hash="e56519892ee2583c2978c262ffb9880e"/><file name="Order.php" hash="14039a9f9529bdc40e89c3013aa0d17b"/><file name="Troubleshooting.php" hash="82e8bb3fb83f0dbd5cc2db118cef1fe6"/></dir><dir name="Model"><dir name="Abandoned"><file name="Observer.php" hash="b97f35f4bb49ce7127d0879a0bdabad1"/></dir><dir name="Configuration"><file name="Observer.php" hash="9a188656d5f7d73c91bf4221cc6e4aac"/></dir><dir name="Customer"><file name="Observer.php" hash="a26dd056b55d0578c96a082d00508659"/></dir><dir name="Mysql4"><dir name="Abandoned"><file name="Collection.php" hash="1a9129267942a98ac3830ceaf714c2ab"/></dir><dir name="Order"><file name="Collection.php" hash="43d343562cf7e54f1b36315aa5d1d4a7"/></dir><dir name="Session"><file name="Collection.php" hash="7d6a8283fdbc1207d709e2bbbc78906d"/></dir><file name="Abandoned.php" hash="485b3771906783d383de75ae9761e55c"/><file name="Order.php" hash="8d538a5737095a1ba0ad448c027b3afb"/><file name="Session.php" hash="516eeeb28038416dc885ed7af6a8a8b0"/></dir><dir name="Newsletter"><file name="Observer.php" hash="5d73fdd62c69b16f7312a13b721d3a37"/></dir><dir name="Observer"><file name="Abstract.php" hash="1db39dc86bed51af1d2a3b4df50099bd"/></dir><dir name="Order"><file name="Observer.php" hash="81416e0d6f8ce63513aae67a53005eb9"/></dir><dir name="Resource"><file name="Setup.php" hash="5435dccf0f14ec402018bb45af56ecb5"/></dir><dir name="System"><dir name="Config"><dir name="Source"><dir name="Export"><file name="Batch.php" hash="96c51fc5c0b947750be4e612e32c83ab"/></dir><dir name="Send"><file name="Field.php" hash="8ecffa8ccce40f3b2db6513b24eb9200"/></dir><dir name="Signup"><file name="Opacity.php" hash="8eabed4c72e7347f0376c3d4cc1023a7"/><file name="Recurrence.php" hash="e11200bbc204b00486c373d8a4e6675e"/></dir><file name="Abandoned.php" hash="9881811b94f38be90bd20a99951a1903"/><file name="Abandonedlist.php" hash="b81d7f2cb03b8482debea5cd6a2bd1c5"/><file name="Additionallist.php" hash="9f109ab04c7ae7832887572b26868e3a"/><file name="Checkoutsubscribe.php" hash="fd90252a1f19649a420dae136ad2a2ba"/><file name="List.php" hash="84c1c8e27f579d5d33992fcb15202748"/><file name="Publication.php" hash="a5bc0192605fc558fe59b37cc0462825"/><file name="Sequence.php" hash="a599f218882d2cfc68dfcf4d58a98a41"/><file name="Source.php" hash="44815cbf4ac6443032df1e7d9c4cadef"/><file name="States.php" hash="a746affc786d8165a98801e68cbf80ab"/><file name="Statuses.php" hash="9844a7a9c3b5c68df45c8f6c518acf16"/><file name="Time.php" hash="8acbb5cb33e66de1e408cf55d17a9398"/></dir></dir></dir><dir name="Wrapper"><file name="Abandoned.php" hash="ef81d36a7276737f2d0aa1a5d783a83b"/><file name="Abstract.php" hash="9e97ce6a12e0d074921bb3a1391f3648"/><file name="Database.php" hash="3cceb467358d13584baff58c043762ec"/><file name="Execute.php" hash="e38737d197b2ccd6700ec87ec1836456"/><file name="Ftp.php" hash="d5335cfb68f99761d6902dd390a3d7a8"/><file name="Lists.php" hash="425d64b9256bbdbafa899c4138e78368"/><file name="Orders.php" hash="66be3441f9204048279fb4921a04e375"/><file name="Publications.php" hash="1bebd172a8bba669d075f09589785652"/><file name="Sources.php" hash="c6caf0274f7d0c50114324bc47a490c4"/><file name="Subscribers.php" hash="f9abcadf5b793640a4301495462d6ea7"/><file name="Wishlist.php" hash="2ceb111bbeaa06c4f13f61281aaa5b5e"/></dir><file name="Abandoned.php" hash="93bd43b59b143dec15858a6fba6ae568"/><file name="Observer.php" hash="24d421b11e04e228cbdf3eee0b852572"/><file name="Order.php" hash="b21426543cd46f799cd0743525120fb8"/><file name="Session.php" hash="c56ecf779dbfb2dae0030935af31911a"/></dir><dir name="controllers"><dir name="Admin"><file name="AbandonedController.php" hash="7366ad52662d5494e1b0e65988ee1dc7"/><file name="DiagnosticController.php" hash="aa0f4e9bf3c22124c61c3f46729372a9"/><file name="ExportController.php" hash="3ff11560de77d99bccb2cc257d14b8ab"/><file name="TroubleshootingController.php" hash="be806ede9ec0e1986dcfe720e0dd7b74"/></dir><dir name="Customer"><file name="AccountController.php" hash="5bd831a8b452d9853db29967fc2b28b4"/></dir><file name="AbandonedController.php" hash="dce0db1b2148889d067fce613c0d6914"/><file name="CaptureController.php" hash="89e043bb3864617a062e915d2209dcf4"/><file name="ExportController.php" hash="7ca147debc5c1436b3bf2d9501592f33"/><file name="SignupController.php" hash="fe975d44cc11f1270d34d9d82c7d4be9"/></dir><dir name="etc"><file name="adminhtml.xml" hash="5dd2b99c6efd1d0958579d2873fe8b69"/><file name="cache.xml" hash="ba54476a74c730c6fcefdd12aced8560"/><file name="config.xml" hash="efbfe35b1cd79fca38981433535f7a42"/><file name="system.xml" hash="0c1b20f5e671e3004d42d0a8d65c5901"/></dir><dir name="sql"><dir name="emaildirect_setup"><file name="mysql4-install-2.0.0.php" hash="bdc5e09fe949b36534c50c85fd198e66"/><file name="mysql4-upgrade-1.5.8-2.0.0.php" hash="8f33c7f6dca96cfa8210ec1fe016d95b"/></dir></dir></dir></dir></target><target name="mageskin"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="emaildirect"><file name="emaildirect-tab.png" hash="9ddb077b74a7078ac509d79b024631a1"/><file name="emaildirect.css" hash="61d3d7b29b97f75023f2232cae6eb0c1"/><file name="logo.png" hash="2e7e39ced387c798ef27b77dd69f073e"/></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="emaildirect"><dir name="images"><file name="window_close.png" hash="3af14f053f360bf31f8ba2df73ec7f1e"/></dir><file name="emaildirect.css" hash="c9caf9ea168efa3b0d6f4b881bcf093c"/><file name="integration.js" hash="e02936e3295b737424d7fc3aed429a1f"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="emaildirect.xml" hash="7767cd483e20d1930c0f1d79fee03b2a"/></dir><dir name="template"><dir name="emaildirect"><dir name="abandoned"><dir name="details"><dir name="tab"><dir name="diagnostics"><file name="status.phtml" hash="24829356b9dba966e53fb1cfe0f192b6"/></dir><file name="cart.phtml" hash="be7ca2b147fc836c2ca547b290ffe841"/></dir><file name="form.phtml" hash="60633d212382770e99d11d24ae919e47"/></dir><file name="details.phtml" hash="9d467b97a2d773aec950bea7061c6730"/><file name="status.phtml" hash="9e7723dc1fe5f8693345db9cc7cda808"/></dir><dir name="order"><dir name="view"><dir name="tab"><dir name="diagnostics"><file name="status.phtml" hash="a3bdecb1ec08903dd1b61dce6992e190"/></dir></dir></dir></dir><dir name="system"><dir name="config"><dir name="fieldset"><file name="hint.phtml" hash="176f3ddb8ea667a64a06967351526f3c"/></dir><dir name="form"><dir name="field"><dir name="export"><file name="date_range.phtml" hash="6a37b1e58456e1dcec734c48deb8c0c1"/><file name="orders.phtml" hash="1dfa19a712b18d2c95c2f4b938f6acef"/><file name="products.phtml" hash="098b7b21b6424c2a4eea26194883a623"/></dir><dir name="signup"><file name="test.phtml" hash="636501cd90c6ab4231bea54efb16b2ff"/></dir><file name="api.phtml" hash="468f33b2a23dbe2828489c1620000c74"/><file name="array.phtml" hash="5415eeff311735624354468c886d39b5"/><file name="diagnostics.phtml" hash="3327dba9e03362077f7562e3045180b7"/><file name="info.phtml" hash="44ab79fdfc5fb5b0cd7e15e79bfd9502"/><file name="logging.phtml" hash="3c7bd2a6f48a84efca1d0f1e75097a8a"/><file name="note.phtml" hash="6625a3771ba10daba5ded5570574716f"/><file name="trouble.phtml" hash="fe706c8465a404ae8fd9cf645db0491c"/></dir></dir><file name="setup_check.phtml" hash="1814302f58a15fb1629446e074a7e1e0"/></dir><dir name="convert"><dir name="profile"><file name="export.phtml" hash="c829eeccb120ffe4c0b9f0ddf9c7ff9a"/></dir></dir></dir><dir name="troubleshooting"><dir name="view"><dir name="tab"><file name="download.phtml" hash="d5701a0af7a8f308467fa5552d0de6b2"/><file name="help.phtml" hash="e1cb1209995b357bdbceb45a4197e17f"/><file name="info.phtml" hash="bd19bb1072ce1d60a4fb7bda660a0ce7"/><file name="log.phtml" hash="724a65165770bc92ed08ea32d20c1fe7"/><file name="settings.phtml" hash="b8661b58c492283b6670c377803fd03f"/><file name="submit.phtml" hash="2929f5910bcd809777d6f4634717d93e"/></dir><file name="form.phtml" hash="d2338bfe3598e9315ca8f5ac8d9b5516"/></dir><file name="status.phtml" hash="fac61e17efe7bd4cf67a47eb67786496"/><file name="view.phtml" hash="6ddfc8c6efe25d30e63f792b19a95c84"/></dir><file name="diagnostics.phtml" hash="f1f43a89824cad9f39e599df21ac44b4"/></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="emaildirect.xml" hash="0e97169b46f1b866e6ff2e49f9b6575a"/></dir><dir name="template"><dir name="emaildirect"><dir name="capture"><file name="email.phtml" hash="fa273ff1a48a12eb386f58f3e3e78f66"/></dir><dir name="checkout"><file name="subscribe.phtml" hash="d57eb93aab4e0f1d58f1ec8b9ed24c50"/></dir><dir name="customer"><dir name="account"><dir name="dashboard"><file name="info.phtml" hash="fb89b2a726be35932de32ec9417ba81a"/></dir><file name="lists.phtml" hash="4c697dcfa63ece1db7885cadb02982d1"/></dir></dir><dir name="signup"><file name="form.phtml" hash="ce2ab9513c457363650d27000c772b99"/></dir></dir></dir></dir></dir></dir></target><target name="magelocale"><dir name="en_US"><dir name="template"><dir name="email"><file name="newsletter_subscr_success_emaildirect.html" hash="f6afb69d207bbc3f8920e7a72ac9dd07"/><file name="newsletter_unsub_success_emaildirect.html" hash="bd9f97e8f5485180d4420097b5200ef4"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="EmailDirect_Integration.xml" hash="90a441f2d0dff6c247f810274e8a76ab"/></dir></target></contents>
|
26 |
<compatible/>
|
27 |
<dependencies/>
|
28 |
</package>
|
skin/adminhtml/default/default/emaildirect/emaildirect.css
CHANGED
@@ -9,16 +9,48 @@ ul.tabs a.emaildirect-section.active, ul.tabs a.emaildirect-section.active:hover
|
|
9 |
|
10 |
h3.emaildirect-header { background:url(emaildirect-tab.png) no-repeat 0 0; height: 24px; overflow:hidden; padding:0; width:120px; text-indent:-9999px; }
|
11 |
|
12 |
-
div.emaildirect-notice{
|
13 |
background:#EAF0EE;
|
14 |
border:1px solid #CCCCCC;
|
15 |
margin-bottom:10px;
|
16 |
padding:11px 10px 5px;
|
17 |
}
|
18 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
div.emaildirect-notice h4
|
20 |
{
|
21 |
-
color: #EA7601;
|
22 |
}
|
23 |
|
24 |
div.emaildirect-notice h4 div.abandoned
|
@@ -64,4 +96,40 @@ table.missing_columns tr th { font-weight: bold; color: red; }
|
|
64 |
|
65 |
.abandoned_status tr td { padding-right: 10px; }
|
66 |
|
67 |
-
.head-adminhtml-abandoned { background-image: url("../images/fam_cart.gif"); }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
|
10 |
h3.emaildirect-header { background:url(emaildirect-tab.png) no-repeat 0 0; height: 24px; overflow:hidden; padding:0; width:120px; text-indent:-9999px; }
|
11 |
|
12 |
+
div.emaildirect-notice, div.emaildirect-status{
|
13 |
background:#EAF0EE;
|
14 |
border:1px solid #CCCCCC;
|
15 |
margin-bottom:10px;
|
16 |
padding:11px 10px 5px;
|
17 |
}
|
18 |
|
19 |
+
div.emaildirect-status
|
20 |
+
{
|
21 |
+
padding:10px;
|
22 |
+
font-weight: bold;
|
23 |
+
}
|
24 |
+
|
25 |
+
div.emaildirect-status table
|
26 |
+
{
|
27 |
+
width: 100%;
|
28 |
+
}
|
29 |
+
|
30 |
+
div.emaildirect-status table td
|
31 |
+
{
|
32 |
+
width: 25%;
|
33 |
+
}
|
34 |
+
|
35 |
+
.warning
|
36 |
+
{
|
37 |
+
color: #ea7601;
|
38 |
+
font-weight: bold;
|
39 |
+
}
|
40 |
+
|
41 |
+
#ed_status_row span
|
42 |
+
{
|
43 |
+
color: green;
|
44 |
+
}
|
45 |
+
|
46 |
+
#ed_status_row.disabled span
|
47 |
+
{
|
48 |
+
color: red;
|
49 |
+
}
|
50 |
+
|
51 |
div.emaildirect-notice h4
|
52 |
{
|
53 |
+
color: #EA7601;
|
54 |
}
|
55 |
|
56 |
div.emaildirect-notice h4 div.abandoned
|
96 |
|
97 |
.abandoned_status tr td { padding-right: 10px; }
|
98 |
|
99 |
+
.head-adminhtml-abandoned { background-image: url("../images/fam_cart.gif"); }
|
100 |
+
|
101 |
+
.cron_warning { margin: 0 10px; cursor: pointer;}
|
102 |
+
|
103 |
+
table.troubleshooting_details tr td, table.troubleshooting_details tr th { padding: 4px; }
|
104 |
+
table.troubleshooting_details { margin-top: 15px; margin-bottom: 10px; }
|
105 |
+
|
106 |
+
#troubleshooting_stores { margin-left: 20px; }
|
107 |
+
|
108 |
+
#ip_address { height: 3em; }
|
109 |
+
|
110 |
+
#apikey_validator { float: right; }
|
111 |
+
|
112 |
+
#emaildirect_status_indicator { font-weight: bold; }
|
113 |
+
.apikey_valid { color: green; }
|
114 |
+
.apikey_invalid { color: red; }
|
115 |
+
.apikey_validating { color: black; }
|
116 |
+
|
117 |
+
.emaildirect_api_status { width: 280px; }
|
118 |
+
|
119 |
+
.emaildirect_help { max-width: 700px; font-size: 1.2em;}
|
120 |
+
|
121 |
+
table.map_field_list, table.map_field_custom { margin-left: 20px; margin-bottom: 10px; width: 90%; }
|
122 |
+
table.map_field_list tr td, table.map_field_custom tr td {width: 33%; padding: 5px;}
|
123 |
+
|
124 |
+
table.map_field_custom tr td:first-child { width: 20%; }
|
125 |
+
table.map_field_custom tr td:last-child { width: 80%; }
|
126 |
+
|
127 |
+
.current_ip { margin-top: 10px; }
|
128 |
+
.current_ip button { float: left; }
|
129 |
+
.your_ip { float: left; margin-top: 2px; font-weight: bold; }
|
130 |
+
.current_ip_address { background-color: #FCFBBB; font-weight: bold; border: solid 1px; padding: 1px 5px 0 5px; margin: 0 10px; float: left;}
|
131 |
+
|
132 |
+
.emaildirect_help h3 { margin-top: 15px; }
|
133 |
+
.emaildirect_help h2 { border-bottom: solid 1px; margin-top: 15px; color: #F15628;}
|
134 |
+
|
135 |
+
.sequence_example { border: solid 1px; padding: 3px; margin-bottom: 4px; width: 100px; }
|
skin/frontend/base/default/emaildirect/emaildirect.css
CHANGED
@@ -11,6 +11,7 @@ z-index: 10000;
|
|
11 |
top: 0;
|
12 |
left: 0;
|
13 |
color: white;
|
|
|
14 |
}
|
15 |
|
16 |
#emaildirect_signup {
|
@@ -25,6 +26,8 @@ width: auto;
|
|
25 |
position: absolute;
|
26 |
top: 0; left: 0; bottom: 0; right: 0;
|
27 |
border-radius: 15px;
|
|
|
|
|
28 |
}
|
29 |
|
30 |
#emaildirect_signup iframe
|
11 |
top: 0;
|
12 |
left: 0;
|
13 |
color: white;
|
14 |
+
zoom: 1;
|
15 |
}
|
16 |
|
17 |
#emaildirect_signup {
|
26 |
position: absolute;
|
27 |
top: 0; left: 0; bottom: 0; right: 0;
|
28 |
border-radius: 15px;
|
29 |
+
z-index: 10001;
|
30 |
+
zoom: 1;
|
31 |
}
|
32 |
|
33 |
#emaildirect_signup iframe
|
skin/frontend/base/default/emaildirect/integration.js
CHANGED
@@ -16,5 +16,4 @@ document.observe("dom:loaded", function() {
|
|
16 |
editLink.first().writeAttribute('href', emaildirectEnabled.first().readAttribute('href'));
|
17 |
}
|
18 |
}
|
19 |
-
|
20 |
});
|
16 |
editLink.first().writeAttribute('href', emaildirectEnabled.first().readAttribute('href'));
|
17 |
}
|
18 |
}
|
|
|
19 |
});
|