Version Notes
New Automation improvements.
Transactional Emails, Custom Customer Attributes, Reports & More
This release includes some great new functionality as well as including a number of fixes.
##IMPORTANT## Dynamic content URL's have been changed so will need updating within your dotMailer account to ensure they continue working correctly. ##IMPORTANT##
Release Highlights:
+ Transactional Emails: Replace the standard emails Magento currently sends to your customers and guests with beautifully created campaigns from dotMailer. Emails include new account, new order, dispatch, cancel and refund emails. **A dotMailer child account is required to enable this functionality**
+ Custom Customer Attributes: Sync your custom created customer attributes to dotMailer
+ Dynamic Content Styling: Apply custom CSS to all dynamic content pages e.g. font size, colour and type.
+ Reporting: Now within the Newsletter section in Magento you can view the import status of contacts and orders, as well as the sending status of transactional and lost basket emails.
Release Info
Developer | Calin Diacon |
Extension | dotmailermagento |
Version | 6.0.0 |
Comparing to | |
See all releases |
Code changes from version 5.3.0 to 6.0.0
- app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Automation.php +8 -6
- app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Automation/Grid.php +176 -142
- app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Campaign.php +8 -6
- app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Campaign/Grid.php +160 -118
- app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Catalog.php +6 -4
- app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Catalog/Grid.php +71 -44
- app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Column/Renderer/Delete.php +14 -3
- app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Column/Renderer/Imported.php +16 -8
- app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Column/Renderer/Reset.php +14 -3
- app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Column/Renderer/Script.php +7 -2
- app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Column/Renderer/Status.php +13 -8
- app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Column/Renderer/Sync.php +13 -8
- app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Column/Renderer/Website.php +4 -1
- app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Config/Automation/Customdatafields.php +42 -21
- app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Config/Customdatafields.php +37 -20
- app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Config/Rules/Customdatafields.php +59 -29
- app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Config/Select.php +4 -2
- app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Contact.php +8 -6
- app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Contact/Edit.php +29 -14
- app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Contact/Edit/Form.php +18 -10
- app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Contact/Grid.php +216 -154
- app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Customer/Tab.php +2 -1
- app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Customer/Tab/Stats.php +22 -13
- app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Dashboard.php +49 -47
- app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Dashboard/Switcher.php +91 -80
- app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Dashboard/Tabs.php +59 -53
- app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Dashboard/Tabs/Analysis.php +71 -54
- app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Dashboard/Tabs/Analysis/Abandonedcarts.php +28 -9
- app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Dashboard/Tabs/Analysis/Customer.php +20 -7
- app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Dashboard/Tabs/Analysis/Rfm.php +46 -28
- app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Dashboard/Tabs/Analysis/Sales.php +26 -9
- app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Dashboard/Tabs/Analysis/Subscriber.php +24 -8
- app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Dashboard/Tabs/General.php +94 -91
- app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Dashboard/Tabs/General/Data.php +8 -4
- app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Dashboard/Tabs/Logs.php +2 -0
- app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Dashboard/Tabs/Status.php +2063 -1419
- app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Importer.php +3 -1
- app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Importer/Grid.php +134 -93
- app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Order.php +5 -3
- app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Order/Grid.php +106 -76
- app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Quote.php +6 -4
- app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Quote/Grid.php +89 -58
- app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Review.php +6 -4
- app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Review/Grid.php +86 -62
- app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Rules.php +8 -4
- app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Rules/Edit.php +11 -8
- app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Rules/Edit/Form.php +8 -2
- app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Rules/Edit/Tab/Conditions.php +38 -22
- app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Rules/Edit/Tab/Main.php +63 -46
- app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Rules/Edit/Tabs.php +3 -1
- app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Rules/Grid.php +83 -62
- app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Sales/Order/Creditmemo/View.php +92 -52
- app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Advanced/Deletecontactids.php +8 -3
- app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Advanced/Notification.php +18 -7
- app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Advanced/Reimportcatalog.php +6 -2
- app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Advanced/Reimportorders.php +6 -2
- app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Advanced/Reimportquotes.php +6 -2
- app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Advanced/Reimportreviews.php +6 -2
- app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Advanced/Reimportsubscribers.php +6 -2
- app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Advanced/Reimportwishlists.php +6 -2
- app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Advanced/Reset.php +5 -2
- app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Advanced/Resetcustomersimport.php +6 -2
- app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Advanced/Runcatalogsync.php +5 -2
- app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Advanced/Runcontactsync.php +5 -2
- app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Advanced/Runimportersync.php +5 -2
- app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Advanced/Runordersync.php +5 -2
- app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Advanced/Runquotesync.php +5 -2
- app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Advanced/Runreviewsync.php +5 -2
- app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Advanced/Runsubscribersync.php +8 -3
- app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Advanced/Runwishlistsync.php +5 -2
- app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Advanced/Setupdatafields.php +21 -16
- app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Ajaxvalidate.php +5 -2
- app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Automation/Connect.php +23 -11
- app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Config/Addressbook.php +15 -9
- app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Config/Colorpicker.php +21 -8
- app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Config/Datafield.php +15 -10
- app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Config/Enterprisevalidator.php +13 -8
- app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Config/Resetcontacts.php +15 -8
- app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Config/Resetguests.php +13 -8
- app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Config/Resetsubscribers.php +15 -8
- app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Config/Trial.php +50 -0
- app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Config/Validator.php +17 -13
- app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Config/Waitingfield.php +0 -65
- app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Config/Wrapper.php +0 -59
- app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Dynamic/Addressbookbutton.php +7 -3
- app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Dynamic/Basket/Crosssell.php +19 -11
- app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Dynamic/Basket/Related.php +17 -9
- app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Dynamic/Basket/Upsell.php +17 -8
- app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Dynamic/Bestsellers.php +16 -9
- app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Dynamic/Couponinfo.php +13 -7
- app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Dynamic/Creditmemonew.php +17 -9
- app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Dynamic/Crosssell.php +20 -12
- app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Dynamic/Datafieldbutton.php +8 -3
- app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Dynamic/Fallbackchooser.php +8 -5
- app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Dynamic/Fallbackcontainer.php +5 -3
- app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Dynamic/Feefo/Reviews.php +11 -4
- app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Dynamic/Feefo/Score.php +7 -3
- app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Dynamic/Gridlist.php +15 -11
- app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Dynamic/Lostbasket.php +20 -12
- app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Dynamic/Manualchooser.php +8 -5
- app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Dynamic/Manualcontainer.php +5 -3
- app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Dynamic/Mostviewed.php +14 -8
- app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Dynamic/Nosto.php +0 -22
- app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Dynamic/Productpush.php +15 -9
- app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Dynamic/Recentlyviewed.php +19 -10
- app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Dynamic/Related.php +22 -14
- app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Dynamic/Review.php +12 -5
- app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Dynamic/Upsell.php +20 -11
- app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Dynamic/Wishlist.php +14 -5
- app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Dynamic/Wishlist/Crosssell.php +14 -5
- app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Dynamic/Wishlist/Related.php +14 -5
- app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Dynamic/Wishlist/Upsell.php +15 -5
- app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Emailapivalidate.php +12 -6
- app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Installation.php +68 -58
- app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Sms/Smsmessagefour.php +0 -24
- app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Sms/Smsmessageone.php +0 -46
- app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Sms/Smsmessagethree.php +0 -26
- app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Sms/Smsmessagetwo.php +0 -25
- app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Url/Creditmemoupdate.php +29 -13
- app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Url/Creditmemoupdateguest.php +29 -13
- app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Url/Customerconfirmation.php +29 -16
- app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Url/Customerconfirmed.php +29 -16
- app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Url/Customernew.php +29 -16
- app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Url/Invoiceupdate.php +28 -14
- app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Url/Invoiceupdateguest.php +28 -14
- app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Url/Newcreditmemo.php +30 -16
- app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Url/Newcreditmemoguest.php +29 -15
- app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Url/Newinvoice.php +29 -15
- app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Url/Newinvoiceguest.php +29 -15
- app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Url/Neworder.php +30 -15
- app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Url/Neworderguest.php +30 -15
- app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Url/Newshipment.php +30 -15
- app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Url/Newshipmentguest.php +30 -15
- app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Url/Orderupdate.php +30 -15
- app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Url/Orderupdateguest.php +30 -15
- app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Url/Shipmentupdate.php +30 -15
- app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Url/Shipmentupdateguest.php +30 -15
- app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Widget/Chooser/Product.php +82 -54
- app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Wishlist.php +6 -4
- app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Wishlist/Grid.php +104 -73
- app/code/community/Dotdigitalgroup/Email/Block/Basket.php +104 -90
- app/code/community/Dotdigitalgroup/Email/Block/Coupon.php +59 -32
- app/code/community/Dotdigitalgroup/Email/Block/Customer/Account/Books.php +87 -58
- app/code/community/Dotdigitalgroup/Email/Block/Edc.php +178 -92
- app/code/community/Dotdigitalgroup/Email/Block/Feefo.php +43 -31
- app/code/community/Dotdigitalgroup/Email/Block/Order.php +57 -47
- app/code/community/Dotdigitalgroup/Email/Block/Order/Creditmemo.php +28 -18
- app/code/community/Dotdigitalgroup/Email/Block/Order/Invoice.php +23 -13
- app/code/community/Dotdigitalgroup/Email/Block/Order/Shipping.php +22 -13
- app/code/community/Dotdigitalgroup/Email/Block/Products.php +24 -19
- app/code/community/Dotdigitalgroup/Email/Block/Recommended/Products.php +25 -58
- app/code/community/Dotdigitalgroup/Email/Block/Recommended/Wishlistproducts.php +16 -10
- app/code/community/Dotdigitalgroup/Email/Block/Wishlist.php +16 -9
- app/code/community/Dotdigitalgroup/Email/Helper/Config.php +28 -26
- app/code/community/Dotdigitalgroup/Email/Helper/Dashboard.php +200 -165
- app/code/community/Dotdigitalgroup/Email/Helper/Data.php +1172 -221
- app/code/community/Dotdigitalgroup/Email/Helper/File.php +112 -75
- app/code/community/Dotdigitalgroup/Email/Helper/Recommended.php +76 -45
- app/code/community/Dotdigitalgroup/Email/Helper/Transactional.php +21 -12
- app/code/community/Dotdigitalgroup/Email/Model/Abstract/Rest.php +292 -266
- app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Dashboard/Content.php +127 -110
- app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Dashboard/Tabs/Analysis/Abandoned.php +30 -19
- app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Dashboard/Tabs/Analysis/Customer.php +24 -14
- app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Dashboard/Tabs/Analysis/Orders.php +41 -24
- app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Dashboard/Tabs/Analysis/Rfm.php +149 -122
- app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Dashboard/Tabs/Analysis/Subscriber.php +103 -84
- app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Observer.php +135 -164
- app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Source/Addressbooks.php +44 -38
- app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Source/Addressbookspref.php +71 -60
- app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Source/Advanced/Abandonedlimit.php +37 -32
- app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Source/Advanced/Attributes.php +6 -2
- app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Source/Advanced/Cronexpressionsone.php +7 -3
- app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Source/Advanced/Cronexpressionstwo.php +7 -3
- app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Source/Advanced/Frequency.php +15 -10
- app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Source/Advanced/Quoteattributes.php +5 -2
- app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Source/Advanced/Transdata.php +1 -0
- app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Source/Attributes.php +6 -2
- app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Source/Automation/Programme.php +39 -37
- app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Source/Campaigns.php +35 -30
- app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Source/Contact/Imported.php +8 -7
- app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Source/Contact/Modified.php +8 -7
- app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Source/Customer/Attributes/Select.php +16 -12
- app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Source/Datafields.php +46 -39
- app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Source/Datamapping/Datafieldaccess.php +14 -11
- app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Source/Datamapping/Datafieldtype.php +10 -4
- app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Source/Dynamic/Displaytype.php +9 -7
- app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Source/Dynamic/Gridview.php +1 -0
- app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Source/Fontpicker.php +15 -10
- app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Source/Fontsize.php +1 -0
- app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Source/Importer/Bulklimit.php +18 -0
- app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Source/Importer/Mode.php +7 -7
- app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Source/Importer/Status.php +13 -4
- app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Source/Lostbaskets/Interval.php +15 -11
- app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Source/Lostbaskets/Intervalminute.php +16 -7
- app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Source/Orderstatus.php +5 -2
- app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Source/Publicdatafields.php +59 -49
- app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Source/Reviews/Delay.php +4 -1
- app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Source/Rules/Condition.php +29 -10
- app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Source/Rules/Type.php +47 -21
- app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Source/Rules/Value.php +39 -13
- app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Source/Styling.php +2 -1
- app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Source/Sweettooth/Yesno.php +6 -4
- app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Source/Sync/Catalog/Attributes.php +8 -3
- app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Source/Sync/Catalog/Type.php +2 -0
- app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Source/Sync/Catalog/Values.php +1 -0
- app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Source/Sync/Catalog/Visibility.php +4 -1
- app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Source/Sync/Yesno.php +0 -62
- app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Source/Transactional/Mode.php +8 -7
- app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Source/Transactional/Port.php +9 -8
- app/code/community/Dotdigitalgroup/Email/Model/Api2/Subscriber/Rest/Admin/V1.php +126 -107
- app/code/community/Dotdigitalgroup/Email/Model/Apiconnector/Client.php +563 -325
- app/code/community/Dotdigitalgroup/Email/Model/Apiconnector/Contact.php +302 -160
- app/code/community/Dotdigitalgroup/Email/Model/Apiconnector/Customer.php +489 -383
- app/code/community/Dotdigitalgroup/Email/Model/Apiconnector/Test.php +16 -3
- app/code/community/Dotdigitalgroup/Email/Model/Automation.php +224 -217
@@ -1,16 +1,18 @@
|
|
1 |
Â
<?php
|
2 |
Â
|
3 |
-
class Dotdigitalgroup_Email_Block_Adminhtml_Automation
|
Â
|
|
4 |
Â
{
|
Â
|
|
5 |
Â
/**
|
6 |
-
|
7 |
-
|
8 |
Â
public function __construct()
|
9 |
Â
{
|
10 |
-
$this->_controller
|
11 |
-
$this->_blockGroup
|
12 |
Â
parent::__construct();
|
13 |
-
$this->_headerText
|
14 |
Â
$this->_removeButton('add');
|
15 |
Â
|
16 |
Â
}
|
1 |
Â
<?php
|
2 |
Â
|
3 |
+
class Dotdigitalgroup_Email_Block_Adminhtml_Automation
|
4 |
+
extends Mage_Adminhtml_Block_Widget_Grid_Container
|
5 |
Â
{
|
6 |
+
|
7 |
Â
/**
|
8 |
+
* Set the template.
|
9 |
+
*/
|
10 |
Â
public function __construct()
|
11 |
Â
{
|
12 |
+
$this->_controller = 'adminhtml_automation';
|
13 |
+
$this->_blockGroup = 'ddg_automation';
|
14 |
Â
parent::__construct();
|
15 |
+
$this->_headerText = Mage::helper('ddg')->__('Automation Status');
|
16 |
Â
$this->_removeButton('add');
|
17 |
Â
|
18 |
Â
}
|
@@ -1,147 +1,181 @@
|
|
1 |
Â
<?php
|
2 |
Â
|
3 |
-
class Dotdigitalgroup_Email_Block_Adminhtml_Automation_Grid
|
Â
|
|
4 |
Â
{
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
146 |
Â
|
147 |
Â
}
|
1 |
Â
<?php
|
2 |
Â
|
3 |
+
class Dotdigitalgroup_Email_Block_Adminhtml_Automation_Grid
|
4 |
+
extends Mage_Adminhtml_Block_Widget_Grid
|
5 |
Â
{
|
6 |
+
|
7 |
+
public function __construct()
|
8 |
+
{
|
9 |
+
parent::__construct();
|
10 |
+
$this->setId('id');
|
11 |
+
$this->setDefaultSort('entity_id');
|
12 |
+
$this->setDefaultDir('ASC');
|
13 |
+
$this->setSaveParametersInSession(true);
|
14 |
+
$this->setUseAjax(true);
|
15 |
+
|
16 |
+
}
|
17 |
+
|
18 |
+
protected function _prepareCollection()
|
19 |
+
{
|
20 |
+
$collection = Mage::getModel('ddg_automation/automation')
|
21 |
+
->getCollection();
|
22 |
+
$this->setCollection($collection);
|
23 |
+
$this->setDefaultSort('updated_at');
|
24 |
+
$this->setDefaultDir('DESC');
|
25 |
+
|
26 |
+
return parent::_prepareCollection();
|
27 |
+
}
|
28 |
+
|
29 |
+
protected function _prepareColumns()
|
30 |
+
{
|
31 |
+
$this->addColumn(
|
32 |
+
'id', array(
|
33 |
+
'header' => Mage::helper('ddg')->__('ID'),
|
34 |
+
'index' => 'id',
|
35 |
+
'type' => 'number',
|
36 |
+
'escape' => true,
|
37 |
+
)
|
38 |
+
)->addColumn(
|
39 |
+
'program_id', array(
|
40 |
+
'header' => Mage::helper('ddg')->__('Program ID'),
|
41 |
+
'align' => 'center',
|
42 |
+
'index' => 'program_id',
|
43 |
+
'type' => 'number',
|
44 |
+
'escape' => true,
|
45 |
+
)
|
46 |
+
)->addColumn(
|
47 |
+
'automation_type', array(
|
48 |
+
'header' => Mage::helper('ddg')->__('Automation Type'),
|
49 |
+
'align' => 'right',
|
50 |
+
'index' => 'automation_type',
|
51 |
+
'type' => 'text',
|
52 |
+
'escape' => true
|
53 |
+
)
|
54 |
+
)->addColumn(
|
55 |
+
'enrolment_status', array(
|
56 |
+
'header' => Mage::helper('ddg')->__('Enrollment Status'),
|
57 |
+
'align' => 'left',
|
58 |
+
'index' => 'enrolment_status',
|
59 |
+
'type' => 'options',
|
60 |
+
'options' => array(
|
61 |
+
'pending' => 'Pending',
|
62 |
+
'suppressed' => 'Suppressed',
|
63 |
+
'Active' => 'Active',
|
64 |
+
'Draft' => 'Draft',
|
65 |
+
'Deactivated' => 'Deactivated',
|
66 |
+
'ReadOnly' => 'ReadOnly',
|
67 |
+
'NotAvailableInThisVersion' => 'NotAvailableInThisVersion',
|
68 |
+
'Failed' => 'Failed'
|
69 |
+
),
|
70 |
+
'escape' => true
|
71 |
+
)
|
72 |
+
)->addColumn(
|
73 |
+
'email', array(
|
74 |
+
'header' => Mage::helper('ddg')->__('Email'),
|
75 |
+
'align' => 'right',
|
76 |
+
'index' => 'email',
|
77 |
+
'type' => 'text',
|
78 |
+
'escape' => true,
|
79 |
+
)
|
80 |
+
)->addColumn(
|
81 |
+
'type_id', array(
|
82 |
+
'header' => Mage::helper('ddg')->__('Type ID'),
|
83 |
+
'align' => 'center',
|
84 |
+
'index' => 'type_id',
|
85 |
+
'type' => 'number',
|
86 |
+
'escape' => true,
|
87 |
+
)
|
88 |
+
)->addColumn(
|
89 |
+
'message', array(
|
90 |
+
'header' => Mage::helper('ddg')->__('Message'),
|
91 |
+
'align' => 'right',
|
92 |
+
'index' => 'message',
|
93 |
+
'type' => 'text',
|
94 |
+
'escape' => true
|
95 |
+
)
|
96 |
+
)->addColumn(
|
97 |
+
'created_at', array(
|
98 |
+
'header' => Mage::helper('ddg')->__('Created at'),
|
99 |
+
'align' => 'center',
|
100 |
+
'index' => 'created_at',
|
101 |
+
'escape' => true,
|
102 |
+
'type' => 'datetime'
|
103 |
+
|
104 |
+
)
|
105 |
+
)->addColumn(
|
106 |
+
'updated_at', array(
|
107 |
+
'header' => Mage::helper('ddg')->__('Updated at'),
|
108 |
+
'align' => 'center',
|
109 |
+
'index' => 'updated_at',
|
110 |
+
'escape' => true,
|
111 |
+
'type' => 'datetime'
|
112 |
+
)
|
113 |
+
);
|
114 |
+
if ( ! Mage::app()->isSingleStoreMode()) {
|
115 |
+
$this->addColumn(
|
116 |
+
'website_id', array(
|
117 |
+
'header' => Mage::helper('customer')->__('Website'),
|
118 |
+
'align' => 'center',
|
119 |
+
'type' => 'options',
|
120 |
+
'options' => Mage::getSingleton('adminhtml/system_store')
|
121 |
+
->getWebsiteOptionHash(true),
|
122 |
+
'index' => 'website_id',
|
123 |
+
)
|
124 |
+
);
|
125 |
+
}
|
126 |
+
|
127 |
+
$this->addExportType('*/*/exportCsv', Mage::helper('ddg')->__('CSV'));
|
128 |
+
|
129 |
+
return parent::_prepareColumns();
|
130 |
+
}
|
131 |
+
|
132 |
+
/**
|
133 |
+
* Get the store.
|
134 |
+
*
|
135 |
+
* @return Mage_Core_Model_Store
|
136 |
+
* @throws Exception
|
137 |
+
*/
|
138 |
+
protected function _getStore()
|
139 |
+
{
|
140 |
+
$storeId = (int)$this->getRequest()->getParam('store', 0);
|
141 |
+
|
142 |
+
return Mage::app()->getStore($storeId);
|
143 |
+
}
|
144 |
+
|
145 |
+
/**
|
146 |
+
* Prepare the grid massaction.
|
147 |
+
*
|
148 |
+
* @return $this|Mage_Adminhtml_Block_Widget_Grid
|
149 |
+
*/
|
150 |
+
protected function _prepareMassaction()
|
151 |
+
{
|
152 |
+
$this->setMassactionIdField('id');
|
153 |
+
$this->getMassactionBlock()->setFormFieldName('automation');
|
154 |
+
$this->getMassactionBlock()->addItem(
|
155 |
+
'resend', array(
|
156 |
+
'label' => Mage::helper('ddg')->__('Resend'),
|
157 |
+
'url' => $this->getUrl('*/*/massResend'),
|
158 |
+
|
159 |
+
)
|
160 |
+
);
|
161 |
+
$this->getMassactionBlock()->addItem(
|
162 |
+
'delete', array(
|
163 |
+
'label' => Mage::helper('ddg')->__('Delete'),
|
164 |
+
'url' => $this->getUrl('*/*/massDelete'),
|
165 |
+
'confirm' => Mage::helper('ddg')->__('Are you sure?'))
|
166 |
+
);
|
167 |
+
|
168 |
+
return $this;
|
169 |
+
}
|
170 |
+
|
171 |
+
/**
|
172 |
+
* Grid url.
|
173 |
+
*
|
174 |
+
* @return string
|
175 |
+
*/
|
176 |
+
public function getGridUrl()
|
177 |
+
{
|
178 |
+
return $this->getUrl('*/*/grid', array('_current' => true));
|
179 |
+
}
|
180 |
Â
|
181 |
Â
}
|
@@ -1,16 +1,18 @@
|
|
1 |
Â
<?php
|
2 |
Â
|
3 |
-
class Dotdigitalgroup_Email_Block_Adminhtml_Campaign
|
Â
|
|
4 |
Â
{
|
Â
|
|
5 |
Â
/**
|
6 |
-
|
7 |
-
|
8 |
Â
public function __construct()
|
9 |
Â
{
|
10 |
-
$this->_controller
|
11 |
-
$this->_blockGroup
|
12 |
Â
parent::__construct();
|
13 |
-
$this->_headerText
|
14 |
Â
$this->_removeButton('add');
|
15 |
Â
|
16 |
Â
}
|
1 |
Â
<?php
|
2 |
Â
|
3 |
+
class Dotdigitalgroup_Email_Block_Adminhtml_Campaign
|
4 |
+
extends Mage_Adminhtml_Block_Widget_Grid_Container
|
5 |
Â
{
|
6 |
+
|
7 |
Â
/**
|
8 |
+
* Set the template.
|
9 |
+
*/
|
10 |
Â
public function __construct()
|
11 |
Â
{
|
12 |
+
$this->_controller = 'adminhtml_campaign';
|
13 |
+
$this->_blockGroup = 'ddg_automation';
|
14 |
Â
parent::__construct();
|
15 |
+
$this->_headerText = Mage::helper('ddg')->__('Campaigns');
|
16 |
Â
$this->_removeButton('add');
|
17 |
Â
|
18 |
Â
}
|
@@ -1,7 +1,9 @@
|
|
1 |
Â
<?php
|
2 |
Â
|
3 |
-
class Dotdigitalgroup_Email_Block_Adminhtml_Campaign_Grid
|
Â
|
|
4 |
Â
{
|
Â
|
|
5 |
Â
public function __construct()
|
6 |
Â
{
|
7 |
Â
parent::__construct();
|
@@ -13,166 +15,206 @@ class Dotdigitalgroup_Email_Block_Adminhtml_Campaign_Grid extends Mage_Adminhtml
|
|
13 |
Â
}
|
14 |
Â
|
15 |
Â
/**
|
16 |
-
|
17 |
-
|
18 |
-
|
Â
|
|
19 |
Â
protected function _prepareCollection()
|
20 |
Â
{
|
21 |
-
$collection = Mage::getModel('ddg_automation/campaign')->getCollection(
|
Â
|
|
22 |
Â
$this->setCollection($collection);
|
23 |
Â
$this->setDefaultSort('created_at');
|
24 |
Â
$this->setDefaultDir('DESC');
|
Â
|
|
25 |
Â
return parent::_prepareCollection();
|
26 |
Â
}
|
27 |
Â
|
28 |
Â
protected function _prepareColumns()
|
29 |
Â
{
|
30 |
-
$this->addColumn(
|
31 |
-
'
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
'
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
'
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
'
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
'
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
'
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
'
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
'
|
114 |
-
'
|
115 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
116 |
Â
}
|
117 |
Â
|
118 |
Â
$this->addExportType('*/*/exportCsv', Mage::helper('ddg')->__('CSV'));
|
Â
|
|
119 |
Â
return parent::_prepareColumns();
|
120 |
Â
}
|
121 |
Â
|
122 |
Â
/**
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
Â
|
|
127 |
Â
protected function _getStore()
|
128 |
Â
{
|
129 |
-
$storeId = (int)
|
Â
|
|
130 |
Â
return Mage::app()->getStore($storeId);
|
131 |
Â
}
|
132 |
Â
|
133 |
Â
|
134 |
Â
/**
|
135 |
-
|
136 |
-
|
137 |
Â
protected function _prepareMassaction()
|
138 |
Â
{
|
139 |
Â
$this->setMassactionIdField('id');
|
140 |
Â
$this->getMassactionBlock()->setFormFieldName('campaign');
|
141 |
-
$this->getMassactionBlock()->addItem(
|
142 |
-
|
143 |
-
'
|
144 |
-
'
|
145 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
146 |
Â
);
|
147 |
Â
|
148 |
-
$this->getMassactionBlock()->addItem('resend', array('label'=>Mage::helper('ddg')->__('Resend'),'url'=>$this->getUrl('*/*/massResend')));
|
149 |
Â
return $this;
|
150 |
Â
}
|
151 |
Â
|
152 |
Â
/**
|
153 |
-
|
154 |
-
|
155 |
-
|
Â
|
|
156 |
Â
public function getGridUrl()
|
157 |
Â
{
|
158 |
-
return $this->getUrl('*/*/grid', array('_current'=>true));
|
159 |
Â
}
|
Â
|
|
160 |
Â
/**
|
161 |
-
|
162 |
Â
*
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
Â
public function filterCallbackContact($collection, $column)
|
167 |
-
|
168 |
-
|
169 |
-
|
Â
|
|
170 |
Â
|
171 |
Â
if ($value == 'null') {
|
172 |
-
|
173 |
Â
} else {
|
174 |
-
|
175 |
Â
}
|
176 |
-
|
177 |
Â
|
178 |
Â
}
|
1 |
Â
<?php
|
2 |
Â
|
3 |
+
class Dotdigitalgroup_Email_Block_Adminhtml_Campaign_Grid
|
4 |
+
extends Mage_Adminhtml_Block_Widget_Grid
|
5 |
Â
{
|
6 |
+
|
7 |
Â
public function __construct()
|
8 |
Â
{
|
9 |
Â
parent::__construct();
|
15 |
Â
}
|
16 |
Â
|
17 |
Â
/**
|
18 |
+
* Prepare grid collection object.
|
19 |
+
*
|
20 |
+
* @return Mage_Adminhtml_Block_Widget_Grid
|
21 |
+
*/
|
22 |
Â
protected function _prepareCollection()
|
23 |
Â
{
|
24 |
+
$collection = Mage::getModel('ddg_automation/campaign')->getCollection(
|
25 |
+
);
|
26 |
Â
$this->setCollection($collection);
|
27 |
Â
$this->setDefaultSort('created_at');
|
28 |
Â
$this->setDefaultDir('DESC');
|
29 |
+
|
30 |
Â
return parent::_prepareCollection();
|
31 |
Â
}
|
32 |
Â
|
33 |
Â
protected function _prepareColumns()
|
34 |
Â
{
|
35 |
+
$this->addColumn(
|
36 |
+
'id', array(
|
37 |
+
'header' => Mage::helper('ddg')->__('Campaign ID'),
|
38 |
+
'width' => '20px',
|
39 |
+
'index' => 'campaign_id',
|
40 |
+
'type' => 'number',
|
41 |
+
'truncate' => 50,
|
42 |
+
'escape' => true
|
43 |
+
)
|
44 |
+
)->addColumn(
|
45 |
+
'customer_id', array(
|
46 |
+
'header' => Mage::helper('ddg')->__('Customer ID'),
|
47 |
+
'align' => 'left',
|
48 |
+
'width' => '50px',
|
49 |
+
'index' => 'customer_id',
|
50 |
+
'type' => 'number',
|
51 |
+
'escape' => true
|
52 |
+
)
|
53 |
+
)->addColumn(
|
54 |
+
'email', array(
|
55 |
+
'header' => Mage::helper('ddg')->__('Email'),
|
56 |
+
'align' => 'left',
|
57 |
+
'width' => '50px',
|
58 |
+
'index' => 'email',
|
59 |
+
'type' => 'text',
|
60 |
+
'escape' => true
|
61 |
+
)
|
62 |
+
)->addColumn(
|
63 |
+
'is_sent', array(
|
64 |
+
'header' => Mage::helper('ddg')->__(
|
65 |
+
'Is Sent'
|
66 |
+
),
|
67 |
+
'align' => 'center',
|
68 |
+
'width' => '20px',
|
69 |
+
'index' => 'is_sent',
|
70 |
+
'escape' => true,
|
71 |
+
'type' => 'options',
|
72 |
+
'renderer' => 'ddg_automation/adminhtml_column_renderer_imported',
|
73 |
+
'options' => array(
|
74 |
+
'1' => 'Is Send',
|
75 |
+
'null' => 'Not Send'
|
76 |
+
),
|
77 |
+
'filter_condition_callback' => array($this,
|
78 |
+
'filterCallbackContact')
|
79 |
+
)
|
80 |
+
)->addColumn(
|
81 |
+
'message', array(
|
82 |
+
'header' => Mage::helper('ddg')->__('Send Message'),
|
83 |
+
'align' => 'left',
|
84 |
+
'width' => '300px',
|
85 |
+
'index' => 'message',
|
86 |
+
'type' => 'text',
|
87 |
+
'escape' => true
|
88 |
+
)
|
89 |
+
)->addColumn(
|
90 |
+
'event_name', array(
|
91 |
+
'header' => Mage::helper('ddg')->__('Event Name'),
|
92 |
+
'align' => 'left',
|
93 |
+
'index' => 'event_name',
|
94 |
+
'width' => '100px',
|
95 |
+
'type' => 'string',
|
96 |
+
'escape' => true
|
97 |
+
)
|
98 |
+
)->addColumn(
|
99 |
+
'quote_id', array(
|
100 |
+
'header' => Mage::helper('ddg')->__('Quote Id'),
|
101 |
+
'align' => 'left',
|
102 |
+
'width' => '50px',
|
103 |
+
'index' => 'quote_id',
|
104 |
+
'type' => 'number',
|
105 |
+
'escape' => true
|
106 |
+
)
|
107 |
+
)->addColumn(
|
108 |
+
'sent_at', array(
|
109 |
+
'header' => Mage::helper('ddg')->__('Sent At'),
|
110 |
+
'align' => 'center',
|
111 |
+
'width' => '100px',
|
112 |
+
'index' => 'sent_at',
|
113 |
+
'type' => 'datetime',
|
114 |
+
'escape' => true
|
115 |
+
)
|
116 |
+
)->addColumn(
|
117 |
+
'created_at', array(
|
118 |
+
'header' => Mage::helper('ddg')->__('Created At'),
|
119 |
+
'align' => 'center',
|
120 |
+
'width' => '100px',
|
121 |
+
'index' => 'created_at',
|
122 |
+
'type' => 'datetime',
|
123 |
+
'escape' => true
|
124 |
+
)
|
125 |
+
)->addColumn(
|
126 |
+
'updated_at', array(
|
127 |
+
'header' => Mage::helper('ddg')->__('Updated At'),
|
128 |
+
'align' => 'center',
|
129 |
+
'width' => '100px',
|
130 |
+
'index' => 'updated_at',
|
131 |
+
'type' => 'datetime',
|
132 |
+
'escape' => true
|
133 |
+
)
|
134 |
+
);
|
135 |
+
if ( ! Mage::app()->isSingleStoreMode()) {
|
136 |
+
$this->addColumn(
|
137 |
+
'store_id', array(
|
138 |
+
'header' => Mage::helper('customer')->__('Store'),
|
139 |
+
'align' => 'center',
|
140 |
+
'width' => '80px',
|
141 |
+
'type' => 'options',
|
142 |
+
'options' => Mage::getSingleton('adminhtml/system_store')
|
143 |
+
->getStoreOptionHash(true),
|
144 |
+
'index' => 'store_id'
|
145 |
+
)
|
146 |
+
);
|
147 |
Â
}
|
148 |
Â
|
149 |
Â
$this->addExportType('*/*/exportCsv', Mage::helper('ddg')->__('CSV'));
|
150 |
+
|
151 |
Â
return parent::_prepareColumns();
|
152 |
Â
}
|
153 |
Â
|
154 |
Â
/**
|
155 |
+
* Get the store selected.
|
156 |
+
*
|
157 |
+
* @return Mage_Core_Model_Store
|
158 |
+
* @throws Exception
|
159 |
+
*/
|
160 |
Â
protected function _getStore()
|
161 |
Â
{
|
162 |
+
$storeId = (int)$this->getRequest()->getParam('store', 0);
|
163 |
+
|
164 |
Â
return Mage::app()->getStore($storeId);
|
165 |
Â
}
|
166 |
Â
|
167 |
Â
|
168 |
Â
/**
|
169 |
+
* @return $this|Mage_Adminhtml_Block_Widget_Grid
|
170 |
+
*/
|
171 |
Â
protected function _prepareMassaction()
|
172 |
Â
{
|
173 |
Â
$this->setMassactionIdField('id');
|
174 |
Â
$this->getMassactionBlock()->setFormFieldName('campaign');
|
175 |
+
$this->getMassactionBlock()->addItem(
|
176 |
+
'delete', array(
|
177 |
+
'label' => Mage::helper('ddg')->__('Delete'),
|
178 |
+
'url' => $this->getUrl('*/*/massDelete'),
|
179 |
+
'confirm' => Mage::helper('ddg')->__('Are you sure?')
|
180 |
+
)
|
181 |
+
);
|
182 |
+
|
183 |
+
$this->getMassactionBlock()->addItem(
|
184 |
+
'resend', array('label' => Mage::helper('ddg')->__('Resend'),
|
185 |
+
'url' => $this->getUrl('*/*/massResend'))
|
186 |
Â
);
|
187 |
Â
|
Â
|
|
188 |
Â
return $this;
|
189 |
Â
}
|
190 |
Â
|
191 |
Â
/**
|
192 |
+
* Grid selected url.
|
193 |
+
*
|
194 |
+
* @return string
|
195 |
+
*/
|
196 |
Â
public function getGridUrl()
|
197 |
Â
{
|
198 |
+
return $this->getUrl('*/*/grid', array('_current' => true));
|
199 |
Â
}
|
200 |
+
|
201 |
Â
/**
|
202 |
+
* Custom callback action for the campaign.
|
203 |
Â
*
|
204 |
+
* @param $collection
|
205 |
+
* @param $column
|
206 |
+
*/
|
207 |
Â
public function filterCallbackContact($collection, $column)
|
208 |
+
{
|
209 |
+
$field = $column->getFilterIndex() ? $column->getFilterIndex()
|
210 |
+
: $column->getIndex();
|
211 |
+
$value = $column->getFilter()->getValue();
|
212 |
Â
|
213 |
Â
if ($value == 'null') {
|
214 |
+
$collection->addFieldToFilter($field, array('null' => true));
|
215 |
Â
} else {
|
216 |
+
$collection->addFieldToFilter($field, array('notnull' => true));
|
217 |
Â
}
|
218 |
+
}
|
219 |
Â
|
220 |
Â
}
|
@@ -1,14 +1,16 @@
|
|
1 |
Â
<?php
|
2 |
Â
|
3 |
-
class Dotdigitalgroup_Email_Block_Adminhtml_Catalog
|
Â
|
|
4 |
Â
{
|
Â
|
|
5 |
Â
public function __construct()
|
6 |
Â
{
|
7 |
Â
parent::__construct();
|
8 |
Â
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
Â
|
13 |
Â
$this->_removeButton('add');
|
14 |
Â
}
|
1 |
Â
<?php
|
2 |
Â
|
3 |
+
class Dotdigitalgroup_Email_Block_Adminhtml_Catalog
|
4 |
+
extends Mage_Adminhtml_Block_Widget_Grid_Container
|
5 |
Â
{
|
6 |
+
|
7 |
Â
public function __construct()
|
8 |
Â
{
|
9 |
Â
parent::__construct();
|
10 |
Â
|
11 |
+
$this->_controller = 'adminhtml_catalog';
|
12 |
+
$this->_blockGroup = 'ddg_automation';
|
13 |
+
$this->_headerText = Mage::helper('ddg')->__('Email Catalog');
|
14 |
Â
|
15 |
Â
$this->_removeButton('add');
|
16 |
Â
}
|
@@ -1,7 +1,9 @@
|
|
1 |
Â
<?php
|
2 |
Â
|
3 |
-
class Dotdigitalgroup_Email_Block_Adminhtml_Catalog_Grid
|
Â
|
|
4 |
Â
{
|
Â
|
|
5 |
Â
public function __construct()
|
6 |
Â
{
|
7 |
Â
parent::__construct();
|
@@ -14,6 +16,7 @@ class Dotdigitalgroup_Email_Block_Adminhtml_Catalog_Grid extends Mage_Adminhtml_
|
|
14 |
Â
|
15 |
Â
/**
|
16 |
Â
* Collection class;
|
Â
|
|
17 |
Â
* @return string
|
18 |
Â
*/
|
19 |
Â
protected function _getCollectionClass()
|
@@ -24,6 +27,7 @@ class Dotdigitalgroup_Email_Block_Adminhtml_Catalog_Grid extends Mage_Adminhtml_
|
|
24 |
Â
|
25 |
Â
/**
|
26 |
Â
* Prepare the grid collection.
|
Â
|
|
27 |
Â
* @return Mage_Adminhtml_Block_Widget_Grid
|
28 |
Â
*/
|
29 |
Â
protected function _prepareCollection()
|
@@ -31,58 +35,80 @@ class Dotdigitalgroup_Email_Block_Adminhtml_Catalog_Grid extends Mage_Adminhtml_
|
|
31 |
Â
// Get and set our collection for the grid
|
32 |
Â
$collection = Mage::getResourceModel($this->_getCollectionClass());
|
33 |
Â
$this->setCollection($collection);
|
Â
|
|
34 |
Â
return parent::_prepareCollection();
|
35 |
Â
}
|
36 |
Â
|
37 |
Â
/**
|
38 |
Â
* Prepare the grid collumns.
|
Â
|
|
39 |
Â
* @return $this
|
40 |
Â
* @throws Exception
|
41 |
Â
*/
|
42 |
Â
protected function _prepareColumns()
|
43 |
Â
{
|
44 |
-
$this->addColumn(
|
45 |
-
'
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
'
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
86 |
Â
|
87 |
Â
return parent::_prepareColumns();
|
88 |
Â
}
|
@@ -95,7 +121,8 @@ class Dotdigitalgroup_Email_Block_Adminhtml_Catalog_Grid extends Mage_Adminhtml_
|
|
95 |
Â
*/
|
96 |
Â
public function filterCallbackContact($collection, $column)
|
97 |
Â
{
|
98 |
-
$field = $column->getFilterIndex() ? $column->getFilterIndex()
|
Â
|
|
99 |
Â
$value = $column->getFilter()->getValue();
|
100 |
Â
if ($value == 'null') {
|
101 |
Â
$collection->addFieldToFilter($field, array('null' => true));
|
1 |
Â
<?php
|
2 |
Â
|
3 |
+
class Dotdigitalgroup_Email_Block_Adminhtml_Catalog_Grid
|
4 |
+
extends Mage_Adminhtml_Block_Widget_Grid
|
5 |
Â
{
|
6 |
+
|
7 |
Â
public function __construct()
|
8 |
Â
{
|
9 |
Â
parent::__construct();
|
16 |
Â
|
17 |
Â
/**
|
18 |
Â
* Collection class;
|
19 |
+
*
|
20 |
Â
* @return string
|
21 |
Â
*/
|
22 |
Â
protected function _getCollectionClass()
|
27 |
Â
|
28 |
Â
/**
|
29 |
Â
* Prepare the grid collection.
|
30 |
+
*
|
31 |
Â
* @return Mage_Adminhtml_Block_Widget_Grid
|
32 |
Â
*/
|
33 |
Â
protected function _prepareCollection()
|
35 |
Â
// Get and set our collection for the grid
|
36 |
Â
$collection = Mage::getResourceModel($this->_getCollectionClass());
|
37 |
Â
$this->setCollection($collection);
|
38 |
+
|
39 |
Â
return parent::_prepareCollection();
|
40 |
Â
}
|
41 |
Â
|
42 |
Â
/**
|
43 |
Â
* Prepare the grid collumns.
|
44 |
+
*
|
45 |
Â
* @return $this
|
46 |
Â
* @throws Exception
|
47 |
Â
*/
|
48 |
Â
protected function _prepareColumns()
|
49 |
Â
{
|
50 |
+
$this->addColumn(
|
51 |
+
'product_id', array(
|
52 |
+
'header' => Mage::helper('ddg')->__('Product ID'),
|
53 |
+
'align' => 'left',
|
54 |
+
'width' => '50px',
|
55 |
+
'index' => 'product_id',
|
56 |
+
'type' => 'number',
|
57 |
+
'escape' => true
|
58 |
+
)
|
59 |
+
)->addColumn(
|
60 |
+
'imported', array(
|
61 |
+
'header' => Mage::helper('ddg')->__(
|
62 |
+
'Imported'
|
63 |
+
),
|
64 |
+
'align' => 'center',
|
65 |
+
'width' => '50px',
|
66 |
+
'index' => 'imported',
|
67 |
+
'type' => 'options',
|
68 |
+
'escape' => true,
|
69 |
+
'renderer' => 'ddg_automation/adminhtml_column_renderer_imported',
|
70 |
+
'options' => Mage::getModel(
|
71 |
+
'ddg_automation/adminhtml_source_contact_imported'
|
72 |
+
)->getOptions(),
|
73 |
+
'filter_condition_callback' => array($this,
|
74 |
+
'filterCallbackContact')
|
75 |
+
)
|
76 |
+
)->addColumn(
|
77 |
+
'modified', array(
|
78 |
+
'header' => Mage::helper('ddg')->__(
|
79 |
+
'Modified'
|
80 |
+
),
|
81 |
+
'align' => 'center',
|
82 |
+
'width' => '50px',
|
83 |
+
'index' => 'modified',
|
84 |
+
'type' => 'options',
|
85 |
+
'escape' => true,
|
86 |
+
'renderer' => 'ddg_automation/adminhtml_column_renderer_imported',
|
87 |
+
'options' => Mage::getModel(
|
88 |
+
'ddg_automation/adminhtml_source_contact_modified'
|
89 |
+
)->getOptions(),
|
90 |
+
'filter_condition_callback' => array($this,
|
91 |
+
'filterCallbackContact')
|
92 |
+
)
|
93 |
+
)->addColumn(
|
94 |
+
'created_at', array(
|
95 |
+
'header' => Mage::helper('ddg')->__('Created At'),
|
96 |
+
'width' => '50px',
|
97 |
+
'align' => 'center',
|
98 |
+
'index' => 'created_at',
|
99 |
+
'type' => 'datetime',
|
100 |
+
'escape' => true,
|
101 |
+
)
|
102 |
+
)->addColumn(
|
103 |
+
'updated_at', array(
|
104 |
+
'header' => Mage::helper('ddg')->__('Updated At'),
|
105 |
+
'width' => '50px',
|
106 |
+
'align' => 'center',
|
107 |
+
'index' => 'updated_at',
|
108 |
+
'type' => 'datetime',
|
109 |
+
'escape' => true,
|
110 |
+
)
|
111 |
+
);
|
112 |
Â
|
113 |
Â
return parent::_prepareColumns();
|
114 |
Â
}
|
121 |
Â
*/
|
122 |
Â
public function filterCallbackContact($collection, $column)
|
123 |
Â
{
|
124 |
+
$field = $column->getFilterIndex() ? $column->getFilterIndex()
|
125 |
+
: $column->getIndex();
|
126 |
Â
$value = $column->getFilter()->getValue();
|
127 |
Â
if ($value == 'null') {
|
128 |
Â
$collection->addFieldToFilter($field, array('null' => true));
|
@@ -1,17 +1,28 @@
|
|
1 |
Â
<?php
|
2 |
Â
|
3 |
-
class Dotdigitalgroup_Email_Block_Adminhtml_Column_Renderer_Delete
|
Â
|
|
4 |
Â
{
|
Â
|
|
5 |
Â
/**
|
6 |
Â
* Render the grid columns.
|
7 |
Â
*
|
8 |
Â
* @param Varien_Object $row
|
Â
|
|
9 |
Â
* @return string
|
10 |
Â
*/
|
11 |
Â
public function render(Varien_Object $row)
|
12 |
Â
{
|
13 |
-
$url = HtmlSpecialChars(
|
14 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
15 |
Â
}
|
16 |
Â
|
17 |
Â
}
|
1 |
Â
<?php
|
2 |
Â
|
3 |
+
class Dotdigitalgroup_Email_Block_Adminhtml_Column_Renderer_Delete
|
4 |
+
extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
|
5 |
Â
{
|
6 |
+
|
7 |
Â
/**
|
8 |
Â
* Render the grid columns.
|
9 |
Â
*
|
10 |
Â
* @param Varien_Object $row
|
11 |
+
*
|
12 |
Â
* @return string
|
13 |
Â
*/
|
14 |
Â
public function render(Varien_Object $row)
|
15 |
Â
{
|
16 |
+
$url = HtmlSpecialChars(
|
17 |
+
json_encode(
|
18 |
+
Mage::helper('adminhtml')->getUrl(
|
19 |
+
'*/*/delete', array('id' => $row->getId())
|
20 |
+
)
|
21 |
+
)
|
22 |
+
);
|
23 |
+
|
24 |
+
return '<button title="Delete" onclick="visitPage(' . $url
|
25 |
+
. ')" type="button" style=""><span><span><span>Delete</span></span></span></button>';
|
26 |
Â
}
|
27 |
Â
|
28 |
Â
}
|
@@ -1,16 +1,24 @@
|
|
1 |
Â
<?php
|
2 |
Â
|
3 |
-
class Dotdigitalgroup_Email_Block_Adminhtml_Column_Renderer_Imported
|
Â
|
|
4 |
Â
{
|
Â
|
|
5 |
Â
/**
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
Â
|
|
11 |
Â
public function render(Varien_Object $row)
|
12 |
Â
{
|
13 |
-
return '<img style="padding-top:2px" '.(($this->_getValue($row)
|
14 |
-
$this->
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
15 |
Â
}
|
16 |
Â
}
|
1 |
Â
<?php
|
2 |
Â
|
3 |
+
class Dotdigitalgroup_Email_Block_Adminhtml_Column_Renderer_Imported
|
4 |
+
extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
|
5 |
Â
{
|
6 |
+
|
7 |
Â
/**
|
8 |
+
* Render grid columns.
|
9 |
+
*
|
10 |
+
* @param Varien_Object $row
|
11 |
+
*
|
12 |
+
* @return string
|
13 |
+
*/
|
14 |
Â
public function render(Varien_Object $row)
|
15 |
Â
{
|
16 |
+
return '<img style="padding-top:2px" ' . (($this->_getValue($row) == '1'
|
17 |
+
|| $this->_getValue($row) == true)
|
18 |
+
? 'src="' . $this->getSkinUrl('images/success_msg_icon.gif')
|
19 |
+
. '" alt="YES" '
|
20 |
+
: 'src="' .
|
21 |
+
$this->getSkinUrl('images/error_msg_icon.gif') . '" alt="NO" ')
|
22 |
+
. '>';
|
23 |
Â
}
|
24 |
Â
}
|
@@ -1,17 +1,28 @@
|
|
1 |
Â
<?php
|
2 |
Â
|
3 |
-
class Dotdigitalgroup_Email_Block_Adminhtml_Column_Renderer_Reset
|
Â
|
|
4 |
Â
{
|
Â
|
|
5 |
Â
/**
|
6 |
Â
* Render the grid columns.
|
7 |
Â
*
|
8 |
Â
* @param Varien_Object $row
|
Â
|
|
9 |
Â
* @return string
|
10 |
Â
*/
|
11 |
Â
public function render(Varien_Object $row)
|
12 |
Â
{
|
13 |
-
$url = HtmlSpecialChars(
|
14 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
15 |
Â
}
|
16 |
Â
|
17 |
Â
}
|
1 |
Â
<?php
|
2 |
Â
|
3 |
+
class Dotdigitalgroup_Email_Block_Adminhtml_Column_Renderer_Reset
|
4 |
+
extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
|
5 |
Â
{
|
6 |
+
|
7 |
Â
/**
|
8 |
Â
* Render the grid columns.
|
9 |
Â
*
|
10 |
Â
* @param Varien_Object $row
|
11 |
+
*
|
12 |
Â
* @return string
|
13 |
Â
*/
|
14 |
Â
public function render(Varien_Object $row)
|
15 |
Â
{
|
16 |
+
$url = HtmlSpecialChars(
|
17 |
+
json_encode(
|
18 |
+
Mage::helper('adminhtml')->getUrl(
|
19 |
+
'*/*/reset', array('id' => $row->getId())
|
20 |
+
)
|
21 |
+
)
|
22 |
+
);
|
23 |
+
|
24 |
+
return '<button title="Reset" onclick="visitPage(' . $url
|
25 |
+
. '); return false" type="button" style=""><span><span><span>Reset</span></span></span></button>';
|
26 |
Â
}
|
27 |
Â
|
28 |
Â
}
|
@@ -1,20 +1,25 @@
|
|
1 |
Â
<?php
|
2 |
Â
|
3 |
-
class Dotdigitalgroup_Email_Block_Adminhtml_Column_Renderer_Script
|
Â
|
|
4 |
Â
{
|
Â
|
|
5 |
Â
/**
|
6 |
Â
* Render the grid columns.
|
7 |
Â
*
|
8 |
Â
* @param Varien_Object $row
|
Â
|
|
9 |
Â
* @return string
|
10 |
Â
*/
|
11 |
Â
public function render(Varien_Object $row)
|
12 |
Â
{
|
13 |
-
$html
|
Â
|
|
14 |
Â
function visitPage(url){
|
15 |
Â
document.location.href = url;
|
16 |
Â
}
|
17 |
Â
</script>";
|
Â
|
|
18 |
Â
return $html;
|
19 |
Â
}
|
20 |
Â
|
1 |
Â
<?php
|
2 |
Â
|
3 |
+
class Dotdigitalgroup_Email_Block_Adminhtml_Column_Renderer_Script
|
4 |
+
extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
|
5 |
Â
{
|
6 |
+
|
7 |
Â
/**
|
8 |
Â
* Render the grid columns.
|
9 |
Â
*
|
10 |
Â
* @param Varien_Object $row
|
11 |
+
*
|
12 |
Â
* @return string
|
13 |
Â
*/
|
14 |
Â
public function render(Varien_Object $row)
|
15 |
Â
{
|
16 |
+
$html
|
17 |
+
= "<script type='application/javascript'>
|
18 |
Â
function visitPage(url){
|
19 |
Â
document.location.href = url;
|
20 |
Â
}
|
21 |
Â
</script>";
|
22 |
+
|
23 |
Â
return $html;
|
24 |
Â
}
|
25 |
Â
|
@@ -1,17 +1,22 @@
|
|
1 |
Â
<?php
|
2 |
Â
|
3 |
-
class Dotdigitalgroup_Email_Block_Adminhtml_Column_Renderer_Status
|
Â
|
|
4 |
Â
{
|
Â
|
|
5 |
Â
/**
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
Â
|
|
11 |
Â
public function render(Varien_Object $row)
|
12 |
Â
{
|
13 |
-
if($this->getValue($row) == '1')
|
14 |
-
return
|
Â
|
|
Â
|
|
15 |
Â
return $this->__('Unsubscribed');
|
16 |
Â
}
|
17 |
Â
|
1 |
Â
<?php
|
2 |
Â
|
3 |
+
class Dotdigitalgroup_Email_Block_Adminhtml_Column_Renderer_Status
|
4 |
+
extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
|
5 |
Â
{
|
6 |
+
|
7 |
Â
/**
|
8 |
+
* Render the grid columns.
|
9 |
+
*
|
10 |
+
* @param Varien_Object $row
|
11 |
+
*
|
12 |
+
* @return string
|
13 |
+
*/
|
14 |
Â
public function render(Varien_Object $row)
|
15 |
Â
{
|
16 |
+
if ($this->getValue($row) == '1') {
|
17 |
+
return $this->__('Subscribed');
|
18 |
+
}
|
19 |
+
|
20 |
Â
return $this->__('Unsubscribed');
|
21 |
Â
}
|
22 |
Â
|
@@ -1,18 +1,23 @@
|
|
1 |
Â
<?php
|
2 |
Â
|
3 |
-
class Dotdigitalgroup_Email_Block_Adminhtml_Column_Renderer_Sync
|
Â
|
|
4 |
Â
{
|
Â
|
|
5 |
Â
/**
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
Â
|
|
11 |
Â
public function render(Varien_Object $row)
|
12 |
Â
{
|
13 |
-
|
Â
|
|
Â
|
|
14 |
Â
|
15 |
-
|
16 |
Â
}
|
17 |
Â
|
18 |
Â
}
|
1 |
Â
<?php
|
2 |
Â
|
3 |
+
class Dotdigitalgroup_Email_Block_Adminhtml_Column_Renderer_Sync
|
4 |
+
extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
|
5 |
Â
{
|
6 |
+
|
7 |
Â
/**
|
8 |
+
* Render the grid columns.
|
9 |
+
*
|
10 |
+
* @param Varien_Object $row
|
11 |
+
*
|
12 |
+
* @return string
|
13 |
+
*/
|
14 |
Â
public function render(Varien_Object $row)
|
15 |
Â
{
|
16 |
+
$title
|
17 |
+
= '<button title="Connect" type="button" style=""><span><span><span>'
|
18 |
+
. $this->__('Sync Now') . '</span></span></span></button>';
|
19 |
Â
|
20 |
+
return $title;
|
21 |
Â
}
|
22 |
Â
|
23 |
Â
}
|
@@ -1,9 +1,12 @@
|
|
1 |
Â
<?php
|
2 |
Â
|
3 |
-
class Dotdigitalgroup_Email_Block_Adminhtml_Column_Renderer_Website
|
Â
|
|
4 |
Â
{
|
Â
|
|
5 |
Â
/**
|
6 |
Â
* Render grid columns.
|
Â
|
|
7 |
Â
* @param Varien_Object $row
|
8 |
Â
*
|
9 |
Â
* @return string
|
1 |
Â
<?php
|
2 |
Â
|
3 |
+
class Dotdigitalgroup_Email_Block_Adminhtml_Column_Renderer_Website
|
4 |
+
extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
|
5 |
Â
{
|
6 |
+
|
7 |
Â
/**
|
8 |
Â
* Render grid columns.
|
9 |
+
*
|
10 |
Â
* @param Varien_Object $row
|
11 |
Â
*
|
12 |
Â
* @return string
|
@@ -1,43 +1,52 @@
|
|
1 |
Â
<?php
|
2 |
Â
|
3 |
-
class Dotdigitalgroup_Email_Block_Adminhtml_Config_Automation_Customdatafields
|
Â
|
|
4 |
Â
{
|
Â
|
|
5 |
Â
protected $_getStatusRenderer;
|
6 |
Â
protected $_getAutomationRenderer;
|
7 |
Â
|
8 |
Â
|
9 |
Â
/**
|
10 |
-
|
11 |
-
|
12 |
Â
public function __construct()
|
13 |
Â
{
|
14 |
-
$this->_addAfter
|
15 |
-
$this->_addButtonLabel = Mage::helper('adminhtml')->__(
|
Â
|
|
Â
|
|
16 |
Â
parent::__construct();
|
17 |
Â
|
18 |
Â
}
|
19 |
Â
|
20 |
Â
protected function _prepareToRender()
|
21 |
Â
{
|
22 |
-
$this->_getStatusRenderer
|
23 |
Â
$this->_getAutomationRenderer = null;
|
24 |
-
$this->addColumn(
|
25 |
-
|
26 |
-
|
Â
|
|
27 |
Â
'style' => 'width:120px',
|
28 |
Â
)
|
29 |
Â
);
|
30 |
-
$this->addColumn(
|
31 |
-
|
32 |
-
|
33 |
-
|
Â
|
|
Â
|
|
Â
|
|
34 |
Â
);
|
35 |
Â
}
|
36 |
Â
|
37 |
Â
protected function _renderCellTemplate($columnName)
|
38 |
Â
{
|
39 |
-
$inputName
|
40 |
-
|
Â
|
|
41 |
Â
return $this->_getStatusRenderer()
|
42 |
Â
->setName($inputName)
|
43 |
Â
->setTitle($columnName)
|
@@ -51,9 +60,14 @@ class Dotdigitalgroup_Email_Block_Adminhtml_Config_Automation_Customdatafields
|
|
51 |
Â
->setName($inputName)
|
52 |
Â
->setTitle($columnName)
|
53 |
Â
->setExtraParams('style="width:160px"')
|
54 |
-
->setOptions(
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
55 |
Â
->toHtml();
|
56 |
Â
}
|
Â
|
|
57 |
Â
return parent::_renderCellTemplate($columnName);
|
58 |
Â
}
|
59 |
Â
|
@@ -66,38 +80,45 @@ class Dotdigitalgroup_Email_Block_Adminhtml_Config_Automation_Customdatafields
|
|
66 |
Â
{
|
67 |
Â
|
68 |
Â
$row->setData(
|
69 |
-
'option_extra_attr_' . $this->_getStatusRenderer()->calcOptionHash(
|
Â
|
|
Â
|
|
70 |
Â
'selected="selected"'
|
71 |
Â
);
|
72 |
Â
|
73 |
Â
$row->setData(
|
74 |
-
'option_extra_attr_' . $this->_getAutomationRenderer()
|
Â
|
|
75 |
Â
'selected="selected"'
|
76 |
Â
);
|
77 |
Â
}
|
Â
|
|
78 |
Â
protected function _getStatusRenderer()
|
79 |
Â
{
|
80 |
-
if (
|
81 |
Â
$this->_getStatusRenderer = $this->getLayout()
|
82 |
Â
->createBlock('ddg_automation/adminhtml_config_select')
|
83 |
Â
->setIsRenderToJsTemplate(true);
|
84 |
Â
}
|
Â
|
|
85 |
Â
return $this->_getStatusRenderer;
|
86 |
Â
}
|
87 |
Â
|
88 |
Â
protected function _getAutomationRenderer()
|
89 |
Â
{
|
90 |
-
if (
|
91 |
Â
$this->_getAutomationRenderer = $this->getLayout()
|
92 |
Â
->createBlock('ddg_automation/adminhtml_config_select')
|
93 |
Â
->setIsRenderToJsTemplate(true);
|
94 |
Â
}
|
Â
|
|
95 |
Â
return $this->_getAutomationRenderer;
|
96 |
Â
}
|
97 |
Â
|
98 |
Â
public function _toHtml()
|
99 |
Â
{
|
100 |
-
return '<input type="hidden" id="'
|
Â
|
|
101 |
Â
|
102 |
Â
}
|
103 |
Â
|
1 |
Â
<?php
|
2 |
Â
|
3 |
+
class Dotdigitalgroup_Email_Block_Adminhtml_Config_Automation_Customdatafields
|
4 |
+
extends Mage_Adminhtml_Block_System_Config_Form_Field_Array_Abstract
|
5 |
Â
{
|
6 |
+
|
7 |
Â
protected $_getStatusRenderer;
|
8 |
Â
protected $_getAutomationRenderer;
|
9 |
Â
|
10 |
Â
|
11 |
Â
/**
|
12 |
+
* Construct.
|
13 |
+
*/
|
14 |
Â
public function __construct()
|
15 |
Â
{
|
16 |
+
$this->_addAfter = false;
|
17 |
+
$this->_addButtonLabel = Mage::helper('adminhtml')->__(
|
18 |
+
'Add New Enrolment'
|
19 |
+
);
|
20 |
Â
parent::__construct();
|
21 |
Â
|
22 |
Â
}
|
23 |
Â
|
24 |
Â
protected function _prepareToRender()
|
25 |
Â
{
|
26 |
+
$this->_getStatusRenderer = null;
|
27 |
Â
$this->_getAutomationRenderer = null;
|
28 |
+
$this->addColumn(
|
29 |
+
'status',
|
30 |
+
array(
|
31 |
+
'label' => Mage::helper('adminhtml')->__('Order Status'),
|
32 |
Â
'style' => 'width:120px',
|
33 |
Â
)
|
34 |
Â
);
|
35 |
+
$this->addColumn(
|
36 |
+
'automation', array(
|
37 |
+
'label' => Mage::helper('adminhtml')->__(
|
38 |
+
'Automation Programme'
|
39 |
+
),
|
40 |
+
'style' => 'width:120px',
|
41 |
+
)
|
42 |
Â
);
|
43 |
Â
}
|
44 |
Â
|
45 |
Â
protected function _renderCellTemplate($columnName)
|
46 |
Â
{
|
47 |
+
$inputName = $this->getElement()->getName() . '[#{_id}][' . $columnName
|
48 |
+
. ']';
|
49 |
+
if ($columnName == "status") {
|
50 |
Â
return $this->_getStatusRenderer()
|
51 |
Â
->setName($inputName)
|
52 |
Â
->setTitle($columnName)
|
60 |
Â
->setName($inputName)
|
61 |
Â
->setTitle($columnName)
|
62 |
Â
->setExtraParams('style="width:160px"')
|
63 |
+
->setOptions(
|
64 |
+
Mage::getModel(
|
65 |
+
'ddg_automation/adminhtml_source_automation_programme'
|
66 |
+
)->toOptionArray()
|
67 |
+
)
|
68 |
Â
->toHtml();
|
69 |
Â
}
|
70 |
+
|
71 |
Â
return parent::_renderCellTemplate($columnName);
|
72 |
Â
}
|
73 |
Â
|
80 |
Â
{
|
81 |
Â
|
82 |
Â
$row->setData(
|
83 |
+
'option_extra_attr_' . $this->_getStatusRenderer()->calcOptionHash(
|
84 |
+
$row->getData('status')
|
85 |
+
),
|
86 |
Â
'selected="selected"'
|
87 |
Â
);
|
88 |
Â
|
89 |
Â
$row->setData(
|
90 |
+
'option_extra_attr_' . $this->_getAutomationRenderer()
|
91 |
+
->calcOptionHash($row->getData('automation')),
|
92 |
Â
'selected="selected"'
|
93 |
Â
);
|
94 |
Â
}
|
95 |
+
|
96 |
Â
protected function _getStatusRenderer()
|
97 |
Â
{
|
98 |
+
if ( ! $this->_getStatusRenderer) {
|
99 |
Â
$this->_getStatusRenderer = $this->getLayout()
|
100 |
Â
->createBlock('ddg_automation/adminhtml_config_select')
|
101 |
Â
->setIsRenderToJsTemplate(true);
|
102 |
Â
}
|
103 |
+
|
104 |
Â
return $this->_getStatusRenderer;
|
105 |
Â
}
|
106 |
Â
|
107 |
Â
protected function _getAutomationRenderer()
|
108 |
Â
{
|
109 |
+
if ( ! $this->_getAutomationRenderer) {
|
110 |
Â
$this->_getAutomationRenderer = $this->getLayout()
|
111 |
Â
->createBlock('ddg_automation/adminhtml_config_select')
|
112 |
Â
->setIsRenderToJsTemplate(true);
|
113 |
Â
}
|
114 |
+
|
115 |
Â
return $this->_getAutomationRenderer;
|
116 |
Â
}
|
117 |
Â
|
118 |
Â
public function _toHtml()
|
119 |
Â
{
|
120 |
+
return '<input type="hidden" id="' . $this->getElement()->getHtmlId()
|
121 |
+
. '"/>' . parent::_toHtml();
|
122 |
Â
|
123 |
Â
}
|
124 |
Â
|
@@ -1,7 +1,9 @@
|
|
1 |
Â
<?php
|
2 |
Â
|
3 |
-
class Dotdigitalgroup_Email_Block_Adminhtml_Config_Customdatafields
|
Â
|
|
4 |
Â
{
|
Â
|
|
5 |
Â
/**
|
6 |
Â
* Customer attribute
|
7 |
Â
*
|
@@ -15,12 +17,14 @@ class Dotdigitalgroup_Email_Block_Adminhtml_Config_Customdatafields extends Mag
|
|
15 |
Â
|
16 |
Â
|
17 |
Â
/**
|
18 |
-
|
19 |
-
|
20 |
Â
public function __construct()
|
21 |
Â
{
|
22 |
-
$this->_addAfter
|
23 |
-
$this->_addButtonLabel = Mage::helper('adminhtml')->__(
|
Â
|
|
Â
|
|
24 |
Â
parent::__construct();
|
25 |
Â
|
26 |
Â
}
|
@@ -29,23 +33,26 @@ class Dotdigitalgroup_Email_Block_Adminhtml_Config_Customdatafields extends Mag
|
|
29 |
Â
{
|
30 |
Â
$this->_getDatafieldRenderer = null;
|
31 |
Â
$this->_getAttributeRenderer = null;
|
32 |
-
$this->addColumn(
|
33 |
-
|
34 |
-
|
Â
|
|
35 |
Â
'style' => 'width:120px',
|
36 |
Â
)
|
37 |
Â
);
|
38 |
-
$this->addColumn(
|
39 |
-
|
40 |
-
|
41 |
-
|
Â
|
|
42 |
Â
);
|
43 |
Â
}
|
44 |
Â
|
45 |
Â
protected function _renderCellTemplate($columnName)
|
46 |
Â
{
|
47 |
-
$inputName
|
48 |
-
|
Â
|
|
49 |
Â
return $this->_getAttributeRenderer()
|
50 |
Â
->setName($inputName)
|
51 |
Â
->setTitle($columnName)
|
@@ -59,9 +66,13 @@ class Dotdigitalgroup_Email_Block_Adminhtml_Config_Customdatafields extends Mag
|
|
59 |
Â
->setName($inputName)
|
60 |
Â
->setTitle($columnName)
|
61 |
Â
->setExtraParams('style="width:160px"')
|
62 |
-
->setOptions(
|
Â
|
|
Â
|
|
Â
|
|
63 |
Â
->toHtml();
|
64 |
Â
}
|
Â
|
|
65 |
Â
return parent::_renderCellTemplate($columnName);
|
66 |
Â
}
|
67 |
Â
|
@@ -74,38 +85,44 @@ class Dotdigitalgroup_Email_Block_Adminhtml_Config_Customdatafields extends Mag
|
|
74 |
Â
{
|
75 |
Â
|
76 |
Â
$row->setData(
|
77 |
-
'option_extra_attr_' . $this->_getAttributeRenderer()
|
Â
|
|
78 |
Â
'selected="selected"'
|
79 |
Â
);
|
80 |
Â
|
81 |
Â
$row->setData(
|
82 |
-
'option_extra_attr_' . $this->_getDatafieldRenderer()
|
Â
|
|
83 |
Â
'selected="selected"'
|
84 |
Â
);
|
85 |
Â
}
|
Â
|
|
86 |
Â
protected function _getAttributeRenderer()
|
87 |
Â
{
|
88 |
-
if (
|
89 |
Â
$this->_getAttributeRenderer = $this->getLayout()
|
90 |
Â
->createBlock('ddg_automation/adminhtml_config_select')
|
91 |
Â
->setIsRenderToJsTemplate(true);
|
92 |
Â
}
|
Â
|
|
93 |
Â
return $this->_getAttributeRenderer;
|
94 |
Â
}
|
95 |
Â
|
96 |
Â
protected function _getDatafieldRenderer()
|
97 |
Â
{
|
98 |
-
if (
|
99 |
Â
$this->_getDatafieldRenderer = $this->getLayout()
|
100 |
Â
->createBlock('ddg_automation/adminhtml_config_select')
|
101 |
Â
->setIsRenderToJsTemplate(true);
|
102 |
Â
}
|
Â
|
|
103 |
Â
return $this->_getDatafieldRenderer;
|
104 |
Â
}
|
105 |
Â
|
106 |
Â
public function _toHtml()
|
107 |
Â
{
|
108 |
-
return '<input type="hidden" id="'
|
Â
|
|
109 |
Â
|
110 |
Â
}
|
111 |
Â
|
1 |
Â
<?php
|
2 |
Â
|
3 |
+
class Dotdigitalgroup_Email_Block_Adminhtml_Config_Customdatafields
|
4 |
+
extends Mage_Adminhtml_Block_System_Config_Form_Field_Array_Abstract
|
5 |
Â
{
|
6 |
+
|
7 |
Â
/**
|
8 |
Â
* Customer attribute
|
9 |
Â
*
|
17 |
Â
|
18 |
Â
|
19 |
Â
/**
|
20 |
+
* Construct.
|
21 |
+
*/
|
22 |
Â
public function __construct()
|
23 |
Â
{
|
24 |
+
$this->_addAfter = false;
|
25 |
+
$this->_addButtonLabel = Mage::helper('adminhtml')->__(
|
26 |
+
'Add New Attribute'
|
27 |
+
);
|
28 |
Â
parent::__construct();
|
29 |
Â
|
30 |
Â
}
|
33 |
Â
{
|
34 |
Â
$this->_getDatafieldRenderer = null;
|
35 |
Â
$this->_getAttributeRenderer = null;
|
36 |
+
$this->addColumn(
|
37 |
+
'attribute',
|
38 |
+
array(
|
39 |
+
'label' => Mage::helper('adminhtml')->__('Attribute'),
|
40 |
Â
'style' => 'width:120px',
|
41 |
Â
)
|
42 |
Â
);
|
43 |
+
$this->addColumn(
|
44 |
+
'datafield', array(
|
45 |
+
'label' => Mage::helper('adminhtml')->__('DataField'),
|
46 |
+
'style' => 'width:120px',
|
47 |
+
)
|
48 |
Â
);
|
49 |
Â
}
|
50 |
Â
|
51 |
Â
protected function _renderCellTemplate($columnName)
|
52 |
Â
{
|
53 |
+
$inputName = $this->getElement()->getName() . '[#{_id}][' . $columnName
|
54 |
+
. ']';
|
55 |
+
if ($columnName == "attribute") {
|
56 |
Â
return $this->_getAttributeRenderer()
|
57 |
Â
->setName($inputName)
|
58 |
Â
->setTitle($columnName)
|
66 |
Â
->setName($inputName)
|
67 |
Â
->setTitle($columnName)
|
68 |
Â
->setExtraParams('style="width:160px"')
|
69 |
+
->setOptions(
|
70 |
+
Mage::getModel('ddg_automation/adminhtml_source_datafields')
|
71 |
+
->toOptionArray()
|
72 |
+
)
|
73 |
Â
->toHtml();
|
74 |
Â
}
|
75 |
+
|
76 |
Â
return parent::_renderCellTemplate($columnName);
|
77 |
Â
}
|
78 |
Â
|
85 |
Â
{
|
86 |
Â
|
87 |
Â
$row->setData(
|
88 |
+
'option_extra_attr_' . $this->_getAttributeRenderer()
|
89 |
+
->calcOptionHash($row->getData('attribute')),
|
90 |
Â
'selected="selected"'
|
91 |
Â
);
|
92 |
Â
|
93 |
Â
$row->setData(
|
94 |
+
'option_extra_attr_' . $this->_getDatafieldRenderer()
|
95 |
+
->calcOptionHash($row->getData('datafield')),
|
96 |
Â
'selected="selected"'
|
97 |
Â
);
|
98 |
Â
}
|
99 |
+
|
100 |
Â
protected function _getAttributeRenderer()
|
101 |
Â
{
|
102 |
+
if ( ! $this->_getAttributeRenderer) {
|
103 |
Â
$this->_getAttributeRenderer = $this->getLayout()
|
104 |
Â
->createBlock('ddg_automation/adminhtml_config_select')
|
105 |
Â
->setIsRenderToJsTemplate(true);
|
106 |
Â
}
|
107 |
+
|
108 |
Â
return $this->_getAttributeRenderer;
|
109 |
Â
}
|
110 |
Â
|
111 |
Â
protected function _getDatafieldRenderer()
|
112 |
Â
{
|
113 |
+
if ( ! $this->_getDatafieldRenderer) {
|
114 |
Â
$this->_getDatafieldRenderer = $this->getLayout()
|
115 |
Â
->createBlock('ddg_automation/adminhtml_config_select')
|
116 |
Â
->setIsRenderToJsTemplate(true);
|
117 |
Â
}
|
118 |
+
|
119 |
Â
return $this->_getDatafieldRenderer;
|
120 |
Â
}
|
121 |
Â
|
122 |
Â
public function _toHtml()
|
123 |
Â
{
|
124 |
+
return '<input type="hidden" id="' . $this->getElement()->getHtmlId()
|
125 |
+
. '"/>' . parent::_toHtml();
|
126 |
Â
|
127 |
Â
}
|
128 |
Â
|
@@ -1,19 +1,23 @@
|
|
1 |
Â
<?php
|
2 |
Â
|
3 |
-
class Dotdigitalgroup_Email_Block_Adminhtml_Config_Rules_Customdatafields
|
Â
|
|
4 |
Â
{
|
Â
|
|
5 |
Â
protected $_getAttributeRenderer;
|
6 |
Â
protected $_getConditionsRenderer;
|
7 |
Â
protected $_getValueRenderer;
|
8 |
Â
|
9 |
Â
|
10 |
Â
/**
|
11 |
-
|
12 |
-
|
13 |
Â
public function __construct()
|
14 |
Â
{
|
15 |
-
$this->_addAfter
|
16 |
-
$this->_addButtonLabel = Mage::helper('adminhtml')->__(
|
Â
|
|
Â
|
|
17 |
Â
parent::__construct();
|
18 |
Â
|
19 |
Â
}
|
@@ -24,21 +28,24 @@ class Dotdigitalgroup_Email_Block_Adminhtml_Config_Rules_Customdatafields exten
|
|
24 |
Â
protected function _prepareToRender()
|
25 |
Â
{
|
26 |
Â
$this->_getConditionsRenderer = null;
|
27 |
-
$this->_getAttributeRenderer
|
28 |
-
$this->_getValueRenderer
|
29 |
-
$this->addColumn(
|
30 |
-
|
31 |
-
|
Â
|
|
32 |
Â
'style' => 'width:120px',
|
33 |
Â
)
|
34 |
Â
);
|
35 |
-
$this->addColumn(
|
Â
|
|
36 |
Â
array(
|
37 |
Â
'label' => Mage::helper('adminhtml')->__('Condition'),
|
38 |
Â
'style' => 'width:120px',
|
39 |
-
|
40 |
Â
);
|
41 |
-
$this->addColumn(
|
Â
|
|
42 |
Â
array(
|
43 |
Â
'label' => Mage::helper('adminhtml')->__('Value'),
|
44 |
Â
'style' => 'width:120px',
|
@@ -50,13 +57,15 @@ class Dotdigitalgroup_Email_Block_Adminhtml_Config_Rules_Customdatafields exten
|
|
50 |
Â
* render cell template
|
51 |
Â
*
|
52 |
Â
* @param string $columnName
|
Â
|
|
53 |
Â
* @return string
|
54 |
Â
* @throws Exception
|
55 |
Â
*/
|
56 |
Â
protected function _renderCellTemplate($columnName)
|
57 |
Â
{
|
58 |
-
$inputName
|
59 |
-
|
Â
|
|
60 |
Â
return $this->_getAttributeRenderer()
|
61 |
Â
->setName($inputName)
|
62 |
Â
->setTitle($columnName)
|
@@ -65,21 +74,30 @@ class Dotdigitalgroup_Email_Block_Adminhtml_Config_Rules_Customdatafields exten
|
|
65 |
Â
$this->getElement()->getValues()
|
66 |
Â
)
|
67 |
Â
->toHtml();
|
68 |
-
}elseif ($columnName == "conditions") {
|
69 |
Â
return $this->_getConditionsRenderer()
|
70 |
Â
->setName($inputName)
|
71 |
Â
->setTitle($columnName)
|
72 |
Â
->setExtraParams('style="width:160px"')
|
73 |
-
->setOptions(
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
74 |
Â
->toHtml();
|
75 |
-
}elseif ($columnName == "cvalue") {
|
76 |
Â
return $this->_getValueRenderer()
|
77 |
Â
->setName($inputName)
|
78 |
Â
->setTitle($columnName)
|
79 |
Â
->setExtraParams('style="width:160px"')
|
80 |
-
->setOptions(
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
81 |
Â
->toHtml();
|
82 |
Â
}
|
Â
|
|
83 |
Â
return parent::_renderCellTemplate($columnName);
|
84 |
Â
}
|
85 |
Â
|
@@ -91,7 +109,8 @@ class Dotdigitalgroup_Email_Block_Adminhtml_Config_Rules_Customdatafields exten
|
|
91 |
Â
protected function _prepareArrayRow(Varien_Object $row)
|
92 |
Â
{
|
93 |
Â
$row->setData(
|
94 |
-
'option_extra_attr_' . $this->_getAttributeRenderer()
|
Â
|
|
95 |
Â
'selected="selected"'
|
96 |
Â
);
|
97 |
Â
}
|
@@ -103,11 +122,12 @@ class Dotdigitalgroup_Email_Block_Adminhtml_Config_Rules_Customdatafields exten
|
|
103 |
Â
*/
|
104 |
Â
protected function _getAttributeRenderer()
|
105 |
Â
{
|
106 |
-
if (
|
107 |
Â
$this->_getAttributeRenderer = $this->getLayout()
|
108 |
Â
->createBlock('ddg_automation/adminhtml_config_select')
|
109 |
Â
->setIsRenderToJsTemplate(true);
|
110 |
Â
}
|
Â
|
|
111 |
Â
return $this->_getAttributeRenderer;
|
112 |
Â
}
|
113 |
Â
|
@@ -118,11 +138,12 @@ class Dotdigitalgroup_Email_Block_Adminhtml_Config_Rules_Customdatafields exten
|
|
118 |
Â
*/
|
119 |
Â
protected function _getConditionsRenderer()
|
120 |
Â
{
|
121 |
-
if (
|
122 |
Â
$this->_getConditionsRenderer = $this->getLayout()
|
123 |
Â
->createBlock('ddg_automation/adminhtml_config_select')
|
124 |
Â
->setIsRenderToJsTemplate(true);
|
125 |
Â
}
|
Â
|
|
126 |
Â
return $this->_getConditionsRenderer;
|
127 |
Â
}
|
128 |
Â
|
@@ -133,18 +154,19 @@ class Dotdigitalgroup_Email_Block_Adminhtml_Config_Rules_Customdatafields exten
|
|
133 |
Â
*/
|
134 |
Â
protected function _getValueRenderer()
|
135 |
Â
{
|
136 |
-
if (
|
137 |
Â
$this->_getValueRenderer = $this->getLayout()
|
138 |
Â
->createBlock('ddg_automation/adminhtml_config_select')
|
139 |
Â
->setIsRenderToJsTemplate(true);
|
140 |
Â
}
|
Â
|
|
141 |
Â
return $this->_getValueRenderer;
|
142 |
Â
}
|
143 |
Â
|
144 |
Â
public function _toHtml()
|
145 |
Â
{
|
146 |
-
$script
|
147 |
-
"<script type=\"text/javascript\">
|
148 |
Â
document.observe('dom:loaded', function() {
|
149 |
Â
$$('tr#row_rule_condition tr td:first-child select').each(function(item) {
|
150 |
Â
doUpdateWithValues(item);
|
@@ -174,7 +196,9 @@ class Dotdigitalgroup_Email_Block_Adminhtml_Config_Rules_Customdatafields exten
|
|
174 |
Â
});
|
175 |
Â
|
176 |
Â
function doUpdate(item){
|
177 |
-
var url = '". Mage::helper('adminhtml')->getUrl(
|
Â
|
|
Â
|
|
178 |
Â
var cond = item.up(1).down().next();
|
179 |
Â
var condName = cond.down().readAttribute('name');
|
180 |
Â
var value = item.up(1).down().next(1);
|
@@ -204,7 +228,9 @@ class Dotdigitalgroup_Email_Block_Adminhtml_Config_Rules_Customdatafields exten
|
|
204 |
Â
}
|
205 |
Â
|
206 |
Â
function doUpdateWithValues(item){
|
207 |
-
var url = '". Mage::helper('adminhtml')->getUrl(
|
Â
|
|
Â
|
|
208 |
Â
var arrayKey = item.up(1).readAttribute('id');
|
209 |
Â
var cond = item.up(1).down().next();
|
210 |
Â
var condName = cond.down().readAttribute('name');
|
@@ -238,7 +264,9 @@ class Dotdigitalgroup_Email_Block_Adminhtml_Config_Rules_Customdatafields exten
|
|
238 |
Â
}
|
239 |
Â
|
240 |
Â
function doUpdateForCondition(item){
|
241 |
-
var url = '". Mage::helper('adminhtml')->getUrl(
|
Â
|
|
Â
|
|
242 |
Â
var attribute = item.up(1).down();
|
243 |
Â
var attributeValue = attribute.down().value;
|
244 |
Â
var value = item.up().next();
|
@@ -259,7 +287,9 @@ class Dotdigitalgroup_Email_Block_Adminhtml_Config_Rules_Customdatafields exten
|
|
259 |
Â
}
|
260 |
Â
});
|
261 |
Â
</script>";
|
262 |
-
|
Â
|
|
Â
|
|
263 |
Â
|
264 |
Â
}
|
265 |
Â
|
1 |
Â
<?php
|
2 |
Â
|
3 |
+
class Dotdigitalgroup_Email_Block_Adminhtml_Config_Rules_Customdatafields
|
4 |
+
extends Mage_Adminhtml_Block_System_Config_Form_Field_Array_Abstract
|
5 |
Â
{
|
6 |
+
|
7 |
Â
protected $_getAttributeRenderer;
|
8 |
Â
protected $_getConditionsRenderer;
|
9 |
Â
protected $_getValueRenderer;
|
10 |
Â
|
11 |
Â
|
12 |
Â
/**
|
13 |
+
* Construct.
|
14 |
+
*/
|
15 |
Â
public function __construct()
|
16 |
Â
{
|
17 |
+
$this->_addAfter = false;
|
18 |
+
$this->_addButtonLabel = Mage::helper('adminhtml')->__(
|
19 |
+
'Add New Condition'
|
20 |
+
);
|
21 |
Â
parent::__construct();
|
22 |
Â
|
23 |
Â
}
|
28 |
Â
protected function _prepareToRender()
|
29 |
Â
{
|
30 |
Â
$this->_getConditionsRenderer = null;
|
31 |
+
$this->_getAttributeRenderer = null;
|
32 |
+
$this->_getValueRenderer = null;
|
33 |
+
$this->addColumn(
|
34 |
+
'attribute',
|
35 |
+
array(
|
36 |
+
'label' => Mage::helper('adminhtml')->__('Attribute'),
|
37 |
Â
'style' => 'width:120px',
|
38 |
Â
)
|
39 |
Â
);
|
40 |
+
$this->addColumn(
|
41 |
+
'conditions',
|
42 |
Â
array(
|
43 |
Â
'label' => Mage::helper('adminhtml')->__('Condition'),
|
44 |
Â
'style' => 'width:120px',
|
45 |
+
)
|
46 |
Â
);
|
47 |
+
$this->addColumn(
|
48 |
+
'cvalue',
|
49 |
Â
array(
|
50 |
Â
'label' => Mage::helper('adminhtml')->__('Value'),
|
51 |
Â
'style' => 'width:120px',
|
57 |
Â
* render cell template
|
58 |
Â
*
|
59 |
Â
* @param string $columnName
|
60 |
+
*
|
61 |
Â
* @return string
|
62 |
Â
* @throws Exception
|
63 |
Â
*/
|
64 |
Â
protected function _renderCellTemplate($columnName)
|
65 |
Â
{
|
66 |
+
$inputName = $this->getElement()->getName() . '[#{_id}][' . $columnName
|
67 |
+
. ']';
|
68 |
+
if ($columnName == "attribute") {
|
69 |
Â
return $this->_getAttributeRenderer()
|
70 |
Â
->setName($inputName)
|
71 |
Â
->setTitle($columnName)
|
74 |
Â
$this->getElement()->getValues()
|
75 |
Â
)
|
76 |
Â
->toHtml();
|
77 |
+
} elseif ($columnName == "conditions") {
|
78 |
Â
return $this->_getConditionsRenderer()
|
79 |
Â
->setName($inputName)
|
80 |
Â
->setTitle($columnName)
|
81 |
Â
->setExtraParams('style="width:160px"')
|
82 |
+
->setOptions(
|
83 |
+
Mage::getModel(
|
84 |
+
'ddg_automation/adminhtml_source_rules_condition'
|
85 |
+
)->toOptionArray()
|
86 |
+
)
|
87 |
Â
->toHtml();
|
88 |
+
} elseif ($columnName == "cvalue") {
|
89 |
Â
return $this->_getValueRenderer()
|
90 |
Â
->setName($inputName)
|
91 |
Â
->setTitle($columnName)
|
92 |
Â
->setExtraParams('style="width:160px"')
|
93 |
+
->setOptions(
|
94 |
+
Mage::getModel(
|
95 |
+
'ddg_automation/adminhtml_source_rules_value'
|
96 |
+
)->toOptionArray()
|
97 |
+
)
|
98 |
Â
->toHtml();
|
99 |
Â
}
|
100 |
+
|
101 |
Â
return parent::_renderCellTemplate($columnName);
|
102 |
Â
}
|
103 |
Â
|
109 |
Â
protected function _prepareArrayRow(Varien_Object $row)
|
110 |
Â
{
|
111 |
Â
$row->setData(
|
112 |
+
'option_extra_attr_' . $this->_getAttributeRenderer()
|
113 |
+
->calcOptionHash($row->getData('attribute')),
|
114 |
Â
'selected="selected"'
|
115 |
Â
);
|
116 |
Â
}
|
122 |
Â
*/
|
123 |
Â
protected function _getAttributeRenderer()
|
124 |
Â
{
|
125 |
+
if ( ! $this->_getAttributeRenderer) {
|
126 |
Â
$this->_getAttributeRenderer = $this->getLayout()
|
127 |
Â
->createBlock('ddg_automation/adminhtml_config_select')
|
128 |
Â
->setIsRenderToJsTemplate(true);
|
129 |
Â
}
|
130 |
+
|
131 |
Â
return $this->_getAttributeRenderer;
|
132 |
Â
}
|
133 |
Â
|
138 |
Â
*/
|
139 |
Â
protected function _getConditionsRenderer()
|
140 |
Â
{
|
141 |
+
if ( ! $this->_getConditionsRenderer) {
|
142 |
Â
$this->_getConditionsRenderer = $this->getLayout()
|
143 |
Â
->createBlock('ddg_automation/adminhtml_config_select')
|
144 |
Â
->setIsRenderToJsTemplate(true);
|
145 |
Â
}
|
146 |
+
|
147 |
Â
return $this->_getConditionsRenderer;
|
148 |
Â
}
|
149 |
Â
|
154 |
Â
*/
|
155 |
Â
protected function _getValueRenderer()
|
156 |
Â
{
|
157 |
+
if ( ! $this->_getValueRenderer) {
|
158 |
Â
$this->_getValueRenderer = $this->getLayout()
|
159 |
Â
->createBlock('ddg_automation/adminhtml_config_select')
|
160 |
Â
->setIsRenderToJsTemplate(true);
|
161 |
Â
}
|
162 |
+
|
163 |
Â
return $this->_getValueRenderer;
|
164 |
Â
}
|
165 |
Â
|
166 |
Â
public function _toHtml()
|
167 |
Â
{
|
168 |
+
$script
|
169 |
+
= "<script type=\"text/javascript\">
|
170 |
Â
document.observe('dom:loaded', function() {
|
171 |
Â
$$('tr#row_rule_condition tr td:first-child select').each(function(item) {
|
172 |
Â
doUpdateWithValues(item);
|
196 |
Â
});
|
197 |
Â
|
198 |
Â
function doUpdate(item){
|
199 |
+
var url = '" . Mage::helper('adminhtml')->getUrl(
|
200 |
+
'adminhtml/rules/ajax'
|
201 |
+
) . "';
|
202 |
Â
var cond = item.up(1).down().next();
|
203 |
Â
var condName = cond.down().readAttribute('name');
|
204 |
Â
var value = item.up(1).down().next(1);
|
228 |
Â
}
|
229 |
Â
|
230 |
Â
function doUpdateWithValues(item){
|
231 |
+
var url = '" . Mage::helper('adminhtml')->getUrl(
|
232 |
+
'adminhtml/rules/selected'
|
233 |
+
) . "';
|
234 |
Â
var arrayKey = item.up(1).readAttribute('id');
|
235 |
Â
var cond = item.up(1).down().next();
|
236 |
Â
var condName = cond.down().readAttribute('name');
|
264 |
Â
}
|
265 |
Â
|
266 |
Â
function doUpdateForCondition(item){
|
267 |
+
var url = '" . Mage::helper('adminhtml')->getUrl(
|
268 |
+
'adminhtml/rules/value'
|
269 |
+
) . "';
|
270 |
Â
var attribute = item.up(1).down();
|
271 |
Â
var attributeValue = attribute.down().value;
|
272 |
Â
var value = item.up().next();
|
287 |
Â
}
|
288 |
Â
});
|
289 |
Â
</script>";
|
290 |
+
|
291 |
+
return '<input type="hidden" id="' . $this->getElement()->getHtmlId()
|
292 |
+
. '"/>' . parent::_toHtml() . $script;
|
293 |
Â
|
294 |
Â
}
|
295 |
Â
|
@@ -1,7 +1,9 @@
|
|
1 |
Â
<?php
|
2 |
Â
|
3 |
-
class Dotdigitalgroup_Email_Block_Adminhtml_Config_Select
|
Â
|
|
4 |
Â
{
|
Â
|
|
5 |
Â
/**
|
6 |
Â
* Return output in one line
|
7 |
Â
*
|
@@ -9,6 +11,6 @@ class Dotdigitalgroup_Email_Block_Adminhtml_Config_Select extends Mage_Core_Bloc
|
|
9 |
Â
*/
|
10 |
Â
public function _toHtml()
|
11 |
Â
{
|
12 |
-
return trim(preg_replace('/\s+/', ' ',parent::_toHtml()));
|
13 |
Â
}
|
14 |
Â
}
|
1 |
Â
<?php
|
2 |
Â
|
3 |
+
class Dotdigitalgroup_Email_Block_Adminhtml_Config_Select
|
4 |
+
extends Mage_Core_Block_Html_Select
|
5 |
Â
{
|
6 |
+
|
7 |
Â
/**
|
8 |
Â
* Return output in one line
|
9 |
Â
*
|
11 |
Â
*/
|
12 |
Â
public function _toHtml()
|
13 |
Â
{
|
14 |
+
return trim(preg_replace('/\s+/', ' ', parent::_toHtml()));
|
15 |
Â
}
|
16 |
Â
}
|
@@ -1,16 +1,18 @@
|
|
1 |
Â
<?php
|
2 |
Â
|
3 |
-
class Dotdigitalgroup_Email_Block_Adminhtml_Contact
|
Â
|
|
4 |
Â
{
|
Â
|
|
5 |
Â
/**
|
6 |
-
|
7 |
-
|
8 |
Â
public function __construct()
|
9 |
Â
{
|
10 |
-
$this->_controller
|
11 |
-
$this->_blockGroup
|
12 |
Â
parent::__construct();
|
13 |
-
$this->_headerText
|
14 |
Â
$this->_removeButton('add');
|
15 |
Â
|
16 |
Â
}
|
1 |
Â
<?php
|
2 |
Â
|
3 |
+
class Dotdigitalgroup_Email_Block_Adminhtml_Contact
|
4 |
+
extends Mage_Adminhtml_Block_Widget_Grid_Container
|
5 |
Â
{
|
6 |
+
|
7 |
Â
/**
|
8 |
+
* Set the template.
|
9 |
+
*/
|
10 |
Â
public function __construct()
|
11 |
Â
{
|
12 |
+
$this->_controller = 'adminhtml_contact';
|
13 |
+
$this->_blockGroup = 'ddg_automation';
|
14 |
Â
parent::__construct();
|
15 |
+
$this->_headerText = Mage::helper('ddg')->__('Contacts');
|
16 |
Â
$this->_removeButton('add');
|
17 |
Â
|
18 |
Â
}
|
@@ -1,20 +1,29 @@
|
|
1 |
Â
<?php
|
2 |
Â
|
3 |
-
class Dotdigitalgroup_Email_Block_Adminhtml_Contact_Edit
|
Â
|
|
4 |
Â
{
|
Â
|
|
5 |
Â
public function __construct()
|
6 |
Â
{
|
7 |
Â
parent::__construct();
|
8 |
Â
$this->_blockGroup = 'ddg_automation';
|
9 |
Â
$this->_controller = 'adminhtml_contact';
|
10 |
-
$this->_updateButton(
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
'
|
15 |
-
|
16 |
-
|
17 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
18 |
Â
function saveAndContinueEdit(){
|
19 |
Â
editForm.submit($('edit_form').action+'back/edit/');
|
20 |
Â
}
|
@@ -22,13 +31,19 @@ class Dotdigitalgroup_Email_Block_Adminhtml_Contact_Edit extends Mage_Adminhtml_
|
|
22 |
Â
}
|
23 |
Â
|
24 |
Â
/**
|
25 |
-
|
26 |
-
|
27 |
-
|
Â
|
|
28 |
Â
public function getHeaderText()
|
29 |
Â
{
|
30 |
-
if (
|
31 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
32 |
Â
} else {
|
33 |
Â
return Mage::helper('ddg')->__('Add Contact');
|
34 |
Â
}
|
1 |
Â
<?php
|
2 |
Â
|
3 |
+
class Dotdigitalgroup_Email_Block_Adminhtml_Contact_Edit
|
4 |
+
extends Mage_Adminhtml_Block_Widget_Form_Container
|
5 |
Â
{
|
6 |
+
|
7 |
Â
public function __construct()
|
8 |
Â
{
|
9 |
Â
parent::__construct();
|
10 |
Â
$this->_blockGroup = 'ddg_automation';
|
11 |
Â
$this->_controller = 'adminhtml_contact';
|
12 |
+
$this->_updateButton(
|
13 |
+
'save', 'label', Mage::helper('ddg')->__('Save Contact')
|
14 |
+
);
|
15 |
+
$this->_updateButton(
|
16 |
+
'delete', 'label', Mage::helper('ddg')->__('Delete Contact')
|
17 |
+
);
|
18 |
+
$this->_addButton(
|
19 |
+
'saveandcontinue', array(
|
20 |
+
'label' => Mage::helper('ddg')->__('Save And Continue Edit'),
|
21 |
+
'onclick' => 'saveAndContinueEdit()',
|
22 |
+
'class' => 'save',
|
23 |
+
), -100
|
24 |
+
);
|
25 |
+
$this->_formScripts[]
|
26 |
+
= "
|
27 |
Â
function saveAndContinueEdit(){
|
28 |
Â
editForm.submit($('edit_form').action+'back/edit/');
|
29 |
Â
}
|
31 |
Â
}
|
32 |
Â
|
33 |
Â
/**
|
34 |
+
* HEader text.
|
35 |
+
*
|
36 |
+
* @return string
|
37 |
+
*/
|
38 |
Â
public function getHeaderText()
|
39 |
Â
{
|
40 |
+
if (Mage::registry('contact_data')
|
41 |
+
&& Mage::registry('contact_data')->getId()
|
42 |
+
) {
|
43 |
+
return Mage::helper('ddg')->__(
|
44 |
+
"Edit Contact '%s'",
|
45 |
+
$this->htmlEscape(Mage::registry('contact_data')->getContact())
|
46 |
+
);
|
47 |
Â
} else {
|
48 |
Â
return Mage::helper('ddg')->__('Add Contact');
|
49 |
Â
}
|
@@ -1,25 +1,33 @@
|
|
1 |
Â
<?php
|
2 |
Â
|
3 |
-
class Dotdigitalgroup_Email_Block_Adminhtml_Contact_Edit_Form
|
Â
|
|
4 |
Â
{
|
5 |
Â
|
6 |
Â
/**
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
Â
|
|
11 |
Â
protected function _prepareForm()
|
12 |
Â
{
|
13 |
-
$form = new Varien_Data_Form(
|
14 |
-
|
15 |
-
'
|
16 |
-
'
|
17 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
18 |
Â
)
|
19 |
Â
);
|
20 |
Â
$form->setUseContainer(true);
|
21 |
Â
|
22 |
Â
$this->setForm($form);
|
Â
|
|
23 |
Â
return parent::_prepareForm();
|
24 |
Â
}
|
25 |
Â
|
1 |
Â
<?php
|
2 |
Â
|
3 |
+
class Dotdigitalgroup_Email_Block_Adminhtml_Contact_Edit_Form
|
4 |
+
extends Mage_Adminhtml_Block_Widget_Form
|
5 |
Â
{
|
6 |
Â
|
7 |
Â
/**
|
8 |
+
* Contact Form.
|
9 |
+
*
|
10 |
+
* @return Mage_Adminhtml_Block_Widget_Form
|
11 |
+
* @throws Exception
|
12 |
+
*/
|
13 |
Â
protected function _prepareForm()
|
14 |
Â
{
|
15 |
+
$form = new Varien_Data_Form(
|
16 |
+
array(
|
17 |
+
'id' => 'edit_form',
|
18 |
+
'action' => $this->getUrl(
|
19 |
+
'*/*/save',
|
20 |
+
array('id' => $this->getRequest()->getParam('id'),
|
21 |
+
'store' => $this->getRequest()->getParam('store'))
|
22 |
+
),
|
23 |
+
'method' => 'post',
|
24 |
+
'enctype' => 'multipart/form-data'
|
25 |
Â
)
|
26 |
Â
);
|
27 |
Â
$form->setUseContainer(true);
|
28 |
Â
|
29 |
Â
$this->setForm($form);
|
30 |
+
|
31 |
Â
return parent::_prepareForm();
|
32 |
Â
}
|
33 |
Â
|
@@ -1,7 +1,9 @@
|
|
1 |
Â
<?php
|
2 |
Â
|
3 |
-
class Dotdigitalgroup_Email_Block_Adminhtml_Contact_Grid
|
Â
|
|
4 |
Â
{
|
Â
|
|
5 |
Â
public function __construct()
|
6 |
Â
{
|
7 |
Â
parent::__construct();
|
@@ -14,203 +16,263 @@ class Dotdigitalgroup_Email_Block_Adminhtml_Contact_Grid extends Mage_Adminhtml_
|
|
14 |
Â
|
15 |
Â
protected function _prepareCollection()
|
16 |
Â
{
|
17 |
-
|
18 |
Â
$this->setCollection($collection);
|
Â
|
|
19 |
Â
return parent::_prepareCollection();
|
20 |
Â
}
|
21 |
Â
|
22 |
Â
protected function _prepareColumns()
|
23 |
Â
{
|
24 |
-
$this->addColumn(
|
25 |
-
'
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
'
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
'
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
'
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
'
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
134 |
Â
}
|
135 |
Â
|
136 |
-
$this->addColumn(
|
137 |
-
'
|
138 |
-
|
139 |
-
|
140 |
-
|
Â
|
|
141 |
Â
|
142 |
-
|
Â
|
|
143 |
Â
|
144 |
Â
$this->addExportType('*/*/exportCsv', Mage::helper('ddg')->__('CSV'));
|
Â
|
|
145 |
Â
return parent::_prepareColumns();
|
146 |
Â
}
|
147 |
Â
|
148 |
Â
/**
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
Â
protected function _getStore()
|
155 |
Â
{
|
156 |
-
$storeId = (int)
|
Â
|
|
157 |
Â
return Mage::app()->getStore($storeId);
|
158 |
Â
}
|
159 |
Â
|
160 |
Â
/**
|
161 |
-
|
162 |
-
|
163 |
-
|
Â
|
|
164 |
Â
protected function _prepareMassaction()
|
165 |
Â
{
|
166 |
Â
$this->setMassactionIdField('email_contact_id');
|
167 |
Â
$this->getMassactionBlock()->setFormFieldName('contact');
|
168 |
-
$this->getMassactionBlock()->addItem(
|
169 |
-
'
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
177 |
Â
return $this;
|
178 |
Â
}
|
179 |
Â
|
180 |
Â
/**
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
Â
|
|
185 |
Â
public function filterCallbackContact($collection, $column)
|
186 |
Â
{
|
187 |
-
$field = $column->getFilterIndex() ? $column->getFilterIndex()
|
Â
|
|
188 |
Â
$value = $column->getFilter()->getValue();
|
189 |
Â
|
190 |
-
if ($value == 'null')
|
191 |
-
|
192 |
-
else
|
193 |
Â
$collection->addFieldToFilter($field, array('notnull' => true));
|
Â
|
|
194 |
Â
}
|
195 |
Â
|
196 |
Â
/**
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
Â
|
|
202 |
Â
public function getRowUrl($row)
|
203 |
Â
{
|
204 |
-
return $this->getUrl(
|
Â
|
|
Â
|
|
205 |
Â
}
|
206 |
Â
|
207 |
Â
/**
|
208 |
-
|
209 |
-
|
210 |
-
|
Â
|
|
211 |
Â
public function getGridUrl()
|
212 |
Â
{
|
213 |
-
return $this->getUrl('*/*/grid', array('_current'=>true));
|
214 |
Â
}
|
215 |
Â
|
216 |
Â
}
|
1 |
Â
<?php
|
2 |
Â
|
3 |
+
class Dotdigitalgroup_Email_Block_Adminhtml_Contact_Grid
|
4 |
+
extends Mage_Adminhtml_Block_Widget_Grid
|
5 |
Â
{
|
6 |
+
|
7 |
Â
public function __construct()
|
8 |
Â
{
|
9 |
Â
parent::__construct();
|
16 |
Â
|
17 |
Â
protected function _prepareCollection()
|
18 |
Â
{
|
19 |
+
$collection = Mage::getModel('ddg_automation/contact')->getCollection();
|
20 |
Â
$this->setCollection($collection);
|
21 |
+
|
22 |
Â
return parent::_prepareCollection();
|
23 |
Â
}
|
24 |
Â
|
25 |
Â
protected function _prepareColumns()
|
26 |
Â
{
|
27 |
+
$this->addColumn(
|
28 |
+
'email_contact_id', array(
|
29 |
+
'header' => Mage::helper('ddg')->__('Email Contact ID'),
|
30 |
+
'width' => '20px',
|
31 |
+
'index' => 'email_contact_id',
|
32 |
+
'type' => 'number',
|
33 |
+
'escape' => true,
|
34 |
+
)
|
35 |
+
)->addColumn(
|
36 |
+
'email', array(
|
37 |
+
'header' => Mage::helper('ddg')->__('Email'),
|
38 |
+
'align' => 'left',
|
39 |
+
'width' => '50px',
|
40 |
+
'index' => 'email',
|
41 |
+
'type' => 'text',
|
42 |
+
'escape' => true
|
43 |
+
)
|
44 |
+
)->addColumn(
|
45 |
+
'customer_id', array(
|
46 |
+
'header' => Mage::helper('ddg')->__('Customer ID'),
|
47 |
+
'align' => 'left',
|
48 |
+
'index' => 'customer_id',
|
49 |
+
'type' => 'number',
|
50 |
+
'escape' => true
|
51 |
+
)
|
52 |
+
)->addColumn(
|
53 |
+
'is_guest', array(
|
54 |
+
'header' => Mage::helper('ddg')->__(
|
55 |
+
'Is Guest'
|
56 |
+
),
|
57 |
+
'align' => 'right',
|
58 |
+
'width' => '50px',
|
59 |
+
'index' => 'is_guest',
|
60 |
+
'type' => 'options',
|
61 |
+
'options' => array(
|
62 |
+
'1' => 'Guest',
|
63 |
+
'null' => 'Not Guest'
|
64 |
+
),
|
65 |
+
'escape' => true,
|
66 |
+
'filter_condition_callback' => array($this,
|
67 |
+
'filterCallbackContact')
|
68 |
+
)
|
69 |
+
)->addColumn(
|
70 |
+
'is_subscriber', array(
|
71 |
+
'header' => Mage::helper('ddg')->__(
|
72 |
+
'Is Subscriber'
|
73 |
+
),
|
74 |
+
'width' => '50px',
|
75 |
+
'align' => 'right',
|
76 |
+
'index' => 'is_subscriber',
|
77 |
+
'type' => 'options',
|
78 |
+
'options' => array(
|
79 |
+
'1' => 'Subscriber',
|
80 |
+
'null' => 'Not Subscriber'
|
81 |
+
),
|
82 |
+
'filter_condition_callback' => array($this,
|
83 |
+
'filterCallbackContact'),
|
84 |
+
'escape' => true,
|
85 |
+
)
|
86 |
+
)->addColumn(
|
87 |
+
'subscriber_status', array(
|
88 |
+
'header' => Mage::helper('ddg')->__('Subscriber Status'),
|
89 |
+
'align' => 'center',
|
90 |
+
'width' => '50px',
|
91 |
+
'index' => 'subscriber_status',
|
92 |
+
'type' => 'options',
|
93 |
+
'options' => array(
|
94 |
+
'1' => 'Subscribed',
|
95 |
+
'2' => 'Not Active',
|
96 |
+
'3' => 'Unsubscribed',
|
97 |
+
'4' => 'Unconfirmed'
|
98 |
+
),
|
99 |
+
'escape' => true,
|
100 |
+
)
|
101 |
+
)->addColumn(
|
102 |
+
'email_imported', array(
|
103 |
+
'header' => Mage::helper('ddg')->__(
|
104 |
+
'Email Imported'
|
105 |
+
),
|
106 |
+
'width' => '20px',
|
107 |
+
'align' => 'center',
|
108 |
+
'index' => 'email_imported',
|
109 |
+
'escape' => true,
|
110 |
+
'type' => 'options',
|
111 |
+
'options' => Mage::getModel(
|
112 |
+
'ddg_automation/adminhtml_source_contact_imported'
|
113 |
+
)->getOptions(),
|
114 |
+
'renderer' => 'ddg_automation/adminhtml_column_renderer_imported',
|
115 |
+
'filter_condition_callback' => array($this,
|
116 |
+
'filterCallbackContact')
|
117 |
+
)
|
118 |
+
)->addColumn(
|
119 |
+
'subscriber_imported', array(
|
120 |
+
'header' => Mage::helper('ddg')->__(
|
121 |
+
'Subscriber Imported'
|
122 |
+
),
|
123 |
+
'width' => '20px',
|
124 |
+
'align' => 'center',
|
125 |
+
'index' => 'subscriber_imported',
|
126 |
+
'type' => 'options',
|
127 |
+
'escape' => true,
|
128 |
+
'renderer' => 'ddg_automation/adminhtml_column_renderer_imported',
|
129 |
+
'options' => Mage::getModel(
|
130 |
+
'ddg_automation/adminhtml_source_contact_imported'
|
131 |
+
)->getOptions(),
|
132 |
+
'filter_condition_callback' => array($this,
|
133 |
+
'filterCallbackContact')
|
134 |
+
)
|
135 |
+
)->addColumn(
|
136 |
+
'suppressed', array(
|
137 |
+
'header' => Mage::helper('ddg')->__(
|
138 |
+
'Suppressed'
|
139 |
+
),
|
140 |
+
'align' => 'right',
|
141 |
+
'width' => '50px',
|
142 |
+
'index' => 'suppressed',
|
143 |
+
'escape' => true,
|
144 |
+
'type' => 'options',
|
145 |
+
'options' => array(
|
146 |
+
'1' => 'Suppressed',
|
147 |
+
'null' => 'Not Suppressed'
|
148 |
+
),
|
149 |
+
'filter_condition_callback' => array($this,
|
150 |
+
'filterCallbackContact')
|
151 |
+
)
|
152 |
+
);
|
153 |
+
|
154 |
+
//Enterprise customer segments.
|
155 |
+
if (Mage::helper('ddg')->isEnterprise()) {
|
156 |
+
$this->addColumn(
|
157 |
+
'segment_ids', array(
|
158 |
+
'header' => Mage::helper('ddg')->__('Segment Id\'s'),
|
159 |
+
'align' => 'right',
|
160 |
+
'width' => '50px',
|
161 |
+
'index' => 'segment_ids',
|
162 |
+
'escape' => true,
|
163 |
+
'type' => 'text'
|
164 |
+
)
|
165 |
+
);
|
166 |
+
}
|
167 |
+
if ( ! Mage::app()->isSingleStoreMode()) {
|
168 |
+
$this->addColumn(
|
169 |
+
'website_id', array(
|
170 |
+
'header' => Mage::helper('customer')->__('Website'),
|
171 |
+
'align' => 'center',
|
172 |
+
'width' => '80px',
|
173 |
+
'type' => 'options',
|
174 |
+
'options' => Mage::getSingleton('adminhtml/system_store')
|
175 |
+
->getWebsiteOptionHash(true),
|
176 |
+
'index' => 'website_id',
|
177 |
+
)
|
178 |
+
);
|
179 |
Â
}
|
180 |
Â
|
181 |
+
$this->addColumn(
|
182 |
+
'sync', array(
|
183 |
+
'header' => Mage::helper('ddg')->__('Sync Contact'),
|
184 |
+
'align' => 'center',
|
185 |
+
'width' => '80px',
|
186 |
+
'renderer' => 'ddg_automation/adminhtml_column_renderer_sync'
|
187 |
Â
|
188 |
+
)
|
189 |
+
);
|
190 |
Â
|
191 |
Â
$this->addExportType('*/*/exportCsv', Mage::helper('ddg')->__('CSV'));
|
192 |
+
|
193 |
Â
return parent::_prepareColumns();
|
194 |
Â
}
|
195 |
Â
|
196 |
Â
/**
|
197 |
+
* Get the store.
|
198 |
+
*
|
199 |
+
* @return Mage_Core_Model_Store
|
200 |
+
* @throws Exception
|
201 |
+
*/
|
202 |
Â
protected function _getStore()
|
203 |
Â
{
|
204 |
+
$storeId = (int)$this->getRequest()->getParam('store', 0);
|
205 |
+
|
206 |
Â
return Mage::app()->getStore($storeId);
|
207 |
Â
}
|
208 |
Â
|
209 |
Â
/**
|
210 |
+
* Prepare the grid massaction.
|
211 |
+
*
|
212 |
+
* @return $this|Mage_Adminhtml_Block_Widget_Grid
|
213 |
+
*/
|
214 |
Â
protected function _prepareMassaction()
|
215 |
Â
{
|
216 |
Â
$this->setMassactionIdField('email_contact_id');
|
217 |
Â
$this->getMassactionBlock()->setFormFieldName('contact');
|
218 |
+
$this->getMassactionBlock()->addItem(
|
219 |
+
'delete', array(
|
220 |
+
'label' => Mage::helper('ddg')->__('Delete'),
|
221 |
+
'url' => $this->getUrl('*/*/massDelete'),
|
222 |
+
'confirm' => Mage::helper('ddg')->__('Are you sure?'))
|
223 |
+
);
|
224 |
+
$this->getMassactionBlock()->addItem(
|
225 |
+
'resend', array(
|
226 |
+
'label' => Mage::helper('ddg')->__('Resend'),
|
227 |
+
'url' => $this->getUrl('*/*/massResend'),
|
228 |
+
|
229 |
+
)
|
230 |
+
);
|
231 |
+
|
232 |
Â
return $this;
|
233 |
Â
}
|
234 |
Â
|
235 |
Â
/**
|
236 |
+
* Custom callback action for the subscribers/contacts.
|
237 |
+
*
|
238 |
+
* @param $collection
|
239 |
+
* @param $column
|
240 |
+
*/
|
241 |
Â
public function filterCallbackContact($collection, $column)
|
242 |
Â
{
|
243 |
+
$field = $column->getFilterIndex() ? $column->getFilterIndex()
|
244 |
+
: $column->getIndex();
|
245 |
Â
$value = $column->getFilter()->getValue();
|
246 |
Â
|
247 |
+
if ($value == 'null') {
|
248 |
+
$collection->addFieldToFilter($field, array('null' => true));
|
249 |
+
} else {
|
250 |
Â
$collection->addFieldToFilter($field, array('notnull' => true));
|
251 |
+
}
|
252 |
Â
}
|
253 |
Â
|
254 |
Â
/**
|
255 |
+
* Edit the row.
|
256 |
+
*
|
257 |
+
* @param $row
|
258 |
+
*
|
259 |
+
* @return string
|
260 |
+
*/
|
261 |
Â
public function getRowUrl($row)
|
262 |
Â
{
|
263 |
+
return $this->getUrl(
|
264 |
+
'*/*/edit', array('id' => $row->getEmailContactId())
|
265 |
+
);
|
266 |
Â
}
|
267 |
Â
|
268 |
Â
/**
|
269 |
+
* Grid url.
|
270 |
+
*
|
271 |
+
* @return string
|
272 |
+
*/
|
273 |
Â
public function getGridUrl()
|
274 |
Â
{
|
275 |
+
return $this->getUrl('*/*/grid', array('_current' => true));
|
276 |
Â
}
|
277 |
Â
|
278 |
Â
}
|
@@ -2,7 +2,8 @@
|
|
2 |
Â
|
3 |
Â
class Dotdigitalgroup_Email_Block_Adminhtml_Customer_Tab
|
4 |
Â
extends Mage_Adminhtml_Block_Widget
|
5 |
-
implements Mage_Adminhtml_Block_Widget_Tab_Interface
|
Â
|
|
6 |
Â
|
7 |
Â
public function getTabLabel()
|
8 |
Â
{
|
2 |
Â
|
3 |
Â
class Dotdigitalgroup_Email_Block_Adminhtml_Customer_Tab
|
4 |
Â
extends Mage_Adminhtml_Block_Widget
|
5 |
+
implements Mage_Adminhtml_Block_Widget_Tab_Interface
|
6 |
+
{
|
7 |
Â
|
8 |
Â
public function getTabLabel()
|
9 |
Â
{
|
@@ -1,7 +1,9 @@
|
|
1 |
Â
<?php
|
2 |
Â
|
3 |
-
class Dotdigitalgroup_Email_Block_Adminhtml_Customer_Tab_Stats
|
Â
|
|
4 |
Â
{
|
Â
|
|
5 |
Â
protected $_stat = array();
|
6 |
Â
|
7 |
Â
public function _construct()
|
@@ -11,21 +13,27 @@ class Dotdigitalgroup_Email_Block_Adminhtml_Customer_Tab_Stats extends Mage_Admi
|
|
11 |
Â
|
12 |
Â
protected function _getCampaignStatsForCustomer()
|
13 |
Â
{
|
14 |
-
$id
|
15 |
Â
$customer = Mage::getModel('customer/customer')->load($id);
|
16 |
-
$email
|
17 |
-
$website
|
18 |
Â
|
19 |
-
$client
|
20 |
Â
$contact = $client->postContacts($email);
|
21 |
-
if(!isset($contact->message)){
|
22 |
-
$locale
|
23 |
-
$date
|
24 |
-
$response = $client->getCampaignsWithActivitySinceDate(
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
29 |
Â
$this->_stat[$one->name] = $result;
|
30 |
Â
}
|
31 |
Â
}
|
@@ -36,6 +44,7 @@ class Dotdigitalgroup_Email_Block_Adminhtml_Customer_Tab_Stats extends Mage_Admi
|
|
36 |
Â
public function getStats()
|
37 |
Â
{
|
38 |
Â
$this->_getCampaignStatsForCustomer();
|
Â
|
|
39 |
Â
return $this->_stat;
|
40 |
Â
}
|
41 |
Â
}
|
1 |
Â
<?php
|
2 |
Â
|
3 |
+
class Dotdigitalgroup_Email_Block_Adminhtml_Customer_Tab_Stats
|
4 |
+
extends Mage_Adminhtml_Block_Template
|
5 |
Â
{
|
6 |
+
|
7 |
Â
protected $_stat = array();
|
8 |
Â
|
9 |
Â
public function _construct()
|
13 |
Â
|
14 |
Â
protected function _getCampaignStatsForCustomer()
|
15 |
Â
{
|
16 |
+
$id = Mage::app()->getRequest()->getParam('id');
|
17 |
Â
$customer = Mage::getModel('customer/customer')->load($id);
|
18 |
+
$email = $customer->getEmail();
|
19 |
+
$website = $customer->getStore()->getWebsite();
|
20 |
Â
|
21 |
+
$client = Mage::helper('ddg')->getWebsiteApiClient($website);
|
22 |
Â
$contact = $client->postContacts($email);
|
23 |
+
if ( ! isset($contact->message)) {
|
24 |
+
$locale = Mage::app()->getLocale()->getLocale();
|
25 |
+
$date = Zend_Date::now($locale)->subDay(30);
|
26 |
+
$response = $client->getCampaignsWithActivitySinceDate(
|
27 |
+
$date->toString(Zend_Date::ISO_8601)
|
28 |
+
);
|
29 |
+
if ( ! isset($response->message) && is_array($response)) {
|
30 |
+
foreach ($response as $one) {
|
31 |
+
$result = $client->getCampaignActivityByContactId(
|
32 |
+
$one->id, $contact->id
|
33 |
+
);
|
34 |
+
if ( ! empty($result) && ! isset($result->message)
|
35 |
+
&& ! is_null($result)
|
36 |
+
) {
|
37 |
Â
$this->_stat[$one->name] = $result;
|
38 |
Â
}
|
39 |
Â
}
|
44 |
Â
public function getStats()
|
45 |
Â
{
|
46 |
Â
$this->_getCampaignStatsForCustomer();
|
47 |
+
|
48 |
Â
return $this->_stat;
|
49 |
Â
}
|
50 |
Â
}
|
@@ -1,52 +1,54 @@
|
|
1 |
Â
<?php
|
2 |
Â
|
3 |
-
class Dotdigitalgroup_Email_Block_Adminhtml_Dashboard
|
4 |
-
|
5 |
Â
{
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
Â
|
|
Â
|
|
51 |
Â
|
52 |
Â
}
|
1 |
Â
<?php
|
2 |
Â
|
3 |
+
class Dotdigitalgroup_Email_Block_Adminhtml_Dashboard
|
4 |
+
extends Mage_Adminhtml_Block_Dashboard_Bar
|
5 |
Â
{
|
6 |
+
|
7 |
+
/**
|
8 |
+
* Set the template.
|
9 |
+
*/
|
10 |
+
public function _construct()
|
11 |
+
{
|
12 |
+
parent::_construct();
|
13 |
+
|
14 |
+
$this->setTemplate('connector/dashboard/accountbar.phtml');
|
15 |
+
}
|
16 |
+
|
17 |
+
/**
|
18 |
+
* Prepare the layout.
|
19 |
+
*
|
20 |
+
* @return Mage_Core_Block_Abstract|void
|
21 |
+
* @throws Exception
|
22 |
+
*/
|
23 |
+
protected function _prepareLayout()
|
24 |
+
{
|
25 |
+
|
26 |
+
|
27 |
+
$website = 0;
|
28 |
+
//request store param
|
29 |
+
if ($store = $this->getRequest()->getParam('store')) {
|
30 |
+
$website = Mage::app()->getStore($store)->getWebsite();
|
31 |
+
//website param
|
32 |
+
} elseif ($this->getRequest()->getParam('website')) {
|
33 |
+
$website = $this->getRequest()->getParam('website');
|
34 |
+
}
|
35 |
+
|
36 |
+
$apiUsername = Mage::helper('ddg')->getApiUsername($website);
|
37 |
+
$apiPassword = Mage::helper('ddg')->getApiPassword($website);
|
38 |
+
|
39 |
+
//api get account info
|
40 |
+
$data = Mage::getModel('ddg_automation/apiconnector_client')
|
41 |
+
->setApiUsername($apiUsername)
|
42 |
+
->setApiPassword($apiPassword)
|
43 |
+
->getAccountInfo();
|
44 |
+
|
45 |
+
//check if properties for the data exists
|
46 |
+
if (isset($data->properties)) {
|
47 |
+
foreach ($data->properties as $one) {
|
48 |
+
//add total for the api calls
|
49 |
+
$this->addTotal($this->__($one->name), $one->value, true);
|
50 |
+
}
|
51 |
+
}
|
52 |
+
}
|
53 |
Â
|
54 |
Â
}
|
@@ -1,92 +1,103 @@
|
|
1 |
Â
<?php
|
2 |
Â
|
3 |
-
class Dotdigitalgroup_Email_Block_Adminhtml_Dashboard_Switcher
|
Â
|
|
4 |
Â
{
|
5 |
-
protected function _prepareLayout()
|
6 |
-
{
|
7 |
-
$this->setTemplate('system/config/switcher.phtml');
|
8 |
-
return parent::_prepareLayout();
|
9 |
-
}
|
10 |
Â
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
*/
|
15 |
-
public function getStoreSelectOptions()
|
16 |
-
{
|
17 |
-
$section = $this->getRequest()->getParam('section');
|
18 |
Â
|
19 |
-
|
20 |
-
|
21 |
Â
|
22 |
-
|
23 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
24 |
Â
|
25 |
-
|
Â
|
|
26 |
Â
|
27 |
-
|
28 |
-
|
29 |
-
'label' => Mage::helper('adminhtml')->__('Default Config'),
|
30 |
-
'url' => $url->getUrl('*/*/*', array('section'=>$section)),
|
31 |
-
'selected' => !$curWebsite && !$curStore,
|
32 |
-
'style' => 'background:#ccc; font-weight:bold;',
|
33 |
-
);
|
34 |
Â
|
35 |
-
|
36 |
-
$websiteShow = false;
|
37 |
-
foreach ($storeModel->getGroupCollection() as $group) {
|
38 |
-
if ($group->getWebsiteId() != $website->getId()) {
|
39 |
-
continue;
|
40 |
-
}
|
41 |
-
$groupShow = false;
|
42 |
-
foreach ($storeModel->getStoreCollection() as $store) {
|
43 |
-
if ($store->getGroupId() != $group->getId()) {
|
44 |
-
continue;
|
45 |
-
}
|
46 |
-
if (!$websiteShow) {
|
47 |
-
$websiteShow = true;
|
48 |
-
$options['website_' . $website->getId()] = array(
|
49 |
-
'label' => $website->getName(),
|
50 |
-
'url' => $url->getUrl('*/*/*', array('section'=>$section, 'website'=>$website->getId())),
|
51 |
-
'selected' => !$curStore && $curWebsite == $website->getId(),
|
52 |
-
'style' => 'padding-left:16px; background:#DDD; font-weight:bold;',
|
53 |
-
);
|
54 |
-
}
|
55 |
-
if (!$groupShow) {
|
56 |
-
$groupShow = true;
|
57 |
-
$options['group_' . $group->getId() . '_open'] = array(
|
58 |
-
'is_group' => true,
|
59 |
-
'is_close' => false,
|
60 |
-
'label' => $group->getName(),
|
61 |
-
'style' => 'padding-left:32px;'
|
62 |
-
);
|
63 |
-
}
|
64 |
-
$options['store_' . $store->getId()] = array(
|
65 |
-
'label' => $store->getName(),
|
66 |
-
'url' => $url->getUrl('*/*/*', array('section'=>$section, 'store'=>$store->getId())),
|
67 |
-
'selected' => $curStore == $store->getId(),
|
68 |
-
'style' => '',
|
69 |
-
);
|
70 |
-
}
|
71 |
-
if ($groupShow) {
|
72 |
-
$options['group_' . $group->getId() . '_close'] = array(
|
73 |
-
'is_group' => true,
|
74 |
-
'is_close' => true,
|
75 |
-
);
|
76 |
-
}
|
77 |
-
}
|
78 |
-
}
|
79 |
Â
|
80 |
-
|
81 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
82 |
Â
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
92 |
Â
}
|
1 |
Â
<?php
|
2 |
Â
|
3 |
+
class Dotdigitalgroup_Email_Block_Adminhtml_Dashboard_Switcher
|
4 |
+
extends Mage_Adminhtml_Block_Template
|
5 |
Â
{
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
6 |
Â
|
7 |
+
protected function _prepareLayout()
|
8 |
+
{
|
9 |
+
$this->setTemplate('system/config/switcher.phtml');
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
10 |
Â
|
11 |
+
return parent::_prepareLayout();
|
12 |
+
}
|
13 |
Â
|
14 |
+
/**
|
15 |
+
*
|
16 |
+
* @return array
|
17 |
+
*/
|
18 |
+
public function getStoreSelectOptions()
|
19 |
+
{
|
20 |
+
$section = $this->getRequest()->getParam('section');
|
21 |
Â
|
22 |
+
$curWebsite = $this->getRequest()->getParam('website');
|
23 |
+
$curStore = $this->getRequest()->getParam('store');
|
24 |
Â
|
25 |
+
$storeModel = Mage::getSingleton('adminhtml/system_store');
|
26 |
+
/* @var $storeModel Mage_Adminhtml_Model_System_Store */
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
27 |
Â
|
28 |
+
$url = Mage::getModel('adminhtml/url');
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
29 |
Â
|
30 |
+
$options = array();
|
31 |
+
$options['default'] = array(
|
32 |
+
'label' => Mage::helper('adminhtml')->__('Default Config'),
|
33 |
+
'url' => $url->getUrl('*/*/*', array('section' => $section)),
|
34 |
+
'selected' => ! $curWebsite && ! $curStore,
|
35 |
+
'style' => 'background:#ccc; font-weight:bold;',
|
36 |
+
);
|
37 |
Â
|
38 |
+
foreach ($storeModel->getWebsiteCollection() as $website) {
|
39 |
+
$websiteShow = false;
|
40 |
+
foreach ($storeModel->getGroupCollection() as $group) {
|
41 |
+
if ($group->getWebsiteId() != $website->getId()) {
|
42 |
+
continue;
|
43 |
+
}
|
44 |
+
$groupShow = false;
|
45 |
+
foreach ($storeModel->getStoreCollection() as $store) {
|
46 |
+
if ($store->getGroupId() != $group->getId()) {
|
47 |
+
continue;
|
48 |
+
}
|
49 |
+
if ( ! $websiteShow) {
|
50 |
+
$websiteShow = true;
|
51 |
+
$options['website_' . $website->getId()] = array(
|
52 |
+
'label' => $website->getName(),
|
53 |
+
'url' => $url->getUrl(
|
54 |
+
'*/*/*', array('section' => $section,
|
55 |
+
'website' => $website->getId())
|
56 |
+
),
|
57 |
+
'selected' => ! $curStore
|
58 |
+
&& $curWebsite == $website->getId(),
|
59 |
+
'style' => 'padding-left:16px; background:#DDD; font-weight:bold;',
|
60 |
+
);
|
61 |
+
}
|
62 |
+
if ( ! $groupShow) {
|
63 |
+
$groupShow = true;
|
64 |
+
$options['group_' . $group->getId() . '_open'] = array(
|
65 |
+
'is_group' => true,
|
66 |
+
'is_close' => false,
|
67 |
+
'label' => $group->getName(),
|
68 |
+
'style' => 'padding-left:32px;'
|
69 |
+
);
|
70 |
+
}
|
71 |
+
$options['store_' . $store->getId()] = array(
|
72 |
+
'label' => $store->getName(),
|
73 |
+
'url' => $url->getUrl(
|
74 |
+
'*/*/*', array('section' => $section,
|
75 |
+
'store' => $store->getId())
|
76 |
+
),
|
77 |
+
'selected' => $curStore == $store->getId(),
|
78 |
+
'style' => '',
|
79 |
+
);
|
80 |
+
}
|
81 |
+
if ($groupShow) {
|
82 |
+
$options['group_' . $group->getId() . '_close'] = array(
|
83 |
+
'is_group' => true,
|
84 |
+
'is_close' => true,
|
85 |
+
);
|
86 |
+
}
|
87 |
+
}
|
88 |
+
}
|
89 |
+
|
90 |
+
return $options;
|
91 |
+
}
|
92 |
+
|
93 |
+
/**
|
94 |
+
* Return store switcher hint html
|
95 |
+
*
|
96 |
+
* @return mixed
|
97 |
+
*/
|
98 |
+
public function getHintHtml()
|
99 |
+
{
|
100 |
+
return Mage::getBlockSingleton('adminhtml/store_switcher')->getHintHtml(
|
101 |
+
);
|
102 |
+
}
|
103 |
Â
}
|
@@ -1,59 +1,65 @@
|
|
1 |
Â
<?php
|
2 |
Â
|
3 |
-
class Dotdigitalgroup_Email_Block_Adminhtml_Dashboard_Tabs
|
Â
|
|
4 |
Â
{
|
5 |
Â
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
Â
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
59 |
Â
}
|
1 |
Â
<?php
|
2 |
Â
|
3 |
+
class Dotdigitalgroup_Email_Block_Adminhtml_Dashboard_Tabs
|
4 |
+
extends Mage_Adminhtml_Block_Widget_Tabs
|
5 |
Â
{
|
6 |
Â
|
7 |
+
public function __construct()
|
8 |
+
{
|
9 |
+
parent::__construct();
|
10 |
+
$this->setId('connector_dashboard_tabs');
|
11 |
+
$this->setTitle($this->__('Dashboards'));
|
12 |
+
$this->setTemplate('connector/dashboard/tabs.phtml');
|
13 |
+
}
|
14 |
Â
|
15 |
+
/**
|
16 |
+
* set tabs
|
17 |
+
*
|
18 |
+
* @return Mage_Core_Block_Abstract
|
19 |
+
* @throws Exception
|
20 |
+
*/
|
21 |
+
protected function _beforeToHtml()
|
22 |
+
{
|
23 |
+
$this->addTab(
|
24 |
+
'general',
|
25 |
+
array(
|
26 |
+
'label' => $this->__('Account Information'),
|
27 |
+
'title' => $this->__('Account Information'),
|
28 |
+
'content' => $this->getLayout()->createBlock(
|
29 |
+
'ddg_automation/adminhtml_dashboard_tabs_general'
|
30 |
+
)->toHtml(),
|
31 |
+
'active' => true
|
32 |
+
)
|
33 |
+
);
|
34 |
+
$this->addTab(
|
35 |
+
'status',
|
36 |
+
array(
|
37 |
+
'label' => $this->__('Connector Status'),
|
38 |
+
'title' => $this->__('Connector Status'),
|
39 |
+
'url' => $this->getUrl('*/*/statusGrid'),
|
40 |
+
'class' => 'ajax',
|
41 |
+
)
|
42 |
+
);
|
43 |
+
$this->addTab(
|
44 |
+
'analysis',
|
45 |
+
array(
|
46 |
+
'label' => $this->__('Data Analysis'),
|
47 |
+
'title' => $this->__('Data Analysis'),
|
48 |
+
'content' => $this->getLayout()->createBlock(
|
49 |
+
'ddg_automation/adminhtml_dashboard_tabs_analysis'
|
50 |
+
)->toHtml()
|
51 |
+
)
|
52 |
+
);
|
53 |
+
$this->addTab(
|
54 |
+
'logs',
|
55 |
+
array(
|
56 |
+
'label' => $this->__('Connector Logs'),
|
57 |
+
'title' => $this->__('Connector Logs'),
|
58 |
+
'url' => $this->getUrl('*/*/logs'),
|
59 |
+
'class' => 'ajax',
|
60 |
+
)
|
61 |
+
);
|
62 |
+
|
63 |
+
return parent::_beforeToHtml();
|
64 |
+
}
|
65 |
Â
}
|
@@ -1,61 +1,78 @@
|
|
1 |
Â
<?php
|
2 |
Â
|
3 |
-
class Dotdigitalgroup_Email_Block_Adminhtml_Dashboard_Tabs_Analysis
|
Â
|
|
4 |
Â
{
|
5 |
-
/**
|
6 |
-
* set template
|
7 |
-
*
|
8 |
-
* @throws Exception
|
9 |
-
*/
|
10 |
-
public function _construct()
|
11 |
-
{
|
12 |
-
parent::_construct();
|
13 |
-
$this->setTemplate('connector/dashboard/tabs/analysis/index.phtml');
|
14 |
-
}
|
15 |
Â
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
);
|
27 |
-
$this->setChild('abandoned_cart',
|
28 |
-
$this->getLayout()->createBlock('ddg_automation/adminhtml_dashboard_tabs_analysis_abandonedcarts')
|
29 |
-
);
|
30 |
-
$this->setChild('customer',
|
31 |
-
$this->getLayout()->createBlock('ddg_automation/adminhtml_dashboard_tabs_analysis_customer')
|
32 |
-
);
|
33 |
-
$this->setChild('subscriber',
|
34 |
-
$this->getLayout()->createBlock('ddg_automation/adminhtml_dashboard_tabs_analysis_subscriber')
|
35 |
-
);
|
36 |
-
$this->setChild('rfm',
|
37 |
-
$this->getLayout()->createBlock('ddg_automation/adminhtml_dashboard_tabs_analysis_rfm')
|
38 |
-
);
|
39 |
-
parent::_prepareLayout();
|
40 |
-
}
|
41 |
Â
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
51 |
Â
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
61 |
Â
}
|
1 |
Â
<?php
|
2 |
Â
|
3 |
+
class Dotdigitalgroup_Email_Block_Adminhtml_Dashboard_Tabs_Analysis
|
4 |
+
extends Mage_Adminhtml_Block_Dashboard_Bar
|
5 |
Â
{
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
6 |
Â
|
7 |
+
/**
|
8 |
+
* set template
|
9 |
+
*
|
10 |
+
* @throws Exception
|
11 |
+
*/
|
12 |
+
public function _construct()
|
13 |
+
{
|
14 |
+
parent::_construct();
|
15 |
+
$this->setTemplate('connector/dashboard/tabs/analysis/index.phtml');
|
16 |
+
}
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
17 |
Â
|
18 |
+
/**
|
19 |
+
* Prepare the layout. set child blocks
|
20 |
+
*
|
21 |
+
* @return Mage_Core_Block_Abstract|void
|
22 |
+
* @throws Exception
|
23 |
+
*/
|
24 |
+
protected function _prepareLayout()
|
25 |
+
{
|
26 |
+
$this->setChild(
|
27 |
+
'sales',
|
28 |
+
$this->getLayout()->createBlock(
|
29 |
+
'ddg_automation/adminhtml_dashboard_tabs_analysis_sales'
|
30 |
+
)
|
31 |
+
);
|
32 |
+
$this->setChild(
|
33 |
+
'abandoned_cart',
|
34 |
+
$this->getLayout()->createBlock(
|
35 |
+
'ddg_automation/adminhtml_dashboard_tabs_analysis_abandonedcarts'
|
36 |
+
)
|
37 |
+
);
|
38 |
+
$this->setChild(
|
39 |
+
'customer',
|
40 |
+
$this->getLayout()->createBlock(
|
41 |
+
'ddg_automation/adminhtml_dashboard_tabs_analysis_customer'
|
42 |
+
)
|
43 |
+
);
|
44 |
+
$this->setChild(
|
45 |
+
'subscriber',
|
46 |
+
$this->getLayout()->createBlock(
|
47 |
+
'ddg_automation/adminhtml_dashboard_tabs_analysis_subscriber'
|
48 |
+
)
|
49 |
+
);
|
50 |
+
$this->setChild(
|
51 |
+
'rfm',
|
52 |
+
$this->getLayout()->createBlock(
|
53 |
+
'ddg_automation/adminhtml_dashboard_tabs_analysis_rfm'
|
54 |
+
)
|
55 |
+
);
|
56 |
+
parent::_prepareLayout();
|
57 |
+
}
|
58 |
Â
|
59 |
+
/**
|
60 |
+
* get Tab content title
|
61 |
+
*
|
62 |
+
* @return string
|
63 |
+
*/
|
64 |
+
public function getTitle()
|
65 |
+
{
|
66 |
+
return Mage::helper('ddg')->__("Marketing Automation Data Analysis");
|
67 |
+
}
|
68 |
+
|
69 |
+
/**
|
70 |
+
* get column width
|
71 |
+
*
|
72 |
+
* @return string
|
73 |
+
*/
|
74 |
+
public function getColumnWidth()
|
75 |
+
{
|
76 |
+
return "290px";
|
77 |
+
}
|
78 |
Â
}
|
@@ -1,7 +1,9 @@
|
|
1 |
Â
<?php
|
2 |
Â
|
3 |
-
class Dotdigitalgroup_Email_Block_Adminhtml_Dashboard_Tabs_Analysis_Abandonedcarts
|
Â
|
|
4 |
Â
{
|
Â
|
|
5 |
Â
protected $_store = 0;
|
6 |
Â
protected $_group = 0;
|
7 |
Â
protected $_website = 0;
|
@@ -15,8 +17,8 @@ class Dotdigitalgroup_Email_Block_Adminhtml_Dashboard_Tabs_Analysis_Abandonedcar
|
|
15 |
Â
{
|
16 |
Â
parent::_construct();
|
17 |
Â
|
18 |
-
$this->_store
|
19 |
-
$this->_group
|
20 |
Â
$this->_website = $this->getRequest()->getParam('website');
|
21 |
Â
$this->setTemplate('connector/dashboard/tabs/data.phtml');
|
22 |
Â
}
|
@@ -30,10 +32,22 @@ class Dotdigitalgroup_Email_Block_Adminhtml_Dashboard_Tabs_Analysis_Abandonedcar
|
|
30 |
Â
protected function _prepareLayout()
|
31 |
Â
{
|
32 |
Â
$lifetimeAbanodned = $this->getAbandonedCartInformationForTab();
|
33 |
-
$this->addTotal(
|
34 |
-
|
35 |
-
|
36 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
37 |
Â
}
|
38 |
Â
|
39 |
Â
/**
|
@@ -43,8 +57,13 @@ class Dotdigitalgroup_Email_Block_Adminhtml_Dashboard_Tabs_Analysis_Abandonedcar
|
|
43 |
Â
*/
|
44 |
Â
protected function getAbandonedCartInformationForTab()
|
45 |
Â
{
|
46 |
-
$abandonedAnalysisModel = Mage::getModel(
|
47 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
48 |
Â
}
|
49 |
Â
|
50 |
Â
/**
|
1 |
Â
<?php
|
2 |
Â
|
3 |
+
class Dotdigitalgroup_Email_Block_Adminhtml_Dashboard_Tabs_Analysis_Abandonedcarts
|
4 |
+
extends Dotdigitalgroup_Email_Block_Adminhtml_Dashboard_Tabs_Analysis
|
5 |
Â
{
|
6 |
+
|
7 |
Â
protected $_store = 0;
|
8 |
Â
protected $_group = 0;
|
9 |
Â
protected $_website = 0;
|
17 |
Â
{
|
18 |
Â
parent::_construct();
|
19 |
Â
|
20 |
+
$this->_store = $this->getRequest()->getParam('store');
|
21 |
+
$this->_group = $this->getRequest()->getParam('group');
|
22 |
Â
$this->_website = $this->getRequest()->getParam('website');
|
23 |
Â
$this->setTemplate('connector/dashboard/tabs/data.phtml');
|
24 |
Â
}
|
32 |
Â
protected function _prepareLayout()
|
33 |
Â
{
|
34 |
Â
$lifetimeAbanodned = $this->getAbandonedCartInformationForTab();
|
35 |
+
$this->addTotal(
|
36 |
+
$this->__('Total Abandoned Cart Lost Revenue'),
|
37 |
+
$lifetimeAbanodned->getLifetime()
|
38 |
+
);
|
39 |
+
$this->addTotal(
|
40 |
+
$this->__('Average Abandoned Cart Lost Revenue'),
|
41 |
+
$lifetimeAbanodned->getAverage()
|
42 |
+
);
|
43 |
+
$this->addTotal(
|
44 |
+
$this->__('Total Number Of Abandoned Carts'),
|
45 |
+
$lifetimeAbanodned->getTotalCount(), true
|
46 |
+
);
|
47 |
+
$this->addTotal(
|
48 |
+
$this->__('Average Abandoned Carts Created Per Day'),
|
49 |
+
$lifetimeAbanodned->getDayCount(), true
|
50 |
+
);
|
51 |
Â
}
|
52 |
Â
|
53 |
Â
/**
|
57 |
Â
*/
|
58 |
Â
protected function getAbandonedCartInformationForTab()
|
59 |
Â
{
|
60 |
+
$abandonedAnalysisModel = Mage::getModel(
|
61 |
+
'ddg_automation/adminhtml_dashboard_tabs_analysis_abandoned'
|
62 |
+
);
|
63 |
+
|
64 |
+
return $abandonedAnalysisModel->getLifeTimeAbandoned(
|
65 |
+
$this->_store, $this->_website, $this->_group
|
66 |
+
);
|
67 |
Â
}
|
68 |
Â
|
69 |
Â
/**
|
@@ -1,7 +1,9 @@
|
|
1 |
Â
<?php
|
2 |
Â
|
3 |
-
class Dotdigitalgroup_Email_Block_Adminhtml_Dashboard_Tabs_Analysis_Customer
|
Â
|
|
4 |
Â
{
|
Â
|
|
5 |
Â
protected $_store = 0;
|
6 |
Â
protected $_group = 0;
|
7 |
Â
protected $_website = 0;
|
@@ -15,8 +17,8 @@ class Dotdigitalgroup_Email_Block_Adminhtml_Dashboard_Tabs_Analysis_Customer ext
|
|
15 |
Â
{
|
16 |
Â
parent::_construct();
|
17 |
Â
|
18 |
-
$this->_store
|
19 |
-
$this->_group
|
20 |
Â
$this->_website = $this->getRequest()->getParam('website');
|
21 |
Â
$this->setTemplate('connector/dashboard/tabs/data.phtml');
|
22 |
Â
}
|
@@ -30,8 +32,14 @@ class Dotdigitalgroup_Email_Block_Adminhtml_Dashboard_Tabs_Analysis_Customer ext
|
|
30 |
Â
protected function _prepareLayout()
|
31 |
Â
{
|
32 |
Â
$lifetimeCustomer = $this->getCustomerInformationForTab();
|
33 |
-
$this->addTotal(
|
34 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
35 |
Â
}
|
36 |
Â
|
37 |
Â
/**
|
@@ -41,8 +49,13 @@ class Dotdigitalgroup_Email_Block_Adminhtml_Dashboard_Tabs_Analysis_Customer ext
|
|
41 |
Â
*/
|
42 |
Â
protected function getCustomerInformationForTab()
|
43 |
Â
{
|
44 |
-
$customerAnalysisModel = Mage::getModel(
|
45 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
46 |
Â
}
|
47 |
Â
|
48 |
Â
/**
|
1 |
Â
<?php
|
2 |
Â
|
3 |
+
class Dotdigitalgroup_Email_Block_Adminhtml_Dashboard_Tabs_Analysis_Customer
|
4 |
+
extends Dotdigitalgroup_Email_Block_Adminhtml_Dashboard_Tabs_Analysis
|
5 |
Â
{
|
6 |
+
|
7 |
Â
protected $_store = 0;
|
8 |
Â
protected $_group = 0;
|
9 |
Â
protected $_website = 0;
|
17 |
Â
{
|
18 |
Â
parent::_construct();
|
19 |
Â
|
20 |
+
$this->_store = $this->getRequest()->getParam('store');
|
21 |
+
$this->_group = $this->getRequest()->getParam('group');
|
22 |
Â
$this->_website = $this->getRequest()->getParam('website');
|
23 |
Â
$this->setTemplate('connector/dashboard/tabs/data.phtml');
|
24 |
Â
}
|
32 |
Â
protected function _prepareLayout()
|
33 |
Â
{
|
34 |
Â
$lifetimeCustomer = $this->getCustomerInformationForTab();
|
35 |
+
$this->addTotal(
|
36 |
+
$this->__('Total Number Of Customers'),
|
37 |
+
$lifetimeCustomer->getTotalCount(), true
|
38 |
+
);
|
39 |
+
$this->addTotal(
|
40 |
+
$this->__('Average Customers Created Per Day'),
|
41 |
+
$lifetimeCustomer->getDayCount(), true
|
42 |
+
);
|
43 |
Â
}
|
44 |
Â
|
45 |
Â
/**
|
49 |
Â
*/
|
50 |
Â
protected function getCustomerInformationForTab()
|
51 |
Â
{
|
52 |
+
$customerAnalysisModel = Mage::getModel(
|
53 |
+
'ddg_automation/adminhtml_dashboard_tabs_analysis_customer'
|
54 |
+
);
|
55 |
+
|
56 |
+
return $customerAnalysisModel->getLifeTimeTimeCustomer(
|
57 |
+
$this->_store, $this->_website, $this->_group
|
58 |
+
);
|
59 |
Â
}
|
60 |
Â
|
61 |
Â
/**
|
@@ -1,8 +1,10 @@
|
|
1 |
Â
<?php
|
2 |
Â
|
3 |
-
class Dotdigitalgroup_Email_Block_Adminhtml_Dashboard_Tabs_Analysis_Rfm
|
Â
|
|
4 |
Â
{
|
5 |
-
|
Â
|
|
6 |
Â
protected $_store = 0;
|
7 |
Â
protected $_group = 0;
|
8 |
Â
protected $_website = 0;
|
@@ -17,8 +19,8 @@ class Dotdigitalgroup_Email_Block_Adminhtml_Dashboard_Tabs_Analysis_Rfm extends
|
|
17 |
Â
{
|
18 |
Â
parent::_construct();
|
19 |
Â
|
20 |
-
$this->_store
|
21 |
-
$this->_group
|
22 |
Â
$this->_website = $this->getRequest()->getParam('website');
|
23 |
Â
$this->setTemplate('connector/dashboard/tabs/analysis/rfm.phtml');
|
24 |
Â
}
|
@@ -31,10 +33,13 @@ class Dotdigitalgroup_Email_Block_Adminhtml_Dashboard_Tabs_Analysis_Rfm extends
|
|
31 |
Â
*/
|
32 |
Â
protected function _prepareLayout()
|
33 |
Â
{
|
34 |
-
$rfmAnalysisModel = Mage::getModel(
|
35 |
-
|
36 |
-
|
37 |
-
|
Â
|
|
Â
|
|
Â
|
|
38 |
Â
$this->rfm['Monetary'][$key] = $this->format($value);
|
39 |
Â
}
|
40 |
Â
}
|
@@ -44,28 +49,31 @@ class Dotdigitalgroup_Email_Block_Adminhtml_Dashboard_Tabs_Analysis_Rfm extends
|
|
44 |
Â
*/
|
45 |
Â
protected function getRfm()
|
46 |
Â
{
|
47 |
-
foreach($this->rfm as $k => $type){
|
48 |
-
foreach($type as $p => $value){
|
49 |
-
if($value == '')
|
50 |
Â
$this->rfm[$k][$p] = '0';
|
Â
|
|
51 |
Â
}
|
52 |
Â
}
|
Â
|
|
53 |
Â
return $this->rfm;
|
54 |
Â
}
|
55 |
Â
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
Â
|
|
60 |
Â
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
Â
|
67 |
-
|
68 |
-
|
69 |
Â
|
70 |
Â
/**
|
71 |
Â
* get currency
|
@@ -77,14 +85,21 @@ class Dotdigitalgroup_Email_Block_Adminhtml_Dashboard_Tabs_Analysis_Rfm extends
|
|
77 |
Â
public function getCurrency()
|
78 |
Â
{
|
79 |
Â
if ($this->_store) {
|
80 |
-
$currencyCode = Mage::app()->getStore(
|
81 |
-
|
82 |
-
|
83 |
-
} else if ($this->
|
84 |
-
$currencyCode =
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
85 |
Â
} else {
|
86 |
Â
$currencyCode = Mage::app()->getStore()->getBaseCurrency();
|
87 |
Â
}
|
Â
|
|
88 |
Â
return $currencyCode;
|
89 |
Â
}
|
90 |
Â
|
@@ -92,6 +107,7 @@ class Dotdigitalgroup_Email_Block_Adminhtml_Dashboard_Tabs_Analysis_Rfm extends
|
|
92 |
Â
* format price from currency
|
93 |
Â
*
|
94 |
Â
* @param $price
|
Â
|
|
95 |
Â
* @return string
|
96 |
Â
*/
|
97 |
Â
public function format($price)
|
@@ -101,6 +117,8 @@ class Dotdigitalgroup_Email_Block_Adminhtml_Dashboard_Tabs_Analysis_Rfm extends
|
|
101 |
Â
|
102 |
Â
public function getTitle()
|
103 |
Â
{
|
104 |
-
return $this->__("RFM Matrix")
|
Â
|
|
Â
|
|
105 |
Â
}
|
106 |
Â
}
|
1 |
Â
<?php
|
2 |
Â
|
3 |
+
class Dotdigitalgroup_Email_Block_Adminhtml_Dashboard_Tabs_Analysis_Rfm
|
4 |
+
extends Dotdigitalgroup_Email_Block_Adminhtml_Dashboard_Tabs_Analysis
|
5 |
Â
{
|
6 |
+
|
7 |
+
public $rfm = array();
|
8 |
Â
protected $_store = 0;
|
9 |
Â
protected $_group = 0;
|
10 |
Â
protected $_website = 0;
|
19 |
Â
{
|
20 |
Â
parent::_construct();
|
21 |
Â
|
22 |
+
$this->_store = $this->getRequest()->getParam('store');
|
23 |
+
$this->_group = $this->getRequest()->getParam('group');
|
24 |
Â
$this->_website = $this->getRequest()->getParam('website');
|
25 |
Â
$this->setTemplate('connector/dashboard/tabs/analysis/rfm.phtml');
|
26 |
Â
}
|
33 |
Â
*/
|
34 |
Â
protected function _prepareLayout()
|
35 |
Â
{
|
36 |
+
$rfmAnalysisModel = Mage::getModel(
|
37 |
+
'ddg_automation/adminhtml_dashboard_tabs_analysis_rfm'
|
38 |
+
);
|
39 |
+
$this->rfm = $rfmAnalysisModel->getPreparedRfm(
|
40 |
+
$this->_store, $this->_website, $this->_group
|
41 |
+
);
|
42 |
+
foreach ($this->rfm['Monetary'] as $key => $value) {
|
43 |
Â
$this->rfm['Monetary'][$key] = $this->format($value);
|
44 |
Â
}
|
45 |
Â
}
|
49 |
Â
*/
|
50 |
Â
protected function getRfm()
|
51 |
Â
{
|
52 |
+
foreach ($this->rfm as $k => $type) {
|
53 |
+
foreach ($type as $p => $value) {
|
54 |
+
if ($value == '') {
|
55 |
Â
$this->rfm[$k][$p] = '0';
|
56 |
+
}
|
57 |
Â
}
|
58 |
Â
}
|
59 |
+
|
60 |
Â
return $this->rfm;
|
61 |
Â
}
|
62 |
Â
|
63 |
+
/**
|
64 |
+
* @return array
|
65 |
+
*/
|
66 |
+
protected function getLabels()
|
67 |
+
{
|
68 |
Â
|
69 |
+
$labels = array(
|
70 |
+
Dotdigitalgroup_Email_Model_Adminhtml_Dashboard_Tabs_Analysis_Rfm::FREQUENCY => "Frequency (orders)",
|
71 |
+
Dotdigitalgroup_Email_Model_Adminhtml_Dashboard_Tabs_Analysis_Rfm::RECENCY => "Recency (days)",
|
72 |
+
Dotdigitalgroup_Email_Model_Adminhtml_Dashboard_Tabs_Analysis_Rfm::MONETARY => "Monetary (value)"
|
73 |
+
);
|
74 |
Â
|
75 |
+
return $labels;
|
76 |
+
}
|
77 |
Â
|
78 |
Â
/**
|
79 |
Â
* get currency
|
85 |
Â
public function getCurrency()
|
86 |
Â
{
|
87 |
Â
if ($this->_store) {
|
88 |
+
$currencyCode = Mage::app()->getStore(
|
89 |
+
$this->getRequest()->getParam('store')
|
90 |
+
)->getBaseCurrency();
|
91 |
+
} else if ($this->_website) {
|
92 |
+
$currencyCode = Mage::app()->getWebsite(
|
93 |
+
$this->getRequest()->getParam('website')
|
94 |
+
)->getBaseCurrency();
|
95 |
+
} else if ($this->_group) {
|
96 |
+
$currencyCode = Mage::app()->getGroup(
|
97 |
+
$this->getRequest()->getParam('group')
|
98 |
+
)->getWebsite()->getBaseCurrency();
|
99 |
Â
} else {
|
100 |
Â
$currencyCode = Mage::app()->getStore()->getBaseCurrency();
|
101 |
Â
}
|
102 |
+
|
103 |
Â
return $currencyCode;
|
104 |
Â
}
|
105 |
Â
|
107 |
Â
* format price from currency
|
108 |
Â
*
|
109 |
Â
* @param $price
|
110 |
+
*
|
111 |
Â
* @return string
|
112 |
Â
*/
|
113 |
Â
public function format($price)
|
117 |
Â
|
118 |
Â
public function getTitle()
|
119 |
Â
{
|
120 |
+
return $this->__("RFM Matrix")
|
121 |
+
. "(<a href='https://econsultancy.com/blog/64481-finding-your-best-customers-with-the-rfm-matrix' target='_blank'>"
|
122 |
+
. $this->__("Find out more") . "</a>)";
|
123 |
Â
}
|
124 |
Â
}
|
@@ -1,7 +1,9 @@
|
|
1 |
Â
<?php
|
2 |
Â
|
3 |
-
class Dotdigitalgroup_Email_Block_Adminhtml_Dashboard_Tabs_Analysis_Sales
|
Â
|
|
4 |
Â
{
|
Â
|
|
5 |
Â
protected $_store = 0;
|
6 |
Â
protected $_group = 0;
|
7 |
Â
protected $_website = 0;
|
@@ -15,8 +17,8 @@ class Dotdigitalgroup_Email_Block_Adminhtml_Dashboard_Tabs_Analysis_Sales extend
|
|
15 |
Â
{
|
16 |
Â
parent::_construct();
|
17 |
Â
|
18 |
-
$this->_store
|
19 |
-
$this->_group
|
20 |
Â
$this->_website = $this->getRequest()->getParam('website');
|
21 |
Â
$this->setTemplate('connector/dashboard/tabs/data.phtml');
|
22 |
Â
}
|
@@ -30,10 +32,20 @@ class Dotdigitalgroup_Email_Block_Adminhtml_Dashboard_Tabs_Analysis_Sales extend
|
|
30 |
Â
protected function _prepareLayout()
|
31 |
Â
{
|
32 |
Â
$lifetimeSales = $this->getSalesInformationForTab();
|
33 |
-
$this->addTotal(
|
34 |
-
|
35 |
-
|
36 |
-
$this->addTotal(
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
37 |
Â
}
|
38 |
Â
|
39 |
Â
/**
|
@@ -43,8 +55,13 @@ class Dotdigitalgroup_Email_Block_Adminhtml_Dashboard_Tabs_Analysis_Sales extend
|
|
43 |
Â
*/
|
44 |
Â
protected function getSalesInformationForTab()
|
45 |
Â
{
|
46 |
-
$orderAnalysisModel = Mage::getModel(
|
47 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
48 |
Â
}
|
49 |
Â
|
50 |
Â
public function getTitle()
|
1 |
Â
<?php
|
2 |
Â
|
3 |
+
class Dotdigitalgroup_Email_Block_Adminhtml_Dashboard_Tabs_Analysis_Sales
|
4 |
+
extends Dotdigitalgroup_Email_Block_Adminhtml_Dashboard_Tabs_Analysis
|
5 |
Â
{
|
6 |
+
|
7 |
Â
protected $_store = 0;
|
8 |
Â
protected $_group = 0;
|
9 |
Â
protected $_website = 0;
|
17 |
Â
{
|
18 |
Â
parent::_construct();
|
19 |
Â
|
20 |
+
$this->_store = $this->getRequest()->getParam('store');
|
21 |
+
$this->_group = $this->getRequest()->getParam('group');
|
22 |
Â
$this->_website = $this->getRequest()->getParam('website');
|
23 |
Â
$this->setTemplate('connector/dashboard/tabs/data.phtml');
|
24 |
Â
}
|
32 |
Â
protected function _prepareLayout()
|
33 |
Â
{
|
34 |
Â
$lifetimeSales = $this->getSalesInformationForTab();
|
35 |
+
$this->addTotal(
|
36 |
+
$this->__('Total Sales Revenue'), $lifetimeSales->getLifetime()
|
37 |
+
);
|
38 |
+
$this->addTotal(
|
39 |
+
$this->__('Average Order Value'), $lifetimeSales->getAverage()
|
40 |
+
);
|
41 |
+
$this->addTotal(
|
42 |
+
$this->__('Total Number Of Orders'),
|
43 |
+
$lifetimeSales->getTotalCount(), true
|
44 |
+
);
|
45 |
+
$this->addTotal(
|
46 |
+
$this->__('Average Orders Created Per Day'),
|
47 |
+
$lifetimeSales->getDayCount(), true
|
48 |
+
);
|
49 |
Â
}
|
50 |
Â
|
51 |
Â
/**
|
55 |
Â
*/
|
56 |
Â
protected function getSalesInformationForTab()
|
57 |
Â
{
|
58 |
+
$orderAnalysisModel = Mage::getModel(
|
59 |
+
'ddg_automation/adminhtml_dashboard_tabs_analysis_orders'
|
60 |
+
);
|
61 |
+
|
62 |
+
return $orderAnalysisModel->getLifetimeSales(
|
63 |
+
$this->_store, $this->_website, $this->_group
|
64 |
+
);
|
65 |
Â
}
|
66 |
Â
|
67 |
Â
public function getTitle()
|
@@ -1,7 +1,9 @@
|
|
1 |
Â
<?php
|
2 |
Â
|
3 |
-
class Dotdigitalgroup_Email_Block_Adminhtml_Dashboard_Tabs_Analysis_Subscriber
|
Â
|
|
4 |
Â
{
|
Â
|
|
5 |
Â
protected $_store = 0;
|
6 |
Â
protected $_group = 0;
|
7 |
Â
protected $_website = 0;
|
@@ -15,8 +17,8 @@ class Dotdigitalgroup_Email_Block_Adminhtml_Dashboard_Tabs_Analysis_Subscriber e
|
|
15 |
Â
{
|
16 |
Â
parent::_construct();
|
17 |
Â
|
18 |
-
$this->_store
|
19 |
-
$this->_group
|
20 |
Â
$this->_website = $this->getRequest()->getParam('website');
|
21 |
Â
$this->setTemplate('connector/dashboard/tabs/data.phtml');
|
22 |
Â
}
|
@@ -30,9 +32,18 @@ class Dotdigitalgroup_Email_Block_Adminhtml_Dashboard_Tabs_Analysis_Subscriber e
|
|
30 |
Â
protected function _prepareLayout()
|
31 |
Â
{
|
32 |
Â
$lifetimeSubscribers = $this->getSubscriberInformationForTab();
|
33 |
-
$this->addTotal(
|
34 |
-
|
35 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
36 |
Â
}
|
37 |
Â
|
38 |
Â
/**
|
@@ -42,8 +53,13 @@ class Dotdigitalgroup_Email_Block_Adminhtml_Dashboard_Tabs_Analysis_Subscriber e
|
|
42 |
Â
*/
|
43 |
Â
protected function getSubscriberInformationForTab()
|
44 |
Â
{
|
45 |
-
$subscriberAnalysisModel = Mage::getModel(
|
46 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
47 |
Â
}
|
48 |
Â
|
49 |
Â
/**
|
1 |
Â
<?php
|
2 |
Â
|
3 |
+
class Dotdigitalgroup_Email_Block_Adminhtml_Dashboard_Tabs_Analysis_Subscriber
|
4 |
+
extends Dotdigitalgroup_Email_Block_Adminhtml_Dashboard_Tabs_Analysis
|
5 |
Â
{
|
6 |
+
|
7 |
Â
protected $_store = 0;
|
8 |
Â
protected $_group = 0;
|
9 |
Â
protected $_website = 0;
|
17 |
Â
{
|
18 |
Â
parent::_construct();
|
19 |
Â
|
20 |
+
$this->_store = $this->getRequest()->getParam('store');
|
21 |
+
$this->_group = $this->getRequest()->getParam('group');
|
22 |
Â
$this->_website = $this->getRequest()->getParam('website');
|
23 |
Â
$this->setTemplate('connector/dashboard/tabs/data.phtml');
|
24 |
Â
}
|
32 |
Â
protected function _prepareLayout()
|
33 |
Â
{
|
34 |
Â
$lifetimeSubscribers = $this->getSubscriberInformationForTab();
|
35 |
+
$this->addTotal(
|
36 |
+
$this->__('Total Number Of Subscribers'),
|
37 |
+
$lifetimeSubscribers->getTotalSubscriber(), true
|
38 |
+
);
|
39 |
+
$this->addTotal(
|
40 |
+
$this->__('Subscribers Who Are Also Customers'),
|
41 |
+
$lifetimeSubscribers->getTotalSubscriberCustomer(), true
|
42 |
+
);
|
43 |
+
$this->addTotal(
|
44 |
+
$this->__('Average Subscribers Created Per Day'),
|
45 |
+
$lifetimeSubscribers->getSubscribersPerDay(), true
|
46 |
+
);
|
47 |
Â
}
|
48 |
Â
|
49 |
Â
/**
|
53 |
Â
*/
|
54 |
Â
protected function getSubscriberInformationForTab()
|
55 |
Â
{
|
56 |
+
$subscriberAnalysisModel = Mage::getModel(
|
57 |
+
'ddg_automation/adminhtml_dashboard_tabs_analysis_subscriber'
|
58 |
+
);
|
59 |
+
|
60 |
+
return $subscriberAnalysisModel->getLifetimeSubscribers(
|
61 |
+
$this->_store, $this->_website, $this->_group
|
62 |
+
);
|
63 |
Â
}
|
64 |
Â
|
65 |
Â
/**
|
@@ -1,106 +1,109 @@
|
|
1 |
Â
<?php
|
2 |
Â
|
3 |
-
class Dotdigitalgroup_Email_Block_Adminhtml_Dashboard_Tabs_General
|
Â
|
|
4 |
Â
{
|
5 |
-
protected $group = array();
|
6 |
Â
|
7 |
-
|
8 |
-
* Set the template.
|
9 |
-
*/
|
10 |
-
public function _construct()
|
11 |
-
{
|
12 |
-
$this->initiateGroupArray();
|
13 |
-
parent::_construct();
|
14 |
-
$this->setTemplate('connector/dashboard/tabs/general/index.phtml');
|
15 |
-
}
|
16 |
Â
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
if ($store = $this->getRequest()->getParam('store')) {
|
27 |
-
$website = Mage::app()->getStore($store)->getWebsite();
|
28 |
-
} elseif ($this->getRequest()->getParam('website')) {
|
29 |
-
$website = $this->getRequest()->getParam('website');
|
30 |
-
}
|
31 |
-
$apiUsername = Mage::helper('ddg')->getApiUsername($website);
|
32 |
-
$apiPassword = Mage::helper('ddg')->getApiPassword($website);
|
33 |
-
$data = Mage::getModel('ddg_automation/apiconnector_client')
|
34 |
-
->setApiUsername($apiUsername)
|
35 |
-
->setApiPassword($apiPassword)
|
36 |
-
->getAccountInfo();
|
37 |
Â
|
38 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
39 |
Â
$this->prepareGroupArray($data);
|
Â
|
|
Â
|
|
Â
|
|
40 |
Â
|
41 |
-
|
Â
|
|
42 |
Â
|
43 |
-
|
44 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
45 |
Â
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
Â
|
|
Â
|
|
54 |
Â
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
}
|
65 |
Â
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
'MainEmail' => $this->__('Not Available'),
|
73 |
-
'AvailableEmailSendsCredits' => $this->__('Not Available')
|
74 |
-
);
|
75 |
-
$this->group['data'] = array(
|
76 |
-
'Title' => 'Data',
|
77 |
-
'TransactionalDataAllowanceInMegabytes' => $this->__('Not Available'),
|
78 |
-
'TransactionalDataUsageInMegabytes' => $this->__('Not Available')
|
79 |
-
);
|
80 |
-
$this->group['api'] = array(
|
81 |
-
'Title' => 'Api',
|
82 |
-
'APILocale' => $this->__('Not Available'),
|
83 |
-
'ApiCallsRemaining' => $this->__('Not Available')
|
84 |
-
);
|
85 |
-
}
|
86 |
Â
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
Â
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
Â
}
|
1 |
Â
<?php
|
2 |
Â
|
3 |
+
class Dotdigitalgroup_Email_Block_Adminhtml_Dashboard_Tabs_General
|
4 |
+
extends Mage_Adminhtml_Block_Dashboard_Bar
|
5 |
Â
{
|
Â
|
|
6 |
Â
|
7 |
+
public $group = array();
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
8 |
Â
|
9 |
+
/**
|
10 |
+
* Set the template.
|
11 |
+
*/
|
12 |
+
public function _construct()
|
13 |
+
{
|
14 |
+
$this->initiateGroupArray();
|
15 |
+
parent::_construct();
|
16 |
+
$this->setTemplate('connector/dashboard/tabs/general/index.phtml');
|
17 |
+
}
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
18 |
Â
|
19 |
+
/**
|
20 |
+
* Prepare the layout.
|
21 |
+
*
|
22 |
+
* @return Mage_Core_Block_Abstract|void
|
23 |
+
* @throws Exception
|
24 |
+
*/
|
25 |
+
protected function _prepareLayout()
|
26 |
+
{
|
27 |
+
$website = 0;
|
28 |
+
if ($store = $this->getRequest()->getParam('store')) {
|
29 |
+
$website = Mage::app()->getStore($store)->getWebsite();
|
30 |
+
} elseif ($this->getRequest()->getParam('website')) {
|
31 |
+
$website = $this->getRequest()->getParam('website');
|
32 |
+
}
|
33 |
+
$apiUsername = Mage::helper('ddg')->getApiUsername($website);
|
34 |
+
$apiPassword = Mage::helper('ddg')->getApiPassword($website);
|
35 |
+
$data = Mage::getModel('ddg_automation/apiconnector_client')
|
36 |
+
->setApiUsername($apiUsername)
|
37 |
+
->setApiPassword($apiPassword)
|
38 |
+
->getAccountInfo();
|
39 |
+
|
40 |
+
if (isset($data->id)) {
|
41 |
Â
$this->prepareGroupArray($data);
|
42 |
+
}
|
43 |
+
|
44 |
+
$this->_setChild();
|
45 |
Â
|
46 |
+
parent::_prepareLayout();
|
47 |
+
}
|
48 |
Â
|
49 |
+
protected function _setChild()
|
50 |
+
{
|
51 |
+
foreach ($this->group as $key => $data) {
|
52 |
+
$this->setChild(
|
53 |
+
$key,
|
54 |
+
$this->getLayout()->createBlock(
|
55 |
+
'ddg_automation/adminhtml_dashboard_tabs_general_data', '',
|
56 |
+
$data
|
57 |
+
)
|
58 |
+
);
|
59 |
+
}
|
60 |
+
}
|
61 |
Â
|
62 |
+
protected function prepareGroupArray($data)
|
63 |
+
{
|
64 |
+
foreach ($data->properties as $one) {
|
65 |
+
foreach ($this->group as $key => $type) {
|
66 |
+
if (array_key_exists($one->name, $type)) {
|
67 |
+
$this->group[$key][$one->name] = $one->value;
|
68 |
+
}
|
69 |
+
}
|
70 |
+
}
|
71 |
+
}
|
72 |
Â
|
73 |
+
protected function initiateGroupArray()
|
74 |
+
{
|
75 |
+
$this->group['account'] = array(
|
76 |
+
'Title' => 'Account',
|
77 |
+
'Name' => $this->__('Not Available'),
|
78 |
+
'MainMobilePhoneNumber' => $this->__('Not Available'),
|
79 |
+
'MainEmail' => $this->__('Not Available'),
|
80 |
+
'AvailableEmailSendsCredits' => $this->__('Not Available')
|
81 |
+
);
|
Â
|
|
82 |
Â
|
83 |
+
$this->group['api'] = array(
|
84 |
+
'Title' => 'Api',
|
85 |
+
'APILocale' => $this->__('Not Available'),
|
86 |
+
'ApiCallsRemaining' => $this->__('Not Available')
|
87 |
+
);
|
88 |
+
}
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
89 |
Â
|
90 |
+
/**
|
91 |
+
* get Tab content title
|
92 |
+
*
|
93 |
+
* @return string
|
94 |
+
*/
|
95 |
+
public function getTitle()
|
96 |
+
{
|
97 |
+
return Mage::helper('ddg')->__("Connector Account Information");
|
98 |
+
}
|
99 |
Â
|
100 |
+
/**
|
101 |
+
* get column width
|
102 |
+
*
|
103 |
+
* @return string
|
104 |
+
*/
|
105 |
+
public function getColumnWidth()
|
106 |
+
{
|
107 |
+
return "400px;";
|
108 |
+
}
|
109 |
Â
}
|
@@ -1,13 +1,17 @@
|
|
1 |
Â
<?php
|
2 |
Â
|
3 |
-
class Dotdigitalgroup_Email_Block_Adminhtml_Dashboard_Tabs_General_Data
|
Â
|
|
4 |
Â
{
|
5 |
-
|
6 |
-
|
Â
|
|
7 |
Â
|
8 |
Â
/**
|
9 |
Â
* set template
|
Â
|
|
10 |
Â
* @param $info
|
Â
|
|
11 |
Â
* @throws Exception
|
12 |
Â
*/
|
13 |
Â
public function __construct($info = array())
|
@@ -28,7 +32,7 @@ class Dotdigitalgroup_Email_Block_Adminhtml_Dashboard_Tabs_General_Data extends
|
|
28 |
Â
*/
|
29 |
Â
protected function _prepareLayout()
|
30 |
Â
{
|
31 |
-
foreach($this->data as $key => $value){
|
32 |
Â
$this->addTotal($this->__($key), $value, true);
|
33 |
Â
}
|
34 |
Â
}
|
1 |
Â
<?php
|
2 |
Â
|
3 |
+
class Dotdigitalgroup_Email_Block_Adminhtml_Dashboard_Tabs_General_Data
|
4 |
+
extends Dotdigitalgroup_Email_Block_Adminhtml_Dashboard_Tabs_General
|
5 |
Â
{
|
6 |
+
|
7 |
+
public $data = array();
|
8 |
+
public $title = "";
|
9 |
Â
|
10 |
Â
/**
|
11 |
Â
* set template
|
12 |
+
*
|
13 |
Â
* @param $info
|
14 |
+
*
|
15 |
Â
* @throws Exception
|
16 |
Â
*/
|
17 |
Â
public function __construct($info = array())
|
32 |
Â
*/
|
33 |
Â
protected function _prepareLayout()
|
34 |
Â
{
|
35 |
+
foreach ($this->data as $key => $value) {
|
36 |
Â
$this->addTotal($this->__($key), $value, true);
|
37 |
Â
}
|
38 |
Â
}
|
@@ -4,6 +4,7 @@ class Dotdigitalgroup_Email_Block_Adminhtml_Dashboard_Tabs_Logs
|
|
4 |
Â
extends Mage_Adminhtml_Block_Widget
|
5 |
Â
implements Mage_Adminhtml_Block_Widget_Tab_Interface
|
6 |
Â
{
|
Â
|
|
7 |
Â
/**
|
8 |
Â
* Set the template.
|
9 |
Â
*/
|
@@ -18,6 +19,7 @@ class Dotdigitalgroup_Email_Block_Adminhtml_Dashboard_Tabs_Logs
|
|
18 |
Â
{
|
19 |
Â
return true;
|
20 |
Â
}
|
Â
|
|
21 |
Â
public function isHidden()
|
22 |
Â
{
|
23 |
Â
return true;
|
4 |
Â
extends Mage_Adminhtml_Block_Widget
|
5 |
Â
implements Mage_Adminhtml_Block_Widget_Tab_Interface
|
6 |
Â
{
|
7 |
+
|
8 |
Â
/**
|
9 |
Â
* Set the template.
|
10 |
Â
*/
|
19 |
Â
{
|
20 |
Â
return true;
|
21 |
Â
}
|
22 |
+
|
23 |
Â
public function isHidden()
|
24 |
Â
{
|
25 |
Â
return true;
|
@@ -1,48 +1,52 @@
|
|
1 |
Â
<?php
|
2 |
Â
|
3 |
-
class Dotdigitalgroup_Email_Block_Adminhtml_Dashboard_Tabs_Status
|
Â
|
|
Â
|
|
4 |
Â
{
|
5 |
Â
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
Â
|
|
Â
|
|
39 |
Â
* Set the template.
|
40 |
Â
*/
|
41 |
Â
public function __construct()
|
42 |
Â
{
|
43 |
Â
parent::__construct();
|
44 |
Â
|
45 |
-
|
46 |
Â
}
|
47 |
Â
|
48 |
Â
/**
|
@@ -55,273 +59,364 @@ class Dotdigitalgroup_Email_Block_Adminhtml_Dashboard_Tabs_Status extends Mage_A
|
|
55 |
Â
{
|
56 |
Â
}
|
57 |
Â
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
299 |
Â
->setMessage('Looks Great.');
|
300 |
Â
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
325 |
Â
|
326 |
Â
/**
|
327 |
Â
* Js dir
|
@@ -333,266 +428,373 @@ class Dotdigitalgroup_Email_Block_Adminhtml_Dashboard_Tabs_Status extends Mage_A
|
|
333 |
Â
*/
|
334 |
Â
$libDir = Mage::getBaseDir('lib');
|
335 |
Â
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
-
|
391 |
-
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
-
|
397 |
-
|
398 |
-
|
399 |
-
|
400 |
-
|
401 |
-
|
402 |
-
|
403 |
-
|
404 |
-
|
405 |
-
|
406 |
-
|
407 |
-
|
408 |
-
|
409 |
-
|
410 |
-
|
411 |
-
|
412 |
-
|
413 |
-
|
414 |
-
|
415 |
-
|
416 |
-
|
417 |
-
|
418 |
-
|
419 |
-
|
420 |
-
|
421 |
-
|
422 |
-
|
423 |
-
|
424 |
-
|
425 |
-
|
426 |
-
|
427 |
-
|
428 |
-
|
429 |
-
|
430 |
-
|
431 |
-
|
432 |
-
|
433 |
-
|
434 |
-
|
435 |
-
|
436 |
-
|
437 |
-
|
438 |
-
|
439 |
-
|
440 |
-
|
441 |
-
|
442 |
-
|
443 |
-
|
444 |
-
|
445 |
-
|
446 |
-
|
447 |
-
|
448 |
-
|
449 |
-
|
450 |
-
|
451 |
-
|
452 |
-
|
453 |
-
|
454 |
-
|
455 |
-
|
456 |
-
|
457 |
-
|
458 |
-
|
459 |
-
|
460 |
-
|
461 |
-
|
462 |
-
|
463 |
-
|
464 |
-
|
465 |
-
|
466 |
-
|
467 |
-
|
468 |
-
|
469 |
-
|
470 |
-
|
471 |
-
|
472 |
-
|
473 |
-
|
474 |
-
|
475 |
-
|
476 |
-
|
477 |
-
|
478 |
-
|
479 |
-
|
480 |
-
|
481 |
-
|
482 |
-
|
483 |
-
|
484 |
-
|
485 |
-
|
486 |
-
|
487 |
-
|
488 |
-
|
489 |
-
|
490 |
-
|
491 |
-
|
492 |
-
|
493 |
-
|
494 |
-
|
495 |
-
|
496 |
-
|
497 |
-
|
498 |
-
|
499 |
-
|
500 |
-
|
501 |
-
|
502 |
-
|
503 |
-
|
504 |
-
|
505 |
-
|
506 |
-
|
507 |
-
|
508 |
-
|
509 |
-
|
510 |
-
|
511 |
-
|
512 |
-
|
513 |
-
|
514 |
-
|
515 |
-
|
516 |
-
|
517 |
-
|
518 |
-
|
519 |
-
|
520 |
-
|
521 |
-
|
522 |
-
|
523 |
-
|
524 |
-
|
525 |
-
|
526 |
-
|
527 |
-
|
528 |
-
|
529 |
-
|
530 |
-
|
531 |
-
|
532 |
-
|
533 |
-
|
534 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
535 |
Â
->useOnlySubscribed()
|
536 |
Â
->addStoreFilter($storeIds)
|
537 |
-
|
538 |
-
|
539 |
-
|
540 |
-
|
541 |
-
|
542 |
-
|
543 |
-
|
544 |
-
|
545 |
-
|
546 |
-
|
547 |
-
|
548 |
-
|
549 |
-
|
550 |
-
|
551 |
-
|
552 |
-
|
553 |
-
|
554 |
-
|
555 |
-
|
556 |
-
|
557 |
-
|
558 |
-
|
559 |
-
|
560 |
-
|
561 |
-
|
562 |
-
|
563 |
-
|
564 |
-
|
565 |
-
|
566 |
-
|
567 |
-
|
568 |
-
|
569 |
-
|
570 |
-
|
571 |
-
|
572 |
-
|
573 |
-
|
574 |
-
|
575 |
-
|
576 |
-
|
577 |
-
|
578 |
-
|
579 |
-
|
580 |
-
|
581 |
-
|
582 |
-
|
583 |
-
|
584 |
-
|
585 |
-
|
586 |
-
|
587 |
-
|
588 |
-
|
589 |
-
|
590 |
-
|
591 |
-
|
592 |
-
|
593 |
-
|
594 |
-
|
595 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
596 |
Â
|
597 |
Â
//check for wishlist program
|
598 |
Â
if ($wishlistProgram) {
|
@@ -601,15 +803,19 @@ class Dotdigitalgroup_Email_Block_Adminhtml_Dashboard_Tabs_Status extends Mage_A
|
|
601 |
Â
|
602 |
Â
//set the status as failed
|
603 |
Â
$resultContent->setStyle(self::CONNECTOR_DASHBOARD_FAILED)
|
604 |
-
->setMessage(
|
Â
|
|
Â
|
|
605 |
Â
|
606 |
-
$disableWishlist = Mage::helper(
|
Â
|
|
607 |
Â
'path' => 'XML_PATH_CONNECTOR_AUTOMATION_STUDIO_WISHLIST',
|
608 |
Â
'value' => '0',
|
609 |
Â
'website' => $website->getId()
|
610 |
Â
)
|
611 |
Â
);
|
612 |
-
$disableWishlist = 'Deactivated! <a href="'
|
Â
|
|
613 |
Â
|
614 |
Â
} else {
|
615 |
Â
|
@@ -624,529 +830,796 @@ class Dotdigitalgroup_Email_Block_Adminhtml_Dashboard_Tabs_Status extends Mage_A
|
|
624 |
Â
|
625 |
Â
//set the status as failed
|
626 |
Â
$resultContent->setStyle(self::CONNECTOR_DASHBOARD_FAILED)
|
627 |
-
->setMessage(
|
Â
|
|
Â
|
|
628 |
Â
|
629 |
-
$disableOrder = Mage::helper(
|
Â
|
|
630 |
Â
'path' => 'XML_PATH_CONNECTOR_AUTOMATION_STUDIO_ORDER',
|
631 |
Â
'value' => '0',
|
632 |
Â
'website' => $website->getId()
|
633 |
Â
)
|
634 |
Â
);
|
635 |
-
$disableOrder = 'Deactivated! <a href="' . $disableOrder
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
636 |
Â
|
637 |
-
|
Â
|
|
638 |
Â
|
639 |
-
$disableOrder = $orderProgram->status;
|
640 |
-
}
|
641 |
-
}
|
642 |
Â
|
643 |
-
|
644 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
645 |
Â
|
646 |
-
|
Â
|
|
647 |
Â
|
648 |
-
|
649 |
-
|
650 |
-
->setMessage(' Consider to disable not active programs');
|
651 |
Â
|
652 |
-
|
653 |
-
|
654 |
-
|
655 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
656 |
Â
)
|
657 |
Â
);
|
658 |
-
$disableReviews = 'Deactivated! <a href="' . $disableReviews . '">click</a> to disable';
|
659 |
-
|
660 |
-
} else {
|
661 |
-
|
662 |
-
$disableReviews = $reviewsProgram->status;
|
663 |
-
}
|
664 |
Â
}
|
Â
|
|
665 |
Â
|
666 |
-
|
667 |
-
|
668 |
Â
|
669 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
670 |
Â
|
671 |
-
|
672 |
-
|
673 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
674 |
Â
|
675 |
-
|
676 |
-
|
677 |
-
|
678 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
679 |
Â
)
|
680 |
Â
);
|
681 |
-
$disableGuestOrder = 'Deactivated! <a href="' . $disableGuestOrder . '">click</a> to disable';
|
682 |
-
|
683 |
-
} else {
|
684 |
-
|
685 |
-
$disableGuestOrder = $guestOrderProgram->status;
|
686 |
-
}
|
687 |
-
}
|
688 |
-
|
689 |
-
//check for customer program
|
690 |
-
if ($cusProgram) {
|
691 |
-
|
692 |
-
if ($cusProgram->status != 'Active') {
|
693 |
-
|
694 |
-
//set the status as failed
|
695 |
-
$resultContent->setStyle(self::CONNECTOR_DASHBOARD_FAILED)
|
696 |
-
->setMessage(' Consider to disable not active programs');
|
697 |
-
|
698 |
-
$disableCustomer = Mage::helper( 'adminhtml' )->getUrl( '*/connector/enablewebsiteconfiguration', array(
|
699 |
-
'path' => 'XML_PATH_CONNECTOR_AUTOMATION_STUDIO_CUSTOMER',
|
700 |
-
'value' => '0',
|
701 |
-
'website' => $website->getId()
|
702 |
-
)
|
703 |
-
);
|
704 |
-
$disableCustomer = 'Deactivated! <a href="' . $disableCustomer . '">click</a> to disable';
|
705 |
-
|
706 |
-
} else {
|
707 |
-
|
708 |
-
$disableCustomer = $cusProgram->status;
|
709 |
-
}
|
710 |
-
}
|
711 |
-
|
712 |
-
//check for subscriber program
|
713 |
-
if ($subProgram) {
|
714 |
-
|
715 |
-
if ($subProgram->status != 'Active') {
|
716 |
-
// set the status failed
|
717 |
-
$resultContent->setStyle(self::CONNECTOR_DASHBOARD_FAILED)
|
718 |
-
->setMessage(' Consider to disable not active programs');
|
719 |
-
|
720 |
-
//link to disbale config
|
721 |
-
$disableSubscriber = Mage::helper( 'adminhtml' )->getUrl( '*/connector/enablewebsiteconfiguration', array(
|
722 |
-
'path' => 'XML_PATH_CONNECTOR_AUTOMATION_STUDIO_SUBSCRIBER',
|
723 |
-
'value' => '0',
|
724 |
-
'website' => $website->getId()
|
725 |
-
)
|
726 |
-
);
|
727 |
-
$disableSubscriber = 'Deactivated <a href="' . $disableSubscriber . '">click</a> to disable';
|
728 |
-
|
729 |
-
} else {
|
730 |
-
$disableSubscriber = $subProgram->status;
|
731 |
-
}
|
732 |
-
}
|
733 |
-
|
734 |
-
$tableData = array(
|
735 |
-
'Website' => $website->getName(),
|
736 |
-
'Customer Program' => (isset($cusProgram->name))? $cusProgram->name : 'Disabled',
|
737 |
-
'Customer Status' => (isset($cusProgram->status))? $disableCustomer : '',
|
738 |
-
'Subscriber Program' => (isset($subProgram->name))? $subProgram->name : 'Disabled',
|
739 |
-
'Subscriber Status' => (isset($subProgram->status))? $disableSubscriber : '',
|
740 |
-
'Order Program' => (isset($orderProgram->name))? $orderProgram->name : 'Disabled',
|
741 |
-
'Order Status' => (isset($orderProgram->status))? $disableOrder : '',
|
742 |
-
'Guest Order Program' => (isset($guestOrderProgram->name))? $guestOrderProgram->name : 'Disabled',
|
743 |
-
'Guest Order Status' => (isset($guestOrderProgram->status))? $disableGuestOrder : '',
|
744 |
-
'Review Program' => (isset($reviewsProgram->name))? $reviewsProgram->name : 'Disabled',
|
745 |
-
'Review Status' => (isset($reviewsProgram->status))? $disableReviews : '',
|
746 |
-
'Wishlist Program' => (isset($wishlistProgram->name))? $wishlistProgram->name : 'Disabled',
|
747 |
-
'Wishlist Status' => (isset($wishlistProgram->status))? $disableWishlist : '',
|
748 |
-
);
|
749 |
-
|
750 |
-
//set the content with table data
|
751 |
-
$resultContent->setTable($tableData);
|
752 |
-
|
753 |
-
}
|
754 |
-
|
755 |
-
return $resultContent;
|
756 |
-
}
|
757 |
-
|
758 |
-
/**
|
759 |
-
* Abandoned carts status.
|
760 |
-
* @return Dotdigitalgroup_Email_Model_Adminhtml_Dashboard_Content
|
761 |
-
*/
|
762 |
-
public function abandonedCartsEnabled()
|
763 |
-
{
|
764 |
-
$resultContent = Mage::getModel('ddg_automation/adminhtml_dashboard_content');
|
765 |
-
|
766 |
-
$resultContent->setStyle(self::CONNECTOR_DASHBOARD_PASSED)
|
767 |
-
->setTitle('Abandoned Carts Status : ')
|
768 |
-
->setMessage('Looks Great.');
|
769 |
-
|
770 |
-
foreach ( Mage::app()->getWebsites() as $website ) {
|
771 |
-
$websiteName = $website->getName();
|
772 |
-
$abandonedCusomer_1 = ($website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_ABANDONED_CARTS_ENABLED_1))? true :
|
773 |
-
'Disabled!';
|
774 |
-
$abandonedCusomer_2 = ($website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_ABANDONED_CARTS_ENABLED_2))? true :
|
775 |
-
'Disabled!';
|
776 |
-
$abandonedCusomer_3 = ($website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_ABANDONED_CARTS_ENABLED_3))? true :
|
777 |
-
'Disabled!';
|
778 |
-
$abandonedGuest_1 = ($website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_GUEST_ABANDONED_CARTS_ENABLED_1))? true :
|
779 |
-
'Disabled!';
|
780 |
-
$abandonedGuest_2 = ($website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_GUEST_ABANDONED_CARTS_ENABLED_2))? true :
|
781 |
-
'Disabled!';
|
782 |
-
$abandonedGuest_3 = ($website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_GUEST_ABANDONED_CARTS_ENABLED_3))? true :
|
783 |
-
'Disabled!';
|
784 |
-
|
785 |
-
if ($abandonedCusomer_1 !== true || $abandonedCusomer_2 !== true || $abandonedCusomer_3 !== true || $abandonedGuest_1 !== true || $abandonedGuest_2 !== true || $abandonedGuest_3 !== true){
|
786 |
-
//customer abandoned links to enable
|
787 |
-
$customer1 = Mage::helper('adminhtml')->getUrl('*/connector/enablewebsiteconfiguration', array('path' => 'XML_PATH_CONNECTOR_CUSTOMER_ABANDONED_CARTS_ENABLED_1', 'website' => $website->getId()));
|
788 |
-
$customer2 = Mage::helper('adminhtml')->getUrl('*/connector/enablewebsiteconfiguration', array('path' => 'XML_PATH_CONNECTOR_CUSTOMER_ABANDONED_CARTS_ENABLED_2', 'website' => $website->getId()));
|
789 |
-
$customer3 = Mage::helper('adminhtml')->getUrl('*/connector/enablewebsiteconfiguration', array('path' => 'XML_PATH_CONNECTOR_CUSTOMER_ABANDONED_CARTS_ENABLED_3', 'website' => $website->getId()));
|
790 |
-
//guests abandoned links to enable
|
791 |
-
$guest1 = Mage::helper('adminhtml')->getUrl('*/connector/enablewebsiteconfiguration', array('path' => 'XML_PATH_CONNECTOR_GUEST_ABANDONED_CARTS_ENABLED_1', 'website' => $website->getId()));
|
792 |
-
$guest2 = Mage::helper('adminhtml')->getUrl('*/connector/enablewebsiteconfiguration', array('path' => 'XML_PATH_CONNECTOR_GUEST_ABANDONED_CARTS_ENABLED_2', 'website' => $website->getId()));
|
793 |
-
$guest3 = Mage::helper('adminhtml')->getUrl('*/connector/enablewebsiteconfiguration', array('path' => 'XML_PATH_CONNECTOR_GUEST_ABANDONED_CARTS_ENABLED_3', 'website' => $website->getId()));
|
794 |
-
|
795 |
-
|
796 |
-
$resultContent->setStyle( self::CONNECTOR_DASHBOARD_FAILED)
|
797 |
-
->setMessage('Don\'t forget to map')
|
798 |
-
->setTable(array(
|
799 |
-
'Website' => $websiteName,
|
800 |
-
'Customer Abandoned 1' => ($abandonedCusomer_1 !== true)? $abandonedCusomer_1 . ' <a href="' . $customer1 . '">enable</a>' : 'Enabled',
|
801 |
-
'Customer Abandoned 2' => ($abandonedCusomer_2 !== true)? $abandonedCusomer_2 . ' <a href="' . $customer2 . '">enable</a>' : 'Enabled',
|
802 |
-
'Customer Abandoned 3' => ($abandonedCusomer_3 !== true)? $abandonedCusomer_3 . ' <a href="' . $customer3 . '">enable</a>' : 'Enabled',
|
803 |
-
'Guest Abandoned 1' => ($abandonedGuest_1 !== true)? $abandonedGuest_1 . ' <a href="' . $guest1 . '">enable</a>' : 'Enabled',
|
804 |
-
'Guest Abandoned 2' => ($abandonedGuest_2 !== true)? $abandonedGuest_2 . ' <a href="' . $guest2 . '">enable</a>' : 'Enabled',
|
805 |
-
'Guest Abandoned 3' => ($abandonedGuest_3 !== true)? $abandonedGuest_3 . ' <a href="' . $guest3 . '">enable</a>' : 'Enabled',
|
806 |
-
));
|
807 |
-
}
|
808 |
-
}
|
809 |
-
|
810 |
-
return $resultContent;
|
811 |
-
}
|
812 |
-
|
813 |
-
/**
|
814 |
-
* Crazy mapping checking.
|
815 |
-
* @return Dotdigitalgroup_Email_Model_Adminhtml_Dashboard_Content
|
816 |
-
*/
|
817 |
-
public function dataFieldMapped()
|
818 |
-
{
|
819 |
-
$resultContent = Mage::getModel('ddg_automation/adminhtml_dashboard_content');
|
820 |
-
|
821 |
-
$resultContent->setStyle(self::CONNECTOR_DASHBOARD_PASSED)
|
822 |
-
->setTitle('Default Datafields Mapped Status : ')
|
823 |
-
->setMessage('All Datafields Are Mapped.');
|
824 |
-
|
825 |
-
foreach ( Mage::app()->getWebsites() as $website ) {
|
826 |
-
$passed = true;
|
827 |
-
$mapped = 0;
|
828 |
-
$tableData = array();
|
829 |
-
//website name for table data
|
830 |
-
$websiteName = $website->getName();
|
831 |
-
$tableData['Website'] = $websiteName;
|
832 |
-
if (! $website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_ID)) {
|
833 |
-
$passed = false;
|
834 |
-
$mapped++;
|
835 |
-
}
|
836 |
-
if (! $website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_FIRSTNAME)) {
|
837 |
-
$passed = false;
|
838 |
-
$mapped++;
|
839 |
-
}
|
840 |
-
if (! $website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_LASTNAME)) {
|
841 |
-
$passed = false;
|
842 |
-
$mapped++;
|
843 |
-
}
|
844 |
-
if (! $website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_DOB)) {
|
845 |
-
$passed = false;
|
846 |
-
$mapped++;
|
847 |
-
}
|
848 |
-
if (! $website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_GENDER)) {
|
849 |
-
$passed = false;
|
850 |
-
$mapped++;
|
851 |
-
}
|
852 |
-
if (! $website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_WEBSITE_NAME)) {
|
853 |
-
$passed = false;
|
854 |
-
$mapped++;
|
855 |
-
}
|
856 |
-
if (! $website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_STORE_NAME)) {
|
857 |
-
$passed = false;
|
858 |
-
$mapped++;
|
859 |
-
}
|
860 |
-
if (! $website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_CREATED_AT)) {
|
861 |
-
$passed = false;
|
862 |
-
$mapped++;
|
863 |
-
}
|
864 |
-
if (! $website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_LAST_LOGGED_DATE)) {
|
865 |
-
$passed = false;
|
866 |
-
$mapped++;
|
867 |
-
}
|
868 |
-
if (! $website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_CUSTOMER_GROUP)) {
|
869 |
-
$passed = false;
|
870 |
-
$mapped++;
|
871 |
-
}
|
872 |
-
if (! $website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_REVIEW_COUNT)) {
|
873 |
-
$passed = false;
|
874 |
-
$mapped++;
|
875 |
-
}
|
876 |
-
if (! $website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_LAST_REVIEW_DATE)) {
|
877 |
-
$passed = false;
|
878 |
-
$mapped++;
|
879 |
-
}
|
880 |
-
if (! $website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_BILLING_ADDRESS_1)) {
|
881 |
-
$passed = false;
|
882 |
-
$mapped++;
|
883 |
-
}
|
884 |
-
if (! $website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_BILLING_ADDRESS_2)) {
|
885 |
-
$passed = false;
|
886 |
-
$mapped++;
|
887 |
-
}
|
888 |
-
if (! $website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_BILLING_CITY)) {
|
889 |
-
$passed = false;
|
890 |
-
$mapped++;
|
891 |
-
}
|
892 |
-
if (! $website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_BILLING_STATE)) {
|
893 |
-
$passed = false;
|
894 |
-
$mapped++;
|
895 |
-
}
|
896 |
-
if (! $website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_BILLING_COUNTRY)) {
|
897 |
-
$passed = false;
|
898 |
-
$mapped++;
|
899 |
-
}
|
900 |
-
if (! $website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_BILLING_POSTCODE)) {
|
901 |
-
$passed = false;
|
902 |
-
$mapped++;
|
903 |
-
}
|
904 |
-
if (! $website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_BILLING_TELEPHONE)) {
|
905 |
-
$passed = false;
|
906 |
-
$mapped++;
|
907 |
-
}
|
908 |
-
if (! $website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_DELIVERY_ADDRESS_1)) {
|
909 |
-
$passed = false;
|
910 |
-
$mapped++;
|
911 |
-
}
|
912 |
-
if (! $website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_DELIVERY_ADDRESS_2)) {
|
913 |
-
$passed = false;
|
914 |
-
$mapped++;
|
915 |
-
}
|
916 |
-
if (! $website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_DELIVERY_CITY)) {
|
917 |
-
$passed = false;
|
918 |
-
$mapped++;
|
919 |
-
}
|
920 |
-
if (! $website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_DELIVERY_STATE)) {
|
921 |
-
$passed = false;
|
922 |
-
$mapped++;
|
923 |
-
}
|
924 |
-
if (! $website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_DELIVERY_COUNTRY)) {
|
925 |
-
$passed = false;
|
926 |
-
$mapped++;
|
927 |
-
}
|
928 |
-
if (! $website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_DELIVERY_POSTCODE)) {
|
929 |
-
$passed = false;
|
930 |
-
$mapped++;
|
931 |
-
}
|
932 |
-
if (! $website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_DELIVERY_TELEPHONE)) {
|
933 |
-
$passed = false;
|
934 |
-
$mapped++;
|
935 |
-
}
|
936 |
-
if (! $website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_TOTAL_NUMBER_ORDER)) {
|
937 |
-
$passed = false;
|
938 |
-
$mapped++;
|
939 |
-
}
|
940 |
-
if (! $website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_AOV)) {
|
941 |
-
$passed = false;
|
942 |
-
$mapped++;
|
943 |
-
}
|
944 |
-
if (! $website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_TOTAL_SPEND)) {
|
945 |
-
$passed = false;
|
946 |
-
$mapped++;
|
947 |
-
}
|
948 |
-
if (! $website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_LAST_ORDER_DATE)) {
|
949 |
-
$passed = false;
|
950 |
-
$mapped++;
|
951 |
-
}
|
952 |
-
if (! $website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_LAST_ORDER_ID)) {
|
953 |
-
$passed = false;
|
954 |
-
$mapped++;
|
955 |
-
}
|
956 |
-
if (! $website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_MAPPING_CUSTOMER_TOTALREFUND)) {
|
957 |
-
$passed = false;
|
958 |
-
$mapped++;
|
959 |
-
}
|
960 |
-
if (! $website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_SUBSCRIBER_STATUS)) {
|
961 |
Â
$passed = false;
|
962 |
-
$mapped++;
|
963 |
Â
}
|
964 |
-
|
965 |
-
|
966 |
-
|
967 |
-
|
968 |
-
|
969 |
-
|
970 |
-
|
971 |
-
|
972 |
-
$resultContent->setTable($tableData);
|
973 |
-
}
|
974 |
-
|
975 |
-
return $resultContent;
|
976 |
-
}
|
977 |
-
|
978 |
-
|
979 |
-
/**
|
980 |
-
* Validate API Credentials.
|
981 |
-
* @return Dotdigitalgroup_Email_Model_Adminhtml_Dashboard_Content
|
982 |
-
*/
|
983 |
-
public function validApiCredentials()
|
984 |
-
{
|
985 |
-
$resultContent = Mage::getModel('ddg_automation/adminhtml_dashboard_content');
|
986 |
-
$resultContent->setStyle(self::CONNECTOR_DASHBOARD_PASSED)
|
987 |
-
->setTitle('API Credentials Status : ')
|
988 |
-
->setMessage('Valid.');
|
989 |
-
$helper = Mage::helper('ddg');
|
990 |
-
foreach ( Mage::app()->getWebsites() as $website ) {
|
991 |
-
$websiteName = $website->getName();
|
992 |
-
$websiteId = $website->getId();
|
993 |
-
|
994 |
-
$apiUsername = $helper->getApiUsername($websiteId);
|
995 |
-
$apiPassword = $helper->getApiPassword($websiteId);
|
996 |
-
|
997 |
-
$api = Mage::getModel('ddg_automation/apiconnector_test')->ajaxvalidate($apiUsername, $apiPassword);
|
998 |
-
|
999 |
-
if ($api != 'Credentials Valid.') {
|
1000 |
-
$url = Mage::helper('adminhtml')->getUrl('*/system_config/edit/section/connector_api_credentials/website/' . $website->getCode());
|
1001 |
-
|
1002 |
-
$resultContent->setStyle( self::CONNECTOR_DASHBOARD_FAILED)
|
1003 |
-
->setMessage('')
|
1004 |
-
->setTable(array(
|
1005 |
-
'Website' => $websiteName,
|
1006 |
-
'Status' => $api,
|
1007 |
-
'Fast Fix' => 'Click <a href="' . $url . '">here</a> to enter new api credentials.'
|
1008 |
-
));
|
1009 |
-
}
|
1010 |
-
}
|
1011 |
-
|
1012 |
-
return $resultContent;
|
1013 |
-
}
|
1014 |
-
|
1015 |
-
/**
|
1016 |
-
* Order sync enabled.
|
1017 |
-
* @return Dotdigitalgroup_Email_Model_Adminhtml_Dashboard_Content
|
1018 |
-
*/
|
1019 |
-
public function orderEnabled()
|
1020 |
-
{
|
1021 |
-
$resultContent = Mage::getModel('ddg_automation/adminhtml_dashboard_content');
|
1022 |
-
$resultContent->setStyle(self::CONNECTOR_DASHBOARD_PASSED)
|
1023 |
-
->setTitle('Order Sync : ')
|
1024 |
-
->setMessage('Enabled.');
|
1025 |
-
|
1026 |
-
$passed = true;
|
1027 |
-
foreach ( Mage::app()->getWebsites() as $website ) {
|
1028 |
-
$websiteName = $website->getName();
|
1029 |
-
$order = ($website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_SYNC_ORDER_ENABLED))? true :
|
1030 |
-
'Disabled!';
|
1031 |
-
|
1032 |
-
if ($order !== true){
|
1033 |
-
|
1034 |
-
$url = Mage::helper('adminhtml')->getUrl('*/connector/enablewebsiteconfiguration', array('path' => 'XML_PATH_CONNECTOR_SYNC_ORDER_ENABLED', 'website' => $website->getId()));
|
1035 |
-
$resultContent->setStyle( self::CONNECTOR_DASHBOARD_FAILED)
|
1036 |
-
->setMessage('')
|
1037 |
-
->setTable(array(
|
1038 |
-
'Website' => $websiteName,
|
1039 |
-
'Status' => $order . ' <a href="' . $url . '">enable</a>'
|
1040 |
-
));
|
1041 |
-
$passed = false;
|
1042 |
-
}
|
1043 |
-
}
|
1044 |
-
//validation failed
|
1045 |
-
if (! $passed) {
|
1046 |
-
$resultContent->setHowto(self::FAST_FIX_MESSAGE);
|
1047 |
-
}
|
1048 |
-
|
1049 |
-
return $resultContent;
|
1050 |
-
}
|
1051 |
Â
|
1052 |
Â
/**
|
1053 |
Â
* check if any custom order attribute selected
|
Â
|
|
1054 |
Â
* @return Dotdigitalgroup_Email_Model_Adminhtml_Dashboard_Content
|
1055 |
Â
*/
|
1056 |
Â
public function customOrderAttributes()
|
1057 |
Â
{
|
1058 |
-
$resultContent = Mage::getModel(
|
Â
|
|
Â
|
|
1059 |
Â
$resultContent->setStyle(self::CONNECTOR_DASHBOARD_PASSED)
|
1060 |
Â
->setTitle('Custom Order Attributes : ')
|
1061 |
Â
->setMessage('Selected.');
|
1062 |
Â
|
1063 |
-
foreach (
|
1064 |
-
$websiteName
|
1065 |
-
$customOrderAttibute = ($website->getConfig(
|
Â
|
|
Â
|
|
1066 |
Â
|
1067 |
-
if ($customOrderAttibute !== true){
|
1068 |
-
$resultContent->setStyle(
|
1069 |
-
->setTitle(
|
Â
|
|
Â
|
|
1070 |
Â
->setMessage('')
|
1071 |
-
->setTable(
|
1072 |
-
|
1073 |
-
|
1074 |
-
|
Â
|
|
Â
|
|
1075 |
Â
}
|
1076 |
Â
}
|
1077 |
Â
|
1078 |
Â
return $resultContent;
|
1079 |
Â
}
|
1080 |
Â
|
1081 |
-
|
1082 |
-
|
1083 |
-
|
1084 |
-
|
1085 |
-
|
1086 |
-
|
1087 |
-
|
1088 |
-
|
1089 |
-
|
1090 |
-
|
1091 |
-
|
1092 |
-
|
1093 |
-
|
1094 |
-
|
1095 |
-
|
1096 |
-
|
1097 |
-
|
1098 |
-
|
1099 |
-
|
1100 |
-
|
1101 |
-
|
1102 |
-
|
1103 |
-
|
1104 |
-
|
1105 |
-
|
1106 |
-
|
1107 |
-
|
1108 |
-
|
1109 |
-
|
1110 |
-
|
1111 |
-
|
1112 |
-
|
1113 |
-
|
1114 |
-
|
1115 |
-
|
1116 |
-
|
1117 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
1118 |
Â
|
1119 |
Â
/**
|
1120 |
Â
* Quote sync enabled.
|
Â
|
|
1121 |
Â
* @return Dotdigitalgroup_Email_Model_Adminhtml_Dashboard_Content
|
1122 |
Â
*/
|
1123 |
Â
public function quoteEnabled()
|
1124 |
Â
{
|
1125 |
-
$resultContent = Mage::getModel(
|
Â
|
|
Â
|
|
1126 |
Â
$resultContent->setStyle(self::CONNECTOR_DASHBOARD_PASSED)
|
1127 |
Â
->setTitle('Quote Sync : ')
|
1128 |
Â
->setMessage('Enabled.');
|
1129 |
Â
|
1130 |
Â
$passed = true;
|
1131 |
-
foreach (
|
1132 |
-
$websiteName
|
1133 |
-
$quote
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
1134 |
Â
'Disabled!';
|
1135 |
Â
|
1136 |
-
if ($quote !== true){
|
1137 |
Â
|
1138 |
-
$url = Mage::helper('adminhtml')->getUrl(
|
1139 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
1140 |
Â
->setMessage('')
|
1141 |
-
->setTable(
|
1142 |
-
|
1143 |
-
|
1144 |
-
|
Â
|
|
Â
|
|
Â
|
|
1145 |
Â
$passed = false;
|
1146 |
Â
}
|
1147 |
Â
}
|
1148 |
Â
//validation failed
|
1149 |
-
if (! $passed) {
|
1150 |
Â
$resultContent->setHowto(self::FAST_FIX_MESSAGE);
|
1151 |
Â
}
|
1152 |
Â
|
@@ -1155,27 +1628,36 @@ class Dotdigitalgroup_Email_Block_Adminhtml_Dashboard_Tabs_Status extends Mage_A
|
|
1155 |
Â
|
1156 |
Â
/**
|
1157 |
Â
* check if any custom quote attribute selected
|
Â
|
|
1158 |
Â
* @return Dotdigitalgroup_Email_Model_Adminhtml_Dashboard_Content
|
1159 |
Â
*/
|
1160 |
Â
public function customQuoteAttributes()
|
1161 |
Â
{
|
1162 |
-
$resultContent = Mage::getModel(
|
Â
|
|
Â
|
|
1163 |
Â
$resultContent->setStyle(self::CONNECTOR_DASHBOARD_PASSED)
|
1164 |
Â
->setTitle('Custom Quote Attributes : ')
|
1165 |
Â
->setMessage('Selected.');
|
1166 |
Â
|
1167 |
-
foreach (
|
1168 |
-
$websiteName
|
1169 |
-
$customQuoteAttribute = ($website->getConfig(
|
Â
|
|
Â
|
|
1170 |
Â
|
1171 |
-
if ($customQuoteAttribute !== true){
|
1172 |
-
$resultContent->setStyle(
|
1173 |
-
->setTitle(
|
Â
|
|
Â
|
|
1174 |
Â
->setMessage('')
|
1175 |
-
->setTable(
|
1176 |
-
|
1177 |
-
|
1178 |
-
|
Â
|
|
Â
|
|
1179 |
Â
}
|
1180 |
Â
}
|
1181 |
Â
|
@@ -1184,35 +1666,44 @@ class Dotdigitalgroup_Email_Block_Adminhtml_Dashboard_Tabs_Status extends Mage_A
|
|
1184 |
Â
|
1185 |
Â
/**
|
1186 |
Â
* Check if any quote are imported.
|
Â
|
|
1187 |
Â
* @return Dotdigitalgroup_Email_Model_Adminhtml_Dashboard_Content
|
1188 |
Â
*/
|
1189 |
Â
public function quoteSyncing()
|
1190 |
Â
{
|
1191 |
-
$resultContent = Mage::getModel(
|
Â
|
|
Â
|
|
1192 |
Â
$resultContent->setStyle(self::CONNECTOR_DASHBOARD_PASSED)
|
1193 |
Â
->setTitle('Quote Syncing : ')
|
1194 |
Â
->setMessage('Looks Great.');
|
1195 |
Â
|
1196 |
-
foreach (
|
1197 |
-
$websiteName
|
1198 |
-
$storeIds
|
1199 |
Â
|
1200 |
-
|
1201 |
-
|
Â
|
|
1202 |
Â
|
1203 |
Â
//number of quote marked as imported
|
1204 |
Â
$numQuotes = Mage::getModel('ddg_automation/quote')->getCollection()
|
1205 |
Â
->addFieldToFilter('imported', 1)
|
1206 |
-
->addFieldToFilter('store_id', array('in', $storeIds))->getSize(
|
Â
|
|
1207 |
Â
|
1208 |
-
if (! $numQuotes) {
|
1209 |
-
$resultContent->setStyle(
|
1210 |
-
->setTitle(
|
Â
|
|
Â
|
|
1211 |
Â
->setMessage('')
|
1212 |
-
->setTable(
|
1213 |
-
|
1214 |
-
|
1215 |
-
|
Â
|
|
Â
|
|
1216 |
Â
}
|
1217 |
Â
}
|
1218 |
Â
|
@@ -1222,517 +1713,670 @@ class Dotdigitalgroup_Email_Block_Adminhtml_Dashboard_Tabs_Status extends Mage_A
|
|
1222 |
Â
|
1223 |
Â
/**
|
1224 |
Â
* review sync enabled.
|
Â
|
|
1225 |
Â
* @return Dotdigitalgroup_Email_Model_Adminhtml_Dashboard_Content
|
1226 |
Â
* Display the transactional data for orders to be removed.
|
1227 |
Â
*/
|
1228 |
Â
public function reviewEnabled()
|
1229 |
Â
{
|
1230 |
-
$resultContent = Mage::getModel(
|
Â
|
|
Â
|
|
1231 |
Â
$resultContent->setStyle(self::CONNECTOR_DASHBOARD_PASSED)
|
1232 |
Â
->setTitle('Review Sync : ')
|
1233 |
Â
->setMessage('Enabled.');
|
1234 |
Â
|
1235 |
-
foreach (
|
1236 |
-
$websiteName
|
1237 |
-
$review
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
1238 |
Â
'Disabled';
|
1239 |
Â
|
1240 |
-
if ($review !== true){
|
1241 |
-
$url = Mage::helper('adminhtml')->getUrl(
|
1242 |
-
|
1243 |
-
|
1244 |
-
|
1245 |
-
|
1246 |
-
|
1247 |
-
|
1248 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
1249 |
Â
}
|
1250 |
Â
}
|
Â
|
|
1251 |
Â
return $resultContent;
|
1252 |
Â
}
|
1253 |
Â
|
1254 |
Â
/**
|
1255 |
Â
* Check if any reviews are imported.
|
Â
|
|
1256 |
Â
* @return Dotdigitalgroup_Email_Model_Adminhtml_Dashboard_Content
|
1257 |
Â
*/
|
1258 |
Â
public function reviewSyncing()
|
1259 |
Â
{
|
1260 |
-
$resultContent = Mage::getModel(
|
Â
|
|
Â
|
|
1261 |
Â
$resultContent->setStyle(self::CONNECTOR_DASHBOARD_PASSED)
|
1262 |
Â
->setTitle('Review Syncing : ')
|
1263 |
Â
->setMessage('Looks Great.');
|
1264 |
Â
|
1265 |
-
foreach (
|
1266 |
-
$websiteName
|
1267 |
-
$storeIds
|
1268 |
Â
|
1269 |
-
|
1270 |
-
|
Â
|
|
1271 |
Â
|
1272 |
Â
//number of reviews marked as imported
|
1273 |
-
$numReview = Mage::getModel('ddg_automation/review')->getCollection(
|
Â
|
|
1274 |
Â
->addFieldToFilter('review_imported', 1)
|
1275 |
Â
->addFieldToFilter('store_id', array('in', $storeIds))
|
1276 |
Â
->getSize();
|
1277 |
Â
|
1278 |
Â
//total reviews
|
1279 |
-
$totalReview = Mage::getModel('ddg_automation/review')
|
Â
|
|
1280 |
Â
->addFieldToFilter('store_id', array('in', $storeIds))
|
1281 |
Â
->getSize();
|
1282 |
Â
|
1283 |
Â
$tableData = array(
|
1284 |
-
'Website'
|
1285 |
Â
'Total Reviews' => $totalReview,
|
1286 |
-
'Imported'
|
1287 |
Â
);
|
1288 |
Â
|
1289 |
Â
$tableData['Status'] = 'Importing';
|
1290 |
Â
|
1291 |
-
if (! $numReview) {
|
1292 |
Â
$tableData['Status'] = 'No Imported Review Found.';
|
1293 |
Â
$resultContent->setStyle(self::CONNECTOR_DASHBOARD_FAILED)
|
1294 |
-
->setTitle(
|
Â
|
|
Â
|
|
1295 |
Â
->setMessage('');
|
1296 |
Â
}
|
1297 |
Â
$resultContent->setTable($tableData);
|
1298 |
Â
}
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
1299 |
Â
return $resultContent;
|
1300 |
Â
}
|
1301 |
Â
|
1302 |
-
|
1303 |
-
|
1304 |
-
|
1305 |
-
|
1306 |
-
|
1307 |
-
|
1308 |
-
|
1309 |
-
|
1310 |
-
|
1311 |
-
|
1312 |
-
|
1313 |
-
|
1314 |
-
|
1315 |
-
|
1316 |
-
|
1317 |
-
|
1318 |
-
|
1319 |
-
|
1320 |
-
|
1321 |
-
|
1322 |
-
|
1323 |
-
|
1324 |
-
|
1325 |
-
|
1326 |
-
|
1327 |
-
|
1328 |
-
|
1329 |
-
|
1330 |
-
|
1331 |
-
|
1332 |
-
|
1333 |
-
|
1334 |
-
|
1335 |
-
|
1336 |
-
|
1337 |
-
|
1338 |
-
|
1339 |
-
|
1340 |
-
|
1341 |
-
|
1342 |
-
|
1343 |
-
|
1344 |
-
|
1345 |
-
|
1346 |
-
|
1347 |
-
|
1348 |
-
|
1349 |
-
|
1350 |
-
|
1351 |
-
|
1352 |
-
|
1353 |
-
|
1354 |
-
|
1355 |
-
|
1356 |
-
|
1357 |
-
|
1358 |
-
|
1359 |
-
|
1360 |
-
|
1361 |
-
|
1362 |
-
|
1363 |
-
|
1364 |
-
|
1365 |
-
|
1366 |
-
|
1367 |
-
|
1368 |
-
|
1369 |
-
|
1370 |
-
|
1371 |
-
|
1372 |
-
public function conflictCheck()
|
1373 |
-
{
|
1374 |
-
$resultContent = Mage::getModel('ddg_automation/adminhtml_dashboard_content');
|
1375 |
-
$resultContent->setStyle(self::CONNECTOR_DASHBOARD_PASSED)
|
1376 |
-
->setTitle('Conflict Status : ')
|
1377 |
-
->setMessage('Looks Great.');
|
1378 |
-
|
1379 |
-
//check the module override and conflict
|
1380 |
-
$rewrites = Mage::helper('ddg/dashboard')->getRewrites();
|
1381 |
-
|
1382 |
-
|
1383 |
-
if ($rewrites === false) {
|
1384 |
-
$resultContent->setStyle(self::CONNECTOR_DASHBOARD_PASSED)
|
1385 |
-
->setMessage('No Conflict Rewrites Found.');
|
1386 |
-
} else {
|
1387 |
-
|
1388 |
-
$types = array('blocks', 'models', 'helpers');
|
1389 |
-
foreach ($types as $t) {
|
1390 |
-
|
1391 |
-
if (!empty($rewrites[$t])) {
|
1392 |
-
|
1393 |
-
$resultContent->setStyle(self::CONNECTOR_DASHBOARD_FAILED)
|
1394 |
-
->setMessage('Conflicting Rewrite Found : ');
|
1395 |
-
|
1396 |
-
foreach ($rewrites[$t] as $node => $rewriteInfo) {
|
1397 |
-
|
1398 |
-
$resultContent->setTable(array(
|
1399 |
-
'Type' => $t,
|
1400 |
-
'Class' => implode(', ', array_values($rewriteInfo['classes'])),
|
1401 |
-
'Rewrites' => '',
|
1402 |
-
'Loaded Class' => ''
|
1403 |
-
));
|
1404 |
-
}
|
1405 |
-
}
|
1406 |
-
}
|
1407 |
-
|
1408 |
-
$conflictCounter = 0;
|
1409 |
-
$tableData = array();
|
1410 |
-
foreach ($rewrites as $type => $data) {
|
1411 |
-
if (count($data) > 0 && is_array($data)) {
|
1412 |
-
|
1413 |
-
foreach ($data as $class => $rewriteClass) {
|
1414 |
-
|
1415 |
-
if (count($rewriteClass) > 1) {
|
1416 |
-
if ($this->_isInheritanceConflict($rewriteClass)) {
|
1417 |
-
|
1418 |
-
$resultContent->setTable(array(
|
1419 |
-
'Type' => $type,
|
1420 |
-
'Class' => $class,
|
1421 |
-
'Rewrites' => implode(', ', $rewriteClass['classes']),
|
1422 |
-
'Loaded Class' => $this->_getLoadedClass($type, $class),
|
1423 |
-
));
|
1424 |
-
|
1425 |
-
$conflictCounter++;
|
1426 |
-
}
|
1427 |
-
}
|
1428 |
-
}
|
1429 |
-
}
|
1430 |
-
}
|
1431 |
-
if (! empty($tableData))
|
1432 |
-
$resultContent->setTable($tableData);
|
1433 |
-
|
1434 |
-
}
|
1435 |
-
|
1436 |
-
return $resultContent;
|
1437 |
-
}
|
1438 |
-
|
1439 |
-
/**
|
1440 |
-
* Returns loaded class by type like models or blocks
|
1441 |
-
*
|
1442 |
-
* @param string $type
|
1443 |
-
* @param string $class
|
1444 |
-
* @return string
|
1445 |
-
*/
|
1446 |
-
protected function _getLoadedClass($type, $class)
|
1447 |
-
{
|
1448 |
-
switch ($type) {
|
1449 |
-
case 'blocks':
|
1450 |
-
return Mage::getConfig()->getBlockClassName($class);
|
1451 |
-
|
1452 |
-
case 'helpers':
|
1453 |
-
return Mage::getConfig()->getHelperClassName($class);
|
1454 |
-
|
1455 |
-
default:
|
1456 |
-
case 'models':
|
1457 |
-
return Mage::getConfig()->getModelClassName($class);
|
1458 |
-
break;
|
1459 |
-
}
|
1460 |
-
}
|
1461 |
-
|
1462 |
-
/**
|
1463 |
-
* Check if rewritten class has inherited the parent class.
|
1464 |
-
* If yes we have no conflict. The top class can extend every core class.
|
1465 |
-
* So we cannot check this.
|
1466 |
-
*
|
1467 |
-
* @var array $classes
|
1468 |
-
* @return bool
|
1469 |
-
*/
|
1470 |
-
protected function _isInheritanceConflict($classes)
|
1471 |
-
{
|
1472 |
-
$classes = array_reverse($classes);
|
1473 |
-
$numClases = count($classes);
|
1474 |
-
|
1475 |
-
for ($i = 0; $i < $numClases - 1; $i++) {
|
1476 |
-
try {
|
1477 |
-
if (class_exists($classes[$i])
|
1478 |
-
&& class_exists($classes[$i + 1])
|
1479 |
-
) {
|
1480 |
-
if (! is_a($classes[$i], $classes[$i + 1], true)) {
|
1481 |
-
return true;
|
1482 |
-
}
|
1483 |
-
}
|
1484 |
-
} catch (\Exception $e) {
|
1485 |
-
return true;
|
1486 |
-
}
|
1487 |
-
}
|
1488 |
-
|
1489 |
-
return false;
|
1490 |
-
}
|
1491 |
-
|
1492 |
-
/**
|
1493 |
-
* System information about the version used and the memory limits.
|
1494 |
-
*
|
1495 |
-
* @return Dotdigitalgroup_Email_Model_Adminhtml_Dashboard_Content
|
1496 |
-
*/
|
1497 |
-
public function systemInformation()
|
1498 |
-
{
|
1499 |
-
$resultContent = Mage::getModel('ddg_automation/adminhtml_dashboard_content');
|
1500 |
-
$resultContent->setStyle(self::CONNECTOR_DASHBOARD_PASSED);
|
1501 |
-
|
1502 |
-
//compatibility with the old versions
|
1503 |
-
if (version_compare(Mage::getVersion(), '1.6.2.0', '>')) {
|
1504 |
-
$version = 'Magento ' . Mage::getEdition() . ' ' . Mage::getVersion() . 'V';
|
1505 |
-
} else {
|
1506 |
-
$version = 'Magento version : ' . Mage::getVersion() . 'V';
|
1507 |
-
}
|
1508 |
-
|
1509 |
-
$fh = @fopen('/proc/meminfo', 'r');
|
1510 |
-
$mem = 0;
|
1511 |
-
if ($fh) {
|
1512 |
-
while ($line = fgets($fh)) {
|
1513 |
-
$pieces = array();
|
1514 |
-
if (preg_match('^MemTotal:\s+(\d+)\skB$^', $line, $pieces)) {
|
1515 |
-
$mem = $pieces[1];
|
1516 |
-
break;
|
1517 |
-
}
|
1518 |
-
}
|
1519 |
-
fclose($fh);
|
1520 |
-
}
|
1521 |
-
if ($mem > 0) {
|
1522 |
-
$mem = $mem / 1024 . 'M';
|
1523 |
-
} else {
|
1524 |
-
$mem = 'Not available';
|
1525 |
-
}
|
1526 |
-
|
1527 |
-
//check for php version
|
1528 |
-
$resultContent->setHowTo('PHP version : V' . PHP_VERSION)
|
1529 |
-
->setHowto('PHP Memory : ' . $mem)
|
1530 |
-
->setHowto('PHP Max Execution Time : ' . ini_get('max_execution_time') . ' sec')
|
1531 |
-
->setHowto($version)
|
1532 |
-
->setHowto('Connector version : V' . Mage::helper('ddg')->getConnectorVersion());
|
1533 |
-
|
1534 |
-
return $resultContent;
|
1535 |
-
}
|
1536 |
-
|
1537 |
-
|
1538 |
-
/**
|
1539 |
-
* Check if the mapped program is active.
|
1540 |
-
*/
|
1541 |
-
protected function _getWebisteProgram($program, $website) {
|
1542 |
-
|
1543 |
-
$client = Mage::helper('ddg')->getWebsiteApiClient($website);
|
1544 |
-
|
1545 |
-
if (! $client || !$program){
|
1546 |
-
return false;
|
1547 |
-
}
|
1548 |
-
|
1549 |
-
$data = $client->getProgramById($program);
|
1550 |
-
|
1551 |
-
if (isset($data->message))
|
1552 |
-
return false;
|
1553 |
-
|
1554 |
-
|
1555 |
-
return $data;
|
1556 |
-
}
|
1557 |
-
|
1558 |
-
/**
|
1559 |
-
* Get the contacts address book.
|
1560 |
-
* @param $addressBook
|
1561 |
-
* @param $webiste
|
1562 |
-
*
|
1563 |
-
* @return bool|null
|
1564 |
-
*/
|
1565 |
-
protected function _getAddressBookContacts($addressBook, $webiste) {
|
1566 |
-
$client = Mage::helper('ddg')->getWebsiteApiClient($webiste);
|
1567 |
-
|
1568 |
-
if (! $client && $addressBook)
|
1569 |
-
return false;
|
1570 |
-
|
1571 |
-
$response = $client->getAddressBookById($addressBook);
|
1572 |
-
|
1573 |
-
if (isset($response->message))
|
1574 |
-
return false;
|
1575 |
-
return $response;
|
1576 |
-
}
|
1577 |
-
|
1578 |
-
/**
|
1579 |
-
* Get the method name
|
1580 |
-
* @param $name
|
1581 |
-
*
|
1582 |
-
* @return string
|
1583 |
-
*/
|
1584 |
-
public function getFormatedMethodName($name)
|
1585 |
-
{
|
1586 |
-
//version that not support the lcfirst method
|
1587 |
-
if(function_exists('lcfirst') === false) {
|
1588 |
-
|
1589 |
-
$method = strtolower(substr(uc_words($name, '') ,0,1)).substr(uc_words($name, ''), 1);
|
1590 |
-
|
1591 |
-
} else {
|
1592 |
-
$method = lcfirst(uc_words($name, ''));
|
1593 |
-
}
|
1594 |
-
|
1595 |
-
return $method;
|
1596 |
-
}
|
1597 |
Â
|
1598 |
Â
/**
|
1599 |
Â
* easy email capture enabled
|
Â
|
|
1600 |
Â
* @return Dotdigitalgroup_Email_Model_Adminhtml_Dashboard_Content
|
1601 |
Â
*/
|
1602 |
Â
public function easyEmailCaptureEnabled()
|
1603 |
Â
{
|
1604 |
-
$resultContent = Mage::getModel(
|
Â
|
|
Â
|
|
1605 |
Â
$resultContent->setStyle(self::CONNECTOR_DASHBOARD_PASSED)
|
1606 |
Â
->setTitle('Easy Email Capture : ')
|
1607 |
Â
->setMessage('Enabled.');
|
1608 |
Â
|
1609 |
-
foreach (
|
1610 |
-
$websiteName
|
1611 |
-
$enabled
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
1612 |
Â
'Disabled';
|
1613 |
Â
|
1614 |
-
if ($enabled !== true){
|
1615 |
-
$url = Mage::helper('adminhtml')->getUrl(
|
1616 |
-
|
1617 |
-
|
1618 |
-
|
1619 |
-
|
1620 |
-
|
1621 |
-
|
1622 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
1623 |
Â
}
|
1624 |
Â
}
|
Â
|
|
1625 |
Â
return $resultContent;
|
1626 |
Â
}
|
1627 |
Â
|
1628 |
Â
/**
|
1629 |
Â
* disabled newsletter success enabled
|
Â
|
|
1630 |
Â
* @return Dotdigitalgroup_Email_Model_Adminhtml_Dashboard_Content
|
1631 |
Â
*/
|
1632 |
Â
public function disableNewsletterSuccessEnabled()
|
1633 |
Â
{
|
1634 |
-
$resultContent = Mage::getModel(
|
Â
|
|
Â
|
|
1635 |
Â
$resultContent->setStyle(self::CONNECTOR_DASHBOARD_PASSED)
|
1636 |
Â
->setTitle('Disable Newsletter Success : ')
|
1637 |
Â
->setMessage('Enabled.');
|
1638 |
Â
|
1639 |
-
foreach (
|
1640 |
-
$websiteName
|
1641 |
-
$enabled
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
1642 |
Â
'Disabled';
|
1643 |
Â
|
1644 |
-
if ($enabled !== true){
|
1645 |
-
$url = Mage::helper('adminhtml')->getUrl(
|
1646 |
-
|
1647 |
-
|
1648 |
-
|
1649 |
-
|
1650 |
-
|
1651 |
-
|
1652 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
1653 |
Â
}
|
1654 |
Â
}
|
Â
|
|
1655 |
Â
return $resultContent;
|
1656 |
Â
}
|
1657 |
Â
|
1658 |
Â
/**
|
1659 |
Â
* wishlist sync enabled.
|
Â
|
|
1660 |
Â
* @return Dotdigitalgroup_Email_Model_Adminhtml_Dashboard_Content
|
1661 |
Â
*/
|
1662 |
Â
public function wishlistEnabled()
|
1663 |
Â
{
|
1664 |
-
$resultContent = Mage::getModel(
|
Â
|
|
Â
|
|
1665 |
Â
$resultContent->setStyle(self::CONNECTOR_DASHBOARD_PASSED)
|
1666 |
Â
->setTitle('Wishlist Sync : ')
|
1667 |
Â
->setMessage('Enabled.');
|
1668 |
Â
|
1669 |
-
foreach (
|
1670 |
-
$websiteName
|
1671 |
-
$wishlist
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
1672 |
Â
'Disabled';
|
1673 |
Â
|
1674 |
-
if ($wishlist !== true){
|
1675 |
-
$url = Mage::helper('adminhtml')->getUrl(
|
1676 |
-
|
1677 |
-
|
1678 |
-
|
1679 |
-
|
1680 |
-
|
1681 |
-
|
1682 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
1683 |
Â
}
|
1684 |
Â
}
|
Â
|
|
1685 |
Â
return $resultContent;
|
1686 |
Â
}
|
1687 |
Â
|
1688 |
Â
/**
|
1689 |
Â
* Check if any wishlist are imported.
|
Â
|
|
1690 |
Â
* @return Dotdigitalgroup_Email_Model_Adminhtml_Dashboard_Content
|
1691 |
Â
*/
|
1692 |
Â
public function wishlistSyncing()
|
1693 |
Â
{
|
1694 |
-
$resultContent = Mage::getModel(
|
Â
|
|
Â
|
|
1695 |
Â
$resultContent->setStyle(self::CONNECTOR_DASHBOARD_PASSED)
|
1696 |
Â
->setTitle('Wishlist Syncing : ')
|
1697 |
Â
->setMessage('Looks Great.');
|
1698 |
Â
|
1699 |
-
foreach (
|
1700 |
-
$websiteName
|
1701 |
-
$storeIds
|
1702 |
Â
|
1703 |
-
|
1704 |
-
|
Â
|
|
1705 |
Â
|
1706 |
Â
//number of wishlist marked as imported
|
1707 |
-
$numWishlist = Mage::getModel('ddg_automation/wishlist')
|
Â
|
|
1708 |
Â
->addFieldToFilter('wishlist_imported', 1)
|
1709 |
Â
->addFieldToFilter('store_id', array('in', $storeIds))
|
1710 |
Â
->getSize();
|
1711 |
Â
|
1712 |
Â
//total wishlist
|
1713 |
-
$totalWishlist = Mage::getModel('ddg_automation/wishlist')
|
Â
|
|
1714 |
Â
->addFieldToFilter('store_id', array('in', $storeIds))
|
1715 |
Â
->getSize();
|
1716 |
Â
|
1717 |
Â
$tableData = array(
|
1718 |
-
'Website'
|
1719 |
Â
'Total Wishlist' => $totalWishlist,
|
1720 |
-
'Imported'
|
1721 |
Â
);
|
1722 |
Â
|
1723 |
Â
$tableData['Status'] = 'Importing';
|
1724 |
Â
|
1725 |
-
if (! $numWishlist) {
|
1726 |
Â
$tableData['Status'] = 'No Imported Wishlist Found.';
|
1727 |
Â
$resultContent->setStyle(self::CONNECTOR_DASHBOARD_FAILED)
|
1728 |
-
->setTitle(
|
Â
|
|
Â
|
|
1729 |
Â
->setMessage('');
|
1730 |
Â
}
|
1731 |
Â
$resultContent->setTable($tableData);
|
1732 |
Â
}
|
Â
|
|
1733 |
Â
return $resultContent;
|
1734 |
Â
}
|
1735 |
Â
|
1736 |
Â
|
1737 |
-
|
1738 |
Â
}
|
1 |
Â
<?php
|
2 |
Â
|
3 |
+
class Dotdigitalgroup_Email_Block_Adminhtml_Dashboard_Tabs_Status
|
4 |
+
extends Mage_Adminhtml_Block_Widget
|
5 |
+
implements Mage_Adminhtml_Block_Widget_Tab_Interface
|
6 |
Â
{
|
7 |
Â
|
8 |
+
const CONNECTOR_DASHBOARD_PASSED = 'available';
|
9 |
+
const CONNECTOR_DASHBOARD_WARRNING = 'connector_warning';
|
10 |
+
const CONNECTOR_DASHBOARD_FAILED = 'error';
|
11 |
+
|
12 |
+
const FAST_FIX_MESSAGE = 'Fast Fix Available, Click To Enable The Mapping And Redirect Back.';
|
13 |
+
|
14 |
+
protected $_checkpoints
|
15 |
+
= array(
|
16 |
+
'valid_api_credentials' => 'API Credentials',
|
17 |
+
'cron_running' => 'Cron running',
|
18 |
+
'conflict_check' => 'Conflict Check',
|
19 |
+
'address_book_mapped' => 'Address Book Mapping',
|
20 |
+
'file_permission_setttings' => 'File Permission Settings',
|
21 |
+
'missing_files' => 'Missing Files',
|
22 |
+
'contact_sync_enabled' => 'Contact Sync Enabled',
|
23 |
+
'contact_syncing' => 'Contacts Syncing',
|
24 |
+
'subscriber_sync_enabled' => 'Subscribers Sync Enabled',
|
25 |
+
'subscribers_syncing' => 'Subscribers Syncing',
|
26 |
+
'automation_active' => 'Automation Programs Active',
|
27 |
+
'abandoned_carts_enabled' => 'Abandoned Carts Enabled',
|
28 |
+
'data_field_mapped' => 'Data Field Mapped',
|
29 |
+
'order_enabled' => 'Order Sync Enabled',
|
30 |
+
'order_syncing' => 'Orders Syncing',
|
31 |
+
'custom_order_attributes' => 'Custom Order Attributes',
|
32 |
+
'quote_enabled' => 'Quote Sync Enabled',
|
33 |
+
'quote_syncing' => 'Quote Syncing',
|
34 |
+
'custom_quote_attributes' => 'Custom Quote Attributes',
|
35 |
+
'last_abandoned_cart_sent_day' => 'Last Abandoned Cart Sent Day',
|
36 |
+
'easy_email_capture_enabled' => 'Easy Email Capture Enabled',
|
37 |
+
'disable_newsletter_success_enabled' => 'Disable Newsletter Success Enabled',
|
38 |
+
'system_information' => 'System Information'
|
39 |
+
|
40 |
+
);
|
41 |
+
|
42 |
+
/**
|
43 |
Â
* Set the template.
|
44 |
Â
*/
|
45 |
Â
public function __construct()
|
46 |
Â
{
|
47 |
Â
parent::__construct();
|
48 |
Â
|
49 |
+
$this->setTemplate('connector/dashboard/status.phtml');
|
50 |
Â
}
|
51 |
Â
|
52 |
Â
/**
|
59 |
Â
{
|
60 |
Â
}
|
61 |
Â
|
62 |
+
public function canShowTab()
|
63 |
+
{
|
64 |
+
return true;
|
65 |
+
}
|
66 |
+
|
67 |
+
public function isHidden()
|
68 |
+
{
|
69 |
+
return true;
|
70 |
+
}
|
71 |
+
|
72 |
+
public function getTabLabel()
|
73 |
+
{
|
74 |
+
return Mage::helper('ddg')->__('Marketing Automation System Status');
|
75 |
+
}
|
76 |
+
|
77 |
+
public function getTabTitle()
|
78 |
+
{
|
79 |
+
return Mage::helper('ddg')->__('Marketing Automation System Status');
|
80 |
+
}
|
81 |
+
|
82 |
+
/**
|
83 |
+
* Collapse key for the fieldset state.
|
84 |
+
*
|
85 |
+
* @param $key
|
86 |
+
*
|
87 |
+
* @return bool
|
88 |
+
*/
|
89 |
+
protected function _getCollapseState($key)
|
90 |
+
{
|
91 |
+
$extra = Mage::getSingleton('admin/session')->getUser()->getExtra();
|
92 |
+
if (isset($extra['configState'][$key])) {
|
93 |
+
return $extra['configState'][$key];
|
94 |
+
}
|
95 |
+
|
96 |
+
return false;
|
97 |
+
}
|
98 |
+
|
99 |
+
public function getCheckpoints()
|
100 |
+
{
|
101 |
+
return $this->_checkpoints;
|
102 |
+
}
|
103 |
+
|
104 |
+
protected function getDisplayData()
|
105 |
+
{
|
106 |
+
|
107 |
+
$displayData = array();
|
108 |
+
foreach ($this->getCheckpoints() as $key => $checkpoint) {
|
109 |
+
|
110 |
+
$method = $this->getFormatedMethodName($key);
|
111 |
+
|
112 |
+
if (is_callable(array($this, $method))) {
|
113 |
+
$data = $this->$method();
|
114 |
+
$showHowTo = '';
|
115 |
+
$collapsable = '1';
|
116 |
+
|
117 |
+
if ($data->getStyle() == 'connector_passed') {
|
118 |
+
$showHowTo = 'no_display';
|
119 |
+
$collapsable = '0';
|
120 |
+
}
|
121 |
+
if ($this->_getCollapseState($key) !== false) {
|
122 |
+
$collapsable = $this->_getCollapseState($key);
|
123 |
+
}
|
124 |
+
$displayData[$key] = array(
|
125 |
+
'showHowTo' => $showHowTo,
|
126 |
+
'collapsable' => $collapsable,
|
127 |
+
'data' => $data
|
128 |
+
);
|
129 |
+
}
|
130 |
+
}
|
131 |
+
|
132 |
+
return $displayData;
|
133 |
+
}
|
134 |
+
|
135 |
+
|
136 |
+
public function addCheckpoint($checkpoint)
|
137 |
+
{
|
138 |
+
$this->_checkpoints[$checkpoint->getName()] = $checkpoint;
|
139 |
+
}
|
140 |
+
|
141 |
+
|
142 |
+
/**
|
143 |
+
* Check cron for the customer sync.
|
144 |
+
*
|
145 |
+
* @return array
|
146 |
+
*/
|
147 |
+
public function cronRunning()
|
148 |
+
{
|
149 |
+
$resultContent = Mage::getModel(
|
150 |
+
'ddg_automation/adminhtml_dashboard_content'
|
151 |
+
);
|
152 |
+
$resultContent->setStyle(self::CONNECTOR_DASHBOARD_PASSED)
|
153 |
+
->setTitle('Cron Status : ')
|
154 |
+
->setMessage('Cron is running.');
|
155 |
+
$message
|
156 |
+
= 'No cronjob task found. Check if cron is configured correctly.';
|
157 |
+
$howToSetupCron
|
158 |
+
= 'For more information <a href="http://www.magentocommerce.com/wiki/1_-_installation_and_configuration/how_to_setup_a_cron_job">how to setup the Magento cronjob.</a>';
|
159 |
+
$lastCustomerSync = Mage::getModel('ddg_automation/cron')
|
160 |
+
->getLastCustomerSync();
|
161 |
+
|
162 |
+
if ($lastCustomerSync === false) {
|
163 |
+
$resultContent->setStyle(self::CONNECTOR_DASHBOARD_FAILED)
|
164 |
+
->setHowto($howToSetupCron);
|
165 |
+
} else {
|
166 |
+
$timespan = Mage::helper('ddg')->dateDiff($lastCustomerSync);
|
167 |
+
//last cron was less then 5min
|
168 |
+
if ($timespan <= 5 * 60) {
|
169 |
+
$resultContent->setTitle('Cronjob is working : ');
|
170 |
+
$message = sprintf(
|
171 |
+
'(Last execution: %s minute(s) ago) ', round($timespan / 60)
|
172 |
+
);
|
173 |
+
} elseif ($timespan > 5 * 60 && $timespan <= 60 * 60) {
|
174 |
+
//last cron execution was between 15min and 60min
|
175 |
+
$resultContent->setTitle('Last customer sync : ')
|
176 |
+
->setStyle(self::CONNECTOR_DASHBOARD_FAILED);
|
177 |
+
$message = sprintf(' %s minutes. ', round($timespan / 60));
|
178 |
+
} else {
|
179 |
+
//last cron was more then an hour
|
180 |
+
$resultContent->setStyle(self::CONNECTOR_DASHBOARD_FAILED)
|
181 |
+
->setHowto('Last customer sync is older than one hour.')
|
182 |
+
->setHowto($howToSetupCron);
|
183 |
+
}
|
184 |
+
}
|
185 |
+
|
186 |
+
$resultContent->setMessage($message);
|
187 |
+
|
188 |
+
return $resultContent;
|
189 |
+
}
|
190 |
+
|
191 |
+
/**
|
192 |
+
* Address Book Mapping.
|
193 |
+
*
|
194 |
+
* @return Dotdigitalgroup_Email_Model_Adminhtml_Dashboard_Content
|
195 |
+
*/
|
196 |
+
public function addressBookMapped()
|
197 |
+
{
|
198 |
+
$resultContent = Mage::getModel(
|
199 |
+
'ddg_automation/adminhtml_dashboard_content'
|
200 |
+
);
|
201 |
+
$resultContent->setStyle(self::CONNECTOR_DASHBOARD_PASSED)
|
202 |
+
->setTitle('Configuration For Address Book Status : ')
|
203 |
+
->setMessage('Looks Great.');
|
204 |
+
|
205 |
+
foreach (Mage::app()->getWebsites() as $website) {
|
206 |
+
|
207 |
+
$websiteName = $website->getName();
|
208 |
+
$link = Mage::helper('adminhtml')->getUrl(
|
209 |
+
'*/system_config/edit/section/connector_sync_settings/website/'
|
210 |
+
. $website->getCode()
|
211 |
+
);
|
212 |
+
|
213 |
+
$customerMapped = ($website->getConfig(
|
214 |
+
Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMERS_ADDRESS_BOOK_ID
|
215 |
+
))
|
216 |
+
? true
|
217 |
+
:
|
218 |
+
'Not mapped!';
|
219 |
+
$subscriberMapped = ($website->getConfig(
|
220 |
+
Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_SUBSCRIBERS_ADDRESS_BOOK_ID
|
221 |
+
))
|
222 |
+
? true
|
223 |
+
:
|
224 |
+
'Not mapped!';
|
225 |
+
$guestMapped = ($website->getConfig(
|
226 |
+
Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_GUEST_ADDRESS_BOOK_ID
|
227 |
+
))
|
228 |
+
? true
|
229 |
+
:
|
230 |
+
'Not mapped!';
|
231 |
+
|
232 |
+
if ($customerMapped !== true || $subscriberMapped !== true
|
233 |
+
|| $guestMapped !== true
|
234 |
+
) {
|
235 |
+
$resultContent->setStyle(self::CONNECTOR_DASHBOARD_FAILED)
|
236 |
+
->setMessage('')
|
237 |
+
->setTable(
|
238 |
+
array(
|
239 |
+
'Website' => $websiteName,
|
240 |
+
'Customers' => ($customerMapped !== true)
|
241 |
+
? $customerMapped . ' <a href="' . $link
|
242 |
+
. '">configuration</a>' : 'Mapped.',
|
243 |
+
'Subscribers' => ($subscriberMapped !== true)
|
244 |
+
? $subscriberMapped . ' <a href="' . $link
|
245 |
+
. '">configuration</a>' : 'Mapped.',
|
246 |
+
'Guests' => ($guestMapped !== true)
|
247 |
+
? $guestMapped . ' <a href="' . $link
|
248 |
+
. '">configuration</a>' : 'Mapped.'
|
249 |
+
)
|
250 |
+
);
|
251 |
+
}
|
252 |
+
}
|
253 |
+
|
254 |
+
return $resultContent;
|
255 |
+
}
|
256 |
+
|
257 |
+
/**
|
258 |
+
* ROI Tracking.
|
259 |
+
*
|
260 |
+
* @return Dotdigitalgroup_Email_Model_Adminhtml_Dashboard_Content
|
261 |
+
*/
|
262 |
+
public function roiTrackingEnabled()
|
263 |
+
{
|
264 |
+
$resultContent = Mage::getModel(
|
265 |
+
'ddg_automation/adminhtml_dashboard_content'
|
266 |
+
);
|
267 |
+
$resultContent->setStyle(self::CONNECTOR_DASHBOARD_PASSED)
|
268 |
+
->setTitle('ROI Tracking Status : ')
|
269 |
+
->setMessage('Looks Great.');
|
270 |
+
|
271 |
+
$valid = true;
|
272 |
+
foreach (Mage::app()->getWebsites() as $website) {
|
273 |
+
$websiteName = $website->getName();
|
274 |
+
|
275 |
+
$roiConfig = ($website->getConfig(
|
276 |
+
Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_ROI_TRACKING_ENABLED
|
277 |
+
)) ? true : 'Not Mapped! ';
|
278 |
+
$pageTracking = ($website->getConfig(
|
279 |
+
Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_PAGE_TRACKING_ENABLED
|
280 |
+
)) ? true : 'Not Mapped! ';
|
281 |
+
//not mapped show options
|
282 |
+
if ($roiConfig !== true || $pageTracking !== true) {
|
283 |
+
|
284 |
+
//links to enable and get redirected back
|
285 |
+
$roiUrl = Mage::helper('adminhtml')->getUrl(
|
286 |
+
'*/connector/enablewebsiteconfiguration',
|
287 |
+
array('path' => 'XML_PATH_CONNECTOR_ROI_TRACKING_ENABLED',
|
288 |
+
'website' => $website->getId())
|
289 |
+
);
|
290 |
+
$pageUrl = Mage::helper('adminhtml')->getUrl(
|
291 |
+
'*/connector/enablewebsiteconfiguration',
|
292 |
+
array('path' => 'XML_PATH_CONNECTOR_PAGE_TRACKING_ENABLED',
|
293 |
+
'website' => $website->getId())
|
294 |
+
);
|
295 |
+
|
296 |
+
$resultContent->setStyle(self::CONNECTOR_DASHBOARD_FAILED)
|
297 |
+
->setMessage('')
|
298 |
+
->setTable(
|
299 |
+
array(
|
300 |
+
'Website' => $websiteName,
|
301 |
+
'ROI' => ($roiConfig !== true) ? $roiConfig
|
302 |
+
. ' <a href="' . $roiUrl . '">enable</a>'
|
303 |
+
: 'Mapped.',
|
304 |
+
'PAGE' => ($pageTracking !== true)
|
305 |
+
? $pageTracking . ' <a href="' . $pageUrl
|
306 |
+
. '">enable</a>' : 'Mapped.'
|
307 |
+
)
|
308 |
+
);
|
309 |
+
$valid = false;
|
310 |
+
}
|
311 |
+
}
|
312 |
+
//validation failed
|
313 |
+
if ( ! $valid) {
|
314 |
+
$resultContent->setHowto(self::FAST_FIX_MESSAGE);
|
315 |
+
}
|
316 |
+
|
317 |
+
return $resultContent;
|
318 |
+
}
|
319 |
+
|
320 |
+
/**
|
321 |
+
* File Permissions.
|
322 |
+
*
|
323 |
+
* @return Dotdigitalgroup_Email_Model_Adminhtml_Dashboard_Content
|
324 |
+
*/
|
325 |
+
public function filePermissionSetttings()
|
326 |
+
{
|
327 |
+
$resultContent = Mage::getModel(
|
328 |
+
'ddg_automation/adminhtml_dashboard_content'
|
329 |
+
);
|
330 |
+
$resultContent->setStyle(self::CONNECTOR_DASHBOARD_PASSED)
|
331 |
+
->setTitle('Files/Folders Permission Settings : ')
|
332 |
+
->setMessage('Looks Great.');
|
333 |
+
|
334 |
+
/**
|
335 |
+
* Arhive and email export directories.
|
336 |
+
*/
|
337 |
+
$emailDir = Mage::getBaseDir('var') . DIRECTORY_SEPARATOR . 'export'
|
338 |
+
. DIRECTORY_SEPARATOR . 'email';
|
339 |
+
$archiveDir = Mage::getBaseDir('var') . DIRECTORY_SEPARATOR . 'export'
|
340 |
+
. DIRECTORY_SEPARATOR . 'email' . DIRECTORY_SEPARATOR . 'archive';
|
341 |
+
|
342 |
+
$checkEmail = Mage::helper('ddg/file')->getPathPermission($emailDir);
|
343 |
+
$checkArchive = Mage::helper('ddg/file')->getPathPermission(
|
344 |
+
$archiveDir
|
345 |
+
);
|
346 |
+
|
347 |
+
//file persmission failed
|
348 |
+
if ($checkEmail != 755 && $checkEmail != 777
|
349 |
+
|| $checkArchive != 755
|
350 |
+
&& $checkArchive != 777
|
351 |
+
) {
|
352 |
+
$resultContent->setStyle(self::CONNECTOR_DASHBOARD_FAILED)
|
353 |
+
->setMessage('Wrong Permission For Directory : 777 or 755');
|
354 |
+
|
355 |
+
//list of directory permission checked
|
356 |
+
if ($checkEmail != 755 || $checkEmail != 777) {
|
357 |
+
$resultContent->setHowto(
|
358 |
+
$emailDir . ' is set to : ' . $checkEmail
|
359 |
+
);
|
360 |
+
}
|
361 |
+
if ($checkArchive != 755 || $checkArchive != 777) {
|
362 |
+
$resultContent->setHowto(
|
363 |
+
$archiveDir . ' is set to : ' . $checkArchive
|
364 |
+
);
|
365 |
+
}
|
366 |
+
}
|
367 |
+
|
368 |
+
return $resultContent;
|
369 |
+
}
|
370 |
+
|
371 |
+
/**
|
372 |
+
* Check for missing files.
|
373 |
+
*
|
374 |
+
* @return Dotdigitalgroup_Email_Model_Adminhtml_Dashboard_Content
|
375 |
+
*/
|
376 |
+
public function missingFiles()
|
377 |
+
{
|
378 |
+
$resultContent = Mage::getModel(
|
379 |
+
'ddg_automation/adminhtml_dashboard_content'
|
380 |
+
);
|
381 |
+
|
382 |
+
$resultContent->setStyle(self::CONNECTOR_DASHBOARD_PASSED)
|
383 |
+
->setTitle('Missing Files : ')
|
384 |
Â
->setMessage('Looks Great.');
|
385 |
Â
|
386 |
+
$filePath = Mage::getModuleDir(
|
387 |
+
'etc', Dotdigitalgroup_Email_Helper_Config::MODULE_NAME
|
388 |
+
) . DS . 'files.yaml';
|
389 |
+
$config = Zend_Config_Yaml::decode(file_get_contents($filePath));
|
390 |
+
|
391 |
+
/**
|
392 |
+
* Code dirs.
|
393 |
+
*/
|
394 |
+
$etcDir = Mage::getModuleDir(
|
395 |
+
'etc', Dotdigitalgroup_Email_Helper_Config::MODULE_NAME
|
396 |
+
);
|
397 |
+
$controllerDir = Mage::getModuleDir(
|
398 |
+
'controllers', Dotdigitalgroup_Email_Helper_Config::MODULE_NAME
|
399 |
+
);
|
400 |
+
$sqlDir = Mage::getModuleDir(
|
401 |
+
'sql', Dotdigitalgroup_Email_Helper_Config::MODULE_NAME
|
402 |
+
);
|
403 |
+
$localeDir = Mage::getBaseDir('locale');
|
404 |
+
$rootDir = Mage::getModuleDir(
|
405 |
+
'', Dotdigitalgroup_Email_Helper_Config::MODULE_NAME
|
406 |
+
);
|
407 |
+
$blockDir = $rootDir . DS . 'Block';
|
408 |
+
$helperDir = $rootDir . DS . 'Helper';
|
409 |
+
$modelDir = $rootDir . DS . 'Model';
|
410 |
+
|
411 |
+
/**
|
412 |
+
* Design dir.
|
413 |
+
*/
|
414 |
+
$designDir = Mage::getBaseDir('design');
|
415 |
+
|
416 |
+
/**
|
417 |
+
* Skin dir.
|
418 |
+
*/
|
419 |
+
$skinDir = Mage::getBaseDir('skin');
|
420 |
Â
|
421 |
Â
/**
|
422 |
Â
* Js dir
|
428 |
Â
*/
|
429 |
Â
$libDir = Mage::getBaseDir('lib');
|
430 |
Â
|
431 |
+
$filesToCheck = array($config['etc'], $config['controllers'],
|
432 |
+
$config['sql'], $config['locale'],
|
433 |
+
$config['block'],
|
434 |
+
$config['helper'], $config['model'],
|
435 |
+
$config['design'], $config['skin'],
|
436 |
+
$config['lib'], $config['js']);
|
437 |
+
$pathToCheck = array($etcDir, $controllerDir, $sqlDir, $localeDir,
|
438 |
+
$blockDir, $helperDir,
|
439 |
+
$modelDir, $designDir, $skinDir, $libDir, $jsDir);
|
440 |
+
foreach ($filesToCheck as $subdir) {
|
441 |
+
foreach ($subdir as $path) {
|
442 |
+
$file = $pathToCheck[0] . DS . str_replace('#', DS, $path);
|
443 |
+
|
444 |
+
if ( ! file_exists($file)) {
|
445 |
+
$resultContent->setStyle(self::CONNECTOR_DASHBOARD_FAILED)
|
446 |
+
->setMessage('')
|
447 |
+
->setHowto('File not found : ' . $file);
|
448 |
+
}
|
449 |
+
}
|
450 |
+
array_shift($pathToCheck);
|
451 |
+
}
|
452 |
+
|
453 |
+
return $resultContent;
|
454 |
+
}
|
455 |
+
|
456 |
+
/**
|
457 |
+
* Contact Sync Status.
|
458 |
+
*
|
459 |
+
* @return Dotdigitalgroup_Email_Model_Adminhtml_Dashboard_Content
|
460 |
+
*/
|
461 |
+
public function contactSyncEnabled()
|
462 |
+
{
|
463 |
+
$resultContent = Mage::getModel(
|
464 |
+
'ddg_automation/adminhtml_dashboard_content'
|
465 |
+
);
|
466 |
+
$resultContent->setStyle(self::CONNECTOR_DASHBOARD_PASSED)
|
467 |
+
->setTitle('Contacts Sync Status : ')
|
468 |
+
->setMessage('Looks Great.');
|
469 |
+
|
470 |
+
$valid = true;
|
471 |
+
foreach (Mage::app()->getWebsites() as $website) {
|
472 |
+
$websiteName = $website->getName();
|
473 |
+
$contact = ($website->getConfig(
|
474 |
+
Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_SYNC_CONTACT_ENABLED
|
475 |
+
)) ? true : 'Disabled!';
|
476 |
+
//disabled show data table
|
477 |
+
if ($contact !== true) {
|
478 |
+
//redirection url to enable website config
|
479 |
+
$url = Mage::helper('adminhtml')->getUrl(
|
480 |
+
'*/connector/enablewebsiteconfiguration',
|
481 |
+
array('path' => 'XML_PATH_CONNECTOR_SYNC_CONTACT_ENABLED',
|
482 |
+
'website' => $website->getId())
|
483 |
+
);
|
484 |
+
$resultContent->setStyle(self::CONNECTOR_DASHBOARD_FAILED)
|
485 |
+
->setMessage('')
|
486 |
+
->setTable(
|
487 |
+
array(
|
488 |
+
'Website' => $websiteName,
|
489 |
+
'Status' => ($contact) ? $contact . ' <a href="'
|
490 |
+
. $url . '">enable</a>' : 'Enabled.'
|
491 |
+
)
|
492 |
+
);
|
493 |
+
$valid = false;
|
494 |
+
}
|
495 |
+
}
|
496 |
+
//validation failed
|
497 |
+
if ( ! $valid) {
|
498 |
+
$resultContent->setHowto(self::FAST_FIX_MESSAGE);
|
499 |
+
}
|
500 |
+
|
501 |
+
return $resultContent;
|
502 |
+
}
|
503 |
+
|
504 |
+
/**
|
505 |
+
* Check if contact is syncing by counting the number of contacts imported.
|
506 |
+
*
|
507 |
+
* @return Dotdigitalgroup_Email_Model_Adminhtml_Dashboard_Content
|
508 |
+
*/
|
509 |
+
public function contactSyncing()
|
510 |
+
{
|
511 |
+
//content to render
|
512 |
+
$resultContent = Mage::getModel(
|
513 |
+
'ddg_automation/adminhtml_dashboard_content'
|
514 |
+
);
|
515 |
+
$resultContent->setStyle(self::CONNECTOR_DASHBOARD_PASSED)
|
516 |
+
->setTitle('Contacts Sync : ')
|
517 |
+
->setMessage('Looks Great.');
|
518 |
+
$contactModel = Mage::getModel('ddg_automation/contact');
|
519 |
+
|
520 |
+
//global email duplicates
|
521 |
+
if (Mage::getResourceModel('customer/customer')->findEmailDuplicates()
|
522 |
+
) {
|
523 |
+
|
524 |
+
//duplicate email customers
|
525 |
+
$customers = Mage::helper('ddg')
|
526 |
+
->getCustomersWithDuplicateEmails();
|
527 |
+
$customerEmails = implode(
|
528 |
+
', ', $customers->getColumnValues('email')
|
529 |
+
);
|
530 |
+
//render the email duplicates
|
531 |
+
$resultContent->setHowto('Found Duplicate Customers Emails :')
|
532 |
+
->setHowto($customerEmails);
|
533 |
+
}
|
534 |
+
|
535 |
+
foreach (Mage::app()->getWebsites() as $website) {
|
536 |
+
|
537 |
+
$websiteId = $website->getId();
|
538 |
+
//total customers for website
|
539 |
+
$countCustomers = Mage::getModel('customer/customer')
|
540 |
+
->getCollection()
|
541 |
+
->addAttributeToFilter('website_id', $websiteId)
|
542 |
+
->getSize();
|
543 |
+
|
544 |
+
//skip if no customers
|
545 |
+
if ( ! $countCustomers) {
|
546 |
+
continue;
|
547 |
+
}
|
548 |
+
|
549 |
+
//total contacts from customer address book
|
550 |
+
$customerAddressBook = $this->_getAddressBookContacts(
|
551 |
+
$website->getConfig(
|
552 |
+
Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMERS_ADDRESS_BOOK_ID
|
553 |
+
), $website
|
554 |
+
);
|
555 |
+
$countAddressbookContacts = ($customerAddressBook)
|
556 |
+
? $customerAddressBook->contacts : 0;
|
557 |
+
//total contacts as customers
|
558 |
+
$countCustomerContacts = $contactModel->getNumberCustomerContacts(
|
559 |
+
$websiteId
|
560 |
+
);
|
561 |
+
|
562 |
+
//suppressed contacts
|
563 |
+
$suppressed = $contactModel->getNumberCustomerSuppressed(
|
564 |
+
$websiteId
|
565 |
+
);
|
566 |
+
|
567 |
+
//table data
|
568 |
+
$tableData = array(
|
569 |
+
'Website' => $website->getName(),
|
570 |
+
'Total Customers/Contacts' => $countCustomers . '/ '
|
571 |
+
. $countCustomerContacts,
|
572 |
+
'Customer AddressBook Contacts' => ($customerAddressBook)
|
573 |
+
? $customerAddressBook->name . ' : '
|
574 |
+
. $countAddressbookContacts : 'Not Mapped.',
|
575 |
+
'Suppressed' => $suppressed,
|
576 |
+
'Synced' => $contactModel->getNumberCustomerSynced(
|
577 |
+
$websiteId
|
578 |
+
)
|
579 |
+
);
|
580 |
+
|
581 |
+
//number of customers not match, try to update
|
582 |
+
if ($countCustomers != $countCustomerContacts) {
|
583 |
+
|
584 |
+
$url = Mage::helper('adminhtml')->getUrl(
|
585 |
+
'*/connector/populatecontacts',
|
586 |
+
array('type' => 'customers', 'website' => $website->getId())
|
587 |
+
);
|
588 |
+
$link = ' <a href="' . $url . '"> populate</a>';
|
589 |
+
$tableData['Status']
|
590 |
+
= 'Customers not matching the contact table. ' . $link;
|
591 |
+
//customers not synced yet
|
592 |
+
} elseif ($countCustomers > $countCustomerContacts + $suppressed) {
|
593 |
+
$tableData['Status'] = 'Syncing..';
|
594 |
+
//all customers syned.
|
595 |
+
} else {
|
596 |
+
$tableData['Status'] = 'Synced';
|
597 |
+
}
|
598 |
+
|
599 |
+
//not valid response remove status
|
600 |
+
if ( ! $countAddressbookContacts) {
|
601 |
+
unset($tableData['Status']);
|
602 |
+
}
|
603 |
+
|
604 |
+
//no contacts
|
605 |
+
if ( ! $countCustomers) {
|
606 |
+
|
607 |
+
$resultContent->setStyle(self::CONNECTOR_DASHBOARD_FAILED)
|
608 |
+
->setTitle(
|
609 |
+
'Contacts Sync (ignore if you have reset contacts for reimport) : '
|
610 |
+
)
|
611 |
+
->setMessage('');
|
612 |
+
$tableData['Status'] = 'No Imported Contacts Found!';
|
613 |
+
unset($tableData['Imported Contacts']);
|
614 |
+
}
|
615 |
+
|
616 |
+
$resultContent->setTable($tableData);
|
617 |
+
}
|
618 |
+
|
619 |
+
return $resultContent;
|
620 |
+
}
|
621 |
+
|
622 |
+
/**
|
623 |
+
* Check for subscribers sync status.
|
624 |
+
*
|
625 |
+
* @return Dotdigitalgroup_Email_Model_Adminhtml_Dashboard_Content
|
626 |
+
*/
|
627 |
+
public function subscriberSyncEnabled()
|
628 |
+
{
|
629 |
+
$resultContent = Mage::getModel(
|
630 |
+
'ddg_automation/adminhtml_dashboard_content'
|
631 |
+
);
|
632 |
+
$resultContent->setStyle(self::CONNECTOR_DASHBOARD_PASSED)
|
633 |
+
->setTitle('Subscribers Sync Status : ')
|
634 |
+
->setMessage('Looks Great.');
|
635 |
+
|
636 |
+
$passed = true;
|
637 |
+
foreach (Mage::app()->getWebsites() as $website) {
|
638 |
+
$websiteName = $website->getName();
|
639 |
+
$contact = ($website->getConfig(
|
640 |
+
Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_SYNC_SUBSCRIBER_ENABLED
|
641 |
+
))
|
642 |
+
? true
|
643 |
+
:
|
644 |
+
'Disabled!';
|
645 |
+
//disabled show data table
|
646 |
+
if ($contact !== true) {
|
647 |
+
//redirection url to enable website config
|
648 |
+
$url = Mage::helper('adminhtml')->getUrl(
|
649 |
+
'*/connector/enablewebsiteconfiguration',
|
650 |
+
array('path' => 'XML_PATH_CONNECTOR_SYNC_SUBSCRIBER_ENABLED',
|
651 |
+
'website' => $website->getId())
|
652 |
+
);
|
653 |
+
$resultContent->setStyle(self::CONNECTOR_DASHBOARD_FAILED)
|
654 |
+
->setMessage('')
|
655 |
+
->setTable(
|
656 |
+
array(
|
657 |
+
'Website' => $websiteName,
|
658 |
+
'Status' => ($contact) ? $contact . ' <a href="'
|
659 |
+
. $url . '">enable</a>' : 'Enabled.'
|
660 |
+
)
|
661 |
+
);
|
662 |
+
$passed = false;
|
663 |
+
}
|
664 |
+
}
|
665 |
+
//if validation not passed
|
666 |
+
if ( ! $passed) {
|
667 |
+
$resultContent->setHowto(self::FAST_FIX_MESSAGE);
|
668 |
+
}
|
669 |
+
|
670 |
+
return $resultContent;
|
671 |
+
}
|
672 |
+
|
673 |
+
/**
|
674 |
+
* Subscribers syncing status.
|
675 |
+
*
|
676 |
+
* @return Dotdigitalgroup_Email_Model_Adminhtml_Dashboard_Content
|
677 |
+
*/
|
678 |
+
public function subscribersSyncing()
|
679 |
+
{
|
680 |
+
$resultContent = Mage::getModel(
|
681 |
+
'ddg_automation/adminhtml_dashboard_content'
|
682 |
+
);
|
683 |
+
$resultContent->setStyle(self::CONNECTOR_DASHBOARD_PASSED)
|
684 |
+
->setTitle('Subscribers Sync : ')
|
685 |
+
->setMessage('Looks Great.');
|
686 |
+
$contactModel = Mage::getModel('ddg_automation/contact');
|
687 |
+
|
688 |
+
foreach (Mage::app()->getWebsites() as $website) {
|
689 |
+
$websiteId = $website->getId();
|
690 |
+
$websiteName = $website->getName();
|
691 |
+
$storeIds = $website->getStoreIds();
|
692 |
+
//total subscribers
|
693 |
+
$countSubscribers = Mage::getModel('newsletter/subscriber')
|
694 |
+
->getCollection()
|
695 |
Â
->useOnlySubscribed()
|
696 |
Â
->addStoreFilter($storeIds)
|
697 |
+
->getSize();
|
698 |
+
//skip if no subscriber
|
699 |
+
if ( ! $countSubscribers) {
|
700 |
+
continue;
|
701 |
+
}
|
702 |
+
|
703 |
+
//total contacts subscribed
|
704 |
+
$countSubscribedContacts = $contactModel->getNumberSubscribers(
|
705 |
+
$websiteId
|
706 |
+
);
|
707 |
+
//total contacts subscribed imported
|
708 |
+
$countSubscribersImported
|
709 |
+
= $contactModel->getNumberSubscribersSynced($websiteId);
|
710 |
+
|
711 |
+
//number of address
|
712 |
+
$countAddressbookContacts = $this->_getAddressBookContacts(
|
713 |
+
$website->getConfig(
|
714 |
+
Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_SUBSCRIBERS_ADDRESS_BOOK_ID
|
715 |
+
), $website
|
716 |
+
);
|
717 |
+
|
718 |
+
$tableData = array(
|
719 |
+
'Website' => $websiteName,
|
720 |
+
'Total Subscribers/Contacts' => $countSubscribers . '/ '
|
721 |
+
. $countSubscribedContacts,
|
722 |
+
'Subscriber AddressBook Contacts' => ($countAddressbookContacts)
|
723 |
+
? $countAddressbookContacts->name . ' : '
|
724 |
+
. $countAddressbookContacts->contacts : 'Not Mapped.',
|
725 |
+
'Imported' => $countSubscribersImported
|
726 |
+
);
|
727 |
+
|
728 |
+
$tableData['Status'] = '';
|
729 |
+
|
730 |
+
//no imported contacts
|
731 |
+
if ( ! $countSubscribersImported) {
|
732 |
+
|
733 |
+
$tableData['Status'] = 'No Imported Subscribers Found.';
|
734 |
+
$resultContent->setStyle(self::CONNECTOR_DASHBOARD_FAILED)
|
735 |
+
->setTitle(
|
736 |
+
'Subscriber Sync (ignore if you have reset subscribers for reimport) : '
|
737 |
+
)
|
738 |
+
->setMessage('');
|
739 |
+
}
|
740 |
+
$resultContent->setTable($tableData);
|
741 |
+
}
|
742 |
+
|
743 |
+
return $resultContent;
|
744 |
+
}
|
745 |
+
|
746 |
+
//check the mapped programs are active
|
747 |
+
public function automationActive()
|
748 |
+
{
|
749 |
+
$disableCustomer
|
750 |
+
= $disableSubscriber = $disableOrder
|
751 |
+
= $disableGuestOrder = $disableReviews = $disableWishlist = '';
|
752 |
+
$resultContent = Mage::getModel(
|
753 |
+
'ddg_automation/adminhtml_dashboard_content'
|
754 |
+
);
|
755 |
+
$resultContent->setStyle(self::CONNECTOR_DASHBOARD_PASSED)
|
756 |
+
->setTitle('Automation Program Status :')
|
757 |
+
->setMessage('');
|
758 |
+
|
759 |
+
foreach (Mage::app()->getWebsites() as $website) {
|
760 |
+
$customerProgram = $website->getConfig(
|
761 |
+
Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_AUTOMATION_STUDIO_CUSTOMER
|
762 |
+
);
|
763 |
+
$subscriberProgram = $website->getConfig(
|
764 |
+
Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_AUTOMATION_STUDIO_SUBSCRIBER
|
765 |
+
);
|
766 |
+
$orderProgram = $website->getConfig(
|
767 |
+
Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_AUTOMATION_STUDIO_ORDER
|
768 |
+
);
|
769 |
+
$guestOrderProgram = $website->getConfig(
|
770 |
+
Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_AUTOMATION_STUDIO_GUEST_ORDER
|
771 |
+
);
|
772 |
+
$reviewsProgram = $website->getConfig(
|
773 |
+
Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_AUTOMATION_STUDIO_REVIEW
|
774 |
+
);
|
775 |
+
$wishlistProgram = $website->getConfig(
|
776 |
+
Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_AUTOMATION_STUDIO_WISHLIST
|
777 |
+
);
|
778 |
+
|
779 |
+
//programs
|
780 |
+
$cusProgram = $this->_getWebisteProgram(
|
781 |
+
$customerProgram, $website
|
782 |
+
);
|
783 |
+
$subProgram = $this->_getWebisteProgram(
|
784 |
+
$subscriberProgram, $website
|
785 |
+
);
|
786 |
+
$orderProgram = $this->_getWebisteProgram(
|
787 |
+
$orderProgram, $website
|
788 |
+
);
|
789 |
+
$guestOrderProgram = $this->_getWebisteProgram(
|
790 |
+
$guestOrderProgram, $website
|
791 |
+
);
|
792 |
+
$reviewsProgram = $this->_getWebisteProgram(
|
793 |
+
$reviewsProgram, $website
|
794 |
+
);
|
795 |
+
$wishlistProgram = $this->_getWebisteProgram(
|
796 |
+
$wishlistProgram, $website
|
797 |
+
);
|
798 |
Â
|
799 |
Â
//check for wishlist program
|
800 |
Â
if ($wishlistProgram) {
|
803 |
Â
|
804 |
Â
//set the status as failed
|
805 |
Â
$resultContent->setStyle(self::CONNECTOR_DASHBOARD_FAILED)
|
806 |
+
->setMessage(
|
807 |
+
' Consider to disable not active programs'
|
808 |
+
);
|
809 |
Â
|
810 |
+
$disableWishlist = Mage::helper('adminhtml')->getUrl(
|
811 |
+
'*/connector/enablewebsiteconfiguration', array(
|
812 |
Â
'path' => 'XML_PATH_CONNECTOR_AUTOMATION_STUDIO_WISHLIST',
|
813 |
Â
'value' => '0',
|
814 |
Â
'website' => $website->getId()
|
815 |
Â
)
|
816 |
Â
);
|
817 |
+
$disableWishlist = 'Deactivated! <a href="'
|
818 |
+
. $disableWishlist . '">click</a> to disable';
|
819 |
Â
|
820 |
Â
} else {
|
821 |
Â
|
830 |
Â
|
831 |
Â
//set the status as failed
|
832 |
Â
$resultContent->setStyle(self::CONNECTOR_DASHBOARD_FAILED)
|
833 |
+
->setMessage(
|
834 |
+
' Consider to disable not active programs'
|
835 |
+
);
|
836 |
Â
|
837 |
+
$disableOrder = Mage::helper('adminhtml')->getUrl(
|
838 |
+
'*/connector/enablewebsiteconfiguration', array(
|
839 |
Â
'path' => 'XML_PATH_CONNECTOR_AUTOMATION_STUDIO_ORDER',
|
840 |
Â
'value' => '0',
|
841 |
Â
'website' => $website->getId()
|
842 |
Â
)
|
843 |
Â
);
|
844 |
+
$disableOrder = 'Deactivated! <a href="' . $disableOrder
|
845 |
+
. '">click</a> to disable';
|
846 |
+
|
847 |
+
} else {
|
848 |
+
|
849 |
+
$disableOrder = $orderProgram->status;
|
850 |
+
}
|
851 |
+
}
|
852 |
+
|
853 |
+
//check for review program
|
854 |
+
if ($reviewsProgram) {
|
855 |
+
|
856 |
+
if ($reviewsProgram->status != 'Active') {
|
857 |
+
|
858 |
+
//set the status as failed
|
859 |
+
$resultContent->setStyle(self::CONNECTOR_DASHBOARD_FAILED)
|
860 |
+
->setMessage(
|
861 |
+
' Consider to disable not active programs'
|
862 |
+
);
|
863 |
+
|
864 |
+
$disableReviews = Mage::helper('adminhtml')->getUrl(
|
865 |
+
'*/connector/enablewebsiteconfiguration', array(
|
866 |
+
'path' => 'XML_PATH_CONNECTOR_AUTOMATION_STUDIO_REVIEW',
|
867 |
+
'value' => '0',
|
868 |
+
'website' => $website->getId()
|
869 |
+
)
|
870 |
+
);
|
871 |
+
$disableReviews = 'Deactivated! <a href="' . $disableReviews
|
872 |
+
. '">click</a> to disable';
|
873 |
+
|
874 |
+
} else {
|
875 |
+
|
876 |
+
$disableReviews = $reviewsProgram->status;
|
877 |
+
}
|
878 |
+
}
|
879 |
+
|
880 |
+
//check for guest order program
|
881 |
+
if ($guestOrderProgram) {
|
882 |
+
|
883 |
+
if ($guestOrderProgram->status != 'Active') {
|
884 |
+
|
885 |
+
//set the status as failed
|
886 |
+
$resultContent->setStyle(self::CONNECTOR_DASHBOARD_FAILED)
|
887 |
+
->setMessage(
|
888 |
+
' Consider to disable not active programs'
|
889 |
+
);
|
890 |
+
|
891 |
+
$disableGuestOrder = Mage::helper('adminhtml')->getUrl(
|
892 |
+
'*/connector/enablewebsiteconfiguration', array(
|
893 |
+
'path' => 'XML_PATH_CONNECTOR_AUTOMATION_STUDIO_GUEST_ORDER',
|
894 |
+
'value' => '0',
|
895 |
+
'website' => $website->getId()
|
896 |
+
)
|
897 |
+
);
|
898 |
+
$disableGuestOrder = 'Deactivated! <a href="'
|
899 |
+
. $disableGuestOrder . '">click</a> to disable';
|
900 |
+
|
901 |
+
} else {
|
902 |
+
|
903 |
+
$disableGuestOrder = $guestOrderProgram->status;
|
904 |
+
}
|
905 |
+
}
|
906 |
+
|
907 |
+
//check for customer program
|
908 |
+
if ($cusProgram) {
|
909 |
+
|
910 |
+
if ($cusProgram->status != 'Active') {
|
911 |
+
|
912 |
+
//set the status as failed
|
913 |
+
$resultContent->setStyle(self::CONNECTOR_DASHBOARD_FAILED)
|
914 |
+
->setMessage(
|
915 |
+
' Consider to disable not active programs'
|
916 |
+
);
|
917 |
+
|
918 |
+
$disableCustomer = Mage::helper('adminhtml')->getUrl(
|
919 |
+
'*/connector/enablewebsiteconfiguration', array(
|
920 |
+
'path' => 'XML_PATH_CONNECTOR_AUTOMATION_STUDIO_CUSTOMER',
|
921 |
+
'value' => '0',
|
922 |
+
'website' => $website->getId()
|
923 |
+
)
|
924 |
+
);
|
925 |
+
$disableCustomer = 'Deactivated! <a href="'
|
926 |
+
. $disableCustomer . '">click</a> to disable';
|
927 |
+
|
928 |
+
} else {
|
929 |
+
|
930 |
+
$disableCustomer = $cusProgram->status;
|
931 |
+
}
|
932 |
+
}
|
933 |
+
|
934 |
+
//check for subscriber program
|
935 |
+
if ($subProgram) {
|
936 |
+
|
937 |
+
if ($subProgram->status != 'Active') {
|
938 |
+
// set the status failed
|
939 |
+
$resultContent->setStyle(self::CONNECTOR_DASHBOARD_FAILED)
|
940 |
+
->setMessage(
|
941 |
+
' Consider to disable not active programs'
|
942 |
+
);
|
943 |
+
|
944 |
+
//link to disbale config
|
945 |
+
$disableSubscriber = Mage::helper('adminhtml')->getUrl(
|
946 |
+
'*/connector/enablewebsiteconfiguration', array(
|
947 |
+
'path' => 'XML_PATH_CONNECTOR_AUTOMATION_STUDIO_SUBSCRIBER',
|
948 |
+
'value' => '0',
|
949 |
+
'website' => $website->getId()
|
950 |
+
)
|
951 |
+
);
|
952 |
+
$disableSubscriber = 'Deactivated <a href="'
|
953 |
+
. $disableSubscriber . '">click</a> to disable';
|
954 |
+
|
955 |
+
} else {
|
956 |
+
$disableSubscriber = $subProgram->status;
|
957 |
+
}
|
958 |
+
}
|
959 |
+
|
960 |
+
$tableData = array(
|
961 |
+
'Website' => $website->getName(),
|
962 |
+
'Customer Program' => (isset($cusProgram->name))
|
963 |
+
? $cusProgram->name : 'Disabled',
|
964 |
+
'Customer Status' => (isset($cusProgram->status))
|
965 |
+
? $disableCustomer : '',
|
966 |
+
'Subscriber Program' => (isset($subProgram->name))
|
967 |
+
? $subProgram->name : 'Disabled',
|
968 |
+
'Subscriber Status' => (isset($subProgram->status))
|
969 |
+
? $disableSubscriber : '',
|
970 |
+
'Order Program' => (isset($orderProgram->name))
|
971 |
+
? $orderProgram->name : 'Disabled',
|
972 |
+
'Order Status' => (isset($orderProgram->status))
|
973 |
+
? $disableOrder : '',
|
974 |
+
'Guest Order Program' => (isset($guestOrderProgram->name))
|
975 |
+
? $guestOrderProgram->name : 'Disabled',
|
976 |
+
'Guest Order Status' => (isset($guestOrderProgram->status))
|
977 |
+
? $disableGuestOrder : '',
|
978 |
+
'Review Program' => (isset($reviewsProgram->name))
|
979 |
+
? $reviewsProgram->name : 'Disabled',
|
980 |
+
'Review Status' => (isset($reviewsProgram->status))
|
981 |
+
? $disableReviews : '',
|
982 |
+
'Wishlist Program' => (isset($wishlistProgram->name))
|
983 |
+
? $wishlistProgram->name : 'Disabled',
|
984 |
+
'Wishlist Status' => (isset($wishlistProgram->status))
|
985 |
+
? $disableWishlist : '',
|
986 |
+
);
|
987 |
+
|
988 |
+
//set the content with table data
|
989 |
+
$resultContent->setTable($tableData);
|
990 |
+
|
991 |
+
}
|
992 |
+
|
993 |
+
return $resultContent;
|
994 |
+
}
|
995 |
+
|
996 |
+
/**
|
997 |
+
* Abandoned carts status.
|
998 |
+
*
|
999 |
+
* @return Dotdigitalgroup_Email_Model_Adminhtml_Dashboard_Content
|
1000 |
+
*/
|
1001 |
+
public function abandonedCartsEnabled()
|
1002 |
+
{
|
1003 |
+
$resultContent = Mage::getModel(
|
1004 |
+
'ddg_automation/adminhtml_dashboard_content'
|
1005 |
+
);
|
1006 |
+
|
1007 |
+
$resultContent->setStyle(self::CONNECTOR_DASHBOARD_PASSED)
|
1008 |
+
->setTitle('Abandoned Carts Status : ')
|
1009 |
+
->setMessage('Looks Great.');
|
1010 |
+
|
1011 |
+
foreach (Mage::app()->getWebsites() as $website) {
|
1012 |
+
$websiteName = $website->getName();
|
1013 |
+
$abandonedCusomer1 = ($website->getConfig(
|
1014 |
+
Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_ABANDONED_CARTS_ENABLED_1
|
1015 |
+
))
|
1016 |
+
? true
|
1017 |
+
:
|
1018 |
+
'Disabled!';
|
1019 |
+
$abandonedCusomer2 = ($website->getConfig(
|
1020 |
+
Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_ABANDONED_CARTS_ENABLED_2
|
1021 |
+
))
|
1022 |
+
? true
|
1023 |
+
:
|
1024 |
+
'Disabled!';
|
1025 |
+
$abandonedCusomer3 = ($website->getConfig(
|
1026 |
+
Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_ABANDONED_CARTS_ENABLED_3
|
1027 |
+
))
|
1028 |
+
? true
|
1029 |
+
:
|
1030 |
+
'Disabled!';
|
1031 |
+
$abandonedGuest1 = ($website->getConfig(
|
1032 |
+
Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_GUEST_ABANDONED_CARTS_ENABLED_1
|
1033 |
+
))
|
1034 |
+
? true
|
1035 |
+
:
|
1036 |
+
'Disabled!';
|
1037 |
+
$abandonedGuest2 = ($website->getConfig(
|
1038 |
+
Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_GUEST_ABANDONED_CARTS_ENABLED_2
|
1039 |
+
))
|
1040 |
+
? true
|
1041 |
+
:
|
1042 |
+
'Disabled!';
|
1043 |
+
$abandonedGuest3 = ($website->getConfig(
|
1044 |
+
Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_GUEST_ABANDONED_CARTS_ENABLED_3
|
1045 |
+
))
|
1046 |
+
? true
|
1047 |
+
:
|
1048 |
+
'Disabled!';
|
1049 |
+
|
1050 |
+
if ($abandonedCusomer1 !== true || $abandonedCusomer2 !== true
|
1051 |
+
|| $abandonedCusomer3 !== true
|
1052 |
+
|| $abandonedGuest1 !== true
|
1053 |
+
|| $abandonedGuest2 !== true
|
1054 |
+
|| $abandonedGuest3 !== true
|
1055 |
+
) {
|
1056 |
+
//customer abandoned links to enable
|
1057 |
+
$customer1 = Mage::helper('adminhtml')->getUrl(
|
1058 |
+
'*/connector/enablewebsiteconfiguration',
|
1059 |
+
array('path' => 'XML_PATH_CONNECTOR_CUSTOMER_ABANDONED_CARTS_ENABLED_1',
|
1060 |
+
'website' => $website->getId())
|
1061 |
+
);
|
1062 |
+
$customer2 = Mage::helper('adminhtml')->getUrl(
|
1063 |
+
'*/connector/enablewebsiteconfiguration',
|
1064 |
+
array('path' => 'XML_PATH_CONNECTOR_CUSTOMER_ABANDONED_CARTS_ENABLED_2',
|
1065 |
+
'website' => $website->getId())
|
1066 |
+
);
|
1067 |
+
$customer3 = Mage::helper('adminhtml')->getUrl(
|
1068 |
+
'*/connector/enablewebsiteconfiguration',
|
1069 |
+
array('path' => 'XML_PATH_CONNECTOR_CUSTOMER_ABANDONED_CARTS_ENABLED_3',
|
1070 |
+
'website' => $website->getId())
|
1071 |
+
);
|
1072 |
+
//guests abandoned links to enable
|
1073 |
+
$guest1 = Mage::helper('adminhtml')->getUrl(
|
1074 |
+
'*/connector/enablewebsiteconfiguration',
|
1075 |
+
array('path' => 'XML_PATH_CONNECTOR_GUEST_ABANDONED_CARTS_ENABLED_1',
|
1076 |
+
'website' => $website->getId())
|
1077 |
+
);
|
1078 |
+
$guest2 = Mage::helper('adminhtml')->getUrl(
|
1079 |
+
'*/connector/enablewebsiteconfiguration',
|
1080 |
+
array('path' => 'XML_PATH_CONNECTOR_GUEST_ABANDONED_CARTS_ENABLED_2',
|
1081 |
+
'website' => $website->getId())
|
1082 |
+
);
|
1083 |
+
$guest3 = Mage::helper('adminhtml')->getUrl(
|
1084 |
+
'*/connector/enablewebsiteconfiguration',
|
1085 |
+
array('path' => 'XML_PATH_CONNECTOR_GUEST_ABANDONED_CARTS_ENABLED_3',
|
1086 |
+
'website' => $website->getId())
|
1087 |
+
);
|
1088 |
+
|
1089 |
+
|
1090 |
+
$resultContent->setStyle(self::CONNECTOR_DASHBOARD_FAILED)
|
1091 |
+
->setMessage('Don\'t forget to map')
|
1092 |
+
->setTable(
|
1093 |
+
array(
|
1094 |
+
'Website' => $websiteName,
|
1095 |
+
'Customer Abandoned 1' => ($abandonedCusomer1
|
1096 |
+
!== true) ? $abandonedCusomer1 . ' <a href="'
|
1097 |
+
. $customer1 . '">enable</a>' : 'Enabled',
|
1098 |
+
'Customer Abandoned 2' => ($abandonedCusomer2
|
1099 |
+
!== true) ? $abandonedCusomer2 . ' <a href="'
|
1100 |
+
. $customer2 . '">enable</a>' : 'Enabled',
|
1101 |
+
'Customer Abandoned 3' => ($abandonedCusomer3
|
1102 |
+
!== true) ? $abandonedCusomer3 . ' <a href="'
|
1103 |
+
. $customer3 . '">enable</a>' : 'Enabled',
|
1104 |
+
'Guest Abandoned 1' => ($abandonedGuest1
|
1105 |
+
!== true) ? $abandonedGuest1 . ' <a href="'
|
1106 |
+
. $guest1 . '">enable</a>' : 'Enabled',
|
1107 |
+
'Guest Abandoned 2' => ($abandonedGuest2
|
1108 |
+
!== true) ? $abandonedGuest2 . ' <a href="'
|
1109 |
+
. $guest2 . '">enable</a>' : 'Enabled',
|
1110 |
+
'Guest Abandoned 3' => ($abandonedGuest3
|
1111 |
+
!== true) ? $abandonedGuest3 . ' <a href="'
|
1112 |
+
. $guest3 . '">enable</a>' : 'Enabled',
|
1113 |
+
)
|
1114 |
+
);
|
1115 |
+
}
|
1116 |
+
}
|
1117 |
+
|
1118 |
+
return $resultContent;
|
1119 |
+
}
|
1120 |
+
|
1121 |
+
/**
|
1122 |
+
* Crazy mapping checking.
|
1123 |
+
*
|
1124 |
+
* @return Dotdigitalgroup_Email_Model_Adminhtml_Dashboard_Content
|
1125 |
+
*/
|
1126 |
+
public function dataFieldMapped()
|
1127 |
+
{
|
1128 |
+
$resultContent = Mage::getModel(
|
1129 |
+
'ddg_automation/adminhtml_dashboard_content'
|
1130 |
+
);
|
1131 |
+
|
1132 |
+
$resultContent->setStyle(self::CONNECTOR_DASHBOARD_PASSED)
|
1133 |
+
->setTitle('Default Datafields Mapped Status : ')
|
1134 |
+
->setMessage('All Datafields Are Mapped.');
|
1135 |
+
|
1136 |
+
foreach (Mage::app()->getWebsites() as $website) {
|
1137 |
+
$passed = true;
|
1138 |
+
$mapped = 0;
|
1139 |
+
$tableData = array();
|
1140 |
+
//website name for table data
|
1141 |
+
$websiteName = $website->getName();
|
1142 |
+
$tableData['Website'] = $websiteName;
|
1143 |
+
if ( ! $website->getConfig(
|
1144 |
+
Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_ID
|
1145 |
+
)
|
1146 |
+
) {
|
1147 |
+
$passed = false;
|
1148 |
+
$mapped++;
|
1149 |
+
}
|
1150 |
+
if ( ! $website->getConfig(
|
1151 |
+
Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_FIRSTNAME
|
1152 |
+
)
|
1153 |
+
) {
|
1154 |
+
$passed = false;
|
1155 |
+
$mapped++;
|
1156 |
+
}
|
1157 |
+
if ( ! $website->getConfig(
|
1158 |
+
Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_LASTNAME
|
1159 |
+
)
|
1160 |
+
) {
|
1161 |
+
$passed = false;
|
1162 |
+
$mapped++;
|
1163 |
+
}
|
1164 |
+
if ( ! $website->getConfig(
|
1165 |
+
Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_DOB
|
1166 |
+
)
|
1167 |
+
) {
|
1168 |
+
$passed = false;
|
1169 |
+
$mapped++;
|
1170 |
+
}
|
1171 |
+
if ( ! $website->getConfig(
|
1172 |
+
Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_GENDER
|
1173 |
+
)
|
1174 |
+
) {
|
1175 |
+
$passed = false;
|
1176 |
+
$mapped++;
|
1177 |
+
}
|
1178 |
+
if ( ! $website->getConfig(
|
1179 |
+
Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_WEBSITE_NAME
|
1180 |
+
)
|
1181 |
+
) {
|
1182 |
+
$passed = false;
|
1183 |
+
$mapped++;
|
1184 |
+
}
|
1185 |
+
if ( ! $website->getConfig(
|
1186 |
+
Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_STORE_NAME
|
1187 |
+
)
|
1188 |
+
) {
|
1189 |
+
$passed = false;
|
1190 |
+
$mapped++;
|
1191 |
+
}
|
1192 |
+
if ( ! $website->getConfig(
|
1193 |
+
Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_CREATED_AT
|
1194 |
+
)
|
1195 |
+
) {
|
1196 |
+
$passed = false;
|
1197 |
+
$mapped++;
|
1198 |
+
}
|
1199 |
+
if ( ! $website->getConfig(
|
1200 |
+
Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_LAST_LOGGED_DATE
|
1201 |
+
)
|
1202 |
+
) {
|
1203 |
+
$passed = false;
|
1204 |
+
$mapped++;
|
1205 |
+
}
|
1206 |
+
if ( ! $website->getConfig(
|
1207 |
+
Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_CUSTOMER_GROUP
|
1208 |
+
)
|
1209 |
+
) {
|
1210 |
+
$passed = false;
|
1211 |
+
$mapped++;
|
1212 |
+
}
|
1213 |
+
if ( ! $website->getConfig(
|
1214 |
+
Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_REVIEW_COUNT
|
1215 |
+
)
|
1216 |
+
) {
|
1217 |
+
$passed = false;
|
1218 |
+
$mapped++;
|
1219 |
+
}
|
1220 |
+
if ( ! $website->getConfig(
|
1221 |
+
Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_LAST_REVIEW_DATE
|
1222 |
+
)
|
1223 |
+
) {
|
1224 |
+
$passed = false;
|
1225 |
+
$mapped++;
|
1226 |
+
}
|
1227 |
+
if ( ! $website->getConfig(
|
1228 |
+
Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_BILLING_ADDRESS_1
|
1229 |
+
)
|
1230 |
+
) {
|
1231 |
+
$passed = false;
|
1232 |
+
$mapped++;
|
1233 |
+
}
|
1234 |
+
if ( ! $website->getConfig(
|
1235 |
+
Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_BILLING_ADDRESS_2
|
1236 |
+
)
|
1237 |
+
) {
|
1238 |
+
$passed = false;
|
1239 |
+
$mapped++;
|
1240 |
+
}
|
1241 |
+
if ( ! $website->getConfig(
|
1242 |
+
Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_BILLING_CITY
|
1243 |
+
)
|
1244 |
+
) {
|
1245 |
+
$passed = false;
|
1246 |
+
$mapped++;
|
1247 |
+
}
|
1248 |
+
if ( ! $website->getConfig(
|
1249 |
+
Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_BILLING_STATE
|
1250 |
+
)
|
1251 |
+
) {
|
1252 |
+
$passed = false;
|
1253 |
+
$mapped++;
|
1254 |
+
}
|
1255 |
+
if ( ! $website->getConfig(
|
1256 |
+
Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_BILLING_COUNTRY
|
1257 |
+
)
|
1258 |
+
) {
|
1259 |
+
$passed = false;
|
1260 |
+
$mapped++;
|
1261 |
+
}
|
1262 |
+
if ( ! $website->getConfig(
|
1263 |
+
Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_BILLING_POSTCODE
|
1264 |
+
)
|
1265 |
+
) {
|
1266 |
+
$passed = false;
|
1267 |
+
$mapped++;
|
1268 |
+
}
|
1269 |
+
if ( ! $website->getConfig(
|
1270 |
+
Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_BILLING_TELEPHONE
|
1271 |
+
)
|
1272 |
+
) {
|
1273 |
+
$passed = false;
|
1274 |
+
$mapped++;
|
1275 |
+
}
|
1276 |
+
if ( ! $website->getConfig(
|
1277 |
+
Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_DELIVERY_ADDRESS_1
|
1278 |
+
)
|
1279 |
+
) {
|
1280 |
+
$passed = false;
|
1281 |
+
$mapped++;
|
1282 |
+
}
|
1283 |
+
if ( ! $website->getConfig(
|
1284 |
+
Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_DELIVERY_ADDRESS_2
|
1285 |
+
)
|
1286 |
+
) {
|
1287 |
+
$passed = false;
|
1288 |
+
$mapped++;
|
1289 |
+
}
|
1290 |
+
if ( ! $website->getConfig(
|
1291 |
+
Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_DELIVERY_CITY
|
1292 |
+
)
|
1293 |
+
) {
|
1294 |
+
$passed = false;
|
1295 |
+
$mapped++;
|
1296 |
+
}
|
1297 |
+
if ( ! $website->getConfig(
|
1298 |
+
Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_DELIVERY_STATE
|
1299 |
+
)
|
1300 |
+
) {
|
1301 |
+
$passed = false;
|
1302 |
+
$mapped++;
|
1303 |
+
}
|
1304 |
+
if ( ! $website->getConfig(
|
1305 |
+
Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_DELIVERY_COUNTRY
|
1306 |
+
)
|
1307 |
+
) {
|
1308 |
+
$passed = false;
|
1309 |
+
$mapped++;
|
1310 |
+
}
|
1311 |
+
if ( ! $website->getConfig(
|
1312 |
+
Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_DELIVERY_POSTCODE
|
1313 |
+
)
|
1314 |
+
) {
|
1315 |
+
$passed = false;
|
1316 |
+
$mapped++;
|
1317 |
+
}
|
1318 |
+
if ( ! $website->getConfig(
|
1319 |
+
Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_DELIVERY_TELEPHONE
|
1320 |
+
)
|
1321 |
+
) {
|
1322 |
+
$passed = false;
|
1323 |
+
$mapped++;
|
1324 |
+
}
|
1325 |
+
if ( ! $website->getConfig(
|
1326 |
+
Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_TOTAL_NUMBER_ORDER
|
1327 |
+
)
|
1328 |
+
) {
|
1329 |
+
$passed = false;
|
1330 |
+
$mapped++;
|
1331 |
+
}
|
1332 |
+
if ( ! $website->getConfig(
|
1333 |
+
Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_AOV
|
1334 |
+
)
|
1335 |
+
) {
|
1336 |
+
$passed = false;
|
1337 |
+
$mapped++;
|
1338 |
+
}
|
1339 |
+
if ( ! $website->getConfig(
|
1340 |
+
Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_TOTAL_SPEND
|
1341 |
+
)
|
1342 |
+
) {
|
1343 |
+
$passed = false;
|
1344 |
+
$mapped++;
|
1345 |
+
}
|
1346 |
+
if ( ! $website->getConfig(
|
1347 |
+
Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_LAST_ORDER_DATE
|
1348 |
+
)
|
1349 |
+
) {
|
1350 |
+
$passed = false;
|
1351 |
+
$mapped++;
|
1352 |
+
}
|
1353 |
+
if ( ! $website->getConfig(
|
1354 |
+
Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_LAST_ORDER_ID
|
1355 |
+
)
|
1356 |
+
) {
|
1357 |
+
$passed = false;
|
1358 |
+
$mapped++;
|
1359 |
+
}
|
1360 |
+
if ( ! $website->getConfig(
|
1361 |
+
Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_MAPPING_CUSTOMER_TOTALREFUND
|
1362 |
+
)
|
1363 |
+
) {
|
1364 |
+
$passed = false;
|
1365 |
+
$mapped++;
|
1366 |
+
}
|
1367 |
+
if ( ! $website->getConfig(
|
1368 |
+
Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_SUBSCRIBER_STATUS
|
1369 |
+
)
|
1370 |
+
) {
|
1371 |
+
$passed = false;
|
1372 |
+
$mapped++;
|
1373 |
+
}
|
1374 |
+
$tableData['Mapped Percentage'] = number_format(
|
1375 |
+
(1 - $mapped / 32) * 100, 2
|
1376 |
+
) . ' %';
|
1377 |
+
//mapping not complete.
|
1378 |
+
if ( ! $passed) {
|
1379 |
+
$url = Mage::helper('adminhtml')->getUrl(
|
1380 |
+
'*/system_config/edit/section/connector_data_mapping/website/'
|
1381 |
+
. $website->getCode()
|
1382 |
+
);
|
1383 |
+
$resultContent->setStyle(self::CONNECTOR_DASHBOARD_FAILED)
|
1384 |
+
->setMessage(
|
1385 |
+
'Click <a href="' . $url
|
1386 |
+
. '">here</a> to change mapping configuration.'
|
1387 |
+
);
|
1388 |
+
}
|
1389 |
+
$resultContent->setTable($tableData);
|
1390 |
+
}
|
1391 |
Â
|
1392 |
+
return $resultContent;
|
1393 |
+
}
|
1394 |
Â
|
Â
|
|
Â
|
|
Â
|
|
1395 |
Â
|
1396 |
+
/**
|
1397 |
+
* Validate API Credentials.
|
1398 |
+
*
|
1399 |
+
* @return Dotdigitalgroup_Email_Model_Adminhtml_Dashboard_Content
|
1400 |
+
*/
|
1401 |
+
public function validApiCredentials()
|
1402 |
+
{
|
1403 |
+
$resultContent = Mage::getModel(
|
1404 |
+
'ddg_automation/adminhtml_dashboard_content'
|
1405 |
+
);
|
1406 |
+
$resultContent->setStyle(self::CONNECTOR_DASHBOARD_PASSED)
|
1407 |
+
->setTitle('API Credentials Status : ')
|
1408 |
+
->setMessage('Valid.');
|
1409 |
+
$helper = Mage::helper('ddg');
|
1410 |
+
foreach (Mage::app()->getWebsites() as $website) {
|
1411 |
+
$websiteName = $website->getName();
|
1412 |
+
$websiteId = $website->getId();
|
1413 |
Â
|
1414 |
+
$apiUsername = $helper->getApiUsername($websiteId);
|
1415 |
+
$apiPassword = $helper->getApiPassword($websiteId);
|
1416 |
Â
|
1417 |
+
$api = Mage::getModel('ddg_automation/apiconnector_test')
|
1418 |
+
->ajaxvalidate($apiUsername, $apiPassword);
|
Â
|
|
1419 |
Â
|
1420 |
+
if ($api != 'Credentials Valid.') {
|
1421 |
+
$url = Mage::helper('adminhtml')->getUrl(
|
1422 |
+
'*/system_config/edit/section/connector_api_credentials/website/'
|
1423 |
+
. $website->getCode()
|
1424 |
+
);
|
1425 |
+
|
1426 |
+
$resultContent->setStyle(self::CONNECTOR_DASHBOARD_FAILED)
|
1427 |
+
->setMessage('')
|
1428 |
+
->setTable(
|
1429 |
+
array(
|
1430 |
+
'Website' => $websiteName,
|
1431 |
+
'Status' => $api,
|
1432 |
+
'Fast Fix' => 'Click <a href="' . $url
|
1433 |
+
. '">here</a> to enter new api credentials.'
|
1434 |
Â
)
|
1435 |
Â
);
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
1436 |
Â
}
|
1437 |
+
}
|
1438 |
Â
|
1439 |
+
return $resultContent;
|
1440 |
+
}
|
1441 |
Â
|
1442 |
+
/**
|
1443 |
+
* Order sync enabled.
|
1444 |
+
*
|
1445 |
+
* @return Dotdigitalgroup_Email_Model_Adminhtml_Dashboard_Content
|
1446 |
+
*/
|
1447 |
+
public function orderEnabled()
|
1448 |
+
{
|
1449 |
+
$resultContent = Mage::getModel(
|
1450 |
+
'ddg_automation/adminhtml_dashboard_content'
|
1451 |
+
);
|
1452 |
+
$resultContent->setStyle(self::CONNECTOR_DASHBOARD_PASSED)
|
1453 |
+
->setTitle('Order Sync : ')
|
1454 |
+
->setMessage('Enabled.');
|
1455 |
Â
|
1456 |
+
$passed = true;
|
1457 |
+
foreach (Mage::app()->getWebsites() as $website) {
|
1458 |
+
$websiteName = $website->getName();
|
1459 |
+
$order = ($website->getConfig(
|
1460 |
+
Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_SYNC_ORDER_ENABLED
|
1461 |
+
))
|
1462 |
+
? true
|
1463 |
+
:
|
1464 |
+
'Disabled!';
|
1465 |
Â
|
1466 |
+
if ($order !== true) {
|
1467 |
+
|
1468 |
+
$url = Mage::helper('adminhtml')->getUrl(
|
1469 |
+
'*/connector/enablewebsiteconfiguration',
|
1470 |
+
array('path' => 'XML_PATH_CONNECTOR_SYNC_ORDER_ENABLED',
|
1471 |
+
'website' => $website->getId())
|
1472 |
+
);
|
1473 |
+
$resultContent->setStyle(self::CONNECTOR_DASHBOARD_FAILED)
|
1474 |
+
->setMessage('')
|
1475 |
+
->setTable(
|
1476 |
+
array(
|
1477 |
+
'Website' => $websiteName,
|
1478 |
+
'Status' => $order . ' <a href="' . $url
|
1479 |
+
. '">enable</a>'
|
1480 |
Â
)
|
1481 |
Â
);
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
1482 |
Â
$passed = false;
|
Â
|
|
1483 |
Â
}
|
1484 |
+
}
|
1485 |
+
//validation failed
|
1486 |
+
if ( ! $passed) {
|
1487 |
+
$resultContent->setHowto(self::FAST_FIX_MESSAGE);
|
1488 |
+
}
|
1489 |
+
|
1490 |
+
return $resultContent;
|
1491 |
+
}
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
1492 |
Â
|
1493 |
Â
/**
|
1494 |
Â
* check if any custom order attribute selected
|
1495 |
+
*
|
1496 |
Â
* @return Dotdigitalgroup_Email_Model_Adminhtml_Dashboard_Content
|
1497 |
Â
*/
|
1498 |
Â
public function customOrderAttributes()
|
1499 |
Â
{
|
1500 |
+
$resultContent = Mage::getModel(
|
1501 |
+
'ddg_automation/adminhtml_dashboard_content'
|
1502 |
+
);
|
1503 |
Â
$resultContent->setStyle(self::CONNECTOR_DASHBOARD_PASSED)
|
1504 |
Â
->setTitle('Custom Order Attributes : ')
|
1505 |
Â
->setMessage('Selected.');
|
1506 |
Â
|
1507 |
+
foreach (Mage::app()->getWebsites() as $website) {
|
1508 |
+
$websiteName = $website->getName();
|
1509 |
+
$customOrderAttibute = ($website->getConfig(
|
1510 |
+
Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOM_ORDER_ATTRIBUTES
|
1511 |
+
)) ? true : false;
|
1512 |
Â
|
1513 |
+
if ($customOrderAttibute !== true) {
|
1514 |
+
$resultContent->setStyle(self::CONNECTOR_DASHBOARD_FAILED)
|
1515 |
+
->setTitle(
|
1516 |
+
'Custom order attribute not selected (ignore if you do not want to import custom order attributes) :'
|
1517 |
+
)
|
1518 |
Â
->setMessage('')
|
1519 |
+
->setTable(
|
1520 |
+
array(
|
1521 |
+
'Website' => $websiteName,
|
1522 |
+
'Status' => 'No Custom Order Attribute Selected'
|
1523 |
+
)
|
1524 |
+
);
|
1525 |
Â
}
|
1526 |
Â
}
|
1527 |
Â
|
1528 |
Â
return $resultContent;
|
1529 |
Â
}
|
1530 |
Â
|
1531 |
+
/**
|
1532 |
+
* Check if any orders are imported.
|
1533 |
+
*
|
1534 |
+
* @return Dotdigitalgroup_Email_Model_Adminhtml_Dashboard_Content
|
1535 |
+
*/
|
1536 |
+
public function orderSyncing()
|
1537 |
+
{
|
1538 |
+
$resultContent = Mage::getModel(
|
1539 |
+
'ddg_automation/adminhtml_dashboard_content'
|
1540 |
+
);
|
1541 |
+
$resultContent->setStyle(self::CONNECTOR_DASHBOARD_PASSED)
|
1542 |
+
->setTitle('Order Syncing : ')
|
1543 |
+
->setMessage('Looks Great.');
|
1544 |
+
|
1545 |
+
foreach (Mage::app()->getWebsites() as $website) {
|
1546 |
+
$websiteName = $website->getName();
|
1547 |
+
$storeIds = $website->getStoreIds();
|
1548 |
+
|
1549 |
+
if (empty($storeIds)) {
|
1550 |
+
continue;
|
1551 |
+
}
|
1552 |
+
|
1553 |
+
//numbser of orders marked as imported
|
1554 |
+
$numOrders = Mage::getModel('ddg_automation/order')->getCollection()
|
1555 |
+
->addFieldToFilter('email_imported', 1)
|
1556 |
+
->addFieldToFilter('store_id', array('in', $storeIds))->getSize(
|
1557 |
+
);
|
1558 |
+
|
1559 |
+
if ( ! $numOrders) {
|
1560 |
+
$resultContent->setStyle(self::CONNECTOR_DASHBOARD_FAILED)
|
1561 |
+
->setTitle(
|
1562 |
+
'Order Syncing (ignore if you have reset orders for reimport) :'
|
1563 |
+
)
|
1564 |
+
->setMessage('')
|
1565 |
+
->setTable(
|
1566 |
+
array(
|
1567 |
+
'Website' => $websiteName,
|
1568 |
+
'Status' => 'No Imported Orders Found'
|
1569 |
+
)
|
1570 |
+
);
|
1571 |
+
}
|
1572 |
+
}
|
1573 |
+
|
1574 |
+
return $resultContent;
|
1575 |
+
|
1576 |
+
}
|
1577 |
Â
|
1578 |
Â
/**
|
1579 |
Â
* Quote sync enabled.
|
1580 |
+
*
|
1581 |
Â
* @return Dotdigitalgroup_Email_Model_Adminhtml_Dashboard_Content
|
1582 |
Â
*/
|
1583 |
Â
public function quoteEnabled()
|
1584 |
Â
{
|
1585 |
+
$resultContent = Mage::getModel(
|
1586 |
+
'ddg_automation/adminhtml_dashboard_content'
|
1587 |
+
);
|
1588 |
Â
$resultContent->setStyle(self::CONNECTOR_DASHBOARD_PASSED)
|
1589 |
Â
->setTitle('Quote Sync : ')
|
1590 |
Â
->setMessage('Enabled.');
|
1591 |
Â
|
1592 |
Â
$passed = true;
|
1593 |
+
foreach (Mage::app()->getWebsites() as $website) {
|
1594 |
+
$websiteName = $website->getName();
|
1595 |
+
$quote = ($website->getConfig(
|
1596 |
+
Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_SYNC_QUOTE_ENABLED
|
1597 |
+
))
|
1598 |
+
? true
|
1599 |
+
:
|
1600 |
Â
'Disabled!';
|
1601 |
Â
|
1602 |
+
if ($quote !== true) {
|
1603 |
Â
|
1604 |
+
$url = Mage::helper('adminhtml')->getUrl(
|
1605 |
+
'*/connector/enablewebsiteconfiguration',
|
1606 |
+
array('path' => 'XML_PATH_CONNECTOR_SYNC_QUOTE_ENABLED',
|
1607 |
+
'website' => $website->getId())
|
1608 |
+
);
|
1609 |
+
$resultContent->setStyle(self::CONNECTOR_DASHBOARD_FAILED)
|
1610 |
Â
->setMessage('')
|
1611 |
+
->setTable(
|
1612 |
+
array(
|
1613 |
+
'Website' => $websiteName,
|
1614 |
+
'Status' => $quote . ' <a href="' . $url
|
1615 |
+
. '">enable</a>'
|
1616 |
+
)
|
1617 |
+
);
|
1618 |
Â
$passed = false;
|
1619 |
Â
}
|
1620 |
Â
}
|
1621 |
Â
//validation failed
|
1622 |
+
if ( ! $passed) {
|
1623 |
Â
$resultContent->setHowto(self::FAST_FIX_MESSAGE);
|
1624 |
Â
}
|
1625 |
Â
|
1628 |
Â
|
1629 |
Â
/**
|
1630 |
Â
* check if any custom quote attribute selected
|
1631 |
+
*
|
1632 |
Â
* @return Dotdigitalgroup_Email_Model_Adminhtml_Dashboard_Content
|
1633 |
Â
*/
|
1634 |
Â
public function customQuoteAttributes()
|
1635 |
Â
{
|
1636 |
+
$resultContent = Mage::getModel(
|
1637 |
+
'ddg_automation/adminhtml_dashboard_content'
|
1638 |
+
);
|
1639 |
Â
$resultContent->setStyle(self::CONNECTOR_DASHBOARD_PASSED)
|
1640 |
Â
->setTitle('Custom Quote Attributes : ')
|
1641 |
Â
->setMessage('Selected.');
|
1642 |
Â
|
1643 |
+
foreach (Mage::app()->getWebsites() as $website) {
|
1644 |
+
$websiteName = $website->getName();
|
1645 |
+
$customQuoteAttribute = ($website->getConfig(
|
1646 |
+
Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOM_QUOTE_ATTRIBUTES
|
1647 |
+
)) ? true : false;
|
1648 |
Â
|
1649 |
+
if ($customQuoteAttribute !== true) {
|
1650 |
+
$resultContent->setStyle(self::CONNECTOR_DASHBOARD_FAILED)
|
1651 |
+
->setTitle(
|
1652 |
+
'Custom quote attribute not selected (ignore if you do not want to import custom quote attributes) :'
|
1653 |
+
)
|
1654 |
Â
->setMessage('')
|
1655 |
+
->setTable(
|
1656 |
+
array(
|
1657 |
+
'Website' => $websiteName,
|
1658 |
+
'Status' => 'No Custom Quote Attribute Selected'
|
1659 |
+
)
|
1660 |
+
);
|
1661 |
Â
}
|
1662 |
Â
}
|
1663 |
Â
|
1666 |
Â
|
1667 |
Â
/**
|
1668 |
Â
* Check if any quote are imported.
|
1669 |
+
*
|
1670 |
Â
* @return Dotdigitalgroup_Email_Model_Adminhtml_Dashboard_Content
|
1671 |
Â
*/
|
1672 |
Â
public function quoteSyncing()
|
1673 |
Â
{
|
1674 |
+
$resultContent = Mage::getModel(
|
1675 |
+
'ddg_automation/adminhtml_dashboard_content'
|
1676 |
+
);
|
1677 |
Â
$resultContent->setStyle(self::CONNECTOR_DASHBOARD_PASSED)
|
1678 |
Â
->setTitle('Quote Syncing : ')
|
1679 |
Â
->setMessage('Looks Great.');
|
1680 |
Â
|
1681 |
+
foreach (Mage::app()->getWebsites() as $website) {
|
1682 |
+
$websiteName = $website->getName();
|
1683 |
+
$storeIds = $website->getStoreIds();
|
1684 |
Â
|
1685 |
+
if (empty($storeIds)) {
|
1686 |
+
continue;
|
1687 |
+
}
|
1688 |
Â
|
1689 |
Â
//number of quote marked as imported
|
1690 |
Â
$numQuotes = Mage::getModel('ddg_automation/quote')->getCollection()
|
1691 |
Â
->addFieldToFilter('imported', 1)
|
1692 |
+
->addFieldToFilter('store_id', array('in', $storeIds))->getSize(
|
1693 |
+
);
|
1694 |
Â
|
1695 |
+
if ( ! $numQuotes) {
|
1696 |
+
$resultContent->setStyle(self::CONNECTOR_DASHBOARD_FAILED)
|
1697 |
+
->setTitle(
|
1698 |
+
'Quote Syncing (ignore if you have reset quote for re-import) :'
|
1699 |
+
)
|
1700 |
Â
->setMessage('')
|
1701 |
+
->setTable(
|
1702 |
+
array(
|
1703 |
+
'Website' => $websiteName,
|
1704 |
+
'Status' => 'No Imported Quotes Found'
|
1705 |
+
)
|
1706 |
+
);
|
1707 |
Â
}
|
1708 |
Â
}
|
1709 |
Â
|
1713 |
Â
|
1714 |
Â
/**
|
1715 |
Â
* review sync enabled.
|
1716 |
+
*
|
1717 |
Â
* @return Dotdigitalgroup_Email_Model_Adminhtml_Dashboard_Content
|
1718 |
Â
* Display the transactional data for orders to be removed.
|
1719 |
Â
*/
|
1720 |
Â
public function reviewEnabled()
|
1721 |
Â
{
|
1722 |
+
$resultContent = Mage::getModel(
|
1723 |
+
'ddg_automation/adminhtml_dashboard_content'
|
1724 |
+
);
|
1725 |
Â
$resultContent->setStyle(self::CONNECTOR_DASHBOARD_PASSED)
|
1726 |
Â
->setTitle('Review Sync : ')
|
1727 |
Â
->setMessage('Enabled.');
|
1728 |
Â
|
1729 |
+
foreach (Mage::app()->getWebsites() as $website) {
|
1730 |
+
$websiteName = $website->getName();
|
1731 |
+
$review = ($website->getConfig(
|
1732 |
+
Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_SYNC_REVIEW_ENABLED
|
1733 |
+
))
|
1734 |
+
? true
|
1735 |
+
:
|
1736 |
Â
'Disabled';
|
1737 |
Â
|
1738 |
+
if ($review !== true) {
|
1739 |
+
$url = Mage::helper('adminhtml')->getUrl(
|
1740 |
+
'*/connector/enablewebsiteconfiguration',
|
1741 |
+
array('path' => 'XML_PATH_CONNECTOR_SYNC_REVIEW_ENABLED',
|
1742 |
+
'website' => $website->getId())
|
1743 |
+
);
|
1744 |
+
$resultContent->setStyle(self::CONNECTOR_DASHBOARD_FAILED)
|
1745 |
+
->setMessage(
|
1746 |
+
'Don\'t forget to enable if you want to sync reviews.'
|
1747 |
+
)
|
1748 |
+
->setTable(
|
1749 |
+
array(
|
1750 |
+
'Website' => $websiteName,
|
1751 |
+
'Status' => $review,
|
1752 |
+
'Fast Fix' => 'Click <a href="' . $url
|
1753 |
+
. '">here </a>to enable.'
|
1754 |
+
)
|
1755 |
+
);
|
1756 |
Â
}
|
1757 |
Â
}
|
1758 |
+
|
1759 |
Â
return $resultContent;
|
1760 |
Â
}
|
1761 |
Â
|
1762 |
Â
/**
|
1763 |
Â
* Check if any reviews are imported.
|
1764 |
+
*
|
1765 |
Â
* @return Dotdigitalgroup_Email_Model_Adminhtml_Dashboard_Content
|
1766 |
Â
*/
|
1767 |
Â
public function reviewSyncing()
|
1768 |
Â
{
|
1769 |
+
$resultContent = Mage::getModel(
|
1770 |
+
'ddg_automation/adminhtml_dashboard_content'
|
1771 |
+
);
|
1772 |
Â
$resultContent->setStyle(self::CONNECTOR_DASHBOARD_PASSED)
|
1773 |
Â
->setTitle('Review Syncing : ')
|
1774 |
Â
->setMessage('Looks Great.');
|
1775 |
Â
|
1776 |
+
foreach (Mage::app()->getWebsites() as $website) {
|
1777 |
+
$websiteName = $website->getName();
|
1778 |
+
$storeIds = $website->getStoreIds();
|
1779 |
Â
|
1780 |
+
if (empty($storeIds)) {
|
1781 |
+
continue;
|
1782 |
+
}
|
1783 |
Â
|
1784 |
Â
//number of reviews marked as imported
|
1785 |
+
$numReview = Mage::getModel('ddg_automation/review')->getCollection(
|
1786 |
+
)
|
1787 |
Â
->addFieldToFilter('review_imported', 1)
|
1788 |
Â
->addFieldToFilter('store_id', array('in', $storeIds))
|
1789 |
Â
->getSize();
|
1790 |
Â
|
1791 |
Â
//total reviews
|
1792 |
+
$totalReview = Mage::getModel('ddg_automation/review')
|
1793 |
+
->getCollection()
|
1794 |
Â
->addFieldToFilter('store_id', array('in', $storeIds))
|
1795 |
Â
->getSize();
|
1796 |
Â
|
1797 |
Â
$tableData = array(
|
1798 |
+
'Website' => $websiteName,
|
1799 |
Â
'Total Reviews' => $totalReview,
|
1800 |
+
'Imported' => $numReview
|
1801 |
Â
);
|
1802 |
Â
|
1803 |
Â
$tableData['Status'] = 'Importing';
|
1804 |
Â
|
1805 |
+
if ( ! $numReview) {
|
1806 |
Â
$tableData['Status'] = 'No Imported Review Found.';
|
1807 |
Â
$resultContent->setStyle(self::CONNECTOR_DASHBOARD_FAILED)
|
1808 |
+
->setTitle(
|
1809 |
+
'Review Sync (ignore if you have reset wishlist) : '
|
1810 |
+
)
|
1811 |
Â
->setMessage('');
|
1812 |
Â
}
|
1813 |
Â
$resultContent->setTable($tableData);
|
1814 |
Â
}
|
1815 |
+
|
1816 |
+
return $resultContent;
|
1817 |
+
}
|
1818 |
+
|
1819 |
+
/**
|
1820 |
+
* Get the last date for abandaned carts.
|
1821 |
+
*
|
1822 |
+
* @return Dotdigitalgroup_Email_Model_Adminhtml_Dashboard_Content
|
1823 |
+
*/
|
1824 |
+
public function lastAbandonedCartSentDay()
|
1825 |
+
{
|
1826 |
+
$resultContent = Mage::getModel(
|
1827 |
+
'ddg_automation/adminhtml_dashboard_content'
|
1828 |
+
);
|
1829 |
+
$resultContent->setStyle(self::CONNECTOR_DASHBOARD_PASSED)
|
1830 |
+
->setTitle('Last Abandoned Summary : ');
|
1831 |
+
|
1832 |
+
foreach (Mage::app()->getWebsites() as $website) {
|
1833 |
+
|
1834 |
+
$websiteName = $website->getName();
|
1835 |
+
$client = Mage::helper('ddg')->getWebsiteApiClient($website);
|
1836 |
+
|
1837 |
+
//customer carts
|
1838 |
+
$customerCampaign1 = $website->getConfig(
|
1839 |
+
Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_ABANDONED_CAMPAIGN_1
|
1840 |
+
);
|
1841 |
+
$customerCampaign2 = $website->getConfig(
|
1842 |
+
Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_ABANDONED_CAMPAIGN_2
|
1843 |
+
);
|
1844 |
+
$customerCampaign3 = $website->getConfig(
|
1845 |
+
Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_ABANDONED_CAMPAIGN_3
|
1846 |
+
);
|
1847 |
+
|
1848 |
+
//guests carts
|
1849 |
+
$guestCampaign1 = $website->getConfig(
|
1850 |
+
Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_GUEST_ABANDONED_CAMPAIGN_1
|
1851 |
+
);
|
1852 |
+
$guestCampaign2 = $website->getConfig(
|
1853 |
+
Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_GUEST_ABANDONED_CAMPAIGN_2
|
1854 |
+
);
|
1855 |
+
$guestCampaign3 = $website->getConfig(
|
1856 |
+
Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_GUEST_ABANDONED_CAMPAIGN_3
|
1857 |
+
);
|
1858 |
+
|
1859 |
+
|
1860 |
+
//date customer carts
|
1861 |
+
|
1862 |
+
$cusDateSent1 = ($customerCampaign1) ? $client->getCampaignSummary(
|
1863 |
+
$customerCampaign1
|
1864 |
+
) : '';
|
1865 |
+
$cusDateSent2 = ($customerCampaign2) ? $client->getCampaignSummary(
|
1866 |
+
$customerCampaign2
|
1867 |
+
) : '';
|
1868 |
+
$cusDateSent3 = ($customerCampaign3) ? $client->getCampaignSummary(
|
1869 |
+
$customerCampaign3
|
1870 |
+
) : '';
|
1871 |
+
|
1872 |
+
//date guest carts
|
1873 |
+
$resGuest1 = ($guestCampaign1) ? $client->getCampaignSummary(
|
1874 |
+
$guestCampaign1
|
1875 |
+
) : '';
|
1876 |
+
$resGuest2 = ($guestCampaign2) ? $client->getCampaignSummary(
|
1877 |
+
$guestCampaign2
|
1878 |
+
) : '';
|
1879 |
+
$resGuest3 = ($guestCampaign3) ? $client->getCampaignSummary(
|
1880 |
+
$guestCampaign3
|
1881 |
+
) : '';
|
1882 |
+
|
1883 |
+
/**
|
1884 |
+
* Customers.
|
1885 |
+
*/
|
1886 |
+
$customerCampaign1 = (isset($cusDateSent1->dateSent)
|
1887 |
+
? $cusDateSent1->dateSent : 'Not Sent/Selected');
|
1888 |
+
$customerCampaign2 = (isset($cusDateSent2->dateSent)
|
1889 |
+
? $cusDateSent2->dateSent : 'Not Sent/Selected');
|
1890 |
+
$customerCampaign3 = (isset($cusDateSent3->dateSent)
|
1891 |
+
? $cusDateSent3->dateSent : 'Not Sent/Selected');
|
1892 |
+
|
1893 |
+
/**
|
1894 |
+
* Guests.
|
1895 |
+
*/
|
1896 |
+
$guestCampaign1 = (isset($resGuest1->dateSent)
|
1897 |
+
? $resGuest1->dateSent : 'Not Sent/Selected');
|
1898 |
+
$guestCampaign2 = (isset($resGuest2->dateSent)
|
1899 |
+
? $resGuest2->dateSent : 'Not Sent/Selected');
|
1900 |
+
$guestCampaign3 = (isset($resGuest3->dateSent)
|
1901 |
+
? $resGuest3->dateSent : 'Not Sent/Selected');
|
1902 |
+
|
1903 |
+
|
1904 |
+
$resultContent->setTable(
|
1905 |
+
array(
|
1906 |
+
'Website' => $websiteName,
|
1907 |
+
'Customer Campaign 1' => $customerCampaign1,
|
1908 |
+
'Customer Campaign 2' => $customerCampaign2,
|
1909 |
+
'Customer Campaign 3' => $customerCampaign3,
|
1910 |
+
'Guest Campaign 1' => $guestCampaign1,
|
1911 |
+
'Guest Campaign 2' => $guestCampaign2,
|
1912 |
+
'Guest Campaign 3' => $guestCampaign3
|
1913 |
+
)
|
1914 |
+
);
|
1915 |
+
}
|
1916 |
+
|
1917 |
+
return $resultContent;
|
1918 |
+
}
|
1919 |
+
|
1920 |
+
/**
|
1921 |
+
* Conflict checker.
|
1922 |
+
*
|
1923 |
+
* @return Dotdigitalgroup_Email_Model_Adminhtml_Dashboard_Content
|
1924 |
+
*/
|
1925 |
+
public function conflictCheck()
|
1926 |
+
{
|
1927 |
+
$resultContent = Mage::getModel(
|
1928 |
+
'ddg_automation/adminhtml_dashboard_content'
|
1929 |
+
);
|
1930 |
+
$resultContent->setStyle(self::CONNECTOR_DASHBOARD_PASSED)
|
1931 |
+
->setTitle('Conflict Status : ')
|
1932 |
+
->setMessage('Looks Great.');
|
1933 |
+
|
1934 |
+
//check the module override and conflict
|
1935 |
+
$rewrites = Mage::helper('ddg/dashboard')->getRewrites();
|
1936 |
+
|
1937 |
+
|
1938 |
+
if ($rewrites === false) {
|
1939 |
+
$resultContent->setStyle(self::CONNECTOR_DASHBOARD_PASSED)
|
1940 |
+
->setMessage('No Conflict Rewrites Found.');
|
1941 |
+
} else {
|
1942 |
+
|
1943 |
+
$types = array('blocks', 'models', 'helpers');
|
1944 |
+
foreach ($types as $t) {
|
1945 |
+
|
1946 |
+
if ( ! empty($rewrites[$t])) {
|
1947 |
+
|
1948 |
+
$resultContent->setStyle(self::CONNECTOR_DASHBOARD_FAILED)
|
1949 |
+
->setMessage('Conflicting Rewrite Found : ');
|
1950 |
+
|
1951 |
+
foreach ($rewrites[$t] as $node => $rewriteInfo) {
|
1952 |
+
|
1953 |
+
$resultContent->setTable(
|
1954 |
+
array(
|
1955 |
+
'Type' => $t,
|
1956 |
+
'Class' => implode(
|
1957 |
+
', ', array_values($rewriteInfo['classes'])
|
1958 |
+
),
|
1959 |
+
'Rewrites' => '',
|
1960 |
+
'Loaded Class' => ''
|
1961 |
+
)
|
1962 |
+
);
|
1963 |
+
}
|
1964 |
+
}
|
1965 |
+
}
|
1966 |
+
|
1967 |
+
$conflictCounter = 0;
|
1968 |
+
$tableData = array();
|
1969 |
+
foreach ($rewrites as $type => $data) {
|
1970 |
+
if (count($data) > 0 && is_array($data)) {
|
1971 |
+
|
1972 |
+
foreach ($data as $class => $rewriteClass) {
|
1973 |
+
|
1974 |
+
if (count($rewriteClass) > 1) {
|
1975 |
+
if ($this->_isInheritanceConflict($rewriteClass)) {
|
1976 |
+
|
1977 |
+
$resultContent->setTable(
|
1978 |
+
array(
|
1979 |
+
'Type' => $type,
|
1980 |
+
'Class' => $class,
|
1981 |
+
'Rewrites' => implode(
|
1982 |
+
', ', $rewriteClass['classes']
|
1983 |
+
),
|
1984 |
+
'Loaded Class' => $this->_getLoadedClass(
|
1985 |
+
$type, $class
|
1986 |
+
),
|
1987 |
+
)
|
1988 |
+
);
|
1989 |
+
|
1990 |
+
$conflictCounter++;
|
1991 |
+
}
|
1992 |
+
}
|
1993 |
+
}
|
1994 |
+
}
|
1995 |
+
}
|
1996 |
+
if ( ! empty($tableData)) {
|
1997 |
+
$resultContent->setTable($tableData);
|
1998 |
+
}
|
1999 |
+
|
2000 |
+
}
|
2001 |
+
|
2002 |
+
return $resultContent;
|
2003 |
+
}
|
2004 |
+
|
2005 |
+
/**
|
2006 |
+
* Returns loaded class by type like models or blocks
|
2007 |
+
*
|
2008 |
+
* @param string $type
|
2009 |
+
* @param string $class
|
2010 |
+
*
|
2011 |
+
* @return string
|
2012 |
+
*/
|
2013 |
+
protected function _getLoadedClass($type, $class)
|
2014 |
+
{
|
2015 |
+
switch ($type) {
|
2016 |
+
case 'blocks':
|
2017 |
+
return Mage::getConfig()->getBlockClassName($class);
|
2018 |
+
|
2019 |
+
case 'helpers':
|
2020 |
+
return Mage::getConfig()->getHelperClassName($class);
|
2021 |
+
|
2022 |
+
default:
|
2023 |
+
case 'models':
|
2024 |
+
return Mage::getConfig()->getModelClassName($class);
|
2025 |
+
}
|
2026 |
+
}
|
2027 |
+
|
2028 |
+
/**
|
2029 |
+
* Check if rewritten class has inherited the parent class.
|
2030 |
+
* If yes we have no conflict. The top class can extend every core class.
|
2031 |
+
* So we cannot check this.
|
2032 |
+
*
|
2033 |
+
* @var array $classes
|
2034 |
+
* @return bool
|
2035 |
+
*/
|
2036 |
+
protected function _isInheritanceConflict($classes)
|
2037 |
+
{
|
2038 |
+
$classes = array_reverse($classes);
|
2039 |
+
$numClases = count($classes);
|
2040 |
+
|
2041 |
+
for ($i = 0; $i < $numClases - 1; $i++) {
|
2042 |
+
try {
|
2043 |
+
if (class_exists($classes[$i])
|
2044 |
+
&& class_exists($classes[$i + 1])
|
2045 |
+
) {
|
2046 |
+
if ( ! is_a($classes[$i], $classes[$i + 1], true)) {
|
2047 |
+
return true;
|
2048 |
+
}
|
2049 |
+
}
|
2050 |
+
} catch (\Exception $e) {
|
2051 |
+
return true;
|
2052 |
+
}
|
2053 |
+
}
|
2054 |
+
|
2055 |
+
return false;
|
2056 |
+
}
|
2057 |
+
|
2058 |
+
/**
|
2059 |
+
* System information about the version used and the memory limits.
|
2060 |
+
*
|
2061 |
+
* @return Dotdigitalgroup_Email_Model_Adminhtml_Dashboard_Content
|
2062 |
+
*/
|
2063 |
+
public function systemInformation()
|
2064 |
+
{
|
2065 |
+
$resultContent = Mage::getModel(
|
2066 |
+
'ddg_automation/adminhtml_dashboard_content'
|
2067 |
+
);
|
2068 |
+
$resultContent->setStyle(self::CONNECTOR_DASHBOARD_PASSED);
|
2069 |
+
|
2070 |
+
//compatibility with the old versions
|
2071 |
+
if (version_compare(Mage::getVersion(), '1.6.2.0', '>')) {
|
2072 |
+
$version = 'Magento ' . Mage::getEdition() . ' ' . Mage::getVersion(
|
2073 |
+
) . 'V';
|
2074 |
+
} else {
|
2075 |
+
$version = 'Magento version : ' . Mage::getVersion() . 'V';
|
2076 |
+
}
|
2077 |
+
|
2078 |
+
$fh = fopen('/proc/meminfo', 'r');
|
2079 |
+
$mem = 0;
|
2080 |
+
if ($fh) {
|
2081 |
+
while ($line = fgets($fh)) {
|
2082 |
+
$pieces = array();
|
2083 |
+
if (preg_match('^MemTotal:\s+(\d+)\skB$^', $line, $pieces)) {
|
2084 |
+
$mem = $pieces[1];
|
2085 |
+
break;
|
2086 |
+
}
|
2087 |
+
}
|
2088 |
+
fclose($fh);
|
2089 |
+
}
|
2090 |
+
if ($mem > 0) {
|
2091 |
+
$mem = $mem / 1024 . 'M';
|
2092 |
+
} else {
|
2093 |
+
$mem = 'Not available';
|
2094 |
+
}
|
2095 |
+
|
2096 |
+
//check for php version
|
2097 |
+
$resultContent->setHowTo('PHP version : V' . PHP_VERSION)
|
2098 |
+
->setHowto('PHP Memory : ' . $mem)
|
2099 |
+
->setHowto(
|
2100 |
+
'PHP Max Execution Time : ' . ini_get('max_execution_time')
|
2101 |
+
. ' sec'
|
2102 |
+
)
|
2103 |
+
->setHowto($version)
|
2104 |
+
->setHowto(
|
2105 |
+
'Connector version : V' . Mage::helper('ddg')
|
2106 |
+
->getConnectorVersion()
|
2107 |
+
);
|
2108 |
+
|
2109 |
Â
return $resultContent;
|
2110 |
Â
}
|
2111 |
Â
|
2112 |
+
|
2113 |
+
/**
|
2114 |
+
* Check if the mapped program is active.
|
2115 |
+
*/
|
2116 |
+
protected function _getWebisteProgram($program, $website)
|
2117 |
+
{
|
2118 |
+
|
2119 |
+
$client = Mage::helper('ddg')->getWebsiteApiClient($website);
|
2120 |
+
|
2121 |
+
if ( ! $client || ! $program) {
|
2122 |
+
return false;
|
2123 |
+
}
|
2124 |
+
|
2125 |
+
$data = $client->getProgramById($program);
|
2126 |
+
|
2127 |
+
if (isset($data->message)) {
|
2128 |
+
return false;
|
2129 |
+
}
|
2130 |
+
|
2131 |
+
|
2132 |
+
return $data;
|
2133 |
+
}
|
2134 |
+
|
2135 |
+
/**
|
2136 |
+
* Get the contacts address book.
|
2137 |
+
*
|
2138 |
+
* @param $addressBook
|
2139 |
+
* @param $webiste
|
2140 |
+
*
|
2141 |
+
* @return bool|null
|
2142 |
+
*/
|
2143 |
+
protected function _getAddressBookContacts($addressBook, $webiste)
|
2144 |
+
{
|
2145 |
+
$client = Mage::helper('ddg')->getWebsiteApiClient($webiste);
|
2146 |
+
|
2147 |
+
if ( ! $client && $addressBook) {
|
2148 |
+
return false;
|
2149 |
+
}
|
2150 |
+
|
2151 |
+
$response = $client->getAddressBookById($addressBook);
|
2152 |
+
|
2153 |
+
if (isset($response->message)) {
|
2154 |
+
return false;
|
2155 |
+
}
|
2156 |
+
|
2157 |
+
return $response;
|
2158 |
+
}
|
2159 |
+
|
2160 |
+
/**
|
2161 |
+
* Get the method name
|
2162 |
+
*
|
2163 |
+
* @param $name
|
2164 |
+
*
|
2165 |
+
* @return string
|
2166 |
+
*/
|
2167 |
+
public function getFormatedMethodName($name)
|
2168 |
+
{
|
2169 |
+
//version that not support the lcfirst method
|
2170 |
+
if (function_exists('lcfirst') === false) {
|
2171 |
+
|
2172 |
+
$method = strtolower(substr(uc_words($name, ''), 0, 1)) . substr(
|
2173 |
+
uc_words($name, ''), 1
|
2174 |
+
);
|
2175 |
+
|
2176 |
+
} else {
|
2177 |
+
$method = lcfirst(uc_words($name, ''));
|
2178 |
+
}
|
2179 |
+
|
2180 |
+
return $method;
|
2181 |
+
}
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
2182 |
Â
|
2183 |
Â
/**
|
2184 |
Â
* easy email capture enabled
|
2185 |
+
*
|
2186 |
Â
* @return Dotdigitalgroup_Email_Model_Adminhtml_Dashboard_Content
|
2187 |
Â
*/
|
2188 |
Â
public function easyEmailCaptureEnabled()
|
2189 |
Â
{
|
2190 |
+
$resultContent = Mage::getModel(
|
2191 |
+
'ddg_automation/adminhtml_dashboard_content'
|
2192 |
+
);
|
2193 |
Â
$resultContent->setStyle(self::CONNECTOR_DASHBOARD_PASSED)
|
2194 |
Â
->setTitle('Easy Email Capture : ')
|
2195 |
Â
->setMessage('Enabled.');
|
2196 |
Â
|
2197 |
+
foreach (Mage::app()->getWebsites() as $website) {
|
2198 |
+
$websiteName = $website->getName();
|
2199 |
+
$enabled = ($website->getConfig(
|
2200 |
+
Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_EMAIL_CAPTURE
|
2201 |
+
))
|
2202 |
+
? true
|
2203 |
+
:
|
2204 |
Â
'Disabled';
|
2205 |
Â
|
2206 |
+
if ($enabled !== true) {
|
2207 |
+
$url = Mage::helper('adminhtml')->getUrl(
|
2208 |
+
'*/connector/enablewebsiteconfiguration',
|
2209 |
+
array('path' => 'XML_PATH_CONNECTOR_EMAIL_CAPTURE',
|
2210 |
+
'website' => $website->getId())
|
2211 |
+
);
|
2212 |
+
$resultContent->setStyle(self::CONNECTOR_DASHBOARD_FAILED)
|
2213 |
+
->setMessage(
|
2214 |
+
'Don\'t forget to enable if you want to enable easy email capture.'
|
2215 |
+
)
|
2216 |
+
->setTable(
|
2217 |
+
array(
|
2218 |
+
'Website' => $websiteName,
|
2219 |
+
'Status' => $enabled,
|
2220 |
+
'Fast Fix' => 'Click <a href="' . $url
|
2221 |
+
. '">here </a>to enable.'
|
2222 |
+
)
|
2223 |
+
);
|
2224 |
Â
}
|
2225 |
Â
}
|
2226 |
+
|
2227 |
Â
return $resultContent;
|
2228 |
Â
}
|
2229 |
Â
|
2230 |
Â
/**
|
2231 |
Â
* disabled newsletter success enabled
|
2232 |
+
*
|
2233 |
Â
* @return Dotdigitalgroup_Email_Model_Adminhtml_Dashboard_Content
|
2234 |
Â
*/
|
2235 |
Â
public function disableNewsletterSuccessEnabled()
|
2236 |
Â
{
|
2237 |
+
$resultContent = Mage::getModel(
|
2238 |
+
'ddg_automation/adminhtml_dashboard_content'
|
2239 |
+
);
|
2240 |
Â
$resultContent->setStyle(self::CONNECTOR_DASHBOARD_PASSED)
|
2241 |
Â
->setTitle('Disable Newsletter Success : ')
|
2242 |
Â
->setMessage('Enabled.');
|
2243 |
Â
|
2244 |
+
foreach (Mage::app()->getWebsites() as $website) {
|
2245 |
+
$websiteName = $website->getName();
|
2246 |
+
$enabled = ($website->getConfig(
|
2247 |
+
Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_DISABLE_NEWSLETTER_SUCCESS
|
2248 |
+
))
|
2249 |
+
? true
|
2250 |
+
:
|
2251 |
Â
'Disabled';
|
2252 |
Â
|
2253 |
+
if ($enabled !== true) {
|
2254 |
+
$url = Mage::helper('adminhtml')->getUrl(
|
2255 |
+
'*/connector/enablewebsiteconfiguration',
|
2256 |
+
array('path' => 'XML_PATH_CONNECTOR_DISABLE_NEWSLETTER_SUCCESS',
|
2257 |
+
'website' => $website->getId())
|
2258 |
+
);
|
2259 |
+
$resultContent->setStyle(self::CONNECTOR_DASHBOARD_FAILED)
|
2260 |
+
->setMessage(
|
2261 |
+
'Don\'t forget to enable if you want to disable Magento newsletter success email.'
|
2262 |
+
)
|
2263 |
+
->setTable(
|
2264 |
+
array(
|
2265 |
+
'Website' => $websiteName,
|
2266 |
+
'Status' => $enabled,
|
2267 |
+
'Fast Fix' => 'Click <a href="' . $url
|
2268 |
+
. '">here </a>to enable.'
|
2269 |
+
)
|
2270 |
+
);
|
2271 |
Â
}
|
2272 |
Â
}
|
2273 |
+
|
2274 |
Â
return $resultContent;
|
2275 |
Â
}
|
2276 |
Â
|
2277 |
Â
/**
|
2278 |
Â
* wishlist sync enabled.
|
2279 |
+
*
|
2280 |
Â
* @return Dotdigitalgroup_Email_Model_Adminhtml_Dashboard_Content
|
2281 |
Â
*/
|
2282 |
Â
public function wishlistEnabled()
|
2283 |
Â
{
|
2284 |
+
$resultContent = Mage::getModel(
|
2285 |
+
'ddg_automation/adminhtml_dashboard_content'
|
2286 |
+
);
|
2287 |
Â
$resultContent->setStyle(self::CONNECTOR_DASHBOARD_PASSED)
|
2288 |
Â
->setTitle('Wishlist Sync : ')
|
2289 |
Â
->setMessage('Enabled.');
|
2290 |
Â
|
2291 |
+
foreach (Mage::app()->getWebsites() as $website) {
|
2292 |
+
$websiteName = $website->getName();
|
2293 |
+
$wishlist = ($website->getConfig(
|
2294 |
+
Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_SYNC_WISHLIST_ENABLED
|
2295 |
+
))
|
2296 |
+
? true
|
2297 |
+
:
|
2298 |
Â
'Disabled';
|
2299 |
Â
|
2300 |
+
if ($wishlist !== true) {
|
2301 |
+
$url = Mage::helper('adminhtml')->getUrl(
|
2302 |
+
'*/connector/enablewebsiteconfiguration',
|
2303 |
+
array('path' => 'XML_PATH_CONNECTOR_SYNC_WISHLIST_ENABLED',
|
2304 |
+
'website' => $website->getId())
|
2305 |
+
);
|
2306 |
+
$resultContent->setStyle(self::CONNECTOR_DASHBOARD_FAILED)
|
2307 |
+
->setMessage(
|
2308 |
+
'Don\'t forget to enable if you want to sync wishlist.'
|
2309 |
+
)
|
2310 |
+
->setTable(
|
2311 |
+
array(
|
2312 |
+
'Website' => $websiteName,
|
2313 |
+
'Status' => $wishlist,
|
2314 |
+
'Fast Fix' => 'Click <a href="' . $url
|
2315 |
+
. '">here </a>to enable.'
|
2316 |
+
)
|
2317 |
+
);
|
2318 |
Â
}
|
2319 |
Â
}
|
2320 |
+
|
2321 |
Â
return $resultContent;
|
2322 |
Â
}
|
2323 |
Â
|
2324 |
Â
/**
|
2325 |
Â
* Check if any wishlist are imported.
|
2326 |
+
*
|
2327 |
Â
* @return Dotdigitalgroup_Email_Model_Adminhtml_Dashboard_Content
|
2328 |
Â
*/
|
2329 |
Â
public function wishlistSyncing()
|
2330 |
Â
{
|
2331 |
+
$resultContent = Mage::getModel(
|
2332 |
+
'ddg_automation/adminhtml_dashboard_content'
|
2333 |
+
);
|
2334 |
Â
$resultContent->setStyle(self::CONNECTOR_DASHBOARD_PASSED)
|
2335 |
Â
->setTitle('Wishlist Syncing : ')
|
2336 |
Â
->setMessage('Looks Great.');
|
2337 |
Â
|
2338 |
+
foreach (Mage::app()->getWebsites() as $website) {
|
2339 |
+
$websiteName = $website->getName();
|
2340 |
+
$storeIds = $website->getStoreIds();
|
2341 |
Â
|
2342 |
+
if (empty($storeIds)) {
|
2343 |
+
continue;
|
2344 |
+
}
|
2345 |
Â
|
2346 |
Â
//number of wishlist marked as imported
|
2347 |
+
$numWishlist = Mage::getModel('ddg_automation/wishlist')
|
2348 |
+
->getCollection()
|
2349 |
Â
->addFieldToFilter('wishlist_imported', 1)
|
2350 |
Â
->addFieldToFilter('store_id', array('in', $storeIds))
|
2351 |
Â
->getSize();
|
2352 |
Â
|
2353 |
Â
//total wishlist
|
2354 |
+
$totalWishlist = Mage::getModel('ddg_automation/wishlist')
|
2355 |
+
->getCollection()
|
2356 |
Â
->addFieldToFilter('store_id', array('in', $storeIds))
|
2357 |
Â
->getSize();
|
2358 |
Â
|
2359 |
Â
$tableData = array(
|
2360 |
+
'Website' => $websiteName,
|
2361 |
Â
'Total Wishlist' => $totalWishlist,
|
2362 |
+
'Imported' => $numWishlist
|
2363 |
Â
);
|
2364 |
Â
|
2365 |
Â
$tableData['Status'] = 'Importing';
|
2366 |
Â
|
2367 |
+
if ( ! $numWishlist) {
|
2368 |
Â
$tableData['Status'] = 'No Imported Wishlist Found.';
|
2369 |
Â
$resultContent->setStyle(self::CONNECTOR_DASHBOARD_FAILED)
|
2370 |
+
->setTitle(
|
2371 |
+
'Wishlist Sync (ignore if you have reset wishlist) : '
|
2372 |
+
)
|
2373 |
Â
->setMessage('');
|
2374 |
Â
}
|
2375 |
Â
$resultContent->setTable($tableData);
|
2376 |
Â
}
|
2377 |
+
|
2378 |
Â
return $resultContent;
|
2379 |
Â
}
|
2380 |
Â
|
2381 |
Â
|
Â
|
|
2382 |
Â
}
|
@@ -1,7 +1,9 @@
|
|
1 |
Â
<?php
|
2 |
Â
|
3 |
-
class Dotdigitalgroup_Email_Block_Adminhtml_Importer
|
Â
|
|
4 |
Â
{
|
Â
|
|
5 |
Â
public function __construct()
|
6 |
Â
{
|
7 |
Â
parent::__construct();
|
1 |
Â
<?php
|
2 |
Â
|
3 |
+
class Dotdigitalgroup_Email_Block_Adminhtml_Importer
|
4 |
+
extends Mage_Adminhtml_Block_Widget_Grid_Container
|
5 |
Â
{
|
6 |
+
|
7 |
Â
public function __construct()
|
8 |
Â
{
|
9 |
Â
parent::__construct();
|
@@ -1,7 +1,9 @@
|
|
1 |
Â
<?php
|
2 |
Â
|
3 |
-
class Dotdigitalgroup_Email_Block_Adminhtml_Importer_Grid
|
Â
|
|
4 |
Â
{
|
Â
|
|
5 |
Â
public function __construct()
|
6 |
Â
{
|
7 |
Â
parent::__construct();
|
@@ -14,6 +16,7 @@ class Dotdigitalgroup_Email_Block_Adminhtml_Importer_Grid extends Mage_Adminhtml
|
|
14 |
Â
|
15 |
Â
/**
|
16 |
Â
* Collection class;
|
Â
|
|
17 |
Â
* @return string
|
18 |
Â
*/
|
19 |
Â
protected function _getCollectionClass()
|
@@ -24,6 +27,7 @@ class Dotdigitalgroup_Email_Block_Adminhtml_Importer_Grid extends Mage_Adminhtml
|
|
24 |
Â
|
25 |
Â
/**
|
26 |
Â
* Prepare the grid collection.
|
Â
|
|
27 |
Â
* @return Mage_Adminhtml_Block_Widget_Grid
|
28 |
Â
*/
|
29 |
Â
protected function _prepareCollection()
|
@@ -31,93 +35,124 @@ class Dotdigitalgroup_Email_Block_Adminhtml_Importer_Grid extends Mage_Adminhtml
|
|
31 |
Â
// Get and set our collection for the grid
|
32 |
Â
$collection = Mage::getResourceModel($this->_getCollectionClass());
|
33 |
Â
$this->setCollection($collection);
|
Â
|
|
34 |
Â
return parent::_prepareCollection();
|
35 |
Â
}
|
36 |
Â
|
37 |
Â
/**
|
38 |
Â
* Prepare the grid collumns.
|
Â
|
|
39 |
Â
* @return $this
|
40 |
Â
* @throws Exception
|
41 |
Â
*/
|
42 |
Â
protected function _prepareColumns()
|
43 |
Â
{
|
44 |
-
$this->addColumn(
|
45 |
-
'
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
'
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
'
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
'
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
'
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
'
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
107 |
Â
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
118 |
Â
|
119 |
Â
|
120 |
-
|
121 |
Â
}
|
122 |
Â
|
123 |
Â
/**
|
@@ -129,27 +164,33 @@ class Dotdigitalgroup_Email_Block_Adminhtml_Importer_Grid extends Mage_Adminhtml
|
|
129 |
Â
protected function _getStore()
|
130 |
Â
{
|
131 |
Â
$storeId = (int)$this->getRequest()->getParam('store', 0);
|
Â
|
|
132 |
Â
return Mage::app()->getStore($storeId);
|
133 |
Â
}
|
134 |
Â
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
Â
|
|
Â
|
|
146 |
Â
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
Â
|
|
Â
|
|
Â
|
|
152 |
Â
|
153 |
-
|
154 |
-
|
155 |
Â
}
|
1 |
Â
<?php
|
2 |
Â
|
3 |
+
class Dotdigitalgroup_Email_Block_Adminhtml_Importer_Grid
|
4 |
+
extends Mage_Adminhtml_Block_Widget_Grid
|
5 |
Â
{
|
6 |
+
|
7 |
Â
public function __construct()
|
8 |
Â
{
|
9 |
Â
parent::__construct();
|
16 |
Â
|
17 |
Â
/**
|
18 |
Â
* Collection class;
|
19 |
+
*
|
20 |
Â
* @return string
|
21 |
Â
*/
|
22 |
Â
protected function _getCollectionClass()
|
27 |
Â
|
28 |
Â
/**
|
29 |
Â
* Prepare the grid collection.
|
30 |
+
*
|
31 |
Â
* @return Mage_Adminhtml_Block_Widget_Grid
|
32 |
Â
*/
|
33 |
Â
protected function _prepareCollection()
|
35 |
Â
// Get and set our collection for the grid
|
36 |
Â
$collection = Mage::getResourceModel($this->_getCollectionClass());
|
37 |
Â
$this->setCollection($collection);
|
38 |
+
|
39 |
Â
return parent::_prepareCollection();
|
40 |
Â
}
|
41 |
Â
|
42 |
Â
/**
|
43 |
Â
* Prepare the grid collumns.
|
44 |
+
*
|
45 |
Â
* @return $this
|
46 |
Â
* @throws Exception
|
47 |
Â
*/
|
48 |
Â
protected function _prepareColumns()
|
49 |
Â
{
|
50 |
+
$this->addColumn(
|
51 |
+
'id', array(
|
52 |
+
'header' => Mage::helper('ddg')->__('ID'),
|
53 |
+
'align' => 'left',
|
54 |
+
'index' => 'id',
|
55 |
+
'type' => 'number',
|
56 |
+
'escape' => true
|
57 |
+
)
|
58 |
+
)->addColumn(
|
59 |
+
'import_type', array(
|
60 |
+
'header' => Mage::helper('ddg')->__('Import Type'),
|
61 |
+
'index' => 'import_type',
|
62 |
+
'type' => 'text',
|
63 |
+
'escape' => true
|
64 |
+
)
|
65 |
+
)->addColumn(
|
66 |
+
'import_status', array(
|
67 |
+
'header' => Mage::helper('ddg')->__('Import Status'),
|
68 |
+
'index' => 'import_status',
|
69 |
+
'type' => 'options',
|
70 |
+
'escape' => true,
|
71 |
+
'options' => Mage::getModel(
|
72 |
+
'ddg_automation/adminhtml_source_importer_status'
|
73 |
+
)->getOptions(),
|
74 |
+
)
|
75 |
+
)->addColumn(
|
76 |
+
'message', array(
|
77 |
+
'header' => Mage::helper('ddg')->__('Error Message'),
|
78 |
+
'index' => 'message',
|
79 |
+
'type' => 'text',
|
80 |
+
'escape' => true
|
81 |
+
)
|
82 |
+
)->addColumn(
|
83 |
+
'import_mode', array(
|
84 |
+
'header' => Mage::helper('ddg')->__('Import Mode'),
|
85 |
+
'index' => 'import_mode',
|
86 |
+
'type' => 'options',
|
87 |
+
'escape' => true,
|
88 |
+
'options' => Mage::getModel(
|
89 |
+
'ddg_automation/adminhtml_source_importer_mode'
|
90 |
+
)->getOptions(),
|
91 |
+
)
|
92 |
+
)->addColumn(
|
93 |
+
'import_id', array(
|
94 |
+
'header' => Mage::helper('ddg')->__('Import ID'),
|
95 |
+
'index' => 'import_id',
|
96 |
+
'type' => 'text',
|
97 |
+
'escape' => true
|
98 |
+
)
|
99 |
+
)->addColumn(
|
100 |
+
'import_started', array(
|
101 |
+
'header' => Mage::helper('ddg')->__('Imported Started At'),
|
102 |
+
'width' => '50px',
|
103 |
+
'align' => 'center',
|
104 |
+
'index' => 'import_started',
|
105 |
+
'type' => 'datetime',
|
106 |
+
'escape' => true
|
107 |
+
)
|
108 |
+
)->addColumn(
|
109 |
+
'import_finished', array(
|
110 |
+
'header' => Mage::helper('ddg')->__('Last Import Check Time'),
|
111 |
+
'align' => 'center',
|
112 |
+
'index' => 'import_finished',
|
113 |
+
'type' => 'datetime',
|
114 |
+
'escape' => true
|
115 |
+
)
|
116 |
+
)->addColumn(
|
117 |
+
'script', array(
|
118 |
+
'header' => Mage::helper('ddg')->__('Script'),
|
119 |
+
'renderer' => 'ddg_automation/adminhtml_column_renderer_script',
|
120 |
+
'column_css_class' => 'no-display',
|
121 |
+
'header_css_class' => 'no-display'
|
122 |
+
)
|
123 |
+
)->addColumn(
|
124 |
+
'created_at', array(
|
125 |
+
'header' => Mage::helper('ddg')->__('Created At'),
|
126 |
+
'align' => 'center',
|
127 |
+
'index' => 'created_at',
|
128 |
+
'type' => 'datetime',
|
129 |
+
'escape' => true
|
130 |
+
)
|
131 |
+
)->addColumn(
|
132 |
+
'updated_at', array(
|
133 |
+
'header' => Mage::helper('ddg')->__('Updated At'),
|
134 |
+
'align' => 'center',
|
135 |
+
'index' => 'updated_at',
|
136 |
+
'type' => 'datetime',
|
137 |
+
'escape' => true
|
138 |
Â
|
139 |
+
)
|
140 |
+
);
|
141 |
+
if ( ! Mage::app()->isSingleStoreMode()) {
|
142 |
+
$this->addColumn(
|
143 |
+
'website_id', array(
|
144 |
+
'header' => Mage::helper('customer')->__('Website'),
|
145 |
+
'align' => 'center',
|
146 |
+
'type' => 'options',
|
147 |
+
'options' => Mage::getSingleton('adminhtml/system_store')
|
148 |
+
->getWebsiteOptionHash(true),
|
149 |
+
'index' => 'website_id',
|
150 |
+
)
|
151 |
+
);
|
152 |
+
}
|
153 |
Â
|
154 |
Â
|
155 |
+
return parent::_prepareColumns();
|
156 |
Â
}
|
157 |
Â
|
158 |
Â
/**
|
164 |
Â
protected function _getStore()
|
165 |
Â
{
|
166 |
Â
$storeId = (int)$this->getRequest()->getParam('store', 0);
|
167 |
+
|
168 |
Â
return Mage::app()->getStore($storeId);
|
169 |
Â
}
|
170 |
Â
|
171 |
+
/**
|
172 |
+
* Prepare the grid massaction.
|
173 |
+
*
|
174 |
+
* @return $this|Mage_Adminhtml_Block_Widget_Grid
|
175 |
+
*/
|
176 |
+
protected function _prepareMassaction()
|
177 |
+
{
|
178 |
+
$this->setMassactionIdField('id');
|
179 |
+
$this->getMassactionBlock()->setFormFieldName('importer');
|
180 |
+
$this->getMassactionBlock()->addItem(
|
181 |
+
'resend', array(
|
182 |
+
'label' => Mage::helper('ddg')->__('Reset'),
|
183 |
+
'url' => $this->getUrl('*/*/massResend'),
|
184 |
Â
|
185 |
+
)
|
186 |
+
);
|
187 |
+
$this->getMassactionBlock()->addItem(
|
188 |
+
'delete', array(
|
189 |
+
'label' => Mage::helper('ddg')->__('Delete'),
|
190 |
+
'url' => $this->getUrl('*/*/massDelete'),
|
191 |
+
'confirm' => Mage::helper('ddg')->__('Are you sure?'))
|
192 |
+
);
|
193 |
Â
|
194 |
+
return $this;
|
195 |
+
}
|
196 |
Â
}
|
@@ -1,13 +1,15 @@
|
|
1 |
Â
<?php
|
2 |
Â
|
3 |
-
class Dotdigitalgroup_Email_Block_Adminhtml_Order
|
Â
|
|
4 |
Â
{
|
Â
|
|
5 |
Â
public function __construct()
|
6 |
Â
{
|
7 |
Â
parent::__construct();
|
8 |
Â
|
9 |
-
|
10 |
-
|
11 |
Â
$this->_headerText = Mage::helper('ddg')->__('Email Order(s)');
|
12 |
Â
|
13 |
Â
$this->_removeButton('add');
|
1 |
Â
<?php
|
2 |
Â
|
3 |
+
class Dotdigitalgroup_Email_Block_Adminhtml_Order
|
4 |
+
extends Mage_Adminhtml_Block_Widget_Grid_Container
|
5 |
Â
{
|
6 |
+
|
7 |
Â
public function __construct()
|
8 |
Â
{
|
9 |
Â
parent::__construct();
|
10 |
Â
|
11 |
+
$this->_controller = 'adminhtml_order';
|
12 |
+
$this->_blockGroup = 'ddg_automation';
|
13 |
Â
$this->_headerText = Mage::helper('ddg')->__('Email Order(s)');
|
14 |
Â
|
15 |
Â
$this->_removeButton('add');
|
@@ -1,7 +1,9 @@
|
|
1 |
Â
<?php
|
2 |
Â
|
3 |
-
class Dotdigitalgroup_Email_Block_Adminhtml_Order_Grid
|
Â
|
|
4 |
Â
{
|
Â
|
|
5 |
Â
public function __construct()
|
6 |
Â
{
|
7 |
Â
parent::__construct();
|
@@ -13,9 +15,10 @@ class Dotdigitalgroup_Email_Block_Adminhtml_Order_Grid extends Mage_Adminhtml_Bl
|
|
13 |
Â
}
|
14 |
Â
|
15 |
Â
/**
|
16 |
-
|
17 |
-
|
18 |
-
|
Â
|
|
19 |
Â
protected function _getCollectionClass()
|
20 |
Â
{
|
21 |
Â
// This is the model we are using for the grid
|
@@ -23,96 +26,123 @@ class Dotdigitalgroup_Email_Block_Adminhtml_Order_Grid extends Mage_Adminhtml_Bl
|
|
23 |
Â
}
|
24 |
Â
|
25 |
Â
/**
|
26 |
-
|
27 |
-
|
28 |
-
|
Â
|
|
29 |
Â
protected function _prepareCollection()
|
30 |
Â
{
|
31 |
Â
// Get and set our collection for the grid
|
32 |
Â
$collection = Mage::getResourceModel($this->_getCollectionClass());
|
33 |
Â
$this->setCollection($collection);
|
Â
|
|
34 |
Â
return parent::_prepareCollection();
|
35 |
Â
}
|
36 |
Â
|
37 |
Â
/**
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
Â
|
|
42 |
Â
protected function _prepareColumns()
|
43 |
Â
{
|
44 |
-
$this->addColumn(
|
45 |
-
'
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
'
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
'
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
'
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
103 |
Â
|
104 |
Â
return parent::_prepareColumns();
|
105 |
Â
}
|
106 |
Â
|
107 |
Â
/**
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
Â
public function filterCallbackContact($collection, $column)
|
114 |
Â
{
|
115 |
-
$field = $column->getFilterIndex() ? $column->getFilterIndex()
|
Â
|
|
116 |
Â
$value = $column->getFilter()->getValue();
|
117 |
Â
if ($value == 'null') {
|
118 |
Â
$collection->addFieldToFilter($field, array('null' => true));
|
1 |
Â
<?php
|
2 |
Â
|
3 |
+
class Dotdigitalgroup_Email_Block_Adminhtml_Order_Grid
|
4 |
+
extends Mage_Adminhtml_Block_Widget_Grid
|
5 |
Â
{
|
6 |
+
|
7 |
Â
public function __construct()
|
8 |
Â
{
|
9 |
Â
parent::__construct();
|
15 |
Â
}
|
16 |
Â
|
17 |
Â
/**
|
18 |
+
* Collection class;
|
19 |
+
*
|
20 |
+
* @return string
|
21 |
+
*/
|
22 |
Â
protected function _getCollectionClass()
|
23 |
Â
{
|
24 |
Â
// This is the model we are using for the grid
|
26 |
Â
}
|
27 |
Â
|
28 |
Â
/**
|
29 |
+
* Prepare the grid collection.
|
30 |
+
*
|
31 |
+
* @return Mage_Adminhtml_Block_Widget_Grid
|
32 |
+
*/
|
33 |
Â
protected function _prepareCollection()
|
34 |
Â
{
|
35 |
Â
// Get and set our collection for the grid
|
36 |
Â
$collection = Mage::getResourceModel($this->_getCollectionClass());
|
37 |
Â
$this->setCollection($collection);
|
38 |
+
|
39 |
Â
return parent::_prepareCollection();
|
40 |
Â
}
|
41 |
Â
|
42 |
Â
/**
|
43 |
+
* Prepare the grid collumns.
|
44 |
+
*
|
45 |
+
* @return $this
|
46 |
+
* @throws Exception
|
47 |
+
*/
|
48 |
Â
protected function _prepareColumns()
|
49 |
Â
{
|
50 |
+
$this->addColumn(
|
51 |
+
'order_id', array(
|
52 |
+
'header' => Mage::helper('ddg')->__('Order ID'),
|
53 |
+
'align' => 'left',
|
54 |
+
'width' => '50px',
|
55 |
+
'index' => 'order_id',
|
56 |
+
'type' => 'number',
|
57 |
+
'escape' => true
|
58 |
+
)
|
59 |
+
)->addColumn(
|
60 |
+
'store_id', array(
|
61 |
+
'header' => Mage::helper('ddg')->__('Store ID'),
|
62 |
+
'width' => '50px',
|
63 |
+
'index' => 'store_id',
|
64 |
+
'type' => 'number',
|
65 |
+
'escape' => true,
|
66 |
+
)
|
67 |
+
)->addColumn(
|
68 |
+
'order_status', array(
|
69 |
+
'header' => Mage::helper('ddg')->__('Order Status'),
|
70 |
+
'align' => 'right',
|
71 |
+
'width' => '50px',
|
72 |
+
'index' => 'order_status',
|
73 |
+
'type' => 'options',
|
74 |
+
'escape' => true,
|
75 |
+
'options' => Mage::getSingleton('sales/order_config')
|
76 |
+
->getStatuses(),
|
77 |
+
)
|
78 |
+
)->addColumn(
|
79 |
+
'email_imported', array(
|
80 |
+
'header' => Mage::helper('ddg')->__(
|
81 |
+
'Imported'
|
82 |
+
),
|
83 |
+
'align' => 'center',
|
84 |
+
'width' => '50px',
|
85 |
+
'index' => 'email_imported',
|
86 |
+
'type' => 'options',
|
87 |
+
'escape' => true,
|
88 |
+
'renderer' => 'ddg_automation/adminhtml_column_renderer_imported',
|
89 |
+
'options' => Mage::getModel(
|
90 |
+
'ddg_automation/adminhtml_source_contact_imported'
|
91 |
+
)->getOptions(),
|
92 |
+
'filter_condition_callback' => array($this,
|
93 |
+
'filterCallbackContact')
|
94 |
+
)
|
95 |
+
)->addColumn(
|
96 |
+
'modified', array(
|
97 |
+
'header' => Mage::helper('ddg')->__(
|
98 |
+
'Modified'
|
99 |
+
),
|
100 |
+
'align' => 'center',
|
101 |
+
'width' => '50px',
|
102 |
+
'index' => 'modified',
|
103 |
+
'type' => 'options',
|
104 |
+
'escape' => true,
|
105 |
+
'renderer' => 'ddg_automation/adminhtml_column_renderer_imported',
|
106 |
+
'options' => array(
|
107 |
+
1 => 'Modified',
|
108 |
+
null => 'Not Modified',
|
109 |
+
),
|
110 |
+
'filter_condition_callback' => array($this,
|
111 |
+
'filterCallbackContact')
|
112 |
+
)
|
113 |
+
)->addColumn(
|
114 |
+
'created_at', array(
|
115 |
+
'header' => Mage::helper('ddg')->__('Created At'),
|
116 |
+
'width' => '50px',
|
117 |
+
'align' => 'center',
|
118 |
+
'index' => 'created_at',
|
119 |
+
'type' => 'datetime',
|
120 |
+
'escape' => true,
|
121 |
+
)
|
122 |
+
)->addColumn(
|
123 |
+
'updated_at', array(
|
124 |
+
'header' => Mage::helper('ddg')->__('Updated At'),
|
125 |
+
'width' => '50px',
|
126 |
+
'align' => 'center',
|
127 |
+
'index' => 'updated_at',
|
128 |
+
'type' => 'datetime',
|
129 |
+
'escape' => true,
|
130 |
+
)
|
131 |
+
);
|
132 |
Â
|
133 |
Â
return parent::_prepareColumns();
|
134 |
Â
}
|
135 |
Â
|
136 |
Â
/**
|
137 |
+
* Callback action for the imported subscribers/contacts.
|
138 |
+
*
|
139 |
+
* @param $collection
|
140 |
+
* @param $column
|
141 |
+
*/
|
142 |
Â
public function filterCallbackContact($collection, $column)
|
143 |
Â
{
|
144 |
+
$field = $column->getFilterIndex() ? $column->getFilterIndex()
|
145 |
+
: $column->getIndex();
|
146 |
Â
$value = $column->getFilter()->getValue();
|
147 |
Â
if ($value == 'null') {
|
148 |
Â
$collection->addFieldToFilter($field, array('null' => true));
|
@@ -1,14 +1,16 @@
|
|
1 |
Â
<?php
|
2 |
Â
|
3 |
-
class Dotdigitalgroup_Email_Block_Adminhtml_Quote
|
Â
|
|
4 |
Â
{
|
Â
|
|
5 |
Â
public function __construct()
|
6 |
Â
{
|
7 |
Â
parent::__construct();
|
8 |
Â
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
Â
|
13 |
Â
$this->_removeButton('add');
|
14 |
Â
}
|
1 |
Â
<?php
|
2 |
Â
|
3 |
+
class Dotdigitalgroup_Email_Block_Adminhtml_Quote
|
4 |
+
extends Mage_Adminhtml_Block_Widget_Grid_Container
|
5 |
Â
{
|
6 |
+
|
7 |
Â
public function __construct()
|
8 |
Â
{
|
9 |
Â
parent::__construct();
|
10 |
Â
|
11 |
+
$this->_controller = 'adminhtml_quote';
|
12 |
+
$this->_blockGroup = 'ddg_automation';
|
13 |
+
$this->_headerText = Mage::helper('ddg')->__('Email Quote(s)');
|
14 |
Â
|
15 |
Â
$this->_removeButton('add');
|
16 |
Â
}
|
@@ -1,7 +1,9 @@
|
|
1 |
Â
<?php
|
2 |
Â
|
3 |
-
class Dotdigitalgroup_Email_Block_Adminhtml_Quote_Grid
|
Â
|
|
4 |
Â
{
|
Â
|
|
5 |
Â
public function __construct()
|
6 |
Â
{
|
7 |
Â
parent::__construct();
|
@@ -14,6 +16,7 @@ class Dotdigitalgroup_Email_Block_Adminhtml_Quote_Grid extends Mage_Adminhtml_Bl
|
|
14 |
Â
|
15 |
Â
/**
|
16 |
Â
* Collection class;
|
Â
|
|
17 |
Â
* @return string
|
18 |
Â
*/
|
19 |
Â
protected function _getCollectionClass()
|
@@ -24,6 +27,7 @@ class Dotdigitalgroup_Email_Block_Adminhtml_Quote_Grid extends Mage_Adminhtml_Bl
|
|
24 |
Â
|
25 |
Â
/**
|
26 |
Â
* Prepare the grid collection.
|
Â
|
|
27 |
Â
* @return Mage_Adminhtml_Block_Widget_Grid
|
28 |
Â
*/
|
29 |
Â
protected function _prepareCollection()
|
@@ -31,72 +35,98 @@ class Dotdigitalgroup_Email_Block_Adminhtml_Quote_Grid extends Mage_Adminhtml_Bl
|
|
31 |
Â
// Get and set our collection for the grid
|
32 |
Â
$collection = Mage::getResourceModel($this->_getCollectionClass());
|
33 |
Â
$this->setCollection($collection);
|
Â
|
|
34 |
Â
return parent::_prepareCollection();
|
35 |
Â
}
|
36 |
Â
|
37 |
Â
/**
|
38 |
Â
* Prepare the grid collumns.
|
Â
|
|
39 |
Â
* @return $this
|
40 |
Â
* @throws Exception
|
41 |
Â
*/
|
42 |
Â
protected function _prepareColumns()
|
43 |
Â
{
|
44 |
-
$this->addColumn(
|
45 |
-
'
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
'
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
'
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
'
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
'
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
100 |
Â
|
101 |
Â
return parent::_prepareColumns();
|
102 |
Â
}
|
@@ -109,7 +139,8 @@ class Dotdigitalgroup_Email_Block_Adminhtml_Quote_Grid extends Mage_Adminhtml_Bl
|
|
109 |
Â
*/
|
110 |
Â
public function filterCallbackContact($collection, $column)
|
111 |
Â
{
|
112 |
-
$field = $column->getFilterIndex() ? $column->getFilterIndex()
|
Â
|
|
113 |
Â
$value = $column->getFilter()->getValue();
|
114 |
Â
if ($value == 'null') {
|
115 |
Â
$collection->addFieldToFilter($field, array('null' => true));
|
1 |
Â
<?php
|
2 |
Â
|
3 |
+
class Dotdigitalgroup_Email_Block_Adminhtml_Quote_Grid
|
4 |
+
extends Mage_Adminhtml_Block_Widget_Grid
|
5 |
Â
{
|
6 |
+
|
7 |
Â
public function __construct()
|
8 |
Â
{
|
9 |
Â
parent::__construct();
|
16 |
Â
|
17 |
Â
/**
|
18 |
Â
* Collection class;
|
19 |
+
*
|
20 |
Â
* @return string
|
21 |
Â
*/
|
22 |
Â
protected function _getCollectionClass()
|
27 |
Â
|
28 |
Â
/**
|
29 |
Â
* Prepare the grid collection.
|
30 |
+
*
|
31 |
Â
* @return Mage_Adminhtml_Block_Widget_Grid
|
32 |
Â
*/
|
33 |
Â
protected function _prepareCollection()
|
35 |
Â
// Get and set our collection for the grid
|
36 |
Â
$collection = Mage::getResourceModel($this->_getCollectionClass());
|
37 |
Â
$this->setCollection($collection);
|
38 |
+
|
39 |
Â
return parent::_prepareCollection();
|
40 |
Â
}
|
41 |
Â
|
42 |
Â
/**
|
43 |
Â
* Prepare the grid collumns.
|
44 |
+
*
|
45 |
Â
* @return $this
|
46 |
Â
* @throws Exception
|
47 |
Â
*/
|
48 |
Â
protected function _prepareColumns()
|
49 |
Â
{
|
50 |
+
$this->addColumn(
|
51 |
+
'quote_id', array(
|
52 |
+
'header' => Mage::helper('ddg')->__('Quote ID'),
|
53 |
+
'align' => 'left',
|
54 |
+
'width' => '50px',
|
55 |
+
'index' => 'quote_id',
|
56 |
+
'type' => 'number',
|
57 |
+
'escape' => true
|
58 |
+
)
|
59 |
+
)->addColumn(
|
60 |
+
'customer_id', array(
|
61 |
+
'header' => Mage::helper('ddg')->__('Customer ID'),
|
62 |
+
'align' => 'left',
|
63 |
+
'width' => '50px',
|
64 |
+
'index' => 'customer_id',
|
65 |
+
'type' => 'number',
|
66 |
+
'escape' => true
|
67 |
+
)
|
68 |
+
)->addColumn(
|
69 |
+
'store_id', array(
|
70 |
+
'header' => Mage::helper('ddg')->__('Store ID'),
|
71 |
+
'align' => 'left',
|
72 |
+
'width' => '50px',
|
73 |
+
'index' => 'store_id',
|
74 |
+
'type' => 'number',
|
75 |
+
'escape' => true
|
76 |
+
)
|
77 |
+
)->addColumn(
|
78 |
+
'imported', array(
|
79 |
+
'header' => Mage::helper('ddg')->__(
|
80 |
+
'Quote Imported'
|
81 |
+
),
|
82 |
+
'align' => 'center',
|
83 |
+
'width' => '50px',
|
84 |
+
'index' => 'imported',
|
85 |
+
'type' => 'options',
|
86 |
+
'escape' => true,
|
87 |
+
'renderer' => 'ddg_automation/adminhtml_column_renderer_imported',
|
88 |
+
'options' => Mage::getModel(
|
89 |
+
'ddg_automation/adminhtml_source_contact_imported'
|
90 |
+
)->getOptions(),
|
91 |
+
'filter_condition_callback' => array($this,
|
92 |
+
'filterCallbackContact')
|
93 |
+
)
|
94 |
+
)->addColumn(
|
95 |
+
'modified', array(
|
96 |
+
'header' => Mage::helper('ddg')->__(
|
97 |
+
'Quote Modified'
|
98 |
+
),
|
99 |
+
'align' => 'center',
|
100 |
+
'width' => '50px',
|
101 |
+
'index' => 'modified',
|
102 |
+
'type' => 'options',
|
103 |
+
'escape' => true,
|
104 |
+
'renderer' => 'ddg_automation/adminhtml_column_renderer_imported',
|
105 |
+
'options' => Mage::getModel(
|
106 |
+
'ddg_automation/adminhtml_source_contact_imported'
|
107 |
+
)->getOptions(),
|
108 |
+
'filter_condition_callback' => array($this,
|
109 |
+
'filterCallbackContact')
|
110 |
+
)
|
111 |
+
)->addColumn(
|
112 |
+
'created_at', array(
|
113 |
+
'header' => Mage::helper('ddg')->__('Created At'),
|
114 |
+
'width' => '50px',
|
115 |
+
'align' => 'center',
|
116 |
+
'index' => 'created_at',
|
117 |
+
'type' => 'datetime',
|
118 |
+
'escape' => true,
|
119 |
+
)
|
120 |
+
)->addColumn(
|
121 |
+
'updated_at', array(
|
122 |
+
'header' => Mage::helper('ddg')->__('Updated At'),
|
123 |
+
'width' => '50px',
|
124 |
+
'align' => 'center',
|
125 |
+
'index' => 'updated_at',
|
126 |
+
'type' => 'datetime',
|
127 |
+
'escape' => true,
|
128 |
+
)
|
129 |
+
);
|
130 |
Â
|
131 |
Â
return parent::_prepareColumns();
|
132 |
Â
}
|
139 |
Â
*/
|
140 |
Â
public function filterCallbackContact($collection, $column)
|
141 |
Â
{
|
142 |
+
$field = $column->getFilterIndex() ? $column->getFilterIndex()
|
143 |
+
: $column->getIndex();
|
144 |
Â
$value = $column->getFilter()->getValue();
|
145 |
Â
if ($value == 'null') {
|
146 |
Â
$collection->addFieldToFilter($field, array('null' => true));
|
@@ -1,14 +1,16 @@
|
|
1 |
Â
<?php
|
2 |
Â
|
3 |
-
class Dotdigitalgroup_Email_Block_Adminhtml_Review
|
Â
|
|
4 |
Â
{
|
Â
|
|
5 |
Â
public function __construct()
|
6 |
Â
{
|
7 |
Â
parent::__construct();
|
8 |
Â
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
Â
|
13 |
Â
$this->_removeButton('add');
|
14 |
Â
}
|
1 |
Â
<?php
|
2 |
Â
|
3 |
+
class Dotdigitalgroup_Email_Block_Adminhtml_Review
|
4 |
+
extends Mage_Adminhtml_Block_Widget_Grid_Container
|
5 |
Â
{
|
6 |
+
|
7 |
Â
public function __construct()
|
8 |
Â
{
|
9 |
Â
parent::__construct();
|
10 |
Â
|
11 |
+
$this->_controller = 'adminhtml_review';
|
12 |
+
$this->_blockGroup = 'ddg_automation';
|
13 |
+
$this->_headerText = Mage::helper('ddg')->__('Email Review(s)');
|
14 |
Â
|
15 |
Â
$this->_removeButton('add');
|
16 |
Â
}
|
@@ -1,7 +1,9 @@
|
|
1 |
Â
<?php
|
2 |
Â
|
3 |
-
class Dotdigitalgroup_Email_Block_Adminhtml_Review_Grid
|
Â
|
|
4 |
Â
{
|
Â
|
|
5 |
Â
public function __construct()
|
6 |
Â
{
|
7 |
Â
parent::__construct();
|
@@ -13,9 +15,10 @@ class Dotdigitalgroup_Email_Block_Adminhtml_Review_Grid extends Mage_Adminhtml_B
|
|
13 |
Â
}
|
14 |
Â
|
15 |
Â
/**
|
16 |
-
|
17 |
-
|
18 |
-
|
Â
|
|
19 |
Â
protected function _getCollectionClass()
|
20 |
Â
{
|
21 |
Â
// This is the model we are using for the grid
|
@@ -23,82 +26,103 @@ class Dotdigitalgroup_Email_Block_Adminhtml_Review_Grid extends Mage_Adminhtml_B
|
|
23 |
Â
}
|
24 |
Â
|
25 |
Â
/**
|
26 |
-
|
27 |
-
|
28 |
-
|
Â
|
|
29 |
Â
protected function _prepareCollection()
|
30 |
Â
{
|
31 |
Â
// Get and set our collection for the grid
|
32 |
Â
$collection = Mage::getResourceModel($this->_getCollectionClass());
|
33 |
Â
$this->setCollection($collection);
|
Â
|
|
34 |
Â
return parent::_prepareCollection();
|
35 |
Â
}
|
36 |
Â
|
37 |
Â
/**
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
Â
|
|
42 |
Â
protected function _prepareColumns()
|
43 |
Â
{
|
44 |
-
$this->addColumn(
|
45 |
-
'
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
'
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
'
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
89 |
Â
|
90 |
Â
return parent::_prepareColumns();
|
91 |
Â
}
|
92 |
Â
|
93 |
Â
/**
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
Â
public function filterCallbackContact($collection, $column)
|
100 |
Â
{
|
101 |
-
$field = $column->getFilterIndex() ? $column->getFilterIndex()
|
Â
|
|
102 |
Â
$value = $column->getFilter()->getValue();
|
103 |
Â
if ($value == 'null') {
|
104 |
Â
$collection->addFieldToFilter($field, array('null' => true));
|
1 |
Â
<?php
|
2 |
Â
|
3 |
+
class Dotdigitalgroup_Email_Block_Adminhtml_Review_Grid
|
4 |
+
extends Mage_Adminhtml_Block_Widget_Grid
|
5 |
Â
{
|
6 |
+
|
7 |
Â
public function __construct()
|
8 |
Â
{
|
9 |
Â
parent::__construct();
|
15 |
Â
}
|
16 |
Â
|
17 |
Â
/**
|
18 |
+
* Collection class;
|
19 |
+
*
|
20 |
+
* @return string
|
21 |
+
*/
|
22 |
Â
protected function _getCollectionClass()
|
23 |
Â
{
|
24 |
Â
// This is the model we are using for the grid
|
26 |
Â
}
|
27 |
Â
|
28 |
Â
/**
|
29 |
+
* Prepare the grid collection.
|
30 |
+
*
|
31 |
+
* @return Mage_Adminhtml_Block_Widget_Grid
|
32 |
+
*/
|
33 |
Â
protected function _prepareCollection()
|
34 |
Â
{
|
35 |
Â
// Get and set our collection for the grid
|
36 |
Â
$collection = Mage::getResourceModel($this->_getCollectionClass());
|
37 |
Â
$this->setCollection($collection);
|
38 |
+
|
39 |
Â
return parent::_prepareCollection();
|
40 |
Â
}
|
41 |
Â
|
42 |
Â
/**
|
43 |
+
* Prepare the grid collumns.
|
44 |
+
*
|
45 |
+
* @return $this
|
46 |
+
* @throws Exception
|
47 |
+
*/
|
48 |
Â
protected function _prepareColumns()
|
49 |
Â
{
|
50 |
+
$this->addColumn(
|
51 |
+
'review_id', array(
|
52 |
+
'header' => Mage::helper('ddg')->__('Review ID'),
|
53 |
+
'align' => 'left',
|
54 |
+
'width' => '50px',
|
55 |
+
'index' => 'review_id',
|
56 |
+
'type' => 'number',
|
57 |
+
'escape' => true
|
58 |
+
)
|
59 |
+
)->addColumn(
|
60 |
+
'customer_id', array(
|
61 |
+
'header' => Mage::helper('ddg')->__('Customer ID'),
|
62 |
+
'align' => 'left',
|
63 |
+
'width' => '50px',
|
64 |
+
'index' => 'customer_id',
|
65 |
+
'type' => 'number',
|
66 |
+
'escape' => true
|
67 |
+
)
|
68 |
+
)->addColumn(
|
69 |
+
'store_id', array(
|
70 |
+
'header' => Mage::helper('ddg')->__('Store ID'),
|
71 |
+
'width' => '50px',
|
72 |
+
'index' => 'store_id',
|
73 |
+
'type' => 'number',
|
74 |
+
'escape' => true,
|
75 |
+
)
|
76 |
+
)->addColumn(
|
77 |
+
'review_imported', array(
|
78 |
+
'header' => Mage::helper('ddg')->__(
|
79 |
+
'Review Imported'
|
80 |
+
),
|
81 |
+
'align' => 'center',
|
82 |
+
'width' => '50px',
|
83 |
+
'index' => 'review_imported',
|
84 |
+
'type' => 'options',
|
85 |
+
'escape' => true,
|
86 |
+
'renderer' => 'ddg_automation/adminhtml_column_renderer_imported',
|
87 |
+
'options' => Mage::getModel(
|
88 |
+
'ddg_automation/adminhtml_source_contact_imported'
|
89 |
+
)->getOptions(),
|
90 |
+
'filter_condition_callback' => array($this,
|
91 |
+
'filterCallbackContact')
|
92 |
+
)
|
93 |
+
)->addColumn(
|
94 |
+
'created_at', array(
|
95 |
+
'header' => Mage::helper('ddg')->__('Created At'),
|
96 |
+
'width' => '50px',
|
97 |
+
'align' => 'center',
|
98 |
+
'index' => 'created_at',
|
99 |
+
'type' => 'datetime',
|
100 |
+
'escape' => true,
|
101 |
+
)
|
102 |
+
)->addColumn(
|
103 |
+
'updated_at', array(
|
104 |
+
'header' => Mage::helper('ddg')->__('Updated At'),
|
105 |
+
'width' => '50px',
|
106 |
+
'align' => 'center',
|
107 |
+
'index' => 'updated_at',
|
108 |
+
'type' => 'datetime',
|
109 |
+
'escape' => true,
|
110 |
+
)
|
111 |
+
);
|
112 |
Â
|
113 |
Â
return parent::_prepareColumns();
|
114 |
Â
}
|
115 |
Â
|
116 |
Â
/**
|
117 |
+
* Callback action for the imported subscribers/contacts.
|
118 |
+
*
|
119 |
+
* @param $collection
|
120 |
+
* @param $column
|
121 |
+
*/
|
122 |
Â
public function filterCallbackContact($collection, $column)
|
123 |
Â
{
|
124 |
+
$field = $column->getFilterIndex() ? $column->getFilterIndex()
|
125 |
+
: $column->getIndex();
|
126 |
Â
$value = $column->getFilter()->getValue();
|
127 |
Â
if ($value == 'null') {
|
128 |
Â
$collection->addFieldToFilter($field, array('null' => true));
|
@@ -1,13 +1,17 @@
|
|
1 |
Â
<?php
|
2 |
Â
|
3 |
-
class Dotdigitalgroup_Email_Block_Adminhtml_Rules
|
Â
|
|
4 |
Â
{
|
Â
|
|
5 |
Â
public function __construct()
|
6 |
Â
{
|
7 |
Â
parent::__construct();
|
8 |
-
|
9 |
-
|
10 |
-
|
Â
|
|
Â
|
|
11 |
Â
$this->_addButtonLabel = Mage::helper('ddg')->__('Add New Rule');
|
12 |
Â
|
13 |
Â
}
|
1 |
Â
<?php
|
2 |
Â
|
3 |
+
class Dotdigitalgroup_Email_Block_Adminhtml_Rules
|
4 |
+
extends Mage_Adminhtml_Block_Widget_Grid_Container
|
5 |
Â
{
|
6 |
+
|
7 |
Â
public function __construct()
|
8 |
Â
{
|
9 |
Â
parent::__construct();
|
10 |
+
$this->_controller = 'adminhtml_rules';
|
11 |
+
$this->_blockGroup = 'ddg_automation';
|
12 |
+
$this->_headerText = Mage::helper('ddg')->__(
|
13 |
+
'Email Exclusion Rule(s)'
|
14 |
+
);
|
15 |
Â
$this->_addButtonLabel = Mage::helper('ddg')->__('Add New Rule');
|
16 |
Â
|
17 |
Â
}
|
@@ -3,8 +3,8 @@
|
|
3 |
Â
/**
|
4 |
Â
* Shopping cart rule edit form block
|
5 |
Â
*/
|
6 |
-
|
7 |
-
|
8 |
Â
{
|
9 |
Â
|
10 |
Â
/**
|
@@ -14,17 +14,19 @@ class Dotdigitalgroup_Email_Block_Adminhtml_Rules_Edit extends Mage_Adminhtml_Bl
|
|
14 |
Â
*/
|
15 |
Â
public function __construct()
|
16 |
Â
{
|
17 |
-
$this->_objectId
|
18 |
Â
$this->_blockGroup = 'ddg_automation';
|
19 |
Â
$this->_controller = 'adminhtml_rules';
|
20 |
Â
|
21 |
Â
parent::__construct();
|
22 |
Â
|
23 |
-
$this->_addButton(
|
Â
|
|
24 |
Â
'class' => 'save',
|
25 |
Â
'label' => Mage::helper('ddg')->__('Save and Continue Edit'),
|
26 |
Â
'onclick' => 'editForm.submit($(\'edit_form\').action + \'back/edit/\')',
|
27 |
-
|
Â
|
|
28 |
Â
}
|
29 |
Â
|
30 |
Â
/**
|
@@ -36,9 +38,10 @@ class Dotdigitalgroup_Email_Block_Adminhtml_Rules_Edit extends Mage_Adminhtml_Bl
|
|
36 |
Â
{
|
37 |
Â
$rule = Mage::registry('current_ddg_rule');
|
38 |
Â
if ($rule->getId()) {
|
39 |
-
return Mage::helper('ddg')->__(
|
40 |
-
|
41 |
-
|
Â
|
|
42 |
Â
return Mage::helper('ddg')->__('New Rule');
|
43 |
Â
}
|
44 |
Â
}
|
3 |
Â
/**
|
4 |
Â
* Shopping cart rule edit form block
|
5 |
Â
*/
|
6 |
+
class Dotdigitalgroup_Email_Block_Adminhtml_Rules_Edit
|
7 |
+
extends Mage_Adminhtml_Block_Widget_Form_Container
|
8 |
Â
{
|
9 |
Â
|
10 |
Â
/**
|
14 |
Â
*/
|
15 |
Â
public function __construct()
|
16 |
Â
{
|
17 |
+
$this->_objectId = 'id';
|
18 |
Â
$this->_blockGroup = 'ddg_automation';
|
19 |
Â
$this->_controller = 'adminhtml_rules';
|
20 |
Â
|
21 |
Â
parent::__construct();
|
22 |
Â
|
23 |
+
$this->_addButton(
|
24 |
+
'save_and_continue_edit', array(
|
25 |
Â
'class' => 'save',
|
26 |
Â
'label' => Mage::helper('ddg')->__('Save and Continue Edit'),
|
27 |
Â
'onclick' => 'editForm.submit($(\'edit_form\').action + \'back/edit/\')',
|
28 |
+
), 10
|
29 |
+
);
|
30 |
Â
}
|
31 |
Â
|
32 |
Â
/**
|
38 |
Â
{
|
39 |
Â
$rule = Mage::registry('current_ddg_rule');
|
40 |
Â
if ($rule->getId()) {
|
41 |
+
return Mage::helper('ddg')->__(
|
42 |
+
"Edit Rule '%s'", $this->escapeHtml($rule->getName())
|
43 |
+
);
|
44 |
+
} else {
|
45 |
Â
return Mage::helper('ddg')->__('New Rule');
|
46 |
Â
}
|
47 |
Â
}
|
@@ -1,6 +1,7 @@
|
|
1 |
Â
<?php
|
2 |
Â
|
3 |
-
class Dotdigitalgroup_Email_Block_Adminhtml_Rules_Edit_Form
|
Â
|
|
4 |
Â
{
|
5 |
Â
|
6 |
Â
public function __construct()
|
@@ -12,9 +13,14 @@ class Dotdigitalgroup_Email_Block_Adminhtml_Rules_Edit_Form extends Mage_Adminht
|
|
12 |
Â
|
13 |
Â
protected function _prepareForm()
|
14 |
Â
{
|
15 |
-
$form = new Varien_Data_Form(
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
16 |
Â
$form->setUseContainer(true);
|
17 |
Â
$this->setForm($form);
|
Â
|
|
18 |
Â
return parent::_prepareForm();
|
19 |
Â
}
|
20 |
Â
|
1 |
Â
<?php
|
2 |
Â
|
3 |
+
class Dotdigitalgroup_Email_Block_Adminhtml_Rules_Edit_Form
|
4 |
+
extends Mage_Adminhtml_Block_Widget_Form
|
5 |
Â
{
|
6 |
Â
|
7 |
Â
public function __construct()
|
13 |
Â
|
14 |
Â
protected function _prepareForm()
|
15 |
Â
{
|
16 |
+
$form = new Varien_Data_Form(
|
17 |
+
array('id' => 'edit_form',
|
18 |
+
'action' => $this->getUrl('adminhtml/email_rules/save'),
|
19 |
+
'method' => 'post')
|
20 |
+
);
|
21 |
Â
$form->setUseContainer(true);
|
22 |
Â
$this->setForm($form);
|
23 |
+
|
24 |
Â
return parent::_prepareForm();
|
25 |
Â
}
|
26 |
Â
|
@@ -4,6 +4,7 @@ class Dotdigitalgroup_Email_Block_Adminhtml_Rules_Edit_Tab_Conditions
|
|
4 |
Â
extends Mage_Adminhtml_Block_Widget_Form
|
5 |
Â
implements Mage_Adminhtml_Block_Widget_Tab_Interface
|
6 |
Â
{
|
Â
|
|
7 |
Â
/**
|
8 |
Â
* Prepare content for tab
|
9 |
Â
*
|
@@ -47,34 +48,49 @@ class Dotdigitalgroup_Email_Block_Adminhtml_Rules_Edit_Tab_Conditions
|
|
47 |
Â
protected function _prepareForm()
|
48 |
Â
{
|
49 |
Â
$model = Mage::registry('current_ddg_rule');
|
50 |
-
$form
|
51 |
Â
$form->setHtmlIdPrefix('rule_');
|
52 |
Â
|
53 |
-
$fieldset = $form->addFieldset(
|
54 |
-
|
Â
|
|
Â
|
|
Â
|
|
55 |
Â
);
|
56 |
Â
|
57 |
-
$fieldset->addField(
|
58 |
-
'
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
67 |
Â
If multi line conditions for same attribute is used and ALL is chosen then multiple lines for same attribute will be ignored.</small>',
|
68 |
-
|
Â
|
|
69 |
Â
|
70 |
-
$field
|
71 |
-
'
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
78 |
Â
$field->setRenderer($renderer);
|
79 |
Â
|
80 |
Â
$form->setValues($model->getData());
|
4 |
Â
extends Mage_Adminhtml_Block_Widget_Form
|
5 |
Â
implements Mage_Adminhtml_Block_Widget_Tab_Interface
|
6 |
Â
{
|
7 |
+
|
8 |
Â
/**
|
9 |
Â
* Prepare content for tab
|
10 |
Â
*
|
48 |
Â
protected function _prepareForm()
|
49 |
Â
{
|
50 |
Â
$model = Mage::registry('current_ddg_rule');
|
51 |
+
$form = new Varien_Data_Form();
|
52 |
Â
$form->setHtmlIdPrefix('rule_');
|
53 |
Â
|
54 |
+
$fieldset = $form->addFieldset(
|
55 |
+
'base_fieldset',
|
56 |
+
array('legend' => Mage::helper('ddg')->__(
|
57 |
+
'Exclusion Rule Conditions'
|
58 |
+
))
|
59 |
Â
);
|
60 |
Â
|
61 |
+
$fieldset->addField(
|
62 |
+
'combination', 'select', array(
|
63 |
+
'label' => Mage::helper('ddg')->__(
|
64 |
+
'Conditions Combination Match'
|
65 |
+
),
|
66 |
+
'title' => Mage::helper('ddg')->__(
|
67 |
+
'Conditions Combination Match'
|
68 |
+
),
|
69 |
+
'name' => 'combination',
|
70 |
+
'required' => true,
|
71 |
+
'options' => array(
|
72 |
+
'1' => Mage::helper('ddg')->__('ALL'),
|
73 |
+
'2' => Mage::helper('ddg')->__('ANY'),
|
74 |
+
),
|
75 |
+
'after_element_html' => '<small>Choose ANY if using multi line conditions for same attribute.
|
76 |
Â
If multi line conditions for same attribute is used and ALL is chosen then multiple lines for same attribute will be ignored.</small>',
|
77 |
+
)
|
78 |
+
);
|
79 |
Â
|
80 |
+
$field = $fieldset->addField(
|
81 |
+
'condition', 'select', array(
|
82 |
+
'name' => 'condition',
|
83 |
+
'label' => Mage::helper('ddg')->__('Condition'),
|
84 |
+
'title' => Mage::helper('ddg')->__('Condition'),
|
85 |
+
'required' => true,
|
86 |
+
'options' => Mage::getModel(
|
87 |
+
'ddg_automation/adminhtml_source_rules_type'
|
88 |
+
)->toOptionArray(),
|
89 |
+
)
|
90 |
+
);
|
91 |
+
$renderer = $this->getLayout()->createBlock(
|
92 |
+
'ddg_automation/adminhtml_config_rules_customdatafields'
|
93 |
+
);
|
94 |
Â
$field->setRenderer($renderer);
|
95 |
Â
|
96 |
Â
$form->setValues($model->getData());
|
@@ -4,6 +4,7 @@ class Dotdigitalgroup_Email_Block_Adminhtml_Rules_Edit_Tab_Main
|
|
4 |
Â
extends Mage_Adminhtml_Block_Widget_Form
|
5 |
Â
implements Mage_Adminhtml_Block_Widget_Tab_Interface
|
6 |
Â
{
|
Â
|
|
7 |
Â
/**
|
8 |
Â
* Prepare content for tab
|
9 |
Â
*
|
@@ -51,65 +52,81 @@ class Dotdigitalgroup_Email_Block_Adminhtml_Rules_Edit_Tab_Main
|
|
51 |
Â
$form = new Varien_Data_Form();
|
52 |
Â
$form->setHtmlIdPrefix('rule_');
|
53 |
Â
|
54 |
-
$fieldset = $form->addFieldset(
|
Â
|
|
55 |
Â
array('legend' => Mage::helper('ddg')->__('Rule Information'))
|
56 |
Â
);
|
57 |
Â
|
58 |
Â
if ($model->getId()) {
|
59 |
-
$fieldset->addField(
|
60 |
-
'
|
61 |
-
|
Â
|
|
Â
|
|
62 |
Â
}
|
63 |
Â
|
64 |
-
$fieldset->addField(
|
65 |
-
'name'
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
'
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
'
|
88 |
-
'
|
89 |
-
'
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
94 |
Â
$model->setData('status', '0');
|
95 |
Â
}
|
96 |
Â
|
97 |
Â
if (Mage::app()->isSingleStoreMode()) {
|
98 |
Â
$websiteId = Mage::app()->getStore(true)->getWebsiteId();
|
99 |
-
$fieldset->addField(
|
100 |
-
'
|
101 |
-
|
102 |
-
|
Â
|
|
Â
|
|
103 |
Â
$model->setWebsiteIds($websiteId);
|
104 |
Â
} else {
|
105 |
-
$field
|
106 |
-
'
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
113 |
Â
$field->setRenderer($renderer);
|
114 |
Â
}
|
115 |
Â
|
4 |
Â
extends Mage_Adminhtml_Block_Widget_Form
|
5 |
Â
implements Mage_Adminhtml_Block_Widget_Tab_Interface
|
6 |
Â
{
|
7 |
+
|
8 |
Â
/**
|
9 |
Â
* Prepare content for tab
|
10 |
Â
*
|
52 |
Â
$form = new Varien_Data_Form();
|
53 |
Â
$form->setHtmlIdPrefix('rule_');
|
54 |
Â
|
55 |
+
$fieldset = $form->addFieldset(
|
56 |
+
'base_fieldset',
|
57 |
Â
array('legend' => Mage::helper('ddg')->__('Rule Information'))
|
58 |
Â
);
|
59 |
Â
|
60 |
Â
if ($model->getId()) {
|
61 |
+
$fieldset->addField(
|
62 |
+
'id', 'hidden', array(
|
63 |
+
'name' => 'id',
|
64 |
+
)
|
65 |
+
);
|
66 |
Â
}
|
67 |
Â
|
68 |
+
$fieldset->addField(
|
69 |
+
'name', 'text', array(
|
70 |
+
'name' => 'name',
|
71 |
+
'label' => Mage::helper('ddg')->__('Rule Name'),
|
72 |
+
'title' => Mage::helper('ddg')->__('Rule Name'),
|
73 |
+
'required' => true,
|
74 |
+
)
|
75 |
+
);
|
76 |
+
|
77 |
+
$fieldset->addField(
|
78 |
+
'type', 'select', array(
|
79 |
+
'label' => Mage::helper('ddg')->__('Rule Type'),
|
80 |
+
'title' => Mage::helper('ddg')->__('Rule Type'),
|
81 |
+
'name' => 'type',
|
82 |
+
'required' => true,
|
83 |
+
'options' => array(
|
84 |
+
Dotdigitalgroup_Email_Model_Rules::ABANDONED => 'Abandoned Cart Exclusion Rule',
|
85 |
+
Dotdigitalgroup_Email_Model_Rules::REVIEW => 'Review Email Exclusion Rule',
|
86 |
+
),
|
87 |
+
)
|
88 |
+
);
|
89 |
+
|
90 |
+
$fieldset->addField(
|
91 |
+
'status', 'select', array(
|
92 |
+
'label' => Mage::helper('ddg')->__('Status'),
|
93 |
+
'title' => Mage::helper('ddg')->__('Status'),
|
94 |
+
'name' => 'status',
|
95 |
+
'required' => true,
|
96 |
+
'options' => array(
|
97 |
+
'1' => Mage::helper('ddg')->__('Active'),
|
98 |
+
'0' => Mage::helper('ddg')->__('Inactive'),
|
99 |
+
),
|
100 |
+
)
|
101 |
+
);
|
102 |
+
|
103 |
+
if ( ! $model->getId()) {
|
104 |
Â
$model->setData('status', '0');
|
105 |
Â
}
|
106 |
Â
|
107 |
Â
if (Mage::app()->isSingleStoreMode()) {
|
108 |
Â
$websiteId = Mage::app()->getStore(true)->getWebsiteId();
|
109 |
+
$fieldset->addField(
|
110 |
+
'website_ids', 'hidden', array(
|
111 |
+
'name' => 'website_ids[]',
|
112 |
+
'value' => $websiteId
|
113 |
+
)
|
114 |
+
);
|
115 |
Â
$model->setWebsiteIds($websiteId);
|
116 |
Â
} else {
|
117 |
+
$field = $fieldset->addField(
|
118 |
+
'website_ids', 'multiselect', array(
|
119 |
+
'name' => 'website_ids[]',
|
120 |
+
'label' => Mage::helper('ddg')->__('Websites'),
|
121 |
+
'title' => Mage::helper('ddg')->__('Websites'),
|
122 |
+
'required' => true,
|
123 |
+
'values' => Mage::getSingleton('adminhtml/system_store')
|
124 |
+
->getWebsiteValuesForForm()
|
125 |
+
)
|
126 |
+
);
|
127 |
+
$renderer = $this->getLayout()->createBlock(
|
128 |
+
'adminhtml/store_switcher_form_renderer_fieldset_element'
|
129 |
+
);
|
130 |
Â
$field->setRenderer($renderer);
|
131 |
Â
}
|
132 |
Â
|
@@ -1,7 +1,9 @@
|
|
1 |
Â
<?php
|
2 |
Â
|
3 |
-
class Dotdigitalgroup_Email_Block_Adminhtml_Rules_Edit_Tabs
|
Â
|
|
4 |
Â
{
|
Â
|
|
5 |
Â
public function __construct()
|
6 |
Â
{
|
7 |
Â
parent::__construct();
|
1 |
Â
<?php
|
2 |
Â
|
3 |
+
class Dotdigitalgroup_Email_Block_Adminhtml_Rules_Edit_Tabs
|
4 |
+
extends Mage_Adminhtml_Block_Widget_Tabs
|
5 |
Â
{
|
6 |
+
|
7 |
Â
public function __construct()
|
8 |
Â
{
|
9 |
Â
parent::__construct();
|
@@ -1,7 +1,9 @@
|
|
1 |
Â
<?php
|
2 |
Â
|
3 |
-
class Dotdigitalgroup_Email_Block_Adminhtml_Rules_Grid
|
Â
|
|
4 |
Â
{
|
Â
|
|
5 |
Â
public function __construct()
|
6 |
Â
{
|
7 |
Â
parent::__construct();
|
@@ -15,13 +17,16 @@ class Dotdigitalgroup_Email_Block_Adminhtml_Rules_Grid extends Mage_Adminhtml_Bl
|
|
15 |
Â
|
16 |
Â
/**
|
17 |
Â
* Prepare the grid collection.
|
Â
|
|
18 |
Â
* @return Mage_Adminhtml_Block_Widget_Grid
|
19 |
Â
*/
|
20 |
Â
protected function _prepareCollection()
|
21 |
Â
{
|
22 |
-
$collection = Mage::getModel('ddg_automation/rules')
|
Â
|
|
23 |
Â
$this->setCollection($collection);
|
24 |
Â
parent::_prepareCollection();
|
Â
|
|
25 |
Â
return $this;
|
26 |
Â
}
|
27 |
Â
|
@@ -33,72 +38,88 @@ class Dotdigitalgroup_Email_Block_Adminhtml_Rules_Grid extends Mage_Adminhtml_Bl
|
|
33 |
Â
*/
|
34 |
Â
protected function _prepareColumns()
|
35 |
Â
{
|
36 |
-
$this->addColumn(
|
37 |
-
'
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
42 |
Â
|
43 |
-
$this->addColumn(
|
44 |
-
'
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
49 |
Â
|
50 |
-
$this->addColumn(
|
51 |
-
'
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
Â
|
|
Â
|
|
61 |
Â
|
62 |
-
$this->addColumn(
|
63 |
-
'
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
),
|
72 |
-
));
|
73 |
Â
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
Â
|
|
Â
|
|
81 |
Â
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
89 |
Â
|
90 |
-
if (!Mage::app()->isSingleStoreMode()) {
|
91 |
-
$this->addColumn('rule_website', array(
|
92 |
-
'header' => Mage::helper('salesrule')->__('Website'),
|
93 |
-
'align' =>'left',
|
94 |
-
'index' => 'website_ids',
|
95 |
-
'type' => 'options',
|
96 |
-
'sortable' => false,
|
97 |
-
'options' => Mage::getSingleton('adminhtml/system_store')->getWebsiteOptionHash(),
|
98 |
-
'width' => 150,
|
99 |
-
));
|
100 |
-
}
|
101 |
-
parent::_prepareColumns();
|
102 |
Â
return $this;
|
103 |
Â
}
|
104 |
Â
|
1 |
Â
<?php
|
2 |
Â
|
3 |
+
class Dotdigitalgroup_Email_Block_Adminhtml_Rules_Grid
|
4 |
+
extends Mage_Adminhtml_Block_Widget_Grid
|
5 |
Â
{
|
6 |
+
|
7 |
Â
public function __construct()
|
8 |
Â
{
|
9 |
Â
parent::__construct();
|
17 |
Â
|
18 |
Â
/**
|
19 |
Â
* Prepare the grid collection.
|
20 |
+
*
|
21 |
Â
* @return Mage_Adminhtml_Block_Widget_Grid
|
22 |
Â
*/
|
23 |
Â
protected function _prepareCollection()
|
24 |
Â
{
|
25 |
+
$collection = Mage::getModel('ddg_automation/rules')
|
26 |
+
->getResourceCollection();
|
27 |
Â
$this->setCollection($collection);
|
28 |
Â
parent::_prepareCollection();
|
29 |
+
|
30 |
Â
return $this;
|
31 |
Â
}
|
32 |
Â
|
38 |
Â
*/
|
39 |
Â
protected function _prepareColumns()
|
40 |
Â
{
|
41 |
+
$this->addColumn(
|
42 |
+
'rule_id', array(
|
43 |
+
'header' => Mage::helper('ddg')->__('ID'),
|
44 |
+
'align' => 'right',
|
45 |
+
'width' => '50px',
|
46 |
+
'index' => 'id',
|
47 |
+
)
|
48 |
+
);
|
49 |
+
|
50 |
+
$this->addColumn(
|
51 |
+
'name', array(
|
52 |
+
'header' => Mage::helper('ddg')->__('Rule Name'),
|
53 |
+
'align' => 'left',
|
54 |
+
'width' => '150px',
|
55 |
+
'index' => 'name',
|
56 |
+
)
|
57 |
+
);
|
58 |
Â
|
59 |
+
$this->addColumn(
|
60 |
+
'type', array(
|
61 |
+
'header' => Mage::helper('ddg')->__('Rule Type'),
|
62 |
+
'align' => 'left',
|
63 |
+
'width' => '150px',
|
64 |
+
'index' => 'type',
|
65 |
+
'type' => 'options',
|
66 |
+
'options' => array(
|
67 |
+
1 => 'Abandoned Cart Exclusion Rule',
|
68 |
+
2 => 'Review Email Exclusion Rule',
|
69 |
+
),
|
70 |
+
)
|
71 |
+
);
|
72 |
Â
|
73 |
+
$this->addColumn(
|
74 |
+
'status', array(
|
75 |
+
'header' => Mage::helper('ddg')->__('Status'),
|
76 |
+
'align' => 'left',
|
77 |
+
'width' => '80px',
|
78 |
+
'index' => 'status',
|
79 |
+
'type' => 'options',
|
80 |
+
'options' => array(
|
81 |
+
1 => 'Active',
|
82 |
+
0 => 'Inactive',
|
83 |
+
),
|
84 |
+
)
|
85 |
+
);
|
86 |
Â
|
87 |
+
$this->addColumn(
|
88 |
+
'created_at', array(
|
89 |
+
'header' => Mage::helper('ddg')->__('Created At'),
|
90 |
+
'align' => 'left',
|
91 |
+
'width' => '120px',
|
92 |
+
'type' => 'datetime',
|
93 |
+
'index' => 'created_at',
|
94 |
+
)
|
95 |
+
);
|
Â
|
|
Â
|
|
96 |
Â
|
97 |
+
$this->addColumn(
|
98 |
+
'updated_at', array(
|
99 |
+
'header' => Mage::helper('ddg')->__('Updated At'),
|
100 |
+
'align' => 'left',
|
101 |
+
'width' => '120px',
|
102 |
+
'type' => 'datetime',
|
103 |
+
'index' => 'updated_at',
|
104 |
+
)
|
105 |
+
);
|
106 |
Â
|
107 |
+
if ( ! Mage::app()->isSingleStoreMode()) {
|
108 |
+
$this->addColumn(
|
109 |
+
'rule_website', array(
|
110 |
+
'header' => Mage::helper('salesrule')->__('Website'),
|
111 |
+
'align' => 'left',
|
112 |
+
'index' => 'website_ids',
|
113 |
+
'type' => 'options',
|
114 |
+
'sortable' => false,
|
115 |
+
'options' => Mage::getSingleton('adminhtml/system_store')
|
116 |
+
->getWebsiteOptionHash(),
|
117 |
+
'width' => 150,
|
118 |
+
)
|
119 |
+
);
|
120 |
+
}
|
121 |
+
parent::_prepareColumns();
|
122 |
Â
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
123 |
Â
return $this;
|
124 |
Â
}
|
125 |
Â
|
@@ -1,12 +1,14 @@
|
|
1 |
Â
<?php
|
2 |
-
|
Â
|
|
Â
|
|
3 |
Â
{
|
4 |
Â
|
5 |
Â
public function __construct()
|
6 |
Â
{
|
7 |
-
$this->_objectId
|
8 |
-
$this->_controller
|
9 |
-
$this->_mode
|
10 |
Â
|
11 |
Â
parent::__construct();
|
12 |
Â
|
@@ -15,46 +17,56 @@ class Dotdigitalgroup_Email_Block_Adminhtml_Sales_Order_Creditmemo_View extends
|
|
15 |
Â
$this->_removeButton('delete');
|
16 |
Â
|
17 |
Â
if ($this->getCreditmemo()->canCancel()) {
|
18 |
-
$this->_addButton(
|
19 |
-
|
20 |
-
'
|
21 |
-
'
|
Â
|
|
Â
|
|
22 |
Â
)
|
23 |
Â
);
|
24 |
Â
}
|
25 |
Â
|
26 |
Â
if ($this->_isAllowedAction('emails')) {
|
27 |
-
$this->addButton(
|
28 |
-
'
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
33 |
Â
}
|
34 |
Â
|
35 |
Â
if ($this->getCreditmemo()->canRefund()) {
|
36 |
-
$this->_addButton(
|
37 |
-
|
38 |
-
'
|
39 |
-
'
|
Â
|
|
Â
|
|
40 |
Â
)
|
41 |
Â
);
|
42 |
Â
}
|
43 |
Â
|
44 |
Â
if ($this->getCreditmemo()->canVoid()) {
|
45 |
-
$this->_addButton(
|
46 |
-
|
47 |
-
'
|
48 |
-
'
|
Â
|
|
49 |
Â
)
|
50 |
Â
);
|
51 |
Â
}
|
52 |
Â
|
53 |
Â
if ($this->getCreditmemo()->getId()) {
|
54 |
-
$this->_addButton(
|
55 |
-
|
56 |
-
'
|
57 |
-
'
|
Â
|
|
58 |
Â
)
|
59 |
Â
);
|
60 |
Â
}
|
@@ -78,12 +90,21 @@ class Dotdigitalgroup_Email_Block_Adminhtml_Sales_Order_Creditmemo_View extends
|
|
78 |
Â
public function getHeaderText()
|
79 |
Â
{
|
80 |
Â
if ($this->getCreditmemo()->getEmailSent()) {
|
81 |
-
$emailSent = Mage::helper('sales')->__(
|
82 |
-
|
83 |
-
|
84 |
-
|
Â
|
|
Â
|
|
Â
|
|
85 |
Â
}
|
86 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
87 |
Â
}
|
88 |
Â
|
89 |
Â
/**
|
@@ -96,9 +117,10 @@ class Dotdigitalgroup_Email_Block_Adminhtml_Sales_Order_Creditmemo_View extends
|
|
96 |
Â
return $this->getUrl(
|
97 |
Â
'*/sales_order/view',
|
98 |
Â
array(
|
99 |
-
'order_id'
|
100 |
-
'active_tab'=> 'order_creditmemos'
|
101 |
-
)
|
Â
|
|
102 |
Â
}
|
103 |
Â
|
104 |
Â
/**
|
@@ -108,7 +130,10 @@ class Dotdigitalgroup_Email_Block_Adminhtml_Sales_Order_Creditmemo_View extends
|
|
108 |
Â
*/
|
109 |
Â
public function getCaptureUrl()
|
110 |
Â
{
|
111 |
-
return $this->getUrl(
|
Â
|
|
Â
|
|
Â
|
|
112 |
Â
}
|
113 |
Â
|
114 |
Â
/**
|
@@ -118,7 +143,10 @@ class Dotdigitalgroup_Email_Block_Adminhtml_Sales_Order_Creditmemo_View extends
|
|
118 |
Â
*/
|
119 |
Â
public function getVoidUrl()
|
120 |
Â
{
|
121 |
-
return $this->getUrl(
|
Â
|
|
Â
|
|
Â
|
|
122 |
Â
}
|
123 |
Â
|
124 |
Â
/**
|
@@ -128,7 +156,10 @@ class Dotdigitalgroup_Email_Block_Adminhtml_Sales_Order_Creditmemo_View extends
|
|
128 |
Â
*/
|
129 |
Â
public function getCancelUrl()
|
130 |
Â
{
|
131 |
-
return $this->getUrl(
|
Â
|
|
Â
|
|
Â
|
|
132 |
Â
}
|
133 |
Â
|
134 |
Â
/**
|
@@ -138,10 +169,12 @@ class Dotdigitalgroup_Email_Block_Adminhtml_Sales_Order_Creditmemo_View extends
|
|
138 |
Â
*/
|
139 |
Â
public function getEmailUrl()
|
140 |
Â
{
|
141 |
-
return $this->getUrl(
|
142 |
-
'
|
143 |
-
|
144 |
-
|
Â
|
|
Â
|
|
145 |
Â
}
|
146 |
Â
|
147 |
Â
/**
|
@@ -151,18 +184,20 @@ class Dotdigitalgroup_Email_Block_Adminhtml_Sales_Order_Creditmemo_View extends
|
|
151 |
Â
*/
|
152 |
Â
public function getPrintUrl()
|
153 |
Â
{
|
154 |
-
return $this->getUrl(
|
155 |
-
'
|
156 |
-
|
Â
|
|
Â
|
|
157 |
Â
}
|
158 |
Â
|
159 |
Â
/**
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
Â
public function updateBackButtonUrl($flag)
|
167 |
Â
{
|
168 |
Â
if ($flag) {
|
@@ -170,7 +205,8 @@ class Dotdigitalgroup_Email_Block_Adminhtml_Sales_Order_Creditmemo_View extends
|
|
170 |
Â
return $this->_updateButton(
|
171 |
Â
'back',
|
172 |
Â
'onclick',
|
173 |
-
'setLocation(\'' . $this->getCreditmemo()->getBackUrl()
|
Â
|
|
174 |
Â
);
|
175 |
Â
}
|
176 |
Â
|
@@ -180,6 +216,7 @@ class Dotdigitalgroup_Email_Block_Adminhtml_Sales_Order_Creditmemo_View extends
|
|
180 |
Â
'setLocation(\'' . $this->getUrl('*/sales_creditmemo/') . '\')'
|
181 |
Â
);
|
182 |
Â
}
|
Â
|
|
183 |
Â
return $this;
|
184 |
Â
}
|
185 |
Â
|
@@ -187,10 +224,13 @@ class Dotdigitalgroup_Email_Block_Adminhtml_Sales_Order_Creditmemo_View extends
|
|
187 |
Â
* Check whether action is allowed
|
188 |
Â
*
|
189 |
Â
* @param string $action
|
Â
|
|
190 |
Â
* @return bool
|
191 |
Â
*/
|
192 |
Â
public function _isAllowedAction($action)
|
193 |
Â
{
|
194 |
-
return Mage::getSingleton('admin/session')->isAllowed(
|
Â
|
|
Â
|
|
195 |
Â
}
|
196 |
Â
}
|
1 |
Â
<?php
|
2 |
+
|
3 |
+
class Dotdigitalgroup_Email_Block_Adminhtml_Sales_Order_Creditmemo_View
|
4 |
+
extends Mage_Adminhtml_Block_Widget_Form_Container
|
5 |
Â
{
|
6 |
Â
|
7 |
Â
public function __construct()
|
8 |
Â
{
|
9 |
+
$this->_objectId = 'creditmemo_id';
|
10 |
+
$this->_controller = 'sales_order_creditmemo';
|
11 |
+
$this->_mode = 'view';
|
12 |
Â
|
13 |
Â
parent::__construct();
|
14 |
Â
|
17 |
Â
$this->_removeButton('delete');
|
18 |
Â
|
19 |
Â
if ($this->getCreditmemo()->canCancel()) {
|
20 |
+
$this->_addButton(
|
21 |
+
'cancel', array(
|
22 |
+
'label' => Mage::helper('sales')->__('Cancel'),
|
23 |
+
'class' => 'delete',
|
24 |
+
'onclick' => 'setLocation(\'' . $this->getCancelUrl()
|
25 |
+
. '\')'
|
26 |
Â
)
|
27 |
Â
);
|
28 |
Â
}
|
29 |
Â
|
30 |
Â
if ($this->_isAllowedAction('emails')) {
|
31 |
+
$this->addButton(
|
32 |
+
'send_notification', array(
|
33 |
+
'label' => Mage::helper('sales')->__('Send Email'),
|
34 |
+
'onclick' => 'confirmSetLocation(\''
|
35 |
+
. Mage::helper('sales')->__(
|
36 |
+
'Are you sure you want to send Creditmemo email to customer?'
|
37 |
+
)
|
38 |
+
. '\', \'' . $this->getEmailUrl() . '\')'
|
39 |
+
)
|
40 |
+
);
|
41 |
Â
}
|
42 |
Â
|
43 |
Â
if ($this->getCreditmemo()->canRefund()) {
|
44 |
+
$this->_addButton(
|
45 |
+
'refund', array(
|
46 |
+
'label' => Mage::helper('sales')->__('Refund'),
|
47 |
+
'class' => 'save',
|
48 |
+
'onclick' => 'setLocation(\'' . $this->getRefundUrl()
|
49 |
+
. '\')'
|
50 |
Â
)
|
51 |
Â
);
|
52 |
Â
}
|
53 |
Â
|
54 |
Â
if ($this->getCreditmemo()->canVoid()) {
|
55 |
+
$this->_addButton(
|
56 |
+
'void', array(
|
57 |
+
'label' => Mage::helper('sales')->__('Void'),
|
58 |
+
'class' => 'save',
|
59 |
+
'onclick' => 'setLocation(\'' . $this->getVoidUrl() . '\')'
|
60 |
Â
)
|
61 |
Â
);
|
62 |
Â
}
|
63 |
Â
|
64 |
Â
if ($this->getCreditmemo()->getId()) {
|
65 |
+
$this->_addButton(
|
66 |
+
'print', array(
|
67 |
+
'label' => Mage::helper('sales')->__('Print'),
|
68 |
+
'class' => 'save',
|
69 |
+
'onclick' => 'setLocation(\'' . $this->getPrintUrl() . '\')'
|
70 |
Â
)
|
71 |
Â
);
|
72 |
Â
}
|
90 |
Â
public function getHeaderText()
|
91 |
Â
{
|
92 |
Â
if ($this->getCreditmemo()->getEmailSent()) {
|
93 |
+
$emailSent = Mage::helper('sales')->__(
|
94 |
+
'the credit memo email was sent'
|
95 |
+
);
|
96 |
+
} else {
|
97 |
+
$emailSent = Mage::helper('sales')->__(
|
98 |
+
'the credit memo email is not sent'
|
99 |
+
);
|
100 |
Â
}
|
101 |
+
|
102 |
+
return Mage::helper('sales')->__(
|
103 |
+
'Credit Memo #%1$s | %3$s | %2$s (%4$s)',
|
104 |
+
$this->getCreditmemo()->getIncrementId(), $this->formatDate(
|
105 |
+
$this->getCreditmemo()->getCreatedAtDate(), 'medium', true
|
106 |
+
), $this->getCreditmemo()->getStateName(), $emailSent
|
107 |
+
);
|
108 |
Â
}
|
109 |
Â
|
110 |
Â
/**
|
117 |
Â
return $this->getUrl(
|
118 |
Â
'*/sales_order/view',
|
119 |
Â
array(
|
120 |
+
'order_id' => $this->getCreditmemo()->getOrderId(),
|
121 |
+
'active_tab' => 'order_creditmemos'
|
122 |
+
)
|
123 |
+
);
|
124 |
Â
}
|
125 |
Â
|
126 |
Â
/**
|
130 |
Â
*/
|
131 |
Â
public function getCaptureUrl()
|
132 |
Â
{
|
133 |
+
return $this->getUrl(
|
134 |
+
'*/*/capture',
|
135 |
+
array('creditmemo_id' => $this->getCreditmemo()->getId())
|
136 |
+
);
|
137 |
Â
}
|
138 |
Â
|
139 |
Â
/**
|
143 |
Â
*/
|
144 |
Â
public function getVoidUrl()
|
145 |
Â
{
|
146 |
+
return $this->getUrl(
|
147 |
+
'*/*/void',
|
148 |
+
array('creditmemo_id' => $this->getCreditmemo()->getId())
|
149 |
+
);
|
150 |
Â
}
|
151 |
Â
|
152 |
Â
/**
|
156 |
Â
*/
|
157 |
Â
public function getCancelUrl()
|
158 |
Â
{
|
159 |
+
return $this->getUrl(
|
160 |
+
'*/*/cancel',
|
161 |
+
array('creditmemo_id' => $this->getCreditmemo()->getId())
|
162 |
+
);
|
163 |
Â
}
|
164 |
Â
|
165 |
Â
/**
|
169 |
Â
*/
|
170 |
Â
public function getEmailUrl()
|
171 |
Â
{
|
172 |
+
return $this->getUrl(
|
173 |
+
'*/*/email', array(
|
174 |
+
'creditmemo_id' => $this->getCreditmemo()->getId(),
|
175 |
+
'order_id' => $this->getCreditmemo()->getOrderId()
|
176 |
+
)
|
177 |
+
);
|
178 |
Â
}
|
179 |
Â
|
180 |
Â
/**
|
184 |
Â
*/
|
185 |
Â
public function getPrintUrl()
|
186 |
Â
{
|
187 |
+
return $this->getUrl(
|
188 |
+
'*/*/print', array(
|
189 |
+
'creditmemo_id' => $this->getCreditmemo()->getId()
|
190 |
+
)
|
191 |
+
);
|
192 |
Â
}
|
193 |
Â
|
194 |
Â
/**
|
195 |
+
* Update 'back' button url.
|
196 |
+
*
|
197 |
+
* @param $flag
|
198 |
+
*
|
199 |
+
* @return $this|Mage_Adminhtml_Block_Widget_Container
|
200 |
+
*/
|
201 |
Â
public function updateBackButtonUrl($flag)
|
202 |
Â
{
|
203 |
Â
if ($flag) {
|
205 |
Â
return $this->_updateButton(
|
206 |
Â
'back',
|
207 |
Â
'onclick',
|
208 |
+
'setLocation(\'' . $this->getCreditmemo()->getBackUrl()
|
209 |
+
. '\')'
|
210 |
Â
);
|
211 |
Â
}
|
212 |
Â
|
216 |
Â
'setLocation(\'' . $this->getUrl('*/sales_creditmemo/') . '\')'
|
217 |
Â
);
|
218 |
Â
}
|
219 |
+
|
220 |
Â
return $this;
|
221 |
Â
}
|
222 |
Â
|
224 |
Â
* Check whether action is allowed
|
225 |
Â
*
|
226 |
Â
* @param string $action
|
227 |
+
*
|
228 |
Â
* @return bool
|
229 |
Â
*/
|
230 |
Â
public function _isAllowedAction($action)
|
231 |
Â
{
|
232 |
+
return Mage::getSingleton('admin/session')->isAllowed(
|
233 |
+
'sales/order/actions/' . $action
|
234 |
+
);
|
235 |
Â
}
|
236 |
Â
}
|
@@ -1,17 +1,22 @@
|
|
1 |
Â
<?php
|
2 |
Â
|
3 |
-
class Dotdigitalgroup_Email_Block_Adminhtml_System_Advanced_Deletecontactids
|
Â
|
|
4 |
Â
{
|
5 |
Â
|
6 |
-
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element
|
Â
|
|
7 |
Â
{
|
8 |
Â
$this->setElement($element);
|
Â
|
|
9 |
Â
return $this->_getAddRowButtonHtml($this->__("Run Now"));
|
10 |
Â
}
|
11 |
Â
|
12 |
Â
protected function _getAddRowButtonHtml($title)
|
13 |
Â
{
|
14 |
-
$url = Mage::helper('adminhtml')->getUrl(
|
Â
|
|
Â
|
|
15 |
Â
|
16 |
Â
return $this->getLayout()->createBlock('adminhtml/widget_button')
|
17 |
Â
->setType('button')
|
1 |
Â
<?php
|
2 |
Â
|
3 |
+
class Dotdigitalgroup_Email_Block_Adminhtml_System_Advanced_Deletecontactids
|
4 |
+
extends Mage_Adminhtml_Block_System_Config_Form_Field
|
5 |
Â
{
|
6 |
Â
|
7 |
+
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element
|
8 |
+
)
|
9 |
Â
{
|
10 |
Â
$this->setElement($element);
|
11 |
+
|
12 |
Â
return $this->_getAddRowButtonHtml($this->__("Run Now"));
|
13 |
Â
}
|
14 |
Â
|
15 |
Â
protected function _getAddRowButtonHtml($title)
|
16 |
Â
{
|
17 |
+
$url = Mage::helper('adminhtml')->getUrl(
|
18 |
+
"*/connector/deletecontactids"
|
19 |
+
);
|
20 |
Â
|
21 |
Â
return $this->getLayout()->createBlock('adminhtml/widget_button')
|
22 |
Â
->setType('button')
|
@@ -1,11 +1,22 @@
|
|
1 |
Â
<?php
|
2 |
Â
|
3 |
-
class Dotdigitalgroup_Email_Block_Adminhtml_System_Advanced_Notification
|
Â
|
|
4 |
Â
{
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
11 |
Â
}
|
1 |
Â
<?php
|
2 |
Â
|
3 |
+
class Dotdigitalgroup_Email_Block_Adminhtml_System_Advanced_Notification
|
4 |
+
extends Mage_Adminhtml_Block_System_Config_Form_Field
|
5 |
Â
{
|
6 |
+
|
7 |
+
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element
|
8 |
+
)
|
9 |
+
{
|
10 |
+
$element->setValue(
|
11 |
+
Mage::app()->loadCache(
|
12 |
+
Dotdigitalgroup_Email_Helper_Config::CONNECTOR_FEED_LAST_CHECK_TIME
|
13 |
+
)
|
14 |
+
);
|
15 |
+
$format = Mage::app()->getLocale()->getDateTimeFormat(
|
16 |
+
Mage_Core_Model_Locale::FORMAT_TYPE_MEDIUM
|
17 |
+
);
|
18 |
+
|
19 |
+
return Mage::app()->getLocale()->date(intval($element->getValue()))
|
20 |
+
->toString($format);
|
21 |
+
}
|
22 |
Â
}
|
@@ -1,10 +1,14 @@
|
|
1 |
Â
<?php
|
2 |
-
|
Â
|
|
Â
|
|
3 |
Â
{
|
4 |
Â
|
5 |
-
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element
|
Â
|
|
6 |
Â
{
|
7 |
Â
$this->setElement($element);
|
Â
|
|
8 |
Â
return $this->_getAddRowButtonHtml($this->__("Run Now"));
|
9 |
Â
}
|
10 |
Â
|
1 |
Â
<?php
|
2 |
+
|
3 |
+
class Dotdigitalgroup_Email_Block_Adminhtml_System_Advanced_Reimportcatalog
|
4 |
+
extends Mage_Adminhtml_Block_System_Config_Form_Field
|
5 |
Â
{
|
6 |
Â
|
7 |
+
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element
|
8 |
+
)
|
9 |
Â
{
|
10 |
Â
$this->setElement($element);
|
11 |
+
|
12 |
Â
return $this->_getAddRowButtonHtml($this->__("Run Now"));
|
13 |
Â
}
|
14 |
Â
|
@@ -1,10 +1,14 @@
|
|
1 |
Â
<?php
|
2 |
-
|
Â
|
|
Â
|
|
3 |
Â
{
|
4 |
Â
|
5 |
-
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element
|
Â
|
|
6 |
Â
{
|
7 |
Â
$this->setElement($element);
|
Â
|
|
8 |
Â
return $this->_getAddRowButtonHtml($this->__("Run Now"));
|
9 |
Â
}
|
10 |
Â
|
1 |
Â
<?php
|
2 |
+
|
3 |
+
class Dotdigitalgroup_Email_Block_Adminhtml_System_Advanced_Reimportorders
|
4 |
+
extends Mage_Adminhtml_Block_System_Config_Form_Field
|
5 |
Â
{
|
6 |
Â
|
7 |
+
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element
|
8 |
+
)
|
9 |
Â
{
|
10 |
Â
$this->setElement($element);
|
11 |
+
|
12 |
Â
return $this->_getAddRowButtonHtml($this->__("Run Now"));
|
13 |
Â
}
|
14 |
Â
|
@@ -1,10 +1,14 @@
|
|
1 |
Â
<?php
|
2 |
-
|
Â
|
|
Â
|
|
3 |
Â
{
|
4 |
Â
|
5 |
-
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element
|
Â
|
|
6 |
Â
{
|
7 |
Â
$this->setElement($element);
|
Â
|
|
8 |
Â
return $this->_getAddRowButtonHtml($this->__("Run Now"));
|
9 |
Â
}
|
10 |
Â
|
1 |
Â
<?php
|
2 |
+
|
3 |
+
class Dotdigitalgroup_Email_Block_Adminhtml_System_Advanced_Reimportquotes
|
4 |
+
extends Mage_Adminhtml_Block_System_Config_Form_Field
|
5 |
Â
{
|
6 |
Â
|
7 |
+
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element
|
8 |
+
)
|
9 |
Â
{
|
10 |
Â
$this->setElement($element);
|
11 |
+
|
12 |
Â
return $this->_getAddRowButtonHtml($this->__("Run Now"));
|
13 |
Â
}
|
14 |
Â
|
@@ -1,10 +1,14 @@
|
|
1 |
Â
<?php
|
2 |
-
|
Â
|
|
Â
|
|
3 |
Â
{
|
4 |
Â
|
5 |
-
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element
|
Â
|
|
6 |
Â
{
|
7 |
Â
$this->setElement($element);
|
Â
|
|
8 |
Â
return $this->_getAddRowButtonHtml($this->__("Run Now"));
|
9 |
Â
}
|
10 |
Â
|
1 |
Â
<?php
|
2 |
+
|
3 |
+
class Dotdigitalgroup_Email_Block_Adminhtml_System_Advanced_Reimportreviews
|
4 |
+
extends Mage_Adminhtml_Block_System_Config_Form_Field
|
5 |
Â
{
|
6 |
Â
|
7 |
+
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element
|
8 |
+
)
|
9 |
Â
{
|
10 |
Â
$this->setElement($element);
|
11 |
+
|
12 |
Â
return $this->_getAddRowButtonHtml($this->__("Run Now"));
|
13 |
Â
}
|
14 |
Â
|
@@ -1,10 +1,14 @@
|
|
1 |
Â
<?php
|
2 |
-
|
Â
|
|
Â
|
|
3 |
Â
{
|
4 |
Â
|
5 |
-
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element
|
Â
|
|
6 |
Â
{
|
7 |
Â
$this->setElement($element);
|
Â
|
|
8 |
Â
return $this->_getAddRowButtonHtml($this->__("Run Now"));
|
9 |
Â
}
|
10 |
Â
|
1 |
Â
<?php
|
2 |
+
|
3 |
+
class Dotdigitalgroup_Email_Block_Adminhtml_System_Advanced_Reimportsubscribers
|
4 |
+
extends Mage_Adminhtml_Block_System_Config_Form_Field
|
5 |
Â
{
|
6 |
Â
|
7 |
+
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element
|
8 |
+
)
|
9 |
Â
{
|
10 |
Â
$this->setElement($element);
|
11 |
+
|
12 |
Â
return $this->_getAddRowButtonHtml($this->__("Run Now"));
|
13 |
Â
}
|
14 |
Â
|
@@ -1,10 +1,14 @@
|
|
1 |
Â
<?php
|
2 |
-
|
Â
|
|
Â
|
|
3 |
Â
{
|
4 |
Â
|
5 |
-
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element
|
Â
|
|
6 |
Â
{
|
7 |
Â
$this->setElement($element);
|
Â
|
|
8 |
Â
return $this->_getAddRowButtonHtml($this->__("Run Now"));
|
9 |
Â
}
|
10 |
Â
|
1 |
Â
<?php
|
2 |
+
|
3 |
+
class Dotdigitalgroup_Email_Block_Adminhtml_System_Advanced_Reimportwishlists
|
4 |
+
extends Mage_Adminhtml_Block_System_Config_Form_Field
|
5 |
Â
{
|
6 |
Â
|
7 |
+
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element
|
8 |
+
)
|
9 |
Â
{
|
10 |
Â
$this->setElement($element);
|
11 |
+
|
12 |
Â
return $this->_getAddRowButtonHtml($this->__("Run Now"));
|
13 |
Â
}
|
14 |
Â
|
@@ -1,11 +1,14 @@
|
|
1 |
Â
<?php
|
2 |
Â
|
3 |
-
class Dotdigitalgroup_Email_Block_Adminhtml_System_Advanced_Reset
|
Â
|
|
4 |
Â
{
|
5 |
Â
|
6 |
-
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element
|
Â
|
|
7 |
Â
{
|
8 |
Â
$this->setElement($element);
|
Â
|
|
9 |
Â
return $this->_getAddRowButtonHtml($this->__("Run Now"));
|
10 |
Â
}
|
11 |
Â
|
1 |
Â
<?php
|
2 |
Â
|
3 |
+
class Dotdigitalgroup_Email_Block_Adminhtml_System_Advanced_Reset
|
4 |
+
extends Mage_Adminhtml_Block_System_Config_Form_Field
|
5 |
Â
{
|
6 |
Â
|
7 |
+
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element
|
8 |
+
)
|
9 |
Â
{
|
10 |
Â
$this->setElement($element);
|
11 |
+
|
12 |
Â
return $this->_getAddRowButtonHtml($this->__("Run Now"));
|
13 |
Â
}
|
14 |
Â
|
@@ -1,10 +1,14 @@
|
|
1 |
Â
<?php
|
2 |
-
|
Â
|
|
Â
|
|
3 |
Â
{
|
4 |
Â
|
5 |
-
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element
|
Â
|
|
6 |
Â
{
|
7 |
Â
$this->setElement($element);
|
Â
|
|
8 |
Â
return $this->_getAddRowButtonHtml($this->__("Run Now"));
|
9 |
Â
}
|
10 |
Â
|
1 |
Â
<?php
|
2 |
+
|
3 |
+
class Dotdigitalgroup_Email_Block_Adminhtml_System_Advanced_Resetcustomersimport
|
4 |
+
extends Mage_Adminhtml_Block_System_Config_Form_Field
|
5 |
Â
{
|
6 |
Â
|
7 |
+
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element
|
8 |
+
)
|
9 |
Â
{
|
10 |
Â
$this->setElement($element);
|
11 |
+
|
12 |
Â
return $this->_getAddRowButtonHtml($this->__("Run Now"));
|
13 |
Â
}
|
14 |
Â
|
@@ -1,11 +1,14 @@
|
|
1 |
Â
<?php
|
2 |
Â
|
3 |
-
class Dotdigitalgroup_Email_Block_Adminhtml_System_Advanced_Runcatalogsync
|
Â
|
|
4 |
Â
{
|
5 |
Â
|
6 |
-
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element
|
Â
|
|
7 |
Â
{
|
8 |
Â
$this->setElement($element);
|
Â
|
|
9 |
Â
return $this->_getAddRowButtonHtml($this->__("Run Now"));
|
10 |
Â
}
|
11 |
Â
|
1 |
Â
<?php
|
2 |
Â
|
3 |
+
class Dotdigitalgroup_Email_Block_Adminhtml_System_Advanced_Runcatalogsync
|
4 |
+
extends Mage_Adminhtml_Block_System_Config_Form_Field
|
5 |
Â
{
|
6 |
Â
|
7 |
+
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element
|
8 |
+
)
|
9 |
Â
{
|
10 |
Â
$this->setElement($element);
|
11 |
+
|
12 |
Â
return $this->_getAddRowButtonHtml($this->__("Run Now"));
|
13 |
Â
}
|
14 |
Â
|
@@ -1,11 +1,14 @@
|
|
1 |
Â
<?php
|
2 |
Â
|
3 |
-
class Dotdigitalgroup_Email_Block_Adminhtml_System_Advanced_Runcontactsync
|
Â
|
|
4 |
Â
{
|
5 |
Â
|
6 |
-
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element
|
Â
|
|
7 |
Â
{
|
8 |
Â
$this->setElement($element);
|
Â
|
|
9 |
Â
return $this->_getAddRowButtonHtml($this->__("Run Now"));
|
10 |
Â
}
|
11 |
Â
|
1 |
Â
<?php
|
2 |
Â
|
3 |
+
class Dotdigitalgroup_Email_Block_Adminhtml_System_Advanced_Runcontactsync
|
4 |
+
extends Mage_Adminhtml_Block_System_Config_Form_Field
|
5 |
Â
{
|
6 |
Â
|
7 |
+
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element
|
8 |
+
)
|
9 |
Â
{
|
10 |
Â
$this->setElement($element);
|
11 |
+
|
12 |
Â
return $this->_getAddRowButtonHtml($this->__("Run Now"));
|
13 |
Â
}
|
14 |
Â
|
@@ -1,11 +1,14 @@
|
|
1 |
Â
<?php
|
2 |
Â
|
3 |
-
class Dotdigitalgroup_Email_Block_Adminhtml_System_Advanced_Runimportersync
|
Â
|
|
4 |
Â
{
|
5 |
Â
|
6 |
-
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element
|
Â
|
|
7 |
Â
{
|
8 |
Â
$this->setElement($element);
|
Â
|
|
9 |
Â
return $this->_getAddRowButtonHtml($this->__("Run Now"));
|
10 |
Â
}
|
11 |
Â
|
1 |
Â
<?php
|
2 |
Â
|
3 |
+
class Dotdigitalgroup_Email_Block_Adminhtml_System_Advanced_Runimportersync
|
4 |
+
extends Mage_Adminhtml_Block_System_Config_Form_Field
|
5 |
Â
{
|
6 |
Â
|
7 |
+
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element
|
8 |
+
)
|
9 |
Â
{
|
10 |
Â
$this->setElement($element);
|
11 |
+
|
12 |
Â
return $this->_getAddRowButtonHtml($this->__("Run Now"));
|
13 |
Â
}
|
14 |
Â
|
@@ -1,11 +1,14 @@
|
|
1 |
Â
<?php
|
2 |
Â
|
3 |
-
class Dotdigitalgroup_Email_Block_Adminhtml_System_Advanced_Runordersync
|
Â
|
|
4 |
Â
{
|
5 |
Â
|
6 |
-
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element
|
Â
|
|
7 |
Â
{
|
8 |
Â
$this->setElement($element);
|
Â
|
|
9 |
Â
return $this->_getAddRowButtonHtml($this->__("Run Now"));
|
10 |
Â
}
|
11 |
Â
|
1 |
Â
<?php
|
2 |
Â
|
3 |
+
class Dotdigitalgroup_Email_Block_Adminhtml_System_Advanced_Runordersync
|
4 |
+
extends Mage_Adminhtml_Block_System_Config_Form_Field
|
5 |
Â
{
|
6 |
Â
|
7 |
+
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element
|
8 |
+
)
|
9 |
Â
{
|
10 |
Â
$this->setElement($element);
|
11 |
+
|
12 |
Â
return $this->_getAddRowButtonHtml($this->__("Run Now"));
|
13 |
Â
}
|
14 |
Â
|
@@ -1,11 +1,14 @@
|
|
1 |
Â
<?php
|
2 |
Â
|
3 |
-
class Dotdigitalgroup_Email_Block_Adminhtml_System_Advanced_Runquotesync
|
Â
|
|
4 |
Â
{
|
5 |
Â
|
6 |
-
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element
|
Â
|
|
7 |
Â
{
|
8 |
Â
$this->setElement($element);
|
Â
|
|
9 |
Â
return $this->_getAddRowButtonHtml($this->__("Run Now"));
|
10 |
Â
}
|
11 |
Â
|
1 |
Â
<?php
|
2 |
Â
|
3 |
+
class Dotdigitalgroup_Email_Block_Adminhtml_System_Advanced_Runquotesync
|
4 |
+
extends Mage_Adminhtml_Block_System_Config_Form_Field
|
5 |
Â
{
|
6 |
Â
|
7 |
+
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element
|
8 |
+
)
|
9 |
Â
{
|
10 |
Â
$this->setElement($element);
|
11 |
+
|
12 |
Â
return $this->_getAddRowButtonHtml($this->__("Run Now"));
|
13 |
Â
}
|
14 |
Â
|
@@ -1,11 +1,14 @@
|
|
1 |
Â
<?php
|
2 |
Â
|
3 |
-
class Dotdigitalgroup_Email_Block_Adminhtml_System_Advanced_Runreviewsync
|
Â
|
|
4 |
Â
{
|
5 |
Â
|
6 |
-
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element
|
Â
|
|
7 |
Â
{
|
8 |
Â
$this->setElement($element);
|
Â
|
|
9 |
Â
return $this->_getAddRowButtonHtml($this->__("Run Now"));
|
10 |
Â
}
|
11 |
Â
|
1 |
Â
<?php
|
2 |
Â
|
3 |
+
class Dotdigitalgroup_Email_Block_Adminhtml_System_Advanced_Runreviewsync
|
4 |
+
extends Mage_Adminhtml_Block_System_Config_Form_Field
|
5 |
Â
{
|
6 |
Â
|
7 |
+
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element
|
8 |
+
)
|
9 |
Â
{
|
10 |
Â
$this->setElement($element);
|
11 |
+
|
12 |
Â
return $this->_getAddRowButtonHtml($this->__("Run Now"));
|
13 |
Â
}
|
14 |
Â
|
@@ -1,17 +1,22 @@
|
|
1 |
Â
<?php
|
2 |
Â
|
3 |
-
class Dotdigitalgroup_Email_Block_Adminhtml_System_Advanced_Runsubscribersync
|
Â
|
|
4 |
Â
{
|
5 |
Â
|
6 |
-
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element
|
Â
|
|
7 |
Â
{
|
8 |
Â
$this->setElement($element);
|
Â
|
|
9 |
Â
return $this->_getAddRowButtonHtml($this->__("Run Now"));
|
10 |
Â
}
|
11 |
Â
|
12 |
Â
protected function _getAddRowButtonHtml($title)
|
13 |
Â
{
|
14 |
-
$url = Mage::helper('adminhtml')->getUrl(
|
Â
|
|
Â
|
|
15 |
Â
|
16 |
Â
return $this->getLayout()->createBlock('adminhtml/widget_button')
|
17 |
Â
->setType('button')
|
1 |
Â
<?php
|
2 |
Â
|
3 |
+
class Dotdigitalgroup_Email_Block_Adminhtml_System_Advanced_Runsubscribersync
|
4 |
+
extends Mage_Adminhtml_Block_System_Config_Form_Field
|
5 |
Â
{
|
6 |
Â
|
7 |
+
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element
|
8 |
+
)
|
9 |
Â
{
|
10 |
Â
$this->setElement($element);
|
11 |
+
|
12 |
Â
return $this->_getAddRowButtonHtml($this->__("Run Now"));
|
13 |
Â
}
|
14 |
Â
|
15 |
Â
protected function _getAddRowButtonHtml($title)
|
16 |
Â
{
|
17 |
+
$url = Mage::helper('adminhtml')->getUrl(
|
18 |
+
"*/connector/runsubscribersync"
|
19 |
+
);
|
20 |
Â
|
21 |
Â
return $this->getLayout()->createBlock('adminhtml/widget_button')
|
22 |
Â
->setType('button')
|
@@ -1,11 +1,14 @@
|
|
1 |
Â
<?php
|
2 |
Â
|
3 |
-
class Dotdigitalgroup_Email_Block_Adminhtml_System_Advanced_Runwishlistsync
|
Â
|
|
4 |
Â
{
|
5 |
Â
|
6 |
-
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element
|
Â
|
|
7 |
Â
{
|
8 |
Â
$this->setElement($element);
|
Â
|
|
9 |
Â
return $this->_getAddRowButtonHtml($this->__("Run Now"));
|
10 |
Â
}
|
11 |
Â
|
1 |
Â
<?php
|
2 |
Â
|
3 |
+
class Dotdigitalgroup_Email_Block_Adminhtml_System_Advanced_Runwishlistsync
|
4 |
+
extends Mage_Adminhtml_Block_System_Config_Form_Field
|
5 |
Â
{
|
6 |
Â
|
7 |
+
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element
|
8 |
+
)
|
9 |
Â
{
|
10 |
Â
$this->setElement($element);
|
11 |
+
|
12 |
Â
return $this->_getAddRowButtonHtml($this->__("Run Now"));
|
13 |
Â
}
|
14 |
Â
|
@@ -1,24 +1,29 @@
|
|
1 |
Â
<?php
|
2 |
Â
|
3 |
-
class Dotdigitalgroup_Email_Block_Adminhtml_System_Advanced_Setupdatafields
|
Â
|
|
4 |
Â
{
|
5 |
Â
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
}
|
11 |
Â
|
12 |
-
|
13 |
-
|
14 |
-
$website = $this->getRequest()->getParam('website', 0);
|
15 |
-
$url = $this->getUrl("*/connector/setupdatafields/website/" . $website );
|
16 |
Â
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
23 |
Â
|
24 |
Â
}
|
1 |
Â
<?php
|
2 |
Â
|
3 |
+
class Dotdigitalgroup_Email_Block_Adminhtml_System_Advanced_Setupdatafields
|
4 |
+
extends Mage_Adminhtml_Block_System_Config_Form_Field
|
5 |
Â
{
|
6 |
Â
|
7 |
+
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element
|
8 |
+
)
|
9 |
+
{
|
10 |
+
$this->setElement($element);
|
Â
|
|
11 |
Â
|
12 |
+
return $this->_getAddRowButtonHtml($this->__("Run Now"));
|
13 |
+
}
|
Â
|
|
Â
|
|
14 |
Â
|
15 |
+
protected function _getAddRowButtonHtml($title)
|
16 |
+
{
|
17 |
+
$website = $this->getRequest()->getParam('website', 0);
|
18 |
+
$url = $this->getUrl(
|
19 |
+
"*/connector/setupdatafields/website/" . $website
|
20 |
+
);
|
21 |
+
|
22 |
+
return $this->getLayout()->createBlock('adminhtml/widget_button')
|
23 |
+
->setType('button')
|
24 |
+
->setLabel($this->__($title))
|
25 |
+
->setOnClick("window.location.href='" . $url . "'")
|
26 |
+
->toHtml();
|
27 |
+
}
|
28 |
Â
|
29 |
Â
}
|
@@ -1,8 +1,11 @@
|
|
1 |
Â
<?php
|
2 |
Â
|
3 |
-
class Dotdigitalgroup_Email_Block_Adminhtml_System_Ajaxvalidate
|
Â
|
|
4 |
Â
{
|
5 |
-
|
Â
|
|
Â
|
|
6 |
Â
|
7 |
Â
$element->setData('onchange', "apiValidation(this.form, this)");
|
8 |
Â
|
1 |
Â
<?php
|
2 |
Â
|
3 |
+
class Dotdigitalgroup_Email_Block_Adminhtml_System_Ajaxvalidate
|
4 |
+
extends Mage_Adminhtml_Block_System_Config_Form_Field
|
5 |
Â
{
|
6 |
+
|
7 |
+
public function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
|
8 |
+
{
|
9 |
Â
|
10 |
Â
$element->setData('onchange', "apiValidation(this.form, this)");
|
11 |
Â
|
@@ -1,27 +1,37 @@
|
|
1 |
Â
<?php
|
2 |
Â
|
3 |
-
class Dotdigitalgroup_Email_Block_Adminhtml_System_Automation_Connect
|
Â
|
|
4 |
Â
{
|
5 |
-
|
Â
|
|
Â
|
|
6 |
Â
{
|
7 |
Â
$this->setElement($element);
|
Â
|
|
8 |
Â
return $this->_getAddRowButtonHtml();
|
9 |
Â
}
|
10 |
Â
|
11 |
Â
protected function _getAddRowButtonHtml()
|
12 |
Â
{
|
13 |
-
$url
|
14 |
-
$ssl
|
15 |
Â
$disabled = false;
|
16 |
-
|
17 |
-
if (
|
18 |
Â
$disabled = true;
|
19 |
Â
}
|
20 |
Â
|
21 |
-
$adminUser
|
22 |
Â
$refreshToken = $adminUser->getRefreshToken();
|
23 |
-
$title
|
24 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
25 |
Â
|
26 |
Â
return $this->getLayout()->createBlock('adminhtml/widget_button')
|
27 |
Â
->setType('button')
|
@@ -31,12 +41,14 @@ class Dotdigitalgroup_Email_Block_Adminhtml_System_Automation_Connect extends Ma
|
|
31 |
Â
->toHtml();
|
32 |
Â
}
|
33 |
Â
|
34 |
-
protected function _checkForSecureUrl()
|
Â
|
|
35 |
Â
|
36 |
Â
$baseUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB, true);
|
37 |
-
if (!preg_match('/https/'
|
38 |
Â
return false;
|
39 |
Â
}
|
Â
|
|
40 |
Â
return $this;
|
41 |
Â
}
|
42 |
Â
}
|
1 |
Â
<?php
|
2 |
Â
|
3 |
+
class Dotdigitalgroup_Email_Block_Adminhtml_System_Automation_Connect
|
4 |
+
extends Mage_Adminhtml_Block_System_Config_Form_Field
|
5 |
Â
{
|
6 |
+
|
7 |
+
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element
|
8 |
+
)
|
9 |
Â
{
|
10 |
Â
$this->setElement($element);
|
11 |
+
|
12 |
Â
return $this->_getAddRowButtonHtml();
|
13 |
Â
}
|
14 |
Â
|
15 |
Â
protected function _getAddRowButtonHtml()
|
16 |
Â
{
|
17 |
+
$url = Mage::helper('ddg')->getAuthoriseUrl();
|
18 |
+
$ssl = $this->_checkForSecureUrl();
|
19 |
Â
$disabled = false;
|
20 |
+
//disable for ssl missing
|
21 |
+
if ( ! $ssl) {
|
22 |
Â
$disabled = true;
|
23 |
Â
}
|
24 |
Â
|
25 |
+
$adminUser = Mage::getSingleton('admin/session')->getUser();
|
26 |
Â
$refreshToken = $adminUser->getRefreshToken();
|
27 |
+
$title = ($refreshToken)
|
28 |
+
? $this->__('Disconnect')
|
29 |
+
: $this->__(
|
30 |
+
'Connect'
|
31 |
+
);
|
32 |
+
$url = ($refreshToken) ? $this->getUrl(
|
33 |
+
'*/email_studio/disconnect'
|
34 |
+
) : $url;
|
35 |
Â
|
36 |
Â
return $this->getLayout()->createBlock('adminhtml/widget_button')
|
37 |
Â
->setType('button')
|
41 |
Â
->toHtml();
|
42 |
Â
}
|
43 |
Â
|
44 |
+
protected function _checkForSecureUrl()
|
45 |
+
{
|
46 |
Â
|
47 |
Â
$baseUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB, true);
|
48 |
+
if ( ! preg_match('/https/', $baseUrl)) {
|
49 |
Â
return false;
|
50 |
Â
}
|
51 |
+
|
52 |
Â
return $this;
|
53 |
Â
}
|
54 |
Â
}
|
@@ -1,20 +1,26 @@
|
|
1 |
Â
<?php
|
2 |
Â
|
3 |
-
class Dotdigitalgroup_Email_Block_Adminhtml_System_Config_Addressbook
|
Â
|
|
4 |
Â
{
|
5 |
Â
|
6 |
Â
/**
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
Â
|
|
Â
|
|
13 |
Â
{
|
14 |
-
$url
|
Â
|
|
Â
|
|
15 |
Â
$website = Mage::app()->getRequest()->getParam('website', 0);
|
16 |
Â
|
17 |
-
$element->setData(
|
Â
|
|
18 |
Â
"<script>
|
19 |
Â
function createAddressbook(form, element) {
|
20 |
Â
var name = $('connector_sync_settings_dynamic_addressbook_addressbook_name').value;
|
1 |
Â
<?php
|
2 |
Â
|
3 |
+
class Dotdigitalgroup_Email_Block_Adminhtml_System_Config_Addressbook
|
4 |
+
extends Mage_Adminhtml_Block_System_Config_Form_Field
|
5 |
Â
{
|
6 |
Â
|
7 |
Â
/**
|
8 |
+
* Ajax Create the addressbooks.
|
9 |
+
*
|
10 |
+
* @param Varien_Data_Form_Element_Abstract $element
|
11 |
+
*
|
12 |
+
* @return string
|
13 |
+
*/
|
14 |
+
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element
|
15 |
+
)
|
16 |
Â
{
|
17 |
+
$url = Mage::helper('adminhtml')->getUrl(
|
18 |
+
'*/connector/createnewaddressbook'
|
19 |
+
);
|
20 |
Â
$website = Mage::app()->getRequest()->getParam('website', 0);
|
21 |
Â
|
22 |
+
$element->setData(
|
23 |
+
'after_element_html',
|
24 |
Â
"<script>
|
25 |
Â
function createAddressbook(form, element) {
|
26 |
Â
var name = $('connector_sync_settings_dynamic_addressbook_addressbook_name').value;
|
@@ -1,17 +1,21 @@
|
|
1 |
Â
<?php
|
2 |
Â
|
3 |
-
class Dotdigitalgroup_Email_Block_Adminhtml_System_Config_Colorpicker
|
Â
|
|
4 |
Â
{
|
Â
|
|
5 |
Â
/**
|
6 |
Â
* Generate HTML code for color picker
|
7 |
Â
*
|
8 |
Â
* @param Varien_Data_Form_Element_Abstract $element
|
Â
|
|
9 |
Â
* @return string
|
10 |
Â
*/
|
11 |
-
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element
|
12 |
-
{
|
13 |
Â
// Include Procolor library JS file
|
14 |
-
$html = '<script type="text/javascript" src="' . Mage::getBaseUrl('js')
|
Â
|
|
15 |
Â
|
16 |
Â
// Use Varien text element as a basis
|
17 |
Â
$input = new Varien_Data_Form_Element_Text();
|
@@ -22,8 +26,10 @@ class Dotdigitalgroup_Email_Block_Adminhtml_System_Config_Colorpicker extends Ma
|
|
22 |
Â
->setValue($element->getValue())
|
23 |
Â
->setHtmlId($element->getHtmlId())
|
24 |
Â
->setName($element->getName())
|
25 |
-
->setStyle('width: 60px')
|
26 |
-
->addClass(
|
Â
|
|
Â
|
|
27 |
Â
|
28 |
Â
// Inject updated Varien text element HTML in our current HTML
|
29 |
Â
$html .= $input->getHtml();
|
@@ -41,12 +47,17 @@ class Dotdigitalgroup_Email_Block_Adminhtml_System_Config_Colorpicker extends Ma
|
|
41 |
Â
* Procolor JS code to display color picker
|
42 |
Â
*
|
43 |
Â
* @see http://procolor.sourceforge.net/examples.php
|
Â
|
|
44 |
Â
* @param string $htmlId
|
Â
|
|
45 |
Â
* @return string
|
46 |
Â
*/
|
47 |
Â
protected function _getProcolorJs($htmlId)
|
48 |
Â
{
|
49 |
-
return '<script type="text/javascript">ProColor.prototype.attachButton(\''
|
Â
|
|
Â
|
|
Â
|
|
50 |
Â
}
|
51 |
Â
|
52 |
Â
/**
|
@@ -58,7 +69,9 @@ class Dotdigitalgroup_Email_Block_Adminhtml_System_Config_Colorpicker extends Ma
|
|
58 |
Â
{
|
59 |
Â
return
|
60 |
Â
'<script type="text/javascript">
|
61 |
-
Validation.add(\'validate-hex\', \'' . Mage::helper('ddg')->__(
|
Â
|
|
Â
|
|
62 |
Â
return /^#(?:[0-9a-fA-F]{3}){1,2}$/.test(v);
|
63 |
Â
});
|
64 |
Â
</script>';
|
1 |
Â
<?php
|
2 |
Â
|
3 |
+
class Dotdigitalgroup_Email_Block_Adminhtml_System_Config_Colorpicker
|
4 |
+
extends Mage_Adminhtml_Block_System_Config_Form_Field
|
5 |
Â
{
|
6 |
+
|
7 |
Â
/**
|
8 |
Â
* Generate HTML code for color picker
|
9 |
Â
*
|
10 |
Â
* @param Varien_Data_Form_Element_Abstract $element
|
11 |
+
*
|
12 |
Â
* @return string
|
13 |
Â
*/
|
14 |
+
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element
|
15 |
+
) {
|
16 |
Â
// Include Procolor library JS file
|
17 |
+
$html = '<script type="text/javascript" src="' . Mage::getBaseUrl('js')
|
18 |
+
. 'connector/procolor-1.0/procolor.compressed.js' . '"></script>';
|
19 |
Â
|
20 |
Â
// Use Varien text element as a basis
|
21 |
Â
$input = new Varien_Data_Form_Element_Text();
|
26 |
Â
->setValue($element->getValue())
|
27 |
Â
->setHtmlId($element->getHtmlId())
|
28 |
Â
->setName($element->getName())
|
29 |
+
->setStyle('width: 60px')// Update style in order to shrink width
|
30 |
+
->addClass(
|
31 |
+
'validate-hex'
|
32 |
+
); // Add some Prototype validation to make sure color code is correct
|
33 |
Â
|
34 |
Â
// Inject updated Varien text element HTML in our current HTML
|
35 |
Â
$html .= $input->getHtml();
|
47 |
Â
* Procolor JS code to display color picker
|
48 |
Â
*
|
49 |
Â
* @see http://procolor.sourceforge.net/examples.php
|
50 |
+
*
|
51 |
Â
* @param string $htmlId
|
52 |
+
*
|
53 |
Â
* @return string
|
54 |
Â
*/
|
55 |
Â
protected function _getProcolorJs($htmlId)
|
56 |
Â
{
|
57 |
+
return '<script type="text/javascript">ProColor.prototype.attachButton(\''
|
58 |
+
. $htmlId . '\', { imgPath:\'' . Mage::getBaseUrl('js')
|
59 |
+
. 'connector/procolor-1.0/'
|
60 |
+
. 'img/procolor_win_\', showInField: true });</script>';
|
61 |
Â
}
|
62 |
Â
|
63 |
Â
/**
|
69 |
Â
{
|
70 |
Â
return
|
71 |
Â
'<script type="text/javascript">
|
72 |
+
Validation.add(\'validate-hex\', \'' . Mage::helper('ddg')->__(
|
73 |
+
'Please enter a valid hex color code'
|
74 |
+
) . '\', function(v) {
|
75 |
Â
return /^#(?:[0-9a-fA-F]{3}){1,2}$/.test(v);
|
76 |
Â
});
|
77 |
Â
</script>';
|
@@ -1,20 +1,25 @@
|
|
1 |
Â
<?php
|
2 |
Â
|
3 |
-
class Dotdigitalgroup_Email_Block_Adminhtml_System_Config_Datafield
|
Â
|
|
4 |
Â
{
|
5 |
Â
|
6 |
Â
/**
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
Â
|
|
Â
|
|
Â
|
|
15 |
Â
$website = Mage::app()->getRequest()->getParam('website', 0);
|
16 |
Â
|
17 |
-
$element->setData(
|
Â
|
|
18 |
Â
"<script>
|
19 |
Â
function createDatafield(form, element) {
|
20 |
Â
var datafield_name = $('connector_data_mapping_dynamic_datafield_datafield_name').value;
|
1 |
Â
<?php
|
2 |
Â
|
3 |
+
class Dotdigitalgroup_Email_Block_Adminhtml_System_Config_Datafield
|
4 |
+
extends Mage_Adminhtml_Block_System_Config_Form_Field
|
5 |
Â
{
|
6 |
Â
|
7 |
Â
/**
|
8 |
+
* Ajax Create the datafields.
|
9 |
+
*
|
10 |
+
* @param Varien_Data_Form_Element_Abstract $element
|
11 |
+
*
|
12 |
+
* @return string
|
13 |
+
*/
|
14 |
+
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element
|
15 |
+
) {
|
16 |
+
$url = Mage::helper('adminhtml')->getUrl(
|
17 |
+
'*/connector/createnewdatafield'
|
18 |
+
);
|
19 |
Â
$website = Mage::app()->getRequest()->getParam('website', 0);
|
20 |
Â
|
21 |
+
$element->setData(
|
22 |
+
'after_element_html',
|
23 |
Â
"<script>
|
24 |
Â
function createDatafield(form, element) {
|
25 |
Â
var datafield_name = $('connector_data_mapping_dynamic_datafield_datafield_name').value;
|
@@ -1,30 +1,35 @@
|
|
1 |
Â
<?php
|
2 |
Â
|
3 |
Â
|
4 |
-
class Dotdigitalgroup_Email_Block_Adminhtml_System_Config_Enterprisevalidator
|
Â
|
|
5 |
Â
{
|
6 |
-
|
Â
|
|
Â
|
|
7 |
Â
{
|
8 |
Â
// Get the default HTML for this option
|
9 |
Â
$html = parent::_getElementHtml($element);
|
10 |
Â
|
11 |
Â
// Set up additional JavaScript for our validation using jQuery.
|
12 |
Â
|
13 |
-
$jquery
|
Â
|
|
14 |
Â
|
15 |
-
if (! Mage::helper('ddg')->isEnterprise()) {
|
16 |
-
|
17 |
-
|
Â
|
|
18 |
Â
jQuery.noConflict();
|
19 |
Â
jQuery(document).ready(function() {
|
20 |
Â
jQuery('#connector_data_mapping_enterprise_data-head').parent().hide();
|
21 |
Â
|
22 |
Â
});
|
23 |
Â
</script>";
|
24 |
-
|
25 |
Â
}
|
26 |
Â
|
27 |
Â
|
28 |
-
|
29 |
Â
}
|
30 |
Â
}
|
1 |
Â
<?php
|
2 |
Â
|
3 |
Â
|
4 |
+
class Dotdigitalgroup_Email_Block_Adminhtml_System_Config_Enterprisevalidator
|
5 |
+
extends Mage_Adminhtml_Block_System_Config_Form_Field
|
6 |
Â
{
|
7 |
+
|
8 |
+
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element
|
9 |
+
)
|
10 |
Â
{
|
11 |
Â
// Get the default HTML for this option
|
12 |
Â
$html = parent::_getElementHtml($element);
|
13 |
Â
|
14 |
Â
// Set up additional JavaScript for our validation using jQuery.
|
15 |
Â
|
16 |
+
$jquery
|
17 |
+
= '<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js" ></script>';
|
18 |
Â
|
19 |
+
if ( ! Mage::helper('ddg')->isEnterprise()) {
|
20 |
+
$html .= $jquery;
|
21 |
+
$javaScript
|
22 |
+
= "<script type=\"text/javascript\">
|
23 |
Â
jQuery.noConflict();
|
24 |
Â
jQuery(document).ready(function() {
|
25 |
Â
jQuery('#connector_data_mapping_enterprise_data-head').parent().hide();
|
26 |
Â
|
27 |
Â
});
|
28 |
Â
</script>";
|
29 |
+
$html .= $javaScript;
|
30 |
Â
}
|
31 |
Â
|
32 |
Â
|
33 |
+
return $html;
|
34 |
Â
}
|
35 |
Â
}
|
@@ -1,14 +1,20 @@
|
|
1 |
Â
<?php
|
2 |
Â
|
3 |
-
class Dotdigitalgroup_Email_Block_Adminhtml_System_Config_Resetcontacts
|
Â
|
|
4 |
Â
{
|
5 |
-
public function _getElementHtml(Varien_Data_Form_Element_Abstract$element){
|
6 |
Â
|
7 |
-
|
8 |
-
|
9 |
-
$url = Mage::helper('adminhtml')->getUrl('*/connector/resetcontactsajax');
|
10 |
Â
|
11 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
12 |
Â
<script>
|
13 |
Â
function resetContacts(){
|
14 |
Â
new Ajax.Request('{$url}', {
|
@@ -19,9 +25,10 @@ class Dotdigitalgroup_Email_Block_Adminhtml_System_Config_Resetcontacts extends
|
|
19 |
Â
return false;
|
20 |
Â
}
|
21 |
Â
</script>
|
22 |
-
"
|
Â
|
|
23 |
Â
|
24 |
-
|
25 |
Â
|
26 |
Â
|
27 |
Â
}
|
1 |
Â
<?php
|
2 |
Â
|
3 |
+
class Dotdigitalgroup_Email_Block_Adminhtml_System_Config_Resetcontacts
|
4 |
+
extends Mage_Adminhtml_Block_System_Config_Form_Field
|
5 |
Â
{
|
Â
|
|
6 |
Â
|
7 |
+
public function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
|
8 |
+
{
|
Â
|
|
9 |
Â
|
10 |
+
$element->setData('onchange', "resetContacts();");
|
11 |
+
//url to reset the contacs
|
12 |
+
$url = Mage::helper('adminhtml')->getUrl(
|
13 |
+
'*/connector/resetcontactsajax'
|
14 |
+
);
|
15 |
+
|
16 |
+
$element->setData(
|
17 |
+
'after_element_html', "
|
18 |
Â
<script>
|
19 |
Â
function resetContacts(){
|
20 |
Â
new Ajax.Request('{$url}', {
|
25 |
Â
return false;
|
26 |
Â
}
|
27 |
Â
</script>
|
28 |
+
"
|
29 |
+
);
|
30 |
Â
|
31 |
+
return parent::_getElementHtml($element);
|
32 |
Â
|
33 |
Â
|
34 |
Â
}
|
@@ -1,14 +1,18 @@
|
|
1 |
Â
<?php
|
2 |
Â
|
3 |
-
class Dotdigitalgroup_Email_Block_Adminhtml_System_Config_Resetguests
|
Â
|
|
4 |
Â
{
|
5 |
-
public function _getElementHtml(Varien_Data_Form_Element_Abstract$element){
|
6 |
Â
|
7 |
-
|
8 |
-
|
9 |
-
$url = Mage::helper('adminhtml')->getUrl('*/connector/ajaxresetguests');
|
10 |
Â
|
11 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
12 |
Â
<script>
|
13 |
Â
function resetGuests(){
|
14 |
Â
new Ajax.Request('{$url}', {
|
@@ -19,9 +23,10 @@ class Dotdigitalgroup_Email_Block_Adminhtml_System_Config_Resetguests extends Ma
|
|
19 |
Â
return false;
|
20 |
Â
}
|
21 |
Â
</script>
|
22 |
-
"
|
Â
|
|
23 |
Â
|
24 |
-
|
25 |
Â
|
26 |
Â
|
27 |
Â
}
|
1 |
Â
<?php
|
2 |
Â
|
3 |
+
class Dotdigitalgroup_Email_Block_Adminhtml_System_Config_Resetguests
|
4 |
+
extends Mage_Adminhtml_Block_System_Config_Form_Field
|
5 |
Â
{
|
Â
|
|
6 |
Â
|
7 |
+
public function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
|
8 |
+
{
|
Â
|
|
9 |
Â
|
10 |
+
$element->setData('onchange', "resetGuests();");
|
11 |
+
//url to reset the guests
|
12 |
+
$url = Mage::helper('adminhtml')->getUrl('*/connector/ajaxresetguests');
|
13 |
+
|
14 |
+
$element->setData(
|
15 |
+
'after_element_html', "
|
16 |
Â
<script>
|
17 |
Â
function resetGuests(){
|
18 |
Â
new Ajax.Request('{$url}', {
|
23 |
Â
return false;
|
24 |
Â
}
|
25 |
Â
</script>
|
26 |
+
"
|
27 |
+
);
|
28 |
Â
|
29 |
+
return parent::_getElementHtml($element);
|
30 |
Â
|
31 |
Â
|
32 |
Â
}
|
@@ -1,14 +1,20 @@
|
|
1 |
Â
<?php
|
2 |
Â
|
3 |
-
class Dotdigitalgroup_Email_Block_Adminhtml_System_Config_Resetsubscribers
|
Â
|
|
4 |
Â
{
|
5 |
-
public function _getElementHtml(Varien_Data_Form_Element_Abstract$element){
|
6 |
Â
|
7 |
-
|
8 |
-
|
9 |
-
$url = Mage::helper('adminhtml')->getUrl('*/connector/ajaxresetsubscribers');
|
10 |
Â
|
11 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
12 |
Â
<script>
|
13 |
Â
function resetSubscribers(){
|
14 |
Â
new Ajax.Request('{$url}', {
|
@@ -19,9 +25,10 @@ class Dotdigitalgroup_Email_Block_Adminhtml_System_Config_Resetsubscribers exten
|
|
19 |
Â
return false;
|
20 |
Â
}
|
21 |
Â
</script>
|
22 |
-
"
|
Â
|
|
23 |
Â
|
24 |
-
|
25 |
Â
|
26 |
Â
|
27 |
Â
}
|
1 |
Â
<?php
|
2 |
Â
|
3 |
+
class Dotdigitalgroup_Email_Block_Adminhtml_System_Config_Resetsubscribers
|
4 |
+
extends Mage_Adminhtml_Block_System_Config_Form_Field
|
5 |
Â
{
|
Â
|
|
6 |
Â
|
7 |
+
public function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
|
8 |
+
{
|
Â
|
|
9 |
Â
|
10 |
+
$element->setData('onchange', "resetSubscribers();");
|
11 |
+
//url to reset the subscribers
|
12 |
+
$url = Mage::helper('adminhtml')->getUrl(
|
13 |
+
'*/connector/ajaxresetsubscribers'
|
14 |
+
);
|
15 |
+
|
16 |
+
$element->setData(
|
17 |
+
'after_element_html', "
|
18 |
Â
<script>
|
19 |
Â
function resetSubscribers(){
|
20 |
Â
new Ajax.Request('{$url}', {
|
25 |
Â
return false;
|
26 |
Â
}
|
27 |
Â
</script>
|
28 |
+
"
|
29 |
+
);
|
30 |
Â
|
31 |
+
return parent::_getElementHtml($element);
|
32 |
Â
|
33 |
Â
|
34 |
Â
}
|
@@ -0,0 +1,50 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Dotdigitalgroup_Email_Block_Adminhtml_System_Config_Trial extends Mage_Adminhtml_Block_System_Config_Form_Fieldset
|
4 |
+
{
|
5 |
+
public function render(Varien_Data_Form_Element_Abstract $element)
|
6 |
+
{
|
7 |
+
$helper = Mage::helper('ddg');
|
8 |
+
if (!$helper->isFrontendAdminSecure()) {
|
9 |
+
$html = '<a class="various" href=' .
|
10 |
+
Mage::getDesign()->getSkinUrl('connector/trialerror.png') . '><img style="margin-bottom:15px;" src=' .
|
11 |
+
Mage::getDesign()->getSkinUrl('connector/banner.png') .
|
12 |
+
' alt="Open Trial Account"></a>';
|
13 |
+
$script = "
|
14 |
+
<script>
|
15 |
+
var j = jQuery.noConflict();
|
16 |
+
j(document).ready(function() {
|
17 |
+
j('.various').fancybox();
|
18 |
+
});
|
19 |
+
</script>
|
20 |
+
";
|
21 |
+
} else {
|
22 |
+
$html = '<a class="various fancybox.iframe" data-fancybox-type="iframe" href=' .
|
23 |
+
$helper->getIframeFormUrl() . '><img style="margin-bottom:15px;" src=' .
|
24 |
+
Mage::getDesign()->getSkinUrl('connector/banner.png') .
|
25 |
+
' alt="Open Trial Account"></a>';
|
26 |
+
$script = "
|
27 |
+
<script>
|
28 |
+
var j = jQuery.noConflict();
|
29 |
+
j(document).ready(function() {
|
30 |
+
j('.various').fancybox({
|
31 |
+
width : 508,
|
32 |
+
height : 612,
|
33 |
+
scrolling : 'no',
|
34 |
+
fitToView : false,
|
35 |
+
autoSize : false,
|
36 |
+
closeClick : false,
|
37 |
+
openEffect : 'none',
|
38 |
+
closeEffect : 'none',
|
39 |
+
});
|
40 |
+
|
41 |
+
j(document).on('click', 'a.fancybox-close', function(){
|
42 |
+
location.reload();
|
43 |
+
});
|
44 |
+
});
|
45 |
+
</script>
|
46 |
+
";
|
47 |
+
}
|
48 |
+
return $html . $script;
|
49 |
+
}
|
50 |
+
}
|
@@ -1,33 +1,36 @@
|
|
1 |
Â
<?php
|
2 |
Â
|
3 |
Â
|
4 |
-
class Dotdigitalgroup_Email_Block_Adminhtml_System_Config_Validator
|
Â
|
|
5 |
Â
{
|
6 |
Â
|
7 |
Â
/**
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
Â
|
|
15 |
Â
// Get the default HTML for this option
|
16 |
Â
$html = parent::_getElementHtml($element);
|
17 |
Â
|
18 |
Â
// Set up additional JavaScript for our validation using jQuery.
|
19 |
Â
|
20 |
-
$jquery
|
Â
|
|
21 |
Â
|
22 |
-
$html
|
23 |
Â
$javaScript = "<script type=\"text/javascript\"> var show_warning = 0;";
|
24 |
Â
|
25 |
-
if(!Mage::helper('ddg')->isSweetToothEnabled()){
|
26 |
Â
$javaScript .= "show_warning = 1;";
|
27 |
Â
}
|
28 |
Â
|
29 |
-
$javaScript
|
30 |
-
"jQuery.noConflict();
|
31 |
Â
|
32 |
Â
jQuery(document).ready(function() {
|
33 |
Â
// Handler for .ready() called.
|
@@ -81,6 +84,7 @@ class Dotdigitalgroup_Email_Block_Adminhtml_System_Config_Validator extends Mage
|
|
81 |
Â
</script>";
|
82 |
Â
|
83 |
Â
$html .= $javaScript;
|
Â
|
|
84 |
Â
return $html;
|
85 |
Â
}
|
86 |
Â
|
1 |
Â
<?php
|
2 |
Â
|
3 |
Â
|
4 |
+
class Dotdigitalgroup_Email_Block_Adminhtml_System_Config_Validator
|
5 |
+
extends Mage_Adminhtml_Block_System_Config_Form_Field
|
6 |
Â
{
|
7 |
Â
|
8 |
Â
/**
|
9 |
+
* Ajax Validate the duplicate selection.
|
10 |
+
*
|
11 |
+
* @param Varien_Data_Form_Element_Abstract $element
|
12 |
+
*
|
13 |
+
* @return string
|
14 |
+
*/
|
15 |
+
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element
|
16 |
+
) {
|
17 |
Â
// Get the default HTML for this option
|
18 |
Â
$html = parent::_getElementHtml($element);
|
19 |
Â
|
20 |
Â
// Set up additional JavaScript for our validation using jQuery.
|
21 |
Â
|
22 |
+
$jquery
|
23 |
+
= '<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js" ></script>';
|
24 |
Â
|
25 |
+
$html .= $jquery;
|
26 |
Â
$javaScript = "<script type=\"text/javascript\"> var show_warning = 0;";
|
27 |
Â
|
28 |
+
if ( ! Mage::helper('ddg')->isSweetToothEnabled()) {
|
29 |
Â
$javaScript .= "show_warning = 1;";
|
30 |
Â
}
|
31 |
Â
|
32 |
+
$javaScript
|
33 |
+
.= "jQuery.noConflict();
|
34 |
Â
|
35 |
Â
jQuery(document).ready(function() {
|
36 |
Â
// Handler for .ready() called.
|
84 |
Â
</script>";
|
85 |
Â
|
86 |
Â
$html .= $javaScript;
|
87 |
+
|
88 |
Â
return $html;
|
89 |
Â
}
|
90 |
Â
|
@@ -1,65 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class Dotdigitalgroup_Email_Block_Adminhtml_System_Config_Waitingfield extends Mage_Adminhtml_Block_System_Config_Form_Field
|
4 |
-
{
|
5 |
-
/**
|
6 |
-
* Unscope the website level.
|
7 |
-
* @param Varien_Data_Form_Element_Abstract $element
|
8 |
-
*
|
9 |
-
* @return string
|
10 |
-
*/
|
11 |
-
public function render(Varien_Data_Form_Element_Abstract $element)
|
12 |
-
{
|
13 |
-
|
14 |
-
$element->unsScope()->unsCanUseWebsiteValue()->unsCanUseDefaultValue();
|
15 |
-
return parent::render($element);
|
16 |
-
|
17 |
-
}
|
18 |
-
|
19 |
-
/**
|
20 |
-
* Loading background on save.
|
21 |
-
* @param Varien_Data_Form_Element_Abstract $element
|
22 |
-
*
|
23 |
-
* @return string
|
24 |
-
*/
|
25 |
-
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
|
26 |
-
{
|
27 |
-
// Get the default HTML for this option
|
28 |
-
$html = parent::_getElementHtml($element);
|
29 |
-
|
30 |
-
|
31 |
-
$html .= sprintf('<div id="loadingmask" style="position: fixed;">
|
32 |
-
<div class="loader" id="loading-mask-loader">
|
33 |
-
<img src="%sskin/adminhtml/default/default/images/ajax-loader-tr.gif" alt="%s"/>%s', preg_replace('/index.php\//', '', $this->getBaseUrl()), $this->__('Loading...'), $this->__('Loading...'))
|
34 |
-
. '<div id="loading-mask"></div></div>';
|
35 |
-
|
36 |
-
$jQuery = '<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js" ></script>';
|
37 |
-
|
38 |
-
$jQuery .=
|
39 |
-
'<script type="text/javascript">
|
40 |
-
jQuery.noConflict();
|
41 |
-
jQuery(document).ready(function() {
|
42 |
-
//hide the load image field
|
43 |
-
jQuery("#row_connector_api_credentials_api_credentials_validator").hide();
|
44 |
-
jQuery("#row_connector_sync_settings_sync_customer_schedule_validator").hide();
|
45 |
-
var loadingmask = jQuery("#loadingmask");
|
46 |
-
loadingmask.hide();
|
47 |
-
loadingmask.css({top : "50\%", left: "50\%"});
|
48 |
-
//var thisButton = jQuery("button");
|
49 |
-
//console.log(thisButton);
|
50 |
-
//jQuery("button").click(function(){
|
51 |
-
// jQuery("body").css({"background-color": "black", "opacity": "0.4"});
|
52 |
-
// jQuery("#row_connector_api_settings_api_credentials_validator").show();
|
53 |
-
// jQuery("#row_connector_sync_settings_sync_customer_schedule_validator").show();
|
54 |
-
// loadingmask.show();
|
55 |
-
// loadingmask.css({"display": "block", "opacity" : "1"});
|
56 |
-
//})
|
57 |
-
});
|
58 |
-
</script>';
|
59 |
-
|
60 |
-
$html .= $jQuery;
|
61 |
-
|
62 |
-
return $html;
|
63 |
-
}
|
64 |
-
|
65 |
-
}
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
@@ -1,59 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class Dotdigitalgroup_Email_Block_Adminhtml_System_Config_Wrapper extends Mage_Adminhtml_Block_System_Config_Form_Field
|
4 |
-
{
|
5 |
-
|
6 |
-
/**
|
7 |
-
* Ajax Validate the api credentials.
|
8 |
-
*
|
9 |
-
* @param Varien_Data_Form_Element_Abstract $element
|
10 |
-
*
|
11 |
-
* @return string
|
12 |
-
*/
|
13 |
-
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
|
14 |
-
{
|
15 |
-
$element->setData('onchange', "apiValidation(this.form, this);");
|
16 |
-
|
17 |
-
$url = Mage::helper('adminhtml')->getUrl('*/connector/ajaxvalidation');
|
18 |
-
|
19 |
-
$element->setData('after_element_html', "
|
20 |
-
<script>
|
21 |
-
document.observe('dom:loaded', function(){
|
22 |
-
apiValidation();
|
23 |
-
});
|
24 |
-
function apiValidation(form, element) {
|
25 |
-
var api_username = $('connector_api_credentials_api_username');
|
26 |
-
var api_password = $('connector_api_credentials_api_password');
|
27 |
-
var reloadurl = '{$url}';
|
28 |
-
var encoded = btoa(api_password.value);
|
29 |
-
if(api_username.value && api_password.value){
|
30 |
-
new Ajax.Request(reloadurl, {
|
31 |
-
method: 'post',
|
32 |
-
parameters: {'api_username' : api_username.value, 'api_password' : encoded},
|
33 |
-
onComplete: function(transport) {
|
34 |
-
Element.hide('loadingmask');
|
35 |
-
if(transport.responseText == '\"Credentials Valid.\"'){
|
36 |
-
api_username.setStyle({
|
37 |
-
fontWeight: 'bold',
|
38 |
-
color: 'green' ,
|
39 |
-
background: 'transparent url(\"" . $this->getSkinUrl('images/success_msg_icon.gif') . "\") no-repeat right center'
|
40 |
-
})
|
41 |
-
}else{
|
42 |
-
api_username.setStyle({
|
43 |
-
fontWeight: 'bold',
|
44 |
-
color: 'red',
|
45 |
-
background: 'transparent url(\"" . $this->getSkinUrl('images/error_msg_icon.gif') . "\") no-repeat right center'
|
46 |
-
});
|
47 |
-
}
|
48 |
-
}
|
49 |
-
});
|
50 |
-
}
|
51 |
-
return false;
|
52 |
-
}
|
53 |
-
</script>
|
54 |
-
");
|
55 |
-
|
56 |
-
return parent::_getElementHtml($element);
|
57 |
-
|
58 |
-
}
|
59 |
-
}
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
@@ -1,6 +1,7 @@
|
|
1 |
Â
<?php
|
2 |
Â
|
3 |
-
class Dotdigitalgroup_Email_Block_Adminhtml_System_Dynamic_Addressbookbutton
|
Â
|
|
4 |
Â
{
|
5 |
Â
|
6 |
Â
protected function _getAddRowButtonHtml($title)
|
@@ -12,11 +13,14 @@ class Dotdigitalgroup_Email_Block_Adminhtml_System_Dynamic_Addressbookbutton ext
|
|
12 |
Â
->toHtml();
|
13 |
Â
}
|
14 |
Â
|
15 |
-
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element
|
Â
|
|
16 |
Â
{
|
17 |
Â
$this->setElement($element);
|
18 |
Â
$originalData = $element->getOriginalData();
|
19 |
Â
|
20 |
-
return $this->_getAddRowButtonHtml(
|
Â
|
|
Â
|
|
21 |
Â
}
|
22 |
Â
}
|
1 |
Â
<?php
|
2 |
Â
|
3 |
+
class Dotdigitalgroup_Email_Block_Adminhtml_System_Dynamic_Addressbookbutton
|
4 |
+
extends Mage_Adminhtml_Block_System_Config_Form_Field
|
5 |
Â
{
|
6 |
Â
|
7 |
Â
protected function _getAddRowButtonHtml($title)
|
13 |
Â
->toHtml();
|
14 |
Â
}
|
15 |
Â
|
16 |
+
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element
|
17 |
+
)
|
18 |
Â
{
|
19 |
Â
$this->setElement($element);
|
20 |
Â
$originalData = $element->getOriginalData();
|
21 |
Â
|
22 |
+
return $this->_getAddRowButtonHtml(
|
23 |
+
$this->__($originalData['button_label'])
|
24 |
+
);
|
25 |
Â
}
|
26 |
Â
}
|
@@ -1,24 +1,32 @@
|
|
1 |
Â
<?php
|
2 |
Â
|
3 |
-
class Dotdigitalgroup_Email_Block_Adminhtml_System_Dynamic_Basket_Crosssell
|
Â
|
|
4 |
Â
{
|
5 |
-
|
Â
|
|
Â
|
|
6 |
Â
{
|
7 |
Â
//base url
|
8 |
-
|
9 |
-
|
10 |
Â
$passcode = Mage::helper('ddg')->getPasscode();
|
11 |
Â
//last quote id for dynamic page
|
12 |
-
|
13 |
Â
|
14 |
-
if (!strlen($passcode))
|
15 |
-
|
16 |
-
|
17 |
-
|
Â
|
|
18 |
Â
$lastQuoteId = '[PLEASE MAP THE LAST QUOTE ID]';
|
Â
|
|
19 |
Â
|
20 |
-
|
21 |
-
$text =
|
Â
|
|
Â
|
|
Â
|
|
22 |
Â
$element->setData('value', $text);
|
23 |
Â
|
24 |
Â
return parent::_getElementHtml($element);
|
1 |
Â
<?php
|
2 |
Â
|
3 |
+
class Dotdigitalgroup_Email_Block_Adminhtml_System_Dynamic_Basket_Crosssell
|
4 |
+
extends Mage_Adminhtml_Block_System_Config_Form_Field
|
5 |
Â
{
|
6 |
+
|
7 |
+
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element
|
8 |
+
)
|
9 |
Â
{
|
10 |
Â
//base url
|
11 |
+
$baseUrl = Mage::helper('ddg')->generateDynamicUrl();
|
12 |
+
//config passcode
|
13 |
Â
$passcode = Mage::helper('ddg')->getPasscode();
|
14 |
Â
//last quote id for dynamic page
|
15 |
+
$lastQuoteId = Mage::helper('ddg')->getLastQuoteId();
|
16 |
Â
|
17 |
+
if ( ! strlen($passcode)) {
|
18 |
+
$passcode = '[PLEASE SET UP A PASSCODE]';
|
19 |
+
}
|
20 |
+
//alert message for last order id is not mapped
|
21 |
+
if ( ! $lastQuoteId) {
|
22 |
Â
$lastQuoteId = '[PLEASE MAP THE LAST QUOTE ID]';
|
23 |
+
}
|
24 |
Â
|
25 |
+
//full url for dynamic content
|
26 |
+
$text = sprintf(
|
27 |
+
'%sconnector/quoteproducts/crosssell/code/%s/quote_id/@%s@',
|
28 |
+
$baseUrl, $passcode, $lastQuoteId
|
29 |
+
);
|
30 |
Â
$element->setData('value', $text);
|
31 |
Â
|
32 |
Â
return parent::_getElementHtml($element);
|
@@ -1,25 +1,33 @@
|
|
1 |
Â
<?php
|
2 |
Â
|
3 |
-
class Dotdigitalgroup_Email_Block_Adminhtml_System_Dynamic_Basket_Related
|
Â
|
|
4 |
Â
{
|
5 |
-
|
Â
|
|
Â
|
|
6 |
Â
{
|
7 |
-
|
8 |
Â
$passcode = Mage::helper('ddg')->getPasscode();
|
9 |
Â
//last quote id for dynamic page
|
10 |
Â
$lastQuoteId = Mage::helper('ddg')->getLastQuoteId();
|
11 |
Â
|
12 |
-
if (!strlen($passcode))
|
13 |
Â
$passcode = '[PLEASE SET UP A PASSCODE]';
|
Â
|
|
14 |
Â
//alert message for last order id is not mapped
|
15 |
-
if (
|
16 |
Â
$lastQuoteId = '[PLEASE MAP THE LAST QUOTE ID]';
|
Â
|
|
17 |
Â
|
18 |
-
|
19 |
-
|
20 |
Â
|
21 |
-
|
22 |
-
$text = sprintf(
|
Â
|
|
Â
|
|
Â
|
|
23 |
Â
$element->setData('value', $text);
|
24 |
Â
|
25 |
Â
return parent::_getElementHtml($element);
|
1 |
Â
<?php
|
2 |
Â
|
3 |
+
class Dotdigitalgroup_Email_Block_Adminhtml_System_Dynamic_Basket_Related
|
4 |
+
extends Mage_Adminhtml_Block_System_Config_Form_Field
|
5 |
Â
{
|
6 |
+
|
7 |
+
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element
|
8 |
+
)
|
9 |
Â
{
|
10 |
+
//passcode to append for url
|
11 |
Â
$passcode = Mage::helper('ddg')->getPasscode();
|
12 |
Â
//last quote id for dynamic page
|
13 |
Â
$lastQuoteId = Mage::helper('ddg')->getLastQuoteId();
|
14 |
Â
|
15 |
+
if ( ! strlen($passcode)) {
|
16 |
Â
$passcode = '[PLEASE SET UP A PASSCODE]';
|
17 |
+
}
|
18 |
Â
//alert message for last order id is not mapped
|
19 |
+
if ( ! $lastQuoteId) {
|
20 |
Â
$lastQuoteId = '[PLEASE MAP THE LAST QUOTE ID]';
|
21 |
+
}
|
22 |
Â
|
23 |
+
//generate the base url and display for default store id
|
24 |
+
$baseUrl = Mage::helper('ddg')->generateDynamicUrl();
|
25 |
Â
|
26 |
+
//display the full url
|
27 |
+
$text = sprintf(
|
28 |
+
'%sconnector/quoteproducts/related/code/%s/quote_id/@%s@', $baseUrl,
|
29 |
+
$passcode, $lastQuoteId
|
30 |
+
);
|
31 |
Â
$element->setData('value', $text);
|
32 |
Â
|
33 |
Â
return parent::_getElementHtml($element);
|
@@ -1,23 +1,32 @@
|
|
1 |
Â
<?php
|
2 |
-
|
Â
|
|
Â
|
|
3 |
Â
{
|
4 |
-
|
Â
|
|
Â
|
|
5 |
Â
{
|
6 |
Â
//passcode to append for url
|
7 |
Â
$passcode = Mage::helper('ddg')->getPasscode();
|
8 |
Â
//last quote id for dynamic page
|
9 |
Â
$lastQuoteId = Mage::helper('ddg')->getLastQuoteId();
|
10 |
Â
|
11 |
-
if (!strlen($passcode))
|
12 |
Â
$passcode = '[PLEASE SET UP A PASSCODE]';
|
Â
|
|
13 |
Â
//alert message for last order id is not mapped
|
14 |
-
if (
|
15 |
Â
$lastQuoteId = '[PLEASE MAP THE LAST QUOTE ID]';
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
16 |
Â
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
Â
$element->setData('value', $text);
|
22 |
Â
|
23 |
Â
return parent::_getElementHtml($element);
|
1 |
Â
<?php
|
2 |
+
|
3 |
+
class Dotdigitalgroup_Email_Block_Adminhtml_System_Dynamic_Basket_Upsell
|
4 |
+
extends Mage_Adminhtml_Block_System_Config_Form_Field
|
5 |
Â
{
|
6 |
+
|
7 |
+
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element
|
8 |
+
)
|
9 |
Â
{
|
10 |
Â
//passcode to append for url
|
11 |
Â
$passcode = Mage::helper('ddg')->getPasscode();
|
12 |
Â
//last quote id for dynamic page
|
13 |
Â
$lastQuoteId = Mage::helper('ddg')->getLastQuoteId();
|
14 |
Â
|
15 |
+
if ( ! strlen($passcode)) {
|
16 |
Â
$passcode = '[PLEASE SET UP A PASSCODE]';
|
17 |
+
}
|
18 |
Â
//alert message for last order id is not mapped
|
19 |
+
if ( ! $lastQuoteId) {
|
20 |
Â
$lastQuoteId = '[PLEASE MAP THE LAST QUOTE ID]';
|
21 |
+
}
|
22 |
+
|
23 |
+
//generate the base url and display for default store id
|
24 |
+
$baseUrl = Mage::helper('ddg')->generateDynamicUrl();
|
25 |
Â
|
26 |
+
$text = sprintf(
|
27 |
+
'%sconnector/quoteproducts/upsell/code/%s/quote_id/@%s@', $baseUrl,
|
28 |
+
$passcode, $lastQuoteId
|
29 |
+
);
|
30 |
Â
$element->setData('value', $text);
|
31 |
Â
|
32 |
Â
return parent::_getElementHtml($element);
|
@@ -1,21 +1,28 @@
|
|
1 |
Â
<?php
|
2 |
Â
|
3 |
-
class Dotdigitalgroup_Email_Block_Adminhtml_System_Dynamic_Bestsellers
|
Â
|
|
4 |
Â
{
|
Â
|
|
5 |
Â
/** label */
|
6 |
-
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element
|
Â
|
|
Â
|
|
7 |
Â
|
8 |
-
|
9 |
-
|
10 |
Â
|
11 |
-
|
12 |
Â
$passcode = Mage::helper('ddg')->getPasscode();
|
13 |
Â
|
14 |
-
if (!strlen($passcode))
|
15 |
-
|
Â
|
|
16 |
Â
|
17 |
-
|
18 |
-
$text = sprintf(
|
Â
|
|
Â
|
|
19 |
Â
$element->setData('value', $text);
|
20 |
Â
$element->setData('disabled', 'disabled');
|
21 |
Â
|
1 |
Â
<?php
|
2 |
Â
|
3 |
+
class Dotdigitalgroup_Email_Block_Adminhtml_System_Dynamic_Bestsellers
|
4 |
+
extends Mage_Adminhtml_Block_System_Config_Form_Field
|
5 |
Â
{
|
6 |
+
|
7 |
Â
/** label */
|
8 |
+
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element
|
9 |
+
)
|
10 |
+
{
|
11 |
Â
|
12 |
+
//base url
|
13 |
+
$baseUrl = Mage::helper('ddg')->generateDynamicUrl();
|
14 |
Â
|
15 |
+
//config passcode
|
16 |
Â
$passcode = Mage::helper('ddg')->getPasscode();
|
17 |
Â
|
18 |
+
if ( ! strlen($passcode)) {
|
19 |
+
$passcode = '[PLEASE SET UP A PASSCODE]';
|
20 |
+
}
|
21 |
Â
|
22 |
+
//full url
|
23 |
+
$text = sprintf(
|
24 |
+
'%sconnector/report/bestsellers/code/%s', $baseUrl, $passcode
|
25 |
+
);
|
26 |
Â
$element->setData('value', $text);
|
27 |
Â
$element->setData('disabled', 'disabled');
|
28 |
Â
|
@@ -1,25 +1,31 @@
|
|
1 |
Â
<?php
|
2 |
Â
|
3 |
-
class Dotdigitalgroup_Email_Block_Adminhtml_System_Dynamic_Couponinfo
|
Â
|
|
4 |
Â
{
|
Â
|
|
5 |
Â
/** label */
|
6 |
-
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element
|
Â
|
|
7 |
Â
{
|
8 |
-
|
9 |
Â
$baseUrl = Mage::helper('ddg')->generateDynamicUrl();
|
10 |
Â
|
11 |
Â
|
12 |
-
|
13 |
Â
$code = Mage::helper('ddg')->getPasscode();
|
14 |
Â
|
15 |
-
|
16 |
Â
$code = '[PLEASE SET UP A PASSCODE]';
|
Â
|
|
17 |
Â
|
18 |
-
|
19 |
-
|
Â
|
|
20 |
Â
|
21 |
Â
$element->setData('value', $text);
|
22 |
Â
$element->setData('disabled', 'disabled');
|
Â
|
|
23 |
Â
return parent::_getElementHtml($element);
|
24 |
Â
}
|
25 |
Â
|
1 |
Â
<?php
|
2 |
Â
|
3 |
+
class Dotdigitalgroup_Email_Block_Adminhtml_System_Dynamic_Couponinfo
|
4 |
+
extends Mage_Adminhtml_Block_System_Config_Form_Field
|
5 |
Â
{
|
6 |
+
|
7 |
Â
/** label */
|
8 |
+
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element
|
9 |
+
)
|
10 |
Â
{
|
11 |
+
//base url
|
12 |
Â
$baseUrl = Mage::helper('ddg')->generateDynamicUrl();
|
13 |
Â
|
14 |
Â
|
15 |
+
//config code
|
16 |
Â
$code = Mage::helper('ddg')->getPasscode();
|
17 |
Â
|
18 |
+
if ( ! strlen($code)) {
|
19 |
Â
$code = '[PLEASE SET UP A PASSCODE]';
|
20 |
+
}
|
21 |
Â
|
22 |
+
//full url
|
23 |
+
$text = $baseUrl . 'connector/email/coupon/id/[INSERT ID HERE]/code/'
|
24 |
+
. $code . '/@EMAIL@';
|
25 |
Â
|
26 |
Â
$element->setData('value', $text);
|
27 |
Â
$element->setData('disabled', 'disabled');
|
28 |
+
|
29 |
Â
return parent::_getElementHtml($element);
|
30 |
Â
}
|
31 |
Â
|
@@ -1,21 +1,29 @@
|
|
1 |
Â
<?php
|
2 |
Â
|
3 |
-
class Dotdigitalgroup_Email_Block_Adminhtml_System_Dynamic_Creditmemonew
|
Â
|
|
4 |
Â
{
|
5 |
-
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element) {
|
6 |
Â
|
7 |
-
|
8 |
-
|
Â
|
|
9 |
Â
|
10 |
-
|
Â
|
|
Â
|
|
Â
|
|
11 |
Â
$code = Mage::helper('ddg')->getPasscode();
|
12 |
Â
$orderId = Mage::helper('ddg')->getMappedOrderId();
|
13 |
Â
|
14 |
-
|
15 |
-
if (!strlen($code))
|
16 |
Â
$code = '[PLEASE SET UP A PASSCODE]';
|
17 |
-
|
18 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
19 |
Â
|
20 |
Â
$element->setData('value', $text);
|
21 |
Â
|
1 |
Â
<?php
|
2 |
Â
|
3 |
+
class Dotdigitalgroup_Email_Block_Adminhtml_System_Dynamic_Creditmemonew
|
4 |
+
extends Mage_Adminhtml_Block_System_Config_Form_Field
|
5 |
Â
{
|
Â
|
|
6 |
Â
|
7 |
+
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element
|
8 |
+
)
|
9 |
+
{
|
10 |
Â
|
11 |
+
//base url
|
12 |
+
$baseUrl = Mage::helper('ddg')->generateDynamicUrl();
|
13 |
+
|
14 |
+
//config code
|
15 |
Â
$code = Mage::helper('ddg')->getPasscode();
|
16 |
Â
$orderId = Mage::helper('ddg')->getMappedOrderId();
|
17 |
Â
|
18 |
+
//message to set up the passcode
|
19 |
+
if ( ! strlen($code)) {
|
20 |
Â
$code = '[PLEASE SET UP A PASSCODE]';
|
21 |
+
}
|
22 |
+
//full url for dynamic content
|
23 |
+
$text = sprintf(
|
24 |
+
'%s/connector/creditmemo/new/code/%s/id/@%s@', $baseUrl, $code,
|
25 |
+
$orderId
|
26 |
+
);
|
27 |
Â
|
28 |
Â
$element->setData('value', $text);
|
29 |
Â
|
@@ -1,24 +1,32 @@
|
|
1 |
Â
<?php
|
2 |
Â
|
3 |
-
class Dotdigitalgroup_Email_Block_Adminhtml_System_Dynamic_Crosssell
|
Â
|
|
4 |
Â
{
|
5 |
-
|
Â
|
|
Â
|
|
6 |
Â
{
|
7 |
Â
//base url
|
8 |
-
|
9 |
-
|
10 |
Â
$passcode = Mage::helper('ddg')->getPasscode();
|
11 |
Â
//last order id for dynamic page
|
12 |
-
|
13 |
Â
|
14 |
-
if (!strlen($passcode))
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
Â
|
|
Â
|
|
19 |
Â
|
20 |
-
|
21 |
-
$text =
|
Â
|
|
Â
|
|
Â
|
|
22 |
Â
$element->setData('value', $text);
|
23 |
Â
|
24 |
Â
return parent::_getElementHtml($element);
|
1 |
Â
<?php
|
2 |
Â
|
3 |
+
class Dotdigitalgroup_Email_Block_Adminhtml_System_Dynamic_Crosssell
|
4 |
+
extends Mage_Adminhtml_Block_System_Config_Form_Field
|
5 |
Â
{
|
6 |
+
|
7 |
+
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element
|
8 |
+
)
|
9 |
Â
{
|
10 |
Â
//base url
|
11 |
+
$baseUrl = Mage::helper('ddg')->generateDynamicUrl();
|
12 |
+
//config passcode
|
13 |
Â
$passcode = Mage::helper('ddg')->getPasscode();
|
14 |
Â
//last order id for dynamic page
|
15 |
+
$lastOrderId = Mage::helper('ddg')->getLastOrderId();
|
16 |
Â
|
17 |
+
if ( ! strlen($passcode)) {
|
18 |
+
$passcode = '[PLEASE SET UP A PASSCODE]';
|
19 |
+
}
|
20 |
+
//alert message for last order id is not mapped
|
21 |
+
if ( ! $lastOrderId) {
|
22 |
+
$lastOrderId = '[PLEASE MAP THE LAST ORDER ID]';
|
23 |
+
}
|
24 |
Â
|
25 |
+
//full url for dynamic content
|
26 |
+
$text = sprintf(
|
27 |
+
'%sconnector/products/crosssell/code/%s/order_id/@%s@', $baseUrl,
|
28 |
+
$passcode, $lastOrderId
|
29 |
+
);
|
30 |
Â
$element->setData('value', $text);
|
31 |
Â
|
32 |
Â
return parent::_getElementHtml($element);
|
@@ -1,7 +1,9 @@
|
|
1 |
Â
<?php
|
2 |
Â
|
3 |
-
class Dotdigitalgroup_Email_Block_Adminhtml_System_Dynamic_Datafieldbutton
|
Â
|
|
4 |
Â
{
|
Â
|
|
5 |
Â
protected function _getAddRowButtonHtml($title)
|
6 |
Â
{
|
7 |
Â
return $this->getLayout()->createBlock('adminhtml/widget_button')
|
@@ -11,11 +13,14 @@ class Dotdigitalgroup_Email_Block_Adminhtml_System_Dynamic_Datafieldbutton exten
|
|
11 |
Â
->toHtml();
|
12 |
Â
}
|
13 |
Â
|
14 |
-
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element
|
Â
|
|
15 |
Â
{
|
16 |
Â
$this->setElement($element);
|
17 |
Â
$originalData = $element->getOriginalData();
|
18 |
Â
|
19 |
-
return $this->_getAddRowButtonHtml(
|
Â
|
|
Â
|
|
20 |
Â
}
|
21 |
Â
}
|
1 |
Â
<?php
|
2 |
Â
|
3 |
+
class Dotdigitalgroup_Email_Block_Adminhtml_System_Dynamic_Datafieldbutton
|
4 |
+
extends Mage_Adminhtml_Block_System_Config_Form_Field
|
5 |
Â
{
|
6 |
+
|
7 |
Â
protected function _getAddRowButtonHtml($title)
|
8 |
Â
{
|
9 |
Â
return $this->getLayout()->createBlock('adminhtml/widget_button')
|
13 |
Â
->toHtml();
|
14 |
Â
}
|
15 |
Â
|
16 |
+
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element
|
17 |
+
)
|
18 |
Â
{
|
19 |
Â
$this->setElement($element);
|
20 |
Â
$originalData = $element->getOriginalData();
|
21 |
Â
|
22 |
+
return $this->_getAddRowButtonHtml(
|
23 |
+
$this->__($originalData['button_label'])
|
24 |
+
);
|
25 |
Â
}
|
26 |
Â
}
|
@@ -1,20 +1,23 @@
|
|
1 |
Â
<?php
|
2 |
Â
|
3 |
-
class Dotdigitalgroup_Email_Block_Adminhtml_System_Dynamic_Fallbackchooser
|
Â
|
|
4 |
Â
{
|
5 |
Â
|
6 |
-
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element
|
Â
|
|
7 |
Â
{
|
8 |
Â
$this->setElement($element);
|
Â
|
|
9 |
Â
return $this->_getAddRowButtonHtml($this->__("Choose Products"));
|
10 |
Â
}
|
11 |
Â
|
12 |
Â
protected function _getAddRowButtonHtml($title)
|
13 |
Â
{
|
14 |
Â
$action = 'getFallbackProductChooser(\'' . Mage::getUrl(
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
Â
|
19 |
Â
return $this->getLayout()->createBlock('adminhtml/widget_button')
|
20 |
Â
->setType('button')
|
1 |
Â
<?php
|
2 |
Â
|
3 |
+
class Dotdigitalgroup_Email_Block_Adminhtml_System_Dynamic_Fallbackchooser
|
4 |
+
extends Mage_Adminhtml_Block_System_Config_Form_Field
|
5 |
Â
{
|
6 |
Â
|
7 |
+
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element
|
8 |
+
)
|
9 |
Â
{
|
10 |
Â
$this->setElement($element);
|
11 |
+
|
12 |
Â
return $this->_getAddRowButtonHtml($this->__("Choose Products"));
|
13 |
Â
}
|
14 |
Â
|
15 |
Â
protected function _getAddRowButtonHtml($title)
|
16 |
Â
{
|
17 |
Â
$action = 'getFallbackProductChooser(\'' . Mage::getUrl(
|
18 |
+
'*/widget_chooser/product/form/fallback_product_selector',
|
19 |
+
array('_secure' => Mage::app()->getStore()->isAdminUrlSecure())
|
20 |
+
) . '?isAjax=true\'); return false;';
|
21 |
Â
|
22 |
Â
return $this->getLayout()->createBlock('adminhtml/widget_button')
|
23 |
Â
->setType('button')
|
@@ -1,11 +1,13 @@
|
|
1 |
Â
<?php
|
2 |
Â
|
3 |
-
class Dotdigitalgroup_Email_Block_Adminhtml_System_Dynamic_Fallbackcontainer
|
Â
|
|
4 |
Â
{
|
5 |
Â
|
6 |
-
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element
|
7 |
-
{
|
8 |
Â
$this->setElement($element);
|
Â
|
|
9 |
Â
return
|
10 |
Â
"<script type='text/javascript'>
|
11 |
Â
var fallback_product_selector = new ConnectorProductSelectorForm('connector_dynamic_content_fallback_products_product_list');
|
1 |
Â
<?php
|
2 |
Â
|
3 |
+
class Dotdigitalgroup_Email_Block_Adminhtml_System_Dynamic_Fallbackcontainer
|
4 |
+
extends Mage_Adminhtml_Block_System_Config_Form_Field
|
5 |
Â
{
|
6 |
Â
|
7 |
+
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element
|
8 |
+
) {
|
9 |
Â
$this->setElement($element);
|
10 |
+
|
11 |
Â
return
|
12 |
Â
"<script type='text/javascript'>
|
13 |
Â
var fallback_product_selector = new ConnectorProductSelectorForm('connector_dynamic_content_fallback_products_product_list');
|
@@ -1,20 +1,27 @@
|
|
1 |
Â
<?php
|
2 |
Â
|
3 |
-
class Dotdigitalgroup_Email_Block_Adminhtml_System_Dynamic_Feefo_Reviews
|
Â
|
|
4 |
Â
{
|
5 |
-
|
Â
|
|
Â
|
|
6 |
Â
{
|
7 |
Â
//passcode to append for url
|
8 |
Â
$passcode = Mage::helper('ddg')->getPasscode();
|
9 |
Â
|
10 |
-
if(!strlen($passcode))
|
11 |
Â
$passcode = '[PLEASE SET UP A PASSCODE]';
|
Â
|
|
12 |
Â
|
13 |
Â
//generate the base url and display for default store id
|
14 |
Â
$baseUrl = Mage::helper('ddg')->generateDynamicUrl();
|
15 |
Â
|
16 |
Â
//display the full url
|
17 |
-
$text = sprintf(
|
Â
|
|
Â
|
|
Â
|
|
18 |
Â
$element->setData('value', $text);
|
19 |
Â
|
20 |
Â
return parent::_getElementHtml($element);
|
1 |
Â
<?php
|
2 |
Â
|
3 |
+
class Dotdigitalgroup_Email_Block_Adminhtml_System_Dynamic_Feefo_Reviews
|
4 |
+
extends Mage_Adminhtml_Block_System_Config_Form_Field
|
5 |
Â
{
|
6 |
+
|
7 |
+
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element
|
8 |
+
)
|
9 |
Â
{
|
10 |
Â
//passcode to append for url
|
11 |
Â
$passcode = Mage::helper('ddg')->getPasscode();
|
12 |
Â
|
13 |
+
if ( ! strlen($passcode)) {
|
14 |
Â
$passcode = '[PLEASE SET UP A PASSCODE]';
|
15 |
+
}
|
16 |
Â
|
17 |
Â
//generate the base url and display for default store id
|
18 |
Â
$baseUrl = Mage::helper('ddg')->generateDynamicUrl();
|
19 |
Â
|
20 |
Â
//display the full url
|
21 |
+
$text = sprintf(
|
22 |
+
'%sconnector/feefo/reviews/code/%s/quote_id/@QUOTE_ID@', $baseUrl,
|
23 |
+
$passcode
|
24 |
+
);
|
25 |
Â
$element->setData('value', $text);
|
26 |
Â
|
27 |
Â
return parent::_getElementHtml($element);
|
@@ -1,14 +1,18 @@
|
|
1 |
Â
<?php
|
2 |
Â
|
3 |
-
class Dotdigitalgroup_Email_Block_Adminhtml_System_Dynamic_Feefo_Score
|
Â
|
|
4 |
Â
{
|
5 |
-
|
Â
|
|
Â
|
|
6 |
Â
{
|
7 |
Â
//passcode to append for url
|
8 |
Â
$passcode = Mage::helper('ddg')->getPasscode();
|
9 |
Â
|
10 |
-
if(!strlen($passcode))
|
11 |
Â
$passcode = '[PLEASE SET UP A PASSCODE]';
|
Â
|
|
12 |
Â
|
13 |
Â
//generate the base url and display for default store id
|
14 |
Â
$baseUrl = Mage::helper('ddg')->generateDynamicUrl();
|
1 |
Â
<?php
|
2 |
Â
|
3 |
+
class Dotdigitalgroup_Email_Block_Adminhtml_System_Dynamic_Feefo_Score
|
4 |
+
extends Mage_Adminhtml_Block_System_Config_Form_Field
|
5 |
Â
{
|
6 |
+
|
7 |
+
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element
|
8 |
+
)
|
9 |
Â
{
|
10 |
Â
//passcode to append for url
|
11 |
Â
$passcode = Mage::helper('ddg')->getPasscode();
|
12 |
Â
|
13 |
+
if ( ! strlen($passcode)) {
|
14 |
Â
$passcode = '[PLEASE SET UP A PASSCODE]';
|
15 |
+
}
|
16 |
Â
|
17 |
Â
//generate the base url and display for default store id
|
18 |
Â
$baseUrl = Mage::helper('ddg')->generateDynamicUrl();
|
@@ -1,24 +1,28 @@
|
|
1 |
Â
<?php
|
2 |
Â
|
3 |
-
class Dotdigitalgroup_Email_Block_Adminhtml_System_Dynamic_Gridlist
|
Â
|
|
4 |
Â
{
|
Â
|
|
5 |
Â
/**
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element
|
Â
|
|
13 |
Â
{
|
14 |
Â
// Get the default HTML for this option
|
15 |
Â
$html = parent::_getElementHtml($element);
|
16 |
Â
|
17 |
Â
|
18 |
-
$jQuery
|
Â
|
|
19 |
Â
|
20 |
-
$jQuery
|
21 |
-
|
22 |
Â
jQuery.noConflict();
|
23 |
Â
jQuery(document).ready(function() {
|
24 |
Â
var gridOptions = {
|
1 |
Â
<?php
|
2 |
Â
|
3 |
+
class Dotdigitalgroup_Email_Block_Adminhtml_System_Dynamic_Gridlist
|
4 |
+
extends Mage_Adminhtml_Block_System_Config_Form_Field
|
5 |
Â
{
|
6 |
+
|
7 |
Â
/**
|
8 |
+
* Dynamic contaent dysplay type.
|
9 |
+
*
|
10 |
+
* @param Varien_Data_Form_Element_Abstract $element
|
11 |
+
*
|
12 |
+
* @return string
|
13 |
+
*/
|
14 |
+
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element
|
15 |
+
)
|
16 |
Â
{
|
17 |
Â
// Get the default HTML for this option
|
18 |
Â
$html = parent::_getElementHtml($element);
|
19 |
Â
|
20 |
Â
|
21 |
+
$jQuery
|
22 |
+
= '<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js" ></script>';
|
23 |
Â
|
24 |
+
$jQuery
|
25 |
+
.= '<script type="text/javascript">
|
26 |
Â
jQuery.noConflict();
|
27 |
Â
jQuery(document).ready(function() {
|
28 |
Â
var gridOptions = {
|
@@ -1,30 +1,38 @@
|
|
1 |
Â
<?php
|
2 |
Â
|
3 |
-
class Dotdigitalgroup_Email_Block_Adminhtml_System_Dynamic_Lostbasket
|
Â
|
|
4 |
Â
{
|
5 |
Â
|
6 |
Â
/** label */
|
7 |
-
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element
|
Â
|
|
8 |
Â
{
|
9 |
-
|
10 |
Â
$baseUrl = Mage::helper('ddg')->generateDynamicUrl();
|
11 |
Â
$passcode = Mage::helper('ddg')->getPasscode();
|
12 |
Â
|
13 |
-
|
14 |
-
|
15 |
Â
|
16 |
-
|
17 |
-
|
18 |
Â
$passcode = '[PLEASE SET UP A PASSCODE]';
|
19 |
-
|
20 |
-
|
21 |
-
|
Â
|
|
Â
|
|
22 |
Â
|
23 |
-
|
24 |
Â
|
25 |
-
$text =
|
Â
|
|
Â
|
|
Â
|
|
26 |
Â
|
27 |
Â
$element->setData('value', $text);
|
Â
|
|
28 |
Â
return parent::_getElementHtml($element);
|
29 |
Â
}
|
30 |
Â
|
1 |
Â
<?php
|
2 |
Â
|
3 |
+
class Dotdigitalgroup_Email_Block_Adminhtml_System_Dynamic_Lostbasket
|
4 |
+
extends Mage_Adminhtml_Block_System_Config_Form_Field
|
5 |
Â
{
|
6 |
Â
|
7 |
Â
/** label */
|
8 |
+
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element
|
9 |
+
)
|
10 |
Â
{
|
11 |
+
//base url for dynamic content
|
12 |
Â
$baseUrl = Mage::helper('ddg')->generateDynamicUrl();
|
13 |
Â
$passcode = Mage::helper('ddg')->getPasscode();
|
14 |
Â
|
15 |
+
//last quote id for dynamic page
|
16 |
+
$lastQuoteId = Mage::helper('ddg')->getLastQuoteId();
|
17 |
Â
|
18 |
+
//config passcode
|
19 |
+
if ( ! strlen($passcode)) {
|
20 |
Â
$passcode = '[PLEASE SET UP A PASSCODE]';
|
21 |
+
}
|
22 |
+
//alert message for last order id is not mapped
|
23 |
+
if ( ! $lastQuoteId) {
|
24 |
+
$lastQuoteId = '[PLEASE MAP THE LAST QUOTE ID]';
|
25 |
+
}
|
26 |
Â
|
27 |
+
// full url
|
28 |
Â
|
29 |
+
$text = sprintf(
|
30 |
+
"%sconnector/email/basket/code/%s/quote_id/@%s@", $baseUrl,
|
31 |
+
$passcode, $lastQuoteId
|
32 |
+
);
|
33 |
Â
|
34 |
Â
$element->setData('value', $text);
|
35 |
+
|
36 |
Â
return parent::_getElementHtml($element);
|
37 |
Â
}
|
38 |
Â
|
@@ -1,20 +1,23 @@
|
|
1 |
Â
<?php
|
2 |
Â
|
3 |
-
class Dotdigitalgroup_Email_Block_Adminhtml_System_Dynamic_Manualchooser
|
Â
|
|
4 |
Â
{
|
5 |
Â
|
6 |
-
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element
|
Â
|
|
7 |
Â
{
|
8 |
Â
$this->setElement($element);
|
Â
|
|
9 |
Â
return $this->_getAddRowButtonHtml($this->__("Choose Products"));
|
10 |
Â
}
|
11 |
Â
|
12 |
Â
protected function _getAddRowButtonHtml($title)
|
13 |
Â
{
|
14 |
Â
$action = 'getManualProductChooser(\'' . Mage::getUrl(
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
Â
|
19 |
Â
return $this->getLayout()->createBlock('adminhtml/widget_button')
|
20 |
Â
->setType('button')
|
1 |
Â
<?php
|
2 |
Â
|
3 |
+
class Dotdigitalgroup_Email_Block_Adminhtml_System_Dynamic_Manualchooser
|
4 |
+
extends Mage_Adminhtml_Block_System_Config_Form_Field
|
5 |
Â
{
|
6 |
Â
|
7 |
+
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element
|
8 |
+
)
|
9 |
Â
{
|
10 |
Â
$this->setElement($element);
|
11 |
+
|
12 |
Â
return $this->_getAddRowButtonHtml($this->__("Choose Products"));
|
13 |
Â
}
|
14 |
Â
|
15 |
Â
protected function _getAddRowButtonHtml($title)
|
16 |
Â
{
|
17 |
Â
$action = 'getManualProductChooser(\'' . Mage::getUrl(
|
18 |
+
'*/widget_chooser/product/form/manual_product_selector',
|
19 |
+
array('_secure' => Mage::app()->getStore()->isAdminUrlSecure())
|
20 |
+
) . '?isAjax=true\'); return false;';
|
21 |
Â
|
22 |
Â
return $this->getLayout()->createBlock('adminhtml/widget_button')
|
23 |
Â
->setType('button')
|
@@ -1,11 +1,13 @@
|
|
1 |
Â
<?php
|
2 |
Â
|
3 |
-
class Dotdigitalgroup_Email_Block_Adminhtml_System_Dynamic_Manualcontainer
|
Â
|
|
4 |
Â
{
|
5 |
Â
|
6 |
-
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element
|
7 |
-
{
|
8 |
Â
$this->setElement($element);
|
Â
|
|
9 |
Â
return
|
10 |
Â
"<script type='text/javascript'>
|
11 |
Â
var manual_product_selector = new ConnectorProductSelectorForm('connector_dynamic_content_manual_product_search_products_push_items');
|
1 |
Â
<?php
|
2 |
Â
|
3 |
+
class Dotdigitalgroup_Email_Block_Adminhtml_System_Dynamic_Manualcontainer
|
4 |
+
extends Mage_Adminhtml_Block_System_Config_Form_Field
|
5 |
Â
{
|
6 |
Â
|
7 |
+
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element
|
8 |
+
) {
|
9 |
Â
$this->setElement($element);
|
10 |
+
|
11 |
Â
return
|
12 |
Â
"<script type='text/javascript'>
|
13 |
Â
var manual_product_selector = new ConnectorProductSelectorForm('connector_dynamic_content_manual_product_search_products_push_items');
|
@@ -1,19 +1,25 @@
|
|
1 |
Â
<?php
|
2 |
Â
|
3 |
-
class Dotdigitalgroup_Email_Block_Adminhtml_System_Dynamic_Mostviewed
|
Â
|
|
4 |
Â
{
|
Â
|
|
5 |
Â
/** label */
|
6 |
-
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element
|
Â
|
|
7 |
Â
{
|
8 |
-
|
9 |
-
|
10 |
Â
$passcode = Mage::helper('ddg')->getPasscode();
|
11 |
Â
|
12 |
-
if (!strlen($passcode))
|
13 |
-
|
Â
|
|
14 |
Â
|
15 |
-
|
16 |
-
$text = sprintf(
|
Â
|
|
Â
|
|
17 |
Â
$element->setData('value', $text);
|
18 |
Â
|
19 |
Â
return parent::_getElementHtml($element);
|
1 |
Â
<?php
|
2 |
Â
|
3 |
+
class Dotdigitalgroup_Email_Block_Adminhtml_System_Dynamic_Mostviewed
|
4 |
+
extends Mage_Adminhtml_Block_System_Config_Form_Field
|
5 |
Â
{
|
6 |
+
|
7 |
Â
/** label */
|
8 |
+
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element
|
9 |
+
)
|
10 |
Â
{
|
11 |
+
//base url for dynamic content
|
12 |
+
$baseUrl = Mage::helper('ddg')->generateDynamicUrl();
|
13 |
Â
$passcode = Mage::helper('ddg')->getPasscode();
|
14 |
Â
|
15 |
+
if ( ! strlen($passcode)) {
|
16 |
+
$passcode = '[PLEASE SET UP A PASSCODE]';
|
17 |
+
}
|
18 |
Â
|
19 |
+
//full url for dynamic content
|
20 |
+
$text = sprintf(
|
21 |
+
'%sconnector/report/mostviewed/code/%s', $baseUrl, $passcode
|
22 |
+
);
|
23 |
Â
$element->setData('value', $text);
|
24 |
Â
|
25 |
Â
return parent::_getElementHtml($element);
|
@@ -1,22 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class Dotdigitalgroup_Email_Block_Adminhtml_System_Dynamic_Nosto extends Mage_Adminhtml_Block_System_Config_Form_Field
|
4 |
-
{
|
5 |
-
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
|
6 |
-
{
|
7 |
-
//passcode to append for url
|
8 |
-
$passcode = Mage::helper('ddg')->getPasscode();
|
9 |
-
|
10 |
-
if(!strlen($passcode))
|
11 |
-
$passcode = '[PLEASE SET UP A PASSCODE]';
|
12 |
-
|
13 |
-
//generate the base url and display for default store id
|
14 |
-
$baseUrl = Mage::helper('ddg')->generateDynamicUrl();
|
15 |
-
|
16 |
-
//display the full url
|
17 |
-
$text = sprintf('%sconnector/products/nosto/code/%s/slot/@SLOT_NAME@/email/@EMAIL@', $baseUrl, $passcode);
|
18 |
-
$element->setData('value', $text);
|
19 |
-
|
20 |
-
return parent::_getElementHtml($element);
|
21 |
-
}
|
22 |
-
}
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
@@ -1,19 +1,25 @@
|
|
1 |
Â
<?php
|
2 |
Â
|
3 |
-
class Dotdigitalgroup_Email_Block_Adminhtml_System_Dynamic_Productpush
|
Â
|
|
4 |
Â
{
|
Â
|
|
5 |
Â
/** label */
|
6 |
-
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element
|
Â
|
|
7 |
Â
{
|
8 |
-
|
9 |
-
|
10 |
-
$passcode
|
11 |
Â
|
12 |
-
if (!strlen($passcode))
|
13 |
-
|
Â
|
|
14 |
Â
|
15 |
-
|
16 |
-
$text = sprintf(
|
Â
|
|
Â
|
|
17 |
Â
$element->setData('value', $text);
|
18 |
Â
|
19 |
Â
return parent::_getElementHtml($element);
|
1 |
Â
<?php
|
2 |
Â
|
3 |
+
class Dotdigitalgroup_Email_Block_Adminhtml_System_Dynamic_Productpush
|
4 |
+
extends Mage_Adminhtml_Block_System_Config_Form_Field
|
5 |
Â
{
|
6 |
+
|
7 |
Â
/** label */
|
8 |
+
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element
|
9 |
+
)
|
10 |
Â
{
|
11 |
+
//generate base url
|
12 |
+
$baseUrl = Mage::helper('ddg')->generateDynamicUrl();
|
13 |
+
$passcode = Mage::helper('ddg')->getPasscode();
|
14 |
Â
|
15 |
+
if ( ! strlen($passcode)) {
|
16 |
+
$passcode = '[PLEASE SET UP A PASSCODE]';
|
17 |
+
}
|
18 |
Â
|
19 |
+
//full url for dynamic content
|
20 |
+
$text = sprintf(
|
21 |
+
'%sconnector/products/push/code/%s', $baseUrl, $passcode
|
22 |
+
);
|
23 |
Â
$element->setData('value', $text);
|
24 |
Â
|
25 |
Â
return parent::_getElementHtml($element);
|
@@ -1,21 +1,30 @@
|
|
1 |
Â
<?php
|
2 |
-
|
Â
|
|
Â
|
|
3 |
Â
{
|
4 |
-
|
Â
|
|
Â
|
|
5 |
Â
{
|
6 |
Â
//generate base url for dynamic content
|
7 |
-
|
8 |
Â
|
9 |
-
|
10 |
Â
$passcode = Mage::helper('ddg')->getPasscode();
|
11 |
Â
$customerId = Mage::helper('ddg')->getMappedCustomerId();
|
12 |
Â
|
13 |
-
if (!strlen($passcode))
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
19 |
Â
$element->setData('value', $text);
|
20 |
Â
|
21 |
Â
return parent::_getElementHtml($element);
|
1 |
Â
<?php
|
2 |
+
|
3 |
+
class Dotdigitalgroup_Email_Block_Adminhtml_System_Dynamic_Recentlyviewed
|
4 |
+
extends Mage_Adminhtml_Block_System_Config_Form_Field
|
5 |
Â
{
|
6 |
+
|
7 |
+
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element
|
8 |
+
)
|
9 |
Â
{
|
10 |
Â
//generate base url for dynamic content
|
11 |
+
$baseUrl = Mage::helper('ddg')->generateDynamicUrl();
|
12 |
Â
|
13 |
+
//config passcode
|
14 |
Â
$passcode = Mage::helper('ddg')->getPasscode();
|
15 |
Â
$customerId = Mage::helper('ddg')->getMappedCustomerId();
|
16 |
Â
|
17 |
+
if ( ! strlen($passcode)) {
|
18 |
+
$passcode = '[PLEASE SET UP A PASSCODE]';
|
19 |
+
}
|
20 |
+
if ( ! $customerId) {
|
21 |
+
$customerId = '[PLEASE MAP THE CUSTOMER ID]';
|
22 |
+
}
|
23 |
+
//dynamic content url
|
24 |
+
$text = sprintf(
|
25 |
+
'%sconnector/report/recentlyviewed/code/%s/customer_id/@%s@',
|
26 |
+
$baseUrl, $passcode, $customerId
|
27 |
+
);
|
28 |
Â
$element->setData('value', $text);
|
29 |
Â
|
30 |
Â
return parent::_getElementHtml($element);
|
@@ -1,24 +1,32 @@
|
|
1 |
Â
<?php
|
2 |
Â
|
3 |
-
class Dotdigitalgroup_Email_Block_Adminhtml_System_Dynamic_Related
|
Â
|
|
4 |
Â
{
|
5 |
-
|
Â
|
|
Â
|
|
6 |
Â
{
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
Â
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
Â
|
|
Â
|
|
16 |
Â
|
17 |
-
|
18 |
-
|
19 |
Â
|
20 |
-
|
21 |
-
$text = sprintf(
|
Â
|
|
Â
|
|
Â
|
|
22 |
Â
$element->setData('value', $text);
|
23 |
Â
|
24 |
Â
return parent::_getElementHtml($element);
|
1 |
Â
<?php
|
2 |
Â
|
3 |
+
class Dotdigitalgroup_Email_Block_Adminhtml_System_Dynamic_Related
|
4 |
+
extends Mage_Adminhtml_Block_System_Config_Form_Field
|
5 |
Â
{
|
6 |
+
|
7 |
+
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element
|
8 |
+
)
|
9 |
Â
{
|
10 |
+
//passcode to append for url
|
11 |
+
$passcode = Mage::helper('ddg')->getPasscode();
|
12 |
+
//last order id witch information will be generated
|
13 |
+
$lastOrderId = Mage::helper('ddg')->getLastOrderId();
|
14 |
Â
|
15 |
+
if ( ! strlen($passcode)) {
|
16 |
+
$passcode = '[PLEASE SET UP A PASSCODE]';
|
17 |
+
}
|
18 |
+
if ( ! $lastOrderId) {
|
19 |
+
$lastOrderId = '[PLEASE MAP THE LAST ORDER ID]';
|
20 |
+
}
|
21 |
Â
|
22 |
+
//generate the base url and display for default store id
|
23 |
+
$baseUrl = Mage::helper('ddg')->generateDynamicUrl();
|
24 |
Â
|
25 |
+
//display the full url
|
26 |
+
$text = sprintf(
|
27 |
+
'%sconnector/products/related/code/%s/order_id/@%s@', $baseUrl,
|
28 |
+
$passcode, $lastOrderId
|
29 |
+
);
|
30 |
Â
$element->setData('value', $text);
|
31 |
Â
|
32 |
Â
return parent::_getElementHtml($element);
|
@@ -1,26 +1,33 @@
|
|
1 |
Â
<?php
|
2 |
Â
|
3 |
-
class Dotdigitalgroup_Email_Block_Adminhtml_System_Dynamic_Review
|
Â
|
|
4 |
Â
{
|
5 |
Â
|
6 |
Â
/** label */
|
7 |
-
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element
|
Â
|
|
8 |
Â
{
|
9 |
Â
//passcode to append for url
|
10 |
Â
$passcode = Mage::helper('ddg')->getPasscode();
|
11 |
Â
//last order id witch information will be generated
|
12 |
Â
$lastOrderId = Mage::helper('ddg')->getLastOrderId();
|
13 |
Â
|
14 |
-
if(!strlen($passcode))
|
15 |
Â
$passcode = '[PLEASE SET UP A PASSCODE]';
|
16 |
-
|
Â
|
|
17 |
Â
$lastOrderId = '[PLEASE MAP THE LAST ORDER ID]';
|
Â
|
|
18 |
Â
|
19 |
Â
//generate the base url and display for default store id
|
20 |
Â
$baseUrl = Mage::helper('ddg')->generateDynamicUrl();
|
21 |
Â
|
22 |
Â
//display the full url
|
23 |
-
$text = sprintf(
|
Â
|
|
Â
|
|
Â
|
|
24 |
Â
$element->setData('value', $text);
|
25 |
Â
|
26 |
Â
return parent::_getElementHtml($element);
|
1 |
Â
<?php
|
2 |
Â
|
3 |
+
class Dotdigitalgroup_Email_Block_Adminhtml_System_Dynamic_Review
|
4 |
+
extends Mage_Adminhtml_Block_System_Config_Form_Field
|
5 |
Â
{
|
6 |
Â
|
7 |
Â
/** label */
|
8 |
+
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element
|
9 |
+
)
|
10 |
Â
{
|
11 |
Â
//passcode to append for url
|
12 |
Â
$passcode = Mage::helper('ddg')->getPasscode();
|
13 |
Â
//last order id witch information will be generated
|
14 |
Â
$lastOrderId = Mage::helper('ddg')->getLastOrderId();
|
15 |
Â
|
16 |
+
if ( ! strlen($passcode)) {
|
17 |
Â
$passcode = '[PLEASE SET UP A PASSCODE]';
|
18 |
+
}
|
19 |
+
if ( ! $lastOrderId) {
|
20 |
Â
$lastOrderId = '[PLEASE MAP THE LAST ORDER ID]';
|
21 |
+
}
|
22 |
Â
|
23 |
Â
//generate the base url and display for default store id
|
24 |
Â
$baseUrl = Mage::helper('ddg')->generateDynamicUrl();
|
25 |
Â
|
26 |
Â
//display the full url
|
27 |
+
$text = sprintf(
|
28 |
+
'%sconnector/email/review/code/%s/order_id/@%s@', $baseUrl,
|
29 |
+
$passcode, $lastOrderId
|
30 |
+
);
|
31 |
Â
$element->setData('value', $text);
|
32 |
Â
|
33 |
Â
return parent::_getElementHtml($element);
|
@@ -1,22 +1,31 @@
|
|
1 |
Â
<?php
|
2 |
-
|
Â
|
|
Â
|
|
3 |
Â
{
|
4 |
-
|
Â
|
|
Â
|
|
5 |
Â
{
|
6 |
Â
//passcode to append for url
|
7 |
Â
$passcode = Mage::helper('ddg')->getPasscode();
|
8 |
-
|
9 |
Â
$lastOrderid = Mage::helper('ddg')->getLastOrderId();
|
10 |
Â
|
11 |
-
if(!strlen($passcode))
|
12 |
-
|
13 |
-
|
14 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
15 |
Â
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
Â
$element->setData('value', $text);
|
21 |
Â
|
22 |
Â
return parent::_getElementHtml($element);
|
1 |
Â
<?php
|
2 |
+
|
3 |
+
class Dotdigitalgroup_Email_Block_Adminhtml_System_Dynamic_Upsell
|
4 |
+
extends Mage_Adminhtml_Block_System_Config_Form_Field
|
5 |
Â
{
|
6 |
+
|
7 |
+
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element
|
8 |
+
)
|
9 |
Â
{
|
10 |
Â
//passcode to append for url
|
11 |
Â
$passcode = Mage::helper('ddg')->getPasscode();
|
12 |
+
//last order id witch information will be generated
|
13 |
Â
$lastOrderid = Mage::helper('ddg')->getLastOrderId();
|
14 |
Â
|
15 |
+
if ( ! strlen($passcode)) {
|
16 |
+
$passcode = '[PLEASE SET UP A PASSCODE]';
|
17 |
+
}
|
18 |
+
if ( ! $lastOrderid) {
|
19 |
+
$lastOrderid = '[PLEASE MAP THE LAST ORDER ID]';
|
20 |
+
}
|
21 |
+
|
22 |
+
//generate the base url and display for default store id
|
23 |
+
$baseUrl = Mage::helper('ddg')->generateDynamicUrl();
|
24 |
Â
|
25 |
+
$text = sprintf(
|
26 |
+
'%sconnector/products/upsell/code/%s/order_id/@%s@', $baseUrl,
|
27 |
+
$passcode, $lastOrderid
|
28 |
+
);
|
29 |
Â
$element->setData('value', $text);
|
30 |
Â
|
31 |
Â
return parent::_getElementHtml($element);
|
@@ -1,30 +1,39 @@
|
|
1 |
Â
<?php
|
2 |
Â
|
3 |
-
class Dotdigitalgroup_Email_Block_Adminhtml_System_Dynamic_Wishlist
|
Â
|
|
4 |
Â
{
|
Â
|
|
5 |
Â
/**
|
6 |
Â
* label
|
7 |
Â
*
|
8 |
Â
* @param Varien_Data_Form_Element_Abstract $element
|
Â
|
|
9 |
Â
* @return string
|
10 |
Â
*/
|
11 |
-
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element
|
Â
|
|
12 |
Â
{
|
13 |
Â
//passcode to append for url
|
14 |
Â
$passcode = Mage::helper('ddg')->getPasscode();
|
15 |
Â
//last order id witch information will be generated
|
16 |
Â
$customerId = Mage::helper('ddg')->getMappedCustomerId();
|
17 |
Â
|
18 |
-
if(!strlen($passcode))
|
19 |
Â
$passcode = '[PLEASE SET UP A PASSCODE]';
|
20 |
-
|
Â
|
|
21 |
Â
$customerId = '[PLEASE MAP THE CUSTOMER ID]';
|
Â
|
|
22 |
Â
|
23 |
Â
//generate the base url and display for default store id
|
24 |
Â
$baseUrl = Mage::helper('ddg')->generateDynamicUrl();
|
25 |
Â
|
26 |
Â
//display the full url
|
27 |
-
$text = sprintf(
|
Â
|
|
Â
|
|
Â
|
|
28 |
Â
$element->setData('value', $text);
|
29 |
Â
|
30 |
Â
return parent::_getElementHtml($element);
|
1 |
Â
<?php
|
2 |
Â
|
3 |
+
class Dotdigitalgroup_Email_Block_Adminhtml_System_Dynamic_Wishlist
|
4 |
+
extends Mage_Adminhtml_Block_System_Config_Form_Field
|
5 |
Â
{
|
6 |
+
|
7 |
Â
/**
|
8 |
Â
* label
|
9 |
Â
*
|
10 |
Â
* @param Varien_Data_Form_Element_Abstract $element
|
11 |
+
*
|
12 |
Â
* @return string
|
13 |
Â
*/
|
14 |
+
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element
|
15 |
+
)
|
16 |
Â
{
|
17 |
Â
//passcode to append for url
|
18 |
Â
$passcode = Mage::helper('ddg')->getPasscode();
|
19 |
Â
//last order id witch information will be generated
|
20 |
Â
$customerId = Mage::helper('ddg')->getMappedCustomerId();
|
21 |
Â
|
22 |
+
if ( ! strlen($passcode)) {
|
23 |
Â
$passcode = '[PLEASE SET UP A PASSCODE]';
|
24 |
+
}
|
25 |
+
if ( ! $customerId) {
|
26 |
Â
$customerId = '[PLEASE MAP THE CUSTOMER ID]';
|
27 |
+
}
|
28 |
Â
|
29 |
Â
//generate the base url and display for default store id
|
30 |
Â
$baseUrl = Mage::helper('ddg')->generateDynamicUrl();
|
31 |
Â
|
32 |
Â
//display the full url
|
33 |
+
$text = sprintf(
|
34 |
+
'%sconnector/email/wishlist/code/%s/customer_id/@%s@', $baseUrl,
|
35 |
+
$passcode, $customerId
|
36 |
+
);
|
37 |
Â
$element->setData('value', $text);
|
38 |
Â
|
39 |
Â
return parent::_getElementHtml($element);
|
@@ -1,30 +1,39 @@
|
|
1 |
Â
<?php
|
2 |
Â
|
3 |
-
class Dotdigitalgroup_Email_Block_Adminhtml_System_Dynamic_Wishlist_Crosssell
|
Â
|
|
4 |
Â
{
|
Â
|
|
5 |
Â
/**
|
6 |
Â
* label
|
7 |
Â
*
|
8 |
Â
* @param Varien_Data_Form_Element_Abstract $element
|
Â
|
|
9 |
Â
* @return string
|
10 |
Â
*/
|
11 |
-
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element
|
Â
|
|
12 |
Â
{
|
13 |
Â
//passcode to append for url
|
14 |
Â
$passcode = Mage::helper('ddg')->getPasscode();
|
15 |
Â
//last order id witch information will be generated
|
16 |
Â
$customerId = Mage::helper('ddg')->getMappedCustomerId();
|
17 |
Â
|
18 |
-
if(!strlen($passcode))
|
19 |
Â
$passcode = '[PLEASE SET UP A PASSCODE]';
|
20 |
-
|
Â
|
|
21 |
Â
$customerId = '[PLEASE MAP THE CUSTOMER ID]';
|
Â
|
|
22 |
Â
|
23 |
Â
//generate the base url and display for default store id
|
24 |
Â
$baseUrl = Mage::helper('ddg')->generateDynamicUrl();
|
25 |
Â
|
26 |
Â
//display the full url
|
27 |
-
$text = sprintf(
|
Â
|
|
Â
|
|
Â
|
|
28 |
Â
$element->setData('value', $text);
|
29 |
Â
|
30 |
Â
return parent::_getElementHtml($element);
|
1 |
Â
<?php
|
2 |
Â
|
3 |
+
class Dotdigitalgroup_Email_Block_Adminhtml_System_Dynamic_Wishlist_Crosssell
|
4 |
+
extends Mage_Adminhtml_Block_System_Config_Form_Field
|
5 |
Â
{
|
6 |
+
|
7 |
Â
/**
|
8 |
Â
* label
|
9 |
Â
*
|
10 |
Â
* @param Varien_Data_Form_Element_Abstract $element
|
11 |
+
*
|
12 |
Â
* @return string
|
13 |
Â
*/
|
14 |
+
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element
|
15 |
+
)
|
16 |
Â
{
|
17 |
Â
//passcode to append for url
|
18 |
Â
$passcode = Mage::helper('ddg')->getPasscode();
|
19 |
Â
//last order id witch information will be generated
|
20 |
Â
$customerId = Mage::helper('ddg')->getMappedCustomerId();
|
21 |
Â
|
22 |
+
if ( ! strlen($passcode)) {
|
23 |
Â
$passcode = '[PLEASE SET UP A PASSCODE]';
|
24 |
+
}
|
25 |
+
if ( ! $customerId) {
|
26 |
Â
$customerId = '[PLEASE MAP THE CUSTOMER ID]';
|
27 |
+
}
|
28 |
Â
|
29 |
Â
//generate the base url and display for default store id
|
30 |
Â
$baseUrl = Mage::helper('ddg')->generateDynamicUrl();
|
31 |
Â
|
32 |
Â
//display the full url
|
33 |
+
$text = sprintf(
|
34 |
+
'%sconnector/wishlist/crosssell/code/%s/customer_id/@%s@', $baseUrl,
|
35 |
+
$passcode, $customerId
|
36 |
+
);
|
37 |
Â
$element->setData('value', $text);
|
38 |
Â
|
39 |
Â
return parent::_getElementHtml($element);
|
@@ -1,30 +1,39 @@
|
|
1 |
Â
<?php
|
2 |
Â
|
3 |
-
class Dotdigitalgroup_Email_Block_Adminhtml_System_Dynamic_Wishlist_Related
|
Â
|
|
4 |
Â
{
|
Â
|
|
5 |
Â
/**
|
6 |
Â
* label
|
7 |
Â
*
|
8 |
Â
* @param Varien_Data_Form_Element_Abstract $element
|
Â
|
|
9 |
Â
* @return string
|
10 |
Â
*/
|
11 |
-
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element
|
Â
|
|
12 |
Â
{
|
13 |
Â
//passcode to append for url
|
14 |
Â
$passcode = Mage::helper('ddg')->getPasscode();
|
15 |
Â
//last order id witch information will be generated
|
16 |
Â
$customerId = Mage::helper('ddg')->getMappedCustomerId();
|
17 |
Â
|
18 |
-
if(!strlen($passcode))
|
19 |
Â
$passcode = '[PLEASE SET UP A PASSCODE]';
|
20 |
-
|
Â
|
|
21 |
Â
$customerId = '[PLEASE MAP THE CUSTOMER ID]';
|
Â
|
|
22 |
Â
|
23 |
Â
//generate the base url and display for default store id
|
24 |
Â
$baseUrl = Mage::helper('ddg')->generateDynamicUrl();
|
25 |
Â
|
26 |
Â
//display the full url
|
27 |
-
$text = sprintf(
|
Â
|
|
Â
|
|
Â
|
|
28 |
Â
$element->setData('value', $text);
|
29 |
Â
|
30 |
Â
return parent::_getElementHtml($element);
|
1 |
Â
<?php
|
2 |
Â
|
3 |
+
class Dotdigitalgroup_Email_Block_Adminhtml_System_Dynamic_Wishlist_Related
|
4 |
+
extends Mage_Adminhtml_Block_System_Config_Form_Field
|
5 |
Â
{
|
6 |
+
|
7 |
Â
/**
|
8 |
Â
* label
|
9 |
Â
*
|
10 |
Â
* @param Varien_Data_Form_Element_Abstract $element
|
11 |
+
*
|
12 |
Â
* @return string
|
13 |
Â
*/
|
14 |
+
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element
|
15 |
+
)
|
16 |
Â
{
|
17 |
Â
//passcode to append for url
|
18 |
Â
$passcode = Mage::helper('ddg')->getPasscode();
|
19 |
Â
//last order id witch information will be generated
|
20 |
Â
$customerId = Mage::helper('ddg')->getMappedCustomerId();
|
21 |
Â
|
22 |
+
if ( ! strlen($passcode)) {
|
23 |
Â
$passcode = '[PLEASE SET UP A PASSCODE]';
|
24 |
+
}
|
25 |
+
if ( ! $customerId) {
|
26 |
Â
$customerId = '[PLEASE MAP THE CUSTOMER ID]';
|
27 |
+
}
|
28 |
Â
|
29 |
Â
//generate the base url and display for default store id
|
30 |
Â
$baseUrl = Mage::helper('ddg')->generateDynamicUrl();
|
31 |
Â
|
32 |
Â
//display the full url
|
33 |
+
$text = sprintf(
|
34 |
+
'%sconnector/wishlist/related/code/%s/customer_id/@%s@', $baseUrl,
|
35 |
+
$passcode, $customerId
|
36 |
+
);
|
37 |
Â
$element->setData('value', $text);
|
38 |
Â
|
39 |
Â
return parent::_getElementHtml($element);
|
@@ -1,29 +1,39 @@
|
|
1 |
Â
<?php
|
2 |
-
|
Â
|
|
Â
|
|
3 |
Â
{
|
Â
|
|
4 |
Â
/**
|
5 |
Â
* label
|
6 |
Â
*
|
7 |
Â
* @param Varien_Data_Form_Element_Abstract $element
|
Â
|
|
8 |
Â
* @return string
|
9 |
Â
*/
|
10 |
-
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element
|
Â
|
|
11 |
Â
{
|
12 |
Â
//passcode to append for url
|
13 |
Â
$passcode = Mage::helper('ddg')->getPasscode();
|
14 |
Â
//last order id witch information will be generated
|
15 |
Â
$customerId = Mage::helper('ddg')->getMappedCustomerId();
|
16 |
Â
|
17 |
-
if(!strlen($passcode))
|
18 |
Â
$passcode = '[PLEASE SET UP A PASSCODE]';
|
19 |
-
|
Â
|
|
20 |
Â
$customerId = '[PLEASE MAP THE CUSTOMER ID]';
|
Â
|
|
21 |
Â
|
22 |
Â
//generate the base url and display for default store id
|
23 |
Â
$baseUrl = Mage::helper('ddg')->generateDynamicUrl();
|
24 |
Â
|
25 |
Â
//display the full url
|
26 |
-
$text = sprintf(
|
Â
|
|
Â
|
|
Â
|
|
27 |
Â
$element->setData('value', $text);
|
28 |
Â
|
29 |
Â
return parent::_getElementHtml($element);
|
1 |
Â
<?php
|
2 |
+
|
3 |
+
class Dotdigitalgroup_Email_Block_Adminhtml_System_Dynamic_Wishlist_Upsell
|
4 |
+
extends Mage_Adminhtml_Block_System_Config_Form_Field
|
5 |
Â
{
|
6 |
+
|
7 |
Â
/**
|
8 |
Â
* label
|
9 |
Â
*
|
10 |
Â
* @param Varien_Data_Form_Element_Abstract $element
|
11 |
+
*
|
12 |
Â
* @return string
|
13 |
Â
*/
|
14 |
+
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element
|
15 |
+
)
|
16 |
Â
{
|
17 |
Â
//passcode to append for url
|
18 |
Â
$passcode = Mage::helper('ddg')->getPasscode();
|
19 |
Â
//last order id witch information will be generated
|
20 |
Â
$customerId = Mage::helper('ddg')->getMappedCustomerId();
|
21 |
Â
|
22 |
+
if ( ! strlen($passcode)) {
|
23 |
Â
$passcode = '[PLEASE SET UP A PASSCODE]';
|
24 |
+
}
|
25 |
+
if ( ! $customerId) {
|
26 |
Â
$customerId = '[PLEASE MAP THE CUSTOMER ID]';
|
27 |
+
}
|
28 |
Â
|
29 |
Â
//generate the base url and display for default store id
|
30 |
Â
$baseUrl = Mage::helper('ddg')->generateDynamicUrl();
|
31 |
Â
|
32 |
Â
//display the full url
|
33 |
+
$text = sprintf(
|
34 |
+
'%sconnector/wishlist/upsell/code/%s/customer_id/@%s@', $baseUrl,
|
35 |
+
$passcode, $customerId
|
36 |
+
);
|
37 |
Â
$element->setData('value', $text);
|
38 |
Â
|
39 |
Â
return parent::_getElementHtml($element);
|
@@ -1,15 +1,18 @@
|
|
1 |
Â
<?php
|
2 |
Â
|
3 |
-
class Dotdigitalgroup_Email_Block_Adminhtml_System_Emailapivalidate
|
Â
|
|
4 |
Â
{
|
5 |
Â
|
6 |
-
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element
|
Â
|
|
7 |
Â
{
|
8 |
Â
$element->setData('onchange', "apiValidation(this.form, this);");
|
9 |
Â
|
10 |
Â
$url = Mage::helper('adminhtml')->getUrl('*/connector/ajaxvalidation');
|
11 |
Â
|
12 |
-
$element->setData(
|
Â
|
|
13 |
Â
<script>
|
14 |
Â
document.observe('dom:loaded', function(){
|
15 |
Â
apiValidation();
|
@@ -29,13 +32,15 @@ class Dotdigitalgroup_Email_Block_Adminhtml_System_Emailapivalidate extends Mage
|
|
29 |
Â
api_user.setStyle({
|
30 |
Â
fontWeight: 'bold',
|
31 |
Â
color: 'green' ,
|
32 |
-
background: 'transparent url(\""
|
Â
|
|
33 |
Â
})
|
34 |
Â
}else{
|
35 |
Â
api_user.setStyle({
|
36 |
Â
fontWeight: 'bold',
|
37 |
Â
color: 'red',
|
38 |
-
background: 'transparent url(\""
|
Â
|
|
39 |
Â
});
|
40 |
Â
|
41 |
Â
}
|
@@ -46,7 +51,8 @@ class Dotdigitalgroup_Email_Block_Adminhtml_System_Emailapivalidate extends Mage
|
|
46 |
Â
}
|
47 |
Â
|
48 |
Â
</script>
|
49 |
-
"
|
Â
|
|
50 |
Â
|
51 |
Â
return parent::_getElementHtml($element);
|
52 |
Â
|
1 |
Â
<?php
|
2 |
Â
|
3 |
+
class Dotdigitalgroup_Email_Block_Adminhtml_System_Emailapivalidate
|
4 |
+
extends Mage_Adminhtml_Block_System_Config_Form_Field
|
5 |
Â
{
|
6 |
Â
|
7 |
+
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element
|
8 |
+
)
|
9 |
Â
{
|
10 |
Â
$element->setData('onchange', "apiValidation(this.form, this);");
|
11 |
Â
|
12 |
Â
$url = Mage::helper('adminhtml')->getUrl('*/connector/ajaxvalidation');
|
13 |
Â
|
14 |
+
$element->setData(
|
15 |
+
'after_element_html', "
|
16 |
Â
<script>
|
17 |
Â
document.observe('dom:loaded', function(){
|
18 |
Â
apiValidation();
|
32 |
Â
api_user.setStyle({
|
33 |
Â
fontWeight: 'bold',
|
34 |
Â
color: 'green' ,
|
35 |
+
background: 'transparent url(\""
|
36 |
+
. $this->getSkinUrl('images/success_msg_icon.gif') . "\") no-repeat right center'
|
37 |
Â
})
|
38 |
Â
}else{
|
39 |
Â
api_user.setStyle({
|
40 |
Â
fontWeight: 'bold',
|
41 |
Â
color: 'red',
|
42 |
+
background: 'transparent url(\""
|
43 |
+
. $this->getSkinUrl('images/error_msg_icon.gif') . "\") no-repeat right center'
|
44 |
Â
});
|
45 |
Â
|
46 |
Â
}
|
51 |
Â
}
|
52 |
Â
|
53 |
Â
</script>
|
54 |
+
"
|
55 |
+
);
|
56 |
Â
|
57 |
Â
return parent::_getElementHtml($element);
|
58 |
Â
|
@@ -1,19 +1,22 @@
|
|
1 |
Â
<?php
|
2 |
Â
|
3 |
-
class Dotdigitalgroup_Email_Block_Adminhtml_System_Installation
|
Â
|
|
4 |
Â
{
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
Â
|
|
Â
|
|
17 |
Â
|
18 |
Â
/**
|
19 |
Â
* get the website domain.
|
@@ -27,6 +30,7 @@ class Dotdigitalgroup_Email_Block_Adminhtml_System_Installation extends Mage_Cor
|
|
27 |
Â
|
28 |
Â
/**
|
29 |
Â
* api username.
|
Â
|
|
30 |
Â
* @return string
|
31 |
Â
*/
|
32 |
Â
public function getApiUsername()
|
@@ -36,11 +40,12 @@ class Dotdigitalgroup_Email_Block_Adminhtml_System_Installation extends Mage_Cor
|
|
36 |
Â
|
37 |
Â
/**
|
38 |
Â
* check if the cron is running.
|
Â
|
|
39 |
Â
* @return bool
|
40 |
Â
*/
|
41 |
Â
public function getCronInstalled()
|
42 |
Â
{
|
43 |
-
return (Mage::helper('ddg')->getCronInstalled())? '1' : '0';
|
44 |
Â
}
|
45 |
Â
|
46 |
Â
/*
|
@@ -51,17 +56,18 @@ class Dotdigitalgroup_Email_Block_Adminhtml_System_Installation extends Mage_Cor
|
|
51 |
Â
$section = $this->getRequest()->getParam('section');
|
52 |
Â
|
53 |
Â
// not not track other sections
|
54 |
-
if (!in_array($section, $this->sections))
|
55 |
Â
return;
|
Â
|
|
56 |
Â
|
57 |
Â
$features = array(
|
58 |
-
'customer_sync'
|
59 |
-
'guest_sync'
|
60 |
Â
'subscriber_sync' => $this->getSubscriberSync(),
|
61 |
-
'order_sync'
|
62 |
-
'catalog_sync'
|
63 |
-
'dotmailer_smtp'
|
64 |
-
'roi'
|
65 |
Â
);
|
66 |
Â
|
67 |
Â
return json_encode($features);
|
@@ -105,6 +111,7 @@ class Dotdigitalgroup_Email_Block_Adminhtml_System_Installation extends Mage_Cor
|
|
105 |
Â
|
106 |
Â
/**
|
107 |
Â
* magento version.
|
Â
|
|
108 |
Â
* @return string
|
109 |
Â
*/
|
110 |
Â
public function getMageVersion()
|
@@ -114,6 +121,7 @@ class Dotdigitalgroup_Email_Block_Adminhtml_System_Installation extends Mage_Cor
|
|
114 |
Â
|
115 |
Â
/**
|
116 |
Â
* connector version.
|
Â
|
|
117 |
Â
* @return string
|
118 |
Â
*/
|
119 |
Â
public function getConnectorVersion()
|
@@ -121,41 +129,43 @@ class Dotdigitalgroup_Email_Block_Adminhtml_System_Installation extends Mage_Cor
|
|
121 |
Â
return Mage::helper('ddg')->getConnectorVersion();
|
122 |
Â
}
|
123 |
Â
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
Â
|
|
Â
|
|
161 |
Â
}
|
1 |
Â
<?php
|
2 |
Â
|
3 |
+
class Dotdigitalgroup_Email_Block_Adminhtml_System_Installation
|
4 |
+
extends Mage_Core_Block_Template
|
5 |
Â
{
|
6 |
+
|
7 |
+
public $sections
|
8 |
+
= array(
|
9 |
+
'connector_api_credentials',
|
10 |
+
'connector_data_mapping',
|
11 |
+
'connector_sync_settings',
|
12 |
+
'connector_roi_tracking',
|
13 |
+
'connector_lost_baskets',
|
14 |
+
'connector_reviews',
|
15 |
+
'connector_dynamic_content',
|
16 |
+
'connector_transactional_emails',
|
17 |
+
'connector_configuration',
|
18 |
+
'connector_developer_settings'
|
19 |
+
);
|
20 |
Â
|
21 |
Â
/**
|
22 |
Â
* get the website domain.
|
30 |
Â
|
31 |
Â
/**
|
32 |
Â
* api username.
|
33 |
+
*
|
34 |
Â
* @return string
|
35 |
Â
*/
|
36 |
Â
public function getApiUsername()
|
40 |
Â
|
41 |
Â
/**
|
42 |
Â
* check if the cron is running.
|
43 |
+
*
|
44 |
Â
* @return bool
|
45 |
Â
*/
|
46 |
Â
public function getCronInstalled()
|
47 |
Â
{
|
48 |
+
return (Mage::helper('ddg')->getCronInstalled()) ? '1' : '0';
|
49 |
Â
}
|
50 |
Â
|
51 |
Â
/*
|
56 |
Â
$section = $this->getRequest()->getParam('section');
|
57 |
Â
|
58 |
Â
// not not track other sections
|
59 |
+
if ( ! in_array($section, $this->sections)) {
|
60 |
Â
return;
|
61 |
+
}
|
62 |
Â
|
63 |
Â
$features = array(
|
64 |
+
'customer_sync' => $this->getCustomerSync(),
|
65 |
+
'guest_sync' => $this->getGuestSync(),
|
66 |
Â
'subscriber_sync' => $this->getSubscriberSync(),
|
67 |
+
'order_sync' => $this->getOrderSync(),
|
68 |
+
'catalog_sync' => $this->getCatalogSync(),
|
69 |
+
'dotmailer_smtp' => $this->getDotmailerSmtp(),
|
70 |
+
'roi' => $this->getRoi()
|
71 |
Â
);
|
72 |
Â
|
73 |
Â
return json_encode($features);
|
111 |
Â
|
112 |
Â
/**
|
113 |
Â
* magento version.
|
114 |
+
*
|
115 |
Â
* @return string
|
116 |
Â
*/
|
117 |
Â
public function getMageVersion()
|
121 |
Â
|
122 |
Â
/**
|
123 |
Â
* connector version.
|
124 |
+
*
|
125 |
Â
* @return string
|
126 |
Â
*/
|
127 |
Â
public function getConnectorVersion()
|
129 |
Â
return Mage::helper('ddg')->getConnectorVersion();
|
130 |
Â
}
|
131 |
Â
|
132 |
+
/**
|
133 |
+
* Get the api and website names.
|
134 |
+
*
|
135 |
+
* @return mixed|string
|
136 |
+
*/
|
137 |
+
public function getWebsiteNames()
|
138 |
+
{
|
139 |
+
|
140 |
+
$data = Mage::helper('ddg')->getStringWebsiteApiAccounts();
|
141 |
+
|
142 |
+
return $data;
|
143 |
+
}
|
144 |
+
|
145 |
+
/**
|
146 |
+
* Get the account email.
|
147 |
+
*
|
148 |
+
* @return mixed
|
149 |
+
*/
|
150 |
+
public function getAccountEmail()
|
151 |
+
{
|
152 |
+
return Mage::helper('ddg')->getAccountEmail();
|
153 |
+
}
|
154 |
+
|
155 |
+
|
156 |
+
/**
|
157 |
+
* Use the beacon only on the api connector section.
|
158 |
+
*
|
159 |
+
* @return string
|
160 |
+
*/
|
161 |
+
protected function _toHtml()
|
162 |
+
{
|
163 |
+
$section = $this->getAction()->getRequest()->getParam('section', false);
|
164 |
+
|
165 |
+
if ($section == 'connector_api_credentials') {
|
166 |
+
return parent::_toHtml();
|
167 |
+
} else {
|
168 |
+
return '';
|
169 |
+
}
|
170 |
+
}
|
171 |
Â
}
|
@@ -1,24 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class Dotdigitalgroup_Email_Block_Adminhtml_System_Sms_Smsmessagefour extends Mage_Adminhtml_Block_System_Config_Form_Field
|
4 |
-
{
|
5 |
-
const DEFAULT_TEXT = 'Default SMS Text';
|
6 |
-
|
7 |
-
/**
|
8 |
-
* SMS insert links.
|
9 |
-
* @param Varien_Data_Form_Element_Abstract $element
|
10 |
-
*
|
11 |
-
* @return string
|
12 |
-
*/
|
13 |
-
protected function _getElementHtml(Varien_Data_Form_Element_Abstract$element)
|
14 |
-
{
|
15 |
-
$element->setData('placeholder', self::DEFAULT_TEXT);
|
16 |
-
$element->setData('after_element_html',
|
17 |
-
"<a href='#' onclick=\"injectText('connector_automation_studio_sms_sms_four_message', '{{var order_number}}');return false;\">Insert Order Number</a>
|
18 |
-
<a href='#' onclick=\"injectText('connector_automation_studio_sms_sms_four_message', '{{var customer_name}}');return false;\">Insert Customer Name</a>"
|
19 |
-
);
|
20 |
-
return parent::_getElementHtml($element);
|
21 |
-
}
|
22 |
-
|
23 |
-
|
24 |
-
}
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
@@ -1,46 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class Dotdigitalgroup_Email_Block_Adminhtml_System_Sms_Smsmessageone extends Mage_Adminhtml_Block_System_Config_Form_Field
|
4 |
-
{
|
5 |
-
const DEFAULT_TEXT = 'Default SMS Text';
|
6 |
-
|
7 |
-
/**
|
8 |
-
* SMS insert links.
|
9 |
-
*
|
10 |
-
* @param Varien_Data_Form_Element_Abstract $element
|
11 |
-
*
|
12 |
-
* @return string
|
13 |
-
*/
|
14 |
-
protected function _getElementHtml(Varien_Data_Form_Element_Abstract$element)
|
15 |
-
{
|
16 |
-
$element->setData('placeholder', self::DEFAULT_TEXT);
|
17 |
-
$element->setData('after_element_html',
|
18 |
-
|
19 |
-
"<a href='#' onclick=\"injectText('connector_automation_studio_sms_sms_one_message', '{{var order_number}}');return false;\">Insert Order Number</a>
|
20 |
-
<a href='#' onclick=\"injectText('connector_automation_studio_sms_sms_one_message', '{{var customer_name}}');return false;\">Insert Customer Name</a>
|
21 |
-
|
22 |
-
<script type='text/javascript'>
|
23 |
-
function injectText(element,value){
|
24 |
-
var element_dom=document.getElementById(element);
|
25 |
-
if(document.selection){
|
26 |
-
element_dom.focus();
|
27 |
-
sel=document.selection.createRange();
|
28 |
-
sel.text=value;
|
29 |
-
return;
|
30 |
-
}if(element_dom.selectionStart||element_dom.selectionStart=='0'){
|
31 |
-
var t_start=element_dom.selectionStart;
|
32 |
-
var t_end=element_dom.selectionEnd;
|
33 |
-
var val_start=element_dom.value.substring(0,t_start);
|
34 |
-
var val_end=element_dom.value.substring(t_end,element_dom.value.length);
|
35 |
-
element_dom.value=val_start+value+val_end;
|
36 |
-
}else{
|
37 |
-
element_dom.value+=value;
|
38 |
-
}
|
39 |
-
}
|
40 |
-
</script>
|
41 |
-
");
|
42 |
-
return parent::_getElementHtml($element);
|
43 |
-
}
|
44 |
-
|
45 |
-
|
46 |
-
}
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
@@ -1,26 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class Dotdigitalgroup_Email_Block_Adminhtml_System_Sms_Smsmessagethree extends Mage_Adminhtml_Block_System_Config_Form_Field
|
4 |
-
{
|
5 |
-
const DEFAULT_TEXT = 'Default SMS Text';
|
6 |
-
|
7 |
-
/**
|
8 |
-
* SMS insert links.
|
9 |
-
*
|
10 |
-
* @param Varien_Data_Form_Element_Abstract $element
|
11 |
-
*
|
12 |
-
* @return string
|
13 |
-
*/
|
14 |
-
protected function _getElementHtml(Varien_Data_Form_Element_Abstract$element)
|
15 |
-
{
|
16 |
-
$element->setData('placeholder', self::DEFAULT_TEXT);
|
17 |
-
$element->setData('after_element_html',
|
18 |
-
|
19 |
-
"<a href='#' onclick=\"injectText('connector_automation_studio_sms_sms_three_message', '{{var order_number}}');return false;\">Insert Order Number</a>
|
20 |
-
<a href='#' onclick=\"injectText('connector_automation_studio_sms_sms_three_message', '{{var customer_name}}');return false;\">Insert Customer Name</a>"
|
21 |
-
);
|
22 |
-
return parent::_getElementHtml($element);
|
23 |
-
}
|
24 |
-
|
25 |
-
|
26 |
-
}
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
@@ -1,25 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class Dotdigitalgroup_Email_Block_Adminhtml_System_Sms_Smsmessagetwo extends Mage_Adminhtml_Block_System_Config_Form_Field
|
4 |
-
{
|
5 |
-
const DEFAULT_TEXT = 'Default SMS Text';
|
6 |
-
|
7 |
-
/**
|
8 |
-
* SMS insert links.
|
9 |
-
*
|
10 |
-
* @param Varien_Data_Form_Element_Abstract $element
|
11 |
-
*
|
12 |
-
* @return string
|
13 |
-
*/
|
14 |
-
protected function _getElementHtml(Varien_Data_Form_Element_Abstract$element)
|
15 |
-
{
|
16 |
-
$element->setData('placeholder', self::DEFAULT_TEXT);
|
17 |
-
$element->setData('after_element_html',
|
18 |
-
"<a href='#' onclick=\"injectText('connector_automation_studio_sms_sms_two_message', '{{var order_number}}');return false;\">Insert Order Number</a>
|
19 |
-
<a href='#' onclick=\"injectText('connector_automation_studio_sms_sms_two_message', '{{var customer_name}}');return false;\">Insert Customer Name</a>"
|
20 |
-
);
|
21 |
-
return parent::_getElementHtml($element);
|
22 |
-
}
|
23 |
-
|
24 |
-
|
25 |
-
}
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
@@ -1,29 +1,45 @@
|
|
1 |
Â
<?php
|
2 |
-
|
Â
|
|
Â
|
|
3 |
Â
{
|
Â
|
|
4 |
Â
/**
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
Â
|
|
Â
|
|
12 |
Â
{
|
13 |
Â
$baseUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
|
14 |
Â
$website = Mage::app()->getRequest()->getParam('website', false);
|
15 |
Â
|
16 |
Â
if ($website) {
|
17 |
Â
$website = Mage::app()->getWebsite($website);
|
18 |
-
$baseUrl
|
19 |
Â
}
|
20 |
Â
$helper = Mage::helper('ddg');
|
21 |
-
$passcode = $helper->getWebsiteConfig(
|
22 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
23 |
Â
|
24 |
-
if(!strlen($passcode))
|
Â
|
|
Â
|
|
25 |
Â
|
26 |
-
$text = sprintf(
|
Â
|
|
Â
|
|
Â
|
|
27 |
Â
|
28 |
Â
$element->setData('value', $text);
|
29 |
Â
|
1 |
Â
<?php
|
2 |
+
|
3 |
+
class Dotdigitalgroup_Email_Block_Adminhtml_System_Url_Creditmemoupdate
|
4 |
+
extends Mage_Adminhtml_Block_System_Config_Form_Field
|
5 |
Â
{
|
6 |
+
|
7 |
Â
/**
|
8 |
+
* Generate the urls.
|
9 |
+
*
|
10 |
+
* @param Varien_Data_Form_Element_Abstract $element
|
11 |
+
*
|
12 |
+
* @return string
|
13 |
+
* @throws Mage_Core_Exception
|
14 |
+
*/
|
15 |
+
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element
|
16 |
+
)
|
17 |
Â
{
|
18 |
Â
$baseUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
|
19 |
Â
$website = Mage::app()->getRequest()->getParam('website', false);
|
20 |
Â
|
21 |
Â
if ($website) {
|
22 |
Â
$website = Mage::app()->getWebsite($website);
|
23 |
+
$baseUrl = $website->getConfig('web/secure/base_url');
|
24 |
Â
}
|
25 |
Â
$helper = Mage::helper('ddg');
|
26 |
+
$passcode = $helper->getWebsiteConfig(
|
27 |
+
Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_DYNAMIC_CONTENT_PASSCODE,
|
28 |
+
$website
|
29 |
+
);
|
30 |
+
$orderId = $helper->getWebsiteConfig(
|
31 |
+
Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_MAPPING_LAST_ORDER_ID,
|
32 |
+
$website
|
33 |
+
);
|
34 |
Â
|
35 |
+
if ( ! strlen($passcode)) {
|
36 |
+
$passcode = '[PLEASE SET UP A PASSCODE]';
|
37 |
+
}
|
38 |
Â
|
39 |
+
$text = sprintf(
|
40 |
+
'%sconnector/creditmemo/update/code/%s/order_id/@%s@', $baseUrl,
|
41 |
+
$passcode, $orderId
|
42 |
+
);
|
43 |
Â
|
44 |
Â
$element->setData('value', $text);
|
45 |
Â
|
@@ -1,28 +1,44 @@
|
|
1 |
Â
<?php
|
2 |
-
|
Â
|
|
Â
|
|
3 |
Â
{
|
Â
|
|
4 |
Â
/**
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
Â
|
|
Â
|
|
12 |
Â
{
|
13 |
Â
$baseUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
|
14 |
Â
$website = Mage::app()->getRequest()->getParam('website', false);
|
15 |
Â
|
16 |
Â
if ($website) {
|
17 |
Â
$website = Mage::app()->getWebsite($website);
|
18 |
-
$baseUrl
|
19 |
Â
}
|
20 |
Â
$helper = Mage::helper('ddg');
|
21 |
-
$passcode = $helper->getWebsiteConfig(
|
22 |
-
|
23 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
24 |
Â
|
25 |
-
$text = sprintf(
|
Â
|
|
Â
|
|
Â
|
|
26 |
Â
$element->setData('value', $text);
|
27 |
Â
|
28 |
Â
return parent::_getElementHtml($element);
|
1 |
Â
<?php
|
2 |
+
|
3 |
+
class Dotdigitalgroup_Email_Block_Adminhtml_System_Url_Creditmemoupdateguest
|
4 |
+
extends Mage_Adminhtml_Block_System_Config_Form_Field
|
5 |
Â
{
|
6 |
+
|
7 |
Â
/**
|
8 |
+
* Generate the urls.
|
9 |
+
*
|
10 |
+
* @param Varien_Data_Form_Element_Abstract $element
|
11 |
+
*
|
12 |
+
* @return string
|
13 |
+
* @throws Mage_Core_Exception
|
14 |
+
*/
|
15 |
+
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element
|
16 |
+
)
|
17 |
Â
{
|
18 |
Â
$baseUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
|
19 |
Â
$website = Mage::app()->getRequest()->getParam('website', false);
|
20 |
Â
|
21 |
Â
if ($website) {
|
22 |
Â
$website = Mage::app()->getWebsite($website);
|
23 |
+
$baseUrl = $website->getConfig('web/secure/base_url');
|
24 |
Â
}
|
25 |
Â
$helper = Mage::helper('ddg');
|
26 |
+
$passcode = $helper->getWebsiteConfig(
|
27 |
+
Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_DYNAMIC_CONTENT_PASSCODE,
|
28 |
+
$website
|
29 |
+
);
|
30 |
+
$orderId = $helper->getWebsiteConfig(
|
31 |
+
Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_MAPPING_LAST_ORDER_ID,
|
32 |
+
$website
|
33 |
+
);
|
34 |
+
if ( ! strlen($passcode)) {
|
35 |
+
$passcode = '[PLEASE SET UP A PASSCODE]';
|
36 |
+
}
|
37 |
Â
|
38 |
+
$text = sprintf(
|
39 |
+
'%sconnector/creditmemo/updateguest/code/%s/order_id/@%s@',
|
40 |
+
$baseUrl, $passcode, $orderId
|
41 |
+
);
|
42 |
Â
$element->setData('value', $text);
|
43 |
Â
|
44 |
Â
return parent::_getElementHtml($element);
|
@@ -1,32 +1,45 @@
|
|
1 |
Â
<?php
|
2 |
Â
|
3 |
-
class Dotdigitalgroup_Email_Block_Adminhtml_System_Url_Customerconfirmation
|
Â
|
|
4 |
Â
{
|
5 |
Â
|
6 |
Â
/**
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element
|
Â
|
|
15 |
Â
{
|
16 |
Â
$baseUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
|
17 |
Â
$website = Mage::app()->getRequest()->getParam('website', false);
|
18 |
Â
|
19 |
Â
if ($website) {
|
20 |
Â
$website = Mage::app()->getWebsite($website);
|
21 |
-
$baseUrl
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
22 |
Â
}
|
23 |
-
$helper = Mage::helper('ddg');
|
24 |
-
$passcode = $helper->getWebsiteConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_DYNAMIC_CONTENT_PASSCODE, $website);
|
25 |
-
$customerId = $helper->getWebsiteConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_MAPPING_CUSTOMER_ID, $website);
|
26 |
-
|
27 |
-
if(!strlen($passcode)) $passcode = '[PLEASE SET UP A PASSCODE]';
|
28 |
Â
|
29 |
-
$text = sprintf(
|
Â
|
|
Â
|
|
Â
|
|
30 |
Â
$element->setData('value', $text);
|
31 |
Â
|
32 |
Â
return parent::_getElementHtml($element);
|
1 |
Â
<?php
|
2 |
Â
|
3 |
+
class Dotdigitalgroup_Email_Block_Adminhtml_System_Url_Customerconfirmation
|
4 |
+
extends Mage_Adminhtml_Block_System_Config_Form_Field
|
5 |
Â
{
|
6 |
Â
|
7 |
Â
/**
|
8 |
+
* Generate the urls.
|
9 |
+
*
|
10 |
+
* @param Varien_Data_Form_Element_Abstract $element
|
11 |
+
*
|
12 |
+
* @return string
|
13 |
+
* @throws Mage_Core_Exception
|
14 |
+
*/
|
15 |
+
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element
|
16 |
+
)
|
17 |
Â
{
|
18 |
Â
$baseUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
|
19 |
Â
$website = Mage::app()->getRequest()->getParam('website', false);
|
20 |
Â
|
21 |
Â
if ($website) {
|
22 |
Â
$website = Mage::app()->getWebsite($website);
|
23 |
+
$baseUrl = $website->getConfig('web/secure/base_url');
|
24 |
+
}
|
25 |
+
$helper = Mage::helper('ddg');
|
26 |
+
$passcode = $helper->getWebsiteConfig(
|
27 |
+
Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_DYNAMIC_CONTENT_PASSCODE,
|
28 |
+
$website
|
29 |
+
);
|
30 |
+
$customerId = $helper->getWebsiteConfig(
|
31 |
+
Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_MAPPING_CUSTOMER_ID,
|
32 |
+
$website
|
33 |
+
);
|
34 |
+
|
35 |
+
if ( ! strlen($passcode)) {
|
36 |
+
$passcode = '[PLEASE SET UP A PASSCODE]';
|
37 |
Â
}
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
38 |
Â
|
39 |
+
$text = sprintf(
|
40 |
+
'%sconnector/customer/confirmation/code/%s/customer_id/@%s@',
|
41 |
+
$baseUrl, $passcode, $customerId
|
42 |
+
);
|
43 |
Â
$element->setData('value', $text);
|
44 |
Â
|
45 |
Â
return parent::_getElementHtml($element);
|
@@ -1,32 +1,45 @@
|
|
1 |
Â
<?php
|
2 |
Â
|
3 |
-
class Dotdigitalgroup_Email_Block_Adminhtml_System_Url_Customerconfirmed
|
Â
|
|
4 |
Â
{
|
5 |
Â
|
6 |
Â
/**
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element
|
Â
|
|
15 |
Â
{
|
16 |
Â
$baseUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
|
17 |
Â
$website = Mage::app()->getRequest()->getParam('website', false);
|
18 |
Â
|
19 |
Â
if ($website) {
|
20 |
Â
$website = Mage::app()->getWebsite($website);
|
21 |
-
$baseUrl
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
22 |
Â
}
|
23 |
-
$helper = Mage::helper('ddg');
|
24 |
-
$passcode = $helper->getWebsiteConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_DYNAMIC_CONTENT_PASSCODE, $website);
|
25 |
-
$customerId = $helper->getWebsiteConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_MAPPING_CUSTOMER_ID, $website);
|
26 |
-
|
27 |
-
if(!strlen($passcode)) $passcode = '[PLEASE SET UP A PASSCODE]';
|
28 |
Â
|
29 |
-
$text = sprintf(
|
Â
|
|
Â
|
|
Â
|
|
30 |
Â
$element->setData('value', $text);
|
31 |
Â
|
32 |
Â
return parent::_getElementHtml($element);
|
1 |
Â
<?php
|
2 |
Â
|
3 |
+
class Dotdigitalgroup_Email_Block_Adminhtml_System_Url_Customerconfirmed
|
4 |
+
extends Mage_Adminhtml_Block_System_Config_Form_Field
|
5 |
Â
{
|
6 |
Â
|
7 |
Â
/**
|
8 |
+
* Generate the urls.
|
9 |
+
*
|
10 |
+
* @param Varien_Data_Form_Element_Abstract $element
|
11 |
+
*
|
12 |
+
* @return string
|
13 |
+
* @throws Mage_Core_Exception
|
14 |
+
*/
|
15 |
+
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element
|
16 |
+
)
|
17 |
Â
{
|
18 |
Â
$baseUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
|
19 |
Â
$website = Mage::app()->getRequest()->getParam('website', false);
|
20 |
Â
|
21 |
Â
if ($website) {
|
22 |
Â
$website = Mage::app()->getWebsite($website);
|
23 |
+
$baseUrl = $website->getConfig('web/secure/base_url');
|
24 |
+
}
|
25 |
+
$helper = Mage::helper('ddg');
|
26 |
+
$passcode = $helper->getWebsiteConfig(
|
27 |
+
Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_DYNAMIC_CONTENT_PASSCODE,
|
28 |
+
$website
|
29 |
+
);
|
30 |
+
$customerId = $helper->getWebsiteConfig(
|
31 |
+
Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_MAPPING_CUSTOMER_ID,
|
32 |
+
$website
|
33 |
+
);
|
34 |
+
|
35 |
+
if ( ! strlen($passcode)) {
|
36 |
+
$passcode = '[PLEASE SET UP A PASSCODE]';
|
37 |
Â
}
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
38 |
Â
|
39 |
+
$text = sprintf(
|
40 |
+
'%sconnector/customer/confirmed/code/%s/customer_id/@%s@', $baseUrl,
|
41 |
+
$passcode, $customerId
|
42 |
+
);
|
43 |
Â
$element->setData('value', $text);
|
44 |
Â
|
45 |
Â
return parent::_getElementHtml($element);
|
@@ -1,32 +1,45 @@
|
|
1 |
Â
<?php
|
2 |
Â
|
3 |
-
class Dotdigitalgroup_Email_Block_Adminhtml_System_Url_Customernew
|
Â
|
|
4 |
Â
{
|
5 |
Â
|
6 |
Â
/**
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element
|
Â
|
|
15 |
Â
{
|
16 |
Â
$baseUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
|
17 |
Â
$website = Mage::app()->getRequest()->getParam('website', false);
|
18 |
Â
|
19 |
Â
if ($website) {
|
20 |
Â
$website = Mage::app()->getWebsite($website);
|
21 |
-
$baseUrl
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
22 |
Â
}
|
23 |
-
$helper = Mage::helper('ddg');
|
24 |
-
$passcode = $helper->getWebsiteConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_DYNAMIC_CONTENT_PASSCODE, $website);
|
25 |
-
$customerId = $helper->getWebsiteConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_MAPPING_CUSTOMER_ID, $website);
|
26 |
-
|
27 |
-
if(!strlen($passcode)) $passcode = '[PLEASE SET UP A PASSCODE]';
|
28 |
Â
|
29 |
-
$text = sprintf(
|
Â
|
|
Â
|
|
Â
|
|
30 |
Â
$element->setData('value', $text);
|
31 |
Â
|
32 |
Â
return parent::_getElementHtml($element);
|
1 |
Â
<?php
|
2 |
Â
|
3 |
+
class Dotdigitalgroup_Email_Block_Adminhtml_System_Url_Customernew
|
4 |
+
extends Mage_Adminhtml_Block_System_Config_Form_Field
|
5 |
Â
{
|
6 |
Â
|
7 |
Â
/**
|
8 |
+
* Generate the urls.
|
9 |
+
*
|
10 |
+
* @param Varien_Data_Form_Element_Abstract $element
|
11 |
+
*
|
12 |
+
* @return string
|
13 |
+
* @throws Mage_Core_Exception
|
14 |
+
*/
|
15 |
+
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element
|
16 |
+
)
|
17 |
Â
{
|
18 |
Â
$baseUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
|
19 |
Â
$website = Mage::app()->getRequest()->getParam('website', false);
|
20 |
Â
|
21 |
Â
if ($website) {
|
22 |
Â
$website = Mage::app()->getWebsite($website);
|
23 |
+
$baseUrl = $website->getConfig('web/secure/base_url');
|
24 |
+
}
|
25 |
+
$helper = Mage::helper('ddg');
|
26 |
+
$passcode = $helper->getWebsiteConfig(
|
27 |
+
Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_DYNAMIC_CONTENT_PASSCODE,
|
28 |
+
$website
|
29 |
+
);
|
30 |
+
$customerId = $helper->getWebsiteConfig(
|
31 |
+
Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_MAPPING_CUSTOMER_ID,
|
32 |
+
$website
|
33 |
+
);
|
34 |
+
|
35 |
+
if ( ! strlen($passcode)) {
|
36 |
+
$passcode = '[PLEASE SET UP A PASSCODE]';
|
37 |
Â
}
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
38 |
Â
|
39 |
+
$text = sprintf(
|
40 |
+
'%sconnector/customer/new/code/%s/customer_id/@%s@', $baseUrl,
|
41 |
+
$passcode, $customerId
|
42 |
+
);
|
43 |
Â
$element->setData('value', $text);
|
44 |
Â
|
45 |
Â
return parent::_getElementHtml($element);
|
@@ -1,31 +1,45 @@
|
|
1 |
Â
<?php
|
2 |
Â
|
3 |
-
class Dotdigitalgroup_Email_Block_Adminhtml_System_Url_Invoiceupdate
|
Â
|
|
4 |
Â
{
|
Â
|
|
5 |
Â
/**
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element
|
Â
|
|
14 |
Â
{
|
15 |
Â
$baseUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
|
16 |
Â
$website = Mage::app()->getRequest()->getParam('website', false);
|
17 |
Â
|
18 |
Â
if ($website) {
|
19 |
Â
$website = Mage::app()->getWebsite($website);
|
20 |
-
$baseUrl
|
21 |
Â
}
|
22 |
Â
$helper = Mage::helper('ddg');
|
23 |
-
$passcode = $helper->getWebsiteConfig(
|
24 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
25 |
Â
|
26 |
-
if(!strlen($passcode))
|
Â
|
|
Â
|
|
27 |
Â
|
28 |
-
$text = sprintf(
|
Â
|
|
Â
|
|
Â
|
|
29 |
Â
$element->setData('value', $text);
|
30 |
Â
|
31 |
Â
return parent::_getElementHtml($element);
|
1 |
Â
<?php
|
2 |
Â
|
3 |
+
class Dotdigitalgroup_Email_Block_Adminhtml_System_Url_Invoiceupdate
|
4 |
+
extends Mage_Adminhtml_Block_System_Config_Form_Field
|
5 |
Â
{
|
6 |
+
|
7 |
Â
/**
|
8 |
+
* Generate the urls.
|
9 |
+
*
|
10 |
+
* @param Varien_Data_Form_Element_Abstract $element
|
11 |
+
*
|
12 |
+
* @return string
|
13 |
+
* @throws Mage_Core_Exception
|
14 |
+
*/
|
15 |
+
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element
|
16 |
+
)
|
17 |
Â
{
|
18 |
Â
$baseUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
|
19 |
Â
$website = Mage::app()->getRequest()->getParam('website', false);
|
20 |
Â
|
21 |
Â
if ($website) {
|
22 |
Â
$website = Mage::app()->getWebsite($website);
|
23 |
+
$baseUrl = $website->getConfig('web/secure/base_url');
|
24 |
Â
}
|
25 |
Â
$helper = Mage::helper('ddg');
|
26 |
+
$passcode = $helper->getWebsiteConfig(
|
27 |
+
Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_DYNAMIC_CONTENT_PASSCODE,
|
28 |
+
$website
|
29 |
+
);
|
30 |
+
$orderId = $helper->getWebsiteConfig(
|
31 |
+
Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_MAPPING_LAST_ORDER_ID,
|
32 |
+
$website
|
33 |
+
);
|
34 |
Â
|
35 |
+
if ( ! strlen($passcode)) {
|
36 |
+
$passcode = '[PLEASE SET UP A PASSCODE]';
|
37 |
+
}
|
38 |
Â
|
39 |
+
$text = sprintf(
|
40 |
+
'%sconnector/invoice/update/code/%s/order_id/@%s@', $baseUrl,
|
41 |
+
$passcode, $orderId
|
42 |
+
);
|
43 |
Â
$element->setData('value', $text);
|
44 |
Â
|
45 |
Â
return parent::_getElementHtml($element);
|
@@ -1,31 +1,45 @@
|
|
1 |
Â
<?php
|
2 |
Â
|
3 |
-
class Dotdigitalgroup_Email_Block_Adminhtml_System_Url_Invoiceupdateguest
|
Â
|
|
4 |
Â
{
|
Â
|
|
5 |
Â
/**
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element
|
Â
|
|
14 |
Â
{
|
15 |
Â
$baseUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
|
16 |
Â
$website = Mage::app()->getRequest()->getParam('website', false);
|
17 |
Â
|
18 |
Â
if ($website) {
|
19 |
Â
$website = Mage::app()->getWebsite($website);
|
20 |
-
$baseUrl
|
21 |
Â
}
|
22 |
Â
$helper = Mage::helper('ddg');
|
23 |
-
$passcode = $helper->getWebsiteConfig(
|
24 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
25 |
Â
|
26 |
-
if(!strlen($passcode))
|
Â
|
|
Â
|
|
27 |
Â
|
28 |
-
$text = sprintf(
|
Â
|
|
Â
|
|
Â
|
|
29 |
Â
$element->setData('value', $text);
|
30 |
Â
|
31 |
Â
return parent::_getElementHtml($element);
|
1 |
Â
<?php
|
2 |
Â
|
3 |
+
class Dotdigitalgroup_Email_Block_Adminhtml_System_Url_Invoiceupdateguest
|
4 |
+
extends Mage_Adminhtml_Block_System_Config_Form_Field
|
5 |
Â
{
|
6 |
+
|
7 |
Â
/**
|
8 |
+
* Generate the urls.
|
9 |
+
*
|
10 |
+
* @param Varien_Data_Form_Element_Abstract $element
|
11 |
+
*
|
12 |
+
* @return string
|
13 |
+
* @throws Mage_Core_Exception
|
14 |
+
*/
|
15 |
+
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element
|
16 |
+
)
|
17 |
Â
{
|
18 |
Â
$baseUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
|
19 |
Â
$website = Mage::app()->getRequest()->getParam('website', false);
|
20 |
Â
|
21 |
Â
if ($website) {
|
22 |
Â
$website = Mage::app()->getWebsite($website);
|
23 |
+
$baseUrl = $website->getConfig('web/secure/base_url');
|
24 |
Â
}
|
25 |
Â
$helper = Mage::helper('ddg');
|
26 |
+
$passcode = $helper->getWebsiteConfig(
|
27 |
+
Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_DYNAMIC_CONTENT_PASSCODE,
|
28 |
+
$website
|
29 |
+
);
|
30 |
+
$orderId = $helper->getWebsiteConfig(
|
31 |
+
Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_MAPPING_LAST_ORDER_ID,
|
32 |
+
$website
|
33 |
+
);
|
34 |
Â
|
35 |
+
if ( ! strlen($passcode)) {
|
36 |
+
$passcode = '[PLEASE SET UP A PASSCODE]';
|
37 |
+
}
|
38 |
Â
|
39 |
+
$text = sprintf(
|
40 |
+
'%sconnector/invoice/updateguest/code/%s/order_id/@%s@', $baseUrl,
|
41 |
+
$passcode, $orderId
|
42 |
+
);
|
43 |
Â
$element->setData('value', $text);
|
44 |
Â
|
45 |
Â
return parent::_getElementHtml($element);
|
@@ -1,16 +1,19 @@
|
|
1 |
Â
<?php
|
2 |
Â
|
3 |
-
class Dotdigitalgroup_Email_Block_Adminhtml_System_Url_Newcreditmemo
|
Â
|
|
4 |
Â
{
|
Â
|
|
5 |
Â
/**
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element
|
Â
|
|
14 |
Â
{
|
15 |
Â
|
16 |
Â
$baseUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
|
@@ -18,16 +21,27 @@ class Dotdigitalgroup_Email_Block_Adminhtml_System_Url_Newcreditmemo extends Mag
|
|
18 |
Â
|
19 |
Â
if ($website) {
|
20 |
Â
$website = Mage::app()->getWebsite($website);
|
21 |
-
$baseUrl
|
22 |
Â
}
|
23 |
Â
$helper = Mage::helper('ddg');
|
24 |
-
$passcode = $helper->getWebsiteConfig(
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
29 |
Â
|
30 |
-
$text = sprintf(
|
Â
|
|
Â
|
|
Â
|
|
31 |
Â
$element->setData('value', $text);
|
32 |
Â
|
33 |
Â
return parent::_getElementHtml($element);
|
1 |
Â
<?php
|
2 |
Â
|
3 |
+
class Dotdigitalgroup_Email_Block_Adminhtml_System_Url_Newcreditmemo
|
4 |
+
extends Mage_Adminhtml_Block_System_Config_Form_Field
|
5 |
Â
{
|
6 |
+
|
7 |
Â
/**
|
8 |
+
* Generate the urls.
|
9 |
+
*
|
10 |
+
* @param Varien_Data_Form_Element_Abstract $element
|
11 |
+
*
|
12 |
+
* @return string
|
13 |
+
* @throws Mage_Core_Exception
|
14 |
+
*/
|
15 |
+
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element
|
16 |
+
)
|
17 |
Â
{
|
18 |
Â
|
19 |
Â
$baseUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
|
21 |
Â
|
22 |
Â
if ($website) {
|
23 |
Â
$website = Mage::app()->getWebsite($website);
|
24 |
+
$baseUrl = $website->getConfig('web/secure/base_url');
|
25 |
Â
}
|
26 |
Â
$helper = Mage::helper('ddg');
|
27 |
+
$passcode = $helper->getWebsiteConfig(
|
28 |
+
Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_DYNAMIC_CONTENT_PASSCODE,
|
29 |
+
$website
|
30 |
+
);
|
31 |
+
$orderId = $helper->getWebsiteConfig(
|
32 |
+
Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_MAPPING_LAST_ORDER_ID,
|
33 |
+
$website
|
34 |
+
);
|
35 |
+
|
36 |
+
|
37 |
+
if ( ! strlen($passcode)) {
|
38 |
+
$passcode = '[PLEASE SET UP A PASSCODE]';
|
39 |
+
}
|
40 |
Â
|
41 |
+
$text = sprintf(
|
42 |
+
'%sconnector/creditmemo/new/code/%s/order_id/@%s@', $baseUrl,
|
43 |
+
$passcode, $orderId
|
44 |
+
);
|
45 |
Â
$element->setData('value', $text);
|
46 |
Â
|
47 |
Â
return parent::_getElementHtml($element);
|
@@ -1,32 +1,46 @@
|
|
1 |
Â
<?php
|
2 |
Â
|
3 |
-
class Dotdigitalgroup_Email_Block_Adminhtml_System_Url_Newcreditmemoguest
|
Â
|
|
4 |
Â
{
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
Â
|
|
Â
|
|
14 |
Â
{
|
15 |
Â
$baseUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
|
16 |
Â
$website = Mage::app()->getRequest()->getParam('website', false);
|
17 |
Â
|
18 |
Â
if ($website) {
|
19 |
Â
$website = Mage::app()->getWebsite($website);
|
20 |
-
$baseUrl
|
21 |
Â
}
|
22 |
Â
$helper = Mage::helper('ddg');
|
23 |
-
$passcode = $helper->getWebsiteConfig(
|
24 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
25 |
Â
|
26 |
Â
|
27 |
-
if(!strlen($passcode))
|
Â
|
|
Â
|
|
28 |
Â
|
29 |
-
$text = sprintf(
|
Â
|
|
Â
|
|
Â
|
|
30 |
Â
$element->setData('value', $text);
|
31 |
Â
|
32 |
Â
return parent::_getElementHtml($element);
|
1 |
Â
<?php
|
2 |
Â
|
3 |
+
class Dotdigitalgroup_Email_Block_Adminhtml_System_Url_Newcreditmemoguest
|
4 |
+
extends Mage_Adminhtml_Block_System_Config_Form_Field
|
5 |
Â
{
|
6 |
+
|
7 |
+
/**
|
8 |
+
* Generate the urls.
|
9 |
+
*
|
10 |
+
* @param Varien_Data_Form_Element_Abstract $element
|
11 |
+
*
|
12 |
+
* @return string
|
13 |
+
* @throws Mage_Core_Exception
|
14 |
+
*/
|
15 |
+
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element
|
16 |
+
)
|
17 |
Â
{
|
18 |
Â
$baseUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
|
19 |
Â
$website = Mage::app()->getRequest()->getParam('website', false);
|
20 |
Â
|
21 |
Â
if ($website) {
|
22 |
Â
$website = Mage::app()->getWebsite($website);
|
23 |
+
$baseUrl = $website->getConfig('web/secure/base_url');
|
24 |
Â
}
|
25 |
Â
$helper = Mage::helper('ddg');
|
26 |
+
$passcode = $helper->getWebsiteConfig(
|
27 |
+
Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_DYNAMIC_CONTENT_PASSCODE,
|
28 |
+
$website
|
29 |
+
);
|
30 |
+
$orderId = $helper->getWebsiteConfig(
|
31 |
+
Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_MAPPING_LAST_ORDER_ID,
|
32 |
+
$website
|
33 |
+
);
|
34 |
Â
|
35 |
Â
|
36 |
+
if ( ! strlen($passcode)) {
|
37 |
+
$passcode = '[PLEASE SET UP A PASSCODE]';
|
38 |
+
}
|
39 |
Â
|
40 |
+
$text = sprintf(
|
41 |
+
'%sconnector/creditmemo/newguest/code/%s/order_id/@%s@', $baseUrl,
|
42 |
+
$passcode, $orderId
|
43 |
+
);
|
44 |
Â
$element->setData('value', $text);
|
45 |
Â
|
46 |
Â
return parent::_getElementHtml($element);
|
@@ -1,32 +1,46 @@
|
|
1 |
Â
<?php
|
2 |
Â
|
3 |
-
class Dotdigitalgroup_Email_Block_Adminhtml_System_Url_Newinvoice
|
Â
|
|
4 |
Â
{
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
Â
|
|
Â
|
|
14 |
Â
{
|
15 |
Â
$baseUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
|
16 |
Â
$website = Mage::app()->getRequest()->getParam('website', false);
|
17 |
Â
|
18 |
Â
if ($website) {
|
19 |
Â
$website = Mage::app()->getWebsite($website);
|
20 |
-
$baseUrl
|
21 |
Â
}
|
22 |
Â
$helper = Mage::helper('ddg');
|
23 |
-
$passcode = $helper->getWebsiteConfig(
|
24 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
25 |
Â
|
26 |
Â
|
27 |
-
if(!strlen($passcode))
|
Â
|
|
Â
|
|
28 |
Â
|
29 |
-
$text = sprintf(
|
Â
|
|
Â
|
|
Â
|
|
30 |
Â
$element->setData('value', $text);
|
31 |
Â
|
32 |
Â
return parent::_getElementHtml($element);
|
1 |
Â
<?php
|
2 |
Â
|
3 |
+
class Dotdigitalgroup_Email_Block_Adminhtml_System_Url_Newinvoice
|
4 |
+
extends Mage_Adminhtml_Block_System_Config_Form_Field
|
5 |
Â
{
|
6 |
+
|
7 |
+
/**
|
8 |
+
* Generate the urls.
|
9 |
+
*
|
10 |
+
* @param Varien_Data_Form_Element_Abstract $element
|
11 |
+
*
|
12 |
+
* @return string
|
13 |
+
* @throws Mage_Core_Exception
|
14 |
+
*/
|
15 |
+
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element
|
16 |
+
)
|
17 |
Â
{
|
18 |
Â
$baseUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
|
19 |
Â
$website = Mage::app()->getRequest()->getParam('website', false);
|
20 |
Â
|
21 |
Â
if ($website) {
|
22 |
Â
$website = Mage::app()->getWebsite($website);
|
23 |
+
$baseUrl = $website->getConfig('web/secure/base_url');
|
24 |
Â
}
|
25 |
Â
$helper = Mage::helper('ddg');
|
26 |
+
$passcode = $helper->getWebsiteConfig(
|
27 |
+
Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_DYNAMIC_CONTENT_PASSCODE,
|
28 |
+
$website
|
29 |
+
);
|
30 |
+
$orderId = $helper->getWebsiteConfig(
|
31 |
+
Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_MAPPING_LAST_ORDER_ID,
|
32 |
+
$website
|
33 |
+
);
|
34 |
Â
|
35 |
Â
|
36 |
+
if ( ! strlen($passcode)) {
|
37 |
+
$passcode = '[PLEASE SET UP A PASSCODE]';
|
38 |
+
}
|
39 |
Â
|
40 |
+
$text = sprintf(
|
41 |
+
'%sconnector/invoice/new/code/%s/order_id/@%s@', $baseUrl,
|
42 |
+
$passcode, $orderId
|
43 |
+
);
|
44 |
Â
$element->setData('value', $text);
|
45 |
Â
|
46 |
Â
return parent::_getElementHtml($element);
|
@@ -1,32 +1,46 @@
|
|
1 |
Â
<?php
|
2 |
Â
|
3 |
-
class Dotdigitalgroup_Email_Block_Adminhtml_System_Url_Newinvoiceguest
|
Â
|
|
4 |
Â
{
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
Â
|
|
Â
|
|
14 |
Â
{
|
15 |
Â
$baseUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
|
16 |
Â
$website = Mage::app()->getRequest()->getParam('website', false);
|
17 |
Â
|
18 |
Â
if ($website) {
|
19 |
Â
$website = Mage::app()->getWebsite($website);
|
20 |
-
$baseUrl
|
21 |
Â
}
|
22 |
Â
$helper = Mage::helper('ddg');
|
23 |
-
$passcode = $helper->getWebsiteConfig(
|
24 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
25 |
Â
|
26 |
Â
|
27 |
-
if(!strlen($passcode))
|
Â
|
|
Â
|
|
28 |
Â
|
29 |
-
$text = sprintf(
|
Â
|
|
Â
|
|
Â
|
|
30 |
Â
$element->setData('value', $text);
|
31 |
Â
|
32 |
Â
return parent::_getElementHtml($element);
|
1 |
Â
<?php
|
2 |
Â
|
3 |
+
class Dotdigitalgroup_Email_Block_Adminhtml_System_Url_Newinvoiceguest
|
4 |
+
extends Mage_Adminhtml_Block_System_Config_Form_Field
|
5 |
Â
{
|
6 |
+
|
7 |
+
/**
|
8 |
+
* Generate the urls.
|
9 |
+
*
|
10 |
+
* @param Varien_Data_Form_Element_Abstract $element
|
11 |
+
*
|
12 |
+
* @return string
|
13 |
+
* @throws Mage_Core_Exception
|
14 |
+
*/
|
15 |
+
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element
|
16 |
+
)
|
17 |
Â
{
|
18 |
Â
$baseUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
|
19 |
Â
$website = Mage::app()->getRequest()->getParam('website', false);
|
20 |
Â
|
21 |
Â
if ($website) {
|
22 |
Â
$website = Mage::app()->getWebsite($website);
|
23 |
+
$baseUrl = $website->getConfig('web/secure/base_url');
|
24 |
Â
}
|
25 |
Â
$helper = Mage::helper('ddg');
|
26 |
+
$passcode = $helper->getWebsiteConfig(
|
27 |
+
Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_DYNAMIC_CONTENT_PASSCODE,
|
28 |
+
$website
|
29 |
+
);
|
30 |
+
$orderId = $helper->getWebsiteConfig(
|
31 |
+
Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_MAPPING_LAST_ORDER_ID,
|
32 |
+
$website
|
33 |
+
);
|
34 |
Â
|
35 |
Â
|
36 |
+
if ( ! strlen($passcode)) {
|
37 |
+
$passcode = '[PLEASE SET UP A PASSCODE]';
|
38 |
+
}
|
39 |
Â
|
40 |
+
$text = sprintf(
|
41 |
+
'%sconnector/invoice/newguest/code/%s/order_id/@%s@', $baseUrl,
|
42 |
+
$passcode, $orderId
|
43 |
+
);
|
44 |
Â
$element->setData('value', $text);
|
45 |
Â
|
46 |
Â
return parent::_getElementHtml($element);
|
@@ -1,31 +1,46 @@
|
|
1 |
Â
<?php
|
2 |
-
|
Â
|
|
Â
|
|
3 |
Â
{
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
Â
|
|
Â
|
|
13 |
Â
{
|
14 |
Â
$baseUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
|
15 |
Â
$website = Mage::app()->getRequest()->getParam('website', false);
|
16 |
Â
|
17 |
Â
if ($website) {
|
18 |
Â
$website = Mage::app()->getWebsite($website);
|
19 |
-
$baseUrl
|
20 |
Â
}
|
21 |
Â
$helper = Mage::helper('ddg');
|
22 |
-
$passcode = $helper->getWebsiteConfig(
|
23 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
24 |
Â
|
25 |
Â
|
26 |
-
if(!strlen($passcode))
|
Â
|
|
Â
|
|
27 |
Â
|
28 |
-
$text = sprintf(
|
Â
|
|
Â
|
|
Â
|
|
29 |
Â
$element->setData('value', $text);
|
30 |
Â
|
31 |
Â
return parent::_getElementHtml($element);
|
1 |
Â
<?php
|
2 |
+
|
3 |
+
class Dotdigitalgroup_Email_Block_Adminhtml_System_Url_Neworder
|
4 |
+
extends Mage_Adminhtml_Block_System_Config_Form_Field
|
5 |
Â
{
|
6 |
+
|
7 |
+
/**
|
8 |
+
* Generate the urls.
|
9 |
+
*
|
10 |
+
* @param Varien_Data_Form_Element_Abstract $element
|
11 |
+
*
|
12 |
+
* @return string
|
13 |
+
* @throws Mage_Core_Exception
|
14 |
+
*/
|
15 |
+
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element
|
16 |
+
)
|
17 |
Â
{
|
18 |
Â
$baseUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
|
19 |
Â
$website = Mage::app()->getRequest()->getParam('website', false);
|
20 |
Â
|
21 |
Â
if ($website) {
|
22 |
Â
$website = Mage::app()->getWebsite($website);
|
23 |
+
$baseUrl = $website->getConfig('web/secure/base_url');
|
24 |
Â
}
|
25 |
Â
$helper = Mage::helper('ddg');
|
26 |
+
$passcode = $helper->getWebsiteConfig(
|
27 |
+
Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_DYNAMIC_CONTENT_PASSCODE,
|
28 |
+
$website
|
29 |
+
);
|
30 |
+
$orderId = $helper->getWebsiteConfig(
|
31 |
+
Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_MAPPING_LAST_ORDER_ID,
|
32 |
+
$website
|
33 |
+
);
|
34 |
Â
|
35 |
Â
|
36 |
+
if ( ! strlen($passcode)) {
|
37 |
+
$passcode = '[PLEASE SET UP A PASSCODE]';
|
38 |
+
}
|
39 |
Â
|
40 |
+
$text = sprintf(
|
41 |
+
'%sconnector/order/new/code/%s/order_id/@%s@', $baseUrl, $passcode,
|
42 |
+
$orderId
|
43 |
+
);
|
44 |
Â
$element->setData('value', $text);
|
45 |
Â
|
46 |
Â
return parent::_getElementHtml($element);
|
@@ -1,30 +1,45 @@
|
|
1 |
Â
<?php
|
2 |
-
|
Â
|
|
Â
|
|
3 |
Â
{
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
Â
|
|
Â
|
|
13 |
Â
{
|
14 |
Â
$baseUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
|
15 |
Â
$website = Mage::app()->getRequest()->getParam('website', false);
|
16 |
Â
|
17 |
Â
if ($website) {
|
18 |
Â
$website = Mage::app()->getWebsite($website);
|
19 |
-
$baseUrl
|
20 |
Â
}
|
21 |
Â
$helper = Mage::helper('ddg');
|
22 |
-
$passcode = $helper->getWebsiteConfig(
|
23 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
24 |
Â
|
25 |
-
if(!strlen($passcode))
|
Â
|
|
Â
|
|
26 |
Â
|
27 |
-
$text = sprintf(
|
Â
|
|
Â
|
|
Â
|
|
28 |
Â
$element->setData('value', $text);
|
29 |
Â
|
30 |
Â
return parent::_getElementHtml($element);
|
1 |
Â
<?php
|
2 |
+
|
3 |
+
class Dotdigitalgroup_Email_Block_Adminhtml_System_Url_Neworderguest
|
4 |
+
extends Mage_Adminhtml_Block_System_Config_Form_Field
|
5 |
Â
{
|
6 |
+
|
7 |
+
/**
|
8 |
+
* Generate the urls.
|
9 |
+
*
|
10 |
+
* @param Varien_Data_Form_Element_Abstract $element
|
11 |
+
*
|
12 |
+
* @return string
|
13 |
+
* @throws Mage_Core_Exception
|
14 |
+
*/
|
15 |
+
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element
|
16 |
+
)
|
17 |
Â
{
|
18 |
Â
$baseUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
|
19 |
Â
$website = Mage::app()->getRequest()->getParam('website', false);
|
20 |
Â
|
21 |
Â
if ($website) {
|
22 |
Â
$website = Mage::app()->getWebsite($website);
|
23 |
+
$baseUrl = $website->getConfig('web/secure/base_url');
|
24 |
Â
}
|
25 |
Â
$helper = Mage::helper('ddg');
|
26 |
+
$passcode = $helper->getWebsiteConfig(
|
27 |
+
Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_DYNAMIC_CONTENT_PASSCODE,
|
28 |
+
$website
|
29 |
+
);
|
30 |
+
$orderId = $helper->getWebsiteConfig(
|
31 |
+
Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_MAPPING_LAST_ORDER_ID,
|
32 |
+
$website
|
33 |
+
);
|
34 |
Â
|
35 |
+
if ( ! strlen($passcode)) {
|
36 |
+
$passcode = '[PLEASE SET UP A PASSCODE]';
|
37 |
+
}
|
38 |
Â
|
39 |
+
$text = sprintf(
|
40 |
+
'%sconnector/order/newguest/code/%s/order_id/@%s@', $baseUrl,
|
41 |
+
$passcode, $orderId
|
42 |
+
);
|
43 |
Â
$element->setData('value', $text);
|
44 |
Â
|
45 |
Â
return parent::_getElementHtml($element);
|
@@ -1,30 +1,45 @@
|
|
1 |
Â
<?php
|
2 |
-
|
Â
|
|
Â
|
|
3 |
Â
{
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
Â
|
|
Â
|
|
13 |
Â
{
|
14 |
Â
$baseUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
|
15 |
Â
$website = Mage::app()->getRequest()->getParam('website', false);
|
16 |
Â
|
17 |
Â
if ($website) {
|
18 |
Â
$website = Mage::app()->getWebsite($website);
|
19 |
-
$baseUrl
|
20 |
Â
}
|
21 |
Â
$helper = Mage::helper('ddg');
|
22 |
-
$passcode = $helper->getWebsiteConfig(
|
23 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
24 |
Â
|
25 |
-
if(!strlen($passcode))
|
Â
|
|
Â
|
|
26 |
Â
|
27 |
-
$text = sprintf(
|
Â
|
|
Â
|
|
Â
|
|
28 |
Â
|
29 |
Â
|
30 |
Â
$element->setData('value', $text);
|
1 |
Â
<?php
|
2 |
+
|
3 |
+
class Dotdigitalgroup_Email_Block_Adminhtml_System_Url_Newshipment
|
4 |
+
extends Mage_Adminhtml_Block_System_Config_Form_Field
|
5 |
Â
{
|
6 |
+
|
7 |
+
/**
|
8 |
+
* Generate the urls.
|
9 |
+
*
|
10 |
+
* @param Varien_Data_Form_Element_Abstract $element
|
11 |
+
*
|
12 |
+
* @return string
|
13 |
+
* @throws Mage_Core_Exception
|
14 |
+
*/
|
15 |
+
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element
|
16 |
+
)
|
17 |
Â
{
|
18 |
Â
$baseUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
|
19 |
Â
$website = Mage::app()->getRequest()->getParam('website', false);
|
20 |
Â
|
21 |
Â
if ($website) {
|
22 |
Â
$website = Mage::app()->getWebsite($website);
|
23 |
+
$baseUrl = $website->getConfig('web/secure/base_url');
|
24 |
Â
}
|
25 |
Â
$helper = Mage::helper('ddg');
|
26 |
+
$passcode = $helper->getWebsiteConfig(
|
27 |
+
Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_DYNAMIC_CONTENT_PASSCODE,
|
28 |
+
$website
|
29 |
+
);
|
30 |
+
$orderId = $helper->getWebsiteConfig(
|
31 |
+
Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_MAPPING_LAST_ORDER_ID,
|
32 |
+
$website
|
33 |
+
);
|
34 |
Â
|
35 |
+
if ( ! strlen($passcode)) {
|
36 |
+
$passcode = '[PLEASE SET UP A PASSCODE]';
|
37 |
+
}
|
38 |
Â
|
39 |
+
$text = sprintf(
|
40 |
+
'%sconnector/shipping/new/code/%s/order_id/@%s@', $baseUrl,
|
41 |
+
$passcode, $orderId
|
42 |
+
);
|
43 |
Â
|
44 |
Â
|
45 |
Â
$element->setData('value', $text);
|
@@ -1,30 +1,45 @@
|
|
1 |
Â
<?php
|
2 |
-
|
Â
|
|
Â
|
|
3 |
Â
{
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
Â
|
|
Â
|
|
13 |
Â
{
|
14 |
Â
$baseUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
|
15 |
Â
$website = Mage::app()->getRequest()->getParam('website', false);
|
16 |
Â
|
17 |
Â
if ($website) {
|
18 |
Â
$website = Mage::app()->getWebsite($website);
|
19 |
-
$baseUrl
|
20 |
Â
}
|
21 |
Â
$helper = Mage::helper('ddg');
|
22 |
-
$passcode = $helper->getWebsiteConfig(
|
23 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
24 |
Â
|
25 |
-
if(!strlen($passcode))
|
Â
|
|
Â
|
|
26 |
Â
|
27 |
-
$text = sprintf(
|
Â
|
|
Â
|
|
Â
|
|
28 |
Â
|
29 |
Â
$element->setData('value', $text);
|
30 |
Â
|
1 |
Â
<?php
|
2 |
+
|
3 |
+
class Dotdigitalgroup_Email_Block_Adminhtml_System_Url_Newshipmentguest
|
4 |
+
extends Mage_Adminhtml_Block_System_Config_Form_Field
|
5 |
Â
{
|
6 |
+
|
7 |
+
/**
|
8 |
+
* Generate the urls.
|
9 |
+
*
|
10 |
+
* @param Varien_Data_Form_Element_Abstract $element
|
11 |
+
*
|
12 |
+
* @return string
|
13 |
+
* @throws Mage_Core_Exception
|
14 |
+
*/
|
15 |
+
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element
|
16 |
+
)
|
17 |
Â
{
|
18 |
Â
$baseUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
|
19 |
Â
$website = Mage::app()->getRequest()->getParam('website', false);
|
20 |
Â
|
21 |
Â
if ($website) {
|
22 |
Â
$website = Mage::app()->getWebsite($website);
|
23 |
+
$baseUrl = $website->getConfig('web/secure/base_url');
|
24 |
Â
}
|
25 |
Â
$helper = Mage::helper('ddg');
|
26 |
+
$passcode = $helper->getWebsiteConfig(
|
27 |
+
Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_DYNAMIC_CONTENT_PASSCODE,
|
28 |
+
$website
|
29 |
+
);
|
30 |
+
$orderId = $helper->getWebsiteConfig(
|
31 |
+
Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_MAPPING_LAST_ORDER_ID,
|
32 |
+
$website
|
33 |
+
);
|
34 |
Â
|
35 |
+
if ( ! strlen($passcode)) {
|
36 |
+
$passcode = '[PLEASE SET UP A PASSCODE]';
|
37 |
+
}
|
38 |
Â
|
39 |
+
$text = sprintf(
|
40 |
+
'%sconnector/shipping/newguest/code/%s/order_id/@%s@', $baseUrl,
|
41 |
+
$passcode, $orderId
|
42 |
+
);
|
43 |
Â
|
44 |
Â
$element->setData('value', $text);
|
45 |
Â
|
@@ -1,29 +1,44 @@
|
|
1 |
Â
<?php
|
2 |
-
|
Â
|
|
Â
|
|
3 |
Â
{
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
Â
|
|
Â
|
|
13 |
Â
{
|
14 |
Â
$baseUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
|
15 |
Â
$website = Mage::app()->getRequest()->getParam('website', false);
|
16 |
Â
|
17 |
Â
if ($website) {
|
18 |
Â
$website = Mage::app()->getWebsite($website);
|
19 |
-
$baseUrl
|
20 |
Â
}
|
21 |
Â
$helper = Mage::helper('ddg');
|
22 |
-
$passcode = $helper->getWebsiteConfig(
|
23 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
24 |
Â
|
25 |
-
if(!strlen($passcode))
|
26 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
27 |
Â
$element->setData('value', $text);
|
28 |
Â
|
29 |
Â
return parent::_getElementHtml($element);
|
1 |
Â
<?php
|
2 |
+
|
3 |
+
class Dotdigitalgroup_Email_Block_Adminhtml_System_Url_Orderupdate
|
4 |
+
extends Mage_Adminhtml_Block_System_Config_Form_Field
|
5 |
Â
{
|
6 |
+
|
7 |
+
/**
|
8 |
+
* Generate the urls.
|
9 |
+
*
|
10 |
+
* @param Varien_Data_Form_Element_Abstract $element
|
11 |
+
*
|
12 |
+
* @return string
|
13 |
+
* @throws Mage_Core_Exception
|
14 |
+
*/
|
15 |
+
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element
|
16 |
+
)
|
17 |
Â
{
|
18 |
Â
$baseUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
|
19 |
Â
$website = Mage::app()->getRequest()->getParam('website', false);
|
20 |
Â
|
21 |
Â
if ($website) {
|
22 |
Â
$website = Mage::app()->getWebsite($website);
|
23 |
+
$baseUrl = $website->getConfig('web/secure/base_url');
|
24 |
Â
}
|
25 |
Â
$helper = Mage::helper('ddg');
|
26 |
+
$passcode = $helper->getWebsiteConfig(
|
27 |
+
Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_DYNAMIC_CONTENT_PASSCODE,
|
28 |
+
$website
|
29 |
+
);
|
30 |
+
$orderId = $helper->getWebsiteConfig(
|
31 |
+
Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_MAPPING_LAST_ORDER_ID,
|
32 |
+
$website
|
33 |
+
);
|
34 |
Â
|
35 |
+
if ( ! strlen($passcode)) {
|
36 |
+
$passcode = '[PLEASE SET UP A PASSCODE]';
|
37 |
+
}
|
38 |
+
$text = sprintf(
|
39 |
+
'%sconnector/order/update/code/%s/order_id/@%s@', $baseUrl,
|
40 |
+
$passcode, $orderId
|
41 |
+
);
|
42 |
Â
$element->setData('value', $text);
|
43 |
Â
|
44 |
Â
return parent::_getElementHtml($element);
|
@@ -1,29 +1,44 @@
|
|
1 |
Â
<?php
|
2 |
-
|
Â
|
|
Â
|
|
3 |
Â
{
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
Â
|
|
Â
|
|
13 |
Â
{
|
14 |
Â
$baseUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
|
15 |
Â
$website = Mage::app()->getRequest()->getParam('website', false);
|
16 |
Â
|
17 |
Â
if ($website) {
|
18 |
Â
$website = Mage::app()->getWebsite($website);
|
19 |
-
$baseUrl
|
20 |
Â
}
|
21 |
Â
$helper = Mage::helper('ddg');
|
22 |
-
$passcode = $helper->getWebsiteConfig(
|
23 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
24 |
Â
|
25 |
-
if(!strlen($passcode))
|
26 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
27 |
Â
$element->setData('value', $text);
|
28 |
Â
|
29 |
Â
return parent::_getElementHtml($element);
|
1 |
Â
<?php
|
2 |
+
|
3 |
+
class Dotdigitalgroup_Email_Block_Adminhtml_System_Url_Orderupdateguest
|
4 |
+
extends Mage_Adminhtml_Block_System_Config_Form_Field
|
5 |
Â
{
|
6 |
+
|
7 |
+
/**
|
8 |
+
* Generate the urls.
|
9 |
+
*
|
10 |
+
* @param Varien_Data_Form_Element_Abstract $element
|
11 |
+
*
|
12 |
+
* @return string
|
13 |
+
* @throws Mage_Core_Exception
|
14 |
+
*/
|
15 |
+
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element
|
16 |
+
)
|
17 |
Â
{
|
18 |
Â
$baseUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
|
19 |
Â
$website = Mage::app()->getRequest()->getParam('website', false);
|
20 |
Â
|
21 |
Â
if ($website) {
|
22 |
Â
$website = Mage::app()->getWebsite($website);
|
23 |
+
$baseUrl = $website->getConfig('web/secure/base_url');
|
24 |
Â
}
|
25 |
Â
$helper = Mage::helper('ddg');
|
26 |
+
$passcode = $helper->getWebsiteConfig(
|
27 |
+
Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_DYNAMIC_CONTENT_PASSCODE,
|
28 |
+
$website
|
29 |
+
);
|
30 |
+
$orderId = $helper->getWebsiteConfig(
|
31 |
+
Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_MAPPING_LAST_ORDER_ID,
|
32 |
+
$website
|
33 |
+
);
|
34 |
Â
|
35 |
+
if ( ! strlen($passcode)) {
|
36 |
+
$passcode = '[PLEASE SET UP A PASSCODE]';
|
37 |
+
}
|
38 |
+
$text = sprintf(
|
39 |
+
'%sconnector/order/updateguest/code/%s/order_id/@%s@', $baseUrl,
|
40 |
+
$passcode, $orderId
|
41 |
+
);
|
42 |
Â
$element->setData('value', $text);
|
43 |
Â
|
44 |
Â
return parent::_getElementHtml($element);
|
@@ -1,30 +1,45 @@
|
|
1 |
Â
<?php
|
2 |
-
|
Â
|
|
Â
|
|
3 |
Â
{
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
Â
|
|
Â
|
|
13 |
Â
{
|
14 |
Â
$baseUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
|
15 |
Â
$website = Mage::app()->getRequest()->getParam('website', false);
|
16 |
Â
|
17 |
Â
if ($website) {
|
18 |
Â
$website = Mage::app()->getWebsite($website);
|
19 |
-
$baseUrl
|
20 |
Â
}
|
21 |
Â
$helper = Mage::helper('ddg');
|
22 |
-
$passcode = $helper->getWebsiteConfig(
|
23 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
24 |
Â
|
25 |
-
if(!strlen($passcode))
|
Â
|
|
Â
|
|
26 |
Â
|
27 |
-
$text = sprintf(
|
Â
|
|
Â
|
|
Â
|
|
28 |
Â
|
29 |
Â
$element->setData('value', $text);
|
30 |
Â
|
1 |
Â
<?php
|
2 |
+
|
3 |
+
class Dotdigitalgroup_Email_Block_Adminhtml_System_Url_Shipmentupdate
|
4 |
+
extends Mage_Adminhtml_Block_System_Config_Form_Field
|
5 |
Â
{
|
6 |
+
|
7 |
+
/**
|
8 |
+
* Generate the urls.
|
9 |
+
*
|
10 |
+
* @param Varien_Data_Form_Element_Abstract $element
|
11 |
+
*
|
12 |
+
* @return string
|
13 |
+
* @throws Mage_Core_Exception
|
14 |
+
*/
|
15 |
+
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element
|
16 |
+
)
|
17 |
Â
{
|
18 |
Â
$baseUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
|
19 |
Â
$website = Mage::app()->getRequest()->getParam('website', false);
|
20 |
Â
|
21 |
Â
if ($website) {
|
22 |
Â
$website = Mage::app()->getWebsite($website);
|
23 |
+
$baseUrl = $website->getConfig('web/secure/base_url');
|
24 |
Â
}
|
25 |
Â
$helper = Mage::helper('ddg');
|
26 |
+
$passcode = $helper->getWebsiteConfig(
|
27 |
+
Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_DYNAMIC_CONTENT_PASSCODE,
|
28 |
+
$website
|
29 |
+
);
|
30 |
+
$orderId = $helper->getWebsiteConfig(
|
31 |
+
Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_MAPPING_LAST_ORDER_ID,
|
32 |
+
$website
|
33 |
+
);
|
34 |
Â
|
35 |
+
if ( ! strlen($passcode)) {
|
36 |
+
$passcode = '[PLEASE SET UP A PASSCODE]';
|
37 |
+
}
|
38 |
Â
|
39 |
+
$text = sprintf(
|
40 |
+
'%sconnector/shipping/update/code/%s/order_id/@%s@', $baseUrl,
|
41 |
+
$passcode, $orderId
|
42 |
+
);
|
43 |
Â
|
44 |
Â
$element->setData('value', $text);
|
45 |
Â
|
@@ -1,30 +1,45 @@
|
|
1 |
Â
<?php
|
2 |
-
|
Â
|
|
Â
|
|
3 |
Â
{
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
Â
|
|
Â
|
|
13 |
Â
{
|
14 |
Â
$baseUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
|
15 |
Â
$website = Mage::app()->getRequest()->getParam('website', false);
|
16 |
Â
|
17 |
Â
if ($website) {
|
18 |
Â
$website = Mage::app()->getWebsite($website);
|
19 |
-
$baseUrl
|
20 |
Â
}
|
21 |
Â
$helper = Mage::helper('ddg');
|
22 |
-
$passcode = $helper->getWebsiteConfig(
|
23 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
24 |
Â
|
25 |
-
if(!strlen($passcode))
|
Â
|
|
Â
|
|
26 |
Â
|
27 |
-
$text = sprintf(
|
Â
|
|
Â
|
|
Â
|
|
28 |
Â
$element->setData('value', $text);
|
29 |
Â
|
30 |
Â
return parent::_getElementHtml($element);
|
1 |
Â
<?php
|
2 |
+
|
3 |
+
class Dotdigitalgroup_Email_Block_Adminhtml_System_Url_Shipmentupdateguest
|
4 |
+
extends Mage_Adminhtml_Block_System_Config_Form_Field
|
5 |
Â
{
|
6 |
+
|
7 |
+
/**
|
8 |
+
* Generate the urls.
|
9 |
+
*
|
10 |
+
* @param Varien_Data_Form_Element_Abstract $element
|
11 |
+
*
|
12 |
+
* @return string
|
13 |
+
* @throws Mage_Core_Exception
|
14 |
+
*/
|
15 |
+
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element
|
16 |
+
)
|
17 |
Â
{
|
18 |
Â
$baseUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
|
19 |
Â
$website = Mage::app()->getRequest()->getParam('website', false);
|
20 |
Â
|
21 |
Â
if ($website) {
|
22 |
Â
$website = Mage::app()->getWebsite($website);
|
23 |
+
$baseUrl = $website->getConfig('web/secure/base_url');
|
24 |
Â
}
|
25 |
Â
$helper = Mage::helper('ddg');
|
26 |
+
$passcode = $helper->getWebsiteConfig(
|
27 |
+
Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_DYNAMIC_CONTENT_PASSCODE,
|
28 |
+
$website
|
29 |
+
);
|
30 |
+
$orderId = $helper->getWebsiteConfig(
|
31 |
+
Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_MAPPING_LAST_ORDER_ID,
|
32 |
+
$website
|
33 |
+
);
|
34 |
Â
|
35 |
+
if ( ! strlen($passcode)) {
|
36 |
+
$passcode = '[PLEASE SET UP A PASSCODE]';
|
37 |
+
}
|
38 |
Â
|
39 |
+
$text = sprintf(
|
40 |
+
'%sconnector/shipping/updateguest/code/%s/order_id/@%s@', $baseUrl,
|
41 |
+
$passcode, $orderId
|
42 |
+
);
|
43 |
Â
$element->setData('value', $text);
|
44 |
Â
|
45 |
Â
return parent::_getElementHtml($element);
|
@@ -1,23 +1,26 @@
|
|
1 |
Â
<?php
|
2 |
Â
|
3 |
-
class Dotdigitalgroup_Email_Block_Adminhtml_Widget_Chooser_Product
|
Â
|
|
4 |
Â
{
|
5 |
Â
|
6 |
-
public function __construct($arguments=array())
|
7 |
Â
{
|
8 |
Â
parent::__construct($arguments);
|
9 |
Â
|
10 |
Â
if ($this->getRequest()->getParam('current_grid_id')) {
|
11 |
Â
$this->setId($this->getRequest()->getParam('current_grid_id'));
|
12 |
Â
} else {
|
13 |
-
$this->setId('skuChooserGrid_'
|
14 |
Â
}
|
15 |
Â
|
16 |
Â
//change to 10
|
17 |
Â
$this->setDefaultLimit(10);
|
18 |
Â
$form = $this->getJsFormObject();
|
19 |
Â
$this->setRowClickCallback("$form.chooserGridRowClick.bind($form)");
|
20 |
-
$this->setCheckboxCheckCallback(
|
Â
|
|
Â
|
|
21 |
Â
$this->setRowInitCallback("$form.chooserGridRowInit.bind($form)");
|
22 |
Â
$this->setDefaultSort('entity_id');
|
23 |
Â
$this->setUseAjax(true);
|
@@ -28,6 +31,7 @@ class Dotdigitalgroup_Email_Block_Adminhtml_Widget_Chooser_Product extends Mage_
|
|
28 |
Â
|
29 |
Â
/**
|
30 |
Â
* Retrieve quote store object
|
Â
|
|
31 |
Â
* @return Mage_Core_Model_Store
|
32 |
Â
*/
|
33 |
Â
public function getStore()
|
@@ -44,13 +48,18 @@ class Dotdigitalgroup_Email_Block_Adminhtml_Widget_Chooser_Product extends Mage_
|
|
44 |
Â
$selected = '';
|
45 |
Â
}
|
46 |
Â
if ($column->getFilter()->getValue()) {
|
47 |
-
$this->getCollection()->addFieldToFilter(
|
Â
|
|
Â
|
|
48 |
Â
} else {
|
49 |
-
$this->getCollection()->addFieldToFilter(
|
Â
|
|
Â
|
|
50 |
Â
}
|
51 |
Â
} else {
|
52 |
Â
parent::_addColumnFilterToCollection($column);
|
53 |
Â
}
|
Â
|
|
54 |
Â
return $this;
|
55 |
Â
}
|
56 |
Â
|
@@ -77,68 +86,85 @@ class Dotdigitalgroup_Email_Block_Adminhtml_Widget_Chooser_Product extends Mage_
|
|
77 |
Â
*/
|
78 |
Â
protected function _prepareColumns()
|
79 |
Â
{
|
80 |
-
$this->addColumn(
|
81 |
-
'
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
'
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
98 |
Â
array(
|
99 |
-
'header'=> Mage::helper('catalog')->__('Type'),
|
100 |
-
'width'
|
101 |
-
'index'
|
102 |
-
'type'
|
103 |
-
'options' => Mage::getSingleton('catalog/product_type')
|
104 |
-
|
Â
|
|
Â
|
|
105 |
Â
|
106 |
Â
$sets = Mage::getResourceModel('eav/entity_attribute_set_collection')
|
107 |
-
->setEntityTypeFilter(
|
Â
|
|
Â
|
|
108 |
Â
->load()
|
109 |
Â
->toOptionHash();
|
110 |
Â
|
111 |
-
$this->addColumn(
|
Â
|
|
112 |
Â
array(
|
113 |
-
'header'=> Mage::helper('catalog')->__('Attrib. Set Name'),
|
114 |
-
'width'
|
115 |
-
'index'
|
116 |
-
'type'
|
117 |
Â
'options' => $sets,
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
'
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
131 |
Â
|
132 |
Â
return parent::_prepareColumns();
|
133 |
Â
}
|
134 |
Â
|
135 |
Â
public function getGridUrl()
|
136 |
Â
{
|
137 |
-
return $this->getUrl(
|
138 |
-
'
|
139 |
-
|
140 |
-
|
141 |
-
|
Â
|
|
Â
|
|
142 |
Â
}
|
143 |
Â
|
144 |
Â
protected function _getSelectedProducts()
|
@@ -152,11 +178,13 @@ class Dotdigitalgroup_Email_Block_Adminhtml_Widget_Chooser_Product extends Mage_
|
|
152 |
Â
* set default limit
|
153 |
Â
*
|
154 |
Â
* @param $limit
|
Â
|
|
155 |
Â
* @return $this
|
156 |
Â
*/
|
157 |
Â
public function setDefaultLimit($limit)
|
158 |
Â
{
|
159 |
Â
$this->_defaultLimit = $limit;
|
Â
|
|
160 |
Â
return $this;
|
161 |
Â
}
|
162 |
Â
}
|
1 |
Â
<?php
|
2 |
Â
|
3 |
+
class Dotdigitalgroup_Email_Block_Adminhtml_Widget_Chooser_Product
|
4 |
+
extends Mage_Adminhtml_Block_Widget_Grid
|
5 |
Â
{
|
6 |
Â
|
7 |
+
public function __construct($arguments = array())
|
8 |
Â
{
|
9 |
Â
parent::__construct($arguments);
|
10 |
Â
|
11 |
Â
if ($this->getRequest()->getParam('current_grid_id')) {
|
12 |
Â
$this->setId($this->getRequest()->getParam('current_grid_id'));
|
13 |
Â
} else {
|
14 |
+
$this->setId('skuChooserGrid_' . $this->getId());
|
15 |
Â
}
|
16 |
Â
|
17 |
Â
//change to 10
|
18 |
Â
$this->setDefaultLimit(10);
|
19 |
Â
$form = $this->getJsFormObject();
|
20 |
Â
$this->setRowClickCallback("$form.chooserGridRowClick.bind($form)");
|
21 |
+
$this->setCheckboxCheckCallback(
|
22 |
+
"$form.chooserGridCheckboxCheck.bind($form)"
|
23 |
+
);
|
24 |
Â
$this->setRowInitCallback("$form.chooserGridRowInit.bind($form)");
|
25 |
Â
$this->setDefaultSort('entity_id');
|
26 |
Â
$this->setUseAjax(true);
|
31 |
Â
|
32 |
Â
/**
|
33 |
Â
* Retrieve quote store object
|
34 |
+
*
|
35 |
Â
* @return Mage_Core_Model_Store
|
36 |
Â
*/
|
37 |
Â
public function getStore()
|
48 |
Â
$selected = '';
|
49 |
Â
}
|
50 |
Â
if ($column->getFilter()->getValue()) {
|
51 |
+
$this->getCollection()->addFieldToFilter(
|
52 |
+
'entity_id', array('in' => $selected)
|
53 |
+
);
|
54 |
Â
} else {
|
55 |
+
$this->getCollection()->addFieldToFilter(
|
56 |
+
'entity_id', array('nin' => $selected)
|
57 |
+
);
|
58 |
Â
}
|
59 |
Â
} else {
|
60 |
Â
parent::_addColumnFilterToCollection($column);
|
61 |
Â
}
|
62 |
+
|
63 |
Â
return $this;
|
64 |
Â
}
|
65 |
Â
|
86 |
Â
*/
|
87 |
Â
protected function _prepareColumns()
|
88 |
Â
{
|
89 |
+
$this->addColumn(
|
90 |
+
'in_products', array(
|
91 |
+
'header_css_class' => 'a-center',
|
92 |
+
'type' => 'checkbox',
|
93 |
+
'name' => 'in_products',
|
94 |
+
'values' => $this->_getSelectedProducts(),
|
95 |
+
'align' => 'center',
|
96 |
+
'index' => 'entity_id',
|
97 |
+
'use_index' => true,
|
98 |
+
)
|
99 |
+
);
|
100 |
+
|
101 |
+
$this->addColumn(
|
102 |
+
'entity_id', array(
|
103 |
+
'header' => Mage::helper('sales')->__('ID'),
|
104 |
+
'sortable' => true,
|
105 |
+
'width' => '60px',
|
106 |
+
'index' => 'entity_id'
|
107 |
+
)
|
108 |
+
);
|
109 |
+
|
110 |
+
$this->addColumn(
|
111 |
+
'type',
|
112 |
Â
array(
|
113 |
+
'header' => Mage::helper('catalog')->__('Type'),
|
114 |
+
'width' => '60px',
|
115 |
+
'index' => 'type_id',
|
116 |
+
'type' => 'options',
|
117 |
+
'options' => Mage::getSingleton('catalog/product_type')
|
118 |
+
->getOptionArray(),
|
119 |
+
)
|
120 |
+
);
|
121 |
Â
|
122 |
Â
$sets = Mage::getResourceModel('eav/entity_attribute_set_collection')
|
123 |
+
->setEntityTypeFilter(
|
124 |
+
Mage::getModel('catalog/product')->getResource()->getTypeId()
|
125 |
+
)
|
126 |
Â
->load()
|
127 |
Â
->toOptionHash();
|
128 |
Â
|
129 |
+
$this->addColumn(
|
130 |
+
'set_name',
|
131 |
Â
array(
|
132 |
+
'header' => Mage::helper('catalog')->__('Attrib. Set Name'),
|
133 |
+
'width' => '100px',
|
134 |
+
'index' => 'attribute_set_id',
|
135 |
+
'type' => 'options',
|
136 |
Â
'options' => $sets,
|
137 |
+
)
|
138 |
+
);
|
139 |
+
|
140 |
+
$this->addColumn(
|
141 |
+
'chooser_sku', array(
|
142 |
+
'header' => Mage::helper('sales')->__('SKU'),
|
143 |
+
'name' => 'chooser_sku',
|
144 |
+
'width' => '80px',
|
145 |
+
'index' => 'sku'
|
146 |
+
)
|
147 |
+
);
|
148 |
+
$this->addColumn(
|
149 |
+
'chooser_name', array(
|
150 |
+
'header' => Mage::helper('sales')->__('Product Name'),
|
151 |
+
'name' => 'chooser_name',
|
152 |
+
'index' => 'name'
|
153 |
+
)
|
154 |
+
);
|
155 |
Â
|
156 |
Â
return parent::_prepareColumns();
|
157 |
Â
}
|
158 |
Â
|
159 |
Â
public function getGridUrl()
|
160 |
Â
{
|
161 |
+
return $this->getUrl(
|
162 |
+
'*/*/product', array(
|
163 |
+
'_current' => true,
|
164 |
+
'current_grid_id' => $this->getId(),
|
165 |
+
'collapse' => null
|
166 |
+
)
|
167 |
+
);
|
168 |
Â
}
|
169 |
Â
|
170 |
Â
protected function _getSelectedProducts()
|
178 |
Â
* set default limit
|
179 |
Â
*
|
180 |
Â
* @param $limit
|
181 |
+
*
|
182 |
Â
* @return $this
|
183 |
Â
*/
|
184 |
Â
public function setDefaultLimit($limit)
|
185 |
Â
{
|
186 |
Â
$this->_defaultLimit = $limit;
|
187 |
+
|
188 |
Â
return $this;
|
189 |
Â
}
|
190 |
Â
}
|
@@ -1,14 +1,16 @@
|
|
1 |
Â
<?php
|
2 |
Â
|
3 |
-
class Dotdigitalgroup_Email_Block_Adminhtml_Wishlist
|
Â
|
|
4 |
Â
{
|
Â
|
|
5 |
Â
public function __construct()
|
6 |
Â
{
|
7 |
Â
parent::__construct();
|
8 |
Â
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
Â
|
13 |
Â
$this->_removeButton('add');
|
14 |
Â
}
|
1 |
Â
<?php
|
2 |
Â
|
3 |
+
class Dotdigitalgroup_Email_Block_Adminhtml_Wishlist
|
4 |
+
extends Mage_Adminhtml_Block_Widget_Grid_Container
|
5 |
Â
{
|
6 |
+
|
7 |
Â
public function __construct()
|
8 |
Â
{
|
9 |
Â
parent::__construct();
|
10 |
Â
|
11 |
+
$this->_controller = 'adminhtml_wishlist';
|
12 |
+
$this->_blockGroup = 'ddg_automation';
|
13 |
+
$this->_headerText = Mage::helper('ddg')->__('Email Wishlist(s)');
|
14 |
Â
|
15 |
Â
$this->_removeButton('add');
|
16 |
Â
}
|
@@ -1,7 +1,9 @@
|
|
1 |
Â
<?php
|
2 |
Â
|
3 |
-
class Dotdigitalgroup_Email_Block_Adminhtml_Wishlist_Grid
|
Â
|
|
4 |
Â
{
|
Â
|
|
5 |
Â
public function __construct()
|
6 |
Â
{
|
7 |
Â
parent::__construct();
|
@@ -13,9 +15,10 @@ class Dotdigitalgroup_Email_Block_Adminhtml_Wishlist_Grid extends Mage_Adminhtml
|
|
13 |
Â
}
|
14 |
Â
|
15 |
Â
/**
|
16 |
-
|
17 |
-
|
18 |
-
|
Â
|
|
19 |
Â
protected function _getCollectionClass()
|
20 |
Â
{
|
21 |
Â
// This is the model we are using for the grid
|
@@ -23,93 +26,121 @@ class Dotdigitalgroup_Email_Block_Adminhtml_Wishlist_Grid extends Mage_Adminhtml
|
|
23 |
Â
}
|
24 |
Â
|
25 |
Â
/**
|
26 |
-
|
27 |
-
|
28 |
-
|
Â
|
|
29 |
Â
protected function _prepareCollection()
|
30 |
Â
{
|
31 |
Â
// Get and set our collection for the grid
|
32 |
Â
$collection = Mage::getResourceModel($this->_getCollectionClass());
|
33 |
Â
$this->setCollection($collection);
|
Â
|
|
34 |
Â
return parent::_prepareCollection();
|
35 |
Â
}
|
36 |
Â
|
37 |
Â
/**
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
Â
|
|
42 |
Â
protected function _prepareColumns()
|
43 |
Â
{
|
44 |
-
$this->addColumn(
|
45 |
-
'
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
'
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
'
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
'
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
100 |
Â
|
101 |
Â
return parent::_prepareColumns();
|
102 |
Â
}
|
103 |
Â
|
104 |
Â
/**
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
Â
public function filterCallbackContact($collection, $column)
|
111 |
Â
{
|
112 |
-
$field = $column->getFilterIndex() ? $column->getFilterIndex()
|
Â
|
|
113 |
Â
$value = $column->getFilter()->getValue();
|
114 |
Â
if ($value == 'null') {
|
115 |
Â
$collection->addFieldToFilter($field, array('null' => true));
|
1 |
Â
<?php
|
2 |
Â
|
3 |
+
class Dotdigitalgroup_Email_Block_Adminhtml_Wishlist_Grid
|
4 |
+
extends Mage_Adminhtml_Block_Widget_Grid
|
5 |
Â
{
|
6 |
+
|
7 |
Â
public function __construct()
|
8 |
Â
{
|
9 |
Â
parent::__construct();
|
15 |
Â
}
|
16 |
Â
|
17 |
Â
/**
|
18 |
+
* Collection class;
|
19 |
+
*
|
20 |
+
* @return string
|
21 |
+
*/
|
22 |
Â
protected function _getCollectionClass()
|
23 |
Â
{
|
24 |
Â
// This is the model we are using for the grid
|
26 |
Â
}
|
27 |
Â
|
28 |
Â
/**
|
29 |
+
* Prepare the grid collection.
|
30 |
+
*
|
31 |
+
* @return Mage_Adminhtml_Block_Widget_Grid
|
32 |
+
*/
|
33 |
Â
protected function _prepareCollection()
|
34 |
Â
{
|
35 |
Â
// Get and set our collection for the grid
|
36 |
Â
$collection = Mage::getResourceModel($this->_getCollectionClass());
|
37 |
Â
$this->setCollection($collection);
|
38 |
+
|
39 |
Â
return parent::_prepareCollection();
|
40 |
Â
}
|
41 |
Â
|
42 |
Â
/**
|
43 |
+
* Prepare the grid collumns.
|
44 |
+
*
|
45 |
+
* @return $this
|
46 |
+
* @throws Exception
|
47 |
+
*/
|
48 |
Â
protected function _prepareColumns()
|
49 |
Â
{
|
50 |
+
$this->addColumn(
|
51 |
+
'wishlist_id', array(
|
52 |
+
'header' => Mage::helper('ddg')->__('Wishlist ID'),
|
53 |
+
'align' => 'left',
|
54 |
+
'width' => '50px',
|
55 |
+
'index' => 'wishlist_id',
|
56 |
+
'type' => 'number',
|
57 |
+
'escape' => true
|
58 |
+
)
|
59 |
+
)->addColumn(
|
60 |
+
'customer_id', array(
|
61 |
+
'header' => Mage::helper('ddg')->__('Customer ID'),
|
62 |
+
'align' => 'left',
|
63 |
+
'width' => '50px',
|
64 |
+
'index' => 'customer_id',
|
65 |
+
'type' => 'number',
|
66 |
+
'escape' => true
|
67 |
+
)
|
68 |
+
)->addColumn(
|
69 |
+
'item_count', array(
|
70 |
+
'header' => Mage::helper('ddg')->__('Item Count'),
|
71 |
+
'align' => 'left',
|
72 |
+
'width' => '50px',
|
73 |
+
'index' => 'item_count',
|
74 |
+
'type' => 'number',
|
75 |
+
'escape' => true
|
76 |
+
)
|
77 |
+
)->addColumn(
|
78 |
+
'wishlist_imported', array(
|
79 |
+
'header' => Mage::helper('ddg')->__(
|
80 |
+
'Wishlist Imported'
|
81 |
+
),
|
82 |
+
'align' => 'center',
|
83 |
+
'width' => '50px',
|
84 |
+
'index' => 'wishlist_imported',
|
85 |
+
'type' => 'options',
|
86 |
+
'escape' => true,
|
87 |
+
'renderer' => 'ddg_automation/adminhtml_column_renderer_imported',
|
88 |
+
'options' => Mage::getModel(
|
89 |
+
'ddg_automation/adminhtml_source_contact_imported'
|
90 |
+
)->getOptions(),
|
91 |
+
'filter_condition_callback' => array($this,
|
92 |
+
'filterCallbackContact')
|
93 |
+
)
|
94 |
+
)->addColumn(
|
95 |
+
'wishlist_modified', array(
|
96 |
+
'header' => Mage::helper('ddg')->__(
|
97 |
+
'Wishlist Modified'
|
98 |
+
),
|
99 |
+
'align' => 'center',
|
100 |
+
'width' => '50px',
|
101 |
+
'index' => 'wishlist_modified',
|
102 |
+
'type' => 'options',
|
103 |
+
'escape' => true,
|
104 |
+
'renderer' => 'ddg_automation/adminhtml_column_renderer_imported',
|
105 |
+
'options' => Mage::getModel(
|
106 |
+
'ddg_automation/adminhtml_source_contact_imported'
|
107 |
+
)->getOptions(),
|
108 |
+
'filter_condition_callback' => array($this,
|
109 |
+
'filterCallbackContact')
|
110 |
+
)
|
111 |
+
)->addColumn(
|
112 |
+
'created_at', array(
|
113 |
+
'header' => Mage::helper('ddg')->__('Created At'),
|
114 |
+
'width' => '50px',
|
115 |
+
'align' => 'center',
|
116 |
+
'index' => 'created_at',
|
117 |
+
'type' => 'datetime',
|
118 |
+
'escape' => true,
|
119 |
+
)
|
120 |
+
)->addColumn(
|
121 |
+
'updated_at', array(
|
122 |
+
'header' => Mage::helper('ddg')->__('Updated At'),
|
123 |
+
'width' => '50px',
|
124 |
+
'align' => 'center',
|
125 |
+
'index' => 'updated_at',
|
126 |
+
'type' => 'datetime',
|
127 |
+
'escape' => true,
|
128 |
+
)
|
129 |
+
);
|
130 |
Â
|
131 |
Â
return parent::_prepareColumns();
|
132 |
Â
}
|
133 |
Â
|
134 |
Â
/**
|
135 |
+
* Callback action for the imported subscribers/contacts.
|
136 |
+
*
|
137 |
+
* @param $collection
|
138 |
+
* @param $column
|
139 |
+
*/
|
140 |
Â
public function filterCallbackContact($collection, $column)
|
141 |
Â
{
|
142 |
+
$field = $column->getFilterIndex() ? $column->getFilterIndex()
|
143 |
+
: $column->getIndex();
|
144 |
Â
$value = $column->getFilter()->getValue();
|
145 |
Â
if ($value == 'null') {
|
146 |
Â
$collection->addFieldToFilter($field, array('null' => true));
|
@@ -2,123 +2,137 @@
|
|
2 |
Â
|
3 |
Â
class Dotdigitalgroup_Email_Block_Basket extends Mage_Core_Block_Template
|
4 |
Â
{
|
Â
|
|
5 |
Â
protected $_quote;
|
6 |
Â
|
7 |
Â
/**
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
Â
public function getBasketItems()
|
15 |
Â
{
|
16 |
Â
$params = $this->getRequest()->getParams();
|
17 |
Â
|
18 |
-
|
19 |
Â
Mage::helper('ddg')->log('Basket no quote id or code is set');
|
Â
|
|
20 |
Â
return false;
|
21 |
Â
}
|
22 |
Â
|
23 |
-
$quoteId
|
24 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
25 |
Â
|
26 |
-
//check for any quote for this email, don't want to render further
|
27 |
-
if (! $quoteModel->getId()) {
|
28 |
-
Mage::helper('ddg')->log('no quote found for '. $quoteId);
|
29 |
Â
return false;
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
return false;
|
34 |
-
}
|
35 |
Â
|
36 |
-
|
Â
|
|
37 |
Â
|
38 |
-
|
39 |
-
$storeId = $quoteModel->getStoreId();
|
40 |
-
$appEmulation = Mage::getSingleton('core/app_emulation');
|
41 |
-
$appEmulation->startEnvironmentEmulation($storeId);
|
42 |
Â
|
43 |
-
|
44 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
45 |
Â
|
46 |
-
|
47 |
-
|
48 |
-
continue;
|
49 |
-
$_product = Mage::getModel('catalog/product')->load($quoteItem->getProductId());
|
50 |
Â
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
'productUrl' => $productUrl,
|
60 |
-
'product' => $_product,
|
61 |
-
'qty' => $quoteItem->getQty()
|
62 |
Â
|
63 |
-
|
64 |
-
}
|
65 |
Â
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
66 |
Â
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
67 |
Â
|
68 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
69 |
Â
}
|
70 |
Â
|
Â
|
|
71 |
Â
/**
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
Â
{
|
78 |
-
return $this->_quote->getGrandTotal();
|
79 |
Â
|
Â
|
|
Â
|
|
Â
|
|
80 |
Â
}
|
81 |
-
/**
|
82 |
-
* url for "take me to basket" link
|
83 |
-
*
|
84 |
-
* @return string
|
85 |
-
*/
|
86 |
-
public function getUrlForLink()
|
87 |
-
{
|
88 |
-
return $this->_quote->getStore()->getUrl(
|
89 |
-
'connector/email/getbasket',
|
90 |
-
array('quote_id' => $this->_quote->getId())
|
91 |
-
);
|
92 |
-
}
|
93 |
-
|
94 |
-
/**
|
95 |
-
* can show go to basket url
|
96 |
-
*
|
97 |
-
* @return bool
|
98 |
-
*/
|
99 |
-
public function canShowUrl()
|
100 |
-
{
|
101 |
-
return (boolean) $this->_quote->getStore()->getWebsite()->getConfig(
|
102 |
-
Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CONTENT_LINK_ENABLED
|
103 |
-
);
|
104 |
-
}
|
105 |
-
|
106 |
-
public function takeMeToCartTextForUrl()
|
107 |
-
{
|
108 |
-
return $this->_quote->getStore()->getWebsite()->getConfig(
|
109 |
-
Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CONTENT_LINK_TEXT
|
110 |
-
);
|
111 |
-
}
|
112 |
-
|
113 |
-
|
114 |
-
/**
|
115 |
-
* Get dynamic style configuration.
|
116 |
-
* @return array
|
117 |
-
*/
|
118 |
-
protected function getDynamicStyle() {
|
119 |
-
|
120 |
-
$dynamicStyle = Mage::helper('ddg')->getDynamicStyles();
|
121 |
-
return $dynamicStyle;
|
122 |
-
}
|
123 |
Â
|
124 |
Â
}
|
2 |
Â
|
3 |
Â
class Dotdigitalgroup_Email_Block_Basket extends Mage_Core_Block_Template
|
4 |
Â
{
|
5 |
+
|
6 |
Â
protected $_quote;
|
7 |
Â
|
8 |
Â
/**
|
9 |
+
* Basket itmes.
|
10 |
+
*
|
11 |
+
* @return mixed
|
12 |
+
* @throws Exception
|
13 |
+
* @throws Mage_Core_Exception
|
14 |
+
*/
|
15 |
Â
public function getBasketItems()
|
16 |
Â
{
|
17 |
Â
$params = $this->getRequest()->getParams();
|
18 |
Â
|
19 |
+
if ( ! isset($params['quote_id']) || ! isset($params['code'])) {
|
20 |
Â
Mage::helper('ddg')->log('Basket no quote id or code is set');
|
21 |
+
|
22 |
Â
return false;
|
23 |
Â
}
|
24 |
Â
|
25 |
+
$quoteId = $params['quote_id'];
|
26 |
+
$quoteModel = Mage::getModel('sales/quote')->load($quoteId);
|
27 |
+
|
28 |
+
//check for any quote for this email, don't want to render further
|
29 |
+
if ( ! $quoteModel->getId()) {
|
30 |
+
Mage::helper('ddg')->log('no quote found for ' . $quoteId);
|
31 |
Â
|
Â
|
|
Â
|
|
Â
|
|
32 |
Â
return false;
|
33 |
+
}
|
34 |
+
if ( ! $quoteModel->getIsActive()) {
|
35 |
+
Mage::helper('ddg')->log('Cart is not active : ' . $quoteId);
|
Â
|
|
Â
|
|
36 |
Â
|
37 |
+
return false;
|
38 |
+
}
|
39 |
Â
|
40 |
+
$this->_quote = $quoteModel;
|
Â
|
|
Â
|
|
Â
|
|
41 |
Â
|
42 |
+
//Start environment emulation of the specified store
|
43 |
+
$storeId = $quoteModel->getStoreId();
|
44 |
+
$appEmulation = Mage::getSingleton('core/app_emulation');
|
45 |
+
$appEmulation->startEnvironmentEmulation($storeId);
|
46 |
+
|
47 |
+
$quoteItems = $quoteModel->getAllItems();
|
48 |
+
|
49 |
+
$itemsData = array();
|
50 |
+
|
51 |
+
foreach ($quoteItems as $quoteItem) {
|
52 |
+
if ($quoteItem->getParentItemId() != null) {
|
53 |
+
continue;
|
54 |
+
}
|
55 |
+
|
56 |
+
$_product = $quoteItem->getProduct();
|
57 |
+
$inStock = ($_product->getStockItem()->getIsInStock())
|
58 |
+
? 'In Stock'
|
59 |
+
: 'Out of stock';
|
60 |
+
$total = Mage::helper('core')->currency(
|
61 |
+
$quoteItem->getBaseRowTotalInclTax()
|
62 |
+
);
|
63 |
+
$productUrl = $_product->getProductUrl();
|
64 |
+
$grandTotal = Mage::helper('core')->currency(
|
65 |
+
$this->getGrandTotal()
|
66 |
+
);
|
67 |
+
$itemsData[] = array(
|
68 |
+
'grandTotal' => $grandTotal,
|
69 |
+
'total' => $total,
|
70 |
+
'inStock' => $inStock,
|
71 |
+
'productUrl' => $productUrl,
|
72 |
+
'product' => $_product,
|
73 |
+
'qty' => $quoteItem->getQty()
|
74 |
+
|
75 |
+
);
|
76 |
+
}
|
77 |
Â
|
78 |
+
return $itemsData;
|
79 |
+
}
|
Â
|
|
Â
|
|
80 |
Â
|
81 |
+
/**
|
82 |
+
* Grand total.
|
83 |
+
*
|
84 |
+
* @return mixed
|
85 |
+
*/
|
86 |
+
public function getGrandTotal()
|
87 |
+
{
|
88 |
+
return $this->_quote->getGrandTotal();
|
Â
|
|
Â
|
|
Â
|
|
89 |
Â
|
90 |
+
}
|
Â
|
|
91 |
Â
|
92 |
+
/**
|
93 |
+
* url for "take me to basket" link
|
94 |
+
*
|
95 |
+
* @return string
|
96 |
+
*/
|
97 |
+
public function getUrlForLink()
|
98 |
+
{
|
99 |
+
return $this->_quote->getStore()->getUrl(
|
100 |
+
'connector/email/getbasket',
|
101 |
+
array('quote_id' => $this->_quote->getId())
|
102 |
+
);
|
103 |
+
}
|
104 |
Â
|
105 |
+
/**
|
106 |
+
* can show go to basket url
|
107 |
+
*
|
108 |
+
* @return bool
|
109 |
+
*/
|
110 |
+
public function canShowUrl()
|
111 |
+
{
|
112 |
+
return (boolean)$this->_quote->getStore()->getWebsite()->getConfig(
|
113 |
+
Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CONTENT_LINK_ENABLED
|
114 |
+
);
|
115 |
+
}
|
116 |
Â
|
117 |
+
public function takeMeToCartTextForUrl()
|
118 |
+
{
|
119 |
+
return $this->_quote->getStore()->getWebsite()->getConfig(
|
120 |
+
Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CONTENT_LINK_TEXT
|
121 |
+
);
|
122 |
Â
}
|
123 |
Â
|
124 |
+
|
125 |
Â
/**
|
126 |
+
* Get dynamic style configuration.
|
127 |
+
*
|
128 |
+
* @return array
|
129 |
+
*/
|
130 |
+
protected function getDynamicStyle()
|
131 |
Â
{
|
Â
|
|
132 |
Â
|
133 |
+
$dynamicStyle = Mage::helper('ddg')->getDynamicStyles();
|
134 |
+
|
135 |
+
return $dynamicStyle;
|
136 |
Â
}
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
137 |
Â
|
138 |
Â
}
|
@@ -2,17 +2,19 @@
|
|
2 |
Â
|
3 |
Â
class Dotdigitalgroup_Email_Block_Coupon extends Mage_Core_Block_Template
|
4 |
Â
{
|
Â
|
|
5 |
Â
/**
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
Â
|
|
10 |
Â
public function generateCoupon()
|
11 |
Â
{
|
12 |
Â
$params = $this->getRequest()->getParams();
|
13 |
-
if (!isset($params['id']) || !isset($params['code'])){
|
14 |
-
//throw new Exception('Coupon no id or code is set');
|
15 |
Â
Mage::helper('ddg')->log('Coupon no id or code is set');
|
Â
|
|
16 |
Â
return false;
|
17 |
Â
}
|
18 |
Â
//coupon rule id
|
@@ -21,13 +23,18 @@ class Dotdigitalgroup_Email_Block_Coupon extends Mage_Core_Block_Template
|
|
21 |
Â
if ($couponCodeId) {
|
22 |
Â
|
23 |
Â
$rule = Mage::getModel('salesrule/rule')->load($couponCodeId);
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
Â
|
|
Â
|
|
Â
|
|
29 |
Â
$generator = Mage::getModel('salesrule/coupon_massgenerator');
|
30 |
-
$generator->setFormat(
|
Â
|
|
Â
|
|
31 |
Â
$generator->setRuleId($couponCodeId);
|
32 |
Â
$generator->setUsesPerCoupon(1);
|
33 |
Â
$generator->setDash(3);
|
@@ -38,38 +45,58 @@ class Dotdigitalgroup_Email_Block_Coupon extends Mage_Core_Block_Template
|
|
38 |
Â
$rule->setCouponCodeGenerator($generator);
|
39 |
Â
$rule->setCouponType(Mage_SalesRule_Model_Rule::COUPON_TYPE_AUTO);
|
40 |
Â
//generate the coupon
|
41 |
-
$coupon
|
42 |
Â
$couponCode = $coupon->getCode();
|
43 |
Â
//save the type of coupon
|
44 |
-
$couponModel = Mage::getModel('salesrule/coupon')->loadByCode(
|
45 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
46 |
Â
$couponModel->save();
|
47 |
Â
|
48 |
Â
return $couponCode;
|
49 |
Â
}
|
Â
|
|
50 |
Â
return false;
|
51 |
Â
}
|
52 |
Â
|
53 |
Â
|
54 |
-
|
55 |
-
|
56 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
57 |
Â
|
58 |
-
|
59 |
-
|
60 |
-
|
Â
|
|
Â
|
|
Â
|
|
61 |
Â
|
62 |
-
|
63 |
-
|
64 |
-
|
Â
|
|
Â
|
|
Â
|
|
65 |
Â
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
Â
|
|
Â
|
|
70 |
Â
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
Â
|
|
Â
|
|
75 |
Â
}
|
2 |
Â
|
3 |
Â
class Dotdigitalgroup_Email_Block_Coupon extends Mage_Core_Block_Template
|
4 |
Â
{
|
5 |
+
|
6 |
Â
/**
|
7 |
+
* Generates the coupon code based on the code id.
|
8 |
+
*
|
9 |
+
* @return bool
|
10 |
+
* @throws Exception
|
11 |
+
*/
|
12 |
Â
public function generateCoupon()
|
13 |
Â
{
|
14 |
Â
$params = $this->getRequest()->getParams();
|
15 |
+
if ( ! isset($params['id']) || ! isset($params['code'])) {
|
Â
|
|
16 |
Â
Mage::helper('ddg')->log('Coupon no id or code is set');
|
17 |
+
|
18 |
Â
return false;
|
19 |
Â
}
|
20 |
Â
//coupon rule id
|
23 |
Â
if ($couponCodeId) {
|
24 |
Â
|
25 |
Â
$rule = Mage::getModel('salesrule/rule')->load($couponCodeId);
|
26 |
+
//coupon code id not found
|
27 |
+
if ( ! $rule->getId()) {
|
28 |
+
Mage::helper('ddg')->log(
|
29 |
+
'Rule with couponId model not found : ' . $couponCodeId
|
30 |
+
);
|
31 |
+
|
32 |
+
return false;
|
33 |
+
}
|
34 |
Â
$generator = Mage::getModel('salesrule/coupon_massgenerator');
|
35 |
+
$generator->setFormat(
|
36 |
+
Mage_SalesRule_Helper_Coupon::COUPON_FORMAT_ALPHANUMERIC
|
37 |
+
);
|
38 |
Â
$generator->setRuleId($couponCodeId);
|
39 |
Â
$generator->setUsesPerCoupon(1);
|
40 |
Â
$generator->setDash(3);
|
45 |
Â
$rule->setCouponCodeGenerator($generator);
|
46 |
Â
$rule->setCouponType(Mage_SalesRule_Model_Rule::COUPON_TYPE_AUTO);
|
47 |
Â
//generate the coupon
|
48 |
+
$coupon = $rule->acquireCoupon();
|
49 |
Â
$couponCode = $coupon->getCode();
|
50 |
Â
//save the type of coupon
|
51 |
+
$couponModel = Mage::getModel('salesrule/coupon')->loadByCode(
|
52 |
+
$couponCode
|
53 |
+
);
|
54 |
+
$couponModel->setType(
|
55 |
+
Mage_SalesRule_Model_Rule::COUPON_TYPE_NO_COUPON
|
56 |
+
);
|
57 |
Â
$couponModel->save();
|
58 |
Â
|
59 |
Â
return $couponCode;
|
60 |
Â
}
|
61 |
+
|
62 |
Â
return false;
|
63 |
Â
}
|
64 |
Â
|
65 |
Â
|
66 |
+
protected function getStyle()
|
67 |
+
{
|
68 |
+
return explode(
|
69 |
+
',', Mage::getStoreConfig(
|
70 |
+
Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_DYNAMIC_COUPON_STYLE
|
71 |
+
)
|
72 |
+
);
|
73 |
+
}
|
74 |
Â
|
75 |
+
protected function getCouponColor()
|
76 |
+
{
|
77 |
+
return Mage::getStoreConfig(
|
78 |
+
Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_DYNAMIC_COUPON_COLOR
|
79 |
+
);
|
80 |
+
}
|
81 |
Â
|
82 |
+
protected function getFontSize()
|
83 |
+
{
|
84 |
+
return Mage::getStoreConfig(
|
85 |
+
Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_DYNAMIC_COUPON_FONT_SIZE
|
86 |
+
);
|
87 |
+
}
|
88 |
Â
|
89 |
+
protected function getFont()
|
90 |
+
{
|
91 |
+
return Mage::getStoreConfig(
|
92 |
+
Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_DYNAMIC_COUPON_FONT
|
93 |
+
);
|
94 |
+
}
|
95 |
Â
|
96 |
+
protected function getBackgroundColor()
|
97 |
+
{
|
98 |
+
return Mage::getStoreConfig(
|
99 |
+
Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_DYNAMIC_COUPON_BG_COLOR
|
100 |
+
);
|
101 |
+
}
|
102 |
Â
}
|
@@ -1,9 +1,11 @@
|
|
1 |
Â
<?php
|
2 |
Â
|
3 |
-
class Dotdigitalgroup_Email_Block_Customer_Account_Books
|
Â
|
|
4 |
Â
{
|
Â
|
|
5 |
Â
protected $_client;
|
6 |
-
|
7 |
Â
|
8 |
Â
/**
|
9 |
Â
* subscription pref save url
|
@@ -20,6 +22,7 @@ class Dotdigitalgroup_Email_Block_Customer_Account_Books extends Mage_Customer_B
|
|
20 |
Â
*
|
21 |
Â
* @param $path
|
22 |
Â
* @param $website
|
Â
|
|
23 |
Â
* @return mixed
|
24 |
Â
*/
|
25 |
Â
protected function _getWebsiteConfigFromHelper($path, $website)
|
@@ -34,13 +37,16 @@ class Dotdigitalgroup_Email_Block_Customer_Account_Books extends Mage_Customer_B
|
|
34 |
Â
*/
|
35 |
Â
protected function _getApiClient()
|
36 |
Â
{
|
37 |
-
if(empty($this->_client)) {
|
38 |
Â
$website = $this->getCustomer()->getStore()->getWebsite();
|
39 |
-
$client
|
40 |
-
$client->setApiUsername(
|
Â
|
|
Â
|
|
41 |
Â
->setApiPassword(Mage::helper('ddg')->getApiPassword($website));
|
42 |
Â
$this->_client = $client;
|
43 |
Â
}
|
Â
|
|
44 |
Â
return $this->_client;
|
45 |
Â
}
|
46 |
Â
|
@@ -65,39 +71,45 @@ class Dotdigitalgroup_Email_Block_Customer_Account_Books extends Mage_Customer_B
|
|
65 |
Â
public function getAdditionalBooksToShow()
|
66 |
Â
{
|
67 |
Â
$additionalBooksToShow = array();
|
68 |
-
$additionalFromConfig
|
69 |
Â
Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_ADDRESSBOOK_PREF_SHOW_BOOKS,
|
70 |
Â
$this->getCustomer()->getStore()->getWebsite()
|
71 |
Â
);
|
72 |
Â
|
73 |
-
if(strlen($additionalFromConfig))
|
74 |
-
{
|
75 |
Â
$additionalFromConfig = explode(',', $additionalFromConfig);
|
76 |
Â
$this->getConnectorContact();
|
77 |
-
if($this->
|
78 |
-
$addressBooks
|
Â
|
|
Â
|
|
Â
|
|
79 |
Â
$processedAddressBooks = array();
|
80 |
-
if(is_array($addressBooks)){
|
81 |
-
foreach($addressBooks as $addressBook){
|
82 |
-
$processedAddressBooks[$addressBook->id]
|
Â
|
|
83 |
Â
}
|
84 |
Â
}
|
85 |
-
foreach($additionalFromConfig as $bookId){
|
86 |
-
$connectorBook = $this->_getApiClient()->getAddressBookById(
|
87 |
-
|
88 |
-
|
Â
|
|
89 |
Â
$subscribed = 0;
|
90 |
-
if(isset($processedAddressBooks[$bookId]))
|
91 |
Â
$subscribed = 1;
|
Â
|
|
92 |
Â
$additionalBooksToShow[] = array(
|
93 |
-
"name"
|
94 |
-
"value"
|
95 |
-
"subscribed"
|
96 |
Â
);
|
97 |
Â
}
|
98 |
Â
}
|
99 |
Â
}
|
100 |
Â
}
|
Â
|
|
101 |
Â
return $additionalBooksToShow;
|
102 |
Â
}
|
103 |
Â
|
@@ -121,52 +133,59 @@ class Dotdigitalgroup_Email_Block_Customer_Account_Books extends Mage_Customer_B
|
|
121 |
Â
*/
|
122 |
Â
public function getDataFieldsToShow()
|
123 |
Â
{
|
124 |
-
$datafieldsToShow
|
125 |
-
$dataFieldsFromConfig =
|
126 |
Â
Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_ADDRESSBOOK_PREF_SHOW_FIELDS,
|
127 |
Â
$this->getCustomer()->getStore()->getWebsite()
|
128 |
Â
);
|
129 |
-
if(strlen($dataFieldsFromConfig))
|
130 |
-
{
|
131 |
Â
$dataFieldsFromConfig = explode(',', $dataFieldsFromConfig);
|
132 |
-
$contact
|
133 |
-
if($this->
|
134 |
-
|
135 |
-
$contactDataFields = $contact->dataFields;
|
136 |
Â
$processedContactDataFields = array();
|
137 |
-
foreach($contactDataFields as $contactDataField){
|
138 |
-
$processedContactDataFields[$contactDataField->key]
|
Â
|
|
139 |
Â
}
|
140 |
Â
|
141 |
-
$connectorDataFields
|
Â
|
|
142 |
Â
$processedConnectorDataFields = array();
|
143 |
-
foreach($connectorDataFields as $connectorDataField){
|
144 |
-
$processedConnectorDataFields[$connectorDataField->name]
|
Â
|
|
145 |
Â
}
|
146 |
-
foreach($dataFieldsFromConfig as $dataFieldFromConfig){
|
147 |
-
if(isset($processedConnectorDataFields[$dataFieldFromConfig])){
|
148 |
Â
$value = "";
|
149 |
-
$type
|
150 |
-
if(isset($processedContactDataFields[$processedConnectorDataFields[$dataFieldFromConfig]->name])){
|
151 |
-
if($processedConnectorDataFields[$dataFieldFromConfig]->type
|
152 |
-
|
153 |
-
|
154 |
-
$
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
155 |
Â
}
|
156 |
-
else
|
157 |
-
$value = $processedContactDataFields[$processedConnectorDataFields[$dataFieldFromConfig]->name];
|
158 |
Â
}
|
159 |
Â
|
160 |
Â
$datafieldsToShow[] = array(
|
161 |
-
'name' =>
|
162 |
-
'type' =>
|
163 |
-
'value' =>
|
164 |
Â
);
|
165 |
Â
}
|
166 |
Â
}
|
167 |
Â
|
168 |
Â
}
|
169 |
Â
}
|
Â
|
|
170 |
Â
return $datafieldsToShow;
|
171 |
Â
}
|
172 |
Â
|
@@ -177,12 +196,15 @@ class Dotdigitalgroup_Email_Block_Customer_Account_Books extends Mage_Customer_B
|
|
177 |
Â
*/
|
178 |
Â
public function canShowAnything()
|
179 |
Â
{
|
180 |
-
if($this->getCanShowDataFields() or $this->getCanShowAdditionalBooks()
|
181 |
-
|
Â
|
|
182 |
Â
$fields = $this->getDataFieldsToShow();
|
183 |
-
if(!empty($books) or !empty($fields))
|
184 |
Â
return true;
|
Â
|
|
185 |
Â
}
|
Â
|
|
186 |
Â
return false;
|
187 |
Â
}
|
188 |
Â
|
@@ -193,17 +215,24 @@ class Dotdigitalgroup_Email_Block_Customer_Account_Books extends Mage_Customer_B
|
|
193 |
Â
*/
|
194 |
Â
public function getConnectorContact()
|
195 |
Â
{
|
196 |
-
$contact = $this->_getApiClient()->getContactByEmail(
|
197 |
-
|
Â
|
|
Â
|
|
198 |
Â
$this->_getCustomerSession()->setConnectorContactId($contact->id);
|
199 |
-
$this->
|
200 |
-
}else{
|
201 |
-
$contact = $this->_getApiClient()->postContacts(
|
202 |
-
|
203 |
-
|
204 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
205 |
Â
}
|
206 |
Â
}
|
Â
|
|
207 |
Â
return $contact;
|
208 |
Â
}
|
209 |
Â
|
1 |
Â
<?php
|
2 |
Â
|
3 |
+
class Dotdigitalgroup_Email_Block_Customer_Account_Books
|
4 |
+
extends Mage_Customer_Block_Account_Dashboard
|
5 |
Â
{
|
6 |
+
|
7 |
Â
protected $_client;
|
8 |
+
public $contactId;
|
9 |
Â
|
10 |
Â
/**
|
11 |
Â
* subscription pref save url
|
22 |
Â
*
|
23 |
Â
* @param $path
|
24 |
Â
* @param $website
|
25 |
+
*
|
26 |
Â
* @return mixed
|
27 |
Â
*/
|
28 |
Â
protected function _getWebsiteConfigFromHelper($path, $website)
|
37 |
Â
*/
|
38 |
Â
protected function _getApiClient()
|
39 |
Â
{
|
40 |
+
if (empty($this->_client)) {
|
41 |
Â
$website = $this->getCustomer()->getStore()->getWebsite();
|
42 |
+
$client = Mage::getModel('ddg_automation/apiconnector_client');
|
43 |
+
$client->setApiUsername(
|
44 |
+
Mage::helper('ddg')->getApiUsername($website)
|
45 |
+
)
|
46 |
Â
->setApiPassword(Mage::helper('ddg')->getApiPassword($website));
|
47 |
Â
$this->_client = $client;
|
48 |
Â
}
|
49 |
+
|
50 |
Â
return $this->_client;
|
51 |
Â
}
|
52 |
Â
|
71 |
Â
public function getAdditionalBooksToShow()
|
72 |
Â
{
|
73 |
Â
$additionalBooksToShow = array();
|
74 |
+
$additionalFromConfig = $this->_getWebsiteConfigFromHelper(
|
75 |
Â
Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_ADDRESSBOOK_PREF_SHOW_BOOKS,
|
76 |
Â
$this->getCustomer()->getStore()->getWebsite()
|
77 |
Â
);
|
78 |
Â
|
79 |
+
if (strlen($additionalFromConfig)) {
|
Â
|
|
80 |
Â
$additionalFromConfig = explode(',', $additionalFromConfig);
|
81 |
Â
$this->getConnectorContact();
|
82 |
+
if ($this->contactId) {
|
83 |
+
$addressBooks = $this->_getApiClient()
|
84 |
+
->getContactAddressBooks(
|
85 |
+
$this->contactId
|
86 |
+
);
|
87 |
Â
$processedAddressBooks = array();
|
88 |
+
if (is_array($addressBooks)) {
|
89 |
+
foreach ($addressBooks as $addressBook) {
|
90 |
+
$processedAddressBooks[$addressBook->id]
|
91 |
+
= $addressBook->name;
|
92 |
Â
}
|
93 |
Â
}
|
94 |
+
foreach ($additionalFromConfig as $bookId) {
|
95 |
+
$connectorBook = $this->_getApiClient()->getAddressBookById(
|
96 |
+
$bookId
|
97 |
+
);
|
98 |
+
if (isset($connectorBook->id)) {
|
99 |
Â
$subscribed = 0;
|
100 |
+
if (isset($processedAddressBooks[$bookId])) {
|
101 |
Â
$subscribed = 1;
|
102 |
+
}
|
103 |
Â
$additionalBooksToShow[] = array(
|
104 |
+
"name" => $connectorBook->name,
|
105 |
+
"value" => $connectorBook->id,
|
106 |
+
"subscribed" => $subscribed
|
107 |
Â
);
|
108 |
Â
}
|
109 |
Â
}
|
110 |
Â
}
|
111 |
Â
}
|
112 |
+
|
113 |
Â
return $additionalBooksToShow;
|
114 |
Â
}
|
115 |
Â
|
133 |
Â
*/
|
134 |
Â
public function getDataFieldsToShow()
|
135 |
Â
{
|
136 |
+
$datafieldsToShow = array();
|
137 |
+
$dataFieldsFromConfig = $this->_getWebsiteConfigFromHelper(
|
138 |
Â
Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_ADDRESSBOOK_PREF_SHOW_FIELDS,
|
139 |
Â
$this->getCustomer()->getStore()->getWebsite()
|
140 |
Â
);
|
141 |
+
if (strlen($dataFieldsFromConfig)) {
|
Â
|
|
142 |
Â
$dataFieldsFromConfig = explode(',', $dataFieldsFromConfig);
|
143 |
+
$contact = $this->getConnectorContact();
|
144 |
+
if ($this->contactId) {
|
145 |
+
$contactDataFields = $contact->dataFields;
|
Â
|
|
146 |
Â
$processedContactDataFields = array();
|
147 |
+
foreach ($contactDataFields as $contactDataField) {
|
148 |
+
$processedContactDataFields[$contactDataField->key]
|
149 |
+
= $contactDataField->value;
|
150 |
Â
}
|
151 |
Â
|
152 |
+
$connectorDataFields = $this->_getApiClient()
|
153 |
+
->getDataFields();
|
154 |
Â
$processedConnectorDataFields = array();
|
155 |
+
foreach ($connectorDataFields as $connectorDataField) {
|
156 |
+
$processedConnectorDataFields[$connectorDataField->name]
|
157 |
+
= $connectorDataField;
|
158 |
Â
}
|
159 |
+
foreach ($dataFieldsFromConfig as $dataFieldFromConfig) {
|
160 |
+
if (isset($processedConnectorDataFields[$dataFieldFromConfig])) {
|
161 |
Â
$value = "";
|
162 |
+
$type = "";
|
163 |
+
if (isset($processedContactDataFields[$processedConnectorDataFields[$dataFieldFromConfig]->name])) {
|
164 |
+
if ($processedConnectorDataFields[$dataFieldFromConfig]->type
|
165 |
+
== "Date"
|
166 |
+
) {
|
167 |
+
$type = "Date";
|
168 |
+
$value
|
169 |
+
= $processedContactDataFields[$processedConnectorDataFields[$dataFieldFromConfig]->name];
|
170 |
+
$value = Mage::app()->getLocale()->date($value)
|
171 |
+
->toString("Y/M/d");
|
172 |
+
} else {
|
173 |
+
$value
|
174 |
+
= $processedContactDataFields[$processedConnectorDataFields[$dataFieldFromConfig]->name];
|
175 |
Â
}
|
Â
|
|
Â
|
|
176 |
Â
}
|
177 |
Â
|
178 |
Â
$datafieldsToShow[] = array(
|
179 |
+
'name' => $processedConnectorDataFields[$dataFieldFromConfig]->name,
|
180 |
+
'type' => $processedConnectorDataFields[$dataFieldFromConfig]->type,
|
181 |
+
'value' => $value
|
182 |
Â
);
|
183 |
Â
}
|
184 |
Â
}
|
185 |
Â
|
186 |
Â
}
|
187 |
Â
}
|
188 |
+
|
189 |
Â
return $datafieldsToShow;
|
190 |
Â
}
|
191 |
Â
|
196 |
Â
*/
|
197 |
Â
public function canShowAnything()
|
198 |
Â
{
|
199 |
+
if ($this->getCanShowDataFields() or $this->getCanShowAdditionalBooks()
|
200 |
+
) {
|
201 |
+
$books = $this->getAdditionalBooksToShow();
|
202 |
Â
$fields = $this->getDataFieldsToShow();
|
203 |
+
if ( ! empty($books) or ! empty($fields)) {
|
204 |
Â
return true;
|
205 |
+
}
|
206 |
Â
}
|
207 |
+
|
208 |
Â
return false;
|
209 |
Â
}
|
210 |
Â
|
215 |
Â
*/
|
216 |
Â
public function getConnectorContact()
|
217 |
Â
{
|
218 |
+
$contact = $this->_getApiClient()->getContactByEmail(
|
219 |
+
$this->getCustomer()->getEmail()
|
220 |
+
);
|
221 |
+
if ($contact->id) {
|
222 |
Â
$this->_getCustomerSession()->setConnectorContactId($contact->id);
|
223 |
+
$this->contactId = $contact->id;
|
224 |
+
} else {
|
225 |
+
$contact = $this->_getApiClient()->postContacts(
|
226 |
+
$this->getCustomer()->getEmail()
|
227 |
+
);
|
228 |
+
if ($contact->id) {
|
229 |
+
$this->_getCustomerSession()->setConnectorContactId(
|
230 |
+
$contact->id
|
231 |
+
);
|
232 |
+
$this->contactId = $contact->id;
|
233 |
Â
}
|
234 |
Â
}
|
235 |
+
|
236 |
Â
return $contact;
|
237 |
Â
}
|
238 |
Â
|
@@ -2,7 +2,8 @@
|
|
2 |
Â
|
3 |
Â
class Dotdigitalgroup_Email_Block_Edc extends Mage_Core_Block_Template
|
4 |
Â
{
|
5 |
-
|
Â
|
|
6 |
Â
|
7 |
Â
protected function _construct()
|
8 |
Â
{
|
@@ -10,12 +11,13 @@ class Dotdigitalgroup_Email_Block_Edc extends Mage_Core_Block_Template
|
|
10 |
Â
parent::_construct();
|
11 |
Â
|
12 |
Â
if ($this->getRequest()->getControllerName() == 'quoteproducts') {
|
13 |
-
$this->
|
14 |
Â
}
|
15 |
Â
}
|
16 |
Â
|
17 |
Â
/**
|
18 |
Â
* Prepare layout, set the template.
|
Â
|
|
19 |
Â
* @return Mage_Core_Block_Abstract|void
|
20 |
Â
*/
|
21 |
Â
protected function _prepareLayout()
|
@@ -29,15 +31,17 @@ class Dotdigitalgroup_Email_Block_Edc extends Mage_Core_Block_Template
|
|
29 |
Â
* Product related items.
|
30 |
Â
*
|
31 |
Â
* @param Mage_Catalog_Model_Product $productModel
|
32 |
-
* @param
|
33 |
Â
*
|
34 |
Â
* @return array
|
35 |
Â
*/
|
36 |
-
protected function _getRecommendedProduct(Mage_Catalog_Model_Product $productModel,
|
Â
|
|
Â
|
|
37 |
Â
{
|
38 |
Â
//array of products to display
|
39 |
Â
$products = array();
|
40 |
-
switch($mode){
|
41 |
Â
case 'related':
|
42 |
Â
$products = $productModel->getRelatedProducts();
|
43 |
Â
break;
|
@@ -50,15 +54,17 @@ class Dotdigitalgroup_Email_Block_Edc extends Mage_Core_Block_Template
|
|
50 |
Â
|
51 |
Â
}
|
52 |
Â
$productIds = array();
|
53 |
-
foreach($products as $product){
|
54 |
Â
$productIds[] = $product->getId();
|
55 |
Â
}
|
Â
|
|
56 |
Â
return $productIds;
|
57 |
Â
}
|
58 |
Â
|
59 |
Â
public function getTextForUrl($store)
|
60 |
Â
{
|
61 |
Â
$store = Mage::app()->getStore($store);
|
Â
|
|
62 |
Â
return $store->getConfig(
|
63 |
Â
Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_DYNAMIC_CONTENT_LINK_TEXT
|
64 |
Â
);
|
@@ -77,16 +83,20 @@ class Dotdigitalgroup_Email_Block_Edc extends Mage_Core_Block_Template
|
|
77 |
Â
|
78 |
Â
/**
|
79 |
Â
* Number of the colums.
|
Â
|
|
80 |
Â
* @return int|mixed
|
81 |
Â
* @throws Exception
|
82 |
Â
*/
|
83 |
Â
public function getColumnCount()
|
84 |
Â
{
|
85 |
-
return Mage::helper('ddg/recommended')->getDisplayLimitByMode(
|
Â
|
|
Â
|
|
86 |
Â
}
|
87 |
Â
|
88 |
Â
/**
|
89 |
Â
* Price html.
|
Â
|
|
90 |
Â
* @param $product
|
91 |
Â
*
|
92 |
Â
* @return string
|
@@ -95,6 +105,7 @@ class Dotdigitalgroup_Email_Block_Edc extends Mage_Core_Block_Template
|
|
95 |
Â
{
|
96 |
Â
$this->setTemplate('connector/product/price.phtml');
|
97 |
Â
$this->setProduct($product);
|
Â
|
|
98 |
Â
return $this->toHtml();
|
99 |
Â
}
|
100 |
Â
|
@@ -106,65 +117,77 @@ class Dotdigitalgroup_Email_Block_Edc extends Mage_Core_Block_Template
|
|
106 |
Â
*/
|
107 |
Â
public function getLoadedProductCollection()
|
108 |
Â
{
|
109 |
-
$mode
|
Â
|
|
110 |
Â
$limit = Mage::helper('ddg/recommended')->getDisplayLimitByMode($mode);
|
111 |
-
|
112 |
-
|
Â
|
|
Â
|
|
113 |
Â
|
114 |
-
switch ($this->
|
115 |
Â
case 'recentlyviewed':
|
116 |
-
|
117 |
Â
break;
|
118 |
Â
case 'push':
|
119 |
-
|
120 |
Â
break;
|
121 |
Â
case 'bestsellers':
|
122 |
-
|
123 |
Â
break;
|
124 |
Â
case 'mostviewed':
|
125 |
-
|
126 |
Â
break;
|
127 |
Â
case 'quote_products':
|
128 |
-
|
129 |
Â
break;
|
130 |
Â
}
|
Â
|
|
Â
|
|
131 |
Â
}
|
132 |
Â
|
133 |
Â
/**
|
134 |
Â
* get collection for recently viewed products
|
135 |
Â
*
|
136 |
Â
* @param $limit
|
Â
|
|
137 |
Â
* @return array
|
138 |
Â
* @throws Exception
|
139 |
Â
*/
|
140 |
Â
protected function _getRecentlyViewedCollection($limit)
|
141 |
Â
{
|
142 |
Â
$productsToDisplay = array();
|
143 |
-
$customerId
|
144 |
Â
|
145 |
Â
//login customer to receive the recent products
|
146 |
-
$session
|
147 |
Â
$isLoggedIn = $session->loginById($customerId);
|
148 |
Â
|
149 |
Â
/** @var Mage_Reports_Block_Product_Viewed $collection */
|
150 |
-
$collection
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
Mage::helper('ddg')->log(
|
155 |
-
'
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
168 |
Â
$session->logout();
|
169 |
Â
|
170 |
Â
return $productsToDisplay;
|
@@ -174,22 +197,29 @@ class Dotdigitalgroup_Email_Block_Edc extends Mage_Core_Block_Template
|
|
174 |
Â
* get collection for push items
|
175 |
Â
*
|
176 |
Â
* @param $limit
|
Â
|
|
177 |
Â
* @return array
|
178 |
Â
*/
|
179 |
Â
protected function _getProductPushCollection($limit)
|
180 |
Â
{
|
181 |
Â
$productsToDisplay = array();
|
182 |
-
$productIds
|
Â
|
|
183 |
Â
|
184 |
-
$productCollection = Mage::getResourceModel(
|
Â
|
|
Â
|
|
185 |
Â
->addAttributeToFilter('entity_id', array('in' => $productIds))
|
186 |
-
->addAttributeToSelect(
|
Â
|
|
Â
|
|
187 |
Â
->setPageSize($limit);
|
188 |
Â
|
189 |
Â
foreach ($productCollection as $product) {
|
190 |
Â
//add only salable products
|
191 |
-
|
192 |
Â
$productsToDisplay[] = $product;
|
Â
|
|
193 |
Â
}
|
194 |
Â
|
195 |
Â
return $productsToDisplay;
|
@@ -200,38 +230,50 @@ class Dotdigitalgroup_Email_Block_Edc extends Mage_Core_Block_Template
|
|
200 |
Â
*
|
201 |
Â
* @param $mode
|
202 |
Â
* @param $limit
|
Â
|
|
203 |
Â
* @return Varien_Data_Collection
|
204 |
Â
*/
|
205 |
Â
protected function _getBestSellersCollection($mode, $limit)
|
206 |
Â
{
|
207 |
-
$from
|
208 |
Â
$locale = Mage::app()->getLocale()->getLocale();
|
209 |
-
$to
|
210 |
-
|
211 |
-
$productCollection = Mage::getResourceModel(
|
212 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
213 |
Â
->addOrderedQty($from, $to)
|
214 |
Â
->setOrder('ordered_qty', 'desc')
|
Â
|
|
215 |
Â
->setPageSize($limit);
|
216 |
Â
|
217 |
-
Mage::getSingleton('cataloginventory/stock')
|
218 |
-
|
Â
|
|
219 |
Â
|
220 |
-
$
|
221 |
-
$
|
222 |
Â
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
Â
//load by category id
|
227 |
-
|
228 |
-
$category->load($
|
229 |
-
|
230 |
-
|
231 |
-
|
Â
|
|
Â
|
|
232 |
Â
|
233 |
-
$productCollection = $this->_joinCategoryOnCollection(
|
Â
|
|
Â
|
|
234 |
Â
}
|
Â
|
|
235 |
Â
return $productCollection;
|
236 |
Â
}
|
237 |
Â
|
@@ -240,43 +282,59 @@ class Dotdigitalgroup_Email_Block_Edc extends Mage_Core_Block_Template
|
|
240 |
Â
*
|
241 |
Â
* @param $mode
|
242 |
Â
* @param $limit
|
Â
|
|
243 |
Â
* @return array
|
244 |
Â
*/
|
245 |
Â
protected function _getMostViewedCollection($mode, $limit)
|
246 |
Â
{
|
247 |
Â
$productsToDisplay = array();
|
248 |
-
$from
|
249 |
-
|
Â
|
|
Â
|
|
250 |
Â
|
251 |
-
$to
|
252 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
253 |
Â
->addViewsCount($from, $to)
|
254 |
Â
->setPageSize($limit);
|
255 |
Â
|
256 |
-
$
|
257 |
-
$
|
258 |
-
if($
|
259 |
-
|
260 |
Â
|
261 |
-
|
262 |
-
$category->load($
|
Â
|
|
263 |
Â
|
264 |
-
if($
|
265 |
-
$category->loadByAttribute('name', $
|
Â
|
|
266 |
Â
|
267 |
-
$productCollection = $this->_joinCategoryOnCollection(
|
Â
|
|
Â
|
|
268 |
Â
}
|
269 |
Â
|
270 |
Â
$productIds = $productCollection->getColumnValues('entity_id');
|
271 |
Â
$productCollection->clear();
|
272 |
-
$productCollection = Mage::getResourceModel(
|
Â
|
|
Â
|
|
273 |
Â
->addIdFilter($productIds)
|
274 |
-
->addAttributeToSelect(
|
Â
|
|
Â
|
|
275 |
Â
|
276 |
Â
foreach ($productCollection as $_product) {
|
277 |
Â
//add only salable products
|
278 |
-
|
279 |
Â
$productsToDisplay[] = $_product;
|
Â
|
|
280 |
Â
}
|
281 |
Â
|
282 |
Â
return $productsToDisplay;
|
@@ -287,20 +345,23 @@ class Dotdigitalgroup_Email_Block_Edc extends Mage_Core_Block_Template
|
|
287 |
Â
*
|
288 |
Â
* @param $productCollection
|
289 |
Â
* @param $category
|
Â
|
|
290 |
Â
* @return mixed
|
291 |
Â
*/
|
292 |
Â
protected function _joinCategoryOnCollection($productCollection, $category)
|
293 |
Â
{
|
294 |
-
if ($category->getId()){
|
295 |
Â
$productCollection->getSelect()
|
296 |
Â
->joinLeft(
|
297 |
Â
array("ccpi" => 'catalog_category_product_index'),
|
298 |
Â
"e.entity_id = ccpi.product_id",
|
299 |
Â
array("category_id")
|
300 |
Â
)
|
301 |
-
->where('ccpi.category_id =?',
|
302 |
-
}else{
|
303 |
-
Mage::helper('ddg')->log(
|
Â
|
|
Â
|
|
304 |
Â
}
|
305 |
Â
|
306 |
Â
return $productCollection;
|
@@ -311,6 +372,7 @@ class Dotdigitalgroup_Email_Block_Edc extends Mage_Core_Block_Template
|
|
311 |
Â
*
|
312 |
Â
* @param $mode
|
313 |
Â
* @param $limit
|
Â
|
|
314 |
Â
* @return array
|
315 |
Â
* @throws Exception
|
316 |
Â
*/
|
@@ -318,12 +380,16 @@ class Dotdigitalgroup_Email_Block_Edc extends Mage_Core_Block_Template
|
|
318 |
Â
{
|
319 |
Â
$quoteModel = Mage::registry('current_quote');
|
320 |
Â
|
321 |
-
if (! $quoteModel) {
|
322 |
-
Mage::throwException(
|
Â
|
|
Â
|
|
323 |
Â
}
|
324 |
-
|
325 |
Â
|
326 |
-
|
Â
|
|
Â
|
|
327 |
Â
|
328 |
Â
return $productsToDisplay;
|
329 |
Â
}
|
@@ -335,12 +401,13 @@ class Dotdigitalgroup_Email_Block_Edc extends Mage_Core_Block_Template
|
|
335 |
Â
* @param $limit
|
336 |
Â
* @param $mode
|
337 |
Â
* @param $type
|
Â
|
|
338 |
Â
* @return array
|
339 |
Â
*/
|
340 |
Â
protected function getProductsToDisplay($items, $limit, $mode, $type)
|
341 |
Â
{
|
342 |
Â
//products to be display for recommended pages
|
343 |
-
$productsToDisplay
|
344 |
Â
$productsToDisplayCounter = 0;
|
345 |
Â
|
346 |
Â
$numItems = count($items);
|
@@ -348,13 +415,16 @@ class Dotdigitalgroup_Email_Block_Edc extends Mage_Core_Block_Template
|
|
348 |
Â
//no product found to display
|
349 |
Â
if ($numItems == 0 || ! $limit) {
|
350 |
Â
return array();
|
351 |
-
}elseif (count($items) > $limit) {
|
352 |
Â
$maxPerChild = 1;
|
353 |
Â
} else {
|
354 |
Â
$maxPerChild = number_format($limit / count($items));
|
355 |
Â
}
|
356 |
Â
|
357 |
-
Mage::helper('ddg')->log(
|
Â
|
|
Â
|
|
Â
|
|
358 |
Â
|
359 |
Â
foreach ($items as $item) {
|
360 |
Â
$i = 0;
|
@@ -363,17 +433,26 @@ class Dotdigitalgroup_Email_Block_Edc extends Mage_Core_Block_Template
|
|
363 |
Â
//check for product exists
|
364 |
Â
|
365 |
Â
//get single product for current mode
|
366 |
-
$recommendedProducts = $this->_getRecommendedProduct(
|
367 |
-
|
Â
|
|
Â
|
|
368 |
Â
|
369 |
Â
$recommendedProducts = Mage::getModel('catalog/product')
|
370 |
Â
->getCollection()
|
371 |
Â
->addIdFilter($recommendedProducts)
|
372 |
-
->addAttributeToSelect(
|
Â
|
|
Â
|
|
Â
|
|
373 |
Â
|
374 |
Â
foreach ($recommendedProducts as $product) {
|
375 |
Â
//check if still exists
|
376 |
-
if ($product->getId() && $productsToDisplayCounter < $limit
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
377 |
Â
//we have a product to display
|
378 |
Â
$productsToDisplay[$product->getId()] = $product;
|
379 |
Â
$i++;
|
@@ -390,21 +469,28 @@ class Dotdigitalgroup_Email_Block_Edc extends Mage_Core_Block_Template
|
|
390 |
Â
|
391 |
Â
//check for more space to fill up the table with fallback products
|
392 |
Â
if ($productsToDisplayCounter < $limit) {
|
393 |
-
$fallbackIds
|
Â
|
|
394 |
Â
$productCollection = Mage::getModel('catalog/product')
|
395 |
Â
->getCollection()
|
396 |
Â
->addIdFilter($fallbackIds)
|
397 |
-
->addAttributeToSelect(
|
Â
|
|
Â
|
|
Â
|
|
398 |
Â
|
399 |
Â
foreach ($productCollection as $product) {
|
400 |
-
if($product->isSaleable())
|
401 |
Â
$productsToDisplay[$product->getId()] = $product;
|
Â
|
|
Â
|
|
402 |
Â
//stop the limit was reached
|
403 |
Â
if (count($productsToDisplay) == $limit) {
|
404 |
Â
break;
|
405 |
Â
}
|
406 |
Â
}
|
407 |
Â
}
|
Â
|
|
408 |
Â
return $productsToDisplay;
|
409 |
Â
}
|
410 |
Â
}
|
2 |
Â
|
3 |
Â
class Dotdigitalgroup_Email_Block_Edc extends Mage_Core_Block_Template
|
4 |
Â
{
|
5 |
+
|
6 |
+
protected $_edcType;
|
7 |
Â
|
8 |
Â
protected function _construct()
|
9 |
Â
{
|
11 |
Â
parent::_construct();
|
12 |
Â
|
13 |
Â
if ($this->getRequest()->getControllerName() == 'quoteproducts') {
|
14 |
+
$this->_edcType = 'quote_products';
|
15 |
Â
}
|
16 |
Â
}
|
17 |
Â
|
18 |
Â
/**
|
19 |
Â
* Prepare layout, set the template.
|
20 |
+
*
|
21 |
Â
* @return Mage_Core_Block_Abstract|void
|
22 |
Â
*/
|
23 |
Â
protected function _prepareLayout()
|
31 |
Â
* Product related items.
|
32 |
Â
*
|
33 |
Â
* @param Mage_Catalog_Model_Product $productModel
|
34 |
+
* @param $mode
|
35 |
Â
*
|
36 |
Â
* @return array
|
37 |
Â
*/
|
38 |
+
protected function _getRecommendedProduct(Mage_Catalog_Model_Product $productModel,
|
39 |
+
$mode
|
40 |
+
)
|
41 |
Â
{
|
42 |
Â
//array of products to display
|
43 |
Â
$products = array();
|
44 |
+
switch ($mode) {
|
45 |
Â
case 'related':
|
46 |
Â
$products = $productModel->getRelatedProducts();
|
47 |
Â
break;
|
54 |
Â
|
55 |
Â
}
|
56 |
Â
$productIds = array();
|
57 |
+
foreach ($products as $product) {
|
58 |
Â
$productIds[] = $product->getId();
|
59 |
Â
}
|
60 |
+
|
61 |
Â
return $productIds;
|
62 |
Â
}
|
63 |
Â
|
64 |
Â
public function getTextForUrl($store)
|
65 |
Â
{
|
66 |
Â
$store = Mage::app()->getStore($store);
|
67 |
+
|
68 |
Â
return $store->getConfig(
|
69 |
Â
Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_DYNAMIC_CONTENT_LINK_TEXT
|
70 |
Â
);
|
83 |
Â
|
84 |
Â
/**
|
85 |
Â
* Number of the colums.
|
86 |
+
*
|
87 |
Â
* @return int|mixed
|
88 |
Â
* @throws Exception
|
89 |
Â
*/
|
90 |
Â
public function getColumnCount()
|
91 |
Â
{
|
92 |
+
return Mage::helper('ddg/recommended')->getDisplayLimitByMode(
|
93 |
+
$this->getRequest()->getActionName()
|
94 |
+
);
|
95 |
Â
}
|
96 |
Â
|
97 |
Â
/**
|
98 |
Â
* Price html.
|
99 |
+
*
|
100 |
Â
* @param $product
|
101 |
Â
*
|
102 |
Â
* @return string
|
105 |
Â
{
|
106 |
Â
$this->setTemplate('connector/product/price.phtml');
|
107 |
Â
$this->setProduct($product);
|
108 |
+
|
109 |
Â
return $this->toHtml();
|
110 |
Â
}
|
111 |
Â
|
117 |
Â
*/
|
118 |
Â
public function getLoadedProductCollection()
|
119 |
Â
{
|
120 |
+
$mode = $this->getRequest()->getActionName();
|
121 |
+
$result = array();
|
122 |
Â
$limit = Mage::helper('ddg/recommended')->getDisplayLimitByMode($mode);
|
123 |
+
if ( ! $this->_edcType) {
|
124 |
+
$this->_edcType = $mode;
|
125 |
+
}
|
126 |
+
|
127 |
Â
|
128 |
+
switch ($this->_edcType) {
|
129 |
Â
case 'recentlyviewed':
|
130 |
+
$result = $this->_getRecentlyViewedCollection($limit);
|
131 |
Â
break;
|
132 |
Â
case 'push':
|
133 |
+
$result = $this->_getProductPushCollection($limit);
|
134 |
Â
break;
|
135 |
Â
case 'bestsellers':
|
136 |
+
$result = $this->_getBestSellersCollection($mode, $limit);
|
137 |
Â
break;
|
138 |
Â
case 'mostviewed':
|
139 |
+
$result = $this->_getMostViewedCollection($mode, $limit);
|
140 |
Â
break;
|
141 |
Â
case 'quote_products':
|
142 |
+
$result = $this->_getQuoteProductCollection($mode, $limit);
|
143 |
Â
break;
|
144 |
Â
}
|
145 |
+
|
146 |
+
return $result;
|
147 |
Â
}
|
148 |
Â
|
149 |
Â
/**
|
150 |
Â
* get collection for recently viewed products
|
151 |
Â
*
|
152 |
Â
* @param $limit
|
153 |
+
*
|
154 |
Â
* @return array
|
155 |
Â
* @throws Exception
|
156 |
Â
*/
|
157 |
Â
protected function _getRecentlyViewedCollection($limit)
|
158 |
Â
{
|
159 |
Â
$productsToDisplay = array();
|
160 |
+
$customerId = $this->getRequest()->getParam('customer_id');
|
161 |
Â
|
162 |
Â
//login customer to receive the recent products
|
163 |
+
$session = Mage::getSingleton('customer/session');
|
164 |
Â
$isLoggedIn = $session->loginById($customerId);
|
165 |
Â
|
166 |
Â
/** @var Mage_Reports_Block_Product_Viewed $collection */
|
167 |
+
$collection = Mage::getSingleton('Mage_Reports_Block_Product_Viewed');
|
168 |
+
$productItems = $collection->getItemsCollection()
|
169 |
+
->setPageSize($limit);
|
170 |
+
|
171 |
+
Mage::helper('ddg')->log(
|
172 |
+
'Recentlyviewed customer : ' . $customerId . ', limit : ' . $limit
|
173 |
+
.
|
174 |
+
', items found : ' . count($productItems)
|
175 |
+
. ', is customer logged in : ' . $isLoggedIn . ', products :'
|
176 |
+
. count($productsToDisplay)
|
177 |
+
);
|
178 |
+
//get the product ids from items collection
|
179 |
+
$productIds = $productItems->getColumnValues('product_id');
|
180 |
+
//get product collection to check for salable
|
181 |
+
$productCollection = Mage::getModel('catalog/product')->getCollection()
|
182 |
+
->addAttributeToSelect('*')
|
183 |
+
->addFieldToFilter('entity_id', array('in' => $productIds));
|
184 |
+
//show products only if is salable
|
185 |
+
foreach ($productCollection as $product) {
|
186 |
+
if ($product->isSalable()) {
|
187 |
+
$productsToDisplay[$product->getId()] = $product;
|
188 |
+
}
|
189 |
+
|
190 |
+
}
|
191 |
Â
$session->logout();
|
192 |
Â
|
193 |
Â
return $productsToDisplay;
|
197 |
Â
* get collection for push items
|
198 |
Â
*
|
199 |
Â
* @param $limit
|
200 |
+
*
|
201 |
Â
* @return array
|
202 |
Â
*/
|
203 |
Â
protected function _getProductPushCollection($limit)
|
204 |
Â
{
|
205 |
Â
$productsToDisplay = array();
|
206 |
+
$productIds = Mage::helper('ddg/recommended')->getProductPushIds(
|
207 |
+
);
|
208 |
Â
|
209 |
+
$productCollection = Mage::getResourceModel(
|
210 |
+
'catalog/product_collection'
|
211 |
+
)
|
212 |
Â
->addAttributeToFilter('entity_id', array('in' => $productIds))
|
213 |
+
->addAttributeToSelect(
|
214 |
+
array('product_url', 'name', 'store_id', 'small_image', 'price')
|
215 |
+
)
|
216 |
Â
->setPageSize($limit);
|
217 |
Â
|
218 |
Â
foreach ($productCollection as $product) {
|
219 |
Â
//add only salable products
|
220 |
+
if ($product->isSaleable()) {
|
221 |
Â
$productsToDisplay[] = $product;
|
222 |
+
}
|
223 |
Â
}
|
224 |
Â
|
225 |
Â
return $productsToDisplay;
|
230 |
Â
*
|
231 |
Â
* @param $mode
|
232 |
Â
* @param $limit
|
233 |
+
*
|
234 |
Â
* @return Varien_Data_Collection
|
235 |
Â
*/
|
236 |
Â
protected function _getBestSellersCollection($mode, $limit)
|
237 |
Â
{
|
238 |
+
$from = Mage::helper('ddg/recommended')->getTimeFromConfig($mode);
|
239 |
Â
$locale = Mage::app()->getLocale()->getLocale();
|
240 |
+
$to = Zend_Date::now($locale)->toString(Zend_Date::ISO_8601);
|
241 |
+
|
242 |
+
$productCollection = Mage::getResourceModel(
|
243 |
+
'reports/product_collection'
|
244 |
+
)
|
245 |
+
->addAttributeToSelect(
|
246 |
+
array('product_url', 'name', 'store_id', 'small_image', 'price')
|
247 |
+
)
|
248 |
Â
->addOrderedQty($from, $to)
|
249 |
Â
->setOrder('ordered_qty', 'desc')
|
250 |
+
->addWebsiteFilter(Mage::app()->getWebsite()->getId())
|
251 |
Â
->setPageSize($limit);
|
252 |
Â
|
253 |
+
Mage::getSingleton('cataloginventory/stock')
|
254 |
+
->addInStockFilterToCollection($productCollection);
|
255 |
+
$productCollection->addAttributeToFilter('is_saleable', true);
|
256 |
Â
|
257 |
+
$catId = Mage::app()->getRequest()->getParam('category_id', false);
|
258 |
+
$catName = Mage::app()->getRequest()->getParam('category_name', false);
|
259 |
Â
|
260 |
+
//check for params
|
261 |
+
if ($catId or $catName) {
|
262 |
+
$category = Mage::getModel('catalog/category');
|
263 |
Â
//load by category id
|
264 |
+
if ($catId) {
|
265 |
+
$category->load($catId);
|
266 |
+
}
|
267 |
+
//load by the category name
|
268 |
+
if ($catName) {
|
269 |
+
$category->loadByAttribute('name', $catName);
|
270 |
+
}
|
271 |
Â
|
272 |
+
$productCollection = $this->_joinCategoryOnCollection(
|
273 |
+
$productCollection, $category
|
274 |
+
);
|
275 |
Â
}
|
276 |
+
|
277 |
Â
return $productCollection;
|
278 |
Â
}
|
279 |
Â
|
282 |
Â
*
|
283 |
Â
* @param $mode
|
284 |
Â
* @param $limit
|
285 |
+
*
|
286 |
Â
* @return array
|
287 |
Â
*/
|
288 |
Â
protected function _getMostViewedCollection($mode, $limit)
|
289 |
Â
{
|
290 |
Â
$productsToDisplay = array();
|
291 |
+
$from = Mage::helper('ddg/recommended')->getTimeFromConfig(
|
292 |
+
$mode
|
293 |
+
);
|
294 |
+
$locale = Mage::app()->getLocale()->getLocale();
|
295 |
Â
|
296 |
+
$to = Zend_Date::now($locale)->toString(
|
297 |
+
Zend_Date::ISO_8601
|
298 |
+
);
|
299 |
+
$productCollection = Mage::getResourceModel(
|
300 |
+
'reports/product_collection'
|
301 |
+
)
|
302 |
Â
->addViewsCount($from, $to)
|
303 |
Â
->setPageSize($limit);
|
304 |
Â
|
305 |
+
$catId = Mage::app()->getRequest()->getParam('category_id');
|
306 |
+
$catName = Mage::app()->getRequest()->getParam('category_name');
|
307 |
+
if ($catId or $catName) {
|
308 |
+
$category = Mage::getModel('catalog/category');
|
309 |
Â
|
310 |
+
if ($catId) {
|
311 |
+
$category->load($catId);
|
312 |
+
}
|
313 |
Â
|
314 |
+
if ($catName) {
|
315 |
+
$category->loadByAttribute('name', $catName);
|
316 |
+
}
|
317 |
Â
|
318 |
+
$productCollection = $this->_joinCategoryOnCollection(
|
319 |
+
$productCollection, $category
|
320 |
+
);
|
321 |
Â
}
|
322 |
Â
|
323 |
Â
$productIds = $productCollection->getColumnValues('entity_id');
|
324 |
Â
$productCollection->clear();
|
325 |
+
$productCollection = Mage::getResourceModel(
|
326 |
+
'catalog/product_collection'
|
327 |
+
)
|
328 |
Â
->addIdFilter($productIds)
|
329 |
+
->addAttributeToSelect(
|
330 |
+
array('product_url', 'name', 'store_id', 'small_image', 'price')
|
331 |
+
);
|
332 |
Â
|
333 |
Â
foreach ($productCollection as $_product) {
|
334 |
Â
//add only salable products
|
335 |
+
if ($_product->isSalable()) {
|
336 |
Â
$productsToDisplay[] = $_product;
|
337 |
+
}
|
338 |
Â
}
|
339 |
Â
|
340 |
Â
return $productsToDisplay;
|
345 |
Â
*
|
346 |
Â
* @param $productCollection
|
347 |
Â
* @param $category
|
348 |
+
*
|
349 |
Â
* @return mixed
|
350 |
Â
*/
|
351 |
Â
protected function _joinCategoryOnCollection($productCollection, $category)
|
352 |
Â
{
|
353 |
+
if ($category->getId()) {
|
354 |
Â
$productCollection->getSelect()
|
355 |
Â
->joinLeft(
|
356 |
Â
array("ccpi" => 'catalog_category_product_index'),
|
357 |
Â
"e.entity_id = ccpi.product_id",
|
358 |
Â
array("category_id")
|
359 |
Â
)
|
360 |
+
->where('ccpi.category_id =?', $category->getId());
|
361 |
+
} else {
|
362 |
+
Mage::helper('ddg')->log(
|
363 |
+
'Most viewed. Category id/name is invalid. It does not exist.'
|
364 |
+
);
|
365 |
Â
}
|
366 |
Â
|
367 |
Â
return $productCollection;
|
372 |
Â
*
|
373 |
Â
* @param $mode
|
374 |
Â
* @param $limit
|
375 |
+
*
|
376 |
Â
* @return array
|
377 |
Â
* @throws Exception
|
378 |
Â
*/
|
380 |
Â
{
|
381 |
Â
$quoteModel = Mage::registry('current_quote');
|
382 |
Â
|
383 |
+
if ( ! $quoteModel) {
|
384 |
+
Mage::throwException(
|
385 |
+
Mage::helper('ddg')->__('no current_quote found for EDC')
|
386 |
+
);
|
387 |
Â
}
|
388 |
+
$quoteItems = $quoteModel->getAllItems();
|
389 |
Â
|
390 |
+
$productsToDisplay = $this->getProductsToDisplay(
|
391 |
+
$quoteItems, $limit, $mode, 'QUOTE'
|
392 |
+
);
|
393 |
Â
|
394 |
Â
return $productsToDisplay;
|
395 |
Â
}
|
401 |
Â
* @param $limit
|
402 |
Â
* @param $mode
|
403 |
Â
* @param $type
|
404 |
+
*
|
405 |
Â
* @return array
|
406 |
Â
*/
|
407 |
Â
protected function getProductsToDisplay($items, $limit, $mode, $type)
|
408 |
Â
{
|
409 |
Â
//products to be display for recommended pages
|
410 |
+
$productsToDisplay = array();
|
411 |
Â
$productsToDisplayCounter = 0;
|
412 |
Â
|
413 |
Â
$numItems = count($items);
|
415 |
Â
//no product found to display
|
416 |
Â
if ($numItems == 0 || ! $limit) {
|
417 |
Â
return array();
|
418 |
+
} elseif (count($items) > $limit) {
|
419 |
Â
$maxPerChild = 1;
|
420 |
Â
} else {
|
421 |
Â
$maxPerChild = number_format($limit / count($items));
|
422 |
Â
}
|
423 |
Â
|
424 |
+
Mage::helper('ddg')->log(
|
425 |
+
'DYNAMIC ' . $type . ' PRODUCTS : limit ' . $limit . ' products : '
|
426 |
+
. $numItems . ', max per child : ' . $maxPerChild
|
427 |
+
);
|
428 |
Â
|
429 |
Â
foreach ($items as $item) {
|
430 |
Â
$i = 0;
|
433 |
Â
//check for product exists
|
434 |
Â
|
435 |
Â
//get single product for current mode
|
436 |
+
$recommendedProducts = $this->_getRecommendedProduct(
|
437 |
+
$product, $mode
|
438 |
+
);
|
439 |
+
if ( ! empty($recommendedProducts)) {
|
440 |
Â
|
441 |
Â
$recommendedProducts = Mage::getModel('catalog/product')
|
442 |
Â
->getCollection()
|
443 |
Â
->addIdFilter($recommendedProducts)
|
444 |
+
->addAttributeToSelect(
|
445 |
+
array('product_url', 'name', 'store_id', 'small_image',
|
446 |
+
'price')
|
447 |
+
);
|
448 |
Â
|
449 |
Â
foreach ($recommendedProducts as $product) {
|
450 |
Â
//check if still exists
|
451 |
+
if ($product->getId() && $productsToDisplayCounter < $limit
|
452 |
+
&& $i <= $maxPerChild
|
453 |
+
&& $product->isSaleable()
|
454 |
+
&& ! $product->getParentId()
|
455 |
+
) {
|
456 |
Â
//we have a product to display
|
457 |
Â
$productsToDisplay[$product->getId()] = $product;
|
458 |
Â
$i++;
|
469 |
Â
|
470 |
Â
//check for more space to fill up the table with fallback products
|
471 |
Â
if ($productsToDisplayCounter < $limit) {
|
472 |
+
$fallbackIds = Mage::helper('ddg/recommended')
|
473 |
+
->getFallbackIds();
|
474 |
Â
$productCollection = Mage::getModel('catalog/product')
|
475 |
Â
->getCollection()
|
476 |
Â
->addIdFilter($fallbackIds)
|
477 |
+
->addAttributeToSelect(
|
478 |
+
array('product_url', 'name', 'store_id', 'small_image',
|
479 |
+
'price')
|
480 |
+
);
|
481 |
Â
|
482 |
Â
foreach ($productCollection as $product) {
|
483 |
+
if ($product->isSaleable()) {
|
484 |
Â
$productsToDisplay[$product->getId()] = $product;
|
485 |
+
}
|
486 |
+
|
487 |
Â
//stop the limit was reached
|
488 |
Â
if (count($productsToDisplay) == $limit) {
|
489 |
Â
break;
|
490 |
Â
}
|
491 |
Â
}
|
492 |
Â
}
|
493 |
+
|
494 |
Â
return $productsToDisplay;
|
495 |
Â
}
|
496 |
Â
}
|
@@ -3,8 +3,10 @@
|
|
3 |
Â
|
4 |
Â
class Dotdigitalgroup_Email_Block_Feefo extends Mage_Core_Block_Template
|
5 |
Â
{
|
Â
|
|
6 |
Â
/**
|
7 |
Â
* Prepare layout, set the template.
|
Â
|
|
8 |
Â
* @return Mage_Core_Block_Abstract|void
|
9 |
Â
*/
|
10 |
Â
protected function _prepareLayout()
|
@@ -21,15 +23,17 @@ class Dotdigitalgroup_Email_Block_Feefo extends Mage_Core_Block_Template
|
|
21 |
Â
*/
|
22 |
Â
public function getServiceScoreLogo()
|
23 |
Â
{
|
24 |
-
$helper
|
25 |
-
$url
|
26 |
-
$logon
|
27 |
Â
$template = '';
|
28 |
Â
|
29 |
-
|
30 |
Â
$template = '&template=' . $helper->getFeefoLogoTemplate();
|
31 |
-
|
32 |
-
$
|
Â
|
|
Â
|
|
33 |
Â
|
34 |
Â
return
|
35 |
Â
"<a href=$vendorUrl target='_blank'>
|
@@ -44,24 +48,28 @@ class Dotdigitalgroup_Email_Block_Feefo extends Mage_Core_Block_Template
|
|
44 |
Â
*/
|
45 |
Â
public function getQuoteProducts()
|
46 |
Â
{
|
47 |
-
$products
|
48 |
-
$quoteId
|
49 |
Â
$quoteModel = Mage::getModel('sales/quote')->load($quoteId);
|
50 |
Â
//quote id param
|
51 |
-
|
52 |
-
Mage::throwException(
|
Â
|
|
Â
|
|
Â
|
|
53 |
Â
|
54 |
Â
$quoteItems = $quoteModel->getAllItems();
|
55 |
Â
|
56 |
-
if(count($quoteItems) == 0)
|
57 |
Â
return array();
|
Â
|
|
58 |
Â
|
59 |
Â
/** @var Mage_Sales_Model_Quote_Item $item */
|
60 |
-
foreach($quoteItems as $item)
|
61 |
-
{
|
62 |
Â
$productModel = $item->getProduct();
|
63 |
-
if ($productModel->getId())
|
64 |
Â
$products[$productModel->getSku()] = $productModel->getName();
|
Â
|
|
65 |
Â
}
|
66 |
Â
|
67 |
Â
return $products;
|
@@ -74,33 +82,37 @@ class Dotdigitalgroup_Email_Block_Feefo extends Mage_Core_Block_Template
|
|
74 |
Â
*/
|
75 |
Â
public function getProductsReview()
|
76 |
Â
{
|
77 |
-
$check
|
78 |
-
$reviews
|
79 |
-
|
80 |
-
$
|
81 |
-
|
82 |
-
$logon
|
83 |
-
$limit
|
84 |
-
$products
|
85 |
-
|
86 |
-
foreach($products as $sku => $name)
|
87 |
-
|
88 |
-
|
Â
|
|
89 |
Â
$doc = new DOMDocument();
|
90 |
Â
$xsl = new XSLTProcessor();
|
91 |
-
if ($check)
|
92 |
-
$doc->load($
|
93 |
-
else
|
94 |
-
$doc->load($
|
Â
|
|
95 |
Â
|
96 |
Â
$xsl->importStyleSheet($doc);
|
97 |
Â
$doc->load($url);
|
98 |
Â
$productReview = $xsl->transformToXML($doc);
|
99 |
Â
|
100 |
-
|
101 |
Â
$reviews[$name] = $xsl->transformToXML($doc);
|
Â
|
|
102 |
Â
$check = false;
|
103 |
Â
}
|
Â
|
|
104 |
Â
return $reviews;
|
105 |
Â
}
|
106 |
Â
}
|
3 |
Â
|
4 |
Â
class Dotdigitalgroup_Email_Block_Feefo extends Mage_Core_Block_Template
|
5 |
Â
{
|
6 |
+
|
7 |
Â
/**
|
8 |
Â
* Prepare layout, set the template.
|
9 |
+
*
|
10 |
Â
* @return Mage_Core_Block_Abstract|void
|
11 |
Â
*/
|
12 |
Â
protected function _prepareLayout()
|
23 |
Â
*/
|
24 |
Â
public function getServiceScoreLogo()
|
25 |
Â
{
|
26 |
+
$helper = Mage::helper('ddg');
|
27 |
+
$url = 'http://www.feefo.com/feefo/feefologo.jsp?logon=';
|
28 |
+
$logon = $helper->getFeefoLogon();
|
29 |
Â
$template = '';
|
30 |
Â
|
31 |
+
if ($helper->getFeefoLogoTemplate()) {
|
32 |
Â
$template = '&template=' . $helper->getFeefoLogoTemplate();
|
33 |
+
}
|
34 |
+
$fullUrl = $url . $logon . $template;
|
35 |
+
$vendorUrl = 'http://www.feefo.com/feefo/viewvendor.jsp?logon='
|
36 |
+
. $logon;
|
37 |
Â
|
38 |
Â
return
|
39 |
Â
"<a href=$vendorUrl target='_blank'>
|
48 |
Â
*/
|
49 |
Â
public function getQuoteProducts()
|
50 |
Â
{
|
51 |
+
$products = array();
|
52 |
+
$quoteId = Mage::app()->getRequest()->getParam('quote_id');
|
53 |
Â
$quoteModel = Mage::getModel('sales/quote')->load($quoteId);
|
54 |
Â
//quote id param
|
55 |
+
if ( ! $quoteModel->getId()) {
|
56 |
+
Mage::throwException(
|
57 |
+
Mage::helper('ddg')->__('cannot continue, missing quote data')
|
58 |
+
);
|
59 |
+
}
|
60 |
Â
|
61 |
Â
$quoteItems = $quoteModel->getAllItems();
|
62 |
Â
|
63 |
+
if (count($quoteItems) == 0) {
|
64 |
Â
return array();
|
65 |
+
}
|
66 |
Â
|
67 |
Â
/** @var Mage_Sales_Model_Quote_Item $item */
|
68 |
+
foreach ($quoteItems as $item) {
|
Â
|
|
69 |
Â
$productModel = $item->getProduct();
|
70 |
+
if ($productModel->getId()) {
|
71 |
Â
$products[$productModel->getSku()] = $productModel->getName();
|
72 |
+
}
|
73 |
Â
}
|
74 |
Â
|
75 |
Â
return $products;
|
82 |
Â
*/
|
83 |
Â
public function getProductsReview()
|
84 |
Â
{
|
85 |
+
$check = true;
|
86 |
+
$reviews = array();
|
87 |
+
$helper = Mage::helper('ddg');
|
88 |
+
$feeforDir = Mage::getModel('core/config_options')
|
89 |
+
->getLibDir() . DS . 'connector' . DS . 'feefo';
|
90 |
+
$logon = $helper->getFeefoLogon();
|
91 |
+
$limit = $helper->getFeefoReviewsPerProduct();
|
92 |
+
$products = $this->getQuoteProducts();
|
93 |
+
|
94 |
+
foreach ($products as $sku => $name) {
|
95 |
+
$url = "http://www.feefo.com/feefo/xmlfeed.jsp?logon=" . $logon
|
96 |
+
. "&limit=" . $limit . "&vendorref=" . $sku
|
97 |
+
. "&mode=productonly";
|
98 |
Â
$doc = new DOMDocument();
|
99 |
Â
$xsl = new XSLTProcessor();
|
100 |
+
if ($check) {
|
101 |
+
$doc->load($feeforDir . DS . "feedback.xsl");
|
102 |
+
} else {
|
103 |
+
$doc->load($feeforDir . DS . "feedback-no-th.xsl");
|
104 |
+
}
|
105 |
Â
|
106 |
Â
$xsl->importStyleSheet($doc);
|
107 |
Â
$doc->load($url);
|
108 |
Â
$productReview = $xsl->transformToXML($doc);
|
109 |
Â
|
110 |
+
if (strpos($productReview, '<td') !== false) {
|
111 |
Â
$reviews[$name] = $xsl->transformToXML($doc);
|
112 |
+
}
|
113 |
Â
$check = false;
|
114 |
Â
}
|
115 |
+
|
116 |
Â
return $reviews;
|
117 |
Â
}
|
118 |
Â
}
|
@@ -4,72 +4,82 @@ class Dotdigitalgroup_Email_Block_Order extends Dotdigitalgroup_Email_Block_Edc
|
|
4 |
Â
{
|
5 |
Â
|
6 |
Â
/**
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
Â
protected function _prepareLayout()
|
12 |
Â
{
|
13 |
Â
if ($root = $this->getLayout()->getBlock('root')) {
|
14 |
Â
$root->setTemplate('page/blank.phtml');
|
15 |
Â
}
|
16 |
Â
if ($headBlock = $this->getLayout()->getBlock('head')) {
|
17 |
-
$headBlock->setTitle(
|
Â
|
|
Â
|
|
18 |
Â
}
|
19 |
Â
}
|
20 |
Â
|
21 |
Â
/**
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
Â
public function getOrder()
|
27 |
Â
{
|
28 |
Â
$order = Mage::registry('current_order');
|
29 |
-
if (! $order) {
|
30 |
-
Mage::throwException(
|
Â
|
|
Â
|
|
31 |
Â
}
|
32 |
Â
|
33 |
Â
return $order;
|
34 |
Â
}
|
35 |
Â
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
Â
|
|
Â
|
|
44 |
Â
|
45 |
-
|
46 |
-
|
47 |
Â
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
* @return Mage_Catalog_Model_Resource_Product_Collection
|
59 |
-
*/
|
60 |
-
public function getItems()
|
61 |
-
{
|
62 |
-
$order = $this->getOrder();
|
63 |
-
$items = $order->getAllVisibleItems();
|
64 |
-
$productIds = array();
|
65 |
-
//get the product ids for the collection
|
66 |
-
foreach ( $items as $item ) {
|
67 |
-
$productIds[] = $item->getProductId();
|
68 |
-
}
|
69 |
-
$items = Mage::getModel('catalog/product')->getCollection()
|
70 |
-
->addAttributeToSelect('*')
|
71 |
-
->addFieldToFilter('entity_id', array('in' => $productIds));
|
72 |
Â
|
73 |
-
|
74 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
75 |
Â
}
|
4 |
Â
{
|
5 |
Â
|
6 |
Â
/**
|
7 |
+
* Prepare layout, set template and title.
|
8 |
+
*
|
9 |
+
* @return Mage_Core_Block_Abstract|void
|
10 |
+
*/
|
11 |
Â
protected function _prepareLayout()
|
12 |
Â
{
|
13 |
Â
if ($root = $this->getLayout()->getBlock('root')) {
|
14 |
Â
$root->setTemplate('page/blank.phtml');
|
15 |
Â
}
|
16 |
Â
if ($headBlock = $this->getLayout()->getBlock('head')) {
|
17 |
+
$headBlock->setTitle(
|
18 |
+
$this->__('Order # %s', $this->getOrder()->getRealOrderId())
|
19 |
+
);
|
20 |
Â
}
|
21 |
Â
}
|
22 |
Â
|
23 |
Â
/**
|
24 |
+
* Current Order.
|
25 |
+
*
|
26 |
+
* @return Mage_Core_Model_Abstract|mixed
|
27 |
+
*/
|
28 |
Â
public function getOrder()
|
29 |
Â
{
|
30 |
Â
$order = Mage::registry('current_order');
|
31 |
+
if ( ! $order) {
|
32 |
+
Mage::throwException(
|
33 |
+
Mage::helper('ddg')->__('no current_order found for EDC')
|
34 |
+
);
|
35 |
Â
}
|
36 |
Â
|
37 |
Â
return $order;
|
38 |
Â
}
|
39 |
Â
|
40 |
+
/**
|
41 |
+
* Dysplay mode.
|
42 |
+
*
|
43 |
+
* @return string
|
44 |
+
*/
|
45 |
+
public function getMode()
|
46 |
+
{
|
47 |
+
$website = Mage::app()->getStore($this->getOrder()->getStoreId())
|
48 |
+
->getWebsite();
|
49 |
+
$mode = Mage::helper('ddg')->getReviewDisplayType($website);
|
50 |
Â
|
51 |
+
return $mode;
|
52 |
+
}
|
53 |
Â
|
54 |
+
/**
|
55 |
+
* Order website.
|
56 |
+
*
|
57 |
+
* @return Mage_Core_Model_Website
|
58 |
+
*/
|
59 |
+
public function getWebsite()
|
60 |
+
{
|
61 |
+
return Mage::app()->getStore($this->getOrder()->getStoreId())
|
62 |
+
->getWebsite();
|
63 |
+
}
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
64 |
Â
|
65 |
+
/**
|
66 |
+
* Product items to display.
|
67 |
+
*
|
68 |
+
* @return Mage_Catalog_Model_Resource_Product_Collection
|
69 |
+
*/
|
70 |
+
public function getItems()
|
71 |
+
{
|
72 |
+
$order = $this->getOrder();
|
73 |
+
$items = $order->getAllVisibleItems();
|
74 |
+
$productIds = array();
|
75 |
+
//get the product ids for the collection
|
76 |
+
foreach ($items as $item) {
|
77 |
+
$productIds[] = $item->getProductId();
|
78 |
+
}
|
79 |
+
$items = Mage::getModel('catalog/product')->getCollection()
|
80 |
+
->addAttributeToSelect('*')
|
81 |
+
->addFieldToFilter('entity_id', array('in' => $productIds));
|
82 |
+
|
83 |
+
return $items;
|
84 |
+
}
|
85 |
Â
}
|
@@ -1,11 +1,14 @@
|
|
1 |
Â
<?php
|
2 |
-
|
Â
|
|
Â
|
|
3 |
Â
{
|
Â
|
|
4 |
Â
/**
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
Â
protected function _prepareLayout()
|
10 |
Â
{
|
11 |
Â
if ($root = $this->getLayout()->getBlock('root')) {
|
@@ -13,21 +16,27 @@ class Dotdigitalgroup_Email_Block_Order_Creditmemo extends Mage_Sales_Block_Ord
|
|
13 |
Â
}
|
14 |
Â
}
|
15 |
Â
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
Â
|
|
21 |
Â
public function getOrder()
|
22 |
Â
{
|
23 |
Â
$order = Mage::registry('current_order');
|
24 |
-
if (! $order) {
|
25 |
-
Mage::throwException(
|
Â
|
|
Â
|
|
26 |
Â
}
|
27 |
Â
|
28 |
-
if (! $order->hasCreditmemos()) {
|
29 |
-
|
30 |
-
Mage::helper('ddg')->log(
|
Â
|
|
Â
|
|
Â
|
|
31 |
Â
return false;
|
32 |
Â
}
|
33 |
Â
|
@@ -35,9 +44,10 @@ class Dotdigitalgroup_Email_Block_Order_Creditmemo extends Mage_Sales_Block_Ord
|
|
35 |
Â
}
|
36 |
Â
|
37 |
Â
/**
|
38 |
-
|
39 |
-
|
40 |
-
|
Â
|
|
41 |
Â
public function getCreditmemoItems()
|
42 |
Â
{
|
43 |
Â
return Mage::registry('current_order')->getItemsCollection();
|
1 |
Â
<?php
|
2 |
+
|
3 |
+
class Dotdigitalgroup_Email_Block_Order_Creditmemo
|
4 |
+
extends Mage_Sales_Block_Order_Creditmemo_Items
|
5 |
Â
{
|
6 |
+
|
7 |
Â
/**
|
8 |
+
* Prepare layout.
|
9 |
+
*
|
10 |
+
* @return Mage_Core_Block_Abstract|void
|
11 |
+
*/
|
12 |
Â
protected function _prepareLayout()
|
13 |
Â
{
|
14 |
Â
if ($root = $this->getLayout()->getBlock('root')) {
|
16 |
Â
}
|
17 |
Â
}
|
18 |
Â
|
19 |
+
/**
|
20 |
+
* Get current Order.
|
21 |
+
*
|
22 |
+
* @return Mage_Sales_Model_Order
|
23 |
+
* @throws Exception
|
24 |
+
*/
|
25 |
Â
public function getOrder()
|
26 |
Â
{
|
27 |
Â
$order = Mage::registry('current_order');
|
28 |
+
if ( ! $order) {
|
29 |
+
Mage::throwException(
|
30 |
+
Mage::helper('ddg')->__('no current_order found for EDC')
|
31 |
+
);
|
32 |
Â
}
|
33 |
Â
|
34 |
+
if ( ! $order->hasCreditmemos()) {
|
35 |
+
|
36 |
+
Mage::helper('ddg')->log(
|
37 |
+
'TE - no creditmemo for order : ' . $order->getId()
|
38 |
+
);
|
39 |
+
|
40 |
Â
return false;
|
41 |
Â
}
|
42 |
Â
|
44 |
Â
}
|
45 |
Â
|
46 |
Â
/**
|
47 |
+
* Order items.
|
48 |
+
*
|
49 |
+
* @return mixed
|
50 |
+
*/
|
51 |
Â
public function getCreditmemoItems()
|
52 |
Â
{
|
53 |
Â
return Mage::registry('current_order')->getItemsCollection();
|
@@ -1,10 +1,14 @@
|
|
1 |
Â
<?php
|
2 |
-
|
Â
|
|
Â
|
|
3 |
Â
{
|
Â
|
|
4 |
Â
/**
|
5 |
-
|
6 |
-
|
7 |
-
|
Â
|
|
8 |
Â
protected function _prepareLayout()
|
9 |
Â
{
|
10 |
Â
if ($root = $this->getLayout()->getBlock('root')) {
|
@@ -12,21 +16,27 @@ class Dotdigitalgroup_Email_Block_Order_Invoice extends Mage_Sales_Block_Order_I
|
|
12 |
Â
}
|
13 |
Â
}
|
14 |
Â
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
Â
|
|
20 |
Â
public function getOrder()
|
21 |
Â
{
|
22 |
Â
$order = Mage::registry('current_order');
|
23 |
-
if (! $order) {
|
24 |
-
Mage::throwException(
|
Â
|
|
Â
|
|
25 |
Â
}
|
26 |
Â
|
27 |
-
if (! $order->hasInvoices()) {
|
28 |
Â
//throw new Exception('TE - no invoice for order : '. $orderId);
|
29 |
-
Mage::helper('ddg')->log(
|
Â
|
|
Â
|
|
Â
|
|
30 |
Â
return false;
|
31 |
Â
}
|
32 |
Â
|
1 |
Â
<?php
|
2 |
+
|
3 |
+
class Dotdigitalgroup_Email_Block_Order_Invoice
|
4 |
+
extends Mage_Sales_Block_Order_Invoice_Items
|
5 |
Â
{
|
6 |
+
|
7 |
Â
/**
|
8 |
+
* Prepare layout.
|
9 |
+
*
|
10 |
+
* @return Mage_Core_Block_Abstract|void
|
11 |
+
*/
|
12 |
Â
protected function _prepareLayout()
|
13 |
Â
{
|
14 |
Â
if ($root = $this->getLayout()->getBlock('root')) {
|
16 |
Â
}
|
17 |
Â
}
|
18 |
Â
|
19 |
+
/**
|
20 |
+
* Get current order.
|
21 |
+
*
|
22 |
+
* @return Mage_Sales_Model_Order
|
23 |
+
* @throws Exception
|
24 |
+
*/
|
25 |
Â
public function getOrder()
|
26 |
Â
{
|
27 |
Â
$order = Mage::registry('current_order');
|
28 |
+
if ( ! $order) {
|
29 |
+
Mage::throwException(
|
30 |
+
Mage::helper('ddg')->__('no current_order found for EDC')
|
31 |
+
);
|
32 |
Â
}
|
33 |
Â
|
34 |
+
if ( ! $order->hasInvoices()) {
|
35 |
Â
//throw new Exception('TE - no invoice for order : '. $orderId);
|
36 |
+
Mage::helper('ddg')->log(
|
37 |
+
'TE - no invoice for order : ' . $order->getId()
|
38 |
+
);
|
39 |
+
|
40 |
Â
return false;
|
41 |
Â
}
|
42 |
Â
|
@@ -1,10 +1,14 @@
|
|
1 |
Â
<?php
|
2 |
-
|
Â
|
|
Â
|
|
3 |
Â
{
|
Â
|
|
4 |
Â
/**
|
5 |
-
|
6 |
-
|
7 |
-
|
Â
|
|
8 |
Â
protected function _prepareLayout()
|
9 |
Â
{
|
10 |
Â
if ($root = $this->getLayout()->getBlock('root')) {
|
@@ -12,20 +16,25 @@ class Dotdigitalgroup_Email_Block_Order_Shipping extends Mage_Sales_Block_Order
|
|
12 |
Â
}
|
13 |
Â
}
|
14 |
Â
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
Â
public function getOrder()
|
20 |
Â
{
|
21 |
Â
$order = Mage::registry('current_order');
|
22 |
-
if (! $order) {
|
23 |
-
Mage::throwException(
|
Â
|
|
Â
|
|
24 |
Â
}
|
25 |
Â
|
26 |
-
if (! $order->hasShipments()) {
|
27 |
-
|
28 |
-
Mage::helper('ddg')->log(
|
Â
|
|
Â
|
|
Â
|
|
29 |
Â
return false;
|
30 |
Â
}
|
31 |
Â
|
1 |
Â
<?php
|
2 |
+
|
3 |
+
class Dotdigitalgroup_Email_Block_Order_Shipping
|
4 |
+
extends Mage_Sales_Block_Order_Creditmemo_Items
|
5 |
Â
{
|
6 |
+
|
7 |
Â
/**
|
8 |
+
* Prepare layout.
|
9 |
+
*
|
10 |
+
* @return Mage_Core_Block_Abstract|void
|
11 |
+
*/
|
12 |
Â
protected function _prepareLayout()
|
13 |
Â
{
|
14 |
Â
if ($root = $this->getLayout()->getBlock('root')) {
|
16 |
Â
}
|
17 |
Â
}
|
18 |
Â
|
19 |
+
/**
|
20 |
+
* @return Mage_Sales_Model_Order
|
21 |
+
* @throws Exception
|
22 |
+
*/
|
23 |
Â
public function getOrder()
|
24 |
Â
{
|
25 |
Â
$order = Mage::registry('current_order');
|
26 |
+
if ( ! $order) {
|
27 |
+
Mage::throwException(
|
28 |
+
Mage::helper('ddg')->__('no current_order found for EDC')
|
29 |
+
);
|
30 |
Â
}
|
31 |
Â
|
32 |
+
if ( ! $order->hasShipments()) {
|
33 |
+
|
34 |
+
Mage::helper('ddg')->log(
|
35 |
+
'TE - no shipments for order : ' . $order->getId()
|
36 |
+
);
|
37 |
+
|
38 |
Â
return false;
|
39 |
Â
}
|
40 |
Â
|
@@ -2,11 +2,12 @@
|
|
2 |
Â
|
3 |
Â
class Dotdigitalgroup_Email_Block_Products extends Mage_Core_Block_Template
|
4 |
Â
{
|
Â
|
|
5 |
Â
/**
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
Â
protected function _prepareLayout()
|
11 |
Â
{
|
12 |
Â
if ($root = $this->getLayout()->getBlock('root')) {
|
@@ -20,16 +21,18 @@ class Dotdigitalgroup_Email_Block_Products extends Mage_Core_Block_Template
|
|
20 |
Â
public function getRecommendedProducts()
|
21 |
Â
{
|
22 |
Â
$productsToDisplay = array();
|
23 |
-
$orderId
|
24 |
-
$mode
|
25 |
Â
if ($orderId && $mode) {
|
26 |
Â
$orderModel = Mage::getModel('sales/order')->load($orderId);
|
27 |
Â
if ($orderModel->getId()) {
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
Â
//order products
|
32 |
-
$productRecommended = Mage::getModel(
|
Â
|
|
Â
|
|
33 |
Â
$productRecommended->setMode($mode);
|
34 |
Â
|
35 |
Â
//get the order items recommendations
|
@@ -42,23 +45,25 @@ class Dotdigitalgroup_Email_Block_Products extends Mage_Core_Block_Template
|
|
42 |
Â
|
43 |
Â
|
44 |
Â
/**
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
Â
public function getPriceHtml($product)
|
52 |
Â
{
|
53 |
Â
$this->setTemplate('connector/price.phtml');
|
54 |
Â
$this->setProduct($product);
|
Â
|
|
55 |
Â
return $this->toHtml();
|
56 |
Â
}
|
57 |
Â
|
58 |
Â
/**
|
59 |
-
|
60 |
-
|
61 |
-
|
Â
|
|
62 |
Â
public function getDisplayType()
|
63 |
Â
{
|
64 |
Â
return Mage::helper('ddg/recommended')->getDisplayType();
|
2 |
Â
|
3 |
Â
class Dotdigitalgroup_Email_Block_Products extends Mage_Core_Block_Template
|
4 |
Â
{
|
5 |
+
|
6 |
Â
/**
|
7 |
+
* Prepare layout, set template.
|
8 |
+
*
|
9 |
+
* @return Mage_Core_Block_Abstract|void
|
10 |
+
*/
|
11 |
Â
protected function _prepareLayout()
|
12 |
Â
{
|
13 |
Â
if ($root = $this->getLayout()->getBlock('root')) {
|
21 |
Â
public function getRecommendedProducts()
|
22 |
Â
{
|
23 |
Â
$productsToDisplay = array();
|
24 |
+
$orderId = $this->getRequest()->getParam('order', false);
|
25 |
+
$mode = $this->getRequest()->getParam('mode', false);
|
26 |
Â
if ($orderId && $mode) {
|
27 |
Â
$orderModel = Mage::getModel('sales/order')->load($orderId);
|
28 |
Â
if ($orderModel->getId()) {
|
29 |
+
$storeId = $orderModel->getStoreId();
|
30 |
+
$appEmulation = Mage::getSingleton('core/app_emulation');
|
31 |
+
$appEmulation->startEnvironmentEmulation($storeId);
|
32 |
Â
//order products
|
33 |
+
$productRecommended = Mage::getModel(
|
34 |
+
'ddg_automation/dynamic_recommended', $orderModel
|
35 |
+
);
|
36 |
Â
$productRecommended->setMode($mode);
|
37 |
Â
|
38 |
Â
//get the order items recommendations
|
45 |
Â
|
46 |
Â
|
47 |
Â
/**
|
48 |
+
* Price html block.
|
49 |
+
*
|
50 |
+
* @param $product
|
51 |
+
*
|
52 |
+
* @return string
|
53 |
+
*/
|
54 |
Â
public function getPriceHtml($product)
|
55 |
Â
{
|
56 |
Â
$this->setTemplate('connector/price.phtml');
|
57 |
Â
$this->setProduct($product);
|
58 |
+
|
59 |
Â
return $this->toHtml();
|
60 |
Â
}
|
61 |
Â
|
62 |
Â
/**
|
63 |
+
* Display type mode.
|
64 |
+
*
|
65 |
+
* @return mixed|string
|
66 |
+
*/
|
67 |
Â
public function getDisplayType()
|
68 |
Â
{
|
69 |
Â
return Mage::helper('ddg/recommended')->getDisplayType();
|
@@ -1,69 +1,36 @@
|
|
1 |
Â
<?php
|
2 |
Â
|
3 |
-
class Dotdigitalgroup_Email_Block_Recommended_Products
|
Â
|
|
4 |
Â
{
|
5 |
-
/**
|
6 |
-
* Slot div name.
|
7 |
-
* @var string
|
8 |
-
*/
|
9 |
-
public $slot;
|
10 |
Â
|
11 |
Â
/**
|
12 |
-
*
|
Â
|
|
Â
|
|
Â
|
|
13 |
Â
*/
|
14 |
Â
public function getLoadedProductCollection()
|
15 |
Â
{
|
16 |
Â
$orderModel = Mage::registry('current_order');
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
$
|
27 |
-
|
28 |
-
|
29 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
30 |
Â
}
|
31 |
-
|
32 |
-
/**
|
33 |
-
* Nosto products data.
|
34 |
-
* @return object
|
35 |
-
*/
|
36 |
-
public function getNostoProducts()
|
37 |
-
{
|
38 |
-
$client = Mage::getModel('ddg_automation/apiconnector_client');
|
39 |
-
//slot name, div id
|
40 |
-
$slot = Mage::app()->getRequest()->getParam('slot', false);
|
41 |
-
|
42 |
-
//email recommendation
|
43 |
-
$email = Mage::app()->getRequest()->getParam('email', false);
|
44 |
-
|
45 |
-
//no valid data for nosto recommendation
|
46 |
-
if (!$slot || ! $email)
|
47 |
-
return false;
|
48 |
-
else
|
49 |
-
$this->slot = $slot;
|
50 |
-
|
51 |
-
//html data from nosto
|
52 |
-
$data = $client->getNostoProducts($slot, $email);
|
53 |
-
|
54 |
-
//check for valid response
|
55 |
-
if (! isset($data->$email) && !isset($data->$email->$slot))
|
56 |
-
return false;
|
57 |
-
return $data->$email->$slot;
|
58 |
-
}
|
59 |
-
|
60 |
-
/**
|
61 |
-
* Slot name.
|
62 |
-
* Should be called after getNostoProducts.
|
63 |
-
* @return string
|
64 |
-
*/
|
65 |
-
public function getSlotName()
|
66 |
-
{
|
67 |
-
return $this->slot;
|
68 |
-
}
|
69 |
Â
}
|
1 |
Â
<?php
|
2 |
Â
|
3 |
+
class Dotdigitalgroup_Email_Block_Recommended_Products
|
4 |
+
extends Dotdigitalgroup_Email_Block_Edc
|
5 |
Â
{
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
6 |
Â
|
7 |
Â
/**
|
8 |
+
* Get the products to display for table.
|
9 |
+
*
|
10 |
+
* @return array
|
11 |
+
* @throws Exception
|
12 |
Â
*/
|
13 |
Â
public function getLoadedProductCollection()
|
14 |
Â
{
|
15 |
Â
$orderModel = Mage::registry('current_order');
|
16 |
+
if (! $orderModel) {
|
17 |
+
Mage::log('no current_order found for EDC');
|
18 |
+
|
19 |
+
return array();
|
20 |
+
}
|
21 |
+
|
22 |
+
//display mode based on the action name
|
23 |
+
$mode = $this->getRequest()->getActionName();
|
24 |
+
//number of product items to be displayed
|
25 |
+
$limit = Mage::helper('ddg/recommended')
|
26 |
+
->getDisplayLimitByMode(
|
27 |
+
$mode
|
28 |
+
);
|
29 |
+
$orderItems = $orderModel->getAllItems();
|
30 |
+
$productsToDisplay = $this->getProductsToDisplay(
|
31 |
+
$orderItems, $limit, $mode, 'PRODUCT'
|
32 |
+
);
|
33 |
+
|
34 |
+
return $productsToDisplay;
|
35 |
Â
}
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
36 |
Â
}
|
@@ -1,30 +1,34 @@
|
|
1 |
Â
<?php
|
2 |
Â
|
3 |
-
class Dotdigitalgroup_Email_Block_Recommended_Wishlistproducts
|
Â
|
|
4 |
Â
{
|
5 |
Â
|
6 |
Â
protected function _getWishlistItems()
|
7 |
Â
{
|
8 |
Â
$wishlist = $this->_getWishlist();
|
9 |
-
if($wishlist && count($wishlist->getItemCollection()))
|
10 |
Â
return $wishlist->getItemCollection();
|
11 |
-
else
|
12 |
Â
return array();
|
Â
|
|
13 |
Â
}
|
14 |
Â
|
15 |
-
protected function _getWishlist()
|
Â
|
|
16 |
Â
|
17 |
Â
//customer id param
|
18 |
-
|
19 |
Â
|
20 |
-
|
21 |
Â
return array();
|
Â
|
|
22 |
Â
|
23 |
Â
//load customer wishlist collection
|
24 |
Â
$wishlistModel = Mage::getModel('wishlist/wishlist')
|
25 |
-
|
26 |
Â
|
27 |
-
|
28 |
Â
}
|
29 |
Â
|
30 |
Â
/**
|
@@ -33,12 +37,14 @@ class Dotdigitalgroup_Email_Block_Recommended_Wishlistproducts extends Dotdigita
|
|
33 |
Â
public function getLoadedProductCollection()
|
34 |
Â
{
|
35 |
Â
//display mode based on the action name
|
36 |
-
$mode
|
37 |
Â
//number of product items to be displayed
|
38 |
Â
$limit = Mage::helper('ddg/recommended')->getDisplayLimitByMode($mode);
|
39 |
Â
|
40 |
Â
$items = $this->_getWishlistItems();
|
41 |
-
$productsToDisplay = $this->getProductsToDisplay(
|
Â
|
|
Â
|
|
42 |
Â
|
43 |
Â
return $productsToDisplay;
|
44 |
Â
}
|
1 |
Â
<?php
|
2 |
Â
|
3 |
+
class Dotdigitalgroup_Email_Block_Recommended_Wishlistproducts
|
4 |
+
extends Dotdigitalgroup_Email_Block_Edc
|
5 |
Â
{
|
6 |
Â
|
7 |
Â
protected function _getWishlistItems()
|
8 |
Â
{
|
9 |
Â
$wishlist = $this->_getWishlist();
|
10 |
+
if ($wishlist && count($wishlist->getItemCollection())) {
|
11 |
Â
return $wishlist->getItemCollection();
|
12 |
+
} else {
|
13 |
Â
return array();
|
14 |
+
}
|
15 |
Â
}
|
16 |
Â
|
17 |
+
protected function _getWishlist()
|
18 |
+
{
|
19 |
Â
|
20 |
Â
//customer id param
|
21 |
+
$customerId = Mage::app()->getRequest()->getParam('customer_id');
|
22 |
Â
|
23 |
+
if ( ! $customerId) {
|
24 |
Â
return array();
|
25 |
+
}
|
26 |
Â
|
27 |
Â
//load customer wishlist collection
|
28 |
Â
$wishlistModel = Mage::getModel('wishlist/wishlist')
|
29 |
+
->loadByCustomer($customerId);
|
30 |
Â
|
31 |
+
return $wishlistModel;
|
32 |
Â
}
|
33 |
Â
|
34 |
Â
/**
|
37 |
Â
public function getLoadedProductCollection()
|
38 |
Â
{
|
39 |
Â
//display mode based on the action name
|
40 |
+
$mode = $this->getRequest()->getActionName();
|
41 |
Â
//number of product items to be displayed
|
42 |
Â
$limit = Mage::helper('ddg/recommended')->getDisplayLimitByMode($mode);
|
43 |
Â
|
44 |
Â
$items = $this->_getWishlistItems();
|
45 |
+
$productsToDisplay = $this->getProductsToDisplay(
|
46 |
+
$items, $limit, $mode, 'WISHLIST'
|
47 |
+
);
|
48 |
Â
|
49 |
Â
return $productsToDisplay;
|
50 |
Â
}
|
@@ -1,29 +1,36 @@
|
|
1 |
Â
<?php
|
2 |
Â
|
3 |
-
class Dotdigitalgroup_Email_Block_Wishlist
|
Â
|
|
4 |
Â
{
|
Â
|
|
5 |
Â
protected $_website;
|
6 |
Â
|
7 |
Â
public function getWishlistItems()
|
8 |
Â
{
|
9 |
Â
$wishlist = $this->_getWishlist();
|
10 |
-
if($wishlist && count($wishlist->getItemCollection()))
|
11 |
Â
return $wishlist->getItemCollection();
|
12 |
-
else
|
13 |
Â
return false;
|
Â
|
|
14 |
Â
}
|
15 |
Â
|
16 |
-
protected function _getWishlist()
|
Â
|
|
17 |
Â
|
18 |
-
|
19 |
-
|
20 |
Â
|
21 |
-
|
22 |
Â
return false;
|
Â
|
|
23 |
Â
|
24 |
-
$wishlistModel = Mage::getModel('wishlist/wishlist')->loadByCustomer(
|
Â
|
|
Â
|
|
25 |
Â
|
26 |
-
|
27 |
Â
}
|
28 |
Â
|
29 |
Â
public function getMode()
|
1 |
Â
<?php
|
2 |
Â
|
3 |
+
class Dotdigitalgroup_Email_Block_Wishlist
|
4 |
+
extends Dotdigitalgroup_Email_Block_Edc
|
5 |
Â
{
|
6 |
+
|
7 |
Â
protected $_website;
|
8 |
Â
|
9 |
Â
public function getWishlistItems()
|
10 |
Â
{
|
11 |
Â
$wishlist = $this->_getWishlist();
|
12 |
+
if ($wishlist && count($wishlist->getItemCollection())) {
|
13 |
Â
return $wishlist->getItemCollection();
|
14 |
+
} else {
|
15 |
Â
return false;
|
16 |
+
}
|
17 |
Â
}
|
18 |
Â
|
19 |
+
protected function _getWishlist()
|
20 |
+
{
|
21 |
Â
|
22 |
+
//customer id param
|
23 |
+
$customerId = Mage::app()->getRequest()->getParam('customer_id', false);
|
24 |
Â
|
25 |
+
if ( ! $customerId) {
|
26 |
Â
return false;
|
27 |
+
}
|
28 |
Â
|
29 |
+
$wishlistModel = Mage::getModel('wishlist/wishlist')->loadByCustomer(
|
30 |
+
$customerId
|
31 |
+
);
|
32 |
Â
|
33 |
+
return $wishlistModel;
|
34 |
Â
}
|
35 |
Â
|
36 |
Â
public function getMode()
|
@@ -11,25 +11,6 @@ class Dotdigitalgroup_Email_Helper_Config
|
|
11 |
Â
const XML_PATH_CONNECTOR_API_USERNAME = 'connector_api_credentials/api/username';
|
12 |
Â
const XML_PATH_CONNECTOR_API_PASSWORD = 'connector_api_credentials/api/password';
|
13 |
Â
|
14 |
-
/**
|
15 |
-
* SMS SECTION.
|
16 |
-
*/
|
17 |
-
//enabled
|
18 |
-
const XML_PATH_CONNECTOR_SMS_ENABLED_1 = 'connector_automation_studio/sms/sms_one_enabled';
|
19 |
-
const XML_PATH_CONNECTOR_SMS_ENABLED_2 = 'connector_automation_studio/sms/sms_two_enabled';
|
20 |
-
const XML_PATH_CONNECTOR_SMS_ENABLED_3 = 'connector_automation_studio/sms/sms_three_enabled';
|
21 |
-
const XML_PATH_CONNECTOR_SMS_ENABLED_4 = 'connector_automation_studio/sms/sms_four_enabled';
|
22 |
-
//status
|
23 |
-
const XML_PATH_CONNECTOR_SMS_STATUS_1 = 'connector_automation_studio/sms/sms_one_status';
|
24 |
-
const XML_PATH_CONNECTOR_SMS_STATUS_2 = 'connector_automation_studio/sms/sms_two_status';
|
25 |
-
const XML_PATH_CONNECTOR_SMS_STATUS_3 = 'connector_automation_studio/sms/sms_three_status';
|
26 |
-
const XML_PATH_CONNECTOR_SMS_STATUS_4 = 'connector_automation_studio/sms/sms_four_status';
|
27 |
-
//message
|
28 |
-
const XML_PATH_CONNECTOR_SMS_MESSAGE_1 = 'connector_automation_studio/sms/sms_one_message';
|
29 |
-
const XML_PATH_CONNECTOR_SMS_MESSAGE_2 = 'connector_automation_studio/sms/sms_two_message';
|
30 |
-
const XML_PATH_CONNECTOR_SMS_MESSAGE_3 = 'connector_automation_studio/sms/sms_three_message';
|
31 |
-
const XML_PATH_CONNECTOR_SMS_MESSAGE_4 = 'connector_automation_studio/sms/sms_four_message';
|
32 |
-
|
33 |
Â
/**
|
34 |
Â
* SYNC SECTION.
|
35 |
Â
*/
|
@@ -116,6 +97,8 @@ class Dotdigitalgroup_Email_Helper_Config
|
|
116 |
Â
const XML_PATH_CONNECTOR_CUSTOMER_LAST_BRAND_PURCHASED = 'connector_data_mapping/customer_data/last_brand_pur';
|
117 |
Â
const XML_PATH_CONNECTOR_CUSTOMER_SUBSCRIBER_STATUS = 'connector_data_mapping/customer_data/subscriber_status';
|
118 |
Â
const XML_PATH_CONNECTOR_ABANDONED_PRODUCT_NAME = 'connector_data_mapping/customer_data/abandoned_prod_name';
|
Â
|
|
Â
|
|
119 |
Â
|
120 |
Â
const XML_PATH_CONNECTOR_ENTERPRISE_CURRENT_BALANCE = 'connector_data_mapping/enterprise_data/reward_points';
|
121 |
Â
const XML_PATH_CONNECTOR_ENTERPRISE_REWARD_AMOUNT = 'connector_data_mapping/enterprise_data/reward_amount';
|
@@ -129,7 +112,6 @@ class Dotdigitalgroup_Email_Helper_Config
|
|
129 |
Â
* Dynamic Content
|
130 |
Â
*/
|
131 |
Â
const XML_PATH_CONNECTOR_DYNAMIC_CONTENT_PASSCODE = 'connector_dynamic_content/external_dynamic_content_urls/passcode';
|
132 |
-
const XML_PATH_CONNECTOR_DYNAMIC_CONTENT_NOSTO = 'connector_dynamic_content/nosto_recommendation/api';
|
133 |
Â
const XML_PATH_CONNECTOR_DYNAMIC_CONTENT_WIHSLIST_DISPLAY = 'connector_dynamic_content/products/wishlist_display_type';
|
134 |
Â
const XML_PATH_CONNECTOR_DYNAMIC_CONTENT_REVIEW_DISPLAY_TYPE = 'connector_dynamic_content/products/review_display_type';
|
135 |
Â
|
@@ -219,7 +201,6 @@ class Dotdigitalgroup_Email_Helper_Config
|
|
219 |
Â
/**
|
220 |
Â
* OAUTH
|
221 |
Â
*/
|
222 |
-
const API_CONNECTOR_OAUTH_URL = 'https://my.dotmailer.com/';
|
223 |
Â
const API_CONNECTOR_OAUTH_URL_AUTHORISE = 'OAuth2/authorise.aspx?';
|
224 |
Â
const API_CONNECTOR_OAUTH_URL_TOKEN = 'OAuth2/Tokens.ashx';
|
225 |
Â
const API_CONNECTOR_OAUTH_URL_LOG_USER = '?oauthtoken=';
|
@@ -269,6 +250,12 @@ class Dotdigitalgroup_Email_Helper_Config
|
|
269 |
Â
*/
|
270 |
Â
const PATH_FOR_API_ENDPOINT = 'connector/api/endpoint';
|
271 |
Â
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
272 |
Â
/**
|
273 |
Â
* @param int $website
|
274 |
Â
*
|
@@ -296,15 +283,30 @@ class Dotdigitalgroup_Email_Helper_Config
|
|
296 |
Â
if ($this->getAuthorizeLinkFlag($website)){
|
297 |
Â
$website = Mage::app()->getWebsite($website);
|
298 |
Â
|
299 |
-
$baseUrl = $website->getConfig(self::XML_PATH_CONNECTOR_CUSTOM_DOMAIN)
|
300 |
-
|
301 |
Â
} else {
|
302 |
-
|
Â
|
|
303 |
Â
}
|
304 |
Â
|
305 |
Â
return $baseUrl;
|
306 |
Â
}
|
307 |
Â
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
308 |
Â
/**
|
309 |
Â
* Callback authorization url.
|
310 |
Â
* @return mixed|string
|
@@ -331,7 +333,7 @@ class Dotdigitalgroup_Email_Helper_Config
|
|
331 |
Â
$tokenUrl = $website->getConfig(self::XML_PATH_CONNECTOR_CUSTOM_DOMAIN) . self::API_CONNECTOR_OAUTH_URL_TOKEN;
|
332 |
Â
} else {
|
333 |
Â
|
334 |
-
$tokenUrl =
|
335 |
Â
}
|
336 |
Â
|
337 |
Â
return $tokenUrl;
|
@@ -351,7 +353,7 @@ class Dotdigitalgroup_Email_Helper_Config
|
|
351 |
Â
$logUserUrl = $website->getConfig(self::XML_PATH_CONNECTOR_CUSTOM_DOMAIN) . self::API_CONNECTOR_OAUTH_URL_LOG_USER;
|
352 |
Â
} else {
|
353 |
Â
|
354 |
-
$logUserUrl =
|
355 |
Â
}
|
356 |
Â
return $logUserUrl;
|
357 |
Â
}
|
11 |
Â
const XML_PATH_CONNECTOR_API_USERNAME = 'connector_api_credentials/api/username';
|
12 |
Â
const XML_PATH_CONNECTOR_API_PASSWORD = 'connector_api_credentials/api/password';
|
13 |
Â
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
14 |
Â
/**
|
15 |
Â
* SYNC SECTION.
|
16 |
Â
*/
|
97 |
Â
const XML_PATH_CONNECTOR_CUSTOMER_LAST_BRAND_PURCHASED = 'connector_data_mapping/customer_data/last_brand_pur';
|
98 |
Â
const XML_PATH_CONNECTOR_CUSTOMER_SUBSCRIBER_STATUS = 'connector_data_mapping/customer_data/subscriber_status';
|
99 |
Â
const XML_PATH_CONNECTOR_ABANDONED_PRODUCT_NAME = 'connector_data_mapping/customer_data/abandoned_prod_name';
|
100 |
+
const XML_PATH_CONNECTOR_CUSTOMER_BILLING_COMPANY_NAME = 'connector_data_mapping/customer_data/billing_company';
|
101 |
+
const XML_PATH_CONNECTOR_CUSTOMER_DELIVERY_COMPANY_NAME = 'connector_data_mapping/customer_data/delivery_company';
|
102 |
Â
|
103 |
Â
const XML_PATH_CONNECTOR_ENTERPRISE_CURRENT_BALANCE = 'connector_data_mapping/enterprise_data/reward_points';
|
104 |
Â
const XML_PATH_CONNECTOR_ENTERPRISE_REWARD_AMOUNT = 'connector_data_mapping/enterprise_data/reward_amount';
|
112 |
Â
* Dynamic Content
|
113 |
Â
*/
|
114 |
Â
const XML_PATH_CONNECTOR_DYNAMIC_CONTENT_PASSCODE = 'connector_dynamic_content/external_dynamic_content_urls/passcode';
|
Â
|
|
115 |
Â
const XML_PATH_CONNECTOR_DYNAMIC_CONTENT_WIHSLIST_DISPLAY = 'connector_dynamic_content/products/wishlist_display_type';
|
116 |
Â
const XML_PATH_CONNECTOR_DYNAMIC_CONTENT_REVIEW_DISPLAY_TYPE = 'connector_dynamic_content/products/review_display_type';
|
117 |
Â
|
201 |
Â
/**
|
202 |
Â
* OAUTH
|
203 |
Â
*/
|
Â
|
|
204 |
Â
const API_CONNECTOR_OAUTH_URL_AUTHORISE = 'OAuth2/authorise.aspx?';
|
205 |
Â
const API_CONNECTOR_OAUTH_URL_TOKEN = 'OAuth2/Tokens.ashx';
|
206 |
Â
const API_CONNECTOR_OAUTH_URL_LOG_USER = '?oauthtoken=';
|
250 |
Â
*/
|
251 |
Â
const PATH_FOR_API_ENDPOINT = 'connector/api/endpoint';
|
252 |
Â
|
253 |
+
/**
|
254 |
+
* Trial Account
|
255 |
+
*/
|
256 |
+
const API_CONNECTOR_TRIAL_FORM_URL = 'https://magentosignup.dotmailer.com/';
|
257 |
+
const API_CONNECTOR_TRIAL_FORM_SECRET = 'DmTrialFormSecret';
|
258 |
+
|
259 |
Â
/**
|
260 |
Â
* @param int $website
|
261 |
Â
*
|
283 |
Â
if ($this->getAuthorizeLinkFlag($website)){
|
284 |
Â
$website = Mage::app()->getWebsite($website);
|
285 |
Â
|
286 |
+
$baseUrl = $website->getConfig(self::XML_PATH_CONNECTOR_CUSTOM_DOMAIN)
|
287 |
+
. self::API_CONNECTOR_OAUTH_URL_AUTHORISE;
|
288 |
Â
} else {
|
289 |
+
|
290 |
+
$baseUrl = $this->getRegionAuthorize($website) . self::API_CONNECTOR_OAUTH_URL_AUTHORISE;
|
291 |
Â
}
|
292 |
Â
|
293 |
Â
return $baseUrl;
|
294 |
Â
}
|
295 |
Â
|
296 |
+
/**
|
297 |
+
* Region aware authorize link.
|
298 |
+
* @param $website
|
299 |
+
*
|
300 |
+
* @return mixed
|
301 |
+
*/
|
302 |
+
public function getRegionAuthorize($website)
|
303 |
+
{
|
304 |
+
$baseRegionBaseUrl = Mage::helper('ddg')->getWebsiteConfig(
|
305 |
+
Dotdigitalgroup_Email_Helper_Config::PATH_FOR_API_ENDPOINT, $website) . DS;
|
306 |
+
|
307 |
+
return $baseRegionBaseUrl;
|
308 |
+
}
|
309 |
+
|
310 |
Â
/**
|
311 |
Â
* Callback authorization url.
|
312 |
Â
* @return mixed|string
|
333 |
Â
$tokenUrl = $website->getConfig(self::XML_PATH_CONNECTOR_CUSTOM_DOMAIN) . self::API_CONNECTOR_OAUTH_URL_TOKEN;
|
334 |
Â
} else {
|
335 |
Â
|
336 |
+
$tokenUrl = $this->getRegionAuthorize($website) . self::API_CONNECTOR_OAUTH_URL_TOKEN;
|
337 |
Â
}
|
338 |
Â
|
339 |
Â
return $tokenUrl;
|
353 |
Â
$logUserUrl = $website->getConfig(self::XML_PATH_CONNECTOR_CUSTOM_DOMAIN) . self::API_CONNECTOR_OAUTH_URL_LOG_USER;
|
354 |
Â
} else {
|
355 |
Â
|
356 |
+
$logUserUrl = $this->getRegionAuthorize($website) . self::API_CONNECTOR_OAUTH_URL_LOG_USER;
|
357 |
Â
}
|
358 |
Â
return $logUserUrl;
|
359 |
Â
}
|
@@ -2,171 +2,206 @@
|
|
2 |
Â
|
3 |
Â
class Dotdigitalgroup_Email_Helper_Dashboard extends Mage_Core_Helper_Abstract
|
4 |
Â
{
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
170 |
Â
|
171 |
Â
|
172 |
Â
}
|
2 |
Â
|
3 |
Â
class Dotdigitalgroup_Email_Helper_Dashboard extends Mage_Core_Helper_Abstract
|
4 |
Â
{
|
5 |
+
|
6 |
+
protected $_rewriteTypes
|
7 |
+
= array(
|
8 |
+
'blocks',
|
9 |
+
'helpers',
|
10 |
+
'models',
|
11 |
+
);
|
12 |
+
|
13 |
+
public function getRewrites()
|
14 |
+
{
|
15 |
+
$rewrites = array(
|
16 |
+
'blocks',
|
17 |
+
'models',
|
18 |
+
'helpers',
|
19 |
+
);
|
20 |
+
|
21 |
+
/* @var $_magentoConfig Mage_Core_Model_Config */
|
22 |
+
$_magentoConfig = Mage::getConfig();
|
23 |
+
|
24 |
+
// Load config of each module because modules can overwrite config each other. Global config is already merged
|
25 |
+
$modules = $_magentoConfig->getNode('modules')->children();
|
26 |
+
foreach ($modules as $moduleName => $moduleData) {
|
27 |
+
// Check only active modules
|
28 |
+
if ( ! $moduleData->is('active')) {
|
29 |
+
continue;
|
30 |
+
}
|
31 |
+
|
32 |
+
// Load config of module
|
33 |
+
$configXmlFile = $_magentoConfig->getModuleDir('etc', $moduleName)
|
34 |
+
. DIRECTORY_SEPARATOR . 'config.xml';
|
35 |
+
if ( ! file_exists($configXmlFile)) {
|
36 |
+
continue;
|
37 |
+
}
|
38 |
+
|
39 |
+
$xml = simplexml_load_file($configXmlFile);
|
40 |
+
if ($xml) {
|
41 |
+
$rewriteElements = $xml->xpath('//rewrite');
|
42 |
+
foreach ($rewriteElements as $element) {
|
43 |
+
foreach ($element->children() as $child) {
|
44 |
+
$type = simplexml_import_dom(
|
45 |
+
dom_import_simplexml(
|
46 |
+
$element
|
47 |
+
)->parentNode->parentNode
|
48 |
+
)->getName();
|
49 |
+
if ( ! in_array($type, $this->_rewriteTypes)) {
|
50 |
+
continue;
|
51 |
+
}
|
52 |
+
$groupClassName = simplexml_import_dom(
|
53 |
+
dom_import_simplexml($element)->parentNode
|
54 |
+
)->getName();
|
55 |
+
if ( ! isset(
|
56 |
+
$rewrites[$type][$groupClassName . '/'
|
57 |
+
. $child->getName()]
|
58 |
+
)
|
59 |
+
) {
|
60 |
+
$rewrites[$type][$groupClassName . '/'
|
61 |
+
. $child->getName()]
|
62 |
+
= array();
|
63 |
+
}
|
64 |
+
$rewrites[$type][$groupClassName . '/'
|
65 |
+
. $child->getName()]['classes'][]
|
66 |
+
= (string)$child;
|
67 |
+
}
|
68 |
+
}
|
69 |
+
}
|
70 |
+
}
|
71 |
+
|
72 |
+
foreach ($rewrites as $type => $data) {
|
73 |
+
if (count($data) > 0 && is_array($data)) {
|
74 |
+
foreach ($data as $node => $rewriteInfo) {
|
75 |
+
if (count($rewriteInfo['classes']) > 1) {
|
76 |
+
if ($this->_isInheritanceConflict(
|
77 |
+
$rewriteInfo['classes']
|
78 |
+
)
|
79 |
+
) {
|
80 |
+
$rewrites[$type][$node]['conflicts'][] = array(
|
81 |
+
'node' => $node,
|
82 |
+
'loaded_class' => $this->_getLoadedClass(
|
83 |
+
$type, $node
|
84 |
+
)
|
85 |
+
);
|
86 |
+
}
|
87 |
+
}
|
88 |
+
}
|
89 |
+
}
|
90 |
+
}
|
91 |
+
|
92 |
+
$rewrites = array_merge(
|
93 |
+
$rewrites, $this->_loadLocalAutoloaderRewrites()
|
94 |
+
);
|
95 |
+
|
96 |
+
if (empty($rewrites['blocks']) && empty($rewrites['models'])
|
97 |
+
&& empty($rewrites['helpers'])
|
98 |
+
&& empty($rewrites['autoload'])
|
99 |
+
) {
|
100 |
+
return false;
|
101 |
+
}
|
102 |
+
|
103 |
+
return $rewrites;
|
104 |
+
}
|
105 |
+
|
106 |
+
|
107 |
+
/**
|
108 |
+
* Check if rewritten class has inherited the parent class.
|
109 |
+
* If yes we have no conflict. The top class can extend every core class.
|
110 |
+
* So we cannot check this.
|
111 |
+
*
|
112 |
+
* @var array $classes
|
113 |
+
* @return bool
|
114 |
+
*/
|
115 |
+
protected function _isInheritanceConflict($classes)
|
116 |
+
{
|
117 |
+
$classes = array_reverse($classes);
|
118 |
+
$count = count($classes) - 1;
|
119 |
+
for ($i = 0; $i < $count; $i++) {
|
120 |
+
try {
|
121 |
+
if (class_exists($classes[$i])
|
122 |
+
&& class_exists(
|
123 |
+
$classes[$i + 1]
|
124 |
+
)
|
125 |
+
) {
|
126 |
+
if ( ! is_a($classes[$i], $classes[$i + 1], true)) {
|
127 |
+
return true;
|
128 |
+
}
|
129 |
+
}
|
130 |
+
} catch (Exception $e) {
|
131 |
+
return true;
|
132 |
+
}
|
133 |
+
}
|
134 |
+
|
135 |
+
return false;
|
136 |
+
}
|
137 |
+
|
138 |
+
/**
|
139 |
+
* Returns loaded class by type like models or blocks
|
140 |
+
*
|
141 |
+
* @param string $type Class Type
|
142 |
+
* @param string $classGroup Class Group Name
|
143 |
+
*
|
144 |
+
* @return string
|
145 |
+
*/
|
146 |
+
protected function _getLoadedClass($type, $classGroup)
|
147 |
+
{
|
148 |
+
switch ($type) {
|
149 |
+
case 'blocks':
|
150 |
+
return Mage::getConfig()->getBlockClassName($classGroup);
|
151 |
+
|
152 |
+
case 'helpers':
|
153 |
+
return Mage::getConfig()->getHelperClassName($classGroup);
|
154 |
+
|
155 |
+
default:
|
156 |
+
case 'models':
|
157 |
+
return Mage::getConfig()->getModelClassName($classGroup);
|
158 |
+
}
|
159 |
+
}
|
160 |
+
|
161 |
+
|
162 |
+
/**
|
163 |
+
* Searches for all rewrites over autoloader in "app/code/local" of
|
164 |
+
* Mage, Enterprise Zend, Varien namespaces.
|
165 |
+
*
|
166 |
+
* @return array
|
167 |
+
*/
|
168 |
+
protected function _loadLocalAutoloaderRewrites()
|
169 |
+
{
|
170 |
+
$return = array();
|
171 |
+
$localCodeFolder = Mage::getBaseDir('code') . '/local';
|
172 |
+
|
173 |
+
$folders = array(
|
174 |
+
'Mage' => $localCodeFolder . '/Mage',
|
175 |
+
'Enterprise' => $localCodeFolder . '/Enterprise',
|
176 |
+
'Varien' => $localCodeFolder . '/Varien',
|
177 |
+
'Zend' => $localCodeFolder . '/Zend',
|
178 |
+
);
|
179 |
+
|
180 |
+
foreach ($folders as $vendorPrefix => $folder) {
|
181 |
+
if (is_dir($folder)) {
|
182 |
+
$directory = new RecursiveDirectoryIterator($folder);
|
183 |
+
$iterator = new RecursiveIteratorIterator($directory);
|
184 |
+
$files = new RegexIterator(
|
185 |
+
$iterator, '/^.+\.php$/i', RecursiveRegexIterator::GET_MATCH
|
186 |
+
);
|
187 |
+
|
188 |
+
foreach ($files as $file) {
|
189 |
+
$classFile = trim(
|
190 |
+
str_replace($folder, '', realpath($file[0])), '/'
|
191 |
+
);
|
192 |
+
$className = $vendorPrefix
|
193 |
+
. '_'
|
194 |
+
. str_replace(DIRECTORY_SEPARATOR, '_', $classFile);
|
195 |
+
$className = substr(
|
196 |
+
$className, 0, -4
|
197 |
+
); // replace .php extension
|
198 |
+
$return['autoload'][$className]['classes'][] = $className;
|
199 |
+
}
|
200 |
+
}
|
201 |
+
}
|
202 |
+
|
203 |
+
return $return;
|
204 |
+
}
|
205 |
Â
|
206 |
Â
|
207 |
Â
}
|
@@ -6,61 +6,88 @@ class Dotdigitalgroup_Email_Helper_Data extends Mage_Core_Helper_Abstract
|
|
6 |
Â
public function isEnabled($website = 0)
|
7 |
Â
{
|
8 |
Â
$website = Mage::app()->getWebsite($website);
|
9 |
-
|
Â
|
|
Â
|
|
Â
|
|
10 |
Â
}
|
11 |
Â
|
12 |
Â
/**
|
13 |
-
* @param int/object $website
|
Â
|
|
14 |
Â
* @return mixed
|
15 |
Â
*/
|
16 |
Â
public function getApiUsername($website = 0)
|
17 |
Â
{
|
18 |
Â
$website = Mage::app()->getWebsite($website);
|
19 |
Â
|
20 |
-
return $website->getConfig(
|
Â
|
|
Â
|
|
21 |
Â
}
|
22 |
Â
|
23 |
Â
public function getApiPassword($website = 0)
|
24 |
Â
{
|
25 |
Â
$website = Mage::app()->getWebsite($website);
|
26 |
Â
|
27 |
-
return
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
28 |
Â
}
|
29 |
Â
|
30 |
Â
public function auth($authRequest)
|
31 |
Â
{
|
32 |
-
if ($authRequest != Mage::getStoreConfig(
|
33 |
-
|
34 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
35 |
Â
return false;
|
36 |
Â
}
|
Â
|
|
37 |
Â
return true;
|
38 |
Â
}
|
39 |
Â
|
40 |
Â
public function getMappedCustomerId()
|
41 |
Â
{
|
42 |
-
return Mage::getStoreConfig(
|
Â
|
|
Â
|
|
43 |
Â
}
|
44 |
Â
|
45 |
Â
public function getMappedOrderId()
|
46 |
Â
{
|
47 |
-
return Mage::getStoreConfig(
|
Â
|
|
Â
|
|
48 |
Â
}
|
49 |
Â
|
50 |
Â
public function getPasscode()
|
51 |
Â
{
|
52 |
-
return Mage::getStoreConfig(
|
Â
|
|
Â
|
|
53 |
Â
}
|
54 |
Â
|
55 |
Â
public function getLastOrderId()
|
56 |
Â
{
|
57 |
-
return Mage::getStoreConfig(
|
Â
|
|
Â
|
|
58 |
Â
|
59 |
Â
}
|
60 |
Â
|
61 |
Â
public function getLastQuoteId()
|
62 |
Â
{
|
63 |
-
return Mage::getStoreConfig(
|
Â
|
|
Â
|
|
64 |
Â
|
65 |
Â
}
|
66 |
Â
|
@@ -72,53 +99,68 @@ class Dotdigitalgroup_Email_Helper_Data extends Mage_Core_Helper_Abstract
|
|
72 |
Â
Mage::log($data, $level, $filename, $force = true);
|
73 |
Â
}
|
74 |
Â
|
75 |
-
|
76 |
Â
}
|
77 |
Â
|
78 |
Â
public function getDebugEnabled()
|
79 |
Â
{
|
80 |
-
return (bool)
|
Â
|
|
Â
|
|
81 |
Â
}
|
82 |
Â
|
83 |
Â
/**
|
84 |
Â
* Extension version number.
|
Â
|
|
85 |
Â
* @return string
|
86 |
Â
*/
|
87 |
Â
public function getConnectorVersion()
|
88 |
Â
{
|
89 |
-
$modules = (array)
|
90 |
Â
if (isset($modules['Dotdigitalgroup_Email'])) {
|
91 |
Â
$moduleName = $modules['Dotdigitalgroup_Email'];
|
92 |
-
|
Â
|
|
93 |
Â
}
|
Â
|
|
94 |
Â
return '';
|
95 |
Â
}
|
96 |
Â
|
97 |
Â
|
98 |
Â
public function getPageTrackingEnabled()
|
99 |
Â
{
|
100 |
-
return (bool)Mage::getStoreConfig(
|
Â
|
|
Â
|
|
101 |
Â
}
|
102 |
Â
|
103 |
Â
public function getRoiTrackingEnabled()
|
104 |
Â
{
|
105 |
-
return (bool)Mage::getStoreConfig(
|
Â
|
|
Â
|
|
106 |
Â
}
|
107 |
Â
|
108 |
Â
public function getResourceAllocationEnabled()
|
109 |
Â
{
|
110 |
-
return (bool)Mage::getStoreConfig(
|
Â
|
|
Â
|
|
111 |
Â
}
|
112 |
Â
|
113 |
Â
public function getMappedStoreName($website)
|
114 |
Â
{
|
115 |
-
$mapped = $website->getConfig(
|
116 |
-
|
117 |
-
|
Â
|
|
Â
|
|
Â
|
|
118 |
Â
}
|
119 |
Â
|
120 |
Â
/**
|
121 |
Â
* Get the contact id for the custoemer based on website id.
|
Â
|
|
122 |
Â
* @param $email
|
123 |
Â
* @param $websiteId
|
124 |
Â
*
|
@@ -126,7 +168,8 @@ class Dotdigitalgroup_Email_Helper_Data extends Mage_Core_Helper_Abstract
|
|
126 |
Â
*/
|
127 |
Â
public function getContactId($email, $websiteId)
|
128 |
Â
{
|
129 |
-
$contact = Mage::getModel('ddg_automation/contact')
|
Â
|
|
130 |
Â
if ($contactId = $contact->getContactId()) {
|
131 |
Â
return $contactId;
|
132 |
Â
}
|
@@ -134,38 +177,49 @@ class Dotdigitalgroup_Email_Helper_Data extends Mage_Core_Helper_Abstract
|
|
134 |
Â
$client = $this->getWebsiteApiClient($websiteId);
|
135 |
Â
$response = $client->postContacts($email);
|
136 |
Â
|
137 |
-
if (isset($response->message))
|
138 |
Â
return false;
|
Â
|
|
139 |
Â
//save contact id
|
140 |
-
if (isset($response->id)){
|
141 |
Â
$contact->setContactId($response->id)
|
142 |
Â
->save();
|
143 |
Â
}
|
Â
|
|
144 |
Â
return $response->id;
|
145 |
Â
}
|
146 |
Â
|
147 |
Â
public function getCustomerAddressBook($website)
|
148 |
Â
{
|
149 |
Â
$website = Mage::app()->getWebsite($website);
|
150 |
-
|
Â
|
|
Â
|
|
Â
|
|
151 |
Â
}
|
152 |
Â
|
153 |
Â
public function getSubscriberAddressBook($website)
|
154 |
Â
{
|
155 |
Â
$website = Mage::app()->getWebsite($website);
|
156 |
-
|
Â
|
|
Â
|
|
Â
|
|
157 |
Â
}
|
158 |
Â
|
159 |
Â
public function getGuestAddressBook($website)
|
160 |
Â
{
|
161 |
Â
$website = Mage::app()->getWebsite($website);
|
162 |
-
|
Â
|
|
Â
|
|
Â
|
|
163 |
Â
}
|
164 |
Â
|
165 |
Â
/**
|
166 |
Â
* @return $this
|
167 |
Â
*/
|
168 |
-
public
|
169 |
Â
{
|
170 |
Â
if ($this->getResourceAllocationEnabled()) {
|
171 |
Â
|
@@ -176,12 +230,16 @@ class Dotdigitalgroup_Email_Helper_Data extends Mage_Core_Helper_Abstract
|
|
176 |
Â
/* and memory to 512 megabytes */
|
177 |
Â
ini_set('memory_limit', '512M');
|
178 |
Â
}
|
Â
|
|
179 |
Â
return $this;
|
180 |
Â
}
|
Â
|
|
181 |
Â
public function convert($size)
|
182 |
Â
{
|
183 |
-
$unit=array('b','kb','mb','gb','tb','pb');
|
184 |
-
|
Â
|
|
Â
|
|
185 |
Â
}
|
186 |
Â
|
187 |
Â
/**
|
@@ -193,8 +251,10 @@ class Dotdigitalgroup_Email_Helper_Data extends Mage_Core_Helper_Abstract
|
|
193 |
Â
foreach (Mage::app()->getWebsites() as $website) {
|
194 |
Â
$websiteId = $website->getId();
|
195 |
Â
$apiUsername = $this->getApiUsername($website);
|
196 |
-
$accounts[$apiUsername] = $apiUsername . ', websiteId: '
|
Â
|
|
197 |
Â
}
|
Â
|
|
198 |
Â
return implode('</br>', $accounts);
|
199 |
Â
}
|
200 |
Â
|
@@ -207,10 +267,13 @@ class Dotdigitalgroup_Email_Helper_Data extends Mage_Core_Helper_Abstract
|
|
207 |
Â
public function getCustomAttributes($website = 0)
|
208 |
Â
{
|
209 |
Â
$website = Mage::app()->getWebsite($website);
|
210 |
-
$attr = $website->getConfig(
|
Â
|
|
Â
|
|
211 |
Â
|
212 |
-
if (!$attr)
|
213 |
Â
return array();
|
Â
|
|
214 |
Â
|
215 |
Â
return unserialize($attr);
|
216 |
Â
}
|
@@ -218,39 +281,50 @@ class Dotdigitalgroup_Email_Helper_Data extends Mage_Core_Helper_Abstract
|
|
218 |
Â
|
219 |
Â
/**
|
220 |
Â
* Enterprise custom datafields attributes.
|
Â
|
|
221 |
Â
* @param int $website
|
222 |
Â
*
|
223 |
Â
* @return array
|
224 |
Â
* @throws Mage_Core_Exception
|
225 |
Â
*/
|
226 |
-
public function getEnterpriseAttributes(
|
Â
|
|
227 |
Â
$website = Mage::app()->getWebsite($website);
|
228 |
Â
$result = array();
|
229 |
-
$attrs = $website->getConfig(
|
Â
|
|
Â
|
|
230 |
Â
|
231 |
-
if(is_array($attrs)){
|
232 |
Â
//get individual mapped keys
|
233 |
-
foreach (
|
234 |
-
$config = $website->getConfig(
|
Â
|
|
Â
|
|
235 |
Â
//check for the mapped field
|
236 |
-
if ($config)
|
237 |
Â
$result[$key] = $config;
|
Â
|
|
238 |
Â
}
|
239 |
Â
}
|
240 |
Â
|
241 |
-
if (empty($result))
|
242 |
Â
return false;
|
Â
|
|
Â
|
|
243 |
Â
return $result;
|
244 |
Â
}
|
245 |
Â
|
246 |
Â
/**
|
247 |
-
* @param
|
248 |
Â
* @param null|string|bool|int|Mage_Core_Model_Website $websiteId
|
Â
|
|
249 |
Â
* @return mixed
|
250 |
Â
*/
|
251 |
Â
public function getWebsiteConfig($path, $websiteId = 0)
|
252 |
Â
{
|
253 |
Â
$website = Mage::app()->getWebsite($websiteId);
|
Â
|
|
254 |
Â
return $website->getConfig($path);
|
255 |
Â
}
|
256 |
Â
|
@@ -263,11 +337,16 @@ class Dotdigitalgroup_Email_Helper_Data extends Mage_Core_Helper_Abstract
|
|
263 |
Â
*/
|
264 |
Â
public function getWebsiteApiClient($website = 0)
|
265 |
Â
{
|
266 |
-
if(!$this->isEnabled($website))
|
267 |
Â
return false;
|
Â
|
|
268 |
Â
|
269 |
-
if (
|
Â
|
|
Â
|
|
Â
|
|
270 |
Â
return false;
|
Â
|
|
271 |
Â
|
272 |
Â
$client = Mage::getModel('ddg_automation/apiconnector_client');
|
273 |
Â
$client->setApiUsername($this->getApiUsername($website))
|
@@ -289,11 +368,14 @@ class Dotdigitalgroup_Email_Helper_Data extends Mage_Core_Helper_Abstract
|
|
289 |
Â
|
290 |
Â
/**
|
291 |
Â
* Autorisation url for OAUTH.
|
Â
|
|
292 |
Â
* @return string
|
293 |
Â
*/
|
294 |
Â
public function getAuthoriseUrl()
|
295 |
Â
{
|
296 |
-
$clientId = Mage::getStoreConfig(
|
Â
|
|
Â
|
|
297 |
Â
|
298 |
Â
//callback uri if not set custom
|
299 |
Â
$redirectUri = $this->getRedirectUri();
|
@@ -308,7 +390,8 @@ class Dotdigitalgroup_Email_Helper_Data extends Mage_Core_Helper_Abstract
|
|
308 |
Â
);
|
309 |
Â
|
310 |
Â
$authorizeBaseUrl = Mage::helper('ddg/config')->getAuthorizeLink();
|
311 |
-
$url = $authorizeBaseUrl . http_build_query($params)
|
Â
|
|
312 |
Â
|
313 |
Â
return $url;
|
314 |
Â
}
|
@@ -322,54 +405,79 @@ class Dotdigitalgroup_Email_Helper_Data extends Mage_Core_Helper_Abstract
|
|
322 |
Â
|
323 |
Â
/**
|
324 |
Â
* order status config value
|
Â
|
|
325 |
Â
* @param int $website
|
Â
|
|
326 |
Â
* @return mixed order status
|
327 |
Â
*/
|
328 |
Â
public function getConfigSelectedStatus($website = 0)
|
329 |
Â
{
|
330 |
-
$status = $this->getWebsiteConfig(
|
331 |
-
|
332 |
-
|
333 |
-
|
Â
|
|
Â
|
|
Â
|
|
334 |
Â
return false;
|
Â
|
|
335 |
Â
}
|
336 |
Â
|
337 |
Â
public function getConfigSelectedCustomOrderAttributes($website = 0)
|
338 |
Â
{
|
339 |
-
$customAttributes = $this->getWebsiteConfig(
|
340 |
-
|
341 |
-
|
342 |
-
|
Â
|
|
Â
|
|
Â
|
|
343 |
Â
return false;
|
Â
|
|
344 |
Â
}
|
345 |
Â
|
346 |
Â
public function getConfigSelectedCustomQuoteAttributes($website = 0)
|
347 |
Â
{
|
348 |
-
$customAttributes = $this->getWebsiteConfig(
|
349 |
-
|
350 |
-
|
351 |
-
|
Â
|
|
Â
|
|
Â
|
|
352 |
Â
return false;
|
Â
|
|
353 |
Â
}
|
354 |
Â
|
355 |
Â
/**
|
356 |
Â
* check sweet tooth installed/active status
|
Â
|
|
357 |
Â
* @return boolean
|
358 |
Â
*/
|
359 |
Â
public function isSweetToothEnabled()
|
360 |
Â
{
|
361 |
-
return (bool)Mage::getConfig()->getModuleConfig('TBT_Rewards')->is(
|
Â
|
|
Â
|
|
362 |
Â
}
|
363 |
Â
|
364 |
Â
/**
|
365 |
Â
* check sweet tooth installed/active status and active status
|
Â
|
|
366 |
Â
* @param Mage_Core_Model_Website $website
|
Â
|
|
367 |
Â
* @return boolean
|
368 |
Â
*/
|
369 |
Â
public function isSweetToothToGo($website)
|
370 |
Â
{
|
371 |
-
$stMappingStatus = $this->getWebsiteConfig(
|
372 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
373 |
Â
return false;
|
374 |
Â
}
|
375 |
Â
|
@@ -384,29 +492,33 @@ class Dotdigitalgroup_Email_Helper_Data extends Mage_Core_Helper_Abstract
|
|
384 |
Â
array("customer_id = ?" => $customerId)
|
385 |
Â
);
|
386 |
Â
} catch (Exception $e) {
|
387 |
-
|
388 |
Â
}
|
389 |
Â
}
|
390 |
Â
|
391 |
Â
/**
|
392 |
-
* Diff between to times
|
Â
|
|
Â
|
|
Â
|
|
393 |
Â
*
|
394 |
-
* @param $time1
|
395 |
-
* @param $time2
|
396 |
Â
* @return int
|
397 |
Â
*/
|
398 |
-
public function dateDiff($
|
399 |
-
|
400 |
-
|
Â
|
|
401 |
Â
}
|
402 |
-
$
|
403 |
-
$
|
404 |
-
|
Â
|
|
405 |
Â
}
|
406 |
Â
|
407 |
Â
|
408 |
Â
/**
|
409 |
Â
* Disable website config when the request is made admin area only!
|
Â
|
|
410 |
Â
* @param $path
|
411 |
Â
*
|
412 |
Â
* @throws Mage_Core_Exception
|
@@ -427,9 +539,11 @@ class Dotdigitalgroup_Email_Helper_Data extends Mage_Core_Helper_Abstract
|
|
427 |
Â
|
428 |
Â
/**
|
429 |
Â
* number of customers with duplicate emails, emails as total number
|
Â
|
|
430 |
Â
* @return Mage_Customer_Model_Resource_Customer_Collection
|
431 |
Â
*/
|
432 |
-
public function getCustomersWithDuplicateEmails(
|
Â
|
|
433 |
Â
$customers = Mage::getModel('customer/customer')->getCollection();
|
434 |
Â
|
435 |
Â
//duplicate emails
|
@@ -448,12 +562,18 @@ class Dotdigitalgroup_Email_Helper_Data extends Mage_Core_Helper_Abstract
|
|
448 |
Â
*/
|
449 |
Â
public function getRaygunClient()
|
450 |
Â
{
|
451 |
-
$code = Mage::getstoreConfig(
|
Â
|
|
Â
|
|
452 |
Â
|
453 |
Â
if ($this->raygunEnabled()) {
|
454 |
Â
//use async mode for sending.
|
455 |
-
$async = Mage::getStoreConfigFlag(
|
456 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
457 |
Â
return new Raygun4php\RaygunClient($code, $async);
|
458 |
Â
}
|
459 |
Â
|
@@ -462,22 +582,28 @@ class Dotdigitalgroup_Email_Helper_Data extends Mage_Core_Helper_Abstract
|
|
462 |
Â
|
463 |
Â
/**
|
464 |
Â
* Raygun logs.
|
465 |
-
*
|
Â
|
|
466 |
Â
* @param string $filename
|
467 |
Â
* @param int $line
|
468 |
Â
* @param array $tags
|
469 |
Â
*
|
470 |
Â
* @return int|null
|
471 |
Â
*/
|
472 |
-
public function rayLog(
|
473 |
-
|
474 |
-
|
475 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
476 |
Â
return;
|
Â
|
|
477 |
Â
|
478 |
-
|
479 |
Â
|
480 |
-
|
481 |
Â
$tags = array(
|
482 |
Â
$baseUrl,
|
483 |
Â
Mage::getVersion()
|
@@ -488,12 +614,13 @@ class Dotdigitalgroup_Email_Helper_Data extends Mage_Core_Helper_Abstract
|
|
488 |
Â
//user, firstname, lastname, email, annonim, uuid
|
489 |
Â
$client->SetUser($baseUrl, null, null, $this->getApiUsername());
|
490 |
Â
$client->SetVersion($this->getConnectorVersion());
|
491 |
-
$client->SendError(100, $message, $filename
|
492 |
Â
}
|
493 |
Â
|
494 |
Â
|
495 |
Â
/**
|
496 |
Â
* check for raygun application and if enabled.
|
Â
|
|
497 |
Â
* @param int $websiteId
|
498 |
Â
*
|
499 |
Â
* @return mixed
|
@@ -503,13 +630,16 @@ class Dotdigitalgroup_Email_Helper_Data extends Mage_Core_Helper_Abstract
|
|
503 |
Â
{
|
504 |
Â
$website = Mage::app()->getWebsite($websiteId);
|
505 |
Â
|
506 |
-
return
|
Â
|
|
Â
|
|
507 |
Â
|
508 |
Â
}
|
509 |
Â
|
510 |
Â
/**
|
511 |
Â
* Generate the baseurl for the default store
|
512 |
Â
* dynamic content will be displayed
|
Â
|
|
513 |
Â
* @return string
|
514 |
Â
* @throws Mage_Core_Exception
|
515 |
Â
*/
|
@@ -518,16 +648,20 @@ class Dotdigitalgroup_Email_Helper_Data extends Mage_Core_Helper_Abstract
|
|
518 |
Â
$website = Mage::app()->getRequest()->getParam('website', false);
|
519 |
Â
|
520 |
Â
//set website url for the default store id
|
521 |
-
$website = ($website)? Mage::app()->getWebsite(
|
522 |
Â
|
523 |
Â
$defaultGroup = Mage::app()->getWebsite($website)
|
524 |
Â
->getDefaultGroup();
|
525 |
Â
|
526 |
-
if (
|
527 |
-
return $mage = Mage::app()->getStore()->getBaseUrl(
|
Â
|
|
Â
|
|
Â
|
|
528 |
Â
|
529 |
Â
//base url
|
530 |
-
$baseUrl = Mage::app()->getStore($defaultGroup->getDefaultStore())
|
Â
|
|
531 |
Â
|
532 |
Â
return $baseUrl;
|
533 |
Â
|
@@ -537,11 +671,15 @@ class Dotdigitalgroup_Email_Helper_Data extends Mage_Core_Helper_Abstract
|
|
537 |
Â
*
|
538 |
Â
*
|
539 |
Â
* @param int $store
|
Â
|
|
540 |
Â
* @return mixed
|
541 |
Â
*/
|
542 |
Â
public function isNewsletterSuccessDisabled($store = 0)
|
543 |
Â
{
|
544 |
-
return Mage::getStoreConfig(
|
Â
|
|
Â
|
|
Â
|
|
545 |
Â
}
|
546 |
Â
|
547 |
Â
/**
|
@@ -549,7 +687,9 @@ class Dotdigitalgroup_Email_Helper_Data extends Mage_Core_Helper_Abstract
|
|
549 |
Â
*/
|
550 |
Â
public function getEasyEmailCapture()
|
551 |
Â
{
|
552 |
-
return Mage::getStoreConfigFlag(
|
Â
|
|
Â
|
|
553 |
Â
}
|
554 |
Â
|
555 |
Â
/**
|
@@ -557,8 +697,11 @@ class Dotdigitalgroup_Email_Helper_Data extends Mage_Core_Helper_Abstract
|
|
557 |
Â
*/
|
558 |
Â
public function getEasyEmailCaptureForNewsletter()
|
559 |
Â
{
|
560 |
-
return Mage::getStoreConfigFlag(
|
Â
|
|
Â
|
|
561 |
Â
}
|
Â
|
|
562 |
Â
/**
|
563 |
Â
* get feefo logon config value
|
564 |
Â
*
|
@@ -566,7 +709,9 @@ class Dotdigitalgroup_Email_Helper_Data extends Mage_Core_Helper_Abstract
|
|
566 |
Â
*/
|
567 |
Â
public function getFeefoLogon()
|
568 |
Â
{
|
569 |
-
return $this->getWebsiteConfig(
|
Â
|
|
Â
|
|
570 |
Â
}
|
571 |
Â
|
572 |
Â
/**
|
@@ -576,7 +721,9 @@ class Dotdigitalgroup_Email_Helper_Data extends Mage_Core_Helper_Abstract
|
|
576 |
Â
*/
|
577 |
Â
public function getFeefoReviewsPerProduct()
|
578 |
Â
{
|
579 |
-
return $this->getWebsiteConfig(
|
Â
|
|
Â
|
|
580 |
Â
}
|
581 |
Â
|
582 |
Â
/**
|
@@ -586,41 +733,56 @@ class Dotdigitalgroup_Email_Helper_Data extends Mage_Core_Helper_Abstract
|
|
586 |
Â
*/
|
587 |
Â
public function getFeefoLogoTemplate()
|
588 |
Â
{
|
589 |
-
return $this->getWebsiteConfig(
|
Â
|
|
Â
|
|
590 |
Â
}
|
591 |
Â
|
592 |
-
|
593 |
-
|
594 |
-
|
595 |
-
|
596 |
-
|
597 |
-
|
598 |
-
|
599 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
600 |
Â
|
601 |
Â
/**
|
602 |
Â
* update data fields
|
603 |
Â
*
|
604 |
-
* @param
|
605 |
Â
* @param Mage_Core_Model_Website $website
|
606 |
-
* @param
|
607 |
Â
*/
|
608 |
-
public function updateDataFields(
|
609 |
-
|
Â
|
|
Â
|
|
Â
|
|
610 |
Â
$data = array();
|
611 |
-
if($
|
Â
|
|
Â
|
|
Â
|
|
612 |
Â
$data[] = array(
|
613 |
-
'Key' => $
|
614 |
Â
'Value' => $storeName
|
615 |
Â
);
|
616 |
Â
}
|
617 |
-
if($
|
Â
|
|
Â
|
|
Â
|
|
618 |
Â
$data[] = array(
|
619 |
-
'Key' => $
|
620 |
Â
'Value' => $website->getName()
|
621 |
Â
);
|
622 |
Â
}
|
623 |
-
if(!empty($data)){
|
624 |
Â
//update data fields
|
625 |
Â
$client = $this->getWebsiteApiClient($website);
|
626 |
Â
$client->updateContactDatafieldsByEmail($email, $data);
|
@@ -629,25 +791,32 @@ class Dotdigitalgroup_Email_Helper_Data extends Mage_Core_Helper_Abstract
|
|
629 |
Â
|
630 |
Â
/**
|
631 |
Â
* check connector SMTP installed/active status
|
Â
|
|
632 |
Â
* @return boolean
|
633 |
Â
*/
|
634 |
Â
public function isSmtpEnabled()
|
635 |
Â
{
|
636 |
-
return (bool)Mage::getConfig()->getModuleConfig('Ddg_Transactional')
|
Â
|
|
637 |
Â
}
|
638 |
Â
|
639 |
Â
/**
|
640 |
Â
* Is magento enterprise.
|
Â
|
|
641 |
Â
* @return bool
|
642 |
Â
*/
|
643 |
Â
public function isEnterprise()
|
644 |
Â
{
|
645 |
-
return Mage::getConfig
|
Â
|
|
Â
|
|
Â
|
|
646 |
Â
|
647 |
Â
}
|
648 |
Â
|
649 |
Â
/**
|
650 |
Â
* Update last quote id datafield.
|
Â
|
|
651 |
Â
* @param $quoteId
|
652 |
Â
* @param $email
|
653 |
Â
* @param $websiteId
|
@@ -672,17 +841,25 @@ class Dotdigitalgroup_Email_Helper_Data extends Mage_Core_Helper_Abstract
|
|
672 |
Â
public function disableRaygun()
|
673 |
Â
{
|
674 |
Â
$config = Mage::getModel('core/config');
|
675 |
-
$config->saveConfig(
|
Â
|
|
Â
|
|
Â
|
|
676 |
Â
Mage::getConfig()->cleanCache();
|
677 |
Â
}
|
678 |
Â
|
679 |
Â
public function enableRaygunCode()
|
680 |
Â
{
|
681 |
Â
$curl = new Varien_Http_Adapter_Curl();
|
682 |
-
$curl->setConfig(
|
683 |
-
|
684 |
-
|
685 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
686 |
Â
$data = $curl->read();
|
687 |
Â
|
688 |
Â
if ($data === false) {
|
@@ -692,15 +869,19 @@ class Dotdigitalgroup_Email_Helper_Data extends Mage_Core_Helper_Abstract
|
|
692 |
Â
$data = trim($data[1]);
|
693 |
Â
$curl->close();
|
694 |
Â
|
695 |
-
$xml
|
696 |
Â
$raygunCode = $xml->code;
|
697 |
Â
|
698 |
Â
//not found
|
699 |
-
if (!$raygunCode)
|
700 |
Â
return;
|
Â
|
|
701 |
Â
|
702 |
Â
$config = Mage::getModel('core/config');
|
703 |
-
$config->saveConfig(
|
Â
|
|
Â
|
|
Â
|
|
704 |
Â
}
|
705 |
Â
|
706 |
Â
/**
|
@@ -708,10 +889,11 @@ class Dotdigitalgroup_Email_Helper_Data extends Mage_Core_Helper_Abstract
|
|
708 |
Â
*
|
709 |
Â
* @param $e Exception
|
710 |
Â
*/
|
711 |
-
public function sendRaygunException(
|
712 |
Â
{
|
713 |
-
if (!$this->raygunEnabled())
|
714 |
Â
return;
|
Â
|
|
715 |
Â
$baseUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
|
716 |
Â
$tags = array(
|
717 |
Â
$baseUrl,
|
@@ -732,8 +914,12 @@ class Dotdigitalgroup_Email_Helper_Data extends Mage_Core_Helper_Abstract
|
|
732 |
Â
*/
|
733 |
Â
public function getOrderSyncEnabled($websiteId = 0)
|
734 |
Â
{
|
735 |
-
return Mage::getStoreConfigFlag(
|
Â
|
|
Â
|
|
Â
|
|
736 |
Â
}
|
Â
|
|
737 |
Â
/**
|
738 |
Â
* @param int $websiteId
|
739 |
Â
*
|
@@ -741,7 +927,10 @@ class Dotdigitalgroup_Email_Helper_Data extends Mage_Core_Helper_Abstract
|
|
741 |
Â
*/
|
742 |
Â
public function getCatalogSyncEnabled($websiteId = 0)
|
743 |
Â
{
|
744 |
-
return Mage::getStoreConfigFlag(
|
Â
|
|
Â
|
|
Â
|
|
745 |
Â
}
|
746 |
Â
|
747 |
Â
/**
|
@@ -751,7 +940,10 @@ class Dotdigitalgroup_Email_Helper_Data extends Mage_Core_Helper_Abstract
|
|
751 |
Â
*/
|
752 |
Â
public function getContactSyncEnabled($websiteId = 0)
|
753 |
Â
{
|
754 |
-
return Mage::getStoreConfigFlag(
|
Â
|
|
Â
|
|
Â
|
|
755 |
Â
}
|
756 |
Â
|
757 |
Â
/**
|
@@ -761,7 +953,10 @@ class Dotdigitalgroup_Email_Helper_Data extends Mage_Core_Helper_Abstract
|
|
761 |
Â
*/
|
762 |
Â
public function getGuestSyncEnabled($websiteId = 0)
|
763 |
Â
{
|
764 |
-
return Mage::getStoreConfigFlag(
|
Â
|
|
Â
|
|
Â
|
|
765 |
Â
}
|
766 |
Â
|
767 |
Â
/**
|
@@ -771,7 +966,10 @@ class Dotdigitalgroup_Email_Helper_Data extends Mage_Core_Helper_Abstract
|
|
771 |
Â
*/
|
772 |
Â
public function getSubscriberSyncEnabled($websiteId = 0)
|
773 |
Â
{
|
774 |
-
return Mage::getStoreConfigFlag(
|
Â
|
|
Â
|
|
Â
|
|
775 |
Â
}
|
776 |
Â
|
777 |
Â
/**
|
@@ -779,25 +977,31 @@ class Dotdigitalgroup_Email_Helper_Data extends Mage_Core_Helper_Abstract
|
|
779 |
Â
*/
|
780 |
Â
public function getCronInstalled()
|
781 |
Â
{
|
782 |
-
$lastCustomerSync = Mage::getModel('ddg_automation/cron')
|
Â
|
|
783 |
Â
$timespan = Mage::helper('ddg')->dateDiff($lastCustomerSync);
|
784 |
Â
|
785 |
Â
//last customer cron was less then 15 min
|
786 |
Â
if ($timespan <= 15 * 60) {
|
787 |
Â
return true;
|
788 |
Â
}
|
Â
|
|
789 |
Â
return false;
|
790 |
Â
}
|
Â
|
|
791 |
Â
/**
|
792 |
Â
* Get the config id by the automation type.
|
793 |
-
*
|
Â
|
|
794 |
Â
* @param int $websiteId
|
795 |
Â
*
|
796 |
Â
* @return mixed
|
797 |
Â
*/
|
798 |
Â
public function getAutomationIdByType($automationType, $websiteId = 0)
|
799 |
Â
{
|
800 |
-
$path = constant(
|
Â
|
|
Â
|
|
801 |
Â
$automationCampaignId = $this->getWebsiteConfig($path, $websiteId);
|
802 |
Â
|
803 |
Â
return $automationCampaignId;
|
@@ -805,12 +1009,15 @@ class Dotdigitalgroup_Email_Helper_Data extends Mage_Core_Helper_Abstract
|
|
805 |
Â
|
806 |
Â
public function getAbandonedProductName()
|
807 |
Â
{
|
808 |
-
return Mage::getStoreConfig(
|
Â
|
|
Â
|
|
809 |
Â
|
810 |
Â
}
|
811 |
Â
|
812 |
Â
/**
|
813 |
Â
* Update last quote id datafield.
|
Â
|
|
814 |
Â
* @param $name
|
815 |
Â
* @param $email
|
816 |
Â
* @param $websiteId
|
@@ -843,7 +1050,9 @@ class Dotdigitalgroup_Email_Helper_Data extends Mage_Core_Helper_Abstract
|
|
843 |
Â
public function getApiResponseTimeLimit($websiteId = 0)
|
844 |
Â
{
|
845 |
Â
$website = Mage::app()->getWebsite($websiteId);
|
846 |
-
$limit = $website->getConfig(
|
Â
|
|
Â
|
|
847 |
Â
|
848 |
Â
return $limit;
|
849 |
Â
}
|
@@ -855,27 +1064,32 @@ class Dotdigitalgroup_Email_Helper_Data extends Mage_Core_Helper_Abstract
|
|
855 |
Â
*
|
856 |
Â
* @return string
|
857 |
Â
*/
|
858 |
-
public function getAccountEmail(
|
859 |
Â
{
|
860 |
Â
$client = $this->getWebsiteApiClient($website);
|
861 |
-
$info =
|
862 |
Â
$email = '';
|
863 |
Â
|
864 |
-
if(isset($info->properties)){
|
865 |
Â
$properties = $info->properties;
|
866 |
Â
|
867 |
-
foreach (
|
868 |
Â
|
869 |
-
if ($property->name == 'MainEmail')
|
870 |
Â
$email = $property->value;
|
Â
|
|
871 |
Â
}
|
872 |
Â
}
|
Â
|
|
873 |
Â
return $email;
|
874 |
Â
}
|
875 |
Â
|
876 |
Â
public function authIpAddress()
|
877 |
Â
{
|
878 |
-
if ($ipString = Mage::getStoreConfig(
|
Â
|
|
Â
|
|
Â
|
|
879 |
Â
//string to array
|
880 |
Â
$ipArray = explode(',', $ipString);
|
881 |
Â
//remove white spaces
|
@@ -891,35 +1105,38 @@ class Dotdigitalgroup_Email_Helper_Data extends Mage_Core_Helper_Abstract
|
|
891 |
Â
|
892 |
Â
return false;
|
893 |
Â
} else {
|
894 |
-
|
895 |
-
|
896 |
Â
}
|
897 |
Â
}
|
898 |
Â
|
899 |
-
|
900 |
-
|
901 |
-
|
902 |
-
|
903 |
-
|
904 |
-
|
905 |
-
|
906 |
Â
public function getLogFileContent($filename = 'connector_api.log')
|
907 |
Â
{
|
908 |
-
$
|
909 |
-
|
910 |
-
|
Â
|
|
911 |
Â
|
912 |
-
|
913 |
-
|
914 |
Â
|
915 |
Â
if (!$handle) {
|
916 |
-
return "Log file is not readable or does not exist at this moment. File path is "
|
Â
|
|
917 |
Â
}
|
918 |
Â
|
919 |
-
|
920 |
Â
|
921 |
Â
if (!$contents) {
|
922 |
-
return "Log file is not readable or does not exist at this moment. File path is "
|
Â
|
|
923 |
Â
}
|
924 |
Â
fclose($handle);
|
925 |
Â
|
@@ -927,69 +1144,803 @@ class Dotdigitalgroup_Email_Helper_Data extends Mage_Core_Helper_Abstract
|
|
927 |
Â
}
|
928 |
Â
|
929 |
Â
|
930 |
-
|
931 |
-
|
932 |
-
|
933 |
-
|
934 |
-
|
935 |
-
|
936 |
-
|
937 |
-
|
938 |
-
|
939 |
-
|
940 |
-
|
941 |
-
|
942 |
-
|
943 |
-
|
944 |
-
|
945 |
-
|
946 |
-
|
947 |
-
|
948 |
-
|
949 |
-
|
950 |
-
|
951 |
-
|
952 |
-
|
953 |
-
|
954 |
-
|
955 |
-
|
956 |
-
|
957 |
-
|
958 |
-
|
959 |
-
|
960 |
-
|
961 |
-
|
962 |
-
|
963 |
-
|
964 |
-
|
965 |
-
|
966 |
-
|
967 |
-
|
968 |
-
|
969 |
-
|
970 |
-
|
971 |
-
|
972 |
-
|
973 |
-
|
974 |
-
|
975 |
-
|
976 |
-
|
977 |
-
|
978 |
-
|
979 |
-
|
980 |
-
|
981 |
-
|
982 |
-
|
983 |
-
|
984 |
-
|
985 |
-
|
986 |
-
|
987 |
-
|
988 |
-
|
989 |
-
|
990 |
-
|
991 |
-
|
992 |
-
|
993 |
-
|
994 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
995 |
Â
}
|
6 |
Â
public function isEnabled($website = 0)
|
7 |
Â
{
|
8 |
Â
$website = Mage::app()->getWebsite($website);
|
9 |
+
|
10 |
+
return (bool)$website->getConfig(
|
11 |
+
Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_API_ENABLED
|
12 |
+
);
|
13 |
Â
}
|
14 |
Â
|
15 |
Â
/**
|
16 |
+
* @param int /object $website
|
17 |
+
*
|
18 |
Â
* @return mixed
|
19 |
Â
*/
|
20 |
Â
public function getApiUsername($website = 0)
|
21 |
Â
{
|
22 |
Â
$website = Mage::app()->getWebsite($website);
|
23 |
Â
|
24 |
+
return $website->getConfig(
|
25 |
+
Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_API_USERNAME
|
26 |
+
);
|
27 |
Â
}
|
28 |
Â
|
29 |
Â
public function getApiPassword($website = 0)
|
30 |
Â
{
|
31 |
Â
$website = Mage::app()->getWebsite($website);
|
32 |
Â
|
33 |
+
return Mage::helper('core')->decrypt(
|
34 |
+
$website->getConfig(
|
35 |
+
Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_API_PASSWORD
|
36 |
+
)
|
37 |
+
);
|
38 |
+
|
39 |
Â
}
|
40 |
Â
|
41 |
Â
public function auth($authRequest)
|
42 |
Â
{
|
43 |
+
if ($authRequest != Mage::getStoreConfig(
|
44 |
+
Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_DYNAMIC_CONTENT_PASSCODE
|
45 |
+
)
|
46 |
+
) {
|
47 |
+
$this->getRaygunClient()->Send(
|
48 |
+
'Authentication failed with code :' . $authRequest
|
49 |
+
);
|
50 |
+
|
51 |
Â
return false;
|
52 |
Â
}
|
53 |
+
|
54 |
Â
return true;
|
55 |
Â
}
|
56 |
Â
|
57 |
Â
public function getMappedCustomerId()
|
58 |
Â
{
|
59 |
+
return Mage::getStoreConfig(
|
60 |
+
Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_MAPPING_CUSTOMER_ID
|
61 |
+
);
|
62 |
Â
}
|
63 |
Â
|
64 |
Â
public function getMappedOrderId()
|
65 |
Â
{
|
66 |
+
return Mage::getStoreConfig(
|
67 |
+
Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_MAPPING_LAST_ORDER_ID
|
68 |
+
);
|
69 |
Â
}
|
70 |
Â
|
71 |
Â
public function getPasscode()
|
72 |
Â
{
|
73 |
+
return Mage::getStoreConfig(
|
74 |
+
Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_DYNAMIC_CONTENT_PASSCODE
|
75 |
+
);
|
76 |
Â
}
|
77 |
Â
|
78 |
Â
public function getLastOrderId()
|
79 |
Â
{
|
80 |
+
return Mage::getStoreConfig(
|
81 |
+
Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_MAPPING_LAST_ORDER_ID
|
82 |
+
);
|
83 |
Â
|
84 |
Â
}
|
85 |
Â
|
86 |
Â
public function getLastQuoteId()
|
87 |
Â
{
|
88 |
+
return Mage::getStoreConfig(
|
89 |
+
Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_MAPPING_LAST_QUOTE_ID
|
90 |
+
);
|
91 |
Â
|
92 |
Â
}
|
93 |
Â
|
99 |
Â
Mage::log($data, $level, $filename, $force = true);
|
100 |
Â
}
|
101 |
Â
|
102 |
+
return $this;
|
103 |
Â
}
|
104 |
Â
|
105 |
Â
public function getDebugEnabled()
|
106 |
Â
{
|
107 |
+
return (bool)Mage::getStoreConfig(
|
108 |
+
Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_ADVANCED_DEBUG_ENABLED
|
109 |
+
);
|
110 |
Â
}
|
111 |
Â
|
112 |
Â
/**
|
113 |
Â
* Extension version number.
|
114 |
+
*
|
115 |
Â
* @return string
|
116 |
Â
*/
|
117 |
Â
public function getConnectorVersion()
|
118 |
Â
{
|
119 |
+
$modules = (array)Mage::getConfig()->getNode('modules')->children();
|
120 |
Â
if (isset($modules['Dotdigitalgroup_Email'])) {
|
121 |
Â
$moduleName = $modules['Dotdigitalgroup_Email'];
|
122 |
+
|
123 |
+
return (string)$moduleName->version;
|
124 |
Â
}
|
125 |
+
|
126 |
Â
return '';
|
127 |
Â
}
|
128 |
Â
|
129 |
Â
|
130 |
Â
public function getPageTrackingEnabled()
|
131 |
Â
{
|
132 |
+
return (bool)Mage::getStoreConfig(
|
133 |
+
Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_PAGE_TRACKING_ENABLED
|
134 |
+
);
|
135 |
Â
}
|
136 |
Â
|
137 |
Â
public function getRoiTrackingEnabled()
|
138 |
Â
{
|
139 |
+
return (bool)Mage::getStoreConfig(
|
140 |
+
Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_ROI_TRACKING_ENABLED
|
141 |
+
);
|
142 |
Â
}
|
143 |
Â
|
144 |
Â
public function getResourceAllocationEnabled()
|
145 |
Â
{
|
146 |
+
return (bool)Mage::getStoreConfig(
|
147 |
+
Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_RESOURCE_ALLOCATION
|
148 |
+
);
|
149 |
Â
}
|
150 |
Â
|
151 |
Â
public function getMappedStoreName($website)
|
152 |
Â
{
|
153 |
+
$mapped = $website->getConfig(
|
154 |
+
Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_MAPPING_CUSTOMER_STORENAME
|
155 |
+
);
|
156 |
+
$storeName = ($mapped) ? $mapped : '';
|
157 |
+
|
158 |
+
return $storeName;
|
159 |
Â
}
|
160 |
Â
|
161 |
Â
/**
|
162 |
Â
* Get the contact id for the custoemer based on website id.
|
163 |
+
*
|
164 |
Â
* @param $email
|
165 |
Â
* @param $websiteId
|
166 |
Â
*
|
168 |
Â
*/
|
169 |
Â
public function getContactId($email, $websiteId)
|
170 |
Â
{
|
171 |
+
$contact = Mage::getModel('ddg_automation/contact')
|
172 |
+
->loadByCustomerEmail($email, $websiteId);
|
173 |
Â
if ($contactId = $contact->getContactId()) {
|
174 |
Â
return $contactId;
|
175 |
Â
}
|
177 |
Â
$client = $this->getWebsiteApiClient($websiteId);
|
178 |
Â
$response = $client->postContacts($email);
|
179 |
Â
|
180 |
+
if (isset($response->message)) {
|
181 |
Â
return false;
|
182 |
+
}
|
183 |
Â
//save contact id
|
184 |
+
if (isset($response->id)) {
|
185 |
Â
$contact->setContactId($response->id)
|
186 |
Â
->save();
|
187 |
Â
}
|
188 |
+
|
189 |
Â
return $response->id;
|
190 |
Â
}
|
191 |
Â
|
192 |
Â
public function getCustomerAddressBook($website)
|
193 |
Â
{
|
194 |
Â
$website = Mage::app()->getWebsite($website);
|
195 |
+
|
196 |
+
return $website->getConfig(
|
197 |
+
Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMERS_ADDRESS_BOOK_ID
|
198 |
+
);
|
199 |
Â
}
|
200 |
Â
|
201 |
Â
public function getSubscriberAddressBook($website)
|
202 |
Â
{
|
203 |
Â
$website = Mage::app()->getWebsite($website);
|
204 |
+
|
205 |
+
return $website->getConfig(
|
206 |
+
Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_SUBSCRIBERS_ADDRESS_BOOK_ID
|
207 |
+
);
|
208 |
Â
}
|
209 |
Â
|
210 |
Â
public function getGuestAddressBook($website)
|
211 |
Â
{
|
212 |
Â
$website = Mage::app()->getWebsite($website);
|
213 |
+
|
214 |
+
return $website->getConfig(
|
215 |
+
Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_GUEST_ADDRESS_BOOK_ID
|
216 |
+
);
|
217 |
Â
}
|
218 |
Â
|
219 |
Â
/**
|
220 |
Â
* @return $this
|
221 |
Â
*/
|
222 |
+
public function allowResourceFullExecution()
|
223 |
Â
{
|
224 |
Â
if ($this->getResourceAllocationEnabled()) {
|
225 |
Â
|
230 |
Â
/* and memory to 512 megabytes */
|
231 |
Â
ini_set('memory_limit', '512M');
|
232 |
Â
}
|
233 |
+
|
234 |
Â
return $this;
|
235 |
Â
}
|
236 |
+
|
237 |
Â
public function convert($size)
|
238 |
Â
{
|
239 |
+
$unit = array('b', 'kb', 'mb', 'gb', 'tb', 'pb');
|
240 |
+
|
241 |
+
return round($size / pow(1024, ($i = floor(log($size, 1024)))), 2) . ' '
|
242 |
+
. $unit[$i];
|
243 |
Â
}
|
244 |
Â
|
245 |
Â
/**
|
251 |
Â
foreach (Mage::app()->getWebsites() as $website) {
|
252 |
Â
$websiteId = $website->getId();
|
253 |
Â
$apiUsername = $this->getApiUsername($website);
|
254 |
+
$accounts[$apiUsername] = $apiUsername . ', websiteId: '
|
255 |
+
. $websiteId . ' name ' . $website->getName();
|
256 |
Â
}
|
257 |
+
|
258 |
Â
return implode('</br>', $accounts);
|
259 |
Â
}
|
260 |
Â
|
267 |
Â
public function getCustomAttributes($website = 0)
|
268 |
Â
{
|
269 |
Â
$website = Mage::app()->getWebsite($website);
|
270 |
+
$attr = $website->getConfig(
|
271 |
+
Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_MAPPING_CUSTOM_DATAFIELDS
|
272 |
+
);
|
273 |
Â
|
274 |
+
if (!$attr) {
|
275 |
Â
return array();
|
276 |
+
}
|
277 |
Â
|
278 |
Â
return unserialize($attr);
|
279 |
Â
}
|
281 |
Â
|
282 |
Â
/**
|
283 |
Â
* Enterprise custom datafields attributes.
|
284 |
+
*
|
285 |
Â
* @param int $website
|
286 |
Â
*
|
287 |
Â
* @return array
|
288 |
Â
* @throws Mage_Core_Exception
|
289 |
Â
*/
|
290 |
+
public function getEnterpriseAttributes($website = 0)
|
291 |
+
{
|
292 |
Â
$website = Mage::app()->getWebsite($website);
|
293 |
Â
$result = array();
|
294 |
+
$attrs = $website->getConfig(
|
295 |
+
'connector_data_mapping/enterprise_data'
|
296 |
+
);
|
297 |
Â
|
298 |
+
if (is_array($attrs)) {
|
299 |
Â
//get individual mapped keys
|
300 |
+
foreach ($attrs as $key => $one) {
|
301 |
+
$config = $website->getConfig(
|
302 |
+
'connector_data_mapping/enterprise_data/' . $key
|
303 |
+
);
|
304 |
Â
//check for the mapped field
|
305 |
+
if ($config) {
|
306 |
Â
$result[$key] = $config;
|
307 |
+
}
|
308 |
Â
}
|
309 |
Â
}
|
310 |
Â
|
311 |
+
if (empty($result)) {
|
312 |
Â
return false;
|
313 |
+
}
|
314 |
+
|
315 |
Â
return $result;
|
316 |
Â
}
|
317 |
Â
|
318 |
Â
/**
|
319 |
+
* @param $path
|
320 |
Â
* @param null|string|bool|int|Mage_Core_Model_Website $websiteId
|
321 |
+
*
|
322 |
Â
* @return mixed
|
323 |
Â
*/
|
324 |
Â
public function getWebsiteConfig($path, $websiteId = 0)
|
325 |
Â
{
|
326 |
Â
$website = Mage::app()->getWebsite($websiteId);
|
327 |
+
|
328 |
Â
return $website->getConfig($path);
|
329 |
Â
}
|
330 |
Â
|
337 |
Â
*/
|
338 |
Â
public function getWebsiteApiClient($website = 0)
|
339 |
Â
{
|
340 |
+
if (!$this->isEnabled($website)) {
|
341 |
Â
return false;
|
342 |
+
}
|
343 |
Â
|
344 |
+
if (!$apiUsername = $this->getApiUsername($website)
|
345 |
+
|| !$apiPassword
|
346 |
+
= $this->getApiPassword($website)
|
347 |
+
) {
|
348 |
Â
return false;
|
349 |
+
}
|
350 |
Â
|
351 |
Â
$client = Mage::getModel('ddg_automation/apiconnector_client');
|
352 |
Â
$client->setApiUsername($this->getApiUsername($website))
|
368 |
Â
|
369 |
Â
/**
|
370 |
Â
* Autorisation url for OAUTH.
|
371 |
+
*
|
372 |
Â
* @return string
|
373 |
Â
*/
|
374 |
Â
public function getAuthoriseUrl()
|
375 |
Â
{
|
376 |
+
$clientId = Mage::getStoreConfig(
|
377 |
+
Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CLIENT_ID
|
378 |
+
);
|
379 |
Â
|
380 |
Â
//callback uri if not set custom
|
381 |
Â
$redirectUri = $this->getRedirectUri();
|
390 |
Â
);
|
391 |
Â
|
392 |
Â
$authorizeBaseUrl = Mage::helper('ddg/config')->getAuthorizeLink();
|
393 |
+
$url = $authorizeBaseUrl . http_build_query($params)
|
394 |
+
. '&client_id=' . $clientId;
|
395 |
Â
|
396 |
Â
return $url;
|
397 |
Â
}
|
405 |
Â
|
406 |
Â
/**
|
407 |
Â
* order status config value
|
408 |
+
*
|
409 |
Â
* @param int $website
|
410 |
+
*
|
411 |
Â
* @return mixed order status
|
412 |
Â
*/
|
413 |
Â
public function getConfigSelectedStatus($website = 0)
|
414 |
Â
{
|
415 |
+
$status = $this->getWebsiteConfig(
|
416 |
+
Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_SYNC_ORDER_STATUS,
|
417 |
+
$website
|
418 |
+
);
|
419 |
+
if ($status) {
|
420 |
+
return explode(',', $status);
|
421 |
+
} else {
|
422 |
Â
return false;
|
423 |
+
}
|
424 |
Â
}
|
425 |
Â
|
426 |
Â
public function getConfigSelectedCustomOrderAttributes($website = 0)
|
427 |
Â
{
|
428 |
+
$customAttributes = $this->getWebsiteConfig(
|
429 |
+
Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOM_ORDER_ATTRIBUTES,
|
430 |
+
$website
|
431 |
+
);
|
432 |
+
if ($customAttributes) {
|
433 |
+
return explode(',', $customAttributes);
|
434 |
+
} else {
|
435 |
Â
return false;
|
436 |
+
}
|
437 |
Â
}
|
438 |
Â
|
439 |
Â
public function getConfigSelectedCustomQuoteAttributes($website = 0)
|
440 |
Â
{
|
441 |
+
$customAttributes = $this->getWebsiteConfig(
|
442 |
+
Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOM_QUOTE_ATTRIBUTES,
|
443 |
+
$website
|
444 |
+
);
|
445 |
+
if ($customAttributes) {
|
446 |
+
return explode(',', $customAttributes);
|
447 |
+
} else {
|
448 |
Â
return false;
|
449 |
+
}
|
450 |
Â
}
|
451 |
Â
|
452 |
Â
/**
|
453 |
Â
* check sweet tooth installed/active status
|
454 |
+
*
|
455 |
Â
* @return boolean
|
456 |
Â
*/
|
457 |
Â
public function isSweetToothEnabled()
|
458 |
Â
{
|
459 |
+
return (bool)Mage::getConfig()->getModuleConfig('TBT_Rewards')->is(
|
460 |
+
'active', 'true'
|
461 |
+
);
|
462 |
Â
}
|
463 |
Â
|
464 |
Â
/**
|
465 |
Â
* check sweet tooth installed/active status and active status
|
466 |
+
*
|
467 |
Â
* @param Mage_Core_Model_Website $website
|
468 |
+
*
|
469 |
Â
* @return boolean
|
470 |
Â
*/
|
471 |
Â
public function isSweetToothToGo($website)
|
472 |
Â
{
|
473 |
+
$stMappingStatus = $this->getWebsiteConfig(
|
474 |
+
Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_MAPPING_SWEETTOOTH_ACTIVE,
|
475 |
+
$website
|
476 |
+
);
|
477 |
+
if ($stMappingStatus && $this->isSweetToothEnabled()) {
|
478 |
+
return true;
|
479 |
+
}
|
480 |
+
|
481 |
Â
return false;
|
482 |
Â
}
|
483 |
Â
|
492 |
Â
array("customer_id = ?" => $customerId)
|
493 |
Â
);
|
494 |
Â
} catch (Exception $e) {
|
495 |
+
Mage::logException($e);
|
496 |
Â
}
|
497 |
Â
}
|
498 |
Â
|
499 |
Â
/**
|
500 |
+
* Diff between to times.
|
501 |
+
*
|
502 |
+
* @param $timeOne
|
503 |
+
* @param null $timeTwo
|
504 |
Â
*
|
Â
|
|
Â
|
|
505 |
Â
* @return int
|
506 |
Â
*/
|
507 |
+
public function dateDiff($timeOne, $timeTwo = null)
|
508 |
+
{
|
509 |
+
if (is_null($timeTwo)) {
|
510 |
+
$timeTwo = Mage::getModel('core/date')->date();
|
511 |
Â
}
|
512 |
+
$timeOne = strtotime($timeOne);
|
513 |
+
$timeTwo = strtotime($timeTwo);
|
514 |
+
|
515 |
+
return $timeTwo - $timeOne;
|
516 |
Â
}
|
517 |
Â
|
518 |
Â
|
519 |
Â
/**
|
520 |
Â
* Disable website config when the request is made admin area only!
|
521 |
+
*
|
522 |
Â
* @param $path
|
523 |
Â
*
|
524 |
Â
* @throws Mage_Core_Exception
|
539 |
Â
|
540 |
Â
/**
|
541 |
Â
* number of customers with duplicate emails, emails as total number
|
542 |
+
*
|
543 |
Â
* @return Mage_Customer_Model_Resource_Customer_Collection
|
544 |
Â
*/
|
545 |
+
public function getCustomersWithDuplicateEmails()
|
546 |
+
{
|
547 |
Â
$customers = Mage::getModel('customer/customer')->getCollection();
|
548 |
Â
|
549 |
Â
//duplicate emails
|
562 |
Â
*/
|
563 |
Â
public function getRaygunClient()
|
564 |
Â
{
|
565 |
+
$code = Mage::getstoreConfig(
|
566 |
+
Dotdigitalgroup_Email_Helper_Config::XML_PATH_RAYGUN_APPLICATION_CODE
|
567 |
+
);
|
568 |
Â
|
569 |
Â
if ($this->raygunEnabled()) {
|
570 |
Â
//use async mode for sending.
|
571 |
+
$async = Mage::getStoreConfigFlag(
|
572 |
+
Dotdigitalgroup_Email_Helper_Config::XML_PATH_RAYGUN_APPLICATION_ASYNC
|
573 |
+
);
|
574 |
+
require_once Mage::getBaseDir('lib') . DS . 'Raygun4php' . DS
|
575 |
+
. 'RaygunClient.php';
|
576 |
+
|
577 |
Â
return new Raygun4php\RaygunClient($code, $async);
|
578 |
Â
}
|
579 |
Â
|
582 |
Â
|
583 |
Â
/**
|
584 |
Â
* Raygun logs.
|
585 |
+
*
|
586 |
+
* @param $message
|
587 |
Â
* @param string $filename
|
588 |
Â
* @param int $line
|
589 |
Â
* @param array $tags
|
590 |
Â
*
|
591 |
Â
* @return int|null
|
592 |
Â
*/
|
593 |
+
public function rayLog(
|
594 |
+
$message,
|
595 |
+
$filename = 'apiconnector/client.php',
|
596 |
+
$line = 1,
|
597 |
+
$tags = array()
|
598 |
+
) {
|
599 |
+
//check if raygun has code enabled
|
600 |
+
if (!$this->raygunEnabled()) {
|
601 |
Â
return;
|
602 |
+
}
|
603 |
Â
|
604 |
+
$baseUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
|
605 |
Â
|
606 |
+
if (empty($tags)) {
|
607 |
Â
$tags = array(
|
608 |
Â
$baseUrl,
|
609 |
Â
Mage::getVersion()
|
614 |
Â
//user, firstname, lastname, email, annonim, uuid
|
615 |
Â
$client->SetUser($baseUrl, null, null, $this->getApiUsername());
|
616 |
Â
$client->SetVersion($this->getConnectorVersion());
|
617 |
+
$client->SendError(100, $message, $filename, $line, $tags);
|
618 |
Â
}
|
619 |
Â
|
620 |
Â
|
621 |
Â
/**
|
622 |
Â
* check for raygun application and if enabled.
|
623 |
+
*
|
624 |
Â
* @param int $websiteId
|
625 |
Â
*
|
626 |
Â
* @return mixed
|
630 |
Â
{
|
631 |
Â
$website = Mage::app()->getWebsite($websiteId);
|
632 |
Â
|
633 |
+
return (bool)$website->getConfig(
|
634 |
+
Dotdigitalgroup_Email_Helper_Config::XML_PATH_RAYGUN_APPLICATION_CODE
|
635 |
+
);
|
636 |
Â
|
637 |
Â
}
|
638 |
Â
|
639 |
Â
/**
|
640 |
Â
* Generate the baseurl for the default store
|
641 |
Â
* dynamic content will be displayed
|
642 |
+
*
|
643 |
Â
* @return string
|
644 |
Â
* @throws Mage_Core_Exception
|
645 |
Â
*/
|
648 |
Â
$website = Mage::app()->getRequest()->getParam('website', false);
|
649 |
Â
|
650 |
Â
//set website url for the default store id
|
651 |
+
$website = ($website) ? Mage::app()->getWebsite($website) : 0;
|
652 |
Â
|
653 |
Â
$defaultGroup = Mage::app()->getWebsite($website)
|
654 |
Â
->getDefaultGroup();
|
655 |
Â
|
656 |
+
if (!$defaultGroup) {
|
657 |
+
return $mage = Mage::app()->getStore()->getBaseUrl(
|
658 |
+
Mage_Core_Model_Store::URL_TYPE_WEB
|
659 |
+
);
|
660 |
+
}
|
661 |
Â
|
662 |
Â
//base url
|
663 |
+
$baseUrl = Mage::app()->getStore($defaultGroup->getDefaultStore())
|
664 |
+
->getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK);
|
665 |
Â
|
666 |
Â
return $baseUrl;
|
667 |
Â
|
671 |
Â
*
|
672 |
Â
*
|
673 |
Â
* @param int $store
|
674 |
+
*
|
675 |
Â
* @return mixed
|
676 |
Â
*/
|
677 |
Â
public function isNewsletterSuccessDisabled($store = 0)
|
678 |
Â
{
|
679 |
+
return Mage::getStoreConfig(
|
680 |
+
Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_DISABLE_NEWSLETTER_SUCCESS,
|
681 |
+
$store
|
682 |
+
);
|
683 |
Â
}
|
684 |
Â
|
685 |
Â
/**
|
687 |
Â
*/
|
688 |
Â
public function getEasyEmailCapture()
|
689 |
Â
{
|
690 |
+
return Mage::getStoreConfigFlag(
|
691 |
+
Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_EMAIL_CAPTURE
|
692 |
+
);
|
693 |
Â
}
|
694 |
Â
|
695 |
Â
/**
|
697 |
Â
*/
|
698 |
Â
public function getEasyEmailCaptureForNewsletter()
|
699 |
Â
{
|
700 |
+
return Mage::getStoreConfigFlag(
|
701 |
+
Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_EMAIL_CAPTURE_NEWSLETTER
|
702 |
+
);
|
703 |
Â
}
|
704 |
+
|
705 |
Â
/**
|
706 |
Â
* get feefo logon config value
|
707 |
Â
*
|
709 |
Â
*/
|
710 |
Â
public function getFeefoLogon()
|
711 |
Â
{
|
712 |
+
return $this->getWebsiteConfig(
|
713 |
+
Dotdigitalgroup_Email_Helper_Config::XML_PATH_REVIEWS_FEEFO_LOGON
|
714 |
+
);
|
715 |
Â
}
|
716 |
Â
|
717 |
Â
/**
|
721 |
Â
*/
|
722 |
Â
public function getFeefoReviewsPerProduct()
|
723 |
Â
{
|
724 |
+
return $this->getWebsiteConfig(
|
725 |
+
Dotdigitalgroup_Email_Helper_Config::XML_PATH_REVIEWS_FEEFO_REVIEWS
|
726 |
+
);
|
727 |
Â
}
|
728 |
Â
|
729 |
Â
/**
|
733 |
Â
*/
|
734 |
Â
public function getFeefoLogoTemplate()
|
735 |
Â
{
|
736 |
+
return $this->getWebsiteConfig(
|
737 |
+
Dotdigitalgroup_Email_Helper_Config::XML_PATH_REVIEWS_FEEFO_TEMPLATE
|
738 |
+
);
|
739 |
Â
}
|
740 |
Â
|
741 |
+
/**
|
742 |
+
* @param $website
|
743 |
+
*
|
744 |
+
* @return string
|
745 |
+
*/
|
746 |
+
public function getReviewDisplayType($website)
|
747 |
+
{
|
748 |
+
return $this->getWebsiteConfig(
|
749 |
+
Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_DYNAMIC_CONTENT_REVIEW_DISPLAY_TYPE,
|
750 |
+
$website
|
751 |
+
);
|
752 |
+
}
|
753 |
Â
|
754 |
Â
/**
|
755 |
Â
* update data fields
|
756 |
Â
*
|
757 |
+
* @param $email
|
758 |
Â
* @param Mage_Core_Model_Website $website
|
759 |
+
* @param $storeName
|
760 |
Â
*/
|
761 |
+
public function updateDataFields(
|
762 |
+
$email,
|
763 |
+
Mage_Core_Model_Website $website,
|
764 |
+
$storeName
|
765 |
+
) {
|
766 |
Â
$data = array();
|
767 |
+
if ($storeName = $website->getConfig(
|
768 |
+
Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_STORE_NAME
|
769 |
+
)
|
770 |
+
) {
|
771 |
Â
$data[] = array(
|
772 |
+
'Key' => $storeName,
|
773 |
Â
'Value' => $storeName
|
774 |
Â
);
|
775 |
Â
}
|
776 |
+
if ($websiteName = $website->getConfig(
|
777 |
+
Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_WEBSITE_NAME
|
778 |
+
)
|
779 |
+
) {
|
780 |
Â
$data[] = array(
|
781 |
+
'Key' => $websiteName,
|
782 |
Â
'Value' => $website->getName()
|
783 |
Â
);
|
784 |
Â
}
|
785 |
+
if (!empty($data)) {
|
786 |
Â
//update data fields
|
787 |
Â
$client = $this->getWebsiteApiClient($website);
|
788 |
Â
$client->updateContactDatafieldsByEmail($email, $data);
|
791 |
Â
|
792 |
Â
/**
|
793 |
Â
* check connector SMTP installed/active status
|
794 |
+
*
|
795 |
Â
* @return boolean
|
796 |
Â
*/
|
797 |
Â
public function isSmtpEnabled()
|
798 |
Â
{
|
799 |
+
return (bool)Mage::getConfig()->getModuleConfig('Ddg_Transactional')
|
800 |
+
->is('active', 'true');
|
801 |
Â
}
|
802 |
Â
|
803 |
Â
/**
|
804 |
Â
* Is magento enterprise.
|
805 |
+
*
|
806 |
Â
* @return bool
|
807 |
Â
*/
|
808 |
Â
public function isEnterprise()
|
809 |
Â
{
|
810 |
+
return Mage::getConfig()->getModuleConfig('Enterprise_Enterprise')
|
811 |
+
&& Mage::getConfig()->getModuleConfig('Enterprise_AdminGws')
|
812 |
+
&& Mage::getConfig()->getModuleConfig('Enterprise_Checkout')
|
813 |
+
&& Mage::getConfig()->getModuleConfig('Enterprise_Customer');
|
814 |
Â
|
815 |
Â
}
|
816 |
Â
|
817 |
Â
/**
|
818 |
Â
* Update last quote id datafield.
|
819 |
+
*
|
820 |
Â
* @param $quoteId
|
821 |
Â
* @param $email
|
822 |
Â
* @param $websiteId
|
841 |
Â
public function disableRaygun()
|
842 |
Â
{
|
843 |
Â
$config = Mage::getModel('core/config');
|
844 |
+
$config->saveConfig(
|
845 |
+
Dotdigitalgroup_Email_Helper_Config::XML_PATH_RAYGUN_APPLICATION_CODE,
|
846 |
+
''
|
847 |
+
);
|
848 |
Â
Mage::getConfig()->cleanCache();
|
849 |
Â
}
|
850 |
Â
|
851 |
Â
public function enableRaygunCode()
|
852 |
Â
{
|
853 |
Â
$curl = new Varien_Http_Adapter_Curl();
|
854 |
+
$curl->setConfig(
|
855 |
+
array(
|
856 |
+
'timeout' => 2
|
857 |
+
)
|
858 |
+
);
|
859 |
+
$curl->write(
|
860 |
+
Zend_Http_Client::GET,
|
861 |
+
Dotdigitalgroup_Email_Helper_Config::RAYGUN_API_CODE_URL, '1.0'
|
862 |
+
);
|
863 |
Â
$data = $curl->read();
|
864 |
Â
|
865 |
Â
if ($data === false) {
|
869 |
Â
$data = trim($data[1]);
|
870 |
Â
$curl->close();
|
871 |
Â
|
872 |
+
$xml = new SimpleXMLElement($data);
|
873 |
Â
$raygunCode = $xml->code;
|
874 |
Â
|
875 |
Â
//not found
|
876 |
+
if (!$raygunCode) {
|
877 |
Â
return;
|
878 |
+
}
|
879 |
Â
|
880 |
Â
$config = Mage::getModel('core/config');
|
881 |
+
$config->saveConfig(
|
882 |
+
Dotdigitalgroup_Email_Helper_Config::XML_PATH_RAYGUN_APPLICATION_CODE,
|
883 |
+
$raygunCode
|
884 |
+
);
|
885 |
Â
}
|
886 |
Â
|
887 |
Â
/**
|
889 |
Â
*
|
890 |
Â
* @param $e Exception
|
891 |
Â
*/
|
892 |
+
public function sendRaygunException($e)
|
893 |
Â
{
|
894 |
+
if (!$this->raygunEnabled()) {
|
895 |
Â
return;
|
896 |
+
}
|
897 |
Â
$baseUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
|
898 |
Â
$tags = array(
|
899 |
Â
$baseUrl,
|
914 |
Â
*/
|
915 |
Â
public function getOrderSyncEnabled($websiteId = 0)
|
916 |
Â
{
|
917 |
+
return Mage::getStoreConfigFlag(
|
918 |
+
Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_SYNC_ORDER_ENABLED,
|
919 |
+
$websiteId
|
920 |
+
);
|
921 |
Â
}
|
922 |
+
|
923 |
Â
/**
|
924 |
Â
* @param int $websiteId
|
925 |
Â
*
|
927 |
Â
*/
|
928 |
Â
public function getCatalogSyncEnabled($websiteId = 0)
|
929 |
Â
{
|
930 |
+
return Mage::getStoreConfigFlag(
|
931 |
+
Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_SYNC_CATALOG_ENABLED,
|
932 |
+
$websiteId
|
933 |
+
);
|
934 |
Â
}
|
935 |
Â
|
936 |
Â
/**
|
940 |
Â
*/
|
941 |
Â
public function getContactSyncEnabled($websiteId = 0)
|
942 |
Â
{
|
943 |
+
return Mage::getStoreConfigFlag(
|
944 |
+
Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_SYNC_CONTACT_ENABLED,
|
945 |
+
$websiteId
|
946 |
+
);
|
947 |
Â
}
|
948 |
Â
|
949 |
Â
/**
|
953 |
Â
*/
|
954 |
Â
public function getGuestSyncEnabled($websiteId = 0)
|
955 |
Â
{
|
956 |
+
return Mage::getStoreConfigFlag(
|
957 |
+
Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_SYNC_GUEST_ENABLED,
|
958 |
+
$websiteId
|
959 |
+
);
|
960 |
Â
}
|
961 |
Â
|
962 |
Â
/**
|
966 |
Â
*/
|
967 |
Â
public function getSubscriberSyncEnabled($websiteId = 0)
|
968 |
Â
{
|
969 |
+
return Mage::getStoreConfigFlag(
|
970 |
+
Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_SYNC_SUBSCRIBER_ENABLED,
|
971 |
+
$websiteId
|
972 |
+
);
|
973 |
Â
}
|
974 |
Â
|
975 |
Â
/**
|
977 |
Â
*/
|
978 |
Â
public function getCronInstalled()
|
979 |
Â
{
|
980 |
+
$lastCustomerSync = Mage::getModel('ddg_automation/cron')
|
981 |
+
->getLastCustomerSync();
|
982 |
Â
$timespan = Mage::helper('ddg')->dateDiff($lastCustomerSync);
|
983 |
Â
|
984 |
Â
//last customer cron was less then 15 min
|
985 |
Â
if ($timespan <= 15 * 60) {
|
986 |
Â
return true;
|
987 |
Â
}
|
988 |
+
|
989 |
Â
return false;
|
990 |
Â
}
|
991 |
+
|
992 |
Â
/**
|
993 |
Â
* Get the config id by the automation type.
|
994 |
+
*
|
995 |
+
* @param $automationType
|
996 |
Â
* @param int $websiteId
|
997 |
Â
*
|
998 |
Â
* @return mixed
|
999 |
Â
*/
|
1000 |
Â
public function getAutomationIdByType($automationType, $websiteId = 0)
|
1001 |
Â
{
|
1002 |
+
$path = constant(
|
1003 |
+
'Dotdigitalgroup_Email_Helper_Config::' . $automationType
|
1004 |
+
);
|
1005 |
Â
$automationCampaignId = $this->getWebsiteConfig($path, $websiteId);
|
1006 |
Â
|
1007 |
Â
return $automationCampaignId;
|
1009 |
Â
|
1010 |
Â
public function getAbandonedProductName()
|
1011 |
Â
{
|
1012 |
+
return Mage::getStoreConfig(
|
1013 |
+
Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_ABANDONED_PRODUCT_NAME
|
1014 |
+
);
|
1015 |
Â
|
1016 |
Â
}
|
1017 |
Â
|
1018 |
Â
/**
|
1019 |
Â
* Update last quote id datafield.
|
1020 |
+
*
|
1021 |
Â
* @param $name
|
1022 |
Â
* @param $email
|
1023 |
Â
* @param $websiteId
|
1050 |
Â
public function getApiResponseTimeLimit($websiteId = 0)
|
1051 |
Â
{
|
1052 |
Â
$website = Mage::app()->getWebsite($websiteId);
|
1053 |
+
$limit = $website->getConfig(
|
1054 |
+
Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_DEBUG_API_REQUEST_LIMIT
|
1055 |
+
);
|
1056 |
Â
|
1057 |
Â
return $limit;
|
1058 |
Â
}
|
1064 |
Â
*
|
1065 |
Â
* @return string
|
1066 |
Â
*/
|
1067 |
+
public function getAccountEmail($website = 0)
|
1068 |
Â
{
|
1069 |
Â
$client = $this->getWebsiteApiClient($website);
|
1070 |
+
$info = $client->getAccountInfo();
|
1071 |
Â
$email = '';
|
1072 |
Â
|
1073 |
+
if (isset($info->properties)) {
|
1074 |
Â
$properties = $info->properties;
|
1075 |
Â
|
1076 |
+
foreach ($properties as $property) {
|
1077 |
Â
|
1078 |
+
if ($property->name == 'MainEmail') {
|
1079 |
Â
$email = $property->value;
|
1080 |
+
}
|
1081 |
Â
}
|
1082 |
Â
}
|
1083 |
+
|
1084 |
Â
return $email;
|
1085 |
Â
}
|
1086 |
Â
|
1087 |
Â
public function authIpAddress()
|
1088 |
Â
{
|
1089 |
+
if ($ipString = Mage::getStoreConfig(
|
1090 |
+
Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_IP_RESTRICTION_ADDRESSES
|
1091 |
+
)
|
1092 |
+
) {
|
1093 |
Â
//string to array
|
1094 |
Â
$ipArray = explode(',', $ipString);
|
1095 |
Â
//remove white spaces
|
1105 |
Â
|
1106 |
Â
return false;
|
1107 |
Â
} else {
|
1108 |
+
//empty ip list will ignore the validation
|
1109 |
+
return true;
|
1110 |
Â
}
|
1111 |
Â
}
|
1112 |
Â
|
1113 |
+
/**
|
1114 |
+
* get log file content.
|
1115 |
+
*
|
1116 |
+
* @param string $filename
|
1117 |
+
*
|
1118 |
+
* @return string
|
1119 |
+
*/
|
1120 |
Â
public function getLogFileContent($filename = 'connector_api.log')
|
1121 |
Â
{
|
1122 |
+
$pathLogfile = Mage::getBaseDir('var') . DS . 'log' . DS
|
1123 |
+
. $filename;;
|
1124 |
+
//tail the length file content
|
1125 |
+
$lengthBefore = 500000;
|
1126 |
Â
|
1127 |
+
$handle = fopen($pathLogfile, 'r');
|
1128 |
+
fseek($handle, -$lengthBefore, SEEK_END);
|
1129 |
Â
|
1130 |
Â
if (!$handle) {
|
1131 |
+
return "Log file is not readable or does not exist at this moment. File path is "
|
1132 |
+
. $pathLogfile;
|
1133 |
Â
}
|
1134 |
Â
|
1135 |
+
$contents = fread($handle, filesize($pathLogfile));
|
1136 |
Â
|
1137 |
Â
if (!$contents) {
|
1138 |
+
return "Log file is not readable or does not exist at this moment. File path is "
|
1139 |
+
. $pathLogfile;
|
1140 |
Â
}
|
1141 |
Â
fclose($handle);
|
1142 |
Â
|
1144 |
Â
}
|
1145 |
Â
|
1146 |
Â
|
1147 |
+
/**
|
1148 |
+
* PRODUCT REVIEW REMINDER.
|
1149 |
+
*/
|
1150 |
+
public function isReviewReminderEnabled($website)
|
1151 |
+
{
|
1152 |
+
return $this->getWebsiteConfig(
|
1153 |
+
Dotdigitalgroup_Email_Helper_Config::XML_PATH_REVIEWS_ENABLED,
|
1154 |
+
$website
|
1155 |
+
);
|
1156 |
+
}
|
1157 |
+
|
1158 |
+
/**
|
1159 |
+
* @param $website
|
1160 |
+
*
|
1161 |
+
* @return string
|
1162 |
+
*/
|
1163 |
+
public function getReviewReminderOrderStatus($website)
|
1164 |
+
{
|
1165 |
+
return $this->getWebsiteConfig(
|
1166 |
+
Dotdigitalgroup_Email_Helper_Config::XML_PATH_AUTOMATION_REVIEW_STATUS,
|
1167 |
+
$website
|
1168 |
+
);
|
1169 |
+
}
|
1170 |
+
|
1171 |
+
/**
|
1172 |
+
* @param $website
|
1173 |
+
*
|
1174 |
+
* @return int
|
1175 |
+
*/
|
1176 |
+
public function getReviewReminderDelay($website)
|
1177 |
+
{
|
1178 |
+
return $this->getWebsiteConfig(
|
1179 |
+
Dotdigitalgroup_Email_Helper_Config::XML_PATH_AUTOMATION_REVIEW_DELAY,
|
1180 |
+
$website
|
1181 |
+
);
|
1182 |
+
}
|
1183 |
+
|
1184 |
+
/**
|
1185 |
+
* @param $website
|
1186 |
+
*
|
1187 |
+
* @return int
|
1188 |
+
*/
|
1189 |
+
public function getReviewReminderCampaign($website)
|
1190 |
+
{
|
1191 |
+
return $this->getWebsiteConfig(
|
1192 |
+
Dotdigitalgroup_Email_Helper_Config::XML_PATH_AUTOMATION_REVIEW_CAMPAIGN,
|
1193 |
+
$website
|
1194 |
+
);
|
1195 |
+
}
|
1196 |
+
|
1197 |
+
/**
|
1198 |
+
* @param $website
|
1199 |
+
*
|
1200 |
+
* @return string
|
1201 |
+
*/
|
1202 |
+
public function getReviewReminderAnchor($website)
|
1203 |
+
{
|
1204 |
+
return $this->getWebsiteConfig(
|
1205 |
+
Dotdigitalgroup_Email_Helper_Config::XML_PATH_AUTOMATION_REVIEW_ANCHOR,
|
1206 |
+
$website
|
1207 |
+
);
|
1208 |
+
}
|
1209 |
+
|
1210 |
+
|
1211 |
+
public function getDynamicStyles()
|
1212 |
+
{
|
1213 |
+
return $dynamicStyle = array(
|
1214 |
+
'nameStyle' => explode(
|
1215 |
+
',', Mage::getStoreConfig(
|
1216 |
+
Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_DYNAMIC_NAME_STYLE
|
1217 |
+
)
|
1218 |
+
),
|
1219 |
+
'priceStyle' => explode(
|
1220 |
+
',', Mage::getStoreConfig(
|
1221 |
+
Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_DYNAMIC_PRICE_STYLE
|
1222 |
+
)
|
1223 |
+
),
|
1224 |
+
'linkStyle' => explode(
|
1225 |
+
',', Mage::getStoreConfig(
|
1226 |
+
Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_DYNAMIC_LINK_STYLE
|
1227 |
+
)
|
1228 |
+
),
|
1229 |
+
'otherStyle' => explode(
|
1230 |
+
',', Mage::getStoreConfig(
|
1231 |
+
Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_DYNAMIC_OTHER_STYLE
|
1232 |
+
)
|
1233 |
+
),
|
1234 |
+
'nameColor' => Mage::getStoreConfig(
|
1235 |
+
Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_DYNAMIC_NAME_COLOR
|
1236 |
+
),
|
1237 |
+
'fontSize' => Mage::getStoreConfig(
|
1238 |
+
Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_DYNAMIC_NAME_FONT_SIZE
|
1239 |
+
),
|
1240 |
+
'priceColor' => Mage::getStoreConfig(
|
1241 |
+
Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_DYNAMIC_PRICE_COLOR
|
1242 |
+
),
|
1243 |
+
'priceFontSize' => Mage::getStoreConfig(
|
1244 |
+
Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_DYNAMIC_PRICE_FONT_SIZE
|
1245 |
+
),
|
1246 |
+
'urlColor' => Mage::getStoreConfig(
|
1247 |
+
Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_DYNAMIC_LINK_COLOR
|
1248 |
+
),
|
1249 |
+
'urlFontSize' => Mage::getStoreConfig(
|
1250 |
+
Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_DYNAMIC_LINK_FONT_SIZE
|
1251 |
+
),
|
1252 |
+
'otherColor' => Mage::getStoreConfig(
|
1253 |
+
Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_DYNAMIC_OTHER_COLOR
|
1254 |
+
),
|
1255 |
+
'otherFontSize' => Mage::getStoreConfig(
|
1256 |
+
Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_DYNAMIC_OTHER_FONT_SIZE
|
1257 |
+
),
|
1258 |
+
'docFont' => Mage::getStoreConfig(
|
1259 |
+
Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_DYNAMIC_DOC_FONT
|
1260 |
+
),
|
1261 |
+
'docBackgroundColor' => Mage::getStoreConfig(
|
1262 |
+
Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_DYNAMIC_DOC_BG_COLOR
|
1263 |
+
),
|
1264 |
+
'dynamicStyling' => Mage::getStoreConfig(
|
1265 |
+
Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_DYNAMIC_STYLING
|
1266 |
+
)
|
1267 |
+
);
|
1268 |
+
}
|
1269 |
+
|
1270 |
+
/**
|
1271 |
+
* generate url for iframe for trial account popup
|
1272 |
+
*
|
1273 |
+
* @return string
|
1274 |
+
* @throws Mage_Core_Exception
|
1275 |
+
*/
|
1276 |
+
public function getIframeFormUrl()
|
1277 |
+
{
|
1278 |
+
$formUrl = Dotdigitalgroup_Email_Helper_Config::API_CONNECTOR_TRIAL_FORM_URL;
|
1279 |
+
$ipAddress = Mage::helper('core/http')->getRemoteAddr();
|
1280 |
+
$timezone = $this->getTimeZoneId();
|
1281 |
+
$culture = $this->getCultureId();
|
1282 |
+
$company = Mage::app()->getWebsite()->getConfig('general/store_information/name');
|
1283 |
+
$callback = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB, true) . 'connector/email/accountcallback';
|
1284 |
+
$secret = Dotdigitalgroup_Email_Helper_Config::API_CONNECTOR_TRIAL_FORM_SECRET;
|
1285 |
+
//query params
|
1286 |
+
$params = array(
|
1287 |
+
'callback' => $callback,
|
1288 |
+
'company' => $company,
|
1289 |
+
'culture' => $culture,
|
1290 |
+
'timezone' => $timezone,
|
1291 |
+
'ip' => $ipAddress,
|
1292 |
+
'secret' => $secret
|
1293 |
+
);
|
1294 |
+
$url = $formUrl . '?' . http_build_query($params);
|
1295 |
+
return $url;
|
1296 |
+
}
|
1297 |
+
|
1298 |
+
/**
|
1299 |
+
* get time zone id for trial account
|
1300 |
+
*
|
1301 |
+
* @return string
|
1302 |
+
* @throws Mage_Core_Exception
|
1303 |
+
*/
|
1304 |
+
public function getTimeZoneId()
|
1305 |
+
{
|
1306 |
+
$timeZone = Mage::app()->getWebsite()->getConfig(Mage_Core_Model_Locale::XML_PATH_DEFAULT_TIMEZONE);
|
1307 |
+
$result = '085';
|
1308 |
+
if ($timeZone) {
|
1309 |
+
$timeZones = Array
|
1310 |
+
(
|
1311 |
+
Array("MageTimeZone" => "Australia/Darwin", "MicrosoftTimeZoneIndex" => "250"),
|
1312 |
+
Array("MageTimeZone" => "Australia/Melbourne", "MicrosoftTimeZoneIndex" => "260"),
|
1313 |
+
Array("MageTimeZone" => "Australia/Sydney", "MicrosoftTimeZoneIndex" => "260"),
|
1314 |
+
Array("MageTimeZone" => "Asia/Kabul", "MicrosoftTimeZoneIndex" => "175"),
|
1315 |
+
Array("MageTimeZone" => "America/Anchorage", "MicrosoftTimeZoneIndex" => "003"),
|
1316 |
+
Array("MageTimeZone" => "America/Juneau", "MicrosoftTimeZoneIndex" => "003"),
|
1317 |
+
Array("MageTimeZone" => "America/Nome", "MicrosoftTimeZoneIndex" => "003"),
|
1318 |
+
Array("MageTimeZone" => "America/Sitka", "MicrosoftTimeZoneIndex" => "003"),
|
1319 |
+
Array("MageTimeZone" => "America/Yakutat", "MicrosoftTimeZoneIndex" => "003"),
|
1320 |
+
Array("MageTimeZone" => "Asia/Aden", "MicrosoftTimeZoneIndex" => "150"),
|
1321 |
+
Array("MageTimeZone" => "Asia/Bahrain", "MicrosoftTimeZoneIndex" => "150"),
|
1322 |
+
Array("MageTimeZone" => "Asia/Kuwait", "MicrosoftTimeZoneIndex" => "150"),
|
1323 |
+
Array("MageTimeZone" => "Asia/Qatar", "MicrosoftTimeZoneIndex" => "150"),
|
1324 |
+
Array("MageTimeZone" => "Asia/Riyadh", "MicrosoftTimeZoneIndex" => "150"),
|
1325 |
+
Array("MageTimeZone" => "Asia/Dubai", "MicrosoftTimeZoneIndex" => "165"),
|
1326 |
+
Array("MageTimeZone" => "Asia/Muscat", "MicrosoftTimeZoneIndex" => "165"),
|
1327 |
+
Array("MageTimeZone" => "Etc/GMT-4", "MicrosoftTimeZoneIndex" => "165"),
|
1328 |
+
Array("MageTimeZone" => "Asia/Baghdad", "MicrosoftTimeZoneIndex" => "165"),
|
1329 |
+
Array("MageTimeZone" => "America/Argentina/La_Rioja", "MicrosoftTimeZoneIndex" => "070"),
|
1330 |
+
Array("MageTimeZone" => "America/Argentina/Rio_Gallegos", "MicrosoftTimeZoneIndex" => "070"),
|
1331 |
+
Array("MageTimeZone" => "America/Argentina/Salta", "MicrosoftTimeZoneIndex" => "070"),
|
1332 |
+
Array("MageTimeZone" => "America/Argentina/San_Juan", "MicrosoftTimeZoneIndex" => "070"),
|
1333 |
+
Array("MageTimeZone" => "America/Argentina/San_Luis", "MicrosoftTimeZoneIndex" => "070"),
|
1334 |
+
Array("MageTimeZone" => "America/Argentina/Tucuman", "MicrosoftTimeZoneIndex" => "070"),
|
1335 |
+
Array("MageTimeZone" => "America/Argentina/Ushuaia", "MicrosoftTimeZoneIndex" => "070"),
|
1336 |
+
Array("MageTimeZone" => "America/Buenos_Aires", "MicrosoftTimeZoneIndex" => "070"),
|
1337 |
+
Array("MageTimeZone" => "America/Catamarca", "MicrosoftTimeZoneIndex" => "070"),
|
1338 |
+
Array("MageTimeZone" => "America/Cordoba", "MicrosoftTimeZoneIndex" => "070"),
|
1339 |
+
Array("MageTimeZone" => "America/Jujuy", "MicrosoftTimeZoneIndex" => "070"),
|
1340 |
+
Array("MageTimeZone" => "America/Mendoza", "MicrosoftTimeZoneIndex" => "070"),
|
1341 |
+
Array("MageTimeZone" => "America/Glace_Bay", "MicrosoftTimeZoneIndex" => "050"),
|
1342 |
+
Array("MageTimeZone" => "America/Goose_Bay", "MicrosoftTimeZoneIndex" => "050"),
|
1343 |
+
Array("MageTimeZone" => "America/Halifax", "MicrosoftTimeZoneIndex" => "050"),
|
1344 |
+
Array("MageTimeZone" => "America/Moncton", "MicrosoftTimeZoneIndex" => "050"),
|
1345 |
+
Array("MageTimeZone" => "America/Thule", "MicrosoftTimeZoneIndex" => "050"),
|
1346 |
+
Array("MageTimeZone" => "Atlantic/Bermuda", "MicrosoftTimeZoneIndex" => "050"),
|
1347 |
+
Array("MageTimeZone" => "Asia/Baku", "MicrosoftTimeZoneIndex" => "170"),
|
1348 |
+
Array("MageTimeZone" => "America/Scoresbysund", "MicrosoftTimeZoneIndex" => "080"),
|
1349 |
+
Array("MageTimeZone" => "Atlantic/Azores", "MicrosoftTimeZoneIndex" => "080"),
|
1350 |
+
Array("MageTimeZone" => "America/Bahia", "MicrosoftTimeZoneIndex" => "065"),
|
1351 |
+
Array("MageTimeZone" => "Asia/Dhaka", "MicrosoftTimeZoneIndex" => "195"),
|
1352 |
+
Array("MageTimeZone" => "Asia/Thimphu", "MicrosoftTimeZoneIndex" => "195"),
|
1353 |
+
Array("MageTimeZone" => "America/Regina", "MicrosoftTimeZoneIndex" => "025"),
|
1354 |
+
Array("MageTimeZone" => "America/Swift_Current", "MicrosoftTimeZoneIndex" => "025"),
|
1355 |
+
Array("MageTimeZone" => "Atlantic/Cape_Verde", "MicrosoftTimeZoneIndex" => "083"),
|
1356 |
+
Array("MageTimeZone" => "Etc/GMT+1", "MicrosoftTimeZoneIndex" => "083"),
|
1357 |
+
Array("MageTimeZone" => "Asia/Yerevan", "MicrosoftTimeZoneIndex" => "170"),
|
1358 |
+
Array("MageTimeZone" => "Australia/Adelaide", "MicrosoftTimeZoneIndex" => "250"),
|
1359 |
+
Array("MageTimeZone" => "Australia/Broken_Hill", "MicrosoftTimeZoneIndex" => "250"),
|
1360 |
+
Array("MageTimeZone" => "America/Belize", "MicrosoftTimeZoneIndex" => "033"),
|
1361 |
+
Array("MageTimeZone" => "America/Costa_Rica", "MicrosoftTimeZoneIndex" => "033"),
|
1362 |
+
Array("MageTimeZone" => "America/El_Salvador", "MicrosoftTimeZoneIndex" => "033"),
|
1363 |
+
Array("MageTimeZone" => "America/Guatemala", "MicrosoftTimeZoneIndex" => "033"),
|
1364 |
+
Array("MageTimeZone" => "America/Managua", "MicrosoftTimeZoneIndex" => "033"),
|
1365 |
+
Array("MageTimeZone" => "America/Tegucigalpa", "MicrosoftTimeZoneIndex" => "033"),
|
1366 |
+
Array("MageTimeZone" => "Etc/GMT+6", "MicrosoftTimeZoneIndex" => "033"),
|
1367 |
+
Array("MageTimeZone" => "Pacific/Galapagos", "MicrosoftTimeZoneIndex" => "033"),
|
1368 |
+
Array("MageTimeZone" => "Antarctica/Vostok", "MicrosoftTimeZoneIndex" => "195"),
|
1369 |
+
Array("MageTimeZone" => "Asia/Almaty", "MicrosoftTimeZoneIndex" => "195"),
|
1370 |
+
Array("MageTimeZone" => "Asia/Bishkek", "MicrosoftTimeZoneIndex" => "195"),
|
1371 |
+
Array("MageTimeZone" => "Asia/Qyzylorda", "MicrosoftTimeZoneIndex" => "195"),
|
1372 |
+
Array("MageTimeZone" => "Etc/GMT-6", "MicrosoftTimeZoneIndex" => "195"),
|
1373 |
+
Array("MageTimeZone" => "Indian/Chagos", "MicrosoftTimeZoneIndex" => "195"),
|
1374 |
+
Array("MageTimeZone" => "America/Campo_Grande", "MicrosoftTimeZoneIndex" => "065"),
|
1375 |
+
Array("MageTimeZone" => "America/Cuiaba", "MicrosoftTimeZoneIndex" => "065"),
|
1376 |
+
Array("MageTimeZone" => "Europe/Belgrade", "MicrosoftTimeZoneIndex" => "095"),
|
1377 |
+
Array("MageTimeZone" => "Europe/Bratislava", "MicrosoftTimeZoneIndex" => "095"),
|
1378 |
+
Array("MageTimeZone" => "Europe/Budapest", "MicrosoftTimeZoneIndex" => "095"),
|
1379 |
+
Array("MageTimeZone" => "Europe/Ljubljana", "MicrosoftTimeZoneIndex" => "095"),
|
1380 |
+
Array("MageTimeZone" => "Europe/Podgorica", "MicrosoftTimeZoneIndex" => "095"),
|
1381 |
+
Array("MageTimeZone" => "Europe/Prague", "MicrosoftTimeZoneIndex" => "095"),
|
1382 |
+
Array("MageTimeZone" => "Europe/Tirane", "MicrosoftTimeZoneIndex" => "095"),
|
1383 |
+
Array("MageTimeZone" => "Europe/Sarajevo", "MicrosoftTimeZoneIndex" => "095"),
|
1384 |
+
Array("MageTimeZone" => "Europe/Skopje", "MicrosoftTimeZoneIndex" => "095"),
|
1385 |
+
Array("MageTimeZone" => "Europe/Warsaw", "MicrosoftTimeZoneIndex" => "095"),
|
1386 |
+
Array("MageTimeZone" => "Europe/Zagreb", "MicrosoftTimeZoneIndex" => "095"),
|
1387 |
+
Array("MageTimeZone" => "Antarctica/Macquarie", "MicrosoftTimeZoneIndex" => "280"),
|
1388 |
+
Array("MageTimeZone" => "Etc/GMT-11", "MicrosoftTimeZoneIndex" => "280"),
|
1389 |
+
Array("MageTimeZone" => "Pacific/Efate", "MicrosoftTimeZoneIndex" => "280"),
|
1390 |
+
Array("MageTimeZone" => "Pacific/Guadalcanal", "MicrosoftTimeZoneIndex" => "280"),
|
1391 |
+
Array("MageTimeZone" => "Pacific/Kosrae", "MicrosoftTimeZoneIndex" => "280"),
|
1392 |
+
Array("MageTimeZone" => "Pacific/Noumea", "MicrosoftTimeZoneIndex" => "280"),
|
1393 |
+
Array("MageTimeZone" => "Pacific/Ponape", "MicrosoftTimeZoneIndex" => "280"),
|
1394 |
+
Array("MageTimeZone" => "America/Chicago", "MicrosoftTimeZoneIndex" => "020"),
|
1395 |
+
Array("MageTimeZone" => "America/Indiana/Knox", "MicrosoftTimeZoneIndex" => "020"),
|
1396 |
+
Array("MageTimeZone" => "America/Indiana/Tell_City", "MicrosoftTimeZoneIndex" => "020"),
|
1397 |
+
Array("MageTimeZone" => "America/Matamoros", "MicrosoftTimeZoneIndex" => "020"),
|
1398 |
+
Array("MageTimeZone" => "America/Menominee", "MicrosoftTimeZoneIndex" => "020"),
|
1399 |
+
Array("MageTimeZone" => "America/North_Dakota/Beulah", "MicrosoftTimeZoneIndex" => "020"),
|
1400 |
+
Array("MageTimeZone" => "America/North_Dakota/Center", "MicrosoftTimeZoneIndex" => "020"),
|
1401 |
+
Array("MageTimeZone" => "America/North_Dakota/New_Salem", "MicrosoftTimeZoneIndex" => "020"),
|
1402 |
+
Array("MageTimeZone" => "America/Rainy_River", "MicrosoftTimeZoneIndex" => "020"),
|
1403 |
+
Array("MageTimeZone" => "America/Rankin_Inlet", "MicrosoftTimeZoneIndex" => "020"),
|
1404 |
+
Array("MageTimeZone" => "America/Resolute", "MicrosoftTimeZoneIndex" => "020"),
|
1405 |
+
Array("MageTimeZone" => "America/Winnipeg", "MicrosoftTimeZoneIndex" => "020"),
|
1406 |
+
Array("MageTimeZone" => "CST6CDT", "MicrosoftTimeZoneIndex" => "020"),
|
1407 |
+
Array("MageTimeZone" => "America/Bahia_Banderas", "MicrosoftTimeZoneIndex" => "020"),
|
1408 |
+
Array("MageTimeZone" => "America/Cancun", "MicrosoftTimeZoneIndex" => "020"),
|
1409 |
+
Array("MageTimeZone" => "America/Merida", "MicrosoftTimeZoneIndex" => "020"),
|
1410 |
+
Array("MageTimeZone" => "America/Mexico_City", "MicrosoftTimeZoneIndex" => "020"),
|
1411 |
+
Array("MageTimeZone" => "America/Monterrey", "MicrosoftTimeZoneIndex" => "020"),
|
1412 |
+
Array("MageTimeZone" => "Asia/Chongqing", "MicrosoftTimeZoneIndex" => "210"),
|
1413 |
+
Array("MageTimeZone" => "Asia/Harbin", "MicrosoftTimeZoneIndex" => "210"),
|
1414 |
+
Array("MageTimeZone" => "Asia/Hong_Kong", "MicrosoftTimeZoneIndex" => "210"),
|
1415 |
+
Array("MageTimeZone" => "Asia/Kashgar", "MicrosoftTimeZoneIndex" => "210"),
|
1416 |
+
Array("MageTimeZone" => "Asia/Macau", "MicrosoftTimeZoneIndex" => "210"),
|
1417 |
+
Array("MageTimeZone" => "Asia/Shanghai", "MicrosoftTimeZoneIndex" => "210"),
|
1418 |
+
Array("MageTimeZone" => "Asia/Urumqi", "MicrosoftTimeZoneIndex" => "210"),
|
1419 |
+
Array("MageTimeZone" => "Etc/GMT+12", "MicrosoftTimeZoneIndex" => "000"),
|
1420 |
+
Array("MageTimeZone" => "Africa/Addis_Ababa", "MicrosoftTimeZoneIndex" => "115"),
|
1421 |
+
Array("MageTimeZone" => "Africa/Asmera", "MicrosoftTimeZoneIndex" => "115"),
|
1422 |
+
Array("MageTimeZone" => "Africa/Dar_es_Salaam", "MicrosoftTimeZoneIndex" => "115"),
|
1423 |
+
Array("MageTimeZone" => "Africa/Djibouti", "MicrosoftTimeZoneIndex" => "115"),
|
1424 |
+
Array("MageTimeZone" => "Africa/Juba", "MicrosoftTimeZoneIndex" => "115"),
|
1425 |
+
Array("MageTimeZone" => "Africa/Kampala", "MicrosoftTimeZoneIndex" => "115"),
|
1426 |
+
Array("MageTimeZone" => "Africa/Khartoum", "MicrosoftTimeZoneIndex" => "115"),
|
1427 |
+
Array("MageTimeZone" => "Africa/Mogadishu", "MicrosoftTimeZoneIndex" => "115"),
|
1428 |
+
Array("MageTimeZone" => "Africa/Nairobi", "MicrosoftTimeZoneIndex" => "115"),
|
1429 |
+
Array("MageTimeZone" => "Antarctica/Syowa", "MicrosoftTimeZoneIndex" => "115"),
|
1430 |
+
Array("MageTimeZone" => "Etc/GMT-3", "MicrosoftTimeZoneIndex" => "115"),
|
1431 |
+
Array("MageTimeZone" => "Indian/Antananarivo", "MicrosoftTimeZoneIndex" => "115"),
|
1432 |
+
Array("MageTimeZone" => "Indian/Comoro", "MicrosoftTimeZoneIndex" => "115"),
|
1433 |
+
Array("MageTimeZone" => "Indian/Mayotte", "MicrosoftTimeZoneIndex" => "115"),
|
1434 |
+
Array("MageTimeZone" => "Australia/Brisbane", "MicrosoftTimeZoneIndex" => "260"),
|
1435 |
+
Array("MageTimeZone" => "Australia/Lindeman", "MicrosoftTimeZoneIndex" => "260"),
|
1436 |
+
Array("MageTimeZone" => "America/Sao_Paulo", "MicrosoftTimeZoneIndex" => "065"),
|
1437 |
+
Array("MageTimeZone" => "America/Detroit", "MicrosoftTimeZoneIndex" => "035"),
|
1438 |
+
Array("MageTimeZone" => "America/Grand_Turk", "MicrosoftTimeZoneIndex" => "035"),
|
1439 |
+
Array("MageTimeZone" => "America/Havana", "MicrosoftTimeZoneIndex" => "035"),
|
1440 |
+
Array("MageTimeZone" => "America/Indiana/Petersburg", "MicrosoftTimeZoneIndex" => "035"),
|
1441 |
+
Array("MageTimeZone" => "America/Indiana/Vincennes", "MicrosoftTimeZoneIndex" => "035"),
|
1442 |
+
Array("MageTimeZone" => "America/Indiana/Winamac", "MicrosoftTimeZoneIndex" => "035"),
|
1443 |
+
Array("MageTimeZone" => "America/Iqaluit", "MicrosoftTimeZoneIndex" => "035"),
|
1444 |
+
Array("MageTimeZone" => "America/Kentucky/Monticello", "MicrosoftTimeZoneIndex" => "035"),
|
1445 |
+
Array("MageTimeZone" => "America/Louisville", "MicrosoftTimeZoneIndex" => "035"),
|
1446 |
+
Array("MageTimeZone" => "America/Montreal", "MicrosoftTimeZoneIndex" => "035"),
|
1447 |
+
Array("MageTimeZone" => "America/Nassau", "MicrosoftTimeZoneIndex" => "035"),
|
1448 |
+
Array("MageTimeZone" => "America/New_York", "MicrosoftTimeZoneIndex" => "035"),
|
1449 |
+
Array("MageTimeZone" => "America/Nipigon", "MicrosoftTimeZoneIndex" => "035"),
|
1450 |
+
Array("MageTimeZone" => "America/Pangnirtung", "MicrosoftTimeZoneIndex" => "035"),
|
1451 |
+
Array("MageTimeZone" => "America/Port-au-Prince", "MicrosoftTimeZoneIndex" => "035"),
|
1452 |
+
Array("MageTimeZone" => "America/Thunder_Bay", "MicrosoftTimeZoneIndex" => "035"),
|
1453 |
+
Array("MageTimeZone" => "America/Toronto", "MicrosoftTimeZoneIndex" => "035"),
|
1454 |
+
Array("MageTimeZone" => "EST5EDT", "MicrosoftTimeZoneIndex" => "035"),
|
1455 |
+
Array("MageTimeZone" => "Africa/Cairo", "MicrosoftTimeZoneIndex" => "120"),
|
1456 |
+
Array("MageTimeZone" => "Asia/Yekaterinburg", "MicrosoftTimeZoneIndex" => "180"),
|
1457 |
+
Array("MageTimeZone" => "Europe/Helsinki", "MicrosoftTimeZoneIndex" => "125"),
|
1458 |
+
Array("MageTimeZone" => "Europe/Kiev", "MicrosoftTimeZoneIndex" => "125"),
|
1459 |
+
Array("MageTimeZone" => "Europe/Riga", "MicrosoftTimeZoneIndex" => "125"),
|
1460 |
+
Array("MageTimeZone" => "Europe/Simferopol", "MicrosoftTimeZoneIndex" => "125"),
|
1461 |
+
Array("MageTimeZone" => "Europe/Sofia", "MicrosoftTimeZoneIndex" => "125"),
|
1462 |
+
Array("MageTimeZone" => "Europe/Tallinn", "MicrosoftTimeZoneIndex" => "125"),
|
1463 |
+
Array("MageTimeZone" => "Europe/Uzhgorod", "MicrosoftTimeZoneIndex" => "125"),
|
1464 |
+
Array("MageTimeZone" => "Europe/Vilnius", "MicrosoftTimeZoneIndex" => "125"),
|
1465 |
+
Array("MageTimeZone" => "Europe/Zaporozhye", "MicrosoftTimeZoneIndex" => "125"),
|
1466 |
+
Array("MageTimeZone" => "Pacific/Fiji", "MicrosoftTimeZoneIndex" => "285"),
|
1467 |
+
Array("MageTimeZone" => "Atlantic/Canary", "MicrosoftTimeZoneIndex" => "085"),
|
1468 |
+
Array("MageTimeZone" => "Atlantic/Faeroe", "MicrosoftTimeZoneIndex" => "085"),
|
1469 |
+
Array("MageTimeZone" => "Atlantic/Madeira", "MicrosoftTimeZoneIndex" => "085"),
|
1470 |
+
Array("MageTimeZone" => "Europe/Dublin", "MicrosoftTimeZoneIndex" => "085"),
|
1471 |
+
Array("MageTimeZone" => "Europe/Guernsey", "MicrosoftTimeZoneIndex" => "085"),
|
1472 |
+
Array("MageTimeZone" => "Europe/Isle_of_Man", "MicrosoftTimeZoneIndex" => "085"),
|
1473 |
+
Array("MageTimeZone" => "Europe/Jersey", "MicrosoftTimeZoneIndex" => "085"),
|
1474 |
+
Array("MageTimeZone" => "Europe/Lisbon", "MicrosoftTimeZoneIndex" => "085"),
|
1475 |
+
Array("MageTimeZone" => "Europe/London", "MicrosoftTimeZoneIndex" => "085"),
|
1476 |
+
Array("MageTimeZone" => "Asia/Nicosia", "MicrosoftTimeZoneIndex" => "130"),
|
1477 |
+
Array("MageTimeZone" => "Europe/Athens", "MicrosoftTimeZoneIndex" => "130"),
|
1478 |
+
Array("MageTimeZone" => "Europe/Bucharest", "MicrosoftTimeZoneIndex" => "130"),
|
1479 |
+
Array("MageTimeZone" => "Europe/Chisinau", "MicrosoftTimeZoneIndex" => "130"),
|
1480 |
+
Array("MageTimeZone" => "Asia/Tbilisi", "MicrosoftTimeZoneIndex" => "170"),
|
1481 |
+
Array("MageTimeZone" => "America/Godthab", "MicrosoftTimeZoneIndex" => "073"),
|
1482 |
+
Array("MageTimeZone" => "Africa/Abidjan", "MicrosoftTimeZoneIndex" => "090"),
|
1483 |
+
Array("MageTimeZone" => "Africa/Accra", "MicrosoftTimeZoneIndex" => "090"),
|
1484 |
+
Array("MageTimeZone" => "Africa/Bamako", "MicrosoftTimeZoneIndex" => "090"),
|
1485 |
+
Array("MageTimeZone" => "Africa/Banjul", "MicrosoftTimeZoneIndex" => "090"),
|
1486 |
+
Array("MageTimeZone" => "Africa/Bissau", "MicrosoftTimeZoneIndex" => "090"),
|
1487 |
+
Array("MageTimeZone" => "Africa/Conakry", "MicrosoftTimeZoneIndex" => "090"),
|
1488 |
+
Array("MageTimeZone" => "Africa/Dakar", "MicrosoftTimeZoneIndex" => "090"),
|
1489 |
+
Array("MageTimeZone" => "Africa/Freetown", "MicrosoftTimeZoneIndex" => "090"),
|
1490 |
+
Array("MageTimeZone" => "Africa/Lome", "MicrosoftTimeZoneIndex" => "090"),
|
1491 |
+
Array("MageTimeZone" => "Africa/Monrovia", "MicrosoftTimeZoneIndex" => "090"),
|
1492 |
+
Array("MageTimeZone" => "Africa/Nouakchott", "MicrosoftTimeZoneIndex" => "090"),
|
1493 |
+
Array("MageTimeZone" => "Africa/Ouagadougou", "MicrosoftTimeZoneIndex" => "090"),
|
1494 |
+
Array("MageTimeZone" => "Africa/Sao_Tome", "MicrosoftTimeZoneIndex" => "090"),
|
1495 |
+
Array("MageTimeZone" => "Atlantic/Reykjavik", "MicrosoftTimeZoneIndex" => "090"),
|
1496 |
+
Array("MageTimeZone" => "Atlantic/St_Helena", "MicrosoftTimeZoneIndex" => "090"),
|
1497 |
+
Array("MageTimeZone" => "Etc/GMT+10", "MicrosoftTimeZoneIndex" => "002"),
|
1498 |
+
Array("MageTimeZone" => "Pacific/Honolulu", "MicrosoftTimeZoneIndex" => "002"),
|
1499 |
+
Array("MageTimeZone" => "Pacific/Johnston", "MicrosoftTimeZoneIndex" => "002"),
|
1500 |
+
Array("MageTimeZone" => "Pacific/Rarotonga", "MicrosoftTimeZoneIndex" => "002"),
|
1501 |
+
Array("MageTimeZone" => "Pacific/Tahiti", "MicrosoftTimeZoneIndex" => "002"),
|
1502 |
+
Array("MageTimeZone" => "Asia/Calcutta", "MicrosoftTimeZoneIndex" => "190"),
|
1503 |
+
Array("MageTimeZone" => "Asia/Tehran", "MicrosoftTimeZoneIndex" => "160"),
|
1504 |
+
Array("MageTimeZone" => "Asia/Jerusalem", "MicrosoftTimeZoneIndex" => "135"),
|
1505 |
+
Array("MageTimeZone" => "Asia/Amman", "MicrosoftTimeZoneIndex" => "150"),
|
1506 |
+
Array("MageTimeZone" => "Europe/Kaliningrad", "MicrosoftTimeZoneIndex" => "130"),
|
1507 |
+
Array("MageTimeZone" => "Europe/Minsk", "MicrosoftTimeZoneIndex" => "130"),
|
1508 |
+
Array("MageTimeZone" => "Asia/Pyongyang", "MicrosoftTimeZoneIndex" => "230"),
|
1509 |
+
Array("MageTimeZone" => "Asia/Seoul", "MicrosoftTimeZoneIndex" => "230"),
|
1510 |
+
Array("MageTimeZone" => "Africa/Tripoli", "MicrosoftTimeZoneIndex" => "120"),
|
1511 |
+
Array("MageTimeZone" => "Asia/Anadyr", "MicrosoftTimeZoneIndex" => "280"),
|
1512 |
+
Array("MageTimeZone" => "Asia/Kamchatka", "MicrosoftTimeZoneIndex" => "280"),
|
1513 |
+
Array("MageTimeZone" => "Asia/Magadan", "MicrosoftTimeZoneIndex" => "280"),
|
1514 |
+
Array("MageTimeZone" => "Indian/Mahe", "MicrosoftTimeZoneIndex" => "165"),
|
1515 |
+
Array("MageTimeZone" => "Indian/Mauritius", "MicrosoftTimeZoneIndex" => "165"),
|
1516 |
+
Array("MageTimeZone" => "Indian/Reunion", "MicrosoftTimeZoneIndex" => "165"),
|
1517 |
+
Array("MageTimeZone" => "Asia/Beirut", "MicrosoftTimeZoneIndex" => "158"),
|
1518 |
+
Array("MageTimeZone" => "America/Montevideo", "MicrosoftTimeZoneIndex" => "065"),
|
1519 |
+
Array("MageTimeZone" => "Africa/Casablanca", "MicrosoftTimeZoneIndex" => "113"),
|
1520 |
+
Array("MageTimeZone" => "Africa/El_Aaiun", "MicrosoftTimeZoneIndex" => "113"),
|
1521 |
+
Array("MageTimeZone" => "America/Boise", "MicrosoftTimeZoneIndex" => "010"),
|
1522 |
+
Array("MageTimeZone" => "America/Cambridge_Bay", "MicrosoftTimeZoneIndex" => "010"),
|
1523 |
+
Array("MageTimeZone" => "America/Denver", "MicrosoftTimeZoneIndex" => "010"),
|
1524 |
+
Array("MageTimeZone" => "America/Edmonton", "MicrosoftTimeZoneIndex" => "010"),
|
1525 |
+
Array("MageTimeZone" => "America/Inuvik", "MicrosoftTimeZoneIndex" => "010"),
|
1526 |
+
Array("MageTimeZone" => "America/Ojinaga", "MicrosoftTimeZoneIndex" => "010"),
|
1527 |
+
Array("MageTimeZone" => "America/Shiprock", "MicrosoftTimeZoneIndex" => "010"),
|
1528 |
+
Array("MageTimeZone" => "America/Yellowknife", "MicrosoftTimeZoneIndex" => "010"),
|
1529 |
+
Array("MageTimeZone" => "MST7MDT", "MicrosoftTimeZoneIndex" => "010"),
|
1530 |
+
Array("MageTimeZone" => "America/Chihuahua", "MicrosoftTimeZoneIndex" => "010"),
|
1531 |
+
Array("MageTimeZone" => "America/Mazatlan", "MicrosoftTimeZoneIndex" => "010"),
|
1532 |
+
Array("MageTimeZone" => "Asia/Rangoon", "MicrosoftTimeZoneIndex" => "203"),
|
1533 |
+
Array("MageTimeZone" => "Indian/Cocos", "MicrosoftTimeZoneIndex" => "203"),
|
1534 |
+
Array("MageTimeZone" => "Asia/Novokuznetsk", "MicrosoftTimeZoneIndex" => "201"),
|
1535 |
+
Array("MageTimeZone" => "Asia/Novosibirsk", "MicrosoftTimeZoneIndex" => "201"),
|
1536 |
+
Array("MageTimeZone" => "Asia/Omsk", "MicrosoftTimeZoneIndex" => "201"),
|
1537 |
+
Array("MageTimeZone" => "Africa/Windhoek", "MicrosoftTimeZoneIndex" => "120"),
|
1538 |
+
Array("MageTimeZone" => "Asia/Katmandu", "MicrosoftTimeZoneIndex" => "193"),
|
1539 |
+
Array("MageTimeZone" => "Antarctica/McMurdo", "MicrosoftTimeZoneIndex" => "290"),
|
1540 |
+
Array("MageTimeZone" => "Antarctica/South_Pole", "MicrosoftTimeZoneIndex" => "290"),
|
1541 |
+
Array("MageTimeZone" => "Pacific/Auckland", "MicrosoftTimeZoneIndex" => "290"),
|
1542 |
+
Array("MageTimeZone" => "America/St_Johns", "MicrosoftTimeZoneIndex" => "060"),
|
1543 |
+
Array("MageTimeZone" => "Asia/Irkutsk", "MicrosoftTimeZoneIndex" => "207"),
|
1544 |
+
Array("MageTimeZone" => "Asia/Krasnoyarsk", "MicrosoftTimeZoneIndex" => "207"),
|
1545 |
+
Array("MageTimeZone" => "America/Santiago", "MicrosoftTimeZoneIndex" => "056"),
|
1546 |
+
Array("MageTimeZone" => "Antarctica/Palmer", "MicrosoftTimeZoneIndex" => "004"),
|
1547 |
+
Array("MageTimeZone" => "America/Dawson", "MicrosoftTimeZoneIndex" => "004"),
|
1548 |
+
Array("MageTimeZone" => "America/Los_Angeles", "MicrosoftTimeZoneIndex" => "004"),
|
1549 |
+
Array("MageTimeZone" => "America/Tijuana", "MicrosoftTimeZoneIndex" => "004"),
|
1550 |
+
Array("MageTimeZone" => "America/Vancouver", "MicrosoftTimeZoneIndex" => "004"),
|
1551 |
+
Array("MageTimeZone" => "America/Whitehorse", "MicrosoftTimeZoneIndex" => "004"),
|
1552 |
+
Array("MageTimeZone" => "America/Santa_Isabel", "MicrosoftTimeZoneIndex" => "004"),
|
1553 |
+
Array("MageTimeZone" => "PST8PDT", "MicrosoftTimeZoneIndex" => "004"),
|
1554 |
+
Array("MageTimeZone" => "Asia/Karachi", "MicrosoftTimeZoneIndex" => "185"),
|
1555 |
+
Array("MageTimeZone" => "America/Asuncion", "MicrosoftTimeZoneIndex" => "065"),
|
1556 |
+
Array("MageTimeZone" => "Africa/Ceuta", "MicrosoftTimeZoneIndex" => "105"),
|
1557 |
+
Array("MageTimeZone" => "Europe/Brussels", "MicrosoftTimeZoneIndex" => "105"),
|
1558 |
+
Array("MageTimeZone" => "Europe/Copenhagen", "MicrosoftTimeZoneIndex" => "105"),
|
1559 |
+
Array("MageTimeZone" => "Europe/Madrid", "MicrosoftTimeZoneIndex" => "105"),
|
1560 |
+
Array("MageTimeZone" => "Europe/Paris", "MicrosoftTimeZoneIndex" => "105"),
|
1561 |
+
Array("MageTimeZone" => "Europe/Moscow", "MicrosoftTimeZoneIndex" => "145"),
|
1562 |
+
Array("MageTimeZone" => "Europe/Samara", "MicrosoftTimeZoneIndex" => "145"),
|
1563 |
+
Array("MageTimeZone" => "Europe/Volgograd", "MicrosoftTimeZoneIndex" => "145"),
|
1564 |
+
Array("MageTimeZone" => "America/Araguaina", "MicrosoftTimeZoneIndex" => "070"),
|
1565 |
+
Array("MageTimeZone" => "America/Belem", "MicrosoftTimeZoneIndex" => "070"),
|
1566 |
+
Array("MageTimeZone" => "America/Cayenne", "MicrosoftTimeZoneIndex" => "070"),
|
1567 |
+
Array("MageTimeZone" => "America/Fortaleza", "MicrosoftTimeZoneIndex" => "070"),
|
1568 |
+
Array("MageTimeZone" => "America/Maceio", "MicrosoftTimeZoneIndex" => "070"),
|
1569 |
+
Array("MageTimeZone" => "America/Paramaribo", "MicrosoftTimeZoneIndex" => "070"),
|
1570 |
+
Array("MageTimeZone" => "America/Recife", "MicrosoftTimeZoneIndex" => "070"),
|
1571 |
+
Array("MageTimeZone" => "America/Santarem", "MicrosoftTimeZoneIndex" => "070"),
|
1572 |
+
Array("MageTimeZone" => "Antarctica/Rothera", "MicrosoftTimeZoneIndex" => "070"),
|
1573 |
+
Array("MageTimeZone" => "Atlantic/Stanley", "MicrosoftTimeZoneIndex" => "070"),
|
1574 |
+
Array("MageTimeZone" => "Etc/GMT+3", "MicrosoftTimeZoneIndex" => "070"),
|
1575 |
+
Array("MageTimeZone" => "America/Bogota", "MicrosoftTimeZoneIndex" => "045"),
|
1576 |
+
Array("MageTimeZone" => "America/Cayman", "MicrosoftTimeZoneIndex" => "045"),
|
1577 |
+
Array("MageTimeZone" => "America/Coral_Harbour", "MicrosoftTimeZoneIndex" => "045"),
|
1578 |
+
Array("MageTimeZone" => "America/Eirunepe", "MicrosoftTimeZoneIndex" => "045"),
|
1579 |
+
Array("MageTimeZone" => "America/Guayaquil", "MicrosoftTimeZoneIndex" => "045"),
|
1580 |
+
Array("MageTimeZone" => "America/Jamaica", "MicrosoftTimeZoneIndex" => "045"),
|
1581 |
+
Array("MageTimeZone" => "America/Lima", "MicrosoftTimeZoneIndex" => "045"),
|
1582 |
+
Array("MageTimeZone" => "America/Panama", "MicrosoftTimeZoneIndex" => "045"),
|
1583 |
+
Array("MageTimeZone" => "America/Rio_Branco", "MicrosoftTimeZoneIndex" => "045"),
|
1584 |
+
Array("MageTimeZone" => "Etc/GMT+5", "MicrosoftTimeZoneIndex" => "045"),
|
1585 |
+
Array("MageTimeZone" => "America/Anguilla", "MicrosoftTimeZoneIndex" => "055"),
|
1586 |
+
Array("MageTimeZone" => "America/Antigua", "MicrosoftTimeZoneIndex" => "055"),
|
1587 |
+
Array("MageTimeZone" => "America/Aruba", "MicrosoftTimeZoneIndex" => "055"),
|
1588 |
+
Array("MageTimeZone" => "America/Barbados", "MicrosoftTimeZoneIndex" => "055"),
|
1589 |
+
Array("MageTimeZone" => "America/Blanc-Sablon", "MicrosoftTimeZoneIndex" => "055"),
|
1590 |
+
Array("MageTimeZone" => "America/Boa_Vista", "MicrosoftTimeZoneIndex" => "055"),
|
1591 |
+
Array("MageTimeZone" => "America/Curacao", "MicrosoftTimeZoneIndex" => "055"),
|
1592 |
+
Array("MageTimeZone" => "America/Dominica", "MicrosoftTimeZoneIndex" => "055"),
|
1593 |
+
Array("MageTimeZone" => "America/Grenada", "MicrosoftTimeZoneIndex" => "055"),
|
1594 |
+
Array("MageTimeZone" => "America/Guadeloupe", "MicrosoftTimeZoneIndex" => "055"),
|
1595 |
+
Array("MageTimeZone" => "America/Guyana", "MicrosoftTimeZoneIndex" => "055"),
|
1596 |
+
Array("MageTimeZone" => "America/Kralendijk", "MicrosoftTimeZoneIndex" => "055"),
|
1597 |
+
Array("MageTimeZone" => "America/La_Paz", "MicrosoftTimeZoneIndex" => "055"),
|
1598 |
+
Array("MageTimeZone" => "America/Lower_Princes", "MicrosoftTimeZoneIndex" => "055"),
|
1599 |
+
Array("MageTimeZone" => "America/Manaus", "MicrosoftTimeZoneIndex" => "055"),
|
1600 |
+
Array("MageTimeZone" => "America/Marigot", "MicrosoftTimeZoneIndex" => "055"),
|
1601 |
+
Array("MageTimeZone" => "America/Martinique", "MicrosoftTimeZoneIndex" => "055"),
|
1602 |
+
Array("MageTimeZone" => "America/Montserrat", "MicrosoftTimeZoneIndex" => "055"),
|
1603 |
+
Array("MageTimeZone" => "America/Port_of_Spain", "MicrosoftTimeZoneIndex" => "055"),
|
1604 |
+
Array("MageTimeZone" => "America/Porto_Velho", "MicrosoftTimeZoneIndex" => "055"),
|
1605 |
+
Array("MageTimeZone" => "America/Puerto_Rico", "MicrosoftTimeZoneIndex" => "055"),
|
1606 |
+
Array("MageTimeZone" => "America/Santo_Domingo", "MicrosoftTimeZoneIndex" => "055"),
|
1607 |
+
Array("MageTimeZone" => "America/St_Barthelemy", "MicrosoftTimeZoneIndex" => "055"),
|
1608 |
+
Array("MageTimeZone" => "America/St_Kitts", "MicrosoftTimeZoneIndex" => "055"),
|
1609 |
+
Array("MageTimeZone" => "America/St_Lucia", "MicrosoftTimeZoneIndex" => "055"),
|
1610 |
+
Array("MageTimeZone" => "America/St_Thomas", "MicrosoftTimeZoneIndex" => "055"),
|
1611 |
+
Array("MageTimeZone" => "America/St_Vincent", "MicrosoftTimeZoneIndex" => "055"),
|
1612 |
+
Array("MageTimeZone" => "America/Tortola", "MicrosoftTimeZoneIndex" => "055"),
|
1613 |
+
Array("MageTimeZone" => "Etc/GMT+4", "MicrosoftTimeZoneIndex" => "055"),
|
1614 |
+
Array("MageTimeZone" => "Antarctica/Davis", "MicrosoftTimeZoneIndex" => "205"),
|
1615 |
+
Array("MageTimeZone" => "Asia/Bangkok", "MicrosoftTimeZoneIndex" => "205"),
|
1616 |
+
Array("MageTimeZone" => "Asia/Hovd", "MicrosoftTimeZoneIndex" => "205"),
|
1617 |
+
Array("MageTimeZone" => "Asia/Jakarta", "MicrosoftTimeZoneIndex" => "205"),
|
1618 |
+
Array("MageTimeZone" => "Asia/Phnom_Penh", "MicrosoftTimeZoneIndex" => "205"),
|
1619 |
+
Array("MageTimeZone" => "Asia/Pontianak", "MicrosoftTimeZoneIndex" => "205"),
|
1620 |
+
Array("MageTimeZone" => "Asia/Saigon", "MicrosoftTimeZoneIndex" => "205"),
|
1621 |
+
Array("MageTimeZone" => "Asia/Vientiane", "MicrosoftTimeZoneIndex" => "205"),
|
1622 |
+
Array("MageTimeZone" => "Etc/GMT-7", "MicrosoftTimeZoneIndex" => "205"),
|
1623 |
+
Array("MageTimeZone" => "Indian/Christmas", "MicrosoftTimeZoneIndex" => "205"),
|
1624 |
+
Array("MageTimeZone" => "Pacific/Apia", "MicrosoftTimeZoneIndex" => "001"),
|
1625 |
+
Array("MageTimeZone" => "Asia/Brunei", "MicrosoftTimeZoneIndex" => "215"),
|
1626 |
+
Array("MageTimeZone" => "Asia/Kuala_Lumpur", "MicrosoftTimeZoneIndex" => "215"),
|
1627 |
+
Array("MageTimeZone" => "Asia/Kuching", "MicrosoftTimeZoneIndex" => "215"),
|
1628 |
+
Array("MageTimeZone" => "Asia/Makassar", "MicrosoftTimeZoneIndex" => "215"),
|
1629 |
+
Array("MageTimeZone" => "Asia/Manila", "MicrosoftTimeZoneIndex" => "215"),
|
1630 |
+
Array("MageTimeZone" => "Asia/Singapore", "MicrosoftTimeZoneIndex" => "215"),
|
1631 |
+
Array("MageTimeZone" => "Etc/GMT-8", "MicrosoftTimeZoneIndex" => "215"),
|
1632 |
+
Array("MageTimeZone" => "Africa/Blantyre", "MicrosoftTimeZoneIndex" => "140"),
|
1633 |
+
Array("MageTimeZone" => "Africa/Bujumbura", "MicrosoftTimeZoneIndex" => "140"),
|
1634 |
+
Array("MageTimeZone" => "Africa/Gaborone", "MicrosoftTimeZoneIndex" => "140"),
|
1635 |
+
Array("MageTimeZone" => "Africa/Harare", "MicrosoftTimeZoneIndex" => "140"),
|
1636 |
+
Array("MageTimeZone" => "Africa/Johannesburg", "MicrosoftTimeZoneIndex" => "140"),
|
1637 |
+
Array("MageTimeZone" => "Africa/Kigali", "MicrosoftTimeZoneIndex" => "140"),
|
1638 |
+
Array("MageTimeZone" => "Africa/Lubumbashi", "MicrosoftTimeZoneIndex" => "140"),
|
1639 |
+
Array("MageTimeZone" => "Africa/Lusaka", "MicrosoftTimeZoneIndex" => "140"),
|
1640 |
+
Array("MageTimeZone" => "Africa/Maputo", "MicrosoftTimeZoneIndex" => "140"),
|
1641 |
+
Array("MageTimeZone" => "Africa/Maseru", "MicrosoftTimeZoneIndex" => "140"),
|
1642 |
+
Array("MageTimeZone" => "Africa/Mbabane", "MicrosoftTimeZoneIndex" => "140"),
|
1643 |
+
Array("MageTimeZone" => "Etc/GMT-2", "MicrosoftTimeZoneIndex" => "140"),
|
1644 |
+
Array("MageTimeZone" => "Asia/Colombo", "MicrosoftTimeZoneIndex" => "200"),
|
1645 |
+
Array("MageTimeZone" => "Asia/Damascus", "MicrosoftTimeZoneIndex" => "158"),
|
1646 |
+
Array("MageTimeZone" => "Asia/Taipei", "MicrosoftTimeZoneIndex" => "220"),
|
1647 |
+
Array("MageTimeZone" => "Australia/Currie", "MicrosoftTimeZoneIndex" => "265"),
|
1648 |
+
Array("MageTimeZone" => "Australia/Hobart", "MicrosoftTimeZoneIndex" => "265"),
|
1649 |
+
Array("MageTimeZone" => "Asia/Dili", "MicrosoftTimeZoneIndex" => "235"),
|
1650 |
+
Array("MageTimeZone" => "Asia/Jayapura", "MicrosoftTimeZoneIndex" => "235"),
|
1651 |
+
Array("MageTimeZone" => "Asia/Tokyo", "MicrosoftTimeZoneIndex" => "235"),
|
1652 |
+
Array("MageTimeZone" => "Etc/GMT-9", "MicrosoftTimeZoneIndex" => "235"),
|
1653 |
+
Array("MageTimeZone" => "Pacific/Palau", "MicrosoftTimeZoneIndex" => "235"),
|
1654 |
+
Array("MageTimeZone" => "Etc/GMT-13", "MicrosoftTimeZoneIndex" => "300"),
|
1655 |
+
Array("MageTimeZone" => "Pacific/Enderbury", "MicrosoftTimeZoneIndex" => "300"),
|
1656 |
+
Array("MageTimeZone" => "Pacific/Fakaofo", "MicrosoftTimeZoneIndex" => "300"),
|
1657 |
+
Array("MageTimeZone" => "Pacific/Tongatapu", "MicrosoftTimeZoneIndex" => "300"),
|
1658 |
+
Array("MageTimeZone" => "Europe/Istanbul", "MicrosoftTimeZoneIndex" => "130"),
|
1659 |
+
Array("MageTimeZone" => "America/Indiana/Marengo", "MicrosoftTimeZoneIndex" => "040"),
|
1660 |
+
Array("MageTimeZone" => "America/Indiana/Vevay", "MicrosoftTimeZoneIndex" => "040"),
|
1661 |
+
Array("MageTimeZone" => "America/Indianapolis", "MicrosoftTimeZoneIndex" => "040"),
|
1662 |
+
Array("MageTimeZone" => "America/Creston", "MicrosoftTimeZoneIndex" => "015"),
|
1663 |
+
Array("MageTimeZone" => "America/Dawson_Creek", "MicrosoftTimeZoneIndex" => "015"),
|
1664 |
+
Array("MageTimeZone" => "America/Hermosillo", "MicrosoftTimeZoneIndex" => "015"),
|
1665 |
+
Array("MageTimeZone" => "America/Phoenix", "MicrosoftTimeZoneIndex" => "015"),
|
1666 |
+
Array("MageTimeZone" => "Etc/GMT+7", "MicrosoftTimeZoneIndex" => "015"),
|
1667 |
+
Array("MageTimeZone" => "America/Danmarkshavn", "MicrosoftTimeZoneIndex" => "085"),
|
1668 |
+
Array("MageTimeZone" => "Etc/GMT", "MicrosoftTimeZoneIndex" => "085"),
|
1669 |
+
Array("MageTimeZone" => "Etc/GMT-12", "MicrosoftTimeZoneIndex" => "285"),
|
1670 |
+
Array("MageTimeZone" => "Pacific/Funafuti", "MicrosoftTimeZoneIndex" => "285"),
|
1671 |
+
Array("MageTimeZone" => "Pacific/Kwajalein", "MicrosoftTimeZoneIndex" => "285"),
|
1672 |
+
Array("MageTimeZone" => "Pacific/Majuro", "MicrosoftTimeZoneIndex" => "285"),
|
1673 |
+
Array("MageTimeZone" => "Pacific/Nauru", "MicrosoftTimeZoneIndex" => "285"),
|
1674 |
+
Array("MageTimeZone" => "Pacific/Tarawa", "MicrosoftTimeZoneIndex" => "285"),
|
1675 |
+
Array("MageTimeZone" => "Pacific/Wake", "MicrosoftTimeZoneIndex" => "285"),
|
1676 |
+
Array("MageTimeZone" => "Pacific/Wallis", "MicrosoftTimeZoneIndex" => "285"),
|
1677 |
+
Array("MageTimeZone" => "America/Noronha", "MicrosoftTimeZoneIndex" => "075"),
|
1678 |
+
Array("MageTimeZone" => "Atlantic/South_Georgia", "MicrosoftTimeZoneIndex" => "075"),
|
1679 |
+
Array("MageTimeZone" => "Etc/GMT+2", "MicrosoftTimeZoneIndex" => "075"),
|
1680 |
+
Array("MageTimeZone" => "Etc/GMT+11", "MicrosoftTimeZoneIndex" => "280"),
|
1681 |
+
Array("MageTimeZone" => "Pacific/Midway", "MicrosoftTimeZoneIndex" => "280"),
|
1682 |
+
Array("MageTimeZone" => "Pacific/Niue", "MicrosoftTimeZoneIndex" => "280"),
|
1683 |
+
Array("MageTimeZone" => "Pacific/Pago_Pago", "MicrosoftTimeZoneIndex" => "280"),
|
1684 |
+
Array("MageTimeZone" => "Asia/Choibalsan", "MicrosoftTimeZoneIndex" => "227"),
|
1685 |
+
Array("MageTimeZone" => "Asia/Ulaanbaatar", "MicrosoftTimeZoneIndex" => "227"),
|
1686 |
+
Array("MageTimeZone" => "America/Caracas", "MicrosoftTimeZoneIndex" => "055"),
|
1687 |
+
Array("MageTimeZone" => "Asia/Sakhalin", "MicrosoftTimeZoneIndex" => "270"),
|
1688 |
+
Array("MageTimeZone" => "Asia/Ust-Nera", "MicrosoftTimeZoneIndex" => "270"),
|
1689 |
+
Array("MageTimeZone" => "Asia/Vladivostok", "MicrosoftTimeZoneIndex" => "270"),
|
1690 |
+
Array("MageTimeZone" => "Antarctica/Casey", "MicrosoftTimeZoneIndex" => "225"),
|
1691 |
+
Array("MageTimeZone" => "Australia/Perth", "MicrosoftTimeZoneIndex" => "225"),
|
1692 |
+
Array("MageTimeZone" => "Africa/Algiers", "MicrosoftTimeZoneIndex" => "113"),
|
1693 |
+
Array("MageTimeZone" => "Africa/Bangui", "MicrosoftTimeZoneIndex" => "113"),
|
1694 |
+
Array("MageTimeZone" => "Africa/Brazzaville", "MicrosoftTimeZoneIndex" => "113"),
|
1695 |
+
Array("MageTimeZone" => "Africa/Douala", "MicrosoftTimeZoneIndex" => "113"),
|
1696 |
+
Array("MageTimeZone" => "Africa/Kinshasa", "MicrosoftTimeZoneIndex" => "113"),
|
1697 |
+
Array("MageTimeZone" => "Africa/Lagos", "MicrosoftTimeZoneIndex" => "113"),
|
1698 |
+
Array("MageTimeZone" => "Africa/Libreville", "MicrosoftTimeZoneIndex" => "113"),
|
1699 |
+
Array("MageTimeZone" => "Africa/Luanda", "MicrosoftTimeZoneIndex" => "113"),
|
1700 |
+
Array("MageTimeZone" => "Africa/Malabo", "MicrosoftTimeZoneIndex" => "113"),
|
1701 |
+
Array("MageTimeZone" => "Africa/Ndjamena", "MicrosoftTimeZoneIndex" => "113"),
|
1702 |
+
Array("MageTimeZone" => "Africa/Niamey", "MicrosoftTimeZoneIndex" => "113"),
|
1703 |
+
Array("MageTimeZone" => "Africa/Porto-Novo", "MicrosoftTimeZoneIndex" => "113"),
|
1704 |
+
Array("MageTimeZone" => "Africa/Tunis", "MicrosoftTimeZoneIndex" => "113"),
|
1705 |
+
Array("MageTimeZone" => "Etc/GMT-1", "MicrosoftTimeZoneIndex" => "113"),
|
1706 |
+
Array("MageTimeZone" => "Arctic/Longyearbyen", "MicrosoftTimeZoneIndex" => "110"),
|
1707 |
+
Array("MageTimeZone" => "Europe/Amsterdam", "MicrosoftTimeZoneIndex" => "110"),
|
1708 |
+
Array("MageTimeZone" => "Europe/Andorra", "MicrosoftTimeZoneIndex" => "110"),
|
1709 |
+
Array("MageTimeZone" => "Europe/Berlin", "MicrosoftTimeZoneIndex" => "110"),
|
1710 |
+
Array("MageTimeZone" => "Europe/Busingen", "MicrosoftTimeZoneIndex" => "110"),
|
1711 |
+
Array("MageTimeZone" => "Europe/Gibraltar", "MicrosoftTimeZoneIndex" => "110"),
|
1712 |
+
Array("MageTimeZone" => "Europe/Luxembourg", "MicrosoftTimeZoneIndex" => "110"),
|
1713 |
+
Array("MageTimeZone" => "Europe/Malta", "MicrosoftTimeZoneIndex" => "110"),
|
1714 |
+
Array("MageTimeZone" => "Europe/Monaco", "MicrosoftTimeZoneIndex" => "110"),
|
1715 |
+
Array("MageTimeZone" => "Europe/Oslo", "MicrosoftTimeZoneIndex" => "110"),
|
1716 |
+
Array("MageTimeZone" => "Europe/Rome", "MicrosoftTimeZoneIndex" => "110"),
|
1717 |
+
Array("MageTimeZone" => "Europe/San_Marino", "MicrosoftTimeZoneIndex" => "110"),
|
1718 |
+
Array("MageTimeZone" => "Europe/Stockholm", "MicrosoftTimeZoneIndex" => "110"),
|
1719 |
+
Array("MageTimeZone" => "Europe/Vaduz", "MicrosoftTimeZoneIndex" => "110"),
|
1720 |
+
Array("MageTimeZone" => "Europe/Vatican", "MicrosoftTimeZoneIndex" => "110"),
|
1721 |
+
Array("MageTimeZone" => "Europe/Vienna", "MicrosoftTimeZoneIndex" => "110"),
|
1722 |
+
Array("MageTimeZone" => "Europe/Zurich", "MicrosoftTimeZoneIndex" => "110"),
|
1723 |
+
Array("MageTimeZone" => "Antarctica/Mawson", "MicrosoftTimeZoneIndex" => "185"),
|
1724 |
+
Array("MageTimeZone" => "Asia/Aqtau", "MicrosoftTimeZoneIndex" => "185"),
|
1725 |
+
Array("MageTimeZone" => "Asia/Aqtobe", "MicrosoftTimeZoneIndex" => "185"),
|
1726 |
+
Array("MageTimeZone" => "Asia/Ashgabat", "MicrosoftTimeZoneIndex" => "185"),
|
1727 |
+
Array("MageTimeZone" => "Asia/Dushanbe", "MicrosoftTimeZoneIndex" => "185"),
|
1728 |
+
Array("MageTimeZone" => "Asia/Oral", "MicrosoftTimeZoneIndex" => "185"),
|
1729 |
+
Array("MageTimeZone" => "Asia/Samarkand", "MicrosoftTimeZoneIndex" => "185"),
|
1730 |
+
Array("MageTimeZone" => "Asia/Tashkent", "MicrosoftTimeZoneIndex" => "185"),
|
1731 |
+
Array("MageTimeZone" => "Etc/GMT-5", "MicrosoftTimeZoneIndex" => "TEST"),
|
1732 |
+
Array("MageTimeZone" => "Indian/Kerguelen", "MicrosoftTimeZoneIndex" => "185"),
|
1733 |
+
Array("MageTimeZone" => "Indian/Maldives", "MicrosoftTimeZoneIndex" => "185"),
|
1734 |
+
Array("MageTimeZone" => "Antarctica/DumontDUrville", "MicrosoftTimeZoneIndex" => "275"),
|
1735 |
+
Array("MageTimeZone" => "Etc/GMT-10", "MicrosoftTimeZoneIndex" => "275"),
|
1736 |
+
Array("MageTimeZone" => "Pacific/Guam", "MicrosoftTimeZoneIndex" => "275"),
|
1737 |
+
Array("MageTimeZone" => "Pacific/Port_Moresby", "MicrosoftTimeZoneIndex" => "275"),
|
1738 |
+
Array("MageTimeZone" => "Pacific/Saipan", "MicrosoftTimeZoneIndex" => "275"),
|
1739 |
+
Array("MageTimeZone" => "Pacific/Truk", "MicrosoftTimeZoneIndex" => "275"),
|
1740 |
+
Array("MageTimeZone" => "Asia/Khandyga", "MicrosoftTimeZoneIndex" => "240"),
|
1741 |
+
Array("MageTimeZone" => "Asia/Yakutsk", "MicrosoftTimeZoneIndex" => "240"),
|
1742 |
+
);
|
1743 |
+
foreach ($timeZones as $time) {
|
1744 |
+
if ($time['MageTimeZone'] == $timeZone) {
|
1745 |
+
$result = $time['MicrosoftTimeZoneIndex'];
|
1746 |
+
}
|
1747 |
+
}
|
1748 |
+
}
|
1749 |
+
return $result;
|
1750 |
+
}
|
1751 |
+
|
1752 |
+
/**
|
1753 |
+
* get culture id needed for trial account
|
1754 |
+
*
|
1755 |
+
* @return mixed
|
1756 |
+
*/
|
1757 |
+
public function getCultureId()
|
1758 |
+
{
|
1759 |
+
$fallback = 'en_US';
|
1760 |
+
$supportedCultures = array(
|
1761 |
+
'en_US' => '1033',
|
1762 |
+
'en_GB' => '2057',
|
1763 |
+
'fr_FR' => '1036',
|
1764 |
+
'es_ES' => '3082',
|
1765 |
+
'de_DE' => '1031',
|
1766 |
+
'it_IT' => '1040',
|
1767 |
+
'ru_RU' => '1049',
|
1768 |
+
'pt_PT' => '2070'
|
1769 |
+
);
|
1770 |
+
$localeCode = Mage::app()->getLocale()->getLocaleCode();
|
1771 |
+
if (isset($supportedCultures[$localeCode])) {
|
1772 |
+
return $supportedCultures[$localeCode];
|
1773 |
+
}
|
1774 |
+
return $supportedCultures[$fallback];
|
1775 |
+
}
|
1776 |
+
|
1777 |
+
/**
|
1778 |
+
* save api credentials
|
1779 |
+
*
|
1780 |
+
* @param $apiUser
|
1781 |
+
* @param $apiPass
|
1782 |
+
* @return bool
|
1783 |
+
*/
|
1784 |
+
public function saveApiCreds($apiUser, $apiPass)
|
1785 |
+
{
|
1786 |
+
try {
|
1787 |
+
$apiPass = Mage::helper('core')->encrypt($apiPass);
|
1788 |
+
$config = new Mage_Core_Model_Config();
|
1789 |
+
$config->saveConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_API_ENABLED, '1');
|
1790 |
+
$config->saveConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_API_USERNAME, $apiUser);
|
1791 |
+
$config->saveConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_API_PASSWORD, $apiPass);
|
1792 |
+
Mage::getConfig()->cleanCache();
|
1793 |
+
return true;
|
1794 |
+
} catch (Exception $e) {
|
1795 |
+
Mage::logException($e);
|
1796 |
+
return false;
|
1797 |
+
}
|
1798 |
+
}
|
1799 |
+
|
1800 |
+
/**
|
1801 |
+
* setup data fields
|
1802 |
+
*
|
1803 |
+
* @return bool
|
1804 |
+
*/
|
1805 |
+
public function setupDataFields()
|
1806 |
+
{
|
1807 |
+
$error = false;
|
1808 |
+
$apiModel = Mage::helper('ddg')->getWebsiteApiClient();
|
1809 |
+
if (!$apiModel) {
|
1810 |
+
return false;
|
1811 |
+
} else {
|
1812 |
+
$dataFields = Mage::getModel('ddg_automation/connector_datafield')->getContactDatafields();
|
1813 |
+
foreach ($dataFields as $key => $dataField) {
|
1814 |
+
$response = $apiModel->postDataFields($dataField);
|
1815 |
+
//ignore existing datafields message
|
1816 |
+
if (isset($response->message) &&
|
1817 |
+
$response->message != Dotdigitalgroup_Email_Model_Apiconnector_Client::API_ERROR_DATAFIELD_EXISTS
|
1818 |
+
) {
|
1819 |
+
$error = true;
|
1820 |
+
} else {
|
1821 |
+
try {
|
1822 |
+
//map the successfully created data field
|
1823 |
+
$config = new Mage_Core_Model_Config();
|
1824 |
+
$config->saveConfig('connector_data_mapping/customer_data/' . $key,
|
1825 |
+
strtoupper($dataField['name']));
|
1826 |
+
Mage::helper('ddg')->log('successfully connected : ' . $dataField['name']);
|
1827 |
+
} catch (Exception $e) {
|
1828 |
+
Mage::logException($e);
|
1829 |
+
$error = true;
|
1830 |
+
}
|
1831 |
+
}
|
1832 |
+
}
|
1833 |
+
if ($error) {
|
1834 |
+
return false;
|
1835 |
+
} else {
|
1836 |
+
Mage::getConfig()->cleanCache();
|
1837 |
+
return true;
|
1838 |
+
}
|
1839 |
+
}
|
1840 |
+
}
|
1841 |
+
|
1842 |
+
/**
|
1843 |
+
* create certain address books
|
1844 |
+
*
|
1845 |
+
* @return bool
|
1846 |
+
*/
|
1847 |
+
public function createAddressBooks()
|
1848 |
+
{
|
1849 |
+
$addressBooks = array(
|
1850 |
+
array('name' => 'Magento_Customers', 'visibility' => 'Private'),
|
1851 |
+
array('name' => 'Magento_Subscribers', 'visibility' => 'Private'),
|
1852 |
+
array('name' => 'Magento_Guests', 'visibility' => 'Private'),
|
1853 |
+
);
|
1854 |
+
$addressBookMap = array(
|
1855 |
+
'Magento_Customers' => Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMERS_ADDRESS_BOOK_ID,
|
1856 |
+
'Magento_Subscribers' => Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_SUBSCRIBERS_ADDRESS_BOOK_ID,
|
1857 |
+
'Magento_Guests' => Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_GUEST_ADDRESS_BOOK_ID
|
1858 |
+
);
|
1859 |
+
$error = false;
|
1860 |
+
$client = Mage::helper('ddg')->getWebsiteApiClient();
|
1861 |
+
if (!$client) {
|
1862 |
+
return false;
|
1863 |
+
} else {
|
1864 |
+
foreach ($addressBooks as $addressBook) {
|
1865 |
+
$addressBookName = $addressBook['name'];
|
1866 |
+
$visibility = $addressBook['visibility'];
|
1867 |
+
if (strlen($addressBookName)) {
|
1868 |
+
$response = $client->postAddressBooks($addressBookName, $visibility);
|
1869 |
+
if (isset($response->message)) {
|
1870 |
+
$error = true;
|
1871 |
+
} else {
|
1872 |
+
try {
|
1873 |
+
//map the successfully created address book
|
1874 |
+
$config = new Mage_Core_Model_Config();
|
1875 |
+
$config->saveConfig($addressBookMap[$addressBookName], $response->id);
|
1876 |
+
Mage::helper('ddg')->log('successfully connected address book : ' . $addressBookName);
|
1877 |
+
} catch (Exception $e) {
|
1878 |
+
Mage::logException($e);
|
1879 |
+
$error = true;
|
1880 |
+
}
|
1881 |
+
}
|
1882 |
+
}
|
1883 |
+
}
|
1884 |
+
}
|
1885 |
+
if ($error) {
|
1886 |
+
return false;
|
1887 |
+
} else {
|
1888 |
+
Mage::getConfig()->cleanCache();
|
1889 |
+
return true;
|
1890 |
+
}
|
1891 |
+
}
|
1892 |
+
|
1893 |
+
/**
|
1894 |
+
* enable certain syncs for newly created trial account
|
1895 |
+
*
|
1896 |
+
* @return bool
|
1897 |
+
*/
|
1898 |
+
public function enableSyncForTrial()
|
1899 |
+
{
|
1900 |
+
try {
|
1901 |
+
$config = new Mage_Core_Model_Config();
|
1902 |
+
$config->saveConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_SYNC_CONTACT_ENABLED, '1');
|
1903 |
+
$config->saveConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_SYNC_GUEST_ENABLED, '1');
|
1904 |
+
$config->saveConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_SYNC_SUBSCRIBER_ENABLED, '1');
|
1905 |
+
$config->saveConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_SYNC_ORDER_ENABLED, '1');
|
1906 |
+
Mage::getConfig()->cleanCache();
|
1907 |
+
return true;
|
1908 |
+
} catch (Exception $e) {
|
1909 |
+
Mage::logException($e);
|
1910 |
+
return false;
|
1911 |
+
}
|
1912 |
+
}
|
1913 |
+
|
1914 |
+
/**
|
1915 |
+
* save api endpoint
|
1916 |
+
*
|
1917 |
+
* @param $value
|
1918 |
+
*/
|
1919 |
+
public function saveApiEndPoint($value)
|
1920 |
+
{
|
1921 |
+
$config = Mage::getConfig();
|
1922 |
+
$config->saveConfig(
|
1923 |
+
Dotdigitalgroup_Email_Helper_Config::PATH_FOR_API_ENDPOINT,
|
1924 |
+
$value
|
1925 |
+
);
|
1926 |
+
$config->cleanCache();
|
1927 |
+
}
|
1928 |
+
|
1929 |
+
/**
|
1930 |
+
* check if both frotnend and backend secure(HTTPS)
|
1931 |
+
*
|
1932 |
+
* @return bool
|
1933 |
+
*/
|
1934 |
+
public function isFrontendAdminSecure()
|
1935 |
+
{
|
1936 |
+
$frontend = Mage::app()->getStore()->isFrontUrlSecure();
|
1937 |
+
$admin = Mage::app()->getStore()->isAdminUrlSecure();
|
1938 |
+
$current = Mage::app()->getStore()->isCurrentlySecure();
|
1939 |
+
|
1940 |
+
if ($frontend && $admin && $current) {
|
1941 |
+
return true;
|
1942 |
+
}
|
1943 |
+
|
1944 |
+
return false;
|
1945 |
+
}
|
1946 |
Â
}
|
@@ -1,24 +1,26 @@
|
|
1 |
Â
<?php
|
2 |
Â
|
3 |
-
class Dotdigitalgroup_Email_Helper_File
|
Â
|
|
4 |
Â
{
|
5 |
Â
|
6 |
-
|
7 |
Â
|
8 |
Â
/**
|
9 |
Â
* Location of files we are building
|
10 |
Â
*/
|
11 |
Â
|
12 |
-
protected $
|
13 |
-
protected $
|
14 |
Â
|
15 |
-
|
16 |
-
|
17 |
Â
|
18 |
Â
public function __construct()
|
19 |
Â
{
|
20 |
-
$this->
|
21 |
-
|
Â
|
|
22 |
Â
|
23 |
Â
$this->delimiter = ','; // tab character
|
24 |
Â
$this->enclosure = '"';
|
@@ -27,60 +29,67 @@ class Dotdigitalgroup_Email_Helper_File extends Dotdigitalgroup_Email_Helper_Dat
|
|
27 |
Â
|
28 |
Â
public function getOutputFolder()
|
29 |
Â
{
|
30 |
-
$this->pathExists($this->
|
31 |
-
|
Â
|
|
32 |
Â
} // end
|
33 |
Â
|
34 |
Â
public function getArchiveFolder()
|
35 |
Â
{
|
36 |
-
$this->pathExists($this->
|
37 |
-
|
Â
|
|
38 |
Â
} // end
|
39 |
Â
|
40 |
Â
/* Return the full filepath */
|
41 |
-
public
|
42 |
Â
{
|
43 |
Â
return $this->getOutputFolder() . DS . $filename;
|
44 |
Â
}
|
45 |
Â
|
46 |
-
public
|
47 |
Â
{
|
48 |
-
$this->moveFile(
|
Â
|
|
Â
|
|
49 |
Â
}
|
50 |
Â
|
51 |
Â
/**
|
52 |
Â
* Moves the output file from one folder to the next
|
53 |
-
*
|
54 |
-
* @param $
|
Â
|
|
55 |
Â
* @param $filename
|
56 |
Â
*/
|
57 |
-
public function moveFile($
|
58 |
Â
{
|
59 |
Â
// generate the full file paths
|
60 |
-
$
|
61 |
-
$
|
62 |
Â
|
63 |
Â
// rename the file
|
64 |
-
rename($
|
65 |
Â
|
66 |
Â
} // end
|
67 |
Â
|
68 |
Â
|
69 |
Â
/**
|
70 |
Â
* Output an array to the output file FORCING Quotes around all fields
|
Â
|
|
71 |
Â
* @param $filepath
|
72 |
Â
* @param $csv
|
73 |
Â
*/
|
74 |
Â
public function outputForceQuotesCSV($filepath, $csv)
|
75 |
Â
{
|
76 |
-
$fqCsv = $this->arrayToCsv($csv,chr(9),'"',true,false);
|
77 |
Â
// Open for writing only; place the file pointer at the end of the file. If the file does not exist, attempt to create it.
|
78 |
Â
$fp = fopen($filepath, "a");
|
79 |
Â
|
80 |
Â
// for some reason passing the preset delimiter/enclosure variables results in error
|
81 |
-
|
82 |
-
|
83 |
-
|
Â
|
|
84 |
Â
}
|
85 |
Â
fclose($fp);
|
86 |
Â
|
@@ -89,6 +98,7 @@ class Dotdigitalgroup_Email_Helper_File extends Dotdigitalgroup_Email_Helper_Dat
|
|
89 |
Â
|
90 |
Â
/**
|
91 |
Â
* Output an array to the output file
|
Â
|
|
92 |
Â
* @param $filepath
|
93 |
Â
* @param $csv
|
94 |
Â
*/
|
@@ -98,9 +108,11 @@ class Dotdigitalgroup_Email_Helper_File extends Dotdigitalgroup_Email_Helper_Dat
|
|
98 |
Â
$handle = fopen($filepath, "a");
|
99 |
Â
|
100 |
Â
// for some reason passing the preset delimiter/enclosure variables results in error
|
101 |
-
|
102 |
-
if (fputcsv($handle, $csv, ',', '"') == 0
|
103 |
-
Mage::throwException(
|
Â
|
|
Â
|
|
104 |
Â
}
|
105 |
Â
|
106 |
Â
fclose($handle);
|
@@ -110,78 +122,97 @@ class Dotdigitalgroup_Email_Helper_File extends Dotdigitalgroup_Email_Helper_Dat
|
|
110 |
Â
|
111 |
Â
/**
|
112 |
Â
* If the path does not exist then create it
|
Â
|
|
113 |
Â
* @param string $path
|
114 |
Â
*/
|
115 |
Â
public function pathExists($path)
|
116 |
Â
{
|
117 |
-
if (!is_dir($path)) {
|
118 |
Â
mkdir($path, 0775, true);
|
119 |
Â
} // end
|
120 |
-
|
121 |
-
return;
|
122 |
-
|
123 |
-
} // end
|
124 |
Â
|
125 |
Â
|
126 |
-
protected function arrayToCsv(
|
127 |
-
|
128 |
-
|
129 |
-
$
|
Â
|
|
130 |
Â
|
131 |
Â
$output = array();
|
132 |
-
foreach (
|
133 |
Â
if ($field === null && $nullToMysqlNull) {
|
134 |
Â
$output[] = 'NULL';
|
135 |
Â
continue;
|
136 |
Â
}
|
137 |
Â
|
138 |
Â
// Enclose fields containing $delimiter, $enclosure or whitespace
|
139 |
-
if ($encloseAll
|
140 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
141 |
Â
} else {
|
142 |
Â
$output[] = $field;
|
143 |
Â
}
|
144 |
Â
}
|
145 |
Â
|
146 |
-
return implode(
|
147 |
Â
}
|
148 |
Â
|
149 |
Â
/**
|
150 |
Â
* Delete file or directory
|
Â
|
|
151 |
Â
* @param $path
|
Â
|
|
152 |
Â
* @return bool
|
153 |
Â
*/
|
154 |
Â
public function deleteDir($path)
|
155 |
Â
{
|
156 |
Â
$class_func = array(__CLASS__, __FUNCTION__);
|
157 |
-
|
158 |
-
|
159 |
-
|
Â
|
|
Â
|
|
Â
|
|
160 |
Â
}
|
161 |
Â
|
162 |
Â
|
163 |
Â
public function getWebsiteCustomerMappingDatafields($website)
|
164 |
Â
{
|
165 |
-
$store
|
166 |
-
$mappedData = Mage::getStoreConfig(
|
Â
|
|
Â
|
|
167 |
Â
unset($mappedData['custom_attributes']);
|
168 |
Â
unset($mappedData['abandoned_prod_name']);
|
169 |
Â
|
170 |
-
|
171 |
-
|
172 |
Â
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
Â
|
|
Â
|
|
178 |
Â
|
179 |
-
$mappedRewardData = $this->getWebsiteCustomerRewardMappingDatafields(
|
180 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
181 |
Â
|
182 |
Â
foreach ($mappedData as $key => $value) {
|
183 |
-
if (! $value)
|
184 |
Â
unset($mappedData[$key]);
|
Â
|
|
185 |
Â
}
|
186 |
Â
|
187 |
Â
return $mappedData;
|
@@ -190,29 +221,35 @@ class Dotdigitalgroup_Email_Helper_File extends Dotdigitalgroup_Email_Helper_Dat
|
|
190 |
Â
public function getWebsiteCustomerRewardMappingDatafields($website)
|
191 |
Â
{
|
192 |
Â
$helper = Mage::helper('ddg');
|
193 |
-
if($helper->isSweetToothToGo($website)) {
|
194 |
-
$store
|
195 |
-
$mappedData = Mage::getStoreConfig(
|
Â
|
|
Â
|
|
196 |
Â
unset($mappedData['active']);
|
Â
|
|
197 |
Â
return $mappedData;
|
198 |
Â
}
|
Â
|
|
199 |
Â
return false;
|
200 |
Â
}
|
201 |
Â
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
Â
|
|
Â
|
|
218 |
Â
}
|
1 |
Â
<?php
|
2 |
Â
|
3 |
+
class Dotdigitalgroup_Email_Helper_File
|
4 |
+
extends Dotdigitalgroup_Email_Helper_Data
|
5 |
Â
{
|
6 |
Â
|
7 |
+
const FILE_FULL_ACCESS_PERMISSION = '777';
|
8 |
Â
|
9 |
Â
/**
|
10 |
Â
* Location of files we are building
|
11 |
Â
*/
|
12 |
Â
|
13 |
+
protected $_outputFolder; // set in _construct
|
14 |
+
protected $_outputArchiveFolder; // set in _construct
|
15 |
Â
|
16 |
+
public $delimiter; // set in _construct
|
17 |
+
public $enclosure; // set in _construct
|
18 |
Â
|
19 |
Â
public function __construct()
|
20 |
Â
{
|
21 |
+
$this->_outputFolder = Mage::getBaseDir('var') . DS . 'export'
|
22 |
+
. DS . 'email';
|
23 |
+
$this->_outputArchiveFolder = $this->_outputFolder . DS . 'archive';
|
24 |
Â
|
25 |
Â
$this->delimiter = ','; // tab character
|
26 |
Â
$this->enclosure = '"';
|
29 |
Â
|
30 |
Â
public function getOutputFolder()
|
31 |
Â
{
|
32 |
+
$this->pathExists($this->_outputFolder);
|
33 |
+
|
34 |
+
return $this->_outputFolder;
|
35 |
Â
} // end
|
36 |
Â
|
37 |
Â
public function getArchiveFolder()
|
38 |
Â
{
|
39 |
+
$this->pathExists($this->_outputArchiveFolder);
|
40 |
+
|
41 |
+
return $this->_outputArchiveFolder;
|
42 |
Â
} // end
|
43 |
Â
|
44 |
Â
/* Return the full filepath */
|
45 |
+
public function getFilePath($filename)
|
46 |
Â
{
|
47 |
Â
return $this->getOutputFolder() . DS . $filename;
|
48 |
Â
}
|
49 |
Â
|
50 |
+
public function archiveCSV($filename)
|
51 |
Â
{
|
52 |
+
$this->moveFile(
|
53 |
+
$this->getOutputFolder(), $this->getArchiveFolder(), $filename
|
54 |
+
);
|
55 |
Â
}
|
56 |
Â
|
57 |
Â
/**
|
58 |
Â
* Moves the output file from one folder to the next
|
59 |
+
*
|
60 |
+
* @param $sourceFolder
|
61 |
+
* @param $destFolder
|
62 |
Â
* @param $filename
|
63 |
Â
*/
|
64 |
+
public function moveFile($sourceFolder, $destFolder, $filename)
|
65 |
Â
{
|
66 |
Â
// generate the full file paths
|
67 |
+
$sourceFilepath = $sourceFolder . DS . $filename;
|
68 |
+
$destFilepath = $destFolder . DS . $filename;
|
69 |
Â
|
70 |
Â
// rename the file
|
71 |
+
rename($sourceFilepath, $destFilepath);
|
72 |
Â
|
73 |
Â
} // end
|
74 |
Â
|
75 |
Â
|
76 |
Â
/**
|
77 |
Â
* Output an array to the output file FORCING Quotes around all fields
|
78 |
+
*
|
79 |
Â
* @param $filepath
|
80 |
Â
* @param $csv
|
81 |
Â
*/
|
82 |
Â
public function outputForceQuotesCSV($filepath, $csv)
|
83 |
Â
{
|
84 |
+
$fqCsv = $this->arrayToCsv($csv, chr(9), '"', true, false);
|
85 |
Â
// Open for writing only; place the file pointer at the end of the file. If the file does not exist, attempt to create it.
|
86 |
Â
$fp = fopen($filepath, "a");
|
87 |
Â
|
88 |
Â
// for some reason passing the preset delimiter/enclosure variables results in error
|
89 |
+
if (fwrite($fp, $fqCsv) == 0) {
|
90 |
+
Mage::throwException(
|
91 |
+
Mage::helper('ddg')->__('Problem writing CSV file')
|
92 |
+
);
|
93 |
Â
}
|
94 |
Â
fclose($fp);
|
95 |
Â
|
98 |
Â
|
99 |
Â
/**
|
100 |
Â
* Output an array to the output file
|
101 |
+
*
|
102 |
Â
* @param $filepath
|
103 |
Â
* @param $csv
|
104 |
Â
*/
|
108 |
Â
$handle = fopen($filepath, "a");
|
109 |
Â
|
110 |
Â
// for some reason passing the preset delimiter/enclosure variables results in error
|
111 |
+
//$this->delimiter $this->enclosure
|
112 |
+
if (fputcsv($handle, $csv, ',', '"') == 0) {
|
113 |
+
Mage::throwException(
|
114 |
+
Mage::helper('ddg')->__('Problem writing CSV file')
|
115 |
+
);
|
116 |
Â
}
|
117 |
Â
|
118 |
Â
fclose($handle);
|
122 |
Â
|
123 |
Â
/**
|
124 |
Â
* If the path does not exist then create it
|
125 |
+
*
|
126 |
Â
* @param string $path
|
127 |
Â
*/
|
128 |
Â
public function pathExists($path)
|
129 |
Â
{
|
130 |
+
if ( ! is_dir($path)) {
|
131 |
Â
mkdir($path, 0775, true);
|
132 |
Â
} // end
|
133 |
+
}
|
Â
|
|
Â
|
|
Â
|
|
134 |
Â
|
135 |
Â
|
136 |
+
protected function arrayToCsv(array &$fields, $delimiter, $enclosure,
|
137 |
+
$encloseAll = false, $nullToMysqlNull = false
|
138 |
+
) {
|
139 |
+
$delimiterEsc = preg_quote($delimiter, '/');
|
140 |
+
$enclosureEsc = preg_quote($enclosure, '/');
|
141 |
Â
|
142 |
Â
$output = array();
|
143 |
+
foreach ($fields as $field) {
|
144 |
Â
if ($field === null && $nullToMysqlNull) {
|
145 |
Â
$output[] = 'NULL';
|
146 |
Â
continue;
|
147 |
Â
}
|
148 |
Â
|
149 |
Â
// Enclose fields containing $delimiter, $enclosure or whitespace
|
150 |
+
if ($encloseAll
|
151 |
+
|| preg_match(
|
152 |
+
"/(?:${delimiterEsc}|${enclosureEsc}|\s)/", $field
|
153 |
+
)
|
154 |
+
) {
|
155 |
+
$output[] = $enclosure . str_replace(
|
156 |
+
$enclosure, $enclosure . $enclosure, $field
|
157 |
+
) . $enclosure;
|
158 |
Â
} else {
|
159 |
Â
$output[] = $field;
|
160 |
Â
}
|
161 |
Â
}
|
162 |
Â
|
163 |
+
return implode($delimiter, $output) . "\n";
|
164 |
Â
}
|
165 |
Â
|
166 |
Â
/**
|
167 |
Â
* Delete file or directory
|
168 |
+
*
|
169 |
Â
* @param $path
|
170 |
+
*
|
171 |
Â
* @return bool
|
172 |
Â
*/
|
173 |
Â
public function deleteDir($path)
|
174 |
Â
{
|
175 |
Â
$class_func = array(__CLASS__, __FUNCTION__);
|
176 |
+
|
177 |
+
return is_file($path)
|
178 |
+
?
|
179 |
+
unlink($path)
|
180 |
+
:
|
181 |
+
array_map($class_func, glob($path . '/*')) == rmdir($path);
|
182 |
Â
}
|
183 |
Â
|
184 |
Â
|
185 |
Â
public function getWebsiteCustomerMappingDatafields($website)
|
186 |
Â
{
|
187 |
+
$store = $website->getDefaultStore();
|
188 |
+
$mappedData = Mage::getStoreConfig(
|
189 |
+
'connector_data_mapping/customer_data', $store
|
190 |
+
);
|
191 |
Â
unset($mappedData['custom_attributes']);
|
192 |
Â
unset($mappedData['abandoned_prod_name']);
|
193 |
Â
|
194 |
+
//enterprise datafields
|
195 |
+
if (Mage::helper('ddg')->isEnterprise()) {
|
196 |
Â
|
197 |
+
$enterpriseMapping = Mage::helper('ddg')->getEnterpriseAttributes(
|
198 |
+
$website
|
199 |
+
);
|
200 |
+
if ($enterpriseMapping) {
|
201 |
+
$mappedData = array_merge($mappedData, $enterpriseMapping);
|
202 |
+
}
|
203 |
+
}
|
204 |
Â
|
205 |
+
$mappedRewardData = $this->getWebsiteCustomerRewardMappingDatafields(
|
206 |
+
$website
|
207 |
+
);
|
208 |
+
if ($mappedRewardData) {
|
209 |
+
$mappedData = array_merge($mappedData, $mappedRewardData);
|
210 |
+
}
|
211 |
Â
|
212 |
Â
foreach ($mappedData as $key => $value) {
|
213 |
+
if ( ! $value) {
|
214 |
Â
unset($mappedData[$key]);
|
215 |
+
}
|
216 |
Â
}
|
217 |
Â
|
218 |
Â
return $mappedData;
|
221 |
Â
public function getWebsiteCustomerRewardMappingDatafields($website)
|
222 |
Â
{
|
223 |
Â
$helper = Mage::helper('ddg');
|
224 |
+
if ($helper->isSweetToothToGo($website)) {
|
225 |
+
$store = $website->getDefaultStore();
|
226 |
+
$mappedData = Mage::getStoreConfig(
|
227 |
+
'connector_data_mapping/sweet_tooth', $store
|
228 |
+
);
|
229 |
Â
unset($mappedData['active']);
|
230 |
+
|
231 |
Â
return $mappedData;
|
232 |
Â
}
|
233 |
+
|
234 |
Â
return false;
|
235 |
Â
}
|
236 |
Â
|
237 |
+
/**
|
238 |
+
* @param $path
|
239 |
+
*
|
240 |
+
* @return bool
|
241 |
+
*/
|
242 |
+
public function getPathPermission($path)
|
243 |
+
{
|
244 |
+
|
245 |
+
//check for directory created before looking into permission
|
246 |
+
if (is_dir($path)) {
|
247 |
+
clearstatcache(null, $path);
|
248 |
+
|
249 |
+
return decoct(fileperms($path) & 0777);
|
250 |
+
}
|
251 |
+
|
252 |
+
//the file is not created and return the passing value
|
253 |
+
return 755;
|
254 |
+
}
|
255 |
Â
}
|
@@ -2,32 +2,34 @@
|
|
2 |
Â
|
3 |
Â
class Dotdigitalgroup_Email_Helper_Recommended extends Mage_Core_Helper_Abstract
|
4 |
Â
{
|
5 |
-
|
6 |
-
const
|
7 |
-
const
|
8 |
-
const
|
9 |
-
const
|
10 |
-
const
|
11 |
-
const
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
const
|
16 |
-
const
|
17 |
-
const
|
18 |
-
const
|
Â
|
|
19 |
Â
const XML_PATH_RECENTLYVIEWED_PRODUCT_ITEMS = 'connector_dynamic_content/products/recently_viewed_items_to_display';
|
20 |
Â
|
21 |
-
const XML_PATH_PRODUCTPUSH_DISPLAY_ITEMS
|
22 |
-
const XML_PATH_BESTSELLER_TIME_PERIOD
|
23 |
-
const XML_PATH_MOSTVIEWED_TIME_PERIOD
|
24 |
-
const XML_PATH_PRODUCTPUSH_ITEMS
|
25 |
-
const XML_PATH_FALLBACK_PRODUCTS_ITEMS
|
26 |
Â
|
27 |
Â
public $periods = array('week', 'month', 'year');
|
28 |
Â
|
29 |
Â
/**
|
30 |
Â
* Dispay type
|
Â
|
|
31 |
Â
* @return mixed|string grid:list
|
32 |
Â
*/
|
33 |
Â
public function getDisplayType()
|
@@ -35,7 +37,7 @@ class Dotdigitalgroup_Email_Helper_Recommended extends Mage_Core_Helper_Abstract
|
|
35 |
Â
$mode = Mage::app()->getRequest()->getActionName();
|
36 |
Â
$type = '';
|
37 |
Â
|
38 |
-
switch($mode){
|
39 |
Â
case 'related':
|
40 |
Â
$type = $this->getRelatedProductsType();
|
41 |
Â
break;
|
@@ -52,7 +54,7 @@ class Dotdigitalgroup_Email_Helper_Recommended extends Mage_Core_Helper_Abstract
|
|
52 |
Â
$type = $this->getMostViewedProductsType();
|
53 |
Â
break;
|
54 |
Â
case 'recentlyviewed':
|
55 |
-
$type
|
56 |
Â
break;
|
57 |
Â
case 'push':
|
58 |
Â
$type = $this->getProductpushProductsType();
|
@@ -98,37 +100,52 @@ class Dotdigitalgroup_Email_Helper_Recommended extends Mage_Core_Helper_Abstract
|
|
98 |
Â
}
|
99 |
Â
|
100 |
Â
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
Â
|
|
108 |
Â
{
|
109 |
Â
$result = 0;
|
110 |
Â
|
111 |
-
switch($mode){
|
112 |
Â
case 'related':
|
113 |
-
$result = Mage::getStoreConfig(
|
Â
|
|
Â
|
|
114 |
Â
break;
|
115 |
Â
case 'upsell':
|
116 |
-
$result = Mage::getStoreConfig(
|
Â
|
|
Â
|
|
117 |
Â
break;
|
118 |
Â
case 'crosssell':
|
119 |
-
$result = Mage::getStoreConfig(
|
Â
|
|
Â
|
|
120 |
Â
break;
|
121 |
Â
case 'bestsellers':
|
122 |
-
$result = Mage::getStoreConfig(
|
Â
|
|
Â
|
|
123 |
Â
break;
|
124 |
Â
case 'mostviewed':
|
125 |
-
$result = Mage::getStoreConfig(
|
Â
|
|
Â
|
|
126 |
Â
break;
|
127 |
Â
case 'recentlyviewed':
|
128 |
-
$result = Mage::getStoreConfig(
|
Â
|
|
Â
|
|
129 |
Â
break;
|
130 |
Â
case 'push':
|
131 |
-
$result = Mage::getStoreConfig(
|
Â
|
|
Â
|
|
132 |
Â
}
|
133 |
Â
|
134 |
Â
return $result;
|
@@ -136,9 +153,16 @@ class Dotdigitalgroup_Email_Helper_Recommended extends Mage_Core_Helper_Abstract
|
|
136 |
Â
|
137 |
Â
public function getFallbackIds()
|
138 |
Â
{
|
139 |
-
$fallbackIds = Mage::getStoreConfig(
|
140 |
-
|
141 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
142 |
Â
return array();
|
143 |
Â
}
|
144 |
Â
|
@@ -146,12 +170,19 @@ class Dotdigitalgroup_Email_Helper_Recommended extends Mage_Core_Helper_Abstract
|
|
146 |
Â
{
|
147 |
Â
$now = new Zend_Date();
|
148 |
Â
$period = '';
|
149 |
-
if ($config == 'mostviewed')
|
150 |
-
$period = Mage::getStoreConfig(
|
151 |
-
|
152 |
-
|
153 |
-
}elseif($config == '
|
154 |
-
$period = Mage::getStoreConfig(
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
155 |
Â
|
156 |
Â
if ($period == 'week') {
|
157 |
Â
$sub = Zend_Date::WEEK;
|
2 |
Â
|
3 |
Â
class Dotdigitalgroup_Email_Helper_Recommended extends Mage_Core_Helper_Abstract
|
4 |
Â
{
|
5 |
+
|
6 |
+
const XML_PATH_RELATED_PRODUCTS_TYPE = 'connector_dynamic_content/products/related_display_type';
|
7 |
+
const XML_PATH_UPSELL_PRODUCTS_TYPE = 'connector_dynamic_content/products/upsell_display_type';
|
8 |
+
const XML_PATH_CROSSSELL_PRODUCTS_TYPE = 'connector_dynamic_content/products/crosssell_display_type';
|
9 |
+
const XML_PATH_BESTSELLER_PRODUCT_TYPE = 'connector_dynamic_content/products/bestsellers_display_type';
|
10 |
+
const XML_PATH_MOSTVIEWED_PRODUCT_TYPE = 'connector_dynamic_content/products/most_viewed_display_type';
|
11 |
+
const XML_PATH_RECENTLYVIEWED_PRODUCT_TYPE = 'connector_dynamic_content/products/recently_viewed_display_type';
|
12 |
+
const XML_PATH_PRODUCTPUSH_TYPE = 'connector_dynamic_content/manual_product_search/display_type';
|
13 |
+
|
14 |
+
|
15 |
+
const XML_PATH_RELATED_PRODUCTS_ITEMS = 'connector_dynamic_content/products/related_items_to_display';
|
16 |
+
const XML_PATH_UPSELL_PRODUCTS_ITEMS = 'connector_dynamic_content/products/upsell_items_to_display';
|
17 |
+
const XML_PATH_CROSSSELL_PRODUCTS_ITEMS = 'connector_dynamic_content/products/crosssell_items_to_display';
|
18 |
+
const XML_PATH_BESTSELLER_PRODUCT_ITEMS = 'connector_dynamic_content/products/bestsellers_items_to_display';
|
19 |
+
const XML_PATH_MOSTVIEWED_PRODUCT_ITEMS = 'connector_dynamic_content/products/most_viewed_items_to_display';
|
20 |
Â
const XML_PATH_RECENTLYVIEWED_PRODUCT_ITEMS = 'connector_dynamic_content/products/recently_viewed_items_to_display';
|
21 |
Â
|
22 |
+
const XML_PATH_PRODUCTPUSH_DISPLAY_ITEMS = 'connector_dynamic_content/manual_product_search/items_to_display';
|
23 |
+
const XML_PATH_BESTSELLER_TIME_PERIOD = 'connector_dynamic_content/products/bestsellers_time_period';
|
24 |
+
const XML_PATH_MOSTVIEWED_TIME_PERIOD = 'connector_dynamic_content/products/most_viewed_time_period';
|
25 |
+
const XML_PATH_PRODUCTPUSH_ITEMS = 'connector_dynamic_content/manual_product_search/products_push_items';
|
26 |
+
const XML_PATH_FALLBACK_PRODUCTS_ITEMS = 'connector_dynamic_content/fallback_products/product_list';
|
27 |
Â
|
28 |
Â
public $periods = array('week', 'month', 'year');
|
29 |
Â
|
30 |
Â
/**
|
31 |
Â
* Dispay type
|
32 |
+
*
|
33 |
Â
* @return mixed|string grid:list
|
34 |
Â
*/
|
35 |
Â
public function getDisplayType()
|
37 |
Â
$mode = Mage::app()->getRequest()->getActionName();
|
38 |
Â
$type = '';
|
39 |
Â
|
40 |
+
switch ($mode) {
|
41 |
Â
case 'related':
|
42 |
Â
$type = $this->getRelatedProductsType();
|
43 |
Â
break;
|
54 |
Â
$type = $this->getMostViewedProductsType();
|
55 |
Â
break;
|
56 |
Â
case 'recentlyviewed':
|
57 |
+
$type = $this->getRecentlyviewedProductsType();
|
58 |
Â
break;
|
59 |
Â
case 'push':
|
60 |
Â
$type = $this->getProductpushProductsType();
|
100 |
Â
}
|
101 |
Â
|
102 |
Â
|
103 |
+
/**
|
104 |
+
* Limit of products displayed.
|
105 |
+
*
|
106 |
+
* @param $mode
|
107 |
+
*
|
108 |
+
* @return int|mixed
|
109 |
+
*/
|
110 |
+
public function getDisplayLimitByMode($mode)
|
111 |
Â
{
|
112 |
Â
$result = 0;
|
113 |
Â
|
114 |
+
switch ($mode) {
|
115 |
Â
case 'related':
|
116 |
+
$result = Mage::getStoreConfig(
|
117 |
+
self::XML_PATH_RELATED_PRODUCTS_ITEMS
|
118 |
+
);
|
119 |
Â
break;
|
120 |
Â
case 'upsell':
|
121 |
+
$result = Mage::getStoreConfig(
|
122 |
+
self::XML_PATH_UPSELL_PRODUCTS_ITEMS
|
123 |
+
);
|
124 |
Â
break;
|
125 |
Â
case 'crosssell':
|
126 |
+
$result = Mage::getStoreConfig(
|
127 |
+
self::XML_PATH_CROSSSELL_PRODUCTS_ITEMS
|
128 |
+
);
|
129 |
Â
break;
|
130 |
Â
case 'bestsellers':
|
131 |
+
$result = Mage::getStoreConfig(
|
132 |
+
self::XML_PATH_BESTSELLER_PRODUCT_ITEMS
|
133 |
+
);
|
134 |
Â
break;
|
135 |
Â
case 'mostviewed':
|
136 |
+
$result = Mage::getStoreConfig(
|
137 |
+
self::XML_PATH_MOSTVIEWED_PRODUCT_ITEMS
|
138 |
+
);
|
139 |
Â
break;
|
140 |
Â
case 'recentlyviewed':
|
141 |
+
$result = Mage::getStoreConfig(
|
142 |
+
self::XML_PATH_RECENTLYVIEWED_PRODUCT_ITEMS
|
143 |
+
);
|
144 |
Â
break;
|
145 |
Â
case 'push':
|
146 |
+
$result = Mage::getStoreConfig(
|
147 |
+
self::XML_PATH_PRODUCTPUSH_DISPLAY_ITEMS
|
148 |
+
);
|
149 |
Â
}
|
150 |
Â
|
151 |
Â
return $result;
|
153 |
Â
|
154 |
Â
public function getFallbackIds()
|
155 |
Â
{
|
156 |
+
$fallbackIds = Mage::getStoreConfig(
|
157 |
+
self::XML_PATH_FALLBACK_PRODUCTS_ITEMS
|
158 |
+
);
|
159 |
+
if ($fallbackIds) {
|
160 |
+
return explode(
|
161 |
+
',',
|
162 |
+
Mage::getStoreConfig(self::XML_PATH_FALLBACK_PRODUCTS_ITEMS)
|
163 |
+
);
|
164 |
+
}
|
165 |
+
|
166 |
Â
return array();
|
167 |
Â
}
|
168 |
Â
|
170 |
Â
{
|
171 |
Â
$now = new Zend_Date();
|
172 |
Â
$period = '';
|
173 |
+
if ($config == 'mostviewed') {
|
174 |
+
$period = Mage::getStoreConfig(
|
175 |
+
self::XML_PATH_MOSTVIEWED_TIME_PERIOD
|
176 |
+
);
|
177 |
+
} elseif ($config == 'bestsellers') {
|
178 |
+
$period = Mage::getStoreConfig(
|
179 |
+
self::XML_PATH_BESTSELLER_TIME_PERIOD
|
180 |
+
);
|
181 |
+
} elseif ($config == 'recentlyviewed') {
|
182 |
+
$period = Mage::getStoreConfig(
|
183 |
+
self::XML_PATH_MOSTVIEWED_TIME_PERIOD
|
184 |
+
);
|
185 |
+
}
|
186 |
Â
|
187 |
Â
if ($period == 'week') {
|
188 |
Â
$sub = Zend_Date::WEEK;
|
@@ -1,20 +1,25 @@
|
|
1 |
Â
<?php
|
2 |
-
|
Â
|
|
Â
|
|
3 |
Â
{
|
4 |
Â
|
5 |
-
const XML_PATH_DDG_TRANSACTIONAL_ENABLED
|
6 |
-
const XML_PATH_DDG_TRANSACTIONAL_HOST
|
7 |
-
const XML_PATH_DDG_TRANSACTIONAL_USERNAME
|
8 |
-
const XML_PATH_DDG_TRANSACTIONAL_PASSWORD
|
9 |
-
const XML_PATH_DDG_TRANSACTIONAL_PORT
|
10 |
-
const XML_PATH_DDG_TRANSACTIONAL_DEBUG
|
11 |
Â
|
12 |
Â
|
13 |
Â
public function isEnabled()
|
14 |
Â
{
|
15 |
-
return Mage::getStoreConfigFlag(
|
Â
|
|
Â
|
|
16 |
Â
|
17 |
Â
}
|
Â
|
|
18 |
Â
public function getSmtpHost()
|
19 |
Â
{
|
20 |
Â
|
@@ -49,17 +54,21 @@ class Dotdigitalgroup_Email_Helper_Transactional extends Mage_Core_Helper_Abstra
|
|
49 |
Â
public function getTransport()
|
50 |
Â
{
|
51 |
Â
$config = array(
|
52 |
-
'port'
|
53 |
Â
'auth' => 'login',
|
54 |
Â
'username' => $this->getSmtpUsername(),
|
55 |
Â
'password' => $this->getSmtpPassword(),
|
56 |
Â
'ssl' => 'tls'
|
57 |
Â
);
|
58 |
Â
|
59 |
-
if ($this->isDebugEnabled())
|
60 |
-
Mage::log('Mail transport config : '. implode(',', $config));
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
61 |
Â
|
62 |
-
$transport = new Zend_Mail_Transport_Smtp($this->getSmtpHost(), $config);
|
63 |
Â
return $transport;
|
64 |
Â
}
|
65 |
Â
}
|
1 |
Â
<?php
|
2 |
+
|
3 |
+
class Dotdigitalgroup_Email_Helper_Transactional
|
4 |
+
extends Mage_Core_Helper_Abstract
|
5 |
Â
{
|
6 |
Â
|
7 |
+
const XML_PATH_DDG_TRANSACTIONAL_ENABLED = 'connector_transactional_emails/ddg_transactional/enabled';
|
8 |
+
const XML_PATH_DDG_TRANSACTIONAL_HOST = 'connector_transactional_emails/ddg_transactional/host';
|
9 |
+
const XML_PATH_DDG_TRANSACTIONAL_USERNAME = 'connector_transactional_emails/ddg_transactional/username';
|
10 |
+
const XML_PATH_DDG_TRANSACTIONAL_PASSWORD = 'connector_transactional_emails/ddg_transactional/password';
|
11 |
+
const XML_PATH_DDG_TRANSACTIONAL_PORT = 'connector_transactional_emails/ddg_transactional/port';
|
12 |
+
const XML_PATH_DDG_TRANSACTIONAL_DEBUG = 'connector_transactional_emails/ddg_transactional/debug';
|
13 |
Â
|
14 |
Â
|
15 |
Â
public function isEnabled()
|
16 |
Â
{
|
17 |
+
return Mage::getStoreConfigFlag(
|
18 |
+
self::XML_PATH_DDG_TRANSACTIONAL_ENABLED
|
19 |
+
);
|
20 |
Â
|
21 |
Â
}
|
22 |
+
|
23 |
Â
public function getSmtpHost()
|
24 |
Â
{
|
25 |
Â
|
54 |
Â
public function getTransport()
|
55 |
Â
{
|
56 |
Â
$config = array(
|
57 |
+
'port' => $this->getSmtpPort(),
|
58 |
Â
'auth' => 'login',
|
59 |
Â
'username' => $this->getSmtpUsername(),
|
60 |
Â
'password' => $this->getSmtpPassword(),
|
61 |
Â
'ssl' => 'tls'
|
62 |
Â
);
|
63 |
Â
|
64 |
+
if ($this->isDebugEnabled()) {
|
65 |
+
Mage::log('Mail transport config : ' . implode(',', $config));
|
66 |
+
}
|
67 |
+
|
68 |
+
$transport = new Zend_Mail_Transport_Smtp(
|
69 |
+
$this->getSmtpHost(), $config
|
70 |
+
);
|
71 |
Â
|
Â
|
|
72 |
Â
return $transport;
|
73 |
Â
}
|
74 |
Â
}
|
@@ -2,29 +2,34 @@
|
|
2 |
Â
|
3 |
Â
abstract class Dotdigitalgroup_Email_Model_Abstract_Rest
|
4 |
Â
{
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
Â
|
|
9 |
Â
protected $_apiUsername;
|
10 |
Â
protected $_apiPassword;
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
public function __construct($website = 0
|
18 |
-
{
|
19 |
-
$this->url
|
20 |
-
$this->verb
|
21 |
-
$this->requestBody
|
22 |
-
$this->requestLength
|
23 |
-
$this->_apiUsername
|
24 |
-
|
25 |
-
|
26 |
-
$this->
|
27 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
28 |
Â
|
29 |
Â
if ($this->requestBody !== null) {
|
30 |
Â
$this->buildPostBody();
|
@@ -33,69 +38,74 @@ abstract class Dotdigitalgroup_Email_Model_Abstract_Rest
|
|
33 |
Â
|
34 |
Â
protected function prettyPrint($json)
|
35 |
Â
{
|
36 |
-
$result
|
37 |
-
$level
|
38 |
-
$
|
39 |
-
$
|
40 |
-
$
|
41 |
-
$
|
42 |
-
|
43 |
-
for ($i = 0; $i < $
|
44 |
-
$char
|
45 |
-
$
|
46 |
-
$post
|
47 |
-
if ($
|
48 |
-
$
|
49 |
-
$
|
50 |
Â
}
|
51 |
-
if ($char === '"' && $
|
52 |
-
$
|
53 |
-
} elseif (! $
|
54 |
Â
switch ($char) {
|
55 |
-
case '}':
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
Â
|
|
60 |
Â
|
61 |
-
case '{':
|
62 |
-
|
Â
|
|
63 |
Â
case ',':
|
64 |
-
$
|
65 |
Â
break;
|
66 |
Â
|
67 |
Â
case ':':
|
68 |
Â
$post = " ";
|
69 |
Â
break;
|
70 |
Â
|
71 |
-
case " ":
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
Â
|
|
Â
|
|
Â
|
|
76 |
Â
}
|
77 |
Â
}
|
78 |
-
if ($
|
79 |
-
$result .= "\n".str_repeat(
|
80 |
Â
}
|
81 |
-
$result .= $char
|
82 |
-
$
|
83 |
Â
}
|
84 |
Â
|
85 |
Â
return $result;
|
86 |
Â
}
|
87 |
Â
|
88 |
Â
/**
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
public function toJSON($pretty=false)
|
96 |
Â
{
|
97 |
Â
|
98 |
-
if (
|
99 |
Â
return json_encode($this->expose());
|
100 |
Â
} else {
|
101 |
Â
return $this->prettyPrint(json_encode($this->expose()));
|
@@ -103,9 +113,10 @@ abstract class Dotdigitalgroup_Email_Model_Abstract_Rest
|
|
103 |
Â
}
|
104 |
Â
|
105 |
Â
/**
|
106 |
-
|
107 |
-
|
108 |
-
|
Â
|
|
109 |
Â
public function expose()
|
110 |
Â
{
|
111 |
Â
|
@@ -115,36 +126,35 @@ abstract class Dotdigitalgroup_Email_Model_Abstract_Rest
|
|
115 |
Â
|
116 |
Â
|
117 |
Â
/**
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
public function flush
|
123 |
Â
{
|
124 |
-
$this->_apiUsername
|
125 |
-
$this->_apiPassword
|
126 |
-
$this->requestBody
|
127 |
-
$this->requestLength
|
128 |
-
$this->verb
|
129 |
-
$this->responseBody
|
130 |
-
$this->responseInfo
|
Â
|
|
131 |
Â
return $this;
|
132 |
Â
}
|
133 |
Â
|
134 |
Â
/**
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
Â
public function execute()
|
141 |
Â
{
|
142 |
Â
$ch = curl_init();
|
143 |
Â
$this->setAuth($ch);
|
144 |
-
try
|
145 |
-
|
146 |
-
switch (strtoupper($this->verb))
|
147 |
-
{
|
148 |
Â
case 'GET':
|
149 |
Â
$this->executeGet($ch);
|
150 |
Â
break;
|
@@ -158,72 +168,76 @@ abstract class Dotdigitalgroup_Email_Model_Abstract_Rest
|
|
158 |
Â
$this->executeDelete($ch);
|
159 |
Â
break;
|
160 |
Â
default:
|
161 |
-
throw new InvalidArgumentException(
|
Â
|
|
Â
|
|
Â
|
|
162 |
Â
}
|
163 |
-
}catch (InvalidArgumentException $e){
|
164 |
Â
curl_close($ch);
|
165 |
Â
throw $e;
|
166 |
-
}catch (Exception $e){
|
167 |
Â
curl_close($ch);
|
168 |
Â
throw $e;
|
169 |
Â
}
|
170 |
Â
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
Â
}
|
195 |
Â
|
196 |
Â
/**
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
Â
public function buildPostBody($data = null)
|
204 |
Â
{
|
205 |
Â
$this->requestBody = json_encode($data);
|
Â
|
|
206 |
Â
return $this;
|
207 |
Â
}
|
208 |
Â
|
209 |
Â
/**
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
Â
protected function executeGet($ch)
|
215 |
Â
{
|
216 |
Â
$this->doExecute($ch);
|
217 |
Â
}
|
218 |
Â
|
219 |
Â
/**
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
Â
protected function executePost($ch)
|
225 |
Â
{
|
226 |
-
if (!is_string($this->requestBody)) {
|
227 |
Â
$this->buildPostBody();
|
228 |
Â
}
|
229 |
Â
|
@@ -233,26 +247,26 @@ abstract class Dotdigitalgroup_Email_Model_Abstract_Rest
|
|
233 |
Â
$this->doExecute($ch);
|
234 |
Â
}
|
235 |
Â
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
$this->requestBody = array
|
244 |
-
'file' => '@'
|
245 |
Â
);
|
246 |
Â
}
|
247 |
Â
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
Â
{
|
255 |
-
if (!is_string($this->requestBody)) {
|
256 |
Â
$this->buildPostBody();
|
257 |
Â
}
|
258 |
Â
|
@@ -271,37 +285,37 @@ abstract class Dotdigitalgroup_Email_Model_Abstract_Rest
|
|
271 |
Â
fclose($fh);
|
272 |
Â
}
|
273 |
Â
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
Â
{
|
281 |
Â
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'DELETE');
|
282 |
Â
|
283 |
Â
$this->doExecute($ch);
|
284 |
Â
}
|
285 |
Â
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
Â
{
|
293 |
Â
$this->setCurlOpts($ch);
|
294 |
Â
|
295 |
-
if($this->isNotJson)
|
296 |
Â
$this->responseBody = curl_exec($ch);
|
297 |
-
else
|
298 |
Â
$this->responseBody = json_decode(curl_exec($ch));
|
Â
|
|
299 |
Â
|
300 |
-
$this->responseInfo
|
301 |
Â
|
302 |
Â
//if curl error found
|
303 |
-
if(curl_errno($ch))
|
304 |
-
{
|
305 |
Â
//save the error
|
306 |
Â
$this->curlError = curl_error($ch);
|
307 |
Â
}
|
@@ -309,172 +323,183 @@ abstract class Dotdigitalgroup_Email_Model_Abstract_Rest
|
|
309 |
Â
curl_close($ch);
|
310 |
Â
}
|
311 |
Â
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
Â
{
|
319 |
Â
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
|
320 |
Â
curl_setopt($ch, CURLOPT_URL, $this->url);
|
321 |
Â
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
322 |
Â
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
|
323 |
Â
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
|
324 |
-
curl_setopt(
|
Â
|
|
Â
|
|
Â
|
|
325 |
Â
}
|
326 |
Â
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
Â
{
|
334 |
-
if ($this->_apiUsername !== null && $this->_apiPassword !== null)
|
335 |
-
{
|
336 |
Â
curl_setopt($ch, CURLAUTH_BASIC, CURLAUTH_DIGEST);
|
337 |
-
curl_setopt(
|
Â
|
|
Â
|
|
Â
|
|
338 |
Â
}
|
339 |
Â
}
|
340 |
Â
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
Â
{
|
348 |
Â
return $this->acceptType;
|
349 |
Â
}
|
350 |
Â
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
Â
{
|
358 |
Â
$this->acceptType = $acceptType;
|
359 |
Â
}
|
360 |
Â
|
361 |
Â
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
|
Â
|
|
Â
|
|
390 |
Â
{
|
391 |
Â
return $this->_apiPassword;
|
392 |
Â
}
|
393 |
Â
|
394 |
-
|
395 |
-
|
396 |
-
|
397 |
-
|
398 |
-
|
399 |
-
|
400 |
-
|
Â
|
|
401 |
Â
{
|
402 |
Â
$this->_apiPassword = $apiPassword;
|
Â
|
|
403 |
Â
return $this;
|
404 |
Â
}
|
405 |
Â
|
406 |
-
|
407 |
-
|
408 |
-
|
409 |
-
|
410 |
-
|
411 |
-
|
412 |
Â
{
|
413 |
Â
return $this->responseBody;
|
414 |
Â
}
|
415 |
Â
|
416 |
-
|
417 |
-
|
418 |
-
|
419 |
-
|
420 |
-
|
421 |
-
|
422 |
Â
{
|
423 |
Â
return $this->responseInfo;
|
424 |
Â
}
|
425 |
Â
|
426 |
-
|
427 |
-
|
428 |
-
|
429 |
-
|
430 |
-
|
431 |
-
|
432 |
Â
{
|
433 |
Â
return $this->url;
|
434 |
Â
}
|
435 |
Â
|
436 |
-
|
437 |
-
|
438 |
-
|
439 |
-
|
440 |
-
|
441 |
-
|
442 |
-
|
443 |
-
|
444 |
Â
{
|
445 |
Â
$this->url = $url;
|
Â
|
|
446 |
Â
return $this;
|
447 |
Â
}
|
448 |
Â
|
449 |
-
|
450 |
-
|
451 |
-
|
452 |
-
|
453 |
-
|
454 |
-
|
455 |
Â
{
|
456 |
Â
return $this->verb;
|
457 |
Â
}
|
458 |
Â
|
459 |
-
|
460 |
-
|
461 |
-
|
462 |
-
|
463 |
-
|
464 |
-
|
465 |
-
|
466 |
-
|
467 |
Â
{
|
468 |
Â
$this->verb = $verb;
|
Â
|
|
469 |
Â
return $this;
|
470 |
Â
}
|
471 |
Â
|
472 |
Â
public function getCurlError()
|
473 |
Â
{
|
474 |
Â
//if curl error
|
475 |
-
if(!empty($this->curlError)){
|
476 |
Â
//log curl error
|
477 |
-
$message = 'CURL ERROR '. $this->curlError;
|
478 |
Â
Mage::helper('ddg')->log($message)
|
479 |
Â
->rayLog($message, 'apiconnector/rest.php', __LINE__);
|
480 |
Â
|
@@ -487,6 +512,7 @@ abstract class Dotdigitalgroup_Email_Model_Abstract_Rest
|
|
487 |
Â
public function setIsNotJsonTrue()
|
488 |
Â
{
|
489 |
Â
$this->isNotJson = true;
|
Â
|
|
490 |
Â
return $this;
|
491 |
Â
}
|
492 |
Â
}
|
2 |
Â
|
3 |
Â
abstract class Dotdigitalgroup_Email_Model_Abstract_Rest
|
4 |
Â
{
|
5 |
+
|
6 |
+
public $url;
|
7 |
+
public $verb;
|
8 |
+
public $requestBody;
|
9 |
+
public $requestLength;
|
10 |
Â
protected $_apiUsername;
|
11 |
Â
protected $_apiPassword;
|
12 |
+
public $acceptType;
|
13 |
+
public $responseBody;
|
14 |
+
public $responseInfo;
|
15 |
+
public $curlError;
|
16 |
+
public $isNotJson = false;
|
17 |
+
|
18 |
+
public function __construct($website = 0
|
19 |
+
) {
|
20 |
+
$this->url = null; //$url;
|
21 |
+
$this->verb = 'GET'; //$verb;
|
22 |
+
$this->requestBody = null; //$requestBody;
|
23 |
+
$this->requestLength = 0;
|
24 |
+
$this->_apiUsername = (string)Mage::helper('ddg')->getApiUsername(
|
25 |
+
$website
|
26 |
+
);
|
27 |
+
$this->_apiPassword = (string)Mage::helper('ddg')->getApiPassword(
|
28 |
+
$website
|
29 |
+
);
|
30 |
+
$this->acceptType = 'application/json';
|
31 |
+
$this->responseBody = null;
|
32 |
+
$this->responseInfo = null;
|
33 |
Â
|
34 |
Â
if ($this->requestBody !== null) {
|
35 |
Â
$this->buildPostBody();
|
38 |
Â
|
39 |
Â
protected function prettyPrint($json)
|
40 |
Â
{
|
41 |
+
$result = '';
|
42 |
+
$level = 0;
|
43 |
+
$prevChar = '';
|
44 |
+
$inQuotes = false;
|
45 |
+
$endsLineLevel = null;
|
46 |
+
$jsonLength = strlen($json);
|
47 |
+
|
48 |
+
for ($i = 0; $i < $jsonLength; $i++) {
|
49 |
+
$char = $json[$i];
|
50 |
+
$newLineLevel = null;
|
51 |
+
$post = "";
|
52 |
+
if ($endsLineLevel !== null) {
|
53 |
+
$newLineLevel = $endsLineLevel;
|
54 |
+
$endsLineLevel = null;
|
55 |
Â
}
|
56 |
+
if ($char === '"' && $prevChar != '\\') {
|
57 |
+
$inQuotes = ! $inQuotes;
|
58 |
+
} elseif ( ! $inQuotes) {
|
59 |
Â
switch ($char) {
|
60 |
+
case '}':
|
61 |
+
case ']':
|
62 |
+
$level--;
|
63 |
+
$endsLineLevel = null;
|
64 |
+
$newLineLevel = $level;
|
65 |
+
break;
|
66 |
Â
|
67 |
+
case '{':
|
68 |
+
case '[':
|
69 |
+
$level++;
|
70 |
Â
case ',':
|
71 |
+
$endsLineLevel = $level;
|
72 |
Â
break;
|
73 |
Â
|
74 |
Â
case ':':
|
75 |
Â
$post = " ";
|
76 |
Â
break;
|
77 |
Â
|
78 |
+
case " ":
|
79 |
+
case "\t":
|
80 |
+
case "\n":
|
81 |
+
case "\r":
|
82 |
+
$char = "";
|
83 |
+
$endsLineLevel = $newLineLevel;
|
84 |
+
$newLineLevel = null;
|
85 |
+
break;
|
86 |
Â
}
|
87 |
Â
}
|
88 |
+
if ($newLineLevel !== null) {
|
89 |
+
$result .= "\n" . str_repeat("\t", $newLineLevel);
|
90 |
Â
}
|
91 |
+
$result .= $char . $post;
|
92 |
+
$prevChar = $char;
|
93 |
Â
}
|
94 |
Â
|
95 |
Â
return $result;
|
96 |
Â
}
|
97 |
Â
|
98 |
Â
/**
|
99 |
+
* returns the object as JSON.
|
100 |
+
*
|
101 |
+
* @param bool $pretty
|
102 |
+
*
|
103 |
+
* @return string
|
104 |
+
*/
|
105 |
+
public function toJSON($pretty = false)
|
106 |
Â
{
|
107 |
Â
|
108 |
+
if ( ! $pretty) {
|
109 |
Â
return json_encode($this->expose());
|
110 |
Â
} else {
|
111 |
Â
return $this->prettyPrint(json_encode($this->expose()));
|
113 |
Â
}
|
114 |
Â
|
115 |
Â
/**
|
116 |
+
* exposes the class as an array of objects
|
117 |
+
*
|
118 |
+
* @return array
|
119 |
+
*/
|
120 |
Â
public function expose()
|
121 |
Â
{
|
122 |
Â
|
126 |
Â
|
127 |
Â
|
128 |
Â
/**
|
129 |
+
* Reset the client.
|
130 |
+
*
|
131 |
+
* @return $this
|
132 |
+
*/
|
133 |
+
public function flush()
|
134 |
Â
{
|
135 |
+
$this->_apiUsername = '';
|
136 |
+
$this->_apiPassword = '';
|
137 |
+
$this->requestBody = null;
|
138 |
+
$this->requestLength = 0;
|
139 |
+
$this->verb = 'GET';
|
140 |
+
$this->responseBody = null;
|
141 |
+
$this->responseInfo = null;
|
142 |
+
|
143 |
Â
return $this;
|
144 |
Â
}
|
145 |
Â
|
146 |
Â
/**
|
147 |
+
* Execute the curl request.
|
148 |
+
*
|
149 |
+
* @return null
|
150 |
+
* @throws Exception
|
151 |
+
*/
|
152 |
Â
public function execute()
|
153 |
Â
{
|
154 |
Â
$ch = curl_init();
|
155 |
Â
$this->setAuth($ch);
|
156 |
+
try {
|
157 |
+
switch (strtoupper($this->verb)) {
|
Â
|
|
Â
|
|
158 |
Â
case 'GET':
|
159 |
Â
$this->executeGet($ch);
|
160 |
Â
break;
|
168 |
Â
$this->executeDelete($ch);
|
169 |
Â
break;
|
170 |
Â
default:
|
171 |
+
throw new InvalidArgumentException(
|
172 |
+
'Current verb (' . $this->verb
|
173 |
+
. ') is an invalid REST verb.'
|
174 |
+
);
|
175 |
Â
}
|
176 |
+
} catch (InvalidArgumentException $e) {
|
177 |
Â
curl_close($ch);
|
178 |
Â
throw $e;
|
179 |
+
} catch (Exception $e) {
|
180 |
Â
curl_close($ch);
|
181 |
Â
throw $e;
|
182 |
Â
}
|
183 |
Â
|
184 |
+
/**
|
185 |
+
* check and debug api request total time
|
186 |
+
*/
|
187 |
+
if (Mage::helper('ddg')->getDebugEnabled()) {
|
188 |
+
$info = $this->getResponseInfo();
|
189 |
+
//the response info data is set
|
190 |
+
if (isset($info['url']) && isset($info['total_time'])) {
|
191 |
+
$url = $info['url'];
|
192 |
+
$time = $info['total_time'];
|
193 |
+
$totalTime = sprintf(' time : %g sec', $time);
|
194 |
+
$check = Mage::helper('ddg')->getApiResponseTimeLimit();
|
195 |
+
$limit = ($check) ? $check : '2';
|
196 |
+
$message = $this->verb . ', ' . $url . $totalTime;
|
197 |
+
//check for slow queries
|
198 |
+
if ($time > $limit) {
|
199 |
+
//log the slow queries
|
200 |
+
Mage::helper('ddg')->log($message)
|
201 |
+
->rayLog($message);
|
202 |
+
}
|
203 |
+
}
|
204 |
+
}
|
205 |
+
|
206 |
+
return $this->responseBody;
|
207 |
Â
}
|
208 |
Â
|
209 |
Â
/**
|
210 |
+
* Post data.
|
211 |
+
*
|
212 |
+
* @param null $data
|
213 |
+
*
|
214 |
+
* @return $this
|
215 |
+
*/
|
216 |
Â
public function buildPostBody($data = null)
|
217 |
Â
{
|
218 |
Â
$this->requestBody = json_encode($data);
|
219 |
+
|
220 |
Â
return $this;
|
221 |
Â
}
|
222 |
Â
|
223 |
Â
/**
|
224 |
+
* Execute curl get request.
|
225 |
+
*
|
226 |
+
* @param $ch
|
227 |
+
*/
|
228 |
Â
protected function executeGet($ch)
|
229 |
Â
{
|
230 |
Â
$this->doExecute($ch);
|
231 |
Â
}
|
232 |
Â
|
233 |
Â
/**
|
234 |
+
* Execute post request.
|
235 |
+
*
|
236 |
+
* @param $ch
|
237 |
+
*/
|
238 |
Â
protected function executePost($ch)
|
239 |
Â
{
|
240 |
+
if ( ! is_string($this->requestBody)) {
|
241 |
Â
$this->buildPostBody();
|
242 |
Â
}
|
243 |
Â
|
247 |
Â
$this->doExecute($ch);
|
248 |
Â
}
|
249 |
Â
|
250 |
+
/**
|
251 |
+
* Post from the file.
|
252 |
+
*
|
253 |
+
* @param $filename
|
254 |
+
*/
|
255 |
+
protected function buildPostBodyFromFile($filename)
|
256 |
+
{
|
257 |
+
$this->requestBody = array(
|
258 |
+
'file' => '@' . $filename
|
259 |
Â
);
|
260 |
Â
}
|
261 |
Â
|
262 |
+
/**
|
263 |
+
* Execute put.
|
264 |
+
*
|
265 |
+
* @param $ch
|
266 |
+
*/
|
267 |
+
protected function executePut($ch)
|
268 |
Â
{
|
269 |
+
if ( ! is_string($this->requestBody)) {
|
270 |
Â
$this->buildPostBody();
|
271 |
Â
}
|
272 |
Â
|
285 |
Â
fclose($fh);
|
286 |
Â
}
|
287 |
Â
|
288 |
+
/**
|
289 |
+
* Ececute delete.
|
290 |
+
*
|
291 |
+
* @param $ch
|
292 |
+
*/
|
293 |
+
protected function executeDelete($ch)
|
294 |
Â
{
|
295 |
Â
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'DELETE');
|
296 |
Â
|
297 |
Â
$this->doExecute($ch);
|
298 |
Â
}
|
299 |
Â
|
300 |
+
/**
|
301 |
+
* Execute request.
|
302 |
+
*
|
303 |
+
* @param $ch
|
304 |
+
*/
|
305 |
+
protected function doExecute(&$ch)
|
306 |
Â
{
|
307 |
Â
$this->setCurlOpts($ch);
|
308 |
Â
|
309 |
+
if ($this->isNotJson) {
|
310 |
Â
$this->responseBody = curl_exec($ch);
|
311 |
+
} else {
|
312 |
Â
$this->responseBody = json_decode(curl_exec($ch));
|
313 |
+
}
|
314 |
Â
|
315 |
+
$this->responseInfo = curl_getinfo($ch);
|
316 |
Â
|
317 |
Â
//if curl error found
|
318 |
+
if (curl_errno($ch)) {
|
Â
|
|
319 |
Â
//save the error
|
320 |
Â
$this->curlError = curl_error($ch);
|
321 |
Â
}
|
323 |
Â
curl_close($ch);
|
324 |
Â
}
|
325 |
Â
|
326 |
+
/**
|
327 |
+
* curl options.
|
328 |
+
*
|
329 |
+
* @param $ch
|
330 |
+
*/
|
331 |
+
protected function setCurlOpts(&$ch)
|
332 |
Â
{
|
333 |
Â
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
|
334 |
Â
curl_setopt($ch, CURLOPT_URL, $this->url);
|
335 |
Â
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
336 |
Â
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
|
337 |
Â
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
|
338 |
+
curl_setopt(
|
339 |
+
$ch, CURLOPT_HTTPHEADER, array('Accept: ' . $this->acceptType,
|
340 |
+
'Content-Type: application/json')
|
341 |
+
);
|
342 |
Â
}
|
343 |
Â
|
344 |
+
/**
|
345 |
+
* basic auth.
|
346 |
+
*
|
347 |
+
* @param $ch
|
348 |
+
*/
|
349 |
+
protected function setAuth(&$ch)
|
350 |
Â
{
|
351 |
+
if ($this->_apiUsername !== null && $this->_apiPassword !== null) {
|
Â
|
|
352 |
Â
curl_setopt($ch, CURLAUTH_BASIC, CURLAUTH_DIGEST);
|
353 |
+
curl_setopt(
|
354 |
+
$ch, CURLOPT_USERPWD,
|
355 |
+
$this->_apiUsername . ':' . $this->_apiPassword
|
356 |
+
);
|
357 |
Â
}
|
358 |
Â
}
|
359 |
Â
|
360 |
+
/**
|
361 |
+
* Get accept type.
|
362 |
+
*
|
363 |
+
* @return string
|
364 |
+
*/
|
365 |
+
public function getAcceptType()
|
366 |
Â
{
|
367 |
Â
return $this->acceptType;
|
368 |
Â
}
|
369 |
Â
|
370 |
+
/**
|
371 |
+
* set accept type.
|
372 |
+
*
|
373 |
+
* @param $acceptType
|
374 |
+
*/
|
375 |
+
public function setAcceptType($acceptType)
|
376 |
Â
{
|
377 |
Â
$this->acceptType = $acceptType;
|
378 |
Â
}
|
379 |
Â
|
380 |
Â
|
381 |
+
/**
|
382 |
+
* get api username.
|
383 |
+
*
|
384 |
+
* @return string
|
385 |
+
*/
|
386 |
+
public function getApiUsername()
|
387 |
+
{
|
388 |
+
return $this->_apiUsername;
|
389 |
+
}
|
390 |
+
|
391 |
+
/**
|
392 |
+
* set api username.
|
393 |
+
*
|
394 |
+
* @param $apiUsername
|
395 |
+
*
|
396 |
+
* @return $this
|
397 |
+
*/
|
398 |
+
public function setApiUsername($apiUsername)
|
399 |
+
{
|
400 |
+
$this->_apiUsername = $apiUsername;
|
401 |
+
|
402 |
+
return $this;
|
403 |
+
}
|
404 |
+
|
405 |
+
/**
|
406 |
+
* Get api password.
|
407 |
+
*
|
408 |
+
* @return string
|
409 |
+
*/
|
410 |
+
public function getApiPassword()
|
411 |
Â
{
|
412 |
Â
return $this->_apiPassword;
|
413 |
Â
}
|
414 |
Â
|
415 |
+
/**
|
416 |
+
* set api password.
|
417 |
+
*
|
418 |
+
* @param $apiPassword
|
419 |
+
*
|
420 |
+
* @return $this
|
421 |
+
*/
|
422 |
+
public function setApiPassword($apiPassword)
|
423 |
Â
{
|
424 |
Â
$this->_apiPassword = $apiPassword;
|
425 |
+
|
426 |
Â
return $this;
|
427 |
Â
}
|
428 |
Â
|
429 |
+
/**
|
430 |
+
* get response body.
|
431 |
+
*
|
432 |
+
* @return string/object
|
433 |
+
*/
|
434 |
+
public function getResponseBody()
|
435 |
Â
{
|
436 |
Â
return $this->responseBody;
|
437 |
Â
}
|
438 |
Â
|
439 |
+
/**
|
440 |
+
* get response info.
|
441 |
+
*
|
442 |
+
* @return null
|
443 |
+
*/
|
444 |
+
public function getResponseInfo()
|
445 |
Â
{
|
446 |
Â
return $this->responseInfo;
|
447 |
Â
}
|
448 |
Â
|
449 |
+
/**
|
450 |
+
* get url.
|
451 |
+
*
|
452 |
+
* @return string
|
453 |
+
*/
|
454 |
+
public function getUrl()
|
455 |
Â
{
|
456 |
Â
return $this->url;
|
457 |
Â
}
|
458 |
Â
|
459 |
+
/**
|
460 |
+
* set url.
|
461 |
+
*
|
462 |
+
* @param $url
|
463 |
+
*
|
464 |
+
* @return $this
|
465 |
+
*/
|
466 |
+
public function setUrl($url)
|
467 |
Â
{
|
468 |
Â
$this->url = $url;
|
469 |
+
|
470 |
Â
return $this;
|
471 |
Â
}
|
472 |
Â
|
473 |
+
/**
|
474 |
+
* get the verb.
|
475 |
+
*
|
476 |
+
* @return string
|
477 |
+
*/
|
478 |
+
public function getVerb()
|
479 |
Â
{
|
480 |
Â
return $this->verb;
|
481 |
Â
}
|
482 |
Â
|
483 |
+
/**
|
484 |
+
* set the verb.
|
485 |
+
*
|
486 |
+
* @param $verb
|
487 |
+
*
|
488 |
+
* @return $this
|
489 |
+
*/
|
490 |
+
public function setVerb($verb)
|
491 |
Â
{
|
492 |
Â
$this->verb = $verb;
|
493 |
+
|
494 |
Â
return $this;
|
495 |
Â
}
|
496 |
Â
|
497 |
Â
public function getCurlError()
|
498 |
Â
{
|
499 |
Â
//if curl error
|
500 |
+
if ( ! empty($this->curlError)) {
|
501 |
Â
//log curl error
|
502 |
+
$message = 'CURL ERROR ' . $this->curlError;
|
503 |
Â
Mage::helper('ddg')->log($message)
|
504 |
Â
->rayLog($message, 'apiconnector/rest.php', __LINE__);
|
505 |
Â
|
512 |
Â
public function setIsNotJsonTrue()
|
513 |
Â
{
|
514 |
Â
$this->isNotJson = true;
|
515 |
+
|
516 |
Â
return $this;
|
517 |
Â
}
|
518 |
Â
}
|
@@ -6,116 +6,133 @@
|
|
6 |
Â
class Dotdigitalgroup_Email_Model_Adminhtml_Dashboard_Content
|
7 |
Â
{
|
8 |
Â
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
119 |
Â
|
120 |
Â
|
121 |
Â
}
|
6 |
Â
class Dotdigitalgroup_Email_Model_Adminhtml_Dashboard_Content
|
7 |
Â
{
|
8 |
Â
|
9 |
+
/**
|
10 |
+
* css style that can be used to alert based on result
|
11 |
+
*
|
12 |
+
* @var
|
13 |
+
*/
|
14 |
+
public $style;
|
15 |
+
|
16 |
+
/**
|
17 |
+
* @return mixed
|
18 |
+
*/
|
19 |
+
public function getTitle()
|
20 |
+
{
|
21 |
+
return $this->title;
|
22 |
+
}
|
23 |
+
|
24 |
+
/**
|
25 |
+
* @param $title
|
26 |
+
*
|
27 |
+
* @return $this
|
28 |
+
*/
|
29 |
+
public function setTitle($title)
|
30 |
+
{
|
31 |
+
$this->title = $title;
|
32 |
+
|
33 |
+
return $this;
|
34 |
+
}
|
35 |
+
|
36 |
+
/**
|
37 |
+
* title to be displayed as a key for the status
|
38 |
+
*
|
39 |
+
* @var
|
40 |
+
*/
|
41 |
+
public $title;
|
42 |
+
|
43 |
+
/**
|
44 |
+
* message to be displayd in the body
|
45 |
+
*
|
46 |
+
* @var
|
47 |
+
*/
|
48 |
+
public $message;
|
49 |
+
|
50 |
+
/**
|
51 |
+
* how to fix message
|
52 |
+
*
|
53 |
+
* @var
|
54 |
+
*/
|
55 |
+
public $howto = array();
|
56 |
+
|
57 |
+
/**
|
58 |
+
* @return mixed
|
59 |
+
*/
|
60 |
+
|
61 |
+
/**
|
62 |
+
* table data
|
63 |
+
*
|
64 |
+
* @var
|
65 |
+
*/
|
66 |
+
public $table = array();
|
67 |
+
|
68 |
+
public function getHowto()
|
69 |
+
{
|
70 |
+
return $this->howto;
|
71 |
+
}
|
72 |
+
|
73 |
+
/**
|
74 |
+
* @param $howto
|
75 |
+
*
|
76 |
+
* @return $this
|
77 |
+
*/
|
78 |
+
public function setHowto($howto)
|
79 |
+
{
|
80 |
+
$this->howto[] = $howto;
|
81 |
+
|
82 |
+
return $this;
|
83 |
+
}
|
84 |
+
|
85 |
+
/**
|
86 |
+
* @return mixed
|
87 |
+
*/
|
88 |
+
public function getMessage()
|
89 |
+
{
|
90 |
+
return $this->message;
|
91 |
+
}
|
92 |
+
|
93 |
+
/**
|
94 |
+
* @param $message
|
95 |
+
*
|
96 |
+
* @return $this
|
97 |
+
*/
|
98 |
+
public function setMessage($message)
|
99 |
+
{
|
100 |
+
$this->message = $message;
|
101 |
+
|
102 |
+
return $this;
|
103 |
+
}
|
104 |
+
|
105 |
+
/**
|
106 |
+
* @return mixed
|
107 |
+
*/
|
108 |
+
public function getStyle()
|
109 |
+
{
|
110 |
+
return $this->style;
|
111 |
+
}
|
112 |
+
|
113 |
+
/**
|
114 |
+
* @param $style
|
115 |
+
*
|
116 |
+
* @return $this
|
117 |
+
*/
|
118 |
+
public function setStyle($style)
|
119 |
+
{
|
120 |
+
$this->style = $style;
|
121 |
+
|
122 |
+
return $this;
|
123 |
+
}
|
124 |
+
|
125 |
+
public function setTable($table)
|
126 |
+
{
|
127 |
+
$this->table[] = $table;
|
128 |
+
|
129 |
+
return $this;
|
130 |
+
}
|
131 |
+
|
132 |
+
public function getTable()
|
133 |
+
{
|
134 |
+
return $this->table;
|
135 |
+
}
|
136 |
Â
|
137 |
Â
|
138 |
Â
}
|
@@ -1,8 +1,10 @@
|
|
1 |
Â
<?php
|
2 |
Â
|
3 |
-
class Dotdigitalgroup_Email_Model_Adminhtml_Dashboard_Tabs_Analysis_Abandoned
|
Â
|
|
4 |
Â
{
|
5 |
-
|
Â
|
|
6 |
Â
|
7 |
Â
/**
|
8 |
Â
* prepare collection and needed columns
|
@@ -17,22 +19,28 @@ class Dotdigitalgroup_Email_Model_Adminhtml_Dashboard_Tabs_Analysis_Abandoned ex
|
|
17 |
Â
->addFieldToFilter('main_table.is_active', '1')
|
18 |
Â
->setOrder('updated_at');
|
19 |
Â
|
20 |
-
if (is_array($this->storeIds) && !empty($this->storeIds)) {
|
21 |
-
$collection->addFieldToFilter(
|
Â
|
|
Â
|
|
22 |
Â
}
|
23 |
Â
|
24 |
-
$adapter
|
25 |
Â
$averageExpr = $adapter->getCheckSql(
|
26 |
Â
'COUNT(main_table.entity_id) > 0',
|
27 |
Â
'SUM(main_table.subtotal)/COUNT(main_table.entity_id)',
|
28 |
-
0
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
36 |
Â
return $collection;
|
37 |
Â
}
|
38 |
Â
|
@@ -40,20 +48,23 @@ class Dotdigitalgroup_Email_Model_Adminhtml_Dashboard_Tabs_Analysis_Abandoned ex
|
|
40 |
Â
* @param int $store
|
41 |
Â
* @param int $website
|
42 |
Â
* @param int $group
|
Â
|
|
43 |
Â
* @return Varien_Object
|
44 |
Â
* @throws Mage_Core_Exception
|
45 |
Â
*/
|
46 |
-
public function getLifeTimeAbandoned($store = 0, $website = 0, $group =0)
|
47 |
Â
{
|
48 |
Â
if ($store) {
|
49 |
Â
$this->storeIds = array($store => $store);
|
50 |
-
} else if ($website){
|
51 |
-
$storeIds
|
52 |
Â
$this->storeIds = $storeIds;
|
53 |
-
} else if ($group){
|
54 |
-
$storeIds
|
55 |
Â
$this->storeIds = $storeIds;
|
56 |
Â
}
|
57 |
-
|
Â
|
|
Â
|
|
58 |
Â
}
|
59 |
Â
}
|
1 |
Â
<?php
|
2 |
Â
|
3 |
+
class Dotdigitalgroup_Email_Model_Adminhtml_Dashboard_Tabs_Analysis_Abandoned
|
4 |
+
extends Mage_Core_Model_Abstract
|
5 |
Â
{
|
6 |
+
|
7 |
+
public $storeIds;
|
8 |
Â
|
9 |
Â
/**
|
10 |
Â
* prepare collection and needed columns
|
19 |
Â
->addFieldToFilter('main_table.is_active', '1')
|
20 |
Â
->setOrder('updated_at');
|
21 |
Â
|
22 |
+
if (is_array($this->storeIds) && ! empty($this->storeIds)) {
|
23 |
+
$collection->addFieldToFilter(
|
24 |
+
'store_id', array('in' => $this->storeIds)
|
25 |
+
);
|
26 |
Â
}
|
27 |
Â
|
28 |
+
$adapter = $collection->getConnection();
|
29 |
Â
$averageExpr = $adapter->getCheckSql(
|
30 |
Â
'COUNT(main_table.entity_id) > 0',
|
31 |
Â
'SUM(main_table.subtotal)/COUNT(main_table.entity_id)',
|
32 |
+
0
|
33 |
+
);
|
34 |
+
|
35 |
+
$collection->getSelect()->columns(
|
36 |
+
array(
|
37 |
+
'lifetime' => 'SUM(main_table.subtotal)',
|
38 |
+
'average' => $averageExpr,
|
39 |
+
'total_count' => "COUNT(main_table.entity_id)",
|
40 |
+
'day_count' => "ROUND(COUNT(main_table.entity_id) / DATEDIFF(date(MAX(main_table.updated_at)) , date(MIN(main_table.updated_at))), 2)"
|
41 |
+
)
|
42 |
+
);
|
43 |
+
|
44 |
Â
return $collection;
|
45 |
Â
}
|
46 |
Â
|
48 |
Â
* @param int $store
|
49 |
Â
* @param int $website
|
50 |
Â
* @param int $group
|
51 |
+
*
|
52 |
Â
* @return Varien_Object
|
53 |
Â
* @throws Mage_Core_Exception
|
54 |
Â
*/
|
55 |
+
public function getLifeTimeAbandoned($store = 0, $website = 0, $group = 0)
|
56 |
Â
{
|
57 |
Â
if ($store) {
|
58 |
Â
$this->storeIds = array($store => $store);
|
59 |
+
} else if ($website) {
|
60 |
+
$storeIds = Mage::app()->getWebsite($website)->getStoreIds();
|
61 |
Â
$this->storeIds = $storeIds;
|
62 |
+
} else if ($group) {
|
63 |
+
$storeIds = Mage::app()->getGroup($group)->getStoreIds();
|
64 |
Â
$this->storeIds = $storeIds;
|
65 |
Â
}
|
66 |
+
|
67 |
+
return $this->getPreparedCollection()->setPageSize(1)->setCurPage(1)
|
68 |
+
->getFirstItem();
|
69 |
Â
}
|
70 |
Â
}
|
@@ -1,8 +1,10 @@
|
|
1 |
Â
<?php
|
2 |
Â
|
3 |
-
class Dotdigitalgroup_Email_Model_Adminhtml_Dashboard_Tabs_Analysis_Customer
|
Â
|
|
4 |
Â
{
|
5 |
-
|
Â
|
|
6 |
Â
|
7 |
Â
/**
|
8 |
Â
* prepare collection and needed columns
|
@@ -13,14 +15,18 @@ class Dotdigitalgroup_Email_Model_Adminhtml_Dashboard_Tabs_Analysis_Customer ext
|
|
13 |
Â
{
|
14 |
Â
$collection = Mage::getResourceModel('customer/customer_collection');
|
15 |
Â
|
16 |
-
if (is_array($this->storeIds) && !empty($this->storeIds)) {
|
17 |
-
$collection->addAttributeToFilter(
|
Â
|
|
Â
|
|
18 |
Â
}
|
19 |
Â
|
20 |
-
$collection->getSelect()->columns(
|
21 |
-
|
22 |
-
|
23 |
-
|
Â
|
|
Â
|
|
24 |
Â
|
25 |
Â
return $collection;
|
26 |
Â
}
|
@@ -29,20 +35,24 @@ class Dotdigitalgroup_Email_Model_Adminhtml_Dashboard_Tabs_Analysis_Customer ext
|
|
29 |
Â
* @param int $store
|
30 |
Â
* @param int $website
|
31 |
Â
* @param int $group
|
Â
|
|
32 |
Â
* @return Varien_Object
|
33 |
Â
* @throws Mage_Core_Exception
|
34 |
Â
*/
|
35 |
-
public function getLifeTimeTimeCustomer($store = 0, $website = 0, $group =0
|
Â
|
|
36 |
Â
{
|
37 |
Â
if ($store) {
|
38 |
Â
$this->storeIds = array($store => $store);
|
39 |
-
} else if ($website){
|
40 |
-
$storeIds
|
41 |
Â
$this->storeIds = $storeIds;
|
42 |
-
} else if ($group){
|
43 |
-
$storeIds
|
44 |
Â
$this->storeIds = $storeIds;
|
45 |
Â
}
|
46 |
-
|
Â
|
|
Â
|
|
47 |
Â
}
|
48 |
Â
}
|
1 |
Â
<?php
|
2 |
Â
|
3 |
+
class Dotdigitalgroup_Email_Model_Adminhtml_Dashboard_Tabs_Analysis_Customer
|
4 |
+
extends Mage_Core_Model_Abstract
|
5 |
Â
{
|
6 |
+
|
7 |
+
public $storeIds;
|
8 |
Â
|
9 |
Â
/**
|
10 |
Â
* prepare collection and needed columns
|
15 |
Â
{
|
16 |
Â
$collection = Mage::getResourceModel('customer/customer_collection');
|
17 |
Â
|
18 |
+
if (is_array($this->storeIds) && ! empty($this->storeIds)) {
|
19 |
+
$collection->addAttributeToFilter(
|
20 |
+
'store_id', array('in' => $this->storeIds)
|
21 |
+
);
|
22 |
Â
}
|
23 |
Â
|
24 |
+
$collection->getSelect()->columns(
|
25 |
+
array(
|
26 |
+
'total_count' => "COUNT(*)",
|
27 |
+
'day_count' => "ROUND(COUNT(*) / DATEDIFF(date(MAX(created_at)) , date(MIN(created_at))), 2)"
|
28 |
+
)
|
29 |
+
);
|
30 |
Â
|
31 |
Â
return $collection;
|
32 |
Â
}
|
35 |
Â
* @param int $store
|
36 |
Â
* @param int $website
|
37 |
Â
* @param int $group
|
38 |
+
*
|
39 |
Â
* @return Varien_Object
|
40 |
Â
* @throws Mage_Core_Exception
|
41 |
Â
*/
|
42 |
+
public function getLifeTimeTimeCustomer($store = 0, $website = 0, $group = 0
|
43 |
+
)
|
44 |
Â
{
|
45 |
Â
if ($store) {
|
46 |
Â
$this->storeIds = array($store => $store);
|
47 |
+
} else if ($website) {
|
48 |
+
$storeIds = Mage::app()->getWebsite($website)->getStoreIds();
|
49 |
Â
$this->storeIds = $storeIds;
|
50 |
+
} else if ($group) {
|
51 |
+
$storeIds = Mage::app()->getGroup($group)->getStoreIds();
|
52 |
Â
$this->storeIds = $storeIds;
|
53 |
Â
}
|
54 |
+
|
55 |
+
return $this->getPreparedCollection()->setPageSize(1)->setCurPage(1)
|
56 |
+
->getFirstItem();
|
57 |
Â
}
|
58 |
Â
}
|
@@ -1,11 +1,14 @@
|
|
1 |
Â
<?php
|
2 |
Â
|
3 |
-
class Dotdigitalgroup_Email_Model_Adminhtml_Dashboard_Tabs_Analysis_Orders
|
Â
|
|
4 |
Â
{
|
Â
|
|
5 |
Â
/**
|
6 |
Â
* calculate sales and prepare columns
|
7 |
Â
*
|
8 |
Â
* @param int $isFilter
|
Â
|
|
9 |
Â
* @return Mage_Reports_Model_Resource_Order_Collection
|
10 |
Â
*/
|
11 |
Â
protected function calculateSales($isFilter = 0)
|
@@ -26,43 +29,56 @@ class Dotdigitalgroup_Email_Model_Adminhtml_Dashboard_Tabs_Analysis_Orders exten
|
|
26 |
Â
$averageExpr = $adapter->getCheckSql(
|
27 |
Â
'SUM(main_table.orders_count) > 0',
|
28 |
Â
'SUM(main_table.total_revenue_amount)/SUM(main_table.orders_count)',
|
29 |
-
0
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
Â
|
|
Â
|
|
Â
|
|
36 |
Â
|
37 |
-
if (
|
38 |
-
$collection->addFieldToFilter(
|
39 |
-
|
Â
|
|
Â
|
|
Â
|
|
40 |
Â
);
|
41 |
Â
}
|
42 |
-
$collection->getSelect()->where(
|
Â
|
|
Â
|
|
43 |
Â
} else {
|
44 |
Â
$collection->setMainTable('sales/order');
|
45 |
Â
$collection->removeAllFieldsFromSelect();
|
46 |
Â
|
47 |
-
$expr = Mage::getResourceModel('ddg_automation/contact')
|
Â
|
|
48 |
Â
|
49 |
Â
if ($isFilter == 0) {
|
50 |
Â
$expr = '(' . $expr . ') * main_table.base_to_global_rate';
|
51 |
Â
}
|
52 |
Â
|
53 |
Â
$collection->getSelect()
|
54 |
-
->columns(
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
Â
|
|
Â
|
|
60 |
Â
->where('main_table.status NOT IN(?)', $statuses)
|
61 |
-
->where(
|
Â
|
|
62 |
Â
Mage_Sales_Model_Order::STATE_NEW,
|
63 |
Â
Mage_Sales_Model_Order::STATE_PENDING_PAYMENT)
|
64 |
Â
);
|
65 |
Â
}
|
Â
|
|
66 |
Â
return $collection;
|
67 |
Â
}
|
68 |
Â
|
@@ -70,20 +86,21 @@ class Dotdigitalgroup_Email_Model_Adminhtml_Dashboard_Tabs_Analysis_Orders exten
|
|
70 |
Â
* @param int $store
|
71 |
Â
* @param int $website
|
72 |
Â
* @param int $group
|
Â
|
|
73 |
Â
* @return Varien_Object
|
74 |
Â
* @throws Mage_Core_Exception
|
75 |
Â
*/
|
76 |
-
public function getLifetimeSales($store = 0, $website = 0, $group =0)
|
77 |
Â
{
|
78 |
-
$isFilter
|
79 |
Â
$collection = $this->calculateSales($isFilter);
|
80 |
Â
|
81 |
Â
if ($store) {
|
82 |
Â
$collection->addFieldToFilter('store_id', $store);
|
83 |
-
} else if ($website){
|
84 |
Â
$storeIds = Mage::app()->getWebsite($website)->getStoreIds();
|
85 |
Â
$collection->addFieldToFilter('store_id', array('in' => $storeIds));
|
86 |
-
} else if ($group){
|
87 |
Â
$storeIds = Mage::app()->getGroup($group)->getStoreIds();
|
88 |
Â
$collection->addFieldToFilter('store_id', array('in' => $storeIds));
|
89 |
Â
}
|
1 |
Â
<?php
|
2 |
Â
|
3 |
+
class Dotdigitalgroup_Email_Model_Adminhtml_Dashboard_Tabs_Analysis_Orders
|
4 |
+
extends Mage_Core_Model_Abstract
|
5 |
Â
{
|
6 |
+
|
7 |
Â
/**
|
8 |
Â
* calculate sales and prepare columns
|
9 |
Â
*
|
10 |
Â
* @param int $isFilter
|
11 |
+
*
|
12 |
Â
* @return Mage_Reports_Model_Resource_Order_Collection
|
13 |
Â
*/
|
14 |
Â
protected function calculateSales($isFilter = 0)
|
29 |
Â
$averageExpr = $adapter->getCheckSql(
|
30 |
Â
'SUM(main_table.orders_count) > 0',
|
31 |
Â
'SUM(main_table.total_revenue_amount)/SUM(main_table.orders_count)',
|
32 |
+
0
|
33 |
+
);
|
34 |
+
$collection->getSelect()->columns(
|
35 |
+
array(
|
36 |
+
'lifetime' => 'SUM(main_table.total_revenue_amount)',
|
37 |
+
'average' => $averageExpr,
|
38 |
+
'total_count' => "SUM(main_table.orders_count)",
|
39 |
+
'day_count' => "ROUND(SUM(main_table.orders_count) / DATEDIFF(date(MAX(period)) , date(MIN(period))), 2)"
|
40 |
+
)
|
41 |
+
);
|
42 |
Â
|
43 |
+
if ( ! $isFilter) {
|
44 |
+
$collection->addFieldToFilter(
|
45 |
+
'store_id',
|
46 |
+
array('eq' => Mage::app()->getStore(
|
47 |
+
Mage_Core_Model_Store::ADMIN_CODE
|
48 |
+
)->getId())
|
49 |
Â
);
|
50 |
Â
}
|
51 |
+
$collection->getSelect()->where(
|
52 |
+
'main_table.order_status NOT IN(?)', $statuses
|
53 |
+
);
|
54 |
Â
} else {
|
55 |
Â
$collection->setMainTable('sales/order');
|
56 |
Â
$collection->removeAllFieldsFromSelect();
|
57 |
Â
|
58 |
+
$expr = Mage::getResourceModel('ddg_automation/contact')
|
59 |
+
->getSalesAmountExpression($collection);
|
60 |
Â
|
61 |
Â
if ($isFilter == 0) {
|
62 |
Â
$expr = '(' . $expr . ') * main_table.base_to_global_rate';
|
63 |
Â
}
|
64 |
Â
|
65 |
Â
$collection->getSelect()
|
66 |
+
->columns(
|
67 |
+
array(
|
68 |
+
'lifetime' => "SUM({$expr})",
|
69 |
+
'average' => "AVG({$expr})",
|
70 |
+
'total_count' => "COUNT({$expr})",
|
71 |
+
'day_count' => "ROUND(COUNT({$expr}) / DATEDIFF(date(MAX(created_at)) , date(MIN(created_at))), 2)"
|
72 |
+
)
|
73 |
+
)
|
74 |
Â
->where('main_table.status NOT IN(?)', $statuses)
|
75 |
+
->where(
|
76 |
+
'main_table.state NOT IN(?)', array(
|
77 |
Â
Mage_Sales_Model_Order::STATE_NEW,
|
78 |
Â
Mage_Sales_Model_Order::STATE_PENDING_PAYMENT)
|
79 |
Â
);
|
80 |
Â
}
|
81 |
+
|
82 |
Â
return $collection;
|
83 |
Â
}
|
84 |
Â
|
86 |
Â
* @param int $store
|
87 |
Â
* @param int $website
|
88 |
Â
* @param int $group
|
89 |
+
*
|
90 |
Â
* @return Varien_Object
|
91 |
Â
* @throws Mage_Core_Exception
|
92 |
Â
*/
|
93 |
+
public function getLifetimeSales($store = 0, $website = 0, $group = 0)
|
94 |
Â
{
|
95 |
+
$isFilter = $store || $website || $group;
|
96 |
Â
$collection = $this->calculateSales($isFilter);
|
97 |
Â
|
98 |
Â
if ($store) {
|
99 |
Â
$collection->addFieldToFilter('store_id', $store);
|
100 |
+
} else if ($website) {
|
101 |
Â
$storeIds = Mage::app()->getWebsite($website)->getStoreIds();
|
102 |
Â
$collection->addFieldToFilter('store_id', array('in' => $storeIds));
|
103 |
+
} else if ($group) {
|
104 |
Â
$storeIds = Mage::app()->getGroup($group)->getStoreIds();
|
105 |
Â
$collection->addFieldToFilter('store_id', array('in' => $storeIds));
|
106 |
Â
}
|
@@ -1,160 +1,187 @@
|
|
1 |
Â
<?php
|
2 |
Â
|
3 |
-
class Dotdigitalgroup_Email_Model_Adminhtml_Dashboard_Tabs_Analysis_Rfm
|
Â
|
|
4 |
Â
{
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
Â
|
|
9 |
Â
|
10 |
Â
protected $_resultCount;
|
11 |
Â
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
76 |
Â
protected function calculateQuartile($array)
|
77 |
Â
{
|
78 |
Â
$count = $this->_resultCount;
|
79 |
-
if ($count == 0)
|
80 |
Â
return array(
|
81 |
-
"Low"
|
82 |
Â
"Medium" => 0,
|
83 |
-
"High"
|
84 |
Â
);
|
Â
|
|
85 |
Â
|
86 |
-
$first
|
87 |
Â
$second = intval(round(.50 * ($count + 1)));
|
88 |
-
$third
|
89 |
Â
|
90 |
-
if (!array_key_exists($first, $array))
|
91 |
Â
$first = $this->getClosest($first, $array);
|
Â
|
|
92 |
Â
|
93 |
-
if (!array_key_exists($second, $array))
|
94 |
Â
$second = $this->getClosest($second, $array);
|
Â
|
|
95 |
Â
|
96 |
-
if (!array_key_exists($third, $array))
|
97 |
Â
$third = $this->getClosest($third, $array);
|
Â
|
|
98 |
Â
|
99 |
Â
return array(
|
100 |
-
"Low"
|
101 |
Â
"Medium" => $array[$second],
|
102 |
-
"High"
|
103 |
Â
);
|
104 |
Â
}
|
105 |
Â
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
128 |
Â
protected function prepareRfm()
|
129 |
Â
{
|
130 |
-
$collection
|
131 |
-
|
132 |
Â
|
133 |
-
$values
|
134 |
-
|
Â
|
|
Â
|
|
135 |
Â
$this->rfm[self::FREQUENCY] = $this->calculateQuartile($values);
|
136 |
Â
|
137 |
Â
|
138 |
-
$values
|
Â
|
|
Â
|
|
139 |
Â
$this->rfm[self::RECENCY] = $this->calculateQuartile($values);
|
140 |
Â
|
141 |
-
|
Â
|
|
Â
|
|
142 |
Â
$this->rfm[self::MONETARY] = $this->calculateQuartile($values);
|
143 |
Â
}
|
144 |
Â
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
Â
|
|
Â
|
|
160 |
Â
}
|
1 |
Â
<?php
|
2 |
Â
|
3 |
+
class Dotdigitalgroup_Email_Model_Adminhtml_Dashboard_Tabs_Analysis_Rfm
|
4 |
+
extends Mage_Core_Model_Abstract
|
5 |
Â
{
|
6 |
+
|
7 |
+
public $rfm = array();
|
8 |
+
protected $_store = 0;
|
9 |
+
protected $_group = 0;
|
10 |
+
protected $_website = 0;
|
11 |
Â
|
12 |
Â
protected $_resultCount;
|
13 |
Â
|
14 |
+
const RECENCY = 'Recency';
|
15 |
+
const FREQUENCY = 'Frequency';
|
16 |
+
const MONETARY = 'Monetary';
|
17 |
+
|
18 |
+
/**
|
19 |
+
* prepare collection and needed columns
|
20 |
+
*
|
21 |
+
* @return Mage_Sales_Model_Resource_Order_Collection
|
22 |
+
* @throws Mage_Core_Exception
|
23 |
+
*/
|
24 |
+
protected function getPreparedCollection()
|
25 |
+
{
|
26 |
+
$statuses = Mage::getSingleton('sales/config')
|
27 |
+
->getOrderStatusesForState(Mage_Sales_Model_Order::STATE_CANCELED);
|
28 |
+
if (empty($statuses)) {
|
29 |
+
$statuses = array(0);
|
30 |
+
}
|
31 |
+
|
32 |
+
$collection = Mage::getResourceModel('sales/order_collection');
|
33 |
+
$collection
|
34 |
+
->addFieldToFilter('status', array('nin' => $statuses))
|
35 |
+
->addFieldToFilter(
|
36 |
+
'state',
|
37 |
+
array('nin' => array(
|
38 |
+
Mage_Sales_Model_Order::STATE_NEW,
|
39 |
+
Mage_Sales_Model_Order::STATE_PENDING_PAYMENT)
|
40 |
+
)
|
41 |
+
)
|
42 |
+
->addFieldToFilter('customer_id', array('neq' => 'null'))
|
43 |
+
->addOrder('created_at');
|
44 |
+
|
45 |
+
if ($this->_store) {
|
46 |
+
$collection->addFieldToFilter('store_id', $this->_store);
|
47 |
+
} else if ($this->_website) {
|
48 |
+
$storeIds = Mage::app()->getWebsite($this->_website)->getStoreIds();
|
49 |
+
$collection->addFieldToFilter('store_id', array('in' => $storeIds));
|
50 |
+
} else if ($this->_group) {
|
51 |
+
$storeIds = Mage::app()->getGroup($this->_group)->getStoreIds();
|
52 |
+
$collection->addFieldToFilter('store_id', array('in' => $storeIds));
|
53 |
+
}
|
54 |
+
|
55 |
+
$expr = Mage::getResourceModel('ddg_automation/contact')
|
56 |
+
->getSalesAmountExpression($collection);
|
57 |
+
$isFilter = $this->_store || $this->_website || $this->_group;
|
58 |
+
if ($isFilter == 0) {
|
59 |
+
$expr = '(' . $expr . ') * main_table.base_to_global_rate';
|
60 |
+
}
|
61 |
+
|
62 |
+
$collection->getSelect()
|
63 |
+
->reset(Zend_Db_Select::COLUMNS)
|
64 |
+
->columns(
|
65 |
+
array(
|
66 |
+
'customer_total_orders' => "count(*)",
|
67 |
+
'customer_average_order_value' => "SUM({$expr})/count(*)",
|
68 |
+
'last_order_days_ago' => "DATEDIFF(date(NOW()) , date(MAX(created_at)))"
|
69 |
+
)
|
70 |
+
)
|
71 |
+
->group('customer_id');
|
72 |
+
|
73 |
+
return $collection;
|
74 |
+
}
|
75 |
+
|
76 |
+
/**
|
77 |
+
* calculate quartiles
|
78 |
+
*
|
79 |
+
* @param $array
|
80 |
+
*
|
81 |
+
* @return array
|
82 |
+
*/
|
83 |
Â
protected function calculateQuartile($array)
|
84 |
Â
{
|
85 |
Â
$count = $this->_resultCount;
|
86 |
+
if ($count == 0) {
|
87 |
Â
return array(
|
88 |
+
"Low" => 0,
|
89 |
Â
"Medium" => 0,
|
90 |
+
"High" => 0
|
91 |
Â
);
|
92 |
+
}
|
93 |
Â
|
94 |
+
$first = intval(round(.25 * ($count + 1)));
|
95 |
Â
$second = intval(round(.50 * ($count + 1)));
|
96 |
+
$third = intval(round(.75 * ($count + 1)));
|
97 |
Â
|
98 |
+
if ( ! array_key_exists($first, $array)) {
|
99 |
Â
$first = $this->getClosest($first, $array);
|
100 |
+
}
|
101 |
Â
|
102 |
+
if ( ! array_key_exists($second, $array)) {
|
103 |
Â
$second = $this->getClosest($second, $array);
|
104 |
+
}
|
105 |
Â
|
106 |
+
if ( ! array_key_exists($third, $array)) {
|
107 |
Â
$third = $this->getClosest($third, $array);
|
108 |
+
}
|
109 |
Â
|
110 |
Â
return array(
|
111 |
+
"Low" => $array[$first],
|
112 |
Â
"Medium" => $array[$second],
|
113 |
+
"High" => $array[$third]
|
114 |
Â
);
|
115 |
Â
}
|
116 |
Â
|
117 |
+
/**
|
118 |
+
* find closest index key from array
|
119 |
+
*
|
120 |
+
* @param $search
|
121 |
+
* @param $arr
|
122 |
+
*
|
123 |
+
* @return mix
|
124 |
+
*/
|
125 |
+
protected function getClosest($search, $arr)
|
126 |
+
{
|
127 |
+
$closest = null;
|
128 |
+
foreach ($arr as $key => $value) {
|
129 |
+
if ($search == $key) {
|
130 |
+
return $search;
|
131 |
+
}
|
132 |
+
if ($closest == null
|
133 |
+
|| abs($search - $closest) > abs(
|
134 |
+
$key - $search
|
135 |
+
)
|
136 |
+
) {
|
137 |
+
$closest = $key;
|
138 |
+
}
|
139 |
+
}
|
140 |
+
|
141 |
+
return $closest;
|
142 |
+
}
|
143 |
+
|
144 |
+
/**
|
145 |
+
* prepare rfm data
|
146 |
+
*/
|
147 |
Â
protected function prepareRfm()
|
148 |
Â
{
|
149 |
+
$collection = $this->getPreparedCollection();
|
150 |
+
$contactResource = Mage::getResourceModel('ddg_automation/contact');
|
151 |
Â
|
152 |
+
$values = $contactResource->prepareFrequency(
|
153 |
+
$collection
|
154 |
+
);
|
155 |
+
$this->_resultCount = count($values);
|
156 |
Â
$this->rfm[self::FREQUENCY] = $this->calculateQuartile($values);
|
157 |
Â
|
158 |
Â
|
159 |
+
$values = $contactResource->prepareRecency(
|
160 |
+
$collection
|
161 |
+
);
|
162 |
Â
$this->rfm[self::RECENCY] = $this->calculateQuartile($values);
|
163 |
Â
|
164 |
+
$values = $contactResource->prepareMonetary(
|
165 |
+
$collection
|
166 |
+
);
|
167 |
Â
$this->rfm[self::MONETARY] = $this->calculateQuartile($values);
|
168 |
Â
}
|
169 |
Â
|
170 |
+
/**
|
171 |
+
* @param int $store
|
172 |
+
* @param int $website
|
173 |
+
* @param int $group
|
174 |
+
*
|
175 |
+
* @return array
|
176 |
+
*/
|
177 |
+
public function getPreparedRfm($store = 0, $website = 0, $group = 0)
|
178 |
+
{
|
179 |
+
$this->_store = $store;
|
180 |
+
$this->_group = $group;
|
181 |
+
$this->_website = $website;
|
182 |
+
|
183 |
+
$this->prepareRfm();
|
184 |
+
|
185 |
+
return $this->rfm;
|
186 |
+
}
|
187 |
Â
}
|
@@ -1,90 +1,109 @@
|
|
1 |
Â
<?php
|
2 |
Â
|
3 |
-
class Dotdigitalgroup_Email_Model_Adminhtml_Dashboard_Tabs_Analysis_Subscriber
|
Â
|
|
4 |
Â
{
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
45 |
Â
$customerSubscriberCount = $customerSubscribers->getSize();
|
46 |
Â
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
Â
|
|
Â
|
|
Â
|
|
90 |
Â
}
|
1 |
Â
<?php
|
2 |
Â
|
3 |
+
class Dotdigitalgroup_Email_Model_Adminhtml_Dashboard_Tabs_Analysis_Subscriber
|
4 |
+
extends Mage_Core_Model_Abstract
|
5 |
Â
{
|
6 |
+
|
7 |
+
public $storeIds;
|
8 |
+
|
9 |
+
protected function calculateOperationalDaysFromOrder()
|
10 |
+
{
|
11 |
+
$collection = Mage::getResourceModel('sales/order_collection');
|
12 |
+
$collection->addFieldToSelect('created_at');
|
13 |
+
|
14 |
+
if (is_array($this->storeIds) && ! empty($this->storeIds)) {
|
15 |
+
$collection->addFieldToFilter(
|
16 |
+
'store_id', array('in' => $this->storeIds)
|
17 |
+
);
|
18 |
+
}
|
19 |
+
|
20 |
+
$collection->getSelect()->columns(
|
21 |
+
array(
|
22 |
+
'days' => "DATEDIFF(date(NOW()) , date(MIN(created_at)))"
|
23 |
+
)
|
24 |
+
);
|
25 |
+
|
26 |
+
return $collection->setPageSize(1)->setCurPage(1)->getFirstItem()
|
27 |
+
->getDays();
|
28 |
+
}
|
29 |
+
|
30 |
+
protected function _getCollection()
|
31 |
+
{
|
32 |
+
$collection = Mage::getResourceModel(
|
33 |
+
'newsletter/subscriber_collection'
|
34 |
+
);
|
35 |
+
$collection->addFieldToFilter('subscriber_status', array('neq' => '3'));
|
36 |
+
|
37 |
+
if (is_array($this->storeIds) && ! empty($this->storeIds)) {
|
38 |
+
$collection->addFieldToFilter(
|
39 |
+
'store_id', array('in' => $this->storeIds)
|
40 |
+
);
|
41 |
+
}
|
42 |
+
|
43 |
+
return $collection;
|
44 |
+
}
|
45 |
+
|
46 |
+
/**
|
47 |
+
* prepare collection
|
48 |
+
*
|
49 |
+
* @return Varien_Object
|
50 |
+
*/
|
51 |
+
protected function getPreparedCollection()
|
52 |
+
{
|
53 |
+
//all active subscribers
|
54 |
+
$collection = $this->_getCollection();
|
55 |
+
$totalSubscribers = $collection->getSize();
|
56 |
+
|
57 |
+
//all active subscribers who are also customers
|
58 |
+
$customerSubscribers = $collection->addFieldToFilter(
|
59 |
+
'customer_id', array('neq' => '0')
|
60 |
+
);
|
61 |
Â
$customerSubscriberCount = $customerSubscribers->getSize();
|
62 |
Â
|
63 |
+
$days = $this->calculateOperationalDaysFromOrder();
|
64 |
+
if ($days) {
|
65 |
+
$subscribersPerDay = number_format($totalSubscribers / $days, 2);
|
66 |
+
} else {
|
67 |
+
$subscribersPerDay = $totalSubscribers;
|
68 |
+
}
|
69 |
+
|
70 |
+
$resultObject = new Varien_Object;
|
71 |
+
$resultObject
|
72 |
+
->setTotalSubscriber($totalSubscribers)
|
73 |
+
->setTotalSubscriberCustomer($customerSubscriberCount)
|
74 |
+
->setSubscribersPerDay($subscribersPerDay);
|
75 |
+
|
76 |
+
return $resultObject;
|
77 |
+
}
|
78 |
+
|
79 |
+
/**
|
80 |
+
* @param int $store
|
81 |
+
* @param int $website
|
82 |
+
* @param int $group
|
83 |
+
*
|
84 |
+
* @return Varien_Object
|
85 |
+
* @throws Mage_Core_Exception
|
86 |
+
*/
|
87 |
+
public function getLifetimeSubscribers($store = 0, $website = 0, $group = 0)
|
88 |
+
{
|
89 |
+
if ($store) {
|
90 |
+
$this->storeIds = array($store => $store);
|
91 |
+
} else if ($website) {
|
92 |
+
$storeIds = Mage::app()->getWebsite($website)->getStoreIds();
|
93 |
+
$this->storeIds = $storeIds;
|
94 |
+
} else if ($group) {
|
95 |
+
$storeIds = Mage::app()->getGroup($group)->getStoreIds();
|
96 |
+
$this->storeIds = $storeIds;
|
97 |
+
}
|
98 |
+
|
99 |
+
return $this->getPreparedCollection();
|
100 |
+
}
|
101 |
+
|
102 |
+
/**
|
103 |
+
* @return string
|
104 |
+
*/
|
105 |
+
public function getTitle()
|
106 |
+
{
|
107 |
+
return "Subscribers Analytical Data";
|
108 |
+
}
|
109 |
Â
}
|
@@ -6,118 +6,132 @@ class Dotdigitalgroup_Email_Model_Adminhtml_Observer
|
|
6 |
Â
/**
|
7 |
Â
* API Sync and Data Mapping.
|
8 |
Â
* Reset contacts for reimport.
|
Â
|
|
9 |
Â
* @return $this
|
10 |
Â
*/
|
11 |
Â
public function actionConfigResetContacts()
|
12 |
Â
{
|
13 |
Â
$contactModel = Mage::getModel('ddg_automation/contact');
|
14 |
-
$numImported
|
15 |
-
$updated
|
16 |
-
Mage::helper('ddg')->log(
|
Â
|
|
Â
|
|
Â
|
|
17 |
Â
|
18 |
Â
/**
|
19 |
-
*
|
20 |
Â
*/
|
21 |
-
$this->
|
Â
|
|
Â
|
|
22 |
Â
|
23 |
Â
return $this;
|
24 |
Â
}
|
25 |
Â
|
26 |
Â
/**
|
27 |
-
* Check
|
28 |
-
*
|
Â
|
|
29 |
Â
*/
|
30 |
-
|
31 |
Â
{
|
32 |
-
|
33 |
-
$
|
34 |
-
|
35 |
-
|
36 |
-
$
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
$
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
41 |
Â
}
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
//call request for account info
|
55 |
-
$response = $client->getAccountInfo();
|
56 |
-
|
57 |
-
//properties must be checked
|
58 |
-
if (isset($response->properties)) {
|
59 |
-
$accountInfo = $response->properties;
|
60 |
-
$result = $this->_checkForOption(Dotdigitalgroup_Email_Model_Apiconnector_Client::API_ERROR_TRANS_ALLOWANCE, $accountInfo);
|
61 |
-
|
62 |
-
//account is disabled to use transactional data
|
63 |
-
if (! $result) {
|
64 |
-
$message = 'Transactional Data For This Account Is Disabled. Call Support To Enable.';
|
65 |
-
//send admin message
|
66 |
-
Mage::getSingleton('adminhtml/session')->addError($message);
|
67 |
-
|
68 |
-
//send raygun message for trans data
|
69 |
-
Mage::helper('ddg')->rayLog($message);
|
70 |
-
//disable the config for wishlist and order sync
|
71 |
-
$config = Mage::getConfig();
|
72 |
-
$config->saveConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_SYNC_WISHLIST_ENABLED, 0, $scope, $scopeId);
|
73 |
-
$config->saveConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_SYNC_ORDER_ENABLED, 0, $scope, $scopeId);
|
74 |
-
$config->cleanCache();
|
75 |
-
}
|
76 |
-
}
|
77 |
Â
}
|
78 |
Â
|
79 |
-
return $this;
|
80 |
-
|
81 |
Â
}
|
82 |
Â
|
83 |
Â
/**
|
84 |
Â
* API Credentials.
|
85 |
Â
* Installation and validation confirmation.
|
Â
|
|
86 |
Â
* @return $this
|
87 |
Â
*/
|
88 |
Â
public function actionConfigSaveApi()
|
89 |
Â
{
|
90 |
Â
$groups = Mage::app()->getRequest()->getPost('groups');
|
91 |
-
if (isset($groups['api']['fields']['username']['inherit'])
|
Â
|
|
Â
|
|
92 |
Â
return $this;
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
93 |
Â
|
94 |
-
$apiUsername = isset($groups['api']['fields']['username']['value'])? $groups['api']['fields']['username']['value'] : false;
|
95 |
-
$apiPassword = isset($groups['api']['fields']['password']['value'])? $groups['api']['fields']['password']['value'] : false;
|
96 |
Â
//skip if the inherit option is selected
|
97 |
Â
if ($apiUsername && $apiPassword) {
|
98 |
Â
Mage::helper('ddg')->log('----VALIDATING ACCOUNT---');
|
99 |
Â
$testModel = Mage::getModel('ddg_automation/apiconnector_test');
|
Â
|
|
100 |
Â
$isValid = $testModel->validate($apiUsername, $apiPassword);
|
101 |
-
$config
|
Â
|
|
Â
|
|
102 |
Â
if (! $isValid) {
|
103 |
Â
/**
|
104 |
Â
* Disable invalid Api credentials
|
105 |
Â
*/
|
106 |
-
$
|
107 |
-
|
108 |
-
$scope
|
109 |
-
|
110 |
-
} else {
|
111 |
-
$scope = "default";
|
112 |
-
}
|
113 |
-
$config->saveConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_API_ENABLED, 0, $scope, $scopeId);
|
114 |
Â
}
|
115 |
Â
|
116 |
Â
//check if returned value is an object
|
117 |
-
if(is_object($isValid)){
|
118 |
Â
//save endpoint for account
|
119 |
-
foreach($isValid->properties as $property){
|
120 |
-
if($property->name == 'ApiEndpoint'
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
121 |
Â
$config->saveConfig(
|
122 |
Â
Dotdigitalgroup_Email_Helper_Config::PATH_FOR_API_ENDPOINT,
|
123 |
Â
$property->value
|
@@ -127,118 +141,75 @@ class Dotdigitalgroup_Email_Model_Adminhtml_Observer
|
|
127 |
Â
}
|
128 |
Â
}
|
129 |
Â
$config->cleanCache();
|
130 |
-
Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('ddg')->__('API Credentials Valid.'));
|
131 |
Â
}
|
Â
|
|
132 |
Â
return $this;
|
133 |
Â
}
|
134 |
Â
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
$helper->disableConfigForWebsite(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_SYNC_CONTACT_ENABLED);
|
144 |
-
Mage::getSingleton('adminhtml/session')->addNotice('The Contact Sync Disabled - No Addressbook Selected !');
|
145 |
-
}
|
146 |
-
if (! $subscriberAddressBook && $helper->getWebsiteConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_SYNC_SUBSCRIBER_ENABLED, $website)) {
|
147 |
-
$helper->disableConfigForWebsite( Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_SYNC_SUBSCRIBER_ENABLED );
|
148 |
-
Mage::getSingleton('adminhtml/session')->addNotice('The Subscriber Sync Disabled - No Addressbook Selected !');
|
149 |
-
}
|
150 |
-
|
151 |
Â
}
|
152 |
Â
|
153 |
Â
/**
|
154 |
-
*
|
155 |
Â
*
|
156 |
-
* @param $
|
157 |
-
* @param $data
|
158 |
Â
*
|
159 |
-
* @return
|
160 |
Â
*/
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
Â
|
|
Â
|
|
Â
|
|
168 |
Â
}
|
169 |
Â
|
170 |
-
return
|
171 |
Â
}
|
172 |
Â
|
173 |
Â
/**
|
174 |
-
*
|
175 |
Â
*
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
176 |
Â
*/
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
181 |
Â
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
182 |
Â
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
$websiteId = Mage::app()->getStore()->getWebsiteId();
|
194 |
-
|
195 |
-
if (!empty($segmentsIds) && $customerId) {
|
196 |
-
$this->addContactsFromWebsiteSegments($customerId, $segmentsIds, $websiteId);
|
197 |
-
}
|
198 |
-
|
199 |
-
return $this;
|
200 |
-
}
|
201 |
-
|
202 |
-
|
203 |
-
/**
|
204 |
-
* Add segment ids.
|
205 |
-
* @param $customerId
|
206 |
-
* @param $segmentIds
|
207 |
-
* @param $websiteId
|
208 |
-
*
|
209 |
-
* @return $this
|
210 |
-
*/
|
211 |
-
protected function addContactsFromWebsiteSegments($customerId, $segmentIds, $websiteId){
|
212 |
-
|
213 |
-
if (empty($segmentIds) || ! $customerId)
|
214 |
-
return $this;
|
215 |
-
$segmentIds = implode(',', $segmentIds);
|
216 |
-
|
217 |
-
$contact = Mage::getModel('ddg_automation/contact')->getCollection()
|
218 |
-
->addFieldToFilter('customer_id', $customerId)
|
219 |
-
->addFieldToFilter('website_id', $websiteId)
|
220 |
-
->setPageSize(1)
|
221 |
-
->getFirstItem();
|
222 |
-
try {
|
223 |
-
|
224 |
-
$contact->setSegmentIds($segmentIds)
|
225 |
-
->setEmailImported()
|
226 |
-
->save();
|
227 |
-
|
228 |
-
}catch (Exception $e){
|
229 |
-
Mage::logException($e);
|
230 |
-
}
|
231 |
-
|
232 |
-
return $this;
|
233 |
-
}
|
234 |
-
|
235 |
-
protected function getCustomerSegmentIdsForWebsite($customerId, $websiteId){
|
236 |
-
$segmentIds = Mage::getModel('ddg_automation/contact')->getCollection()
|
237 |
-
->addFieldToFilter('website_id', $websiteId)
|
238 |
-
->addFieldToFilter('customer_id', $customerId)
|
239 |
-
->getFirstItem()
|
240 |
-
->getSegmentIds();
|
241 |
-
|
242 |
-
return $segmentIds;
|
243 |
-
}
|
244 |
Â
}
|
6 |
Â
/**
|
7 |
Â
* API Sync and Data Mapping.
|
8 |
Â
* Reset contacts for reimport.
|
9 |
+
*
|
10 |
Â
* @return $this
|
11 |
Â
*/
|
12 |
Â
public function actionConfigResetContacts()
|
13 |
Â
{
|
14 |
Â
$contactModel = Mage::getModel('ddg_automation/contact');
|
15 |
+
$numImported = $contactModel->getNumberOfImportedContacs();
|
16 |
+
$updated = $contactModel->getResource()->resetAllContacts();
|
17 |
+
Mage::helper('ddg')->log(
|
18 |
+
'-- Imported contacts: ' . $numImported . ' reseted : ' . $updated
|
19 |
+
. ' --'
|
20 |
+
);
|
21 |
Â
|
22 |
Â
/**
|
23 |
+
* Check for addressbook mapping and disable if no address selected.
|
24 |
Â
*/
|
25 |
+
$this->checkAddressBookMapping(
|
26 |
+
Mage::app()->getRequest()->getParam('website')
|
27 |
+
);
|
28 |
Â
|
29 |
Â
return $this;
|
30 |
Â
}
|
31 |
Â
|
32 |
Â
/**
|
33 |
+
* Check for mapping configuration, and disable subscriber/contact sync if not mapped.
|
34 |
+
*
|
35 |
+
* @param $website
|
36 |
Â
*/
|
37 |
+
protected function checkAddressBookMapping($website)
|
38 |
Â
{
|
39 |
+
|
40 |
+
$helper = Mage::helper('ddg');
|
41 |
+
$customerAddressBook = $helper->getWebsiteConfig(
|
42 |
+
Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMERS_ADDRESS_BOOK_ID,
|
43 |
+
$website
|
44 |
+
);
|
45 |
+
$subscriberAddressBook = $helper->getWebsiteConfig(
|
46 |
+
Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_SUBSCRIBERS_ADDRESS_BOOK_ID,
|
47 |
+
$website
|
48 |
+
);
|
49 |
+
|
50 |
+
if (! $customerAddressBook
|
51 |
+
&& $helper->getWebsiteConfig(
|
52 |
+
Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_SYNC_CONTACT_ENABLED,
|
53 |
+
$website
|
54 |
+
)
|
55 |
+
) {
|
56 |
+
|
57 |
+
$helper->disableConfigForWebsite(
|
58 |
+
Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_SYNC_CONTACT_ENABLED
|
59 |
+
);
|
60 |
+
Mage::getSingleton('adminhtml/session')->addNotice(
|
61 |
+
'The Contact Sync Disabled - No Addressbook Selected !'
|
62 |
+
);
|
63 |
Â
}
|
64 |
+
if (! $subscriberAddressBook
|
65 |
+
&& $helper->getWebsiteConfig(
|
66 |
+
Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_SYNC_SUBSCRIBER_ENABLED,
|
67 |
+
$website
|
68 |
+
)
|
69 |
+
) {
|
70 |
+
$helper->disableConfigForWebsite(
|
71 |
+
Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_SYNC_SUBSCRIBER_ENABLED
|
72 |
+
);
|
73 |
+
Mage::getSingleton('adminhtml/session')->addNotice(
|
74 |
+
'The Subscriber Sync Disabled - No Addressbook Selected !'
|
75 |
+
);
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
76 |
Â
}
|
77 |
Â
|
Â
|
|
Â
|
|
78 |
Â
}
|
79 |
Â
|
80 |
Â
/**
|
81 |
Â
* API Credentials.
|
82 |
Â
* Installation and validation confirmation.
|
83 |
+
*
|
84 |
Â
* @return $this
|
85 |
Â
*/
|
86 |
Â
public function actionConfigSaveApi()
|
87 |
Â
{
|
88 |
Â
$groups = Mage::app()->getRequest()->getPost('groups');
|
89 |
+
if (isset($groups['api']['fields']['username']['inherit'])
|
90 |
+
|| isset($groups['api']['fields']['password']['inherit'])
|
91 |
+
) {
|
92 |
Â
return $this;
|
93 |
+
}
|
94 |
+
|
95 |
+
$apiUsername = isset($groups['api']['fields']['username']['value'])
|
96 |
+
? $groups['api']['fields']['username']['value'] : false;
|
97 |
+
$scopeId = 0;
|
98 |
+
if ($website = Mage::app()->getRequest()->getParam('website')) {
|
99 |
+
$scope = 'websites';
|
100 |
+
$scopeId = Mage::app()->getWebsite($website)->getId();
|
101 |
+
} else {
|
102 |
+
$scope = "default";
|
103 |
+
}
|
104 |
+
|
105 |
+
$apiPassword = Mage::helper('ddg')->getApiPassword($website);
|
106 |
Â
|
Â
|
|
Â
|
|
107 |
Â
//skip if the inherit option is selected
|
108 |
Â
if ($apiUsername && $apiPassword) {
|
109 |
Â
Mage::helper('ddg')->log('----VALIDATING ACCOUNT---');
|
110 |
Â
$testModel = Mage::getModel('ddg_automation/apiconnector_test');
|
111 |
+
|
112 |
Â
$isValid = $testModel->validate($apiUsername, $apiPassword);
|
113 |
+
$config = Mage::getConfig();
|
114 |
+
|
115 |
+
|
116 |
Â
if (! $isValid) {
|
117 |
Â
/**
|
118 |
Â
* Disable invalid Api credentials
|
119 |
Â
*/
|
120 |
+
$config->saveConfig(
|
121 |
+
Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_API_ENABLED,
|
122 |
+
0, $scope, $scopeId
|
123 |
+
);
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
124 |
Â
}
|
125 |
Â
|
126 |
Â
//check if returned value is an object
|
127 |
+
if (is_object($isValid)) {
|
128 |
Â
//save endpoint for account
|
129 |
+
foreach ($isValid->properties as $property) {
|
130 |
+
if ($property->name == 'ApiEndpoint'
|
131 |
+
&& strlen(
|
132 |
+
$property->value
|
133 |
+
)
|
134 |
+
) {
|
135 |
Â
$config->saveConfig(
|
136 |
Â
Dotdigitalgroup_Email_Helper_Config::PATH_FOR_API_ENDPOINT,
|
137 |
Â
$property->value
|
141 |
Â
}
|
142 |
Â
}
|
143 |
Â
$config->cleanCache();
|
Â
|
|
144 |
Â
}
|
145 |
+
|
146 |
Â
return $this;
|
147 |
Â
}
|
148 |
Â
|
149 |
+
/**
|
150 |
+
* Update Feed for latest releases.
|
151 |
+
*
|
152 |
+
*/
|
153 |
+
public function updateFeed()
|
154 |
+
{
|
155 |
+
Mage::getModel('ddg_automation/feed')->checkForUpgrade();
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
156 |
Â
}
|
157 |
Â
|
158 |
Â
/**
|
159 |
+
* Add modified segment for contact.
|
160 |
Â
*
|
161 |
+
* @param $observer
|
Â
|
|
162 |
Â
*
|
163 |
+
* @return $this
|
164 |
Â
*/
|
165 |
+
public function connectorCustomerSegmentChanged($observer)
|
166 |
+
{
|
167 |
+
$segmentsIds = $observer->getEvent()->getSegmentIds();
|
168 |
+
$customerId = Mage::getSingleton('customer/session')->getCustomerId();
|
169 |
+
$websiteId = Mage::app()->getStore()->getWebsiteId();
|
170 |
+
|
171 |
+
if (! empty($segmentsIds) && $customerId) {
|
172 |
+
$this->addContactsFromWebsiteSegments(
|
173 |
+
$customerId, $segmentsIds, $websiteId
|
174 |
+
);
|
175 |
Â
}
|
176 |
Â
|
177 |
+
return $this;
|
178 |
Â
}
|
179 |
Â
|
180 |
Â
/**
|
181 |
+
* Add segment ids.
|
182 |
Â
*
|
183 |
+
* @param $customerId
|
184 |
+
* @param $segmentIds
|
185 |
+
* @param $websiteId
|
186 |
+
*
|
187 |
+
* @return $this
|
188 |
Â
*/
|
189 |
+
protected function addContactsFromWebsiteSegments($customerId, $segmentIds,
|
190 |
+
$websiteId
|
191 |
+
) {
|
192 |
+
|
193 |
+
if (empty($segmentIds) || ! $customerId) {
|
194 |
+
return $this;
|
195 |
+
}
|
196 |
+
$segmentIds = implode(',', $segmentIds);
|
197 |
Â
|
198 |
+
$contact = Mage::getModel('ddg_automation/contact')->getCollection()
|
199 |
+
->addFieldToFilter('customer_id', $customerId)
|
200 |
+
->addFieldToFilter('website_id', $websiteId)
|
201 |
+
->setPageSize(1)
|
202 |
+
->getFirstItem();
|
203 |
+
try {
|
204 |
Â
|
205 |
+
$contact->setSegmentIds($segmentIds)
|
206 |
+
->setEmailImported()
|
207 |
+
->save();
|
208 |
+
|
209 |
+
} catch (Exception $e) {
|
210 |
+
Mage::logException($e);
|
211 |
+
}
|
212 |
+
|
213 |
+
return $this;
|
214 |
+
}
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
215 |
Â
}
|
@@ -1,45 +1,51 @@
|
|
1 |
Â
<?php
|
2 |
Â
|
3 |
-
|
4 |
Â
{
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
Â
|
|
12 |
Â
$fields = array();
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
43 |
Â
|
44 |
Â
return $fields;
|
45 |
Â
}
|
1 |
Â
<?php
|
2 |
Â
|
3 |
+
class Dotdigitalgroup_Email_Model_Adminhtml_Source_Addressbooks
|
4 |
Â
{
|
5 |
+
|
6 |
+
/**
|
7 |
+
* Returns the address books options.
|
8 |
+
*
|
9 |
+
* @return array
|
10 |
+
*/
|
11 |
+
public function toOptionArray()
|
12 |
+
{
|
13 |
Â
$fields = array();
|
14 |
+
// Add a "Do Not Map" Option
|
15 |
+
$fields[] = array('value' => 0, 'label' => Mage::helper('ddg')->__(
|
16 |
+
'-- Please Select --'
|
17 |
+
));
|
18 |
+
$website = Mage::app()->getRequest()->getParam('website');
|
19 |
+
|
20 |
+
$enabled = Mage::helper('ddg')->isEnabled($website);
|
21 |
+
|
22 |
+
//get address books options
|
23 |
+
if ($enabled) {
|
24 |
+
$client = Mage::getModel('ddg_automation/apiconnector_client');
|
25 |
+
$client->setApiUsername(
|
26 |
+
Mage::helper('ddg')->getApiUsername($website)
|
27 |
+
)
|
28 |
+
->setApiPassword(Mage::helper('ddg')->getApiPassword($website));
|
29 |
+
|
30 |
+
$savedAddressBooks = Mage::registry('addressbooks');
|
31 |
+
//get saved address books from registry
|
32 |
+
if ($savedAddressBooks) {
|
33 |
+
$addressBooks = $savedAddressBooks;
|
34 |
+
} else {
|
35 |
+
// api all address books
|
36 |
+
$addressBooks = $client->getAddressBooks();
|
37 |
+
Mage::register('addressbooks', $addressBooks);
|
38 |
+
}
|
39 |
+
|
40 |
+
//set up fields with book id and label
|
41 |
+
foreach ($addressBooks as $book) {
|
42 |
+
//check for address book id before displaying, IMPORTANT :Test address book cannot be used through api
|
43 |
+
if (isset($book->id) && $book->name != 'Test') {
|
44 |
+
$fields[] = array('value' => $book->id,
|
45 |
+
'label' => $book->name);
|
46 |
+
}
|
47 |
+
}
|
48 |
+
}
|
49 |
Â
|
50 |
Â
return $fields;
|
51 |
Â
}
|
@@ -2,72 +2,83 @@
|
|
2 |
Â
|
3 |
Â
class Dotdigitalgroup_Email_Model_Adminhtml_Source_Addressbookspref
|
4 |
Â
{
|
5 |
-
protected function getWebsite()
|
6 |
-
{
|
7 |
-
$website = Mage::app()->getWebsite();
|
8 |
-
$websiteParam = Mage::app()->getRequest()->getParam('website');
|
9 |
-
if($websiteParam)
|
10 |
-
$website = Mage::app()->getWebsite($websiteParam);
|
11 |
-
return $website;
|
12 |
-
}
|
13 |
Â
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
$website = $this->getWebsite();
|
22 |
-
$client = Mage::getModel( 'ddg_automation/apiconnector_client' );
|
23 |
-
$client->setApiUsername( Mage::helper( 'ddg' )->getApiUsername( $website ) )
|
24 |
-
->setApiPassword( Mage::helper( 'ddg' )->getApiPassword( $website ) );
|
25 |
Â
|
26 |
-
|
27 |
-
|
28 |
-
if ( $savedAddressBooks ) {
|
29 |
-
$addressBooks = $savedAddressBooks;
|
30 |
-
} else {
|
31 |
-
// api all address books
|
32 |
-
$addressBooks = $client->getAddressBooks();
|
33 |
-
Mage::register( 'addressbooks', $addressBooks );
|
34 |
-
}
|
35 |
-
return $addressBooks;
|
36 |
-
}
|
37 |
Â
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
Â
|
|
48 |
Â
|
49 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
50 |
Â
|
51 |
-
|
52 |
-
|
53 |
-
$addressBooks = $this->getAddressBooks();
|
54 |
-
//set the error message to the select option
|
55 |
-
if ( isset( $addressBooks->message ) ) {
|
56 |
-
$fields[] = array( 'value' => 0, 'label' => Mage::helper( 'ddg' )->__( $addressBooks->message) );
|
57 |
-
}
|
58 |
Â
|
59 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
60 |
Â
|
61 |
-
|
62 |
-
if ($addressBooks) {
|
63 |
-
foreach ( $addressBooks as $book ) {
|
64 |
-
if ( isset( $book->id ) && $book->visibility == 'Public' && $book->id != $subscriberAddressBook ) {
|
65 |
-
$fields[] = array( 'value' => $book->id, 'label' => $book->name );
|
66 |
-
}
|
67 |
-
}
|
68 |
-
}
|
69 |
-
}
|
70 |
Â
|
71 |
-
|
72 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
73 |
Â
}
|
2 |
Â
|
3 |
Â
class Dotdigitalgroup_Email_Model_Adminhtml_Source_Addressbookspref
|
4 |
Â
{
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
5 |
Â
|
6 |
+
protected function getWebsite()
|
7 |
+
{
|
8 |
+
$website = Mage::app()->getWebsite();
|
9 |
+
$websiteParam = Mage::app()->getRequest()->getParam('website');
|
10 |
+
if ($websiteParam) {
|
11 |
+
$website = Mage::app()->getWebsite($websiteParam);
|
12 |
+
}
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
13 |
Â
|
14 |
+
return $website;
|
15 |
+
}
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
16 |
Â
|
17 |
+
/**
|
18 |
+
* get address books
|
19 |
+
*
|
20 |
+
* @return null
|
21 |
+
*/
|
22 |
+
protected function getAddressBooks()
|
23 |
+
{
|
24 |
+
$website = $this->getWebsite();
|
25 |
+
$client = Mage::getModel('ddg_automation/apiconnector_client');
|
26 |
+
$client->setApiUsername(Mage::helper('ddg')->getApiUsername($website))
|
27 |
+
->setApiPassword(Mage::helper('ddg')->getApiPassword($website));
|
28 |
Â
|
29 |
+
$savedAddressBooks = Mage::registry('addressbooks');
|
30 |
+
//get saved address books from registry
|
31 |
+
if ($savedAddressBooks) {
|
32 |
+
$addressBooks = $savedAddressBooks;
|
33 |
+
} else {
|
34 |
+
// api all address books
|
35 |
+
$addressBooks = $client->getAddressBooks();
|
36 |
+
Mage::register('addressbooks', $addressBooks);
|
37 |
+
}
|
38 |
Â
|
39 |
+
return $addressBooks;
|
40 |
+
}
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
41 |
Â
|
42 |
+
/**
|
43 |
+
* addressbook options
|
44 |
+
*
|
45 |
+
* @return array
|
46 |
+
* @throws Mage_Core_Exception
|
47 |
+
*/
|
48 |
+
public function toOptionArray()
|
49 |
+
{
|
50 |
+
$fields = array();
|
51 |
+
$website = $this->getWebsite();
|
52 |
Â
|
53 |
+
$enabled = Mage::helper('ddg')->isEnabled($website);
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
54 |
Â
|
55 |
+
//get address books options
|
56 |
+
if ($enabled) {
|
57 |
+
$addressBooks = $this->getAddressBooks();
|
58 |
+
//set the error message to the select option
|
59 |
+
if (isset($addressBooks->message)) {
|
60 |
+
$fields[] = array('value' => 0,
|
61 |
+
'label' => Mage::helper('ddg')->__(
|
62 |
+
$addressBooks->message
|
63 |
+
));
|
64 |
+
}
|
65 |
+
|
66 |
+
$subscriberAddressBook = Mage::helper('ddg')
|
67 |
+
->getSubscriberAddressBook(Mage::app()->getWebsite());
|
68 |
+
|
69 |
+
//set up fields with book id and label
|
70 |
+
if ($addressBooks) {
|
71 |
+
foreach ($addressBooks as $book) {
|
72 |
+
if (isset($book->id) && $book->visibility == 'Public'
|
73 |
+
&& $book->id != $subscriberAddressBook
|
74 |
+
) {
|
75 |
+
$fields[] = array('value' => $book->id,
|
76 |
+
'label' => $book->name);
|
77 |
+
}
|
78 |
+
}
|
79 |
+
}
|
80 |
+
}
|
81 |
+
|
82 |
+
return $fields;
|
83 |
+
}
|
84 |
Â
}
|
@@ -3,41 +3,46 @@
|
|
3 |
Â
class Dotdigitalgroup_Email_Model_Adminhtml_Source_Advanced_Abandonedlimit
|
4 |
Â
{
|
5 |
Â
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
Â
|
|
Â
|
|
Â
|
|
11 |
Â
|
12 |
Â
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
Â
|
|
22 |
Â
|
23 |
Â
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
Â
|
|
40 |
Â
|
41 |
-
|
42 |
-
|
43 |
Â
}
|
3 |
Â
class Dotdigitalgroup_Email_Model_Adminhtml_Source_Advanced_Abandonedlimit
|
4 |
Â
{
|
5 |
Â
|
6 |
+
/**
|
7 |
+
* available times
|
8 |
+
*
|
9 |
+
* @var array
|
10 |
+
*/
|
11 |
+
protected $_times
|
12 |
+
= array(0, 1, 2, 3, 4, 5, 6, 12, 24, 36, 48, 60, 72, 84, 96, 108, 120,
|
13 |
+
240);
|
14 |
Â
|
15 |
Â
|
16 |
+
/**
|
17 |
+
* send to campain options hours
|
18 |
+
*
|
19 |
+
* @return array
|
20 |
+
*/
|
21 |
+
public function toOptionArray()
|
22 |
+
{
|
23 |
+
$result = $row = array();
|
24 |
+
$i = 0;
|
25 |
+
foreach ($this->_times as $one) {
|
26 |
Â
|
27 |
Â
|
28 |
+
if ($i == 0) {
|
29 |
+
$row = array('value' => $one,
|
30 |
+
'label' => Mage::helper('ddg')->__('No Limit'));
|
31 |
+
} elseif ($i == 1) {
|
32 |
+
$row = array(
|
33 |
+
'value' => $one,
|
34 |
+
'label' => Mage::helper('ddg')->__($one . ' Hour')
|
35 |
+
);
|
36 |
+
} else {
|
37 |
+
$row = array(
|
38 |
+
'value' => $one,
|
39 |
+
'label' => Mage::helper('ddg')->__($one . ' Hours')
|
40 |
+
);
|
41 |
+
}
|
42 |
+
$result[] = $row;
|
43 |
+
$i++;
|
44 |
+
}
|
45 |
Â
|
46 |
+
return $result;
|
47 |
+
}
|
48 |
Â
}
|
@@ -2,21 +2,25 @@
|
|
2 |
Â
|
3 |
Â
class Dotdigitalgroup_Email_Model_Adminhtml_Source_Advanced_Attributes
|
4 |
Â
{
|
Â
|
|
5 |
Â
/**
|
6 |
Â
* Returns custom order attributes
|
Â
|
|
7 |
Â
* @return array
|
8 |
Â
*/
|
9 |
Â
public function toOptionArray()
|
10 |
Â
{
|
11 |
-
$fields = Mage::getResourceModel('ddg_automation/order')
|
Â
|
|
12 |
Â
|
13 |
Â
$customFields = array();
|
14 |
-
foreach($fields as $key => $field){
|
15 |
Â
$customFields[] = array(
|
16 |
Â
'value' => $field['COLUMN_NAME'],
|
17 |
Â
'label' => $field['COLUMN_NAME']
|
18 |
Â
);
|
19 |
Â
}
|
Â
|
|
20 |
Â
return $customFields;
|
21 |
Â
}
|
22 |
Â
}
|
2 |
Â
|
3 |
Â
class Dotdigitalgroup_Email_Model_Adminhtml_Source_Advanced_Attributes
|
4 |
Â
{
|
5 |
+
|
6 |
Â
/**
|
7 |
Â
* Returns custom order attributes
|
8 |
+
*
|
9 |
Â
* @return array
|
10 |
Â
*/
|
11 |
Â
public function toOptionArray()
|
12 |
Â
{
|
13 |
+
$fields = Mage::getResourceModel('ddg_automation/order')
|
14 |
+
->getOrderTableDescription();
|
15 |
Â
|
16 |
Â
$customFields = array();
|
17 |
+
foreach ($fields as $key => $field) {
|
18 |
Â
$customFields[] = array(
|
19 |
Â
'value' => $field['COLUMN_NAME'],
|
20 |
Â
'label' => $field['COLUMN_NAME']
|
21 |
Â
);
|
22 |
Â
}
|
23 |
+
|
24 |
Â
return $customFields;
|
25 |
Â
}
|
26 |
Â
}
|
@@ -2,12 +2,16 @@
|
|
2 |
Â
|
3 |
Â
class Dotdigitalgroup_Email_Model_Adminhtml_Source_Advanced_Cronexpressionsone
|
4 |
Â
{
|
Â
|
|
5 |
Â
public function toOptionArray()
|
6 |
Â
{
|
7 |
Â
return array(
|
8 |
-
array('value' => '*/5 * * * *',
|
9 |
-
|
10 |
-
array('value' => '*/
|
Â
|
|
Â
|
|
Â
|
|
11 |
Â
);
|
12 |
Â
}
|
13 |
Â
}
|
2 |
Â
|
3 |
Â
class Dotdigitalgroup_Email_Model_Adminhtml_Source_Advanced_Cronexpressionsone
|
4 |
Â
{
|
5 |
+
|
6 |
Â
public function toOptionArray()
|
7 |
Â
{
|
8 |
Â
return array(
|
9 |
+
array('value' => '*/5 * * * *',
|
10 |
+
'label' => Mage::helper('ddg')->__('Every 5 Minutes')),
|
11 |
+
array('value' => '*/10 * * * *',
|
12 |
+
'label' => Mage::helper('ddg')->__('Every 10 Minutes')),
|
13 |
+
array('value' => '*/15 * * * *',
|
14 |
+
'label' => Mage::helper('ddg')->__('Every 15 Minutes')),
|
15 |
Â
);
|
16 |
Â
}
|
17 |
Â
}
|
@@ -2,12 +2,16 @@
|
|
2 |
Â
|
3 |
Â
class Dotdigitalgroup_Email_Model_Adminhtml_Source_Advanced_Cronexpressionstwo
|
4 |
Â
{
|
Â
|
|
5 |
Â
public function toOptionArray()
|
6 |
Â
{
|
7 |
Â
return array(
|
8 |
-
array('value' => '*/15 * * * *',
|
9 |
-
|
10 |
-
array('value' => '
|
Â
|
|
Â
|
|
Â
|
|
11 |
Â
);
|
12 |
Â
}
|
13 |
Â
}
|
2 |
Â
|
3 |
Â
class Dotdigitalgroup_Email_Model_Adminhtml_Source_Advanced_Cronexpressionstwo
|
4 |
Â
{
|
5 |
+
|
6 |
Â
public function toOptionArray()
|
7 |
Â
{
|
8 |
Â
return array(
|
9 |
+
array('value' => '*/15 * * * *',
|
10 |
+
'label' => Mage::helper('ddg')->__('Every 15 Minutes')),
|
11 |
+
array('value' => '*/30 * * * *',
|
12 |
+
'label' => Mage::helper('ddg')->__('Every 30 Minutes')),
|
13 |
+
array('value' => '00 * * * *',
|
14 |
+
'label' => Mage::helper('ddg')->__('Every 60 Minutes')),
|
15 |
Â
);
|
16 |
Â
}
|
17 |
Â
}
|
@@ -2,14 +2,19 @@
|
|
2 |
Â
|
3 |
Â
class Dotdigitalgroup_Email_Model_Adminhtml_Source_Advanced_Frequency
|
4 |
Â
{
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
15 |
Â
}
|
2 |
Â
|
3 |
Â
class Dotdigitalgroup_Email_Model_Adminhtml_Source_Advanced_Frequency
|
4 |
Â
{
|
5 |
+
|
6 |
+
public function toOptionArray()
|
7 |
+
{
|
8 |
+
return array(
|
9 |
+
array('value' => '1', 'label' => Mage::helper('ddg')->__('1 Hour')),
|
10 |
+
array('value' => '2',
|
11 |
+
'label' => Mage::helper('ddg')->__('2 Hours')),
|
12 |
+
array('value' => '6',
|
13 |
+
'label' => Mage::helper('ddg')->__('6 Hours')),
|
14 |
+
array('value' => '12',
|
15 |
+
'label' => Mage::helper('ddg')->__('12 Hours')),
|
16 |
+
array('value' => '24',
|
17 |
+
'label' => Mage::helper('ddg')->__('24 Hours'))
|
18 |
+
);
|
19 |
+
}
|
20 |
Â
}
|
@@ -2,20 +2,23 @@
|
|
2 |
Â
|
3 |
Â
class Dotdigitalgroup_Email_Model_Adminhtml_Source_Advanced_Quoteattributes
|
4 |
Â
{
|
Â
|
|
5 |
Â
/**
|
6 |
Â
* @return array
|
7 |
Â
*/
|
8 |
Â
public function toOptionArray()
|
9 |
Â
{
|
10 |
-
$fields = Mage::getResourceModel('ddg_automation/quote')
|
Â
|
|
11 |
Â
|
12 |
Â
$customFields = array();
|
13 |
-
foreach($fields as $key => $field){
|
14 |
Â
$customFields[] = array(
|
15 |
Â
'value' => $field['COLUMN_NAME'],
|
16 |
Â
'label' => $field['COLUMN_NAME']
|
17 |
Â
);
|
18 |
Â
}
|
Â
|
|
19 |
Â
return $customFields;
|
20 |
Â
}
|
21 |
Â
}
|
2 |
Â
|
3 |
Â
class Dotdigitalgroup_Email_Model_Adminhtml_Source_Advanced_Quoteattributes
|
4 |
Â
{
|
5 |
+
|
6 |
Â
/**
|
7 |
Â
* @return array
|
8 |
Â
*/
|
9 |
Â
public function toOptionArray()
|
10 |
Â
{
|
11 |
+
$fields = Mage::getResourceModel('ddg_automation/quote')
|
12 |
+
->getQuoteTableDescription();
|
13 |
Â
|
14 |
Â
$customFields = array();
|
15 |
+
foreach ($fields as $key => $field) {
|
16 |
Â
$customFields[] = array(
|
17 |
Â
'value' => $field['COLUMN_NAME'],
|
18 |
Â
'label' => $field['COLUMN_NAME']
|
19 |
Â
);
|
20 |
Â
}
|
21 |
+
|
22 |
Â
return $customFields;
|
23 |
Â
}
|
24 |
Â
}
|
@@ -2,6 +2,7 @@
|
|
2 |
Â
|
3 |
Â
class Dotdigitalgroup_Email_Model_Adminhtml_Source_Advanced_Transdata
|
4 |
Â
{
|
Â
|
|
5 |
Â
/**
|
6 |
Â
* @return array
|
7 |
Â
*/
|
2 |
Â
|
3 |
Â
class Dotdigitalgroup_Email_Model_Adminhtml_Source_Advanced_Transdata
|
4 |
Â
{
|
5 |
+
|
6 |
Â
/**
|
7 |
Â
* @return array
|
8 |
Â
*/
|
@@ -2,9 +2,12 @@
|
|
2 |
Â
|
3 |
Â
class Dotdigitalgroup_Email_Model_Adminhtml_Source_Attributes
|
4 |
Â
{
|
Â
|
|
5 |
Â
public function toOptionArray()
|
6 |
Â
{
|
7 |
-
$attributes = Mage::getResourceModel(
|
Â
|
|
Â
|
|
8 |
Â
->addVisibleFilter();
|
9 |
Â
|
10 |
Â
$attributeArray = array(
|
@@ -14,12 +17,13 @@ class Dotdigitalgroup_Email_Model_Adminhtml_Source_Attributes
|
|
14 |
Â
)
|
15 |
Â
);
|
16 |
Â
|
17 |
-
foreach($attributes as $attribute){
|
18 |
Â
$attributeArray[] = array(
|
19 |
Â
'label' => $attribute->getFrontendLabel(),
|
20 |
Â
'value' => $attribute->getAttributeCode()
|
21 |
Â
);
|
22 |
Â
}
|
Â
|
|
23 |
Â
return $attributeArray;
|
24 |
Â
}
|
25 |
Â
}
|
2 |
Â
|
3 |
Â
class Dotdigitalgroup_Email_Model_Adminhtml_Source_Attributes
|
4 |
Â
{
|
5 |
+
|
6 |
Â
public function toOptionArray()
|
7 |
Â
{
|
8 |
+
$attributes = Mage::getResourceModel(
|
9 |
+
'catalog/product_attribute_collection'
|
10 |
+
)
|
11 |
Â
->addVisibleFilter();
|
12 |
Â
|
13 |
Â
$attributeArray = array(
|
17 |
Â
)
|
18 |
Â
);
|
19 |
Â
|
20 |
+
foreach ($attributes as $attribute) {
|
21 |
Â
$attributeArray[] = array(
|
22 |
Â
'label' => $attribute->getFrontendLabel(),
|
23 |
Â
'value' => $attribute->getAttributeCode()
|
24 |
Â
);
|
25 |
Â
}
|
26 |
+
|
27 |
Â
return $attributeArray;
|
28 |
Â
}
|
29 |
Â
}
|
@@ -3,42 +3,44 @@
|
|
3 |
Â
class Dotdigitalgroup_Email_Model_Adminhtml_Source_Automation_Programme
|
4 |
Â
{
|
5 |
Â
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
if (! $websiteCode)
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
Â
|
|
Â
|
|
43 |
Â
|
44 |
Â
}
|
3 |
Â
class Dotdigitalgroup_Email_Model_Adminhtml_Source_Automation_Programme
|
4 |
Â
{
|
5 |
Â
|
6 |
+
/**
|
7 |
+
* @return array
|
8 |
+
* @throws Mage_Core_Exception
|
9 |
+
*/
|
10 |
+
public function toOptionArray()
|
11 |
+
{
|
12 |
+
$fields = array();
|
13 |
+
$websiteCode = Mage::app()->getRequest()->getParam('website', false);
|
14 |
+
|
15 |
+
//website code param
|
16 |
+
if ( ! $websiteCode) {
|
17 |
+
$websiteCode = 0;
|
18 |
+
}//use admin
|
19 |
+
|
20 |
+
$website = Mage::app()->getWebsite($websiteCode);
|
21 |
+
|
22 |
+
$fields[] = array('value' => '0',
|
23 |
+
'label' => Mage::helper('ddg')->__('-- Disabled --'));
|
24 |
+
|
25 |
+
if (Mage::helper('ddg')->isEnabled($website)) {
|
26 |
+
|
27 |
+
$client = Mage::helper('ddg')->getWebsiteApiClient($website);
|
28 |
+
$programmes = $client->getPrograms();
|
29 |
+
if ($programmes) {
|
30 |
+
foreach ($programmes as $one) {
|
31 |
+
if (isset($one->id)) {
|
32 |
+
if ($one->status == 'Active') {
|
33 |
+
$fields[] = array(
|
34 |
+
'value' => $one->id,
|
35 |
+
'label' => Mage::helper('ddg')->__($one->name)
|
36 |
+
);
|
37 |
+
}
|
38 |
+
}
|
39 |
+
}
|
40 |
+
}
|
41 |
+
}
|
42 |
+
|
43 |
+
return $fields;
|
44 |
+
}
|
45 |
Â
|
46 |
Â
}
|
@@ -3,54 +3,59 @@
|
|
3 |
Â
class Dotdigitalgroup_Email_Model_Adminhtml_Source_Campaigns
|
4 |
Â
{
|
5 |
Â
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
Â
{
|
14 |
Â
$fields = array();
|
15 |
Â
$websiteName = Mage::app()->getRequest()->getParam('website', false);
|
16 |
Â
|
17 |
Â
$website = Mage::app()->getRequest()->getParam('website', false);
|
18 |
-
if ($website)
|
19 |
Â
$website = Mage::app()->getWebsite($website);
|
20 |
-
else
|
21 |
Â
$website = 0;
|
22 |
-
|
Â
|
|
Â
|
|
Â
|
|
23 |
Â
|
24 |
-
|
25 |
Â
$website = Mage::app()->getWebsite($websiteName);
|
26 |
Â
}
|
27 |
Â
|
28 |
-
|
29 |
Â
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
Â
|
34 |
-
|
35 |
Â
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
Â
|
45 |
-
|
46 |
-
|
47 |
Â
$fields[] = array(
|
48 |
Â
'value' => $one->id,
|
49 |
-
'label' => Mage::helper('ddg')->__(
|
Â
|
|
Â
|
|
50 |
Â
);
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
Â
|
55 |
Â
return $fields;
|
56 |
Â
}
|
3 |
Â
class Dotdigitalgroup_Email_Model_Adminhtml_Source_Campaigns
|
4 |
Â
{
|
5 |
Â
|
6 |
+
/**
|
7 |
+
* Returns the campaigns options.
|
8 |
+
*
|
9 |
+
* @return array
|
10 |
+
* @throws Mage_Core_Exception
|
11 |
+
*/
|
12 |
+
public function toOptionArray()
|
13 |
Â
{
|
14 |
Â
$fields = array();
|
15 |
Â
$websiteName = Mage::app()->getRequest()->getParam('website', false);
|
16 |
Â
|
17 |
Â
$website = Mage::app()->getRequest()->getParam('website', false);
|
18 |
+
if ($website) {
|
19 |
Â
$website = Mage::app()->getWebsite($website);
|
20 |
+
} else {
|
21 |
Â
$website = 0;
|
22 |
+
}
|
23 |
+
$fields[] = array('value' => '0', 'label' => Mage::helper('ddg')->__(
|
24 |
+
'-- Please Select --'
|
25 |
+
));
|
26 |
Â
|
27 |
+
if ($websiteName) {
|
28 |
Â
$website = Mage::app()->getWebsite($websiteName);
|
29 |
Â
}
|
30 |
Â
|
31 |
+
$enabled = Mage::helper('ddg')->isEnabled($website);
|
32 |
Â
|
33 |
+
//api enabled get campaigns
|
34 |
+
if ($enabled) {
|
35 |
+
$client = Mage::helper('ddg')->getWebsiteApiClient($website);
|
36 |
Â
|
37 |
+
$savedCampaigns = Mage::registry('savedcampigns');
|
38 |
Â
|
39 |
+
//get campaigns from registry
|
40 |
+
if ($savedCampaigns) {
|
41 |
+
$campaigns = $savedCampaigns;
|
42 |
+
} else {
|
43 |
+
$campaigns = $client->getCampaigns();
|
44 |
+
Mage::unregister('savedcampigns');
|
45 |
+
Mage::register('savedcampigns', $campaigns);
|
46 |
+
}
|
47 |
Â
|
48 |
+
foreach ($campaigns as $one) {
|
49 |
+
if (isset($one->id)) {
|
50 |
Â
$fields[] = array(
|
51 |
Â
'value' => $one->id,
|
52 |
+
'label' => Mage::helper('ddg')->__(
|
53 |
+
addslashes($one->name)
|
54 |
+
)
|
55 |
Â
);
|
56 |
+
}
|
57 |
+
}
|
58 |
+
}
|
59 |
Â
|
60 |
Â
return $fields;
|
61 |
Â
}
|
@@ -2,15 +2,16 @@
|
|
2 |
Â
|
3 |
Â
class Dotdigitalgroup_Email_Model_Adminhtml_Source_Contact_Imported
|
4 |
Â
{
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
Â
|
|
11 |
Â
{
|
12 |
Â
return array(
|
13 |
-
'1'
|
14 |
Â
'null' => Mage::helper('ddg')->__('Not Imported'),
|
15 |
Â
);
|
16 |
Â
}
|
2 |
Â
|
3 |
Â
class Dotdigitalgroup_Email_Model_Adminhtml_Source_Contact_Imported
|
4 |
Â
{
|
5 |
+
|
6 |
+
/**
|
7 |
+
* Contact imported options.
|
8 |
+
*
|
9 |
+
* @return array
|
10 |
+
*/
|
11 |
+
public function getOptions()
|
12 |
Â
{
|
13 |
Â
return array(
|
14 |
+
'1' => Mage::helper('ddg')->__('Imported'),
|
15 |
Â
'null' => Mage::helper('ddg')->__('Not Imported'),
|
16 |
Â
);
|
17 |
Â
}
|
@@ -2,15 +2,16 @@
|
|
2 |
Â
|
3 |
Â
class Dotdigitalgroup_Email_Model_Adminhtml_Source_Contact_Modified
|
4 |
Â
{
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
Â
|
|
11 |
Â
{
|
12 |
Â
return array(
|
13 |
-
'1'
|
14 |
Â
'null' => Mage::helper('ddg')->__('Not Modified'),
|
15 |
Â
);
|
16 |
Â
}
|
2 |
Â
|
3 |
Â
class Dotdigitalgroup_Email_Model_Adminhtml_Source_Contact_Modified
|
4 |
Â
{
|
5 |
+
|
6 |
+
/**
|
7 |
+
* Contact imported options.
|
8 |
+
*
|
9 |
+
* @return array
|
10 |
+
*/
|
11 |
+
public function getOptions()
|
12 |
Â
{
|
13 |
Â
return array(
|
14 |
+
'1' => Mage::helper('ddg')->__('Modified'),
|
15 |
Â
'null' => Mage::helper('ddg')->__('Not Modified'),
|
16 |
Â
);
|
17 |
Â
}
|
@@ -3,31 +3,35 @@
|
|
3 |
Â
class Dotdigitalgroup_Email_Model_Adminhtml_Source_Customer_Attributes_Select
|
4 |
Â
{
|
5 |
Â
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
Â
{
|
13 |
Â
|
14 |
Â
$options = array();
|
15 |
Â
//exclude attributes from mapping
|
16 |
-
$excluded
|
17 |
-
|
18 |
-
|
Â
|
|
Â
|
|
Â
|
|
19 |
Â
$attributes = Mage::getModel('customer/customer')->getAttributes();
|
20 |
Â
|
21 |
Â
foreach ($attributes as $attribute) {
|
22 |
Â
if ($attribute->getFrontendLabel()) {
|
23 |
Â
$code = $attribute->getAttributeCode();
|
24 |
-
|
25 |
-
|
26 |
-
if(!in_array($code, $excluded))
|
27 |
Â
$options[] = array(
|
28 |
Â
'value' => $attribute->getAttributeCode(),
|
29 |
Â
'label' => $label
|
30 |
Â
);
|
Â
|
|
31 |
Â
}
|
32 |
Â
}
|
33 |
Â
|
3 |
Â
class Dotdigitalgroup_Email_Model_Adminhtml_Source_Customer_Attributes_Select
|
4 |
Â
{
|
5 |
Â
|
6 |
+
/**
|
7 |
+
* customer custom attributes.
|
8 |
+
*
|
9 |
+
* @return array
|
10 |
+
*/
|
11 |
+
public function toOptionArray()
|
12 |
Â
{
|
13 |
Â
|
14 |
Â
$options = array();
|
15 |
Â
//exclude attributes from mapping
|
16 |
+
$excluded
|
17 |
+
= array('created_at', 'created_in', 'dob',
|
18 |
+
'dotmailer_contact_id', 'email', 'firstname',
|
19 |
+
'lastname', 'gender',
|
20 |
+
'group_id', 'password_hash', 'prefix', 'rp_token',
|
21 |
+
'rp_token_create_at', 'website_id');
|
22 |
Â
$attributes = Mage::getModel('customer/customer')->getAttributes();
|
23 |
Â
|
24 |
Â
foreach ($attributes as $attribute) {
|
25 |
Â
if ($attribute->getFrontendLabel()) {
|
26 |
Â
$code = $attribute->getAttributeCode();
|
27 |
+
//escape the label in case of quotes
|
28 |
+
$label = addslashes($attribute->getFrontendLabel());
|
29 |
+
if ( ! in_array($code, $excluded)) {
|
30 |
Â
$options[] = array(
|
31 |
Â
'value' => $attribute->getAttributeCode(),
|
32 |
Â
'label' => $label
|
33 |
Â
);
|
34 |
+
}
|
35 |
Â
}
|
36 |
Â
}
|
37 |
Â
|
@@ -2,53 +2,60 @@
|
|
2 |
Â
|
3 |
Â
class Dotdigitalgroup_Email_Model_Adminhtml_Source_Datafields
|
4 |
Â
{
|
Â
|
|
5 |
Â
/**
|
6 |
Â
* Datafields option.
|
Â
|
|
7 |
Â
* @return array
|
8 |
Â
*/
|
9 |
Â
public function toOptionArray()
|
10 |
Â
{
|
11 |
Â
$fields = array();
|
12 |
Â
$helper = Mage::helper('ddg');
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
52 |
Â
|
53 |
Â
return $fields;
|
54 |
Â
}
|
2 |
Â
|
3 |
Â
class Dotdigitalgroup_Email_Model_Adminhtml_Source_Datafields
|
4 |
Â
{
|
5 |
+
|
6 |
Â
/**
|
7 |
Â
* Datafields option.
|
8 |
+
*
|
9 |
Â
* @return array
|
10 |
Â
*/
|
11 |
Â
public function toOptionArray()
|
12 |
Â
{
|
13 |
Â
$fields = array();
|
14 |
Â
$helper = Mage::helper('ddg');
|
15 |
+
//default data option
|
16 |
+
$fields[] = array('value' => 0, 'label' => Mage::helper('ddg')->__(
|
17 |
+
'-- Please Select --'
|
18 |
+
));
|
19 |
+
|
20 |
+
$website = Mage::app()->getRequest()->getParam('website', 0);
|
21 |
+
$client = $helper->getWebsiteApiClient($website);
|
22 |
+
|
23 |
+
//get datafields options
|
24 |
+
if ($helper->isEnabled($website)) {
|
25 |
+
|
26 |
+
$savedDatafields = Mage::registry('datafields');
|
27 |
+
|
28 |
+
//get saved datafileds from registry
|
29 |
+
if ($savedDatafields) {
|
30 |
+
$datafields = $savedDatafields;
|
31 |
+
} else {
|
32 |
+
//grab the datafields request and save to register
|
33 |
+
$datafields = $client->getDataFields();
|
34 |
+
Mage::register('datafields', $datafields);
|
35 |
+
}
|
36 |
+
|
37 |
+
//set the api error message for the first option
|
38 |
+
if (isset($datafields->message)) {
|
39 |
+
|
40 |
+
//message
|
41 |
+
$fields[] = array('value' => 0,
|
42 |
+
'label' => Mage::helper('ddg')->__(
|
43 |
+
$datafields->message
|
44 |
+
));
|
45 |
+
|
46 |
+
} elseif (is_array($datafields)) {
|
47 |
+
|
48 |
+
//loop for all datafields option
|
49 |
+
foreach ($datafields as $datafield) {
|
50 |
+
if (isset($datafield->name)) {
|
51 |
+
$fields[] = array(
|
52 |
+
'value' => $datafield->name,
|
53 |
+
'label' => Mage::helper('ddg')->__($datafield->name)
|
54 |
+
);
|
55 |
+
}
|
56 |
+
}
|
57 |
+
}
|
58 |
+
}
|
59 |
Â
|
60 |
Â
return $fields;
|
61 |
Â
}
|
@@ -2,16 +2,19 @@
|
|
2 |
Â
|
3 |
Â
class Dotdigitalgroup_Email_Model_Adminhtml_Source_Datamapping_Datafieldaccess
|
4 |
Â
{
|
5 |
-
/**
|
6 |
-
* @return array
|
7 |
-
*/
|
8 |
-
public function toOptionArray()
|
9 |
-
{
|
10 |
-
$dataType = array(
|
11 |
-
array('value' => 'Private', 'label' => Mage::helper('ddg')->__('Private')),
|
12 |
-
array('value' => 'Public', 'label' => Mage::helper('ddg')->__('Public')),
|
13 |
-
);
|
14 |
Â
|
15 |
-
|
16 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
17 |
Â
}
|
2 |
Â
|
3 |
Â
class Dotdigitalgroup_Email_Model_Adminhtml_Source_Datamapping_Datafieldaccess
|
4 |
Â
{
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
5 |
Â
|
6 |
+
/**
|
7 |
+
* @return array
|
8 |
+
*/
|
9 |
+
public function toOptionArray()
|
10 |
+
{
|
11 |
+
$dataType = array(
|
12 |
+
array('value' => 'Private',
|
13 |
+
'label' => Mage::helper('ddg')->__('Private')),
|
14 |
+
array('value' => 'Public',
|
15 |
+
'label' => Mage::helper('ddg')->__('Public')),
|
16 |
+
);
|
17 |
+
|
18 |
+
return $dataType;
|
19 |
+
}
|
20 |
Â
}
|
@@ -2,18 +2,24 @@
|
|
2 |
Â
|
3 |
Â
class Dotdigitalgroup_Email_Model_Adminhtml_Source_Datamapping_Datafieldtype
|
4 |
Â
{
|
Â
|
|
5 |
Â
/**
|
6 |
Â
* Datafield model type.
|
7 |
Â
* Data mapping.
|
Â
|
|
8 |
Â
* @return array
|
9 |
Â
*/
|
10 |
Â
public function toOptionArray()
|
11 |
Â
{
|
12 |
Â
$dataType = array(
|
13 |
-
array('value' => 'String',
|
14 |
-
|
15 |
-
array('value' => '
|
16 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
17 |
Â
);
|
18 |
Â
|
19 |
Â
return $dataType;
|
2 |
Â
|
3 |
Â
class Dotdigitalgroup_Email_Model_Adminhtml_Source_Datamapping_Datafieldtype
|
4 |
Â
{
|
5 |
+
|
6 |
Â
/**
|
7 |
Â
* Datafield model type.
|
8 |
Â
* Data mapping.
|
9 |
+
*
|
10 |
Â
* @return array
|
11 |
Â
*/
|
12 |
Â
public function toOptionArray()
|
13 |
Â
{
|
14 |
Â
$dataType = array(
|
15 |
+
array('value' => 'String',
|
16 |
+
'label' => Mage::helper('ddg')->__('String')),
|
17 |
+
array('value' => 'Numeric',
|
18 |
+
'label' => Mage::helper('ddg')->__('Numeric')),
|
19 |
+
array('value' => 'Date',
|
20 |
+
'label' => Mage::helper('ddg')->__('Date')),
|
21 |
+
array('value' => 'Boolean',
|
22 |
+
'label' => Mage::helper('ddg')->__('Yes/No'))
|
23 |
Â
);
|
24 |
Â
|
25 |
Â
return $dataType;
|
@@ -2,15 +2,17 @@
|
|
2 |
Â
|
3 |
Â
class Dotdigitalgroup_Email_Model_Adminhtml_Source_Dynamic_Displaytype
|
4 |
Â
{
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
Â
|
|
11 |
Â
{
|
12 |
Â
return array(
|
13 |
-
array('value' => 'grid',
|
Â
|
|
14 |
Â
array('value' => 'list', 'label' => Mage::helper('ddg')->__('List'))
|
15 |
Â
);
|
16 |
Â
|
2 |
Â
|
3 |
Â
class Dotdigitalgroup_Email_Model_Adminhtml_Source_Dynamic_Displaytype
|
4 |
Â
{
|
5 |
+
|
6 |
+
/**
|
7 |
+
* Display type mode.
|
8 |
+
*
|
9 |
+
* @return array
|
10 |
+
*/
|
11 |
+
public function toOptionArray()
|
12 |
Â
{
|
13 |
Â
return array(
|
14 |
+
array('value' => 'grid',
|
15 |
+
'label' => Mage::helper('ddg')->__('Grid')),
|
16 |
Â
array('value' => 'list', 'label' => Mage::helper('ddg')->__('List'))
|
17 |
Â
);
|
18 |
Â
|
@@ -2,6 +2,7 @@
|
|
2 |
Â
|
3 |
Â
class Dotdigitalgroup_Email_Model_Adminhtml_Source_Dynamic_Gridview
|
4 |
Â
{
|
Â
|
|
5 |
Â
/**
|
6 |
Â
* grid display options.
|
7 |
Â
*
|
2 |
Â
|
3 |
Â
class Dotdigitalgroup_Email_Model_Adminhtml_Source_Dynamic_Gridview
|
4 |
Â
{
|
5 |
+
|
6 |
Â
/**
|
7 |
Â
* grid display options.
|
8 |
Â
*
|
@@ -2,6 +2,7 @@
|
|
2 |
Â
|
3 |
Â
class Dotdigitalgroup_Email_Model_Adminhtml_Source_Fontpicker
|
4 |
Â
{
|
Â
|
|
5 |
Â
/**
|
6 |
Â
* Options getter. web safe fonts
|
7 |
Â
*
|
@@ -11,25 +12,29 @@ class Dotdigitalgroup_Email_Model_Adminhtml_Source_Fontpicker
|
|
11 |
Â
{
|
12 |
Â
return array(
|
13 |
Â
array('value' => "Arial, Helvetica, sans-serif",
|
14 |
-
|
15 |
Â
array('value' => "'Arial Black', Gadget, sans-serif",
|
16 |
-
|
17 |
Â
array('value' => "'Courier New', Courier, monospace",
|
18 |
-
|
19 |
Â
array('value' => "Georgia, serif",
|
20 |
-
|
21 |
Â
array('value' => "'MS Sans Serif', Geneva, sans-serif",
|
22 |
-
|
23 |
Â
array('value' => "'Palatino Linotype', 'Book Antiqua', Palatino, serif",
|
24 |
-
|
Â
|
|
Â
|
|
25 |
Â
array('value' => "Tahoma, Geneva, sans-serif",
|
26 |
-
|
27 |
Â
array('value' => "'Times New Roman', Times, serif",
|
28 |
-
|
29 |
Â
array('value' => "'Trebuchet MS', Helvetica, sans-serif",
|
30 |
-
|
Â
|
|
Â
|
|
31 |
Â
array('value' => "Verdana, Geneva, sans-serif",
|
32 |
-
|
33 |
Â
);
|
34 |
Â
}
|
35 |
Â
}
|
2 |
Â
|
3 |
Â
class Dotdigitalgroup_Email_Model_Adminhtml_Source_Fontpicker
|
4 |
Â
{
|
5 |
+
|
6 |
Â
/**
|
7 |
Â
* Options getter. web safe fonts
|
8 |
Â
*
|
12 |
Â
{
|
13 |
Â
return array(
|
14 |
Â
array('value' => "Arial, Helvetica, sans-serif",
|
15 |
+
'label' => Mage::helper('ddg')->__("Arial, Helvetica")),
|
16 |
Â
array('value' => "'Arial Black', Gadget, sans-serif",
|
17 |
+
'label' => Mage::helper('ddg')->__("Arial Black, Gadget")),
|
18 |
Â
array('value' => "'Courier New', Courier, monospace",
|
19 |
+
'label' => Mage::helper('ddg')->__("Courier New, Courier")),
|
20 |
Â
array('value' => "Georgia, serif",
|
21 |
+
'label' => Mage::helper('ddg')->__("Georgia")),
|
22 |
Â
array('value' => "'MS Sans Serif', Geneva, sans-serif",
|
23 |
+
'label' => Mage::helper('ddg')->__("MS Sans Serif, Geneva")),
|
24 |
Â
array('value' => "'Palatino Linotype', 'Book Antiqua', Palatino, serif",
|
25 |
+
'label' => Mage::helper('ddg')->__(
|
26 |
+
"Palatino Linotype, Book Antiqua"
|
27 |
+
)),
|
28 |
Â
array('value' => "Tahoma, Geneva, sans-serif",
|
29 |
+
'label' => Mage::helper('ddg')->__("Tahoma, Geneva")),
|
30 |
Â
array('value' => "'Times New Roman', Times, serif",
|
31 |
+
'label' => Mage::helper('ddg')->__("Times New Roman, Times")),
|
32 |
Â
array('value' => "'Trebuchet MS', Helvetica, sans-serif",
|
33 |
+
'label' => Mage::helper('ddg')->__(
|
34 |
+
"Trebuchet MS, Helvetica"
|
35 |
+
)),
|
36 |
Â
array('value' => "Verdana, Geneva, sans-serif",
|
37 |
+
'label' => Mage::helper('ddg')->__("Verdana, Geneva")),
|
38 |
Â
);
|
39 |
Â
}
|
40 |
Â
}
|
@@ -2,6 +2,7 @@
|
|
2 |
Â
|
3 |
Â
class Dotdigitalgroup_Email_Model_Adminhtml_Source_Fontsize
|
4 |
Â
{
|
Â
|
|
5 |
Â
/**
|
6 |
Â
* Options getter. Styling options
|
7 |
Â
*
|
2 |
Â
|
3 |
Â
class Dotdigitalgroup_Email_Model_Adminhtml_Source_Fontsize
|
4 |
Â
{
|
5 |
+
|
6 |
Â
/**
|
7 |
Â
* Options getter. Styling options
|
8 |
Â
*
|
@@ -0,0 +1,18 @@
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Dotdigitalgroup_Email_Model_Adminhtml_Source_Importer_Bulklimit
|
4 |
+
{
|
5 |
+
/**
|
6 |
+
* @return array
|
7 |
+
*/
|
8 |
+
public function toOptionArray()
|
9 |
+
{
|
10 |
+
return array(
|
11 |
+
array('value' => '1', 'label' => '1'),
|
12 |
+
array('value' => '2', 'label' => '2'),
|
13 |
+
array('value' => '3', 'label' => '3'),
|
14 |
+
array('value' => '4', 'label' => '4'),
|
15 |
+
array('value' => '5', 'label' => '5')
|
16 |
+
);
|
17 |
+
}
|
18 |
+
}
|
@@ -10,13 +10,13 @@ class Dotdigitalgroup_Email_Model_Adminhtml_Source_Importer_Mode
|
|
10 |
Â
public function getOptions()
|
11 |
Â
{
|
12 |
Â
return array(
|
13 |
-
Dotdigitalgroup_Email_Model_Importer::MODE_BULK => Mage::helper('ddg')->__(
|
14 |
-
Dotdigitalgroup_Email_Model_Importer::MODE_SINGLE => Mage::helper('ddg')->__(
|
15 |
-
Dotdigitalgroup_Email_Model_Importer::MODE_SINGLE_DELETE => Mage::helper('ddg')->__(
|
16 |
-
Dotdigitalgroup_Email_Model_Importer::MODE_CONTACT_DELETE => Mage::helper('ddg')->__(
|
17 |
-
Dotdigitalgroup_Email_Model_Importer::
|
18 |
-
Dotdigitalgroup_Email_Model_Importer::
|
19 |
-
Dotdigitalgroup_Email_Model_Importer::MODE_CONTACT_EMAIL_UPDATE => Mage::helper('ddg')->__(
|
20 |
Â
);
|
21 |
Â
}
|
22 |
Â
}
|
10 |
Â
public function getOptions()
|
11 |
Â
{
|
12 |
Â
return array(
|
13 |
+
Dotdigitalgroup_Email_Model_Importer::MODE_BULK => Mage::helper('ddg')->__('Bulk'),
|
14 |
+
Dotdigitalgroup_Email_Model_Importer::MODE_SINGLE => Mage::helper('ddg')->__('Single'),
|
15 |
+
Dotdigitalgroup_Email_Model_Importer::MODE_SINGLE_DELETE => Mage::helper('ddg')->__('Single Delete'),
|
16 |
+
Dotdigitalgroup_Email_Model_Importer::MODE_CONTACT_DELETE => Mage::helper('ddg')->__('Contact Delete'),
|
17 |
+
Dotdigitalgroup_Email_Model_Importer::MODE_SUBSCRIBER_RESUBSCRIBED => Mage::helper('ddg')->__('Subscriber Resubscribed'),
|
18 |
+
Dotdigitalgroup_Email_Model_Importer::MODE_SUBSCRIBER_UPDATE => Mage::helper('ddg')->__('Subscriber Update'),
|
19 |
+
Dotdigitalgroup_Email_Model_Importer::MODE_CONTACT_EMAIL_UPDATE => Mage::helper('ddg')->__('Contact Email Update')
|
20 |
Â
);
|
21 |
Â
}
|
22 |
Â
}
|
@@ -2,6 +2,7 @@
|
|
2 |
Â
|
3 |
Â
class Dotdigitalgroup_Email_Model_Adminhtml_Source_Importer_Status
|
4 |
Â
{
|
Â
|
|
5 |
Â
/**
|
6 |
Â
* Contact imported options.
|
7 |
Â
*
|
@@ -10,10 +11,18 @@ class Dotdigitalgroup_Email_Model_Adminhtml_Source_Importer_Status
|
|
10 |
Â
public function getOptions()
|
11 |
Â
{
|
12 |
Â
return array(
|
13 |
-
Dotdigitalgroup_Email_Model_Importer::NOT_IMPORTED => Mage::helper(
|
14 |
-
|
15 |
-
|
16 |
-
Dotdigitalgroup_Email_Model_Importer::
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
17 |
Â
);
|
18 |
Â
}
|
19 |
Â
}
|
2 |
Â
|
3 |
Â
class Dotdigitalgroup_Email_Model_Adminhtml_Source_Importer_Status
|
4 |
Â
{
|
5 |
+
|
6 |
Â
/**
|
7 |
Â
* Contact imported options.
|
8 |
Â
*
|
11 |
Â
public function getOptions()
|
12 |
Â
{
|
13 |
Â
return array(
|
14 |
+
Dotdigitalgroup_Email_Model_Importer::NOT_IMPORTED => Mage::helper(
|
15 |
+
'ddg'
|
16 |
+
)->__('Not Imported'),
|
17 |
+
Dotdigitalgroup_Email_Model_Importer::IMPORTING => Mage::helper(
|
18 |
+
'ddg'
|
19 |
+
)->__('Importing'),
|
20 |
+
Dotdigitalgroup_Email_Model_Importer::IMPORTED => Mage::helper(
|
21 |
+
'ddg'
|
22 |
+
)->__('Imported'),
|
23 |
+
Dotdigitalgroup_Email_Model_Importer::FAILED => Mage::helper(
|
24 |
+
'ddg'
|
25 |
+
)->__('Failed'),
|
26 |
Â
);
|
27 |
Â
}
|
28 |
Â
}
|
@@ -5,34 +5,38 @@ class Dotdigitalgroup_Email_Model_Adminhtml_Source_Lostbaskets_Interval
|
|
5 |
Â
|
6 |
Â
/**
|
7 |
Â
* available times
|
Â
|
|
8 |
Â
* @var array
|
9 |
Â
*/
|
10 |
-
protected $_times
|
Â
|
|
Â
|
|
11 |
Â
|
12 |
Â
|
13 |
Â
/**
|
14 |
Â
* send to campain options hours
|
Â
|
|
15 |
Â
* @return array
|
16 |
Â
*/
|
17 |
Â
public function toOptionArray()
|
18 |
Â
{
|
19 |
Â
$result = $row = array();
|
20 |
-
$i
|
21 |
Â
foreach ($this->_times as $one) {
|
22 |
Â
|
23 |
Â
if ($i == 0) {
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
Â
} else {
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
Â
}
|
34 |
Â
$result[] = $row;
|
35 |
-
|
36 |
Â
}
|
37 |
Â
|
38 |
Â
return $result;
|
5 |
Â
|
6 |
Â
/**
|
7 |
Â
* available times
|
8 |
+
*
|
9 |
Â
* @var array
|
10 |
Â
*/
|
11 |
+
protected $_times
|
12 |
+
= array(1, 2, 3, 4, 5, 6, 12, 24, 36, 48, 60, 72, 84, 96, 108, 120,
|
13 |
+
240);
|
14 |
Â
|
15 |
Â
|
16 |
Â
/**
|
17 |
Â
* send to campain options hours
|
18 |
+
*
|
19 |
Â
* @return array
|
20 |
Â
*/
|
21 |
Â
public function toOptionArray()
|
22 |
Â
{
|
23 |
Â
$result = $row = array();
|
24 |
+
$i = 0;
|
25 |
Â
foreach ($this->_times as $one) {
|
26 |
Â
|
27 |
Â
if ($i == 0) {
|
28 |
+
$row = array(
|
29 |
+
'value' => $one,
|
30 |
+
'label' => Mage::helper('ddg')->__($one . ' Hour')
|
31 |
+
);
|
32 |
Â
} else {
|
33 |
+
$row = array(
|
34 |
+
'value' => $one,
|
35 |
+
'label' => Mage::helper('ddg')->__($one . ' Hours')
|
36 |
+
);
|
37 |
Â
}
|
38 |
Â
$result[] = $row;
|
39 |
+
$i++;
|
40 |
Â
}
|
41 |
Â
|
42 |
Â
return $result;
|
@@ -2,20 +2,29 @@
|
|
2 |
Â
|
3 |
Â
class Dotdigitalgroup_Email_Model_Adminhtml_Source_Lostbaskets_Intervalminute
|
4 |
Â
{
|
Â
|
|
5 |
Â
/**
|
6 |
Â
* lost basket hour options
|
Â
|
|
7 |
Â
* @return array
|
8 |
Â
*/
|
9 |
Â
public function toOptionArray()
|
10 |
Â
{
|
11 |
Â
return array(
|
12 |
-
array('value' => "15",
|
13 |
-
|
14 |
-
array('value' => "
|
15 |
-
|
16 |
-
array('value' => "
|
17 |
-
|
18 |
-
array('value' => "
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
19 |
Â
);
|
20 |
Â
}
|
21 |
Â
}
|
2 |
Â
|
3 |
Â
class Dotdigitalgroup_Email_Model_Adminhtml_Source_Lostbaskets_Intervalminute
|
4 |
Â
{
|
5 |
+
|
6 |
Â
/**
|
7 |
Â
* lost basket hour options
|
8 |
+
*
|
9 |
Â
* @return array
|
10 |
Â
*/
|
11 |
Â
public function toOptionArray()
|
12 |
Â
{
|
13 |
Â
return array(
|
14 |
+
array('value' => "15",
|
15 |
+
'label' => Mage::helper('ddg')->__('15 Minutes')),
|
16 |
+
array('value' => "20",
|
17 |
+
'label' => Mage::helper('ddg')->__('20 Minutes')),
|
18 |
+
array('value' => "25",
|
19 |
+
'label' => Mage::helper('ddg')->__('25 Minutes')),
|
20 |
+
array('value' => "30",
|
21 |
+
'label' => Mage::helper('ddg')->__('30 Minutes')),
|
22 |
+
array('value' => "40",
|
23 |
+
'label' => Mage::helper('ddg')->__('40 Minutes')),
|
24 |
+
array('value' => "50",
|
25 |
+
'label' => Mage::helper('ddg')->__('50 Minutes')),
|
26 |
+
array('value' => "60",
|
27 |
+
'label' => Mage::helper('ddg')->__('60 Minutes')),
|
28 |
Â
);
|
29 |
Â
}
|
30 |
Â
}
|
@@ -2,21 +2,24 @@
|
|
2 |
Â
|
3 |
Â
class Dotdigitalgroup_Email_Model_Adminhtml_Source_Orderstatus
|
4 |
Â
{
|
Â
|
|
5 |
Â
/**
|
6 |
Â
* Returns the order statuses
|
Â
|
|
7 |
Â
* @return array
|
8 |
Â
*/
|
9 |
Â
public function toOptionArray()
|
10 |
Â
{
|
11 |
Â
$statuses = Mage::getSingleton('sales/order_config')->getStatuses();
|
12 |
-
$options
|
13 |
Â
|
14 |
-
foreach ($statuses as $code
|
15 |
Â
$options[] = array(
|
16 |
Â
'value' => $code,
|
17 |
Â
'label' => $label
|
18 |
Â
);
|
19 |
Â
}
|
Â
|
|
20 |
Â
return $options;
|
21 |
Â
}
|
22 |
Â
}
|
2 |
Â
|
3 |
Â
class Dotdigitalgroup_Email_Model_Adminhtml_Source_Orderstatus
|
4 |
Â
{
|
5 |
+
|
6 |
Â
/**
|
7 |
Â
* Returns the order statuses
|
8 |
+
*
|
9 |
Â
* @return array
|
10 |
Â
*/
|
11 |
Â
public function toOptionArray()
|
12 |
Â
{
|
13 |
Â
$statuses = Mage::getSingleton('sales/order_config')->getStatuses();
|
14 |
+
$options = array();
|
15 |
Â
|
16 |
+
foreach ($statuses as $code => $label) {
|
17 |
Â
$options[] = array(
|
18 |
Â
'value' => $code,
|
19 |
Â
'label' => $label
|
20 |
Â
);
|
21 |
Â
}
|
22 |
+
|
23 |
Â
return $options;
|
24 |
Â
}
|
25 |
Â
}
|
@@ -2,62 +2,72 @@
|
|
2 |
Â
|
3 |
Â
class Dotdigitalgroup_Email_Model_Adminhtml_Source_Publicdatafields
|
4 |
Â
{
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
Â
|
|
Â
|
|
Â
|
|
30 |
Â
|
31 |
Â
/**
|
32 |
Â
* Datafields option.
|
Â
|
|
33 |
Â
* @return array
|
34 |
Â
*/
|
35 |
Â
public function toOptionArray()
|
36 |
Â
{
|
37 |
-
$fields
|
38 |
-
$helper
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
61 |
Â
return $fields;
|
62 |
Â
}
|
63 |
Â
}
|
2 |
Â
|
3 |
Â
class Dotdigitalgroup_Email_Model_Adminhtml_Source_Publicdatafields
|
4 |
Â
{
|
5 |
+
|
6 |
+
protected function getWebsite()
|
7 |
+
{
|
8 |
+
$website = Mage::app()->getWebsite();
|
9 |
+
$websiteParam = Mage::app()->getRequest()->getParam('website');
|
10 |
+
if ($websiteParam) {
|
11 |
+
$website = Mage::app()->getWebsite($websiteParam);
|
12 |
+
}
|
13 |
+
|
14 |
+
return $website;
|
15 |
+
}
|
16 |
+
|
17 |
+
/**
|
18 |
+
* get data fields
|
19 |
+
*
|
20 |
+
* @return mixed
|
21 |
+
*/
|
22 |
+
protected function getDataFields()
|
23 |
+
{
|
24 |
+
$helper = Mage::helper('ddg');
|
25 |
+
$website = $this->getWebsite();
|
26 |
+
$client = $helper->getWebsiteApiClient($website);
|
27 |
+
|
28 |
+
//grab the datafields request and save to register
|
29 |
+
$datafields = $client->getDataFields();
|
30 |
+
|
31 |
+
return $datafields;
|
32 |
+
}
|
33 |
Â
|
34 |
Â
/**
|
35 |
Â
* Datafields option.
|
36 |
+
*
|
37 |
Â
* @return array
|
38 |
Â
*/
|
39 |
Â
public function toOptionArray()
|
40 |
Â
{
|
41 |
+
$fields = array();
|
42 |
+
$helper = Mage::helper('ddg');
|
43 |
+
$website = $this->getWebsite();
|
44 |
+
|
45 |
+
//get datafields options
|
46 |
+
if ($helper->isEnabled($website)) {
|
47 |
+
$datafields = $this->getDataFields();
|
48 |
+
|
49 |
+
//set the api error message for the first option
|
50 |
+
if (isset($datafields->message)) {
|
51 |
+
//message
|
52 |
+
$fields[] = array('value' => 0,
|
53 |
+
'label' => Mage::helper('ddg')->__(
|
54 |
+
$datafields->message
|
55 |
+
));
|
56 |
+
} else {
|
57 |
+
//loop for all datafields option
|
58 |
+
foreach ($datafields as $datafield) {
|
59 |
+
if (isset($datafield->name)
|
60 |
+
&& $datafield->visibility == 'Public'
|
61 |
+
) {
|
62 |
+
$fields[] = array(
|
63 |
+
'value' => $datafield->name,
|
64 |
+
'label' => Mage::helper('ddg')->__($datafield->name)
|
65 |
+
);
|
66 |
+
}
|
67 |
+
}
|
68 |
+
}
|
69 |
+
}
|
70 |
+
|
71 |
Â
return $fields;
|
72 |
Â
}
|
73 |
Â
}
|
@@ -2,14 +2,17 @@
|
|
2 |
Â
|
3 |
Â
class Dotdigitalgroup_Email_Model_Adminhtml_Source_Reviews_Delay
|
4 |
Â
{
|
Â
|
|
5 |
Â
/**
|
6 |
Â
* Returns the values for field delay
|
Â
|
|
7 |
Â
* @return array
|
8 |
Â
*/
|
9 |
Â
public function toOptionArray()
|
10 |
Â
{
|
11 |
Â
return array(
|
12 |
-
array('value' => '',
|
Â
|
|
13 |
Â
array('value' => 1, 'label' => '1'),
|
14 |
Â
array('value' => 2, 'label' => '2'),
|
15 |
Â
array('value' => 3, 'label' => '3'),
|
2 |
Â
|
3 |
Â
class Dotdigitalgroup_Email_Model_Adminhtml_Source_Reviews_Delay
|
4 |
Â
{
|
5 |
+
|
6 |
Â
/**
|
7 |
Â
* Returns the values for field delay
|
8 |
+
*
|
9 |
Â
* @return array
|
10 |
Â
*/
|
11 |
Â
public function toOptionArray()
|
12 |
Â
{
|
13 |
Â
return array(
|
14 |
+
array('value' => '',
|
15 |
+
'label' => Mage::helper('ddg')->__('-- Please Select --')),
|
16 |
Â
array('value' => 1, 'label' => '1'),
|
17 |
Â
array('value' => 2, 'label' => '2'),
|
18 |
Â
array('value' => 3, 'label' => '3'),
|
@@ -2,6 +2,7 @@
|
|
2 |
Â
|
3 |
Â
class Dotdigitalgroup_Email_Model_Adminhtml_Source_Rules_Condition
|
4 |
Â
{
|
Â
|
|
5 |
Â
/**
|
6 |
Â
* options array
|
7 |
Â
*
|
@@ -11,9 +12,12 @@ class Dotdigitalgroup_Email_Model_Adminhtml_Source_Rules_Condition
|
|
11 |
Â
{
|
12 |
Â
$options = array(
|
13 |
Â
array('value' => 'eq', 'label' => Mage::helper('ddg')->__('is')),
|
14 |
-
array('value' => 'neq',
|
15 |
-
|
Â
|
|
Â
|
|
16 |
Â
);
|
Â
|
|
17 |
Â
return $options;
|
18 |
Â
}
|
19 |
Â
|
@@ -21,6 +25,7 @@ class Dotdigitalgroup_Email_Model_Adminhtml_Source_Rules_Condition
|
|
21 |
Â
* get condition options according to type
|
22 |
Â
*
|
23 |
Â
* @param $type
|
Â
|
|
24 |
Â
* @return array
|
25 |
Â
*/
|
26 |
Â
public function getInputTypeOptions($type)
|
@@ -44,11 +49,20 @@ class Dotdigitalgroup_Email_Model_Adminhtml_Source_Rules_Condition
|
|
44 |
Â
*/
|
45 |
Â
public function optionsForNumericType()
|
46 |
Â
{
|
47 |
-
$options
|
48 |
-
$options[] = array('value' => 'gteq',
|
49 |
-
|
50 |
-
|
51 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
52 |
Â
return $options;
|
53 |
Â
}
|
54 |
Â
|
@@ -59,9 +73,14 @@ class Dotdigitalgroup_Email_Model_Adminhtml_Source_Rules_Condition
|
|
59 |
Â
*/
|
60 |
Â
public function optionsForStringType()
|
61 |
Â
{
|
62 |
-
$options
|
63 |
-
$options[] = array('value' => 'like',
|
64 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
65 |
Â
return $options;
|
66 |
Â
}
|
67 |
Â
}
|
2 |
Â
|
3 |
Â
class Dotdigitalgroup_Email_Model_Adminhtml_Source_Rules_Condition
|
4 |
Â
{
|
5 |
+
|
6 |
Â
/**
|
7 |
Â
* options array
|
8 |
Â
*
|
12 |
Â
{
|
13 |
Â
$options = array(
|
14 |
Â
array('value' => 'eq', 'label' => Mage::helper('ddg')->__('is')),
|
15 |
+
array('value' => 'neq',
|
16 |
+
'label' => Mage::helper('ddg')->__('is not')),
|
17 |
+
array('value' => 'null',
|
18 |
+
'label' => Mage::helper('ddg')->__('is empty')),
|
19 |
Â
);
|
20 |
+
|
21 |
Â
return $options;
|
22 |
Â
}
|
23 |
Â
|
25 |
Â
* get condition options according to type
|
26 |
Â
*
|
27 |
Â
* @param $type
|
28 |
+
*
|
29 |
Â
* @return array
|
30 |
Â
*/
|
31 |
Â
public function getInputTypeOptions($type)
|
49 |
Â
*/
|
50 |
Â
public function optionsForNumericType()
|
51 |
Â
{
|
52 |
+
$options = $this->toOptionArray();
|
53 |
+
$options[] = array('value' => 'gteq',
|
54 |
+
'label' => Mage::helper('ddg')->__(
|
55 |
+
'equals or greater than'
|
56 |
+
));
|
57 |
+
$options[] = array('value' => 'lteq',
|
58 |
+
'label' => Mage::helper('ddg')->__(
|
59 |
+
'equals or less then'
|
60 |
+
));
|
61 |
+
$options[] = array('value' => 'gt',
|
62 |
+
'label' => Mage::helper('ddg')->__('greater than'));
|
63 |
+
$options[] = array('value' => 'lt',
|
64 |
+
'label' => Mage::helper('ddg')->__('less than'));
|
65 |
+
|
66 |
Â
return $options;
|
67 |
Â
}
|
68 |
Â
|
73 |
Â
*/
|
74 |
Â
public function optionsForStringType()
|
75 |
Â
{
|
76 |
+
$options = $this->toOptionArray();
|
77 |
+
$options[] = array('value' => 'like',
|
78 |
+
'label' => Mage::helper('ddg')->__('contains'));
|
79 |
+
$options[] = array('value' => 'nlike',
|
80 |
+
'label' => Mage::helper('ddg')->__(
|
81 |
+
'does not contains'
|
82 |
+
));
|
83 |
+
|
84 |
Â
return $options;
|
85 |
Â
}
|
86 |
Â
}
|
@@ -7,24 +7,36 @@ class Dotdigitalgroup_Email_Model_Adminhtml_Source_Rules_Type
|
|
7 |
Â
* get input type
|
8 |
Â
*
|
9 |
Â
* @param $attribute
|
Â
|
|
10 |
Â
* @return string
|
11 |
Â
*/
|
12 |
Â
public function getInputType($attribute)
|
13 |
Â
{
|
14 |
Â
switch ($attribute) {
|
15 |
-
case 'subtotal':
|
Â
|
|
Â
|
|
16 |
Â
return 'numeric';
|
17 |
Â
|
18 |
-
case 'method':
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
19 |
Â
return 'select';
|
20 |
Â
|
21 |
Â
default:
|
22 |
-
$attribute = Mage::getSingleton('eav/config')->getAttribute(
|
23 |
-
|
Â
|
|
Â
|
|
24 |
Â
return 'numeric';
|
25 |
-
|
Â
|
|
26 |
Â
return 'select';
|
Â
|
|
27 |
Â
}
|
Â
|
|
28 |
Â
return 'string';
|
29 |
Â
}
|
30 |
Â
|
@@ -36,17 +48,29 @@ class Dotdigitalgroup_Email_Model_Adminhtml_Source_Rules_Type
|
|
36 |
Â
public function defaultOptions()
|
37 |
Â
{
|
38 |
Â
return array(
|
39 |
-
'method'
|
40 |
-
|
41 |
-
|
42 |
-
'
|
43 |
-
|
44 |
-
|
45 |
-
'
|
46 |
-
|
47 |
-
|
48 |
-
'
|
49 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
50 |
Â
);
|
51 |
Â
}
|
52 |
Â
|
@@ -57,16 +81,18 @@ class Dotdigitalgroup_Email_Model_Adminhtml_Source_Rules_Type
|
|
57 |
Â
*/
|
58 |
Â
public function toOptionArray()
|
59 |
Â
{
|
60 |
-
$defaultOptions
|
61 |
-
$productCondition
|
62 |
-
$productAttributes = $productCondition->loadAttributeOptions()
|
63 |
-
|
64 |
-
|
Â
|
|
65 |
Â
if (strpos($code, 'quote_item_') === false) {
|
66 |
Â
$pAttributes[$code] = Mage::helper('adminhtml')->__($label);
|
67 |
Â
}
|
68 |
Â
}
|
69 |
Â
$options = array_merge($defaultOptions, $pAttributes);
|
Â
|
|
70 |
Â
return $options;
|
71 |
Â
}
|
72 |
Â
}
|
7 |
Â
* get input type
|
8 |
Â
*
|
9 |
Â
* @param $attribute
|
10 |
+
*
|
11 |
Â
* @return string
|
12 |
Â
*/
|
13 |
Â
public function getInputType($attribute)
|
14 |
Â
{
|
15 |
Â
switch ($attribute) {
|
16 |
+
case 'subtotal':
|
17 |
+
case 'grand_total':
|
18 |
+
case 'items_qty':
|
19 |
Â
return 'numeric';
|
20 |
Â
|
21 |
+
case 'method':
|
22 |
+
case 'shipping_method':
|
23 |
+
case 'country_id':
|
24 |
+
case 'region_id':
|
25 |
+
case 'customer_group_id':
|
26 |
Â
return 'select';
|
27 |
Â
|
28 |
Â
default:
|
29 |
+
$attribute = Mage::getSingleton('eav/config')->getAttribute(
|
30 |
+
'catalog_product', $attribute
|
31 |
+
);
|
32 |
+
if ($attribute->getFrontend()->getInputType() == 'price') {
|
33 |
Â
return 'numeric';
|
34 |
+
}
|
35 |
+
if ($attribute->usesSource()) {
|
36 |
Â
return 'select';
|
37 |
+
}
|
38 |
Â
}
|
39 |
+
|
40 |
Â
return 'string';
|
41 |
Â
}
|
42 |
Â
|
48 |
Â
public function defaultOptions()
|
49 |
Â
{
|
50 |
Â
return array(
|
51 |
+
'method' => Mage::helper('adminhtml')->__(
|
52 |
+
'Payment Method'
|
53 |
+
),
|
54 |
+
'shipping_method' => Mage::helper('adminhtml')->__(
|
55 |
+
'Shipping Method'
|
56 |
+
),
|
57 |
+
'country_id' => Mage::helper('adminhtml')->__(
|
58 |
+
'Shipping Country'
|
59 |
+
),
|
60 |
+
'city' => Mage::helper('adminhtml')->__(
|
61 |
+
'Shipping Town'
|
62 |
+
),
|
63 |
+
'region_id' => Mage::helper('adminhtml')->__(
|
64 |
+
'Shipping State/Province'
|
65 |
+
),
|
66 |
+
'customer_group_id' => Mage::helper('adminhtml')->__(
|
67 |
+
'Customer Group'
|
68 |
+
),
|
69 |
+
'coupon_code' => Mage::helper('adminhtml')->__('Coupon'),
|
70 |
+
'subtotal' => Mage::helper('adminhtml')->__('Subtotal'),
|
71 |
+
'grand_total' => Mage::helper('adminhtml')->__('Grand Total'),
|
72 |
+
'items_qty' => Mage::helper('adminhtml')->__('Total Qty'),
|
73 |
+
'customer_email' => Mage::helper('adminhtml')->__('Email'),
|
74 |
Â
);
|
75 |
Â
}
|
76 |
Â
|
81 |
Â
*/
|
82 |
Â
public function toOptionArray()
|
83 |
Â
{
|
84 |
+
$defaultOptions = $this->defaultOptions();
|
85 |
+
$productCondition = Mage::getModel('salesrule/rule_condition_product');
|
86 |
+
$productAttributes = $productCondition->loadAttributeOptions()
|
87 |
+
->getAttributeOption();
|
88 |
+
$pAttributes = array();
|
89 |
+
foreach ($productAttributes as $code => $label) {
|
90 |
Â
if (strpos($code, 'quote_item_') === false) {
|
91 |
Â
$pAttributes[$code] = Mage::helper('adminhtml')->__($label);
|
92 |
Â
}
|
93 |
Â
}
|
94 |
Â
$options = array_merge($defaultOptions, $pAttributes);
|
95 |
+
|
96 |
Â
return $options;
|
97 |
Â
}
|
98 |
Â
}
|
@@ -2,75 +2,99 @@
|
|
2 |
Â
|
3 |
Â
class Dotdigitalgroup_Email_Model_Adminhtml_Source_Rules_Value
|
4 |
Â
{
|
Â
|
|
5 |
Â
/**
|
6 |
Â
* get element type
|
7 |
Â
*
|
8 |
Â
* @param $attribute
|
Â
|
|
9 |
Â
* @return string
|
10 |
Â
*/
|
11 |
Â
public function getValueElementType($attribute)
|
12 |
Â
{
|
13 |
Â
switch ($attribute) {
|
14 |
-
case 'method':
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
15 |
Â
return 'select';
|
16 |
Â
default:
|
17 |
-
$attribute = Mage::getSingleton('eav/config')->getAttribute(
|
Â
|
|
Â
|
|
18 |
Â
if ($attribute->usesSource()) {
|
19 |
Â
return 'select';
|
20 |
Â
}
|
21 |
Â
}
|
Â
|
|
22 |
Â
return 'text';
|
23 |
Â
}
|
24 |
Â
|
25 |
Â
/**
|
26 |
Â
* get options array
|
27 |
Â
*
|
28 |
-
* @param
|
29 |
-
* @param bool $
|
Â
|
|
30 |
Â
* @return array
|
31 |
Â
* @throws Mage_Core_Exception
|
32 |
Â
*/
|
33 |
-
public function getValueSelectOptions($attribute, $
|
34 |
Â
{
|
35 |
Â
$options = array();
|
36 |
-
if($
|
37 |
Â
$options = Mage::getModel('adminhtml/system_config_source_yesno')
|
38 |
Â
->toOptionArray();
|
Â
|
|
39 |
Â
return $options;
|
40 |
Â
}
|
41 |
Â
|
42 |
Â
switch ($attribute) {
|
43 |
Â
case 'country_id':
|
44 |
-
$options = Mage::getModel(
|
Â
|
|
Â
|
|
45 |
Â
->toOptionArray();
|
46 |
Â
break;
|
47 |
Â
|
48 |
Â
case 'region_id':
|
49 |
-
$options = Mage::getModel(
|
Â
|
|
Â
|
|
50 |
Â
->toOptionArray();
|
51 |
Â
break;
|
52 |
Â
|
53 |
Â
case 'shipping_method':
|
54 |
-
$options = Mage::getModel(
|
Â
|
|
Â
|
|
55 |
Â
->toOptionArray();
|
56 |
Â
break;
|
57 |
Â
|
58 |
Â
case 'method':
|
59 |
-
$options = Mage::getModel(
|
Â
|
|
Â
|
|
60 |
Â
->toOptionArray();
|
61 |
Â
break;
|
62 |
Â
|
63 |
Â
case 'customer_group_id':
|
64 |
-
$options = Mage::getModel(
|
Â
|
|
Â
|
|
65 |
Â
->toOptionArray();
|
66 |
Â
break;
|
67 |
Â
|
68 |
Â
default:
|
69 |
-
$attribute = Mage::getSingleton('eav/config')->getAttribute(
|
Â
|
|
Â
|
|
70 |
Â
if ($attribute->usesSource()) {
|
71 |
Â
$options = $attribute->getSource()->getAllOptions(false);
|
72 |
Â
}
|
73 |
Â
}
|
Â
|
|
74 |
Â
return $options;
|
75 |
Â
}
|
76 |
Â
|
@@ -81,7 +105,9 @@ class Dotdigitalgroup_Email_Model_Adminhtml_Source_Rules_Value
|
|
81 |
Â
*/
|
82 |
Â
public function toOptionArray()
|
83 |
Â
{
|
84 |
-
$options = Mage::getModel(
|
Â
|
|
Â
|
|
85 |
Â
->toOptionArray();
|
86 |
Â
|
87 |
Â
return $options;
|
2 |
Â
|
3 |
Â
class Dotdigitalgroup_Email_Model_Adminhtml_Source_Rules_Value
|
4 |
Â
{
|
5 |
+
|
6 |
Â
/**
|
7 |
Â
* get element type
|
8 |
Â
*
|
9 |
Â
* @param $attribute
|
10 |
+
*
|
11 |
Â
* @return string
|
12 |
Â
*/
|
13 |
Â
public function getValueElementType($attribute)
|
14 |
Â
{
|
15 |
Â
switch ($attribute) {
|
16 |
+
case 'method':
|
17 |
+
case 'shipping_method':
|
18 |
+
case 'country_id':
|
19 |
+
case 'region_id':
|
20 |
+
case 'customer_group_id':
|
21 |
Â
return 'select';
|
22 |
Â
default:
|
23 |
+
$attribute = Mage::getSingleton('eav/config')->getAttribute(
|
24 |
+
'catalog_product', $attribute
|
25 |
+
);
|
26 |
Â
if ($attribute->usesSource()) {
|
27 |
Â
return 'select';
|
28 |
Â
}
|
29 |
Â
}
|
30 |
+
|
31 |
Â
return 'text';
|
32 |
Â
}
|
33 |
Â
|
34 |
Â
/**
|
35 |
Â
* get options array
|
36 |
Â
*
|
37 |
+
* @param $attribute
|
38 |
+
* @param bool $isEmpty
|
39 |
+
*
|
40 |
Â
* @return array
|
41 |
Â
* @throws Mage_Core_Exception
|
42 |
Â
*/
|
43 |
+
public function getValueSelectOptions($attribute, $isEmpty = false)
|
44 |
Â
{
|
45 |
Â
$options = array();
|
46 |
+
if ($isEmpty) {
|
47 |
Â
$options = Mage::getModel('adminhtml/system_config_source_yesno')
|
48 |
Â
->toOptionArray();
|
49 |
+
|
50 |
Â
return $options;
|
51 |
Â
}
|
52 |
Â
|
53 |
Â
switch ($attribute) {
|
54 |
Â
case 'country_id':
|
55 |
+
$options = Mage::getModel(
|
56 |
+
'adminhtml/system_config_source_country'
|
57 |
+
)
|
58 |
Â
->toOptionArray();
|
59 |
Â
break;
|
60 |
Â
|
61 |
Â
case 'region_id':
|
62 |
+
$options = Mage::getModel(
|
63 |
+
'adminhtml/system_config_source_allregion'
|
64 |
+
)
|
65 |
Â
->toOptionArray();
|
66 |
Â
break;
|
67 |
Â
|
68 |
Â
case 'shipping_method':
|
69 |
+
$options = Mage::getModel(
|
70 |
+
'adminhtml/system_config_source_shipping_allmethods'
|
71 |
+
)
|
72 |
Â
->toOptionArray();
|
73 |
Â
break;
|
74 |
Â
|
75 |
Â
case 'method':
|
76 |
+
$options = Mage::getModel(
|
77 |
+
'adminhtml/system_config_source_payment_allmethods'
|
78 |
+
)
|
79 |
Â
->toOptionArray();
|
80 |
Â
break;
|
81 |
Â
|
82 |
Â
case 'customer_group_id':
|
83 |
+
$options = Mage::getModel(
|
84 |
+
'adminhtml/system_config_source_customer_group'
|
85 |
+
)
|
86 |
Â
->toOptionArray();
|
87 |
Â
break;
|
88 |
Â
|
89 |
Â
default:
|
90 |
+
$attribute = Mage::getSingleton('eav/config')->getAttribute(
|
91 |
+
'catalog_product', $attribute
|
92 |
+
);
|
93 |
Â
if ($attribute->usesSource()) {
|
94 |
Â
$options = $attribute->getSource()->getAllOptions(false);
|
95 |
Â
}
|
96 |
Â
}
|
97 |
+
|
98 |
Â
return $options;
|
99 |
Â
}
|
100 |
Â
|
105 |
Â
*/
|
106 |
Â
public function toOptionArray()
|
107 |
Â
{
|
108 |
+
$options = Mage::getModel(
|
109 |
+
'adminhtml/system_config_source_payment_allmethods'
|
110 |
+
)
|
111 |
Â
->toOptionArray();
|
112 |
Â
|
113 |
Â
return $options;
|
@@ -2,6 +2,7 @@
|
|
2 |
Â
|
3 |
Â
class Dotdigitalgroup_Email_Model_Adminhtml_Source_Styling
|
4 |
Â
{
|
Â
|
|
5 |
Â
/**
|
6 |
Â
* Options getter. Styling options
|
7 |
Â
*
|
@@ -10,7 +11,7 @@ class Dotdigitalgroup_Email_Model_Adminhtml_Source_Styling
|
|
10 |
Â
public function toOptionArray()
|
11 |
Â
{
|
12 |
Â
return array(
|
13 |
-
|
14 |
Â
array('value' => 'bold', 'label' => 'Bold'),
|
15 |
Â
array('value' => 'italic', 'label' => 'Italic'),
|
16 |
Â
array('value' => 'underline', 'label' => 'Underline')
|
2 |
Â
|
3 |
Â
class Dotdigitalgroup_Email_Model_Adminhtml_Source_Styling
|
4 |
Â
{
|
5 |
+
|
6 |
Â
/**
|
7 |
Â
* Options getter. Styling options
|
8 |
Â
*
|
11 |
Â
public function toOptionArray()
|
12 |
Â
{
|
13 |
Â
return array(
|
14 |
+
array('value' => 'nostyle', 'label' => 'No Style'),
|
15 |
Â
array('value' => 'bold', 'label' => 'Bold'),
|
16 |
Â
array('value' => 'italic', 'label' => 'Italic'),
|
17 |
Â
array('value' => 'underline', 'label' => 'Underline')
|
@@ -11,15 +11,17 @@ class Dotdigitalgroup_Email_Model_Adminhtml_Source_Sweettooth_Yesno
|
|
11 |
Â
public function toOptionArray()
|
12 |
Â
{
|
13 |
Â
$status = Mage::helper('ddg')->isSweetToothEnabled();
|
14 |
-
if($status){
|
15 |
Â
return array(
|
16 |
-
array('value' => 1,
|
17 |
-
|
Â
|
|
Â
|
|
18 |
Â
);
|
19 |
Â
}
|
20 |
Â
|
21 |
Â
return array(
|
22 |
-
array('value' => 0, 'label'=>Mage::helper('adminhtml')->__('No')),
|
23 |
Â
);
|
24 |
Â
}
|
25 |
Â
|
11 |
Â
public function toOptionArray()
|
12 |
Â
{
|
13 |
Â
$status = Mage::helper('ddg')->isSweetToothEnabled();
|
14 |
+
if ($status) {
|
15 |
Â
return array(
|
16 |
+
array('value' => 1,
|
17 |
+
'label' => Mage::helper('adminhtml')->__('Yes')),
|
18 |
+
array('value' => 0,
|
19 |
+
'label' => Mage::helper('adminhtml')->__('No')),
|
20 |
Â
);
|
21 |
Â
}
|
22 |
Â
|
23 |
Â
return array(
|
24 |
+
array('value' => 0, 'label' => Mage::helper('adminhtml')->__('No')),
|
25 |
Â
);
|
26 |
Â
}
|
27 |
Â
|
@@ -2,6 +2,7 @@
|
|
2 |
Â
|
3 |
Â
class Dotdigitalgroup_Email_Model_Adminhtml_Source_Sync_Catalog_Attributes
|
4 |
Â
{
|
Â
|
|
5 |
Â
/**
|
6 |
Â
* all attributes type catalog
|
7 |
Â
*
|
@@ -9,20 +10,24 @@ class Dotdigitalgroup_Email_Model_Adminhtml_Source_Sync_Catalog_Attributes
|
|
9 |
Â
*/
|
10 |
Â
public function toOptionArray()
|
11 |
Â
{
|
12 |
-
$attributes
|
Â
|
|
Â
|
|
13 |
Â
$attributeArray = array();
|
14 |
Â
|
15 |
Â
//exclude these from showing in the options
|
16 |
-
$exclude = array('gallery', 'image', 'media_gallery', 'small_image',
|
Â
|
|
17 |
Â
|
18 |
Â
foreach ($attributes as $attribute) {
|
19 |
-
if (!in_array($attribute->getData('attribute_code'), $exclude)) {
|
20 |
Â
$attributeArray[] = array(
|
21 |
Â
'label' => $attribute->getData('frontend_label'),
|
22 |
Â
'value' => $attribute->getData('attribute_code')
|
23 |
Â
);
|
24 |
Â
}
|
25 |
Â
}
|
Â
|
|
26 |
Â
return $attributeArray;
|
27 |
Â
}
|
28 |
Â
}
|
2 |
Â
|
3 |
Â
class Dotdigitalgroup_Email_Model_Adminhtml_Source_Sync_Catalog_Attributes
|
4 |
Â
{
|
5 |
+
|
6 |
Â
/**
|
7 |
Â
* all attributes type catalog
|
8 |
Â
*
|
10 |
Â
*/
|
11 |
Â
public function toOptionArray()
|
12 |
Â
{
|
13 |
+
$attributes = Mage::getResourceModel(
|
14 |
+
'catalog/product_attribute_collection'
|
15 |
+
)->addVisibleFilter();
|
16 |
Â
$attributeArray = array();
|
17 |
Â
|
18 |
Â
//exclude these from showing in the options
|
19 |
+
$exclude = array('gallery', 'image', 'media_gallery', 'small_image',
|
20 |
+
'thumbnail');
|
21 |
Â
|
22 |
Â
foreach ($attributes as $attribute) {
|
23 |
+
if ( ! in_array($attribute->getData('attribute_code'), $exclude)) {
|
24 |
Â
$attributeArray[] = array(
|
25 |
Â
'label' => $attribute->getData('frontend_label'),
|
26 |
Â
'value' => $attribute->getData('attribute_code')
|
27 |
Â
);
|
28 |
Â
}
|
29 |
Â
}
|
30 |
+
|
31 |
Â
return $attributeArray;
|
32 |
Â
}
|
33 |
Â
}
|
@@ -2,6 +2,7 @@
|
|
2 |
Â
|
3 |
Â
class Dotdigitalgroup_Email_Model_Adminhtml_Source_Sync_Catalog_Type
|
4 |
Â
{
|
Â
|
|
5 |
Â
/**
|
6 |
Â
* Options getter. Styling options
|
7 |
Â
*
|
@@ -11,6 +12,7 @@ class Dotdigitalgroup_Email_Model_Adminhtml_Source_Sync_Catalog_Type
|
|
11 |
Â
{
|
12 |
Â
$options = Mage::getModel('catalog/product_type')->getAllOptions();
|
13 |
Â
array_shift($options);
|
Â
|
|
14 |
Â
return $options;
|
15 |
Â
}
|
16 |
Â
}
|
2 |
Â
|
3 |
Â
class Dotdigitalgroup_Email_Model_Adminhtml_Source_Sync_Catalog_Type
|
4 |
Â
{
|
5 |
+
|
6 |
Â
/**
|
7 |
Â
* Options getter. Styling options
|
8 |
Â
*
|
12 |
Â
{
|
13 |
Â
$options = Mage::getModel('catalog/product_type')->getAllOptions();
|
14 |
Â
array_shift($options);
|
15 |
+
|
16 |
Â
return $options;
|
17 |
Â
}
|
18 |
Â
}
|
@@ -2,6 +2,7 @@
|
|
2 |
Â
|
3 |
Â
class Dotdigitalgroup_Email_Model_Adminhtml_Source_Sync_Catalog_Values
|
4 |
Â
{
|
Â
|
|
5 |
Â
/**
|
6 |
Â
* Options getter. Styling options
|
7 |
Â
*
|
2 |
Â
|
3 |
Â
class Dotdigitalgroup_Email_Model_Adminhtml_Source_Sync_Catalog_Values
|
4 |
Â
{
|
5 |
+
|
6 |
Â
/**
|
7 |
Â
* Options getter. Styling options
|
8 |
Â
*
|
@@ -2,6 +2,7 @@
|
|
2 |
Â
|
3 |
Â
class Dotdigitalgroup_Email_Model_Adminhtml_Source_Sync_Catalog_Visibility
|
4 |
Â
{
|
Â
|
|
5 |
Â
/**
|
6 |
Â
* Options getter. Styling options
|
7 |
Â
*
|
@@ -9,8 +10,10 @@ class Dotdigitalgroup_Email_Model_Adminhtml_Source_Sync_Catalog_Visibility
|
|
9 |
Â
*/
|
10 |
Â
public function toOptionArray()
|
11 |
Â
{
|
12 |
-
$options = Mage::getModel('catalog/product_visibility')->getAllOptions(
|
Â
|
|
13 |
Â
array_shift($options);
|
Â
|
|
14 |
Â
return $options;
|
15 |
Â
}
|
16 |
Â
}
|
2 |
Â
|
3 |
Â
class Dotdigitalgroup_Email_Model_Adminhtml_Source_Sync_Catalog_Visibility
|
4 |
Â
{
|
5 |
+
|
6 |
Â
/**
|
7 |
Â
* Options getter. Styling options
|
8 |
Â
*
|
10 |
Â
*/
|
11 |
Â
public function toOptionArray()
|
12 |
Â
{
|
13 |
+
$options = Mage::getModel('catalog/product_visibility')->getAllOptions(
|
14 |
+
);
|
15 |
Â
array_shift($options);
|
16 |
+
|
17 |
Â
return $options;
|
18 |
Â
}
|
19 |
Â
}
|
@@ -1,62 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class Dotdigitalgroup_Email_Model_Adminhtml_Source_Sync_Yesno
|
4 |
-
{
|
5 |
-
/**
|
6 |
-
* Options getter
|
7 |
-
*
|
8 |
-
* @return array
|
9 |
-
*/
|
10 |
-
public function toOptionArray()
|
11 |
-
{
|
12 |
-
//get current scope website code, set the code to admin if empty
|
13 |
-
$websiteCode = (Mage::getSingleton('adminhtml/config_data')->getWebsite())? Mage::getSingleton('adminhtml/config_data')->getWebsite() : 'admin';
|
14 |
-
|
15 |
-
//for current scope website check if entry exist in registry. if not than
|
16 |
-
//than get account data and store it in registry to re-use
|
17 |
-
if (! Mage::registry('ddg-account-info-'.$websiteCode)) {
|
18 |
-
//websites with code as key
|
19 |
-
$websites = Mage::app()->getWebsites(true, true);
|
20 |
-
$website = $websites[$websiteCode];
|
21 |
-
|
22 |
-
//if scope is empty or no id than load default
|
23 |
-
if (empty($website) or !$website->getId())
|
24 |
-
$website = 0;
|
25 |
-
|
26 |
-
$apiUsername = Mage::helper('ddg')->getApiUsername($website);
|
27 |
-
$apiPassword = Mage::helper('ddg')->getApiPassword($website);
|
28 |
-
$data = Mage::getModel('ddg_automation/apiconnector_client')
|
29 |
-
->setApiUsername($apiUsername)
|
30 |
-
->setApiPassword($apiPassword)
|
31 |
-
->getAccountInfo();
|
32 |
-
|
33 |
-
//save entry in registry for current website scope
|
34 |
-
Mage::register('ddg-account-info-'.$websiteCode, $data);
|
35 |
-
}
|
36 |
-
|
37 |
-
//get from registry
|
38 |
-
$data = Mage::registry('ddg-account-info-'.$websiteCode);
|
39 |
-
//if properties property exist
|
40 |
-
if (isset($data->properties)) {
|
41 |
-
$propertyNames = array();
|
42 |
-
//loop all and save property names
|
43 |
-
foreach ($data->properties as $one) {
|
44 |
-
$propertyNames[] = $one->name;
|
45 |
-
}
|
46 |
-
|
47 |
-
//only return Yes/No option if data allowance properties exist
|
48 |
-
if(in_array('TransactionalDataAllowanceInMegabytes', $propertyNames) &&
|
49 |
-
in_array('TransactionalDataUsageInMegabytes', $propertyNames)){
|
50 |
-
return array(
|
51 |
-
array('value' => 1, 'label'=>Mage::helper('adminhtml')->__('Yes')),
|
52 |
-
array('value' => 0, 'label'=>Mage::helper('adminhtml')->__('No')),
|
53 |
-
);
|
54 |
-
}
|
55 |
-
}
|
56 |
-
|
57 |
-
//return default message if above is scenarios are failed.
|
58 |
-
return array(
|
59 |
-
array('value' => 0, 'label'=>Mage::helper('adminhtml')->__('Not enabled on account'))
|
60 |
-
);
|
61 |
-
}
|
62 |
-
}
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
@@ -1,12 +1,13 @@
|
|
1 |
Â
<?php
|
Â
|
|
2 |
Â
class Dotdigitalgroup_Email_Model_Adminhtml_Source_Transactional_Mode
|
3 |
Â
{
|
4 |
-
public function toOptionArray()
|
5 |
-
{
|
6 |
-
return array(
|
7 |
-
'smtp' => Mage::helper('ddg')->__('SMTP')
|
8 |
-
//'api' => Mage::helper('ddg')->__('API')
|
9 |
-
);
|
10 |
Â
|
11 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
12 |
Â
}
|
1 |
Â
<?php
|
2 |
+
|
3 |
Â
class Dotdigitalgroup_Email_Model_Adminhtml_Source_Transactional_Mode
|
4 |
Â
{
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
5 |
Â
|
6 |
+
public function toOptionArray()
|
7 |
+
{
|
8 |
+
return array(
|
9 |
+
'smtp' => Mage::helper('ddg')->__('SMTP')
|
10 |
+
);
|
11 |
+
|
12 |
+
}
|
13 |
Â
}
|
@@ -1,15 +1,16 @@
|
|
1 |
Â
<?php
|
Â
|
|
2 |
Â
class Dotdigitalgroup_Email_Model_Adminhtml_Source_Transactional_Port
|
3 |
Â
{
|
4 |
Â
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
Â
|
13 |
Â
|
14 |
-
|
15 |
Â
}
|
1 |
Â
<?php
|
2 |
+
|
3 |
Â
class Dotdigitalgroup_Email_Model_Adminhtml_Source_Transactional_Port
|
4 |
Â
{
|
5 |
Â
|
6 |
+
public function toOptionArray()
|
7 |
+
{
|
8 |
+
return array(
|
9 |
+
'25' => Mage::helper('ddg')->__("25"),
|
10 |
+
'2525' => Mage::helper('ddg')->__("2525"),
|
11 |
+
'587' => Mage::helper('ddg')->__("587")
|
12 |
+
);
|
13 |
Â
|
14 |
Â
|
15 |
+
}
|
16 |
Â
}
|
@@ -1,111 +1,130 @@
|
|
1 |
Â
<?php
|
2 |
Â
|
3 |
-
class Dotdigitalgroup_Email_Model_Api2_Subscriber_Rest_Admin_V1
|
Â
|
|
4 |
Â
{
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
111 |
Â
}
|
1 |
Â
<?php
|
2 |
Â
|
3 |
+
class Dotdigitalgroup_Email_Model_Api2_Subscriber_Rest_Admin_V1
|
4 |
+
extends Mage_Api2_Model_Resource
|
5 |
Â
{
|
6 |
+
|
7 |
+
/**
|
8 |
+
* Create a subscriber
|
9 |
+
*
|
10 |
+
* @return array
|
11 |
+
*/
|
12 |
+
|
13 |
+
public function _create()
|
14 |
+
{
|
15 |
+
//Create Subscriber
|
16 |
+
$requestData = $this->getRequest()->getBodyParams();
|
17 |
+
|
18 |
+
$email = $requestData['subscriber_email'];
|
19 |
+
//email is set
|
20 |
+
if ($email) {
|
21 |
+
try {
|
22 |
+
$customerId = (isset($requestData['customer_id']))
|
23 |
+
? $requestData['customer_id'] : 0;
|
24 |
+
$storeId = (isset($requestData['store_id']))
|
25 |
+
? $requestData['store_id'] : 1;
|
26 |
+
//subscriber status 1- subscribed, 3 - unsubscribed
|
27 |
+
$status = (isset($requestData['status']))
|
28 |
+
? $requestData['status'] : 3;
|
29 |
+
//additional data for subscriber
|
30 |
+
$data = array(
|
31 |
+
'subscriber_email' => $email,
|
32 |
+
'customer_id' => $customerId,
|
33 |
+
'subscriber_status' => $status,
|
34 |
+
'store_id' => $storeId
|
35 |
+
);
|
36 |
+
|
37 |
+
//save subscriber
|
38 |
+
Mage::getModel('newsletter/subscriber')->setData($data)
|
39 |
+
->save();
|
40 |
+
|
41 |
+
} catch (Mage_Api2_Exception $e) {
|
42 |
+
Mage::helper('ddg')->log($e->getMessage());
|
43 |
+
} catch (Exception $e) {
|
44 |
+
Mage::logException($e);
|
45 |
+
}
|
46 |
+
|
47 |
+
$json = array('email' => $email);
|
48 |
+
|
49 |
+
return json_encode($json);
|
50 |
+
}
|
51 |
+
|
52 |
+
}
|
53 |
+
|
54 |
+
/**
|
55 |
+
* Retrieve a subscriber name by email
|
56 |
+
*
|
57 |
+
* @return string
|
58 |
+
*/
|
59 |
+
|
60 |
+
public function _retrieve()
|
61 |
+
{
|
62 |
+
$email = $this->getRequest()->getParam('email', false);
|
63 |
+
if ( ! $email) {
|
64 |
+
Mage::helper('ddg')->log('Subscriber id is not set');
|
65 |
+
|
66 |
+
return array();
|
67 |
+
}
|
68 |
+
try {
|
69 |
+
|
70 |
+
$data = Mage::getModel('newsletter/subscriber')->loadByEmail($email)
|
71 |
+
->getData();
|
72 |
+
|
73 |
+
return json_encode($data);
|
74 |
+
|
75 |
+
} catch (Mage_Api2_Exception $e) {
|
76 |
+
Mage::helper('ddg')->log($e->getMessage());
|
77 |
+
} catch (Exception $e) {
|
78 |
+
Mage::logException($e);
|
79 |
+
}
|
80 |
+
}
|
81 |
+
|
82 |
+
/**
|
83 |
+
* Update subscriber data.
|
84 |
+
*
|
85 |
+
* @throws Exception
|
86 |
+
*/
|
87 |
+
public function _update()
|
88 |
+
{
|
89 |
+
//Update Subscriber
|
90 |
+
$requestData = $this->getRequest()->getBodyParams();
|
91 |
+
|
92 |
+
//check for scubscriber email
|
93 |
+
if ($email = $requestData['subscriber_email']) {
|
94 |
+
try {
|
95 |
+
$customerId = (isset($requestData['customer_id']))
|
96 |
+
? $requestData['customer_id'] : 0;
|
97 |
+
$storeId = (isset($requestData['store_id']))
|
98 |
+
? $requestData['store_id'] : 1;
|
99 |
+
//subscriber status 1- subscribed, 3 - unsubscribed
|
100 |
+
$status = (isset($requestData['status']))
|
101 |
+
? $requestData['status'] : 3;
|
102 |
+
//additional data for subscriber
|
103 |
+
$data = array(
|
104 |
+
'customer_id' => $customerId,
|
105 |
+
'subscriber_status' => $status,
|
106 |
+
'store_id' => $storeId
|
107 |
+
);
|
108 |
+
//update subscriber
|
109 |
+
$subscriber = Mage::getModel('newsletter/subscriber')
|
110 |
+
->loadByEmail($email);
|
111 |
+
if ($subscriber->getId()) {
|
112 |
+
$subscriber->setCustomerId($customerId)
|
113 |
+
->setSubscriberStatus($status)
|
114 |
+
->setStoreId($storeId)
|
115 |
+
->save();
|
116 |
+
} else {
|
117 |
+
Mage::helper('ddg')->log(
|
118 |
+
"REST Subscriber not found : " . $email
|
119 |
+
);
|
120 |
+
}
|
121 |
+
|
122 |
+
return json_encode($data);
|
123 |
+
} catch (Mage_Api2_Exception $e) {
|
124 |
+
Mage::helper('ddg')->log($e->getMessage());
|
125 |
+
} catch (Exception $e) {
|
126 |
+
Mage::logException($e);
|
127 |
+
}
|
128 |
+
}
|
129 |
+
}
|
130 |
Â
}
|
@@ -1,57 +1,49 @@
|
|
1 |
Â
<?php
|
2 |
Â
|
3 |
-
class Dotdigitalgroup_Email_Model_Apiconnector_Client
|
Â
|
|
4 |
Â
{
|
Â
|
|
5 |
Â
const APICONNECTOR_VERSION = 'V2';
|
6 |
Â
|
7 |
Â
const REST_WAIT_UPLOAD_TIME = 5;
|
8 |
Â
//rest api data
|
9 |
-
const REST_ACCOUNT_INFO
|
10 |
-
const REST_CONTACTS
|
11 |
-
const REST_CONTACTS_IMPORT
|
12 |
-
const REST_ADDRESS_BOOKS
|
13 |
-
const REST_DATA_FILEDS
|
14 |
-
const REST_TRANSACTIONAL_DATA_IMPORT
|
15 |
-
const REST_TRANSACTIONAL_DATA
|
16 |
-
const REST_CAMPAIGN_SEND
|
17 |
-
const REST_CONTACTS_SUPPRESSED_SINCE
|
18 |
-
const REST_DATA_FIELDS_CAMPAIGNS
|
19 |
-
const
|
20 |
-
const
|
21 |
-
const
|
22 |
-
const
|
23 |
-
const
|
24 |
-
const
|
25 |
-
const REST_TEMPLATES = '/v2/templates';
|
26 |
Â
|
27 |
Â
//rest error responces
|
28 |
-
const API_ERROR_API_EXCEEDED
|
29 |
-
const
|
30 |
-
const
|
31 |
-
const
|
32 |
-
const
|
33 |
-
const
|
34 |
-
const
|
35 |
-
const
|
36 |
-
const
|
37 |
-
const
|
38 |
-
const
|
39 |
-
const
|
40 |
-
const
|
41 |
-
const API_ERROR_ADDRESSBOOK_NOT_FOUND = 'Error: ERROR_ADDRESSBOOK_NOT_FOUND';
|
42 |
Â
|
43 |
Â
|
44 |
Â
protected $_limit = 10;
|
45 |
Â
public $fileHelper;
|
46 |
Â
protected $_filename;
|
47 |
-
protected $_api_helper;
|
48 |
-
protected $_address_book_id;
|
49 |
-
protected $_customers_filename;
|
50 |
-
protected $_subscribers_filename;
|
51 |
-
protected $_customers_address_book_id;
|
52 |
-
protected $_subscribers_address_book_id;
|
53 |
-
protected $_customers_file_slug = 'customer_sync';
|
54 |
-
protected $_subscribers_file_slug = 'subscriber_sync';
|
55 |
Â
public $result = array('error' => false, 'message' => '');
|
56 |
Â
protected $_apiEndpoint;
|
57 |
Â
|
@@ -67,20 +59,26 @@ class Dotdigitalgroup_Email_Model_Apiconnector_Client extends Dotdigitalgroup_Em
|
|
67 |
Â
|
68 |
Â
protected function _checkApiEndPoint()
|
69 |
Â
{
|
70 |
-
$apiEndpoint = Mage::helper('ddg')->getWebsiteConfig(
|
71 |
-
|
Â
|
|
Â
|
|
72 |
Â
$helper = Mage::helper('ddg');
|
73 |
Â
$this->setApiUsername($helper->getApiUsername())
|
74 |
Â
->setApiPassword($helper->getApiPassword());
|
75 |
Â
|
76 |
Â
$accountInfo = $this->getAccountInfo();
|
77 |
Â
//check if returned value is an object
|
78 |
-
if(is_object($accountInfo) && !isset($accountInfo->message)){
|
79 |
Â
//save endpoint for account
|
80 |
-
foreach($accountInfo->properties as $property){
|
81 |
-
if($property->name == 'ApiEndpoint'
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
82 |
Â
$apiEndpoint = $property->value;
|
83 |
-
$config
|
84 |
Â
$config->saveConfig(
|
85 |
Â
Dotdigitalgroup_Email_Helper_Config::PATH_FOR_API_ENDPOINT,
|
86 |
Â
$property->value
|
@@ -92,8 +90,14 @@ class Dotdigitalgroup_Email_Model_Apiconnector_Client extends Dotdigitalgroup_Em
|
|
92 |
Â
}
|
93 |
Â
|
94 |
Â
//check api endpoint again
|
95 |
-
if(!$apiEndpoint)
|
96 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
97 |
Â
}
|
98 |
Â
|
99 |
Â
$this->_apiEndpoint = $apiEndpoint;
|
@@ -101,23 +105,26 @@ class Dotdigitalgroup_Email_Model_Apiconnector_Client extends Dotdigitalgroup_Em
|
|
101 |
Â
|
102 |
Â
/**
|
103 |
Â
* Excluded api response that we don't want to send.
|
Â
|
|
104 |
Â
* @var array
|
105 |
Â
*/
|
106 |
-
public $exludeMessages
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
Â
|
|
117 |
Â
|
118 |
Â
/**
|
119 |
Â
* @param $apiUsername
|
120 |
Â
* @param $apiPassword
|
Â
|
|
121 |
Â
* @return bool|mixed
|
122 |
Â
*/
|
123 |
Â
public function validate($apiUsername, $apiPassword)
|
@@ -128,18 +135,26 @@ class Dotdigitalgroup_Email_Model_Apiconnector_Client extends Dotdigitalgroup_Em
|
|
128 |
Â
$accountInfo = $this->getAccountInfo();
|
129 |
Â
|
130 |
Â
if (isset($accountInfo->message)) {
|
131 |
-
Mage::getSingleton('adminhtml/session')->addError(
|
Â
|
|
Â
|
|
132 |
Â
$message = 'VALIDATION ERROR : ' . $accountInfo->message;
|
133 |
Â
Mage::helper('ddg')->log($message);
|
Â
|
|
134 |
Â
return false;
|
135 |
Â
}
|
Â
|
|
136 |
Â
return $accountInfo;
|
137 |
Â
}
|
Â
|
|
138 |
Â
return false;
|
139 |
Â
}
|
Â
|
|
140 |
Â
/**
|
141 |
Â
* Gets a contact by ID. Unsubscribed or suppressed contacts will not be retrieved.
|
Â
|
|
142 |
Â
* @param $id
|
Â
|
|
143 |
Â
* @return null
|
144 |
Â
*/
|
145 |
Â
public function getContactById($id)
|
@@ -149,9 +164,10 @@ class Dotdigitalgroup_Email_Model_Apiconnector_Client extends Dotdigitalgroup_Em
|
|
149 |
Â
->setVerb('GET');
|
150 |
Â
$response = $this->execute();
|
151 |
Â
|
152 |
-
if(isset($response->message)) {
|
153 |
-
$message = 'GET CONTACT INFO ID ' . $url . ', '
|
154 |
-
|
Â
|
|
155 |
Â
}
|
156 |
Â
|
157 |
Â
return $response;
|
@@ -161,36 +177,49 @@ class Dotdigitalgroup_Email_Model_Apiconnector_Client extends Dotdigitalgroup_Em
|
|
161 |
Â
* Bulk creates, or bulk updates, contacts. Import format can either be CSV or Excel.
|
162 |
Â
* Must include one column called "Email". Any other columns will attempt to map to your custom data fields.
|
163 |
Â
* The ID of returned object can be used to query import progress.
|
Â
|
|
164 |
Â
* @param $filename
|
165 |
Â
* @param $addressBookId
|
Â
|
|
166 |
Â
* @return mixed
|
167 |
Â
*/
|
168 |
Â
|
169 |
Â
public function postAddressBookContactsImport($filename, $addressBookId)
|
170 |
Â
{
|
171 |
-
$url
|
Â
|
|
172 |
Â
$helper = Mage::helper('ddg');
|
173 |
Â
|
174 |
Â
$ch = curl_init($url);
|
175 |
Â
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
|
176 |
-
curl_setopt(
|
Â
|
|
Â
|
|
Â
|
|
177 |
Â
|
178 |
Â
//case the deprication of @filename for uploading
|
179 |
Â
if (function_exists('curl_file_create')) {
|
180 |
Â
curl_setopt($ch, CURLOPT_SAFE_UPLOAD, false);
|
181 |
-
$args['file'] = curl_file_create(
|
Â
|
|
Â
|
|
182 |
Â
curl_setopt($ch, CURLOPT_POSTFIELDS, $args);
|
183 |
Â
|
184 |
Â
} else {
|
185 |
Â
//standart use of curl file
|
186 |
-
curl_setopt(
|
187 |
-
|
188 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
189 |
Â
}
|
190 |
Â
|
191 |
Â
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
192 |
Â
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
|
193 |
-
curl_setopt(
|
Â
|
|
194 |
Â
'Content-Type: multipart/form-data')
|
195 |
Â
);
|
196 |
Â
|
@@ -198,40 +227,50 @@ class Dotdigitalgroup_Email_Model_Apiconnector_Client extends Dotdigitalgroup_Em
|
|
198 |
Â
$result = curl_exec($ch);
|
199 |
Â
|
200 |
Â
//if curl error found
|
201 |
-
if(curl_errno($ch))
|
202 |
-
{
|
203 |
Â
//save the error
|
204 |
Â
$this->curlError = curl_error($ch);
|
205 |
Â
}
|
206 |
Â
|
207 |
Â
$result = json_decode($result);
|
208 |
Â
if (isset($result->message)) {
|
209 |
-
$message = 'POST ADDRESS BOOK ' . $addressBookId
|
Â
|
|
Â
|
|
210 |
Â
$helper->log($message);
|
211 |
Â
Mage::helper('ddg')->log($result)
|
212 |
Â
->rayLog($result->message);
|
213 |
Â
}
|
Â
|
|
214 |
Â
return $result;
|
215 |
Â
}
|
216 |
Â
|
217 |
Â
/**
|
218 |
Â
* Adds a contact to a given address book.
|
Â
|
|
219 |
Â
* @param $addressBookId
|
220 |
Â
* @param $apiContact
|
Â
|
|
221 |
Â
* @return mixed|null
|
222 |
Â
*/
|
223 |
Â
public function postAddressBookContacts($addressBookId, $apiContact)
|
224 |
Â
{
|
225 |
-
$url = $this->_apiEndpoint . self::REST_ADDRESS_BOOKS . $addressBookId
|
Â
|
|
226 |
Â
$this->setUrl($url)
|
227 |
Â
->setVerb("POST")
|
228 |
Â
->buildPostBody($apiContact);
|
229 |
Â
|
230 |
Â
$response = $this->execute();
|
231 |
Â
|
232 |
-
|
233 |
-
|
234 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
235 |
Â
Mage::helper('ddg')->log($message)
|
236 |
Â
->rayLog($response->message);
|
237 |
Â
}
|
@@ -241,14 +280,17 @@ class Dotdigitalgroup_Email_Model_Apiconnector_Client extends Dotdigitalgroup_Em
|
|
241 |
Â
|
242 |
Â
/**
|
243 |
Â
* Deletes all contacts from a given address book.
|
Â
|
|
244 |
Â
* @param $addressBookId
|
245 |
Â
* @param $contactId
|
Â
|
|
246 |
Â
* @return null
|
247 |
Â
*/
|
248 |
Â
public function deleteAddressBookContact($addressBookId, $contactId)
|
249 |
Â
{
|
250 |
Â
|
251 |
-
$url = $this->_apiEndpoint . self::REST_ADDRESS_BOOKS . $addressBookId
|
Â
|
|
252 |
Â
$this->setUrl($url)
|
253 |
Â
->setVerb('DELETE');
|
254 |
Â
|
@@ -257,27 +299,38 @@ class Dotdigitalgroup_Email_Model_Apiconnector_Client extends Dotdigitalgroup_Em
|
|
257 |
Â
|
258 |
Â
/**
|
259 |
Â
* Gets a report with statistics about what was successfully imported, and what was unable to be imported.
|
Â
|
|
260 |
Â
* @param $importId
|
Â
|
|
261 |
Â
* @return mixed
|
262 |
Â
*/
|
263 |
Â
public function getContactsImportReport($importId)
|
264 |
Â
{
|
265 |
-
$url = $this->_apiEndpoint . self::REST_CONTACTS_IMPORT . $importId
|
Â
|
|
266 |
Â
$this->setUrl($url)
|
267 |
Â
->setVerb('GET');
|
268 |
Â
$response = $this->execute();
|
269 |
Â
//log error
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
274 |
Â
}
|
Â
|
|
275 |
Â
return $response;
|
276 |
Â
}
|
277 |
Â
|
278 |
Â
/**
|
279 |
Â
* Gets a contact by email address.
|
Â
|
|
280 |
Â
* @param $email
|
Â
|
|
281 |
Â
* @return mixed
|
282 |
Â
*/
|
283 |
Â
public function getContactByEmail($email)
|
@@ -288,11 +341,16 @@ class Dotdigitalgroup_Email_Model_Apiconnector_Client extends Dotdigitalgroup_Em
|
|
288 |
Â
|
289 |
Â
$response = $this->execute();
|
290 |
Â
|
291 |
-
|
292 |
-
if (isset($response->message)
|
293 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
294 |
Â
Mage::helper('ddg')->log($message)
|
295 |
-
|
296 |
Â
}
|
297 |
Â
|
298 |
Â
return $response;
|
@@ -300,6 +358,7 @@ class Dotdigitalgroup_Email_Model_Apiconnector_Client extends Dotdigitalgroup_Em
|
|
300 |
Â
|
301 |
Â
/**
|
302 |
Â
* Get all address books.
|
Â
|
|
303 |
Â
* @return null
|
304 |
Â
*/
|
305 |
Â
public function getAddressBooks()
|
@@ -309,9 +368,14 @@ class Dotdigitalgroup_Email_Model_Apiconnector_Client extends Dotdigitalgroup_Em
|
|
309 |
Â
->setVerb("GET");
|
310 |
Â
|
311 |
Â
$response = $this->execute();
|
312 |
-
|
313 |
-
if (isset($response->message)
|
314 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
315 |
Â
Mage::helper('ddg')->log($message)
|
316 |
Â
->rayLog($response->message);
|
317 |
Â
}
|
@@ -321,6 +385,7 @@ class Dotdigitalgroup_Email_Model_Apiconnector_Client extends Dotdigitalgroup_Em
|
|
321 |
Â
|
322 |
Â
/**
|
323 |
Â
* Gets an address book by ID.
|
Â
|
|
324 |
Â
* @param $id
|
325 |
Â
*
|
326 |
Â
* @return null
|
@@ -336,7 +401,9 @@ class Dotdigitalgroup_Email_Model_Apiconnector_Client extends Dotdigitalgroup_Em
|
|
336 |
Â
$response = $this->execute();
|
337 |
Â
|
338 |
Â
if (isset($response->message)) {
|
339 |
-
Mage::helper('ddg')->log(
|
Â
|
|
Â
|
|
340 |
Â
}
|
341 |
Â
|
342 |
Â
return $response;
|
@@ -344,26 +411,33 @@ class Dotdigitalgroup_Email_Model_Apiconnector_Client extends Dotdigitalgroup_Em
|
|
344 |
Â
|
345 |
Â
/**
|
346 |
Â
* Creates an address book.
|
Â
|
|
347 |
Â
* @param $name
|
Â
|
|
348 |
Â
* @return null
|
349 |
Â
*/
|
350 |
Â
public function postAddressBooks($name, $visibility = 'Public')
|
351 |
Â
{
|
352 |
Â
$data = array(
|
353 |
-
'Name'
|
354 |
Â
'Visibility' => $visibility
|
355 |
Â
);
|
356 |
-
$url
|
357 |
Â
$this->setUrl($url)
|
358 |
Â
->setVerb('POST')
|
359 |
Â
->buildPostBody($data);
|
360 |
Â
|
361 |
Â
$response = $this->execute();
|
362 |
Â
//log error
|
363 |
-
|
364 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
365 |
Â
Mage::helper('ddg')->log($message)
|
366 |
-
|
367 |
Â
}
|
368 |
Â
|
369 |
Â
return $response;
|
@@ -371,6 +445,7 @@ class Dotdigitalgroup_Email_Model_Apiconnector_Client extends Dotdigitalgroup_Em
|
|
371 |
Â
|
372 |
Â
/**
|
373 |
Â
* Get list of all campaigns.
|
Â
|
|
374 |
Â
* @return mixed
|
375 |
Â
*/
|
376 |
Â
public function getCampaigns()
|
@@ -380,11 +455,16 @@ class Dotdigitalgroup_Email_Model_Apiconnector_Client extends Dotdigitalgroup_Em
|
|
380 |
Â
->setVerb('GET');
|
381 |
Â
|
382 |
Â
$response = $this->execute();
|
383 |
-
|
384 |
-
if (isset($response->message)
|
385 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
386 |
Â
Mage::helper('ddg')->log($message)
|
387 |
-
|
388 |
Â
}
|
389 |
Â
|
390 |
Â
return $response;
|
@@ -392,36 +472,45 @@ class Dotdigitalgroup_Email_Model_Apiconnector_Client extends Dotdigitalgroup_Em
|
|
392 |
Â
|
393 |
Â
/**
|
394 |
Â
* Creates a data field within the account.
|
395 |
-
*
|
396 |
-
* @param
|
Â
|
|
397 |
Â
* @param string $visibility public, private
|
398 |
-
* @param bool
|
Â
|
|
399 |
Â
* @return mixed
|
400 |
Â
*/
|
401 |
-
public function postDataFields($data, $type = 'String',
|
402 |
-
|
Â
|
|
403 |
Â
$url = $this->_apiEndpoint . self::REST_DATA_FILEDS;
|
404 |
Â
//set default value for the numeric datatype
|
405 |
-
if($type == 'numeric' &&
|
406 |
Â
$defaultValue = 0;
|
Â
|
|
407 |
Â
//set data for the string datatype
|
408 |
Â
if (is_string($data)) {
|
409 |
Â
$data = array(
|
410 |
-
'Name'
|
411 |
-
'Type'
|
412 |
Â
'Visibility' => $visibility
|
413 |
Â
);
|
414 |
Â
//default value
|
415 |
-
if($defaultValue)
|
416 |
Â
$data['DefaultValue'] = $defaultValue;
|
Â
|
|
417 |
Â
}
|
418 |
Â
$this->setUrl($url)
|
419 |
Â
->buildPostBody($data)
|
420 |
Â
->setVerb('POST');
|
421 |
Â
|
422 |
Â
$response = $this->execute();
|
423 |
-
|
424 |
-
if (isset($response->message)
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
425 |
Â
$message = 'POST CREATE DATAFIELDS ' . $response->message;
|
426 |
Â
Mage::helper('ddg')->log($message)
|
427 |
Â
->log($data)
|
@@ -433,6 +522,7 @@ class Dotdigitalgroup_Email_Model_Apiconnector_Client extends Dotdigitalgroup_Em
|
|
433 |
Â
|
434 |
Â
/**
|
435 |
Â
* Deletes a data field within the account.
|
Â
|
|
436 |
Â
* @param $name
|
437 |
Â
*
|
438 |
Â
* @return mixed
|
@@ -445,8 +535,12 @@ class Dotdigitalgroup_Email_Model_Apiconnector_Client extends Dotdigitalgroup_Em
|
|
445 |
Â
|
446 |
Â
$response = $this->execute();
|
447 |
Â
//log error
|
448 |
-
|
449 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
450 |
Â
Mage::helper('ddg')->log($message)
|
451 |
Â
->rayLog($response->message);
|
452 |
Â
}
|
@@ -456,6 +550,7 @@ class Dotdigitalgroup_Email_Model_Apiconnector_Client extends Dotdigitalgroup_Em
|
|
456 |
Â
|
457 |
Â
/**
|
458 |
Â
* Lists the data fields within the account.
|
Â
|
|
459 |
Â
* @return mixed
|
460 |
Â
*/
|
461 |
Â
public function getDataFields()
|
@@ -465,8 +560,12 @@ class Dotdigitalgroup_Email_Model_Apiconnector_Client extends Dotdigitalgroup_Em
|
|
465 |
Â
->setVerb('GET');
|
466 |
Â
|
467 |
Â
$response = $this->execute();
|
468 |
-
|
469 |
-
if (isset($response->message)
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
470 |
Â
$message = 'GET ALL DATAFIELDS ' . $response->message;
|
471 |
Â
Mage::helper('ddg')->log($message)
|
472 |
Â
->rayLog($response->message);
|
@@ -477,8 +576,10 @@ class Dotdigitalgroup_Email_Model_Apiconnector_Client extends Dotdigitalgroup_Em
|
|
477 |
Â
|
478 |
Â
/**
|
479 |
Â
* Updates a contact.
|
Â
|
|
480 |
Â
* @param $contactId
|
481 |
Â
* @param $data
|
Â
|
|
482 |
Â
* @return object
|
483 |
Â
*/
|
484 |
Â
public function updateContact($contactId, $data)
|
@@ -489,9 +590,14 @@ class Dotdigitalgroup_Email_Model_Apiconnector_Client extends Dotdigitalgroup_Em
|
|
489 |
Â
->buildPostBody($data);
|
490 |
Â
|
491 |
Â
$response = $this->execute();
|
492 |
-
|
493 |
-
if (isset($response->message)
|
494 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
495 |
Â
Mage::helper('ddg')->log($message)
|
496 |
Â
->log($data)
|
497 |
Â
->rayLog($response->message);
|
@@ -502,7 +608,9 @@ class Dotdigitalgroup_Email_Model_Apiconnector_Client extends Dotdigitalgroup_Em
|
|
502 |
Â
|
503 |
Â
/**
|
504 |
Â
* Deletes a contact.
|
Â
|
|
505 |
Â
* @param $contactId
|
Â
|
|
506 |
Â
* @return null
|
507 |
Â
*/
|
508 |
Â
public function deleteContact($contactId)
|
@@ -512,17 +620,23 @@ class Dotdigitalgroup_Email_Model_Apiconnector_Client extends Dotdigitalgroup_Em
|
|
512 |
Â
->setVerb('DELETE');
|
513 |
Â
|
514 |
Â
$response = $this->execute();
|
515 |
-
|
516 |
-
if (isset($response->message)
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
517 |
Â
$message = 'DELETE CONTACT : ' . $url . ', ' . $response->message;
|
518 |
Â
Mage::helper('ddg')->log($message)
|
519 |
Â
->rayLog($response->message);
|
520 |
Â
}
|
Â
|
|
521 |
Â
return $response;
|
522 |
Â
}
|
523 |
Â
|
524 |
Â
/**
|
525 |
Â
* Update contact datafields by email.
|
Â
|
|
526 |
Â
* @param $email
|
527 |
Â
* @param $dataFields
|
528 |
Â
*
|
@@ -533,25 +647,31 @@ class Dotdigitalgroup_Email_Model_Apiconnector_Client extends Dotdigitalgroup_Em
|
|
533 |
Â
{
|
534 |
Â
$apiContact = $this->postContacts($email);
|
535 |
Â
//do not create for non contact id set
|
536 |
-
if (! isset($apiContact->id)) {
|
537 |
Â
return $apiContact;
|
538 |
Â
} else {
|
539 |
Â
//get the contact id for this email
|
540 |
Â
$contactId = $apiContact->id;
|
541 |
Â
}
|
542 |
-
$data
|
543 |
-
'Email'
|
544 |
Â
'EmailType' => 'Html');
|
545 |
Â
$data['DataFields'] = $dataFields;
|
546 |
-
$url
|
Â
|
|
547 |
Â
$this->setUrl($url)
|
548 |
Â
->setVerb('PUT')
|
549 |
Â
->buildPostBody($data);
|
550 |
Â
|
551 |
Â
$response = $this->execute();
|
552 |
-
|
553 |
-
if (isset($response->message)
|
554 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
555 |
Â
Mage::helper('ddg')->log($message)
|
556 |
Â
->log($data)
|
557 |
Â
->rayLog($response->message);
|
@@ -563,15 +683,17 @@ class Dotdigitalgroup_Email_Model_Apiconnector_Client extends Dotdigitalgroup_Em
|
|
563 |
Â
/**
|
564 |
Â
* Sends a specified campaign to one or more address books, segments or contacts at a specified time.
|
565 |
Â
* Leave the address book array empty to send to All Contacts.
|
Â
|
|
566 |
Â
* @param $campaignId
|
567 |
Â
* @param $contacts
|
Â
|
|
568 |
Â
* @return mixed
|
569 |
Â
*/
|
570 |
Â
public function postCampaignsSend($campaignId, $contacts)
|
571 |
Â
{
|
572 |
Â
$data = array(
|
573 |
-
'username'
|
574 |
-
'password'
|
575 |
Â
"campaignId" => $campaignId,
|
576 |
Â
"ContactIds" => $contacts
|
577 |
Â
);
|
@@ -580,9 +702,13 @@ class Dotdigitalgroup_Email_Model_Apiconnector_Client extends Dotdigitalgroup_Em
|
|
580 |
Â
->buildPostBody($data);
|
581 |
Â
|
582 |
Â
$response = $this->execute();
|
583 |
-
|
584 |
-
if (isset($response->message)
|
585 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
586 |
Â
Mage::helper('ddg')->log($message)
|
587 |
Â
->log($data)
|
588 |
Â
->rayLog($response->message);
|
@@ -593,21 +719,27 @@ class Dotdigitalgroup_Email_Model_Apiconnector_Client extends Dotdigitalgroup_Em
|
|
593 |
Â
|
594 |
Â
/**
|
595 |
Â
* Creates a contact.
|
Â
|
|
596 |
Â
* @param $email
|
Â
|
|
597 |
Â
* @return mixed
|
598 |
Â
*/
|
599 |
Â
public function postContacts($email)
|
600 |
Â
{
|
601 |
-
|
602 |
-
|
603 |
-
|
604 |
-
|
605 |
-
|
606 |
-
|
607 |
-
|
608 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
609 |
Â
$data = array(
|
610 |
-
'Email'
|
611 |
Â
'EmailType' => 'Html',
|
612 |
Â
);
|
613 |
Â
$this->setUrl($url)
|
@@ -615,9 +747,13 @@ class Dotdigitalgroup_Email_Model_Apiconnector_Client extends Dotdigitalgroup_Em
|
|
615 |
Â
->buildPostBody($data);
|
616 |
Â
|
617 |
Â
$response = $this->execute();
|
618 |
-
|
619 |
-
if (isset($response->message)
|
620 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
621 |
Â
Mage::helper('ddg')->log($message)
|
622 |
Â
->rayLog($response->message);
|
623 |
Â
}
|
@@ -628,21 +764,31 @@ class Dotdigitalgroup_Email_Model_Apiconnector_Client extends Dotdigitalgroup_Em
|
|
628 |
Â
|
629 |
Â
/**
|
630 |
Â
* Gets a list of suppressed contacts after a given date along with the reason for suppression.
|
Â
|
|
631 |
Â
* @param $dateString
|
632 |
Â
* @param $select
|
633 |
Â
* @param $skip
|
Â
|
|
634 |
Â
* @return object
|
635 |
Â
*/
|
636 |
-
public function getContactsSuppressedSinceDate($dateString, $select = 1000,
|
637 |
-
|
638 |
-
|
Â
|
|
Â
|
|
639 |
Â
$this->setUrl($url)
|
640 |
Â
->setVerb("GET");
|
641 |
Â
|
642 |
Â
$response = $this->execute();
|
643 |
-
|
644 |
-
if (isset($response->message)
|
645 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
646 |
Â
Mage::helper('ddg')->log($message)
|
647 |
Â
->rayLog($response->message);
|
648 |
Â
}
|
@@ -652,30 +798,38 @@ class Dotdigitalgroup_Email_Model_Apiconnector_Client extends Dotdigitalgroup_Em
|
|
652 |
Â
|
653 |
Â
/**
|
654 |
Â
* Adds multiple pieces of transactional data to contacts asynchronously, returning an identifier that can be used to check for import progress.
|
Â
|
|
655 |
Â
* @param $collectionName
|
656 |
Â
* @param $transactionalData
|
Â
|
|
657 |
Â
* @return object
|
658 |
Â
*/
|
659 |
-
public function postContactsTransactionalDataImport($transactionalData,
|
660 |
-
|
Â
|
|
661 |
Â
$orders = array();
|
662 |
Â
foreach ($transactionalData as $one) {
|
663 |
Â
if (isset($one->email)) {
|
664 |
Â
$orders[] = array(
|
665 |
-
'Key'
|
666 |
Â
'ContactIdentifier' => $one->email,
|
667 |
-
'Json'
|
668 |
Â
);
|
669 |
Â
}
|
670 |
Â
}
|
671 |
-
$url = $this->_apiEndpoint . self::REST_TRANSACTIONAL_DATA_IMPORT
|
Â
|
|
672 |
Â
$this->setURl($url)
|
673 |
Â
->setVerb('POST')
|
674 |
Â
->buildPostBody($orders);
|
675 |
Â
|
676 |
Â
$response = $this->execute();
|
677 |
-
|
678 |
-
if (isset($response->message)
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
679 |
Â
$message = ' SEND MULTI TRANSACTIONAL DATA ' . $response->message;
|
680 |
Â
Mage::helper('ddg')->log($message)
|
681 |
Â
->rayLog($response->message);
|
@@ -687,33 +841,45 @@ class Dotdigitalgroup_Email_Model_Apiconnector_Client extends Dotdigitalgroup_Em
|
|
687 |
Â
/**
|
688 |
Â
* Adds a single piece of transactional data to a contact.
|
689 |
Â
*
|
690 |
-
* @param
|
691 |
Â
* @param string $collectionName
|
692 |
Â
*
|
693 |
Â
* @return null
|
694 |
Â
* @throws Exception
|
695 |
Â
*/
|
696 |
-
public function postContactsTransactionalData($data,
|
697 |
-
|
698 |
-
|
699 |
-
|
700 |
-
$
|
701 |
-
|
702 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
703 |
Â
}
|
704 |
Â
$apiData = array(
|
705 |
-
'Key'
|
706 |
Â
'ContactIdentifier' => $data->email,
|
707 |
-
'Json'
|
708 |
Â
);
|
709 |
Â
|
710 |
Â
$this->setUrl($url)
|
711 |
Â
->setVerb('POST')
|
712 |
Â
->buildPostBody($apiData);
|
713 |
Â
$response = $this->execute();
|
714 |
-
|
715 |
-
if (isset($response->message)
|
716 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
717 |
Â
Mage::helper('ddg')->log($message)
|
718 |
Â
->log($apiData)
|
719 |
Â
->rayLog($response->message);
|
@@ -724,13 +890,16 @@ class Dotdigitalgroup_Email_Model_Apiconnector_Client extends Dotdigitalgroup_Em
|
|
724 |
Â
|
725 |
Â
/**
|
726 |
Â
* Gets a piece of transactional data by key.
|
Â
|
|
727 |
Â
* @param $name
|
728 |
Â
* @param $key
|
Â
|
|
729 |
Â
* @return null
|
730 |
Â
*/
|
731 |
Â
public function getContactsTransactionalDataByKey($name, $key)
|
732 |
Â
{
|
733 |
-
$url = $this->_apiEndpoint . self::REST_TRANSACTIONAL_DATA . $name . '/'
|
Â
|
|
734 |
Â
$this->setUrl($url)
|
735 |
Â
->setVerb('GET');
|
736 |
Â
|
@@ -739,13 +908,17 @@ class Dotdigitalgroup_Email_Model_Apiconnector_Client extends Dotdigitalgroup_Em
|
|
739 |
Â
|
740 |
Â
/**
|
741 |
Â
* Deletes all transactional data for a contact.
|
742 |
-
*
|
Â
|
|
743 |
Â
* @param string $collectionName
|
Â
|
|
744 |
Â
* @return object
|
745 |
Â
*/
|
746 |
-
public function deleteContactTransactionalData($email,
|
747 |
-
|
748 |
-
|
Â
|
|
Â
|
|
749 |
Â
$this->setUrl($url)
|
750 |
Â
->setVerb('DELETE');
|
751 |
Â
|
@@ -754,6 +927,7 @@ class Dotdigitalgroup_Email_Model_Apiconnector_Client extends Dotdigitalgroup_Em
|
|
754 |
Â
|
755 |
Â
/**
|
756 |
Â
* Gets a summary of information about the current status of the account.
|
Â
|
|
757 |
Â
* @return mixed
|
758 |
Â
*/
|
759 |
Â
public function getAccountInfo()
|
@@ -763,34 +937,14 @@ class Dotdigitalgroup_Email_Model_Apiconnector_Client extends Dotdigitalgroup_Em
|
|
763 |
Â
->setVerb('GET');
|
764 |
Â
|
765 |
Â
$response = $this->execute();
|
766 |
-
|
767 |
-
if (isset($response->message)
|
768 |
-
|
769 |
-
|
770 |
-
|
771 |
-
|
772 |
-
|
773 |
-
|
774 |
-
}
|
775 |
-
|
776 |
-
/**
|
777 |
-
* Send a single SMS message.
|
778 |
-
* @param $telephoneNumber
|
779 |
-
* @param $message
|
780 |
-
* @return object
|
781 |
-
*/
|
782 |
-
public function postSmsMessagesSendTo($telephoneNumber, $message)
|
783 |
-
{
|
784 |
-
$data = array('Message' => $message);
|
785 |
-
$url = $this->_apiEndpoint . self::REST_SMS_MESSAGE_SEND_TO . $telephoneNumber;
|
786 |
-
$this->setUrl($url)
|
787 |
-
->setVerb('POST')
|
788 |
-
->buildPostBody($data);
|
789 |
-
|
790 |
-
$response = $this->execute();
|
791 |
-
//log error
|
792 |
-
if (isset($response->message) && ! in_array($response->message, $this->exludeMessages)) {
|
793 |
-
$message = 'POST SMS MESSAGE SEND to ' . $telephoneNumber . ' message: ' . $message . ' error: ' . $response->message;
|
794 |
Â
Mage::helper('ddg')->log($message)
|
795 |
Â
->rayLog($response->message);
|
796 |
Â
}
|
@@ -798,25 +952,32 @@ class Dotdigitalgroup_Email_Model_Apiconnector_Client extends Dotdigitalgroup_Em
|
|
798 |
Â
return $response;
|
799 |
Â
}
|
800 |
Â
|
801 |
-
|
802 |
Â
/**
|
803 |
Â
* Deletes multiple contacts from an address book.
|
Â
|
|
804 |
Â
* @param $addressBookId
|
805 |
Â
* @param $contactIds
|
Â
|
|
806 |
Â
* @return object
|
807 |
Â
*/
|
808 |
Â
public function deleteAddressBookContactsInbulk($addressBookId, $contactIds)
|
809 |
Â
{
|
810 |
-
$url
|
Â
|
|
811 |
Â
$data = array('ContactIds' => array($contactIds[0]));
|
812 |
Â
$this->setUrl($url)
|
813 |
Â
->setVerb('DELETE')
|
814 |
Â
->buildPostBody($data);
|
815 |
Â
|
816 |
Â
$response = $this->execute();
|
817 |
-
|
818 |
-
if (isset($response->message)
|
819 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
820 |
Â
Mage::helper('ddg')->log($message)
|
821 |
Â
->rayLog($response->message);
|
822 |
Â
}
|
@@ -824,17 +985,17 @@ class Dotdigitalgroup_Email_Model_Apiconnector_Client extends Dotdigitalgroup_Em
|
|
824 |
Â
return $response;
|
825 |
Â
}
|
826 |
Â
|
827 |
-
|
828 |
-
|
829 |
-
|
830 |
-
|
831 |
-
|
832 |
-
|
833 |
-
|
834 |
-
|
835 |
Â
public function postContactsResubscribe($apiContact)
|
836 |
Â
{
|
837 |
-
$url
|
838 |
Â
$data = array(
|
839 |
Â
'UnsubscribedContact' => $apiContact
|
840 |
Â
);
|
@@ -844,13 +1005,19 @@ class Dotdigitalgroup_Email_Model_Apiconnector_Client extends Dotdigitalgroup_Em
|
|
844 |
Â
|
845 |
Â
$response = $this->execute();
|
846 |
Â
//log error
|
847 |
-
|
848 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
849 |
Â
Mage::helper('ddg')->log($message)
|
850 |
Â
->log($data)
|
851 |
Â
->rayLog($response->message);
|
852 |
Â
}
|
853 |
-
|
Â
|
|
854 |
Â
}
|
855 |
Â
|
856 |
Â
/**
|
@@ -867,9 +1034,14 @@ class Dotdigitalgroup_Email_Model_Apiconnector_Client extends Dotdigitalgroup_Em
|
|
867 |
Â
->setVerb('GET');
|
868 |
Â
|
869 |
Â
$response = $this->execute();
|
870 |
-
|
871 |
-
if (isset($response->message)
|
872 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
873 |
Â
Mage::helper('ddg')->log($message)
|
874 |
Â
->rayLog($response->message);
|
875 |
Â
}
|
@@ -877,14 +1049,14 @@ class Dotdigitalgroup_Email_Model_Apiconnector_Client extends Dotdigitalgroup_Em
|
|
877 |
Â
return $response;
|
878 |
Â
}
|
879 |
Â
|
880 |
-
|
881 |
-
|
882 |
-
|
883 |
-
|
884 |
-
|
885 |
-
|
886 |
-
|
887 |
-
|
888 |
Â
public function postCampaign($data)
|
889 |
Â
{
|
890 |
Â
$url = $this->_apiEndpoint . self::REST_CREATE_CAMPAIGN;
|
@@ -893,8 +1065,12 @@ class Dotdigitalgroup_Email_Model_Apiconnector_Client extends Dotdigitalgroup_Em
|
|
893 |
Â
->buildPostBody($data);
|
894 |
Â
|
895 |
Â
$response = $this->execute();
|
896 |
-
|
897 |
-
if (isset($response->message)
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
898 |
Â
$message = ' CREATE CAMPAIGN ' . $response->message;
|
899 |
Â
Mage::helper('ddg')->log($message)
|
900 |
Â
->rayLog($response->message);
|
@@ -915,10 +1091,14 @@ class Dotdigitalgroup_Email_Model_Apiconnector_Client extends Dotdigitalgroup_Em
|
|
915 |
Â
->setVerb('GET');
|
916 |
Â
|
917 |
Â
$response = $this->execute();
|
918 |
-
|
919 |
-
if (isset($response->message)
|
920 |
-
|
921 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
922 |
Â
->rayLog($response->message);
|
923 |
Â
}
|
924 |
Â
|
@@ -927,6 +1107,7 @@ class Dotdigitalgroup_Email_Model_Apiconnector_Client extends Dotdigitalgroup_Em
|
|
927 |
Â
|
928 |
Â
/**
|
929 |
Â
* Creates an enrolment.
|
Â
|
|
930 |
Â
* @param $data
|
931 |
Â
*
|
932 |
Â
* @return null
|
@@ -940,8 +1121,12 @@ class Dotdigitalgroup_Email_Model_Apiconnector_Client extends Dotdigitalgroup_Em
|
|
940 |
Â
->buildPostBody($data);
|
941 |
Â
|
942 |
Â
$response = $this->execute();
|
943 |
-
|
944 |
-
if (isset($response->message)
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
945 |
Â
$message = 'Post programs enrolments : ' . $response->message;
|
946 |
Â
Mage::helper('ddg')->log($message)
|
947 |
Â
->log($data)
|
@@ -953,20 +1138,25 @@ class Dotdigitalgroup_Email_Model_Apiconnector_Client extends Dotdigitalgroup_Em
|
|
953 |
Â
|
954 |
Â
/**
|
955 |
Â
* Gets a program by id.
|
Â
|
|
956 |
Â
* @param $id
|
957 |
Â
*
|
958 |
Â
* @return null
|
959 |
Â
* @throws Exception
|
960 |
Â
*/
|
961 |
-
public function getProgramById(
|
962 |
Â
{
|
963 |
-
$url =
|
964 |
Â
$this->setUrl($url)
|
965 |
Â
->setVerb('GET');
|
966 |
Â
|
967 |
Â
$response = $this->execute();
|
968 |
-
|
969 |
-
if (isset($response->message)
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
970 |
Â
$message = 'Get program by id ' . $id . ', ' . $response->message;
|
971 |
Â
Mage::helper('ddg')->log($message)
|
972 |
Â
->rayLog($response->message);
|
@@ -977,6 +1167,7 @@ class Dotdigitalgroup_Email_Model_Apiconnector_Client extends Dotdigitalgroup_Em
|
|
977 |
Â
|
978 |
Â
/**
|
979 |
Â
* Gets a summary of reporting information for a specified campaign.
|
Â
|
|
980 |
Â
* @param $campaignId
|
981 |
Â
*
|
982 |
Â
* @return null
|
@@ -984,15 +1175,21 @@ class Dotdigitalgroup_Email_Model_Apiconnector_Client extends Dotdigitalgroup_Em
|
|
984 |
Â
*/
|
985 |
Â
public function getCampaignSummary($campaignId)
|
986 |
Â
{
|
987 |
-
$url = $this->_apiEndpoint . '/v2/campaigns/' . $campaignId
|
Â
|
|
988 |
Â
|
989 |
Â
$this->setUrl($url)
|
990 |
Â
->setVerb('GET');
|
991 |
Â
$response = $this->execute();
|
992 |
-
|
993 |
-
if (isset($response->message)
|
994 |
-
|
995 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
996 |
Â
->rayLog($response->message);
|
997 |
Â
}
|
998 |
Â
|
@@ -1001,25 +1198,34 @@ class Dotdigitalgroup_Email_Model_Apiconnector_Client extends Dotdigitalgroup_Em
|
|
1001 |
Â
|
1002 |
Â
/**
|
1003 |
Â
* Deletes a piece of transactional data by key.
|
1004 |
-
*
|
Â
|
|
1005 |
Â
* @param string $collectionName
|
Â
|
|
1006 |
Â
* @return object
|
1007 |
Â
*/
|
1008 |
-
public function deleteContactsTransactionalData($key,
|
1009 |
-
|
1010 |
-
|
Â
|
|
Â
|
|
1011 |
Â
$this->setUrl($url)
|
1012 |
Â
->setVerb('DELETE');
|
1013 |
Â
$response = $this->execute();
|
1014 |
Â
|
1015 |
-
if (isset($response->message))
|
1016 |
-
Mage::helper('ddg')->log(
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
1017 |
Â
|
1018 |
Â
return $response;
|
1019 |
Â
}
|
1020 |
Â
|
1021 |
Â
/**
|
1022 |
Â
* Adds a document to a campaign as an attachment.
|
Â
|
|
1023 |
Â
* @param $campaignId
|
1024 |
Â
* @param $data
|
1025 |
Â
*
|
@@ -1028,42 +1234,17 @@ class Dotdigitalgroup_Email_Model_Apiconnector_Client extends Dotdigitalgroup_Em
|
|
1028 |
Â
*/
|
1029 |
Â
public function postCampaignAttachments($campaignId, $data)
|
1030 |
Â
{
|
1031 |
-
$url = $this->_apiEndpoint . self::REST_CREATE_CAMPAIGN
|
Â
|
|
1032 |
Â
$this->setURl($url)
|
1033 |
Â
->setVerb('POST')
|
1034 |
Â
->buildPostBody($data);
|
1035 |
Â
$result = $this->execute();
|
1036 |
Â
|
1037 |
Â
if (isset($result->message)) {
|
1038 |
-
Mage::helper('ddg')->log(
|
1039 |
-
|
1040 |
-
|
1041 |
-
}
|
1042 |
-
|
1043 |
-
|
1044 |
-
public function getNostoProducts($slotName, $email)
|
1045 |
-
{
|
1046 |
-
$recommended = Dotdigitalgroup_Email_Helper_Config::API_ENDPOINT . '/recommendations/email';
|
1047 |
-
$token = Mage::getStoreConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_DYNAMIC_CONTENT_NOSTO);
|
1048 |
-
|
1049 |
-
//check for strin length
|
1050 |
-
if (strlen($slotName) > 1 && strlen($email) > 1) {
|
1051 |
-
|
1052 |
-
$recommended .= '?elements=' . $slotName;
|
1053 |
-
$recommended .= '&emails=' . $email;
|
1054 |
-
}
|
1055 |
-
|
1056 |
-
$this->setApiUsername('')
|
1057 |
-
->setApiPassword($token)
|
1058 |
-
->setUrl($recommended)
|
1059 |
-
->setVerb('GET');
|
1060 |
-
|
1061 |
-
$result = $this->execute();
|
1062 |
-
|
1063 |
-
if (isset($result->message)) {
|
1064 |
-
$message = $result->message;
|
1065 |
-
Mage::helper('ddg')->log($message);
|
1066 |
-
Mage::helper('ddg')->log("Nosto recommendation slot name : $slotName , email : $email");
|
1067 |
Â
}
|
1068 |
Â
|
1069 |
Â
return $result;
|
@@ -1073,18 +1254,25 @@ class Dotdigitalgroup_Email_Model_Apiconnector_Client extends Dotdigitalgroup_Em
|
|
1073 |
Â
* get contact address books
|
1074 |
Â
*
|
1075 |
Â
* @param $contactId
|
Â
|
|
1076 |
Â
* @return object
|
1077 |
Â
* @throws Exception
|
1078 |
Â
*/
|
1079 |
Â
public function getContactAddressBooks($contactId)
|
1080 |
Â
{
|
1081 |
-
$url =
|
Â
|
|
1082 |
Â
$this->setUrl($url)
|
1083 |
Â
->setVerb('GET');
|
1084 |
Â
$response = $this->execute();
|
1085 |
-
|
1086 |
-
if (isset($response->message)
|
1087 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
1088 |
Â
Mage::helper('ddg')->log($message)
|
1089 |
Â
->rayLog($response->message);
|
1090 |
Â
}
|
@@ -1100,17 +1288,21 @@ class Dotdigitalgroup_Email_Model_Apiconnector_Client extends Dotdigitalgroup_Em
|
|
1100 |
Â
*/
|
1101 |
Â
public function getApiTemplateList()
|
1102 |
Â
{
|
1103 |
-
$url =
|
1104 |
Â
$this->setUrl($url)
|
1105 |
Â
->setVerb('GET');
|
1106 |
Â
|
1107 |
-
|
1108 |
Â
|
1109 |
-
|
1110 |
-
if (isset($response->message)
|
1111 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
1112 |
Â
Mage::helper('ddg')->log($message)
|
1113 |
-
|
1114 |
Â
}
|
1115 |
Â
|
1116 |
Â
return $response;
|
@@ -1120,19 +1312,24 @@ class Dotdigitalgroup_Email_Model_Apiconnector_Client extends Dotdigitalgroup_Em
|
|
1120 |
Â
* Gets a template by ID.
|
1121 |
Â
*
|
1122 |
Â
* @param $templateId
|
Â
|
|
1123 |
Â
* @return object
|
1124 |
Â
* @throws Exception
|
1125 |
Â
*/
|
1126 |
Â
public function getApiTemplate($templateId)
|
1127 |
Â
{
|
1128 |
-
$url =
|
1129 |
Â
$this->setUrl($url)
|
1130 |
Â
->setVerb('GET');
|
1131 |
Â
|
1132 |
Â
$response = $this->execute();
|
1133 |
-
|
1134 |
-
if (isset($response->message)
|
1135 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
1136 |
Â
Mage::helper('ddg')->log($message)
|
1137 |
Â
->rayLog($response->message);
|
1138 |
Â
}
|
@@ -1142,31 +1339,40 @@ class Dotdigitalgroup_Email_Model_Apiconnector_Client extends Dotdigitalgroup_Em
|
|
1142 |
Â
|
1143 |
Â
/**
|
1144 |
Â
* Adds multiple pieces of transactional data to account asynchronously, returning an identifier that can be used to check for import progress.
|
Â
|
|
1145 |
Â
* @param $collectionName
|
1146 |
Â
* @param $transactionalData
|
Â
|
|
1147 |
Â
* @return object
|
1148 |
Â
*/
|
1149 |
-
public function postAccountTransactionalDataImport($transactionalData,
|
1150 |
-
|
Â
|
|
1151 |
Â
$orders = array();
|
1152 |
Â
foreach ($transactionalData as $one) {
|
1153 |
Â
if (isset($one->id)) {
|
1154 |
Â
$orders[] = array(
|
1155 |
-
'Key'
|
1156 |
Â
'ContactIdentifier' => 'account',
|
1157 |
-
'Json'
|
1158 |
Â
);
|
1159 |
Â
}
|
1160 |
Â
}
|
1161 |
-
$url = $this->_apiEndpoint . self::REST_TRANSACTIONAL_DATA_IMPORT
|
Â
|
|
1162 |
Â
$this->setURl($url)
|
1163 |
Â
->setVerb('POST')
|
1164 |
Â
->buildPostBody($orders);
|
1165 |
Â
|
1166 |
Â
$response = $this->execute();
|
1167 |
-
|
1168 |
-
if (isset($response->message)
|
1169 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
1170 |
Â
Mage::helper('ddg')->log($message)
|
1171 |
Â
->rayLog($response->message);
|
1172 |
Â
}
|
@@ -1176,15 +1382,21 @@ class Dotdigitalgroup_Email_Model_Apiconnector_Client extends Dotdigitalgroup_Em
|
|
1176 |
Â
|
1177 |
Â
public function getCampaignsWithActivitySinceDate($dateTime)
|
1178 |
Â
{
|
1179 |
-
$url = $this->_apiEndpoint . self::REST_DATA_FIELDS_CAMPAIGNS
|
Â
|
|
1180 |
Â
|
1181 |
Â
$this->setUrl($url)
|
1182 |
Â
->setVerb('GET');
|
1183 |
Â
|
1184 |
Â
$response = $this->execute();
|
1185 |
-
|
1186 |
-
if (isset($response->message)
|
1187 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
1188 |
Â
Mage::helper('ddg')->log($message)
|
1189 |
Â
->rayLog($response->message);
|
1190 |
Â
}
|
@@ -1194,15 +1406,21 @@ class Dotdigitalgroup_Email_Model_Apiconnector_Client extends Dotdigitalgroup_Em
|
|
1194 |
Â
|
1195 |
Â
public function getCampaignActivityByContactId($campaignId, $contactId)
|
1196 |
Â
{
|
1197 |
-
$url = $this->_apiEndpoint . self::REST_DATA_FIELDS_CAMPAIGNS . '/'
|
Â
|
|
1198 |
Â
|
1199 |
Â
$this->setUrl($url)
|
1200 |
Â
->setVerb('GET');
|
1201 |
Â
|
1202 |
Â
$response = $this->execute();
|
1203 |
-
|
1204 |
-
if (isset($response->message)
|
1205 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
1206 |
Â
Mage::helper('ddg')->log($message)
|
1207 |
Â
->rayLog($response->message);
|
1208 |
Â
}
|
@@ -1214,6 +1432,7 @@ class Dotdigitalgroup_Email_Model_Apiconnector_Client extends Dotdigitalgroup_Em
|
|
1214 |
Â
* Gets the import status of a previously started contact import.
|
1215 |
Â
*
|
1216 |
Â
* @param $importId
|
Â
|
|
1217 |
Â
* @return object
|
1218 |
Â
*/
|
1219 |
Â
public function getContactsImportByImportId($importId)
|
@@ -1223,9 +1442,13 @@ class Dotdigitalgroup_Email_Model_Apiconnector_Client extends Dotdigitalgroup_Em
|
|
1223 |
Â
$this->setUrl($url)
|
1224 |
Â
->setVerb('GET');
|
1225 |
Â
|
1226 |
-
|
1227 |
Â
//log error
|
1228 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
1229 |
Â
$message = 'GET CONTACTS IMPORT BY IMPORT ID ' . $response->message;
|
1230 |
Â
Mage::helper('ddg')->log($message)
|
1231 |
Â
->rayLog($response->message);
|
@@ -1238,19 +1461,26 @@ class Dotdigitalgroup_Email_Model_Apiconnector_Client extends Dotdigitalgroup_Em
|
|
1238 |
Â
* Gets the import status of a previously started transactional import.
|
1239 |
Â
*
|
1240 |
Â
* @param $importId
|
Â
|
|
1241 |
Â
* @return object
|
1242 |
Â
*/
|
1243 |
Â
public function getContactsTransactionalDataImportByImportId($importId)
|
1244 |
Â
{
|
1245 |
-
$url = $this->_apiEndpoint . self::REST_TRANSACTIONAL_DATA_IMPORT
|
Â
|
|
1246 |
Â
|
1247 |
Â
$this->setUrl($url)
|
1248 |
Â
->setVerb('GET');
|
1249 |
Â
|
1250 |
-
|
1251 |
-
|
1252 |
-
if (isset($response->message)
|
1253 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
1254 |
Â
Mage::helper('ddg')->log($message)
|
1255 |
Â
->rayLog($response->message);
|
1256 |
Â
}
|
@@ -1262,12 +1492,14 @@ class Dotdigitalgroup_Email_Model_Apiconnector_Client extends Dotdigitalgroup_Em
|
|
1262 |
Â
* get contact import report faults
|
1263 |
Â
*
|
1264 |
Â
* @param $id
|
Â
|
|
1265 |
Â
* @return bool|null
|
1266 |
Â
* @throws Exception
|
1267 |
Â
*/
|
1268 |
Â
public function getContactImportReportFaults($id)
|
1269 |
Â
{
|
1270 |
-
$url = $this->_apiEndpoint . self::REST_CONTACTS_IMPORT . $id
|
Â
|
|
1271 |
Â
$this->setUrl($url)
|
1272 |
Â
->setVerb('GET');
|
1273 |
Â
|
@@ -1275,13 +1507,19 @@ class Dotdigitalgroup_Email_Model_Apiconnector_Client extends Dotdigitalgroup_Em
|
|
1275 |
Â
$response = $this->execute();
|
1276 |
Â
|
1277 |
Â
//if string is JSON than there is a error message
|
1278 |
-
if(json_decode($response)){
|
1279 |
Â
//log error
|
1280 |
-
if (isset($response->message)
|
1281 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
1282 |
Â
Mage::helper('ddg')->log($message)
|
1283 |
Â
->rayLog($response->message);
|
1284 |
Â
}
|
Â
|
|
1285 |
Â
return false;
|
1286 |
Â
}
|
1287 |
Â
|
1 |
Â
<?php
|
2 |
Â
|
3 |
+
class Dotdigitalgroup_Email_Model_Apiconnector_Client
|
4 |
+
extends Dotdigitalgroup_Email_Model_Abstract_Rest
|
5 |
Â
{
|
6 |
+
|
7 |
Â
const APICONNECTOR_VERSION = 'V2';
|
8 |
Â
|
9 |
Â
const REST_WAIT_UPLOAD_TIME = 5;
|
10 |
Â
//rest api data
|
11 |
+
const REST_ACCOUNT_INFO = 'https://r1-api.dotmailer.com/v2/account-info';
|
12 |
+
const REST_CONTACTS = '/v2/contacts/';
|
13 |
+
const REST_CONTACTS_IMPORT = '/v2/contacts/import/';
|
14 |
+
const REST_ADDRESS_BOOKS = '/v2/address-books/';
|
15 |
+
const REST_DATA_FILEDS = '/v2/data-fields';
|
16 |
+
const REST_TRANSACTIONAL_DATA_IMPORT = '/v2/contacts/transactional-data/import/';
|
17 |
+
const REST_TRANSACTIONAL_DATA = '/v2/contacts/transactional-data/';
|
18 |
+
const REST_CAMPAIGN_SEND = '/v2/campaigns/send';
|
19 |
+
const REST_CONTACTS_SUPPRESSED_SINCE = '/v2/contacts/suppressed-since/';
|
20 |
+
const REST_DATA_FIELDS_CAMPAIGNS = '/v2/campaigns';
|
21 |
+
const REST_CONTACTS_RESUBSCRIBE = '/v2/contacts/resubscribe';
|
22 |
+
const REST_CAMPAIGN_FROM_ADDRESS_LIST = '/v2/custom-from-addresses';
|
23 |
+
const REST_CREATE_CAMPAIGN = '/v2/campaigns';
|
24 |
+
const REST_PROGRAM = '/v2/programs/';
|
25 |
+
const REST_PROGRAM_ENROLMENTS = '/v2/programs/enrolments';
|
26 |
+
const REST_TEMPLATES = '/v2/templates';
|
Â
|
|
27 |
Â
|
28 |
Â
//rest error responces
|
29 |
+
const API_ERROR_API_EXCEEDED = 'Your account has generated excess API activity and is being temporarily capped. Please contact support. ERROR_APIUSAGE_EXCEEDED';
|
30 |
+
const API_ERROR_EMAIL_NOT_VALID = 'Email is not a valid email address. ERROR_PARAMETER_INVALID';
|
31 |
+
const API_ERROR_FEATURENOTACTIVE = 'Error: ERROR_FEATURENOTACTIVE';
|
32 |
+
const API_ERROR_REPORT_NOT_FOUND = 'Import is not processed yet or completed with error. ERROR_IMPORT_REPORT_NOT_FOUND';
|
33 |
+
const API_ERROR_TRANS_NOT_EXISTS = 'Error: ERROR_TRANSACTIONAL_DATA_DOES_NOT_EXIST';
|
34 |
+
const API_ERROR_DATAFIELD_EXISTS = 'Field already exists. ERROR_NON_UNIQUE_DATAFIELD';
|
35 |
+
const API_ERROR_CONTACT_NOT_FOUND = 'Error: ERROR_CONTACT_NOT_FOUND';
|
36 |
+
const API_ERROR_PROGRAM_NOT_ACTIVE = 'Error: ERROR_PROGRAM_NOT_ACTIVE';
|
37 |
+
const API_ERROR_ENROLMENT_EXCEEDED = 'Error: ERROR_ENROLMENT_ALLOWANCE_EXCEEDED ';
|
38 |
+
const API_ERROR_SEND_NOT_PERMITTED = 'Send not permitted at this time. ERROR_CAMPAIGN_SENDNOTPERMITTED';
|
39 |
+
const API_ERROR_CONTACT_SUPPRESSED = 'Contact is suppressed. ERROR_CONTACT_SUPPRESSED';
|
40 |
+
const API_ERROR_AUTHORIZATION_DENIED = 'Authorization has been denied for this request.';
|
41 |
+
const API_ERROR_ADDRESSBOOK_NOT_FOUND = 'Error: ERROR_ADDRESSBOOK_NOT_FOUND';
|
Â
|
|
42 |
Â
|
43 |
Â
|
44 |
Â
protected $_limit = 10;
|
45 |
Â
public $fileHelper;
|
46 |
Â
protected $_filename;
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
47 |
Â
public $result = array('error' => false, 'message' => '');
|
48 |
Â
protected $_apiEndpoint;
|
49 |
Â
|
59 |
Â
|
60 |
Â
protected function _checkApiEndPoint()
|
61 |
Â
{
|
62 |
+
$apiEndpoint = Mage::helper('ddg')->getWebsiteConfig(
|
63 |
+
Dotdigitalgroup_Email_Helper_Config::PATH_FOR_API_ENDPOINT
|
64 |
+
);
|
65 |
+
if ( ! $apiEndpoint) {
|
66 |
Â
$helper = Mage::helper('ddg');
|
67 |
Â
$this->setApiUsername($helper->getApiUsername())
|
68 |
Â
->setApiPassword($helper->getApiPassword());
|
69 |
Â
|
70 |
Â
$accountInfo = $this->getAccountInfo();
|
71 |
Â
//check if returned value is an object
|
72 |
+
if (is_object($accountInfo) && ! isset($accountInfo->message)) {
|
73 |
Â
//save endpoint for account
|
74 |
+
foreach ($accountInfo->properties as $property) {
|
75 |
+
if ($property->name == 'ApiEndpoint'
|
76 |
+
&& strlen(
|
77 |
+
$property->value
|
78 |
+
)
|
79 |
+
) {
|
80 |
Â
$apiEndpoint = $property->value;
|
81 |
+
$config = Mage::getConfig();
|
82 |
Â
$config->saveConfig(
|
83 |
Â
Dotdigitalgroup_Email_Helper_Config::PATH_FOR_API_ENDPOINT,
|
84 |
Â
$property->value
|
90 |
Â
}
|
91 |
Â
|
92 |
Â
//check api endpoint again
|
93 |
+
if (!$apiEndpoint && isset($accountInfo->message)) {
|
94 |
+
$helper->log('API endpoint could not be saved. Error from api: ' . $accountInfo->message);
|
95 |
+
Mage::getSingleton('adminhtml/session')
|
96 |
+
->addWarning(
|
97 |
+
'API endpoint cannot be saved. Error from api: ' . $accountInfo->message .
|
98 |
+
' Check credentials and re-save to save api endpoint. '
|
99 |
+
);
|
100 |
+
}
|
101 |
Â
}
|
102 |
Â
|
103 |
Â
$this->_apiEndpoint = $apiEndpoint;
|
105 |
Â
|
106 |
Â
/**
|
107 |
Â
* Excluded api response that we don't want to send.
|
108 |
+
*
|
109 |
Â
* @var array
|
110 |
Â
*/
|
111 |
+
public $exludeMessages
|
112 |
+
= array(
|
113 |
+
self::API_ERROR_FEATURENOTACTIVE,
|
114 |
+
self::API_ERROR_PROGRAM_NOT_ACTIVE,
|
115 |
+
self::API_ERROR_CONTACT_SUPPRESSED,
|
116 |
+
self::API_ERROR_DATAFIELD_EXISTS,
|
117 |
+
self::API_ERROR_AUTHORIZATION_DENIED,
|
118 |
+
self::API_ERROR_ENROLMENT_EXCEEDED,
|
119 |
+
self::API_ERROR_SEND_NOT_PERMITTED,
|
120 |
+
self::API_ERROR_TRANS_NOT_EXISTS,
|
121 |
+
self::API_ERROR_ADDRESSBOOK_NOT_FOUND
|
122 |
+
);
|
123 |
Â
|
124 |
Â
/**
|
125 |
Â
* @param $apiUsername
|
126 |
Â
* @param $apiPassword
|
127 |
+
*
|
128 |
Â
* @return bool|mixed
|
129 |
Â
*/
|
130 |
Â
public function validate($apiUsername, $apiPassword)
|
135 |
Â
$accountInfo = $this->getAccountInfo();
|
136 |
Â
|
137 |
Â
if (isset($accountInfo->message)) {
|
138 |
+
Mage::getSingleton('adminhtml/session')->addError(
|
139 |
+
$accountInfo->message
|
140 |
+
);
|
141 |
Â
$message = 'VALIDATION ERROR : ' . $accountInfo->message;
|
142 |
Â
Mage::helper('ddg')->log($message);
|
143 |
+
|
144 |
Â
return false;
|
145 |
Â
}
|
146 |
+
|
147 |
Â
return $accountInfo;
|
148 |
Â
}
|
149 |
+
|
150 |
Â
return false;
|
151 |
Â
}
|
152 |
+
|
153 |
Â
/**
|
154 |
Â
* Gets a contact by ID. Unsubscribed or suppressed contacts will not be retrieved.
|
155 |
+
*
|
156 |
Â
* @param $id
|
157 |
+
*
|
158 |
Â
* @return null
|
159 |
Â
*/
|
160 |
Â
public function getContactById($id)
|
164 |
Â
->setVerb('GET');
|
165 |
Â
$response = $this->execute();
|
166 |
Â
|
167 |
+
if (isset($response->message)) {
|
168 |
+
$message = 'GET CONTACT INFO ID ' . $url . ', '
|
169 |
+
. $response->message;
|
170 |
+
Mage::helper('ddg')->log($message);
|
171 |
Â
}
|
172 |
Â
|
173 |
Â
return $response;
|
177 |
Â
* Bulk creates, or bulk updates, contacts. Import format can either be CSV or Excel.
|
178 |
Â
* Must include one column called "Email". Any other columns will attempt to map to your custom data fields.
|
179 |
Â
* The ID of returned object can be used to query import progress.
|
180 |
+
*
|
181 |
Â
* @param $filename
|
182 |
Â
* @param $addressBookId
|
183 |
+
*
|
184 |
Â
* @return mixed
|
185 |
Â
*/
|
186 |
Â
|
187 |
Â
public function postAddressBookContactsImport($filename, $addressBookId)
|
188 |
Â
{
|
189 |
+
$url = $this->_apiEndpoint
|
190 |
+
. "/v2/address-books/{$addressBookId}/contacts/import";
|
191 |
Â
$helper = Mage::helper('ddg');
|
192 |
Â
|
193 |
Â
$ch = curl_init($url);
|
194 |
Â
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
|
195 |
+
curl_setopt(
|
196 |
+
$ch, CURLOPT_USERPWD,
|
197 |
+
$this->getApiUsername() . ':' . $this->getApiPassword()
|
198 |
+
);
|
199 |
Â
|
200 |
Â
//case the deprication of @filename for uploading
|
201 |
Â
if (function_exists('curl_file_create')) {
|
202 |
Â
curl_setopt($ch, CURLOPT_SAFE_UPLOAD, false);
|
203 |
+
$args['file'] = curl_file_create(
|
204 |
+
Mage::helper('ddg/file')->getFilePath($filename), 'text/csv'
|
205 |
+
);
|
206 |
Â
curl_setopt($ch, CURLOPT_POSTFIELDS, $args);
|
207 |
Â
|
208 |
Â
} else {
|
209 |
Â
//standart use of curl file
|
210 |
+
curl_setopt(
|
211 |
+
$ch, CURLOPT_POSTFIELDS, array(
|
212 |
+
'file' => '@' . Mage::helper('ddg/file')->getFilePath(
|
213 |
+
$filename
|
214 |
+
)
|
215 |
+
)
|
216 |
+
);
|
217 |
Â
}
|
218 |
Â
|
219 |
Â
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
220 |
Â
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
|
221 |
+
curl_setopt(
|
222 |
+
$ch, CURLOPT_HTTPHEADER, array(
|
223 |
Â
'Content-Type: multipart/form-data')
|
224 |
Â
);
|
225 |
Â
|
227 |
Â
$result = curl_exec($ch);
|
228 |
Â
|
229 |
Â
//if curl error found
|
230 |
+
if (curl_errno($ch)) {
|
Â
|
|
231 |
Â
//save the error
|
232 |
Â
$this->curlError = curl_error($ch);
|
233 |
Â
}
|
234 |
Â
|
235 |
Â
$result = json_decode($result);
|
236 |
Â
if (isset($result->message)) {
|
237 |
+
$message = 'POST ADDRESS BOOK ' . $addressBookId
|
238 |
+
. ', CONTACT IMPORT : ' . ' filename ' . $filename
|
239 |
+
. ' Username ' . $this->getApiUsername() . $result->message;
|
240 |
Â
$helper->log($message);
|
241 |
Â
Mage::helper('ddg')->log($result)
|
242 |
Â
->rayLog($result->message);
|
243 |
Â
}
|
244 |
+
|
245 |
Â
return $result;
|
246 |
Â
}
|
247 |
Â
|
248 |
Â
/**
|
249 |
Â
* Adds a contact to a given address book.
|
250 |
+
*
|
251 |
Â
* @param $addressBookId
|
252 |
Â
* @param $apiContact
|
253 |
+
*
|
254 |
Â
* @return mixed|null
|
255 |
Â
*/
|
256 |
Â
public function postAddressBookContacts($addressBookId, $apiContact)
|
257 |
Â
{
|
258 |
+
$url = $this->_apiEndpoint . self::REST_ADDRESS_BOOKS . $addressBookId
|
259 |
+
. '/contacts';
|
260 |
Â
$this->setUrl($url)
|
261 |
Â
->setVerb("POST")
|
262 |
Â
->buildPostBody($apiContact);
|
263 |
Â
|
264 |
Â
$response = $this->execute();
|
265 |
Â
|
266 |
+
//log the error
|
267 |
+
if (isset($response->message)
|
268 |
+
&& ! in_array(
|
269 |
+
$response->message, $this->exludeMessages
|
270 |
+
)
|
271 |
+
) {
|
272 |
+
$message = 'POST ADDRESS BOOK CONTACTS ' . $url . ', '
|
273 |
+
. $response->message;
|
274 |
Â
Mage::helper('ddg')->log($message)
|
275 |
Â
->rayLog($response->message);
|
276 |
Â
}
|
280 |
Â
|
281 |
Â
/**
|
282 |
Â
* Deletes all contacts from a given address book.
|
283 |
+
*
|
284 |
Â
* @param $addressBookId
|
285 |
Â
* @param $contactId
|
286 |
+
*
|
287 |
Â
* @return null
|
288 |
Â
*/
|
289 |
Â
public function deleteAddressBookContact($addressBookId, $contactId)
|
290 |
Â
{
|
291 |
Â
|
292 |
+
$url = $this->_apiEndpoint . self::REST_ADDRESS_BOOKS . $addressBookId
|
293 |
+
. '/contacts/' . $contactId;
|
294 |
Â
$this->setUrl($url)
|
295 |
Â
->setVerb('DELETE');
|
296 |
Â
|
299 |
Â
|
300 |
Â
/**
|
301 |
Â
* Gets a report with statistics about what was successfully imported, and what was unable to be imported.
|
302 |
+
*
|
303 |
Â
* @param $importId
|
304 |
+
*
|
305 |
Â
* @return mixed
|
306 |
Â
*/
|
307 |
Â
public function getContactsImportReport($importId)
|
308 |
Â
{
|
309 |
+
$url = $this->_apiEndpoint . self::REST_CONTACTS_IMPORT . $importId
|
310 |
+
. "/report";
|
311 |
Â
$this->setUrl($url)
|
312 |
Â
->setVerb('GET');
|
313 |
Â
$response = $this->execute();
|
314 |
Â
//log error
|
315 |
+
if (isset($response->message)
|
316 |
+
&& ! in_array(
|
317 |
+
$response->message, $this->exludeMessages
|
318 |
+
)
|
319 |
+
) {
|
320 |
+
$message = 'GET CONTACTS IMPORT REPORT . ' . $url . ' message : '
|
321 |
+
. $response->message;
|
322 |
+
Mage::helper('ddg')->log($message)
|
323 |
+
->rayLog($response->message);
|
324 |
Â
}
|
325 |
+
|
326 |
Â
return $response;
|
327 |
Â
}
|
328 |
Â
|
329 |
Â
/**
|
330 |
Â
* Gets a contact by email address.
|
331 |
+
*
|
332 |
Â
* @param $email
|
333 |
+
*
|
334 |
Â
* @return mixed
|
335 |
Â
*/
|
336 |
Â
public function getContactByEmail($email)
|
341 |
Â
|
342 |
Â
$response = $this->execute();
|
343 |
Â
|
344 |
+
//log error
|
345 |
+
if (isset($response->message)
|
346 |
+
&& ! in_array(
|
347 |
+
$response->message, $this->exludeMessages
|
348 |
+
)
|
349 |
+
) {
|
350 |
+
$message = 'GET CONTACT BY email : ' . $email . ' '
|
351 |
+
. $response->message;
|
352 |
Â
Mage::helper('ddg')->log($message)
|
353 |
+
->rayLog($response->message);
|
354 |
Â
}
|
355 |
Â
|
356 |
Â
return $response;
|
358 |
Â
|
359 |
Â
/**
|
360 |
Â
* Get all address books.
|
361 |
+
*
|
362 |
Â
* @return null
|
363 |
Â
*/
|
364 |
Â
public function getAddressBooks()
|
368 |
Â
->setVerb("GET");
|
369 |
Â
|
370 |
Â
$response = $this->execute();
|
371 |
+
//log error
|
372 |
+
if (isset($response->message)
|
373 |
+
&& ! in_array(
|
374 |
+
$response->message, $this->exludeMessages
|
375 |
+
)
|
376 |
+
) {
|
377 |
+
$message = 'GET ALL ADDRESS BOOKS : ' . $url . ', '
|
378 |
+
. $response->message;
|
379 |
Â
Mage::helper('ddg')->log($message)
|
380 |
Â
->rayLog($response->message);
|
381 |
Â
}
|
385 |
Â
|
386 |
Â
/**
|
387 |
Â
* Gets an address book by ID.
|
388 |
+
*
|
389 |
Â
* @param $id
|
390 |
Â
*
|
391 |
Â
* @return null
|
401 |
Â
$response = $this->execute();
|
402 |
Â
|
403 |
Â
if (isset($response->message)) {
|
404 |
+
Mage::helper('ddg')->log(
|
405 |
+
'GET ADDRESS BOOK BY ID ' . $id . ', ' . $response->message
|
406 |
+
);
|
407 |
Â
}
|
408 |
Â
|
409 |
Â
return $response;
|
411 |
Â
|
412 |
Â
/**
|
413 |
Â
* Creates an address book.
|
414 |
+
*
|
415 |
Â
* @param $name
|
416 |
+
*
|
417 |
Â
* @return null
|
418 |
Â
*/
|
419 |
Â
public function postAddressBooks($name, $visibility = 'Public')
|
420 |
Â
{
|
421 |
Â
$data = array(
|
422 |
+
'Name' => $name,
|
423 |
Â
'Visibility' => $visibility
|
424 |
Â
);
|
425 |
+
$url = $this->_apiEndpoint . self::REST_ADDRESS_BOOKS;
|
426 |
Â
$this->setUrl($url)
|
427 |
Â
->setVerb('POST')
|
428 |
Â
->buildPostBody($data);
|
429 |
Â
|
430 |
Â
$response = $this->execute();
|
431 |
Â
//log error
|
432 |
+
if (isset($response->message)
|
433 |
+
&& ! in_array(
|
434 |
+
$response->message, $this->exludeMessages
|
435 |
+
)
|
436 |
+
) {
|
437 |
+
$message = 'Postaddressbooks ' . $response->message . ', url :'
|
438 |
+
. $url;
|
439 |
Â
Mage::helper('ddg')->log($message)
|
440 |
+
->rayLog($response->message);
|
441 |
Â
}
|
442 |
Â
|
443 |
Â
return $response;
|
445 |
Â
|
446 |
Â
/**
|
447 |
Â
* Get list of all campaigns.
|
448 |
+
*
|
449 |
Â
* @return mixed
|
450 |
Â
*/
|
451 |
Â
public function getCampaigns()
|
455 |
Â
->setVerb('GET');
|
456 |
Â
|
457 |
Â
$response = $this->execute();
|
458 |
+
//log error
|
459 |
+
if (isset($response->message)
|
460 |
+
&& ! in_array(
|
461 |
+
$response->message, $this->exludeMessages
|
462 |
+
)
|
463 |
+
) {
|
464 |
+
$message = 'GET CAMPAIGNS ' . $response->message . ' api user : '
|
465 |
+
. $this->getApiUsername();
|
466 |
Â
Mage::helper('ddg')->log($message)
|
467 |
+
->rayLog($response->message);
|
468 |
Â
}
|
469 |
Â
|
470 |
Â
return $response;
|
472 |
Â
|
473 |
Â
/**
|
474 |
Â
* Creates a data field within the account.
|
475 |
+
*
|
476 |
+
* @param $data string/array
|
477 |
+
* @param string $type string, numeric, date, boolean
|
478 |
Â
* @param string $visibility public, private
|
479 |
+
* @param bool $defaultValue
|
480 |
+
*
|
481 |
Â
* @return mixed
|
482 |
Â
*/
|
483 |
+
public function postDataFields($data, $type = 'String',
|
484 |
+
$visibility = 'public', $defaultValue = false
|
485 |
+
) {
|
486 |
Â
$url = $this->_apiEndpoint . self::REST_DATA_FILEDS;
|
487 |
Â
//set default value for the numeric datatype
|
488 |
+
if ($type == 'numeric' && ! $defaultValue) {
|
489 |
Â
$defaultValue = 0;
|
490 |
+
}
|
491 |
Â
//set data for the string datatype
|
492 |
Â
if (is_string($data)) {
|
493 |
Â
$data = array(
|
494 |
+
'Name' => $data,
|
495 |
+
'Type' => $type,
|
496 |
Â
'Visibility' => $visibility
|
497 |
Â
);
|
498 |
Â
//default value
|
499 |
+
if ($defaultValue) {
|
500 |
Â
$data['DefaultValue'] = $defaultValue;
|
501 |
+
}
|
502 |
Â
}
|
503 |
Â
$this->setUrl($url)
|
504 |
Â
->buildPostBody($data)
|
505 |
Â
->setVerb('POST');
|
506 |
Â
|
507 |
Â
$response = $this->execute();
|
508 |
+
//log error
|
509 |
+
if (isset($response->message)
|
510 |
+
&& ! in_array(
|
511 |
+
$response->message, $this->exludeMessages
|
512 |
+
)
|
513 |
+
) {
|
514 |
Â
$message = 'POST CREATE DATAFIELDS ' . $response->message;
|
515 |
Â
Mage::helper('ddg')->log($message)
|
516 |
Â
->log($data)
|
522 |
Â
|
523 |
Â
/**
|
524 |
Â
* Deletes a data field within the account.
|
525 |
+
*
|
526 |
Â
* @param $name
|
527 |
Â
*
|
528 |
Â
* @return mixed
|
535 |
Â
|
536 |
Â
$response = $this->execute();
|
537 |
Â
//log error
|
538 |
+
if (isset($response->message)
|
539 |
+
&& ! in_array(
|
540 |
+
$response->message, $this->exludeMessages
|
541 |
+
)
|
542 |
+
) {
|
543 |
+
$message = 'DELETE DATA FIELD :' . $name . ' ' . $response->message;
|
544 |
Â
Mage::helper('ddg')->log($message)
|
545 |
Â
->rayLog($response->message);
|
546 |
Â
}
|
550 |
Â
|
551 |
Â
/**
|
552 |
Â
* Lists the data fields within the account.
|
553 |
+
*
|
554 |
Â
* @return mixed
|
555 |
Â
*/
|
556 |
Â
public function getDataFields()
|
560 |
Â
->setVerb('GET');
|
561 |
Â
|
562 |
Â
$response = $this->execute();
|
563 |
+
//log error
|
564 |
+
if (isset($response->message)
|
565 |
+
&& ! in_array(
|
566 |
+
$response->message, $this->exludeMessages
|
567 |
+
)
|
568 |
+
) {
|
569 |
Â
$message = 'GET ALL DATAFIELDS ' . $response->message;
|
570 |
Â
Mage::helper('ddg')->log($message)
|
571 |
Â
->rayLog($response->message);
|
576 |
Â
|
577 |
Â
/**
|
578 |
Â
* Updates a contact.
|
579 |
+
*
|
580 |
Â
* @param $contactId
|
581 |
Â
* @param $data
|
582 |
+
*
|
583 |
Â
* @return object
|
584 |
Â
*/
|
585 |
Â
public function updateContact($contactId, $data)
|
590 |
Â
->buildPostBody($data);
|
591 |
Â
|
592 |
Â
$response = $this->execute();
|
593 |
+
//log error
|
594 |
+
if (isset($response->message)
|
595 |
+
&& ! in_array(
|
596 |
+
$response->message, $this->exludeMessages
|
597 |
+
)
|
598 |
+
) {
|
599 |
+
$message = 'ERROR : UPDATE SINGLE CONTACT : ' . $url . ' message : '
|
600 |
+
. $response->message;
|
601 |
Â
Mage::helper('ddg')->log($message)
|
602 |
Â
->log($data)
|
603 |
Â
->rayLog($response->message);
|
608 |
Â
|
609 |
Â
/**
|
610 |
Â
* Deletes a contact.
|
611 |
+
*
|
612 |
Â
* @param $contactId
|
613 |
+
*
|
614 |
Â
* @return null
|
615 |
Â
*/
|
616 |
Â
public function deleteContact($contactId)
|
620 |
Â
->setVerb('DELETE');
|
621 |
Â
|
622 |
Â
$response = $this->execute();
|
623 |
+
//log error
|
624 |
+
if (isset($response->message)
|
625 |
+
&& ! in_array(
|
626 |
+
$response->message, $this->exludeMessages
|
627 |
+
)
|
628 |
+
) {
|
629 |
Â
$message = 'DELETE CONTACT : ' . $url . ', ' . $response->message;
|
630 |
Â
Mage::helper('ddg')->log($message)
|
631 |
Â
->rayLog($response->message);
|
632 |
Â
}
|
633 |
+
|
634 |
Â
return $response;
|
635 |
Â
}
|
636 |
Â
|
637 |
Â
/**
|
638 |
Â
* Update contact datafields by email.
|
639 |
+
*
|
640 |
Â
* @param $email
|
641 |
Â
* @param $dataFields
|
642 |
Â
*
|
647 |
Â
{
|
648 |
Â
$apiContact = $this->postContacts($email);
|
649 |
Â
//do not create for non contact id set
|
650 |
+
if ( ! isset($apiContact->id)) {
|
651 |
Â
return $apiContact;
|
652 |
Â
} else {
|
653 |
Â
//get the contact id for this email
|
654 |
Â
$contactId = $apiContact->id;
|
655 |
Â
}
|
656 |
+
$data = array(
|
657 |
+
'Email' => $email,
|
658 |
Â
'EmailType' => 'Html');
|
659 |
Â
$data['DataFields'] = $dataFields;
|
660 |
+
$url = $this->_apiEndpoint . self::REST_CONTACTS
|
661 |
+
. $contactId;
|
662 |
Â
$this->setUrl($url)
|
663 |
Â
->setVerb('PUT')
|
664 |
Â
->buildPostBody($data);
|
665 |
Â
|
666 |
Â
$response = $this->execute();
|
667 |
+
//log error
|
668 |
+
if (isset($response->message)
|
669 |
+
&& ! in_array(
|
670 |
+
$response->message, $this->exludeMessages
|
671 |
+
)
|
672 |
+
) {
|
673 |
+
$message = 'ERROR: UPDATE CONTACT DATAFIELD ' . $url . ' message : '
|
674 |
+
. $response->message;
|
675 |
Â
Mage::helper('ddg')->log($message)
|
676 |
Â
->log($data)
|
677 |
Â
->rayLog($response->message);
|
683 |
Â
/**
|
684 |
Â
* Sends a specified campaign to one or more address books, segments or contacts at a specified time.
|
685 |
Â
* Leave the address book array empty to send to All Contacts.
|
686 |
+
*
|
687 |
Â
* @param $campaignId
|
688 |
Â
* @param $contacts
|
689 |
+
*
|
690 |
Â
* @return mixed
|
691 |
Â
*/
|
692 |
Â
public function postCampaignsSend($campaignId, $contacts)
|
693 |
Â
{
|
694 |
Â
$data = array(
|
695 |
+
'username' => $this->getApiUsername(),
|
696 |
+
'password' => $this->getApiPassword(),
|
697 |
Â
"campaignId" => $campaignId,
|
698 |
Â
"ContactIds" => $contacts
|
699 |
Â
);
|
702 |
Â
->buildPostBody($data);
|
703 |
Â
|
704 |
Â
$response = $this->execute();
|
705 |
+
//log error
|
706 |
+
if (isset($response->message)
|
707 |
+
&& ! in_array(
|
708 |
+
$response->message, $this->exludeMessages
|
709 |
+
)
|
710 |
+
) {
|
711 |
+
$message = 'SENDING CAMPAIGN ' . $response->message;
|
712 |
Â
Mage::helper('ddg')->log($message)
|
713 |
Â
->log($data)
|
714 |
Â
->rayLog($response->message);
|
719 |
Â
|
720 |
Â
/**
|
721 |
Â
* Creates a contact.
|
722 |
+
*
|
723 |
Â
* @param $email
|
724 |
+
*
|
725 |
Â
* @return mixed
|
726 |
Â
*/
|
727 |
Â
public function postContacts($email)
|
728 |
Â
{
|
729 |
+
//validate email before creating a contact
|
730 |
+
$valid = preg_match(
|
731 |
+
"/^([a-z0-9\+_\-]+)(\.[a-z0-9\+_\-]+)*@([a-z0-9\-]+\.)+[a-z]{2,6}$/ix",
|
732 |
+
$email
|
733 |
+
);
|
734 |
+
if ( ! $valid) {
|
735 |
+
$object = new stdClass();
|
736 |
+
|
737 |
+
return $object->message = 'Not valid email :' . $email;
|
738 |
+
}
|
739 |
+
|
740 |
+
$url = $this->_apiEndpoint . self::REST_CONTACTS;
|
741 |
Â
$data = array(
|
742 |
+
'Email' => $email,
|
743 |
Â
'EmailType' => 'Html',
|
744 |
Â
);
|
745 |
Â
$this->setUrl($url)
|
747 |
Â
->buildPostBody($data);
|
748 |
Â
|
749 |
Â
$response = $this->execute();
|
750 |
+
//log error
|
751 |
+
if (isset($response->message)
|
752 |
+
&& ! in_array(
|
753 |
+
$response->message, $this->exludeMessages
|
754 |
+
)
|
755 |
+
) {
|
756 |
+
$message = 'CREATE A NEW CONTACT : ' . $response->message;
|
757 |
Â
Mage::helper('ddg')->log($message)
|
758 |
Â
->rayLog($response->message);
|
759 |
Â
}
|
764 |
Â
|
765 |
Â
/**
|
766 |
Â
* Gets a list of suppressed contacts after a given date along with the reason for suppression.
|
767 |
+
*
|
768 |
Â
* @param $dateString
|
769 |
Â
* @param $select
|
770 |
Â
* @param $skip
|
771 |
+
*
|
772 |
Â
* @return object
|
773 |
Â
*/
|
774 |
+
public function getContactsSuppressedSinceDate($dateString, $select = 1000,
|
775 |
+
$skip = 0
|
776 |
+
) {
|
777 |
+
$url = $this->_apiEndpoint . self::REST_CONTACTS_SUPPRESSED_SINCE
|
778 |
+
. $dateString . '?select=' . $select . '&skip=' . $skip;
|
779 |
Â
$this->setUrl($url)
|
780 |
Â
->setVerb("GET");
|
781 |
Â
|
782 |
Â
$response = $this->execute();
|
783 |
+
//log error
|
784 |
+
if (isset($response->message)
|
785 |
+
&& ! in_array(
|
786 |
+
$response->message, $this->exludeMessages
|
787 |
+
)
|
788 |
+
) {
|
789 |
+
$message = 'GET CONTACTS SUPPRESSED SINSE : ' . $dateString
|
790 |
+
. ' select ' . $select . ' skip : ' . $skip . ' response : '
|
791 |
+
. $response->message;
|
792 |
Â
Mage::helper('ddg')->log($message)
|
793 |
Â
->rayLog($response->message);
|
794 |
Â
}
|
798 |
Â
|
799 |
Â
/**
|
800 |
Â
* Adds multiple pieces of transactional data to contacts asynchronously, returning an identifier that can be used to check for import progress.
|
801 |
+
*
|
802 |
Â
* @param $collectionName
|
803 |
Â
* @param $transactionalData
|
804 |
+
*
|
805 |
Â
* @return object
|
806 |
Â
*/
|
807 |
+
public function postContactsTransactionalDataImport($transactionalData,
|
808 |
+
$collectionName = 'Orders'
|
809 |
+
) {
|
810 |
Â
$orders = array();
|
811 |
Â
foreach ($transactionalData as $one) {
|
812 |
Â
if (isset($one->email)) {
|
813 |
Â
$orders[] = array(
|
814 |
+
'Key' => $one->id,
|
815 |
Â
'ContactIdentifier' => $one->email,
|
816 |
+
'Json' => json_encode($one)
|
817 |
Â
);
|
818 |
Â
}
|
819 |
Â
}
|
820 |
+
$url = $this->_apiEndpoint . self::REST_TRANSACTIONAL_DATA_IMPORT
|
821 |
+
. $collectionName;
|
822 |
Â
$this->setURl($url)
|
823 |
Â
->setVerb('POST')
|
824 |
Â
->buildPostBody($orders);
|
825 |
Â
|
826 |
Â
$response = $this->execute();
|
827 |
+
// log error
|
828 |
+
if (isset($response->message)
|
829 |
+
&& ! in_array(
|
830 |
+
$response->message, $this->exludeMessages
|
831 |
+
)
|
832 |
+
) {
|
833 |
Â
$message = ' SEND MULTI TRANSACTIONAL DATA ' . $response->message;
|
834 |
Â
Mage::helper('ddg')->log($message)
|
835 |
Â
->rayLog($response->message);
|
841 |
Â
/**
|
842 |
Â
* Adds a single piece of transactional data to a contact.
|
843 |
Â
*
|
844 |
+
* @param $data
|
845 |
Â
* @param string $collectionName
|
846 |
Â
*
|
847 |
Â
* @return null
|
848 |
Â
* @throws Exception
|
849 |
Â
*/
|
850 |
+
public function postContactsTransactionalData($data,
|
851 |
+
$collectionName = 'Orders'
|
852 |
+
) {
|
853 |
+
$order = $this->getContactsTransactionalDataByKey(
|
854 |
+
$collectionName, $data->id
|
855 |
+
);
|
856 |
+
if (isset($order->message)
|
857 |
+
&& $order->message == self::API_ERROR_TRANS_NOT_EXISTS
|
858 |
+
) {
|
859 |
+
$url = $this->_apiEndpoint . self::REST_TRANSACTIONAL_DATA
|
860 |
+
. $collectionName;
|
861 |
+
} else {
|
862 |
+
$url = $this->_apiEndpoint . self::REST_TRANSACTIONAL_DATA
|
863 |
+
. $collectionName . '/' . $order->key;
|
864 |
Â
}
|
865 |
Â
$apiData = array(
|
866 |
+
'Key' => $data->id,
|
867 |
Â
'ContactIdentifier' => $data->email,
|
868 |
+
'Json' => json_encode($data->expose())
|
869 |
Â
);
|
870 |
Â
|
871 |
Â
$this->setUrl($url)
|
872 |
Â
->setVerb('POST')
|
873 |
Â
->buildPostBody($apiData);
|
874 |
Â
$response = $this->execute();
|
875 |
+
//log error
|
876 |
+
if (isset($response->message)
|
877 |
+
&& ! in_array(
|
878 |
+
$response->message, $this->exludeMessages
|
879 |
+
)
|
880 |
+
) {
|
881 |
+
$message = 'POST CONTACTS TRANSACTIONAL DATA '
|
882 |
+
. $response->message;
|
883 |
Â
Mage::helper('ddg')->log($message)
|
884 |
Â
->log($apiData)
|
885 |
Â
->rayLog($response->message);
|
890 |
Â
|
891 |
Â
/**
|
892 |
Â
* Gets a piece of transactional data by key.
|
893 |
+
*
|
894 |
Â
* @param $name
|
895 |
Â
* @param $key
|
896 |
+
*
|
897 |
Â
* @return null
|
898 |
Â
*/
|
899 |
Â
public function getContactsTransactionalDataByKey($name, $key)
|
900 |
Â
{
|
901 |
+
$url = $this->_apiEndpoint . self::REST_TRANSACTIONAL_DATA . $name . '/'
|
902 |
+
. $key;
|
903 |
Â
$this->setUrl($url)
|
904 |
Â
->setVerb('GET');
|
905 |
Â
|
908 |
Â
|
909 |
Â
/**
|
910 |
Â
* Deletes all transactional data for a contact.
|
911 |
+
*
|
912 |
+
* @param $email
|
913 |
Â
* @param string $collectionName
|
914 |
+
*
|
915 |
Â
* @return object
|
916 |
Â
*/
|
917 |
+
public function deleteContactTransactionalData($email,
|
918 |
+
$collectionName = 'Orders'
|
919 |
+
) {
|
920 |
+
$url = $this->_apiEndpoint . '/v2/contacts/' . $email
|
921 |
+
. '/transactional-data/' . $collectionName;
|
922 |
Â
$this->setUrl($url)
|
923 |
Â
->setVerb('DELETE');
|
924 |
Â
|
927 |
Â
|
928 |
Â
/**
|
929 |
Â
* Gets a summary of information about the current status of the account.
|
930 |
+
*
|
931 |
Â
* @return mixed
|
932 |
Â
*/
|
933 |
Â
public function getAccountInfo()
|
937 |
Â
->setVerb('GET');
|
938 |
Â
|
939 |
Â
$response = $this->execute();
|
940 |
+
//log error
|
941 |
+
if (isset($response->message)
|
942 |
+
&& ! in_array(
|
943 |
+
$response->message, $this->exludeMessages
|
944 |
+
)
|
945 |
+
) {
|
946 |
+
$message = 'GET ACCOUNT INFO for api user : '
|
947 |
+
. $this->getApiUsername() . ' ' . $response->message;
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
948 |
Â
Mage::helper('ddg')->log($message)
|
949 |
Â
->rayLog($response->message);
|
950 |
Â
}
|
952 |
Â
return $response;
|
953 |
Â
}
|
954 |
Â
|
Â
|
|
955 |
Â
/**
|
956 |
Â
* Deletes multiple contacts from an address book.
|
957 |
+
*
|
958 |
Â
* @param $addressBookId
|
959 |
Â
* @param $contactIds
|
960 |
+
*
|
961 |
Â
* @return object
|
962 |
Â
*/
|
963 |
Â
public function deleteAddressBookContactsInbulk($addressBookId, $contactIds)
|
964 |
Â
{
|
965 |
+
$url = $this->_apiEndpoint . '/v2/address-books/' . $addressBookId
|
966 |
+
. '/contacts/inbulk';
|
967 |
Â
$data = array('ContactIds' => array($contactIds[0]));
|
968 |
Â
$this->setUrl($url)
|
969 |
Â
->setVerb('DELETE')
|
970 |
Â
->buildPostBody($data);
|
971 |
Â
|
972 |
Â
$response = $this->execute();
|
973 |
+
//log error
|
974 |
+
if (isset($response->message)
|
975 |
+
&& ! in_array(
|
976 |
+
$response->message, $this->exludeMessages
|
977 |
+
)
|
978 |
+
) {
|
979 |
+
$message = 'DELETE BULK ADDRESS BOOK CONTACTS ' . $response->message
|
980 |
+
. ' address book ' . $addressBookId;
|
981 |
Â
Mage::helper('ddg')->log($message)
|
982 |
Â
->rayLog($response->message);
|
983 |
Â
}
|
985 |
Â
return $response;
|
986 |
Â
}
|
987 |
Â
|
988 |
+
/**
|
989 |
+
* Resubscribes a previously unsubscribed contact.
|
990 |
+
*
|
991 |
+
* @param $apiContact
|
992 |
+
*
|
993 |
+
* @return null
|
994 |
+
* @throws Exception
|
995 |
+
*/
|
996 |
Â
public function postContactsResubscribe($apiContact)
|
997 |
Â
{
|
998 |
+
$url = $this->_apiEndpoint . self::REST_CONTACTS_RESUBSCRIBE;
|
999 |
Â
$data = array(
|
1000 |
Â
'UnsubscribedContact' => $apiContact
|
1001 |
Â
);
|
1005 |
Â
|
1006 |
Â
$response = $this->execute();
|
1007 |
Â
//log error
|
1008 |
+
if (isset($response->message)
|
1009 |
+
&& ! in_array(
|
1010 |
+
$response->message, $this->exludeMessages
|
1011 |
+
)
|
1012 |
+
) {
|
1013 |
+
$message = 'Resubscribe : ' . $url . ', message :'
|
1014 |
+
. $response->message;
|
1015 |
Â
Mage::helper('ddg')->log($message)
|
1016 |
Â
->log($data)
|
1017 |
Â
->rayLog($response->message);
|
1018 |
Â
}
|
1019 |
+
|
1020 |
+
return $response;
|
1021 |
Â
}
|
1022 |
Â
|
1023 |
Â
/**
|
1034 |
Â
->setVerb('GET');
|
1035 |
Â
|
1036 |
Â
$response = $this->execute();
|
1037 |
+
//log error
|
1038 |
+
if (isset($response->message)
|
1039 |
+
&& ! in_array(
|
1040 |
+
$response->message, $this->exludeMessages
|
1041 |
+
)
|
1042 |
+
) {
|
1043 |
+
$message = 'GET CampaignFromAddressList ' . $response->message
|
1044 |
+
. ' api user : ' . $this->getApiUsername();
|
1045 |
Â
Mage::helper('ddg')->log($message)
|
1046 |
Â
->rayLog($response->message);
|
1047 |
Â
}
|
1049 |
Â
return $response;
|
1050 |
Â
}
|
1051 |
Â
|
1052 |
+
/**
|
1053 |
+
* Creates a campaign.
|
1054 |
+
*
|
1055 |
+
* @param $data
|
1056 |
+
*
|
1057 |
+
* @return null
|
1058 |
+
* @throws Exception
|
1059 |
+
*/
|
1060 |
Â
public function postCampaign($data)
|
1061 |
Â
{
|
1062 |
Â
$url = $this->_apiEndpoint . self::REST_CREATE_CAMPAIGN;
|
1065 |
Â
->buildPostBody($data);
|
1066 |
Â
|
1067 |
Â
$response = $this->execute();
|
1068 |
+
//log error
|
1069 |
+
if (isset($response->message)
|
1070 |
+
&& ! in_array(
|
1071 |
+
$response->message, $this->exludeMessages
|
1072 |
+
)
|
1073 |
+
) {
|
1074 |
Â
$message = ' CREATE CAMPAIGN ' . $response->message;
|
1075 |
Â
Mage::helper('ddg')->log($message)
|
1076 |
Â
->rayLog($response->message);
|
1091 |
Â
->setVerb('GET');
|
1092 |
Â
|
1093 |
Â
$response = $this->execute();
|
1094 |
+
//log error
|
1095 |
+
if (isset($response->message)
|
1096 |
+
&& ! in_array(
|
1097 |
+
$response->message, $this->exludeMessages
|
1098 |
+
)
|
1099 |
+
) {
|
1100 |
+
$message = 'Get programmes : ' . $response->message;
|
1101 |
+
Mage::helper('ddg')->log($message)
|
1102 |
Â
->rayLog($response->message);
|
1103 |
Â
}
|
1104 |
Â
|
1107 |
Â
|
1108 |
Â
/**
|
1109 |
Â
* Creates an enrolment.
|
1110 |
+
*
|
1111 |
Â
* @param $data
|
1112 |
Â
*
|
1113 |
Â
* @return null
|
1121 |
Â
->buildPostBody($data);
|
1122 |
Â
|
1123 |
Â
$response = $this->execute();
|
1124 |
+
//log error
|
1125 |
+
if (isset($response->message)
|
1126 |
+
&& ! in_array(
|
1127 |
+
$response->message, $this->exludeMessages
|
1128 |
+
)
|
1129 |
+
) {
|
1130 |
Â
$message = 'Post programs enrolments : ' . $response->message;
|
1131 |
Â
Mage::helper('ddg')->log($message)
|
1132 |
Â
->log($data)
|
1138 |
Â
|
1139 |
Â
/**
|
1140 |
Â
* Gets a program by id.
|
1141 |
+
*
|
1142 |
Â
* @param $id
|
1143 |
Â
*
|
1144 |
Â
* @return null
|
1145 |
Â
* @throws Exception
|
1146 |
Â
*/
|
1147 |
+
public function getProgramById($id)
|
1148 |
Â
{
|
1149 |
+
$url = $this->_apiEndpoint . self::REST_PROGRAM . $id;
|
1150 |
Â
$this->setUrl($url)
|
1151 |
Â
->setVerb('GET');
|
1152 |
Â
|
1153 |
Â
$response = $this->execute();
|
1154 |
+
//log error
|
1155 |
+
if (isset($response->message)
|
1156 |
+
&& ! in_array(
|
1157 |
+
$response->message, $this->exludeMessages
|
1158 |
+
)
|
1159 |
+
) {
|
1160 |
Â
$message = 'Get program by id ' . $id . ', ' . $response->message;
|
1161 |
Â
Mage::helper('ddg')->log($message)
|
1162 |
Â
->rayLog($response->message);
|
1167 |
Â
|
1168 |
Â
/**
|
1169 |
Â
* Gets a summary of reporting information for a specified campaign.
|
1170 |
+
*
|
1171 |
Â
* @param $campaignId
|
1172 |
Â
*
|
1173 |
Â
* @return null
|
1175 |
Â
*/
|
1176 |
Â
public function getCampaignSummary($campaignId)
|
1177 |
Â
{
|
1178 |
+
$url = $this->_apiEndpoint . '/v2/campaigns/' . $campaignId
|
1179 |
+
. '/summary';
|
1180 |
Â
|
1181 |
Â
$this->setUrl($url)
|
1182 |
Â
->setVerb('GET');
|
1183 |
Â
$response = $this->execute();
|
1184 |
+
//log error
|
1185 |
+
if (isset($response->message)
|
1186 |
+
&& ! in_array(
|
1187 |
+
$response->message, $this->exludeMessages
|
1188 |
+
)
|
1189 |
+
) {
|
1190 |
+
$message = 'Get Campaign Summary ' . $response->message
|
1191 |
+
. ' ,url : ' . $url;
|
1192 |
+
Mage::helper('ddg')->log($message)
|
1193 |
Â
->rayLog($response->message);
|
1194 |
Â
}
|
1195 |
Â
|
1198 |
Â
|
1199 |
Â
/**
|
1200 |
Â
* Deletes a piece of transactional data by key.
|
1201 |
+
*
|
1202 |
+
* @param $key
|
1203 |
Â
* @param string $collectionName
|
1204 |
+
*
|
1205 |
Â
* @return object
|
1206 |
Â
*/
|
1207 |
+
public function deleteContactsTransactionalData($key,
|
1208 |
+
$collectionName = 'Orders'
|
1209 |
+
) {
|
1210 |
+
$url = $this->_apiEndpoint . '/v2/contacts/transactional-data/'
|
1211 |
+
. $collectionName . '/' . $key;
|
1212 |
Â
$this->setUrl($url)
|
1213 |
Â
->setVerb('DELETE');
|
1214 |
Â
$response = $this->execute();
|
1215 |
Â
|
1216 |
+
if (isset($response->message)) {
|
1217 |
+
Mage::helper('ddg')->log(
|
1218 |
+
'DELETE CONTACTS TRANSACTIONAL DATA : ' . $url . ' '
|
1219 |
+
. $response->message
|
1220 |
+
);
|
1221 |
+
}
|
1222 |
Â
|
1223 |
Â
return $response;
|
1224 |
Â
}
|
1225 |
Â
|
1226 |
Â
/**
|
1227 |
Â
* Adds a document to a campaign as an attachment.
|
1228 |
+
*
|
1229 |
Â
* @param $campaignId
|
1230 |
Â
* @param $data
|
1231 |
Â
*
|
1234 |
Â
*/
|
1235 |
Â
public function postCampaignAttachments($campaignId, $data)
|
1236 |
Â
{
|
1237 |
+
$url = $this->_apiEndpoint . self::REST_CREATE_CAMPAIGN
|
1238 |
+
. "/$campaignId/attachments";
|
1239 |
Â
$this->setURl($url)
|
1240 |
Â
->setVerb('POST')
|
1241 |
Â
->buildPostBody($data);
|
1242 |
Â
$result = $this->execute();
|
1243 |
Â
|
1244 |
Â
if (isset($result->message)) {
|
1245 |
+
Mage::helper('ddg')->log(
|
1246 |
+
' CAMPAIGN ATTACHMENT ' . $result->message
|
1247 |
+
);
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
1248 |
Â
}
|
1249 |
Â
|
1250 |
Â
return $result;
|
1254 |
Â
* get contact address books
|
1255 |
Â
*
|
1256 |
Â
* @param $contactId
|
1257 |
+
*
|
1258 |
Â
* @return object
|
1259 |
Â
* @throws Exception
|
1260 |
Â
*/
|
1261 |
Â
public function getContactAddressBooks($contactId)
|
1262 |
Â
{
|
1263 |
+
$url = $this->_apiEndpoint . '/v2/contacts/' . $contactId
|
1264 |
+
. '/address-books';
|
1265 |
Â
$this->setUrl($url)
|
1266 |
Â
->setVerb('GET');
|
1267 |
Â
$response = $this->execute();
|
1268 |
+
//log error
|
1269 |
+
if (isset($response->message)
|
1270 |
+
&& ! in_array(
|
1271 |
+
$response->message, $this->exludeMessages
|
1272 |
+
)
|
1273 |
+
) {
|
1274 |
+
$message = 'GET CONTACTS ADDRESS BOOKS contact: ' . $contactId
|
1275 |
+
. $response->message;
|
1276 |
Â
Mage::helper('ddg')->log($message)
|
1277 |
Â
->rayLog($response->message);
|
1278 |
Â
}
|
1288 |
Â
*/
|
1289 |
Â
public function getApiTemplateList()
|
1290 |
Â
{
|
1291 |
+
$url = $this->_apiEndpoint . self::REST_TEMPLATES;
|
1292 |
Â
$this->setUrl($url)
|
1293 |
Â
->setVerb('GET');
|
1294 |
Â
|
1295 |
+
$response = $this->execute();
|
1296 |
Â
|
1297 |
+
//log error
|
1298 |
+
if (isset($response->message)
|
1299 |
+
&& ! in_array(
|
1300 |
+
$response->message, $this->exludeMessages
|
1301 |
+
)
|
1302 |
+
) {
|
1303 |
+
$message = 'GET API CONTACT LIST ' . $response->message;
|
1304 |
Â
Mage::helper('ddg')->log($message)
|
1305 |
+
->rayLog($response->message);
|
1306 |
Â
}
|
1307 |
Â
|
1308 |
Â
return $response;
|
1312 |
Â
* Gets a template by ID.
|
1313 |
Â
*
|
1314 |
Â
* @param $templateId
|
1315 |
+
*
|
1316 |
Â
* @return object
|
1317 |
Â
* @throws Exception
|
1318 |
Â
*/
|
1319 |
Â
public function getApiTemplate($templateId)
|
1320 |
Â
{
|
1321 |
+
$url = $this->_apiEndpoint . self::REST_TEMPLATES . '/' . $templateId;
|
1322 |
Â
$this->setUrl($url)
|
1323 |
Â
->setVerb('GET');
|
1324 |
Â
|
1325 |
Â
$response = $this->execute();
|
1326 |
+
//log error
|
1327 |
+
if (isset($response->message)
|
1328 |
+
&& ! in_array(
|
1329 |
+
$response->message, $this->exludeMessages
|
1330 |
+
)
|
1331 |
+
) {
|
1332 |
+
$message = 'GET API CONTACT LIST ' . $response->message;
|
1333 |
Â
Mage::helper('ddg')->log($message)
|
1334 |
Â
->rayLog($response->message);
|
1335 |
Â
}
|
1339 |
Â
|
1340 |
Â
/**
|
1341 |
Â
* Adds multiple pieces of transactional data to account asynchronously, returning an identifier that can be used to check for import progress.
|
1342 |
+
*
|
1343 |
Â
* @param $collectionName
|
1344 |
Â
* @param $transactionalData
|
1345 |
+
*
|
1346 |
Â
* @return object
|
1347 |
Â
*/
|
1348 |
+
public function postAccountTransactionalDataImport($transactionalData,
|
1349 |
+
$collectionName = 'Catalog_Default'
|
1350 |
+
) {
|
1351 |
Â
$orders = array();
|
1352 |
Â
foreach ($transactionalData as $one) {
|
1353 |
Â
if (isset($one->id)) {
|
1354 |
Â
$orders[] = array(
|
1355 |
+
'Key' => $one->id,
|
1356 |
Â
'ContactIdentifier' => 'account',
|
1357 |
+
'Json' => json_encode($one->expose())
|
1358 |
Â
);
|
1359 |
Â
}
|
1360 |
Â
}
|
1361 |
+
$url = $this->_apiEndpoint . self::REST_TRANSACTIONAL_DATA_IMPORT
|
1362 |
+
. $collectionName;
|
1363 |
Â
$this->setURl($url)
|
1364 |
Â
->setVerb('POST')
|
1365 |
Â
->buildPostBody($orders);
|
1366 |
Â
|
1367 |
Â
$response = $this->execute();
|
1368 |
+
//log error
|
1369 |
+
if (isset($response->message)
|
1370 |
+
&& ! in_array(
|
1371 |
+
$response->message, $this->exludeMessages
|
1372 |
+
)
|
1373 |
+
) {
|
1374 |
+
$message = ' SEND MULTI TRANSACTIONAL DATA TO ACCOUNT'
|
1375 |
+
. $response->message;
|
1376 |
Â
Mage::helper('ddg')->log($message)
|
1377 |
Â
->rayLog($response->message);
|
1378 |
Â
}
|
1382 |
Â
|
1383 |
Â
public function getCampaignsWithActivitySinceDate($dateTime)
|
1384 |
Â
{
|
1385 |
+
$url = $this->_apiEndpoint . self::REST_DATA_FIELDS_CAMPAIGNS
|
1386 |
+
. '/with-activity-since/' . $dateTime;
|
1387 |
Â
|
1388 |
Â
$this->setUrl($url)
|
1389 |
Â
->setVerb('GET');
|
1390 |
Â
|
1391 |
Â
$response = $this->execute();
|
1392 |
+
//log error
|
1393 |
+
if (isset($response->message)
|
1394 |
+
&& ! in_array(
|
1395 |
+
$response->message, $this->exludeMessages
|
1396 |
+
)
|
1397 |
+
) {
|
1398 |
+
$message = 'GET CAMPAIGNS WITH ACTIVITY SINCE DATE '
|
1399 |
+
. $response->message;
|
1400 |
Â
Mage::helper('ddg')->log($message)
|
1401 |
Â
->rayLog($response->message);
|
1402 |
Â
}
|
1406 |
Â
|
1407 |
Â
public function getCampaignActivityByContactId($campaignId, $contactId)
|
1408 |
Â
{
|
1409 |
+
$url = $this->_apiEndpoint . self::REST_DATA_FIELDS_CAMPAIGNS . '/'
|
1410 |
+
. $campaignId . '/activities/' . $contactId;
|
1411 |
Â
|
1412 |
Â
$this->setUrl($url)
|
1413 |
Â
->setVerb('GET');
|
1414 |
Â
|
1415 |
Â
$response = $this->execute();
|
1416 |
+
//log error
|
1417 |
+
if (isset($response->message)
|
1418 |
+
&& ! in_array(
|
1419 |
+
$response->message, $this->exludeMessages
|
1420 |
+
)
|
1421 |
+
) {
|
1422 |
+
$message = 'GET CAMPAIGN ACTIVITY BY CONTACT ID '
|
1423 |
+
. $response->message;
|
1424 |
Â
Mage::helper('ddg')->log($message)
|
1425 |
Â
->rayLog($response->message);
|
1426 |
Â
}
|
1432 |
Â
* Gets the import status of a previously started contact import.
|
1433 |
Â
*
|
1434 |
Â
* @param $importId
|
1435 |
+
*
|
1436 |
Â
* @return object
|
1437 |
Â
*/
|
1438 |
Â
public function getContactsImportByImportId($importId)
|
1442 |
Â
$this->setUrl($url)
|
1443 |
Â
->setVerb('GET');
|
1444 |
Â
|
1445 |
+
$response = $this->execute();
|
1446 |
Â
//log error
|
1447 |
+
if (isset($response->message)
|
1448 |
+
&& ! in_array(
|
1449 |
+
$response->message, $this->exludeMessages
|
1450 |
+
)
|
1451 |
+
) {
|
1452 |
Â
$message = 'GET CONTACTS IMPORT BY IMPORT ID ' . $response->message;
|
1453 |
Â
Mage::helper('ddg')->log($message)
|
1454 |
Â
->rayLog($response->message);
|
1461 |
Â
* Gets the import status of a previously started transactional import.
|
1462 |
Â
*
|
1463 |
Â
* @param $importId
|
1464 |
+
*
|
1465 |
Â
* @return object
|
1466 |
Â
*/
|
1467 |
Â
public function getContactsTransactionalDataImportByImportId($importId)
|
1468 |
Â
{
|
1469 |
+
$url = $this->_apiEndpoint . self::REST_TRANSACTIONAL_DATA_IMPORT
|
1470 |
+
. $importId;
|
1471 |
Â
|
1472 |
Â
$this->setUrl($url)
|
1473 |
Â
->setVerb('GET');
|
1474 |
Â
|
1475 |
+
$response = $this->execute();
|
1476 |
+
//log error
|
1477 |
+
if (isset($response->message)
|
1478 |
+
&& ! in_array(
|
1479 |
+
$response->message, $this->exludeMessages
|
1480 |
+
)
|
1481 |
+
) {
|
1482 |
+
$message = 'GET CONTACTS TRANSACTIONAL DATA IMPORT BY IMPORT ID '
|
1483 |
+
. $response->message;
|
1484 |
Â
Mage::helper('ddg')->log($message)
|
1485 |
Â
->rayLog($response->message);
|
1486 |
Â
}
|
1492 |
Â
* get contact import report faults
|
1493 |
Â
*
|
1494 |
Â
* @param $id
|
1495 |
+
*
|
1496 |
Â
* @return bool|null
|
1497 |
Â
* @throws Exception
|
1498 |
Â
*/
|
1499 |
Â
public function getContactImportReportFaults($id)
|
1500 |
Â
{
|
1501 |
+
$url = $this->_apiEndpoint . self::REST_CONTACTS_IMPORT . $id
|
1502 |
+
. '/report-faults';
|
1503 |
Â
$this->setUrl($url)
|
1504 |
Â
->setVerb('GET');
|
1505 |
Â
|
1507 |
Â
$response = $this->execute();
|
1508 |
Â
|
1509 |
Â
//if string is JSON than there is a error message
|
1510 |
+
if (json_decode($response)) {
|
1511 |
Â
//log error
|
1512 |
+
if (isset($response->message)
|
1513 |
+
&& ! in_array(
|
1514 |
+
$response->message, $this->exludeMessages
|
1515 |
+
)
|
1516 |
+
) {
|
1517 |
+
$message = 'GET CONTACT IMPORT REPORT FAULTS: '
|
1518 |
+
. $response->message;
|
1519 |
Â
Mage::helper('ddg')->log($message)
|
1520 |
Â
->rayLog($response->message);
|
1521 |
Â
}
|
1522 |
+
|
1523 |
Â
return false;
|
1524 |
Â
}
|
1525 |
Â
|
@@ -2,105 +2,136 @@
|
|
2 |
Â
|
3 |
Â
class Dotdigitalgroup_Email_Model_Apiconnector_Contact
|
4 |
Â
{
|
Â
|
|
5 |
Â
protected $_start;
|
6 |
Â
protected $_countCustomers = 0;
|
7 |
Â
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
Â
{
|
15 |
Â
$result = array('success' => true, 'message' => '');
|
16 |
Â
/** @var Dotdigitalgroup_Email_Helper_Data $helper */
|
17 |
-
$helper
|
18 |
Â
$this->_start = microtime(true);
|
19 |
Â
//resourse allocation
|
20 |
Â
$helper->allowResourceFullExecution();
|
21 |
Â
foreach (Mage::app()->getWebsites(true) as $website) {
|
22 |
-
$enabled = Mage::helper('ddg')->getWebsiteConfig(
|
23 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
24 |
Â
if ($enabled && $sync) {
|
25 |
Â
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
Â
|
|
Â
|
|
Â
|
|
32 |
Â
}
|
33 |
Â
}
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
Â
|
|
Â
|
|
Â
|
|
41 |
Â
|
42 |
Â
return $result;
|
43 |
Â
}
|
44 |
Â
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
Â
|
|
52 |
Â
public function exportCustomersForWebsite(Mage_Core_Model_Website $website)
|
53 |
Â
{
|
54 |
Â
$customers = $headers = $allMappedHash = array();
|
55 |
-
$helper
|
56 |
-
$pageSize
|
Â
|
|
Â
|
|
Â
|
|
57 |
Â
|
58 |
Â
//skip if the mapping field is missing
|
59 |
-
if (
|
60 |
Â
return 0;
|
Â
|
|
61 |
Â
|
62 |
-
$fileHelper
|
63 |
Â
$contactModel = Mage::getModel('ddg_automation/contact');
|
64 |
-
$contacts
|
Â
|
|
Â
|
|
65 |
Â
|
66 |
Â
// no contacts for this website
|
67 |
-
if (
|
68 |
Â
return 0;
|
Â
|
|
69 |
Â
|
70 |
Â
//create customer filename
|
71 |
-
$customersFile = strtolower(
|
Â
|
|
Â
|
|
72 |
Â
$helper->log('Customers file : ' . $customersFile);
|
73 |
Â
|
74 |
Â
//get customer ids
|
75 |
Â
$customerIds = $contacts->getColumnValues('customer_id');
|
76 |
Â
|
77 |
Â
//customer collection
|
78 |
-
$customerCollection = $this->getCollection(
|
Â
|
|
Â
|
|
79 |
Â
|
80 |
Â
/**
|
81 |
Â
* HEADERS.
|
82 |
Â
*/
|
83 |
-
$mappedHash = $fileHelper->getWebsiteCustomerMappingDatafields(
|
84 |
-
|
Â
|
|
Â
|
|
85 |
Â
|
86 |
Â
//custom customer attributes
|
87 |
Â
$customAttributes = $helper->getCustomAttributes($website);
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
Â
}
|
94 |
Â
$headers[] = 'Email';
|
95 |
Â
$headers[] = 'EmailType';
|
96 |
-
$fileHelper->outputCSV(
|
Â
|
|
Â
|
|
97 |
Â
/**
|
98 |
Â
* END HEADERS.
|
99 |
Â
*/
|
100 |
Â
|
101 |
Â
//customer data
|
102 |
Â
foreach ($customerCollection as $customer) {
|
103 |
-
$connectorCustomer = Mage::getModel(
|
Â
|
|
Â
|
|
104 |
Â
$connectorCustomer->setCustomerData($customer);
|
105 |
Â
//count number of customers
|
106 |
Â
$customers[] = $customer->getId();
|
@@ -108,7 +139,7 @@ class Dotdigitalgroup_Email_Model_Apiconnector_Contact
|
|
108 |
Â
if ($connectorCustomer) {
|
109 |
Â
foreach ($customAttributes as $data) {
|
110 |
Â
$attribute = $data['attribute'];
|
111 |
-
$value
|
112 |
Â
$connectorCustomer->setData($value);
|
113 |
Â
}
|
114 |
Â
}
|
@@ -117,116 +148,151 @@ class Dotdigitalgroup_Email_Model_Apiconnector_Contact
|
|
117 |
Â
$connectorCustomer->setData($customer->getEmail());
|
118 |
Â
$connectorCustomer->setData('Html');
|
119 |
Â
// save csv file data for customers
|
120 |
-
$fileHelper->outputCSV(
|
Â
|
|
Â
|
|
Â
|
|
121 |
Â
//clear collection and free memory
|
122 |
Â
$customer->clearInstance();
|
123 |
Â
}
|
124 |
Â
|
125 |
-
|
126 |
-
$helper->log(
|
127 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
128 |
Â
|
129 |
Â
if (is_file($fileHelper->getFilePath($customersFile))) {
|
130 |
Â
if ($customerNum > 0) {
|
131 |
Â
//register in queue with importer
|
132 |
-
$check = Mage::getModel('ddg_automation/importer')
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
Â
|
|
139 |
Â
|
140 |
Â
//set imported
|
141 |
Â
if ($check) {
|
142 |
-
Mage::getResourceModel('ddg_automation/contact')->update(
|
Â
|
|
Â
|
|
143 |
Â
}
|
144 |
Â
}
|
145 |
Â
}
|
146 |
Â
$this->_countCustomers += $customerNum;
|
Â
|
|
147 |
Â
return $customerNum;
|
148 |
Â
}
|
149 |
Â
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
Â
{
|
160 |
-
if ($contactId)
|
161 |
-
$contact = Mage::getModel('ddg_automation/contact')->load(
|
162 |
-
|
Â
|
|
Â
|
|
163 |
Â
$contact = Mage::registry('current_contact');
|
164 |
Â
}
|
165 |
-
if (! $contact->getId()) {
|
166 |
-
Mage::getSingleton('adminhtml/session')->addError(
|
Â
|
|
Â
|
|
Â
|
|
167 |
Â
return false;
|
168 |
Â
}
|
169 |
Â
|
170 |
Â
$websiteId = $contact->getWebsiteId();
|
171 |
-
$website
|
172 |
-
$updated
|
173 |
Â
$customers = $headers = $allMappedHash = array();
|
174 |
-
$helper
|
175 |
Â
$helper->log('---------- Start single customer sync ----------');
|
176 |
Â
//skip if the mapping field is missing
|
177 |
-
if(
|
178 |
Â
return false;
|
Â
|
|
179 |
Â
$fileHelper = Mage::helper('ddg/file');
|
180 |
Â
|
181 |
Â
$customerId = $contact->getCustomerId();
|
182 |
-
if (
|
183 |
-
Mage::getSingleton('adminhtml/session')->addError(
|
Â
|
|
Â
|
|
Â
|
|
184 |
Â
return false;
|
185 |
Â
}
|
186 |
Â
|
187 |
Â
//create customer filename
|
188 |
-
$customersFile = strtolower(
|
Â
|
|
Â
|
|
189 |
Â
$helper->log('Customers file : ' . $customersFile);
|
190 |
Â
|
191 |
Â
/**
|
192 |
Â
* HEADERS.
|
193 |
Â
*/
|
194 |
-
$mappedHash = $fileHelper->getWebsiteCustomerMappingDatafields(
|
195 |
-
|
Â
|
|
Â
|
|
196 |
Â
//custom customer attributes
|
197 |
Â
$customAttributes = $helper->getCustomAttributes($website);
|
198 |
Â
foreach ($customAttributes as $data) {
|
199 |
-
$headers[]
|
200 |
Â
$allMappedHash[$data['attribute']] = $data['datafield'];
|
201 |
Â
}
|
202 |
Â
|
203 |
Â
$headers[] = 'Email';
|
204 |
Â
$headers[] = 'EmailType';
|
205 |
-
$fileHelper->outputCSV(
|
Â
|
|
Â
|
|
206 |
Â
/**
|
207 |
Â
* END HEADERS.
|
208 |
Â
*/
|
209 |
Â
|
210 |
-
$customerCollection = $this->getCollection(
|
Â
|
|
Â
|
|
211 |
Â
|
212 |
Â
foreach ($customerCollection as $customer) {
|
213 |
Â
/**
|
214 |
Â
* DATA.
|
215 |
Â
*/
|
216 |
-
$connectorCustomer =
|
Â
|
|
Â
|
|
217 |
Â
$connectorCustomer->setCustomerData($customer);
|
218 |
Â
//count number of customers
|
219 |
Â
$customers[] = $connectorCustomer;
|
220 |
Â
foreach ($customAttributes as $data) {
|
221 |
Â
$attribute = $data['attribute'];
|
222 |
-
$value
|
223 |
Â
$connectorCustomer->setData($value);
|
224 |
Â
}
|
225 |
Â
//contact email and email type
|
226 |
Â
$connectorCustomer->setData($customer->getEmail());
|
227 |
Â
$connectorCustomer->setData('Html');
|
228 |
Â
// save csv file data for customers
|
229 |
-
$fileHelper->outputCSV(
|
Â
|
|
Â
|
|
Â
|
|
230 |
Â
|
231 |
Â
/**
|
232 |
Â
* END DATA.
|
@@ -239,72 +305,137 @@ class Dotdigitalgroup_Email_Model_Apiconnector_Contact
|
|
239 |
Â
//import contacts
|
240 |
Â
if ($updated > 0) {
|
241 |
Â
//register in queue with importer
|
242 |
-
$check = Mage::getModel('ddg_automation/importer')
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
Â
|
|
249 |
Â
|
250 |
Â
//set imported
|
251 |
Â
if ($check) {
|
252 |
-
Mage::getResourceModel('ddg_automation/contact')->update(
|
Â
|
|
Â
|
|
253 |
Â
}
|
254 |
Â
}
|
255 |
Â
}
|
Â
|
|
256 |
Â
return $contact->getEmail();
|
257 |
Â
}
|
258 |
Â
|
259 |
Â
|
260 |
Â
/**
|
261 |
Â
* get customer collection
|
Â
|
|
262 |
Â
* @param $customerIds
|
263 |
Â
* @param $websiteId
|
Â
|
|
264 |
Â
* @return Mage_Eav_Model_Entity_Collection_Abstract
|
265 |
Â
* @throws Mage_Core_Exception
|
266 |
Â
*/
|
267 |
Â
public function getCollection($customerIds, $websiteId = 0)
|
268 |
Â
{
|
269 |
-
$customerCollection
|
Â
|
|
Â
|
|
270 |
Â
->addNameToSelect()
|
271 |
Â
->addAttributeToSelect('*')
|
272 |
-
->joinAttribute(
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
->joinAttribute(
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
->joinAttribute(
|
281 |
-
|
282 |
-
|
283 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
284 |
Â
->addAttributeToFilter('entity_id', array('in' => $customerIds));
|
285 |
-
$
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
$
|
290 |
-
|
291 |
-
$
|
292 |
-
|
293 |
-
$
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
294 |
Â
|
295 |
Â
|
296 |
Â
// get the last login date from the log_customer table
|
297 |
Â
$customerCollection->getSelect()->columns(
|
298 |
-
array('last_logged_date' => new Zend_Db_Expr
|
Â
|
|
Â
|
|
Â
|
|
299 |
Â
|
300 |
Â
// customer order information
|
301 |
-
$alias
|
302 |
-
$statuses
|
303 |
-
Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_SYNC_DATA_FIELDS_STATUS,
|
Â
|
|
304 |
Â
);
|
305 |
-
$statuses
|
306 |
-
$subselect = Mage::getModel(
|
307 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
308 |
Â
'customer_id as s_customer_id',
|
309 |
Â
'sum(grand_total) as total_spend',
|
310 |
Â
'count(*) as number_of_orders',
|
@@ -312,29 +443,36 @@ class Dotdigitalgroup_Email_Model_Apiconnector_Contact
|
|
312 |
Â
)
|
313 |
Â
)
|
314 |
Â
->where("status in (?)", $statuses)
|
315 |
-
->group('customer_id')
|
316 |
-
;
|
317 |
Â
|
318 |
Â
$columns = array(
|
319 |
-
'last_order_date'
|
320 |
-
|
321 |
-
|
322 |
-
'
|
323 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
324 |
Â
"(
|
325 |
-
SELECT ccpi.category_id FROM $
|
326 |
-
left join $
|
327 |
-
left join $
|
328 |
Â
WHERE sfo.customer_id = e.entity_id
|
329 |
Â
ORDER BY sfo.created_at ASC, sfoi.price DESC
|
330 |
Â
LIMIT 1
|
331 |
Â
)"
|
332 |
Â
),
|
333 |
-
'last_category_id'
|
334 |
Â
"(
|
335 |
-
SELECT ccpi.category_id FROM $
|
336 |
-
left join $
|
337 |
-
left join $
|
338 |
Â
WHERE sfo.customer_id = e.entity_id
|
339 |
Â
ORDER BY sfo.created_at DESC, sfoi.price DESC
|
340 |
Â
LIMIT 1
|
@@ -342,26 +480,26 @@ class Dotdigitalgroup_Email_Model_Apiconnector_Contact
|
|
342 |
Â
),
|
343 |
Â
'product_id_for_first_brand' => new Zend_Db_Expr(
|
344 |
Â
"(
|
345 |
-
SELECT sfoi.product_id FROM $
|
346 |
-
left join $
|
347 |
Â
WHERE sfo.customer_id = e.entity_id and sfoi.product_type = 'simple'
|
348 |
Â
ORDER BY sfo.created_at ASC, sfoi.price DESC
|
349 |
Â
LIMIT 1
|
350 |
Â
)"
|
351 |
Â
),
|
352 |
-
'product_id_for_last_brand'
|
353 |
Â
"(
|
354 |
-
SELECT sfoi.product_id FROM $
|
355 |
-
left join $
|
356 |
Â
WHERE sfo.customer_id = e.entity_id and sfoi.product_type = 'simple'
|
357 |
Â
ORDER BY sfo.created_at DESC, sfoi.price DESC
|
358 |
Â
LIMIT 1
|
359 |
Â
)"
|
360 |
Â
),
|
361 |
-
'week_day'
|
362 |
Â
"(
|
363 |
Â
SELECT dayname(created_at) as week_day
|
364 |
-
FROM $
|
365 |
Â
WHERE customer_id = e.entity_id
|
366 |
Â
GROUP BY week_day
|
367 |
Â
HAVING COUNT(*) > 0
|
@@ -369,10 +507,10 @@ class Dotdigitalgroup_Email_Model_Apiconnector_Contact
|
|
369 |
Â
LIMIT 1
|
370 |
Â
)"
|
371 |
Â
),
|
372 |
-
'month_day'
|
373 |
Â
"(
|
374 |
Â
SELECT monthname(created_at) as month_day
|
375 |
-
FROM $
|
376 |
Â
WHERE customer_id = e.entity_id
|
377 |
Â
GROUP BY month_day
|
378 |
Â
HAVING COUNT(*) > 0
|
@@ -380,11 +518,11 @@ class Dotdigitalgroup_Email_Model_Apiconnector_Contact
|
|
380 |
Â
LIMIT 1
|
381 |
Â
)"
|
382 |
Â
),
|
383 |
-
'most_category_id'
|
384 |
Â
"(
|
385 |
-
SELECT ccpi.category_id FROM $
|
386 |
-
LEFT JOIN $
|
387 |
-
LEFT JOIN $
|
388 |
Â
WHERE sfo.customer_id = e.entity_id AND ccpi.category_id is not null
|
389 |
Â
GROUP BY category_id
|
390 |
Â
HAVING COUNT(sfoi.product_id) > 0
|
@@ -397,17 +535,18 @@ class Dotdigitalgroup_Email_Model_Apiconnector_Contact
|
|
397 |
Â
);
|
398 |
Â
|
399 |
Â
$brand = Mage::helper('ddg')->getWebsiteConfig(
|
400 |
-
Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_SYNC_DATA_FIELDS_BRAND_ATTRIBUTE,
|
Â
|
|
401 |
Â
);
|
402 |
Â
|
403 |
-
if($brand){
|
404 |
Â
$columns['most_brand'] = new Zend_Db_Expr(
|
405 |
Â
"(
|
406 |
-
SELECT eaov.value from $
|
407 |
-
LEFT JOIN $
|
408 |
-
LEFT JOIN $
|
409 |
-
LEFT JOIN $
|
410 |
-
LEFT JOIN $
|
411 |
Â
WHERE sfo.customer_id = e.entity_id AND ea.attribute_code = '$brand' AND eaov.value is not null
|
412 |
Â
GROUP BY eaov.value
|
413 |
Â
HAVING count(*) > 0
|
@@ -420,7 +559,10 @@ class Dotdigitalgroup_Email_Model_Apiconnector_Contact
|
|
420 |
Â
$customerCollection->getSelect()->columns($columns);
|
421 |
Â
|
422 |
Â
$customerCollection->getSelect()
|
423 |
-
->joinLeft(
|
Â
|
|
Â
|
|
Â
|
|
424 |
Â
|
425 |
Â
return $customerCollection;
|
426 |
Â
}
|
2 |
Â
|
3 |
Â
class Dotdigitalgroup_Email_Model_Apiconnector_Contact
|
4 |
Â
{
|
5 |
+
|
6 |
Â
protected $_start;
|
7 |
Â
protected $_countCustomers = 0;
|
8 |
Â
|
9 |
+
/**
|
10 |
+
* Contact sync.
|
11 |
+
*
|
12 |
+
* @return array
|
13 |
+
*/
|
14 |
+
public function sync()
|
15 |
Â
{
|
16 |
Â
$result = array('success' => true, 'message' => '');
|
17 |
Â
/** @var Dotdigitalgroup_Email_Helper_Data $helper */
|
18 |
+
$helper = Mage::helper('ddg');
|
19 |
Â
$this->_start = microtime(true);
|
20 |
Â
//resourse allocation
|
21 |
Â
$helper->allowResourceFullExecution();
|
22 |
Â
foreach (Mage::app()->getWebsites(true) as $website) {
|
23 |
+
$enabled = Mage::helper('ddg')->getWebsiteConfig(
|
24 |
+
Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_API_ENABLED,
|
25 |
+
$website
|
26 |
+
);
|
27 |
+
$sync = Mage::helper('ddg')->getWebsiteConfig(
|
28 |
+
Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_SYNC_CONTACT_ENABLED,
|
29 |
+
$website
|
30 |
+
);
|
31 |
Â
if ($enabled && $sync) {
|
32 |
Â
|
33 |
+
if ( ! $this->_countCustomers) {
|
34 |
+
$helper->log('---------- Start customer sync ----------');
|
35 |
+
}
|
36 |
+
$numUpdated = $this->exportCustomersForWebsite($website);
|
37 |
+
// show message for any number of customers
|
38 |
+
if ($numUpdated) {
|
39 |
+
$result['message'] .= '</br>' . $website->getName()
|
40 |
+
. ', updated customers = ' . $numUpdated;
|
41 |
+
}
|
42 |
Â
}
|
43 |
Â
}
|
44 |
+
//sync proccessed
|
45 |
+
if ($this->_countCustomers) {
|
46 |
+
$message = 'Total time for sync : ' . gmdate(
|
47 |
+
"H:i:s", microtime(true) - $this->_start
|
48 |
+
) .
|
49 |
+
', Total updated = ' . $this->_countCustomers;
|
50 |
+
$helper->log($message);
|
51 |
+
$message .= $result['message'];
|
52 |
+
$result['message'] = $message;
|
53 |
+
}
|
54 |
Â
|
55 |
Â
return $result;
|
56 |
Â
}
|
57 |
Â
|
58 |
+
/**
|
59 |
+
* Execute the contact sync for the website
|
60 |
+
* number of customer synced.
|
61 |
+
*
|
62 |
+
* @param Mage_Core_Model_Website $website
|
63 |
+
*
|
64 |
+
* @return int|void
|
65 |
+
*/
|
66 |
Â
public function exportCustomersForWebsite(Mage_Core_Model_Website $website)
|
67 |
Â
{
|
68 |
Â
$customers = $headers = $allMappedHash = array();
|
69 |
+
$helper = Mage::helper('ddg');
|
70 |
+
$pageSize = $helper->getWebsiteConfig(
|
71 |
+
Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_SYNC_LIMIT,
|
72 |
+
$website
|
73 |
+
);
|
74 |
Â
|
75 |
Â
//skip if the mapping field is missing
|
76 |
+
if ( ! $helper->getCustomerAddressBook($website)) {
|
77 |
Â
return 0;
|
78 |
+
}
|
79 |
Â
|
80 |
+
$fileHelper = Mage::helper('ddg/file');
|
81 |
Â
$contactModel = Mage::getModel('ddg_automation/contact');
|
82 |
+
$contacts = $contactModel->getContactsToImportForWebsite(
|
83 |
+
$website->getId(), $pageSize
|
84 |
+
);
|
85 |
Â
|
86 |
Â
// no contacts for this website
|
87 |
+
if ( ! $contacts->getSize()) {
|
88 |
Â
return 0;
|
89 |
+
}
|
90 |
Â
|
91 |
Â
//create customer filename
|
92 |
+
$customersFile = strtolower(
|
93 |
+
$website->getCode() . '_customers_' . date('d_m_Y_Hi') . '.csv'
|
94 |
+
);
|
95 |
Â
$helper->log('Customers file : ' . $customersFile);
|
96 |
Â
|
97 |
Â
//get customer ids
|
98 |
Â
$customerIds = $contacts->getColumnValues('customer_id');
|
99 |
Â
|
100 |
Â
//customer collection
|
101 |
+
$customerCollection = $this->getCollection(
|
102 |
+
$customerIds, $website->getId()
|
103 |
+
);
|
104 |
Â
|
105 |
Â
/**
|
106 |
Â
* HEADERS.
|
107 |
Â
*/
|
108 |
+
$mappedHash = $fileHelper->getWebsiteCustomerMappingDatafields(
|
109 |
+
$website
|
110 |
+
);
|
111 |
+
$headers = $mappedHash;
|
112 |
Â
|
113 |
Â
//custom customer attributes
|
114 |
Â
$customAttributes = $helper->getCustomAttributes($website);
|
115 |
+
if ($customAttributes) {
|
116 |
+
foreach ($customAttributes as $data) {
|
117 |
+
$headers[] = $data['datafield'];
|
118 |
+
$allMappedHash[$data['attribute']] = $data['datafield'];
|
119 |
+
}
|
120 |
Â
}
|
121 |
Â
$headers[] = 'Email';
|
122 |
Â
$headers[] = 'EmailType';
|
123 |
+
$fileHelper->outputCSV(
|
124 |
+
$fileHelper->getFilePath($customersFile), $headers
|
125 |
+
);
|
126 |
Â
/**
|
127 |
Â
* END HEADERS.
|
128 |
Â
*/
|
129 |
Â
|
130 |
Â
//customer data
|
131 |
Â
foreach ($customerCollection as $customer) {
|
132 |
+
$connectorCustomer = Mage::getModel(
|
133 |
+
'ddg_automation/apiconnector_customer', $mappedHash
|
134 |
+
);
|
135 |
Â
$connectorCustomer->setCustomerData($customer);
|
136 |
Â
//count number of customers
|
137 |
Â
$customers[] = $customer->getId();
|
139 |
Â
if ($connectorCustomer) {
|
140 |
Â
foreach ($customAttributes as $data) {
|
141 |
Â
$attribute = $data['attribute'];
|
142 |
+
$value = $customer->getData($attribute);
|
143 |
Â
$connectorCustomer->setData($value);
|
144 |
Â
}
|
145 |
Â
}
|
148 |
Â
$connectorCustomer->setData($customer->getEmail());
|
149 |
Â
$connectorCustomer->setData('Html');
|
150 |
Â
// save csv file data for customers
|
151 |
+
$fileHelper->outputCSV(
|
152 |
+
$fileHelper->getFilePath($customersFile),
|
153 |
+
$connectorCustomer->toCSVArray()
|
154 |
+
);
|
155 |
Â
//clear collection and free memory
|
156 |
Â
$customer->clearInstance();
|
157 |
Â
}
|
158 |
Â
|
159 |
+
$customerNum = count($customers);
|
160 |
+
$helper->log(
|
161 |
+
'Website : ' . $website->getName() . ', customers = ' . $customerNum
|
162 |
+
);
|
163 |
+
$helper->log(
|
164 |
+
'---------------------------- execution time :' . gmdate(
|
165 |
+
"H:i:s", microtime(true) - $this->_start
|
166 |
+
)
|
167 |
+
);
|
168 |
Â
|
169 |
Â
if (is_file($fileHelper->getFilePath($customersFile))) {
|
170 |
Â
if ($customerNum > 0) {
|
171 |
Â
//register in queue with importer
|
172 |
+
$check = Mage::getModel('ddg_automation/importer')
|
173 |
+
->registerQueue(
|
174 |
+
Dotdigitalgroup_Email_Model_Importer::IMPORT_TYPE_CONTACT,
|
175 |
+
'',
|
176 |
+
Dotdigitalgroup_Email_Model_Importer::MODE_BULK,
|
177 |
+
$website->getId(),
|
178 |
+
$customersFile
|
179 |
+
);
|
180 |
Â
|
181 |
Â
//set imported
|
182 |
Â
if ($check) {
|
183 |
+
Mage::getResourceModel('ddg_automation/contact')->update(
|
184 |
+
$customers
|
185 |
+
);
|
186 |
Â
}
|
187 |
Â
}
|
188 |
Â
}
|
189 |
Â
$this->_countCustomers += $customerNum;
|
190 |
+
|
191 |
Â
return $customerNum;
|
192 |
Â
}
|
193 |
Â
|
194 |
+
/**
|
195 |
+
* Sync a single contact.
|
196 |
+
*
|
197 |
+
* @param null $contactId
|
198 |
+
*
|
199 |
+
* @return mixed
|
200 |
+
* @throws Mage_Core_Exception
|
201 |
+
*/
|
202 |
+
public function syncContact($contactId = null)
|
203 |
Â
{
|
204 |
+
if ($contactId) {
|
205 |
+
$contact = Mage::getModel('ddg_automation/contact')->load(
|
206 |
+
$contactId
|
207 |
+
);
|
208 |
+
} else {
|
209 |
Â
$contact = Mage::registry('current_contact');
|
210 |
Â
}
|
211 |
+
if ( ! $contact->getId()) {
|
212 |
+
Mage::getSingleton('adminhtml/session')->addError(
|
213 |
+
'No contact found!'
|
214 |
+
);
|
215 |
+
|
216 |
Â
return false;
|
217 |
Â
}
|
218 |
Â
|
219 |
Â
$websiteId = $contact->getWebsiteId();
|
220 |
+
$website = Mage::app()->getWebsite($websiteId);
|
221 |
+
$updated = 0;
|
222 |
Â
$customers = $headers = $allMappedHash = array();
|
223 |
+
$helper = Mage::helper('ddg');
|
224 |
Â
$helper->log('---------- Start single customer sync ----------');
|
225 |
Â
//skip if the mapping field is missing
|
226 |
+
if ( ! $helper->getCustomerAddressBook($website)) {
|
227 |
Â
return false;
|
228 |
+
}
|
229 |
Â
$fileHelper = Mage::helper('ddg/file');
|
230 |
Â
|
231 |
Â
$customerId = $contact->getCustomerId();
|
232 |
+
if ( ! $customerId) {
|
233 |
+
Mage::getSingleton('adminhtml/session')->addError(
|
234 |
+
'Cannot manually sync guests!'
|
235 |
+
);
|
236 |
+
|
237 |
Â
return false;
|
238 |
Â
}
|
239 |
Â
|
240 |
Â
//create customer filename
|
241 |
+
$customersFile = strtolower(
|
242 |
+
$website->getCode() . '_customers_' . date('d_m_Y_Hi') . '.csv'
|
243 |
+
);
|
244 |
Â
$helper->log('Customers file : ' . $customersFile);
|
245 |
Â
|
246 |
Â
/**
|
247 |
Â
* HEADERS.
|
248 |
Â
*/
|
249 |
+
$mappedHash = $fileHelper->getWebsiteCustomerMappingDatafields(
|
250 |
+
$website
|
251 |
+
);
|
252 |
+
$headers = $mappedHash;
|
253 |
Â
//custom customer attributes
|
254 |
Â
$customAttributes = $helper->getCustomAttributes($website);
|
255 |
Â
foreach ($customAttributes as $data) {
|
256 |
+
$headers[] = $data['datafield'];
|
257 |
Â
$allMappedHash[$data['attribute']] = $data['datafield'];
|
258 |
Â
}
|
259 |
Â
|
260 |
Â
$headers[] = 'Email';
|
261 |
Â
$headers[] = 'EmailType';
|
262 |
+
$fileHelper->outputCSV(
|
263 |
+
$fileHelper->getFilePath($customersFile), $headers
|
264 |
+
);
|
265 |
Â
/**
|
266 |
Â
* END HEADERS.
|
267 |
Â
*/
|
268 |
Â
|
269 |
+
$customerCollection = $this->getCollection(
|
270 |
+
array($customerId), $website->getId()
|
271 |
+
);
|
272 |
Â
|
273 |
Â
foreach ($customerCollection as $customer) {
|
274 |
Â
/**
|
275 |
Â
* DATA.
|
276 |
Â
*/
|
277 |
+
$connectorCustomer = Mage::getModel(
|
278 |
+
'ddg_automation/apiconnector_customer', $mappedHash
|
279 |
+
);
|
280 |
Â
$connectorCustomer->setCustomerData($customer);
|
281 |
Â
//count number of customers
|
282 |
Â
$customers[] = $connectorCustomer;
|
283 |
Â
foreach ($customAttributes as $data) {
|
284 |
Â
$attribute = $data['attribute'];
|
285 |
+
$value = $customer->getData($attribute);
|
286 |
Â
$connectorCustomer->setData($value);
|
287 |
Â
}
|
288 |
Â
//contact email and email type
|
289 |
Â
$connectorCustomer->setData($customer->getEmail());
|
290 |
Â
$connectorCustomer->setData('Html');
|
291 |
Â
// save csv file data for customers
|
292 |
+
$fileHelper->outputCSV(
|
293 |
+
$fileHelper->getFilePath($customersFile),
|
294 |
+
$connectorCustomer->toCSVArray()
|
295 |
+
);
|
296 |
Â
|
297 |
Â
/**
|
298 |
Â
* END DATA.
|
305 |
Â
//import contacts
|
306 |
Â
if ($updated > 0) {
|
307 |
Â
//register in queue with importer
|
308 |
+
$check = Mage::getModel('ddg_automation/importer')
|
309 |
+
->registerQueue(
|
310 |
+
Dotdigitalgroup_Email_Model_Importer::IMPORT_TYPE_CONTACT,
|
311 |
+
'',
|
312 |
+
Dotdigitalgroup_Email_Model_Importer::MODE_BULK,
|
313 |
+
$website->getId(),
|
314 |
+
$customersFile
|
315 |
+
);
|
316 |
Â
|
317 |
Â
//set imported
|
318 |
Â
if ($check) {
|
319 |
+
Mage::getResourceModel('ddg_automation/contact')->update(
|
320 |
+
$customerId
|
321 |
+
);
|
322 |
Â
}
|
323 |
Â
}
|
324 |
Â
}
|
325 |
+
|
326 |
Â
return $contact->getEmail();
|
327 |
Â
}
|
328 |
Â
|
329 |
Â
|
330 |
Â
/**
|
331 |
Â
* get customer collection
|
332 |
+
*
|
333 |
Â
* @param $customerIds
|
334 |
Â
* @param $websiteId
|
335 |
+
*
|
336 |
Â
* @return Mage_Eav_Model_Entity_Collection_Abstract
|
337 |
Â
* @throws Mage_Core_Exception
|
338 |
Â
*/
|
339 |
Â
public function getCollection($customerIds, $websiteId = 0)
|
340 |
Â
{
|
341 |
+
$customerCollection = Mage::getResourceModel(
|
342 |
+
'customer/customer_collection'
|
343 |
+
)
|
344 |
Â
->addNameToSelect()
|
345 |
Â
->addAttributeToSelect('*')
|
346 |
+
->joinAttribute(
|
347 |
+
'billing_street', 'customer_address/street', 'default_billing',
|
348 |
+
null, 'left'
|
349 |
+
)
|
350 |
+
->joinAttribute(
|
351 |
+
'billing_city', 'customer_address/city', 'default_billing',
|
352 |
+
null, 'left'
|
353 |
+
)
|
354 |
+
->joinAttribute(
|
355 |
+
'billing_country_code', 'customer_address/country_id',
|
356 |
+
'default_billing', null, 'left'
|
357 |
+
)
|
358 |
+
->joinAttribute(
|
359 |
+
'billing_postcode', 'customer_address/postcode',
|
360 |
+
'default_billing', null, 'left'
|
361 |
+
)
|
362 |
+
->joinAttribute(
|
363 |
+
'billing_telephone', 'customer_address/telephone',
|
364 |
+
'default_billing', null, 'left'
|
365 |
+
)
|
366 |
+
->joinAttribute(
|
367 |
+
'billing_region', 'customer_address/region', 'default_billing',
|
368 |
+
null, 'left'
|
369 |
+
)
|
370 |
+
->joinAttribute('billing_company', 'customer_address/company', 'default_billing', null, 'left')
|
371 |
+
->joinAttribute(
|
372 |
+
'shipping_street', 'customer_address/street',
|
373 |
+
'default_shipping', null, 'left'
|
374 |
+
)
|
375 |
+
->joinAttribute(
|
376 |
+
'shipping_city', 'customer_address/city', 'default_shipping',
|
377 |
+
null, 'left'
|
378 |
+
)
|
379 |
+
->joinAttribute(
|
380 |
+
'shipping_country_code', 'customer_address/country_id',
|
381 |
+
'default_shipping', null, 'left'
|
382 |
+
)
|
383 |
+
->joinAttribute(
|
384 |
+
'shipping_postcode', 'customer_address/postcode',
|
385 |
+
'default_shipping', null, 'left'
|
386 |
+
)
|
387 |
+
->joinAttribute(
|
388 |
+
'shipping_telephone', 'customer_address/telephone',
|
389 |
+
'default_shipping', null, 'left'
|
390 |
+
)
|
391 |
+
->joinAttribute(
|
392 |
+
'shipping_region', 'customer_address/region',
|
393 |
+
'default_shipping', null, 'left'
|
394 |
+
)
|
395 |
+
->joinAttribute('shipping_company', 'customer_address/company', 'default_shipping', null, 'left')
|
396 |
Â
->addAttributeToFilter('entity_id', array('in' => $customerIds));
|
397 |
+
$customerLog = Mage::getSingleton('core/resource')
|
398 |
+
->getTableName(
|
399 |
+
'log_customer'
|
400 |
+
);
|
401 |
+
$salesFlatOrderGrid = Mage::getSingleton('core/resource')
|
402 |
+
->getTableName('sales_flat_order_grid');
|
403 |
+
$salesFlatQuote = Mage::getSingleton('core/resource')
|
404 |
+
->getTableName('sales_flat_quote');
|
405 |
+
$salesFlatOrder = Mage::getSingleton('core/resource')
|
406 |
+
->getTableName('sales_flat_order');
|
407 |
+
$salesFlatOrderItem = Mage::getSingleton('core/resource')
|
408 |
+
->getTableName('sales_flat_order_item');
|
409 |
+
$catalogCategoryProductIndex = Mage::getSingleton('core/resource')
|
410 |
+
->getTableName('catalog_category_product');
|
411 |
+
$eavAttributeOptionValue = Mage::getSingleton('core/resource')
|
412 |
+
->getTableName('eav_attribute_option_value');
|
413 |
+
$catalogProductEntityInt = Mage::getSingleton('core/resource')
|
414 |
+
->getTableName('catalog_product_entity_int');
|
415 |
+
$eavAttribute = Mage::getSingleton('core/resource')
|
416 |
+
->getTableName('eav_attribute');
|
417 |
Â
|
418 |
Â
|
419 |
Â
// get the last login date from the log_customer table
|
420 |
Â
$customerCollection->getSelect()->columns(
|
421 |
+
array('last_logged_date' => new Zend_Db_Expr(
|
422 |
+
"(SELECT login_at FROM $customerLog WHERE customer_id =e.entity_id ORDER BY log_id DESC LIMIT 1)"
|
423 |
+
))
|
424 |
+
);
|
425 |
Â
|
426 |
Â
// customer order information
|
427 |
+
$alias = 'subselect';
|
428 |
+
$statuses = Mage::helper('ddg')->getWebsiteConfig(
|
429 |
+
Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_SYNC_DATA_FIELDS_STATUS,
|
430 |
+
$websiteId
|
431 |
Â
);
|
432 |
+
$statuses = explode(',', $statuses);
|
433 |
+
$subselect = Mage::getModel(
|
434 |
+
'Varien_Db_Select',
|
435 |
+
Mage::getSingleton('core/resource')->getConnection('core_read')
|
436 |
+
)
|
437 |
+
->from(
|
438 |
+
$salesFlatOrderGrid, array(
|
439 |
Â
'customer_id as s_customer_id',
|
440 |
Â
'sum(grand_total) as total_spend',
|
441 |
Â
'count(*) as number_of_orders',
|
443 |
Â
)
|
444 |
Â
)
|
445 |
Â
->where("status in (?)", $statuses)
|
446 |
+
->group('customer_id');
|
Â
|
|
447 |
Â
|
448 |
Â
$columns = array(
|
449 |
+
'last_order_date' => new Zend_Db_Expr(
|
450 |
+
"(SELECT created_at FROM $salesFlatOrderGrid WHERE customer_id =e.entity_id ORDER BY created_at DESC LIMIT 1)"
|
451 |
+
),
|
452 |
+
'last_order_id' => new Zend_Db_Expr(
|
453 |
+
"(SELECT entity_id FROM $salesFlatOrderGrid WHERE customer_id =e.entity_id ORDER BY created_at DESC LIMIT 1)"
|
454 |
+
),
|
455 |
+
'last_increment_id' => new Zend_Db_Expr(
|
456 |
+
"(SELECT increment_id FROM $salesFlatOrderGrid WHERE customer_id =e.entity_id ORDER BY created_at DESC LIMIT 1)"
|
457 |
+
),
|
458 |
+
'last_quote_id' => new Zend_Db_Expr(
|
459 |
+
"(SELECT entity_id FROM $salesFlatQuote WHERE customer_id = e.entity_id ORDER BY created_at DESC LIMIT 1)"
|
460 |
+
),
|
461 |
+
'first_category_id' => new Zend_Db_Expr(
|
462 |
Â
"(
|
463 |
+
SELECT ccpi.category_id FROM $salesFlatOrder as sfo
|
464 |
+
left join $salesFlatOrderItem as sfoi on sfoi.order_id = sfo.entity_id
|
465 |
+
left join $catalogCategoryProductIndex as ccpi on ccpi.product_id = sfoi.product_id
|
466 |
Â
WHERE sfo.customer_id = e.entity_id
|
467 |
Â
ORDER BY sfo.created_at ASC, sfoi.price DESC
|
468 |
Â
LIMIT 1
|
469 |
Â
)"
|
470 |
Â
),
|
471 |
+
'last_category_id' => new Zend_Db_Expr(
|
472 |
Â
"(
|
473 |
+
SELECT ccpi.category_id FROM $salesFlatOrder as sfo
|
474 |
+
left join $salesFlatOrderItem as sfoi on sfoi.order_id = sfo.entity_id
|
475 |
+
left join $catalogCategoryProductIndex as ccpi on ccpi.product_id = sfoi.product_id
|
476 |
Â
WHERE sfo.customer_id = e.entity_id
|
477 |
Â
ORDER BY sfo.created_at DESC, sfoi.price DESC
|
478 |
Â
LIMIT 1
|
480 |
Â
),
|
481 |
Â
'product_id_for_first_brand' => new Zend_Db_Expr(
|
482 |
Â
"(
|
483 |
+
SELECT sfoi.product_id FROM $salesFlatOrder as sfo
|
484 |
+
left join $salesFlatOrderItem as sfoi on sfoi.order_id = sfo.entity_id
|
485 |
Â
WHERE sfo.customer_id = e.entity_id and sfoi.product_type = 'simple'
|
486 |
Â
ORDER BY sfo.created_at ASC, sfoi.price DESC
|
487 |
Â
LIMIT 1
|
488 |
Â
)"
|
489 |
Â
),
|
490 |
+
'product_id_for_last_brand' => new Zend_Db_Expr(
|
491 |
Â
"(
|
492 |
+
SELECT sfoi.product_id FROM $salesFlatOrder as sfo
|
493 |
+
left join $salesFlatOrderItem as sfoi on sfoi.order_id = sfo.entity_id
|
494 |
Â
WHERE sfo.customer_id = e.entity_id and sfoi.product_type = 'simple'
|
495 |
Â
ORDER BY sfo.created_at DESC, sfoi.price DESC
|
496 |
Â
LIMIT 1
|
497 |
Â
)"
|
498 |
Â
),
|
499 |
+
'week_day' => new Zend_Db_Expr(
|
500 |
Â
"(
|
501 |
Â
SELECT dayname(created_at) as week_day
|
502 |
+
FROM $salesFlatOrder
|
503 |
Â
WHERE customer_id = e.entity_id
|
504 |
Â
GROUP BY week_day
|
505 |
Â
HAVING COUNT(*) > 0
|
507 |
Â
LIMIT 1
|
508 |
Â
)"
|
509 |
Â
),
|
510 |
+
'month_day' => new Zend_Db_Expr(
|
511 |
Â
"(
|
512 |
Â
SELECT monthname(created_at) as month_day
|
513 |
+
FROM $salesFlatOrder
|
514 |
Â
WHERE customer_id = e.entity_id
|
515 |
Â
GROUP BY month_day
|
516 |
Â
HAVING COUNT(*) > 0
|
518 |
Â
LIMIT 1
|
519 |
Â
)"
|
520 |
Â
),
|
521 |
+
'most_category_id' => new Zend_Db_Expr(
|
522 |
Â
"(
|
523 |
+
SELECT ccpi.category_id FROM $salesFlatOrder as sfo
|
524 |
+
LEFT JOIN $salesFlatOrderItem as sfoi on sfoi.order_id = sfo.entity_id
|
525 |
+
LEFT JOIN $catalogCategoryProductIndex as ccpi on ccpi.product_id = sfoi.product_id
|
526 |
Â
WHERE sfo.customer_id = e.entity_id AND ccpi.category_id is not null
|
527 |
Â
GROUP BY category_id
|
528 |
Â
HAVING COUNT(sfoi.product_id) > 0
|
535 |
Â
);
|
536 |
Â
|
537 |
Â
$brand = Mage::helper('ddg')->getWebsiteConfig(
|
538 |
+
Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_SYNC_DATA_FIELDS_BRAND_ATTRIBUTE,
|
539 |
+
$websiteId
|
540 |
Â
);
|
541 |
Â
|
542 |
+
if ($brand) {
|
543 |
Â
$columns['most_brand'] = new Zend_Db_Expr(
|
544 |
Â
"(
|
545 |
+
SELECT eaov.value from $salesFlatOrder sfo
|
546 |
+
LEFT JOIN $salesFlatOrderItem as sfoi on sfoi.order_id = sfo.entity_id
|
547 |
+
LEFT JOIN $catalogProductEntityInt pei on pei.entity_id = sfoi.product_id
|
548 |
+
LEFT JOIN $eavAttribute ea ON pei.attribute_id = ea.attribute_id
|
549 |
+
LEFT JOIN $eavAttributeOptionValue as eaov on pei.value = eaov.option_id
|
550 |
Â
WHERE sfo.customer_id = e.entity_id AND ea.attribute_code = '$brand' AND eaov.value is not null
|
551 |
Â
GROUP BY eaov.value
|
552 |
Â
HAVING count(*) > 0
|
559 |
Â
$customerCollection->getSelect()->columns($columns);
|
560 |
Â
|
561 |
Â
$customerCollection->getSelect()
|
562 |
+
->joinLeft(
|
563 |
+
array($alias => $subselect),
|
564 |
+
"{$alias}.s_customer_id = e.entity_id"
|
565 |
+
);
|
566 |
Â
|
567 |
Â
return $customerCollection;
|
568 |
Â
}
|
@@ -7,40 +7,41 @@ class Dotdigitalgroup_Email_Model_Apiconnector_Customer
|
|
7 |
Â
public $customerData;
|
8 |
Â
public $reviewCollection;
|
9 |
Â
|
10 |
-
|
11 |
-
|
12 |
Â
|
13 |
Â
public $rewardCustomer;
|
14 |
Â
public $rewardLastSpent = "";
|
15 |
Â
public $rewardLastEarned = "";
|
16 |
Â
public $rewardExpiry = "";
|
17 |
Â
|
18 |
-
protected $
|
19 |
Â
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
Â
|
|
26 |
Â
|
27 |
Â
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
Â
$this->setMappigHash($mappingHash);
|
36 |
Â
}
|
37 |
Â
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
Â
{
|
45 |
Â
$this->customerData[] = $data;
|
46 |
Â
}
|
@@ -56,8 +57,9 @@ class Dotdigitalgroup_Email_Model_Apiconnector_Customer
|
|
56 |
Â
$this->setReviewCollection();
|
57 |
Â
$website = $customer->getStore()->getWebsite();
|
58 |
Â
|
59 |
-
if ($website && Mage::helper('ddg')->isSweetToothToGo($website))
|
60 |
Â
$this->setRewardCustomer($customer);
|
Â
|
|
61 |
Â
|
62 |
Â
foreach ($this->getMappingHash() as $key => $field) {
|
63 |
Â
|
@@ -69,10 +71,12 @@ class Dotdigitalgroup_Email_Model_Apiconnector_Customer
|
|
69 |
Â
foreach ($exploded as $one) {
|
70 |
Â
$function .= ucfirst($one);
|
71 |
Â
}
|
72 |
-
try{
|
73 |
-
$value
|
Â
|
|
Â
|
|
74 |
Â
$this->customerData[$key] = $value;
|
75 |
-
}catch (Exception $e){
|
76 |
Â
Mage::logException($e);
|
77 |
Â
}
|
78 |
Â
}
|
@@ -80,10 +84,10 @@ class Dotdigitalgroup_Email_Model_Apiconnector_Customer
|
|
80 |
Â
|
81 |
Â
public function setReviewCollection()
|
82 |
Â
{
|
83 |
-
$
|
84 |
-
$collection
|
85 |
-
->addCustomerFilter($
|
86 |
-
->setOrder('review_id','DESC');
|
87 |
Â
|
88 |
Â
$this->reviewCollection = $collection;
|
89 |
Â
}
|
@@ -93,12 +97,15 @@ class Dotdigitalgroup_Email_Model_Apiconnector_Customer
|
|
93 |
Â
return $this->reviewCollection->getSize();
|
94 |
Â
}
|
95 |
Â
|
96 |
-
public function getLastReviewDate()
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
97 |
Â
|
98 |
-
|
99 |
-
$this->reviewCollection->getSelect()->limit(1);
|
100 |
-
return $this->reviewCollection->getFirstItem()->getCreatedAt();
|
101 |
Â
}
|
Â
|
|
102 |
Â
return '';
|
103 |
Â
}
|
104 |
Â
|
@@ -110,349 +117,361 @@ class Dotdigitalgroup_Email_Model_Apiconnector_Customer
|
|
110 |
Â
public function setRewardCustomer(Mage_Customer_Model_Customer $customer)
|
111 |
Â
{
|
112 |
Â
//get tbt reward customer
|
113 |
-
$
|
114 |
-
|
Â
|
|
Â
|
|
Â
|
|
115 |
Â
|
116 |
Â
//get transfers collection from tbt reward. only active and order by last updated.
|
117 |
-
$lastTransfers = $
|
118 |
Â
->selectOnlyActive()
|
119 |
-
->addOrder(
|
Â
|
|
Â
|
|
120 |
Â
|
121 |
Â
$spent = $earn = null;
|
122 |
Â
|
123 |
-
foreach($lastTransfers as $transfer) {
|
124 |
-
// if transfer quantity is greater then 0 then this is last points earned date.
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
Â
|
|
130 |
Â
$spent = $transfer->getEffectiveStart();
|
131 |
Â
}
|
132 |
Â
// break if both spent and earn are not null (a value has been assigned)
|
133 |
-
if(!is_null($spent) && !is_null($earn)) {
|
134 |
Â
break;
|
135 |
Â
}
|
136 |
Â
}
|
137 |
Â
|
138 |
Â
// if earn is not null (has a value) then assign the value to property
|
139 |
-
if($earn)
|
140 |
Â
$this->rewardLastEarned = $earn;
|
Â
|
|
141 |
Â
// if spent is not null (has a value) then assign the value to property
|
142 |
-
if($spent)
|
143 |
Â
$this->rewardLastSpent = $spent;
|
Â
|
|
144 |
Â
|
145 |
-
$
|
146 |
-
->getExpiryDate($
|
147 |
Â
|
148 |
Â
// if there is an expiry (has a value) then assign the value to property
|
149 |
-
if($
|
150 |
-
$this->rewardExpiry = $
|
Â
|
|
151 |
Â
}
|
152 |
Â
|
153 |
Â
/**
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
Â
{
|
160 |
Â
return $this->customer->getId();
|
161 |
Â
}
|
162 |
Â
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
Â
|
|
169 |
Â
return $this->customer->getFirstname();
|
170 |
Â
}
|
171 |
Â
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
Â
{
|
179 |
Â
return $this->customer->getLastname();
|
180 |
Â
}
|
181 |
Â
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
Â
{
|
189 |
Â
return $this->customer->getDob();
|
190 |
Â
}
|
191 |
Â
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
Â
{
|
199 |
Â
return $this->_getCustomerGender();
|
200 |
Â
}
|
201 |
Â
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
Â
{
|
209 |
Â
return $this->customer->getPrefix();
|
210 |
Â
}
|
211 |
Â
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
Â
{
|
219 |
Â
return $this->customer->getSuffix();
|
220 |
Â
}
|
221 |
Â
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
Â
{
|
229 |
Â
return $this->_getWebsiteName();
|
230 |
Â
}
|
231 |
Â
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
Â
{
|
239 |
Â
return $this->_getStoreName();
|
240 |
Â
}
|
241 |
Â
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
Â
{
|
249 |
Â
return $this->customer->getCreatedAt();
|
250 |
Â
}
|
251 |
Â
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
Â
{
|
259 |
Â
return $this->customer->getLastLoggedDate();
|
260 |
Â
}
|
261 |
Â
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
Â
{
|
269 |
Â
return $this->_getCustomerGroup();
|
270 |
Â
}
|
271 |
Â
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
Â
{
|
279 |
Â
return $this->_getStreet($this->customer->getBillingStreet(), 1);
|
280 |
Â
}
|
281 |
Â
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
Â
{
|
289 |
Â
return $this->_getStreet($this->customer->getBillingStreet(), 2);
|
290 |
Â
}
|
291 |
Â
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
Â
{
|
299 |
Â
return $this->customer->getBillingCity();
|
300 |
Â
}
|
301 |
Â
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
Â
{
|
309 |
Â
return $this->customer->getBillingCountryCode();
|
310 |
Â
}
|
311 |
Â
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
Â
{
|
319 |
Â
return $this->customer->getBillingRegion();
|
320 |
Â
}
|
321 |
Â
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
Â
{
|
329 |
Â
return $this->customer->getBillingPostcode();
|
330 |
Â
}
|
331 |
Â
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
Â
{
|
339 |
Â
return $this->customer->getBillingTelephone();
|
340 |
Â
}
|
341 |
Â
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
Â
{
|
349 |
Â
return $this->_getStreet($this->customer->getShippingStreet(), 1);
|
350 |
Â
}
|
351 |
Â
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
Â
{
|
359 |
Â
return $this->_getStreet($this->customer->getShippingStreet(), 2);
|
360 |
Â
}
|
361 |
Â
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
Â
{
|
369 |
Â
return $this->customer->getShippingCity();
|
370 |
Â
}
|
371 |
Â
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
Â
|
|
378 |
Â
return $this->customer->getShippingCountryCode();
|
379 |
Â
}
|
380 |
Â
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
Â
{
|
388 |
Â
return $this->customer->getShippingRegion();
|
389 |
Â
}
|
390 |
Â
|
391 |
-
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
-
|
397 |
Â
{
|
398 |
Â
return $this->customer->getShippingPostcode();
|
399 |
Â
}
|
400 |
Â
|
401 |
-
|
402 |
-
|
403 |
-
|
404 |
-
|
405 |
-
|
406 |
-
|
Â
|
|
407 |
Â
return $this->customer->getShippingTelephone();
|
408 |
Â
}
|
409 |
Â
|
410 |
-
|
411 |
-
|
412 |
-
|
413 |
-
|
414 |
-
|
415 |
-
|
416 |
Â
{
|
417 |
Â
return $this->customer->getNumberOfOrders();
|
418 |
Â
}
|
419 |
Â
|
420 |
-
|
421 |
-
|
422 |
-
|
423 |
-
|
424 |
-
|
425 |
-
|
426 |
Â
{
|
427 |
Â
return $this->customer->getAverageOrderValue();
|
428 |
Â
}
|
429 |
Â
|
430 |
-
|
431 |
-
|
432 |
-
|
433 |
-
|
434 |
-
|
435 |
-
|
436 |
Â
{
|
437 |
Â
return $this->customer->getTotalSpend();
|
438 |
Â
}
|
439 |
Â
|
440 |
-
|
441 |
-
|
442 |
-
|
443 |
-
|
444 |
-
|
445 |
-
|
446 |
Â
{
|
447 |
Â
return $this->customer->getLastOrderDate();
|
448 |
Â
}
|
449 |
Â
|
450 |
-
|
451 |
-
|
452 |
-
|
453 |
-
|
454 |
-
|
455 |
-
|
456 |
Â
{
|
457 |
Â
return $this->customer->getLastOrderId();
|
458 |
Â
}
|
@@ -467,36 +486,35 @@ class Dotdigitalgroup_Email_Model_Apiconnector_Customer
|
|
467 |
Â
return $this->customer->getLastQuoteId();
|
468 |
Â
}
|
469 |
Â
|
470 |
-
|
471 |
-
|
472 |
-
|
473 |
-
|
474 |
-
|
475 |
-
|
476 |
Â
{
|
477 |
Â
return $this->customer->getId();
|
478 |
Â
}
|
479 |
Â
|
480 |
-
|
481 |
-
|
482 |
-
|
483 |
-
|
484 |
-
|
485 |
-
|
486 |
Â
{
|
487 |
Â
return $this->customer->getPrefix();
|
488 |
Â
}
|
489 |
Â
|
490 |
-
|
491 |
-
|
492 |
-
|
493 |
-
|
494 |
-
|
495 |
-
|
496 |
Â
{
|
497 |
-
$orders
|
498 |
-
->addAttributeToFilter('customer_id', $this->customer->getId())
|
499 |
-
;
|
500 |
Â
$totalRefunded = 0;
|
501 |
Â
foreach ($orders as $order) {
|
502 |
Â
$refunded = $order->getTotalRefunded();
|
@@ -506,70 +524,77 @@ class Dotdigitalgroup_Email_Model_Apiconnector_Customer
|
|
506 |
Â
return $totalRefunded;
|
507 |
Â
}
|
508 |
Â
|
509 |
-
|
510 |
-
|
511 |
-
|
512 |
-
|
513 |
-
|
514 |
-
|
515 |
Â
{
|
516 |
Â
$result = $this->customerData;
|
Â
|
|
517 |
Â
return $result;
|
518 |
Â
}
|
519 |
Â
|
520 |
-
|
521 |
-
|
522 |
-
|
523 |
-
|
524 |
-
|
525 |
-
|
526 |
-
|
527 |
Â
{
|
528 |
Â
$genderId = $this->customer->getGender();
|
529 |
Â
if (is_numeric($genderId)) {
|
530 |
Â
$gender = Mage::getResourceModel('customer/customer')
|
531 |
Â
->getAttribute('gender')
|
532 |
Â
->getSource()
|
533 |
-
->getOptionText($genderId)
|
534 |
-
|
535 |
Â
return $gender;
|
536 |
Â
}
|
537 |
Â
|
538 |
Â
return '';
|
539 |
Â
}
|
540 |
Â
|
541 |
-
protected function _getStreet($street, $line)
|
Â
|
|
542 |
Â
$street = explode("\n", $street);
|
543 |
-
if(isset($street[$line - 1]))
|
544 |
Â
return $street[$line - 1];
|
Â
|
|
Â
|
|
545 |
Â
return '';
|
546 |
Â
}
|
547 |
Â
|
548 |
-
protected function _getWebsiteName()
|
Â
|
|
549 |
Â
$websiteId = $this->customer->getWebsiteId();
|
550 |
-
$website
|
551 |
-
if($website)
|
552 |
Â
return $website->getName();
|
Â
|
|
553 |
Â
|
554 |
Â
return '';
|
555 |
Â
}
|
556 |
Â
|
557 |
-
protected
|
558 |
Â
{
|
559 |
Â
$storeId = $this->customer->getStoreId();
|
560 |
-
$store
|
561 |
-
if($store)
|
562 |
Â
return $store->getName();
|
Â
|
|
563 |
Â
|
564 |
Â
return '';
|
565 |
Â
}
|
566 |
Â
|
567 |
Â
/**
|
568 |
-
* @param mixed $
|
569 |
Â
*/
|
570 |
-
public function setMappingHash($
|
571 |
Â
{
|
572 |
-
$this->
|
573 |
Â
}
|
574 |
Â
|
575 |
Â
/**
|
@@ -577,37 +602,46 @@ class Dotdigitalgroup_Email_Model_Apiconnector_Customer
|
|
577 |
Â
*/
|
578 |
Â
public function getMappingHash()
|
579 |
Â
{
|
580 |
-
return $this->
|
581 |
Â
}
|
582 |
Â
|
583 |
-
protected function _getCustomerGroup()
|
Â
|
|
584 |
Â
|
585 |
-
|
586 |
-
$group
|
587 |
Â
|
588 |
Â
if ($group->getId()) {
|
589 |
Â
return $group->getCode();
|
590 |
Â
}
|
Â
|
|
591 |
Â
return '';
|
592 |
Â
}
|
593 |
Â
|
594 |
-
|
595 |
-
|
596 |
-
|
597 |
-
|
598 |
-
|
599 |
-
|
600 |
-
|
601 |
-
|
602 |
Â
{
|
603 |
-
$this->
|
Â
|
|
604 |
Â
return $this;
|
605 |
Â
}
|
606 |
Â
|
607 |
Â
public function getRewardReferralUrl()
|
608 |
Â
{
|
609 |
-
if(Mage::helper('ddg')->isSweetToothToGo(
|
610 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
611 |
Â
|
612 |
Â
return '';
|
613 |
Â
}
|
@@ -619,23 +653,33 @@ class Dotdigitalgroup_Email_Model_Apiconnector_Customer
|
|
619 |
Â
|
620 |
Â
public function getRewardPointPending()
|
621 |
Â
{
|
622 |
-
return $this->cleanString(
|
Â
|
|
Â
|
|
623 |
Â
}
|
624 |
Â
|
625 |
Â
public function getRewardPointPendingTime()
|
626 |
Â
{
|
627 |
-
return $this->cleanString(
|
Â
|
|
Â
|
|
628 |
Â
}
|
629 |
Â
|
630 |
Â
public function getRewardPointOnHold()
|
631 |
Â
{
|
632 |
-
return $this->cleanString(
|
Â
|
|
Â
|
|
633 |
Â
}
|
634 |
Â
|
635 |
Â
public function getRewardPointExpiration()
|
636 |
Â
{
|
637 |
-
if($this->rewardExpiry != "")
|
638 |
-
return Mage::getModel('core/date')->date(
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
639 |
Â
return $this->rewardExpiry;
|
640 |
Â
}
|
641 |
Â
|
@@ -651,78 +695,100 @@ class Dotdigitalgroup_Email_Model_Apiconnector_Customer
|
|
651 |
Â
|
652 |
Â
public function cleanString($string)
|
653 |
Â
{
|
654 |
-
$cleanedString = preg_replace("/[^0-9]/",""
|
655 |
-
if($cleanedString != "")
|
656 |
-
return (int)
|
Â
|
|
Â
|
|
657 |
Â
return 0;
|
658 |
Â
}
|
659 |
Â
|
660 |
Â
public function getSubscriberStatus()
|
661 |
Â
{
|
662 |
-
$subscriber = Mage::getModel('newsletter/subscriber')->loadByCustomer(
|
663 |
-
|
664 |
-
|
Â
|
|
Â
|
|
Â
|
|
665 |
Â
}
|
666 |
Â
|
667 |
-
|
668 |
-
|
669 |
-
|
670 |
-
|
671 |
-
|
672 |
-
|
673 |
-
|
Â
|
|
Â
|
|
Â
|
|
674 |
Â
|
675 |
-
if($this->reward !== true){
|
676 |
Â
return $this->reward->getPointsBalance();
|
677 |
Â
}
|
Â
|
|
678 |
Â
return '';
|
679 |
-
|
680 |
Â
|
681 |
-
|
682 |
-
|
683 |
-
|
684 |
-
|
685 |
-
|
686 |
-
|
687 |
-
|
Â
|
|
Â
|
|
Â
|
|
688 |
Â
|
689 |
-
if($this->reward !== true){
|
690 |
-
|
691 |
Â
}
|
Â
|
|
692 |
Â
return '';
|
693 |
-
|
694 |
-
|
695 |
-
|
696 |
-
|
697 |
-
|
698 |
-
|
699 |
-
|
700 |
-
|
701 |
-
|
702 |
-
|
703 |
-
|
704 |
-
|
705 |
-
|
Â
|
|
Â
|
|
706 |
Â
$expiredAt = $this->reward->getExpirationDate();
|
707 |
Â
|
708 |
Â
if ($expiredAt) {
|
709 |
-
$date = Mage::helper('core')->formatDate(
|
Â
|
|
Â
|
|
710 |
Â
} else {
|
711 |
Â
$date = '';
|
712 |
Â
}
|
Â
|
|
713 |
Â
return $date;
|
714 |
Â
}
|
715 |
Â
|
716 |
-
|
717 |
-
|
718 |
Â
|
719 |
Â
|
720 |
-
|
721 |
-
|
722 |
-
|
Â
|
|
Â
|
|
723 |
Â
->addCustomerFilter($this->customer->getId())
|
724 |
Â
->addWebsiteFilter($this->customer->getWebsiteId())
|
725 |
-
->setExpiryConfig(
|
Â
|
|
Â
|
|
726 |
Â
->addExpirationDate($this->customer->getWebsiteId())
|
727 |
Â
->skipExpiredDuplicates()
|
728 |
Â
->setDefaultOrder();
|
@@ -730,59 +796,66 @@ class Dotdigitalgroup_Email_Model_Apiconnector_Customer
|
|
730 |
Â
$item = $collection->setPageSize(1)->setCurPage(1)->getFirstItem();
|
731 |
Â
|
732 |
Â
$this->reward = $item;
|
733 |
-
}
|
734 |
-
else
|
735 |
Â
$this->reward = true;
|
736 |
-
|
Â
|
|
737 |
Â
|
738 |
Â
|
739 |
-
|
740 |
-
|
741 |
-
|
742 |
-
|
743 |
-
|
744 |
-
|
Â
|
|
745 |
Â
$collection = Mage::getModel('ddg_automation/contact')->getCollection()
|
746 |
Â
->addFieldToFilter('customer_id', $this->getCustomerId())
|
747 |
Â
->addFieldToFilter('website_id', $this->customer->getWebsiteId());
|
748 |
Â
|
749 |
Â
$item = $collection->setPageSize(1)->setCurPage(1)->getFirstItem();
|
750 |
Â
|
751 |
-
|
752 |
-
|
753 |
-
|
754 |
-
return '';
|
755 |
-
}
|
756 |
Â
|
Â
|
|
Â
|
|
757 |
Â
|
758 |
Â
|
759 |
-
|
760 |
-
|
761 |
-
|
762 |
-
|
763 |
-
|
764 |
-
|
Â
|
|
765 |
Â
if (Mage::getModel('enterprise_reward/reward_history')) {
|
766 |
Â
//last used from the reward history based on the points delta used
|
767 |
-
$collection = Mage::getModel('enterprise_reward/reward_history')
|
Â
|
|
768 |
Â
->addCustomerFilter($this->customer->getId())
|
769 |
Â
->addWebsiteFilter($this->customer->getWebsiteId())
|
770 |
Â
->addFieldToFilter('points_delta', array('lt' => 0))
|
771 |
Â
->setDefaultOrder();
|
772 |
Â
|
773 |
-
$item
|
Â
|
|
774 |
Â
$lastUsed = $item->getCreatedAt();
|
775 |
Â
|
776 |
Â
//for any valid date
|
777 |
-
if ($lastUsed)
|
778 |
-
return $date = Mage::helper('core')->formatDate(
|
Â
|
|
Â
|
|
Â
|
|
779 |
Â
}
|
780 |
-
return '';
|
781 |
-
}
|
782 |
Â
|
Â
|
|
Â
|
|
783 |
Â
|
784 |
Â
|
785 |
-
|
786 |
Â
* get most purchased category
|
787 |
Â
*
|
788 |
Â
* @return string
|
@@ -790,12 +863,13 @@ class Dotdigitalgroup_Email_Model_Apiconnector_Customer
|
|
790 |
Â
public function getMostPurCategory()
|
791 |
Â
{
|
792 |
Â
$id = $this->customer->getMostCategoryId();
|
793 |
-
if($id){
|
794 |
Â
return Mage::getModel('catalog/category')
|
795 |
Â
->load($id)
|
796 |
Â
->setStoreId($this->customer->getStoreId())
|
797 |
Â
->getName();
|
798 |
Â
}
|
Â
|
|
799 |
Â
return "";
|
800 |
Â
}
|
801 |
Â
|
@@ -807,8 +881,10 @@ class Dotdigitalgroup_Email_Model_Apiconnector_Customer
|
|
807 |
Â
public function getMostPurBrand()
|
808 |
Â
{
|
809 |
Â
$brand = $this->customer->getMostBrand();
|
810 |
-
if($brand)
|
811 |
Â
return $brand;
|
Â
|
|
Â
|
|
812 |
Â
return "";
|
813 |
Â
}
|
814 |
Â
|
@@ -820,8 +896,10 @@ class Dotdigitalgroup_Email_Model_Apiconnector_Customer
|
|
820 |
Â
public function getMostFreqPurDay()
|
821 |
Â
{
|
822 |
Â
$day = $this->customer->getWeekDay();
|
823 |
-
if($day)
|
824 |
Â
return $day;
|
Â
|
|
Â
|
|
825 |
Â
return "";
|
826 |
Â
}
|
827 |
Â
|
@@ -833,8 +911,10 @@ class Dotdigitalgroup_Email_Model_Apiconnector_Customer
|
|
833 |
Â
public function getMostFreqPurMon()
|
834 |
Â
{
|
835 |
Â
$month = $this->customer->getMonthDay();
|
836 |
-
if($month)
|
837 |
Â
return $month;
|
Â
|
|
Â
|
|
838 |
Â
return "";
|
839 |
Â
}
|
840 |
Â
|
@@ -846,12 +926,13 @@ class Dotdigitalgroup_Email_Model_Apiconnector_Customer
|
|
846 |
Â
public function getFirstCategoryPur()
|
847 |
Â
{
|
848 |
Â
$id = $this->customer->getFirstCategoryId();
|
849 |
-
if($id){
|
850 |
Â
return Mage::getModel('catalog/category')
|
851 |
Â
->load($id)
|
852 |
Â
->setStoreId($this->customer->getStoreId())
|
853 |
Â
->getName();
|
854 |
Â
}
|
Â
|
|
855 |
Â
return "";
|
856 |
Â
}
|
857 |
Â
|
@@ -863,12 +944,13 @@ class Dotdigitalgroup_Email_Model_Apiconnector_Customer
|
|
863 |
Â
public function getLastCategoryPur()
|
864 |
Â
{
|
865 |
Â
$id = $this->customer->getLastCategoryId();
|
866 |
-
if($id){
|
867 |
Â
return Mage::getModel('catalog/category')
|
868 |
Â
->setStoreId($this->customer->getStoreId())
|
869 |
Â
->load($id)
|
870 |
Â
->getName();
|
871 |
Â
}
|
Â
|
|
872 |
Â
return "";
|
873 |
Â
}
|
874 |
Â
|
@@ -880,6 +962,7 @@ class Dotdigitalgroup_Email_Model_Apiconnector_Customer
|
|
880 |
Â
public function getFirstBrandPur()
|
881 |
Â
{
|
882 |
Â
$id = $this->customer->getProductIdForFirstBrand();
|
Â
|
|
883 |
Â
return $this->_getBrandValue($id);
|
884 |
Â
}
|
885 |
Â
|
@@ -891,6 +974,7 @@ class Dotdigitalgroup_Email_Model_Apiconnector_Customer
|
|
891 |
Â
public function getLastBrandPur()
|
892 |
Â
{
|
893 |
Â
$id = $this->customer->getProductIdForLastBrand();
|
Â
|
|
894 |
Â
return $this->_getBrandValue($id);
|
895 |
Â
}
|
896 |
Â
|
@@ -900,14 +984,16 @@ class Dotdigitalgroup_Email_Model_Apiconnector_Customer
|
|
900 |
Â
Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_SYNC_DATA_FIELDS_BRAND_ATTRIBUTE,
|
901 |
Â
$this->customer->getWebsiteId()
|
902 |
Â
);
|
903 |
-
if($id && $attribute){
|
904 |
Â
$brand = Mage::getModel('catalog/product')
|
905 |
Â
->setStoreId($this->customer->getStoreId())
|
906 |
Â
->load($id)
|
907 |
Â
->getAttributeText($attribute);
|
908 |
-
if($brand)
|
909 |
Â
return $brand;
|
Â
|
|
910 |
Â
}
|
Â
|
|
911 |
Â
return "";
|
912 |
Â
}
|
913 |
Â
|
@@ -920,4 +1006,24 @@ class Dotdigitalgroup_Email_Model_Apiconnector_Customer
|
|
920 |
Â
{
|
921 |
Â
return $this->customer->getLastIncrementId();
|
922 |
Â
}
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
923 |
Â
}
|
7 |
Â
public $customerData;
|
8 |
Â
public $reviewCollection;
|
9 |
Â
|
10 |
+
//enterprise reward
|
11 |
+
public $reward;
|
12 |
Â
|
13 |
Â
public $rewardCustomer;
|
14 |
Â
public $rewardLastSpent = "";
|
15 |
Â
public $rewardLastEarned = "";
|
16 |
Â
public $rewardExpiry = "";
|
17 |
Â
|
18 |
+
protected $_mappingHash;
|
19 |
Â
|
20 |
+
public $subscriberStatus
|
21 |
+
= array(
|
22 |
+
Mage_Newsletter_Model_Subscriber::STATUS_SUBSCRIBED => 'Subscribed',
|
23 |
+
Mage_Newsletter_Model_Subscriber::STATUS_NOT_ACTIVE => 'Not Active',
|
24 |
+
Mage_Newsletter_Model_Subscriber::STATUS_UNSUBSCRIBED => 'Unsubscribed',
|
25 |
+
Mage_Newsletter_Model_Subscriber::STATUS_UNCONFIRMED => 'Unconfirmed'
|
26 |
+
);
|
27 |
Â
|
28 |
Â
|
29 |
+
/**
|
30 |
+
* constructor, mapping hash to map.
|
31 |
+
*
|
32 |
+
* @param $mappingHash
|
33 |
+
*/
|
34 |
+
public function __construct($mappingHash)
|
35 |
+
{
|
36 |
Â
$this->setMappigHash($mappingHash);
|
37 |
Â
}
|
38 |
Â
|
39 |
+
/**
|
40 |
+
* Set key value data.
|
41 |
+
*
|
42 |
+
* @param $data
|
43 |
+
*/
|
44 |
+
public function setData($data)
|
45 |
Â
{
|
46 |
Â
$this->customerData[] = $data;
|
47 |
Â
}
|
57 |
Â
$this->setReviewCollection();
|
58 |
Â
$website = $customer->getStore()->getWebsite();
|
59 |
Â
|
60 |
+
if ($website && Mage::helper('ddg')->isSweetToothToGo($website)) {
|
61 |
Â
$this->setRewardCustomer($customer);
|
62 |
+
}
|
63 |
Â
|
64 |
Â
foreach ($this->getMappingHash() as $key => $field) {
|
65 |
Â
|
71 |
Â
foreach ($exploded as $one) {
|
72 |
Â
$function .= ucfirst($one);
|
73 |
Â
}
|
74 |
+
try {
|
75 |
+
$value = call_user_func(
|
76 |
+
array('self', $function)
|
77 |
+
);
|
78 |
Â
$this->customerData[$key] = $value;
|
79 |
+
} catch (Exception $e) {
|
80 |
Â
Mage::logException($e);
|
81 |
Â
}
|
82 |
Â
}
|
84 |
Â
|
85 |
Â
public function setReviewCollection()
|
86 |
Â
{
|
87 |
+
$customerId = $this->customer->getId();
|
88 |
+
$collection = Mage::getModel('review/review')->getCollection()
|
89 |
+
->addCustomerFilter($customerId)
|
90 |
+
->setOrder('review_id', 'DESC');
|
91 |
Â
|
92 |
Â
$this->reviewCollection = $collection;
|
93 |
Â
}
|
97 |
Â
return $this->reviewCollection->getSize();
|
98 |
Â
}
|
99 |
Â
|
100 |
+
public function getLastReviewDate()
|
101 |
+
{
|
102 |
+
|
103 |
+
if (count($this->reviewCollection)) {
|
104 |
+
$this->reviewCollection->getSelect()->limit(1);
|
105 |
Â
|
106 |
+
return $this->reviewCollection->getFirstItem()->getCreatedAt();
|
Â
|
|
Â
|
|
107 |
Â
}
|
108 |
+
|
109 |
Â
return '';
|
110 |
Â
}
|
111 |
Â
|
117 |
Â
public function setRewardCustomer(Mage_Customer_Model_Customer $customer)
|
118 |
Â
{
|
119 |
Â
//get tbt reward customer
|
120 |
+
$tbtReward = Mage::getModel('rewards/customer')
|
121 |
+
->getRewardsCustomer(
|
122 |
+
$customer
|
123 |
+
);
|
124 |
+
$this->rewardCustomer = $tbtReward;
|
125 |
Â
|
126 |
Â
//get transfers collection from tbt reward. only active and order by last updated.
|
127 |
+
$lastTransfers = $tbtReward->getTransfers()
|
128 |
Â
->selectOnlyActive()
|
129 |
+
->addOrder(
|
130 |
+
'last_update_ts', Varien_Data_Collection::SORT_ORDER_DESC
|
131 |
+
);
|
132 |
Â
|
133 |
Â
$spent = $earn = null;
|
134 |
Â
|
135 |
+
foreach ($lastTransfers as $transfer) {
|
136 |
+
// if transfer quantity is greater then 0 then this is last points earned date.
|
137 |
+
// keep checking until earn is not null
|
138 |
+
if (is_null($earn) && $transfer->getQuantity() > 0) {
|
139 |
+
$earn = $transfer->getEffectiveStart();
|
140 |
+
} else if (is_null($spent) && $transfer->getQuantity() < 0) {
|
141 |
+
// id transfer quantity is less then 0 then this is last points spent date.
|
142 |
+
// keep checking until spent is not null
|
143 |
Â
$spent = $transfer->getEffectiveStart();
|
144 |
Â
}
|
145 |
Â
// break if both spent and earn are not null (a value has been assigned)
|
146 |
+
if ( ! is_null($spent) && ! is_null($earn)) {
|
147 |
Â
break;
|
148 |
Â
}
|
149 |
Â
}
|
150 |
Â
|
151 |
Â
// if earn is not null (has a value) then assign the value to property
|
152 |
+
if ($earn) {
|
153 |
Â
$this->rewardLastEarned = $earn;
|
154 |
+
}
|
155 |
Â
// if spent is not null (has a value) then assign the value to property
|
156 |
+
if ($spent) {
|
157 |
Â
$this->rewardLastSpent = $spent;
|
158 |
+
}
|
159 |
Â
|
160 |
+
$tbtExpiry = Mage::getSingleton('rewards/expiry')
|
161 |
+
->getExpiryDate($tbtReward);
|
162 |
Â
|
163 |
Â
// if there is an expiry (has a value) then assign the value to property
|
164 |
+
if ($tbtExpiry) {
|
165 |
+
$this->rewardExpiry = $tbtExpiry;
|
166 |
+
}
|
167 |
Â
}
|
168 |
Â
|
169 |
Â
/**
|
170 |
+
* get customer id.
|
171 |
+
*
|
172 |
+
* @return mixed
|
173 |
+
*/
|
174 |
+
public function getCustomerId()
|
175 |
Â
{
|
176 |
Â
return $this->customer->getId();
|
177 |
Â
}
|
178 |
Â
|
179 |
+
/**
|
180 |
+
* get first name.
|
181 |
+
*
|
182 |
+
* @return mixed
|
183 |
+
*/
|
184 |
+
public function getFirstname()
|
185 |
+
{
|
186 |
Â
return $this->customer->getFirstname();
|
187 |
Â
}
|
188 |
Â
|
189 |
+
/**
|
190 |
+
* get last name.
|
191 |
+
*
|
192 |
+
* @return mixed
|
193 |
+
*/
|
194 |
+
public function getLastname()
|
195 |
Â
{
|
196 |
Â
return $this->customer->getLastname();
|
197 |
Â
}
|
198 |
Â
|
199 |
+
/**
|
200 |
+
* get date of birth.
|
201 |
+
*
|
202 |
+
* @return mixed
|
203 |
+
*/
|
204 |
+
public function getDob()
|
205 |
Â
{
|
206 |
Â
return $this->customer->getDob();
|
207 |
Â
}
|
208 |
Â
|
209 |
+
/**
|
210 |
+
* get customer gender.
|
211 |
+
*
|
212 |
+
* @return bool|string
|
213 |
+
*/
|
214 |
+
public function getGender()
|
215 |
Â
{
|
216 |
Â
return $this->_getCustomerGender();
|
217 |
Â
}
|
218 |
Â
|
219 |
+
/**
|
220 |
+
* get customer prefix.
|
221 |
+
*
|
222 |
+
* @return mixed
|
223 |
+
*/
|
224 |
+
public function getPrefix()
|
225 |
Â
{
|
226 |
Â
return $this->customer->getPrefix();
|
227 |
Â
}
|
228 |
Â
|
229 |
+
/**
|
230 |
+
* get customer suffix.
|
231 |
+
*
|
232 |
+
* @return mixed
|
233 |
+
*/
|
234 |
+
public function getSuffix()
|
235 |
Â
{
|
236 |
Â
return $this->customer->getSuffix();
|
237 |
Â
}
|
238 |
Â
|
239 |
+
/**
|
240 |
+
* get website name.
|
241 |
+
*
|
242 |
+
* @return string
|
243 |
+
*/
|
244 |
+
public function getWebsiteName()
|
245 |
Â
{
|
246 |
Â
return $this->_getWebsiteName();
|
247 |
Â
}
|
248 |
Â
|
249 |
+
/**
|
250 |
+
* get store name.
|
251 |
+
*
|
252 |
+
* @return null|string
|
253 |
+
*/
|
254 |
+
public function getStoreName()
|
255 |
Â
{
|
256 |
Â
return $this->_getStoreName();
|
257 |
Â
}
|
258 |
Â
|
259 |
+
/**
|
260 |
+
* get customer created at date.
|
261 |
+
*
|
262 |
+
* @return mixed
|
263 |
+
*/
|
264 |
+
public function getCreatedAt()
|
265 |
Â
{
|
266 |
Â
return $this->customer->getCreatedAt();
|
267 |
Â
}
|
268 |
Â
|
269 |
+
/**
|
270 |
+
* get customer last logged in date.
|
271 |
+
*
|
272 |
+
* @return mixed
|
273 |
+
*/
|
274 |
+
public function getLastLoggedDate()
|
275 |
Â
{
|
276 |
Â
return $this->customer->getLastLoggedDate();
|
277 |
Â
}
|
278 |
Â
|
279 |
+
/**
|
280 |
+
* get cutomer group.
|
281 |
+
*
|
282 |
+
* @return string
|
283 |
+
*/
|
284 |
+
public function getCustomerGroup()
|
285 |
Â
{
|
286 |
Â
return $this->_getCustomerGroup();
|
287 |
Â
}
|
288 |
Â
|
289 |
+
/**
|
290 |
+
* get billing address line 1.
|
291 |
+
*
|
292 |
+
* @return string
|
293 |
+
*/
|
294 |
+
public function getBillingAddress1()
|
295 |
Â
{
|
296 |
Â
return $this->_getStreet($this->customer->getBillingStreet(), 1);
|
297 |
Â
}
|
298 |
Â
|
299 |
+
/**
|
300 |
+
* get billing address line 2.
|
301 |
+
*
|
302 |
+
* @return string
|
303 |
+
*/
|
304 |
+
public function getBillingAddress2()
|
305 |
Â
{
|
306 |
Â
return $this->_getStreet($this->customer->getBillingStreet(), 2);
|
307 |
Â
}
|
308 |
Â
|
309 |
+
/**
|
310 |
+
* get billing city.
|
311 |
+
*
|
312 |
+
* @return mixed
|
313 |
+
*/
|
314 |
+
public function getBillingCity()
|
315 |
Â
{
|
316 |
Â
return $this->customer->getBillingCity();
|
317 |
Â
}
|
318 |
Â
|
319 |
+
/**
|
320 |
+
* get billing country.
|
321 |
+
*
|
322 |
+
* @return mixed
|
323 |
+
*/
|
324 |
+
public function getBillingCountry()
|
325 |
Â
{
|
326 |
Â
return $this->customer->getBillingCountryCode();
|
327 |
Â
}
|
328 |
Â
|
329 |
+
/**
|
330 |
+
* get billing state.
|
331 |
+
*
|
332 |
+
* @return mixed
|
333 |
+
*/
|
334 |
+
public function getBillingState()
|
335 |
Â
{
|
336 |
Â
return $this->customer->getBillingRegion();
|
337 |
Â
}
|
338 |
Â
|
339 |
+
/**
|
340 |
+
* get billing postcode.
|
341 |
+
*
|
342 |
+
* @return mixed
|
343 |
+
*/
|
344 |
+
public function getBillingPostcode()
|
345 |
Â
{
|
346 |
Â
return $this->customer->getBillingPostcode();
|
347 |
Â
}
|
348 |
Â
|
349 |
+
/**
|
350 |
+
* get billing phone.
|
351 |
+
*
|
352 |
+
* @return mixed
|
353 |
+
*/
|
354 |
+
public function getBillingTelephone()
|
355 |
Â
{
|
356 |
Â
return $this->customer->getBillingTelephone();
|
357 |
Â
}
|
358 |
Â
|
359 |
+
/**
|
360 |
+
* get delivery address line 1.
|
361 |
+
*
|
362 |
+
* @return string
|
363 |
+
*/
|
364 |
+
public function getDeliveryAddress1()
|
365 |
Â
{
|
366 |
Â
return $this->_getStreet($this->customer->getShippingStreet(), 1);
|
367 |
Â
}
|
368 |
Â
|
369 |
+
/**
|
370 |
+
* get delivery addrss line 2.
|
371 |
+
*
|
372 |
+
* @return string
|
373 |
+
*/
|
374 |
+
public function getDeliveryAddress2()
|
375 |
Â
{
|
376 |
Â
return $this->_getStreet($this->customer->getShippingStreet(), 2);
|
377 |
Â
}
|
378 |
Â
|
379 |
+
/**
|
380 |
+
* get delivery city.
|
381 |
+
*
|
382 |
+
* @return mixed
|
383 |
+
*/
|
384 |
+
public function getDeliveryCity()
|
385 |
Â
{
|
386 |
Â
return $this->customer->getShippingCity();
|
387 |
Â
}
|
388 |
Â
|
389 |
+
/**
|
390 |
+
* get delivery country.
|
391 |
+
*
|
392 |
+
* @return mixed
|
393 |
+
*/
|
394 |
+
public function getDeliveryCountry()
|
395 |
+
{
|
396 |
Â
return $this->customer->getShippingCountryCode();
|
397 |
Â
}
|
398 |
Â
|
399 |
+
/**
|
400 |
+
* get delivery state.
|
401 |
+
*
|
402 |
+
* @return mixed
|
403 |
+
*/
|
404 |
+
public function getDeliveryState()
|
405 |
Â
{
|
406 |
Â
return $this->customer->getShippingRegion();
|
407 |
Â
}
|
408 |
Â
|
409 |
+
/**
|
410 |
+
* get delivery postcode.
|
411 |
+
*
|
412 |
+
* @return mixed
|
413 |
+
*/
|
414 |
+
public function getDeliveryPostcode()
|
415 |
Â
{
|
416 |
Â
return $this->customer->getShippingPostcode();
|
417 |
Â
}
|
418 |
Â
|
419 |
+
/**
|
420 |
+
* get delivery phone.
|
421 |
+
*
|
422 |
+
* @return mixed
|
423 |
+
*/
|
424 |
+
public function getDeliveryTelephone()
|
425 |
+
{
|
426 |
Â
return $this->customer->getShippingTelephone();
|
427 |
Â
}
|
428 |
Â
|
429 |
+
/**
|
430 |
+
* get numbser of orders.
|
431 |
+
*
|
432 |
+
* @return mixed
|
433 |
+
*/
|
434 |
+
public function getNumberOfOrders()
|
435 |
Â
{
|
436 |
Â
return $this->customer->getNumberOfOrders();
|
437 |
Â
}
|
438 |
Â
|
439 |
+
/**
|
440 |
+
* get average order value.
|
441 |
+
*
|
442 |
+
* @return mixed
|
443 |
+
*/
|
444 |
+
public function getAverageOrderValue()
|
445 |
Â
{
|
446 |
Â
return $this->customer->getAverageOrderValue();
|
447 |
Â
}
|
448 |
Â
|
449 |
+
/**
|
450 |
+
* get total spend.
|
451 |
+
*
|
452 |
+
* @return mixed
|
453 |
+
*/
|
454 |
+
public function getTotalSpend()
|
455 |
Â
{
|
456 |
Â
return $this->customer->getTotalSpend();
|
457 |
Â
}
|
458 |
Â
|
459 |
+
/**
|
460 |
+
* get last order date.
|
461 |
+
*
|
462 |
+
* @return mixed
|
463 |
+
*/
|
464 |
+
public function getLastOrderDate()
|
465 |
Â
{
|
466 |
Â
return $this->customer->getLastOrderDate();
|
467 |
Â
}
|
468 |
Â
|
469 |
+
/**
|
470 |
+
* get last order id.
|
471 |
+
*
|
472 |
+
* @return mixed
|
473 |
+
*/
|
474 |
+
public function getLastOrderId()
|
475 |
Â
{
|
476 |
Â
return $this->customer->getLastOrderId();
|
477 |
Â
}
|
486 |
Â
return $this->customer->getLastQuoteId();
|
487 |
Â
}
|
488 |
Â
|
489 |
+
/**
|
490 |
+
* get cutomer id.
|
491 |
+
*
|
492 |
+
* @return mixed
|
493 |
+
*/
|
494 |
+
public function getId()
|
495 |
Â
{
|
496 |
Â
return $this->customer->getId();
|
497 |
Â
}
|
498 |
Â
|
499 |
+
/**
|
500 |
+
* get customer title.
|
501 |
+
*
|
502 |
+
* @return mixed
|
503 |
+
*/
|
504 |
+
public function getTitle()
|
505 |
Â
{
|
506 |
Â
return $this->customer->getPrefix();
|
507 |
Â
}
|
508 |
Â
|
509 |
+
/**
|
510 |
+
* get total refund value.
|
511 |
+
*
|
512 |
+
* @return float|int
|
513 |
+
*/
|
514 |
+
public function getTotalRefund()
|
515 |
Â
{
|
516 |
+
$orders = Mage::getResourceModel('sales/order_collection')
|
517 |
+
->addAttributeToFilter('customer_id', $this->customer->getId());
|
Â
|
|
518 |
Â
$totalRefunded = 0;
|
519 |
Â
foreach ($orders as $order) {
|
520 |
Â
$refunded = $order->getTotalRefunded();
|
524 |
Â
return $totalRefunded;
|
525 |
Â
}
|
526 |
Â
|
527 |
+
/**
|
528 |
+
* export to CSV.
|
529 |
+
*
|
530 |
+
* @return mixed
|
531 |
+
*/
|
532 |
+
public function toCSVArray()
|
533 |
Â
{
|
534 |
Â
$result = $this->customerData;
|
535 |
+
|
536 |
Â
return $result;
|
537 |
Â
}
|
538 |
Â
|
539 |
+
/**
|
540 |
+
* customer gender.
|
541 |
+
*
|
542 |
+
* @return bool|string
|
543 |
+
* @throws Mage_Core_Exception
|
544 |
+
*/
|
545 |
+
protected function _getCustomerGender()
|
546 |
Â
{
|
547 |
Â
$genderId = $this->customer->getGender();
|
548 |
Â
if (is_numeric($genderId)) {
|
549 |
Â
$gender = Mage::getResourceModel('customer/customer')
|
550 |
Â
->getAttribute('gender')
|
551 |
Â
->getSource()
|
552 |
+
->getOptionText($genderId);
|
553 |
+
|
554 |
Â
return $gender;
|
555 |
Â
}
|
556 |
Â
|
557 |
Â
return '';
|
558 |
Â
}
|
559 |
Â
|
560 |
+
protected function _getStreet($street, $line)
|
561 |
+
{
|
562 |
Â
$street = explode("\n", $street);
|
563 |
+
if (isset($street[$line - 1])) {
|
564 |
Â
return $street[$line - 1];
|
565 |
+
}
|
566 |
+
|
567 |
Â
return '';
|
568 |
Â
}
|
569 |
Â
|
570 |
+
protected function _getWebsiteName()
|
571 |
+
{
|
572 |
Â
$websiteId = $this->customer->getWebsiteId();
|
573 |
+
$website = Mage::app()->getWebsite($websiteId);
|
574 |
+
if ($website) {
|
575 |
Â
return $website->getName();
|
576 |
+
}
|
577 |
Â
|
578 |
Â
return '';
|
579 |
Â
}
|
580 |
Â
|
581 |
+
protected function _getStoreName()
|
582 |
Â
{
|
583 |
Â
$storeId = $this->customer->getStoreId();
|
584 |
+
$store = Mage::app()->getStore($storeId);
|
585 |
+
if ($store) {
|
586 |
Â
return $store->getName();
|
587 |
+
}
|
588 |
Â
|
589 |
Â
return '';
|
590 |
Â
}
|
591 |
Â
|
592 |
Â
/**
|
593 |
+
* @param mixed $mappingHash
|
594 |
Â
*/
|
595 |
+
public function setMappingHash($mappingHash)
|
596 |
Â
{
|
597 |
+
$this->_mappingHash = $mappingHash;
|
598 |
Â
}
|
599 |
Â
|
600 |
Â
/**
|
602 |
Â
*/
|
603 |
Â
public function getMappingHash()
|
604 |
Â
{
|
605 |
+
return $this->_mappingHash;
|
606 |
Â
}
|
607 |
Â
|
608 |
+
protected function _getCustomerGroup()
|
609 |
+
{
|
610 |
Â
|
611 |
+
$groupId = $this->customer->getGroupId();
|
612 |
+
$group = Mage::getModel('customer/group')->load($groupId);
|
613 |
Â
|
614 |
Â
if ($group->getId()) {
|
615 |
Â
return $group->getCode();
|
616 |
Â
}
|
617 |
+
|
618 |
Â
return '';
|
619 |
Â
}
|
620 |
Â
|
621 |
+
/**
|
622 |
+
* mapping hash value.
|
623 |
+
*
|
624 |
+
* @param $value
|
625 |
+
*
|
626 |
+
* @return $this
|
627 |
+
*/
|
628 |
+
public function setMappigHash($value)
|
629 |
Â
{
|
630 |
+
$this->_mappingHash = $value;
|
631 |
+
|
632 |
Â
return $this;
|
633 |
Â
}
|
634 |
Â
|
635 |
Â
public function getRewardReferralUrl()
|
636 |
Â
{
|
637 |
+
if (Mage::helper('ddg')->isSweetToothToGo(
|
638 |
+
$this->customer->getStore()->getWebsite()
|
639 |
+
)
|
640 |
+
) {
|
641 |
+
return (string)Mage::helper('rewardsref/url')->getUrl(
|
642 |
+
$this->customer
|
643 |
+
);
|
644 |
+
}
|
645 |
Â
|
646 |
Â
return '';
|
647 |
Â
}
|
653 |
Â
|
654 |
Â
public function getRewardPointPending()
|
655 |
Â
{
|
656 |
+
return $this->cleanString(
|
657 |
+
$this->rewardCustomer->getPendingPointsSummary()
|
658 |
+
);
|
659 |
Â
}
|
660 |
Â
|
661 |
Â
public function getRewardPointPendingTime()
|
662 |
Â
{
|
663 |
+
return $this->cleanString(
|
664 |
+
$this->rewardCustomer->getPendingTimePointsSummary()
|
665 |
+
);
|
666 |
Â
}
|
667 |
Â
|
668 |
Â
public function getRewardPointOnHold()
|
669 |
Â
{
|
670 |
+
return $this->cleanString(
|
671 |
+
$this->rewardCustomer->getOnHoldPointsSummary()
|
672 |
+
);
|
673 |
Â
}
|
674 |
Â
|
675 |
Â
public function getRewardPointExpiration()
|
676 |
Â
{
|
677 |
+
if ($this->rewardExpiry != "") {
|
678 |
+
return Mage::getModel('core/date')->date(
|
679 |
+
'Y/m/d', strtotime($this->rewardExpiry)
|
680 |
+
);
|
681 |
+
}
|
682 |
+
|
683 |
Â
return $this->rewardExpiry;
|
684 |
Â
}
|
685 |
Â
|
695 |
Â
|
696 |
Â
public function cleanString($string)
|
697 |
Â
{
|
698 |
+
$cleanedString = preg_replace("/[^0-9]/", "", $string);
|
699 |
+
if ($cleanedString != "") {
|
700 |
+
return (int)number_format($cleanedString, 0, '.', '');
|
701 |
+
}
|
702 |
+
|
703 |
Â
return 0;
|
704 |
Â
}
|
705 |
Â
|
706 |
Â
public function getSubscriberStatus()
|
707 |
Â
{
|
708 |
+
$subscriber = Mage::getModel('newsletter/subscriber')->loadByCustomer(
|
709 |
+
$this->customer
|
710 |
+
);
|
711 |
+
if ($subscriber->getCustomerId()) {
|
712 |
+
return $this->subscriberStatus[$subscriber->getSubscriberStatus()];
|
713 |
+
}
|
714 |
Â
}
|
715 |
Â
|
716 |
+
/**
|
717 |
+
* Reward points balance.
|
718 |
+
*
|
719 |
+
* @return int
|
720 |
+
*/
|
721 |
+
public function getRewardPoints()
|
722 |
+
{
|
723 |
+
if ( ! $this->reward) {
|
724 |
+
$this->_setReward();
|
725 |
+
}
|
726 |
Â
|
727 |
+
if ($this->reward !== true) {
|
728 |
Â
return $this->reward->getPointsBalance();
|
729 |
Â
}
|
730 |
+
|
731 |
Â
return '';
|
732 |
+
}
|
733 |
Â
|
734 |
+
/**
|
735 |
+
* Currency amount points.
|
736 |
+
*
|
737 |
+
* @return mixed
|
738 |
+
*/
|
739 |
+
public function getRewardAmount()
|
740 |
+
{
|
741 |
+
if ( ! $this->reward) {
|
742 |
+
$this->_setReward();
|
743 |
+
}
|
744 |
Â
|
745 |
+
if ($this->reward !== true) {
|
746 |
+
return $this->reward->getCurrencyAmount();
|
747 |
Â
}
|
748 |
+
|
749 |
Â
return '';
|
750 |
+
}
|
751 |
+
|
752 |
+
/**
|
753 |
+
* Expiration date to use the points.
|
754 |
+
*
|
755 |
+
* @return string
|
756 |
+
*/
|
757 |
+
public function getExpirationDate()
|
758 |
+
{
|
759 |
+
//set reward for later use
|
760 |
+
if ( ! $this->reward) {
|
761 |
+
$this->_setReward();
|
762 |
+
}
|
763 |
+
|
764 |
+
if ($this->reward !== true) {
|
765 |
Â
$expiredAt = $this->reward->getExpirationDate();
|
766 |
Â
|
767 |
Â
if ($expiredAt) {
|
768 |
+
$date = Mage::helper('core')->formatDate(
|
769 |
+
$expiredAt, 'short', true
|
770 |
+
);
|
771 |
Â
} else {
|
772 |
Â
$date = '';
|
773 |
Â
}
|
774 |
+
|
775 |
Â
return $date;
|
776 |
Â
}
|
777 |
Â
|
778 |
+
return '';
|
779 |
+
}
|
780 |
Â
|
781 |
Â
|
782 |
+
protected function _setReward()
|
783 |
+
{
|
784 |
+
if (Mage::getModel('enterprise_reward/reward_history')) {
|
785 |
+
$collection = Mage::getModel('enterprise_reward/reward_history')
|
786 |
+
->getCollection()
|
787 |
Â
->addCustomerFilter($this->customer->getId())
|
788 |
Â
->addWebsiteFilter($this->customer->getWebsiteId())
|
789 |
+
->setExpiryConfig(
|
790 |
+
Mage::helper('enterprise_reward')->getExpiryConfig()
|
791 |
+
)
|
792 |
Â
->addExpirationDate($this->customer->getWebsiteId())
|
793 |
Â
->skipExpiredDuplicates()
|
794 |
Â
->setDefaultOrder();
|
796 |
Â
$item = $collection->setPageSize(1)->setCurPage(1)->getFirstItem();
|
797 |
Â
|
798 |
Â
$this->reward = $item;
|
799 |
+
} else {
|
Â
|
|
800 |
Â
$this->reward = true;
|
801 |
+
}
|
802 |
+
}
|
803 |
Â
|
804 |
Â
|
805 |
+
/**
|
806 |
+
* Customer segments id.
|
807 |
+
*
|
808 |
+
* @return string
|
809 |
+
*/
|
810 |
+
public function getCustomerSegments()
|
811 |
+
{
|
812 |
Â
$collection = Mage::getModel('ddg_automation/contact')->getCollection()
|
813 |
Â
->addFieldToFilter('customer_id', $this->getCustomerId())
|
814 |
Â
->addFieldToFilter('website_id', $this->customer->getWebsiteId());
|
815 |
Â
|
816 |
Â
$item = $collection->setPageSize(1)->setCurPage(1)->getFirstItem();
|
817 |
Â
|
818 |
+
if ($item) {
|
819 |
+
return $item->getSegmentIds();
|
820 |
+
}
|
Â
|
|
Â
|
|
821 |
Â
|
822 |
+
return '';
|
823 |
+
}
|
824 |
Â
|
825 |
Â
|
826 |
+
/**
|
827 |
+
* Last used reward points.
|
828 |
+
*
|
829 |
+
* @return mixed
|
830 |
+
*/
|
831 |
+
public function getLastUsedDate()
|
832 |
+
{
|
833 |
Â
if (Mage::getModel('enterprise_reward/reward_history')) {
|
834 |
Â
//last used from the reward history based on the points delta used
|
835 |
+
$collection = Mage::getModel('enterprise_reward/reward_history')
|
836 |
+
->getCollection()
|
837 |
Â
->addCustomerFilter($this->customer->getId())
|
838 |
Â
->addWebsiteFilter($this->customer->getWebsiteId())
|
839 |
Â
->addFieldToFilter('points_delta', array('lt' => 0))
|
840 |
Â
->setDefaultOrder();
|
841 |
Â
|
842 |
+
$item = $collection->setPageSize(1)->setCurPage(1)
|
843 |
+
->getFirstItem();
|
844 |
Â
$lastUsed = $item->getCreatedAt();
|
845 |
Â
|
846 |
Â
//for any valid date
|
847 |
+
if ($lastUsed) {
|
848 |
+
return $date = Mage::helper('core')->formatDate(
|
849 |
+
$lastUsed, 'short', true
|
850 |
+
);
|
851 |
+
}
|
852 |
Â
}
|
Â
|
|
Â
|
|
853 |
Â
|
854 |
+
return '';
|
855 |
+
}
|
856 |
Â
|
857 |
Â
|
858 |
+
/**
|
859 |
Â
* get most purchased category
|
860 |
Â
*
|
861 |
Â
* @return string
|
863 |
Â
public function getMostPurCategory()
|
864 |
Â
{
|
865 |
Â
$id = $this->customer->getMostCategoryId();
|
866 |
+
if ($id) {
|
867 |
Â
return Mage::getModel('catalog/category')
|
868 |
Â
->load($id)
|
869 |
Â
->setStoreId($this->customer->getStoreId())
|
870 |
Â
->getName();
|
871 |
Â
}
|
872 |
+
|
873 |
Â
return "";
|
874 |
Â
}
|
875 |
Â
|
881 |
Â
public function getMostPurBrand()
|
882 |
Â
{
|
883 |
Â
$brand = $this->customer->getMostBrand();
|
884 |
+
if ($brand) {
|
885 |
Â
return $brand;
|
886 |
+
}
|
887 |
+
|
888 |
Â
return "";
|
889 |
Â
}
|
890 |
Â
|
896 |
Â
public function getMostFreqPurDay()
|
897 |
Â
{
|
898 |
Â
$day = $this->customer->getWeekDay();
|
899 |
+
if ($day) {
|
900 |
Â
return $day;
|
901 |
+
}
|
902 |
+
|
903 |
Â
return "";
|
904 |
Â
}
|
905 |
Â
|
911 |
Â
public function getMostFreqPurMon()
|
912 |
Â
{
|
913 |
Â
$month = $this->customer->getMonthDay();
|
914 |
+
if ($month) {
|
915 |
Â
return $month;
|
916 |
+
}
|
917 |
+
|
918 |
Â
return "";
|
919 |
Â
}
|
920 |
Â
|
926 |
Â
public function getFirstCategoryPur()
|
927 |
Â
{
|
928 |
Â
$id = $this->customer->getFirstCategoryId();
|
929 |
+
if ($id) {
|
930 |
Â
return Mage::getModel('catalog/category')
|
931 |
Â
->load($id)
|
932 |
Â
->setStoreId($this->customer->getStoreId())
|
933 |
Â
->getName();
|
934 |
Â
}
|
935 |
+
|
936 |
Â
return "";
|
937 |
Â
}
|
938 |
Â
|
944 |
Â
public function getLastCategoryPur()
|
945 |
Â
{
|
946 |
Â
$id = $this->customer->getLastCategoryId();
|
947 |
+
if ($id) {
|
948 |
Â
return Mage::getModel('catalog/category')
|
949 |
Â
->setStoreId($this->customer->getStoreId())
|
950 |
Â
->load($id)
|
951 |
Â
->getName();
|
952 |
Â
}
|
953 |
+
|
954 |
Â
return "";
|
955 |
Â
}
|
956 |
Â
|
962 |
Â
public function getFirstBrandPur()
|
963 |
Â
{
|
964 |
Â
$id = $this->customer->getProductIdForFirstBrand();
|
965 |
+
|
966 |
Â
return $this->_getBrandValue($id);
|
967 |
Â
}
|
968 |
Â
|
974 |
Â
public function getLastBrandPur()
|
975 |
Â
{
|
976 |
Â
$id = $this->customer->getProductIdForLastBrand();
|
977 |
+
|
978 |
Â
return $this->_getBrandValue($id);
|
979 |
Â
}
|
980 |
Â
|
984 |
Â
Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_SYNC_DATA_FIELDS_BRAND_ATTRIBUTE,
|
985 |
Â
$this->customer->getWebsiteId()
|
986 |
Â
);
|
987 |
+
if ($id && $attribute) {
|
988 |
Â
$brand = Mage::getModel('catalog/product')
|
989 |
Â
->setStoreId($this->customer->getStoreId())
|
990 |
Â
->load($id)
|
991 |
Â
->getAttributeText($attribute);
|
992 |
+
if ($brand) {
|
993 |
Â
return $brand;
|
994 |
+
}
|
995 |
Â
}
|
996 |
+
|
997 |
Â
return "";
|
998 |
Â
}
|
999 |
Â
|
1006 |
Â
{
|
1007 |
Â
return $this->customer->getLastIncrementId();
|
1008 |
Â
}
|
1009 |
+
|
1010 |
+
/**
|
1011 |
+
* get billing company name
|
1012 |
+
*
|
1013 |
+
* @return mixed
|
1014 |
+
*/
|
1015 |
+
public function getBillingCompany()
|
1016 |
+
{
|
1017 |
+
return $this->customer->getBillingCompany();
|
1018 |
+
}
|
1019 |
+
|
1020 |
+
/**
|
1021 |
+
* get shipping company name
|
1022 |
+
*
|
1023 |
+
* @return mixed
|
1024 |
+
*/
|
1025 |
+
public function getDeliveryCompany()
|
1026 |
+
{
|
1027 |
+
return $this->customer->getShippingCompany();
|
1028 |
+
}
|
1029 |
Â
}
|
@@ -1,6 +1,9 @@
|
|
1 |
Â
<?php
|
2 |
-
|
Â
|
|
Â
|
|
3 |
Â
{
|
Â
|
|
4 |
Â
/**
|
5 |
Â
* Validate apiuser on save.
|
6 |
Â
*
|
@@ -16,14 +19,22 @@ class Dotdigitalgroup_Email_Model_Apiconnector_Test extends Dotdigitalgroup_Emai
|
|
16 |
Â
->setApiPassword($apiPassword);
|
17 |
Â
$accountInfo = $this->getAccountInfo();
|
18 |
Â
if (isset($accountInfo->message)) {
|
19 |
-
Mage::getSingleton('adminhtml/session')->addError(
|
20 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
21 |
Â
return false;
|
22 |
Â
}
|
Â
|
|
23 |
Â
return $accountInfo;
|
24 |
Â
}
|
Â
|
|
25 |
Â
return false;
|
26 |
Â
}
|
Â
|
|
27 |
Â
/**
|
28 |
Â
* Ajax validate api user.
|
29 |
Â
*
|
@@ -43,8 +54,10 @@ class Dotdigitalgroup_Email_Model_Apiconnector_Test extends Dotdigitalgroup_Emai
|
|
43 |
Â
$message = 'API Username And Password Do Not Match!';
|
44 |
Â
Mage::helper('ddg')->log($message);
|
45 |
Â
}
|
Â
|
|
46 |
Â
return $message;
|
47 |
Â
}
|
Â
|
|
48 |
Â
return false;
|
49 |
Â
}
|
50 |
Â
}
|
1 |
Â
<?php
|
2 |
+
|
3 |
+
class Dotdigitalgroup_Email_Model_Apiconnector_Test
|
4 |
+
extends Dotdigitalgroup_Email_Model_Apiconnector_Client
|
5 |
Â
{
|
6 |
+
|
7 |
Â
/**
|
8 |
Â
* Validate apiuser on save.
|
9 |
Â
*
|
19 |
Â
->setApiPassword($apiPassword);
|
20 |
Â
$accountInfo = $this->getAccountInfo();
|
21 |
Â
if (isset($accountInfo->message)) {
|
22 |
+
Mage::getSingleton('adminhtml/session')->addError(
|
23 |
+
$accountInfo->message
|
24 |
+
);
|
25 |
+
Mage::helper('ddg')->log(
|
26 |
+
'VALIDATION ERROR : ' . $accountInfo->message
|
27 |
+
);
|
28 |
+
|
29 |
Â
return false;
|
30 |
Â
}
|
31 |
+
|
32 |
Â
return $accountInfo;
|
33 |
Â
}
|
34 |
+
|
35 |
Â
return false;
|
36 |
Â
}
|
37 |
+
|
38 |
Â
/**
|
39 |
Â
* Ajax validate api user.
|
40 |
Â
*
|
54 |
Â
$message = 'API Username And Password Do Not Match!';
|
55 |
Â
Mage::helper('ddg')->log($message);
|
56 |
Â
}
|
57 |
+
|
58 |
Â
return $message;
|
59 |
Â
}
|
60 |
+
|
61 |
Â
return false;
|
62 |
Â
}
|
63 |
Â
}
|
@@ -2,223 +2,282 @@
|
|
2 |
Â
|
3 |
Â
class Dotdigitalgroup_Email_Model_Automation extends Mage_Core_Model_Abstract
|
4 |
Â
{
|
5 |
-
const AUTOMATION_TYPE_NEW_CUSTOMER = 'customer_automation';
|
6 |
-
const AUTOMATION_TYPE_NEW_SUBSCRIBER = 'subscriber_automation';
|
7 |
-
const AUTOMATION_TYPE_NEW_ORDER = 'order_automation';
|
8 |
-
const AUTOMATION_TYPE_NEW_GUEST_ORDER = 'guest_order_automation';
|
9 |
-
const AUTOMATION_TYPE_NEW_REVIEW = 'review_automation';
|
10 |
-
const AUTOMATION_TYPE_NEW_WISHLIST = 'wishlist_automation';
|
11 |
-
const AUTOMATION_STATUS_PENDING = 'pending';
|
12 |
-
//automation enrolment limit
|
13 |
-
public $limit = 100;
|
14 |
-
public $email;
|
15 |
-
public $typeId;
|
16 |
-
public $websiteId;
|
17 |
-
public $storeName;
|
18 |
-
public $programId;
|
19 |
-
public $programStatus = 'Active';
|
20 |
-
public $programMessage;
|
21 |
-
public $automationType;
|
22 |
-
/**
|
23 |
-
* constructor
|
24 |
-
*/
|
25 |
-
public function _construct()
|
26 |
-
{
|
27 |
-
parent::_construct();
|
28 |
-
$this->_init('ddg_automation/automation');
|
29 |
-
}
|
30 |
-
/**
|
31 |
-
* @return $this|Mage_Core_Model_Abstract
|
32 |
-
*/
|
33 |
-
protected function _beforeSave()
|
34 |
-
{
|
35 |
-
parent::_beforeSave();
|
36 |
-
$now = Mage::getSingleton('core/date')->gmtDate();
|
37 |
-
if ($this->isObjectNew()) {
|
38 |
-
$this->setCreatedAt($now);
|
39 |
-
} else {
|
40 |
-
$this->setUpdatedAt($now);
|
41 |
-
}
|
42 |
-
return $this;
|
43 |
-
}
|
44 |
Â
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
//limit because of the each contact request to get the id
|
63 |
-
$automationCollection->getSelect()->limit( $this->limit );
|
64 |
-
foreach ( $automationCollection as $automation ) {
|
65 |
-
$type = $automation->getAutomationType();
|
66 |
-
//customerid, subscriberid, wishlistid..
|
67 |
-
$email = $automation->getEmail();
|
68 |
-
$this->typeId = $automation->getTypeId();
|
69 |
-
$this->websiteId = $automation->getWebsiteId();
|
70 |
-
$this->programId = $automation->getProgramId();
|
71 |
-
$this->storeName = $automation->getStoreName();
|
72 |
-
$contactId = Mage::helper( 'ddg' )->getContactId( $email, $this->websiteId );
|
73 |
-
//contact id is valid, can update datafields
|
74 |
-
if ( $contactId ) {
|
75 |
-
//need to update datafields
|
76 |
-
$this->updateDatafieldsByType( $this->automationType, $email );
|
77 |
-
$contacts[ $automation->getId() ] = $contactId;
|
78 |
-
} else {
|
79 |
-
// the contact is suppressed or the request failed
|
80 |
-
$automation->setEnrolmentStatus('Suppressed')->save();
|
81 |
-
}
|
82 |
-
}
|
83 |
-
//only for subscribed contacts
|
84 |
-
if ( ! empty( $contacts ) && $type != '' && $this->_checkCampignEnrolmentActive( $this->programId ) ) {
|
85 |
-
$result = $this->sendContactsToAutomation( array_values( $contacts ) );
|
86 |
-
//check for error message
|
87 |
-
if ( isset( $result->message ) ) {
|
88 |
-
$this->programStatus = 'Failed';
|
89 |
-
$this->programMessage = $result->message;
|
90 |
-
}
|
91 |
-
//program is not active
|
92 |
-
} elseif ( $this->programMessage == 'Error: ERROR_PROGRAM_NOT_ACTIVE ' ) {
|
93 |
-
$this->programStatus = 'Deactivated';
|
94 |
-
}
|
95 |
-
//update contacts with the new status, and log the error message if failes
|
96 |
-
$num = $this->getResource()->updateContacts($contacts, $this->programStatus, $this->programMessage);
|
97 |
-
if ($num)
|
98 |
-
Mage::helper('ddg')->log('Automation type : ' . $type . ', updated no : ' . $num);
|
99 |
-
}
|
100 |
Â
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
2 |
Â
|
3 |
Â
class Dotdigitalgroup_Email_Model_Automation extends Mage_Core_Model_Abstract
|
4 |
Â
{
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
5 |
Â
|
6 |
+
const AUTOMATION_TYPE_NEW_CUSTOMER = 'customer_automation';
|
7 |
+
const AUTOMATION_TYPE_NEW_SUBSCRIBER = 'subscriber_automation';
|
8 |
+
const AUTOMATION_TYPE_NEW_ORDER = 'order_automation';
|
9 |
+
const AUTOMATION_TYPE_NEW_GUEST_ORDER = 'guest_order_automation';
|
10 |
+
const AUTOMATION_TYPE_NEW_REVIEW = 'review_automation';
|
11 |
+
const AUTOMATION_TYPE_NEW_WISHLIST = 'wishlist_automation';
|
12 |
+
const AUTOMATION_STATUS_PENDING = 'pending';
|
13 |
+
//automation enrolment limit
|
14 |
+
public $limit = 100;
|
15 |
+
public $email;
|
16 |
+
public $typeId;
|
17 |
+
public $websiteId;
|
18 |
+
public $storeName;
|
19 |
+
public $programId;
|
20 |
+
public $programStatus = 'Active';
|
21 |
+
public $programMessage;
|
22 |
+
public $automationType;
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
23 |
Â
|
24 |
+
/**
|
25 |
+
* constructor
|
26 |
+
*/
|
27 |
+
public function _construct()
|
28 |
+
{
|
29 |
+
parent::_construct();
|
30 |
+
$this->_init('ddg_automation/automation');
|
31 |
+
}
|
32 |
+
|
33 |
+
/**
|
34 |
+
* @return $this|Mage_Core_Model_Abstract
|
35 |
+
*/
|
36 |
+
protected function _beforeSave()
|
37 |
+
{
|
38 |
+
parent::_beforeSave();
|
39 |
+
$now = Mage::getSingleton('core/date')->gmtDate();
|
40 |
+
if ($this->isObjectNew()) {
|
41 |
+
$this->setCreatedAt($now);
|
42 |
+
} else {
|
43 |
+
$this->setUpdatedAt($now);
|
44 |
+
}
|
45 |
+
|
46 |
+
return $this;
|
47 |
+
}
|
48 |
+
|
49 |
+
public function enrollment()
|
50 |
+
{
|
51 |
+
//automation statuses to filter
|
52 |
+
$automationCollection = $this->getCollection()
|
53 |
+
->addFieldToSelect('automation_type')
|
54 |
+
->addFieldToFilter(
|
55 |
+
'enrolment_status', self::AUTOMATION_STATUS_PENDING
|
56 |
+
);
|
57 |
+
$automationCollection->getSelect()->group('automation_type');
|
58 |
+
//active types
|
59 |
+
$automationTypes = $automationCollection->getColumnValues(
|
60 |
+
'automation_type'
|
61 |
+
);
|
62 |
+
//send the campaign by each types
|
63 |
+
foreach ($automationTypes as $type) {
|
64 |
+
$contacts = array();
|
65 |
+
//reset the collection
|
66 |
+
$automationCollection->clear();
|
67 |
+
$automationCollection = $this->getCollection()
|
68 |
+
->addFieldToFilter(
|
69 |
+
'enrolment_status', self::AUTOMATION_STATUS_PENDING
|
70 |
+
)
|
71 |
+
->addFieldToFilter('automation_type', $type);
|
72 |
+
//limit because of the each contact request to get the id
|
73 |
+
$automationCollection->getSelect()->limit($this->limit);
|
74 |
+
foreach ($automationCollection as $automation) {
|
75 |
+
$type = $automation->getAutomationType();
|
76 |
+
//customerid, subscriberid, wishlistid..
|
77 |
+
$email = $automation->getEmail();
|
78 |
+
$this->typeId = $automation->getTypeId();
|
79 |
+
$this->websiteId = $automation->getWebsiteId();
|
80 |
+
$this->programId = $automation->getProgramId();
|
81 |
+
$this->storeName = $automation->getStoreName();
|
82 |
+
$contactId = Mage::helper('ddg')->getContactId(
|
83 |
+
$email, $this->websiteId
|
84 |
+
);
|
85 |
+
//contact id is valid, can update datafields
|
86 |
+
if ($contactId) {
|
87 |
+
//need to update datafields
|
88 |
+
$this->updateDatafieldsByType(
|
89 |
+
$this->automationType, $email
|
90 |
+
);
|
91 |
+
$contacts[$automation->getId()] = $contactId;
|
92 |
+
} else {
|
93 |
+
// the contact is suppressed or the request failed
|
94 |
+
$automation->setEnrolmentStatus('Suppressed')->save();
|
95 |
+
}
|
96 |
+
}
|
97 |
+
//only for subscribed contacts
|
98 |
+
if ( ! empty($contacts) && $type != ''
|
99 |
+
&& $this->_checkCampignEnrolmentActive($this->programId)
|
100 |
+
) {
|
101 |
+
$result = $this->sendContactsToAutomation(
|
102 |
+
array_values($contacts)
|
103 |
+
);
|
104 |
+
//check for error message
|
105 |
+
if (isset($result->message)) {
|
106 |
+
$this->programStatus = 'Failed';
|
107 |
+
$this->programMessage = $result->message;
|
108 |
+
}
|
109 |
+
//program is not active
|
110 |
+
} elseif ($this->programMessage
|
111 |
+
== 'Error: ERROR_PROGRAM_NOT_ACTIVE '
|
112 |
+
) {
|
113 |
+
$this->programStatus = 'Deactivated';
|
114 |
+
}
|
115 |
+
//update contacts with the new status, and log the error message if failes
|
116 |
+
$num = $this->getResource()->updateContacts(
|
117 |
+
$contacts, $this->programStatus, $this->programMessage
|
118 |
+
);
|
119 |
+
if ($num) {
|
120 |
+
Mage::helper('ddg')->log(
|
121 |
+
'Automation type : ' . $type . ', updated no : ' . $num
|
122 |
+
);
|
123 |
+
}
|
124 |
+
}
|
125 |
+
|
126 |
+
}
|
127 |
+
|
128 |
+
/**
|
129 |
+
* update single contact datafields for this automation type.
|
130 |
+
*
|
131 |
+
* @param $type
|
132 |
+
*/
|
133 |
+
public function updateDatafieldsByType($type, $email)
|
134 |
+
{
|
135 |
+
switch ($type) {
|
136 |
+
case self::AUTOMATION_TYPE_NEW_CUSTOMER :
|
137 |
+
$this->_updateDefaultDatafields($email);
|
138 |
+
break;
|
139 |
+
case self::AUTOMATION_TYPE_NEW_SUBSCRIBER :
|
140 |
+
$this->_updateDefaultDatafields($email);
|
141 |
+
break;
|
142 |
+
case self::AUTOMATION_TYPE_NEW_ORDER :
|
143 |
+
$this->_updateNewOrderDatafields();
|
144 |
+
break;
|
145 |
+
case self::AUTOMATION_TYPE_NEW_GUEST_ORDER:
|
146 |
+
$this->_updateNewOrderDatafields();
|
147 |
+
break;
|
148 |
+
case self::AUTOMATION_TYPE_NEW_REVIEW :
|
149 |
+
$this->_updateNewOrderDatafields();
|
150 |
+
break;
|
151 |
+
case self::AUTOMATION_TYPE_NEW_WISHLIST:
|
152 |
+
$this->_updateDefaultDatafields($email);
|
153 |
+
break;
|
154 |
+
default:
|
155 |
+
$this->_updateDefaultDatafields($email);
|
156 |
+
break;
|
157 |
+
}
|
158 |
+
}
|
159 |
+
|
160 |
+
protected function _updateDefaultDatafields($email)
|
161 |
+
{
|
162 |
+
$website = Mage::app()->getWebsite($this->websiteId);
|
163 |
+
Mage::helper('ddg')->updateDataFields(
|
164 |
+
$email, $website, $this->storeName
|
165 |
+
);
|
166 |
+
}
|
167 |
+
|
168 |
+
protected function _updateNewOrderDatafields()
|
169 |
+
{
|
170 |
+
$website = Mage::app()->getWebsite($this->websiteId);
|
171 |
+
$order = Mage::getModel('sales/order')->load($this->typeId);
|
172 |
+
//data fields
|
173 |
+
if ($lastOrderId = $website->getConfig(
|
174 |
+
Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_LAST_ORDER_ID
|
175 |
+
)
|
176 |
+
) {
|
177 |
+
$data[] = array(
|
178 |
+
'Key' => $lastOrderId,
|
179 |
+
'Value' => $order->getId()
|
180 |
+
);
|
181 |
+
}
|
182 |
+
if ($orderIncrementId = $website->getConfig(
|
183 |
+
Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_LAST_ORDER_INCREMENT_ID
|
184 |
+
)
|
185 |
+
) {
|
186 |
+
$data[] = array(
|
187 |
+
'Key' => $orderIncrementId,
|
188 |
+
'Value' => $order->getIncrementId()
|
189 |
+
);
|
190 |
+
}
|
191 |
+
if ($storeName = $website->getConfig(
|
192 |
+
Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_STORE_NAME
|
193 |
+
)
|
194 |
+
) {
|
195 |
+
$data[] = array(
|
196 |
+
'Key' => $storeName,
|
197 |
+
'Value' => $this->storeName
|
198 |
+
);
|
199 |
+
}
|
200 |
+
if ($websiteName = $website->getConfig(
|
201 |
+
Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_WEBSITE_NAME
|
202 |
+
)
|
203 |
+
) {
|
204 |
+
$data[] = array(
|
205 |
+
'Key' => $websiteName,
|
206 |
+
'Value' => $website->getName()
|
207 |
+
);
|
208 |
+
}
|
209 |
+
if ($lastOrderDate = $website->getConfig(
|
210 |
+
Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_LAST_ORDER_DATE
|
211 |
+
)
|
212 |
+
) {
|
213 |
+
$data[] = array(
|
214 |
+
'Key' => $lastOrderDate,
|
215 |
+
'Value' => $order->getCreatedAt()
|
216 |
+
);
|
217 |
+
}
|
218 |
+
if (($customerId = $website->getConfig(
|
219 |
+
Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_ID
|
220 |
+
))
|
221 |
+
&& $order->getCustomerId()
|
222 |
+
) {
|
223 |
+
$data[] = array(
|
224 |
+
'Key' => $customerId,
|
225 |
+
'Value' => $order->getCustomerId()
|
226 |
+
);
|
227 |
+
}
|
228 |
+
if ( ! empty($data)) {
|
229 |
+
//update data fields
|
230 |
+
$client = Mage::helper('ddg')->g
|