dotmailermagento - Version 3.1.2

Version Notes

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.

Download this release

Release Info

Developer Calin Diacon
Extension dotmailermagento
Version 3.1.2
Comparing to
See all releases


Code changes from version 1.5.1 to 3.1.2

Files changed (250) hide show
  1. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Campaign.php +18 -0
  2. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Campaign/Edit.php +39 -0
  3. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Campaign/Edit/Form.php +54 -0
  4. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Campaign/Grid.php +164 -0
  5. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Column/Renderer/Imported.php +16 -0
  6. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Column/Renderer/Status.php +18 -0
  7. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Column/Renderer/Sync.php +16 -0
  8. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Config/Customdatafields.php +112 -0
  9. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Config/Select.php +14 -0
  10. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Config/Template/Templatefields.php +149 -0
  11. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Contact.php +18 -0
  12. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Contact/Edit.php +36 -0
  13. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Contact/Edit/Form.php +26 -0
  14. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Contact/Grid.php +207 -0
  15. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Dashboard.php +41 -0
  16. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Dashboard/Content.php +11 -0
  17. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Order.php +15 -0
  18. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Order/Grid.php +103 -0
  19. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Sales/Order/Creditmemo/View.php +196 -0
  20. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Advanced/Deletecontactids.php +22 -0
  21. app/code/{local/Dotdigitalgroup/Email/Block/Debug/Countcontacts.php → community/Dotdigitalgroup/Email/Block/Adminhtml/System/Advanced/Reimportorders.php} +7 -6
  22. app/code/{local/Dotdigitalgroup/Email/Block/Debug/Deletecontacts.php → community/Dotdigitalgroup/Email/Block/Adminhtml/System/Advanced/Reimportsubscribers.php} +7 -6
  23. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Advanced/Setupdatafields.php +24 -0
  24. app/code/{local/Dotdigitalgroup/Email/Block/Debug/Initialsync.php → community/Dotdigitalgroup/Email/Block/Adminhtml/System/Advanced/Suppressedcontacts.php} +8 -5
  25. app/code/{local/Dotdigitalgroup/Email/Block/Adminhtml/System/Config/Password.php → community/Dotdigitalgroup/Email/Block/Adminhtml/System/Ajaxvalidate.php} +1 -1
  26. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Automation/Connect.php +43 -0
  27. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Config/Addressbook.php +38 -0
  28. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Config/Datafield.php +40 -0
  29. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Config/Validator.php +87 -0
  30. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Config/Waitingfield.php +65 -0
  31. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Config/Wrapper.php +59 -0
  32. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Dynamic/Addressbookbutton.php +22 -0
  33. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Dynamic/Bestsellers.php +25 -0
  34. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Dynamic/Couponinfo.php +27 -0
  35. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Dynamic/Creditmemonew.php +28 -0
  36. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Dynamic/Crosssell.php +26 -0
  37. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Dynamic/Datafieldbutton.php +21 -0
  38. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Dynamic/Gridlist.php +106 -0
  39. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Dynamic/Lostbasket.php +25 -0
  40. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Dynamic/Mostviewed.php +24 -0
  41. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Dynamic/Productpush.php +24 -0
  42. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Dynamic/Recentlyviewed.php +24 -0
  43. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Dynamic/Related.php +26 -0
  44. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Dynamic/Upsell.php +24 -0
  45. app/code/{local/Dotdigitalgroup/Email/Block/Adminhtml/System/Config/Wrapper.php → community/Dotdigitalgroup/Email/Block/Adminhtml/System/Emailapivalidate.php} +9 -8
  46. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Sms/Smsmessagefour.php +24 -0
  47. app/code/{local/Dotdigitalgroup/Email/Block/Adminhtml/System/Config → community/Dotdigitalgroup/Email/Block/Adminhtml/System/Sms}/Smsmessageone.php +13 -8
  48. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Sms/Smsmessagethree.php +26 -0
  49. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Sms/Smsmessagetwo.php +25 -0
  50. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Url/Creditmemoupdate.php +32 -0
  51. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Url/Creditmemoupdateguest.php +30 -0
  52. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Url/Customerconfirmation.php +36 -0
  53. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Url/Customerconfirmed.php +36 -0
  54. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Url/Customernew.php +36 -0
  55. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Url/Invoiceupdate.php +33 -0
  56. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Url/Invoiceupdateguest.php +33 -0
  57. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Url/Newcreditmemo.php +36 -0
  58. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Url/Newcreditmemoguest.php +35 -0
  59. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Url/Newinvoice.php +34 -0
  60. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Url/Newinvoiceguest.php +34 -0
  61. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Url/Neworder.php +33 -0
  62. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Url/Neworderguest.php +32 -0
  63. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Url/Newshipment.php +34 -0
  64. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Url/Newshipmentguest.php +33 -0
  65. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Url/Orderupdate.php +31 -0
  66. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Url/Orderupdateguest.php +31 -0
  67. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Url/Shipmentupdate.php +33 -0
  68. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Url/Shipmentupdateguest.php +32 -0
  69. app/code/{local → community}/Dotdigitalgroup/Email/Block/Basket.php +23 -8
  70. app/code/{local → community}/Dotdigitalgroup/Email/Block/Coupon.php +12 -11
  71. app/code/community/Dotdigitalgroup/Email/Block/Customer.php +96 -0
  72. app/code/community/Dotdigitalgroup/Email/Block/Order.php +41 -0
  73. app/code/community/Dotdigitalgroup/Email/Block/Order/Creditmemo.php +48 -0
  74. app/code/community/Dotdigitalgroup/Email/Block/Order/Invoice.php +39 -0
  75. app/code/community/Dotdigitalgroup/Email/Block/Order/Shipping.php +48 -0
  76. app/code/community/Dotdigitalgroup/Email/Block/Products.php +65 -0
  77. app/code/community/Dotdigitalgroup/Email/Block/Recommended/Bestsellers.php +70 -0
  78. app/code/community/Dotdigitalgroup/Email/Block/Recommended/Mostviewed.php +65 -0
  79. app/code/community/Dotdigitalgroup/Email/Block/Recommended/Products.php +141 -0
  80. app/code/community/Dotdigitalgroup/Email/Block/Recommended/Push.php +66 -0
  81. app/code/community/Dotdigitalgroup/Email/Block/Recommended/Recentlyviewed.php +73 -0
  82. app/code/community/Dotdigitalgroup/Email/Helper/Config.php +91 -0
  83. app/code/community/Dotdigitalgroup/Email/Helper/Data.php +283 -0
  84. app/code/{local → community}/Dotdigitalgroup/Email/Helper/File.php +59 -29
  85. app/code/community/Dotdigitalgroup/Email/Helper/Recommended.php +166 -0
  86. app/code/community/Dotdigitalgroup/Email/Helper/Transactional.php +279 -0
  87. app/code/community/Dotdigitalgroup/Email/Model/Abstract/Rest.php +435 -0
  88. app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Observer.php +93 -0
  89. app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Source/Addressbooks.php +44 -0
  90. app/code/{local/Dotdigitalgroup/Email/Model/System/Config/Source/Orderlimit.php → community/Dotdigitalgroup/Email/Model/Adminhtml/Source/Advanced/Transdata.php} +1 -1
  91. app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Source/Automation/Programme.php +40 -0
  92. app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Source/Campaigns.php +44 -0
  93. app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Source/Contact/Imported.php +17 -0
  94. app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Source/Customer/Attributes/Select.php +34 -0
  95. app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Source/Datafields.php +45 -0
  96. app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Source/Datamapping/Datafieldtype.php +22 -0
  97. app/code/{local/Dotdigitalgroup/Email/Model/System/Config/Source → community/Dotdigitalgroup/Email/Model/Adminhtml/Source/Dynamic}/Displaytype.php +7 -2
  98. app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Source/Dynamic/Frequency.php +30 -0
  99. app/code/{local/Dotdigitalgroup/Email/Model/System/Config/Source → community/Dotdigitalgroup/Email/Model/Adminhtml/Source/Dynamic}/Gridview.php +6 -1
  100. app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Source/Lostbaskets/Interval.php +40 -0
  101. app/code/{local/Dotdigitalgroup/Email/Model/System/Config/Source/Lostbasket.php → community/Dotdigitalgroup/Email/Model/Adminhtml/Source/Lostbaskets/Intervalminute.php} +1 -1
  102. app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Source/Orderstatus.php +28 -0
  103. app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Source/Sweettooth/Yesno.php +26 -0
  104. app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Source/Transactional/Campaigns.php +48 -0
  105. app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Source/Transactional/Customselect.php +19 -0
  106. app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Source/Transactional/Defaultselect.php +31 -0
  107. app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Source/Transactional/Fromaddress.php +43 -0
  108. app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Source/Transactional/Replyactions.php +22 -0
  109. app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Source/Transactional/Sendtype.php +21 -0
  110. app/code/community/Dotdigitalgroup/Email/Model/Apiconnector/Client.php +787 -0
  111. app/code/community/Dotdigitalgroup/Email/Model/Apiconnector/Contact.php +363 -0
  112. app/code/community/Dotdigitalgroup/Email/Model/Apiconnector/Customer.php +621 -0
  113. app/code/community/Dotdigitalgroup/Email/Model/Apiconnector/Test.php +78 -0
  114. app/code/community/Dotdigitalgroup/Email/Model/Campaign.php +247 -0
  115. app/code/{local → community}/Dotdigitalgroup/Email/Model/Connector/Account.php +10 -8
  116. app/code/community/Dotdigitalgroup/Email/Model/Connector/Campaign.php +100 -0
  117. app/code/community/Dotdigitalgroup/Email/Model/Connector/Datafield.php +323 -0
  118. app/code/community/Dotdigitalgroup/Email/Model/Connector/Order.php +203 -0
  119. app/code/community/Dotdigitalgroup/Email/Model/Contact.php +169 -0
  120. app/code/community/Dotdigitalgroup/Email/Model/Create.php +130 -0
  121. app/code/community/Dotdigitalgroup/Email/Model/Cron.php +73 -0
  122. app/code/community/Dotdigitalgroup/Email/Model/Customer/Guest.php +55 -0
  123. app/code/community/Dotdigitalgroup/Email/Model/Customer/Observer.php +157 -0
  124. app/code/community/Dotdigitalgroup/Email/Model/Customer/Wishlist.php +94 -0
  125. app/code/{local → community}/Dotdigitalgroup/Email/Model/Customer/Wishlist/Item.php +25 -12
  126. app/code/community/Dotdigitalgroup/Email/Model/Email/Template.php +324 -0
  127. app/code/community/Dotdigitalgroup/Email/Model/Newsletter/Observer.php +110 -0
  128. app/code/community/Dotdigitalgroup/Email/Model/Newsletter/Subscriber.php +142 -0
  129. app/code/community/Dotdigitalgroup/Email/Model/Order.php +81 -0
  130. app/code/community/Dotdigitalgroup/Email/Model/Resource/Campaign.php +13 -0
  131. app/code/community/Dotdigitalgroup/Email/Model/Resource/Campaign/Collection.php +13 -0
  132. app/code/community/Dotdigitalgroup/Email/Model/Resource/Contact.php +14 -0
  133. app/code/community/Dotdigitalgroup/Email/Model/Resource/Contact/Collection.php +25 -0
  134. app/code/community/Dotdigitalgroup/Email/Model/Resource/Create.php +14 -0
  135. app/code/community/Dotdigitalgroup/Email/Model/Resource/Create/Collection.php +14 -0
  136. app/code/community/Dotdigitalgroup/Email/Model/Resource/Order.php +12 -0
  137. app/code/community/Dotdigitalgroup/Email/Model/Resource/Order/Collection.php +18 -0
  138. app/code/community/Dotdigitalgroup/Email/Model/Resource/Setup.php +26 -0
  139. app/code/community/Dotdigitalgroup/Email/Model/Sales/Observer.php +152 -0
  140. app/code/community/Dotdigitalgroup/Email/Model/Sales/Order.php +148 -0
  141. app/code/community/Dotdigitalgroup/Email/Model/Sales/Quote.php +173 -0
  142. app/code/community/Dotdigitalgroup/Email/Model/Sms/Campaign.php +113 -0
  143. app/code/community/Dotdigitalgroup/Email/Model/Sweettooth/Observer.php +21 -0
  144. app/code/community/Dotdigitalgroup/Email/controllers/Adminhtml/ConnectorController.php +160 -0
  145. app/code/community/Dotdigitalgroup/Email/controllers/Adminhtml/Email/AutomationController.php +109 -0
  146. app/code/community/Dotdigitalgroup/Email/controllers/Adminhtml/Email/CampaignController.php +218 -0
  147. app/code/community/Dotdigitalgroup/Email/controllers/Adminhtml/Email/ContactController.php +192 -0
  148. app/code/community/Dotdigitalgroup/Email/controllers/Adminhtml/Email/DashboardController.php +21 -0
  149. app/code/community/Dotdigitalgroup/Email/controllers/Adminhtml/Email/OrderController.php +26 -0
  150. app/code/community/Dotdigitalgroup/Email/controllers/CreditmemoController.php +91 -0
  151. app/code/community/Dotdigitalgroup/Email/controllers/CustomerController.php +38 -0
  152. app/code/community/Dotdigitalgroup/Email/controllers/EmailController.php +111 -0
  153. app/code/community/Dotdigitalgroup/Email/controllers/InvoiceController.php +71 -0
  154. app/code/community/Dotdigitalgroup/Email/controllers/OrderController.php +70 -0
  155. app/code/community/Dotdigitalgroup/Email/controllers/ProductsController.php +69 -0
  156. app/code/community/Dotdigitalgroup/Email/controllers/ReportController.php +63 -0
  157. app/code/community/Dotdigitalgroup/Email/controllers/ShippingController.php +79 -0
  158. app/code/community/Dotdigitalgroup/Email/etc/adminhtml.xml +148 -0
  159. app/code/community/Dotdigitalgroup/Email/etc/config.xml +482 -0
  160. app/code/community/Dotdigitalgroup/Email/etc/system.xml +2134 -0
  161. app/code/{local/Dotdigitalgroup/Email/sql/connector_setup → community/Dotdigitalgroup/Email/sql/email_connector_setup}/mysql4-install-0.1.0.php +4 -11
  162. app/code/community/Dotdigitalgroup/Email/sql/email_connector_setup/mysql4-install-3.0.0.php +307 -0
  163. app/code/{local/Dotdigitalgroup/Email/sql/connector_setup → community/Dotdigitalgroup/Email/sql/email_connector_setup}/mysql4-upgrade-1.1.1-1.1.2.php +0 -0
  164. app/code/community/Dotdigitalgroup/Email/sql/email_connector_setup/mysql4-upgrade-1.1.2-1.5.0.php +8 -0
  165. app/code/community/Dotdigitalgroup/Email/sql/email_connector_setup/mysql4-upgrade-1.5.0-2.0.0.php +75 -0
  166. app/code/community/Dotdigitalgroup/Email/sql/email_connector_setup/mysql4-upgrade-2.0.0-2.0.1.php +9 -0
  167. app/code/community/Dotdigitalgroup/Email/sql/email_connector_setup/mysql4-upgrade-2.0.1-2.0.2.php +52 -0
  168. app/code/community/Dotdigitalgroup/Email/sql/email_connector_setup/mysql4-upgrade-2.0.3-2.0.4.php +28 -0
  169. app/code/community/Dotdigitalgroup/Email/sql/email_connector_setup/mysql4-upgrade-2.0.4-2.0.5.php +9 -0
  170. app/code/community/Dotdigitalgroup/Email/sql/email_connector_setup/mysql4-upgrade-2.0.5-2.0.6.php +103 -0
  171. app/code/community/Dotdigitalgroup/Email/sql/email_connector_setup/mysql4-upgrade-3.0.1-3.0.2.php +18 -0
  172. app/code/community/Dotdigitalgroup/Email/sql/email_connector_setup/mysql4-upgrade-3.0.3-3.0.4.php +12 -0
  173. app/code/community/Dotdigitalgroup/Email/sql/email_connector_setup/mysql4-upgrade-3.0.4-3.0.5.php +121 -0
  174. app/code/local/Dotdigitalgroup/Email/Block/Adminhtml/System/Bestsellers.php +0 -18
  175. app/code/local/Dotdigitalgroup/Email/Block/Adminhtml/System/Config/Gridlist.php +0 -104
  176. app/code/local/Dotdigitalgroup/Email/Block/Adminhtml/System/Config/Insertvariable.php +0 -13
  177. app/code/local/Dotdigitalgroup/Email/Block/Adminhtml/System/Config/Messagedefault.php +0 -46
  178. app/code/local/Dotdigitalgroup/Email/Block/Adminhtml/System/Config/Smsmessagefour.php +0 -23
  179. app/code/local/Dotdigitalgroup/Email/Block/Adminhtml/System/Config/Smsmessagethree.php +0 -23
  180. app/code/local/Dotdigitalgroup/Email/Block/Adminhtml/System/Config/Smsmessagetwo.php +0 -23
  181. app/code/local/Dotdigitalgroup/Email/Block/Adminhtml/System/Config/Validator.php +0 -73
  182. app/code/local/Dotdigitalgroup/Email/Block/Adminhtml/System/Config/Waitingfield.php +0 -43
  183. app/code/local/Dotdigitalgroup/Email/Block/Adminhtml/System/Couponinfo.php +0 -18
  184. app/code/local/Dotdigitalgroup/Email/Block/Adminhtml/System/Crosssell.php +0 -20
  185. app/code/local/Dotdigitalgroup/Email/Block/Adminhtml/System/Lostbasket.php +0 -19
  186. app/code/local/Dotdigitalgroup/Email/Block/Adminhtml/System/Mostviewed.php +0 -18
  187. app/code/local/Dotdigitalgroup/Email/Block/Adminhtml/System/Productpush.php +0 -19
  188. app/code/local/Dotdigitalgroup/Email/Block/Adminhtml/System/Recentlyviewed.php +0 -20
  189. app/code/local/Dotdigitalgroup/Email/Block/Adminhtml/System/Related.php +0 -19
  190. app/code/local/Dotdigitalgroup/Email/Block/Adminhtml/System/Upsell.php +0 -19
  191. app/code/local/Dotdigitalgroup/Email/Block/Debug/Forcecustomersync.php +0 -21
  192. app/code/local/Dotdigitalgroup/Email/Block/Debug/Forcelostbasketsync.php +0 -21
  193. app/code/local/Dotdigitalgroup/Email/Block/Debug/Forcesuppressedsync.php +0 -21
  194. app/code/local/Dotdigitalgroup/Email/Block/Debug/Rescuenow.php +0 -21
  195. app/code/local/Dotdigitalgroup/Email/Block/Debug/Testcredentials.php +0 -21
  196. app/code/local/Dotdigitalgroup/Email/Block/Debug/Transactionalsync.php +0 -20
  197. app/code/local/Dotdigitalgroup/Email/Block/Products.php +0 -53
  198. app/code/local/Dotdigitalgroup/Email/Helper/Api/DotNetExample.php +0 -182
  199. app/code/local/Dotdigitalgroup/Email/Helper/Api/Restrequest.php +0 -298
  200. app/code/local/Dotdigitalgroup/Email/Helper/Data.php +0 -96
  201. app/code/local/Dotdigitalgroup/Email/Helper/Recommended.php +0 -191
  202. app/code/local/Dotdigitalgroup/Email/Model/Account/Test.php +0 -40
  203. app/code/local/Dotdigitalgroup/Email/Model/Api/Rest.php +0 -729
  204. app/code/local/Dotdigitalgroup/Email/Model/Connector/Customer.php +0 -286
  205. app/code/local/Dotdigitalgroup/Email/Model/Connector/Order.php +0 -118
  206. app/code/local/Dotdigitalgroup/Email/Model/Connector/Quote.php +0 -75
  207. app/code/local/Dotdigitalgroup/Email/Model/Connector/Wishlist.php +0 -86
  208. app/code/local/Dotdigitalgroup/Email/Model/Cron.php +0 -58
  209. app/code/local/Dotdigitalgroup/Email/Model/Customer/Customer.php +0 -480
  210. app/code/local/Dotdigitalgroup/Email/Model/Customer/Suppressed.php +0 -85
  211. app/code/local/Dotdigitalgroup/Email/Model/Dynamic/Product/Mapper.php +0 -90
  212. app/code/local/Dotdigitalgroup/Email/Model/Dynamic/Recommended.php +0 -228
  213. app/code/local/Dotdigitalgroup/Email/Model/Newsletter/Subscriber.php +0 -19
  214. app/code/local/Dotdigitalgroup/Email/Model/Observer.php +0 -189
  215. app/code/local/Dotdigitalgroup/Email/Model/Order.php +0 -33
  216. app/code/local/Dotdigitalgroup/Email/Model/Sales/Order.php +0 -96
  217. app/code/local/Dotdigitalgroup/Email/Model/Sales/Quote.php +0 -289
  218. app/code/local/Dotdigitalgroup/Email/Model/Sales/Sms.php +0 -70
  219. app/code/local/Dotdigitalgroup/Email/Model/System/Config/Backend/Syncschedule/Customer.php +0 -50
  220. app/code/local/Dotdigitalgroup/Email/Model/System/Config/Backend/Syncschedule/Suppressed.php +0 -54
  221. app/code/local/Dotdigitalgroup/Email/Model/System/Config/Source/Activebasket.php +0 -12
  222. app/code/local/Dotdigitalgroup/Email/Model/System/Config/Source/Addressbooks.php +0 -30
  223. app/code/local/Dotdigitalgroup/Email/Model/System/Config/Source/Campaigns.php +0 -30
  224. app/code/local/Dotdigitalgroup/Email/Model/System/Config/Source/Datafields.php +0 -35
  225. app/code/local/Dotdigitalgroup/Email/Model/System/Config/Source/Displayifnot.php +0 -12
  226. app/code/local/Dotdigitalgroup/Email/Model/System/Config/Source/Orderstatus.php +0 -16
  227. app/code/local/Dotdigitalgroup/Email/Model/System/Config/Source/Sendcampain.php +0 -30
  228. app/code/local/Dotdigitalgroup/Email/Model/System/Config/Source/Syncfrequency.php +0 -40
  229. app/code/local/Dotdigitalgroup/Email/Model/System/Config/Source/Timeperiod.php +0 -13
  230. app/code/local/Dotdigitalgroup/Email/Test/Model/Product.php +0 -18
  231. app/code/local/Dotdigitalgroup/Email/controllers/Adminhtml/DebugController.php +0 -125
  232. app/code/local/Dotdigitalgroup/Email/controllers/EmailController.php +0 -133
  233. app/code/local/Dotdigitalgroup/Email/etc/adminhtml.xml +0 -43
  234. app/code/local/Dotdigitalgroup/Email/etc/config.xml +0 -289
  235. app/code/local/Dotdigitalgroup/Email/etc/system.xml +0 -1610
  236. app/code/local/Varien/Data/Collection.php +0 -818
  237. app/design/adminhtml/default/default/layout/connector/email.xml +78 -0
  238. app/design/adminhtml/default/default/template/connector/dashboard/accountbar.phtml +10 -0
  239. app/design/adminhtml/default/default/template/connector/dashboard/content.phtml +8 -0
  240. app/design/adminhtml/default/default/template/connector/dashboard/switcher.phtml +24 -0
  241. app/design/adminhtml/default/default/template/connector/grid.phtml +16 -0
  242. app/design/adminhtml/default/default/template/connector/system/config/createdatafield.phtml +17 -0
  243. app/design/frontend/base/default/layout/connector.xml +4 -12
  244. app/design/frontend/base/default/template/connector/basket.phtml +1 -1
  245. app/design/frontend/base/default/template/connector/creditmemo/items.phtml +140 -0
  246. app/design/frontend/base/default/template/connector/creditmemo/new.phtml +77 -0
  247. app/design/frontend/base/default/template/connector/creditmemo/newguest.phtml +78 -0
  248. app/design/frontend/base/default/template/connector/creditmemo/update.phtml +31 -0
  249. app/design/frontend/base/default/template/connector/creditmemo/updateguest.phtml +31 -0
  250. app/design/frontend/base/default/template/connector/customer.phtml +23 -0
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Campaign.php ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dotdigitalgroup_Email_Block_Adminhtml_Campaign extends Mage_Adminhtml_Block_Widget_Grid_Container
4
+ {
5
+ /**
6
+ * Set the template.
7
+ */
8
+ public function __construct()
9
+ {
10
+ $this->_controller = 'adminhtml_campaign';
11
+ $this->_blockGroup = 'email_connector';
12
+ parent::__construct();
13
+ $this->_headerText = Mage::helper('connector')->__('Campaigns');
14
+ $this->_removeButton('add');
15
+
16
+ $this->setTemplate('connector/grid.phtml');
17
+ }
18
+ }
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Campaign/Edit.php ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dotdigitalgroup_Email_Block_Adminhtml_Campaign_Edit extends Mage_Adminhtml_Block_Widget_Form_Container
4
+ {
5
+ /**
6
+ * Construct.
7
+ */
8
+ public function __construct()
9
+ {
10
+ parent::__construct();
11
+ $this->_blockGroup = 'email_connector';
12
+ $this->_controller = 'adminhtml_campaign';
13
+ $this->_mode = 'edit';
14
+ $this->_updateButton('save', 'label', Mage::helper('connector')->__('Save Campaign'));
15
+ $this->_updateButton('delete', 'label', Mage::helper('connector')->__('Delete Campaign'));
16
+ $this->_addButton('saveandcontinue', array(
17
+ 'label' => Mage::helper('connector')->__('Save And Continue Edit'),
18
+ 'onclick' => 'saveAndContinueEdit()',
19
+ 'class' => 'save',
20
+ ), -100);
21
+ $this->_formScripts[] = "
22
+ function saveAndContinueEdit(){
23
+ editForm.submit($('edit_form').action+'back/edit/');
24
+ }";
25
+ }
26
+
27
+ /**
28
+ * Header text for the campaign.
29
+ * @return string
30
+ */
31
+ public function getHeaderText()
32
+ {
33
+ if ( Mage::registry('email_campaign') && Mage::registry('email_campaign')->getId() ) {
34
+ return Mage::helper('connector')->__("Edit Campaign '%s'", $this->htmlEscape(Mage::registry('email_campaign')->getContact()));
35
+ } else {
36
+ return Mage::helper('connector')->__('Add Contact');
37
+ }
38
+ }
39
+ }
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Campaign/Edit/Form.php ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dotdigitalgroup_Email_Block_Adminhtml_Campaign_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
4
+ {
5
+ /**
6
+ * Init class
7
+ */
8
+ public function __construct()
9
+ {
10
+ parent::__construct();
11
+
12
+ $this->setId('id');
13
+ $this->setTitle($this->__('Campaign Information'));
14
+ }
15
+
16
+ /**
17
+ * Setup form fields for inserts/updates
18
+ *
19
+ * return Mage_Adminhtml_Block_Widget_Form
20
+ */
21
+ protected function _prepareForm()
22
+ {
23
+ $model = Mage::registry('email_campaign');
24
+
25
+ $form = new Varien_Data_Form(array(
26
+ 'id' => 'edit_form',
27
+ 'action' => $this->getUrl('*/*/save', array('id' => $this->getRequest()->getParam('id'))),
28
+ 'method' => 'post')
29
+ );
30
+
31
+ $fieldset = $form->addFieldset('base_fieldset', array(
32
+ 'legend' => Mage::helper('connector')->__('Campaign Information')
33
+ ));
34
+
35
+ if ($model->getId()) {
36
+ $fieldset->addField('id', 'hidden', array(
37
+ 'name' => 'id',
38
+ ));
39
+ }
40
+
41
+ $fieldset->addField('name', 'text', array(
42
+ 'name' => 'name',
43
+ 'label' => Mage::helper('connector')->__('Name'),
44
+ 'title' => Mage::helper('connector')->__('Name'),
45
+ 'required' => true,
46
+ ));
47
+
48
+ $form->setValues($model->getData());
49
+ $form->setUseContainer(true);
50
+ $this->setForm($form);
51
+
52
+ return parent::_prepareForm();
53
+ }
54
+ }
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Campaign/Grid.php ADDED
@@ -0,0 +1,164 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dotdigitalgroup_Email_Block_Adminhtml_Campaign_Grid extends Mage_Adminhtml_Block_Widget_Grid
4
+ {
5
+ public function __construct()
6
+ {
7
+ parent::__construct();
8
+ $this->setId('id');
9
+ $this->setDefaultSort('entity_id');
10
+ $this->setDefaultDir('ASC');
11
+ $this->setSaveParametersInSession(true);
12
+ $this->setUseAjax(true);
13
+ }
14
+
15
+ /**
16
+ * Prepare grid collection object.
17
+ * @return Mage_Adminhtml_Block_Widget_Grid
18
+ */
19
+ protected function _prepareCollection()
20
+ {
21
+ $collection = Mage::getModel('email_connector/campaign')->getCollection();
22
+ $this->setCollection($collection);
23
+ $this->setDefaultSort('updated_at');
24
+ $this->setDefaultDir('DESC');
25
+ return parent::_prepareCollection();
26
+ }
27
+
28
+ protected function _prepareColumns()
29
+ {
30
+ $this->addColumn('id', array(
31
+ 'header' => Mage::helper('connector')->__('Campaign ID'),
32
+ 'width' => '20px',
33
+ 'index' => 'campaign_id',
34
+ 'type' => 'number',
35
+ 'truncate' => 50,
36
+ 'escape' => true,
37
+ ))->addColumn('email', array(
38
+ 'header' => Mage::helper('connector')->__('Email'),
39
+ 'align' => 'left',
40
+ 'width' => '50px',
41
+ 'index' => 'email',
42
+ 'type' => 'text',
43
+ 'escape' => true
44
+ ))->addColumn('is_sent', array(
45
+ 'header' => Mage::helper('connector')->__('Is Sent'),
46
+ 'align' => 'center',
47
+ 'width' => '20px',
48
+ 'index' => 'is_sent',
49
+ 'escape' => true,
50
+ 'type' => 'options',
51
+ 'renderer' => 'email_connector/adminhtml_column_renderer_imported',
52
+ 'options' => array(
53
+ '1' => 'Is Send',
54
+ 'null' => 'Not Send'
55
+ ),
56
+ 'filter_condition_callback' => array($this, 'filterCallbackContact')
57
+ ))->addColumn('order_increment_id', array(
58
+ 'header' => Mage::helper('connector')->__('Increment ID'),
59
+ 'align' => 'left',
60
+ 'width' => '50px',
61
+ 'index' => 'order_increment_id',
62
+ 'type' => 'number',
63
+ 'escape' => true
64
+ ))->addColumn('message', array(
65
+ 'header' => Mage::helper('connector')->__('Message'),
66
+ 'align' => 'left',
67
+ 'width' => '300px',
68
+ 'index' => 'message',
69
+ 'type' => 'text',
70
+ 'escape' => true
71
+ ))->addColumn('event_name', array(
72
+ 'header' => Mage::helper('connector')->__('Event Name'),
73
+ 'align' => 'left',
74
+ 'index' => 'event_name',
75
+ 'width' => '100px',
76
+ 'type' => 'string',
77
+ 'escape' => true,
78
+ ))->addColumn('created_at', array(
79
+ 'header' => Mage::helper('connector')->__('Created At'),
80
+ 'align' => 'center',
81
+ 'width' => '100px',
82
+ 'index' => 'created_at',
83
+ 'type' => 'datetime',
84
+ 'escape' => true
85
+ ))->addColumn('sent_at', array(
86
+ 'header' => Mage::helper('connector')->__('Sent At'),
87
+ 'align' => 'center',
88
+ 'width' => '100px',
89
+ 'index' => 'sent_at',
90
+ 'type' => 'datetime',
91
+ 'escape' => true
92
+ ));
93
+ if (!Mage::app()->isSingleStoreMode()) {
94
+ $this->addColumn('website_id', array(
95
+ 'header' => Mage::helper('customer')->__('Website'),
96
+ 'align' => 'center',
97
+ 'width' => '80px',
98
+ 'type' => 'options',
99
+ 'options' => Mage::getSingleton('adminhtml/system_store')->getWebsiteOptionHash(true),
100
+ 'index' => 'website_id',
101
+ ));
102
+ }
103
+
104
+ $this->addExportType('*/*/exportCsv', Mage::helper('connector')->__('CSV'));
105
+ return parent::_prepareColumns();
106
+ }
107
+
108
+ /**
109
+ * Get the store selected.
110
+ * @return Mage_Core_Model_Store
111
+ * @throws Exception
112
+ */
113
+ protected function _getStore()
114
+ {
115
+ $storeId = (int) $this->getRequest()->getParam('store', 0);
116
+ return Mage::app()->getStore($storeId);
117
+ }
118
+
119
+
120
+ /**
121
+ * @return $this|Mage_Adminhtml_Block_Widget_Grid
122
+ */
123
+ protected function _prepareMassaction()
124
+ {
125
+ $this->setMassactionIdField('id');
126
+ $this->getMassactionBlock()->setFormFieldName('campaign');
127
+ $this->getMassactionBlock()->addItem('delete', array (
128
+ 'label'=> Mage::helper('connector')->__('Delete'),
129
+ 'url' => $this->getUrl('*/*/massDelete'),
130
+ 'confirm' => Mage::helper('connector')->__('Are you sure?')
131
+ )
132
+ );
133
+
134
+ $this->getMassactionBlock()->addItem('resend', array('label'=>Mage::helper('connector')->__('Resend'),'url'=>$this->getUrl('*/*/massResend')));
135
+ return $this;
136
+ }
137
+
138
+ /**
139
+ * Grid selected url.
140
+ * @return string
141
+ */
142
+ public function getGridUrl()
143
+ {
144
+ return $this->getUrl('*/*/grid', array('_current'=>true));
145
+ }
146
+ /**
147
+ * Custom callback action for the campaign.
148
+ *
149
+ * @param $collection
150
+ * @param $column
151
+ */
152
+ public function filterCallbackContact($collection, $column)
153
+ {
154
+ $field = $column->getFilterIndex() ? $column->getFilterIndex() : $column->getIndex();
155
+ $value = $column->getFilter()->getValue();
156
+
157
+ if ($value == 'null') {
158
+ $collection->addFieldToFilter($field, array('null' => true) );
159
+ } else {
160
+ $collection->addFieldToFilter($field, array('notnull' => true));
161
+ }
162
+ }
163
+
164
+ }
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Column/Renderer/Imported.php ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dotdigitalgroup_Email_Block_Adminhtml_Column_Renderer_Imported extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
4
+ {
5
+ /**
6
+ * Render grid columns.
7
+ * @param Varien_Object $row
8
+ *
9
+ * @return string
10
+ */
11
+ public function render(Varien_Object $row)
12
+ {
13
+ return '<img style="padding-top:2px" '.(($this->_getValue($row)=='1' || $this->_getValue($row)==true) ? 'src="'.$this->getSkinUrl('images/success_msg_icon.gif').'" alt="YES" ' : 'src="'.
14
+ $this->getSkinUrl('images/error_msg_icon.gif').'" alt="NO" ').'>';
15
+ }
16
+ }
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Column/Renderer/Status.php ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dotdigitalgroup_Email_Block_Adminhtml_Column_Renderer_Status extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
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
+ if($this->getValue($row) == '1')
14
+ return 'Subscribed';
15
+ return 'Unsubscribed';
16
+ }
17
+
18
+ }
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Column/Renderer/Sync.php ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dotdigitalgroup_Email_Block_Adminhtml_Column_Renderer_Sync extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
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
+ return '<button title="Connect" type="button" style=""><span><span><span>Sync Now</span></span></span></button>';
14
+ }
15
+
16
+ }
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Config/Customdatafields.php ADDED
@@ -0,0 +1,112 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dotdigitalgroup_Email_Block_Adminhtml_Config_Customdatafields extends Mage_Adminhtml_Block_System_Config_Form_Field_Array_Abstract
4
+ {
5
+ /**
6
+ * Customer attribute
7
+ *
8
+ */
9
+ protected $_getAttributeRenderer;
10
+
11
+ /**
12
+ * Datafields
13
+ */
14
+ protected $_getDatafieldRenderer;
15
+
16
+
17
+ /**
18
+ * Construct.
19
+ */
20
+ public function __construct()
21
+ {
22
+ $this->_addAfter = false;
23
+ $this->_addButtonLabel = Mage::helper('adminhtml')->__('Add New Attribute');
24
+ parent::__construct();
25
+
26
+ }
27
+
28
+ protected function _prepareToRender()
29
+ {
30
+ $this->_getDatafieldRenderer = null;
31
+ $this->_getAttributeRenderer = null;
32
+ $this->addColumn('attribute',
33
+ array(
34
+ 'label' => Mage::helper('adminhtml')->__('Attribute'),
35
+ 'style' => 'width:120px',
36
+ )
37
+ );
38
+ $this->addColumn('datafield', array(
39
+ 'label' => Mage::helper('adminhtml')->__('DataField'),
40
+ 'style' => 'width:120px',
41
+ )
42
+ );
43
+ }
44
+
45
+ protected function _renderCellTemplate($columnName)
46
+ {
47
+ $inputName = $this->getElement()->getName() . '[#{_id}][' . $columnName . ']';
48
+ if ($columnName=="attribute") {
49
+ return $this->_getAttributeRenderer()
50
+ ->setName($inputName)
51
+ ->setTitle($columnName)
52
+ ->setExtraParams('style="width:160px"')
53
+ ->setOptions(
54
+ $this->getElement()->getValues()
55
+ )
56
+ ->toHtml();
57
+ } elseif ($columnName == "datafield") {
58
+ return $this->_getDatafieldRenderer()
59
+ ->setName($inputName)
60
+ ->setTitle($columnName)
61
+ ->setExtraParams('style="width:160px"')
62
+ ->setOptions(Mage::getModel('email_connector/adminhtml_source_datafields')->toOptionArray())
63
+ ->toHtml();
64
+ }
65
+ return parent::_renderCellTemplate($columnName);
66
+ }
67
+
68
+ /**
69
+ * Assign extra parameters to row
70
+ *
71
+ * @param Varien_Object $row
72
+ */
73
+ protected function _prepareArrayRow(Varien_Object $row)
74
+ {
75
+
76
+ $row->setData(
77
+ 'option_extra_attr_' . $this->_getAttributeRenderer()->calcOptionHash($row->getData('attribute')),
78
+ 'selected="selected"'
79
+ );
80
+
81
+ $row->setData(
82
+ 'option_extra_attr_' . $this->_getDatafieldRenderer()->calcOptionHash($row->getData('datafield')),
83
+ 'selected="selected"'
84
+ );
85
+ }
86
+ protected function _getAttributeRenderer()
87
+ {
88
+ if (!$this->_getAttributeRenderer) {
89
+ $this->_getAttributeRenderer = $this->getLayout()
90
+ ->createBlock('email_connector/adminhtml_config_select')
91
+ ->setIsRenderToJsTemplate(true);
92
+ }
93
+ return $this->_getAttributeRenderer;
94
+ }
95
+
96
+ protected function _getDatafieldRenderer()
97
+ {
98
+ if (!$this->_getDatafieldRenderer) {
99
+ $this->_getDatafieldRenderer = $this->getLayout()
100
+ ->createBlock('email_connector/adminhtml_config_select')
101
+ ->setIsRenderToJsTemplate(true);
102
+ }
103
+ return $this->_getDatafieldRenderer;
104
+ }
105
+
106
+ public function _toHtml()
107
+ {
108
+ return '<input type="hidden" id="'.$this->getElement()->getHtmlId().'"/>'.parent::_toHtml();
109
+
110
+ }
111
+
112
+ }
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Config/Select.php ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dotdigitalgroup_Email_Block_Adminhtml_Config_Select extends Mage_Core_Block_Html_Select
4
+ {
5
+ /**
6
+ * Return output in one line
7
+ *
8
+ * @return string
9
+ */
10
+ public function _toHtml()
11
+ {
12
+ return trim(preg_replace('/\s+/', ' ',parent::_toHtml()));
13
+ }
14
+ }
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Config/Template/Templatefields.php ADDED
@@ -0,0 +1,149 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dotdigitalgroup_Email_Block_Adminhtml_Config_Template_Templatefields extends Mage_Adminhtml_Block_System_Config_Form_Field_Array_Abstract
4
+ {
5
+ /**
6
+ * Templates
7
+ *
8
+ */
9
+ protected $_getTemplateRenderer;
10
+
11
+ /**
12
+ * Datafields
13
+ */
14
+ protected $_getDatafieldRenderer;
15
+
16
+ /**
17
+ * Send Type
18
+ */
19
+ protected $_getSendtypeRenderer;
20
+
21
+
22
+ /**
23
+ * Construct.
24
+ */
25
+ public function __construct()
26
+ {
27
+ $this->_addAfter = false;
28
+ $this->_addButtonLabel = Mage::helper('adminhtml')->__('Map Template');
29
+ parent::__construct();
30
+
31
+ }
32
+
33
+ protected function _prepareToRender()
34
+ {
35
+ $this->_getDatafieldRenderer = null;
36
+ $this->_getTemplateRenderer = null;
37
+ $this->_getSendtypeRenderer = null;
38
+ $this->addColumn('template',
39
+ array(
40
+ 'label' => Mage::helper('adminhtml')->__('Magento Template'),
41
+ 'style' => 'width:120px',
42
+ )
43
+ );
44
+ $this->addColumn('sendtype', array(
45
+ 'label' => Mage::helper('adminhtml')->__('Send Type'),
46
+ 'style' => 'width:120px',
47
+ )
48
+ );
49
+ $this->addColumn('datafield', array(
50
+ 'label' => Mage::helper('adminhtml')->__("Dotmailer Campaign Template <br> (Need For Design + Send)"),
51
+ 'style' => 'width:120px',
52
+ )
53
+ );
54
+ }
55
+
56
+ protected function _renderCellTemplate($columnName)
57
+ {
58
+ $inputName = $this->getElement()->getName() . '[#{_id}][' . $columnName . ']';
59
+ if ($columnName=="template") {
60
+ return $this->_getTemplateRenderer()
61
+ ->setName($inputName)
62
+ ->setTitle($columnName)
63
+ ->setExtraParams('style="width:160px"')
64
+ ->setOptions(
65
+ $this->getElement()->getValues()
66
+ )
67
+ ->toHtml();
68
+ } elseif ($columnName == "sendtype") {
69
+ return $this->_getSendtypeRenderer()
70
+ ->setName($inputName)
71
+ ->setTitle($columnName)
72
+ ->setExtraParams('style="width:160px"')
73
+ ->setOptions(Mage::getModel('email_connector/adminhtml_source_transactional_sendtype')->toOptionArray())
74
+ ->toHtml();
75
+ } elseif ($columnName == "datafield") {
76
+ return $this->_getDatafieldRenderer()
77
+ ->setName($inputName)
78
+ ->setTitle($columnName)
79
+ ->setExtraParams('style="width:160px"')
80
+ ->setOptions(Mage::getModel('email_connector/adminhtml_source_transactional_campaigns')->toOptionArray())
81
+ ->toHtml();
82
+ }
83
+ return parent::_renderCellTemplate($columnName);
84
+ }
85
+
86
+ /**
87
+ * Assign extra parameters to row
88
+ *
89
+ * @param Varien_Object $row
90
+ */
91
+ protected function _prepareArrayRow(Varien_Object $row)
92
+ {
93
+
94
+ $row->setData(
95
+ 'option_extra_attr_' . $this->_getTemplateRenderer()->calcOptionHash($row->getData('template')),
96
+ 'selected="selected"'
97
+ );
98
+
99
+ $row->setData(
100
+ 'option_extra_attr_' . $this->_getSendtypeRenderer()->calcOptionHash($row->getData('sendtype')),
101
+ 'selected="selected"'
102
+ );
103
+
104
+ $row->setData(
105
+ 'option_extra_attr_' . $this->_getDatafieldRenderer()->calcOptionHash($row->getData('datafield')),
106
+ 'selected="selected"'
107
+ );
108
+ }
109
+ protected function _getTemplateRenderer()
110
+ {
111
+ if (!$this->_getTemplateRenderer) {
112
+ $this->_getTemplateRenderer = $this->getLayout()
113
+ ->createBlock('email_connector/adminhtml_config_select')
114
+ ->setIsRenderToJsTemplate(true);
115
+ }
116
+ return $this->_getTemplateRenderer;
117
+ }
118
+
119
+ protected function _getDatafieldRenderer()
120
+ {
121
+ if (!$this->_getDatafieldRenderer) {
122
+ $this->_getDatafieldRenderer = $this->getLayout()
123
+ ->createBlock('email_connector/adminhtml_config_select')
124
+ ->setIsRenderToJsTemplate(true);
125
+ }
126
+ return $this->_getDatafieldRenderer;
127
+ }
128
+
129
+ protected function _getSendtypeRenderer()
130
+ {
131
+ if (!$this->_getSendtypeRenderer) {
132
+ $this->_getSendtypeRenderer = $this->getLayout()
133
+ ->createBlock('email_connector/adminhtml_config_select')
134
+ ->setIsRenderToJsTemplate(true);
135
+ }
136
+ return $this->_getSendtypeRenderer;
137
+ }
138
+ public function _toHtml()
139
+ {
140
+ if(count($this->getElement()->getValues())){
141
+ return '<input type="hidden" id="'.$this->getElement()->getHtmlId().'"/>'.parent::_toHtml();
142
+ }
143
+ else {
144
+ return "<p class='notice'>". Mage::helper('adminhtml')->__("There are no email templates to map.") . "</p>";
145
+ }
146
+
147
+ }
148
+
149
+ }
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Contact.php ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dotdigitalgroup_Email_Block_Adminhtml_Contact extends Mage_Adminhtml_Block_Widget_Grid_Container
4
+ {
5
+ /**
6
+ * Set the template.
7
+ */
8
+ public function __construct()
9
+ {
10
+ $this->_controller = 'adminhtml_contact';
11
+ $this->_blockGroup = 'email_connector';
12
+ parent::__construct();
13
+ $this->_headerText = Mage::helper('connector')->__('Contacts');
14
+ $this->_removeButton('add');
15
+
16
+ $this->setTemplate('connector/grid.phtml');
17
+ }
18
+ }
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Contact/Edit.php ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dotdigitalgroup_Email_Block_Adminhtml_Contact_Edit extends Mage_Adminhtml_Block_Widget_Form_Container
4
+ {
5
+ public function __construct()
6
+ {
7
+ parent::__construct();
8
+ $this->_blockGroup = 'email_connector';
9
+ $this->_controller = 'adminhtml_contact';
10
+ $this->_updateButton('save', 'label', Mage::helper('connector')->__('Save Contact'));
11
+ $this->_updateButton('delete', 'label', Mage::helper('connector')->__('Delete Contact'));
12
+ $this->_addButton('saveandcontinue', array(
13
+ 'label' => Mage::helper('connector')->__('Save And Continue Edit'),
14
+ 'onclick' => 'saveAndContinueEdit()',
15
+ 'class' => 'save',
16
+ ), -100);
17
+ $this->_formScripts[] = "
18
+ function saveAndContinueEdit(){
19
+ editForm.submit($('edit_form').action+'back/edit/');
20
+ }
21
+ ";
22
+ }
23
+
24
+ /**
25
+ * HEader text.
26
+ * @return string
27
+ */
28
+ public function getHeaderText()
29
+ {
30
+ if ( Mage::registry('contact_data') && Mage::registry('contact_data')->getId() ) {
31
+ return Mage::helper('connnector')->__("Edit Contact '%s'", $this->htmlEscape(Mage::registry('contact_data')->getContact()));
32
+ } else {
33
+ return Mage::helper('connector')->__('Add Contact');
34
+ }
35
+ }
36
+ }
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Contact/Edit/Form.php ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dotdigitalgroup_Email_Block_Adminhtml_Contact_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
4
+ {
5
+
6
+ /**
7
+ * Contact Form.
8
+ * @return Mage_Adminhtml_Block_Widget_Form
9
+ * @throws Exception
10
+ */
11
+ protected function _prepareForm()
12
+ {
13
+ $form = new Varien_Data_Form(array(
14
+ 'id' => 'edit_form',
15
+ 'action' => $this->getUrl('*/*/save', array('id' => $this->getRequest()->getParam('id'), 'store' => $this->getRequest()->getParam('store'))),
16
+ 'method' => 'post',
17
+ 'enctype' => 'multipart/form-data'
18
+ )
19
+ );
20
+ $form->setUseContainer(true);
21
+
22
+ $this->setForm($form);
23
+ return parent::_prepareForm();
24
+ }
25
+
26
+ }
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Contact/Grid.php ADDED
@@ -0,0 +1,207 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dotdigitalgroup_Email_Block_Adminhtml_Contact_Grid extends Mage_Adminhtml_Block_Widget_Grid
4
+ {
5
+ public function __construct()
6
+ {
7
+ parent::__construct();
8
+ $this->setId('email_contact_id');
9
+ $this->setDefaultSort('entity_id');
10
+ $this->setDefaultDir('ASC');
11
+ $this->setSaveParametersInSession(true);
12
+ $this->setUseAjax(true);
13
+ }
14
+
15
+ protected function _prepareCollection()
16
+ {
17
+ $collection = Mage::getModel('email_connector/contact')->getCollection();
18
+ $this->setCollection($collection);
19
+ $this->setDefaultSort('updated_at');
20
+ $this->setDefaultDir('DESC');
21
+ return parent::_prepareCollection();
22
+ }
23
+
24
+ protected function _prepareColumns()
25
+ {
26
+ $this->addColumn('email_contact_id', array(
27
+ 'header' => Mage::helper('connector')->__('Email Contact ID'),
28
+ 'width' => '20px',
29
+ 'index' => 'email_contact_id',
30
+ 'type' => 'number',
31
+ 'escape' => true,
32
+ ))->addColumn('email', array(
33
+ 'header' => Mage::helper('connector')->__('Email'),
34
+ 'align' => 'left',
35
+ 'width' => '50px',
36
+ 'index' => 'email',
37
+ 'type' => 'text',
38
+ 'escape' => true
39
+ ))->addColumn('is_guest', array(
40
+ 'header' => Mage::helper('connector')->__('Is Guest'),
41
+ 'align' => 'right',
42
+ 'width' => '50px',
43
+ 'index' => 'is_guest',
44
+ 'type' => 'options',
45
+ 'options' => array(
46
+ '1' => 'Guest',
47
+ 'null' => 'Not Guest'
48
+ ),
49
+ 'escape' => true,
50
+ 'filter_condition_callback' => array($this, 'filterCallbackContact')
51
+ ))->addColumn('customer_id', array(
52
+ 'header' => Mage::helper('connector')->__('Customer ID'),
53
+ 'align' => 'left',
54
+ 'width' => '20px',
55
+ 'index' => 'customer_id',
56
+ 'type' => 'number',
57
+ 'escape' => true
58
+ ))->addColumn('is_subscriber', array(
59
+ 'header' => Mage::helper('connector')->__('Is Subscriber'),
60
+ 'width' => '50px',
61
+ 'align' => 'right',
62
+ 'index' => 'is_subscriber',
63
+ 'type' => 'options',
64
+ 'options' => array(
65
+ '1' => 'Subscriber',
66
+ 'null' => 'Not Subscriber'
67
+ ),
68
+ 'filter_condition_callback' => array($this, 'filterCallbackContact'),
69
+ 'escape' => true,
70
+ ))->addColumn('subscriber_status', array(
71
+ 'header' => Mage::helper('connector')->__('Subscriber Status'),
72
+ 'align' => 'center',
73
+ 'width' => '50px',
74
+ 'index' => 'subscriber_status',
75
+ 'type' => 'options',
76
+ 'options' => array(
77
+ '1' => 'Subscribed',
78
+ '2' => 'Not Active',
79
+ '3' => 'Unsubscribed',
80
+ '4' => 'Unconfirmed'
81
+ ),
82
+ 'escape' => true,
83
+ ))->addColumn('email_imported', array(
84
+ 'header' => Mage::helper('connector')->__('Email Imported'),
85
+ 'width' => '20px',
86
+ 'align' => 'center',
87
+ 'index' => 'email_imported',
88
+ 'escape' => true,
89
+ 'type' => 'options',
90
+ 'options' => Mage::getModel('email_connector/adminhtml_source_contact_imported')->getOptions(),
91
+ 'renderer' => 'email_connector/adminhtml_column_renderer_imported',
92
+ 'filter_condition_callback' => array($this, 'filterCallbackContact')
93
+ ))->addColumn('subscriber_imported', array(
94
+ 'header' => Mage::helper('connector')->__('Subscriber Imported'),
95
+ 'width' => '20px',
96
+ 'align' => 'center',
97
+ 'index' => 'subscriber_imported',
98
+ 'type' => 'options',
99
+ 'escape' => true,
100
+ 'renderer' => 'email_connector/adminhtml_column_renderer_imported',
101
+ 'options' => Mage::getModel('email_connector/adminhtml_source_contact_imported')->getOptions(),
102
+ 'filter_condition_callback' => array($this, 'filterCallbackContact')
103
+ ))->addColumn('suppressed', array(
104
+ 'header' => Mage::helper('connector')->__('Suppressed'),
105
+ 'align' => 'right',
106
+ 'width' => '50px',
107
+ 'index' => 'suppressed',
108
+ 'escape' => true,
109
+ 'type' => 'options',
110
+ 'options' => array(
111
+ '1' => 'Suppressed',
112
+ 'null' => 'Not Suppressed'
113
+ ),
114
+ 'filter_condition_callback' => array($this, 'filterCallbackContact')
115
+ ));
116
+ if (!Mage::app()->isSingleStoreMode()) {
117
+ $this->addColumn('website_id', array(
118
+ 'header' => Mage::helper('customer')->__('Website'),
119
+ 'align' => 'center',
120
+ 'width' => '80px',
121
+ 'type' => 'options',
122
+ 'options' => Mage::getSingleton('adminhtml/system_store')->getWebsiteOptionHash(true),
123
+ 'index' => 'website_id',
124
+ ));
125
+ }
126
+
127
+ $this->addColumn('sync', array(
128
+ 'header' => Mage::helper('connector')->__('Sync Contact'),
129
+ 'align' => 'center',
130
+ 'width' => '80px',
131
+ 'renderer' => 'email_connector/adminhtml_column_renderer_sync'
132
+
133
+ ));
134
+
135
+ $this->addExportType('*/*/exportCsv', Mage::helper('connector')->__('CSV'));
136
+ return parent::_prepareColumns();
137
+ }
138
+
139
+ /**
140
+ * Get the store.
141
+ *
142
+ * @return Mage_Core_Model_Store
143
+ * @throws Exception
144
+ */
145
+ protected function _getStore()
146
+ {
147
+ $storeId = (int) $this->getRequest()->getParam('store', 0);
148
+ return Mage::app()->getStore($storeId);
149
+ }
150
+
151
+ /**
152
+ * Prepare the grid massaction.
153
+ * @return $this|Mage_Adminhtml_Block_Widget_Grid
154
+ */
155
+ protected function _prepareMassaction()
156
+ {
157
+ $this->setMassactionIdField('email_contact_id');
158
+ $this->getMassactionBlock()->setFormFieldName('contact');
159
+ $this->getMassactionBlock()->addItem('delete', array(
160
+ 'label'=> Mage::helper('connector')->__('Delete'),
161
+ 'url' => $this->getUrl('*/*/massDelete'),
162
+ 'confirm' => Mage::helper('connector')->__('Are you sure?')));
163
+ $this->getMassactionBlock()->addItem('resend', array(
164
+ 'label' => Mage::helper('connector')->__('Resend'),
165
+ 'url' => $this->getUrl('*/*/massResend'),
166
+
167
+ ));
168
+ return $this;
169
+ }
170
+
171
+ /**
172
+ * Custom callback action for the subscribers/contacts.
173
+ * @param $collection
174
+ * @param $column
175
+ */
176
+ public function filterCallbackContact($collection, $column)
177
+ {
178
+ $field = $column->getFilterIndex() ? $column->getFilterIndex() : $column->getIndex();
179
+ $value = $column->getFilter()->getValue();
180
+
181
+ if ($value == 'null')
182
+ $collection->addFieldToFilter($field, array('null' => true));
183
+ else
184
+ $collection->addFieldToFilter($field, array('notnull' => true));
185
+ }
186
+
187
+ /**
188
+ * Edit the row.
189
+ * @param $row
190
+ *
191
+ * @return string
192
+ */
193
+ public function getRowUrl($row)
194
+ {
195
+ return $this->getUrl('*/*/edit', array('id' => $row->getEmailContactId()));
196
+ }
197
+
198
+ /**
199
+ * Grid url.
200
+ * @return string
201
+ */
202
+ public function getGridUrl()
203
+ {
204
+ return $this->getUrl('*/*/grid', array('_current'=>true));
205
+ }
206
+
207
+ }
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Dashboard.php ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dotdigitalgroup_Email_Block_Adminhtml_Dashboard extends Mage_Adminhtml_Block_Dashboard_Bar
4
+
5
+ {
6
+ /**
7
+ * Set the template.
8
+ */
9
+ public function __construct()
10
+ {
11
+ parent::_construct();
12
+
13
+ $this->setTemplate('connector/dashboard/accountbar.phtml');
14
+ }
15
+
16
+ /**
17
+ * Prepare the layout.
18
+ *
19
+ * @return Mage_Core_Block_Abstract|void
20
+ * @throws Exception
21
+ */
22
+ protected function _prepareLayout()
23
+ {
24
+ $website = 0;
25
+ if ($store = $this->getRequest()->getParam('store')) {
26
+ $website = Mage::app()->getStore($store)->getWebsite();
27
+ } elseif ($this->getRequest()->getParam('website')) {
28
+ $website = $this->getRequest()->getParam('website');
29
+ }
30
+ $apiUsername = Mage::helper('connector')->getApiUsername($website);
31
+ $apiPassword = Mage::helper('connector')->getApiPassword($website);
32
+ $data = Mage::getModel('email_connector/apiconnector_client')
33
+ ->setApiUsername($apiUsername)
34
+ ->setApiPassword($apiPassword)
35
+ ->getAccountInfo();
36
+ foreach ($data->properties as $one) {
37
+ $this->addTotal($this->__($one->name), $one->value, true);
38
+ }
39
+ }
40
+
41
+ }
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Dashboard/Content.php ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dotdigitalgroup_Email_Block_Adminhtml_Dashboard_Content extends Mage_Adminhtml_Block_Widget_Container
4
+ {
5
+ public function __construct()
6
+ {
7
+ parent::_construct();
8
+ $this->_headerText = Mage::helper('connector')->__('Account Managment.');
9
+
10
+ }
11
+ }
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Order.php ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dotdigitalgroup_Email_Block_Adminhtml_Order extends Mage_Adminhtml_Block_Widget_Grid_Container
4
+ {
5
+ public function __construct()
6
+ {
7
+ parent::__construct();
8
+
9
+ $this->_blockGroup = 'email_connector';
10
+ $this->_controller = 'adminhtml_order';
11
+ $this->_headerText = Mage::helper('connector')->__('Email Order(s)');
12
+
13
+ $this->_removeButton('add');
14
+ }
15
+ }
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Order/Grid.php ADDED
@@ -0,0 +1,103 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dotdigitalgroup_Email_Block_Adminhtml_Order_Grid extends Mage_Adminhtml_Block_Widget_Grid
4
+ {
5
+ public function __construct()
6
+ {
7
+ parent::__construct();
8
+
9
+ // Set some defaults for our grid
10
+ $this->setDefaultSort('email_order_id');
11
+ $this->setId('email_order_id');
12
+ $this->setDefaultDir('asc');
13
+ }
14
+
15
+ /**
16
+ * Collection class;
17
+ * @return string
18
+ */
19
+ protected function _getCollectionClass()
20
+ {
21
+ // This is the model we are using for the grid
22
+ return 'email_connector/order_collection';
23
+ }
24
+
25
+ /**
26
+ * Prepare the grid collection.
27
+ * @return Mage_Adminhtml_Block_Widget_Grid
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
+ * Prepare the grid collumns.
39
+ * @return $this
40
+ * @throws Exception
41
+ */
42
+ protected function _prepareColumns()
43
+ {
44
+ $this->addColumn('order_id', array(
45
+ 'header' => Mage::helper('connector')->__('Order ID'),
46
+ 'align' => 'left',
47
+ 'width' => '50px',
48
+ 'index' => 'order_id',
49
+ 'type' => 'number',
50
+ 'escape' => true
51
+ ))->addColumn('order_status', array(
52
+ 'header' => Mage::helper('connector')->__('Order Status'),
53
+ 'align' => 'right',
54
+ 'width' => '50px',
55
+ 'index' => 'order_status',
56
+ 'type' => 'options',
57
+ 'escape' => true,
58
+ 'options' => Mage::getSingleton('sales/order_config')->getStatuses(),
59
+ ))->addColumn('store_id', array(
60
+ 'header' => Mage::helper('connector')->__('Store ID'),
61
+ 'width' => '50px',
62
+ 'index' => 'store_id',
63
+ 'type' => 'number',
64
+ 'escape' => true,
65
+ ))->addColumn('email_imported', array(
66
+ 'header' => Mage::helper('connector')->__('Email Imported'),
67
+ 'align' => 'center',
68
+ 'width' => '50px',
69
+ 'index' => 'email_imported',
70
+ 'type' => 'options',
71
+ 'escape' => true,
72
+ 'renderer' => 'email_connector/adminhtml_column_renderer_imported',
73
+ 'options' => Mage::getModel('email_connector/adminhtml_source_contact_imported')->getOptions(),
74
+ 'filter_condition_callback' => array($this, 'filterCallbackContact')
75
+ ))->addColumn('updated_at', array(
76
+ 'header' => Mage::helper('connector')->__('Updated At'),
77
+ 'width' => '50px',
78
+ 'align' => 'center',
79
+ 'index' => 'updated_at',
80
+ 'type' => 'datetime',
81
+ 'escape' => true,
82
+ ));
83
+
84
+ return parent::_prepareColumns();
85
+ }
86
+
87
+ /**
88
+ * Callback action for the imported subscribers/contacts.
89
+ *
90
+ * @param $collection
91
+ * @param $column
92
+ */
93
+ public function filterCallbackContact($collection, $column)
94
+ {
95
+ $field = $column->getFilterIndex() ? $column->getFilterIndex() : $column->getIndex();
96
+ $value = $column->getFilter()->getValue();
97
+ if ($value == 'null') {
98
+ $collection->addFieldToFilter($field, array('null' => true));
99
+ } else {
100
+ $collection->addFieldToFilter($field, array('notnull' => true));
101
+ }
102
+ }
103
+ }
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Sales/Order/Creditmemo/View.php ADDED
@@ -0,0 +1,196 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Dotdigitalgroup_Email_Block_Adminhtml_Sales_Order_Creditmemo_View extends Mage_Adminhtml_Block_Widget_Form_Container
3
+ {
4
+
5
+ public function __construct()
6
+ {
7
+ $this->_objectId = 'creditmemo_id';
8
+ $this->_controller = 'sales_order_creditmemo';
9
+ $this->_mode = 'view';
10
+
11
+ parent::__construct();
12
+
13
+ $this->_removeButton('save');
14
+ $this->_removeButton('reset');
15
+ $this->_removeButton('delete');
16
+
17
+ if ($this->getCreditmemo()->canCancel()) {
18
+ $this->_addButton('cancel', array(
19
+ 'label' => Mage::helper('sales')->__('Cancel'),
20
+ 'class' => 'delete',
21
+ 'onclick' => 'setLocation(\''.$this->getCancelUrl().'\')'
22
+ )
23
+ );
24
+ }
25
+
26
+ if ($this->_isAllowedAction('emails')) {
27
+ $this->addButton('send_notification', array(
28
+ 'label' => Mage::helper('sales')->__('Send Email'),
29
+ 'onclick' => 'confirmSetLocation(\''
30
+ . Mage::helper('sales')->__('Are you sure you want to send Creditmemo email to customer?')
31
+ . '\', \'' . $this->getEmailUrl() . '\')'
32
+ ));
33
+ }
34
+
35
+ if ($this->getCreditmemo()->canRefund()) {
36
+ $this->_addButton('refund', array(
37
+ 'label' => Mage::helper('sales')->__('Refund'),
38
+ 'class' => 'save',
39
+ 'onclick' => 'setLocation(\''.$this->getRefundUrl().'\')'
40
+ )
41
+ );
42
+ }
43
+
44
+ if ($this->getCreditmemo()->canVoid()) {
45
+ $this->_addButton('void', array(
46
+ 'label' => Mage::helper('sales')->__('Void'),
47
+ 'class' => 'save',
48
+ 'onclick' => 'setLocation(\''.$this->getVoidUrl().'\')'
49
+ )
50
+ );
51
+ }
52
+
53
+ if ($this->getCreditmemo()->getId()) {
54
+ $this->_addButton('print', array(
55
+ 'label' => Mage::helper('sales')->__('Print'),
56
+ 'class' => 'save',
57
+ 'onclick' => 'setLocation(\''.$this->getPrintUrl().'\')'
58
+ )
59
+ );
60
+ }
61
+ }
62
+
63
+ /**
64
+ * Retrieve creditmemo model instance
65
+ *
66
+ * @return Mage_Sales_Model_Order_Creditmemo
67
+ */
68
+ public function getCreditmemo()
69
+ {
70
+ return Mage::registry('current_creditmemo');
71
+ }
72
+
73
+ /**
74
+ * Retrieve text for header
75
+ *
76
+ * @return string
77
+ */
78
+ public function getHeaderText()
79
+ {
80
+ if ($this->getCreditmemo()->getEmailSent()) {
81
+ $emailSent = Mage::helper('sales')->__('the credit memo email was sent');
82
+ }
83
+ else {
84
+ $emailSent = Mage::helper('sales')->__('the credit memo email is not sent');
85
+ }
86
+ return Mage::helper('sales')->__('Credit Memo #%1$s | %3$s | %2$s (%4$s)', $this->getCreditmemo()->getIncrementId(), $this->formatDate($this->getCreditmemo()->getCreatedAtDate(), 'medium', true), $this->getCreditmemo()->getStateName(), $emailSent);
87
+ }
88
+
89
+ /**
90
+ * Retrieve back url
91
+ *
92
+ * @return string
93
+ */
94
+ public function getBackUrl()
95
+ {
96
+ return $this->getUrl(
97
+ '*/sales_order/view',
98
+ array(
99
+ 'order_id' => $this->getCreditmemo()->getOrderId(),
100
+ 'active_tab'=> 'order_creditmemos'
101
+ ));
102
+ }
103
+
104
+ /**
105
+ * Retrieve capture url
106
+ *
107
+ * @return string
108
+ */
109
+ public function getCaptureUrl()
110
+ {
111
+ return $this->getUrl('*/*/capture', array('creditmemo_id'=>$this->getCreditmemo()->getId()));
112
+ }
113
+
114
+ /**
115
+ * Retrieve void url
116
+ *
117
+ * @return string
118
+ */
119
+ public function getVoidUrl()
120
+ {
121
+ return $this->getUrl('*/*/void', array('creditmemo_id'=>$this->getCreditmemo()->getId()));
122
+ }
123
+
124
+ /**
125
+ * Retrieve cancel url
126
+ *
127
+ * @return string
128
+ */
129
+ public function getCancelUrl()
130
+ {
131
+ return $this->getUrl('*/*/cancel', array('creditmemo_id'=>$this->getCreditmemo()->getId()));
132
+ }
133
+
134
+ /**
135
+ * Retrieve email url
136
+ *
137
+ * @return string
138
+ */
139
+ public function getEmailUrl()
140
+ {
141
+ return $this->getUrl('*/*/email', array(
142
+ 'creditmemo_id' => $this->getCreditmemo()->getId(),
143
+ 'order_id' => $this->getCreditmemo()->getOrderId()
144
+ ));
145
+ }
146
+
147
+ /**
148
+ * Retrieve print url
149
+ *
150
+ * @return string
151
+ */
152
+ public function getPrintUrl()
153
+ {
154
+ return $this->getUrl('*/*/print', array(
155
+ 'creditmemo_id' => $this->getCreditmemo()->getId()
156
+ ));
157
+ }
158
+
159
+ /**
160
+ * Update 'back' button url.
161
+ *
162
+ * @param $flag
163
+ *
164
+ * @return $this|Mage_Adminhtml_Block_Widget_Container
165
+ */
166
+ public function updateBackButtonUrl($flag)
167
+ {
168
+ if ($flag) {
169
+ if ($this->getCreditmemo()->getBackUrl()) {
170
+ return $this->_updateButton(
171
+ 'back',
172
+ 'onclick',
173
+ 'setLocation(\'' . $this->getCreditmemo()->getBackUrl() . '\')'
174
+ );
175
+ }
176
+
177
+ return $this->_updateButton(
178
+ 'back',
179
+ 'onclick',
180
+ 'setLocation(\'' . $this->getUrl('*/sales_creditmemo/') . '\')'
181
+ );
182
+ }
183
+ return $this;
184
+ }
185
+
186
+ /**
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('sales/order/actions/' . $action);
195
+ }
196
+ }
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Advanced/Deletecontactids.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dotdigitalgroup_Email_Block_Adminhtml_System_Advanced_Deletecontactids extends Mage_Adminhtml_Block_System_Config_Form_Field
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("*/connector/deletecontactids");
15
+
16
+ return $this->getLayout()->createBlock('adminhtml/widget_button')
17
+ ->setType('button')
18
+ ->setLabel($this->__($title))
19
+ ->setOnClick("window.location.href='" . $url . "'")
20
+ ->toHtml();
21
+ }
22
+ }
app/code/{local/Dotdigitalgroup/Email/Block/Debug/Countcontacts.php → community/Dotdigitalgroup/Email/Block/Adminhtml/System/Advanced/Reimportorders.php} RENAMED
@@ -1,15 +1,16 @@
1
  <?php
2
-
3
- class Dotdigitalgroup_Email_Block_Debug_Countcontacts extends Mage_Adminhtml_Block_System_Config_Form_Field
4
  {
5
 
6
- protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element) {
 
7
  $this->setElement($element);
8
- return $this->_getAddRowButtonHtml($this->__('Check Customers Now'));
9
  }
10
 
11
- protected function _getAddRowButtonHtml($title) {
12
- $url = Mage::helper('adminhtml')->getUrl("connector/debug/countcontacts");
 
13
 
14
  return $this->getLayout()->createBlock('adminhtml/widget_button')
15
  ->setType('button')
1
  <?php
2
+ class Dotdigitalgroup_Email_Block_Adminhtml_System_Advanced_Reimportorders extends Mage_Adminhtml_Block_System_Config_Form_Field
 
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
 
11
+ protected function _getAddRowButtonHtml($title)
12
+ {
13
+ $url = $this->getUrl("*/connector/resetorders");
14
 
15
  return $this->getLayout()->createBlock('adminhtml/widget_button')
16
  ->setType('button')
app/code/{local/Dotdigitalgroup/Email/Block/Debug/Deletecontacts.php → community/Dotdigitalgroup/Email/Block/Adminhtml/System/Advanced/Reimportsubscribers.php} RENAMED
@@ -1,15 +1,16 @@
1
  <?php
2
-
3
- class Dotdigitalgroup_Email_Block_Debug_Deletecontacts extends Mage_Adminhtml_Block_System_Config_Form_Field
4
  {
5
 
6
- protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element) {
 
7
  $this->setElement($element);
8
- return $this->_getAddRowButtonHtml($this->__("Delete ID's Now"));
9
  }
10
 
11
- protected function _getAddRowButtonHtml($title) {
12
- $url = Mage::helper('adminhtml')->getUrl("connector/debug/deletecontactsid");
 
13
 
14
  return $this->getLayout()->createBlock('adminhtml/widget_button')
15
  ->setType('button')
1
  <?php
2
+ class Dotdigitalgroup_Email_Block_Adminhtml_System_Advanced_Reimportsubscribers extends Mage_Adminhtml_Block_System_Config_Form_Field
 
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
 
11
+ protected function _getAddRowButtonHtml($title)
12
+ {
13
+ $url = $this->getUrl("*/connector/reimoprtsubscribers");
14
 
15
  return $this->getLayout()->createBlock('adminhtml/widget_button')
16
  ->setType('button')
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Advanced/Setupdatafields.php ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dotdigitalgroup_Email_Block_Adminhtml_System_Advanced_Setupdatafields extends Mage_Adminhtml_Block_System_Config_Form_Field
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
+ $website = $this->getRequest()->getParam('website', 0);
15
+ $url = $this->getUrl("*/connector/setupdatafields/website/" . $website );
16
+
17
+ return $this->getLayout()->createBlock('adminhtml/widget_button')
18
+ ->setType('button')
19
+ ->setLabel($this->__($title))
20
+ ->setOnClick("window.location.href='" . $url . "'")
21
+ ->toHtml();
22
+ }
23
+
24
+ }
app/code/{local/Dotdigitalgroup/Email/Block/Debug/Initialsync.php → community/Dotdigitalgroup/Email/Block/Adminhtml/System/Advanced/Suppressedcontacts.php} RENAMED
@@ -1,14 +1,17 @@
1
  <?php
2
 
3
- class Dotdigitalgroup_Email_Block_Debug_Initialsync extends Mage_Adminhtml_Block_System_Config_Form_Field
4
  {
5
- protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element) {
 
 
6
  $this->setElement($element);
7
- return $this->_getAddRowButtonHtml($this->__('Run Initialisation Synchronization'));
8
  }
9
 
10
- protected function _getAddRowButtonHtml($title) {
11
- $url = Mage::helper('adminhtml')->getUrl("connector/debug/initialSync");
 
12
 
13
  return $this->getLayout()->createBlock('adminhtml/widget_button')
14
  ->setType('button')
1
  <?php
2
 
3
+ class Dotdigitalgroup_Email_Block_Adminhtml_System_Advanced_Suppressedcontacts extends Mage_Adminhtml_Block_System_Config_Form_Field
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 = $this->getUrl("*/connector/suppresscontacts");
15
 
16
  return $this->getLayout()->createBlock('adminhtml/widget_button')
17
  ->setType('button')
app/code/{local/Dotdigitalgroup/Email/Block/Adminhtml/System/Config/Password.php → community/Dotdigitalgroup/Email/Block/Adminhtml/System/Ajaxvalidate.php} RENAMED
@@ -1,6 +1,6 @@
1
  <?php
2
 
3
- class Dotdigitalgroup_Email_Block_Adminhtml_System_Config_Password extends Mage_Adminhtml_Block_System_Config_Form_Field
4
  {
5
  public function _getElementHtml(Varien_Data_Form_Element_Abstract$element){
6
 
1
  <?php
2
 
3
+ class Dotdigitalgroup_Email_Block_Adminhtml_System_Ajaxvalidate extends Mage_Adminhtml_Block_System_Config_Form_Field
4
  {
5
  public function _getElementHtml(Varien_Data_Form_Element_Abstract$element){
6
 
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Automation/Connect.php ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dotdigitalgroup_Email_Block_Adminhtml_System_Automation_Connect extends Mage_Adminhtml_Block_System_Config_Form_Field
4
+ {
5
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
6
+ {
7
+ $this->setElement($element);
8
+ return $this->_getAddRowButtonHtml();
9
+ }
10
+
11
+ protected function _getAddRowButtonHtml()
12
+ {
13
+ $url = Mage::helper('connector')->getAuthoriseUrl();
14
+ $ssl = $this->_checkForSecureUrl();
15
+ $disabled = false;
16
+ if (!$ssl) {
17
+ $disabled = true;
18
+ //Mage::getSingleton('adminhtml/session')->addNotice('Cannot Use the Authorization For Non SSL Server!');
19
+
20
+ }
21
+
22
+ $adminUser = Mage::getSingleton('admin/session')->getUser();
23
+ $refreshToken = $adminUser->getRefreshToken();
24
+ $title = ($refreshToken)? $this->__('Disconnect') : $this->__('Connect');
25
+ $url = ($refreshToken)? $this->getUrl('*/email_automation/disconnect') : $url;
26
+
27
+ return $this->getLayout()->createBlock('adminhtml/widget_button')
28
+ ->setType('button')
29
+ ->setLabel($this->__($title))
30
+ ->setDisabled($disabled)
31
+ ->setOnClick("window.location.href='" . $url . "'")
32
+ ->toHtml();
33
+ }
34
+
35
+ private function _checkForSecureUrl()
36
+ {
37
+ $baseUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB, true);
38
+ if (!preg_match('/https/',$baseUrl)) {
39
+ return false;
40
+ }
41
+ return $this;
42
+ }
43
+ }
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Config/Addressbook.php ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dotdigitalgroup_Email_Block_Adminhtml_System_Config_Addressbook extends Mage_Adminhtml_Block_System_Config_Form_Field
4
+ {
5
+
6
+ /**
7
+ * Ajax Create the addressbooks.
8
+ * @param Varien_Data_Form_Element_Abstract $element
9
+ *
10
+ * @return string
11
+ */
12
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
13
+ {
14
+ $url = Mage::helper('adminhtml')->getUrl('*/connector/createnewaddressbook');
15
+ $website = Mage::app()->getRequest()->getParam('website', 0);
16
+
17
+ $element->setData('after_element_html',
18
+ "<script>
19
+ function createAddressbook(form, element) {
20
+ var name = $('connector_sync_settings_dynamic_addressbook_addressbook_name').value;
21
+ var reloadurl = '{$url}';
22
+ if(name){
23
+ new Ajax.Request(reloadurl, {
24
+ method: 'post',
25
+ parameters: {'name' : name, 'website': '$website'},
26
+ onComplete: function(transport) {
27
+ window.location.reload();
28
+ }
29
+ });
30
+ }
31
+ return false;
32
+ }
33
+ </script>"
34
+ );
35
+
36
+ return parent::_getElementHtml($element);
37
+ }
38
+ }
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Config/Datafield.php ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dotdigitalgroup_Email_Block_Adminhtml_System_Config_Datafield extends Mage_Adminhtml_Block_System_Config_Form_Field
4
+ {
5
+
6
+ /**
7
+ * Ajax Create the datafields.
8
+ * @param Varien_Data_Form_Element_Abstract $element
9
+ *
10
+ * @return string
11
+ */
12
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
13
+ {
14
+ $url = Mage::helper('adminhtml')->getUrl('*/connector/createnewdatafield');
15
+ $website = Mage::app()->getRequest()->getParam('website', 0);
16
+
17
+ $element->setData('after_element_html',
18
+ "<script>
19
+ function createDatafield(form, element) {
20
+ var datafield_name = $('connector_data_mapping_dynamic_datafield_datafield_name').value;
21
+ var datafield_type = $('connector_data_mapping_dynamic_datafield_datafield_type').value;
22
+ var reloadurl = '{$url}';
23
+
24
+ if(datafield_name && datafield_type){
25
+ new Ajax.Request(reloadurl, {
26
+ method: 'post',
27
+ parameters: {'name' : datafield_name, 'type' : datafield_type, 'website': '$website'},
28
+ onComplete: function(transport) {
29
+ window.location.reload();
30
+ }
31
+ });
32
+ }
33
+ return false;
34
+ }
35
+ </script>"
36
+ );
37
+
38
+ return parent::_getElementHtml($element);
39
+ }
40
+ }
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Config/Validator.php ADDED
@@ -0,0 +1,87 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+
4
+ class Dotdigitalgroup_Email_Block_Adminhtml_System_Config_Validator extends Mage_Adminhtml_Block_System_Config_Form_Field
5
+ {
6
+
7
+ /**
8
+ * Ajax Validate the duplicate selection.
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
+ // 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 = '<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js" ></script>';
21
+
22
+ $html .=$jquery;
23
+ $javaScript = "<script type=\"text/javascript\"> var show_warning = 0;";
24
+
25
+ if(!Mage::helper('connector')->isSweetToothEnabled()){
26
+ $javaScript .= "show_warning = 1;";
27
+ }
28
+
29
+ $javaScript .=
30
+ "jQuery.noConflict();
31
+
32
+ jQuery(document).ready(function() {
33
+ // Handler for .ready() called.
34
+
35
+ //Show sweet tooth notice
36
+ if(show_warning == 1) jQuery('#sweet-tooth-warning').show();
37
+
38
+ // Hide our validation block
39
+ jQuery('#row_connector_data_mapping_customer_data_validator').hide();
40
+
41
+ // Add listener for changing select box
42
+
43
+ jQuery('#connector_data_mapping_customer_data select').on('change', function() {
44
+ var currentSelection = jQuery(this).val();
45
+ var currentDropdownId = jQuery(this).attr('id');
46
+ check(currentSelection, currentDropdownId);
47
+ });
48
+
49
+ jQuery('#connector_data_mapping_sweet_tooth select').on('change', function() {
50
+ var currentSelection = jQuery(this).val();
51
+ var currentDropdownId = jQuery(this).attr('id');
52
+ check(currentSelection, currentDropdownId);
53
+ });
54
+
55
+ function check(currentSelection, currentDropdownId){
56
+ // foreach of the select fields on our mapping page:
57
+ jQuery('select').each(function(){
58
+ var thisId = jQuery(this).attr('id');
59
+ if (thisId != currentDropdownId) {
60
+
61
+ var currentLabel = jQuery('label[for=\\'' + thisId + '\\']').text();
62
+ var thisVal = jQuery(this).val();
63
+
64
+ switch (thisVal) {
65
+ case '0':
66
+ // ignore DO NOT MAP fields
67
+ break;
68
+ case currentSelection:
69
+ // warning, that field is already mapped somewhere else - reset that value to 'Do not map''
70
+ alert('Warning! You have overwritten: '+currentLabel);
71
+ jQuery(this).val(0);
72
+ break;
73
+ default:
74
+ break;
75
+ break;
76
+ }
77
+ }
78
+ });
79
+ }
80
+ });
81
+ </script>";
82
+
83
+ $html .= $javaScript;
84
+ return $html;
85
+ }
86
+
87
+ }
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Config/Waitingfield.php ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ }
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Config/Wrapper.php ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ }
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Dynamic/Addressbookbutton.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dotdigitalgroup_Email_Block_Adminhtml_System_Dynamic_Addressbookbutton extends Mage_Adminhtml_Block_System_Config_Form_Field
4
+ {
5
+
6
+ protected function _getAddRowButtonHtml($title)
7
+ {
8
+ return $this->getLayout()->createBlock('adminhtml/widget_button')
9
+ ->setType('button')
10
+ ->setLabel($this->__($title))
11
+ ->setOnClick("createAddressbook(this.form, this);")
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($this->__($originalData['button_label']));
21
+ }
22
+ }
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Dynamic/Bestsellers.php ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dotdigitalgroup_Email_Block_Adminhtml_System_Dynamic_Bestsellers extends Mage_Adminhtml_Block_System_Config_Form_Field
4
+ {
5
+ /** label */
6
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
7
+ {
8
+ $baseUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
9
+ $website = Mage::app()->getRequest()->getParam('website', false);
10
+
11
+ if ($website) {
12
+ $website = Mage::app()->getWebsite($website);
13
+ $baseUrl = $website->getConfig('web/secure/base_url');
14
+ }
15
+ $passcode = Mage::helper('connector')->getPasscode();
16
+
17
+ if(!strlen($passcode)) $passcode = '[PLEASE SET UP A PASSCODE]';
18
+
19
+ $text = sprintf('%sconnector/report/bestsellers/code/%s', $baseUrl, $passcode);
20
+ $element->setData('value', $text);
21
+ $element->setData('disabled', 'disabled');
22
+
23
+ return parent::_getElementHtml($element);
24
+ }
25
+ }
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Dynamic/Couponinfo.php ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dotdigitalgroup_Email_Block_Adminhtml_System_Dynamic_Couponinfo extends Mage_Adminhtml_Block_System_Config_Form_Field
4
+ {
5
+ /** label */
6
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
7
+ {
8
+ $baseUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
9
+ $website = Mage::app()->getRequest()->getParam('website', false);
10
+
11
+ if ($website) {
12
+ $website = Mage::app()->getWebsite($website);
13
+ $baseUrl = $website->getConfig('web/secure/base_url');
14
+ }
15
+
16
+
17
+ $code = Mage::helper('connector')->getPasscode();
18
+ if(!strlen($code))
19
+ $code = '[PLEASE SET UP A PASSCODE]';
20
+ $text = $baseUrl . 'connector/email/coupon/id/[INSERT ID HERE]/code/'. $code;
21
+
22
+ $element->setData('value', $text);
23
+ $element->setData('disabled', 'disabled');
24
+ return parent::_getElementHtml($element);
25
+ }
26
+
27
+ }
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Dynamic/Creditmemonew.php ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dotdigitalgroup_Email_Block_Adminhtml_System_Dynamic_Creditmemonew extends Mage_Adminhtml_Block_System_Config_Form_Field
4
+ {
5
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
6
+ {
7
+
8
+ $baseUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
9
+ $website = Mage::app()->getRequest()->getParam('website', false);
10
+
11
+ if ($website) {
12
+ $website = Mage::app()->getWebsite($website);
13
+ $baseUrl = $website->getConfig('web/secure/base_url');
14
+ }
15
+ $helper = Mage::helper('connector');
16
+ $code = $helper->getPasscode();
17
+ $orderId = $helper->getMappedOrderId();
18
+
19
+ if(!strlen($code))
20
+ $code = '[PLEASE SET UP A PASSCODE]';
21
+ $text = sprintf('%s/connector/creditmemo/new/code/%s/id/@%s@', $baseUrl, $code, $orderId);
22
+
23
+ $element->setData('value', $text);
24
+
25
+ return parent::_getElementHtml($element);
26
+ }
27
+
28
+ }
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Dynamic/Crosssell.php ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dotdigitalgroup_Email_Block_Adminhtml_System_Dynamic_Crosssell extends Mage_Adminhtml_Block_System_Config_Form_Field
4
+ {
5
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
6
+ {
7
+ $baseUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
8
+ $website = Mage::app()->getRequest()->getParam('website', false);
9
+
10
+ if ($website) {
11
+ $website = Mage::app()->getWebsite($website);
12
+ $baseUrl = $website->getConfig('web/secure/base_url');
13
+ }
14
+ $passcode = Mage::helper('connector')->getPasscode();
15
+ $lastOrderId = Mage::helper('connector')->getLastOrderId();
16
+
17
+ if(!strlen($passcode)) $passcode = '[PLEASE SET UP A PASSCODE]';
18
+ if(!$lastOrderId) $lastOrderId = '[PLEASE MAP THE LAST ORDER ID]';
19
+
20
+
21
+ $text = sprintf('%sconnector/products/crosssell/code/%s/order_id/@%s@', $baseUrl, $passcode, $lastOrderId);
22
+ $element->setData('value', $text);
23
+
24
+ return parent::_getElementHtml($element);
25
+ }
26
+ }
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Dynamic/Datafieldbutton.php ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dotdigitalgroup_Email_Block_Adminhtml_System_Dynamic_Datafieldbutton extends Mage_Adminhtml_Block_System_Config_Form_Field
4
+ {
5
+ protected function _getAddRowButtonHtml($title)
6
+ {
7
+ return $this->getLayout()->createBlock('adminhtml/widget_button')
8
+ ->setType('button')
9
+ ->setLabel($this->__($title))
10
+ ->setOnClick("createDatafield(this.form, this);")
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($this->__($originalData['button_label']));
20
+ }
21
+ }
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Dynamic/Gridlist.php ADDED
@@ -0,0 +1,106 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dotdigitalgroup_Email_Block_Adminhtml_System_Dynamic_Gridlist extends Mage_Adminhtml_Block_System_Config_Form_Field
4
+ {
5
+ /**
6
+ * Dynamic contaent dysplay type.
7
+ *
8
+ * @param Varien_Data_Form_Element_Abstract $element
9
+ *
10
+ * @return string
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 = '<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js" ></script>';
19
+
20
+ $jQuery .=
21
+ '<script type="text/javascript">
22
+ jQuery.noConflict();
23
+ jQuery(document).ready(function() {
24
+ var gridOptions = {
25
+ "4" : "4",
26
+ "8" : "8",
27
+ "12" : "12",
28
+ "16" : "16",
29
+ "20" : "20",
30
+ "24" : "24",
31
+ "28" : "28",
32
+ "32" : "32"
33
+
34
+ };
35
+ var listOptions = {
36
+ "2" : "2",
37
+ "4" : "4",
38
+ "6" : "6",
39
+ "8" : "8"
40
+ }
41
+
42
+ jQuery("#connector_dynamic_content_products_related_display_type").change(function(){
43
+ var display_type = jQuery(this).closest("tr").next().find("select");
44
+ var display_mode = jQuery(this).val();
45
+ changeOptions(display_type, display_mode);
46
+ });
47
+
48
+ jQuery("#connector_dynamic_content_products_upsell_display_type").change(function(){
49
+ var display_type = jQuery(this).closest("tr").next().find("select");
50
+ var display_mode = jQuery(this).val();
51
+ changeOptions(display_type, display_mode);
52
+
53
+ });
54
+ jQuery("#connector_dynamic_content_products_crosssell_display_type").change(function(){
55
+ var display_type = jQuery(this).closest("tr").next().find("select");
56
+ var display_mode = jQuery(this).val();
57
+ changeOptions(display_type, display_mode);
58
+ });
59
+ jQuery("#connector_dynamic_content_products_bestsellers_display_type").change(function(){
60
+ var display_type = jQuery(this).closest("tr").next().find("select");
61
+ var display_mode = jQuery(this).val();
62
+ changeOptions(display_type, display_mode);
63
+ });
64
+ jQuery("#connector_dynamic_content_products_most_viewed_display_type").change(function(){
65
+ var display_type = jQuery(this).closest("tr").next().find("select");
66
+ var display_mode = jQuery(this).val();
67
+ changeOptions(display_type, display_mode);
68
+ });
69
+ jQuery("#connector_dynamic_content_products_recently_viewed_display_type").change(function(){
70
+ var display_type = jQuery(this).closest("tr").next().find("select");
71
+ var display_mode = jQuery(this).val();
72
+ changeOptions(display_type, display_mode);
73
+ });
74
+ jQuery("#connector_dynamic_content_manual_product_search_display_type").change(function(){
75
+ var display_type = jQuery(this).closest("tr").next().find("select");
76
+ var display_mode = jQuery(this).val();
77
+ changeOptions(display_type, display_mode);
78
+ });
79
+ function changeOptions(display_type, display_mode){
80
+ if(display_mode == "list"){
81
+ display_type.empty();
82
+
83
+ jQuery.each(listOptions, function(key, value) {
84
+ display_type.append(jQuery("<option></option>")
85
+ .attr("value", value).text(key));
86
+ });
87
+
88
+ }
89
+ if(display_mode == "grid"){
90
+ display_type.empty();
91
+ jQuery.each(gridOptions, function(key, value) {
92
+ display_type.append(jQuery("<option></option>")
93
+ .attr("value", value).text(key));
94
+ });
95
+ }
96
+ }
97
+ });
98
+ </script>';
99
+
100
+ $html .= $jQuery;
101
+
102
+ return $html;
103
+ }
104
+
105
+
106
+ }
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Dynamic/Lostbasket.php ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dotdigitalgroup_Email_Block_Adminhtml_System_Dynamic_Lostbasket extends Mage_Adminhtml_Block_System_Config_Form_Field
4
+ {
5
+
6
+ /** label */
7
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
8
+ {
9
+ $baseUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
10
+ $website = Mage::app()->getRequest()->getParam('website', false);
11
+
12
+ if ($website) {
13
+ $website = Mage::app()->getWebsite($website);
14
+ $baseUrl = $website->getConfig('web/secure/base_url');
15
+ }
16
+ $code = Mage::helper('connector')->getPasscode();
17
+ if(!strlen($code))
18
+ $code = '[PLEASE SET UP A PASSCODE]';
19
+ $text = $baseUrl . 'connector/email/basket/email/@EMAIL@/code/'. $code;
20
+
21
+ $element->setData('value', $text);
22
+ return parent::_getElementHtml($element);
23
+ }
24
+
25
+ }
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Dynamic/Mostviewed.php ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dotdigitalgroup_Email_Block_Adminhtml_System_Dynamic_Mostviewed extends Mage_Adminhtml_Block_System_Config_Form_Field
4
+ {
5
+ /** label */
6
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
7
+ {
8
+ $baseUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
9
+ $website = Mage::app()->getRequest()->getParam('website', false);
10
+
11
+ if ($website) {
12
+ $website = Mage::app()->getWebsite($website);
13
+ $baseUrl = $website->getConfig('web/secure/base_url');
14
+ }
15
+ $passcode = Mage::helper('connector')->getPasscode();
16
+
17
+ if(!strlen($passcode)) $passcode = '[PLEASE SET UP A PASSCODE]';
18
+
19
+ $text = sprintf('%sconnector/report/mostviewed/code/%s', $baseUrl, $passcode);
20
+ $element->setData('value', $text);
21
+
22
+ return parent::_getElementHtml($element);
23
+ }
24
+ }
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Dynamic/Productpush.php ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dotdigitalgroup_Email_Block_Adminhtml_System_Dynamic_Productpush extends Mage_Adminhtml_Block_System_Config_Form_Field
4
+ {
5
+ /** label */
6
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
7
+ {
8
+ $baseUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
9
+ $website = Mage::app()->getRequest()->getParam('website', false);
10
+
11
+ if ($website) {
12
+ $website = Mage::app()->getWebsite($website);
13
+ $baseUrl = $website->getConfig('web/secure/base_url');
14
+ }
15
+ $passcode = Mage::helper('connector')->getPasscode();
16
+
17
+ if(!strlen($passcode)) $passcode = '[PLEASE SET UP A PASSCODE]';
18
+
19
+ $text = sprintf('%sconnector/products/push/code/%s', $baseUrl, $passcode);
20
+ $element->setData('value', $text);
21
+
22
+ return parent::_getElementHtml($element);
23
+ }
24
+ }
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Dynamic/Recentlyviewed.php ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Dotdigitalgroup_Email_Block_Adminhtml_System_Dynamic_Recentlyviewed extends Mage_Adminhtml_Block_System_Config_Form_Field
3
+ {
4
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
5
+ {
6
+ $baseUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
7
+ $website = Mage::app()->getRequest()->getParam('website', false);
8
+
9
+ if ($website) {
10
+ $website = Mage::app()->getWebsite($website);
11
+ $baseUrl = $website->getConfig('web/secure/base_url');
12
+ }
13
+ $passcode = Mage::helper('connector')->getPasscode();
14
+ $customerId = Mage::helper('connector')->getMappedCustomerId();
15
+
16
+ if(!strlen($passcode)) $passcode = '[PLEASE SET UP A PASSCODE]';
17
+ if(!$customerId) $customerId = '[PLEASE MAP THE CUSTOMER ID]';
18
+ $text = sprintf('%sconnector/report/recentlyviewed/code/%s/customer_id/@%s@', $baseUrl, $passcode, $customerId);
19
+ $element->setData('value', $text);
20
+
21
+ return parent::_getElementHtml($element);
22
+
23
+ }
24
+ }
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Dynamic/Related.php ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dotdigitalgroup_Email_Block_Adminhtml_System_Dynamic_Related extends Mage_Adminhtml_Block_System_Config_Form_Field
4
+ {
5
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
6
+ {
7
+ $baseUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
8
+ $website = Mage::app()->getRequest()->getParam('website', false);
9
+
10
+ if ($website) {
11
+ $website = Mage::app()->getWebsite($website);
12
+ $baseUrl = $website->getConfig('web/secure/base_url');
13
+ }
14
+ $passcode = Mage::helper('connector')->getPasscode();
15
+ $lastOrderId = Mage::helper('connector')->getLastOrderId();
16
+
17
+ if(!strlen($passcode)) $passcode = '[PLEASE SET UP A PASSCODE]';
18
+ if(!$lastOrderId) $lastOrderId = '[PLEASE MAP THE LAST ORDER ID]';
19
+
20
+ $text = sprintf('%sconnector/products/related/code/%s/order_id/@%s@', $baseUrl, $passcode, $lastOrderId);
21
+ $element->setData('value', $text);
22
+
23
+ return parent::_getElementHtml($element);
24
+
25
+ }
26
+ }
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Dynamic/Upsell.php ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Dotdigitalgroup_Email_Block_Adminhtml_System_Dynamic_Upsell extends Mage_Adminhtml_Block_System_Config_Form_Field
3
+ {
4
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
5
+ {
6
+ $baseUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
7
+ $website = Mage::app()->getRequest()->getParam('website', false);
8
+
9
+ if ($website) {
10
+ $website = Mage::app()->getWebsite($website);
11
+ $baseUrl = $website->getConfig('web/secure/base_url');
12
+ }
13
+ $passcode = Mage::helper('connector')->getPasscode();
14
+ $lastOrderid = Mage::helper('connector')->getLastOrderId();
15
+
16
+ if(!strlen($passcode)) $passcode = '[PLEASE SET UP A PASSCODE]';
17
+ if(!$lastOrderid) $lastOrderid = '[PLEASE MAP THE LAST ORDER ID]';
18
+
19
+ $text = sprintf('%sconnector/products/upsell/code/%s/order_id/@%s@', $baseUrl, $passcode, $lastOrderid);
20
+ $element->setData('value', $text);
21
+
22
+ return parent::_getElementHtml($element);
23
+ }
24
+ }
app/code/{local/Dotdigitalgroup/Email/Block/Adminhtml/System/Config/Wrapper.php → community/Dotdigitalgroup/Email/Block/Adminhtml/System/Emailapivalidate.php} RENAMED
@@ -1,12 +1,14 @@
1
  <?php
2
 
3
- class Dotdigitalgroup_Email_Block_Adminhtml_System_Config_Wrapper extends Mage_Adminhtml_Block_System_Config_Form_Field
4
  {
5
 
6
  protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
7
  {
8
  $element->setData('onchange', "apiValidation(this.form, this);");
9
 
 
 
10
  $element->setData('after_element_html', "
11
  <script>
12
  document.observe('dom:loaded', function(){
@@ -14,17 +16,16 @@ class Dotdigitalgroup_Email_Block_Adminhtml_System_Config_Wrapper extends Mage_A
14
 
15
  });
16
  function apiValidation(form, element) {
17
- var api_user = $('connector_api_settings_api_credentials_username');
18
- var api_password = $('connector_api_settings_api_credentials_password');
19
-
20
- var reloadurl = '{$this->getUrl('connector/debug/ajaxvalidation')}';
21
-
22
  new Ajax.Request(reloadurl, {
23
  method: 'post',
24
- parameters: {'api_user' : api_user.value, 'api_password' : api_password.value},
25
  onComplete: function(transport) {
26
  Element.hide('loadingmask');
27
- if(transport.responseText == '\"Valid\"'){
28
  api_user.setStyle({
29
  fontWeight: 'bold',
30
  color: 'green' ,
1
  <?php
2
 
3
+ class Dotdigitalgroup_Email_Block_Adminhtml_System_Emailapivalidate extends Mage_Adminhtml_Block_System_Config_Form_Field
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('after_element_html', "
13
  <script>
14
  document.observe('dom:loaded', function(){
16
 
17
  });
18
  function apiValidation(form, element) {
19
+ var api_user = $('connector_transactional_emails_credentials_api_username');
20
+ var api_password = $('connector_transactional_emails_credentials_api_password');
21
+ var reloadurl = '{$url}';
22
+ var encoded = btoa(api_password.value);
 
23
  new Ajax.Request(reloadurl, {
24
  method: 'post',
25
+ parameters: {'api_username' : api_user.value, 'api_password' : encoded},
26
  onComplete: function(transport) {
27
  Element.hide('loadingmask');
28
+ if(transport.responseText == '\"Credentials Valid.\"'){
29
  api_user.setStyle({
30
  fontWeight: 'bold',
31
  color: 'green' ,
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Sms/Smsmessagefour.php ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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_sms_sms_four_message', '{{var order_number}}');return false;\">Insert Order Number</a>
18
+ <a href='#' onclick=\"injectText('connector_sms_sms_four_message', '{{var customer_name}}');return false;\">Insert Customer Name</a>"
19
+ );
20
+ return parent::_getElementHtml($element);
21
+ }
22
+
23
+
24
+ }
app/code/{local/Dotdigitalgroup/Email/Block/Adminhtml/System/Config → community/Dotdigitalgroup/Email/Block/Adminhtml/System/Sms}/Smsmessageone.php RENAMED
@@ -1,18 +1,23 @@
1
  <?php
2
 
3
- class Dotdigitalgroup_Email_Block_Adminhtml_System_Config_Smsmessageone extends Mage_Adminhtml_Block_System_Config_Form_Field
4
  {
5
  const DEFAULT_TEXT = 'Default SMS Text';
6
 
7
- protected function _getElementHtml(Varien_Data_Form_Element_Abstract$element){
8
-
9
-
 
 
 
 
 
 
10
  $element->setData('placeholder', self::DEFAULT_TEXT);
 
11
 
12
- $element->setData('after_element_html', "
13
-
14
- <a href='#' onclick=\"injectText('sms_section_sms_message_one_message', '{{var order_number}}');return false;\">Insert Order Number</a>
15
- <a href='#' onclick=\"injectText('sms_section_sms_message_one_message', '{{var customer_name}}');return false;\">Insert Customer Name</a>
16
 
17
  <script type='text/javascript'>
18
  function injectText(element,value){
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_sms_sms_one_message', '{{var order_number}}');return false;\">Insert Order Number</a>
20
+ <a href='#' onclick=\"injectText('connector_sms_sms_one_message', '{{var customer_name}}');return false;\">Insert Customer Name</a>
 
 
21
 
22
  <script type='text/javascript'>
23
  function injectText(element,value){
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Sms/Smsmessagethree.php ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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_sms_sms_three_message', '{{var order_number}}');return false;\">Insert Order Number</a>
20
+ <a href='#' onclick=\"injectText('connector_sms_sms_three_message', '{{var customer_name}}');return false;\">Insert Customer Name</a>"
21
+ );
22
+ return parent::_getElementHtml($element);
23
+ }
24
+
25
+
26
+ }
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Sms/Smsmessagetwo.php ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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_sms_sms_two_message', '{{var order_number}}');return false;\">Insert Order Number</a>
19
+ <a href='#' onclick=\"injectText('connector_sms_sms_two_message', '{{var customer_name}}');return false;\">Insert Customer Name</a>"
20
+ );
21
+ return parent::_getElementHtml($element);
22
+ }
23
+
24
+
25
+ }
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Url/Creditmemoupdate.php ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Dotdigitalgroup_Email_Block_Adminhtml_System_Url_Creditmemoupdate extends Mage_Adminhtml_Block_System_Config_Form_Field
3
+ {
4
+ /**
5
+ * Generate the urls.
6
+ * @param Varien_Data_Form_Element_Abstract $element
7
+ *
8
+ * @return string
9
+ * @throws Mage_Core_Exception
10
+ */
11
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
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 = $website->getConfig('web/secure/base_url');
19
+ }
20
+ $helper = Mage::helper('connector');
21
+ $passcode = $helper->getWebsiteConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_DYNAMIC_CONTENT_PASSCODE, $website);
22
+ $orderId = $helper->getWebsiteConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_MAPPING_LAST_ORDER_ID, $website);
23
+
24
+ if(!strlen($passcode)) $passcode = '[PLEASE SET UP A PASSCODE]';
25
+
26
+ $text = sprintf('%sconnector/creditmemo/update/code/%s/order_id/@%s@', $baseUrl, $passcode, $orderId);
27
+
28
+ $element->setData('value', $text);
29
+
30
+ return parent::_getElementHtml($element);
31
+ }
32
+ }
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Url/Creditmemoupdateguest.php ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Dotdigitalgroup_Email_Block_Adminhtml_System_Url_Creditmemoupdateguest extends Mage_Adminhtml_Block_System_Config_Form_Field
3
+ {
4
+ /**
5
+ * Generate the urls.
6
+ * @param Varien_Data_Form_Element_Abstract $element
7
+ *
8
+ * @return string
9
+ * @throws Mage_Core_Exception
10
+ */
11
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
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 = $website->getConfig('web/secure/base_url');
19
+ }
20
+ $helper = Mage::helper('connector');
21
+ $passcode = $helper->getWebsiteConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_DYNAMIC_CONTENT_PASSCODE, $website);
22
+ $orderId = $helper->getWebsiteConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_MAPPING_LAST_ORDER_ID, $website);
23
+ if(!strlen($passcode)) $passcode = '[PLEASE SET UP A PASSCODE]';
24
+
25
+ $text = sprintf('%sconnector/creditmemo/updateguest/code/%s/order_id/@%s@', $baseUrl, $passcode, $orderId);
26
+ $element->setData('value', $text);
27
+
28
+ return parent::_getElementHtml($element);
29
+ }
30
+ }
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Url/Customerconfirmation.php ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dotdigitalgroup_Email_Block_Adminhtml_System_Url_Customerconfirmation extends Mage_Adminhtml_Block_System_Config_Form_Field
4
+ {
5
+
6
+ /**
7
+ * Generate the urls.
8
+ *
9
+ * @param Varien_Data_Form_Element_Abstract $element
10
+ *
11
+ * @return string
12
+ * @throws Mage_Core_Exception
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 = $website->getConfig('web/secure/base_url');
22
+ }
23
+ $helper = Mage::helper('connector');
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('%sconnector/customer/confirmation/code/%s/customer_id/@%s@', $baseUrl, $passcode, $customerId);
30
+ $element->setData('value', $text);
31
+
32
+ return parent::_getElementHtml($element);
33
+ }
34
+
35
+
36
+ }
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Url/Customerconfirmed.php ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dotdigitalgroup_Email_Block_Adminhtml_System_Url_Customerconfirmed extends Mage_Adminhtml_Block_System_Config_Form_Field
4
+ {
5
+
6
+ /**
7
+ * Generate the urls.
8
+ *
9
+ * @param Varien_Data_Form_Element_Abstract $element
10
+ *
11
+ * @return string
12
+ * @throws Mage_Core_Exception
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 = $website->getConfig('web/secure/base_url');
22
+ }
23
+ $helper = Mage::helper('connector');
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('%sconnector/customer/confirmed/code/%s/customer_id/@%s@', $baseUrl, $passcode, $customerId);
30
+ $element->setData('value', $text);
31
+
32
+ return parent::_getElementHtml($element);
33
+ }
34
+
35
+
36
+ }
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Url/Customernew.php ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dotdigitalgroup_Email_Block_Adminhtml_System_Url_Customernew extends Mage_Adminhtml_Block_System_Config_Form_Field
4
+ {
5
+
6
+ /**
7
+ * Generate the urls.
8
+ *
9
+ * @param Varien_Data_Form_Element_Abstract $element
10
+ *
11
+ * @return string
12
+ * @throws Mage_Core_Exception
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 = $website->getConfig('web/secure/base_url');
22
+ }
23
+ $helper = Mage::helper('connector');
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('%sconnector/customer/new/code/%s/customer_id/@%s@', $baseUrl, $passcode, $customerId);
30
+ $element->setData('value', $text);
31
+
32
+ return parent::_getElementHtml($element);
33
+ }
34
+
35
+
36
+ }
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Url/Invoiceupdate.php ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dotdigitalgroup_Email_Block_Adminhtml_System_Url_Invoiceupdate extends Mage_Adminhtml_Block_System_Config_Form_Field
4
+ {
5
+ /**
6
+ * Generate the urls.
7
+ *
8
+ * @param Varien_Data_Form_Element_Abstract $element
9
+ *
10
+ * @return string
11
+ * @throws Mage_Core_Exception
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 = $website->getConfig('web/secure/base_url');
21
+ }
22
+ $helper = Mage::helper('connector');
23
+ $passcode = $helper->getWebsiteConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_DYNAMIC_CONTENT_PASSCODE, $website);
24
+ $orderId = $helper->getWebsiteConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_MAPPING_LAST_ORDER_ID, $website);
25
+
26
+ if(!strlen($passcode)) $passcode = '[PLEASE SET UP A PASSCODE]';
27
+
28
+ $text = sprintf('%sconnector/invoice/update/code/%s/order_id/@%s@', $baseUrl, $passcode, $orderId);
29
+ $element->setData('value', $text);
30
+
31
+ return parent::_getElementHtml($element);
32
+ }
33
+ }
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Url/Invoiceupdateguest.php ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dotdigitalgroup_Email_Block_Adminhtml_System_Url_Invoiceupdateguest extends Mage_Adminhtml_Block_System_Config_Form_Field
4
+ {
5
+ /**
6
+ * Generate the urls.
7
+ *
8
+ * @param Varien_Data_Form_Element_Abstract $element
9
+ *
10
+ * @return string
11
+ * @throws Mage_Core_Exception
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 = $website->getConfig('web/secure/base_url');
21
+ }
22
+ $helper = Mage::helper('connector');
23
+ $passcode = $helper->getWebsiteConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_DYNAMIC_CONTENT_PASSCODE, $website);
24
+ $orderId = $helper->getWebsiteConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_MAPPING_LAST_ORDER_ID, $website);
25
+
26
+ if(!strlen($passcode)) $passcode = '[PLEASE SET UP A PASSCODE]';
27
+
28
+ $text = sprintf('%sconnector/invoice/updateguest/code/%s/order_id/@%s@', $baseUrl, $passcode, $orderId);
29
+ $element->setData('value', $text);
30
+
31
+ return parent::_getElementHtml($element);
32
+ }
33
+ }
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Url/Newcreditmemo.php ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dotdigitalgroup_Email_Block_Adminhtml_System_Url_Newcreditmemo extends Mage_Adminhtml_Block_System_Config_Form_Field
4
+ {
5
+ /**
6
+ * Generate the urls.
7
+ *
8
+ * @param Varien_Data_Form_Element_Abstract $element
9
+ *
10
+ * @return string
11
+ * @throws Mage_Core_Exception
12
+ */
13
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
14
+ {
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 = $website->getConfig('web/secure/base_url');
22
+ }
23
+ $helper = Mage::helper('connector');
24
+ $passcode = $helper->getWebsiteConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_DYNAMIC_CONTENT_PASSCODE, $website);
25
+ $orderId = $helper->getWebsiteConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_MAPPING_LAST_ORDER_ID, $website);
26
+
27
+
28
+ if(!strlen($passcode)) $passcode = '[PLEASE SET UP A PASSCODE]';
29
+
30
+ $text = sprintf('%sconnector/creditmemo/new/code/%s/order_id/@%s@', $baseUrl, $passcode, $orderId);
31
+ $element->setData('value', $text);
32
+
33
+ return parent::_getElementHtml($element);
34
+ }
35
+
36
+ }
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Url/Newcreditmemoguest.php ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dotdigitalgroup_Email_Block_Adminhtml_System_Url_Newcreditmemoguest extends Mage_Adminhtml_Block_System_Config_Form_Field
4
+ {
5
+ /**
6
+ * Generate the urls.
7
+ *
8
+ * @param Varien_Data_Form_Element_Abstract $element
9
+ *
10
+ * @return string
11
+ * @throws Mage_Core_Exception
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 = $website->getConfig('web/secure/base_url');
21
+ }
22
+ $helper = Mage::helper('connector');
23
+ $passcode = $helper->getWebsiteConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_DYNAMIC_CONTENT_PASSCODE, $website);
24
+ $orderId = $helper->getWebsiteConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_MAPPING_LAST_ORDER_ID, $website);
25
+
26
+
27
+ if(!strlen($passcode)) $passcode = '[PLEASE SET UP A PASSCODE]';
28
+
29
+ $text = sprintf('%sconnector/creditmemo/newguest/code/%s/order_id/@%s@', $baseUrl, $passcode, $orderId);
30
+ $element->setData('value', $text);
31
+
32
+ return parent::_getElementHtml($element);
33
+ }
34
+
35
+ }
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Url/Newinvoice.php ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dotdigitalgroup_Email_Block_Adminhtml_System_Url_Newinvoice extends Mage_Adminhtml_Block_System_Config_Form_Field
4
+ {
5
+ /**
6
+ * Generate the urls.
7
+ *
8
+ * @param Varien_Data_Form_Element_Abstract $element
9
+ *
10
+ * @return string
11
+ * @throws Mage_Core_Exception
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 = $website->getConfig('web/secure/base_url');
21
+ }
22
+ $helper = Mage::helper('connector');
23
+ $passcode = $helper->getWebsiteConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_DYNAMIC_CONTENT_PASSCODE, $website);
24
+ $orderId = $helper->getWebsiteConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_MAPPING_LAST_ORDER_ID, $website);
25
+
26
+
27
+ if(!strlen($passcode)) $passcode = '[PLEASE SET UP A PASSCODE]';
28
+
29
+ $text = sprintf('%sconnector/invoice/new/code/%s/order_id/@%s@', $baseUrl, $passcode, $orderId);
30
+ $element->setData('value', $text);
31
+
32
+ return parent::_getElementHtml($element);
33
+ }
34
+ }
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Url/Newinvoiceguest.php ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dotdigitalgroup_Email_Block_Adminhtml_System_Url_Newinvoiceguest extends Mage_Adminhtml_Block_System_Config_Form_Field
4
+ {
5
+ /**
6
+ * Generate the urls.
7
+ *
8
+ * @param Varien_Data_Form_Element_Abstract $element
9
+ *
10
+ * @return string
11
+ * @throws Mage_Core_Exception
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 = $website->getConfig('web/secure/base_url');
21
+ }
22
+ $helper = Mage::helper('connector');
23
+ $passcode = $helper->getWebsiteConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_DYNAMIC_CONTENT_PASSCODE, $website);
24
+ $orderId = $helper->getWebsiteConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_MAPPING_LAST_ORDER_ID, $website);
25
+
26
+
27
+ if(!strlen($passcode)) $passcode = '[PLEASE SET UP A PASSCODE]';
28
+
29
+ $text = sprintf('%sconnector/invoice/newguest/code/%s/order_id/@%s@', $baseUrl, $passcode, $orderId);
30
+ $element->setData('value', $text);
31
+
32
+ return parent::_getElementHtml($element);
33
+ }
34
+ }
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Url/Neworder.php ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Dotdigitalgroup_Email_Block_Adminhtml_System_Url_Neworder extends Mage_Adminhtml_Block_System_Config_Form_Field
3
+ {
4
+ /**
5
+ * Generate the urls.
6
+ *
7
+ * @param Varien_Data_Form_Element_Abstract $element
8
+ *
9
+ * @return string
10
+ * @throws Mage_Core_Exception
11
+ */
12
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
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 = $website->getConfig('web/secure/base_url');
20
+ }
21
+ $helper = Mage::helper('connector');
22
+ $passcode = $helper->getWebsiteConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_DYNAMIC_CONTENT_PASSCODE, $website);
23
+ $orderId = $helper->getWebsiteConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_MAPPING_LAST_ORDER_ID, $website);
24
+
25
+
26
+ if(!strlen($passcode)) $passcode = '[PLEASE SET UP A PASSCODE]';
27
+
28
+ $text = sprintf('%sconnector/order/new/code/%s/order_id/@%s@', $baseUrl, $passcode, $orderId);
29
+ $element->setData('value', $text);
30
+
31
+ return parent::_getElementHtml($element);
32
+ }
33
+ }
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Url/Neworderguest.php ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Dotdigitalgroup_Email_Block_Adminhtml_System_Url_Neworderguest extends Mage_Adminhtml_Block_System_Config_Form_Field
3
+ {
4
+ /**
5
+ * Generate the urls.
6
+ *
7
+ * @param Varien_Data_Form_Element_Abstract $element
8
+ *
9
+ * @return string
10
+ * @throws Mage_Core_Exception
11
+ */
12
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
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 = $website->getConfig('web/secure/base_url');
20
+ }
21
+ $helper = Mage::helper('connector');
22
+ $passcode = $helper->getWebsiteConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_DYNAMIC_CONTENT_PASSCODE, $website);
23
+ $orderId = $helper->getWebsiteConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_MAPPING_LAST_ORDER_ID, $website);
24
+
25
+ if(!strlen($passcode)) $passcode = '[PLEASE SET UP A PASSCODE]';
26
+
27
+ $text = sprintf('%sconnector/order/newguest/code/%s/order_id/@%s@', $baseUrl, $passcode, $orderId);
28
+ $element->setData('value', $text);
29
+
30
+ return parent::_getElementHtml($element);
31
+ }
32
+ }
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Url/Newshipment.php ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Dotdigitalgroup_Email_Block_Adminhtml_System_Url_Newshipment extends Mage_Adminhtml_Block_System_Config_Form_Field
3
+ {
4
+ /**
5
+ * Generate the urls.
6
+ *
7
+ * @param Varien_Data_Form_Element_Abstract $element
8
+ *
9
+ * @return string
10
+ * @throws Mage_Core_Exception
11
+ */
12
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
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 = $website->getConfig('web/secure/base_url');
20
+ }
21
+ $helper = Mage::helper('connector');
22
+ $passcode = $helper->getWebsiteConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_DYNAMIC_CONTENT_PASSCODE, $website);
23
+ $orderId = $helper->getWebsiteConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_MAPPING_LAST_ORDER_ID, $website);
24
+
25
+ if(!strlen($passcode)) $passcode = '[PLEASE SET UP A PASSCODE]';
26
+
27
+ $text = sprintf('%sconnector/shipping/new/code/%s/order_id/@%s@', $baseUrl, $passcode, $orderId);
28
+
29
+
30
+ $element->setData('value', $text);
31
+
32
+ return parent::_getElementHtml($element);
33
+ }
34
+ }
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Url/Newshipmentguest.php ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Dotdigitalgroup_Email_Block_Adminhtml_System_Url_Newshipmentguest extends Mage_Adminhtml_Block_System_Config_Form_Field
3
+ {
4
+ /**
5
+ * Generate the urls.
6
+ *
7
+ * @param Varien_Data_Form_Element_Abstract $element
8
+ *
9
+ * @return string
10
+ * @throws Mage_Core_Exception
11
+ */
12
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
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 = $website->getConfig('web/secure/base_url');
20
+ }
21
+ $helper = Mage::helper('connector');
22
+ $passcode = $helper->getWebsiteConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_DYNAMIC_CONTENT_PASSCODE, $website);
23
+ $orderId = $helper->getWebsiteConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_MAPPING_LAST_ORDER_ID, $website);
24
+
25
+ if(!strlen($passcode)) $passcode = '[PLEASE SET UP A PASSCODE]';
26
+
27
+ $text = sprintf('%sconnector/shipping/newguest/code/%s/order_id/@%s@', $baseUrl, $passcode, $orderId);
28
+
29
+ $element->setData('value', $text);
30
+
31
+ return parent::_getElementHtml($element);
32
+ }
33
+ }
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Url/Orderupdate.php ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Dotdigitalgroup_Email_Block_Adminhtml_System_Url_Orderupdate extends Mage_Adminhtml_Block_System_Config_Form_Field
3
+ {
4
+ /**
5
+ * Generate the urls.
6
+ *
7
+ * @param Varien_Data_Form_Element_Abstract $element
8
+ *
9
+ * @return string
10
+ * @throws Mage_Core_Exception
11
+ */
12
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
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 = $website->getConfig('web/secure/base_url');
20
+ }
21
+ $helper = Mage::helper('connector');
22
+ $passcode = $helper->getWebsiteConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_DYNAMIC_CONTENT_PASSCODE, $website);
23
+ $orderId = $helper->getWebsiteConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_MAPPING_LAST_ORDER_ID, $website);
24
+
25
+ if(!strlen($passcode)) $passcode = '[PLEASE SET UP A PASSCODE]';
26
+ $text = sprintf('%sconnector/order/update/code/%s/order_id/@%s@', $baseUrl, $passcode, $orderId);
27
+ $element->setData('value', $text);
28
+
29
+ return parent::_getElementHtml($element);
30
+ }
31
+ }
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Url/Orderupdateguest.php ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Dotdigitalgroup_Email_Block_Adminhtml_System_Url_Orderupdateguest extends Mage_Adminhtml_Block_System_Config_Form_Field
3
+ {
4
+ /**
5
+ * Generate the urls.
6
+ *
7
+ * @param Varien_Data_Form_Element_Abstract $element
8
+ *
9
+ * @return string
10
+ * @throws Mage_Core_Exception
11
+ */
12
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
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 = $website->getConfig('web/secure/base_url');
20
+ }
21
+ $helper = Mage::helper('connector');
22
+ $passcode = $helper->getWebsiteConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_DYNAMIC_CONTENT_PASSCODE, $website);
23
+ $orderId = $helper->getWebsiteConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_MAPPING_LAST_ORDER_ID, $website);
24
+
25
+ if(!strlen($passcode)) $passcode = '[PLEASE SET UP A PASSCODE]';
26
+ $text = sprintf('%sconnector/order/updateguest/code/%s/order_id/@%s@', $baseUrl, $passcode, $orderId);
27
+ $element->setData('value', $text);
28
+
29
+ return parent::_getElementHtml($element);
30
+ }
31
+ }
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Url/Shipmentupdate.php ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Dotdigitalgroup_Email_Block_Adminhtml_System_Url_Shipmentupdate extends Mage_Adminhtml_Block_System_Config_Form_Field
3
+ {
4
+ /**
5
+ * Generate the urls.
6
+ *
7
+ * @param Varien_Data_Form_Element_Abstract $element
8
+ *
9
+ * @return string
10
+ * @throws Mage_Core_Exception
11
+ */
12
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
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 = $website->getConfig('web/secure/base_url');
20
+ }
21
+ $helper = Mage::helper('connector');
22
+ $passcode = $helper->getWebsiteConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_DYNAMIC_CONTENT_PASSCODE, $website);
23
+ $orderId = $helper->getWebsiteConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_MAPPING_LAST_ORDER_ID, $website);
24
+
25
+ if(!strlen($passcode)) $passcode = '[PLEASE SET UP A PASSCODE]';
26
+
27
+ $text = sprintf('%sconnector/shipping/update/code/%s/order_id/@%s@', $baseUrl, $passcode, $orderId);
28
+
29
+ $element->setData('value', $text);
30
+
31
+ return parent::_getElementHtml($element);
32
+ }
33
+ }
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Url/Shipmentupdateguest.php ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Dotdigitalgroup_Email_Block_Adminhtml_System_Url_Shipmentupdateguest extends Mage_Adminhtml_Block_System_Config_Form_Field
3
+ {
4
+ /**
5
+ * Generate the urls.
6
+ *
7
+ * @param Varien_Data_Form_Element_Abstract $element
8
+ *
9
+ * @return string
10
+ * @throws Mage_Core_Exception
11
+ */
12
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
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 = $website->getConfig('web/secure/base_url');
20
+ }
21
+ $helper = Mage::helper('connector');
22
+ $passcode = $helper->getWebsiteConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_DYNAMIC_CONTENT_PASSCODE, $website);
23
+ $orderId = $helper->getWebsiteConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_MAPPING_LAST_ORDER_ID, $website);
24
+
25
+ if(!strlen($passcode)) $passcode = '[PLEASE SET UP A PASSCODE]';
26
+
27
+ $text = sprintf('%sconnector/shipping/updateguest/code/%s/order_id/@%s@', $baseUrl, $passcode, $orderId);
28
+ $element->setData('value', $text);
29
+
30
+ return parent::_getElementHtml($element);
31
+ }
32
+ }
app/code/{local → community}/Dotdigitalgroup/Email/Block/Basket.php RENAMED
@@ -4,11 +4,18 @@ class Dotdigitalgroup_Email_Block_Basket extends Mage_Core_Block_Template
4
  {
5
  protected $_quote;
6
 
 
 
 
 
 
 
 
7
  public function getBasketItems()
8
  {
9
  $params = $this->getRequest()->getParams();
10
 
11
- if(!isset($params['email']) && !isset($params['code']))
12
  exit();
13
  Mage::helper('connector')->auth($params['code']);
14
 
@@ -17,24 +24,32 @@ class Dotdigitalgroup_Email_Block_Basket extends Mage_Core_Block_Template
17
  $customer = Mage::getModel('customer/customer');
18
  $customer->setWebsiteId(Mage::app()->getWebsite()->getId())->loadByEmail($email);
19
 
 
 
 
 
20
  //last active guest basket
21
  $quoteModel = Mage::getResourceModel('sales/quote_collection')
22
- ->addFieldToFilter('is_active',1)
23
  ->addFieldToFilter('items_count', array('gt' => 0))
24
  ->addFieldToFilter('customer_email', $email)
25
- ->setOrder('updated_at' , 'DESC')
26
- ->setPageSize(1)
27
- ;
28
 
29
  $quoteModel = $quoteModel->getFirstItem();
30
  $this->_quote = $quoteModel;
31
 
32
- $store_id = $quoteModel->getStoreId();
33
- Mage::app()->setCurrentStore($store_id);
34
 
35
- return $quoteModel->getAllItems();;
36
  }
37
 
 
 
 
 
 
38
  public function getGrandTotal()
39
  {
40
  return $this->_quote->getGrandTotal();
4
  {
5
  protected $_quote;
6
 
7
+ /**
8
+ * Basket itmes.
9
+ *
10
+ * @return mixed
11
+ * @throws Exception
12
+ * @throws Mage_Core_Exception
13
+ */
14
  public function getBasketItems()
15
  {
16
  $params = $this->getRequest()->getParams();
17
 
18
+ if (!isset($params['email']) && !isset($params['code']))
19
  exit();
20
  Mage::helper('connector')->auth($params['code']);
21
 
24
  $customer = Mage::getModel('customer/customer');
25
  $customer->setWebsiteId(Mage::app()->getWebsite()->getId())->loadByEmail($email);
26
 
27
+ if (! $customer->getId()) {
28
+ Mage::helper('connector')->log('Lost basket : customer not found : ' . $email);
29
+ exit();
30
+ }
31
  //last active guest basket
32
  $quoteModel = Mage::getResourceModel('sales/quote_collection')
33
+ ->addFieldToFilter('is_active', 1)
34
  ->addFieldToFilter('items_count', array('gt' => 0))
35
  ->addFieldToFilter('customer_email', $email)
36
+ ->setOrder('updated_at', 'DESC')
37
+ ->setPageSize(1);
 
38
 
39
  $quoteModel = $quoteModel->getFirstItem();
40
  $this->_quote = $quoteModel;
41
 
42
+ $storeId = $quoteModel->getStoreId();
43
+ Mage::app()->setCurrentStore($storeId);
44
 
45
+ return $quoteModel->getAllItems();
46
  }
47
 
48
+ /**
49
+ * Grand total.
50
+ *
51
+ * @return mixed
52
+ */
53
  public function getGrandTotal()
54
  {
55
  return $this->_quote->getGrandTotal();
app/code/{local → community}/Dotdigitalgroup/Email/Block/Coupon.php RENAMED
@@ -2,10 +2,15 @@
2
 
3
  class Dotdigitalgroup_Email_Block_Coupon extends Mage_Core_Block_Template
4
  {
 
 
 
 
 
5
  public function generateCoupon()
6
  {
7
  $params = $this->getRequest()->getParams();
8
- if(!isset($params['id']) || !isset($params['code']))
9
  exit();
10
  //coupon rule id
11
  $couponCodeId = $params['id'];
@@ -14,27 +19,23 @@ class Dotdigitalgroup_Email_Block_Coupon extends Mage_Core_Block_Template
14
  //authenticate
15
  Mage::helper('connector')->auth($authCode);
16
 
17
- if($couponCodeId){
18
 
19
  $rule = Mage::getModel('salesrule/rule')->load($couponCodeId);
20
  $generator = Mage::getModel('salesrule/coupon_massgenerator');
21
-
22
  $generator->setFormat( Mage_SalesRule_Helper_Coupon::COUPON_FORMAT_ALPHANUMERIC );
23
  $generator->setRuleId($couponCodeId);
24
  $generator->setUsesPerCoupon(1);
25
- $generator->setDash( 3 );
26
- $generator->setLength( 9);
27
- $generator->setPrefix( '' );
28
- $generator->setSuffix( '' );
29
-
30
  //set the generation settings
31
  $rule->setCouponCodeGenerator($generator);
32
- $rule->setCouponType( Mage_SalesRule_Model_Rule::COUPON_TYPE_AUTO );
33
-
34
  //generate the coupon
35
  $coupon = $rule->acquireCoupon();
36
  $couponCode = $coupon->getCode();
37
-
38
  //save the type of coupon
39
  $couponModel = Mage::getModel('salesrule/coupon')->loadByCode($couponCode);
40
  $couponModel->setType(Mage_SalesRule_Model_Rule::COUPON_TYPE_NO_COUPON);
2
 
3
  class Dotdigitalgroup_Email_Block_Coupon extends Mage_Core_Block_Template
4
  {
5
+ /**
6
+ * Generates the coupon code based on the code id.
7
+ * @return bool
8
+ * @throws Exception
9
+ */
10
  public function generateCoupon()
11
  {
12
  $params = $this->getRequest()->getParams();
13
+ if (!isset($params['id']) || !isset($params['code']))
14
  exit();
15
  //coupon rule id
16
  $couponCodeId = $params['id'];
19
  //authenticate
20
  Mage::helper('connector')->auth($authCode);
21
 
22
+ if ($couponCodeId) {
23
 
24
  $rule = Mage::getModel('salesrule/rule')->load($couponCodeId);
25
  $generator = Mage::getModel('salesrule/coupon_massgenerator');
 
26
  $generator->setFormat( Mage_SalesRule_Helper_Coupon::COUPON_FORMAT_ALPHANUMERIC );
27
  $generator->setRuleId($couponCodeId);
28
  $generator->setUsesPerCoupon(1);
29
+ $generator->setDash(3);
30
+ $generator->setLength(9);
31
+ $generator->setPrefix('');
32
+ $generator->setSuffix('');
 
33
  //set the generation settings
34
  $rule->setCouponCodeGenerator($generator);
35
+ $rule->setCouponType(Mage_SalesRule_Model_Rule::COUPON_TYPE_AUTO);
 
36
  //generate the coupon
37
  $coupon = $rule->acquireCoupon();
38
  $couponCode = $coupon->getCode();
 
39
  //save the type of coupon
40
  $couponModel = Mage::getModel('salesrule/coupon')->loadByCode($couponCode);
41
  $couponModel->setType(Mage_SalesRule_Model_Rule::COUPON_TYPE_NO_COUPON);
app/code/community/Dotdigitalgroup/Email/Block/Customer.php ADDED
@@ -0,0 +1,96 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dotdigitalgroup_Email_Block_Customer 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')) {
14
+ $root->setTemplate('page/blank.phtml');
15
+ }
16
+ }
17
+
18
+ /**
19
+ * Recommended dynamic products.
20
+ *
21
+ * @return array
22
+ * @throws Exception
23
+ */
24
+ public function getRecommendedProducts()
25
+ {
26
+ $customerId = $this->getRequest()->getParam('customer_id', false);
27
+ $mode = $this->getRequest()->getParam('mode', false);
28
+ if ($mode && $customerId) {
29
+ $customerModel = Mage::getModel('customer/customer')->load($customerId);
30
+ Mage::app()->setCurrentStore($customerModel->getStoreId());
31
+ if ($customerModel->getId()) {
32
+ //order products
33
+ $dynamicReport = Mage::getModel('email_connector/dynamic_report');
34
+ $dynamicReport->setMode($mode)
35
+ ->setCustomer($customerModel);
36
+ } else {
37
+ Mage::helper('connector')->log('ERROR Dynamic content : Customer not found '. $customerId);
38
+ return array();
39
+ }
40
+ } else {
41
+ //load the reports from dynamic
42
+ $dynamicReport = Mage::getModel('email_connector/dynamic_report');
43
+ $dynamicReport->setMode($mode);
44
+ }
45
+ $productsToDisplay = $dynamicReport->getProducts();
46
+
47
+ return $productsToDisplay;
48
+ }
49
+
50
+ public function getCustomer()
51
+ {
52
+ $message = new Varien_Object();
53
+ $customerId = Mage::app()->getRequest()->getParam('customer_id', false);
54
+ if ($customerId) {
55
+ $customerModel = Mage::getModel('customer/customer')->load($customerId);
56
+ if (! $customerModel->getId()) {
57
+ Mage::helper('connector')->log('Error: New customer, no custoemr found : ' . $customerId);
58
+ return $message->setError('No customer found : ' . $customerId);
59
+ }
60
+ return $customerModel;
61
+
62
+ } else {
63
+ return $message->setError('No customer id in param request : ' . $customerId);
64
+ }
65
+ }
66
+
67
+ /**
68
+ * Display type mode.
69
+ * @return mixed|string
70
+ */
71
+ public function getDisplayType()
72
+ {
73
+ return Mage::helper('connector/recommended')->getDisplayType();
74
+ }
75
+
76
+ /**
77
+ * @return Mage_Core_Model_Store
78
+ */
79
+ public function getStore()
80
+ {
81
+ $customerId = Mage::app()->getRequest()->getParam('customer_id', false);
82
+ return Mage::app()->getStore(Mage::getModel('customer/customer')->load($customerId)->getStoreId());
83
+ }
84
+
85
+ public function getConfirmation()
86
+ {
87
+ $customerId = Mage::app()->getRequest()->getParam('customer_id', false);
88
+ $customerModel = Mage::getModel('customer/customer')->load($customerId);
89
+
90
+ if ($confirmation = $customerModel->getConfirmation()) {
91
+ return $confirmation;
92
+ }
93
+ Mage::helper('connector')->log('Customer already confirmed the account');
94
+ }
95
+
96
+ }
app/code/community/Dotdigitalgroup/Email/Block/Order.php ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dotdigitalgroup_Email_Block_Order extends Mage_Core_Block_Template
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($this->__('Order # %s', $this->getOrder()->getRealOrderId()));
18
+ }
19
+ }
20
+
21
+ /**
22
+ * Current Order.
23
+ *
24
+ * @return Mage_Core_Model_Abstract|mixed
25
+ */
26
+ public function getOrder()
27
+ {
28
+ $orderId = Mage::registry('order_id');
29
+ $order = Mage::registry('current_order');
30
+ if (! $orderId) {
31
+ $orderId = Mage::app()->getRequest()->getParam('order_id');
32
+ Mage::register('order_id', $orderId);
33
+ }
34
+ if (! $order) {
35
+ $order = Mage::getModel('sales/order')->load($orderId);
36
+ Mage::register('current_order', $order);
37
+ }
38
+
39
+ return $order;
40
+ }
41
+ }
app/code/community/Dotdigitalgroup/Email/Block/Order/Creditmemo.php ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Dotdigitalgroup_Email_Block_Order_Creditmemo extends Mage_Sales_Block_Order_Creditmemo_Items
3
+ {
4
+ /**
5
+ * Prepare layout.
6
+ *
7
+ * @return Mage_Core_Block_Abstract|void
8
+ */
9
+ protected function _prepareLayout()
10
+ {
11
+ if ($root = $this->getLayout()->getBlock('root')) {
12
+ $root->setTemplate('page/blank.phtml');
13
+ }
14
+ }
15
+
16
+ /**
17
+ * Get current Order.
18
+ * @return Mage_Core_Model_Abstract|Mage_Sales_Model_Order|mixed
19
+ */
20
+ public function getOrder()
21
+ {
22
+ $orderId = Mage::registry('order_id');
23
+ $order = Mage::registry('current_order');
24
+ if (! $orderId) {
25
+ $orderId = Mage::app()->getRequest()->getParam('order_id');
26
+ Mage::register('order_id', $orderId);
27
+ }
28
+ if (! $order) {
29
+ $order = Mage::getModel('sales/order')->load($orderId);
30
+ Mage::register('current_order', $order);
31
+ }
32
+ if (! $order->hasCreditmemos()) {
33
+ Mage::helper('connector')->log('TE - no creditmemo for order : '. $orderId);
34
+ exit;
35
+ }
36
+
37
+ return $order;
38
+ }
39
+
40
+ /**
41
+ * Order items.
42
+ * @return mixed
43
+ */
44
+ public function getCreditmemoItems()
45
+ {
46
+ return Mage::registry('current_order')->getItemsCollection();
47
+ }
48
+ }
app/code/community/Dotdigitalgroup/Email/Block/Order/Invoice.php ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Dotdigitalgroup_Email_Block_Order_Invoice extends Mage_Sales_Block_Order_Invoice_Items
3
+ {
4
+ /**
5
+ * Prepare layout.
6
+ * @return Mage_Core_Block_Abstract|void
7
+ */
8
+ protected function _prepareLayout()
9
+ {
10
+ if ($root = $this->getLayout()->getBlock('root')) {
11
+ $root->setTemplate('page/blank.phtml');
12
+ }
13
+ }
14
+
15
+ /**
16
+ * Get current order.
17
+ * @return Mage_Core_Model_Abstract|Mage_Sales_Model_Order|mixed
18
+ */
19
+ public function getOrder()
20
+ {
21
+ $orderId = Mage::registry('order_id');
22
+ $order = Mage::registry('current_order');
23
+ if (! $orderId) {
24
+ $orderId = Mage::app()->getRequest()->getParam('order_id');
25
+ Mage::register('order_id', $orderId);
26
+ }
27
+ if (! $order) {
28
+ $order = Mage::getModel('sales/order')->load($orderId);
29
+ Mage::register('current_order', $order);
30
+ }
31
+ if (! $order->hasInvoices()) {
32
+ Mage::helper('connector')->log('TE - no invoice for order : '. $orderId);
33
+ exit;
34
+ }
35
+
36
+ return $order;
37
+ }
38
+
39
+ }
app/code/community/Dotdigitalgroup/Email/Block/Order/Shipping.php ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Dotdigitalgroup_Email_Block_Order_Shipping extends Mage_Sales_Block_Order_Creditmemo_Items
3
+ {
4
+ /**
5
+ * Prepare layout.
6
+ * @return Mage_Core_Block_Abstract|void
7
+ */
8
+ protected function _prepareLayout()
9
+ {
10
+ if ($root = $this->getLayout()->getBlock('root')) {
11
+ $root->setTemplate('page/blank.phtml');
12
+ }
13
+ }
14
+
15
+ /**
16
+ * Get current order.
17
+ * @return Mage_Core_Model_Abstract|Mage_Sales_Model_Order|mixed
18
+ */
19
+ public function getOrder()
20
+ {
21
+ $orderId = Mage::registry('order_id');
22
+ $order = Mage::registry('current_order');
23
+ if (! $orderId) {
24
+ $orderId = Mage::app()->getRequest()->getParam('order_id');
25
+ Mage::register('order_id', $orderId);
26
+ }
27
+ if (! $order) {
28
+ $order = Mage::getModel('sales/order')->load($orderId);
29
+ Mage::register('current_order', $order);
30
+ }
31
+ if (! $order->hasShipments()) {
32
+ Mage::helper('connector')->log('TE - no shipments for order : '. $orderId);
33
+ exit;
34
+ }
35
+
36
+ return $order;
37
+
38
+ }
39
+
40
+ /**
41
+ * Order shipments.
42
+ * @return mixed
43
+ */
44
+ public function getShipment()
45
+ {
46
+ return $shipment = Mage::registry('current_order')->getShipmentsCollection()->getFirstItem();
47
+ }
48
+ }
app/code/community/Dotdigitalgroup/Email/Block/Products.php ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dotdigitalgroup_Email_Block_Products extends Mage_Core_Block_Template
4
+ {
5
+ /**
6
+ * Prepare layout, set template.
7
+ *
8
+ * @return Mage_Core_Block_Abstract|void
9
+ */
10
+ protected function _prepareLayout()
11
+ {
12
+ if ($root = $this->getLayout()->getBlock('root')) {
13
+ $root->setTemplate('page/blank.phtml');
14
+ }
15
+ }
16
+
17
+ /**
18
+ * get the products to display for table
19
+ */
20
+ public function getRecommendedProducts()
21
+ {
22
+ $productsToDisplay = array();
23
+ $orderId = $this->getRequest()->getParam('order', false);
24
+ $mode = $this->getRequest()->getParam('mode', false);
25
+ if ($orderId && $mode) {
26
+ $orderModel = Mage::getModel('sales/order')->load($orderId);
27
+ if ($orderModel->getId()) {
28
+ Mage::app()->setCurrentStore($orderModel->getStoreId());
29
+ //order products
30
+ $productRecommended = Mage::getModel('email_connector/dynamic_recommended', $orderModel);
31
+ $productRecommended->setMode($mode);
32
+
33
+ //get the order items recommendations
34
+ $productsToDisplay = $productRecommended->getProducts();
35
+ }
36
+ }
37
+
38
+ return $productsToDisplay;
39
+ }
40
+
41
+
42
+ /**
43
+ * Price html block.
44
+ *
45
+ * @param $product
46
+ *
47
+ * @return string
48
+ */
49
+ public function getPriceHtml($product)
50
+ {
51
+ $this->setTemplate('connector/price.phtml');
52
+ $this->setProduct($product);
53
+ return $this->toHtml();
54
+ }
55
+
56
+ /**
57
+ * Display type mode.
58
+ * @return mixed|string
59
+ */
60
+ public function getDisplayType()
61
+ {
62
+ return Mage::helper('connector/recommended')->getDisplayType();
63
+
64
+ }
65
+ }
app/code/community/Dotdigitalgroup/Email/Block/Recommended/Bestsellers.php ADDED
@@ -0,0 +1,70 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dotdigitalgroup_Email_Block_Recommended_Bestsellers extends Mage_Core_Block_Template
4
+ {
5
+
6
+ /**
7
+ * Prepare layout.
8
+ * @return Mage_Core_Block_Abstract|void
9
+ */
10
+ protected function _prepareLayout()
11
+ {
12
+ if ($root = $this->getLayout()->getBlock('root')) {
13
+ $root->setTemplate('page/blank.phtml');
14
+ }
15
+ }
16
+
17
+ /**
18
+ * Get product collection.
19
+ * @return array
20
+ * @throws Exception
21
+ */
22
+ public function getLoadedProductCollection()
23
+ {
24
+ $productsToDisplay = array();
25
+ $mode = $this->getRequest()->getActionName();
26
+ $limit = Mage::helper('connector/recommended')->getDisplayLimitByMode($mode);
27
+ $from = Mage::helper('connector/recommended')->getTimeFromConfig($mode);
28
+ $to = Zend_Date::now()->toString(Zend_Date::ISO_8601);
29
+
30
+ $productCollection = Mage::getResourceModel('reports/product_collection')
31
+ ->addOrderedQty($from, $to)
32
+ ->addAttributeToSelect('*')
33
+ ->addAttributeToSelect(array('name', 'price', 'small_image'))
34
+ ->setPageSize($limit)
35
+ ->setOrder('ordered_qty', 'desc');
36
+ foreach ($productCollection as $_product) {
37
+ $productId = $_product->getId();
38
+ $product = Mage::getModel('catalog/product')->load($productId);
39
+ if ($product->isSalable())
40
+ $productsToDisplay[] = $product;
41
+ }
42
+
43
+ return $productsToDisplay;
44
+ }
45
+
46
+ /**
47
+ * Display type mode.
48
+ *
49
+ * @return mixed|string
50
+ */
51
+ public function getMode()
52
+ {
53
+ return Mage::helper('connector/recommended')->getDisplayType();
54
+
55
+ }
56
+
57
+ /**
58
+ * Price html.
59
+ * @param $product
60
+ *
61
+ * @return string
62
+ */
63
+ public function getPriceHtml($product)
64
+ {
65
+ $this->setTemplate('connector/product/price.phtml');
66
+ $this->setProduct($product);
67
+ return $this->toHtml();
68
+ }
69
+
70
+ }
app/code/community/Dotdigitalgroup/Email/Block/Recommended/Mostviewed.php ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dotdigitalgroup_Email_Block_Recommended_Mostviewed extends Mage_Core_Block_Template
4
+ {
5
+
6
+ /**
7
+ * Prepare layout.
8
+ * @return Mage_Core_Block_Abstract|void
9
+ */
10
+ protected function _prepareLayout()
11
+ {
12
+ if ($root = $this->getLayout()->getBlock('root')) {
13
+ $root->setTemplate('page/blank.phtml');
14
+ }
15
+ }
16
+
17
+ /**
18
+ * Get product collection.
19
+ * @return array
20
+ * @throws Exception
21
+ */
22
+ public function getLoadedProductCollection()
23
+ {
24
+ $productsToDisplay = array();
25
+ $mode = $this->getRequest()->getActionName();
26
+ $limit = Mage::helper('connector/recommended')->getDisplayLimitByMode($mode);
27
+ $from = Mage::helper('connector/recommended')->getTimeFromConfig($mode);
28
+ $to = Zend_Date::now()->toString(Zend_Date::ISO_8601);
29
+
30
+ $productCollection = Mage::getResourceModel('reports/product_collection')
31
+ ->addViewsCount($from, $to)
32
+ ->setPageSize($limit);
33
+
34
+ foreach ($productCollection as $_product) {
35
+ $productId = $_product->getId();
36
+ $product = Mage::getModel('catalog/product')->load($productId);
37
+ if($product->isSalable())
38
+ $productsToDisplay[] = $product;
39
+ }
40
+
41
+ return $productsToDisplay;
42
+ }
43
+
44
+
45
+ /**
46
+ * Display mode type.
47
+ * @return mixed|string
48
+ */
49
+ public function getMode()
50
+ {
51
+ return Mage::helper('connector/recommended')->getDisplayType();
52
+ }
53
+
54
+ /**
55
+ * @param $product
56
+ *
57
+ * @return string
58
+ */
59
+ public function getPriceHtml($product)
60
+ {
61
+ $this->setTemplate('connector/product/price.phtml');
62
+ $this->setProduct($product);
63
+ return $this->toHtml();
64
+ }
65
+ }
app/code/community/Dotdigitalgroup/Email/Block/Recommended/Products.php ADDED
@@ -0,0 +1,141 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dotdigitalgroup_Email_Block_Recommended_Products extends Mage_Core_Block_Template
4
+ {
5
+ /**
6
+ * Prepare layout, set the template.
7
+ * @return Mage_Core_Block_Abstract|void
8
+ */
9
+ protected function _prepareLayout()
10
+ {
11
+ if ($root = $this->getLayout()->getBlock('root')) {
12
+ $root->setTemplate('page/blank.phtml');
13
+ }
14
+ }
15
+
16
+ /**
17
+ * get the products to display for table
18
+ */
19
+ public function getLoadedProductCollection()
20
+ {
21
+ $productsToDisplay = array();
22
+ $orderId = $this->getRequest()->getParam('order_id');
23
+ $mode = $this->getRequest()->getActionName();
24
+ $orderModel = Mage::getModel('sales/order')->load($orderId);
25
+
26
+ $limit = Mage::helper('connector/recommended')->getDisplayLimitByMode($mode);
27
+ $orderItems = $orderModel->getAllItems();
28
+
29
+ if (count($orderItems) > $limit) {
30
+ $maxPerChild = 1;
31
+ } else {
32
+ $maxPerChild = number_format($limit / count($orderItems));
33
+ }
34
+
35
+ Mage::helper('connector')->log('DYNAMIC PRODUCTS : limit ' . $limit . ' products : ' . count($orderItems) . ', max per child : '. $maxPerChild);
36
+
37
+ foreach ($orderItems as $item) {
38
+ $productId = $item->getProductId();
39
+ /** @var Mage_Catalog_Model_Product $productModel */
40
+ $productModel = Mage::getModel('catalog/product')->load($productId);
41
+ if ($productModel->getId()) {
42
+ $recommendedProducts = $this->_getRecommendedProduct($productModel, $mode);
43
+ $i = 0;
44
+ foreach ($recommendedProducts as $product) {
45
+ $product = Mage::getModel('catalog/product')->load($product->getId());
46
+ if (count($productsToDisplay) < $limit) {
47
+ if ($i <= $maxPerChild && $product->isSaleable() && !$product->getParentId()) {
48
+ $productsToDisplay[$product->getId()] = $product;
49
+ $i++;
50
+ }
51
+ }
52
+ }
53
+ }
54
+ if (count($productsToDisplay) == $limit) {
55
+ break;
56
+ }
57
+
58
+ }
59
+
60
+ //fill up the table with fallback products
61
+ if (count($productsToDisplay) < $limit) {
62
+ $fallbackIds = Mage::helper('connector/recommended')->getFallbackIds();
63
+ Mage::helper( 'connector' )->log( 'fallback products' );
64
+
65
+ foreach ($fallbackIds as $productId) {
66
+ $product = Mage::getModel('catalog/product')->load($productId);
67
+ if($product->isSaleable())
68
+ $productsToDisplay[$product->getId()] = $product;
69
+ //stop the limit was reached
70
+ if (count($productsToDisplay) == $limit) {
71
+ break;
72
+ }
73
+ }
74
+ }
75
+
76
+ Mage::helper('connector')->log('loaded product to display ' . count($productsToDisplay));
77
+ return $productsToDisplay;
78
+ }
79
+
80
+ /**
81
+ * Product related items.
82
+ *
83
+ * @param Mage_Catalog_Model_Product $productModel
84
+ * @param $mode
85
+ *
86
+ * @return array
87
+ */
88
+ private function _getRecommendedProduct(Mage_Catalog_Model_Product $productModel, $mode)
89
+ {
90
+ //array of products to display
91
+ $products = array();
92
+ switch($mode){
93
+ case 'related':
94
+ $products = $productModel->getRelatedProducts();
95
+ break;
96
+ case 'upsell':
97
+ $products = $productModel->getUpSellProducts();
98
+ break;
99
+ case 'crosssell':
100
+ $products = $productModel->getCrossSellProducts();
101
+ break;
102
+
103
+ }
104
+
105
+ return $products;
106
+ }
107
+
108
+ /**
109
+ * Diplay mode type.
110
+ *
111
+ * @return mixed|string
112
+ */
113
+ public function getMode()
114
+ {
115
+ return Mage::helper('connector/recommended')->getDisplayType();
116
+
117
+ }
118
+
119
+ /**
120
+ * Number of the colums.
121
+ * @return int|mixed
122
+ * @throws Exception
123
+ */
124
+ public function getColumnCount()
125
+ {
126
+ return Mage::helper('connector/recommended')->getDisplayLimitByMode($this->getRequest()->getActionName());
127
+ }
128
+
129
+ /**
130
+ * Price html.
131
+ * @param $product
132
+ *
133
+ * @return string
134
+ */
135
+ public function getPriceHtml($product)
136
+ {
137
+ $this->setTemplate('connector/product/price.phtml');
138
+ $this->setProduct($product);
139
+ return $this->toHtml();
140
+ }
141
+ }
app/code/community/Dotdigitalgroup/Email/Block/Recommended/Push.php ADDED
@@ -0,0 +1,66 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dotdigitalgroup_Email_Block_Recommended_Push extends Mage_Core_Block_Template
4
+ {
5
+ /**
6
+ * Prepare layout, set template.
7
+ * @return Mage_Core_Block_Abstract|void
8
+ */
9
+ protected function _prepareLayout()
10
+ {
11
+ if ($root = $this->getLayout()->getBlock('root')) {
12
+ $root->setTemplate('page/blank.phtml');
13
+ }
14
+ }
15
+
16
+ /**
17
+ * get the products to display for table
18
+ */
19
+ public function getLoadedProductCollection()
20
+ {
21
+ $productsToDisplay = array();
22
+ $mode = $this->getRequest()->getActionName();
23
+ $limit = Mage::helper('connector/recommended')->getDisplayLimitByMode($mode);
24
+
25
+ $productIds = Mage::helper('connector/recommended')->getProductPushIds();
26
+
27
+ $productCollection = Mage::getResourceModel('catalog/product_collection')
28
+ ->addAttributeToFilter('entity_id', array('in' => $productIds))
29
+ ->setPageSize($limit)
30
+ ;
31
+ foreach ($productCollection as $_product) {
32
+ $productId = $_product->getId();
33
+ $product = Mage::getModel('catalog/product')->load($productId);
34
+ if($product->isSaleable())
35
+ $productsToDisplay[] = $product;
36
+
37
+ }
38
+
39
+ return $productsToDisplay;
40
+
41
+ }
42
+
43
+ /**
44
+ * Display type mode.
45
+ *
46
+ * @return mixed|string
47
+ */
48
+ public function getMode()
49
+ {
50
+ return Mage::helper('connector/recommended')->getDisplayType();
51
+
52
+ }
53
+
54
+ /**
55
+ * Price html.
56
+ * @param $product
57
+ *
58
+ * @return string
59
+ */
60
+ public function getPriceHtml($product)
61
+ {
62
+ $this->setTemplate('connector/product/price.phtml');
63
+ $this->setProduct($product);
64
+ return $this->toHtml();
65
+ }
66
+ }
app/code/community/Dotdigitalgroup/Email/Block/Recommended/Recentlyviewed.php ADDED
@@ -0,0 +1,73 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dotdigitalgroup_Email_Block_Recommended_Recentlyviewed extends Mage_Core_Block_Template
4
+ {
5
+
6
+ /**
7
+ * Prepare layout, set template.
8
+ * @return Mage_Core_Block_Abstract|void
9
+ */
10
+ protected function _prepareLayout()
11
+ {
12
+ if ($root = $this->getLayout()->getBlock('root')) {
13
+ $root->setTemplate('page/blank.phtml');
14
+ }
15
+ }
16
+
17
+ /**
18
+ * Products collection.
19
+ *
20
+ * @return array
21
+ * @throws Exception
22
+ */
23
+ public function getLoadedProductCollection()
24
+ {
25
+ $productsToDisplay = array();
26
+ $mode = $this->getRequest()->getActionName();
27
+ $customerId = $this->getRequest()->getParam('customer_id');
28
+ $limit = Mage::helper('connector/recommended')->getDisplayLimitByMode($mode);
29
+ //login customer to receive the recent products
30
+ $session = Mage::getSingleton('customer/session');
31
+ $isLoggedIn = $session->loginById($customerId);
32
+ /** @var Mage_Reports_Block_Product_Viewed $collection */
33
+ $collection = Mage::getSingleton('Mage_Reports_Block_Product_Viewed');
34
+ $items = $collection->getItemsCollection()
35
+ ->setPageSize($limit);
36
+ Mage::helper('connector')->log('Recentlyviewed customer : ' . $customerId . ', mode ' . $mode . ', limit : ' . $limit .
37
+ ', items found : ' . count($items) . ', is customer logged in : ' . $isLoggedIn . ', products :' . count($productsToDisplay));
38
+ foreach ($items as $product) {
39
+ $product = Mage::getModel('catalog/product')->load($product->getId());
40
+ if($product->isSalable())
41
+ $productsToDisplay[$product->getId()] = $product;
42
+
43
+ }
44
+ $session->logout();
45
+
46
+ return $productsToDisplay;
47
+ }
48
+
49
+
50
+ /**
51
+ * Display mode type.
52
+ *
53
+ * @return mixed|string
54
+ */
55
+ public function getMode()
56
+ {
57
+ return Mage::helper('connector/recommended')->getDisplayType();
58
+
59
+ }
60
+
61
+ /**
62
+ * Price html.
63
+ * @param $product
64
+ *
65
+ * @return string
66
+ */
67
+ public function getPriceHtml($product)
68
+ {
69
+ $this->setTemplate('connector/product/price.phtml');
70
+ $this->setProduct($product);
71
+ return $this->toHtml();
72
+ }
73
+ }
app/code/community/Dotdigitalgroup/Email/Helper/Config.php ADDED
@@ -0,0 +1,91 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dotdigitalgroup_Email_Helper_Config
4
+ {
5
+
6
+ /**
7
+ * API SECTION.
8
+ */
9
+ //API settings
10
+ const XML_PATH_CONNECTOR_API_ENABLED = 'connector_api_credentials/api/enabled';
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
+ const XML_PATH_CONNECTOR_CLIENT_ID = 'connector_api_credentials/oauth/client_id';
14
+ const XML_PATH_CONNECTOR_CLIENT_SECRET_ID = 'connector_api_credentials/oauth/client_key';
15
+
16
+ /**
17
+ * SMS SECTION.
18
+ */
19
+ //enabled
20
+ const XML_PATH_CONNECTOR_SMS_ENABLED_1 = 'connector_sms/sms_one/enabled';
21
+ const XML_PATH_CONNECTOR_SMS_ENABLED_2 = 'connector_sms/sms_two/enabled';
22
+ const XML_PATH_CONNECTOR_SMS_ENABLED_3 = 'connector_sms/sms_three/enabled';
23
+ const XML_PATH_CONNECTOR_SMS_ENABLED_4 = 'connector_sms/sms_four/enabled';
24
+ //status
25
+ const XML_PATH_CONNECTOR_SMS_STATUS_1 = 'connector_sms/sms_one/status';
26
+ const XML_PATH_CONNECTOR_SMS_STATUS_2 = 'connector_sms/sms_two/status';
27
+ const XML_PATH_CONNECTOR_SMS_STATUS_3 = 'connector_sms/sms_three/status';
28
+ const XML_PATH_CONNECTOR_SMS_STATUS_4 = 'connector_sms/sms_four/status';
29
+ //message
30
+ const XML_PATH_CONNECTOR_SMS_MESSAGE_1 = 'connector_sms/sms_one/message';
31
+ const XML_PATH_CONNECTOR_SMS_MESSAGE_2 = 'connector_sms/sms_two/message';
32
+ const XML_PATH_CONNECTOR_SMS_MESSAGE_3 = 'connector_sms/sms_three/message';
33
+ const XML_PATH_CONNECTOR_SMS_MESSAGE_4 = 'connector_sms/sms_four/message';
34
+
35
+ /**
36
+ * SYNC SECTION.
37
+ */
38
+
39
+ const XML_PATH_CONNECTOR_SYNC_CONTACT_ENABLED = 'connector_sync_settings/sync/contact_enabled';
40
+ const XML_PATH_CONNECTOR_SYNC_SUBSCRIBER_ENABLED = 'connector_sync_settings/sync/subscriber_enabled';
41
+ const XML_PATH_CONNECTOR_SYNC_ORDER_ENABLED = 'connector_sync_settings/sync/order_enabled';
42
+ const XML_PATH_CONNECTOR_SYNC_WISHLIST_ENABLED = 'connector_sync_settings/sync/wishlist_enabled';
43
+
44
+ const XML_PATH_CONNECTOR_CUSTOMERS_ADDRESS_BOOK_ID = 'connector_sync_settings/address_book/customers';
45
+ const XML_PATH_CONNECTOR_SUBSCRIBERS_ADDRESS_BOOK_ID = 'connector_sync_settings/address_book/subscribers';
46
+ const XML_PATH_CONNECTOR_GUEST_ADDRESS_BOOK_ID = 'connector_sync_settings/address_book/guests';
47
+ // Mapping
48
+ const XML_PATH_CONNECTOR_MAPPING_LAST_ORDER_ID = 'connector_data_mapping/customer_data/last_order_id';
49
+ const XML_PATH_CONNECTOR_MAPPING_CUSTOMER_ID = 'connector_data_mapping/customer_data/customer_id';
50
+ const XML_PATH_CONNECTOR_MAPPING_CUSTOM_DATAFIELDS = 'connector_data_mapping/customer_data/custom_attributes';
51
+ const XML_PATH_CONNECTOR_MAPPING_CUSTOMER_STORENAME = 'connector_data_mapping/customer_data/store_name';
52
+ const XML_PATH_CONNECTOR_MAPPING_CUSTOMER_TOTALREFUND = 'connector_data_mapping/customer_data/total_refund';
53
+ const XML_PATH_CONNECTOR_MAPPING_SWEETTOOTH_ACTIVE = 'connector_data_mapping/sweet_tooth/active';
54
+
55
+ // Dynamic
56
+ const XML_PATH_CONNECTOR_DYNAMIC_CONTENT_PASSCODE = 'connector_dynamic_content/external_dynamic_content_urls/passcode';
57
+
58
+ /**
59
+ * ADVANCED SECTION.
60
+ */
61
+ const XML_PATH_CONNECTOR_ADVANCED_DEBUG_ENABLED = 'connector_advanced_settings/admin/debug_enabled';
62
+ const XML_PATH_CONNECTOR_SYNC_LIMIT = 'connector_advanced_settings/admin/batch_size';
63
+ const XML_PATH_CONNECTOR_RESOURCE_ALLOCATION = 'connector_advanced_settings/admin/memory_limit';
64
+ const XML_PATH_CONNECTOR_TRANSACTIONAL_DATA_SYNC_LIMIT = 'connector_advanced_settings/sync_limits/orders';
65
+ const XML_PATH_CONNECTOR_TRANSACTIONAL_STYLING = 'connector_advanced_settings/admin/inline_styling';
66
+ const XML_PATH_CONNECTOR_RECOMMENDED_STYLING = 'connector_advanced_settings/admin/recommended_inline';
67
+ const XML_PATH_CONNECTOR_SYNC_ORDER_STATUS = 'connector_advanced_settings/sync_limits/order_statuses';
68
+
69
+ /**
70
+ * Automation studio.
71
+ */
72
+ const XML_PATH_CONNECTOR_AUTOMATION_STUDIO_SUBSCRIBER = 'connector_automation_studio/automation/subscriber_automation';
73
+ const XML_PATH_CONNECTOR_AUTOMATION_STUDIO_CUSTOMER = 'connector_automation_studio/automation/customer_automation';
74
+
75
+
76
+
77
+ /**
78
+ * ROI SECTION.
79
+ */
80
+ const XML_PATH_CONNECTOR_ROI_TRACKING_ENABLED = 'connector_roi_tracking/roi_tracking/enabled';
81
+ const XML_PATH_CONNECTOR_PAGE_TRACKING_ENABLED = 'connector_roi_tracking/page_tracking/enabled';
82
+
83
+ /**
84
+ * OAUTH
85
+ */
86
+
87
+ const API_CONNECTOR_URL_AUTHORISE = 'https://my.dotmailer.com/OAuth2/authorise.aspx?';
88
+ const API_CONNECTOR_URL_TOKEN = 'https://my.dotmailer.com/OAuth2/Tokens.ashx';
89
+ const API_CONNECTOR_URL_LOG_USER = 'https://my.dotmailer.com/?oauthtoken=';
90
+
91
+ }
app/code/community/Dotdigitalgroup/Email/Helper/Data.php ADDED
@@ -0,0 +1,283 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dotdigitalgroup_Email_Helper_Data extends Mage_Core_Helper_Abstract
4
+ {
5
+
6
+ public function isEnabled($website = 0)
7
+ {
8
+ $website = Mage::app()->getWebsite($website);
9
+ return (bool)$website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_API_ENABLED);
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(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_API_USERNAME);
21
+ }
22
+
23
+ public function getApiPassword($website = 0)
24
+ {
25
+ $website = Mage::app()->getWebsite($website);
26
+
27
+ return $website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_API_PASSWORD);
28
+ }
29
+
30
+ public function auth($authRequest)
31
+ {
32
+ if ($authRequest != Mage::getStoreConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_DYNAMIC_CONTENT_PASSCODE)) {
33
+ $this->log('Authenication failed : ' . $authRequest);
34
+ exit();
35
+ }
36
+ return true;
37
+ }
38
+
39
+ public function getMappedCustomerId()
40
+ {
41
+ return Mage::getStoreConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_MAPPING_CUSTOMER_ID);
42
+ }
43
+
44
+ public function getMappedOrderId()
45
+ {
46
+ return Mage::getStoreConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_MAPPING_LAST_ORDER_ID);
47
+ }
48
+
49
+ public function getPasscode()
50
+ {
51
+ return Mage::getStoreConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_DYNAMIC_CONTENT_PASSCODE);
52
+ }
53
+
54
+ public function getLastOrderId()
55
+ {
56
+ return Mage::getStoreConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_MAPPING_LAST_ORDER_ID);
57
+
58
+ }
59
+
60
+ public function log($data, $level = Zend_Log::DEBUG, $filename = 'api.log')
61
+ {
62
+ if ($this->getDebugEnabled()) {
63
+ $filename = 'connector_' . $filename;
64
+
65
+ Mage::log($data, $level, $filename, $force = true);
66
+ }
67
+ }
68
+
69
+ public function getDebugEnabled()
70
+ {
71
+ return (bool) Mage::getStoreConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_ADVANCED_DEBUG_ENABLED);
72
+ }
73
+
74
+ public function getConnectorVersion()
75
+ {
76
+ $modules = (array) Mage::getConfig()->getNode('modules')->children();
77
+ if (isset($modules['Dotdigitalgroup_Email'])) {
78
+ $moduleName = $modules['Dotdigitalgroup_Email'];
79
+ return $moduleName->version;
80
+ }
81
+ return '';
82
+ }
83
+
84
+
85
+ public function getPageTrackingEnabled()
86
+ {
87
+ return (bool)Mage::getStoreConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_PAGE_TRACKING_ENABLED);
88
+ }
89
+
90
+ public function getRoiTrackingEnabled()
91
+ {
92
+ return (bool)Mage::getStoreConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_ROI_TRACKING_ENABLED);
93
+ }
94
+
95
+ public function getResourceAllocationEnabled()
96
+ {
97
+ return (bool)Mage::getStoreConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_RESOURCE_ALLOCATION);
98
+ }
99
+
100
+ public function getMappedStoreName($website)
101
+ {
102
+ $mapped = $website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_MAPPING_CUSTOMER_STORENAME);
103
+ $storeName = ($mapped)? $mapped : '';
104
+ return $storeName;
105
+ }
106
+
107
+ /**
108
+ * Get the contact id for the custoemer based on website id.
109
+ * @param $email
110
+ * @param $websiteId
111
+ * @return string contact_id
112
+ */
113
+ public function getContactId($email, $websiteId)
114
+ {
115
+ $client = $this->getWebsiteApiClient($websiteId);
116
+ $response = $client->postContacts($email);
117
+ return $response->id;
118
+ }
119
+
120
+ public function getCustomerAddressBook($website)
121
+ {
122
+ $website = Mage::app()->getWebsite($website);
123
+ return $website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMERS_ADDRESS_BOOK_ID);
124
+ }
125
+
126
+ public function getSubscriberAddressBook($website)
127
+ {
128
+ $website = Mage::app()->getWebsite($website);
129
+ return $website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_SUBSCRIBERS_ADDRESS_BOOK_ID);
130
+ }
131
+
132
+ public function getGuestAddressBook($website)
133
+ {
134
+ $website = Mage::app()->getWebsite($website);
135
+ return $website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_GUEST_ADDRESS_BOOK_ID);
136
+ }
137
+
138
+ /**
139
+ * @return $this
140
+ */
141
+ public function allowResourceFullExecution()
142
+ {
143
+ if ($this->getResourceAllocationEnabled()) {
144
+
145
+ /* it may be needed to set maximum execution time of the script to longer,
146
+ * like 60 minutes than usual */
147
+ set_time_limit(7200);
148
+
149
+ /* and memory to 512 megabytes */
150
+ ini_set('memory_limit', '512M');
151
+ }
152
+ return $this;
153
+ }
154
+ public function convert($size)
155
+ {
156
+ $unit=array('b','kb','mb','gb','tb','pb');
157
+ return @round($size/pow(1024,($i=floor(log($size,1024)))),2).' '.$unit[$i];
158
+ }
159
+
160
+ /**
161
+ * @return string
162
+ */
163
+ public function getStringWebsiteApiAccounts()
164
+ {
165
+ $accounts = array();
166
+ foreach (Mage::app()->getWebsites() as $website) {
167
+ $websiteId = $website->getId();
168
+ $apiUsername = $this->getApiUsername($website);
169
+ $accounts[$apiUsername] = $apiUsername . ', websiteId: ' . $websiteId . ' name ' . $website->getName();
170
+ }
171
+ return implode('</br>', $accounts);
172
+ }
173
+
174
+ public function getCustomAttributes($website = 0)
175
+ {
176
+ $website = Mage::app()->getWebsite($website);
177
+ return unserialize($website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_MAPPING_CUSTOM_DATAFIELDS));
178
+ }
179
+
180
+ /**
181
+ * @param $path
182
+ * @param null|string|bool|int|Mage_Core_Model_Website $websiteId
183
+ * @return mixed
184
+ */
185
+ public function getWebsiteConfig($path, $websiteId = 0)
186
+ {
187
+ $website = Mage::app()->getWebsite($websiteId);
188
+ return $website->getConfig($path);
189
+ }
190
+
191
+ /**
192
+ * Api client by website.
193
+ * @param int $website
194
+ * @return Dotdigitalgroup_Email_Model_Apiconnector_Client
195
+ */
196
+ public function getWebsiteApiClient($website = 0)
197
+ {
198
+ $client = Mage::getModel('email_connector/apiconnector_client');
199
+ $client->setApiUsername($this->getApiUsername($website))
200
+ ->setApiPassword($this->getApiPassword($website));
201
+
202
+ return $client;
203
+ }
204
+
205
+ /**
206
+ * Retrieve authorisation code.
207
+ */
208
+ public function getCode()
209
+ {
210
+ $adminUser = Mage::getSingleton('admin/session')->getUser();
211
+ $code = $adminUser->getEmailCode();
212
+
213
+ return $code;
214
+ }
215
+
216
+ /**
217
+ * Autorisation url.
218
+ * @return string
219
+ */
220
+ public function getAuthoriseUrl()
221
+ {
222
+ $clientId = Mage::getStoreConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CLIENT_ID);
223
+ $baseUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB, true);
224
+ $callback = $baseUrl . 'connector/email/callback';
225
+ $adminUser = Mage::getSingleton('admin/session')->getUser();
226
+
227
+ $params = array(
228
+ 'redirect_uri' => $callback,
229
+ 'scope' => 'Account',
230
+ 'state' => $adminUser->getId(),
231
+ 'response_type' => 'code'
232
+ );
233
+ $url = Dotdigitalgroup_Email_Helper_Config::API_CONNECTOR_URL_AUTHORISE . http_build_query($params) . '&client_id=' . $clientId;
234
+ Mage::helper('connector')->log('Authorization code url : '. $url);
235
+
236
+ return $url;
237
+ }
238
+
239
+ /**
240
+ * order status config value
241
+ * @param int $website
242
+ * @return mixed order status
243
+ */
244
+ public function getConfigSelectedStatus($website = 0)
245
+ {
246
+ $status = $this->getWebsiteConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_SYNC_ORDER_STATUS, $website);
247
+ if($status)
248
+ return explode(',',$status);
249
+ else
250
+ return false;
251
+ }
252
+
253
+ /**
254
+ * check sweet tooth installed/active status
255
+ * @return boolean
256
+ */
257
+ public function isSweetToothEnabled()
258
+ {
259
+ return (bool)Mage::getConfig()->getModuleConfig('TBT_Rewards')->is('active', 'true');
260
+ }
261
+
262
+ /**
263
+ * check sweet tooth installed/active status and active status
264
+ * @param Mage_Core_Model_Website $website
265
+ * @return boolean
266
+ */
267
+ public function isSweetToothToGo($website)
268
+ {
269
+ $stMappingStatus = $this->getWebsiteConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_MAPPING_SWEETTOOTH_ACTIVE, $website->getData('website_id'));
270
+ if($stMappingStatus && $this->isSweetToothEnabled()) return true;
271
+ return false;
272
+ }
273
+
274
+ public function setConnectorContactToReImport($customerId)
275
+ {
276
+ $contactModel = Mage::getModel('email_connector/contact');
277
+ $contactModel
278
+ ->loadByCustomerId($customerId)
279
+ ->setEmailImported(Dotdigitalgroup_Email_Model_Contact::EMAIL_CONTACT_NOT_IMPORTED)
280
+ ->save();
281
+ }
282
+
283
+ }
app/code/{local → community}/Dotdigitalgroup/Email/Helper/File.php RENAMED
@@ -1,7 +1,5 @@
1
  <?php
2
- /*
3
- empty helper to keep admin from breaking
4
- */
5
  class Dotdigitalgroup_Email_Helper_File extends Dotdigitalgroup_Email_Helper_Data
6
  {
7
 
@@ -15,8 +13,8 @@ class Dotdigitalgroup_Email_Helper_File extends Dotdigitalgroup_Email_Helper_Dat
15
  private $delimiter; // set in _construct
16
  private $enclosure; // set in _construct
17
 
18
- public function __construct() {
19
-
20
  $this->_output_folder = Mage::getBaseDir('var') . DS . 'export' . DS . 'email';
21
  $this->_output_archive_folder = $this->_output_folder . DS . 'archive';
22
 
@@ -25,34 +23,37 @@ class Dotdigitalgroup_Email_Helper_File extends Dotdigitalgroup_Email_Helper_Dat
25
  } // end
26
 
27
 
28
- public function getOutputFolder() {
 
29
  $this->pathExists($this->_output_folder);
30
  return $this->_output_folder;
31
  } // end
32
 
33
- public function getArchiveFolder() {
 
34
  $this->pathExists($this->_output_archive_folder);
35
  return $this->_output_archive_folder;
36
  } // end
37
 
38
  /* Return the full filepath */
39
- public function getFilePath($filename) {
 
40
  return $this->getOutputFolder() . DS . $filename;
41
  }
42
 
43
- public function archiveCSV($filename) {
44
-
45
  $this->moveFile($this->getOutputFolder(), $this->getArchiveFolder(), $filename);
46
  }
47
 
48
  /**
49
  * Moves the output file from one folder to the next
50
- *
51
- * @param string $source_folder
52
- * @param string $dest_folder
53
  */
54
- public function moveFile($source_folder, $dest_folder, $filename ){
55
-
56
  // generate the full file paths
57
  $source_filepath = $source_folder . DS . $filename;
58
  $dest_filepath = $dest_folder . DS . $filename;
@@ -68,15 +69,15 @@ class Dotdigitalgroup_Email_Helper_File extends Dotdigitalgroup_Email_Helper_Dat
68
  * @param $filepath
69
  * @param $csv
70
  */
71
- public function outputForceQuotesCSV($filepath, $csv) {
72
-
73
  $fqCsv = $this->arrayToCsv($csv,chr(9),'"',true,false);
74
  // Open for writing only; place the file pointer at the end of the file. If the file does not exist, attempt to create it.
75
  $fp = fopen($filepath, "a");
76
 
77
  // for some reason passing the preset delimiter/enclosure variables results in error
78
- if (fwrite($fp, $fqCsv) == 0 ) //$this->delimiter $this->enclosure
79
- {
80
  Mage::throwException('Problem writing CSV file');
81
  }
82
  fclose($fp);
@@ -89,14 +90,14 @@ class Dotdigitalgroup_Email_Helper_File extends Dotdigitalgroup_Email_Helper_Dat
89
  * @param $filepath
90
  * @param $csv
91
  */
92
- public function outputCSV($filepath, $csv) {
93
-
94
  // Open for writing only; place the file pointer at the end of the file. If the file does not exist, attempt to create it.
95
  $handle = fopen($filepath, "a");
96
 
97
  // for some reason passing the preset delimiter/enclosure variables results in error
98
- if (fputcsv($handle, $csv, ',', '"') == 0 ) //$this->delimiter $this->enclosure
99
- {
100
  Mage::throwException('Problem writing CSV file');
101
  }
102
 
@@ -109,8 +110,9 @@ class Dotdigitalgroup_Email_Helper_File extends Dotdigitalgroup_Email_Helper_Dat
109
  * If the path does not exist then create it
110
  * @param string $path
111
  */
112
- public function pathExists($path) {
113
- if (!is_dir( $path ) ) {
 
114
  mkdir($path, 0777, true);
115
  } // end
116
 
@@ -119,7 +121,8 @@ class Dotdigitalgroup_Email_Helper_File extends Dotdigitalgroup_Email_Helper_Dat
119
  } // end
120
 
121
 
122
- protected function arrayToCsv( array &$fields, $delimiter, $enclosure, $encloseAll = false, $nullToMysqlNull = false ) {
 
123
  $delimiter_esc = preg_quote($delimiter, '/');
124
  $enclosure_esc = preg_quote($enclosure, '/');
125
 
@@ -131,10 +134,9 @@ class Dotdigitalgroup_Email_Helper_File extends Dotdigitalgroup_Email_Helper_Dat
131
  }
132
 
133
  // Enclose fields containing $delimiter, $enclosure or whitespace
134
- if ( $encloseAll || preg_match( "/(?:${delimiter_esc}|${enclosure_esc}|\s)/", $field ) ) {
135
  $output[] = $enclosure . str_replace($enclosure, $enclosure . $enclosure, $field) . $enclosure;
136
- }
137
- else {
138
  $output[] = $field;
139
  }
140
  }
@@ -156,4 +158,32 @@ class Dotdigitalgroup_Email_Helper_File extends Dotdigitalgroup_Email_Helper_Dat
156
  }
157
 
158
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
159
  }
1
  <?php
2
+
 
 
3
  class Dotdigitalgroup_Email_Helper_File extends Dotdigitalgroup_Email_Helper_Data
4
  {
5
 
13
  private $delimiter; // set in _construct
14
  private $enclosure; // set in _construct
15
 
16
+ public function __construct()
17
+ {
18
  $this->_output_folder = Mage::getBaseDir('var') . DS . 'export' . DS . 'email';
19
  $this->_output_archive_folder = $this->_output_folder . DS . 'archive';
20
 
23
  } // end
24
 
25
 
26
+ public function getOutputFolder()
27
+ {
28
  $this->pathExists($this->_output_folder);
29
  return $this->_output_folder;
30
  } // end
31
 
32
+ public function getArchiveFolder()
33
+ {
34
  $this->pathExists($this->_output_archive_folder);
35
  return $this->_output_archive_folder;
36
  } // end
37
 
38
  /* Return the full filepath */
39
+ public function getFilePath($filename)
40
+ {
41
  return $this->getOutputFolder() . DS . $filename;
42
  }
43
 
44
+ public function archiveCSV($filename)
45
+ {
46
  $this->moveFile($this->getOutputFolder(), $this->getArchiveFolder(), $filename);
47
  }
48
 
49
  /**
50
  * Moves the output file from one folder to the next
51
+ * @param $source_folder
52
+ * @param $dest_folder
53
+ * @param $filename
54
  */
55
+ public function moveFile($source_folder, $dest_folder, $filename )
56
+ {
57
  // generate the full file paths
58
  $source_filepath = $source_folder . DS . $filename;
59
  $dest_filepath = $dest_folder . DS . $filename;
69
  * @param $filepath
70
  * @param $csv
71
  */
72
+ public function outputForceQuotesCSV($filepath, $csv)
73
+ {
74
  $fqCsv = $this->arrayToCsv($csv,chr(9),'"',true,false);
75
  // Open for writing only; place the file pointer at the end of the file. If the file does not exist, attempt to create it.
76
  $fp = fopen($filepath, "a");
77
 
78
  // for some reason passing the preset delimiter/enclosure variables results in error
79
+ // $this->delimiter $this->enclosure
80
+ if (fwrite($fp, $fqCsv) == 0 ) {
81
  Mage::throwException('Problem writing CSV file');
82
  }
83
  fclose($fp);
90
  * @param $filepath
91
  * @param $csv
92
  */
93
+ public function outputCSV($filepath, $csv)
94
+ {
95
  // Open for writing only; place the file pointer at the end of the file. If the file does not exist, attempt to create it.
96
  $handle = fopen($filepath, "a");
97
 
98
  // for some reason passing the preset delimiter/enclosure variables results in error
99
+ //$this->delimiter $this->enclosure
100
+ if (fputcsv($handle, $csv, ',', '"') == 0 ) {
101
  Mage::throwException('Problem writing CSV file');
102
  }
103
 
110
  * If the path does not exist then create it
111
  * @param string $path
112
  */
113
+ public function pathExists($path)
114
+ {
115
+ if (!is_dir($path)) {
116
  mkdir($path, 0777, true);
117
  } // end
118
 
121
  } // end
122
 
123
 
124
+ protected function arrayToCsv( array &$fields, $delimiter, $enclosure, $encloseAll = false, $nullToMysqlNull = false )
125
+ {
126
  $delimiter_esc = preg_quote($delimiter, '/');
127
  $enclosure_esc = preg_quote($enclosure, '/');
128
 
134
  }
135
 
136
  // Enclose fields containing $delimiter, $enclosure or whitespace
137
+ if ($encloseAll || preg_match( "/(?:${delimiter_esc}|${enclosure_esc}|\s)/", $field )) {
138
  $output[] = $enclosure . str_replace($enclosure, $enclosure . $enclosure, $field) . $enclosure;
139
+ } else {
 
140
  $output[] = $field;
141
  }
142
  }
158
  }
159
 
160
 
161
+ public function getWebsiteCustomerMappingDatafields($website)
162
+ {
163
+ $store = $website->getDefaultStore();
164
+ $mappedData = Mage::getStoreConfig('connector_data_mapping/customer_data', $store);
165
+ unset($mappedData['custom_attributes']);
166
+
167
+ $mappedRewardData = $this->getWebsiteCustomerRewardMappingDatafields($website);
168
+ if($mappedRewardData) $mappedData = array_merge($mappedData, $mappedRewardData);
169
+
170
+ foreach ($mappedData as $key => $value) {
171
+ if (! $value)
172
+ unset($mappedData[$key]);
173
+ }
174
+
175
+ return $mappedData;
176
+ }
177
+
178
+ public function getWebsiteCustomerRewardMappingDatafields($website)
179
+ {
180
+ $helper = Mage::helper('connector');
181
+ if($helper->isSweetToothToGo($website)) {
182
+ $store = $website->getDefaultStore();
183
+ $mappedData = Mage::getStoreConfig('connector_data_mapping/sweet_tooth', $store);
184
+ unset($mappedData['active']);
185
+ return $mappedData;
186
+ }
187
+ return false;
188
+ }
189
  }
app/code/community/Dotdigitalgroup/Email/Helper/Recommended.php ADDED
@@ -0,0 +1,166 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dotdigitalgroup_Email_Helper_Recommended extends Mage_Core_Helper_Abstract
4
+ {
5
+ const XML_PATH_RELATED_PRODUCTS_TYPE = 'connector_dynamic_content/products/related_display_type';
6
+ const XML_PATH_UPSELL_PRODUCTS_TYPE = 'connector_dynamic_content/products/upsell_display_type';
7
+ const XML_PATH_CROSSSELL_PRODUCTS_TYPE = 'connector_dynamic_content/products/crosssell_display_type';
8
+ const XML_PATH_BESTSELLER_PRODUCT_TYPE = 'connector_dynamic_content/products/bestsellers_display_type';
9
+ const XML_PATH_MOSTVIEWED_PRODUCT_TYPE = 'connector_dynamic_content/products/most_viewed_display_type';
10
+ const XML_PATH_RECENTLYVIEWED_PRODUCT_TYPE = 'connector_dynamic_content/products/recently_viewed_display_type';
11
+ const XML_PATH_PRODUCTPUSH_TYPE = 'connector_dynamic_content/manual_product_search/display_type';
12
+
13
+
14
+ const XML_PATH_RELATED_PRODUCTS_ITEMS = 'connector_dynamic_content/products/related_items_to_display';
15
+ const XML_PATH_UPSELL_PRODUCTS_ITEMS = 'connector_dynamic_content/products/upsell_items_to_display';
16
+ const XML_PATH_CROSSSELL_PRODUCTS_ITEMS = 'connector_dynamic_content/products/crosssell_items_to_display';
17
+ const XML_PATH_BESTSELLER_PRODUCT_ITEMS = 'connector_dynamic_content/products/bestsellers_items_to_display';
18
+ const XML_PATH_MOSTVIEWED_PRODUCT_ITEMS = 'connector_dynamic_content/products/most_viewed_items_to_display';
19
+ const XML_PATH_RECENTLYVIEWED_PRODUCT_ITEMS = 'connector_dynamic_content/products/recently_viewed_items_to_display';
20
+
21
+ const XML_PATH_PRODUCTPUSH_DISPLAY_ITEMS = 'connector_dynamic_content/manual_product_search/items_to_display';
22
+ const XML_PATH_BESTSELLER_TIME_PERIOD = 'connector_dynamic_content/products/bestsellers_time_period';
23
+ const XML_PATH_MOSTVIEWED_TIME_PERIOD = 'connector_dynamic_content/products/most_viewed_time_period';
24
+ const XML_PATH_PRODUCTPUSH_ITEMS = 'connector_dynamic_content/manual_product_search/products_push_items';
25
+ const XML_PATH_FALLBACK_PRODUCTS_ITEMS = 'connector_dynamic_content/fallback_products/product_list';
26
+
27
+ public $periods = array('week', 'month', 'year');
28
+
29
+ /**
30
+ * Dispay type
31
+ * @return mixed|string grid:list
32
+ */
33
+ public function getDisplayType()
34
+ {
35
+ $mode = Mage::app()->getRequest()->getActionName();
36
+ $type = '';
37
+
38
+ switch($mode){
39
+ case 'related':
40
+ $type = $this->getRelatedProductsType();
41
+ break;
42
+ case 'upsell':
43
+ $type = $this->getUpsellProductsType();
44
+ break;
45
+ case 'crosssell':
46
+ $type = $this->getCrosssellProductsType();
47
+ break;
48
+ case 'bestsellers':
49
+ $type = $this->getBestSellerProductsType();
50
+ break;
51
+ case 'mostviewed':
52
+ $type = $this->getMostViewedProductsType();
53
+ break;
54
+ case 'recentlyviewed':
55
+ $type = $this->getRecentlyviewedProductsType();
56
+ break;
57
+ case 'push':
58
+ $type = $this->getProductpushProductsType();
59
+ }
60
+
61
+ return $type;
62
+ }
63
+
64
+ public function getRelatedProductsType()
65
+ {
66
+ return Mage::getStoreConfig(self::XML_PATH_RELATED_PRODUCTS_TYPE);
67
+ }
68
+
69
+ public function getUpsellProductsType()
70
+ {
71
+ return Mage::getStoreConfig(self::XML_PATH_UPSELL_PRODUCTS_TYPE);
72
+
73
+ }
74
+
75
+ public function getCrosssellProductsType()
76
+ {
77
+ return Mage::getStoreConfig(self::XML_PATH_CROSSSELL_PRODUCTS_TYPE);
78
+ }
79
+
80
+ public function getBestSellerProductsType()
81
+ {
82
+ return Mage::getStoreConfig(self::XML_PATH_BESTSELLER_PRODUCT_TYPE);
83
+ }
84
+
85
+ public function getMostViewedProductsType()
86
+ {
87
+ return Mage::getStoreConfig(self::XML_PATH_MOSTVIEWED_PRODUCT_TYPE);
88
+ }
89
+
90
+ public function getRecentlyviewedProductsType()
91
+ {
92
+ return Mage::getStoreConfig(self::XML_PATH_RECENTLYVIEWED_PRODUCT_TYPE);
93
+ }
94
+
95
+ public function getProductpushProductsType()
96
+ {
97
+ return Mage::getStoreConfig(self::XML_PATH_PRODUCTPUSH_TYPE);
98
+ }
99
+
100
+
101
+ /**
102
+ * Limit of products displayed.
103
+ * @param $mode
104
+ * @return int|mixed
105
+ */
106
+ public function getDisplayLimitByMode($mode)
107
+ {
108
+ $result = 0;
109
+ if ($mode) {
110
+ switch($mode){
111
+ case 'related':
112
+ $result = Mage::getStoreConfig(self::XML_PATH_RELATED_PRODUCTS_ITEMS);
113
+ break;
114
+ case 'upsell':
115
+ $result = Mage::getStoreConfig(self::XML_PATH_UPSELL_PRODUCTS_ITEMS);
116
+ break;
117
+ case 'crosssell':
118
+ $result = Mage::getStoreConfig(self::XML_PATH_CROSSSELL_PRODUCTS_ITEMS);
119
+ break;
120
+ case 'bestsellers':
121
+ $result = Mage::getStoreConfig(self::XML_PATH_BESTSELLER_PRODUCT_ITEMS);
122
+ break;
123
+ case 'mostviewed':
124
+ $result = Mage::getStoreConfig(self::XML_PATH_MOSTVIEWED_PRODUCT_ITEMS);
125
+ break;
126
+ case 'recentlyviewed':
127
+ $result = Mage::getStoreConfig(self::XML_PATH_RECENTLYVIEWED_PRODUCT_ITEMS);
128
+ break;
129
+ case 'push':
130
+ $result = Mage::getStoreConfig(self::XML_PATH_PRODUCTPUSH_DISPLAY_ITEMS);
131
+ }
132
+ }
133
+
134
+ return $result;
135
+ }
136
+
137
+ public function getFallbackIds()
138
+ {
139
+ $fallbackIds = Mage::getStoreConfig(self::XML_PATH_FALLBACK_PRODUCTS_ITEMS);
140
+ if ($fallbackIds)
141
+ return explode(',', Mage::getStoreConfig(self::XML_PATH_FALLBACK_PRODUCTS_ITEMS));
142
+ return array();
143
+ }
144
+
145
+ public function getTimeFromConfig($config)
146
+ {
147
+ $now = new Zend_Date();
148
+ $period = Zend_Date::YEAR;
149
+ if ($config == 'mostviewed')
150
+ $period = Mage::getStoreConfig(self::XML_PATH_MOSTVIEWED_TIME_PERIOD);
151
+ elseif($config == 'bestsellers')
152
+ $period = Mage::getStoreConfig(self::XML_PATH_BESTSELLER_TIME_PERIOD);
153
+
154
+ $period = $now->sub(1, $period);
155
+
156
+ return $period->tostring(Zend_Date::ISO_8601);
157
+ }
158
+
159
+ public function getProductPushIds()
160
+ {
161
+ $productIds = Mage::getStoreConfig(self::XML_PATH_PRODUCTPUSH_ITEMS);
162
+
163
+ return explode(',', $productIds);
164
+ }
165
+
166
+ }
app/code/community/Dotdigitalgroup/Email/Helper/Transactional.php ADDED
@@ -0,0 +1,279 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dotdigitalgroup_Email_Helper_Transactional extends Mage_Core_Helper_Abstract
4
+ {
5
+ const XML_PATH_TRANSACTIONAL_API_ENABLED = 'connector_transactional_emails/credentials/enabled';
6
+ const XML_PATH_TRANSACTIONAL_API_USERNAME = 'connector_transactional_emails/credentials/api_username';
7
+ const XML_PATH_TRANSACTIONAL_API_PASSWORD = 'connector_transactional_emails/credentials/api_password';
8
+
9
+ const XML_PATH_CONNECTOR_TRANSACTIONAL_FROM_ADDRESS = 'connector_transactional_emails/email_settings/from_address';
10
+ const XML_PATH_CONNECTOR_TRANSACTIONAL_REPLY_ACTION = 'connector_transactional_emails/email_settings/reply_action';
11
+ const XML_PATH_CONNECTOR_TRANSACTIONAL_REPLY_ADDRESS = 'connector_transactional_emails/email_settings/reply_address';
12
+ const XML_PATH_CONNECTOR_TRANSACTIONAL_SEND_COPY = 'connector_transactional_emails/email_settings/send_copy';
13
+ const XML_PATH_CONNECTOR_TRANSACTIONAL_UNSUBSCRIBE_LINK = 'connector_transactional_emails/email_settings/unsubscribe_link';
14
+
15
+ const XML_PATH_CONNECTOR_TRANSACTIONAL_EMAIL_DEFAULT = 'connector_transactional_emails/email_mapping/default_email_templates';
16
+ const XML_PATH_CONNECTOR_TRANSACTIONAL_EMAIL_CUSTOM = 'connector_transactional_emails/email_mapping/custom_email_templates';
17
+
18
+ const MAP_COLUMN_KEY_DATAFIELD = 'datafield';
19
+ const MAP_COLUMN_KEY_SENDTYPE = 'sendtype';
20
+
21
+ /**
22
+ * Get the api enabled.
23
+ *
24
+ * @return mixed
25
+ */
26
+ public function isEnabled()
27
+ {
28
+ return Mage::getStoreConfig(self::XML_PATH_TRANSACTIONAL_API_ENABLED);
29
+ }
30
+
31
+ /**
32
+ * Get api username.
33
+ *
34
+ * @param int $website
35
+ *
36
+ * @return mixed
37
+ * @throws Mage_Core_Exception
38
+ */
39
+ public function getApiUsername($website = 0)
40
+ {
41
+ $website = Mage::app()->getWebsite($website);
42
+
43
+ return $website->getConfig(self::XML_PATH_TRANSACTIONAL_API_USERNAME);
44
+ }
45
+
46
+ /**
47
+ * Get api password.
48
+ *
49
+ * @param int $website
50
+ *
51
+ * @return mixed
52
+ * @throws Mage_Core_Exception
53
+ */
54
+ public function getApiPassword($website = 0)
55
+ {
56
+ $website = Mage::app()->getWebsite($website);
57
+
58
+ return $website->getConfig(self::XML_PATH_TRANSACTIONAL_API_PASSWORD);
59
+ }
60
+
61
+ /**
62
+ * Website by name.
63
+ * @param $websiteName
64
+ *
65
+ * @return Varien_Object
66
+ */
67
+ public function getWebsiteByName($websiteName)
68
+ {
69
+ $website = Mage::getModel('core/website')->getCollection()
70
+ ->addFieldToFilter('code', $websiteName)->getFirstItem();
71
+
72
+ return $website;
73
+ }
74
+
75
+ /**
76
+ * Find template lable by id.
77
+ * @param mixed $templateId
78
+ *
79
+ * @return string
80
+ */
81
+ public function getTemplateLabelById($templateId)
82
+ {
83
+ $default = Mage::getModel('email_connector/adminhtml_source_transactional_defaultselect')->toOptionArray();
84
+ $custom = Mage::getModel('email_connector/adminhtml_source_transactional_customselect')->toOptionArray();
85
+ $all = array_merge($default,$custom);
86
+
87
+ $label = "";
88
+ foreach($all as $one){
89
+ if($one['value'] == $templateId) {
90
+ $label = $one['label'];
91
+ break;
92
+ }
93
+ }
94
+ return $label;
95
+ }
96
+
97
+ /**
98
+ * get all templates mapping
99
+ * @param $storeId
100
+ * @return array
101
+ */
102
+ public function getAllTemplateMapping($storeId){
103
+ $allTemplateMapping = array();
104
+
105
+ $defaultTemplateMapping = $this->getDefaultEmailTemplates($storeId);
106
+ $customTemplateMapping = $this->getCustomEmailTemplates($storeId);
107
+
108
+ if(is_array($defaultTemplateMapping) && is_array($customTemplateMapping))
109
+ {
110
+ $allTemplateMapping = array_merge($defaultTemplateMapping, $customTemplateMapping);
111
+ }
112
+ elseif(is_array($defaultTemplateMapping))
113
+ {
114
+ $allTemplateMapping = $defaultTemplateMapping;
115
+ }
116
+ elseif(is_array($customTemplateMapping))
117
+ {
118
+ $allTemplateMapping = $customTemplateMapping;
119
+ }
120
+
121
+ return $allTemplateMapping;
122
+ }
123
+
124
+ /**
125
+ * Check if the template is mapped
126
+ * @param $templateId
127
+ * @param $key
128
+ * @param $storeId
129
+ *
130
+ * @return mixed
131
+ */
132
+ public function getMapping($templateId, $key ,$storeId = null)
133
+ {
134
+ $allTemplateMapping = $this->getAllTemplateMapping($storeId);
135
+ $isMapped = false;
136
+
137
+ foreach($allTemplateMapping as $templateMapping)
138
+ {
139
+ if($isMapped = $this->findTemplateIdInArray($templateId, $templateMapping))
140
+ break;
141
+ }
142
+
143
+ if(is_array($isMapped) && $key == self::MAP_COLUMN_KEY_DATAFIELD)
144
+ return $isMapped[self::MAP_COLUMN_KEY_DATAFIELD];
145
+
146
+ if(is_array($isMapped) && $key == self::MAP_COLUMN_KEY_SENDTYPE)
147
+ return $isMapped[self::MAP_COLUMN_KEY_SENDTYPE];
148
+
149
+ return $isMapped;
150
+ }
151
+
152
+ /*
153
+ * find template id in array
154
+ * @param mixed $id
155
+ * @param array $data
156
+ *
157
+ * @return mixed
158
+ */
159
+ public function findTemplateIdInArray($id, $data)
160
+ {
161
+ $result = false;
162
+ foreach($data as $key => $value){
163
+ if($key == 'template' && $value == $id) {
164
+ $result = $data;
165
+ break;
166
+ }
167
+ }
168
+ return $result;
169
+ }
170
+
171
+ /*
172
+ * get un-serialised config value for all default email templates for all modules
173
+ *
174
+ * @return array
175
+ */
176
+ public function getDefaultEmailTemplates($storeId = null)
177
+ {
178
+ return unserialize(Mage::getStoreConfig(self::XML_PATH_CONNECTOR_TRANSACTIONAL_EMAIL_DEFAULT, $storeId));
179
+ }
180
+
181
+ /*
182
+ * get un-serialised config value for custom templates
183
+ *
184
+ * @return array
185
+ */
186
+ public function getCustomEmailTemplates($storeId = null)
187
+ {
188
+ return unserialize(Mage::getStoreConfig(self::XML_PATH_CONNECTOR_TRANSACTIONAL_EMAIL_CUSTOM, $storeId));
189
+ }
190
+
191
+ /**
192
+ * Get the contact id for the custoemer based on website id.
193
+ * @param $email
194
+ * @param $websiteId
195
+ * @return string contact_id
196
+ */
197
+ public function getContactId($email, $websiteId)
198
+ {
199
+ $client = $this->getWebsiteApiClient($websiteId);
200
+ $response = $client->postContacts($email);
201
+ if (isset($response->message))
202
+ return $response->message;
203
+ return $response->id;
204
+ }
205
+
206
+ /**
207
+ * Update contact default datafields.
208
+ *
209
+ * @param $contacData
210
+ */
211
+ public function updateContactData($contacData)
212
+ {
213
+ $client = $this->getWebsiteApiClient($contacData->getWebsite());
214
+ $email = $contacData->getCustomerEmail();
215
+ /**
216
+ * Transactional account data default datafields.
217
+ */
218
+ $data = array(
219
+ array(
220
+ 'Key' => 'LAST_ORDER_ID',
221
+ 'Value' => $contacData->getOrderId()),
222
+ array(
223
+ 'Key' => 'CUSTOMER_ID',
224
+ 'Value' => $contacData->getCustomerId()),
225
+ array(
226
+ 'Key' => 'ORDER_INCREMENT_ID',
227
+ 'Value' => $contacData->getOrderIncrementId()),
228
+ array(
229
+ 'Key' => 'WEBSITE_NAME',
230
+ 'Value' => $contacData->getWebsiteName()),
231
+ array(
232
+ 'Key' => 'STORE_NAME',
233
+ 'Value' => $contacData->getStoreName()),
234
+ array(
235
+ 'Key' => 'LAST_ORDER_DATE',
236
+ 'Value' => $contacData->getOrderDate())
237
+ );
238
+ $client->updateContactDatafieldsByEmail($email, $data);
239
+ }
240
+
241
+ /**
242
+ * Api client by website.
243
+ * @param int $website
244
+ * @return Dotdigitalgroup_Email_Model_Apiconnector_Client
245
+ */
246
+ public function getWebsiteApiClient($website = 0)
247
+ {
248
+ $client = Mage::getModel('email_connector/apiconnector_client');
249
+ $client->setApiUsername($this->getApiUsername($website))
250
+ ->setApiPassword($this->getApiPassword($website));
251
+
252
+ return $client;
253
+ }
254
+
255
+ public function getEmailSettings($path, $websiteId)
256
+ {
257
+ $helper = Mage::helper('connector');
258
+ return $helper->getWebsiteConfig($path, $websiteId);
259
+ }
260
+
261
+ public function getFromAddress($websiteId){
262
+ return $this->getEmailSettings(self::XML_PATH_CONNECTOR_TRANSACTIONAL_FROM_ADDRESS, $websiteId);
263
+ }
264
+
265
+ public function getReplyAction($websiteId){
266
+ return $this->getEmailSettings(self::XML_PATH_CONNECTOR_TRANSACTIONAL_REPLY_ACTION, $websiteId);
267
+ }
268
+
269
+ public function getReplyAddress($websiteId){
270
+ return $this->getEmailSettings(self::XML_PATH_CONNECTOR_TRANSACTIONAL_REPLY_ADDRESS, $websiteId);
271
+ }
272
+
273
+ public function getSendCopy($websiteId){
274
+ return $this->getEmailSettings(self::XML_PATH_CONNECTOR_TRANSACTIONAL_SEND_COPY, $websiteId);
275
+ }
276
+ public function getUnsubscribeLink($websiteId){
277
+ return $this->getEmailSettings(self::XML_PATH_CONNECTOR_TRANSACTIONAL_UNSUBSCRIBE_LINK, $websiteId);
278
+ }
279
+ }
app/code/community/Dotdigitalgroup/Email/Model/Abstract/Rest.php ADDED
@@ -0,0 +1,435 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ abstract class Dotdigitalgroup_Email_Model_Abstract_Rest
4
+ {
5
+ protected $url;
6
+ protected $verb;
7
+ protected $requestBody;
8
+ protected $requestLength;
9
+ protected $_apiUsername;
10
+ protected $_apiPassword;
11
+ protected $acceptType;
12
+ protected $responseBody;
13
+ protected $responseInfo;
14
+
15
+ public function __construct($website = 0) // ($url = null, $verb = 'GET', $requestBody = null)
16
+ {
17
+ $this->url = null; //$url;
18
+ $this->verb = 'GET'; //$verb;
19
+ $this->requestBody = null; //$requestBody;
20
+ $this->requestLength = 0;
21
+ $this->_apiUsername = (string)Mage::helper('connector')->getApiUsername($website);
22
+ $this->_apiPassword = (string)Mage::helper('connector')->getApiPassword($website);
23
+ $this->acceptType = 'application/json';
24
+ $this->responseBody = null;
25
+ $this->responseInfo = null;
26
+
27
+ if ($this->requestBody !== null) {
28
+ $this->buildPostBody();
29
+ }
30
+ }
31
+
32
+ private function prettyPrint($json)
33
+ {
34
+ $result = '';
35
+ $level = 0;
36
+ $prev_char = '';
37
+ $in_quotes = false;
38
+ $ends_line_level = NULL;
39
+ $json_length = strlen( $json );
40
+
41
+ for ($i = 0; $i < $json_length; $i++) {
42
+ $char = $json[$i];
43
+ $new_line_level = NULL;
44
+ $post = "";
45
+ if ($ends_line_level !== NULL) {
46
+ $new_line_level = $ends_line_level;
47
+ $ends_line_level = NULL;
48
+ }
49
+ if ($char === '"' && $prev_char != '\\') {
50
+ $in_quotes = !$in_quotes;
51
+ } elseif (! $in_quotes) {
52
+ switch ($char) {
53
+ case '}': case ']':
54
+ $level--;
55
+ $ends_line_level = NULL;
56
+ $new_line_level = $level;
57
+ break;
58
+
59
+ case '{': case '[':
60
+ $level++;
61
+ case ',':
62
+ $ends_line_level = $level;
63
+ break;
64
+
65
+ case ':':
66
+ $post = " ";
67
+ break;
68
+
69
+ case " ": case "\t": case "\n": case "\r":
70
+ $char = "";
71
+ $ends_line_level = $new_line_level;
72
+ $new_line_level = NULL;
73
+ break;
74
+ }
75
+ }
76
+ if ($new_line_level !== NULL) {
77
+ $result .= "\n".str_repeat( "\t", $new_line_level );
78
+ }
79
+ $result .= $char.$post;
80
+ $prev_char = $char;
81
+ }
82
+
83
+ return $result;
84
+ }
85
+
86
+ /**
87
+ * returns the object as JSON.
88
+ *
89
+ * @param bool $pretty
90
+ *
91
+ * @return string
92
+ */
93
+ public function toJSON($pretty=false)
94
+ {
95
+
96
+ if (!$pretty) {
97
+ return json_encode($this->expose());
98
+ } else {
99
+ return $this->prettyPrint(json_encode($this->expose()));
100
+ }
101
+ }
102
+
103
+ /**
104
+ * exposes the class as an array of objects
105
+ * @return array
106
+ */
107
+ public function expose()
108
+ {
109
+
110
+ return get_object_vars($this);
111
+
112
+ }
113
+
114
+
115
+ /**
116
+ * Reset the client.
117
+ *
118
+ * @return $this
119
+ */
120
+ public function flush ()
121
+ {
122
+ $this->_apiUsername = '';
123
+ $this->_apiPassword = '';
124
+ $this->requestBody = null;
125
+ $this->requestLength = 0;
126
+ $this->verb = 'GET';
127
+ $this->responseBody = null;
128
+ $this->responseInfo = null;
129
+ return $this;
130
+ }
131
+
132
+ /**
133
+ * Execute the curl request.
134
+ *
135
+ * @return null
136
+ * @throws Exception
137
+ */
138
+ public function execute()
139
+ {
140
+ $ch = curl_init();
141
+ $this->setAuth($ch);
142
+ try
143
+ {
144
+ switch (strtoupper($this->verb))
145
+ {
146
+ case 'GET':
147
+ $this->executeGet($ch);
148
+ break;
149
+ case 'POST':
150
+ $this->executePost($ch);
151
+ break;
152
+ case 'PUT':
153
+ $this->executePut($ch);
154
+ break;
155
+ case 'DELETE':
156
+ $this->executeDelete($ch);
157
+ break;
158
+ default:
159
+ throw new InvalidArgumentException('Current verb (' . $this->verb . ') is an invalid REST verb.');
160
+ }
161
+ }catch (InvalidArgumentException $e){
162
+ curl_close($ch);
163
+ throw $e;
164
+ }catch (Exception $e){
165
+ curl_close($ch);
166
+ throw $e;
167
+ }
168
+
169
+ return $this->responseBody;
170
+ }
171
+
172
+ /**
173
+ * Post data.
174
+ *
175
+ * @param null $data
176
+ *
177
+ * @return $this
178
+ */
179
+ public function buildPostBody($data = null)
180
+ {
181
+ $this->requestBody = json_encode($data);
182
+ return $this;
183
+ }
184
+
185
+ /**
186
+ * Execute curl get request.
187
+ *
188
+ * @param $ch
189
+ */
190
+ protected function executeGet($ch)
191
+ {
192
+ $this->doExecute($ch);
193
+ }
194
+
195
+ /**
196
+ * Execute post request.
197
+ *
198
+ * @param $ch
199
+ */
200
+ protected function executePost($ch)
201
+ {
202
+ if (!is_string($this->requestBody)) {
203
+ $this->buildPostBody();
204
+ }
205
+
206
+ curl_setopt($ch, CURLOPT_POSTFIELDS, $this->requestBody);
207
+ curl_setopt($ch, CURLOPT_POST, true);
208
+
209
+ $this->doExecute($ch);
210
+ }
211
+
212
+ /**
213
+ * Post from the file.
214
+ *
215
+ * @param $filename
216
+ */
217
+ protected function buildPostBodyFromFile($filename)
218
+ {
219
+ $this->requestBody = array (
220
+ 'file' => '@'.$filename
221
+ );
222
+ }
223
+
224
+ /**
225
+ * Execute put.
226
+ *
227
+ * @param $ch
228
+ */
229
+ protected function executePut($ch)
230
+ {
231
+ if (!is_string($this->requestBody)) {
232
+ $this->buildPostBody();
233
+ }
234
+
235
+ $this->requestLength = strlen($this->requestBody);
236
+
237
+ $fh = fopen('php://memory', 'rw');
238
+ fwrite($fh, $this->requestBody);
239
+ rewind($fh);
240
+
241
+ curl_setopt($ch, CURLOPT_INFILE, $fh);
242
+ curl_setopt($ch, CURLOPT_INFILESIZE, $this->requestLength);
243
+ curl_setopt($ch, CURLOPT_PUT, true);
244
+
245
+ $this->doExecute($ch);
246
+
247
+ fclose($fh);
248
+ }
249
+
250
+ /**
251
+ * Ececute delete.
252
+ *
253
+ * @param $ch
254
+ */
255
+ protected function executeDelete($ch)
256
+ {
257
+ curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'DELETE');
258
+
259
+ $this->doExecute($ch);
260
+ }
261
+
262
+ /**
263
+ * Execute request.
264
+ *
265
+ * @param $ch
266
+ */
267
+ protected function doExecute(&$ch)
268
+ {
269
+ $this->setCurlOpts($ch);
270
+ $this->responseBody = json_decode(curl_exec($ch));
271
+ $this->responseInfo = curl_getinfo($ch);
272
+
273
+ curl_close($ch);
274
+ }
275
+
276
+ /**
277
+ * curl options.
278
+ *
279
+ * @param $ch
280
+ */
281
+ protected function setCurlOpts(&$ch)
282
+ {
283
+ curl_setopt($ch, CURLOPT_TIMEOUT, 10);
284
+ curl_setopt($ch, CURLOPT_URL, $this->url);
285
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
286
+ curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
287
+ curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
288
+ curl_setopt($ch, CURLOPT_HTTPHEADER, array ('Accept: ' . $this->acceptType ,'Content-Type: application/json'));
289
+ }
290
+
291
+ /**
292
+ * basic auth.
293
+ *
294
+ * @param $ch
295
+ */
296
+ protected function setAuth(&$ch)
297
+ {
298
+ if ($this->_apiUsername !== null && $this->_apiPassword !== null)
299
+ {
300
+ curl_setopt($ch, CURLAUTH_BASIC, CURLAUTH_DIGEST);
301
+ curl_setopt($ch, CURLOPT_USERPWD, $this->_apiUsername . ':' . $this->_apiPassword);
302
+ }
303
+ }
304
+
305
+ /**
306
+ * Get accept type.
307
+ *
308
+ * @return string
309
+ */
310
+ public function getAcceptType()
311
+ {
312
+ return $this->acceptType;
313
+ }
314
+
315
+ /**
316
+ * set accept type.
317
+ *
318
+ * @param $acceptType
319
+ */
320
+ public function setAcceptType($acceptType)
321
+ {
322
+ $this->acceptType = $acceptType;
323
+ }
324
+
325
+
326
+ /**
327
+ * get api username.
328
+ *
329
+ * @return string
330
+ */
331
+ public function getApiUsername()
332
+ {
333
+ return $this->_apiUsername;
334
+ }
335
+
336
+ /**
337
+ * set api username.
338
+ *
339
+ * @param $apiUsername
340
+ *
341
+ * @return $this
342
+ */
343
+ public function setApiUsername($apiUsername)
344
+ {
345
+ $this->_apiUsername = $apiUsername;
346
+ return $this;
347
+ }
348
+ /**
349
+ * Get api password.
350
+ *
351
+ * @return string
352
+ */
353
+ public function getApiPassword()
354
+ {
355
+ return $this->_apiPassword;
356
+ }
357
+
358
+ /**
359
+ * set api password.
360
+ * @param $apiPassword
361
+ *
362
+ * @return $this
363
+ */
364
+ public function setApiPassword($apiPassword)
365
+ {
366
+ $this->_apiPassword = $apiPassword;
367
+ return $this;
368
+ }
369
+
370
+ /**
371
+ * get response body.
372
+ *
373
+ * @return string/object
374
+ */
375
+ public function getResponseBody()
376
+ {
377
+ return $this->responseBody;
378
+ }
379
+
380
+ /**
381
+ * get response info.
382
+ *
383
+ * @return null
384
+ */
385
+ public function getResponseInfo()
386
+ {
387
+ return $this->responseInfo;
388
+ }
389
+
390
+ /**
391
+ * get url.
392
+ *
393
+ * @return string
394
+ */
395
+ public function getUrl()
396
+ {
397
+ return $this->url;
398
+ }
399
+
400
+ /**
401
+ * set url.
402
+ *
403
+ * @param $url
404
+ *
405
+ * @return $this
406
+ */
407
+ public function setUrl($url)
408
+ {
409
+ $this->url = $url;
410
+ return $this;
411
+ }
412
+
413
+ /**
414
+ * get the verb.
415
+ *
416
+ * @return string
417
+ */
418
+ public function getVerb ()
419
+ {
420
+ return $this->verb;
421
+ }
422
+
423
+ /**
424
+ * set the verb.
425
+ *
426
+ * @param $verb
427
+ *
428
+ * @return $this
429
+ */
430
+ public function setVerb ($verb)
431
+ {
432
+ $this->verb = $verb;
433
+ return $this;
434
+ }
435
+ }
app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Observer.php ADDED
@@ -0,0 +1,93 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dotdigitalgroup_Email_Model_Adminhtml_Observer
4
+ {
5
+
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('email_connector/contact');
14
+ $numImported = $contactModel->getNumberOfImportedContacs();
15
+ $updated = $contactModel->resetAllContacts();
16
+ Mage::helper('connector')->log('-- Imported contacts: ' . $numImported . ' reseted : ' . $updated . '--');
17
+
18
+ return $this;
19
+ }
20
+
21
+ /**
22
+ * API Transactional Section.
23
+ * Default data fields for transactional account.
24
+ * @return $this
25
+ */
26
+ public function actionConfigTransactional()
27
+ {
28
+ $client = Mage::getModel('email_connector/apiconnector_client');
29
+ $username = Mage::helper('connector/transactional')->getApiUsername();
30
+ $password = Mage::helper('connector/transactional')->getApiPassword();
31
+ $client->setApiUsername($username)->setApiPassword($password);
32
+ $dataFields = Mage::getModel('email_connector/connector_datafield')->getTransactionalDefaultDatafields();
33
+
34
+ foreach ($dataFields as $field) {
35
+ //create the datafields
36
+ $client->postDataFields($field);
37
+ }
38
+ return $this;
39
+ }
40
+
41
+ /**
42
+ * API Credentials.
43
+ * Installation and validation confirmation.
44
+ * @return $this
45
+ */
46
+ public function actionConfigSaveApi()
47
+ {
48
+ $groups = Mage::app()->getRequest()->getPost('groups');
49
+ if (isset($groups['api']['fields']['username']['inherit']) || isset($groups['api']['fields']['password']['inherit']))
50
+ return $this;
51
+
52
+ $apiUsername = isset($groups['api']['fields']['username']['value'])? $groups['api']['fields']['username']['value'] : false;
53
+ $apiPassword = isset($groups['api']['fields']['password']['value'])? $groups['api']['fields']['password']['value'] : false;
54
+ //skip if the inherit option is selected
55
+ if ($apiUsername && $apiPassword) {
56
+ Mage::helper('connector')->log('----VALIDATING ACCOUNT---');
57
+ $testModel = Mage::getModel('email_connector/apiconnector_test');
58
+ $isValid = $testModel->validate($apiUsername, $apiPassword);
59
+ if ($isValid) {
60
+ /**
61
+ * Create account contact datafields
62
+ */
63
+ $client = Mage::getModel('email_connector/apiconnector_client');
64
+ $client->setApiUsername($apiUsername)
65
+ ->setApiPassword($apiPassword);
66
+ $datafields = Mage::getModel('email_connector/connector_datafield')->getDefaultDataFields();
67
+ foreach ($datafields as $datafield) {
68
+ $client->postDataFields($datafield);
69
+ }
70
+ /**
71
+ * Send install info
72
+ */
73
+ $testModel->sendInstallConfirmation();
74
+ } else {
75
+ /**
76
+ * Disable invalid Api credentials
77
+ */
78
+ $scopeId = 0;
79
+ if ($website = Mage::app()->getRequest()->getParam('website')) {
80
+ $scope = 'websites';
81
+ $scopeId = Mage::app()->getWebsite($website)->getId();
82
+ } else {
83
+ $scope = "default";
84
+ }
85
+ $config = Mage::getConfig();
86
+ $config->saveConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_API_ENABLED, 0, $scope, $scopeId);
87
+ $config->cleanCache();
88
+ }
89
+ Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('connector')->__('API Credentials Valid.'));
90
+ }
91
+ return $this;
92
+ }
93
+ }
app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Source/Addressbooks.php ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dotdigitalgroup_Email_Model_Adminhtml_Source_Addressbooks
4
+ {
5
+ /**
6
+ * Returns the address books options.
7
+ *
8
+ * @return array
9
+ */
10
+ public function toOptionArray()
11
+ {
12
+ $fields = array();
13
+
14
+ $website = Mage::app()->getRequest()->getParam('website');
15
+ $client = Mage::getModel('email_connector/apiconnector_client');
16
+
17
+ $client->setApiUsername(Mage::helper('connector')->getApiUsername($website));
18
+ $client->setApiPassword(Mage::helper('connector')->getApiPassword($website));
19
+
20
+ // Add a "Do Not Map" Option
21
+ $fields[] = array('value' => 0, 'label' => Mage::helper('connector')->__('-- Please Select --'));
22
+ $savedAddressBooks = Mage::registry('addressbooks');
23
+ if ($savedAddressBooks) {
24
+ $addressBooks = $savedAddressBooks;
25
+ } else {
26
+ // api all address books
27
+ $addressBooks = $client->getAddressBooks();
28
+ Mage::register('addressbooks', $addressBooks);
29
+ }
30
+
31
+ if (isset($addressBooks->message)) {
32
+ $fields[] = array('value' => 0, 'label' => Mage::helper('connector')->__('-- Please Select --'));
33
+ }
34
+
35
+ //set up fields with book id and label
36
+ foreach ($addressBooks as $book) {
37
+ if(isset($book->id))
38
+ $fields[] = array('value' => $book->id, 'label' => $book->name);
39
+ }
40
+
41
+ return $fields;
42
+ }
43
+
44
+ }
app/code/{local/Dotdigitalgroup/Email/Model/System/Config/Source/Orderlimit.php → community/Dotdigitalgroup/Email/Model/Adminhtml/Source/Advanced/Transdata.php} RENAMED
@@ -1,6 +1,6 @@
1
  <?php
2
 
3
- class Dotdigitalgroup_Email_Model_System_Config_Source_Orderlimit
4
  {
5
  /**
6
  * @return array
1
  <?php
2
 
3
+ class Dotdigitalgroup_Email_Model_Adminhtml_Source_Advanced_Transdata
4
  {
5
  /**
6
  * @return array
app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Source/Automation/Programme.php ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dotdigitalgroup_Email_Model_Adminhtml_Source_Automation_Programme
4
+ {
5
+
6
+ public function toOptionArray()
7
+ {
8
+ $fields = array();
9
+ $websiteName = Mage::app()->getRequest()->getParam('website', false);
10
+ //admin
11
+ $website = 0;
12
+ if ($websiteName) {
13
+ $website = Mage::app()->getWebsite($websiteName);
14
+ }
15
+ $client = Mage::helper('connector')->getWebsiteApiClient($website);
16
+
17
+
18
+ /**
19
+ $savedCampaigns = Mage::registry('savedcampigns');
20
+
21
+ if ($savedCampaigns) {
22
+ $campaigns = $savedCampaigns;
23
+ } else {
24
+ $campaigns = $client->getCampaigns();
25
+ Mage::register('savedcampigns', $campaigns);
26
+ }
27
+ **/
28
+
29
+ $programmes = $client->GetPrograms();
30
+ $fields[] = array('value' => '0', 'label' => Mage::helper('connector')->__('-- Disabled --'));
31
+
32
+ foreach ($programmes as $one) {
33
+ if(isset($one->id))
34
+ $fields[] = array('value' => $one->id, 'label' => Mage::helper('connector')->__($one->name));
35
+ }
36
+
37
+ return $fields;
38
+ }
39
+
40
+ }
app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Source/Campaigns.php ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
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
+ //admin
17
+ $website = 0;
18
+ if ($websiteName) {
19
+ $website = Mage::app()->getWebsite($websiteName);
20
+ }
21
+ $client = Mage::helper('connector')->getWebsiteApiClient($website);
22
+
23
+
24
+ $savedCampaigns = Mage::registry('savedcampigns');
25
+
26
+ if ($savedCampaigns) {
27
+ $campaigns = $savedCampaigns;
28
+ } else {
29
+ $campaigns = $client->getCampaigns();
30
+ Mage::unregister('savedcampigns');
31
+ Mage::register('savedcampigns', $campaigns);
32
+ }
33
+
34
+ $fields[] = array('value' => '0', 'label' => Mage::helper('connector')->__('-- Please Select --'));
35
+
36
+ foreach ($campaigns as $one) {
37
+ if(isset($one->id))
38
+ $fields[] = array('value' => $one->id, 'label' => Mage::helper('connector')->__(addslashes($one->name)));
39
+ }
40
+
41
+ return $fields;
42
+ }
43
+
44
+ }
app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Source/Contact/Imported.php ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dotdigitalgroup_Email_Model_Adminhtml_Source_Contact_Imported
4
+ {
5
+ /**
6
+ * Contact imported options.
7
+ *
8
+ * @return array
9
+ */
10
+ public function getOptions()
11
+ {
12
+ return array(
13
+ '1' => Mage::helper('connector')->__('Imported'),
14
+ 'null' => Mage::helper('connector')->__('Not Imported'),
15
+ );
16
+ }
17
+ }
app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Source/Customer/Attributes/Select.php ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
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', 'dotmailer_contact_id', 'email', 'firstname', 'lastname', 'gender',
18
+ 'group_id', 'password_hash', 'prefix', 'rp_token', 'rp_token_create_at', 'website_id');
19
+ $attributes = Mage::getModel('customer/customer')->getAttributes();
20
+
21
+ foreach ($attributes as $attribute) {
22
+ if ($attribute->getFrontendLabel()) {
23
+ $code = $attribute->getAttributeCode();
24
+ if(!in_array($code, $excluded))
25
+ $options[] = array(
26
+ 'value' => $attribute->getAttributeCode(),
27
+ 'label' => $attribute->getFrontendLabel()
28
+ );
29
+ }
30
+ }
31
+
32
+ return $options;
33
+ }
34
+ }
app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Source/Datafields.php ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dotdigitalgroup_Email_Model_Adminhtml_Source_Datafields
4
+ {
5
+ /**
6
+ * Returns the account's datafields.
7
+ * @return array
8
+ */
9
+ public function toOptionArray()
10
+ {
11
+ $fields = array();
12
+ $helper = Mage::helper('connector');
13
+
14
+ $website = Mage::app()->getRequest()->getParam('website', 0);
15
+ $client = $helper->getWebsiteApiClient($website);
16
+
17
+ /**
18
+ * api get all datafields
19
+ */
20
+ $savedDatafields = Mage::registry('datafields');
21
+ if ($savedDatafields) {
22
+ $datafields = $savedDatafields;
23
+ } else {
24
+ $datafields = $client->getDataFields();
25
+ Mage::register('datafields', $datafields);
26
+ }
27
+
28
+ // Add a "Do Not Map" Option
29
+ $fields[] = array('value' => 0, 'label' => Mage::helper('connector')->__('-- Please Select --'));
30
+
31
+ if (isset($datafields->message)) {
32
+ $fields[] = array('value' => 0, 'label' => $datafields->message);
33
+ }
34
+
35
+
36
+ foreach ($datafields as $datafield) {
37
+ if(isset($datafield->name))
38
+ $fields[] = array('value' => $datafield->name, 'label' => $datafield->name);
39
+ }
40
+
41
+ return $fields;
42
+ }
43
+
44
+
45
+ }
app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Source/Datamapping/Datafieldtype.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
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','label' => Mage::helper('connector')->__('String')),
14
+ array('value' => 'Numeric', 'label' => Mage::helper('connector')->__('Numeric')),
15
+ array('value' => 'Date', 'label' => Mage::helper('connector')->__('Date')),
16
+ array('value' => 'Boolean', 'label' => Mage::helper('connector')->__('Boolean'))
17
+ );
18
+
19
+ return $dataType;
20
+ }
21
+
22
+ }
app/code/{local/Dotdigitalgroup/Email/Model/System/Config/Source → community/Dotdigitalgroup/Email/Model/Adminhtml/Source/Dynamic}/Displaytype.php RENAMED
@@ -1,8 +1,13 @@
1
  <?php
2
 
3
- class Dotdigitalgroup_Email_Model_System_Config_Source_Displaytype
4
  {
5
- public function toOptionArray()
 
 
 
 
 
6
  {
7
  return array(
8
  array('value' => 'grid', 'label' => Mage::helper('connector')->__('Grid')),
1
  <?php
2
 
3
+ class Dotdigitalgroup_Email_Model_Adminhtml_Source_Dynamic_Displaytype
4
  {
5
+ /**
6
+ * Display type mode.
7
+ *
8
+ * @return array
9
+ */
10
+ public function toOptionArray()
11
  {
12
  return array(
13
  array('value' => 'grid', 'label' => Mage::helper('connector')->__('Grid')),
app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Source/Dynamic/Frequency.php ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+
4
+ class Dotdigitalgroup_Email_Model_Adminhtml_Source_Dynamic_Frequency
5
+ {
6
+
7
+ protected static $_options;
8
+
9
+ public function toOptionArray()
10
+ {
11
+ if (!self::$_options) {
12
+ self::$_options = array(
13
+ array(
14
+ 'label' => Mage::helper('cron')->__('Daily'),
15
+ 'value' => Zend_Date::DAY,
16
+ ),
17
+ array(
18
+ 'label' => Mage::helper('cron')->__('Weekly'),
19
+ 'value' => Zend_Date::WEEK,
20
+ ),
21
+ array(
22
+ 'label' => Mage::helper('cron')->__('Monthly'),
23
+ 'value' => Zend_Date::MONTH,
24
+ ),
25
+ );
26
+ }
27
+ return self::$_options;
28
+ }
29
+
30
+ }
app/code/{local/Dotdigitalgroup/Email/Model/System/Config/Source → community/Dotdigitalgroup/Email/Model/Adminhtml/Source/Dynamic}/Gridview.php RENAMED
@@ -1,7 +1,12 @@
1
  <?php
2
 
3
- class Dotdigitalgroup_Email_Model_System_Config_Source_Gridview
4
  {
 
 
 
 
 
5
  public function toOptionArray()
6
  {
7
  return array(
1
  <?php
2
 
3
+ class Dotdigitalgroup_Email_Model_Adminhtml_Source_Dynamic_Gridview
4
  {
5
+ /**
6
+ * grid display options.
7
+ *
8
+ * @return array
9
+ */
10
  public function toOptionArray()
11
  {
12
  return array(
app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Source/Lostbaskets/Interval.php ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dotdigitalgroup_Email_Model_Adminhtml_Source_Lostbaskets_Interval
4
+ {
5
+
6
+ /**
7
+ * available times
8
+ * @var array
9
+ */
10
+ protected $_times = array(1,2,3,4,5,6,12,24,36,48,60,72,84,96,108,120, 240);
11
+
12
+
13
+ /**
14
+ * send to campain options hours
15
+ * @return array
16
+ */
17
+ public function toOptionArray()
18
+ {
19
+ $result = $row = array();
20
+ $i = 0;
21
+ foreach ($this->_times as $one) {
22
+
23
+ if ($i == 0) {
24
+ $row = array(
25
+ 'value' => $one,
26
+ 'label' => Mage::helper( 'connector' )->__( $one . ' Hour' )
27
+ );
28
+ } else {
29
+ $row = array(
30
+ 'value' => $one,
31
+ 'label' => Mage::helper( 'connector' )->__( $one . ' Hours' )
32
+ );
33
+ }
34
+ $result[] = $row;
35
+ $i++;
36
+ }
37
+
38
+ return $result;
39
+ }
40
+ }
app/code/{local/Dotdigitalgroup/Email/Model/System/Config/Source/Lostbasket.php → community/Dotdigitalgroup/Email/Model/Adminhtml/Source/Lostbaskets/Intervalminute.php} RENAMED
@@ -1,6 +1,6 @@
1
  <?php
2
 
3
- class Dotdigitalgroup_Email_Model_System_Config_Source_Lostbasket
4
  {
5
  /**
6
  * lost basket hour options
1
  <?php
2
 
3
+ class Dotdigitalgroup_Email_Model_Adminhtml_Source_Lostbaskets_Intervalminute
4
  {
5
  /**
6
  * lost basket hour options
app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Source/Orderstatus.php ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dotdigitalgroup_Email_Model_Adminhtml_Source_Orderstatus
4
+ {
5
+ /**
6
+ * Returns the order statuses for field order_statuses
7
+ * @return array
8
+ */
9
+ public function toOptionArray()
10
+ {
11
+ $source = Mage::getModel('adminhtml/system_config_source_order_status');
12
+ $statuses = $source->toOptionArray();
13
+
14
+ // Remove the "please select" option if present
15
+ if(count($statuses) > 0 && $statuses[0]['value'] == '')
16
+ array_shift($statuses);
17
+
18
+ $options = array();
19
+
20
+ foreach($statuses as $status) {
21
+ $options[] = array(
22
+ 'value' => $status['value'],
23
+ 'label' => $status['label']
24
+ );
25
+ }
26
+ return $options;
27
+ }
28
+ }
app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Source/Sweettooth/Yesno.php ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dotdigitalgroup_Email_Model_Adminhtml_Source_Sweettooth_Yesno
4
+ {
5
+
6
+ /**
7
+ * Options getter
8
+ *
9
+ * @return array
10
+ */
11
+ public function toOptionArray()
12
+ {
13
+ $status = Mage::helper('connector')->isSweetToothEnabled();
14
+ if($status){
15
+ return array(
16
+ array('value' => 1, 'label'=>Mage::helper('adminhtml')->__('Yes')),
17
+ array('value' => 0, 'label'=>Mage::helper('adminhtml')->__('No')),
18
+ );
19
+ }
20
+
21
+ return array(
22
+ array('value' => 0, 'label'=>Mage::helper('adminhtml')->__('No')),
23
+ );
24
+ }
25
+
26
+ }
app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Source/Transactional/Campaigns.php ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dotdigitalgroup_Email_Model_Adminhtml_Source_Transactional_Campaigns
4
+ {
5
+
6
+ /**
7
+ * Returns the account's datafields.
8
+ *
9
+ * @return array
10
+ * @throws Mage_Core_Exception
11
+ */
12
+ public function toOptionArray()
13
+ {
14
+ $fields = array();
15
+ $client = Mage::getModel('email_connector/apiconnector_client');
16
+
17
+ $websiteName = Mage::app()->getRequest()->getParam('website', false);
18
+ if ($websiteName) {
19
+ $website = Mage::app()->getWebsite($websiteName);
20
+ } else {
21
+ $website = 0;
22
+ }
23
+ $client->setApiUsername(Mage::helper('connector/transactional')->getApiUsername($website));
24
+ $client->setApiPassword(Mage::helper('connector/transactional')->getApiPassword($website));
25
+
26
+ $savedCampaigns = Mage::registry('savedcampigns');
27
+
28
+ if ($savedCampaigns) {
29
+ $campaigns = $savedCampaigns;
30
+ } else {
31
+ $campaigns = $client->getCampaigns();
32
+ Mage::unregister('savedcampigns');
33
+ Mage::register('savedcampigns', $campaigns);
34
+ }
35
+
36
+ $fields[] = array('value' => '0', 'label' => Mage::helper('connector')->__('-- Use system default --'));
37
+
38
+ if (is_array($fields)) {
39
+ foreach ( $campaigns as $one ) {
40
+ if ( isset( $one->id ) )
41
+ $fields[] = array( 'value' => $one->id, 'label' => Mage::helper( 'connector' )->__( addslashes($one->name)) );
42
+ }
43
+ }
44
+
45
+ return $fields;
46
+ }
47
+
48
+ }
app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Source/Transactional/Customselect.php ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dotdigitalgroup_Email_Model_Adminhtml_Source_Transactional_Customselect
4
+ {
5
+
6
+ /**
7
+ * custom email templates - admin transactional emails
8
+ *
9
+ * @return array
10
+ */
11
+ public function toOptionArray()
12
+ {
13
+ $collection = Mage::getResourceModel('core/email_template_collection')
14
+ ->load();
15
+ $options = $collection->toOptionArray();
16
+
17
+ return $options;
18
+ }
19
+ }
app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Source/Transactional/Defaultselect.php ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dotdigitalgroup_Email_Model_Adminhtml_Source_Transactional_Defaultselect
4
+ {
5
+
6
+ /**
7
+ * default email templates - all modules
8
+ *
9
+ * @return array
10
+ */
11
+ public function toOptionArray()
12
+ {
13
+ $options = array();
14
+
15
+ $idLabel = array();
16
+ foreach (Mage_Core_Model_Email_Template::getDefaultTemplates() as $templateId => $row) {
17
+ if (isset($row['@']) && isset($row['@']['module'])) {
18
+ $module = $row['@']['module'];
19
+ } else {
20
+ $module = 'adminhtml';
21
+ }
22
+ $idLabel[$templateId] = Mage::helper($module)->__($row['label'] . " [module = $module]");
23
+ }
24
+ asort($idLabel);
25
+ foreach ($idLabel as $templateId => $label) {
26
+ $options[] = array('value' => $templateId, 'label' => $label);
27
+ }
28
+
29
+ return $options;
30
+ }
31
+ }
app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Source/Transactional/Fromaddress.php ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dotdigitalgroup_Email_Model_Adminhtml_Source_Transactional_Fromaddress
4
+ {
5
+
6
+ /**
7
+ * Returns all custom from addresses.
8
+ *
9
+ * @return array
10
+ * @throws Mage_Core_Exception
11
+ */
12
+ public function toOptionArray()
13
+ {
14
+ $fields = array();
15
+ $client = Mage::getModel('email_connector/apiconnector_client');
16
+
17
+ $websiteName = Mage::app()->getRequest()->getParam('website', false);
18
+ if ($websiteName) {
19
+ $website = Mage::app()->getWebsite($websiteName);
20
+ } else {
21
+ $website = 0;
22
+ }
23
+ $client->setApiUsername(Mage::helper('connector/transactional')->getApiUsername($website));
24
+ $client->setApiPassword(Mage::helper('connector/transactional')->getApiPassword($website));
25
+
26
+ $savedFromAddressList = Mage::registry('savedFromAddressList');
27
+
28
+ if ($savedFromAddressList) {
29
+ $fromAddressList = $savedFromAddressList;
30
+ } else {
31
+ $fromAddressList = $client->getCampaignFromAddressList();
32
+ Mage::unregister('savedFromAddressList');
33
+ Mage::register('savedFromAddressList', $fromAddressList);
34
+ }
35
+ $fields[] = array('value' => '0', 'label' => Mage::helper('connector')->__('-- Please select --'));
36
+ foreach ($fromAddressList as $one) {
37
+ if(isset($one->id))
38
+ $fields[] = array('value' => $one->id, 'label' => Mage::helper('connector')->__($one->email));
39
+ }
40
+ return $fields;
41
+ }
42
+
43
+ }
app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Source/Transactional/Replyactions.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dotdigitalgroup_Email_Model_Adminhtml_Source_Transactional_Replyactions
4
+ {
5
+
6
+ /**
7
+ * Returns all reply actions for campaign
8
+ *
9
+ * @return array
10
+ */
11
+ public function toOptionArray()
12
+ {
13
+ $fields = array(
14
+ array('value' => '0', 'label' => Mage::helper('connector')->__('-- Please select --')),
15
+ array('value' => 'WebMailForward', 'label' => Mage::helper('connector')->__('Report + Forward')),
16
+ array('value' => 'Webmail', 'label' => Mage::helper('connector')->__('Report')),
17
+ array('value' => 'Delete', 'label' => Mage::helper('connector')->__('Delete'))
18
+ );
19
+ return $fields;
20
+ }
21
+
22
+ }
app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Source/Transactional/Sendtype.php ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dotdigitalgroup_Email_Model_Adminhtml_Source_Transactional_Sendtype
4
+ {
5
+
6
+ /**
7
+ * send type options
8
+ *
9
+ * @return array
10
+ */
11
+ public function toOptionArray()
12
+ {
13
+ $options = array(
14
+ array('value' => '0', 'label' => Mage::helper('connector')->__('-- Use system default --')),
15
+ array('value' => '1', 'label' => Mage::helper('connector')->__('-- Send via connector --')),
16
+ array('value' => '2', 'label' => Mage::helper('connector')->__('-- Design + Send via connector --'))
17
+ );
18
+
19
+ return $options;
20
+ }
21
+ }
app/code/community/Dotdigitalgroup/Email/Model/Apiconnector/Client.php ADDED
@@ -0,0 +1,787 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dotdigitalgroup_Email_Model_Apiconnector_Client extends Dotdigitalgroup_Email_Model_Abstract_Rest
4
+ {
5
+ const APICONNECTOR_VERSION = 'V2';
6
+
7
+ const REST_WAIT_UPLOAD_TIME = 5;
8
+ //rest api data
9
+ const REST_ACCOUNT_INFO = 'https://apiconnector.com/v2/account-info';
10
+ const REST_CONTACTS = 'https://apiconnector.com/v2/contacts/';
11
+ const REST_CONTACTS_IMPORT = 'https://apiconnector.com/v2/contacts/import/';
12
+ const REST_ADDRESS_BOOKS = 'https://apiconnector.com/v2/address-books/';
13
+ const REST_DATA_FILEDS = 'https://apiconnector.com/v2/data-fields';
14
+ const REST_TRANSACTIONAL_DATA_IMPORT = 'https://apiconnector.com/v2/contacts/transactional-data/import/';
15
+ const REST_TRANSACTIONAL_DATA = 'https://apiconnector.com/v2/contacts/transactional-data/';
16
+ const REST_CAMPAIGN_SEND = 'https://apiconnector.com/v2/campaigns/send';
17
+ const REST_CONTACTS_SUPPRESSED_SINCE = 'https://apiconnector.com/v2/contacts/suppressed-since/';
18
+ const REST_DATA_FIELDS_CAMPAIGNS = 'https://apiconnector.com/v2/campaigns';
19
+ const REST_SMS_MESSAGE_SEND_TO = 'https://apiconnector.com/v2/sms-messages/send-to/';
20
+ const REST_CONTACTS_RESUBSCRIBE = 'https://apiconnector.com/v2/contacts/resubscribe';
21
+ const REST_CAMPAIGN_FROM_ADDRESS_LIST = 'https://apiconnector.com/v2/custom-from-addresses';
22
+ const REST_CREATE_CAMPAIGN = 'https://apiconnector.com/v2/campaigns';
23
+ const REST_PROGRAM = 'https://api.dotmailer.com/v2/programs/';
24
+ const REST_PROGRAM_ENROLMENTS = 'https://apiconnector.com/v2/programs/enrolments';
25
+
26
+ //rest error responces
27
+ const REST_CONTACT_NOT_FOUND = 'Error: ERROR_CONTACT_NOT_FOUND';
28
+ const REST_SEND_MULTI_TRANSACTIONAL_DATA = 'Error: ERROR_FEATURENOTACTIVE';
29
+ const REST_STATUS_IMPORT_REPORT_NOT_FOUND = 'Import is not processed yet or completed with error. ERROR_IMPORT_REPORT_NOT_FOUND';
30
+ const REST_STATUS_REPORT_NOTFINISHED = 'NotFinished';
31
+ const REST_TRANSACTIONAL_DATA_NOT_EXISTS = 'Error: ERROR_TRANSACTIONAL_DATA_DOES_NOT_EXIST';
32
+ const REST_API_USAGE_EXCEEDED = 'Your account has generated excess API activity and is being temporarily capped. Please contact support. ERROR_APIUSAGE_EXCEEDED';
33
+ const REST_API_EMAIL_NOT_VALID = 'Email is not a valid email address. ERROR_PARAMETER_INVALID';
34
+ const REST_API_DATAFILEDS_EXISTS = 'Field already exists. ERROR_NON_UNIQUE_DATAFIELD';
35
+
36
+ protected $_customers_file_slug = 'customer_sync';
37
+ protected $_subscribers_file_slug = 'subscriber_sync';
38
+ protected $_api_helper;
39
+ protected $_subscribers_address_book_id;
40
+ protected $_customers_address_book_id;
41
+ protected $_filename;
42
+ protected $_subscribers_filename;
43
+ protected $_customers_filename;
44
+ protected $_limit = 10;
45
+ protected $_address_book_id;
46
+ public $fileHelper; /** @var Dotdigitalgroup_Email_Helper_File */
47
+ public $result = array('error' => false, 'message' => '');
48
+
49
+
50
+ /**
51
+ * constructor.
52
+ */
53
+ public function __construct()
54
+ {
55
+ parent::__construct();
56
+ }
57
+
58
+ /**
59
+ * @param $apiUsername
60
+ * @param $apiPassword
61
+ * @return bool|mixed
62
+ */
63
+ public function validate($apiUsername, $apiPassword)
64
+ {
65
+ if ($apiUsername && $apiPassword) {
66
+ $this->setApiUsername($apiUsername)
67
+ ->setApiPassword($apiPassword);
68
+ $accountInfo = $this->getAccountInfo();
69
+ if (isset($accountInfo->message)) {
70
+ Mage::getSingleton('adminhtml/session')->addError($accountInfo->message);
71
+ Mage::helper('connector')->log('VALIDATION ERROR : ' . $accountInfo->message);
72
+ return false;
73
+ }
74
+ return $accountInfo;
75
+ }
76
+ return false;
77
+ }
78
+ /**
79
+ * Gets a contact by ID. Unsubscribed or suppressed contacts will not be retrieved.
80
+ * @param $id
81
+ * @return null
82
+ */
83
+ public function getContactById($id)
84
+ {
85
+ $url = self::REST_CONTACTS . $id;
86
+
87
+ $this->setUrl($url)
88
+ ->setVerb('GET');
89
+ $response = $this->execute();
90
+ if(isset($response->message))
91
+ Mage::helper('connector')->log('GET CONTACT INFO ID ' . $url . ', ' . $response->message);
92
+
93
+ return $response;
94
+ }
95
+
96
+ /**
97
+ * * Bulk creates, or bulk updates, contacts. Import format can either be CSV or Excel.
98
+ * Must include one column called "Email". Any other columns will attempt to map to your custom data fields.
99
+ * The ID of returned object can be used to query import progress.
100
+ * @param $filename
101
+ * @param $addressBookId
102
+ * @return mixed
103
+ */
104
+ public function postAddressBookContactsImport($filename, $addressBookId)
105
+ {
106
+ $url = "https://apiconnector.com/v2/address-books/{$addressBookId}/contacts/import";
107
+ $helper = Mage::helper('connector');
108
+
109
+ $ch = curl_init($url);
110
+ curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
111
+ curl_setopt($ch, CURLOPT_USERPWD, $this->getApiUsername() . ':' . $this->getApiPassword());
112
+ curl_setopt($ch, CURLOPT_POSTFIELDS, array (
113
+ 'file' => '@'.Mage::helper('connector/file')->getFilePath($filename)
114
+ ));
115
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
116
+ curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
117
+ curl_setopt($ch, CURLOPT_HTTPHEADER, array(
118
+ 'Content-Type: multipart/form-data')
119
+ );
120
+
121
+ // send contacts to address book
122
+ $result = curl_exec($ch);
123
+ $result = json_decode($result);
124
+ if (isset($result->message)) {
125
+ $helper->log('POST ADDRESS BOOK ' . $addressBookId . ', CONTACT IMPORT : ' . ' filename ' . $filename . ' Username ' . $this->getApiUsername() . $result->message);
126
+ Mage::helper('connector')->log($result);
127
+ }
128
+
129
+ return $result;
130
+ }
131
+
132
+ /**
133
+ * Adds a contact to a given address book.
134
+ * @param $addressBookId
135
+ * @param $apiContact
136
+ * @return mixed|null
137
+ */
138
+ public function postAddressBookContacts($addressBookId, $apiContact)
139
+ {
140
+ $url = self::REST_ADDRESS_BOOKS . $addressBookId . '/contacts';
141
+ $this->setUrl($url)
142
+ ->setVerb("POST")
143
+ ->buildPostBody($apiContact);
144
+
145
+ $response = $this->execute();
146
+ if (isset($response->message)) {
147
+ Mage::helper('connector')->log('POST ADDRESS BOOK CONTACTS ' . $url . ', ' . $response->message);
148
+ Mage::helper('connector')->log($apiContact->email);
149
+ }
150
+
151
+ return $response;
152
+ }
153
+
154
+ /**
155
+ * Deletes all contacts from a given address book.
156
+ * @param $addressBookId
157
+ * @param $contactId
158
+ * @return null
159
+ */
160
+ public function deleteAddressBookContact($addressBookId, $contactId)
161
+ {
162
+ $url = self::REST_ADDRESS_BOOKS . $addressBookId . '/contacts/' . $contactId;
163
+ $this->setUrl($url)
164
+ ->setVerb('DELETE');
165
+ $response = $this->execute();
166
+ if (isset($response->message))
167
+ Mage::helper('connector')->log('DELETE ADDRESS BOOK CONTACT ' . $url . ', ' . $response->message);
168
+
169
+ return $response;
170
+ }
171
+
172
+ /**
173
+ * Gets a report with statistics about what was successfully imported, and what was unable to be imported.
174
+ * @param $importId
175
+ * @return mixed
176
+ */
177
+ public function getContactsImportReport($importId)
178
+ {
179
+ $url = self::REST_CONTACTS_IMPORT . $importId . "/report";
180
+ $this->setUrl($url)
181
+ ->setVerb('GET');
182
+ $response = $this->execute();
183
+ if (isset($response->message))
184
+ Mage::helper('connector')->log('GET CONTACTS IMPORT REPORT . ' . $url . ' message : ' . $response->message);
185
+ return $response;
186
+ }
187
+
188
+ /**
189
+ * Gets a contact by email address.
190
+ * @param $email
191
+ * @return mixed
192
+ */
193
+ public function getContactByEmail($email)
194
+ {
195
+ $url = self::REST_CONTACTS . $email;
196
+ $this->setUrl($url)
197
+ ->setVerb('GET');
198
+
199
+ $response = $this->execute();
200
+ if (isset($response->message))
201
+ Mage::helper('connector')->log('GET CONTACT BY EMAIL : ' . $email . ' ' . $response->message);
202
+
203
+ return $response;
204
+ }
205
+
206
+ /**
207
+ * Get all address books
208
+ * @return null
209
+ */
210
+ public function getAddressBooks()
211
+ {
212
+ $url = self::REST_ADDRESS_BOOKS;
213
+ $this->setUrl($url)
214
+ ->setVerb("GET");
215
+
216
+ $response = $this->execute();
217
+ if (isset($response->message))
218
+ Mage::helper('connector')->log('GET ALL ADDRESS BOOKS : ' . $url . ', ' . $response->message);
219
+ return $response;
220
+ }
221
+
222
+ /**
223
+ * Creates an address book.
224
+ * @param $name
225
+ * @return null
226
+ */
227
+ public function PostAddressBooks($name)
228
+ {
229
+ $data = array(
230
+ 'Name' => $name,
231
+ 'Visibility' => 'Public'
232
+ );
233
+ $url = self::REST_ADDRESS_BOOKS;
234
+ $this->setUrl($url)
235
+ ->setVerb('POST')
236
+ ->buildPostBody($data);
237
+
238
+ $response = $this->execute();
239
+
240
+ if (isset($response->message)) {
241
+ Mage::helper('connector')->log('POSTADDRESSBOOK ' . $url);
242
+ Mage::helper('connector')->log($response->message);
243
+ }
244
+ return $response;
245
+ }
246
+
247
+ /**
248
+ * Get list of all campaigns
249
+ * @return mixed
250
+ */
251
+ public function getCampaigns()
252
+ {
253
+ $url = self::REST_DATA_FIELDS_CAMPAIGNS;
254
+ $this->setUrl($url)
255
+ ->setVerb('GET');
256
+
257
+ $response = $this->execute();
258
+
259
+ if (isset($response->message))
260
+ Mage::helper('connector')->log('GET CAMPAIGNS ' . $response->message . ' api user : ' . $this->getApiUsername());
261
+
262
+ return $response;
263
+ }
264
+
265
+ /**
266
+ * Creates a data field within the account.
267
+ * @param $data string/array
268
+ * @param string $type string, numeric, date, boolean
269
+ * @param string $visibility public, private
270
+ * @param bool $defaultValue
271
+ * @return mixed
272
+ */
273
+ public function postDataFields($data, $type = 'String', $visibility = 'public', $defaultValue = false)
274
+ {
275
+ $url = self::REST_DATA_FILEDS;
276
+ if($type == 'numeric' && !$defaultValue)
277
+ $defaultValue = 0;
278
+ if (is_string($data)) {
279
+ $data = array(
280
+ 'Name' => $data,
281
+ 'Type' => $type,
282
+ 'Visibility' => $visibility
283
+ );
284
+ if($defaultValue)
285
+ $data['DefaultValue'] = $defaultValue;
286
+ }
287
+ $this->setUrl($url)
288
+ ->buildPostBody($data)
289
+ ->setVerb('POST');
290
+
291
+ $response = $this->execute();
292
+
293
+ if (isset($response->message)) {
294
+ Mage::helper('connector')->log('POST CREATE DATAFIELDS ' . $response->message);
295
+ Mage::helper('connector')->log($data);
296
+ }
297
+
298
+ return $response;
299
+ }
300
+
301
+ public function deleteDataField($name)
302
+ {
303
+ $url = self::REST_DATA_FILEDS . '/' . $name;
304
+ $request = Mage::helper('connector/api_restrequest');
305
+ $request->setUrl($url)
306
+ ->setVerb('DELETE');
307
+
308
+ $response = $request->execute();
309
+ if(isset($response->message))
310
+ Mage::helper('connector')->log('DELETE DATA FIELD :' . $name . ' ' . $response->message);
311
+ return $request->execute();
312
+ }
313
+
314
+ /**
315
+ * Lists the data fields within the account.
316
+ * @return mixed
317
+ */
318
+ public function getDataFields()
319
+ {
320
+ $url = self::REST_DATA_FILEDS;
321
+ $this->setUrl($url)
322
+ ->setVerb('GET');
323
+
324
+ $response = $this->execute();
325
+ if (isset($response->message))
326
+ Mage::helper('connector')->log('GET ALL DATAFIELDS ' . $response->message);
327
+
328
+ return $response;
329
+ }
330
+
331
+ /**
332
+ * Updates a contact.
333
+ * @param $contactId
334
+ * @param $data
335
+ * @return object
336
+ */
337
+ public function updateContact($contactId, $data)
338
+ {
339
+ $url = self::REST_CONTACTS . $contactId;
340
+ $this->setUrl($url)
341
+ ->setVerb('PUT')
342
+ ->buildPostBody($data);
343
+
344
+ $response = $this->execute();
345
+ if(isset($response->message)){
346
+ Mage::helper('connector')->log('ERROR : UPDATE SINGLE CONTACT : ' . $url . ' message : ' . $response->message);
347
+ Mage::helper('connector')->log($data);
348
+ }
349
+
350
+ return $response;
351
+ }
352
+
353
+ /**
354
+ * Deletes a contact.
355
+ * @param $contactId
356
+ * @return null
357
+ */
358
+ public function DeleteContact($contactId)
359
+ {
360
+ $url = self::REST_CONTACTS . $contactId;
361
+ $this->setUrl($url)
362
+ ->setVerb('DELETE');
363
+
364
+ $response = $this->execute();
365
+
366
+ if (isset($response->message)) {
367
+ Mage::helper('connector')->log('DELETE CONTACT : ' . $url . ', ' . $response->message);
368
+ }
369
+ return $response;
370
+ }
371
+
372
+ public function updateContactDatafieldsByEmail($email, $dataFields)
373
+ {
374
+ $contactId = $this->postContacts($email)->id;
375
+ $data = array(
376
+ 'Email' => $email,
377
+ 'EmailType' => 'Html');
378
+ $data['DataFields'] = $dataFields;
379
+ $url = self::REST_CONTACTS . $contactId;
380
+ $this->setUrl($url)
381
+ ->setVerb('PUT')
382
+ ->buildPostBody($data);
383
+ $response = $this->execute();
384
+ if (isset($response->message)) {
385
+ Mage::helper('connector')->log('ERROR: UPDATE CONTACT DATAFIELD ' . $url . ' message : ' . $response->message);
386
+ Mage::helper('connector')->log($data);
387
+ }
388
+
389
+ return $response;
390
+ }
391
+
392
+ /**
393
+ * Sends a specified campaign to one or more address books, segments or contacts at a specified time.
394
+ * Leave the address book array empty to send to All Contacts.
395
+ * @param $campaignId
396
+ * @param $contacts
397
+ * @return mixed
398
+ */
399
+ public function postCampaignsSend($campaignId, $contacts)
400
+ {
401
+ $helper = Mage::helper('connector');
402
+ $data = array(
403
+ 'username' => $this->getApiUsername(),
404
+ 'password' => $this->getApiPassword(),
405
+ "campaignId" => $campaignId,
406
+ "ContactIds" => $contacts
407
+ );
408
+ $this->setUrl(self::REST_CAMPAIGN_SEND)
409
+ ->setVerb('POST')
410
+ ->buildPostBody($data);
411
+
412
+ $response = $this->execute();
413
+ if (isset($response->message)) {
414
+ $helper->log('SENDING CAMPAIGN ' . $response->message);
415
+ $helper->log($data);
416
+ }
417
+
418
+ return $response;
419
+ }
420
+
421
+ /**
422
+ * Creates a contact.
423
+ * @param $email
424
+ * @return mixed
425
+ */
426
+ public function postContacts($email)
427
+ {
428
+ $url = self::REST_CONTACTS;
429
+ $data = array(
430
+ 'Email' => $email,
431
+ 'EmailType' => 'Html',
432
+ );
433
+ $this->setUrl($url)
434
+ ->setVerb('POST')
435
+ ->buildPostBody($data);
436
+
437
+ $response = $this->execute();
438
+ if (isset($response->message)) {
439
+ Mage::helper('connector')->log('CREATE A NEW CONTACT : ' . $email . ' , url ' . $url . ', ' . $response->message);
440
+ }
441
+
442
+ return $response;
443
+ }
444
+
445
+ /**
446
+ * @param $testEmail
447
+ * @param $contactId
448
+ * @param $campaignId
449
+ */
450
+ public function sendIntallInfo($testEmail, $contactId, $campaignId)
451
+ {
452
+ $helper = Mage::helper('connector');
453
+ $productSize= Mage::getModel('catalog/product')->getCollection()->getSize();
454
+ $customerSize = Mage::getModel('customer/customer')->getCollection()->getSize();
455
+
456
+ $data = array(
457
+ 'Email' => $testEmail,
458
+ 'EmailType' => 'Html',
459
+ 'DataFields' => array(
460
+ array(
461
+ 'Key' => 'INSTALLCUSTOMERS',
462
+ 'Value' => (string)$customerSize),
463
+ array(
464
+ 'Key' => 'INSTALLPRODUCTS',
465
+ 'Value' => (string)$productSize),
466
+ array(
467
+ 'Key' => 'INSTALLURL',
468
+ 'Value' => Mage::getBaseUrl('web')),
469
+ array(
470
+ 'Key' => 'INSTALLAPI',
471
+ 'Value' => Mage::helper('connector')->getStringWebsiteApiAccounts()),
472
+ array(
473
+ 'Key' => 'PHPMEMORY',
474
+ 'Value' => ini_get('memory_limit') . ', Version = ' . $helper->getConnectorVersion()
475
+ )
476
+ )
477
+ );
478
+ $helper->log('SENDING INSTALL INFO DATA...', Zend_Log::INFO, 'api.log');
479
+ $helper->log($data);
480
+ /**
481
+ * Update data fields for a contact
482
+ */
483
+ $this->updateContact($contactId, $data);
484
+ /**
485
+ * Send Install info campaign
486
+ */
487
+ $this->postCampaignsSend($campaignId, array($contactId));
488
+
489
+ return;
490
+ }
491
+
492
+
493
+ /**
494
+ * Gets a list of suppressed contacts after a given date along with the reason for suppression.
495
+ * @param $dateString
496
+ * @param $select
497
+ * @param $skip
498
+ * @return object
499
+ */
500
+ public function getContactsSuppressedSinceDate($dateString, $select = 1000, $skip = 0)
501
+ {
502
+ $url = self::REST_CONTACTS_SUPPRESSED_SINCE . $dateString . '?select=' . $select . '&skip=' . $skip;
503
+
504
+ $this->setUrl($url)
505
+ ->setVerb("GET");
506
+
507
+ $response = $this->execute();
508
+ if (isset($response->message))
509
+ Mage::helper('connector')->log('GET CONTACTS SUPPRESSED SINSE : ' . $dateString . ' select ' . $select . ' skip : ' . $skip . ' response : ' . $response->message);
510
+
511
+ return $response;
512
+ }
513
+
514
+ /**
515
+ * Adds multiple pieces of transactional data to contacts asynchronously, returning an identifier that can be used to check for import progress.
516
+ * @param $collectionName
517
+ * @param $transactionalData
518
+ * @return object
519
+ */
520
+ public function postContactsTransactionalDataImport($transactionalData, $collectionName = 'Orders')
521
+ {
522
+ $orders = array();
523
+ foreach ($transactionalData as $one) {
524
+ if (isset($one->email)) {
525
+ $orders[] = array(
526
+ 'Key' => $one->id,
527
+ 'ContactIdentifier' => $one->email,
528
+ 'Json' => json_encode($one->expose())
529
+ );
530
+ }
531
+ }
532
+ $url = self::REST_TRANSACTIONAL_DATA_IMPORT . $collectionName;
533
+ $this->setURl($url)
534
+ ->setVerb('POST')
535
+ ->buildPostBody($orders);
536
+
537
+ $result = $this->execute();
538
+
539
+ if (isset($result->message)) {
540
+ Mage::helper('connector')->log(' SEND MULTI TRANSACTIONAL DATA ' . $result->message);
541
+ }
542
+
543
+ return $result;
544
+ }
545
+
546
+ /**
547
+ * Adds a single piece of transactional data to a contact.
548
+ *
549
+ * @param $data
550
+ * @param string $name
551
+ * @return null
552
+ */
553
+ public function postContactsTransactionalData($data, $name = 'Orders')
554
+ {
555
+ $getData = $this->getContactsTransactionalDataByKey($name, $data->id);
556
+ if(isset($getData->message) && $getData->message == self::REST_TRANSACTIONAL_DATA_NOT_EXISTS){
557
+ $url = self::REST_TRANSACTIONAL_DATA . $name;
558
+ }else{
559
+ $url = self::REST_TRANSACTIONAL_DATA . $name . '/' . $getData->key ;
560
+ }
561
+ $apiData = array(
562
+ 'Key' => $data->id,
563
+ 'ContactIdentifier' => $data->connector_id,
564
+ 'Json' => json_encode($data->expose())
565
+ );
566
+
567
+ $this->setUrl($url)
568
+ ->setVerb('POST')
569
+ ->buildPostBody($apiData);
570
+ $response = $this->execute();
571
+ if(isset($response->message)){
572
+ Mage::helper('connector')->log('POST CONTACTS TRANSACTIONAL DATA ' . $response->message);
573
+ Mage::helper('connector')->log($apiData);
574
+ }
575
+
576
+ return $response;
577
+ }
578
+
579
+ /**
580
+ * Gets a piece of transactional data by key.
581
+ * @param $name
582
+ * @param $key
583
+ * @return null
584
+ */
585
+ public function getContactsTransactionalDataByKey($name, $key)
586
+ {
587
+ $url = self::REST_TRANSACTIONAL_DATA . $name . '/' . $key;
588
+ $this->setUrl($url)
589
+ ->setVerb('GET');
590
+ $response = $this->execute();
591
+ if (isset($response->message))
592
+ Mage::helper('connector')->log('GET CONTACTS TRANSACTIONAL DATA name: ' . $name . ' key: ' . $key . ' ' . $response->message);
593
+
594
+ return $response;
595
+ }
596
+
597
+ /**
598
+ * Deletes all transactional data for a contact.
599
+ * @param $email
600
+ * @param string $collectionName
601
+ * @return object
602
+ */
603
+ public function deleteContactTransactionalData($email, $collectionName = 'Orders')
604
+ {
605
+ $url = 'https://apiconnector.com/v2/contacts/' . $email . '/transactional-data/' . $collectionName ;
606
+ $this->setUrl($url)
607
+ ->setVerb('DELETE');
608
+ $response = $this->execute();
609
+ if (isset($response->message))
610
+ Mage::helper('connector')->log('DELETE CONTACT TRANSACTIONAL DATA : ' . $url . ' ' . $response->message);
611
+
612
+ return $response;
613
+ }
614
+
615
+ /**
616
+ * Gets a summary of information about the current status of the account.
617
+ * @return mixed
618
+ */
619
+ public function getAccountInfo()
620
+ {
621
+ $url = self::REST_ACCOUNT_INFO;
622
+ $this->setUrl($url)
623
+ ->setVerb('GET');
624
+ $response = $this->execute();
625
+
626
+ if (isset($response->message)) {
627
+ Mage::helper('connector')->log('GET ACCOUNT INFO for api user : ' . $this->getApiUsername() . ' ' . $response->message);
628
+ }
629
+
630
+ return $response;
631
+ }
632
+
633
+ /**
634
+ * Send a single SMS message.
635
+ * @param $telephoneNumber
636
+ * @param $message
637
+ * @return object
638
+ */
639
+ public function postSmsMessagesSendTo($telephoneNumber, $message)
640
+ {
641
+ $data = array('Message' => $message);
642
+ $url = self::REST_SMS_MESSAGE_SEND_TO . $telephoneNumber;
643
+ $this->setUrl($url)
644
+ ->setVerb('POST')
645
+ ->buildPostBody($data);
646
+ $response = $this->execute();
647
+ if (isset($response->message))
648
+ Mage::helper('connector')->log('POST SMS MESSAGE SEND to ' . $telephoneNumber . ' message: ' . $message . ' error: ' . $response->message);
649
+
650
+ return $response;
651
+ }
652
+
653
+
654
+ /**
655
+ * Deletes multiple contacts from an address book
656
+ * @param $addressBookId
657
+ * @param $contactIds
658
+ * @return object
659
+ */
660
+ public function deleteAddressBookContactsInbulk($addressBookId, $contactIds)
661
+ {
662
+ $url = 'https://apiconnector.com/v2/address-books/' . $addressBookId . '/contacts/inbulk';
663
+ $data = array('ContactIds' => array($contactIds[0]));
664
+ $this->setUrl($url)
665
+ ->setVerb('DELETE')
666
+ ->buildPostBody($data);
667
+
668
+ $result = $this->execute();
669
+ if (isset($result->message)) {
670
+ Mage::helper('connector')->log('DELETE BULK ADDRESS BOOK CONTACTS ' . $result->message . ' address book ' . $addressBookId);
671
+ }
672
+ return $result;
673
+ }
674
+
675
+ /**
676
+ * Resubscribes a previously unsubscribed contact.
677
+ *
678
+ * @param $apiContact
679
+ */
680
+ public function PostContactsResubscribe($apiContact)
681
+ {
682
+ $url = self::REST_CONTACTS_RESUBSCRIBE;
683
+ $data = array(
684
+ 'UnsubscribedContact' => $apiContact
685
+ );
686
+ $this->setUrl($url)
687
+ ->setVerb("POST")
688
+ ->buildPostBody($data);
689
+
690
+ $response = $this->execute();
691
+ if (isset($response->message)) {
692
+ Mage::helper('connector')->log('Resubscribe : ' . $url . ', message :' . $response->message);
693
+ Mage::helper('connector')->log($data);
694
+ }
695
+ }
696
+
697
+ public function getCampaignFromAddressList()
698
+ {
699
+ $url = self::REST_CAMPAIGN_FROM_ADDRESS_LIST;
700
+ $this->setUrl($url)
701
+ ->setVerb('GET');
702
+
703
+ $response = $this->execute();
704
+
705
+ if (isset($response->message))
706
+ Mage::helper('connector')->log('GET CampaignFromAddressList ' . $response->message . ' api user : ' . $this->getApiUsername());
707
+
708
+ return $response;
709
+ }
710
+
711
+ public function postCampaign($data)
712
+ {
713
+ $url = self::REST_CREATE_CAMPAIGN;
714
+ $this->setURl($url)
715
+ ->setVerb('POST')
716
+ ->buildPostBody($data);
717
+
718
+ $result = $this->execute();
719
+
720
+ if (isset($result->message)) {
721
+ Mage::helper('connector')->log(' CREATE CAMPAIGN ' . $result->message);
722
+ }
723
+
724
+ return $result;
725
+ }
726
+
727
+ /**
728
+ * Gets all programs.
729
+ * https://api.dotmailer.com/v2/programs?select={select}&skip={skip}
730
+ */
731
+ public function GetPrograms()
732
+ {
733
+ $url = 'https://api.dotmailer.com/v2/programs';
734
+
735
+ $this->setUrl($url)
736
+ ->setVerb('GET');
737
+
738
+ $response = $this->execute();
739
+
740
+ if (isset($response->message)) {
741
+ Mage::helper( 'connector' )->log( 'Get programmes : ' . $response->message );
742
+ }
743
+
744
+ return $response;
745
+ }
746
+
747
+ /**
748
+ * Creates an enrolment.
749
+ * @param $data
750
+ *
751
+ * @return null
752
+ * @throws Exception
753
+ */
754
+ public function PostProgramsEnrolments($data)
755
+ {
756
+ $url = self::REST_PROGRAM_ENROLMENTS;
757
+ $this->setUrl($url)
758
+ ->setVerb('POST')
759
+ ->buildPostBody($data);
760
+ $response = $this->execute();
761
+
762
+ if (isset($response->message)) {
763
+ Mage::helper( 'connector' )->log( 'Post programs enrolments : ' . $response->message );
764
+ Mage::helper( 'connector' )->log( $data );
765
+ }
766
+
767
+ return $response;
768
+ }
769
+
770
+ /**
771
+ * Gets a program by id.
772
+ */
773
+ public function GetProgramById( $id ) {
774
+
775
+ $url = self::REST_PROGRAM . $id;
776
+ $this->setUrl($url)
777
+ ->setVerb('GET');
778
+ $response = $this->execute();
779
+
780
+ if(isset($response->messge)){
781
+ Mage::helper( 'connector' )->log( 'Get progrma by id ; ' . $id );
782
+ }
783
+
784
+ return $response;
785
+
786
+ }
787
+ }
app/code/community/Dotdigitalgroup/Email/Model/Apiconnector/Contact.php ADDED
@@ -0,0 +1,363 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dotdigitalgroup_Email_Model_Apiconnector_Contact
4
+ {
5
+ private $_start;
6
+ private $_countCustomers;
7
+ private $_wishlists;
8
+
9
+ /**
10
+ * Contact sync.
11
+ *
12
+ * @return array
13
+ */
14
+ public function sync()
15
+ {
16
+ $result = array('error' => false, 'message' => "Done.");
17
+ /** @var Dotdigitalgroup_Email_Helper_Data $helper */
18
+ $helper = Mage::helper('connector');
19
+ $helper->log('---------- Start customer sync ----------');
20
+ $this->_start = microtime(true);
21
+ //resourse allocation
22
+ $helper->allowResourceFullExecution();
23
+ foreach (Mage::app()->getWebsites(true) as $website) {
24
+ $enabled = Mage::helper('connector')->getWebsiteConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_API_ENABLED, $website);
25
+ $sync = Mage::helper('connector')->getWebsiteConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_SYNC_CONTACT_ENABLED, $website);
26
+ if ($enabled && $sync)
27
+ $this->exportCustomersForWebsite($website);
28
+ }
29
+ $helper->log('Total time for sync : ' . gmdate("H:i:s", microtime(true) - $this->_start));
30
+
31
+ return $result;
32
+ }
33
+
34
+ public function exportCustomersForWebsite(Mage_Core_Model_Website $website){
35
+ $updated = 0;
36
+ $customers = $headers = $allMappedHash = array();
37
+ $helper = Mage::helper('connector');
38
+ $pageSize = $helper->getWebsiteConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_SYNC_LIMIT, $website);
39
+ //skip if the mapping field is missing
40
+ if(!$helper->getCustomerAddressBook($website))
41
+ return;
42
+ //reset wishlists
43
+ $this->_wishlists = array();
44
+ $fileHelper = Mage::helper('connector/file');
45
+ $contactModel = Mage::getModel('email_connector/contact');
46
+ $client = Mage::helper('connector')->getWebsiteApiClient($website);
47
+ $contacts = $contactModel->getContactsToImportForWebsite($website->getId(), $pageSize);
48
+
49
+ // no contacts for this webiste
50
+ if (!count($contacts))
51
+ return;
52
+ //create customer filename
53
+ $customersFile = strtolower($website->getCode() . '_customers_' . date('d_m_Y_Hi') . '.csv');
54
+ $helper->log('Customers file : ' . $customersFile);
55
+
56
+ //get customer ids
57
+ $customerIds = array();
58
+ foreach ($contacts as $contact) {
59
+ $customerIds[] = $contact->getCustomerId();
60
+ }
61
+ //customer collection
62
+ $customerCollection = $this->getCollection($customerIds, $website);
63
+
64
+ /**
65
+ * HEADERS.
66
+ */
67
+ $mappedHash = $fileHelper->getWebsiteCustomerMappingDatafields($website);
68
+ $headers = $mappedHash;
69
+ //custom customer attributes
70
+ $customAttributes = $helper->getCustomAttributes($website);
71
+ foreach ($customAttributes as $data) {
72
+ $headers[] = $data['datafield'];
73
+ $allMappedHash[$data['attribute']] = $data['datafield'];
74
+ }
75
+ $headers[] = 'Email';
76
+ $headers[] = 'EmailType';
77
+ $fileHelper->outputCSV($fileHelper->getFilePath($customersFile), $headers);
78
+ /**
79
+ * END HEADERS.
80
+ */
81
+
82
+
83
+ foreach ($customerCollection as $customer) {
84
+ $contactModel = Mage::getModel('email_connector/contact')->loadByCustomerId($customer->getId());
85
+ //skip contacts without customer id
86
+ if(!$contactModel->getId())
87
+ continue;
88
+ /**
89
+ * DATA.
90
+ */
91
+ $connectorCustomer = Mage::getModel('email_connector/apiconnector_customer', $mappedHash);
92
+ $connectorCustomer->setCustomerData($customer, $website);
93
+ //count number of customers
94
+ $customers[] = $connectorCustomer;
95
+ foreach ($customAttributes as $data) {
96
+ $attribute = $data['attribute'];
97
+ $value = $customer->getData($attribute);
98
+ $connectorCustomer->setData($value);
99
+ }
100
+ //contact email and email type
101
+ $connectorCustomer->setData($customer->getEmail());
102
+ $connectorCustomer->setData('Html');
103
+ // save csv file data for customers
104
+ $fileHelper->outputCSV($fileHelper->getFilePath($customersFile), $connectorCustomer->toCSVArray());
105
+
106
+ /**
107
+ * END DATA.
108
+ */
109
+
110
+ //mark the contact as imported
111
+ $contactModel->setEmailImported(Dotdigitalgroup_Email_Model_Contact::EMAIL_CONTACT_IMPORTED);
112
+ $subscriber = Mage::getModel('newsletter/subscriber')->loadByEmail($customer->getEmail());
113
+ if ($subscriber->isSubscribed()) {
114
+ $contactModel->setIsSubscriber(1)
115
+ ->setSubscriberStatus($subscriber->getSubscriberStatus());
116
+ }
117
+
118
+ $contactModel->save();
119
+
120
+ //Send wishlist as transactional data
121
+ if ($helper->getWebsiteConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_SYNC_WISHLIST_ENABLED, $website)) {
122
+ $this->_setCustomerWishList($customer, $website);
123
+ }
124
+ $updated++;
125
+ }
126
+ //send wishlist as transactional data
127
+ if (isset($this->_wishlists[$website->getId()])) {
128
+ //send wishlists as transactional data
129
+ $websiteWishlists = $this->_wishlists[$website->getId()];
130
+ //remove wishlists one by one
131
+ foreach ($websiteWishlists as $wishlist) {
132
+ $email = $wishlist->email;
133
+ $client->deleteContactTransactionalData($email, 'Wishlist');
134
+ }
135
+ //import wishlists in bulk
136
+ $client->postContactsTransactionalDataImport($websiteWishlists, 'Wishlist');
137
+ }
138
+
139
+ $helper->log('Website : ' . $website->getName() . ', customers = ' . count($customers));
140
+ $helper->log('---------------------------- execution time :' . gmdate("H:i:s", microtime(true) - $this->_start));
141
+
142
+ if (file_exists($fileHelper->getFilePath($customersFile))) {
143
+ //import contacts
144
+ if ($updated > 0)
145
+ $client->postAddressBookContactsImport($customersFile, $helper->getCustomerAddressBook($website));
146
+ //archive file on success
147
+ $fileHelper->archiveCSV($customersFile);
148
+ }
149
+ $this->_countCustomers += $updated;
150
+ return;
151
+ }
152
+
153
+ /**
154
+ * @param $customer
155
+ * @param $website
156
+ */
157
+ private function _setCustomerWishList($customer, $website){
158
+ $website = Mage::app()->getWebsite($website);
159
+ $customerId = $customer->getId();
160
+ $wishlist = Mage::getModel('wishlist/wishlist')->loadByCustomer($customerId);
161
+ /** @var $connectorWishlist */
162
+ $connectorWishlist = Mage::getModel('email_connector/customer_wishlist', $customer);
163
+ $connectorWishlist->setId($wishlist->getId());
164
+ $wishListItemCollection = $wishlist->getItemCollection();
165
+ if (count($wishListItemCollection)) {
166
+ foreach ($wishListItemCollection as $item) {
167
+ /* @var $product Mage_Catalog_Model_Product */
168
+ $product = $item->getProduct();
169
+ $wishlistItem = Mage::getModel('email_connector/customer_wishlist_item', $product)
170
+ ->setQty($item->getQty())
171
+ ->setPrice($product);
172
+ //store for wishlists
173
+ $connectorWishlist->setItem($wishlistItem);
174
+ }
175
+ //set wishlists for later use
176
+ $this->_wishlists[$website->getId()][] = $connectorWishlist;
177
+ }
178
+ }
179
+
180
+ /**
181
+ * Sync a single contact.
182
+ *
183
+ * @param null $contactId
184
+ *
185
+ * @return mixed
186
+ * @throws Mage_Core_Exception
187
+ */
188
+ public function syncContact($contactId = null)
189
+ {
190
+ if ($contactId)
191
+ $contact = Mage::getModel('email_connector/contact')->load($contactId);
192
+ else {
193
+ $contact = Mage::registry('current_contact');
194
+ }
195
+ if (! $contact->getId()) {
196
+ Mage::getSingleton('adminhtml/session')->addError('No contact found!');
197
+ return false;
198
+ }
199
+
200
+ $websiteId = $contact->getWebsiteId();
201
+ $website = Mage::app()->getWebsite($websiteId);
202
+ $updated = 0;
203
+ $customers = $headers = $allMappedHash = array();
204
+ $helper = Mage::helper('connector');
205
+ $helper->log('---------- Start single customer sync ----------');
206
+ //skip if the mapping field is missing
207
+ if(!$helper->getCustomerAddressBook($website))
208
+ return false;
209
+ //reset wishlists
210
+ $this->_wishlists = array();
211
+ $fileHelper = Mage::helper('connector/file');
212
+
213
+ $customerId = $contact->getCustomerId();
214
+ if (!$customerId) {
215
+ Mage::getSingleton('adminhtml/session')->addError('Cannot manually sync guests!');
216
+ return false;
217
+ }
218
+ $client = Mage::helper('connector')->getWebsiteApiClient($website);
219
+
220
+ //create customer filename
221
+ $customersFile = strtolower($website->getCode() . '_customers_' . date('d_m_Y_Hi') . '.csv');
222
+ $helper->log('Customers file : ' . $customersFile);
223
+
224
+ /**
225
+ * HEADERS.
226
+ */
227
+ $mappedHash = $fileHelper->getWebsiteCustomerMappingDatafields($website);
228
+ $headers = $mappedHash;
229
+ //custom customer attributes
230
+ $customAttributes = $helper->getCustomAttributes($website);
231
+ foreach ($customAttributes as $data) {
232
+ $headers[] = $data['datafield'];
233
+ $allMappedHash[$data['attribute']] = $data['datafield'];
234
+ }
235
+ $headers[] = 'Email';
236
+ $headers[] = 'EmailType';
237
+ $fileHelper->outputCSV($fileHelper->getFilePath($customersFile), $headers);
238
+ /**
239
+ * END HEADERS.
240
+ */
241
+ $customerCollection = $this->getCollection(array($customerId));
242
+
243
+ foreach ($customerCollection as $customer) {
244
+ $contactModel = Mage::getModel('email_connector/contact')->loadByCustomerId($customer->getId());
245
+ //skip contacts without customer id
246
+ if (!$contactModel->getId())
247
+ continue;
248
+ /**
249
+ * DATA.
250
+ */
251
+ $connectorCustomer = Mage::getModel('email_connector/apiconnector_customer', $mappedHash);
252
+ $connectorCustomer->setCustomerData($customer, $website);
253
+ //count number of customers
254
+ $customers[] = $connectorCustomer;
255
+ foreach ($customAttributes as $data) {
256
+ $attribute = $data['attribute'];
257
+ $value = $customer->getData($attribute);
258
+ $connectorCustomer->setData($value);
259
+ }
260
+ //contact email and email type
261
+ $connectorCustomer->setData($customer->getEmail());
262
+ $connectorCustomer->setData('Html');
263
+ // save csv file data for customers
264
+ $fileHelper->outputCSV($fileHelper->getFilePath($customersFile), $connectorCustomer->toCSVArray());
265
+
266
+ /**
267
+ * END DATA.
268
+ */
269
+
270
+ //mark the contact as imported
271
+ $contactModel->setEmailImported(Dotdigitalgroup_Email_Model_Contact::EMAIL_CONTACT_IMPORTED);
272
+ $subscriber = Mage::getModel('newsletter/subscriber')->loadByEmail($customer->getEmail());
273
+ if ($subscriber->isSubscribed()) {
274
+ $contactModel->setIsSubscriber(1)
275
+ ->setSubscriberStatus($subscriber->getSubscriberStatus());
276
+ }
277
+
278
+ $contactModel->save();
279
+
280
+ //Send wishlist as transactional data
281
+ if ($helper->getWebsiteConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_SYNC_WISHLIST_ENABLED, $website)) {
282
+ $this->_setCustomerWishList($customer, $website);
283
+ }
284
+ $updated++;
285
+ }
286
+ //send wishlist as transactional data
287
+ if (isset($this->_wishlists[$website->getId()])) {
288
+ //send wishlists as transactional data
289
+ $websiteWishlists = $this->_wishlists[$website->getId()];
290
+ //remove wishlists one by one
291
+ foreach ($websiteWishlists as $wishlist) {
292
+ $email = $wishlist->email;
293
+ $client->deleteContactTransactionalData($email, 'Wishlist');
294
+ }
295
+ //import wishlists in bulk
296
+ $client->postContactsTransactionalDataImport($websiteWishlists, 'Wishlist');
297
+ }
298
+
299
+ if (file_exists($fileHelper->getFilePath($customersFile))) {
300
+ //import contacts
301
+ if ($updated > 0)
302
+ $client->postAddressBookContactsImport($customersFile, $helper->getCustomerAddressBook($website));
303
+ //archive file on success
304
+ $fileHelper->archiveCSV($customersFile);
305
+ }
306
+ return $contact->getEmail();
307
+ }
308
+
309
+
310
+ /**
311
+ * get customer collection
312
+ * @param $customerIds
313
+ * @param $website null
314
+ * @return Mage_Eav_Model_Entity_Collection_Abstract
315
+ * @throws Mage_Core_Exception
316
+ */
317
+ public function getCollection($customerIds, $website = null)
318
+ {
319
+ $customerCollection = Mage::getResourceModel('customer/customer_collection')
320
+ ->addNameToSelect()
321
+ ->addAttributeToSelect('*')
322
+ ->joinAttribute('billing_street', 'customer_address/street', 'default_billing', null, 'left')
323
+ ->joinAttribute('billing_city', 'customer_address/city', 'default_billing', null, 'left')
324
+ ->joinAttribute('billing_country_code', 'customer_address/country_id', 'default_billing', null, 'left')
325
+ ->joinAttribute('billing_postcode', 'customer_address/postcode', 'default_billing', null, 'left')
326
+ ->joinAttribute('billing_telephone', 'customer_address/telephone', 'default_billing', null, 'left')
327
+ ->joinAttribute('billing_region', 'customer_address/region', 'default_billing', null, 'left')
328
+ ->joinAttribute('shipping_street', 'customer_address/street', 'default_shipping', null, 'left')
329
+ ->joinAttribute('shipping_city', 'customer_address/city', 'default_shipping', null, 'left')
330
+ ->joinAttribute('shipping_country_code','customer_address/country_id', 'default_shipping', null, 'left')
331
+ ->joinAttribute('shipping_postcode', 'customer_address/postcode', 'default_shipping', null, 'left')
332
+ ->joinAttribute('shipping_telephone', 'customer_address/telephone', 'default_shipping', null, 'left')
333
+ ->joinAttribute('shipping_region', 'customer_address/region', 'default_shipping', null, 'left')
334
+ ->addAttributeToFilter('entity_id', array('in' => $customerIds));
335
+ $customer_log = Mage::getSingleton('core/resource')->getTableName('log_customer');
336
+ $sales_flat_order_grid = Mage::getSingleton('core/resource')->getTableName('sales_flat_order_grid');
337
+
338
+ // get the last login date from the log_customer table
339
+ $customerCollection->getSelect()->columns(
340
+ array('last_logged_date' => new Zend_Db_Expr ("(SELECT login_at FROM $customer_log WHERE customer_id =e.entity_id ORDER BY log_id DESC LIMIT 1)")));
341
+
342
+ // customer order information
343
+ $alias = 'subselect';
344
+ $subselect = Mage::getModel('Varien_Db_Select', Mage::getSingleton('core/resource')->getConnection('core_read'))
345
+ ->from($sales_flat_order_grid, array(
346
+ 'customer_id as s_customer_id',
347
+ 'sum(grand_total) as total_spend',
348
+ 'count(*) as number_of_orders',
349
+ 'avg(grand_total) as average_order_value',
350
+ )
351
+ )->group('customer_id')
352
+ ;
353
+ $customerCollection->getSelect()->columns(array(
354
+ 'last_order_date' => new Zend_Db_Expr("(SELECT created_at FROM $sales_flat_order_grid WHERE customer_id =e.entity_id ORDER BY created_at DESC LIMIT 1)"),
355
+ 'last_order_id' => new Zend_Db_Expr("(SELECT entity_id FROM $sales_flat_order_grid WHERE customer_id =e.entity_id ORDER BY created_at DESC LIMIT 1)")
356
+ )
357
+ );
358
+ $customerCollection->getSelect()
359
+ ->joinLeft(array($alias => $subselect), "{$alias}.s_customer_id = e.entity_id");
360
+
361
+ return $customerCollection;
362
+ }
363
+ }
app/code/community/Dotdigitalgroup/Email/Model/Apiconnector/Customer.php ADDED
@@ -0,0 +1,621 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dotdigitalgroup_Email_Model_Apiconnector_Customer
4
+ {
5
+
6
+ public $customer;
7
+ public $customerData;
8
+ public $reviewCollection;
9
+
10
+ public $rewardCustomer;
11
+ public $rewardLastSpent = "";
12
+ public $rewardLastEarned = "";
13
+ public $rewardExpiry = "";
14
+
15
+ protected $_mapping_hash;
16
+
17
+
18
+ /**
19
+ * constructor, mapping hash to map.
20
+ *
21
+ * @param $mappingHash
22
+ */
23
+ public function __construct( $mappingHash)
24
+ {
25
+ $this->setMappigHash($mappingHash);
26
+ }
27
+
28
+ /**
29
+ * Set key value data.
30
+ *
31
+ * @param $data
32
+ */
33
+ public function setData($data)
34
+ {
35
+ $this->customerData[] = $data;
36
+ }
37
+
38
+ /**
39
+ * Set customer data.
40
+ *
41
+ * @param Mage_Customer_Model_Customer $customer
42
+ */
43
+ public function setCustomerData(Mage_Customer_Model_Customer $customer, $website = null)
44
+ {
45
+ $helper = Mage::helper('connector');
46
+
47
+ $this->customer = $customer;
48
+ $this->setReviewCollection();
49
+
50
+ if($website && $helper->isSweetToothToGo($website))
51
+ $this->setRewardCustomer($customer);
52
+
53
+ foreach ($this->getMappingHash() as $key => $field) {
54
+
55
+ /**
56
+ * call user function based on the attribute mapped.
57
+ */
58
+ $function = 'get';
59
+ $exploded = explode('_', $key);
60
+ foreach ($exploded as $one) {
61
+ $function .= ucfirst($one);
62
+ }
63
+ try{
64
+ $value = call_user_func(array('self', $function));
65
+ $this->customerData[$key] = $value;
66
+ }catch (Exception $e){
67
+ Mage::logException($e);
68
+ }
69
+ }
70
+ }
71
+
72
+ public function setReviewCollection()
73
+ {
74
+ $customer_id = $this->customer->getId();
75
+ $collection = Mage::getModel('review/review')->getCollection();
76
+ $collection
77
+ ->addCustomerFilter($customer_id)
78
+ ->setOrder('review_id','DESC');
79
+ $this->reviewCollection = $collection;
80
+ }
81
+
82
+ public function getReviewCount()
83
+ {
84
+ return count($this->reviewCollection);
85
+ }
86
+
87
+ public function getLastReviewDate(){
88
+ if(count($this->reviewCollection))
89
+ return $this->reviewCollection->getFirstItem()->getCreatedAt();
90
+ return '';
91
+ }
92
+
93
+ /**
94
+ * Set reward customer
95
+ *
96
+ * @param Mage_Customer_Model_Customer $customer
97
+ */
98
+ public function setRewardCustomer(Mage_Customer_Model_Customer $customer)
99
+ {
100
+ $tbt_reward = Mage::getModel('rewards/customer')->getRewardsCustomer($customer);
101
+ $this->rewardCustomer = $tbt_reward;
102
+
103
+ $lastTransfers = $tbt_reward->getTransfers()
104
+ ->selectOnlyActive()
105
+ ->addOrder('last_update_ts', Varien_Data_Collection::SORT_ORDER_DESC);
106
+
107
+ $spent = $earn = null;
108
+
109
+ if($lastTransfers->getSize()) {
110
+ foreach($lastTransfers as $transfer) {
111
+ if(is_null($earn) && $transfer->getQuantity() > 0){
112
+ $earn = $transfer->getEffectiveStart();
113
+ }else if(is_null($spent) && $transfer->getQuantity() < 0) {
114
+ $spent = $transfer->getEffectiveStart();
115
+ }
116
+ if(!is_null($spent) && !is_null($earn)) {
117
+ break;
118
+ }
119
+ }
120
+ }
121
+
122
+ if($earn) $this->rewardLastEarned = $earn;
123
+ if($spent) $this->rewardLastSpent = $spent;
124
+
125
+ $tbt_expiry = Mage::getSingleton('rewards/expiry')
126
+ ->getExpiryDate($tbt_reward);
127
+
128
+ if($tbt_expiry) $this->rewardExpiry = $tbt_expiry;
129
+ }
130
+
131
+ /**
132
+ * get customer id.
133
+ *
134
+ * @return mixed
135
+ */
136
+ public function getCustomerId()
137
+ {
138
+ return $this->customer->getId();
139
+ }
140
+
141
+ /**
142
+ * get first name.
143
+ *
144
+ * @return mixed
145
+ */
146
+ public function getFirstname(){
147
+ return $this->customer->getFirstname();
148
+ }
149
+
150
+ /**
151
+ * get last name.
152
+ *
153
+ * @return mixed
154
+ */
155
+ public function getLastname()
156
+ {
157
+ return $this->customer->getLastname();
158
+ }
159
+
160
+ /**
161
+ * get date of birth.
162
+ *
163
+ * @return mixed
164
+ */
165
+ public function getDob()
166
+ {
167
+ return $this->customer->getDob();
168
+ }
169
+
170
+ /**
171
+ * get customer gender.
172
+ *
173
+ * @return bool|string
174
+ */
175
+ public function getGender(){
176
+ return $this->_getCustomerGender();
177
+ }
178
+
179
+ /**
180
+ * get customer prefix.
181
+ *
182
+ * @return mixed
183
+ */
184
+ public function getPrefix()
185
+ {
186
+ return $this->customer->getPrefix();
187
+ }
188
+
189
+ /**
190
+ * get customer suffix.
191
+ *
192
+ * @return mixed
193
+ */
194
+ public function getSuffix()
195
+ {
196
+ return $this->customer->getSuffix();
197
+ }
198
+
199
+ /**
200
+ * get website name.
201
+ *
202
+ * @return string
203
+ */
204
+ public function getWebsiteName()
205
+ {
206
+ return $this->_getWebsiteName();
207
+ }
208
+
209
+ /**
210
+ * get store name.
211
+ *
212
+ * @return null|string
213
+ */
214
+ public function getStoreName()
215
+ {
216
+ return $this->_getStoreName();
217
+ }
218
+
219
+ /**
220
+ * get customer created at date.
221
+ *
222
+ * @return mixed
223
+ */
224
+ public function getCreatedAt()
225
+ {
226
+ return $this->customer->getCreatedAt();
227
+ }
228
+
229
+ /**
230
+ * get customer last logged in date.
231
+ *
232
+ * @return mixed
233
+ */
234
+ public function getLastLoggedDate()
235
+ {
236
+ return $this->customer->getLastLoggedDate();
237
+ }
238
+
239
+ /**
240
+ * get cutomer group.
241
+ *
242
+ * @return string
243
+ */
244
+ public function getCustomerGroup()
245
+ {
246
+ return $this->_getCustomerGroup();
247
+ }
248
+
249
+ /**
250
+ * get billing address line 1.
251
+ *
252
+ * @return string
253
+ */
254
+ public function getBillingAddress1()
255
+ {
256
+ return $this->_getStreet($this->customer->getBillingStreet(), 1);
257
+ }
258
+
259
+ /**
260
+ * get billing address line 2.
261
+ *
262
+ * @return string
263
+ */
264
+ public function getBillingAddress2()
265
+ {
266
+ return $this->_getStreet($this->customer->getBillingStreet(), 2);
267
+ }
268
+
269
+ /**
270
+ * get billing city.
271
+ *
272
+ * @return mixed
273
+ */
274
+ public function getBillingCity()
275
+ {
276
+ return $this->customer->getBillingCity();
277
+ }
278
+
279
+ /**
280
+ * get billing country.
281
+ *
282
+ * @return mixed
283
+ */
284
+ public function getBillingCountry()
285
+ {
286
+ return $this->customer->getBillingCountryCode();
287
+ }
288
+
289
+ /**
290
+ * get billing state.
291
+ *
292
+ * @return mixed
293
+ */
294
+ public function getBillingState()
295
+ {
296
+ return $this->customer->getBillingRegion();
297
+ }
298
+
299
+ /**
300
+ * get billing postcode.
301
+ *
302
+ * @return mixed
303
+ */
304
+ public function getBillingPostcode()
305
+ {
306
+ return $this->customer->getBillingPostcode();
307
+ }
308
+
309
+ /**
310
+ * get billing phone.
311
+ *
312
+ * @return mixed
313
+ */
314
+ public function getBillingTelephone()
315
+ {
316
+ return $this->customer->getBillingTelephone();
317
+ }
318
+
319
+ /**
320
+ * get delivery address line 1.
321
+ *
322
+ * @return string
323
+ */
324
+ public function getDeliveryAddress1()
325
+ {
326
+ return $this->_getStreet($this->customer->getShippingStreet(), 1);
327
+ }
328
+
329
+ /**
330
+ * get delivery addrss line 2.
331
+ *
332
+ * @return string
333
+ */
334
+ public function getDeliveryAddress2()
335
+ {
336
+ return $this->_getStreet($this->customer->getShippingStreet(), 2);
337
+ }
338
+
339
+ /**
340
+ * get delivery city.
341
+ *
342
+ * @return mixed
343
+ */
344
+ public function getDeliveryCity()
345
+ {
346
+ return $this->customer->getShippingCity();
347
+ }
348
+
349
+ /**
350
+ * get delivery country.
351
+ *
352
+ * @return mixed
353
+ */
354
+ public function getDeliveryCountry(){
355
+ return $this->customer->getShippingCountryCode();
356
+ }
357
+
358
+ /**
359
+ * get delivery state.
360
+ *
361
+ * @return mixed
362
+ */
363
+ public function getDeliveryState()
364
+ {
365
+ return $this->customer->getShippingRegion();
366
+ }
367
+
368
+ /**
369
+ * get delivery postcode.
370
+ *
371
+ * @return mixed
372
+ */
373
+ public function getDeliveryPostcode()
374
+ {
375
+ return $this->customer->getShippingPostcode();
376
+ }
377
+
378
+ /**
379
+ * get delivery phone.
380
+ *
381
+ * @return mixed
382
+ */
383
+ public function getDeliveryTelephone(){
384
+ return $this->customer->getShippingTelephone();
385
+ }
386
+
387
+ /**
388
+ * get numbser of orders.
389
+ *
390
+ * @return mixed
391
+ */
392
+ public function getNumberOfOrders()
393
+ {
394
+ return $this->customer->getNumberOfOrders();
395
+ }
396
+
397
+ /**
398
+ * get average order value.
399
+ *
400
+ * @return mixed
401
+ */
402
+ public function getAverageOrderValue()
403
+ {
404
+ return $this->customer->getAverageOrderValue();
405
+ }
406
+
407
+ /**
408
+ * get total spend.
409
+ *
410
+ * @return mixed
411
+ */
412
+ public function getTotalSpend()
413
+ {
414
+ return $this->customer->getTotalSpend();
415
+ }
416
+
417
+ /**
418
+ * get last order date.
419
+ *
420
+ * @return mixed
421
+ */
422
+ public function getLastOrderDate()
423
+ {
424
+ return $this->customer->getLastOrderDate();
425
+ }
426
+
427
+ /**
428
+ * get last order date.
429
+ *
430
+ * @return mixed
431
+ */
432
+ public function getLastOrderId()
433
+ {
434
+ return $this->customer->getLastOrderId();
435
+ }
436
+
437
+ /**
438
+ * get cutomer id.
439
+ *
440
+ * @return mixed
441
+ */
442
+ public function getId()
443
+ {
444
+ return $this->customer->getId();
445
+ }
446
+
447
+ /**
448
+ * get customer title.
449
+ *
450
+ * @return mixed
451
+ */
452
+ public function getTitle()
453
+ {
454
+ return $this->customer->getPrefix();
455
+ }
456
+
457
+ /**
458
+ * get total refund value.
459
+ *
460
+ * @return float|int
461
+ */
462
+ public function getTotalRefund()
463
+ {
464
+ $orders = Mage::getResourceModel('sales/order_collection')
465
+ ->addAttributeToFilter('customer_id', $this->customer->getId())
466
+ ;
467
+ $totalRefunded = 0;
468
+ foreach ($orders as $order) {
469
+ $refunded = $order->getTotalRefunded();
470
+ $totalRefunded += $refunded;
471
+ }
472
+
473
+ return $totalRefunded;
474
+ }
475
+
476
+ /**
477
+ * export to CSV.
478
+ *
479
+ * @return mixed
480
+ */
481
+ public function toCSVArray()
482
+ {
483
+ $result = $this->customerData;
484
+ return $result;
485
+ }
486
+
487
+ /**
488
+ * customer gender.
489
+ *
490
+ * @return bool|string
491
+ * @throws Mage_Core_Exception
492
+ */
493
+ private function _getCustomerGender()
494
+ {
495
+ $genderId = $this->customer->getGender();
496
+ if (is_numeric($genderId)) {
497
+ $gender = Mage::getResourceModel('customer/customer')
498
+ ->getAttribute('gender')
499
+ ->getSource()
500
+ ->getOptionText($genderId)
501
+ ;
502
+ return $gender;
503
+ }
504
+
505
+ return '';
506
+ }
507
+
508
+ private function _getStreet($street, $line){
509
+ $street = explode("\n", $street);
510
+ if(isset($street[$line - 1]))
511
+ return $street[$line - 1];
512
+ return '';
513
+ }
514
+
515
+ private function _getWebsiteName(){
516
+ $websiteId = $this->customer->getWebsiteId();
517
+ $website = Mage::app()->getWebsite($websiteId);
518
+ if($website)
519
+ return $website->getName();
520
+
521
+ return '';
522
+ }
523
+
524
+ private function _getStoreName()
525
+ {
526
+ $storeId = $this->customer->getStoreId();
527
+ $store = Mage::app()->getStore($storeId);
528
+ if($store)
529
+ return $store->getName();
530
+
531
+ return '';
532
+ }
533
+
534
+ /**
535
+ * @param mixed $mapping_hash
536
+ */
537
+ public function setMappingHash($mapping_hash)
538
+ {
539
+ $this->_mapping_hash = $mapping_hash;
540
+ }
541
+
542
+ /**
543
+ * @return mixed
544
+ */
545
+ public function getMappingHash()
546
+ {
547
+ return $this->_mapping_hash;
548
+ }
549
+
550
+ private function _getCustomerGroup(){
551
+ $groupId = $this->customer->getGroupId();
552
+ $group = Mage::getModel('customer/group')->load($groupId);
553
+ if($group){
554
+ return $group->getCode();
555
+ }
556
+ return '';
557
+ }
558
+
559
+ /**
560
+ * mapping hash value.
561
+ *
562
+ * @param $value
563
+ *
564
+ * @return $this
565
+ */
566
+ public function setMappigHash($value)
567
+ {
568
+ $this->_mapping_hash = $value;
569
+ return $this;
570
+ }
571
+
572
+ public function getRewardPointBalance()
573
+ {
574
+ return $this->cleanString($this->rewardCustomer->getPointsSummary());
575
+ }
576
+
577
+ public function getRewardPointPending()
578
+ {
579
+ return $this->cleanString($this->rewardCustomer->getPendingPointsSummary());
580
+ }
581
+
582
+ public function getRewardPointPendingTime()
583
+ {
584
+ return $this->cleanString($this->rewardCustomer->getPendingTimePointsSummary());
585
+ }
586
+
587
+ public function getRewardPointOnHold()
588
+ {
589
+ return $this->cleanString($this->rewardCustomer->getOnHoldPointsSummary());
590
+ }
591
+
592
+ public function getRewardPointExpiration()
593
+ {
594
+ if($this->rewardExpiry != "")
595
+ return date_format(date_create($this->makeUSDate($this->rewardExpiry)), 'Y-m-d H:i:s');
596
+ return $this->rewardExpiry;
597
+ }
598
+
599
+ public function getRewardPointLastSpent()
600
+ {
601
+ return $this->rewardLastSpent;
602
+ }
603
+
604
+ public function getRewardPointLastEarn()
605
+ {
606
+ return $this->rewardLastEarned;
607
+ }
608
+
609
+ public function makeUSDate($uk_date, $separator_input = '/', $sepatator_output = '/')
610
+ {
611
+ list($day, $month, $year) = explode($separator_input, $uk_date);
612
+ return $month.$sepatator_output.$day.$sepatator_output.$year;
613
+ }
614
+
615
+ public function cleanString($string)
616
+ {
617
+ $cleanedString = preg_replace("/[^0-9]/","",$string);
618
+ if($cleanedString != "") return (int) number_format($cleanedString, 0, '.', '');
619
+ return (int) 0;
620
+ }
621
+ }
app/code/community/Dotdigitalgroup/Email/Model/Apiconnector/Test.php ADDED
@@ -0,0 +1,78 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dotdigitalgroup_Email_Model_Apiconnector_Test extends Dotdigitalgroup_Email_Model_Apiconnector_Client
4
+ {
5
+ const TEST_API_USERNAME = 'apiuser-8e3b8f244ec9@apiconnector.com';
6
+ const TEST_API_PASSWORD = 'Magento2013';
7
+ const TEST_API_CAMPAIGN = '2643928';
8
+ const TEST_CONTACT_ID = '13';
9
+ const TEST_CONTACT_EMAIL = 'ben.staveley@dotmailer.co.uk';
10
+
11
+
12
+ /**
13
+ * Validate apiuser on save.
14
+ *
15
+ * @param $apiUsername
16
+ * @param $apiPassword
17
+ *
18
+ * @return bool|mixed
19
+ */
20
+ public function validate($apiUsername, $apiPassword)
21
+ {
22
+ if ($apiUsername && $apiPassword) {
23
+ $this->setApiUsername($apiUsername)
24
+ ->setApiPassword($apiPassword);
25
+
26
+ $accountInfo = $this->getAccountInfo();
27
+ if (isset($accountInfo->message)) {
28
+ Mage::getSingleton('adminhtml/session')->addError($accountInfo->message);
29
+ Mage::helper('connector')->log('VALIDATION ERROR : ' . $accountInfo->message);
30
+ return false;
31
+ }
32
+ return $accountInfo;
33
+ }
34
+ return false;
35
+ }
36
+
37
+ /**
38
+ * Ajax validate api user.
39
+ *
40
+ * @param $apiUsername
41
+ * @param $apiPassword
42
+ *
43
+ * @return bool|string
44
+ */
45
+ public function ajaxvalidate($apiUsername, $apiPassword)
46
+ {
47
+ if ($apiUsername && $apiPassword) {
48
+ $message = 'Credentials Valid.';
49
+ $this->setApiUsername($apiUsername)
50
+ ->setApiPassword($apiPassword);
51
+ $response = $this->getAccountInfo();
52
+ if (isset($response->message)) {
53
+ $message = 'API Username And API Password Do Not Match!';
54
+ Mage::helper('connector')->log($message);
55
+ }
56
+ return $message;
57
+ }
58
+ return false;
59
+ }
60
+
61
+ /**
62
+ * Confirm the installation.
63
+ */
64
+ public function sendInstallConfirmation()
65
+ {
66
+ // set test credentials
67
+ $this->setApiUsername(self::TEST_API_USERNAME)
68
+ ->setApiPassword(self::TEST_API_PASSWORD);
69
+ $testEmail = self::TEST_CONTACT_EMAIL;
70
+ $contactId = self::TEST_CONTACT_ID;
71
+ $campaignId = self::TEST_API_CAMPAIGN;
72
+
73
+ /**
74
+ * send initial info
75
+ */
76
+ $this->sendIntallInfo($testEmail, $contactId, $campaignId);
77
+ }
78
+ }
app/code/community/Dotdigitalgroup/Email/Model/Campaign.php ADDED
@@ -0,0 +1,247 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dotdigitalgroup_Email_Model_Campaign extends Mage_Core_Model_Abstract
4
+ {
5
+ //xml path configuration
6
+ const XML_PATH_LOSTBASKET_1_ENABLED = 'connector_lost_baskets/customers/enabled_1';
7
+ const XML_PATH_LOSTBASKET_2_ENABLED = 'connector_lost_baskets/customers/enabled_2';
8
+ const XML_PATH_LOSTBASKET_3_ENABLED = 'connector_lost_baskets/customers/enabled_3';
9
+
10
+ const XML_PATH_LOSTBASKET_1_INTERVAL = 'connector_lost_baskets/customers/send_after_1';
11
+ const XML_PATH_LOSTBASKET_2_INTERVAL = 'connector_lost_baskets/customers/send_after_2';
12
+ const XML_PATH_LOSTBASKET_3_INTERVAL = 'connector_lost_baskets/customers/send_after_3';
13
+
14
+ const XML_PATH_TRIGGER_1_CAMPAIGN = 'connector_lost_baskets/customers/campaign_1';
15
+ const XML_PATH_TRIGGER_2_CAMPAIGN = 'connector_lost_baskets/customers/campaign_2';
16
+ const XML_PATH_TRIGGER_3_CAMPAIGN = 'connector_lost_baskets/customers/campaign_3';
17
+
18
+ const XML_PATH_GUEST_LOSTBASKET_1_ENABLED = 'connector_lost_baskets/guests/enabled_1';
19
+ const XML_PATH_GUEST_LOSTBASKET_2_ENABLED = 'connector_lost_baskets/guests/enabled_2';
20
+ const XML_PATH_GUEST_LOSTBASKET_3_ENABLED = 'connector_lost_baskets/guests/enabled_3';
21
+
22
+ const XML_PATH_GUEST_LOSTBASKET_1_INTERVAL = 'connector_lost_baskets/guests/send_after_1';
23
+ const XML_PATH_GUEST_LOSTBASKET_2_INTERVAL = 'connector_lost_baskets/guests/send_after_2';
24
+ const XML_PATH_GUEST_LOSTBASKET_3_INTERVAL = 'connector_lost_baskets/guests/send_after_3';
25
+
26
+ const XML_PATH_GUEST_LOSTBASKET_1_CAMPAIGN = 'connector_lost_baskets/guests/campaign_1';
27
+ const XML_PATH_GUEST_LOSTBASKET_2_CAMPAIGN = 'connector_lost_baskets/guests/campaign_2';
28
+ const XML_PATH_GUEST_LOSTBASKET_3_CAMPAIGN = 'connector_lost_baskets/guests/campaign_3';
29
+
30
+
31
+ //error messages
32
+ const SEND_EMAIL_CONTACT_ID_MISSING = 'Error : missing contact id - will try later to send ';
33
+
34
+ /**
35
+ * @var object
36
+ */
37
+ public $transactionalClient;
38
+
39
+ /**
40
+ * constructor
41
+ */
42
+ public function _construct()
43
+ {
44
+ parent::_construct();
45
+ $this->_init('email_connector/campaign');
46
+
47
+ $this->transactionalClient = Mage::helper('connector/transactional')->getWebsiteApiClient();
48
+ }
49
+
50
+ /**
51
+ * @return $this|Mage_Core_Model_Abstract
52
+ */
53
+ protected function _beforeSave()
54
+ {
55
+ parent::_beforeSave();
56
+ $now = Mage::getSingleton('core/date')->gmtDate();
57
+ if ($this->isObjectNew()) {
58
+ $this->setCreatedAt($now);
59
+ }
60
+ $this->setUpdatedAt($now);
61
+ return $this;
62
+ }
63
+
64
+ /**
65
+ * @param $quoteId
66
+ * @param $storeId
67
+ * @return mixed
68
+ */
69
+ public function loadByQuoteId($quoteId, $storeId)
70
+ {
71
+ $collection = $this->getCollection()
72
+ ->addFieldToFilter('quote_id', $quoteId)
73
+ ->addFieldToFilter('store_id', $storeId);
74
+
75
+ if ($collection->count()) {
76
+ return $collection->getFirstItem();
77
+ } else {
78
+ $this->setQuoteId($quoteId)
79
+ ->setStoreId($storeId);
80
+ }
81
+
82
+ return $this;
83
+ }
84
+
85
+
86
+ /**
87
+ * Sending the campaigns.
88
+ */
89
+ public function sendCampaigns()
90
+ {
91
+ //grab the emails not send
92
+ $emailsToSend = $this->_getEmailCampaigns();
93
+ $templateModel = Mage::getModel('email_connector/email_template');
94
+
95
+ foreach ($emailsToSend as $campaign) {
96
+ $email = $campaign->getEmail();
97
+ $storeId = $campaign->getStoreId();
98
+ $store = Mage::app()->getStore($storeId);
99
+ $websiteId = $store->getWebsiteId();
100
+ $storeName = $store->getName();
101
+ $websiteName = $store->getWebsite()->getName();
102
+ $campaignId = $campaign->getCampaignId();
103
+ if (!$campaignId) {
104
+ $campaign->setMessage('Missing campaign id: ' . $campaignId)
105
+ ->setIsSent(1)
106
+ ->save();
107
+ continue;
108
+ } elseif (!$email) {
109
+ $campaign->setMessage('Missing email : ' . $email)
110
+ ->setIsSent(1)
111
+ ->save();
112
+ }
113
+ try{
114
+ if ($campaign->getEventName() == 'Lost Basket') {
115
+ $client = Mage::helper('connector')->getWebsiteApiClient($websiteId);
116
+ $contactId = Mage::helper('connector')->getContactId($campaign->getEmail(), $websiteId);
117
+ Mage::helper('connector')->log($contactId);
118
+ $response = $client->postCampaignsSend($campaignId, array($contactId));
119
+ if (isset($response->message)) {
120
+ //update the failed to send email message
121
+ $campaign->setMessage($response->message)->setIsSent(1)->save();
122
+ }
123
+ $now = Mage::getSingleton('core/date')->gmtDate();
124
+ //record suscces
125
+ $campaign->setIsSent(1)
126
+ ->setMessage(NULL)
127
+ ->setSentAt($now)
128
+ ->save();
129
+
130
+ continue;
131
+ } elseif ($campaign->getEventName() == 'New Customer Account') {
132
+ $contactId = Mage::helper('connector/transactional')->getContactId($campaign->getEmail(), $websiteId);
133
+ $customerId = $campaign->getCustomerId();
134
+ $customer = Mage::getModel('customer/customer')->load($customerId);
135
+ $firstname = $customer->getFirstname();
136
+ $lastname = $customer->getLastname();
137
+ $data = array(
138
+ array(
139
+ 'Key' => 'STORE_NAME',
140
+ 'Value' => $storeName),
141
+ array(
142
+ 'Key' => 'WEBSITE_NAME',
143
+ 'Value' => $websiteName),
144
+ array(
145
+ 'Key' => 'FIRSTNAME',
146
+ 'Value' => $firstname),
147
+ array(
148
+ 'Key' => 'LASTNAME',
149
+ 'Value' => $lastname),
150
+ array(
151
+ 'Key' => 'CUSTOMER_ID',
152
+ 'Value' => $customerId)
153
+ );
154
+ $this->transactionalClient->updateContactDatafieldsByEmail($email, $data);
155
+ $response = $this->transactionalClient->postCampaignsSend($campaignId, array($contactId));
156
+ if (isset($response->message)) {
157
+ //update the failed to send email message
158
+ $campaign->setMessage($response->message)->setIsSent(1)->save();
159
+ } else {
160
+ $now = Mage::getSingleton('core/date')->gmtDate();
161
+ //record suscces
162
+ $campaign->setIsSent(1)
163
+ ->setMessage(NULL)
164
+ ->setSentAt($now)
165
+ ->save();
166
+ }
167
+ } elseif ($templateModel->getSalesEvent($campaign->getEventName())) {
168
+ // transactional
169
+ $orderModel = Mage::getModel("sales/order")->loadByIncrementId($campaign->getOrderIncrementId());
170
+ $contactId = Mage::helper('connector/transactional')->getContactId($campaign->getEmail(), $websiteId);
171
+ if (is_numeric($contactId)) {
172
+ if ($orderModel->getCustomerId()) {
173
+ $firstname = $orderModel->getCustomerFirstname();
174
+ $lastname = $orderModel->getCustomerLastname();
175
+ } else {
176
+ $billing = $orderModel->getBillingAddress();
177
+ $firstname = $billing->getFirstname();
178
+ $lastname = $billing->getLastname();
179
+ }
180
+ $data = array(
181
+ array(
182
+ 'Key' => 'STORE_NAME',
183
+ 'Value' => $storeName),
184
+ array(
185
+ 'Key' => 'WEBSITE_NAME',
186
+ 'Value' => $websiteName),
187
+ array(
188
+ 'Key' => 'FIRSTNAME',
189
+ 'Value' => $firstname),
190
+ array(
191
+ 'Key' => 'LASTNAME',
192
+ 'Value' => $lastname),
193
+ array(
194
+ 'Key' => 'LAST_ORDER_ID',
195
+ 'Value' => $orderModel->getId())
196
+ );
197
+ $this->transactionalClient->updateContactDatafieldsByEmail($email, $data);
198
+ }
199
+ $response = $this->transactionalClient->postCampaignsSend($campaignId, array($contactId));
200
+ if (isset($response->message)) {
201
+ //update the failed to send email message
202
+ $campaign->setMessage($response->message)->setIsSent(1)->save();
203
+ } else {
204
+ $now = Mage::getSingleton('core/date')->gmtDate();
205
+ //record suscces
206
+ $campaign->setIsSent(1)
207
+ ->setMessage(NULL)
208
+ ->setSentAt($now)
209
+ ->save();
210
+ }
211
+ }else{
212
+ $contactId = Mage::helper('connector/transactional')->getContactId($campaign->getEmail(), $websiteId);
213
+ Mage::helper('connector')->log($contactId);
214
+ $response = $this->transactionalClient->postCampaignsSend($campaignId, array($contactId));
215
+ if (isset($response->message)) {
216
+ //update the failed to send email message
217
+ $campaign->setMessage($response->message)->setIsSent(1)->save();
218
+ } else{
219
+ $now = Mage::getSingleton('core/date')->gmtDate();
220
+ //record suscces
221
+ $campaign->setIsSent(1)
222
+ ->setMessage(NULL)
223
+ ->setSentAt($now)
224
+ ->save();
225
+ }
226
+ }
227
+
228
+ }catch(Exception $e){
229
+ Mage::logException($e);
230
+ }
231
+ }
232
+ return;
233
+ }
234
+
235
+ /**
236
+ * @return mixed
237
+ */
238
+ private function _getEmailCampaigns()
239
+ {
240
+ $emailCollection = $this->getCollection();
241
+ $emailCollection->addFieldToFilter('is_sent', array('null' => true))
242
+ ->addFieldToFilter('campaign_id', array('notnull' => true));
243
+ $emailCollection->getSelect()->order('campaign_id');
244
+ return $emailCollection;
245
+ }
246
+
247
+ }
app/code/{local → community}/Dotdigitalgroup/Email/Model/Connector/Account.php RENAMED
@@ -16,11 +16,13 @@ class Dotdigitalgroup_Email_Model_Connector_Account
16
  private $_orders = array();
17
 
18
  /**
19
- * @param mixed $api_password
 
20
  */
21
  public function setApiPassword($api_password)
22
  {
23
  $this->_api_password = $api_password;
 
24
  }
25
 
26
  /**
@@ -32,11 +34,13 @@ class Dotdigitalgroup_Email_Model_Connector_Account
32
  }
33
 
34
  /**
35
- * @param mixed $api_username
 
36
  */
37
  public function setApiUsername($api_username)
38
  {
39
  $this->_api_username = $api_username;
 
40
  }
41
 
42
  /**
@@ -68,12 +72,11 @@ class Dotdigitalgroup_Email_Model_Connector_Account
68
  */
69
  public function setContacts($contacts)
70
  {
71
- // if(!empty($this->_contacts)){
72
- // $this->_contacts += $contacts;
73
- // }else{
74
-
75
  $this->_contacts[] = $contacts;
76
- //}
77
  }
78
 
79
  /**
@@ -214,5 +217,4 @@ class Dotdigitalgroup_Email_Model_Connector_Account
214
  return $this->_websites;
215
  }
216
 
217
-
218
  }
16
  private $_orders = array();
17
 
18
  /**
19
+ * @param $api_password
20
+ * @return $this
21
  */
22
  public function setApiPassword($api_password)
23
  {
24
  $this->_api_password = $api_password;
25
+ return $this;
26
  }
27
 
28
  /**
34
  }
35
 
36
  /**
37
+ * @param $api_username
38
+ * @return $this
39
  */
40
  public function setApiUsername($api_username)
41
  {
42
  $this->_api_username = $api_username;
43
+ return $this;
44
  }
45
 
46
  /**
72
  */
73
  public function setContacts($contacts)
74
  {
75
+ if (!empty($this->_contacts)) {
76
+ $this->_contacts += $contacts;
77
+ } else {
 
78
  $this->_contacts[] = $contacts;
79
+ }
80
  }
81
 
82
  /**
217
  return $this->_websites;
218
  }
219
 
 
220
  }
app/code/community/Dotdigitalgroup/Email/Model/Connector/Campaign.php ADDED
@@ -0,0 +1,100 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dotdigitalgroup_Email_Model_Connector_Campaign
4
+ {
5
+
6
+ public $id;
7
+ public $contacts = array();
8
+ public $emails = array();
9
+ public $emailSendId = array();
10
+ private $_storeId;
11
+
12
+ /**
13
+ * @param mixed $storeId
14
+ */
15
+ public function setStoreId($storeId)
16
+ {
17
+ $this->_storeId = $storeId;
18
+ }
19
+
20
+ /**
21
+ * @return mixed
22
+ */
23
+ public function getStoreId()
24
+ {
25
+ return $this->_storeId;
26
+ }
27
+
28
+ /**
29
+ * @param $emailSendId
30
+ * @return $this
31
+ */
32
+ public function setEmailSendId($emailSendId)
33
+ {
34
+ $this->emailSendId[] = $emailSendId;
35
+ return $this;
36
+ }
37
+
38
+ /**
39
+ * @return array
40
+ */
41
+ public function getEmailSendId()
42
+ {
43
+ return $this->emailSendId;
44
+ }
45
+
46
+ /**
47
+ * @param $contact
48
+ * @return $this
49
+ */
50
+ public function setContactId($contact)
51
+ {
52
+ $this->contacts[] = $contact;
53
+ return $this;
54
+ }
55
+
56
+ /**
57
+ * @return array
58
+ */
59
+ public function getContacts()
60
+ {
61
+ return $this->contacts;
62
+ }
63
+
64
+ /**
65
+ * @param $emails
66
+ * @return $this
67
+ */
68
+ public function setEmails($emails)
69
+ {
70
+ $this->emails = $emails;
71
+ return $this;
72
+ }
73
+
74
+ /**
75
+ * @return array
76
+ */
77
+ public function getEmails()
78
+ {
79
+ return $this->emails;
80
+ }
81
+
82
+ /**
83
+ * @param $id
84
+ * @return $this
85
+ */
86
+ public function setId($id)
87
+ {
88
+ $this->id = $id;
89
+ return $this;
90
+ }
91
+
92
+ /**
93
+ * @return mixed
94
+ */
95
+ public function getId()
96
+ {
97
+ return $this->id;
98
+ }
99
+
100
+ }
app/code/community/Dotdigitalgroup/Email/Model/Connector/Datafield.php ADDED
@@ -0,0 +1,323 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dotdigitalgroup_Email_Model_Connector_Datafield
4
+ {
5
+ /**
6
+ * @var string
7
+ */
8
+ public $name;
9
+ /**
10
+ * @var string
11
+ */
12
+ public $type;
13
+ /**
14
+ * @var string
15
+ */
16
+ public $visibility;
17
+ /**
18
+ * @var string
19
+ */
20
+ public $defaultValue;
21
+ /**
22
+ * Contact datafields.
23
+ * @var array
24
+ */
25
+ public $datafields = array();
26
+
27
+ /**
28
+ * Default datafields
29
+ * @return array
30
+ */
31
+ protected $_defaultDataFields = array(
32
+ array(
33
+ 'name' => 'CUSTOMER_ID',
34
+ 'type' => 'string',
35
+ 'visibility' => 'private',
36
+ ),array(
37
+ 'name' => 'LAST_ORDER_ID',
38
+ 'type' => 'numeric',
39
+ 'visibility' => 'private',
40
+ ),array(
41
+ 'name' => 'ORDER_INCREMENT_ID',
42
+ 'type' => 'numeric',
43
+ 'visibility' => 'private',
44
+ )
45
+ );
46
+
47
+ /**
48
+ * Contact default datafields.
49
+ *
50
+ * @var array
51
+ */
52
+ private $_contactDatafields = array(
53
+ 'customer_id' => array(
54
+ 'name' => 'CUSTOMER_ID',
55
+ 'type' => 'numeric',
56
+ 'visibility' => 'public',
57
+ ),
58
+ 'firstname' => array(
59
+ 'name' => 'FIRSTNAME',
60
+ 'type' => 'string'
61
+ ),
62
+ 'lastname' => array(
63
+ 'name' => 'LASTNAME',
64
+ 'type' => 'string'
65
+ ),
66
+ 'gender' => array(
67
+ 'name' => 'GENDER',
68
+ 'type' => 'string'
69
+ ),
70
+ 'dob' => array(
71
+ 'name' => 'DOB',
72
+ 'type' => 'date',
73
+ 'visibility' => 'public',
74
+ ),
75
+ 'title' => array(
76
+ 'name' => 'TITLE',
77
+ 'type' => 'string',
78
+ 'visibility' => 'public',
79
+ ),
80
+ 'website_name' => array(
81
+ 'name' => 'WEBSITE_NAME',
82
+ 'type' => 'string',
83
+ 'visibility' => 'public',
84
+ ),
85
+ 'store_name' => array(
86
+ 'name' => 'STORE_NAME',
87
+ 'type' => 'string',
88
+ 'visibility' => 'public',
89
+ ),
90
+ 'created_at' => array(
91
+ 'name' => 'ACCOUNT_CREATED_DATE',
92
+ 'type' => 'date',
93
+ 'visibility' => 'public'
94
+ ),
95
+ 'last_logged_date' => array(
96
+ 'name' => 'LAST_LOGGEDIN_DATE',
97
+ 'type' => 'date',
98
+ 'visibility' => 'public'
99
+ ),
100
+ 'customer_group' => array(
101
+ 'name' => 'CUSTOMER_GROUP',
102
+ 'type' => 'string',
103
+ 'visibility' => 'public',
104
+ ),
105
+ 'billing_address_1' => array(
106
+ 'name' => 'BILLING_ADDRESS_1',
107
+ 'type' => 'string',
108
+ 'visibility' => 'private',
109
+ 'defaultValue' => ''
110
+ ),
111
+ 'billing_address_2' => array(
112
+ 'name' => 'BILLING_ADDRESS_2',
113
+ 'type' => 'string',
114
+ 'visibility' => 'public',
115
+ ),
116
+ 'billing_state' => array(
117
+ 'name' => 'BILLING_STATE',
118
+ 'type' => 'string',
119
+ 'visibility' => 'public'
120
+ ),
121
+ 'billing_city' => array(
122
+ 'name' => 'BILLING_CITY',
123
+ 'type' => 'string',
124
+ 'visibility' => 'public',
125
+ ),
126
+ 'billing_country' => array(
127
+ 'name' => 'BILLING_COUNTRY',
128
+ 'type' => 'string',
129
+ 'visibility' => 'public',
130
+ ),
131
+ 'billing_postcode' => array(
132
+ 'name' => 'BILLING_POSTCODE',
133
+ 'type' => 'string',
134
+ 'visibility' => 'public',
135
+ ),
136
+ 'billing_telephone' => array(
137
+ 'name' => 'BILLING_TELEPHONE',
138
+ 'type' => 'string',
139
+ 'visibility' => 'public',
140
+ ),
141
+ 'delivery_address_1' => array(
142
+ 'name' => 'DELIVERY_ADDRESS_1',
143
+ 'type' => 'string',
144
+ 'visibility' => 'public',
145
+ ),
146
+ 'delivery_address_2' => array(
147
+ 'name' => 'DELIVERY_ADDRESS_2',
148
+ 'type' => 'string',
149
+ 'visibility' => 'public',
150
+ ),
151
+ 'delivery_state' => array(
152
+ 'name' => 'DELIVERY_STATE',
153
+ 'type' => 'string',
154
+ 'visibility' => 'public'
155
+ ),
156
+ 'delivery_city' => array(
157
+ 'name' => 'DELIVERY_CITY',
158
+ 'type' => 'string',
159
+ 'visibility' => 'public',
160
+ ),
161
+ 'delivery_country' => array(
162
+ 'name' => 'DELIVERY_COUNTRY',
163
+ 'type' => 'string',
164
+ 'visibility' => 'public',
165
+ ),
166
+ 'delivery_postcode' => array(
167
+ 'name' => 'DELIVERY_POSTCODE',
168
+ 'type' => 'string',
169
+ 'visibility' => 'public',
170
+ ),
171
+ 'delivery_telephone' => array(
172
+ 'name' => 'DELIVERY_TELEPHONE',
173
+ 'type' => 'string',
174
+ 'visibility' => 'public',
175
+ ),
176
+ 'number_of_orders' => array(
177
+ 'name' => 'NUMBER_OF_ORDERS',
178
+ 'type' => 'numeric',
179
+ 'visibility' => 'public',
180
+ ),
181
+ 'total_spend' => array(
182
+ 'name' => 'TOTAL_SPEND',
183
+ 'type' => 'numeric',
184
+ 'visibility' => 'public',
185
+ ),
186
+ 'average_order_value' => array(
187
+ 'name' => 'AVERAGE_ORDER_VALUE',
188
+ 'type' => 'numeric',
189
+ 'visibility' => 'public',
190
+ ),
191
+ 'last_order_date' => array(
192
+ 'name' => 'LAST_ORDER_DATE',
193
+ 'type' => 'date',
194
+ 'visibility' => 'public',
195
+ ),
196
+ 'last_order_id' => array(
197
+ 'name' => 'LAST_ORDER_ID',
198
+ 'type' => 'numeric',
199
+ 'visibility' => 'private',
200
+ ),
201
+ 'total_refund' => array(
202
+ 'name' => 'TOTAL_REFUND',
203
+ 'type' => 'numeric',
204
+ 'visibility' => 'private',
205
+ ),
206
+ 'review_count' => array(
207
+ 'name' => 'REVIEW_COUNT',
208
+ 'type' => 'numeric',
209
+ 'visibility' => 'private',
210
+ ),
211
+ 'last_review_date' => array(
212
+ 'name' => 'LAST_REVIEW_DATE',
213
+ 'type' => 'date',
214
+ 'visibility' => 'private',
215
+ )
216
+ );
217
+
218
+ /**
219
+ * transactional data default datafields.
220
+ *
221
+ * @var array
222
+ */
223
+ private $_transactionalDefaultDatafields = array(
224
+ array(
225
+ 'name' => 'CUSTOMER_ID',
226
+ 'type' => 'string',
227
+ 'visibility' => 'private',
228
+ ),array(
229
+ 'name' => 'LAST_ORDER_ID',
230
+ 'type' => 'numeric',
231
+ 'visibility' => 'private',
232
+ ),array(
233
+ 'name' => 'ORDER_INCREMENT_ID',
234
+ 'type' => 'numeric',
235
+ 'visibility' => 'private',
236
+ ),
237
+ array(
238
+ 'name' => 'WEBSITE_NAME',
239
+ 'type' => 'string',
240
+ 'visibility' => 'private',
241
+ ),
242
+ array(
243
+ 'name' => 'STORE_NAME',
244
+ 'type' => 'string',
245
+ 'visibility' => 'private',
246
+ ),
247
+ array(
248
+ 'name' => 'LAST_ORDER_DATE',
249
+ 'type' => 'date',
250
+ 'visibility' => 'private',
251
+ )
252
+ );
253
+
254
+ /**
255
+ * @param array $contactDatafields
256
+ */
257
+ public function setContactDatafields($contactDatafields)
258
+ {
259
+ $this->_contactDatafields = $contactDatafields;
260
+ }
261
+
262
+ /**
263
+ * @return array
264
+ */
265
+ public function getContactDatafields()
266
+ {
267
+ return $this->_contactDatafields;
268
+ }
269
+
270
+ /**
271
+ * @param array $transactionalDefaultDatafields
272
+ */
273
+ public function setTransactionalDefaultDatafields($transactionalDefaultDatafields)
274
+ {
275
+ $this->_transactionalDefaultDatafields = $transactionalDefaultDatafields;
276
+ }
277
+
278
+ /**
279
+ * @return array
280
+ */
281
+ public function getTransactionalDefaultDatafields()
282
+ {
283
+ return $this->_transactionalDefaultDatafields;
284
+ }
285
+
286
+ /**
287
+ * @param mixed $defaultDataFields
288
+ */
289
+ public function setDefaultDataFields($defaultDataFields)
290
+ {
291
+ $this->_defaultDataFields = $defaultDataFields;
292
+ }
293
+
294
+ /**
295
+ * @return mixed
296
+ */
297
+ public function getDefaultDataFields()
298
+ {
299
+ return $this->_defaultDataFields;
300
+ }
301
+
302
+ /**
303
+ * set a single datafield.
304
+ *
305
+ * @param $name
306
+ * @param $value
307
+ * @param string $type
308
+ * @param string $visibility
309
+ *
310
+ * @return array
311
+ */
312
+ public function setDatafield($name, $value, $type = 'string', $visibility = 'public')
313
+ {
314
+ $this->datafields[] = array(
315
+ 'name' => $name,
316
+ 'value' => $value,
317
+ 'type' => $type,
318
+ 'visibility' => $visibility
319
+ );
320
+ return $this->datafields;
321
+ }
322
+
323
+ }
app/code/community/Dotdigitalgroup/Email/Model/Connector/Order.php ADDED
@@ -0,0 +1,203 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dotdigitalgroup_Email_Model_Connector_Order
4
+ {
5
+ /**
6
+ * Order Increment ID
7
+ * @var string
8
+ */
9
+ public $id;
10
+ /**
11
+ * Email
12
+ * @var string
13
+ */
14
+ public $email;
15
+ /**
16
+ * @var int
17
+ */
18
+ public $quote_id;
19
+ /**
20
+ * @var string
21
+ */
22
+ public $store_name;
23
+ /**
24
+ * @var string
25
+ */
26
+ public $purchase_date;
27
+ /**
28
+ * @var string
29
+ */
30
+ public $delivery_address;
31
+ /**
32
+ * @var string
33
+ */
34
+ public $billing_address;
35
+ /**
36
+ * @var array
37
+ */
38
+ public $products = array();
39
+ /**
40
+ * @var float
41
+ */
42
+ public $order_subtotal;
43
+ /**
44
+ * @var float
45
+ */
46
+ public $discount_ammount;
47
+ /**
48
+ * @var float
49
+ */
50
+ public $order_total;
51
+ /**
52
+ * @var array
53
+ */
54
+ public $categories;
55
+ /**
56
+ * Payment name
57
+ * @var string
58
+ */
59
+ public $payment;
60
+ /**
61
+ * @var string
62
+ */
63
+ public $delivery_method;
64
+ /**
65
+ * @var float
66
+ */
67
+ public $delivery_total;
68
+ /**
69
+ * @var string
70
+ */
71
+ public $currency;
72
+
73
+
74
+ public $couponCode;
75
+
76
+ /**
77
+ * set the order information
78
+ * @param Mage_Sales_Model_Order $orderData
79
+ */
80
+ public function __construct(Mage_Sales_Model_Order $orderData)
81
+ {
82
+ $customerModel = Mage::getModel('customer/customer');
83
+ $customerModel->load($orderData->getCustomerId());
84
+
85
+ $this->id = $orderData->getIncrementId();
86
+ $this->quote_id = $orderData->getQuoteId();
87
+ $this->email = $orderData->getCustomerEmail();
88
+ $this->store_name = $orderData->getStoreName();
89
+ $created_at = new Zend_Date($orderData->getCreatedAt(), Zend_Date::ISO_8601);
90
+ $this->purchase_date = $created_at->toString(Zend_Date::ISO_8601);
91
+ $this->delivery_method = $orderData->getShippingDescription();
92
+ $this->delivery_total = $orderData->getShippingAmount();
93
+ $this->currency = $orderData->getStoreCurrencyCode();
94
+ $this->payment = $orderData->getPayment()->getMethodInstance()->getTitle();
95
+ $this->couponCode = $orderData->getCouponCode();
96
+
97
+ /**
98
+ * Billing address.
99
+ */
100
+ if ($orderData->getBillingAddress()) {
101
+ $billingData = $orderData->getBillingAddress()->getData();
102
+ $this->billing_address = array(
103
+ 'billing_address_1' => $this->_getStreet($billingData['street'], 1),
104
+ 'billing_address_2' => $this->_getStreet($billingData['street'], 2),
105
+ 'billing_city' => $billingData['city'],
106
+ 'billing_region' => $billingData['region'],
107
+ 'billing_country' => $billingData['country_id'],
108
+ 'billing_postcode' => $billingData['postcode'],
109
+ );
110
+ }
111
+ /**
112
+ * Shipping address.
113
+ */
114
+ if ($orderData->getShippingAddress()) {
115
+ $shippingData = $orderData->getShippingAddress()->getData();
116
+
117
+ $this->delivery_address = array(
118
+ 'delivery_address_1' => $this->_getStreet($shippingData['street'], 1),
119
+ 'delivery_address_2' => $this->_getStreet($shippingData['street'], 2),
120
+ 'delivery_city' => $shippingData['city'],
121
+ 'delivery_region' => $shippingData['region'],
122
+ 'delivery_country' => $shippingData['country_id'],
123
+ 'delivery_postcode' => $shippingData['postcode']
124
+ );
125
+ }
126
+
127
+ /**
128
+ * Order items.
129
+ */
130
+ foreach ($orderData->getAllItems() as $productItem) {
131
+ Mage::helper( 'connector' )->log( 'order is : ' . $this->id . ', email: '. $this->email );
132
+ $product = $productItem->getProduct();
133
+ if ($product) {
134
+ // category names
135
+ $categoryCollection = $product->getCategoryCollection()
136
+ ->addAttributeToSelect( 'name' );
137
+
138
+ foreach ( $categoryCollection as $cat ) {
139
+ $categories = array();
140
+ $categories[] = $cat->getName();
141
+ $this->categories[]['Name'] = substr( implode( ', ', $categories ), 0, 244 );
142
+ }
143
+
144
+ $attributeSetModel = Mage::getModel( "eav/entity_attribute_set" );
145
+ $attributeSetModel->load( $product->getAttributeSetId() );
146
+ $attributeSetName = $attributeSetModel->getAttributeSetName();
147
+ $this->products[] = array(
148
+ 'name' => $productItem->getName(),
149
+ 'sku' => $productItem->getSku(),
150
+ 'qty' => (int) number_format( $productItem->getData( 'qty_ordered' ), 2 ),
151
+ 'price' => (float) number_format( $productItem->getPrice(), 2, '.', '' ),
152
+ 'attribute-set' => $attributeSetName
153
+ );
154
+ } else {
155
+ // when no product information is available limit to this data
156
+ $this->products[] = array(
157
+ 'name' => $productItem->getName(),
158
+ 'sku' => $productItem->getSku(),
159
+ 'qty' => (int) number_format( $productItem->getData( 'qty_ordered' ), 2 ),
160
+ 'price' => (float) number_format( $productItem->getPrice(), 2, '.', '' )
161
+ );
162
+ }
163
+ }
164
+
165
+ $this->order_subtotal = (float)number_format($orderData->getData('subtotal'), 2 , '.', '');
166
+ $this->discount_ammount = (float)number_format($orderData->getData('discount_amount'), 2 , '.', '');
167
+ $orderTotal = abs($orderData->getData('grand_total') - $orderData->getTotalRefunded());
168
+ $this->order_total = (float)number_format($orderTotal, 2 , '.', '');
169
+
170
+ return true;
171
+ }
172
+ /**
173
+ * get the street name by line number
174
+ * @param $street
175
+ * @param $line
176
+ * @return string
177
+ */
178
+ private function _getStreet($street, $line)
179
+ {
180
+ $street = explode("\n", $street);
181
+ if ($line == 1) {
182
+ return $street[0];
183
+ }
184
+ if (isset($street[$line -1])) {
185
+
186
+ return $street[$line - 1];
187
+ } else {
188
+
189
+ return '';
190
+ }
191
+ }
192
+
193
+ /**
194
+ * exposes the class as an array of objects.
195
+ * @return array
196
+ */
197
+ public function expose()
198
+ {
199
+ return get_object_vars($this);
200
+
201
+ }
202
+
203
+ }
app/code/community/Dotdigitalgroup/Email/Model/Contact.php ADDED
@@ -0,0 +1,169 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dotdigitalgroup_Email_Model_Contact extends Mage_Core_Model_Abstract
4
+ {
5
+
6
+ const EMAIL_CONTACT_IMPORTED = 1;
7
+ const EMAIL_CONTACT_NOT_IMPORTED = null;
8
+ const EMAIL_SUBSCRIBER_NOT_IMPORTED = null;
9
+ /**
10
+ * constructor
11
+ */
12
+ public function _construct()
13
+ {
14
+ parent::_construct();
15
+ $this->_init('email_connector/contact');
16
+ }
17
+
18
+
19
+ /**
20
+ * @return $this|Mage_Core_Model_Abstract
21
+ */
22
+ protected function _beforeSave()
23
+ {
24
+ parent::_beforeSave();
25
+ $now = Mage::getSingleton('core/date')->gmtDate();
26
+ if ($this->isObjectNew()) {
27
+ $this->setCreatedAt($now);
28
+ }
29
+ return $this;
30
+ }
31
+
32
+ /**
33
+ * Reset the imported contacts
34
+ * @return int
35
+ */
36
+ public function resetAllContacts()
37
+ {
38
+
39
+ /** @var $coreResource Mage_Core_Model_Resource */
40
+ $coreResource = Mage::getSingleton('core/resource');
41
+
42
+ /** @var $conn Varien_Db_Adapter_Pdo_Mysql */
43
+ $conn = $coreResource->getConnection('core_write');
44
+
45
+ try{
46
+ $num = $conn->update($coreResource->getTableName('email_connector/contact'),
47
+ array('email_imported' => new Zend_Db_Expr('null')),
48
+ $conn->quoteInto('email_imported is ?', new Zend_Db_Expr('not null'))
49
+ );
50
+ }catch (Exception $e){
51
+ Mage::logException($e);
52
+ }
53
+ /**
54
+ * Reset subscribers.
55
+ */
56
+ $this->resetSubscribers();
57
+
58
+ return $num;
59
+ }
60
+
61
+
62
+ /**
63
+ * Load contact by customer id
64
+ * @param $customerId
65
+ * @return mixed
66
+ */
67
+ public function loadByCustomerId($customerId)
68
+ {
69
+ $collection = $this->getCollection()
70
+ ->addFieldToFilter('customer_id', $customerId);
71
+ if($collection->count())
72
+ return $collection->getFirstItem();
73
+ return $this;
74
+
75
+ }
76
+
77
+ public function getContactsToImportForWebsite($websiteId, $pageSize = 100)
78
+ {
79
+ $collection = $this->getCollection()
80
+ ->addFieldToFilter('website_id', $websiteId)
81
+ ->addFieldToFilter('email_imported', array('null' => true))
82
+ ->addFieldToFilter('customer_id', array('notnull' => true));
83
+
84
+ $collection->getSelect()->limit($pageSize);
85
+
86
+ return $collection;
87
+ }
88
+
89
+ /**
90
+ * Get missing contacts.
91
+ * @param $websiteId
92
+ * @param int $pageSize
93
+ * @return mixed
94
+ */
95
+ public function getMissingContacts($websiteId, $pageSize = 100)
96
+ {
97
+ $collection = $this->getCollection()
98
+ ->addFieldToFilter('contact_id', array('null' => true))
99
+ ->addFieldToFilter('suppressed', null)
100
+ ->addFieldToFilter('website_id', $websiteId);
101
+
102
+ $collection->getSelect()->limit($pageSize);
103
+
104
+ return $collection->load();
105
+ }
106
+
107
+ /**
108
+ * Load Contact by Email.
109
+ * @param $email
110
+ * @param $websiteId
111
+ * @return $this
112
+ */
113
+ public function loadByCustomerEmail($email, $websiteId)
114
+ {
115
+ $collection = $this->getCollection()
116
+ ->addFieldToFilter('email', $email)
117
+ ->addFieldToFilter('website_id', $websiteId);
118
+ if ($collection->count()) {
119
+ return $collection->getFirstItem();
120
+ } else {
121
+ $this->setEmail($email)
122
+ ->setWebsiteId($websiteId);
123
+ }
124
+ return $this;
125
+ }
126
+
127
+ public function getSubscribersToImport($website, $limit = 1000)
128
+ {
129
+ $storeIds = $website->getStoreIds();
130
+ $collection = $this->getCollection()
131
+ ->addFieldToFilter('is_subscriber', array('notnull' => true))
132
+ ->addFieldToFilter('subscriber_imported', array('null' => true))
133
+ ->addFieldToFilter('store_id', array('in' => $storeIds));
134
+
135
+ $collection->getSelect()->limit($limit);
136
+
137
+ return $collection;
138
+ }
139
+
140
+ public function getGuests($website)
141
+ {
142
+ $guestCollection = $this->getCollection()
143
+ ->addFieldToFilter('is_guest', array('notnull' => true))
144
+ ->addFieldToFilter('email_imported', self::EMAIL_CONTACT_NOT_IMPORTED)
145
+ ->addFieldToFilter('website_id', $website->getId());
146
+
147
+ return $guestCollection->load();
148
+ }
149
+
150
+ public function getNumberOfImportedContacs()
151
+ {
152
+
153
+ $collection = $this->getCollection()
154
+ ->addFieldToFilter('email_imported', array('notnull' => true));
155
+
156
+ return $collection->getSize();
157
+ }
158
+
159
+ public function resetSubscribers()
160
+ {
161
+ $collection = $this->getCollection()
162
+ ->addFieldToFilter('is_subscriber', array('notnull' => true))
163
+ ->addFieldToFilter('subscriber_imported', array('notnull' => true));
164
+ foreach ($collection as $contact) {
165
+ $contact->setSubscriberImported(null)->save();
166
+ }
167
+ return $collection->count();
168
+ }
169
+ }
app/code/community/Dotdigitalgroup/Email/Model/Create.php ADDED
@@ -0,0 +1,130 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dotdigitalgroup_Email_Model_Create extends Mage_Core_Model_Abstract
4
+ {
5
+
6
+ const EMAIL_CREATED_TRANSFERED = 1;
7
+
8
+ private $fromAddress;
9
+ private $replyAction;
10
+ private $replyAddress;
11
+
12
+ /**
13
+ * constructor
14
+ */
15
+ public function _construct()
16
+ {
17
+ parent::_construct();
18
+ $this->_init('email_connector/create');
19
+ }
20
+
21
+ /**
22
+ * create emails to campaigns
23
+ */
24
+ public function createEmailsToCampaigns()
25
+ {
26
+ $helper = Mage::helper('connector/transactional');
27
+ $emails = $this->getEmailsToCreateCampaigns();
28
+
29
+ foreach($emails as $email)
30
+ {
31
+ try {
32
+ $websiteId = $email->getWebsiteId();
33
+
34
+ if (!$this->fromAddress)
35
+ $this->fromAddress = $helper->getFromAddress($websiteId);
36
+ if (!$this->replyAction)
37
+ $this->replyAction = $helper->getReplyAction($websiteId);
38
+ if ($this->replyAction == 'WebMailForward') {
39
+ if (!$this->replyAddress) {
40
+ $this->replyAddress = $helper->getReplyAddress($websiteId);
41
+ }
42
+ }
43
+
44
+ if ($this->fromAddress && $this->replyAction) {
45
+ $data = array(
46
+ 'Name' => $email->getName(),
47
+ 'Subject' => $email->getSubject(),
48
+ 'FromName' => $email->getFromName(),
49
+ 'FromAddress' => $this->fromAddress,
50
+ 'HtmlContent' => $email->getHtmlContent(),
51
+ 'PlainTextContent' => $email->getPlainTextContent(),
52
+ 'ReplyAction' => $this->replyAction,
53
+ 'IsSplitTest' => false,
54
+ 'Status' => 'Unsent'
55
+ );
56
+ if ($this->replyAction == 'WebMailForward' && $this->replyAddress)
57
+ $data['ReplyToAddress'] = $this->replyAddress;
58
+ else
59
+ $data['ReplyToAddress'] = '';
60
+ }
61
+
62
+ if(isset($data)){
63
+ $client = Mage::helper('connector/transactional')->getWebsiteApiClient($websiteId);
64
+ $result = $client->postCampaign($data);
65
+ if (isset($result->message)) {
66
+ $email
67
+ ->setMessage($result->message)
68
+ ->save();
69
+ continue;
70
+ }
71
+
72
+ $this->_registerSendViaConnectorCampaign($result->id, $email->getEmail(), $email->getName());
73
+ if($email->getCopy())
74
+ $this->_registerSendViaConnectorCampaign($result->id, $email->getCopy(), $email->getName());
75
+
76
+ $email->setIsCreated(self::EMAIL_CREATED_TRANSFERED)
77
+ ->save();
78
+ }
79
+ }catch(Exception $e){
80
+ Mage::logException($e);
81
+ }
82
+ }
83
+ return;
84
+ }
85
+
86
+ /**
87
+ * Save campaign
88
+ *
89
+ * @param $campaignId
90
+ * @param $email
91
+ * @param $name
92
+ */
93
+ protected function _registerSendViaConnectorCampaign($campaignId, $email, $name)
94
+ {
95
+ Mage::helper('connector')->log('-- send via connector campaign: ' . $campaignId);
96
+
97
+ try{
98
+ $now = Mage::getSingleton('core/date')->gmtDate();
99
+ if($email){
100
+ //save email for sending
101
+ $emailCampaign = Mage::getModel('email_connector/campaign');
102
+ $emailCampaign
103
+ ->setEmail($email)
104
+ ->setCampaignId($campaignId)
105
+ ->setEventName($name)
106
+ ->setCreatedAt($now);
107
+ $emailCampaign->save();
108
+ }
109
+ }catch (Exception $e) {
110
+ Mage::logException($e);
111
+ }
112
+ }
113
+
114
+ /**
115
+ * get collection to create campaigns
116
+ *
117
+ * @param int $pageSize
118
+ * @return Mage_Eav_Model_Entity_Collection_Abstract
119
+ */
120
+ protected function getEmailsToCreateCampaigns($pageSize = 100)
121
+ {
122
+ $collection = $this->getCollection()
123
+ ->addFieldToFilter('is_created', array('null' => true));
124
+
125
+ $collection->getSelect()->limit($pageSize);
126
+
127
+ return $collection;
128
+ }
129
+
130
+ }
app/code/community/Dotdigitalgroup/Email/Model/Cron.php ADDED
@@ -0,0 +1,73 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dotdigitalgroup_Email_Model_Cron
4
+ {
5
+ /**
6
+ * CRON FOR CONTACTS SYNC
7
+ */
8
+ public function contactSync()
9
+ {
10
+ // send customers
11
+ Mage::getModel('email_connector/apiconnector_contact')->sync();
12
+ }
13
+
14
+ /**
15
+ * CRON FOR LOST BASKET
16
+ */
17
+ public function lostBaskets()
18
+ {
19
+ // send lost basket
20
+ Mage::getModel('email_connector/sales_quote')->proccessLostBaskets();
21
+
22
+ }
23
+
24
+ /**
25
+ * CRON FOR ORDER TRANSACTIONAL DATA
26
+ */
27
+ public function orderSync()
28
+ {
29
+ // send order
30
+ Mage::getModel('email_connector/sales_order')->sync();
31
+ }
32
+
33
+ /**
34
+ * CRON FOR SUBSCRIBERS AND GUEST CONTACTS
35
+ */
36
+ public function subscribersAndGuestSync()
37
+ {
38
+ //sync subscribers
39
+ Mage::getModel('email_connector/newsletter_subscriber')
40
+ ->sync()
41
+ ->unsubscribe();
42
+ //sync guests
43
+ Mage::getModel('email_connector/customer_guest')->sync();
44
+ }
45
+
46
+ /**
47
+ * CRON FOR EMAILS SENDING
48
+ */
49
+ public function sendMappedEmails()
50
+ {
51
+ Mage::getModel('email_connector/campaign')->sendCampaigns();
52
+
53
+ return $this;
54
+ }
55
+
56
+ public function createEmailsToCampaigns()
57
+ {
58
+ Mage::getModel('email_connector/create')->createEmailsToCampaigns();
59
+ }
60
+
61
+ /**
62
+ * CLEAN ARHIVED FOLDERS
63
+ */
64
+ public function cleaning()
65
+ {
66
+ $helper = Mage::helper('connector/file');
67
+ $archivedFolder = $helper->getArchiveFolder();
68
+ $result = $helper->deleteDir($archivedFolder);
69
+ $helper->log('Cleaning cronjob result : ' . $result);
70
+ return $result;
71
+ }
72
+
73
+ }
app/code/community/Dotdigitalgroup/Email/Model/Customer/Guest.php ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dotdigitalgroup_Email_Model_Customer_Guest
4
+ {
5
+ protected $_countGuests = 0;
6
+ protected $_start;
7
+
8
+ /**
9
+ * GUEST SYNC.
10
+ */
11
+ public function sync()
12
+ {
13
+ /** @var Dotdigitalgroup_Email_Helper_Data $helper */
14
+ $helper = Mage::helper('connector');
15
+ $helper->log('----------- Start guest sync ----------');
16
+ $this->_start = microtime(true);
17
+ foreach(Mage::app()->getWebsites() as $website)
18
+ $this->exportGuestPerWebsite($website);
19
+ $helper->log('---- End Guest total time for guest sync : ' . gmdate("H:i:s", microtime(true) - $this->_start));
20
+ return;
21
+ }
22
+
23
+ public function exportGuestPerWebsite(Mage_Core_Model_Website $website)
24
+ {
25
+ $helper = Mage::helper('connector');
26
+ $fileHelper = Mage::helper('connector/file');
27
+ $guests = Mage::getModel('email_connector/contact')->getGuests($website);
28
+ if ($guests->getSize()) {
29
+ $client = Mage::helper('connector')->getWebsiteApiClient($website);
30
+ $guestFilename = strtolower($website->getCode() . '_guest_' . date('d_m_Y_Hi') . '.csv');
31
+ $helper->log('Guest file: ' . $guestFilename);
32
+ $storeName = $helper->getMappedStoreName($website);
33
+ $fileHelper->outputCSV($fileHelper->getFilePath($guestFilename), array('Email', 'emailType', $storeName));
34
+ foreach ($guests as $guest) {
35
+ $email = $guest->getEmail();
36
+ try{
37
+ $guest->setEmailImported(Dotdigitalgroup_Email_Model_Contact::EMAIL_CONTACT_IMPORTED)
38
+ ->save();
39
+ $storeName = $website->getName();
40
+ // save data for guests
41
+ $fileHelper->outputCSV($fileHelper->getFilePath($guestFilename), array($email, 'Html', $storeName));
42
+ $this->_countGuests++;
43
+ }catch (Exception $e){
44
+ Mage::logException($e);
45
+ }
46
+ }
47
+ if ($this->_countGuests) {
48
+ //Add to guest address book
49
+ $client->postAddressBookContactsImport($guestFilename, $helper->getGuestAddressBook($website));
50
+ }
51
+ //arhive guest file
52
+ $fileHelper->archiveCSV($guestFilename);
53
+ }
54
+ }
55
+ }
app/code/community/Dotdigitalgroup/Email/Model/Customer/Observer.php ADDED
@@ -0,0 +1,157 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dotdigitalgroup_Email_Model_Customer_Observer
4
+ {
5
+ /**
6
+ * Create new contact or update info, also check for email change
7
+ * event: customer_save_before
8
+ * @param Varien_Event_Observer $observer
9
+ * @return $this
10
+ */
11
+ public function handleCustomerSaveBefore(Varien_Event_Observer $observer)
12
+ {
13
+ $customer = $observer->getEvent()->getCustomer();
14
+ $email = $customer->getEmail();
15
+ $websiteId = $customer->getWebsiteId();
16
+ $customerId = $customer->getEntityId();
17
+ $isSubscribed = $customer->getIsSubscribed();
18
+ try{
19
+ $emailBefore = Mage::getModel('customer/customer')->load($customer->getId())->getEmail();
20
+ $contactModel = Mage::getModel('email_connector/contact')->loadByCustomerEmail($emailBefore, $websiteId);
21
+ //email change detection
22
+ if ($email != $emailBefore) {
23
+ Mage::helper('connector')->log('email change detected : ' . $email . ', after : ' . $emailBefore . ', website id : ' . $websiteId);
24
+ $enabled = Mage::helper('connector')->getWebsiteConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_API_ENABLED, $websiteId);
25
+
26
+ if ($enabled) {
27
+ $client = Mage::helper('connector')->getWebsiteApiClient($websiteId);
28
+ $subscribersAddressBook = Mage::helper('connector')->getWebsiteConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_SUBSCRIBERS_ADDRESS_BOOK_ID, $websiteId);
29
+ $response = $client->postContacts($emailBefore);
30
+ //check for matching email
31
+ if (isset($response->id)) {
32
+ if ($email != $response->email) {
33
+ $data = array(
34
+ 'Email' => $email,
35
+ 'EmailType' => 'Html'
36
+ );
37
+ //update the contact with same id - different email
38
+ $client->updateContact($response->id, $data);
39
+
40
+ }
41
+ if (!$isSubscribed && $response->status == 'Subscribed') {
42
+ $client->deleteAddressBookContact($subscribersAddressBook, $response->id);
43
+ }
44
+ } elseif (isset($response->message)) {
45
+ Mage::helper('connector')->log('Email change error : ' . $response->message);
46
+ }
47
+ }
48
+ $contactModel->setEmail($email);
49
+ }
50
+
51
+ $contactModel->setEmailImported(Dotdigitalgroup_Email_Model_Contact::EMAIL_CONTACT_NOT_IMPORTED)
52
+ ->setCustomerId($customerId)
53
+ ->save();
54
+ }catch(Exception $e){
55
+ Mage::logException($e);
56
+ }
57
+
58
+ return $this;
59
+ }
60
+
61
+ /**
62
+ * Add new customers to the automation.
63
+ * @param Varien_Event_Observer $observer
64
+ *
65
+ * @return $this
66
+ */
67
+ public function handleCustomerRegiterSuccess(Varien_Event_Observer $observer)
68
+ {
69
+ $customer = $observer->getEvent()->getCustomer();
70
+ $email = $customer->getEmail();
71
+ $websiteId = $customer->getWebsiteId();
72
+
73
+ // send customer to automation mapped
74
+ $this->_postCustomerToAutomation($email, $websiteId);
75
+
76
+ return $this;
77
+ }
78
+
79
+ /**
80
+ * Remove the contact on customer delete.
81
+ *
82
+ * @param Varien_Event_Observer $observer
83
+ *
84
+ * @return $this
85
+ */
86
+ public function handleCustomerDeleteAfter(Varien_Event_Observer $observer)
87
+ {
88
+ $customer = $observer->getEvent()->getCustomer();
89
+ $email = $customer->getEmail();
90
+ $websiteId = $customer->getWebsiteId();
91
+ /**
92
+ * Remove contact.
93
+ */
94
+ try{
95
+ $contactModel = Mage::getModel('email_connector/contact')->loadByCustomerEmail($email, $websiteId);
96
+ if ($contactModel->getId()) {
97
+ //remove contact
98
+ $contactModel->delete();
99
+ }
100
+ //remove from account
101
+ $client = Mage::helper('connector')->getWebsiteApiClient($websiteId);
102
+ $apiContact = $client->postContacts($email);
103
+ if(! isset($apiContact->message) && isset($apiContact->id))
104
+ $client->DeleteContact($apiContact->id);
105
+
106
+ }catch (Exception $e){
107
+ Mage::logException($e);
108
+ }
109
+ return $this;
110
+ }
111
+
112
+ private function _postCustomerToAutomation( $email, $websiteId ) {
113
+ /**
114
+ * Automation Programme
115
+ */
116
+ $customerAutoCamaignId = Mage::helper('connector')->getWebsiteConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_AUTOMATION_STUDIO_CUSTOMER, $websiteId);
117
+ Mage::helper( 'connector' )->log( 'AS - customer automation Campaign id : ' . $customerAutoCamaignId );
118
+ if ($customerAutoCamaignId) {
119
+ $client = Mage::helper( 'connector' )->getWebsiteApiClient( $websiteId );
120
+ $apiContact = $client->postContacts($email);
121
+
122
+ // get a program by id
123
+ $program = $client->GetProgramById($customerAutoCamaignId);
124
+ /**
125
+ * id
126
+ * name
127
+ * status
128
+ * dateCreated
129
+ */
130
+ Mage::helper( 'connector' )->log( 'AS - get customer Program id : ' . $program->id);
131
+
132
+ $data = array(
133
+ 'Contacts' => array($apiContact->id),
134
+ 'ProgramId' => $program->id,
135
+ 'Status' => $program->status,
136
+ 'DateCreated' => $program->dateCreated,
137
+ 'AddressBooks' => array()
138
+ );
139
+ $client->PostProgramsEnrolments($data);
140
+ }
141
+ }
142
+
143
+ /**
144
+ * Set contact to re-import if registered customer submitted a review
145
+ * @param Varien_Event_Observer $observer
146
+ * @return $this
147
+ */
148
+ public function reviewSaveAfter(Varien_Event_Observer $observer)
149
+ {
150
+ $dataObject = $observer->getEvent()->getDataObject();
151
+ if($customerId = $dataObject->getCustomerId()){
152
+ $helper = Mage::helper('connector');
153
+ $helper->setConnectorContactToReImport($customerId);
154
+ }
155
+ return $this;
156
+ }
157
+ }
app/code/community/Dotdigitalgroup/Email/Model/Customer/Wishlist.php ADDED
@@ -0,0 +1,94 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dotdigitalgroup_Email_Model_Customer_Wishlist
4
+ {
5
+ /**
6
+ * @var int
7
+ */
8
+ public $id;
9
+ /**
10
+ * @var int
11
+ */
12
+ public $customer_id;
13
+ /**
14
+ * @var string
15
+ */
16
+ public $email;
17
+
18
+ /**
19
+ * wishlist items.
20
+ * @var array
21
+ */
22
+ public $items = array();
23
+
24
+ /**
25
+ * @var float
26
+ */
27
+ protected $total_wishlist_value;
28
+
29
+ /**
30
+ * constructor.
31
+ *
32
+ * @param Mage_Customer_Model_Customer $customer
33
+ */
34
+ public function __construct(Mage_Customer_Model_Customer $customer)
35
+ {
36
+
37
+ $this->setCustomerId($customer->getId());
38
+ $this->email = $customer->getEmail();
39
+ }
40
+
41
+ /**
42
+ * @param mixed $customer_id
43
+ */
44
+ public function setCustomerId($customer_id)
45
+ {
46
+ $this->customer_id = $customer_id;
47
+ }
48
+
49
+ /**
50
+ * @return mixed
51
+ */
52
+ public function getCustomerId()
53
+ {
54
+ return $this->customer_id;
55
+ }
56
+
57
+ /**
58
+ * @param $id
59
+ * @return $this
60
+ */
61
+ public function setId($id)
62
+ {
63
+ $this->id = $id;
64
+ return $this;
65
+ }
66
+
67
+ /**
68
+ * @return mixed
69
+ */
70
+ public function getId()
71
+ {
72
+ return $this->id;
73
+ }
74
+
75
+ /**
76
+ * set wishlist item.
77
+ *
78
+ * @param $item
79
+ */
80
+ public function setItem($item)
81
+ {
82
+ $this->items[] = $item->expose();
83
+
84
+ $this->total_wishlist_value += $item->getTotalValueOfProduct();
85
+ }
86
+
87
+ /**
88
+ * @return array
89
+ */
90
+ public function expose()
91
+ {
92
+ return get_object_vars($this);
93
+ }
94
+ }
app/code/{local → community}/Dotdigitalgroup/Email/Model/Customer/Wishlist/Item.php RENAMED
@@ -8,18 +8,26 @@ class Dotdigitalgroup_Email_Model_Customer_Wishlist_Item
8
  protected $qty;
9
  protected $total_value_of_product;
10
 
11
- public function __construct($product)
 
 
 
 
 
 
12
  {
13
  $this->setSku($product->getSku());
14
  $this->setName($product->getName());
15
  }
16
 
17
  /**
18
- * @param mixed $name
 
19
  */
20
  public function setName($name)
21
  {
22
  $this->name = $name;
 
23
  }
24
 
25
  /**
@@ -31,11 +39,13 @@ class Dotdigitalgroup_Email_Model_Customer_Wishlist_Item
31
  }
32
 
33
  /**
34
- * @param mixed $qty
 
35
  */
36
  public function setQty($qty)
37
  {
38
  $this->qty = (int)$qty;
 
39
  }
40
 
41
  /**
@@ -55,14 +65,16 @@ class Dotdigitalgroup_Email_Model_Customer_Wishlist_Item
55
  }
56
 
57
  /**
58
- * @param mixed $price
 
59
  */
60
  public function setPrice($product)
61
  {
62
  $this->price = $product->getFinalPrice();
63
  $total = $this->price * $this->qty;
64
 
65
- $this->total_value_of_product = number_format($total, 2);
 
66
  }
67
 
68
  /**
@@ -74,11 +86,13 @@ class Dotdigitalgroup_Email_Model_Customer_Wishlist_Item
74
  }
75
 
76
  /**
77
- * @param mixed $sku
 
78
  */
79
  public function setSku($sku)
80
  {
81
  $this->sku = $sku;
 
82
  }
83
 
84
  /**
@@ -88,13 +102,12 @@ class Dotdigitalgroup_Email_Model_Customer_Wishlist_Item
88
  {
89
  return $this->sku;
90
  }
91
- public function expose() {
92
 
 
 
 
 
 
93
  return get_object_vars($this);
94
-
95
  }
96
-
97
-
98
-
99
-
100
  }
8
  protected $qty;
9
  protected $total_value_of_product;
10
 
11
+
12
+ /**
13
+ * construnctor.
14
+ *
15
+ * @param $product
16
+ */
17
+ public function __construct($product)
18
  {
19
  $this->setSku($product->getSku());
20
  $this->setName($product->getName());
21
  }
22
 
23
  /**
24
+ * @param $name
25
+ * @return $this
26
  */
27
  public function setName($name)
28
  {
29
  $this->name = $name;
30
+ return $this;
31
  }
32
 
33
  /**
39
  }
40
 
41
  /**
42
+ * @param $qty
43
+ * @return $this
44
  */
45
  public function setQty($qty)
46
  {
47
  $this->qty = (int)$qty;
48
+ return $this;
49
  }
50
 
51
  /**
65
  }
66
 
67
  /**
68
+ * @param $product
69
+ * @return $this
70
  */
71
  public function setPrice($product)
72
  {
73
  $this->price = $product->getFinalPrice();
74
  $total = $this->price * $this->qty;
75
 
76
+ $this->total_value_of_product = number_format($total, 2, '.', ',');
77
+ return $this;
78
  }
79
 
80
  /**
86
  }
87
 
88
  /**
89
+ * @param $sku
90
+ * @return $this
91
  */
92
  public function setSku($sku)
93
  {
94
  $this->sku = $sku;
95
+ return $this;
96
  }
97
 
98
  /**
102
  {
103
  return $this->sku;
104
  }
 
105
 
106
+ /**
107
+ * @return array
108
+ */
109
+ public function expose()
110
+ {
111
  return get_object_vars($this);
 
112
  }
 
 
 
 
113
  }
app/code/community/Dotdigitalgroup/Email/Model/Email/Template.php ADDED
@@ -0,0 +1,324 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dotdigitalgroup_Email_Model_Email_Template extends Mage_Core_Model_Email_Template
4
+ {
5
+ /**
6
+ * Registered sales emails that can be mapped as transactional emails.
7
+ *
8
+ * @var array
9
+ */
10
+ private $_registered = array(
11
+ 'sales_email_order_template' => 'New Order',
12
+ 'sales_email_order_guest_template' => 'New Order Guest',
13
+ 'sales_email_order_comment_template' => 'Order Update',
14
+ 'sales_email_order_comment_guest_template' => 'Order Update for Guest',
15
+ 'sales_email_invoice_template' => 'New Invoice',
16
+ 'sales_email_invoice_guest_template' => 'New Invoice for Guest',
17
+ 'sales_email_invoice_comment_template' => 'Invoice Update',
18
+ 'sales_email_invoice_comment_guest_template' => 'Invoice Update for Guest',
19
+ 'sales_email_creditmemo_template' => 'New Credit Memo',
20
+ 'sales_email_creditmemo_guest_template' => 'New Credit Memo for Guest',
21
+ 'sales_email_creditmemo_comment_template' => 'Credit Memo Update',
22
+ 'sales_email_creditmemo_comment_guest_template' => 'Credit Memo Update for Guest',
23
+ 'sales_email_shipment_template' => 'New Shipment',
24
+ 'sales_email_shipment_guest_template' => 'New Shipment for Guest',
25
+ 'sales_email_shipment_comment_template' => 'Shipment Update',
26
+ 'sales_email_shipment_comment_guest_template' => 'Shipment Update for Guest',
27
+ );
28
+ /**
29
+ * customer emails that can be mapped as transactional emails.
30
+ *
31
+ * @var array
32
+ */
33
+ private $_registeredCustomer = array(
34
+ 'customer_create_account_email_template' => 'New Customer Account'
35
+ );
36
+
37
+
38
+ /**
39
+ * Send transactional email to recipient
40
+ *
41
+ * @see Mage_Core_Model_Email_Template::sendTransactional()
42
+ * @param string $templateId
43
+ * @param string|array $sender sneder information, can be declared as part of config path
44
+ * @param string $email recipient email
45
+ * @param string $name recipient name
46
+ * @param array $vars varianles which can be used in template
47
+ * @param int|null $storeId
48
+ * @return Mage_Core_Model_Email_Template
49
+ */
50
+ public function sendTransactional($templateId, $sender, $email, $name, $vars=array(), $storeId=null)
51
+ {
52
+ $sendType = Mage::helper('connector/transactional')->getMapping($templateId,Dotdigitalgroup_Email_Helper_Transactional::MAP_COLUMN_KEY_SENDTYPE);
53
+ $transEnabled = Mage::getStoreConfig(Dotdigitalgroup_Email_Helper_Transactional::XML_PATH_TRANSACTIONAL_API_ENABLED);
54
+ $campaignId = Mage::helper('connector/transactional')->getMapping($templateId,Dotdigitalgroup_Email_Helper_Transactional::MAP_COLUMN_KEY_DATAFIELD);
55
+
56
+ //design and send. campaign id is needed for this option
57
+ if($sendType == 2 && $transEnabled && $campaignId)
58
+ {
59
+ $this->setSentSuccess($this->designAndSend($templateId, $vars, $campaignId, $email, $storeId));
60
+ return $this;
61
+ }
62
+
63
+ //send via connector
64
+ if($sendType == 1 && $transEnabled)
65
+ return $this->sendTransactionalForOptionViaConnector($templateId, $sender, $email, $name, $vars, $storeId, $sendType);
66
+
67
+ //templates not mapped or mapped "Use System Default"
68
+ return parent::sendTransactional($templateId, $sender, $email, $name, $vars, $storeId);
69
+ }
70
+
71
+ /**
72
+ * send transactional for option "Send via connector"
73
+ *
74
+ * @param $templateId
75
+ * @param $sender
76
+ * @param $email
77
+ * @param $name
78
+ * @param array $vars
79
+ * @param null $storeId
80
+ * @param $sendType
81
+ * @return $this
82
+ * @throws Mage_Core_Exception
83
+ */
84
+ public function sendTransactionalForOptionViaConnector($templateId, $sender, $email, $name, $vars = array(), $storeId = null, $sendType)
85
+ {
86
+ $this->setSentSuccess(false);
87
+ if (($storeId === null) && $this->getDesignConfig()->getStore()) {
88
+ $storeId = $this->getDesignConfig()->getStore();
89
+ }
90
+
91
+ if (is_numeric($templateId)) {
92
+ $this->load($templateId);
93
+ } else {
94
+ $localeCode = Mage::getStoreConfig('general/locale/code', $storeId);
95
+ $this->loadDefault($templateId, $localeCode);
96
+ }
97
+
98
+ if (!$this->getId()) {
99
+ throw Mage::exception('Mage_Core', Mage::helper('core')->__('Invalid transactional email code: %s', $templateId));
100
+ }
101
+
102
+ if (!is_array($sender)) {
103
+ $this->setSenderName(Mage::getStoreConfig('trans_email/ident_' . $sender . '/name', $storeId));
104
+ $this->setSenderEmail(Mage::getStoreConfig('trans_email/ident_' . $sender . '/email', $storeId));
105
+ } else {
106
+ $this->setSenderName($sender['name']);
107
+ $this->setSenderEmail($sender['email']);
108
+ }
109
+
110
+ if (!isset($vars['store'])) {
111
+ $vars['store'] = Mage::app()->getStore($storeId);
112
+ }
113
+ $this->setSentSuccess($this->send($email, $name, $vars, $sendType));
114
+ return $this;
115
+ }
116
+
117
+ /**
118
+ * Send mail to recipient
119
+ *
120
+ * @see Mage_Core_Model_Email_Template::send()
121
+ * @param array|string $email E-mail(s)
122
+ * @param array|string|null $name receiver name(s)
123
+ * @param array $variables template variables
124
+ * @param int $sendType
125
+ * @return boolean
126
+ **/
127
+ public function send($email, $name = null, array $variables = array(), $sendType = null)
128
+ {
129
+ //not mapped templates or mapped as "Use system default"
130
+ if($sendType == null)
131
+ return parent::send($email, $name, $variables);
132
+
133
+ $transEnabled = Mage::getStoreConfig(Dotdigitalgroup_Email_Helper_Transactional::XML_PATH_TRANSACTIONAL_API_ENABLED);
134
+ //mapped option "Send via connector"
135
+ if($sendType == 1 && $transEnabled)
136
+ return $this->sendViaConnector($email, $name, $variables);
137
+
138
+ }
139
+
140
+ /**
141
+ * send via connector
142
+ *
143
+ * @param $email
144
+ * @param $name
145
+ * @param $variables
146
+ * @return bool
147
+ * @throws Exception
148
+ */
149
+ public function sendViaConnector($email, $name, $variables)
150
+ {
151
+ $emails = array_values((array)$email);
152
+ $names = is_array($name) ? $name : (array)$name;
153
+ $names = array_values($names);
154
+ foreach ($emails as $key => $email) {
155
+ if (!isset($names[$key])) {
156
+ $names[$key] = substr($email, 0, strpos($email, '@'));
157
+ }
158
+ }
159
+ $variables['email'] = reset($emails);
160
+ $variables['name'] = reset($names);
161
+ $this->setUseAbsoluteLinks(true);
162
+
163
+ $store = $variables['store'];
164
+ $body = $this->getProcessedTemplate($variables, true);
165
+ $subject = $this->getProcessedTemplateSubject($variables);
166
+ $websiteId = $store->getWebsiteId();
167
+
168
+ $helper = Mage::helper('connector/transactional');
169
+ $templateName = $helper->getTemplateLabelById($this->getId());
170
+
171
+ if($helper->getUnsubscribeLink($websiteId))
172
+ $body .= '<br><br>Want to unsubscribe or change your details ' . '<a href="http://$UNSUB$">Unsubscribe from this newsletter</a>';
173
+
174
+ foreach($emails as $email){
175
+ try{
176
+ $now = Mage::getSingleton('core/date')->gmtDate();
177
+ $emailCreate = Mage::getModel('email_connector/create');
178
+ $emailCreate
179
+ ->setEmail($email)
180
+ ->setFromName($this->getSenderName())
181
+ ->setWebsiteId($websiteId)
182
+ ->setName($templateName)
183
+ ->setSubject($subject)
184
+ ->setHtmlContent($body)
185
+ ->setPlainTextContent('Want to unsubscribe or change your details? http://$UNSUB$')
186
+ ->setCreatedAt($now)
187
+ ->setCopy($helper->getSendCopy($websiteId))
188
+ ->save();
189
+ }catch (Exception $e) {
190
+ Mage::logException($e);
191
+ }
192
+ }
193
+ return true;
194
+ }
195
+
196
+ /**
197
+ * design and send
198
+ *
199
+ * @param $templateId
200
+ * @param $templateParams
201
+ * @param $campaignId
202
+ * @param $email
203
+ * @param $storeId
204
+ * @return bool
205
+ */
206
+ public function designAndSend($templateId, $templateParams, $campaignId, $email, $storeId)
207
+ {
208
+ if (array_key_exists($templateId, $this->_registered)) {
209
+ $this->_registerOrderCampaign($templateId, $templateParams, $campaignId);
210
+ return true;
211
+ }
212
+ if (array_key_exists($templateId, $this->_registeredCustomer)) {
213
+ $this->_registerCustomer($templateId, $templateParams, $campaignId);
214
+ return true;
215
+ }
216
+
217
+ $this->_registerOtherDesignAndSendCampaign($templateId, $campaignId, $email, $storeId);
218
+ return true;
219
+ }
220
+
221
+ /**
222
+ * register sales order campaign.
223
+ *
224
+ * @param $templateId
225
+ * @param $data
226
+ * @param $campaignId
227
+ */
228
+ protected function _registerOrderCampaign($templateId, $data, $campaignId)
229
+ {
230
+ $order = $data['order'];
231
+ $storeId = $order->getStoreId();
232
+ Mage::helper('connector')->log('-- Sales Order :' . $campaignId);
233
+ try{
234
+ $now = Mage::getSingleton('core/date')->gmtDate();
235
+ //save email for sending
236
+ $emailCampaign = Mage::getModel('email_connector/campaign');
237
+ $emailCampaign->setOrderIncrementId($order->getRealOrderId())
238
+ ->setQuoteId($order->getQuoteId())
239
+ ->setEmail($order->getCustomerEmail())
240
+ ->setCustomerId($order->getCustomerId())
241
+ ->setStoreId($storeId)
242
+ ->setCampaignId($campaignId)
243
+ ->setEventName($this->_registered[$templateId])
244
+ ->setCreatedAt($now)
245
+ ;
246
+ $emailCampaign->save();
247
+ }catch (Exception $e){
248
+ Mage::logException($e);
249
+ }
250
+ }
251
+
252
+ /**
253
+ * register customer campaign.
254
+ *
255
+ * @param $templateId
256
+ * @param $data
257
+ * @param $campaignId
258
+ */
259
+ protected function _registerCustomer($templateId, $data, $campaignId)
260
+ {
261
+ $customer = $data['customer'];
262
+ Mage::helper('connector')->log('-- Customer campaign: ' . $campaignId);
263
+ try{
264
+ $now = Mage::getSingleton('core/date')->gmtDate();
265
+ //save email for sending
266
+ $emailCampaign = Mage::getModel('email_connector/campaign');
267
+ $emailCampaign->setEmail($customer->getEmail())
268
+ ->setCustomerId($customer->getId())
269
+ ->setStoreId($customer->getStoreId())
270
+ ->setCampaignId($campaignId)
271
+ ->setEventName($this->_registeredCustomer[$templateId])
272
+ ->setCreatedAt($now);
273
+ $emailCampaign->save();
274
+ }catch (Exception $e) {
275
+ Mage::logException($e);
276
+ }
277
+ }
278
+
279
+ /**
280
+ * design and send option. all campaign which are not in array _registered or array _registeredCustomer
281
+ *
282
+ * @param $templateId
283
+ * @param $campaignId
284
+ * @param $email
285
+ * @param $storeId
286
+ */
287
+ protected function _registerOtherDesignAndSendCampaign($templateId, $campaignId, $email, $storeId)
288
+ {
289
+ $helper = Mage::helper('connector/transactional');
290
+ Mage::helper('connector')->log('-- Other campaign: ' . $campaignId);
291
+
292
+ try{
293
+ $now = Mage::getSingleton('core/date')->gmtDate();
294
+ if($email){
295
+ //save email for sending
296
+ $emailCampaign = Mage::getModel('email_connector/campaign');
297
+ $emailCampaign
298
+ ->setEmail($email)
299
+ ->setStoreId($storeId)
300
+ ->setCampaignId($campaignId)
301
+ ->setEventName($helper->getTemplateLabelById($templateId))
302
+ ->setCreatedAt($now);
303
+ $emailCampaign->save();
304
+ }
305
+ }catch (Exception $e) {
306
+ Mage::logException($e);
307
+ }
308
+ }
309
+
310
+ /**
311
+ * find template id in array _registered
312
+ *
313
+ * @param $templateId
314
+ * @return bool
315
+ */
316
+ public function getSalesEvent($templateId)
317
+ {
318
+ if (array_key_exists($templateId, $this->_registered))
319
+ return true;
320
+
321
+ return false;
322
+ }
323
+
324
+ }
app/code/community/Dotdigitalgroup/Email/Model/Newsletter/Observer.php ADDED
@@ -0,0 +1,110 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dotdigitalgroup_Email_Model_Newsletter_Observer
4
+ {
5
+
6
+ /**
7
+ * Newslleter subsciber event.
8
+ *
9
+ * @param Varien_Event_Observer $observer
10
+ *
11
+ * @return $this
12
+ */
13
+ public function handleNewsletterSubscriberSave(Varien_Event_Observer $observer)
14
+ {
15
+ $subscriber = $observer->getEvent()->getSubscriber();
16
+ $storeId = $subscriber->getStoreId();
17
+ $email = $subscriber->getEmail();
18
+ $subscriberStatus = $subscriber->getSubscriberStatus();
19
+ $contactId = '';
20
+ $helper = Mage::helper('connector');
21
+ $websiteId = Mage::app()->getStore($subscriber->getStoreId())->getWebsiteId();
22
+ $contactEmail = Mage::getModel('email_connector/contact')->loadByCustomerEmail($email, $websiteId);
23
+ // send to new subscribers only to automation programm
24
+ if (! Mage::getModel('newsletter/subscriber')->loadByEmail($email)->getId())
25
+ $this->_postSubscriberToAutomation($email, $websiteId);
26
+
27
+ try{
28
+ /**
29
+ * Subscribe a contact
30
+ */
31
+ if ($subscriberStatus == Mage_Newsletter_Model_Subscriber::STATUS_SUBSCRIBED) {
32
+ $contactEmail->setSubscriberStatus($subscriberStatus)
33
+ ->setIsSubscriber(1);
34
+
35
+ /**
36
+ * Resubscribe suppressed contacts.
37
+ */
38
+ $client = Mage::helper('connector')->getWebsiteApiClient($websiteId);
39
+ $apiContact = $client->getContactByEmail($email);
40
+ if (isset($apiContact->status) && $apiContact->status == 'Suppressed') {
41
+ $client->PostContactsResubscribe($apiContact);
42
+ }
43
+ $client->PostContactsResubscribe($apiContact);
44
+ $contactEmail->setSuppressed(null);
45
+
46
+ } else {
47
+ /**
48
+ * Unsubscribe contact
49
+ */
50
+ $client = Mage::helper('connector')->getWebsiteApiClient($websiteId);
51
+ if (!$contactEmail->getContactId()) {
52
+ //if contact id is not set get the contact_id
53
+ $result = $client->postContacts($email);
54
+ $contactId = $result->id;
55
+ } else {
56
+ $contactId = $contactEmail->getContactId();
57
+ }
58
+ if (is_numeric($contactId)) {
59
+ $client->deleteAddressBookContact($helper->getSubscriberAddressBook($websiteId), $contactId);
60
+ } else {
61
+ Mage::helper('connector')->log('CONTACT ID IS EMPTY : ' . $contactId . ' email : ' . $email);
62
+ }
63
+ $contactEmail->setIsSubscriber(null)
64
+ ->setSubscriberStatus(Mage_Newsletter_Model_Subscriber::STATUS_UNSUBSCRIBED);
65
+
66
+ }
67
+
68
+ $contactEmail->setStoreId($storeId)
69
+ ->setContactId($contactId)
70
+ ->save();
71
+
72
+ }catch(Exception $e){
73
+ Mage::logException($e);
74
+ }
75
+ return $this;
76
+ }
77
+
78
+
79
+ private function _postSubscriberToAutomation( $email, $websiteId ) {
80
+ /**
81
+ * Automation Programme
82
+ */
83
+ $subscriberAutoCamaignId = Mage::helper('connector')->getWebsiteConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_AUTOMATION_STUDIO_SUBSCRIBER, $websiteId);
84
+ if ($subscriberAutoCamaignId) {
85
+ $client = Mage::helper( 'connector' )->getWebsiteApiClient( $websiteId );
86
+ $apiContact = $client->postContacts($email);
87
+
88
+ // get a program by id
89
+ $program = $client->GetProgramById($subscriberAutoCamaignId);
90
+ /**
91
+ * id
92
+ * name
93
+ * status
94
+ * dateCreated
95
+ */
96
+ Mage::helper( 'connector' )->log( 'AP - get subscriber Program id : ' . $program->id);
97
+
98
+ $data = array(
99
+ 'Contacts' => array($apiContact->id),
100
+ 'ProgramId' => $program->id,
101
+ 'Status' => $program->status,
102
+ 'DateCreated' => $program->dateCreated,
103
+ 'AddressBooks' => array()
104
+ );
105
+ Mage::helper( 'connector' )->log( 'subscriber to automation email : ' . $email );
106
+ Mage::helper( 'connector' )->log( $data );
107
+ $client->PostProgramsEnrolments($data);
108
+ }
109
+ }
110
+ }
app/code/community/Dotdigitalgroup/Email/Model/Newsletter/Subscriber.php ADDED
@@ -0,0 +1,142 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dotdigitalgroup_Email_Model_Newsletter_Subscriber
4
+ {
5
+ const STATUS_SUBSCRIBED = 1;
6
+ const STATUS_NOT_ACTIVE = 2;
7
+ const STATUS_UNSUBSCRIBED = 3;
8
+ const STATUS_UNCONFIRMED = 4;
9
+
10
+ protected $_start;
11
+
12
+ /**
13
+ * SUBSCRIBER SYNC.
14
+ * @return $this
15
+ */
16
+ public function sync()
17
+ {
18
+ /** @var Dotdigitalgroup_Email_Helper_Data $helper */
19
+ $helper = Mage::helper('connector');
20
+ $helper->log('---------------------- Start subscriber sync -------------------');
21
+ $this->_start = microtime(true);
22
+
23
+ foreach (Mage::app()->getWebsites(true) as $website) {
24
+ if (Mage::helper('connector')->getWebsiteConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_SYNC_SUBSCRIBER_ENABLED, $website))
25
+ $this->exportSubscribersPerWebsite($website);
26
+ }
27
+
28
+ return $this;
29
+ }
30
+
31
+ /**
32
+ * Export subscriber per website.
33
+ *
34
+ * @param $website
35
+ */
36
+ public function exportSubscribersPerWebsite($website)
37
+ {
38
+ $updated = 0;
39
+ $helper = Mage::helper('connector');
40
+ $fileHelper = Mage::helper('connector/file');
41
+ $limit = $helper->getWebsiteConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_SYNC_LIMIT, $website);
42
+ $subscribers = Mage::getModel('email_connector/contact')->getSubscribersToImport($website, $limit);
43
+ if (count($subscribers)) {
44
+ $client = Mage::helper('connector')->getWebsiteApiClient($website);
45
+ $subscribersFilename = strtolower($website->getCode() . '_subscribers_' . date('d_m_Y_Hi') . '.csv');
46
+ //get mapped storename
47
+ $subscriberStorename = $helper->getMappedStoreName($website);
48
+ //file headers
49
+ $fileHelper->outputCSV($fileHelper->getFilePath($subscribersFilename), array('Email', 'emailType', $subscriberStorename));
50
+ foreach ($subscribers as $subscriber) {
51
+ try{
52
+ $email = $subscriber->getEmail();
53
+ $subscriber->setSubscriberImported(1)->save();
54
+ $subscriber = Mage::getModel('newsletter/subscriber')->loadByEmail($email);
55
+ $storeName = Mage::app()->getStore($subscriber->getStoreId())->getName();
56
+ // save data for subscribers
57
+ $fileHelper->outputCSV($fileHelper->getFilePath($subscribersFilename), array($email, 'Html', $storeName));
58
+ $updated++;
59
+ }catch (Exception $e){
60
+ Mage::logException($e);
61
+ }
62
+ }
63
+ $helper->log('Subscriber filename: ' . $subscribersFilename);
64
+ //Add to subscriber address book
65
+ $client->postAddressBookContactsImport($subscribersFilename, $helper->getSubscriberAddressBook($website));
66
+ $fileHelper->archiveCSV($subscribersFilename);
67
+ }
68
+ }
69
+
70
+ /**
71
+ * Unsubscribe suppressed contacts.
72
+ * @param bool $force set 10years old
73
+ * @return mixed
74
+ */
75
+ public function unsubscribe($force = false)
76
+ {
77
+ $result['customers'] = 0;
78
+ $limit = 5;
79
+ $max_to_select = 1000;
80
+ $date = Zend_Date::now()->subHour(1);
81
+ $helper = Mage::helper('connector');
82
+ // force sync all customers
83
+ if($force)
84
+ $date = $date->subYear(10);
85
+ // datetime format string
86
+ $dateString = $date->toString(Zend_Date::W3C);
87
+
88
+ /**
89
+ * 1. Sync all suppressed for each store
90
+ */
91
+ foreach (Mage::app()->getWebsites(true) as $website) {
92
+ if (! Mage::helper('connector')->getWebsiteConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_API_ENABLED, $website))
93
+ continue;
94
+ $contacts = array();
95
+ $skip = $i = 0;
96
+ $client = Mage::helper('connector')->getWebsiteApiClient($website);
97
+ //there is a maximum of request we need to loop to get more suppressed contacts
98
+ for ($i=0; $i<= $limit;$i++) {
99
+ $apiContacts = $client->getContactsSuppressedSinceDate($dateString, $max_to_select , $skip);
100
+ // skip no more contacts
101
+ if(empty($apiContacts))
102
+ break;
103
+ $contacts = array_merge($contacts, $apiContacts);
104
+ $skip += 1000;
105
+ }
106
+ $subscriberBookId = $helper->getSubscriberAddressBook($website);
107
+ // suppressed contacts to unsubscibe
108
+ foreach ($contacts as $apiContact) {
109
+ if (isset($apiContact->suppressedContact)) {
110
+ $suppressedContact = $apiContact->suppressedContact;
111
+ $email = $suppressedContact->email;
112
+ $contactId = $suppressedContact->id;
113
+ try{
114
+ /**
115
+ * 2. Unsubscribe customer.
116
+ */
117
+ $subscriber = Mage::getModel('newsletter/subscriber')->loadByEmail($email);
118
+ if ($subscriber->getStatus() == Mage_Newsletter_Model_Subscriber::STATUS_SUBSCRIBED) {
119
+ $subscriber->setStatus(Mage_Newsletter_Model_Subscriber::STATUS_UNSUBSCRIBED);
120
+ $subscriber->save();
121
+ // remove from subscriber address-book
122
+ $client->deleteAddressBookContact($subscriberBookId, $contactId);
123
+ }
124
+ //mark contact as suppressed and unsubscribe
125
+ $contactCollection = Mage::getModel('email_connector/contact')->getCollection()
126
+ ->addFieldToFilter('email', $email)
127
+ ->addFieldToFilter('website_id', $website->getId());
128
+ //unsubscribe from the email contact table.
129
+ foreach ($contactCollection as $contact) {
130
+ $contact->setIsSubscriber(null)
131
+ ->setSuppressed(1)->save();
132
+ }
133
+ }catch (Exception $e){
134
+ Mage::logException($e);
135
+ }
136
+ }
137
+ }
138
+ }
139
+
140
+ return $result;
141
+ }
142
+ }
app/code/community/Dotdigitalgroup/Email/Model/Order.php ADDED
@@ -0,0 +1,81 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dotdigitalgroup_Email_Model_Order extends Mage_Core_Model_Abstract
4
+ {
5
+ const EMAIL_ORDER_NOT_IMPORTED = null;
6
+ /**
7
+ * constructor
8
+ */
9
+ public function _construct()
10
+ {
11
+ parent::_construct();
12
+ $this->_init('email_connector/order');
13
+ }
14
+
15
+ /**
16
+ * @return $this|Mage_Core_Model_Abstract
17
+ */
18
+ protected function _beforeSave()
19
+ {
20
+ parent::_beforeSave();
21
+ $now = Mage::getSingleton('core/date')->gmtDate();
22
+ if ($this->isObjectNew()) {
23
+ $this->setCreatedAt($now);
24
+ }
25
+ return $this;
26
+ }
27
+
28
+
29
+ /**
30
+ * Load the email order by quote id.
31
+ * @param $orderId
32
+ * @param $quoteId
33
+ * @return $this|Varien_Object
34
+ */
35
+ public function loadByOrderId($orderId, $quoteId)
36
+ {
37
+ $collection = $this->getCollection()
38
+ ->addFieldToFilter('order_id', $orderId)
39
+ ->addFieldToFilter('quote_id', $quoteId);
40
+ if ($collection->count()) {
41
+ return $collection->getFirstItem();
42
+ } else {
43
+ $this->setOrderId($orderId)
44
+ ->setQuoteId($quoteId);
45
+ }
46
+ return $this;
47
+ }
48
+
49
+
50
+ public function getEmailOrderRow($orderId, $quoteId, $storeId)
51
+ {
52
+
53
+ $collection = $this->getCollection()
54
+ ->addFieldToFilter('order_id', $orderId)
55
+ ->addFieldToFilter('quote_id', $quoteId)
56
+ ->addFieldToFilter('store_id', $storeId);
57
+
58
+ if ($collection->count()) {
59
+ return $collection->getFirstItem();
60
+ } else {
61
+ $now = Mage::getSingleton('core/date')->gmtDate();
62
+
63
+ $this->setOrderId($orderId)
64
+ ->setQuoteId($quoteId)
65
+ ->setStoreId($storeId)
66
+ ->setCreatedAt($now);
67
+ }
68
+ return $this;
69
+
70
+ }
71
+ public function getOrdersToImport($storeIds, $limit, $orderStatuses)
72
+ {
73
+ $collection = $this->getCollection()
74
+ ->addFieldToFilter('email_imported', array('null' => true))
75
+ ->addFieldToFilter('store_id', array('in' => $storeIds))
76
+ ->addFieldToFilter('order_status', array('in' => $orderStatuses));
77
+
78
+ $collection->getSelect()->limit($limit);
79
+ return $collection->load();
80
+ }
81
+ }
app/code/community/Dotdigitalgroup/Email/Model/Resource/Campaign.php ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dotdigitalgroup_Email_Model_Resource_Campaign extends Mage_Core_Model_Resource_Db_Abstract
4
+ {
5
+ /**
6
+ * constructor.
7
+ */
8
+ protected function _construct()
9
+ {
10
+ $this->_init('email_connector/campaign', 'id');
11
+
12
+ }
13
+ }
app/code/community/Dotdigitalgroup/Email/Model/Resource/Campaign/Collection.php ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dotdigitalgroup_Email_Model_Resource_Campaign_Collection extends Mage_Core_Model_Resource_Db_Collection_Abstract
4
+ {
5
+ /**
6
+ * constructor.
7
+ */
8
+ public function _construct()
9
+ {
10
+ parent::_construct();
11
+ $this->_init('email_connector/campaign');
12
+ }
13
+ }
app/code/community/Dotdigitalgroup/Email/Model/Resource/Contact.php ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dotdigitalgroup_Email_Model_Resource_Contact extends Mage_Core_Model_Mysql4_Abstract
4
+ {
5
+
6
+ /**
7
+ * constructor.
8
+ */
9
+ protected function _construct()
10
+ {
11
+ $this->_init('email_connector/contact', 'email_contact_id');
12
+
13
+ }
14
+ }
app/code/community/Dotdigitalgroup/Email/Model/Resource/Contact/Collection.php ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dotdigitalgroup_Email_Model_Resource_Contact_Collection extends Mage_Core_Model_Resource_Db_Collection_Abstract
4
+ {
5
+ /**
6
+ * constructor.
7
+ */
8
+ protected function _construct()
9
+ {
10
+ parent::_construct();
11
+ $this->_init('email_connector/contact');
12
+ }
13
+
14
+
15
+ /**
16
+ * @param $website
17
+ * @return $this
18
+ */
19
+ public function addWebsiteFilter($website)
20
+ {
21
+ $this->addFilter('website_id', $website);
22
+ return $this;
23
+ }
24
+
25
+ }
app/code/community/Dotdigitalgroup/Email/Model/Resource/Create.php ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dotdigitalgroup_Email_Model_Resource_Create extends Mage_Core_Model_Mysql4_Abstract
4
+ {
5
+
6
+ /**
7
+ * constructor.
8
+ */
9
+ protected function _construct()
10
+ {
11
+ $this->_init('email_connector/create', 'id');
12
+
13
+ }
14
+ }
app/code/community/Dotdigitalgroup/Email/Model/Resource/Create/Collection.php ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dotdigitalgroup_Email_Model_Resource_Create_Collection extends Mage_Core_Model_Resource_Db_Collection_Abstract
4
+ {
5
+
6
+ /**
7
+ * constructor.
8
+ */
9
+ public function _construct()
10
+ {
11
+ parent::_construct();
12
+ $this->_init('email_connector/create');
13
+ }
14
+ }
app/code/community/Dotdigitalgroup/Email/Model/Resource/Order.php ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dotdigitalgroup_Email_Model_Resource_Order extends Mage_Core_Model_Resource_Db_Abstract
4
+ {
5
+ /**
6
+ * cosntructor.
7
+ */
8
+ protected function _construct()
9
+ {
10
+ $this->_init('email_connector/order', 'email_order_id');
11
+ }
12
+ }
app/code/community/Dotdigitalgroup/Email/Model/Resource/Order/Collection.php ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dotdigitalgroup_Email_Model_Resource_Order_Collection extends Mage_Core_Model_Resource_Db_Collection_Abstract
4
+ {
5
+
6
+ /**
7
+ * constructor.
8
+ */
9
+ public function _construct()
10
+ {
11
+ parent::_construct();
12
+ $this->_init('email_connector/order');
13
+ }
14
+
15
+
16
+
17
+
18
+ }
app/code/community/Dotdigitalgroup/Email/Model/Resource/Setup.php ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dotdigitalgroup_Email_Model_Resource_Setup extends Mage_Eav_Model_Entity_Setup
4
+ {
5
+ /**
6
+ * This method returns true if the attribute exists.
7
+ *
8
+ * @param string|int $entityTypeId
9
+ * @param string|int $attributeId
10
+ * @return bool
11
+ */
12
+ public function attributeExists($entityTypeId, $attributeId)
13
+ {
14
+ try
15
+ {
16
+ $entityTypeId = $this->getEntityTypeId($entityTypeId);
17
+ $attributeId = $this->getAttributeId($entityTypeId, $attributeId);
18
+ return !empty($attributeId);
19
+ }
20
+ catch(Exception $e)
21
+ {
22
+ return FALSE;
23
+ }
24
+ }
25
+
26
+ }
app/code/community/Dotdigitalgroup/Email/Model/Sales/Observer.php ADDED
@@ -0,0 +1,152 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dotdigitalgroup_Email_Model_Sales_Observer
4
+ {
5
+
6
+ /**
7
+ * Register the order status.
8
+ * @param $observer
9
+ * @return $this
10
+ */
11
+ public function handleSalesOrderSaveBefore($observer)
12
+ {
13
+ $order = $observer->getEvent()->getOrder();
14
+ // the reloaded status
15
+ $reloaded = Mage::getModel('sales/order')->load($order->getId());
16
+ Mage::register('sales_order_status_before', $reloaded->getStatus());
17
+ return $this;
18
+ }
19
+ /**
20
+ * save/reset the order as transactional data.
21
+ *
22
+ * @param Varien_Event_Observer $observer
23
+ * @return $this
24
+ */
25
+ public function handleSalesOrderSaveAfter(Varien_Event_Observer $observer)
26
+ {
27
+ try{
28
+ $currentStoreId = Mage::app()->getStore()->getId();
29
+ $order = $observer->getEvent()->getOrder();
30
+ $status = $order->getStatus();
31
+ $storeId = $order->getStoreId();
32
+ $emailOrder = Mage::getModel('email_connector/order')->loadByOrderId($order->getEntityId(), $order->getQuoteId());
33
+ //reimport email order
34
+ $emailOrder->setUpdatedAt($order->getUpdatedAt())
35
+ ->setStoreId($storeId)
36
+ ->setOrderStatus($status);
37
+ if($emailOrder->getEmailImported() != Dotdigitalgroup_Email_Model_Contact::EMAIL_CONTACT_IMPORTED) {
38
+ $emailOrder->setEmailImported(null);
39
+ }
40
+
41
+ // check for order status change
42
+ $statusBefore = Mage::registry('sales_order_status_before');
43
+ if ( $status!= $statusBefore) {
44
+ //If order status has changed and order is already imported then set imported to null
45
+ if($emailOrder->getEmailImported() == Dotdigitalgroup_Email_Model_Contact::EMAIL_CONTACT_IMPORTED) {
46
+ $emailOrder->setEmailImported(Dotdigitalgroup_Email_Model_Contact::EMAIL_CONTACT_NOT_IMPORTED);
47
+ }
48
+ $smsCampaign = Mage::getModel('email_connector/sms_campaign', $order);
49
+ $smsCampaign->setStatus($status);
50
+ $smsCampaign->sendSms();
51
+ // set back the current store
52
+ Mage::app()->setCurrentStore($currentStoreId);
53
+ }
54
+ $emailOrder->save();
55
+
56
+ //admin oder when editing the first one is canceled
57
+ Mage::unregister('sales_order_status_before');
58
+ }catch(Exception $e){
59
+ Mage::logException($e);
60
+ }
61
+ return $this;
62
+ }
63
+
64
+
65
+ /**
66
+ * Create new order event.
67
+ * @param Varien_Event_Observer $observer
68
+ *
69
+ * @return $this
70
+ * @throws Mage_Core_Exception
71
+ */
72
+ public function handleSalesOrderPlaceAfter(Varien_Event_Observer $observer)
73
+ {
74
+ $data = new Varien_Object();
75
+ $order = $observer->getEvent()->getOrder();
76
+ $website = Mage::app()->getWebsite($order->getWebsiteId());
77
+ $websiteName = $website->getName();
78
+ if (Mage::helper('connector')->getWebsiteConfig(Dotdigitalgroup_Email_Helper_Transactional::XML_PATH_TRANSACTIONAL_API_ENABLED, $website)) {
79
+ $storeName = Mage::app()->getStore($order->getStoreId())->getName();
80
+ $data->setCustomerId($order->getCustomerId())
81
+ ->setCustomerEmail($order->getCustomerEmail())
82
+ ->setOrderId($order->getId())
83
+ ->setOrderIncrementId($order->getIncrementId())
84
+ ->setWebsiteName($websiteName)
85
+ ->setStoreName($storeName)
86
+ ->setWebsite($website)
87
+ ->setOrderDate($order->getCreatedAt());
88
+
89
+ Mage::helper('connector/transactional')->updateContactData($data);
90
+ }
91
+
92
+ return $this;
93
+ }
94
+
95
+ /**
96
+ * Sales order refund event.
97
+ *
98
+ * @param Varien_Event_Observer $observer
99
+ *
100
+ * @return $this
101
+ */
102
+ public function handleSalesOrderRefund(Varien_Event_Observer $observer)
103
+ {
104
+ Mage::helper('connector')->log('observer sales order refund');
105
+ $creditmemo = $observer->getEvent()->getCreditmemo();
106
+ $storeId = $creditmemo->getStoreId();
107
+ $order = $creditmemo->getOrder();
108
+ $orderId = $order->getEntityId();
109
+ $quoteId = $order->getQuoteId();
110
+
111
+ try{
112
+ /**
113
+ * Reimport transactional data.
114
+ */
115
+ $emailOrder = Mage::getModel('email_connector/order')->loadByOrderId($orderId, $quoteId, $storeId);
116
+ if (!$emailOrder->getId()) {
117
+ Mage::helper('connector')->log('ERROR Creditmemmo Order not found :' . $orderId . ', quote id : ' . $quoteId . ', store id ' . $storeId);
118
+ return $this;
119
+ }
120
+ $emailOrder->setEmailImported(Dotdigitalgroup_Email_Model_Contact::EMAIL_CONTACT_NOT_IMPORTED)->save();
121
+ }catch (Exception $e){
122
+ Mage::logException($e);
123
+ }
124
+
125
+ return $this;
126
+ }
127
+
128
+ /**
129
+ * Sales cancel order event, remove transactional data.
130
+ *
131
+ * @param Varien_Event_Observer $observer
132
+ *
133
+ * @return $this
134
+ */
135
+ public function hangleSalesOrderCancel(Varien_Event_Observer $observer)
136
+ {
137
+ $order = $observer->getEvent()->getOrder();
138
+ $storeId = $order->getStoreId();
139
+ $websiteId = Mage::app()->getStore($storeId)->getWebsiteId();
140
+ $customerEmail = $order->getCustomerEmail();
141
+ $helper = Mage::helper('connector');
142
+ if ($helper->isEnabled($websiteId)) {
143
+ $client = Mage::getModel('email_connector/apiconnector_client');
144
+ $client->setApiUsername($helper->getApiUsername($websiteId));
145
+ $client->setApiPassword($helper->getApiPassword($websiteId));
146
+ // delete the order transactional data
147
+ $client->deleteContactTransactionalData($customerEmail, 'Orders');
148
+ }
149
+
150
+ return $this;
151
+ }
152
+ }
app/code/community/Dotdigitalgroup/Email/Model/Sales/Order.php ADDED
@@ -0,0 +1,148 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dotdigitalgroup_Email_Model_Sales_Order
4
+ {
5
+ /**
6
+ * @var array
7
+ */
8
+ protected $accounts = array();
9
+ /**
10
+ * @var string
11
+ */
12
+ private $_apiUsername;
13
+ /**
14
+ * @var string
15
+ */
16
+ private $_apiPassword;
17
+
18
+ /**
19
+ * initial sync the transactional data
20
+ * @return array
21
+ */
22
+ public function sync()
23
+ {
24
+ $client = Mage::getModel('email_connector/apiconnector_client');
25
+ // Initialise a return hash containing results of our sync attempt
26
+ $this->_searchAccounts();
27
+ Mage::helper( 'connector' )->log( 'search for the accounts, transactional order' );
28
+ foreach ($this->accounts as $account) {
29
+ $orders = $account->getOrders();
30
+ if (count($orders)) {
31
+ $client->setApiUsername($account->getApiUsername())
32
+ ->setApiPassword($account->getApiPassword());
33
+ Mage::helper('connector')->log('--------- Order sync ---------- : ' . count($orders));
34
+ $client->postContactsTransactionalDataImport($orders, 'Orders');
35
+ Mage::helper('connector')->log('----------end order sync----------');
36
+ }
37
+ unset($this->accounts[$account->getApiUsername()]);
38
+ }
39
+ return $this;
40
+ }
41
+
42
+ /**
43
+ * Search the configuration data per website
44
+ */
45
+ private function _searchAccounts()
46
+ {
47
+ $helper = Mage::helper('connector');
48
+ foreach (Mage::app()->getWebsites(true) as $website) {
49
+ if ($helper->getWebsiteConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_SYNC_ORDER_ENABLED, $website)) {
50
+ $this->_apiUsername = $helper->getApiUsername($website);
51
+ $this->_apiPassword = $helper->getApiPassword($website);
52
+
53
+ // limit for orders included to sync
54
+ $limit = Mage::helper('connector')->getWebsiteConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_TRANSACTIONAL_DATA_SYNC_LIMIT, $website);
55
+ if (!isset($this->accounts[$this->_apiUsername])) {
56
+ $account = Mage::getModel('email_connector/connector_account')
57
+ ->setApiUsername($this->_apiUsername)
58
+ ->setApiPassword($this->_apiPassword);
59
+ $this->accounts[$this->_apiUsername] = $account;
60
+ }
61
+ $this->accounts[$this->_apiUsername]->setOrders($this->getConnectorOrders($website, $limit));
62
+ }
63
+ }
64
+ }
65
+
66
+ /**
67
+ * get all order to import.
68
+ * @param $website
69
+ * @param int $limit
70
+ * @return array
71
+ */
72
+ public function getConnectorOrders($website, $limit = 100)
73
+ {
74
+ $orders = $customers = array();
75
+ $storeIds = $website->getStoreIds();
76
+ $orderModel = Mage::getModel('email_connector/order');
77
+ if(empty($storeIds))
78
+ return;
79
+
80
+ $orderStatuses = Mage::helper('connector')->getConfigSelectedStatus($website);
81
+
82
+ if($orderStatuses)
83
+ $orderCollection = $orderModel->getOrdersToImport($storeIds, $limit, $orderStatuses);
84
+ else
85
+ return;
86
+
87
+ foreach ($orderCollection as $order) {
88
+ try {
89
+ $salesOrder = Mage::getModel('sales/order')->load($order->getOrderId());
90
+ $storeId = $order->getStoreId();
91
+ $websiteId = Mage::app()->getStore($storeId)->getWebsiteId();
92
+ /**
93
+ * Add guest to contacts table.
94
+ */
95
+ if ($salesOrder->getCustomerIsGuest()) {
96
+ $this->_createGuestContact($salesOrder->getCustomerEmail(), $websiteId, $storeId);
97
+ }
98
+ if ($salesOrder->getId()) {
99
+ $connectorOrder = Mage::getModel('email_connector/connector_order', $salesOrder);
100
+ $orders[] = $connectorOrder;
101
+ }
102
+ $order->setEmailImported(Dotdigitalgroup_Email_Model_Contact::EMAIL_CONTACT_IMPORTED)
103
+ ->save();
104
+ }catch(Exception $e){
105
+ Mage::logException($e);
106
+ }
107
+ }
108
+ return $orders;
109
+ }
110
+
111
+ /**
112
+ * Create a guest contact.
113
+ * @param $email
114
+ * @param $websiteId
115
+ * @param $storeId
116
+ *
117
+ * @return bool
118
+ */
119
+ private function _createGuestContact($email, $websiteId, $storeId){
120
+ try{
121
+ $client = Mage::helper('connector')->getWebsiteApiClient($websiteId);
122
+ $contactApi = $client->getContactByEmail($email);
123
+ if (isset($contactApi->message) && $contactApi->message == Dotdigitalgroup_Email_Model_Apiconnector_Client::REST_CONTACT_NOT_FOUND) {
124
+ //create a new contact.
125
+ $contactApi = $client->postContacts($email);
126
+ } elseif (isset($contactApi->message)) {
127
+ return false;
128
+ }
129
+ // Add guest to address book
130
+ $response = $client->postAddressBookContacts(Mage::helper('connector')->getGuestAddressBook($websiteId), $contactApi);
131
+ $contactModel = Mage::getModel('email_connector/contact')->loadByCustomerEmail($email, $websiteId);
132
+ $contactModel->setIsGuest(1)
133
+ ->setStoreId($storeId)
134
+ ->setContactId($contactApi->id)
135
+ ->setEmailImported(1);
136
+
137
+ if (isset($response->message) && $response->message == 'Contact is suppressed. ERROR_CONTACT_SUPPRESSED')
138
+ $contactModel->setSuppressed(1);
139
+
140
+ $contactModel->save();
141
+ Mage::helper('connector')->log('-- guest found : ' . $email . ' website : ' . $websiteId . ' ,store : ' . $storeId);
142
+ }catch(Exception $e){
143
+ Mage::logException($e);
144
+ }
145
+
146
+ return true;
147
+ }
148
+ }
app/code/community/Dotdigitalgroup/Email/Model/Sales/Quote.php ADDED
@@ -0,0 +1,173 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dotdigitalgroup_Email_Model_Sales_Quote
4
+ {
5
+ //customer
6
+ const XML_PATH_LOSTBASKET_CUSTOMER_ENABLED_1 = 'connector_lost_baskets/customers/enabled_1';
7
+ const XML_PATH_LOSTBASKET_CUSTOMER_ENABLED_2 = 'connector_lost_baskets/customers/enabled_2';
8
+ const XML_PATH_LOSTBASKET_CUSTOMER_ENABLED_3 = 'connector_lost_baskets/customers/enabled_3';
9
+ const XML_PATH_LOSTBASKET_CUSTOMER_INTERVAL_1 = 'connector_lost_baskets/customers/send_after_1';
10
+ const XML_PATH_LOSTBASKET_CUSTOMER_INTERVAL_2 = 'connector_lost_baskets/customers/send_after_2';
11
+ const XML_PATH_LOSTBASKET_CUSTOMER_INTERVAL_3 = 'connector_lost_baskets/customers/send_after_3';
12
+ const XML_PATH_LOSTBASKET_CUSTOMER_CAMPAIGN_1 = 'connector_lost_baskets/customers/campaign_1';
13
+ const XML_PATH_LOSTBASKET_CUSTOMER_CAMPAIGN_2 = 'connector_lost_baskets/customers/campaign_2';
14
+ const XML_PATH_LOSTBASKET_CUSTOMER_CAMPAIGN_3 = 'connector_lost_baskets/customers/campaign_3';
15
+
16
+ //guest
17
+ const XML_PATH_LOSTBASKET_GUEST_ENABLED_1 = 'connector_lost_baskets/guests/enabled_1';
18
+ const XML_PATH_LOSTBASKET_GUEST_ENABLED_2 = 'connector_lost_baskets/guests/enabled_2';
19
+ const XML_PATH_LOSTBASKET_GUEST_ENABLED_3 = 'connector_lost_baskets/guests/enabled_3';
20
+ const XML_PATH_LOSTBASKET_GUEST_INTERVAL_1 = 'connector_lost_baskets/guests/send_after_1';
21
+ const XML_PATH_LOSTBASKET_GUEST_INTERVAL_2 = 'connector_lost_baskets/guests/send_after_2';
22
+ const XML_PATH_LOSTBASKET_GUEST_INTERVAL_3 = 'connector_lost_baskets/guests/send_after_3';
23
+ const XML_PATH_LOSTBASKET_GUEST_CAMPAIGN_1 = 'connector_lost_baskets/guests/campaign_1';
24
+ const XML_PATH_LOSTBASKET_GUEST_CAMPAIGN_2 = 'connector_lost_baskets/guests/campaign_2';
25
+ const XML_PATH_LOSTBASKET_GUEST_CAMPAIGN_3 = 'connector_lost_baskets/guests/campaign_3';
26
+
27
+
28
+ /**
29
+ * number of lost baskets available.
30
+ * @var array
31
+ */
32
+ public $lostBasketCustomers = array(1, 2, 3);
33
+ /**
34
+ * number of guest lost baskets available.
35
+ * @var array
36
+ */
37
+ public $lostBasketGuests = array(1, 2, 3);
38
+
39
+
40
+ /**
41
+ * Proccess lost baskets.
42
+ */
43
+ public function proccessLostBaskets()
44
+ {
45
+ /**
46
+ * Save lost baskets to be send in Send table.
47
+ */
48
+ foreach (Mage::app()->getStores() as $store) {
49
+ $storeId = $store->getId();
50
+ $sendModel = Mage::getModel('email_connector/campaign');
51
+ /**
52
+ * Customers campaings
53
+ */
54
+ foreach ($this->lostBasketCustomers as $num) {
55
+ if ($this->_getLostBasketCustomerEnabled($num, $storeId)) {
56
+
57
+ if ($num == 1)
58
+ $from = Zend_Date::now()->subMinute($this->_getLostBasketCustomerInterval($num, $storeId));
59
+ else
60
+ $from = Zend_Date::now()->subHour($this->_getLostBasketCustomerInterval($num, $storeId));
61
+ $to = clone($from);
62
+ $from->sub('5', Zend_Date::MINUTE);
63
+ $quoteCollection = $this->_getStoreQuotes($from->toString('YYYY-MM-dd HH:mm'), $to->toString('YYYY-MM-dd HH:mm'), $guest = false, $storeId);
64
+ if ($quoteCollection->getSize())
65
+ Mage::helper('connector')->log('Customer lost baskets : ' . $num . ', from : ' . $from->toString('YYYY-MM-dd HH:mm') . ':' . $to->toString('YYYY-MM-dd HH:mm'));
66
+ $campaignId = $this->_getLostBasketCustomerCampaignId($num, $storeId);
67
+ foreach ($quoteCollection as $quote) {
68
+ //save lost basket for sending
69
+ $sendModel->loadByQuoteId($quote->getId(), $storeId)
70
+ ->setEmail($quote->getCustomerEmail())
71
+ ->setCustomerId($quote->getCustomerId())
72
+ ->setEventName('Lost Basket')
73
+ ->setCampaignId($campaignId)
74
+ ->setStoreId($storeId)
75
+ ->setIsSent(null)->save();
76
+ }
77
+ }
78
+
79
+ }
80
+ /**
81
+ * Guests campaigns
82
+ */
83
+ foreach ($this->lostBasketGuests as $num) {
84
+ if ($this->_getLostBasketGuestEnabled($num, $storeId)) {
85
+ if ($num == 1)
86
+ $from = Zend_Date::now()->subMinute($this->_getLostBasketGuestIterval($num, $storeId));
87
+ else
88
+ $from = Zend_Date::now()->subHour($this->_getLostBasketGuestIterval($num, $storeId));
89
+ $to = clone($from);
90
+ $from->sub('5', Zend_Date::MINUTE);
91
+ $quoteCollection = $this->_getStoreQuotes($from->toString('YYYY-MM-dd HH:mm'), $to->toString('YYYY-MM-dd HH:mm'), $guest = true, $storeId);
92
+ if ($quoteCollection->getSize())
93
+ Mage::helper('connector')->log('Guest lost baskets : ' . $num . ', from : ' . $from->toString('YYYY-MM-dd HH:mm') . ':' . $to->toString('YYYY-MM-dd HH:mm'));
94
+ $guestCampaignId = $this->_getLostBasketGuestCampaignId($num, $storeId);
95
+ foreach ($quoteCollection as $quote) {
96
+ //save lost basket for sending
97
+ $sendModel->loadByQuoteId($quote->getId(), $storeId)
98
+ ->setEmail($quote->getCustomerEmail())
99
+ ->setEventName('Lost Basket')
100
+ ->setCheckoutMethod('Guest')
101
+ ->setCampaignId($guestCampaignId)
102
+ ->setStoreId($storeId)
103
+ ->setIsSent(null)->save();
104
+ }
105
+ }
106
+ }
107
+
108
+ }
109
+ }
110
+
111
+ private function _getLostBasketCustomerCampaignId($num, $storeId)
112
+ {
113
+ $store = Mage::app()->getStore($storeId);
114
+ return $store->getConfig(constant('self::XML_PATH_LOSTBASKET_CUSTOMER_CAMPAIGN_' . $num));
115
+ }
116
+ private function _getLostBasketGuestCampaignId($num, $storeId)
117
+ {
118
+ $store = Mage::app()->getStore($storeId);
119
+ return $store->getConfig(constant('self::XML_PATH_LOSTBASKET_GUEST_CAMPAIGN_'. $num));
120
+ }
121
+
122
+ private function _getLostBasketCustomerInterval($num, $storeId)
123
+ {
124
+ $store = Mage::app()->getstore($storeId);
125
+ return $store->getConfig(constant('self::XML_PATH_LOSTBASKET_CUSTOMER_INTERVAL_' . $num));
126
+ }
127
+
128
+ private function _getLostBasketGuestIterval($num, $storeId)
129
+ {
130
+ $store = Mage::app()->getStore($storeId);
131
+ return $store->getConfig(constant('self::XML_PATH_LOSTBASKET_GUEST_INTERVAL_' . $num));
132
+ }
133
+
134
+ protected function _getLostBasketCustomerEnabled($num, $storeId)
135
+ {
136
+ $store = Mage::app()->getStore($storeId);
137
+ $enabled = $store->getConfig(constant('self::XML_PATH_LOSTBASKET_CUSTOMER_ENABLED_' . $num));
138
+ return $enabled;
139
+
140
+ }
141
+
142
+ protected function _getLostBasketGuestEnabled($num, $storeId)
143
+ {
144
+ $store = Mage::app()->getStore($storeId);
145
+ return $store->getConfig(constant('self::XML_PATH_LOSTBASKET_GUEST_ENABLED_' . $num));
146
+ }
147
+
148
+ /**
149
+ * @param string $from
150
+ * @param string $to
151
+ * @param bool $guest
152
+ * @param int $storeId
153
+ * @return Mage_Eav_Model_Entity_Collection_Abstract
154
+ */
155
+ private function _getStoreQuotes($from = null, $to = null, $guest = false, $storeId = 0)
156
+ {
157
+
158
+ $updated = array(
159
+ 'from' => $from,
160
+ 'to' => $to,
161
+ 'date' => true);
162
+
163
+ $salesCollection = Mage::getResourceModel('sales/quote_collection')
164
+ ->addFieldToFilter('is_active', 1)
165
+ ->addFieldToFilter('items_count', array('gt' => 0))
166
+ ->addFieldToFilter('customer_email', array('neq' => ''))
167
+ ->addFieldToFilter('store_id', $storeId)
168
+ ->addFieldToFilter('updated_at', $updated);
169
+ if ($guest)
170
+ $salesCollection->addFieldToFilter('checkout_method' , Mage_Checkout_Model_Type_Onepage::METHOD_GUEST);
171
+ return $salesCollection;
172
+ }
173
+ }
app/code/community/Dotdigitalgroup/Email/Model/Sms/Campaign.php ADDED
@@ -0,0 +1,113 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dotdigitalgroup_Email_Model_Sms_Campaign
4
+ {
5
+ const UK_TELEPHONE_PATTERN = '/^(\+44\s?7\d{3}|\(?07\d{3}\)?)\s?\d{3}\s?\d{3}$/';
6
+
7
+ /**
8
+ * @var int
9
+ */
10
+ private $_storeId;
11
+ /**
12
+ * @var string
13
+ */
14
+ private $_status;
15
+ /**
16
+ * @var string
17
+ */
18
+ private $_customerFirstName;
19
+ /**
20
+ * @var string
21
+ */
22
+ private $_customerTelephone;
23
+
24
+ /**
25
+ * @var int
26
+ */
27
+ private $_incrementId;
28
+
29
+ /**
30
+ * @var array
31
+ */
32
+ private $_allsms = array(1, 2, 3, 4);
33
+ /**
34
+ * filter for the variables
35
+ * @var array
36
+ */
37
+ private $_vars = array('/customer_name/', '/order_number/', '/{{var /', '/}}/');
38
+
39
+
40
+ /**
41
+ * constructor.
42
+ *
43
+ * @param $order
44
+ */
45
+ public function __construct($order)
46
+ {
47
+ $this->_storeId = $order->getStoreId();
48
+ $billingAddress = $order->getBillingAddress();
49
+ $this->_customerFirstName = $order->getCustomerFirstname();
50
+ $this->_incrementId = $order->getIncrementId();
51
+ $this->_customerTelephone = $billingAddress->getTelephone();
52
+ Mage::app()->setCurrentStore($this->_storeId);
53
+ }
54
+ /**
55
+ * @return mixed
56
+ */
57
+ public function getStatus()
58
+ {
59
+ return $this->_status;
60
+ }
61
+
62
+ /**
63
+ * @param mixed $status
64
+ */
65
+ public function setStatus($status)
66
+ {
67
+ $this->_status = $status;
68
+ }
69
+
70
+ public function sendSms()
71
+ {
72
+ $website = Mage::app()->getStore($this->_storeId)->getWebsite();
73
+ $client = Mage::helper('connector')->getWebsiteApiClient($website);
74
+ //all available sms in config
75
+ foreach ($this->_allsms as $num) {
76
+
77
+ $enabled = (bool)Mage::getStoreConfig(constant('Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_SMS_ENABLED_' . $num));
78
+ if ($enabled) {
79
+ $status = Mage::getStoreConfig(constant('Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_SMS_STATUS_' . $num));
80
+ $message = $this->_processMessage(Mage::getStoreConfig(constant('Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_SMS_MESSAGE_' . $num)));
81
+ $match = preg_match(self::UK_TELEPHONE_PATTERN, $this->_customerTelephone);
82
+ if ($match != false) {
83
+ $codePhone = preg_replace('/\A(0){1}+/', '+44', $this->_customerTelephone);
84
+ //status and telephone valid
85
+ if ($this->_status == $status) {
86
+ Mage::helper('connector')->log('sending sms message with status : ' . $status . ' and ' . $codePhone);
87
+ $client->postSmsMessagesSendTo($codePhone, $message);
88
+ }
89
+ } else {
90
+ Mage::helper('connector')->log('SMS: phone not valid for UK : ' . $this->_customerTelephone);
91
+ }
92
+ }
93
+ }
94
+ }
95
+
96
+ /**
97
+ * @param $message
98
+ * @return mixed
99
+ */
100
+ protected function _processMessage($message)
101
+ {
102
+ $replacemant = array();
103
+ if (preg_match('/{{var/', $message)) {
104
+ $replacemant[] = $this->_customerFirstName;
105
+ $replacemant[] = $this->_incrementId;
106
+ $replacemant[] = '';
107
+ $replacemant[] = '';
108
+ $message = preg_replace($this->_vars, $replacemant, $message);
109
+ }
110
+ return substr($message, 0, 160);
111
+ }
112
+
113
+ }
app/code/community/Dotdigitalgroup/Email/Model/Sweettooth/Observer.php ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dotdigitalgroup_Email_Model_Sweettooth_Observer
4
+ {
5
+
6
+ public function ConnectorRewardsPointsIndexerUpdate($observer)
7
+ {
8
+ $customer = $observer->getEvent()->getCustomer();
9
+ if (!$customer)
10
+ return $this;
11
+
12
+ $helper = Mage::helper('connector');
13
+ $website = Mage::app()->getWebsite($customer->getWebsiteId());
14
+
15
+ if($helper->isSweetToothToGo($website))
16
+ $helper->setConnectorContactToReImport($customer->getId());
17
+
18
+ return $this;
19
+ }
20
+
21
+ }
app/code/community/Dotdigitalgroup/Email/controllers/Adminhtml/ConnectorController.php ADDED
@@ -0,0 +1,160 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dotdigitalgroup_Email_Adminhtml_ConnectorController extends Mage_Adminhtml_Controller_Action
4
+ {
5
+ /**
6
+ * AutoCreate and map datafields.
7
+ */
8
+ public function setupdatafieldsAction()
9
+ {
10
+ $result = array('errors' => false, 'message' => '');
11
+ $websiteParam = $this->getRequest()->getParam('website', 0);
12
+ $website = Mage::app()->getWebsite($websiteParam);
13
+ $apiModel = Mage::helper('connector')->getWebsiteApiClient($website->getId());
14
+ $redirectUrl = Mage::helper('adminhtml')->getUrl('adminhtml/system_config/edit', array('section' => 'connector_data_mapping'));
15
+
16
+ // get all possible datatifileds
17
+ $datafields = Mage::getModel('email_connector/connector_datafield')->getContactDatafields();
18
+ foreach ($datafields as $key => $datafield) {
19
+ $response = $apiModel->postDataFields($datafield);
20
+
21
+ //ignore existing datafields message
22
+ if (isset($response->message) && $response->message != Dotdigitalgroup_Email_Model_Apiconnector_Client::REST_API_DATAFILEDS_EXISTS) {
23
+ $result['errors'] = true;
24
+ $result['message'] .= ' Datafield ' . $datafield['name'] . ' - '. $response->message . '</br>';
25
+ } else {
26
+ if ($websiteParam) {
27
+ $scope = 'websites';
28
+ $scopeId = $website->getId();
29
+ } else {
30
+ $scope = 'default';
31
+ $scopeId = '0';
32
+ }
33
+ /**
34
+ * map the succesful created datafield
35
+ */
36
+ $config = new Mage_Core_Model_Config();
37
+ $config->saveConfig('connector_data_mapping/customer_data/' . $key, strtoupper($datafield['name']), $scope, $scopeId);
38
+ Mage::helper('connector')->log('successfully connected : ' . $datafield['name']);
39
+ }
40
+ }
41
+ if ($result['errors']) {
42
+ Mage::getSingleton('adminhtml/session')->addNotice($result['message']);
43
+ } else {
44
+ Mage::getConfig()->cleanCache();
45
+ Mage::getSingleton('adminhtml/session')->addSuccess('All Datafields Created And Mapped.');
46
+ }
47
+
48
+ $this->_redirectUrl($redirectUrl);
49
+ }
50
+
51
+ /**
52
+ * Reset order for reimport.
53
+ */
54
+ public function resetordersAction()
55
+ {
56
+ /** @var $coreResource Mage_Core_Model_Resource */
57
+ $coreResource = Mage::getSingleton('core/resource');
58
+
59
+ /** @var $conn Varien_Db_Adapter_Pdo_Mysql */
60
+ $conn = $coreResource->getConnection('core_write');
61
+ try{
62
+ $num = $conn->update($coreResource->getTableName('email_connector/order'),
63
+ array('email_imported' => new Zend_Db_Expr('null')),
64
+ $conn->quoteInto('email_imported is ?', new Zend_Db_Expr('not null'))
65
+ );
66
+ }catch (Exception $e){
67
+ Mage::logException($e);
68
+ }
69
+ Mage::helper('connector')->log('-- Reset Orders for reimport : ' . $num);
70
+ Mage::getSingleton('adminhtml/session')->addSuccess('Done.');
71
+ $this->_redirectReferer();
72
+ }
73
+
74
+ /**
75
+ * Refresh suppressed contacts.
76
+ */
77
+ public function suppresscontactsAction()
78
+ {
79
+ Mage::getModel('email_connector/newsletter_subscriber')
80
+ ->unsubscribe(true);
81
+ Mage::getSingleton('adminhtml/session')->addSuccess('Done.');
82
+ $this->_redirectReferer();
83
+
84
+ }
85
+ /**
86
+ * Remove contact id's.
87
+ */
88
+ public function deletecontactidsAction()
89
+ {
90
+ /** @var $coreResource Mage_Core_Model_Resource */
91
+ $coreResource = Mage::getSingleton('core/resource');
92
+
93
+ /** @var $conn Varien_Db_Adapter_Pdo_Mysql */
94
+ $conn = $coreResource->getConnection('core_write');
95
+ try{
96
+ $num = $conn->update($coreResource->getTableName('email_connector/contact'),
97
+ array('contact_id' => new Zend_Db_Expr('null')),
98
+ $conn->quoteInto('contact_id is ?', new Zend_Db_Expr('not null'))
99
+ );
100
+ }catch (Exception $e){
101
+ Mage::logException($e);
102
+ }
103
+ Mage::getSingleton('adminhtml/session')->addSuccess('Number Of Contacts Id Removed: '. $num);
104
+ $this->_redirectReferer();
105
+ }
106
+ public function ajaxvalidationAction()
107
+ {
108
+ $params = $this->getRequest()->getParams();
109
+ $apiUsername = $params['api_username'];
110
+ // use javascript btoa function to encode the password
111
+
112
+ $apiPassword = base64_decode($params['api_password']);
113
+ $message = Mage::getModel('email_connector/apiconnector_test')->ajaxvalidate($apiUsername, $apiPassword);
114
+ $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($message));
115
+ }
116
+
117
+ public function createnewdatafieldAction()
118
+ {
119
+ $params = $this->getRequest()->getParams();
120
+ $website = $this->getRequest()->getParam('website', 0);
121
+ $client = Mage::helper('connector')->getWebsiteApiClient($website);
122
+ if (strlen($params['name'])) {
123
+ $response = $client->postDataFields($params['name'], $params['type']);
124
+ if (isset($response->message)) {
125
+ Mage::getSingleton('adminhtml/session')->addError($response->message);
126
+ Mage::helper('connector')->log($response->message);
127
+ } else {
128
+ Mage::getSingleton('adminhtml/session')->addSuccess('Datafield created : ' . $params['name']);
129
+ }
130
+ } else {
131
+ Mage::getSingleton('adminhtml/session')->addError('Datafield cannot be empty.');
132
+ }
133
+ }
134
+
135
+ public function createnewaddressbookAction()
136
+ {
137
+ $addressBookName = $this->getRequest()->getParam('name');
138
+ $website = $this->getRequest()->getParam('website', 0);
139
+ $client = Mage::helper('connector')->getWebsiteApiClient($website);
140
+ if (strlen($addressBookName)) {
141
+ $response = $client->PostAddressBooks($addressBookName);
142
+ if(isset($response->message))
143
+ Mage::getSingleton('adminhtml/session')->addError($response->message);
144
+ else
145
+ Mage::getSingleton('adminhtml/session')->addSuccess('Address book : '. $addressBookName . ' created.');
146
+ }
147
+
148
+ }
149
+
150
+ public function reimoprtsubscribersAction()
151
+ {
152
+ $updated = Mage::getModel('email_connector/contact')->resetSubscribers();
153
+ if ($updated) {
154
+ Mage::getSingleton('adminhtml/session')->addSuccess('Subscribers updated : ' . $updated);
155
+ } else {
156
+ Mage::getSingleton('adminhtml/session')->addNotice('No subscribers imported!');
157
+ }
158
+ $this->_redirectReferer();
159
+ }
160
+ }
app/code/community/Dotdigitalgroup/Email/controllers/Adminhtml/Email/AutomationController.php ADDED
@@ -0,0 +1,109 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dotdigitalgroup_Email_Adminhtml_Email_AutomationController extends Mage_Adminhtml_Controller_Action
4
+ {
5
+ /**
6
+ * Main page for automation studio. Must be authinticated.
7
+ */
8
+ public function indexAction()
9
+ {
10
+
11
+ $this->_title($this->__('Automation Studio'));
12
+ $this->loadLayout();
13
+ $this->_setActiveMenu('email_connector');
14
+
15
+ // authorize or create token.
16
+ $token = $this->generatetokenAction();
17
+ $loginuserUrl = Dotdigitalgroup_Email_Helper_Config::API_CONNECTOR_URL_LOG_USER . $token;
18
+
19
+ $block = $this->getLayout()
20
+ ->createBlock('core/text', 'connector_iframe')
21
+ ->setText(
22
+ "<iframe src=" . $loginuserUrl . " width=100% height=1400 frameborder='0' scrolling='no' style='margin:0;padding: 0;display:block;'></iframe>"
23
+ );
24
+
25
+ $this->_addContent($block);
26
+ $this->renderLayout();
27
+ }
28
+
29
+ protected function _isAllowed()
30
+ {
31
+ return Mage::getSingleton('admin/session')->isAllowed('email_connector/automation_studio');
32
+ }
33
+
34
+ /**
35
+ * Generate new token and connect from the admin.
36
+ *
37
+ * POST httpsː//my.dotmailer.com/OAuth2/Tokens.ashx HTTP/1.1
38
+ * Content-Type: application/x-www-form-urlencoded
39
+ * client_id=QVNY867m2DQozogTJfUmqA%253D%253D&
40
+ * redirect_uri=https%3a%2f%2flocalhost%3a10999%2fcallback.aspx
41
+ * &client_secret=SndpTndiSlhRawAAAAAAAA%253D%253D
42
+ * &grant_type=authorization_code
43
+ */
44
+ public function generatetokenAction()
45
+ {
46
+ //check for secure url
47
+ $adminUser = Mage::getSingleton('admin/session')->getUser();
48
+ $refreshToken = Mage::getSingleton('admin/user')->load($adminUser->getId())->getRefreshToken();
49
+
50
+ if ($refreshToken) {
51
+ $code = Mage::helper('connector')->getCode();
52
+ $params = 'client_id=' . Mage::getStoreConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CLIENT_ID) .
53
+ '&client_secret=' . Mage::getStoreConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CLIENT_SECRET_ID) .
54
+ '&refresh_token=' . $refreshToken .
55
+ '&grant_type=refresh_token';
56
+
57
+ $url = Dotdigitalgroup_Email_Helper_Config::API_CONNECTOR_URL_TOKEN;
58
+ Mage::helper('connector')->log('token url : ' . $url . ' code : ' . $code);
59
+
60
+ /**
61
+ * Refresh Token request.
62
+ */
63
+ $ch = curl_init();
64
+ curl_setopt($ch, CURLOPT_URL, $url);
65
+ curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
66
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
67
+ curl_setopt($ch, CURLOPT_TIMEOUT, 5);
68
+ curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
69
+ curl_setopt($ch, CURLOPT_POST, count($params));
70
+ curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
71
+ curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/x-www-form-urlencoded'));
72
+
73
+ $response = json_decode(curl_exec($ch));
74
+
75
+ if (isset($response->error)) {
76
+ Mage::helper('connector')->log("Token Error Num`ber:" . curl_errno($ch) . "Error String:" . curl_error($ch));
77
+ }
78
+ curl_close($ch);
79
+
80
+ $token = $response->access_token;
81
+ return $token;
82
+
83
+ } else {
84
+ Mage::getSingleton('adminhtml/session')->addNotice('Please Connect To Access The Page.');
85
+ }
86
+
87
+ $this->_redirect('*/system_config/edit', array('section' => 'connector_api_credentials'));
88
+ }
89
+
90
+ /**
91
+ * Disconnect and remote the refresh token.
92
+ */
93
+ public function disconnectAction()
94
+ {
95
+ try {
96
+ $adminUser = Mage::getSingleton('admin/session')->getUser();
97
+
98
+ if ($adminUser->getRefreshToken()) {
99
+ $adminUser->setRefreshToken()->save();
100
+ }
101
+ Mage::getSingleton('adminhtml/session')->addSuccess('Successfully disconnected');
102
+ }catch (Exception $e){
103
+ Mage::logException($e);
104
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
105
+ }
106
+
107
+ $this->_redirectReferer('*/*/*');
108
+ }
109
+ }
app/code/community/Dotdigitalgroup/Email/controllers/Adminhtml/Email/CampaignController.php ADDED
@@ -0,0 +1,218 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dotdigitalgroup_Email_Adminhtml_Email_CampaignController extends Mage_Adminhtml_Controller_Action
4
+ {
5
+ /**
6
+ * constructor - set the used module name
7
+ */
8
+ protected function _construct()
9
+ {
10
+ $this->setUsedModuleName('Dotdigitalgroup_Email');
11
+ }
12
+
13
+ /**
14
+ * Email campaigns.
15
+ */
16
+ public function indexAction()
17
+ {
18
+ $this->_title($this->__('Email'))
19
+ ->_title($this->__('Manage Campaigns'));
20
+ $this->loadLayout();
21
+ $this->_setActiveMenu('email_connector');
22
+ $this->renderLayout();
23
+ }
24
+
25
+ /**
26
+ * New campaings.
27
+ */
28
+ public function newAction()
29
+ {
30
+ // We just forward the new action to a blank edit form
31
+ $this->_forward('edit');
32
+ }
33
+
34
+
35
+ /**
36
+ * Edit campign.
37
+ */
38
+ public function editAction()
39
+ {
40
+ $contactId = (int) $this->getRequest()->getParam('id');
41
+ $contact = $this->_initAction();
42
+ if ($contactId && !$contact->getId()) {
43
+ $this->_getSession()->addError(Mage::helper('connector')->__('This campaign no longer exists.'));
44
+ $this->_redirect('*/*/');
45
+ return;
46
+ }
47
+ if ($data = Mage::getSingleton('adminhtml/session')->getCampaignData(true)) {
48
+ $contact->setData($data);
49
+ }
50
+ Mage::dispatchEvent('email_campaign_controller_edit_action', array('contact' => $contact));
51
+ $this->loadLayout();
52
+ if ($contact->getId()) {
53
+ if (!Mage::app()->isSingleStoreMode() && ($switchBlock = $this->getLayout()->getBlock('store_switcher'))) {
54
+ $switchBlock->setDefaultStoreName(Mage::helper('connector')->__('Default Values'))
55
+ ->setSwitchUrl($this->getUrl('*/*/*', array('_current'=>true, 'active_tab'=>null, 'tab' => null, 'store'=>null)));
56
+ }
57
+ } else {
58
+ $this->getLayout()->getBlock('left')->unsetChild('store_switcher');
59
+ }
60
+ $this->getLayout()->getBlock('head')->setCanLoadExtJs(true);
61
+ $this->renderLayout();
62
+ }
63
+
64
+ /**
65
+ * Save campaign.
66
+ */
67
+ public function saveAction()
68
+ {
69
+ $storeId = $this->getRequest()->getParam('store');
70
+ $redirectBack = $this->getRequest()->getParam('back', false);
71
+ $contactId = $this->getRequest()->getParam('id');
72
+ $data = $this->getRequest()->getPost();
73
+ if ($data) {
74
+ $campaign = $this->_initAction();
75
+
76
+ $campaignData = $this->getRequest()->getPost('campaign', array());
77
+ $campaign->addData($campaignData);
78
+
79
+ try {
80
+ $campaign->save();
81
+ $this->_getSession()->addSuccess(Mage::helper('connector')->__('Campaign was saved.'));
82
+ }catch (Mage_Core_Exception $e) {
83
+ Mage::logException($e);
84
+ $this->_getSession()->addError($e->getMessage())
85
+ ->setContactData($campaignData);
86
+ $redirectBack = true;
87
+ }catch (Exception $e){
88
+ Mage::logException($e);
89
+ $this->_getSession()->addError(Mage::helper('connector')->__('Error saving campaign'))
90
+ ->setContactData($campaignData);
91
+ $redirectBack = true;
92
+ }
93
+ }
94
+ if ($redirectBack) {
95
+ $this->_redirect('*/*/edit', array(
96
+ 'id' => $contactId,
97
+ '_current'=>true
98
+ ));
99
+ } else {
100
+ $this->_redirect('*/*/', array('store'=>$storeId));
101
+ }
102
+ }
103
+
104
+ /**
105
+ * Delete campaign.
106
+ */
107
+ public function deleteAction()
108
+ {
109
+ if ($id = $this->getRequest()->getParam('id')) {
110
+ $campaign = Mage::getModel('email_connector/campaign')->load($id);
111
+ try {
112
+ $campaign->delete();
113
+ $this->_getSession()->addSuccess(Mage::helper('connector')->__('The campaign has been deleted.'));
114
+ }
115
+ catch (Exception $e) {
116
+ $this->_getSession()->addError($e->getMessage());
117
+ }
118
+ }
119
+ $this->getResponse()->setRedirect($this->getUrl('*/*/', array('store'=>$this->getRequest()->getParam('store'))));
120
+ }
121
+
122
+ /**
123
+ * Delete mass campaigns.
124
+ */
125
+ public function massDeleteAction()
126
+ {
127
+ $campaignIds = $this->getRequest()->getParam('campaign');
128
+ if (!is_array($campaignIds)) {
129
+ $this->_getSession()->addError($this->__('Please select campaigns.'));
130
+ } else {
131
+ try {
132
+ foreach ($campaignIds as $campaignId) {
133
+ $campaign = Mage::getSingleton('email_connector/campaign')->load($campaignId);
134
+ Mage::dispatchEvent('connector_controller_campaign_delete', array('campaign' => $campaign));
135
+ $campaign->delete();
136
+ }
137
+ $this->_getSession()->addSuccess(
138
+ Mage::helper('connector')->__('Total of %d record(s) have been deleted.', count($campaignIds))
139
+ );
140
+ } catch (Exception $e) {
141
+ $this->_getSession()->addError($e->getMessage());
142
+ }
143
+ }
144
+ $this->_redirect('*/*/index');
145
+ }
146
+
147
+ /**
148
+ * Mass mark for resend campaings.
149
+ */
150
+ public function massResendAction()
151
+ {
152
+ $campaignIds = $this->getRequest()->getParam('campaign');
153
+ if (!is_array($campaignIds)) {
154
+ $this->_getSession()->addError($this->__('Please select campaigns.'));
155
+ } else {
156
+ try {
157
+ foreach ($campaignIds as $campaignId) {
158
+ $campaign = Mage::getSingleton('email_connector/campaign')->load($campaignId);
159
+ Mage::dispatchEvent('connector_controller_campaign_delete', array('campaign' => $campaign));
160
+ $campaign->setIsSent(null)->save();
161
+ }
162
+ $this->_getSession()->addSuccess(
163
+ Mage::helper('connector')->__('Total of %d record(s) have resend .', count($campaignIds))
164
+ );
165
+ } catch (Exception $e) {
166
+ $this->_getSession()->addError($e->getMessage());
167
+ }
168
+ }
169
+ $this->_redirect('*/*/index');
170
+ }
171
+
172
+
173
+ /**
174
+ * main page.
175
+ */
176
+ public function gridAction()
177
+ {
178
+ $this->loadLayout();
179
+ $this->renderLayout();
180
+ }
181
+
182
+ /**
183
+ * manage the campaigns.
184
+ *
185
+ * @return Dotdigitalgroup_Email_Model_Campaign
186
+ */
187
+ protected function _initAction()
188
+ {
189
+ $this->_title($this->__('Newsletter'))
190
+ ->_title($this->__('Manage Campaigns'));
191
+
192
+ $campaignId = (int) $this->getRequest()->getParam('id');
193
+ $campaign = Mage::getModel('email_connector/campaign');
194
+
195
+ if ($campaignId) {
196
+ $campaign->load($campaignId);
197
+ }
198
+ Mage::register('email_campaign', $campaign);
199
+ return $campaign;
200
+ }
201
+
202
+ /**
203
+ * Export campaigns to CSV file.
204
+ */
205
+ public function exportCsvAction()
206
+ {
207
+ $fileName = 'campaign.csv';
208
+ $content = $this->getLayout()->createBlock('email_connector/adminhtml_campaign_grid')
209
+ ->getCsvFile();
210
+ $this->_prepareDownloadResponse($fileName, $content);
211
+ }
212
+
213
+ protected function _isAllowed()
214
+ {
215
+ return Mage::getSingleton('admin/session')->isAllowed('newsletter/email_connetor/email_connector_campaign');
216
+ }
217
+
218
+ }
app/code/community/Dotdigitalgroup/Email/controllers/Adminhtml/Email/ContactController.php ADDED
@@ -0,0 +1,192 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dotdigitalgroup_Email_Adminhtml_Email_ContactController extends Mage_Adminhtml_Controller_Action
4
+ {
5
+ /**
6
+ * constructor - set the used module name
7
+ */
8
+ protected function _construct(){
9
+ $this->setUsedModuleName('Dotdigitalgroup_Email');
10
+ }
11
+
12
+ /**
13
+ * main page.
14
+ */
15
+ public function indexAction()
16
+ {
17
+ $this->_title($this->__('Email'))
18
+ ->_title($this->__('Manage Contacts'));
19
+ $this->loadLayout();
20
+ $this->_setActiveMenu('email_connector');
21
+ $this->renderLayout();
22
+ }
23
+
24
+ /**
25
+ * Edit contact.
26
+ */
27
+ public function editAction()
28
+ {
29
+ $contactId = (int) $this->getRequest()->getParam('id');
30
+ $contact = $this->_initAction();
31
+ if ($contactId && !$contact->getId()) {
32
+ $this->_getSession()->addError(Mage::helper('connector')->__('This contact no longer exists.'));
33
+ $this->_redirect('*/*/');
34
+ return;
35
+ }
36
+ $contactEmail = Mage::getModel('email_connector/apiconnector_contact')->syncContact();
37
+ if ($contactEmail)
38
+ Mage::getSingleton('adminhtml/session')->addSuccess('Successfully synced : ' . $contactEmail);
39
+
40
+ Mage::dispatchEvent('email_contact_controller_edit_action', array('contact' => $contact));
41
+
42
+ $this->_redirect('*/*');
43
+ }
44
+
45
+ /**
46
+ * Save contact.
47
+ */
48
+ public function saveAction(){
49
+ $storeId = $this->getRequest()->getParam('store');
50
+ $redirectBack = $this->getRequest()->getParam('back', false);
51
+ $contactId = $this->getRequest()->getParam('id');
52
+
53
+ $data = $this->getRequest()->getPost();
54
+ if ($data) {
55
+ $contact = $this->_initAction();
56
+
57
+ $contactData = $this->getRequest()->getPost('contact', array());
58
+ $contact->addData($contactData);
59
+
60
+ try {
61
+ $contact->save();
62
+ $contactId = $contact->getId();
63
+ $this->_getSession()->addSuccess(Mage::helper('connector')->__('Contact was saved.'));
64
+ }catch (Mage_Core_Exception $e) {
65
+ Mage::logException($e);
66
+ $this->_getSession()->addError($e->getMessage())
67
+ ->setContactData($contactData);
68
+ $redirectBack = true;
69
+ }catch (Exception $e){
70
+ Mage::logException($e);
71
+ $this->_getSession()->addError(Mage::helper('connector')->__('Error saving contact'))
72
+ ->setContactData($contactData);
73
+ $redirectBack = true;
74
+ }
75
+ }
76
+ if ($redirectBack) {
77
+ $this->_redirect('*/*/edit', array(
78
+ 'id' => $contactId,
79
+ '_current'=>true
80
+ ));
81
+ } else {
82
+ $this->_redirect('*/*/', array('store'=>$storeId));
83
+ }
84
+ }
85
+
86
+ /**
87
+ * Delete a contact.
88
+ */
89
+ public function deleteAction()
90
+ {
91
+ if ($id = $this->getRequest()->getParam('id')) {
92
+ $contact = Mage::getModel('email_connector/contact')->load($id);
93
+ try {
94
+ $contact->delete();
95
+ $this->_getSession()->addSuccess(Mage::helper('connector')->__('The contact has been deleted.'));
96
+ }
97
+ catch (Exception $e) {
98
+ $this->_getSession()->addError($e->getMessage());
99
+ }
100
+ }
101
+ $this->getResponse()->setRedirect($this->getUrl('*/*/', array('store'=>$this->getRequest()->getParam('store'))));
102
+ }
103
+
104
+ /**
105
+ * Mass delete contacts.
106
+ */
107
+ public function massDeleteAction()
108
+ {
109
+ $contactIds = $this->getRequest()->getParam('contact');
110
+ if (!is_array($contactIds)) {
111
+ $this->_getSession()->addError($this->__('Please select contacts.'));
112
+ }else {
113
+ try {
114
+ foreach ($contactIds as $contactId) {
115
+ $contact = Mage::getSingleton('email_connector/contact')->load($contactId);
116
+ Mage::dispatchEvent('connector_controller_affiliate_delete', array('contact' => $contact));
117
+ $contact->delete();
118
+ }
119
+ $this->_getSession()->addSuccess(
120
+ Mage::helper('connector')->__('Total of %d record(s) have been deleted.', count($contactIds))
121
+ );
122
+ } catch (Exception $e) {
123
+ $this->_getSession()->addError($e->getMessage());
124
+ }
125
+ }
126
+ $this->_redirect('*/*/index');
127
+ }
128
+
129
+ /**
130
+ * Mark a contact to be resend.
131
+ */
132
+ public function massResendAction()
133
+ {
134
+ $contactIds = $this->getRequest()->getParam('contact');
135
+
136
+ if (!is_array($contactIds)) {
137
+ $this->_getSession()->addError($this->__('Please select contacts.'));
138
+ }else {
139
+ try {
140
+ foreach ($contactIds as $contactId) {
141
+ $contact = Mage::getSingleton('email_connector/contact')->load($contactId);
142
+ $contact->setEmailImported(null)->save();
143
+ }
144
+ $this->_getSession()->addSuccess(
145
+ Mage::helper('connector')->__('Total of %d record(s) set for resend.', count($contactIds))
146
+ );
147
+ } catch (Exception $e) {
148
+ $this->_getSession()->addError($e->getMessage());
149
+ }
150
+ }
151
+ $this->_redirect('*/*/index');
152
+ }
153
+
154
+
155
+ /**
156
+ * main grid.
157
+ */
158
+ public function gridAction(){
159
+ $this->loadLayout();
160
+ $this->renderLayout();
161
+ }
162
+
163
+ protected function _initAction()
164
+ {
165
+ $this->_title($this->__('Newsletter'))
166
+ ->_title($this->__('Manage Contacts'));
167
+
168
+ $contactId = (int) $this->getRequest()->getParam('id');
169
+ $contact = Mage::getModel('email_connector/contact')
170
+ ->setStoreId($this->getRequest()->getParam('store', 0));
171
+
172
+ if ($contactId) {
173
+ $contact->load($contactId);
174
+ }
175
+ Mage::register('current_contact', $contact);
176
+ return $contact;
177
+ }
178
+
179
+ public function exportCsvAction()
180
+ {
181
+ $fileName = 'contacts.csv';
182
+ $content = $this->getLayout()->createBlock('email_connector/adminhtml_contact_grid')
183
+ ->getCsvFile();
184
+ $this->_prepareDownloadResponse($fileName, $content);
185
+ }
186
+
187
+ protected function _isAllowed()
188
+ {
189
+ return Mage::getSingleton('admin/session')->isAllowed('newsletter/email_connector/email_connector_contact');
190
+ }
191
+
192
+ }
app/code/community/Dotdigitalgroup/Email/controllers/Adminhtml/Email/DashboardController.php ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dotdigitalgroup_Email_Adminhtml_Email_DashboardController extends Mage_Adminhtml_Controller_Action
4
+ {
5
+ /**
6
+ * main page.
7
+ */
8
+ public function indexAction()
9
+ {
10
+ $this->_title($this->__('Dashboard'));
11
+
12
+ $this->loadLayout();
13
+ $this->_setActiveMenu('email_connector');
14
+ $this->_addContent($this->getLayout()->createBlock('email_connector/adminhtml_dashboard'));
15
+ $this->renderLayout();
16
+ }
17
+ protected function _isAllowed()
18
+ {
19
+ return Mage::getSingleton('admin/session')->isAllowed('newsletter/email_connector/email_connector_dashboard');
20
+ }
21
+ }
app/code/community/Dotdigitalgroup/Email/controllers/Adminhtml/Email/OrderController.php ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dotdigitalgroup_Email_Adminhtml_Email_OrderController extends Mage_Adminhtml_Controller_Action
4
+ {
5
+ /**
6
+ * main page.
7
+ */
8
+ public function indexAction()
9
+ {
10
+ $this->loadLayout();
11
+ $this->_setActiveMenu('email_connector');
12
+ $this->_addContent($this->getLayout()->createBlock('email_connector/adminhtml_order'));
13
+ $this->getLayout()->getBlock('head')->setTitle('Connector Orders');
14
+ $this->renderLayout();
15
+ }
16
+
17
+ /**
18
+ * Check currently called action by permissions for current user
19
+ *
20
+ * @return bool
21
+ */
22
+ protected function _isAllowed()
23
+ {
24
+ return Mage::getSingleton('admin/session')->isAllowed('newsletter/email_connector/email_connector_order');
25
+ }
26
+ }
app/code/community/Dotdigitalgroup/Email/controllers/CreditmemoController.php ADDED
@@ -0,0 +1,91 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dotdigitalgroup_Email_CreditmemoController extends Mage_Core_Controller_Front_Action
4
+ {
5
+ /**
6
+ * predispatch
7
+ *
8
+ * @return Mage_Core_Controller_Front_Action|void
9
+ */
10
+ public function preDispatch()
11
+ {
12
+ Mage::helper('connector')->auth($this->getRequest()->getParam('code'));
13
+ $orderId = $this->getRequest()->getParam('order_id', false);
14
+ if ($orderId) {
15
+ $order = Mage::getModel('sales/order')->load($orderId);
16
+ if ($order->getId()) {
17
+ Mage::app()->setCurrentStore($order->getStoreId());
18
+ } else {
19
+ Mage::helper('connector')->log('TE : order not found: ' . $orderId);
20
+ exit;
21
+ }
22
+ } else {
23
+ Mage::helper('connector')->log('TE : order_id missing :' . $orderId);
24
+ exit;
25
+ }
26
+ parent::preDispatch();
27
+ }
28
+
29
+ /**
30
+ * New creditmemo.
31
+ */
32
+ public function newAction()
33
+ {
34
+ $this->loadLayout();
35
+ $newOrder = $this->getLayout()->createBlock('email_connector/order_creditmemo', 'connector_creditmemo_new', array(
36
+ 'template' => 'connector/creditmemo/new.phtml'
37
+ ));
38
+ $this->getLayout()->getBlock('content')->append($newOrder);
39
+ $items = $this->getLayout()->createBlock('email_connector/order_creditmemo', 'connector_creditmemo_items', array(
40
+ 'template' => 'connector/creditmemo/items.phtml'
41
+ ));
42
+ $this->getLayout()->getBlock('connector_creditmemo_new')->append($items);
43
+ $this->renderLayout();
44
+ }
45
+
46
+ /**
47
+ * New guest action.
48
+ */
49
+ public function newguestAction()
50
+ {
51
+ $this->loadLayout();
52
+ $invoice = $this->getLayout()->createBlock('email_connector/order_invoice', 'connector_creditmemo_guest', array(
53
+ 'template' => 'connector/creditmemo/newguest.phtml'
54
+ ));
55
+ $this->getLayout()->getBlock('content')->append($invoice);
56
+ $items = $this->getLayout()->createBlock('email_connector/order_creditmemo', 'connector_creditmemo_items', array(
57
+ 'template' => 'connector/creditmemo/items.phtml'
58
+ ));
59
+ $this->getLayout()->getBlock('connector_creditmemo_guest')->append($items);
60
+
61
+ $this->renderLayout();
62
+
63
+ }
64
+
65
+ /**
66
+ * update creditmemo.
67
+ */
68
+ public function updateAction()
69
+ {
70
+ $this->loadLayout();
71
+ $newOrder = $this->getLayout()->createBlock('email_connector/order_creditmemo', 'connector_creditmemo_update', array(
72
+ 'template' => 'connector/creditmemo/update.phtml'
73
+ ));
74
+ $this->getLayout()->getBlock('content')->append($newOrder);
75
+
76
+ $this->renderLayout();
77
+ }
78
+
79
+ /**
80
+ * update guest.
81
+ */
82
+ public function updateguestAction()
83
+ {
84
+ $this->loadLayout();
85
+ $newOrder = $this->getLayout()->createBlock('email_connector/order_creditmemo', 'connector_creditmemo_update_guest', array(
86
+ 'template' => 'connector/creditmemo/updateguest.phtml'
87
+ ));
88
+ $this->getLayout()->getBlock('content')->append($newOrder);
89
+ $this->renderLayout();
90
+ }
91
+ }
app/code/community/Dotdigitalgroup/Email/controllers/CustomerController.php ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dotdigitalgroup_Email_CustomerController extends Mage_Core_Controller_Front_Action
4
+ {
5
+ public function preDispatch()
6
+ {
7
+ Mage::helper('connector')->auth($this->getRequest()->getParam('code'));
8
+ parent::preDispatch();
9
+ }
10
+ public function newAction()
11
+ {
12
+ $this->loadLayout();
13
+ $newCustomer = $this->getLayout()->createBlock('email_connector/customer', 'connector_customer', array(
14
+ 'template' => 'connector/customer/new.phtml'
15
+ ));
16
+ $this->getLayout()->getBlock('content')->append($newCustomer);
17
+ $this->renderLayout();
18
+ }
19
+
20
+ public function confirmationAction()
21
+ {
22
+ $this->loadLayout();
23
+ $newCustomer = $this->getLayout()->createBlock('email_connector/customer', 'connector_customer_confirmation', array(
24
+ 'template' => 'connector/customer/confirmation.phtml'
25
+ ));
26
+ $this->getLayout()->getBlock('content')->append($newCustomer);
27
+ $this->renderLayout();
28
+ }
29
+ public function confirmedAction()
30
+ {
31
+ $this->loadLayout();
32
+ $newCustomer = $this->getLayout()->createBlock('email_connector/customer', 'connector_customer_confirmed', array(
33
+ 'template' => 'connector/customer/confirmed.phtml'
34
+ ));
35
+ $this->getLayout()->getBlock('content')->append($newCustomer);
36
+ $this->renderLayout();
37
+ }
38
+ }
app/code/community/Dotdigitalgroup/Email/controllers/EmailController.php ADDED
@@ -0,0 +1,111 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dotdigitalgroup_Email_EmailController extends Mage_Core_Controller_Front_Action
4
+ {
5
+ public function indexAction()
6
+ {
7
+ //Get current layout state
8
+ $this->loadLayout();
9
+ $this->renderLayout();
10
+ }
11
+
12
+ public function couponAction()
13
+ {
14
+ $this->loadLayout();
15
+ $this->renderLayout();
16
+ }
17
+ public function basketAction()
18
+ {
19
+ Mage::helper('connector')->auth($this->getRequest()->getParam('code'));
20
+ $this->loadLayout();
21
+ if ($root = $this->getLayout()->getBlock('root')) {
22
+ $root->setTemplate('page/blank.phtml');
23
+ }
24
+ $basket = $this->getLayout()->createBlock('email_connector/basket', 'connector_basket', array(
25
+ 'template' => 'connector/basket.phtml'
26
+ ));
27
+ $this->getLayout()->getBlock('content')->append($basket);
28
+ $this->renderLayout();
29
+ }
30
+
31
+ public function logAction()
32
+ {
33
+ //file name param
34
+ $fileName = $filePath = '';
35
+ $file = $this->getRequest()->getParam('file', false);
36
+ if ($file) {
37
+ $fileName = $file . '.log';
38
+ $filePath = Mage::getBaseDir( 'log' ) . DIRECTORY_SEPARATOR . $fileName;
39
+ } elseif ($csv = $this->getRequest()->getParam('archive', false)){
40
+ $fileName = $csv . '.csv';
41
+ $filePath = Mage::getBaseDir('export') . DIRECTORY_SEPARATOR . 'email' . DIRECTORY_SEPARATOR . 'archive' . DIRECTORY_SEPARATOR . $fileName;
42
+ }
43
+
44
+ $this->_prepareDownloadResponse($fileName, array(
45
+ 'type' => 'filename',
46
+ 'value' => $filePath
47
+ ));
48
+ exit();
49
+ }
50
+
51
+ public function showAction() {
52
+ $list = array();
53
+
54
+ if ($handle = opendir(Mage::getBaseDir('export') . DIRECTORY_SEPARATOR . 'email' . DIRECTORY_SEPARATOR . 'archive')) {
55
+
56
+
57
+ while (false !== ($entry = readdir($handle))) {
58
+
59
+ if ($entry != "." && $entry != "..") {
60
+
61
+ $list[] = $entry;
62
+ }
63
+ }
64
+
65
+ closedir($handle);
66
+ }
67
+
68
+ foreach ( $list as $one ) {
69
+
70
+ echo $one . '</br>';
71
+ }
72
+ return;
73
+ }
74
+
75
+ public function callbackAction()
76
+ {
77
+ $code = $this->getRequest()->getParam('code', false);
78
+ $userId = $this->getRequest()->getParam('state');
79
+ $adminUser = Mage::getModel('admin/user')->load($userId);
80
+ $baseUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB, true);
81
+ $callback = $baseUrl . 'connector/email/callback';
82
+
83
+ if ($code) {
84
+ $data = 'client_id=' . Mage::getStoreConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CLIENT_ID) .
85
+ '&client_secret=' . Mage::getStoreConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CLIENT_SECRET_ID) .
86
+ '&redirect_uri=' . $callback .
87
+ '&grant_type=authorization_code' .
88
+ '&code=' . $code;
89
+
90
+
91
+ $url = Dotdigitalgroup_Email_Helper_Config::API_CONNECTOR_URL_TOKEN;
92
+ $ch = curl_init();
93
+ curl_setopt($ch, CURLOPT_URL, $url);
94
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
95
+ curl_setopt($ch, CURLOPT_TIMEOUT, 10);
96
+ curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
97
+ curl_setopt($ch, CURLOPT_POST, count($data));
98
+ curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
99
+ curl_setopt($ch, CURLOPT_HTTPHEADER, array ('Content-Type: application/x-www-form-urlencoded'));
100
+
101
+
102
+ $response = json_decode(curl_exec($ch));
103
+ if ($response === false) {
104
+ Mage::helper('connector')->log("Error Number: " . curl_errno($ch));
105
+ }
106
+
107
+ $adminUser->setRefreshToken($response->refresh_token)->save();
108
+ }
109
+ $this->_redirectReferer(Mage::helper('adminhtml')->getUrl('adminhtml/email_automation/index'));
110
+ }
111
+ }
app/code/community/Dotdigitalgroup/Email/controllers/InvoiceController.php ADDED
@@ -0,0 +1,71 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dotdigitalgroup_Email_InvoiceController extends Mage_Core_Controller_Front_Action
4
+ {
5
+ public function preDispatch()
6
+ {
7
+ Mage::helper('connector')->auth($this->getRequest()->getParam('code'));
8
+ $orderId = $this->getRequest()->getParam('order_id', false);
9
+ if ($orderId) {
10
+ $order = Mage::getModel('sales/order')->load($orderId);
11
+ if ($order->getId()) {
12
+ Mage::app()->setCurrentStore($order->getStoreId());
13
+ } else {
14
+ Mage::helper('connector')->log('TE : order not found: ' . $orderId);
15
+ exit;
16
+ }
17
+ } else {
18
+ Mage::helper('connector')->log('TE : order_id missing :' . $orderId);
19
+ exit;
20
+ }
21
+ parent::preDispatch();
22
+ }
23
+ public function newAction()
24
+ {
25
+ $this->loadLayout();
26
+ $newOrder = $this->getLayout()->createBlock('email_connector/order_invoice', 'connector_invoice_new', array(
27
+ 'template' => 'connector/invoice/new.phtml'
28
+ ));
29
+ $this->getLayout()->getBlock('content')->append($newOrder);
30
+ $items = $this->getLayout()->createBlock('email_connector/order_invoice', 'connector_order_items', array(
31
+ 'template' => 'connector/order/items.phtml'
32
+ ));
33
+ $this->getLayout()->getBlock('connector_invoice_new')->append($items);
34
+ $this->renderLayout();
35
+ }
36
+
37
+ public function newguestAction()
38
+ {
39
+ $this->loadLayout();
40
+ $invoice = $this->getLayout()->createBlock('email_connector/order_invoice', 'connector_invoiceguest_new', array(
41
+ 'template' => 'connector/invoice/newguest.phtml'
42
+ ));
43
+ $this->getLayout()->getBlock('content')->append($invoice);
44
+ $items = $this->getLayout()->createBlock('email_connector/order_invoice', 'connector_order_items', array(
45
+ 'template' => 'connector/order/items.phtml'
46
+ ));
47
+ $this->getLayout()->getBlock('connector_invoiceguest_new')->append($items);
48
+
49
+ $this->renderLayout();
50
+
51
+ }
52
+ public function updateAction()
53
+ {
54
+ $this->loadLayout();
55
+ $invoice = $this->getLayout()->createBlock('email_connector/order_invoice', 'connector_invoice_update', array(
56
+ 'template' => 'connector/invoice/update.phtml'
57
+ ));
58
+ $this->getLayout()->getBlock('content')->append($invoice);
59
+ $this->renderLayout();
60
+ }
61
+ public function updateguestAction()
62
+ {
63
+ $this->loadLayout();
64
+ $invoice = $this->getLayout()->createBlock('email_connector/order_invoice', 'connector_invoice_updateguest', array(
65
+ 'template' => 'connector/invoice/updateguest.phtml'
66
+ ));
67
+ $this->getLayout()->getBlock('content')->append($invoice);
68
+ $this->renderLayout();
69
+ }
70
+
71
+ }
app/code/community/Dotdigitalgroup/Email/controllers/OrderController.php ADDED
@@ -0,0 +1,70 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dotdigitalgroup_Email_OrderController extends Mage_Core_Controller_Front_Action
4
+ {
5
+ public function preDispatch()
6
+ {
7
+ Mage::helper('connector')->auth($this->getRequest()->getParam('code'));
8
+ $orderId = $this->getRequest()->getParam('order_id', false);
9
+ if ($orderId) {
10
+ $order = Mage::getModel('sales/order')->load($orderId);
11
+ if ($order->getId()) {
12
+ Mage::app()->setCurrentStore($order->getStoreId());
13
+ } else {
14
+ Mage::helper('connector')->log('TE : order not found: ' . $orderId);
15
+ exit;
16
+ }
17
+ } else {
18
+ Mage::helper('connector')->log('TE : order_id missing :' . $orderId);
19
+ exit;
20
+ }
21
+ parent::preDispatch();
22
+ }
23
+ public function newAction()
24
+ {
25
+ $this->loadLayout();
26
+ $newOrder = $this->getLayout()->createBlock('email_connector/order', 'connector_order', array(
27
+ 'template' => 'connector/order/new.phtml'
28
+ ));
29
+ $this->getLayout()->getBlock('content')->append($newOrder);
30
+ $items = $this->getLayout()->createBlock('email_connector/order', 'connector_order_items', array(
31
+ 'template' => 'connector/order/items.phtml'
32
+ ));
33
+ $this->getLayout()->getBlock('connector_order')->append($items);
34
+ $this->renderLayout();
35
+ }
36
+
37
+ public function newguestAction()
38
+ {
39
+ $this->loadLayout();
40
+ $newOrder = $this->getLayout()->createBlock('email_connector/order', 'connector_order_guest', array(
41
+ 'template' => 'connector/order/newguest.phtml'
42
+ ));
43
+ $this->getLayout()->getBlock('content')->append($newOrder);
44
+ $items = $this->getLayout()->createBlock('email_connector/order', 'connector_order_items', array(
45
+ 'template' => 'connector/order/items.phtml'
46
+ ));
47
+ $this->getLayout()->getBlock('connector_order_guest')->append($items);
48
+ $this->renderLayout();
49
+
50
+ }
51
+ public function updateAction()
52
+ {
53
+ $this->loadLayout();
54
+ $newOrder = $this->getLayout()->createBlock('email_connector/order', 'connector_order_update', array(
55
+ 'template' => 'connector/order/update.phtml'
56
+ ));
57
+ $this->getLayout()->getBlock('content')->append($newOrder);
58
+ $this->renderLayout();
59
+ }
60
+ public function updateguestAction()
61
+ {
62
+ $this->loadLayout();
63
+ $newOrder = $this->getLayout()->createBlock('email_connector/order', 'connector_order_update_guest', array(
64
+ 'template' => 'connector/order/updateguest.phtml'
65
+ ));
66
+ $this->getLayout()->getBlock('content')->append($newOrder);
67
+ $this->renderLayout();
68
+ }
69
+
70
+ }
app/code/community/Dotdigitalgroup/Email/controllers/ProductsController.php ADDED
@@ -0,0 +1,69 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dotdigitalgroup_Email_ProductsController extends Mage_Core_Controller_Front_Action
4
+ {
5
+ public function preDispatch()
6
+ {
7
+ Mage::helper('connector')->auth($this->getRequest()->getParam('code'));
8
+ if ($this->getRequest()->getActionName() != 'push') {
9
+ $orderId = $this->getRequest()->getParam('order_id', false);
10
+ if ($orderId) {
11
+ $order = Mage::getModel('sales/order')->load($orderId);
12
+ if ($order->getId()) {
13
+ Mage::app()->setCurrentStore($order->getStoreId());
14
+ } else {
15
+ Mage::helper('connector')->log('Dynamic : order not found: ' . $orderId);
16
+ }
17
+ } else {
18
+ Mage::helper('connector')->log('Dynamic : order_id missing :' . $orderId);
19
+ }
20
+ }
21
+
22
+ parent::preDispatch();
23
+ }
24
+ public function relatedAction()
25
+ {
26
+ $this->loadLayout();
27
+ $products = $this->getLayout()->createBlock('email_connector/recommended_products', 'connector_recommended', array(
28
+ 'template' => 'connector/product/list.phtml'
29
+ ));
30
+ $this->getLayout()->getBlock('content')->append($products);
31
+
32
+ $this->renderLayout();
33
+
34
+ }
35
+ public function crosssellAction()
36
+ {
37
+ $this->loadLayout();
38
+ $products = $this->getLayout()->createBlock('email_connector/recommended_products', 'connector_recommended', array(
39
+ 'template' => 'connector/product/list.phtml'
40
+ ));
41
+ $this->getLayout()->getBlock('content')->append($products);
42
+
43
+ $this->renderLayout();
44
+ }
45
+
46
+ public function upsellAction()
47
+ {
48
+ $this->loadLayout();
49
+ $products = $this->getLayout()->createBlock('email_connector/recommended_products', 'connector_recommended', array(
50
+ 'template' => 'connector/product/list.phtml'
51
+ ));
52
+ $this->getLayout()->getBlock('content')->append($products);
53
+
54
+ $this->renderLayout();
55
+ }
56
+
57
+
58
+ public function pushAction()
59
+ {
60
+ $this->loadLayout();
61
+ $products = $this->getLayout()->createBlock('email_connector/recommended_push', 'connector_product', array(
62
+ 'template' => 'connector/product/list.phtml'
63
+ ));
64
+ $this->getLayout()->getBlock('content')->append($products);
65
+ $this->renderLayout();
66
+ }
67
+
68
+
69
+ }
app/code/community/Dotdigitalgroup/Email/controllers/ReportController.php ADDED
@@ -0,0 +1,63 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dotdigitalgroup_Email_ReportController extends Mage_Core_Controller_Front_Action
4
+ {
5
+ public function preDispatch()
6
+ {
7
+ Mage::helper('connector')->auth($this->getRequest()->getParam('code'));
8
+
9
+
10
+ parent::preDispatch();
11
+ }
12
+
13
+ public function bestsellersAction()
14
+ {
15
+ $this->loadLayout();
16
+ $products = $this->getLayout()->createBlock('email_connector/recommended_bestsellers', 'connector_customer', array(
17
+ 'template' => 'connector/product/list.phtml'
18
+ ));
19
+ $this->getLayout()->getBlock('content')->append($products);
20
+ $this->renderLayout();
21
+
22
+ }
23
+
24
+ public function mostviewedAction()
25
+ {
26
+ $this->loadLayout();
27
+ $products = $this->getLayout()->createBlock('email_connector/recommended_mostviewed', 'connector_customer', array(
28
+ 'template' => 'connector/product/list.phtml'
29
+ ));
30
+ $this->getLayout()->getBlock('content')->append($products);
31
+ $this->renderLayout();
32
+
33
+ }
34
+
35
+ public function recentlyviewedAction()
36
+ {
37
+ $customerId = $this->getRequest()->getParam('customer_id');
38
+ if (!$customerId) {
39
+ Mage::helper('connector')->log('Recentlyviewed : no customer id : ' . $customerId);
40
+ exit;
41
+ }
42
+
43
+ $this->loadLayout();
44
+ $products = $this->getLayout()->createBlock('email_connector/recommended_recentlyviewed', 'connector_customer', array(
45
+ 'template' => 'connector/product/list.phtml'
46
+ ));
47
+ $this->getLayout()->getBlock('content')->append($products);
48
+ $this->renderLayout();
49
+ }
50
+
51
+ public function customerAction()
52
+ {
53
+ $this->loadLayout();
54
+ $products = $this->getLayout()->createBlock('email_connector/customer', 'connector_customer', array(
55
+ 'template' => 'connector/products.phtml'
56
+ ));
57
+ $this->getLayout()->getBlock('content')->append($products);
58
+ $this->renderLayout();
59
+ }
60
+
61
+
62
+
63
+ }
app/code/community/Dotdigitalgroup/Email/controllers/ShippingController.php ADDED
@@ -0,0 +1,79 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dotdigitalgroup_Email_ShippingController extends Mage_Core_Controller_Front_Action
4
+ {
5
+ public function preDispatch()
6
+ {
7
+ Mage::helper('connector')->auth($this->getRequest()->getParam('code'));
8
+ $orderId = $this->getRequest()->getParam('order_id', false);
9
+ if ($orderId) {
10
+ $order = Mage::getModel('sales/order')->load($orderId);
11
+ if ($order->getId()) {
12
+ Mage::app()->setCurrentStore($order->getStoreId());
13
+ } else {
14
+ Mage::helper('connector')->log('TE : order not found: ' . $orderId);
15
+ exit;
16
+ }
17
+ } else {
18
+ Mage::helper('connector')->log('TE : order_id missing :' . $orderId);
19
+ exit;
20
+ }
21
+ parent::preDispatch();
22
+ }
23
+ public function newAction()
24
+ {
25
+ $this->loadLayout();
26
+ $newOrder = $this->getLayout()->createBlock('email_connector/order_shipping', 'connector_shipping_new', array(
27
+ 'template' => 'connector/shipping/new.phtml'
28
+ ));
29
+ $this->getLayout()->getBlock('content')->append($newOrder);
30
+ $items = $this->getLayout()->createBlock('email_connector/order', 'connector_shipping_items', array(
31
+ 'template' => 'connector/order/items.phtml'
32
+ ));
33
+ $this->getLayout()->getBlock('connector_shipping_new')->append($items);
34
+ $items = $this->getLayout()->createBlock('email_connector/order_shipping', 'connector_shipping_track', array(
35
+ 'template' => 'email/order/shipment/track.phtml'
36
+ ));
37
+ $this->getLayout()->getBlock('connector_shipping_new')->append($items);
38
+ $this->renderLayout();
39
+ }
40
+
41
+ public function newguestAction()
42
+ {
43
+ $this->loadLayout();
44
+ $newOrder = $this->getLayout()->createBlock('email_connector/order_shipping', 'connector_shipping_newguest', array(
45
+ 'template' => 'connector/shipping/newguest.phtml'
46
+ ));
47
+ $this->getLayout()->getBlock('content')->append($newOrder);
48
+ $items = $this->getLayout()->createBlock('email_connector/order', 'connector_shipping_items', array(
49
+ 'template' => 'connector/order/items.phtml'
50
+ ));
51
+ $this->getLayout()->getBlock('connector_shipping_newguest')->append($items);
52
+ $items = $this->getLayout()->createBlock('email_connector/order_shipping', 'connector_shipping_track', array(
53
+ 'template' => 'email/order/shipment/track.phtml'
54
+ ));
55
+ $this->getLayout()->getBlock('connector_shipping_newguest')->append($items);
56
+ $this->renderLayout();
57
+
58
+ }
59
+
60
+ public function updateAction()
61
+ {
62
+ $this->loadLayout();
63
+ $newOrder = $this->getLayout()->createBlock('email_connector/order_shipping', 'connector_shipping_update', array(
64
+ 'template' => 'connector/shipping/update.phtml'
65
+ ));
66
+ $this->getLayout()->getBlock('content')->append($newOrder);
67
+ $this->renderLayout();
68
+ }
69
+
70
+ public function updateguestAction()
71
+ {
72
+ $this->loadLayout();
73
+ $newOrder = $this->getLayout()->createBlock('email_connector/order_shipping', 'connector_shipping_updateguest', array(
74
+ 'template' => 'connector/shipping/updateguest.phtml'
75
+ ));
76
+ $this->getLayout()->getBlock('content')->append($newOrder);
77
+ $this->renderLayout();
78
+ }
79
+ }
app/code/community/Dotdigitalgroup/Email/etc/adminhtml.xml ADDED
@@ -0,0 +1,148 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <menu>
4
+ <email_connector translate="title">
5
+ <title>Marketing Automation</title>
6
+ <sort_order>70</sort_order>
7
+ <children>
8
+ <email_connector_dashboard translate="title">
9
+ <title>Dashboard</title>
10
+ <sort_order>10</sort_order>
11
+ <action>adminhtml/email_dashboard</action>
12
+ </email_connector_dashboard>
13
+ <automation_studio translate="title">
14
+ <title>Automation Studio</title>
15
+ <sort_order>20</sort_order>
16
+ <action>adminhtml/email_automation</action>
17
+ </automation_studio>
18
+ <reports translate="title">
19
+ <title>Reports</title>
20
+ <sort_order>30</sort_order>
21
+ <children>
22
+ <email_connector_order translate="title">
23
+ <title>Orders Sync</title>
24
+ <sort_order>20</sort_order>
25
+ <action>adminhtml/email_order</action>
26
+ </email_connector_order>
27
+ <email_connector_campaign translate="title">
28
+ <title>Email Send Status</title>
29
+ <sort_order>30</sort_order>
30
+ <action>adminhtml/email_campaign</action>
31
+ </email_connector_campaign>
32
+ <email_connector_contact translate="title">
33
+ <title>Contact Sync</title>
34
+ <sort_order>10</sort_order>
35
+ <action>adminhtml/email_contact</action>
36
+ </email_connector_contact>
37
+ </children>
38
+ </reports>
39
+ <email_configuration translate="title">
40
+ <title>Configuration</title>
41
+ <sort_order>40</sort_order>
42
+ <children>
43
+ <api_credentials translate="title">
44
+ <title>Api Credentials</title>
45
+ <sort_order>10</sort_order>
46
+ <action>adminhtml/system_config/edit/section/connector_api_credentials</action>
47
+ </api_credentials>
48
+ <data_mapping translate="title">
49
+ <title>Data Mapping</title>
50
+ <sort_order>20</sort_order>
51
+ <action>adminhtml/system_config/edit/section/connector_data_mapping</action>
52
+ </data_mapping>
53
+ <sync_settings translate="title">
54
+ <title>Sync Settings</title>
55
+ <sort_order>30</sort_order>
56
+ <action>adminhtml/system_config/edit/section/connector_sync_settings</action>
57
+ </sync_settings>
58
+ </children>
59
+ </email_configuration>
60
+ </children>
61
+ </email_connector>
62
+ </menu>
63
+ <acl>
64
+ <resources>
65
+ <admin>
66
+ <children>
67
+ <email_connector>
68
+ <title>Email Connector</title>
69
+ <children>
70
+ <email_connector_dashboard translate="title">
71
+ <title>Dashboard</title>
72
+ </email_connector_dashboard>
73
+ <automation_studio translate="title">
74
+ <title>Automation Studio</title>
75
+ </automation_studio>
76
+ <reports>
77
+ <title>Reports</title>
78
+ <children>
79
+ <email_connector_order translate="title">
80
+ <title>Email Connector Orders</title>
81
+ </email_connector_order>
82
+ <email_connector_campaign translate="title">
83
+ <title>Email Connector Campaigns</title>
84
+ </email_connector_campaign>
85
+ <email_connector_contact translate="title">
86
+ <title>Email Connector Contacts</title>
87
+ </email_connector_contact>
88
+ </children>
89
+ </reports>
90
+ <email_configuration translate="title">
91
+ <title>Email Configuration</title>
92
+ <children>
93
+ <api_credentials translate="title">
94
+ <title>Api Credentials</title>
95
+ </api_credentials>
96
+ <data_mapping translate="title">
97
+ <title>Data Mapping</title>
98
+ </data_mapping>
99
+ <sync_settings translate="title">
100
+ <title>Sync Settings</title>
101
+ </sync_settings>
102
+ </children>
103
+ </email_configuration>
104
+ </children>
105
+ </email_connector>
106
+ <system>
107
+ <children>
108
+ <config>
109
+ <children>
110
+ <connector_api_credentials translate="title">
111
+ <title><![CDATA[Email API Credentials]]></title>
112
+ </connector_api_credentials>
113
+ <connector_sync_settings translate="title">
114
+ <title><![CDATA[Email Sync Settings]]></title>
115
+ </connector_sync_settings>
116
+ <connector_data_mapping translate="title">
117
+ <title><![CDATA[Email Data Field Mapping]]></title>
118
+ </connector_data_mapping>
119
+ <connector_roi_tracking translate="title">
120
+ <title><![CDATA[Email ROI & Tracking]]></title>
121
+ </connector_roi_tracking>
122
+ <connector_lost_baskets translate="title">
123
+ <title><![CDATA[Abandoned Carts]]></title>
124
+ </connector_lost_baskets>
125
+ <connector_sms translate="title">
126
+ <title><![CDATA[Email SMS Section]]></title>
127
+ </connector_sms>
128
+ <connector_dynamic_content translate="title">
129
+ <title><![CDATA[Email Dynamic Content]]></title>
130
+ </connector_dynamic_content>
131
+ <connector_transactional_emails translate="title">
132
+ <title><![CDATA[Email Transactional Email]]></title>
133
+ </connector_transactional_emails>
134
+ <connector_automation_studio translate="title">
135
+ <title><![CDATA[Automation Studio]]></title>
136
+ </connector_automation_studio>
137
+ <connector_advanced_settings translate="title">
138
+ <title><![CDATA[Email Advanced Settings]]></title>
139
+ </connector_advanced_settings>
140
+ </children>
141
+ </config>
142
+ </children>
143
+ </system>
144
+ </children>
145
+ </admin>
146
+ </resources>
147
+ </acl>
148
+ </config>
app/code/community/Dotdigitalgroup/Email/etc/config.xml ADDED
@@ -0,0 +1,482 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Dotdigitalgroup_Email>
5
+ <version>3.1.2</version>
6
+ </Dotdigitalgroup_Email>
7
+ </modules>
8
+ <frontend>
9
+ <routers>
10
+ <connector>
11
+ <use>standard</use>
12
+ <args>
13
+ <module>Dotdigitalgroup_Email</module>
14
+ <frontName>connector</frontName>
15
+ </args>
16
+ </connector>
17
+ </routers>
18
+ <layout>
19
+ <updates>
20
+ <connector>
21
+ <file>connector.xml</file>
22
+ </connector>
23
+ </updates>
24
+ </layout>
25
+ </frontend>
26
+ <global>
27
+ <resources>
28
+ <email_connector_setup>
29
+ <setup>
30
+ <module>Dotdigitalgroup_Email</module>
31
+ <class>Dotdigitalgroup_Email_Model_Resource_Setup</class>
32
+ </setup>
33
+ </email_connector_setup>
34
+ </resources>
35
+ <models>
36
+ <email_connector>
37
+ <class>Dotdigitalgroup_Email_Model</class>
38
+ <resourceModel>email_connector_resource</resourceModel>
39
+ </email_connector>
40
+ <email_connector_resource>
41
+ <class>Dotdigitalgroup_Email_Model_Resource</class>
42
+ <entities>
43
+ <order>
44
+ <table>email_order</table>
45
+ </order>
46
+ <contact>
47
+ <table>email_contact</table>
48
+ </contact>
49
+ <campaign>
50
+ <table>email_campaign</table>
51
+ </campaign>
52
+ <create>
53
+ <table>email_create</table>
54
+ </create>
55
+ </entities>
56
+ </email_connector_resource>
57
+ <core>
58
+ <rewrite>
59
+ <email_template>Dotdigitalgroup_Email_Model_Email_Template</email_template>
60
+ </rewrite>
61
+ </core>
62
+ </models>
63
+ <helpers>
64
+ <connector>
65
+ <class>Dotdigitalgroup_Email_Helper</class>
66
+ </connector>
67
+ </helpers>
68
+ <blocks>
69
+ <email_connector>
70
+ <class>Dotdigitalgroup_Email_Block</class>
71
+ </email_connector>
72
+ </blocks>
73
+ <events>
74
+ <admin_system_config_changed_section_connector_api_credentials>
75
+ <observers>
76
+ <connector_api_save>
77
+ <class>Dotdigitalgroup_Email_Model_Adminhtml_Observer</class>
78
+ <method>actionConfigSaveApi</method>
79
+ </connector_api_save>
80
+ </observers>
81
+ </admin_system_config_changed_section_connector_api_credentials>
82
+ <admin_system_config_changed_section_connector_transactional_emails>
83
+ <observers>
84
+ <connector_transactional_api>
85
+ <class>Dotdigitalgroup_Email_Model_Adminhtml_Observer</class>
86
+ <method>actionConfigTransactional</method>
87
+ </connector_transactional_api>
88
+ </observers>
89
+ </admin_system_config_changed_section_connector_transactional_emails>
90
+ <admin_system_config_changed_section_connector_sync_settings>
91
+ <observers>
92
+ <connector_sync_reset>
93
+ <class>Dotdigitalgroup_Email_Model_Adminhtml_Observer</class>
94
+ <method>actionConfigResetContacts</method>
95
+ </connector_sync_reset>
96
+ </observers>
97
+ </admin_system_config_changed_section_connector_sync_settings>
98
+ <admin_system_config_changed_section_connector_data_mapping>
99
+ <observers>
100
+ <connector_data_mapping_reset>
101
+ <class>Dotdigitalgroup_Email_Model_Adminhtml_Observer</class>
102
+ <method>actionConfigResetContacts</method>
103
+ </connector_data_mapping_reset>
104
+ </observers>
105
+ </admin_system_config_changed_section_connector_data_mapping>
106
+ <customer_save_after>
107
+ <observers>
108
+ <connector_customer_save_after>
109
+ <class>Dotdigitalgroup_Email_Model_Customer_Observer</class>
110
+ <method>handleCustomerSaveBefore</method>
111
+ </connector_customer_save_after>
112
+ </observers>
113
+ </customer_save_after>
114
+ <customer_register_success>
115
+ <observers>
116
+ <connector_customer_register_success>
117
+ <type>singleton</type>
118
+ <class>Dotdigitalgroup_Email_Model_Customer_Observer</class>
119
+ <method>handleCustomerRegiterSuccess</method>
120
+ </connector_customer_register_success>
121
+ </observers>
122
+ </customer_register_success>
123
+ <newsletter_subscriber_save_before>
124
+ <observers>
125
+ <connector_newsletter_subscriber_save_before>
126
+ <class>Dotdigitalgroup_Email_Model_Newsletter_Observer</class>
127
+ <method>handleNewsletterSubscriberSave</method>
128
+ </connector_newsletter_subscriber_save_before>
129
+ </observers>
130
+ </newsletter_subscriber_save_before>
131
+ <sales_order_place_after>
132
+ <observers>
133
+ <connector_record_sale>
134
+ <type>singleton</type>
135
+ <class>Dotdigitalgroup_Email_Model_Sales_Observer</class>
136
+ <method>handleSalesOrderPlaceAfter</method>
137
+ </connector_record_sale>
138
+ </observers>
139
+ </sales_order_place_after>
140
+ <sales_order_save_before>
141
+ <observers>
142
+ <connector_sales_save_before>
143
+ <class>Dotdigitalgroup_Email_Model_Sales_Observer</class>
144
+ <method>handleSalesOrderSaveBefore</method>
145
+ </connector_sales_save_before>
146
+ </observers>
147
+ </sales_order_save_before>
148
+ <sales_order_save_after>
149
+ <observers>
150
+ <connector_checkout_type_onepage_save_order_after>
151
+ <class>Dotdigitalgroup_Email_Model_Sales_Observer</class>
152
+ <method>handleSalesOrderSaveAfter</method>
153
+ </connector_checkout_type_onepage_save_order_after>
154
+ </observers>
155
+ </sales_order_save_after>
156
+ <sales_order_creditmemo_save_after>
157
+ <observers>
158
+ <connector_sales_order_payment_refund>
159
+ <class>Dotdigitalgroup_Email_Model_Sales_Observer</class>
160
+ <method>handleSalesOrderRefund</method>
161
+ </connector_sales_order_payment_refund>
162
+ </observers>
163
+ </sales_order_creditmemo_save_after>
164
+ <order_cancel_after>
165
+ <observers>
166
+ <connector_sales_order_cancel>
167
+ <class>Dotdigitalgroup_Email_Model_Sales_Observer</class>
168
+ <method>hangleSalesOrderCancel</method>
169
+ </connector_sales_order_cancel>
170
+ </observers>
171
+ </order_cancel_after>
172
+ <rewards_points_indexer_update>
173
+ <observers>
174
+ <connector_rewards_points_indexer_update>
175
+ <class>Dotdigitalgroup_Email_Model_Sweettooth_Observer</class>
176
+ <method>ConnectorRewardsPointsIndexerUpdate</method>
177
+ </connector_rewards_points_indexer_update>
178
+ </observers>
179
+ </rewards_points_indexer_update>
180
+ <review_save_after>
181
+ <observers>
182
+ <connector_review_save_after>
183
+ <class>Dotdigitalgroup_Email_Model_Customer_Observer</class>
184
+ <method>reviewSaveAfter</method>
185
+ </connector_review_save_after>
186
+ </observers>
187
+ </review_save_after>
188
+ </events>
189
+ </global>
190
+ <adminhtml>
191
+ <layout>
192
+ <updates>
193
+ <connector_email>
194
+ <file>connector/email.xml</file>
195
+ </connector_email>
196
+ </updates>
197
+ </layout>
198
+ <translate>
199
+ <modules>
200
+ <Dotdigitalgroup_Email>
201
+ <files>
202
+ <default>Dotdigitalgroup_Email.csv</default>
203
+ </files>
204
+ </Dotdigitalgroup_Email>
205
+ </modules>
206
+ </translate>
207
+ </adminhtml>
208
+ <admin>
209
+ <routers>
210
+ <adminhtml>
211
+ <args>
212
+ <modules>
213
+ <Dotdigitalgroup_Email before="Mage_Adminhtml">Dotdigitalgroup_Email_Adminhtml</Dotdigitalgroup_Email>
214
+ </modules>
215
+ </args>
216
+ </adminhtml>
217
+ </routers>
218
+ </admin>
219
+ <crontab>
220
+ <jobs>
221
+ <connector_email_customer_sync>
222
+ <run><model>email_connector/cron::contactSync</model></run>
223
+ <schedule>
224
+ <cron_expr>*/15 * * * *</cron_expr>
225
+ </schedule>
226
+ </connector_email_customer_sync>
227
+ <connector_email_subscriber_and_guest_sync>
228
+ <run><model>email_connector/cron::subscribersAndGuestSync</model></run>
229
+ <schedule>
230
+ <cron_expr>*/15 * * * *</cron_expr>
231
+ </schedule>
232
+ </connector_email_subscriber_and_guest_sync>
233
+ <connector_email_lostbaskets>
234
+ <run><model>email_connector/cron::lostBaskets</model></run>
235
+ <schedule>
236
+ <cron_expr>*/5 * * * *</cron_expr>
237
+ </schedule>
238
+ </connector_email_lostbaskets>
239
+ <connector_email_create>
240
+ <run>
241
+ <model>email_connector/cron::createEmailsToCampaigns</model>
242
+ </run>
243
+ <schedule>
244
+ <cron_expr>*/5 * * * *</cron_expr>
245
+ </schedule>
246
+ </connector_email_create>
247
+ <connector_email_campaign>
248
+ <run>
249
+ <model>email_connector/cron::sendMappedEmails</model>
250
+ </run>
251
+ <schedule>
252
+ <cron_expr>02,07,12,17,22,27,32,37,42,47,52,57 * * * *</cron_expr>
253
+ </schedule>
254
+ </connector_email_campaign>
255
+ <connector_email_order_sync>
256
+ <run><model>email_connector/cron::orderSync</model></run>
257
+ <schedule>
258
+ <cron_expr>*/15 * * * *</cron_expr>
259
+ </schedule>
260
+ </connector_email_order_sync>
261
+ <connector_email_cleaner>
262
+ <run><model>email_connector/cron::cleaning</model></run>
263
+ <schedule>
264
+ <cron_expr>0 0 1 * * </cron_expr>
265
+ </schedule>
266
+ </connector_email_cleaner>
267
+ </jobs>
268
+ </crontab>
269
+ <default>
270
+ <connector_api_credentials>
271
+ <api>
272
+ <enabled>0</enabled>
273
+ <username></username>
274
+ <password></password>
275
+ </api>
276
+ </connector_api_credentials>
277
+ <connector_sync_settings>
278
+ <address_book>
279
+ <customers></customers>
280
+ <subscribers></subscribers>
281
+ <guests></guests>
282
+ </address_book>
283
+ <sync>
284
+ <contact_enabled>0</contact_enabled>
285
+ <subscriber_enabled>0</subscriber_enabled>
286
+ <order_enabled>0</order_enabled>
287
+ <wishlist_enabled>0</wishlist_enabled>
288
+ </sync>
289
+ <dynamic_addressbook>
290
+ <addressbook_name></addressbook_name>
291
+ </dynamic_addressbook>
292
+ </connector_sync_settings>
293
+ <connector_data_mapping>
294
+ <customer_data>
295
+ <customer_id></customer_id>
296
+ <firstname></firstname>
297
+ <lastname></lastname>
298
+ <dob></dob>
299
+ <gender></gender>
300
+ <website_name></website_name>
301
+ <store_name></store_name>
302
+ <created_at></created_at>
303
+ <last_logged_date></last_logged_date>
304
+ <customer_group></customer_group>
305
+ <billing_address_1></billing_address_1>
306
+ <billing_address_2></billing_address_2>
307
+ <billing_city></billing_city>
308
+ <billing_state></billing_state>
309
+ <billing_country></billing_country>
310
+ <billing_postcode></billing_postcode>
311
+ <billing_telephone></billing_telephone>
312
+ <delivery_address_1></delivery_address_1>
313
+ <delivery_address_2></delivery_address_2>
314
+ <delivery_city></delivery_city>
315
+ <delivery_state></delivery_state>
316
+ <delivery_country></delivery_country>
317
+ <delivery_postcode></delivery_postcode>
318
+ <delivery_telephone></delivery_telephone>
319
+ <number_of_orders></number_of_orders>
320
+ <average_order_value></average_order_value>
321
+ <total_spend></total_spend>
322
+ <last_order_date></last_order_date>
323
+ <last_order_id></last_order_id>
324
+ <custom_attributes></custom_attributes>
325
+ <validator></validator>
326
+ </customer_data>
327
+ <dynamic_datafield>
328
+ <datafield_name></datafield_name>
329
+ <datafield_type></datafield_type>
330
+ </dynamic_datafield>
331
+ </connector_data_mapping>
332
+ <connector_roi_tracking>
333
+ <page_tracking>
334
+ <enabled>0</enabled>
335
+ </page_tracking>
336
+ <roi_tracking>
337
+ <enabled>0</enabled>
338
+ </roi_tracking>
339
+ </connector_roi_tracking>
340
+ <connector_lost_baskets>
341
+ <customers>
342
+ <enabled_1>0</enabled_1>
343
+ <send_after_1></send_after_1>
344
+ <campaign_1></campaign_1>
345
+ <enabled_2>0</enabled_2>
346
+ <send_after_2></send_after_2>
347
+ <campaign_2></campaign_2>
348
+ <enabled_3>0</enabled_3>
349
+ <send_after_3></send_after_3>
350
+ <campaign_3></campaign_3>
351
+ </customers>
352
+ <guests>
353
+ <enabled_1>0</enabled_1>
354
+ <send_after_1></send_after_1>
355
+ <campaign_1></campaign_1>
356
+ <enabled_2>0</enabled_2>
357
+ <send_after_2></send_after_2>
358
+ <campaign_2></campaign_2>
359
+ <enabled_3>0</enabled_3>
360
+ <send_after_3></send_after_3>
361
+ <campaign_3></campaign_3>
362
+ </guests>
363
+ </connector_lost_baskets>
364
+ <connector_sms>
365
+ <sms_one>
366
+ <enabled>0</enabled>
367
+ <status></status>
368
+ <message></message>
369
+ </sms_one>
370
+ <sms_two>
371
+ <enabled>0</enabled>
372
+ <status></status>
373
+ <message></message>
374
+ </sms_two>
375
+ <sms_three>
376
+ <enabled>0</enabled>
377
+ <status></status>
378
+ <message></message>
379
+ </sms_three>
380
+ <sms_four>
381
+ <enabled>0</enabled>
382
+ <status></status>
383
+ <message></message>
384
+ </sms_four>
385
+ </connector_sms>
386
+ <connector_dynamic_content>
387
+ <products>
388
+ <related_display_type>list</related_display_type>
389
+ <related_items_to_display>2</related_items_to_display>
390
+ <upsell_display_type>list</upsell_display_type>
391
+ <upsell_items_to_display>2</upsell_items_to_display>
392
+ <crosssell_display_type>list</crosssell_display_type>
393
+ <crosssell_items_to_display>2</crosssell_items_to_display>
394
+ <bestsellers_display_type>list</bestsellers_display_type>
395
+ <bestsellers_items_to_display>2</bestsellers_items_to_display>
396
+ <bestsellers_time_period></bestsellers_time_period>
397
+ <most_viewed_display_type>list</most_viewed_display_type>
398
+ <most_viewed_items_to_display>2</most_viewed_items_to_display>
399
+ <most_viewed_time_period></most_viewed_time_period>
400
+ <recently_viewed_display_type>list</recently_viewed_display_type>
401
+ <recently_viewed_items_to_display>2</recently_viewed_items_to_display>
402
+ </products>
403
+ <external_dynamic_content_urls>
404
+ <passcode>secret</passcode>
405
+ <lost_basket_url></lost_basket_url>
406
+ <coupon_code_url></coupon_code_url>
407
+ <dynamic_content_url></dynamic_content_url>
408
+ <related_products_url></related_products_url>
409
+ <upsell_products_url></upsell_products_url>
410
+ <crosssell_products_url></crosssell_products_url>
411
+ <best_sellers_url></best_sellers_url>
412
+ <most_viewed_url></most_viewed_url>
413
+ <product_push_url></product_push_url>
414
+ <recently_viewed_url></recently_viewed_url>
415
+ <new_order_url></new_order_url>
416
+ <new_order_guest_url></new_order_guest_url>
417
+ <order_update_url></order_update_url>
418
+ <order_update_guest_url></order_update_guest_url>
419
+ <new_invoice_url></new_invoice_url>
420
+ <new_invoice_guest_url></new_invoice_guest_url>
421
+ <invoice_update_url></invoice_update_url>
422
+ <invoice_update_guest_url></invoice_update_guest_url>
423
+ <new_creditmemo_url></new_creditmemo_url>
424
+ <new_creditmemo_guest_url></new_creditmemo_guest_url>
425
+ <creditmemo_update_url></creditmemo_update_url>
426
+ <creditmemo_update_guest_url></creditmemo_update_guest_url>
427
+ <new_shipment_url></new_shipment_url>
428
+ <new_shipment_guest_url></new_shipment_guest_url>
429
+ <shipment_update_url></shipment_update_url>
430
+ <shipment_update_guest_url></shipment_update_guest_url>
431
+ </external_dynamic_content_urls>
432
+ <manual_product_search>
433
+ <display_type>list</display_type>
434
+ <items_to_display>2</items_to_display>
435
+ <products_push_items></products_push_items>
436
+ </manual_product_search>
437
+ <fallback_products>
438
+ <product_list></product_list>
439
+ </fallback_products>
440
+ </connector_dynamic_content>
441
+ <connector_transactional_emails>
442
+ <credentials>
443
+ <enabled>0</enabled>
444
+ <api_username></api_username>
445
+ <api_password></api_password>
446
+ </credentials>
447
+ <email_settings>
448
+ <unsubscribe_link>1</unsubscribe_link>
449
+ <reply_action>Webmail</reply_action>
450
+ <reply_address></reply_address>
451
+ </email_settings>
452
+ <email_mapping>
453
+ <default_email_templates></default_email_templates>
454
+ <custom_email_templates></custom_email_templates>
455
+ </email_mapping>
456
+ </connector_transactional_emails>
457
+ <connector_advanced_settings>
458
+ <sync_limits>
459
+ <orders>500</orders>
460
+ </sync_limits>
461
+ <admin>
462
+ <setup_data_fields></setup_data_fields>
463
+ <delete_contact></delete_contact>
464
+ <reimport_orders></reimport_orders>
465
+ <reimport_subscribers></reimport_subscribers>
466
+ <suppressed_contacts></suppressed_contacts>
467
+ <memory_limit>0</memory_limit>
468
+ <batch_size>10000</batch_size>
469
+ <debug_enabled>1</debug_enabled>
470
+ <inline_styling><![CDATA[table{font-family: arial, geneva, sans-serif; font-size:12px;}]]></inline_styling>
471
+ <recommended_inline><![CDATA[table{font-family: arial, geneva, sans-serif; font-size:12px;}]]></recommended_inline>
472
+ </admin>
473
+ </connector_advanced_settings>
474
+ </default>
475
+ <phpunit>
476
+ <suite>
477
+ <modules>
478
+ <Dotdigitalgroup_Email />
479
+ </modules>
480
+ </suite>
481
+ </phpunit>
482
+ </config>
app/code/community/Dotdigitalgroup/Email/etc/system.xml ADDED
@@ -0,0 +1,2134 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <config>
3
+ <tabs>
4
+ <connector translate="label" module="connector">
5
+ <label>EMAIL</label>
6
+ <sort_order>1000</sort_order>
7
+ </connector>
8
+ </tabs>
9
+ <sections>
10
+ <connector_api_credentials translate="label" module="connector">
11
+ <label><![CDATA[API Credentials]]></label>
12
+ <tab>connector</tab>
13
+ <frontend_type>text</frontend_type>
14
+ <sort_order>1000</sort_order>
15
+ <show_in_default>1</show_in_default>
16
+ <show_in_website>1</show_in_website>
17
+ <show_in_store>0</show_in_store>
18
+ <groups>
19
+ <api translate="label" module="connector">
20
+ <label>Settings</label>
21
+ <frontend_type>text</frontend_type>
22
+ <sort_order>10</sort_order>
23
+ <show_in_default>1</show_in_default>
24
+ <show_in_website>1</show_in_website>
25
+ <show_in_store>0</show_in_store>
26
+ <expanded>1</expanded>
27
+ <fields>
28
+ <enabled translate="label" module="connector">
29
+ <label>Enabled</label>
30
+ <frontend_type>select</frontend_type>
31
+ <source_model>adminhtml/system_config_source_yesno</source_model>
32
+ <sort_order>10</sort_order>
33
+ <show_in_default>1</show_in_default>
34
+ <show_in_website>1</show_in_website>
35
+ <show_in_store>0</show_in_store>
36
+ </enabled>
37
+ <username translate="label" module="connector">
38
+ <label>API Username</label>
39
+ <frontend_type>text</frontend_type>
40
+ <frontend_model>email_connector/adminhtml_system_config_wrapper</frontend_model>
41
+ <sort_order>20</sort_order>
42
+ <show_in_default>1</show_in_default>
43
+ <show_in_website>1</show_in_website>
44
+ <show_in_store>0</show_in_store>
45
+ <depends><enabled>1</enabled></depends>
46
+ </username>
47
+ <password translate="label" module="connector">
48
+ <label>API Password</label>
49
+ <frontend_type>password</frontend_type>
50
+ <frontend_model>email_connector/adminhtml_system_ajaxvalidate</frontend_model>
51
+ <sort_order>30</sort_order>
52
+ <show_in_default>1</show_in_default>
53
+ <show_in_website>1</show_in_website>
54
+ <show_in_store>0</show_in_store>
55
+ <depends><enabled>1</enabled></depends>
56
+ </password>
57
+ <validator>
58
+ <frontend_type>hidden</frontend_type>
59
+ <frontend_model>email_connector/adminhtml_system_config_waitingfield</frontend_model>
60
+ <sort_order>50</sort_order>
61
+ <show_in_default>1</show_in_default>
62
+ <show_in_website>1</show_in_website>
63
+ <show_in_store>0</show_in_store>
64
+ <can_be_empty>1</can_be_empty>
65
+ </validator>
66
+ </fields>
67
+ </api>
68
+ <oauth translate="label" module="connector">
69
+ <label>OAUTH Credentials</label>
70
+ <sort_order>20</sort_order>
71
+ <show_in_default>1</show_in_default>
72
+ <show_in_website>1</show_in_website>
73
+ <show_in_store>0</show_in_store>
74
+ <fields>
75
+ <client_id translate="label" module="connector">
76
+ <label>Client ID</label>
77
+ <frontend_type>text</frontend_type>
78
+ <sort_order>10</sort_order>
79
+ <show_in_default>1</show_in_default>
80
+ <show_in_website>1</show_in_website>
81
+ <show_in_store>0</show_in_store>
82
+ </client_id>
83
+ <client_key translate="label" module="connector">
84
+ <label>Client Secret Key</label>
85
+ <frontend_type>text</frontend_type>
86
+ <sort_order>20</sort_order>
87
+ <show_in_default>1</show_in_default>
88
+ <show_in_website>1</show_in_website>
89
+ <show_in_store>0</show_in_store>
90
+ </client_key>
91
+ <test_connect translate="label" module="connector">
92
+ <label>Connection</label>
93
+ <frontend_model>email_connector/adminhtml_system_automation_connect</frontend_model>
94
+ <sort_order>30</sort_order>
95
+ <show_in_default>1</show_in_default>
96
+ <show_in_website>1</show_in_website>
97
+ <comment>Please Save Client ID and Secret Key Before Test. Generate/Refresh New Token.</comment>
98
+ </test_connect>
99
+ </fields>
100
+ </oauth>
101
+ </groups>
102
+ </connector_api_credentials>
103
+ <connector_sync_settings translate="label" module="connector">
104
+ <label><![CDATA[Sync Settings]]></label>
105
+ <tab>connector</tab>
106
+ <frontend_type>text</frontend_type>
107
+ <sort_order>3000</sort_order>
108
+ <show_in_default>1</show_in_default>
109
+ <show_in_website>1</show_in_website>
110
+ <show_in_store>0</show_in_store>
111
+ <groups>
112
+ <address_book translate="label" module="connector">
113
+ <label>Address Book Mapping</label>
114
+ <sort_order>10</sort_order>
115
+ <show_in_default>1</show_in_default>
116
+ <show_in_website>1</show_in_website>
117
+ <show_in_store>0</show_in_store>
118
+ <expanded>1</expanded>
119
+ <fields>
120
+ <customers translate="label" module="connector">
121
+ <label>Add Customers To</label>
122
+ <frontend_type>select</frontend_type>
123
+ <source_model>email_connector/adminhtml_source_addressbooks</source_model>
124
+ <sort_order>10</sort_order>
125
+ <show_in_default>1</show_in_default>
126
+ <show_in_website>1</show_in_website>
127
+ <show_in_store>0</show_in_store>
128
+ </customers>
129
+ <subscribers translate="label" module="connector">
130
+ <label>Add Subscribers To</label>
131
+ <frontend_type>select</frontend_type>
132
+ <source_model>email_connector/adminhtml_source_addressbooks</source_model>
133
+ <sort_order>20</sort_order>
134
+ <show_in_default>1</show_in_default>
135
+ <show_in_website>1</show_in_website>
136
+ <show_in_store>0</show_in_store>
137
+ </subscribers>
138
+ <guests translate="label" module="connector">
139
+ <label>Add Guests To</label>
140
+ <frontend_type>select</frontend_type>
141
+ <source_model>email_connector/adminhtml_source_addressbooks</source_model>
142
+ <sort_order>30</sort_order>
143
+ <show_in_default>1</show_in_default>
144
+ <show_in_website>1</show_in_website>
145
+ <show_in_store>0</show_in_store>
146
+ </guests>
147
+ </fields>
148
+ </address_book>
149
+ <sync translate="label" module="connector">
150
+ <label>Sync</label>
151
+ <frontend_type>text</frontend_type>
152
+ <sort_order>20</sort_order>
153
+ <show_in_default>1</show_in_default>
154
+ <show_in_website>1</show_in_website>
155
+ <show_in_store>0</show_in_store>
156
+ <expanded>1</expanded>
157
+ <fields>
158
+ <contact_title translate="label" module="connector">
159
+ <label>Contact Sync</label>
160
+ <frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
161
+ <sort_order>10</sort_order>
162
+ <show_in_default>1</show_in_default>
163
+ <show_in_website>1</show_in_website>
164
+ <show_in_store>0</show_in_store>
165
+ </contact_title>
166
+ <contact_enabled translate="label" module="connector">
167
+ <label>Enabled</label>
168
+ <frontend_type>select</frontend_type>
169
+ <source_model>adminhtml/system_config_source_yesno</source_model>
170
+ <sort_order>20</sort_order>
171
+ <show_in_default>1</show_in_default>
172
+ <show_in_website>1</show_in_website>
173
+ <show_in_store>0</show_in_store>
174
+ </contact_enabled>
175
+ <subscriber_title translate="label" module="connector">
176
+ <label>Subscriber Sync</label>
177
+ <frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
178
+ <sort_order>50</sort_order>
179
+ <show_in_default>1</show_in_default>
180
+ <show_in_website>1</show_in_website>
181
+ <show_in_store>0</show_in_store>
182
+ </subscriber_title>
183
+ <subscriber_enabled translate="label" module="connector">
184
+ <label>Enabled</label>
185
+ <frontend_type>select</frontend_type>
186
+ <source_model>adminhtml/system_config_source_yesno</source_model>
187
+ <sort_order>60</sort_order>
188
+ <show_in_default>1</show_in_default>
189
+ <show_in_website>1</show_in_website>
190
+ <show_in_store>0</show_in_store>
191
+ </subscriber_enabled>
192
+ <order_title translate="label" module="connector">
193
+ <label>Order Sync</label>
194
+ <frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
195
+ <sort_order>70</sort_order>
196
+ <show_in_default>1</show_in_default>
197
+ <show_in_website>1</show_in_website>
198
+ <show_in_store>0</show_in_store>
199
+ </order_title>
200
+ <order_enabled translate="label" module="connector">
201
+ <label>Enabled</label>
202
+ <frontend_type>select</frontend_type>
203
+ <source_model>adminhtml/system_config_source_yesno</source_model>
204
+ <sort_order>80</sort_order>
205
+ <show_in_default>1</show_in_default>
206
+ <show_in_website>1</show_in_website>
207
+ <show_in_store>0</show_in_store>
208
+ </order_enabled>
209
+ <wishlist_title translate="label" module="connector">
210
+ <label>Wishlist Sync</label>
211
+ <frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
212
+ <sort_order>90</sort_order>
213
+ <show_in_default>1</show_in_default>
214
+ <show_in_website>1</show_in_website>
215
+ <show_in_store>0</show_in_store>
216
+ </wishlist_title>
217
+ <wishlist_enabled translate="label" module="connector">
218
+ <label>Enabled</label>
219
+ <frontend_type>select</frontend_type>
220
+ <source_model>adminhtml/system_config_source_yesno</source_model>
221
+ <sort_order>100</sort_order>
222
+ <show_in_default>1</show_in_default>
223
+ <show_in_website>1</show_in_website>
224
+ <show_in_store>0</show_in_store>
225
+ </wishlist_enabled>
226
+ <validator>
227
+ <frontend_type>hidden</frontend_type>
228
+ <frontend_model>email_connector/adminhtml_system_config_waitingfield</frontend_model>
229
+ <sort_order>110</sort_order>
230
+ <show_in_default>1</show_in_default>
231
+ <show_in_website>1</show_in_website>
232
+ <show_in_store>0</show_in_store>
233
+ <can_be_empty>1</can_be_empty>
234
+ </validator>
235
+ </fields>
236
+ </sync>
237
+ <dynamic_addressbook translate="label" module="connector">
238
+ <label>Create Address Book</label>
239
+ <sort_order>30</sort_order>
240
+ <show_in_default>1</show_in_default>
241
+ <show_in_website>1</show_in_website>
242
+ <show_in_store>0</show_in_store>
243
+ <fields>
244
+ <addressbook_name translate="label" module="connector">
245
+ <label>Address Book Name</label>
246
+ <frontend_type>text</frontend_type>
247
+ <frontend_model>email_connector/adminhtml_system_config_addressbook</frontend_model>
248
+ <sort_order>10</sort_order>
249
+ <show_in_default>1</show_in_default>
250
+ <show_in_website>1</show_in_website>
251
+ <show_in_store>0</show_in_store>
252
+ </addressbook_name>
253
+ <addresbook_button translate="label button_label" module="connector">
254
+ <label />
255
+ <button_label>Create New Address Book</button_label>
256
+ <frontend_model>email_connector/adminhtml_system_dynamic_addressbookbutton</frontend_model>
257
+ <sort_order>30</sort_order>
258
+ <show_in_default>1</show_in_default>
259
+ <show_in_website>1</show_in_website>
260
+ <show_in_store>0</show_in_store>
261
+ </addresbook_button>
262
+ </fields>
263
+ </dynamic_addressbook>
264
+ </groups>
265
+ </connector_sync_settings>
266
+ <connector_data_mapping translate="label" module="connector">
267
+ <label><![CDATA[Data Mapping]]></label>
268
+ <tab>connector</tab>
269
+ <frontend_type>text</frontend_type>
270
+ <sort_order>2000</sort_order>
271
+ <show_in_default>1</show_in_default>
272
+ <show_in_website>1</show_in_website>
273
+ <show_in_store>0</show_in_store>
274
+ <groups>
275
+ <customer_data translate="label" module="connector">
276
+ <label>Data Fields Mapping</label>
277
+ <frontend_type>text</frontend_type>
278
+ <sort_order>20</sort_order>
279
+ <show_in_default>1</show_in_default>
280
+ <show_in_website>1</show_in_website>
281
+ <show_in_store>0</show_in_store>
282
+ <expanded>1</expanded>
283
+ <comment><![CDATA[<p class="notice">AUTOMAP AVAILABLE IN ADVANCED SECTION TO MAP ALL DATAFIELDS.</p>]]></comment>
284
+ <fields>
285
+ <customer_title translate="label" module="connector">
286
+ <label>Customer Information</label>
287
+ <frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
288
+ <sort_order>10</sort_order>
289
+ <show_in_default>1</show_in_default>
290
+ <show_in_website>1</show_in_website>
291
+ <show_in_store>0</show_in_store>
292
+ </customer_title>
293
+ <title translate="label" module="connector">
294
+ <label>Title</label>
295
+ <frontend_type>select</frontend_type>
296
+ <source_model>email_connector/adminhtml_source_datafields</source_model>
297
+ <sort_order>20</sort_order>
298
+ <show_in_default>1</show_in_default>
299
+ <show_in_website>1</show_in_website>
300
+ <show_in_store>0</show_in_store>
301
+ </title>
302
+ <customer_id translate="label" module="connector">
303
+ <label>Customer ID</label>
304
+ <frontend_type>select</frontend_type>
305
+ <source_model>email_connector/adminhtml_source_datafields</source_model>
306
+ <sort_order>30</sort_order>
307
+ <show_in_default>1</show_in_default>
308
+ <show_in_website>1</show_in_website>
309
+ <show_in_store>0</show_in_store>
310
+ </customer_id>
311
+ <firstname translate="label" module="connector">
312
+ <label>First Name</label>
313
+ <frontend_type>select</frontend_type>
314
+ <source_model>email_connector/adminhtml_source_datafields</source_model>
315
+ <sort_order>40</sort_order>
316
+ <show_in_default>1</show_in_default>
317
+ <show_in_website>1</show_in_website>
318
+ <show_in_store>0</show_in_store>
319
+ </firstname>
320
+ <lastname translate="label" module="connector">
321
+ <label>Last Name</label>
322
+ <frontend_type>select</frontend_type>
323
+ <source_model>email_connector/adminhtml_source_datafields</source_model>
324
+ <sort_order>50</sort_order>
325
+ <show_in_default>1</show_in_default>
326
+ <show_in_website>1</show_in_website>
327
+ <show_in_store>0</show_in_store>
328
+ </lastname>
329
+ <dob translate="label" module="connector">
330
+ <label>D.O.B.</label>
331
+ <frontend_type>select</frontend_type>
332
+ <source_model>email_connector/adminhtml_source_datafields</source_model>
333
+ <sort_order>60</sort_order>
334
+ <show_in_default>1</show_in_default>
335
+ <show_in_website>1</show_in_website>
336
+ <show_in_store>0</show_in_store>
337
+ </dob>
338
+ <gender translate="label" module="connector">
339
+ <label>Gender</label>
340
+ <frontend_type>select</frontend_type>
341
+ <source_model>email_connector/adminhtml_source_datafields</source_model>
342
+ <sort_order>70</sort_order>
343
+ <show_in_default>1</show_in_default>
344
+ <show_in_website>1</show_in_website>
345
+ <show_in_store>0</show_in_store>
346
+ </gender>
347
+ <website_name translate="label" module="connector">
348
+ <label>Website Created On</label>
349
+ <frontend_type>select</frontend_type>
350
+ <source_model>email_connector/adminhtml_source_datafields</source_model>
351
+ <sort_order>80</sort_order>
352
+ <show_in_default>1</show_in_default>
353
+ <show_in_website>1</show_in_website>
354
+ <show_in_store>0</show_in_store>
355
+ </website_name>
356
+ <store_name translate="label" module="connector">
357
+ <label>Store Created On</label>
358
+ <frontend_type>select</frontend_type>
359
+ <source_model>email_connector/adminhtml_source_datafields</source_model>
360
+ <sort_order>90</sort_order>
361
+ <show_in_default>1</show_in_default>
362
+ <show_in_website>1</show_in_website>
363
+ <show_in_store>0</show_in_store>
364
+ </store_name>
365
+ <created_at translate="label" module="connector">
366
+ <label>Account Created Date</label>
367
+ <frontend_type>select</frontend_type>
368
+ <source_model>email_connector/adminhtml_source_datafields</source_model>
369
+ <sort_order>100</sort_order>
370
+ <show_in_default>1</show_in_default>
371
+ <show_in_website>1</show_in_website>
372
+ <show_in_store>0</show_in_store>
373
+ </created_at>
374
+ <last_logged_date translate="label" module="connector">
375
+ <label>Last Logged In Date</label>
376
+ <frontend_type>select</frontend_type>
377
+ <source_model>email_connector/adminhtml_source_datafields</source_model>
378
+ <sort_order>110</sort_order>
379
+ <show_in_default>1</show_in_default>
380
+ <show_in_website>1</show_in_website>
381
+ <show_in_store>0</show_in_store>
382
+ </last_logged_date>
383
+ <customer_group translate="label" module="connector">
384
+ <label>Customer Group</label>
385
+ <frontend_type>select</frontend_type>
386
+ <source_model>email_connector/adminhtml_source_datafields</source_model>
387
+ <sort_order>120</sort_order>
388
+ <show_in_default>1</show_in_default>
389
+ <show_in_website>1</show_in_website>
390
+ <show_in_store>0</show_in_store>
391
+ </customer_group>
392
+ <review_count translate="label" module="connector">
393
+ <label>Customer Review Count</label>
394
+ <frontend_type>select</frontend_type>
395
+ <source_model>email_connector/adminhtml_source_datafields</source_model>
396
+ <sort_order>121</sort_order>
397
+ <show_in_default>1</show_in_default>
398
+ <show_in_website>1</show_in_website>
399
+ <show_in_store>0</show_in_store>
400
+ </review_count>
401
+ <last_review_date translate="label" module="connector">
402
+ <label>Last Review Date</label>
403
+ <frontend_type>select</frontend_type>
404
+ <source_model>email_connector/adminhtml_source_datafields</source_model>
405
+ <sort_order>122</sort_order>
406
+ <show_in_default>1</show_in_default>
407
+ <show_in_website>1</show_in_website>
408
+ <show_in_store>0</show_in_store>
409
+ </last_review_date>
410
+ <address_title translate="label" module="connector">
411
+ <label>Address</label>
412
+ <frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
413
+ <sort_order>130</sort_order>
414
+ <show_in_default>1</show_in_default>
415
+ <show_in_website>1</show_in_website>
416
+ <show_in_store>0</show_in_store>
417
+ </address_title>
418
+ <billing_address_1 translate="label" module="connector">
419
+ <label>Billing Address Line 1</label>
420
+ <frontend_type>select</frontend_type>
421
+ <source_model>email_connector/adminhtml_source_datafields</source_model>
422
+ <sort_order>140</sort_order>
423
+ <show_in_default>1</show_in_default>
424
+ <show_in_website>1</show_in_website>
425
+ <show_in_store>0</show_in_store>
426
+ </billing_address_1>
427
+ <billing_address_2 translate="label" module="connector">
428
+ <label>Billing Address Line 2</label>
429
+ <frontend_type>select</frontend_type>
430
+ <source_model>email_connector/adminhtml_source_datafields</source_model>
431
+ <sort_order>150</sort_order>
432
+ <show_in_default>1</show_in_default>
433
+ <show_in_website>1</show_in_website>
434
+ <show_in_store>0</show_in_store>
435
+ </billing_address_2>
436
+ <billing_city translate="label" module="connector">
437
+ <label>Billing City</label>
438
+ <frontend_type>select</frontend_type>
439
+ <source_model>email_connector/adminhtml_source_datafields</source_model>
440
+ <sort_order>160</sort_order>
441
+ <show_in_default>1</show_in_default>
442
+ <show_in_website>1</show_in_website>
443
+ <show_in_store>0</show_in_store>
444
+ </billing_city>
445
+ <billing_state translate="label" module="connector">
446
+ <label>Billing State/Region</label>
447
+ <frontend_type>select</frontend_type>
448
+ <source_model>email_connector/adminhtml_source_datafields</source_model>
449
+ <sort_order>155</sort_order>
450
+ <show_in_default>1</show_in_default>
451
+ <show_in_website>1</show_in_website>
452
+ <show_in_store>0</show_in_store>
453
+ </billing_state>
454
+ <billing_country translate="label" module="connector">
455
+ <label>Billing Country</label>
456
+ <frontend_type>select</frontend_type>
457
+ <source_model>email_connector/adminhtml_source_datafields</source_model>
458
+ <sort_order>170</sort_order>
459
+ <show_in_default>1</show_in_default>
460
+ <show_in_website>1</show_in_website>
461
+ <show_in_store>0</show_in_store>
462
+ </billing_country>
463
+ <billing_postcode translate="label" module="connector">
464
+ <label>Billing Zip/Postcode</label>
465
+ <frontend_type>select</frontend_type>
466
+ <source_model>email_connector/adminhtml_source_datafields</source_model>
467
+ <sort_order>180</sort_order>
468
+ <show_in_default>1</show_in_default>
469
+ <show_in_website>1</show_in_website>
470
+ <show_in_store>0</show_in_store>
471
+ </billing_postcode>
472
+ <billing_telephone translate="label" module="connector">
473
+ <label>Billing Telephone</label>
474
+ <frontend_type>select</frontend_type>
475
+ <source_model>email_connector/adminhtml_source_datafields</source_model>
476
+ <sort_order>190</sort_order>
477
+ <show_in_default>1</show_in_default>
478
+ <show_in_website>1</show_in_website>
479
+ <show_in_store>0</show_in_store>
480
+ </billing_telephone>
481
+ <delivery_address_1 translate="label" module="connector">
482
+ <label>Delivery Address Line 1</label>
483
+ <frontend_type>select</frontend_type>
484
+ <source_model>email_connector/adminhtml_source_datafields</source_model>
485
+ <sort_order>200</sort_order>
486
+ <show_in_default>1</show_in_default>
487
+ <show_in_website>1</show_in_website>
488
+ <show_in_store>0</show_in_store>
489
+ </delivery_address_1>
490
+ <delivery_address_2 translate="label" module="connector">
491
+ <label>Delivery Address Line 2</label>
492
+ <frontend_type>select</frontend_type>
493
+ <source_model>email_connector/adminhtml_source_datafields</source_model>
494
+ <sort_order>210</sort_order>
495
+ <show_in_default>1</show_in_default>
496
+ <show_in_website>1</show_in_website>
497
+ <show_in_store>0</show_in_store>
498
+ </delivery_address_2>
499
+ <delivery_city translate="label" module="connector">
500
+ <label>Delivery City</label>
501
+ <frontend_type>select</frontend_type>
502
+ <source_model>email_connector/adminhtml_source_datafields</source_model>
503
+ <sort_order>220</sort_order>
504
+ <show_in_default>1</show_in_default>
505
+ <show_in_website>1</show_in_website>
506
+ <show_in_store>0</show_in_store>
507
+ </delivery_city>
508
+ <delivery_state translate="label" module="connector">
509
+ <label>Delivery State/Region</label>
510
+ <frontend_type>select</frontend_type>
511
+ <source_model>email_connector/adminhtml_source_datafields</source_model>
512
+ <sort_order>215</sort_order>
513
+ <show_in_default>1</show_in_default>
514
+ <show_in_website>1</show_in_website>
515
+ <show_in_store>0</show_in_store>
516
+ </delivery_state>
517
+ <delivery_country translate="label" module="connector">
518
+ <label>Delivery Country</label>
519
+ <frontend_type>select</frontend_type>
520
+ <source_model>email_connector/adminhtml_source_datafields</source_model>
521
+ <sort_order>230</sort_order>
522
+ <show_in_default>1</show_in_default>
523
+ <show_in_website>1</show_in_website>
524
+ <show_in_store>0</show_in_store>
525
+ </delivery_country>
526
+ <delivery_postcode translate="label" module="connector">
527
+ <label>Delivery Zip/Postcode</label>
528
+ <frontend_type>select</frontend_type>
529
+ <source_model>email_connector/adminhtml_source_datafields</source_model>
530
+ <sort_order>240</sort_order>
531
+ <show_in_default>1</show_in_default>
532
+ <show_in_website>1</show_in_website>
533
+ <show_in_store>0</show_in_store>
534
+ </delivery_postcode>
535
+ <delivery_telephone translate="label" module="connector">
536
+ <label>Delivery Telephone</label>
537
+ <frontend_type>select</frontend_type>
538
+ <source_model>email_connector/adminhtml_source_datafields</source_model>
539
+ <sort_order>250</sort_order>
540
+ <show_in_default>1</show_in_default>
541
+ <show_in_website>1</show_in_website>
542
+ <show_in_store>0</show_in_store>
543
+ </delivery_telephone>
544
+ <sales_title translate="label" module="connector">
545
+ <label>Sales</label>
546
+ <frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
547
+ <sort_order>260</sort_order>
548
+ <show_in_default>1</show_in_default>
549
+ <show_in_website>1</show_in_website>
550
+ <show_in_store>0</show_in_store>
551
+ </sales_title>
552
+ <number_of_orders translate="label" module="connector">
553
+ <label>Total Number of Orders</label>
554
+ <frontend_type>select</frontend_type>
555
+ <source_model>email_connector/adminhtml_source_datafields</source_model>
556
+ <sort_order>270</sort_order>
557
+ <show_in_default>1</show_in_default>
558
+ <show_in_website>1</show_in_website>
559
+ <show_in_store>0</show_in_store>
560
+ </number_of_orders>
561
+ <average_order_value translate="label" module="connector">
562
+ <label>Average Order Value</label>
563
+ <frontend_type>select</frontend_type>
564
+ <source_model>email_connector/adminhtml_source_datafields</source_model>
565
+ <sort_order>280</sort_order>
566
+ <show_in_default>1</show_in_default>
567
+ <show_in_website>1</show_in_website>
568
+ <show_in_store>0</show_in_store>
569
+ </average_order_value>
570
+ <total_spend translate="label" module="connector">
571
+ <label>Total Spend</label>
572
+ <frontend_type>select</frontend_type>
573
+ <source_model>email_connector/adminhtml_source_datafields</source_model>
574
+ <sort_order>290</sort_order>
575
+ <show_in_default>1</show_in_default>
576
+ <show_in_website>1</show_in_website>
577
+ <show_in_store>0</show_in_store>
578
+ </total_spend>
579
+ <last_order_date translate="label" module="connector">
580
+ <label>Last Purchase Date</label>
581
+ <frontend_type>select</frontend_type>
582
+ <source_model>email_connector/adminhtml_source_datafields</source_model>
583
+ <sort_order>300</sort_order>
584
+ <show_in_default>1</show_in_default>
585
+ <show_in_website>1</show_in_website>
586
+ <show_in_store>0</show_in_store>
587
+ </last_order_date>
588
+ <last_order_id translate="label" module="connector">
589
+ <label>Last Order ID</label>
590
+ <frontend_type>select</frontend_type>
591
+ <source_model>email_connector/adminhtml_source_datafields</source_model>
592
+ <sort_order>310</sort_order>
593
+ <show_in_default>1</show_in_default>
594
+ <show_in_website>1</show_in_website>
595
+ <show_in_store>0</show_in_store>
596
+ </last_order_id>
597
+ <total_refund translate="label">
598
+ <label>Total Refund</label>
599
+ <frontend_type>select</frontend_type>
600
+ <source_model>email_connector/adminhtml_source_datafields</source_model>
601
+ <show_in_default>1</show_in_default>
602
+ <show_in_website>1</show_in_website>
603
+ <show_in_store>0</show_in_store>
604
+ <sort_order>320</sort_order>
605
+ <comment>Include total refunded ammount for customer.</comment>
606
+ </total_refund>
607
+ <custom_title translate="label" module="connector">
608
+ <label>Custom Attributes</label>
609
+ <frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
610
+ <sort_order>330</sort_order>
611
+ <show_in_default>1</show_in_default>
612
+ <show_in_website>1</show_in_website>
613
+ <show_in_store>0</show_in_store>
614
+ </custom_title>
615
+ <custom_attributes translate="label" module="connector">
616
+ <label>Customer</label>
617
+ <frontend_model>email_connector/adminhtml_config_customdatafields</frontend_model>
618
+ <backend_model>adminhtml/system_config_backend_serialized_array</backend_model>
619
+ <source_model>email_connector/adminhtml_source_customer_attributes_select</source_model>
620
+ <sort_order>340</sort_order>
621
+ <show_in_default>1</show_in_default>
622
+ <show_in_website>1</show_in_website>
623
+ <show_in_store>0</show_in_store>
624
+ </custom_attributes>
625
+ <validator translate="label" module="connector">
626
+ <label>Validation Block</label>
627
+ <frontend_type>select</frontend_type>
628
+ <source_model>email_connector/adminhtml_source_datafields</source_model>
629
+ <frontend_model>email_connector/adminhtml_system_config_validator</frontend_model>
630
+ <sort_order>920</sort_order>
631
+ <show_in_default>1</show_in_default>
632
+ <show_in_website>1</show_in_website>
633
+ <show_in_store>0</show_in_store>
634
+ <can_be_empty>1</can_be_empty>
635
+ <expanded>1</expanded>
636
+ </validator>
637
+ </fields>
638
+ </customer_data>
639
+ <dynamic_datafield translate="label" module="connector">
640
+ <label>Create Data Field</label>
641
+ <sort_order>30</sort_order>
642
+ <show_in_default>1</show_in_default>
643
+ <show_in_website>1</show_in_website>
644
+ <show_in_store>0</show_in_store>
645
+ <fields>
646
+ <datafield_name module="connector">
647
+ <label>Data Field Name</label>
648
+ <frontend_type>text</frontend_type>
649
+ <frontend_model>email_connector/adminhtml_system_config_datafield</frontend_model>
650
+ <sort_order>10</sort_order>
651
+ <show_in_default>1</show_in_default>
652
+ <show_in_website>1</show_in_website>
653
+ <show_in_store>0</show_in_store>
654
+ </datafield_name>
655
+ <datafield_type translate="label" module="connector">
656
+ <label>Data Field Type</label>
657
+ <frontend_type>select</frontend_type>
658
+ <source_model>email_connector/adminhtml_source_datamapping_datafieldtype</source_model>
659
+ <sort_order>20</sort_order>
660
+ <show_in_default>1</show_in_default>
661
+ <show_in_website>1</show_in_website>
662
+ <show_in_store>0</show_in_store>
663
+ <expended>1</expended>
664
+ </datafield_type>
665
+ <datafield_button translate="label button_label" module="connector">
666
+ <label />
667
+ <button_label>Create New Data Field</button_label>
668
+ <frontend_model>email_connector/adminhtml_system_dynamic_datafieldbutton</frontend_model>
669
+ <sort_order>30</sort_order>
670
+ <show_in_default>1</show_in_default>
671
+ <show_in_website>1</show_in_website>
672
+ <show_in_store>0</show_in_store>
673
+ </datafield_button>
674
+ </fields>
675
+ </dynamic_datafield>
676
+ <sweet_tooth>
677
+ <label>Sweet Tooth Rewards</label>
678
+ <sort_order>40</sort_order>
679
+ <show_in_default>1</show_in_default>
680
+ <show_in_website>1</show_in_website>
681
+ <show_in_store>0</show_in_store>
682
+ <fields>
683
+ <active translate="label" module="connector">
684
+ <label>Enabled</label>
685
+ <frontend_type>select</frontend_type>
686
+ <source_model>email_connector/adminhtml_source_sweettooth_yesno</source_model>
687
+ <sort_order>0</sort_order>
688
+ <show_in_default>1</show_in_default>
689
+ <show_in_website>1</show_in_website>
690
+ <show_in_store>0</show_in_store>
691
+ <comment><![CDATA[<p id="sweet-tooth-warning" style="display:none;" class="notice">SWEET TOOTH EXTENSION HAS TO BE INSTALLED AND ENABLED IN ORDER TO USE THIS FEATURE.</p>]]></comment>
692
+ </active>
693
+ <title translate="label" module="connector">
694
+ <label>Data Fields Mapping</label>
695
+ <frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
696
+ <sort_order>10</sort_order>
697
+ <show_in_default>1</show_in_default>
698
+ <show_in_website>1</show_in_website>
699
+ <show_in_store>0</show_in_store>
700
+ <depends><active>1</active></depends>
701
+ </title>
702
+ <reward_point_balance translate="label" module="connector">
703
+ <label>Current Point Balance</label>
704
+ <frontend_type>select</frontend_type>
705
+ <source_model>email_connector/adminhtml_source_datafields</source_model>
706
+ <sort_order>20</sort_order>
707
+ <show_in_default>1</show_in_default>
708
+ <show_in_website>1</show_in_website>
709
+ <show_in_store>0</show_in_store>
710
+ <depends><active>1</active></depends>
711
+ </reward_point_balance>
712
+ <reward_point_pending translate="label" module="connector">
713
+ <label>Points Pending An Event</label>
714
+ <frontend_type>select</frontend_type>
715
+ <source_model>email_connector/adminhtml_source_datafields</source_model>
716
+ <sort_order>30</sort_order>
717
+ <show_in_default>1</show_in_default>
718
+ <show_in_website>1</show_in_website>
719
+ <show_in_store>0</show_in_store>
720
+ <depends><active>1</active></depends>
721
+ </reward_point_pending>
722
+ <reward_point_pending_time translate="label" module="connector">
723
+ <label>Points Pending A Date</label>
724
+ <frontend_type>select</frontend_type>
725
+ <source_model>email_connector/adminhtml_source_datafields</source_model>
726
+ <sort_order>40</sort_order>
727
+ <show_in_default>1</show_in_default>
728
+ <show_in_website>1</show_in_website>
729
+ <show_in_store>0</show_in_store>
730
+ <depends><active>1</active></depends>
731
+ </reward_point_pending_time>
732
+ <reward_point_on_hold translate="label" module="connector">
733
+ <label>Current On Hold Points</label>
734
+ <frontend_type>select</frontend_type>
735
+ <source_model>email_connector/adminhtml_source_datafields</source_model>
736
+ <sort_order>50</sort_order>
737
+ <show_in_default>1</show_in_default>
738
+ <show_in_website>1</show_in_website>
739
+ <show_in_store>0</show_in_store>
740
+ <depends><active>1</active></depends>
741
+ </reward_point_on_hold>
742
+ <reward_point_expiration translate="label" module="connector">
743
+ <label>Points Expiry Date</label>
744
+ <frontend_type>select</frontend_type>
745
+ <source_model>email_connector/adminhtml_source_datafields</source_model>
746
+ <sort_order>60</sort_order>
747
+ <show_in_default>1</show_in_default>
748
+ <show_in_website>1</show_in_website>
749
+ <show_in_store>0</show_in_store>
750
+ <depends><active>1</active></depends>
751
+ </reward_point_expiration>
752
+ <reward_point_last_earn translate="label" module="connector">
753
+ <label>Last Date Points Earned</label>
754
+ <frontend_type>select</frontend_type>
755
+ <source_model>email_connector/adminhtml_source_datafields</source_model>
756
+ <sort_order>70</sort_order>
757
+ <show_in_default>1</show_in_default>
758
+ <show_in_website>1</show_in_website>
759
+ <show_in_store>0</show_in_store>
760
+ <depends><active>1</active></depends>
761
+ </reward_point_last_earn>
762
+ <reward_point_last_spent translate="label" module="connector">
763
+ <label>Last Date Points Spent</label>
764
+ <frontend_type>select</frontend_type>
765
+ <source_model>email_connector/adminhtml_source_datafields</source_model>
766
+ <sort_order>70</sort_order>
767
+ <show_in_default>1</show_in_default>
768
+ <show_in_website>1</show_in_website>
769
+ <show_in_store>0</show_in_store>
770
+ <depends><active>1</active></depends>
771
+ </reward_point_last_spent>
772
+ </fields>
773
+ </sweet_tooth>
774
+ </groups>
775
+ </connector_data_mapping>
776
+ <connector_roi_tracking translate="label" module="connector">
777
+ <label><![CDATA[ROI & Tracking]]></label>
778
+ <tab>connector</tab>
779
+ <frontend_type>text</frontend_type>
780
+ <sort_order>4000</sort_order>
781
+ <show_in_default>1</show_in_default>
782
+ <show_in_website>1</show_in_website>
783
+ <show_in_store>0</show_in_store>
784
+ <groups>
785
+ <page_tracking translate="label" module="connector">
786
+ <label>Page Tracking</label>
787
+ <frontend_type>text</frontend_type>
788
+ <sort_order>10</sort_order>
789
+ <show_in_default>1</show_in_default>
790
+ <show_in_website>1</show_in_website>
791
+ <show_in_store>0</show_in_store>
792
+ <expanded>1</expanded>
793
+ <fields>
794
+ <enabled translate="label" module="connector">
795
+ <label>Enabled</label>
796
+ <frontend_type>select</frontend_type>
797
+ <source_model>adminhtml/system_config_source_yesno</source_model>
798
+ <sort_order>10</sort_order>
799
+ <show_in_default>1</show_in_default>
800
+ <show_in_website>1</show_in_website>
801
+ <show_in_store>0</show_in_store>
802
+ </enabled>
803
+ </fields>
804
+ </page_tracking>
805
+ <roi_tracking translate="label" module="connector">
806
+ <label>ROI Tracking</label>
807
+ <frontend_type>text</frontend_type>
808
+ <sort_order>20</sort_order>
809
+ <show_in_default>1</show_in_default>
810
+ <show_in_website>1</show_in_website>
811
+ <show_in_store>0</show_in_store>
812
+ <expanded>1</expanded>
813
+ <fields>
814
+ <enabled translate="label" module="connector">
815
+ <label>Enabled</label>
816
+ <frontend_type>select</frontend_type>
817
+ <source_model>adminhtml/system_config_source_yesno</source_model>
818
+ <sort_order>10</sort_order>
819
+ <show_in_default>1</show_in_default>
820
+ <show_in_website>1</show_in_website>
821
+ <show_in_store>0</show_in_store>
822
+ </enabled>
823
+ </fields>
824
+ </roi_tracking>
825
+ </groups>
826
+ </connector_roi_tracking>
827
+ <connector_lost_baskets translate="label" module="connector">
828
+ <label><![CDATA[Abandoned Carts]]></label>
829
+ <tab>connector</tab>
830
+ <frontend_type>text</frontend_type>
831
+ <sort_order>6000</sort_order>
832
+ <show_in_default>1</show_in_default>
833
+ <show_in_website>1</show_in_website>
834
+ <show_in_store>0</show_in_store>
835
+ <groups>
836
+ <customers translate="label" module="connector">
837
+ <label>Customers</label>
838
+ <frontend_type>text</frontend_type>
839
+ <sort_order>10</sort_order>
840
+ <show_in_default>1</show_in_default>
841
+ <show_in_website>1</show_in_website>
842
+ <show_in_store>1</show_in_store>
843
+ <expanded>1</expanded>
844
+ <fields>
845
+ <heading_1 translate="label" module="connector">
846
+ <label>Abandoned Cart 1</label>
847
+ <frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
848
+ <sort_order>10</sort_order>
849
+ <show_in_default>1</show_in_default>
850
+ <show_in_website>1</show_in_website>
851
+ <show_in_store>1</show_in_store>
852
+ </heading_1>
853
+ <enabled_1 translate="label" module="connector">
854
+ <label>Enabled/Disabled</label>
855
+ <frontend_type>select</frontend_type>
856
+ <source_model>adminhtml/system_config_source_enabledisable</source_model>
857
+ <sort_order>20</sort_order>
858
+ <show_in_default>1</show_in_default>
859
+ <show_in_website>1</show_in_website>
860
+ <show_in_store>1</show_in_store>
861
+ </enabled_1>
862
+ <send_after_1 translate="label" module="connector">
863
+ <label>Send After (min)</label>
864
+ <frontend_type>select</frontend_type>
865
+ <source_model>email_connector/adminhtml_source_lostbaskets_intervalminute</source_model>
866
+ <sort_order>30</sort_order>
867
+ <show_in_default>1</show_in_default>
868
+ <show_in_website>1</show_in_website>
869
+ <show_in_store>1</show_in_store>
870
+ </send_after_1>
871
+ <campaign_1 translate="label" module="connector">
872
+ <label>Campaign To Send</label>
873
+ <frontend_type>select</frontend_type>
874
+ <source_model>email_connector/adminhtml_source_campaigns</source_model>
875
+ <sort_order>40</sort_order>
876
+ <show_in_default>1</show_in_default>
877
+ <show_in_website>1</show_in_website>
878
+ <show_in_store>1</show_in_store>
879
+ </campaign_1>
880
+ <heading_2 translate="label" module="connector">
881
+ <label>Abandoned Cart 2</label>
882
+ <frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
883
+ <sort_order>50</sort_order>
884
+ <show_in_default>1</show_in_default>
885
+ <show_in_website>1</show_in_website>
886
+ <show_in_store>1</show_in_store>
887
+ </heading_2>
888
+ <enabled_2 translate="label" module="connector">
889
+ <label>Enabled/Disabled</label>
890
+ <frontend_type>select</frontend_type>
891
+ <source_model>adminhtml/system_config_source_enabledisable</source_model>
892
+ <sort_order>60</sort_order>
893
+ <show_in_default>1</show_in_default>
894
+ <show_in_website>1</show_in_website>
895
+ <show_in_store>1</show_in_store>
896
+ </enabled_2>
897
+ <send_after_2 translate="label" module="connector">
898
+ <label>Send After (hrs)</label>
899
+ <frontend_type>select</frontend_type>
900
+ <source_model>email_connector/adminhtml_source_lostbaskets_interval</source_model>
901
+ <sort_order>70</sort_order>
902
+ <show_in_default>1</show_in_default>
903
+ <show_in_website>1</show_in_website>
904
+ <show_in_store>1</show_in_store>
905
+ </send_after_2>
906
+ <campaign_2 translate="label" module="connector">
907
+ <label>Campaign To Send</label>
908
+ <frontend_type>select</frontend_type>
909
+ <source_model>email_connector/adminhtml_source_campaigns</source_model>
910
+ <sort_order>80</sort_order>
911
+ <show_in_default>1</show_in_default>
912
+ <show_in_website>1</show_in_website>
913
+ <show_in_store>1</show_in_store>
914
+ </campaign_2>
915
+ <heading_3 translate="label" module="connector">
916
+ <label>Abandoned Cart 3</label>
917
+ <frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
918
+ <sort_order>90</sort_order>
919
+ <show_in_default>1</show_in_default>
920
+ <show_in_website>1</show_in_website>
921
+ <show_in_store>1</show_in_store>
922
+ </heading_3>
923
+ <enabled_3 translate="label" module="connector">
924
+ <label>Enabled/Disabled</label>
925
+ <frontend_type>select</frontend_type>
926
+ <source_model>adminhtml/system_config_source_enabledisable</source_model>
927
+ <sort_order>100</sort_order>
928
+ <show_in_default>1</show_in_default>
929
+ <show_in_website>1</show_in_website>
930
+ <show_in_store>1</show_in_store>
931
+ </enabled_3>
932
+ <send_after_3 translate="label" module="connector">
933
+ <label>Send After (hrs)</label>
934
+ <frontend_type>select</frontend_type>
935
+ <source_model>email_connector/adminhtml_source_lostbaskets_interval</source_model>
936
+ <sort_order>110</sort_order>
937
+ <show_in_default>1</show_in_default>
938
+ <show_in_website>1</show_in_website>
939
+ <show_in_store>1</show_in_store>
940
+ </send_after_3>
941
+ <campaign_3 translate="label" module="connector">
942
+ <label>Campaign To Send</label>
943
+ <frontend_type>select</frontend_type>
944
+ <source_model>email_connector/adminhtml_source_campaigns</source_model>
945
+ <sort_order>120</sort_order>
946
+ <show_in_default>1</show_in_default>
947
+ <show_in_website>1</show_in_website>
948
+ <show_in_store>1</show_in_store>
949
+ </campaign_3>
950
+ </fields>
951
+ </customers>
952
+ <guests translate="label" module="connector">
953
+ <label>Guests</label>
954
+ <frontend_type>text</frontend_type>
955
+ <sort_order>20</sort_order>
956
+ <show_in_default>1</show_in_default>
957
+ <show_in_website>1</show_in_website>
958
+ <show_in_store>0</show_in_store>
959
+ <fields>
960
+ <heading_1 translate="label" module="connector">
961
+ <label>Abandoned Cart 1</label>
962
+ <frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
963
+ <sort_order>10</sort_order>
964
+ <show_in_default>1</show_in_default>
965
+ <show_in_website>1</show_in_website>
966
+ <show_in_store>0</show_in_store>
967
+ </heading_1>
968
+ <enabled_1 translate="label" module="connector">
969
+ <label>Enabled/Disabled</label>
970
+ <frontend_type>select</frontend_type>
971
+ <source_model>adminhtml/system_config_source_enabledisable</source_model>
972
+ <sort_order>20</sort_order>
973
+ <show_in_default>1</show_in_default>
974
+ <show_in_website>1</show_in_website>
975
+ <show_in_store>0</show_in_store>
976
+ </enabled_1>
977
+ <send_after_1 translate="label" module="connector">
978
+ <label>Send After (min)</label>
979
+ <frontend_type>select</frontend_type>
980
+ <source_model>email_connector/adminhtml_source_lostbaskets_intervalminute</source_model>
981
+ <sort_order>30</sort_order>
982
+ <show_in_default>1</show_in_default>
983
+ <show_in_website>1</show_in_website>
984
+ <show_in_store>0</show_in_store>
985
+ </send_after_1>
986
+ <campaign_1 translate="label" module="connector">
987
+ <label>Campaign To Send</label>
988
+ <frontend_type>select</frontend_type>
989
+ <source_model>email_connector/adminhtml_source_campaigns</source_model>
990
+ <sort_order>40</sort_order>
991
+ <show_in_default>1</show_in_default>
992
+ <show_in_website>1</show_in_website>
993
+ <show_in_store>0</show_in_store>
994
+ </campaign_1>
995
+ <heading_2 translate="label" module="connector">
996
+ <label>Abandoned Cart 2</label>
997
+ <frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
998
+ <sort_order>50</sort_order>
999
+ <show_in_default>1</show_in_default>
1000
+ <show_in_website>1</show_in_website>
1001
+ <show_in_store>0</show_in_store>
1002
+ </heading_2>
1003
+ <enabled_2 translate="label" module="connector">
1004
+ <label>Enabled/Disabled</label>
1005
+ <frontend_type>select</frontend_type>
1006
+ <source_model>adminhtml/system_config_source_enabledisable</source_model>
1007
+ <sort_order>60</sort_order>
1008
+ <show_in_default>1</show_in_default>
1009
+ <show_in_website>1</show_in_website>
1010
+ <show_in_store>0</show_in_store>
1011
+ </enabled_2>
1012
+ <send_after_2 translate="label" module="connector">
1013
+ <label>Send After (hrs)</label>
1014
+ <frontend_type>select</frontend_type>
1015
+ <source_model>email_connector/adminhtml_source_lostbaskets_interval</source_model>
1016
+ <sort_order>70</sort_order>
1017
+ <show_in_default>1</show_in_default>
1018
+ <show_in_website>1</show_in_website>
1019
+ <show_in_store>0</show_in_store>
1020
+ </send_after_2>
1021
+ <campaign_2 translate="label" module="connector">
1022
+ <label>Campaign To Send</label>
1023
+ <frontend_type>select</frontend_type>
1024
+ <source_model>email_connector/adminhtml_source_campaigns</source_model>
1025
+ <sort_order>80</sort_order>
1026
+ <show_in_default>1</show_in_default>
1027
+ <show_in_website>1</show_in_website>
1028
+ <show_in_store>0</show_in_store>
1029
+ </campaign_2>
1030
+ <heading_3 translate="label" module="connector">
1031
+ <label>Abandoned Cart 3</label>
1032
+ <frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
1033
+ <sort_order>90</sort_order>
1034
+ <show_in_default>1</show_in_default>
1035
+ <show_in_website>1</show_in_website>
1036
+ <show_in_store>0</show_in_store>
1037
+ </heading_3>
1038
+ <enabled_3 translate="label" module="connector">
1039
+ <label>Enabled/Disabled</label>
1040
+ <frontend_type>select</frontend_type>
1041
+ <source_model>adminhtml/system_config_source_enabledisable</source_model>
1042
+ <sort_order>100</sort_order>
1043
+ <show_in_default>1</show_in_default>
1044
+ <show_in_website>1</show_in_website>
1045
+ <show_in_store>0</show_in_store>
1046
+ </enabled_3>
1047
+ <send_after_3 translate="label" module="connector">
1048
+ <label>Send After (hrs)</label>
1049
+ <frontend_type>select</frontend_type>
1050
+ <source_model>email_connector/adminhtml_source_lostbaskets_interval</source_model>
1051
+ <sort_order>110</sort_order>
1052
+ <show_in_default>1</show_in_default>
1053
+ <show_in_website>1</show_in_website>
1054
+ <show_in_store>0</show_in_store>
1055
+ </send_after_3>
1056
+ <campaign_3 translate="label" module="connector">
1057
+ <label>Campaign To Send</label>
1058
+ <frontend_type>select</frontend_type>
1059
+ <source_model>email_connector/adminhtml_source_campaigns</source_model>
1060
+ <sort_order>120</sort_order>
1061
+ <show_in_default>1</show_in_default>
1062
+ <show_in_website>1</show_in_website>
1063
+ <show_in_store>0</show_in_store>
1064
+ </campaign_3>
1065
+ </fields>
1066
+ </guests>
1067
+ </groups>
1068
+ </connector_lost_baskets>
1069
+ <connector_sms translate="label" module="connector">
1070
+ <label><![CDATA[SMS]]></label>
1071
+ <tab>connector</tab>
1072
+ <frontend_type>text</frontend_type>
1073
+ <sort_order>7000</sort_order>
1074
+ <show_in_default>1</show_in_default>
1075
+ <show_in_website>1</show_in_website>
1076
+ <show_in_store>1</show_in_store>
1077
+ <groups>
1078
+ <sms_one translate="label" module="connector">
1079
+ <label>SMS Message 1</label>
1080
+ <frontend_type>text</frontend_type>
1081
+ <sort_order>10</sort_order>
1082
+ <show_in_default>1</show_in_default>
1083
+ <show_in_website>1</show_in_website>
1084
+ <show_in_store>1</show_in_store>
1085
+ <fields>
1086
+ <enabled translate="label" module="connector">
1087
+ <label>Enabled</label>
1088
+ <frontend_type>select</frontend_type>
1089
+ <source_model>adminhtml/system_config_source_yesno</source_model>
1090
+ <sort_order>10</sort_order>
1091
+ <show_in_default>1</show_in_default>
1092
+ <show_in_website>1</show_in_website>
1093
+ <show_in_store>1</show_in_store>
1094
+ </enabled>
1095
+ <status translate="label" module="connector">
1096
+ <label>Order Status</label>
1097
+ <sort_order>20</sort_order>
1098
+ <frontend_type>select</frontend_type>
1099
+ <source_model>adminhtml/system_config_source_order_status</source_model>
1100
+ <show_in_default>1</show_in_default>
1101
+ <show_in_website>1</show_in_website>
1102
+ <show_in_store>1</show_in_store>
1103
+ </status>
1104
+ <message translate="label" module="connector">
1105
+ <label>Message</label>
1106
+ <frontend_type>textarea</frontend_type>
1107
+ <frontend_model>email_connector/adminhtml_system_sms_smsmessageone</frontend_model>
1108
+ <sort_order>30</sort_order>
1109
+ <show_in_default>1</show_in_default>
1110
+ <show_in_website>1</show_in_website>
1111
+ <show_in_store>1</show_in_store>
1112
+ <validate>validate-length maximum-length-160</validate>
1113
+ </message>
1114
+ </fields>
1115
+ </sms_one>
1116
+ <sms_two translate="label" module="connector">
1117
+ <label>SMS Message 2</label>
1118
+ <frontend_type>text</frontend_type>
1119
+ <sort_order>20</sort_order>
1120
+ <show_in_default>1</show_in_default>
1121
+ <show_in_website>1</show_in_website>
1122
+ <show_in_store>1</show_in_store>
1123
+ <fields>
1124
+ <enabled translate="label" module="connector">
1125
+ <label>Enabled</label>
1126
+ <frontend_type>select</frontend_type>
1127
+ <source_model>adminhtml/system_config_source_yesno</source_model>
1128
+ <sort_order>10</sort_order>
1129
+ <show_in_default>1</show_in_default>
1130
+ <show_in_website>1</show_in_website>
1131
+ <show_in_store>1</show_in_store>
1132
+ </enabled>
1133
+ <status translate="label" module="connector">
1134
+ <label>Order Status</label>
1135
+ <sort_order>20</sort_order>
1136
+ <frontend_type>select</frontend_type>
1137
+ <source_model>adminhtml/system_config_source_order_status</source_model>
1138
+ <show_in_default>1</show_in_default>
1139
+ <show_in_website>1</show_in_website>
1140
+ <show_in_store>1</show_in_store>
1141
+ </status>
1142
+ <message translate="label" module="connector">
1143
+ <label>Message</label>
1144
+ <frontend_type>textarea</frontend_type>
1145
+ <frontend_model>email_connector/adminhtml_system_sms_smsmessagetwo</frontend_model>
1146
+ <sort_order>30</sort_order>
1147
+ <show_in_default>1</show_in_default>
1148
+ <show_in_website>1</show_in_website>
1149
+ <show_in_store>1</show_in_store>
1150
+ <validate>validate-length maximum-length-160</validate>
1151
+ </message>
1152
+ </fields>
1153
+ </sms_two>
1154
+ <sms_three translate="label" module="connector">
1155
+ <label>SMS Message 3</label>
1156
+ <frontend_type>text</frontend_type>
1157
+ <sort_order>30</sort_order>
1158
+ <show_in_default>1</show_in_default>
1159
+ <show_in_website>1</show_in_website>
1160
+ <show_in_store>1</show_in_store>
1161
+ <fields>
1162
+ <enabled translate="label" module="connector">
1163
+ <label>Enabled</label>
1164
+ <frontend_type>select</frontend_type>
1165
+ <source_model>adminhtml/system_config_source_yesno</source_model>
1166
+ <sort_order>10</sort_order>
1167
+ <show_in_default>1</show_in_default>
1168
+ <show_in_website>1</show_in_website>
1169
+ <show_in_store>1</show_in_store>
1170
+ </enabled>
1171
+ <status translate="label" module="connector">
1172
+ <label>Order Status</label>
1173
+ <sort_order>20</sort_order>
1174
+ <frontend_type>select</frontend_type>
1175
+ <source_model>adminhtml/system_config_source_order_status</source_model>
1176
+ <show_in_default>1</show_in_default>
1177
+ <show_in_website>1</show_in_website>
1178
+ <show_in_store>1</show_in_store>
1179
+ </status>
1180
+ <message translate="label" module="connector">
1181
+ <label>Message</label>
1182
+ <frontend_type>textarea</frontend_type>
1183
+ <frontend_model>email_connector/adminhtml_system_sms_smsmessagethree</frontend_model>
1184
+ <sort_order>30</sort_order>
1185
+ <show_in_default>1</show_in_default>
1186
+ <show_in_website>1</show_in_website>
1187
+ <show_in_store>1</show_in_store>
1188
+ <validate>validate-length maximum-length-160</validate>
1189
+ </message>
1190
+ </fields>
1191
+ </sms_three>
1192
+ <sms_four translate="label" module="connector">
1193
+ <label>SMS Message 4</label>
1194
+ <frontend_type>text</frontend_type>
1195
+ <sort_order>40</sort_order>
1196
+ <show_in_default>1</show_in_default>
1197
+ <show_in_website>1</show_in_website>
1198
+ <show_in_store>1</show_in_store>
1199
+ <fields>
1200
+ <enabled translate="label" module="connector">
1201
+ <label>Enabled</label>
1202
+ <frontend_type>select</frontend_type>
1203
+ <source_model>adminhtml/system_config_source_yesno</source_model>
1204
+ <sort_order>10</sort_order>
1205
+ <show_in_default>1</show_in_default>
1206
+ <show_in_website>1</show_in_website>
1207
+ <show_in_store>1</show_in_store>
1208
+ </enabled>
1209
+ <status translate="label" module="connector">
1210
+ <label>Order Status</label>
1211
+ <sort_order>20</sort_order>
1212
+ <frontend_type>select</frontend_type>
1213
+ <source_model>adminhtml/system_config_source_order_status</source_model>
1214
+ <show_in_default>1</show_in_default>
1215
+ <show_in_website>1</show_in_website>
1216
+ <show_in_store>1</show_in_store>
1217
+ </status>
1218
+ <message translate="label" module="connector">
1219
+ <label>Message</label>
1220
+ <frontend_type>textarea</frontend_type>
1221
+ <frontend_model>email_connector/adminhtml_system_sms_smsmessagefour</frontend_model>
1222
+ <sort_order>30</sort_order>
1223
+ <show_in_default>1</show_in_default>
1224
+ <show_in_website>1</show_in_website>
1225
+ <show_in_store>1</show_in_store>
1226
+ <validate>validate-length maximum-length-160</validate>
1227
+ </message>
1228
+ </fields>
1229
+ </sms_four>
1230
+ </groups>
1231
+ </connector_sms>
1232
+ <connector_dynamic_content translate="label" module="connector">
1233
+ <label><![CDATA[Dynamic Content]]></label>
1234
+ <tab>connector</tab>
1235
+ <frontend_type>text</frontend_type>
1236
+ <sort_order>8000</sort_order>
1237
+ <show_in_default>1</show_in_default>
1238
+ <show_in_website>1</show_in_website>
1239
+ <show_in_store>0</show_in_store>
1240
+ <groups>
1241
+ <products translate="label" module="connector">
1242
+ <label>Dynamic Products</label>
1243
+ <frontend_type>text</frontend_type>
1244
+ <sort_order>20</sort_order>
1245
+ <show_in_default>1</show_in_default>
1246
+ <show_in_website>1</show_in_website>
1247
+ <show_in_store>0</show_in_store>
1248
+ <fields>
1249
+ <related translate="label" module="connector">
1250
+ <label>Related Products</label>
1251
+ <frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
1252
+ <sort_order>10</sort_order>
1253
+ <show_in_default>1</show_in_default>
1254
+ <show_in_website>1</show_in_website>
1255
+ <show_in_store>0</show_in_store>
1256
+ </related>
1257
+ <related_display_type translate="label" module="connector">
1258
+ <label>Display Type</label>
1259
+ <frontend_type>select</frontend_type>
1260
+ <source_model>email_connector/adminhtml_source_dynamic_displaytype</source_model>
1261
+ <sort_order>20</sort_order>
1262
+ <show_in_default>1</show_in_default>
1263
+ <show_in_website>1</show_in_website>
1264
+ <show_in_store>0</show_in_store>
1265
+ </related_display_type>
1266
+ <related_items_to_display translate="label" module="connector">
1267
+ <label>Items To Display</label>
1268
+ <frontend_type>select</frontend_type>
1269
+ <source_model>email_connector/adminhtml_source_dynamic_gridview</source_model>
1270
+ <sort_order>30</sort_order>
1271
+ <show_in_website>1</show_in_website>
1272
+ <show_in_default>1</show_in_default>
1273
+ <show_in_store>0</show_in_store>
1274
+ </related_items_to_display>
1275
+ <upsell translate="label" module="connector">
1276
+ <label>Up Sell Products</label>
1277
+ <frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
1278
+ <sort_order>40</sort_order>
1279
+ <show_in_default>1</show_in_default>
1280
+ <show_in_website>1</show_in_website>
1281
+ <show_in_store>0</show_in_store>
1282
+ </upsell>
1283
+ <upsell_display_type translate="label" module="connector">
1284
+ <label>Display Type</label>
1285
+ <frontend_type>select</frontend_type>
1286
+ <source_model>email_connector/adminhtml_source_dynamic_displaytype</source_model>
1287
+ <sort_order>50</sort_order>
1288
+ <show_in_default>1</show_in_default>
1289
+ <show_in_website>1</show_in_website>
1290
+ <show_in_store>0</show_in_store>
1291
+ </upsell_display_type>
1292
+ <upsell_items_to_display translate="label" module="connector">
1293
+ <label>Items To Display</label>
1294
+ <frontend_type>select</frontend_type>
1295
+ <source_model>email_connector/adminhtml_source_dynamic_gridview</source_model>
1296
+ <sort_order>60</sort_order>
1297
+ <show_in_website>1</show_in_website>
1298
+ <show_in_default>1</show_in_default>
1299
+ <show_in_store>0</show_in_store>
1300
+ </upsell_items_to_display>
1301
+ <crosssell translate="label" module="connector">
1302
+ <label>Cross Sell Products</label>
1303
+ <frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
1304
+ <sort_order>70</sort_order>
1305
+ <show_in_default>1</show_in_default>
1306
+ <show_in_website>1</show_in_website>
1307
+ <show_in_store>0</show_in_store>
1308
+ </crosssell>
1309
+ <crosssell_display_type translate="label" module="connector">
1310
+ <label>Display Type</label>
1311
+ <frontend_type>select</frontend_type>
1312
+ <source_model>email_connector/adminhtml_source_dynamic_displaytype</source_model>
1313
+ <sort_order>80</sort_order>
1314
+ <show_in_default>1</show_in_default>
1315
+ <show_in_website>1</show_in_website>
1316
+ <show_in_store>0</show_in_store>
1317
+ </crosssell_display_type>
1318
+ <crosssell_items_to_display translate="label" module="connector">
1319
+ <label>Items To Display</label>
1320
+ <frontend_type>select</frontend_type>
1321
+ <source_model>email_connector/adminhtml_source_dynamic_gridview</source_model>
1322
+ <sort_order>90</sort_order>
1323
+ <show_in_website>1</show_in_website>
1324
+ <show_in_default>1</show_in_default>
1325
+ <show_in_store>0</show_in_store>
1326
+ </crosssell_items_to_display>
1327
+ <bestsellers translate="label" module="connector">
1328
+ <label>Best Sellers</label>
1329
+ <frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
1330
+ <sort_order>100</sort_order>
1331
+ <show_in_default>1</show_in_default>
1332
+ <show_in_website>1</show_in_website>
1333
+ <show_in_store>0</show_in_store>
1334
+ </bestsellers>
1335
+ <bestsellers_display_type translate="label" module="connector">
1336
+ <label>Display Type</label>
1337
+ <frontend_type>select</frontend_type>
1338
+ <source_model>email_connector/adminhtml_source_dynamic_displaytype</source_model>
1339
+ <sort_order>110</sort_order>
1340
+ <show_in_default>1</show_in_default>
1341
+ <show_in_website>1</show_in_website>
1342
+ <show_in_store>0</show_in_store>
1343
+ </bestsellers_display_type>
1344
+ <bestsellers_items_to_display translate="label" module="connector">
1345
+ <label>Items To Display</label>
1346
+ <frontend_type>select</frontend_type>
1347
+ <source_model>email_connector/adminhtml_source_dynamic_gridview</source_model>
1348
+ <sort_order>120</sort_order>
1349
+ <show_in_website>1</show_in_website>
1350
+ <show_in_default>1</show_in_default>
1351
+ <show_in_store>0</show_in_store>
1352
+ </bestsellers_items_to_display>
1353
+ <bestsellers_time_period translate="label" module="connector">
1354
+ <label>Time Period</label>
1355
+ <frontend_type>select</frontend_type>
1356
+ <source_model>email_connector/adminhtml_source_dynamic_frequency</source_model>
1357
+ <sort_order>130</sort_order>
1358
+ <show_in_default>1</show_in_default>
1359
+ <show_in_website>1</show_in_website>
1360
+ <show_in_store>0</show_in_store>
1361
+ </bestsellers_time_period>
1362
+ <most_viewed translate="label" module="connector">
1363
+ <label>Most Viewed</label>
1364
+ <frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
1365
+ <sort_order>140</sort_order>
1366
+ <show_in_default>1</show_in_default>
1367
+ <show_in_website>1</show_in_website>
1368
+ <show_in_store>0</show_in_store>
1369
+ </most_viewed>
1370
+ <most_viewed_display_type translate="label" module="connector">
1371
+ <label>Display Type</label>
1372
+ <frontend_type>select</frontend_type>
1373
+ <source_model>email_connector/adminhtml_source_dynamic_displaytype</source_model>
1374
+ <sort_order>150</sort_order>
1375
+ <show_in_default>1</show_in_default>
1376
+ <show_in_website>1</show_in_website>
1377
+ <show_in_store>0</show_in_store>
1378
+ </most_viewed_display_type>
1379
+ <most_viewed_items_to_display translate="label" module="connector">
1380
+ <label>Items To Display</label>
1381
+ <frontend_type>select</frontend_type>
1382
+ <source_model>email_connector/adminhtml_source_dynamic_gridview</source_model>
1383
+ <sort_order>160</sort_order>
1384
+ <show_in_website>1</show_in_website>
1385
+ <show_in_default>1</show_in_default>
1386
+ <show_in_store>0</show_in_store>
1387
+ </most_viewed_items_to_display>
1388
+ <most_viewed_time_period translate="label" module="connector">
1389
+ <label>Time Period</label>
1390
+ <frontend_type>select</frontend_type>
1391
+ <source_model>email_connector/adminhtml_source_dynamic_frequency</source_model>
1392
+ <sort_order>170</sort_order>
1393
+ <show_in_default>1</show_in_default>
1394
+ <show_in_website>1</show_in_website>
1395
+ <show_in_store>0</show_in_store>
1396
+ </most_viewed_time_period>
1397
+ <recently_viewed translate="label" module="connector">
1398
+ <label>Recently Viewed</label>
1399
+ <frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
1400
+ <sort_order>180</sort_order>
1401
+ <show_in_default>1</show_in_default>
1402
+ <show_in_website>1</show_in_website>
1403
+ <show_in_store>0</show_in_store>
1404
+ </recently_viewed>
1405
+ <recently_viewed_display_type translate="label" module="connector">
1406
+ <label>Display Type</label>
1407
+ <frontend_type>select</frontend_type>
1408
+ <source_model>email_connector/adminhtml_source_dynamic_displaytype</source_model>
1409
+ <sort_order>190</sort_order>
1410
+ <show_in_default>1</show_in_default>
1411
+ <show_in_website>1</show_in_website>
1412
+ <show_in_store>0</show_in_store>
1413
+ </recently_viewed_display_type>
1414
+ <recently_viewed_items_to_display translate="label" module="connector">
1415
+ <label>items To Display</label>
1416
+ <frontend_type>select</frontend_type>
1417
+ <source_model>email_connector/adminhtml_source_dynamic_gridview</source_model>
1418
+ <sort_order>200</sort_order>
1419
+ <show_in_default>1</show_in_default>
1420
+ <show_in_website>1</show_in_website>
1421
+ <show_in_store>0</show_in_store>
1422
+ </recently_viewed_items_to_display>
1423
+ <validator>
1424
+ <frontend_type>hidden</frontend_type>
1425
+ <frontend_model>email_connector/adminhtml_system_dynamic_gridlist</frontend_model>
1426
+ <sort_order>210</sort_order>
1427
+ <show_in_default>1</show_in_default>
1428
+ <show_in_website>1</show_in_website>
1429
+ <show_in_store>0</show_in_store>
1430
+ <can_be_empty>1</can_be_empty>
1431
+ </validator>
1432
+ </fields>
1433
+ </products>
1434
+ <external_dynamic_content_urls translate="label" module="connector">
1435
+ <label><![CDATA[External Dynamic Content URL's]]></label>
1436
+ <frontend_type>text</frontend_type>
1437
+ <sort_order>10</sort_order>
1438
+ <show_in_default>1</show_in_default>
1439
+ <show_in_website>1</show_in_website>
1440
+ <show_in_store>0</show_in_store>
1441
+ <fields>
1442
+ <passcode translate="label comment" module="connector">
1443
+ <label>Passcode</label>
1444
+ <frontend_type>text</frontend_type>
1445
+ <sort_order>10</sort_order>
1446
+ <show_in_default>1</show_in_default>
1447
+ <show_in_website>1</show_in_website>
1448
+ <show_in_store>0</show_in_store>
1449
+ <comment><![CDATA[Recommended: Set a passcode so that basket contents and coupon codes can only be viewed if the following passcode is sent with the request.]]></comment>
1450
+ </passcode>
1451
+ <lost_basket_title translate="label" module="connector">
1452
+ <label>Lost Baskets</label>
1453
+ <frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
1454
+ <sort_order>20</sort_order>
1455
+ <show_in_default>1</show_in_default>
1456
+ <show_in_website>1</show_in_website>
1457
+ <show_in_store>0</show_in_store>
1458
+ </lost_basket_title>
1459
+ <lost_basket_url translate="label" module="connector">
1460
+ <label>Baskets Content URL</label>
1461
+ <frontend_type>label</frontend_type>
1462
+ <frontend_model>email_connector/adminhtml_system_dynamic_lostbasket</frontend_model>
1463
+ <sort_order>30</sort_order>
1464
+ <show_in_default>1</show_in_default>
1465
+ <show_in_website>1</show_in_website>
1466
+ <show_in_store>0</show_in_store>
1467
+ </lost_basket_url>
1468
+ <coupon_code_title title="label" module="connector">
1469
+ <label>Coupon Codes</label>
1470
+ <frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
1471
+ <sort_order>40</sort_order>
1472
+ <show_in_website>1</show_in_website>
1473
+ <show_in_default>1</show_in_default>
1474
+ <show_in_store>0</show_in_store>
1475
+ </coupon_code_title>
1476
+ <coupon_code_url translate="label" module="connector">
1477
+ <label>Coupon Codes URL</label>
1478
+ <frontend_type>label</frontend_type>
1479
+ <frontend_model>email_connector/adminhtml_system_dynamic_couponinfo</frontend_model>
1480
+ <sort_order>50</sort_order>
1481
+ <show_in_default>1</show_in_default>
1482
+ <show_in_website>1</show_in_website>
1483
+ <show_in_store>0</show_in_store>
1484
+ </coupon_code_url>
1485
+ <dynamic_content_url translate="label" module="connector">
1486
+ <label>Product Recommendation</label>
1487
+ <frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
1488
+ <sort_order>60</sort_order>
1489
+ <show_in_default>1</show_in_default>
1490
+ <show_in_website>1</show_in_website>
1491
+ <show_in_store>0</show_in_store>
1492
+ </dynamic_content_url>
1493
+ <related_products_url translate="label" module="connector">
1494
+ <label>Related Products URL</label>
1495
+ <frontend_type>label</frontend_type>
1496
+ <frontend_model>email_connector/adminhtml_system_dynamic_related</frontend_model>
1497
+ <sort_order>70</sort_order>
1498
+ <show_in_default>1</show_in_default>
1499
+ <show_in_website>1</show_in_website>
1500
+ <show_in_store>0</show_in_store>
1501
+ </related_products_url>
1502
+ <upsell_products_url translate="label" module="connector">
1503
+ <label>Up-Sell Products URL</label>
1504
+ <frontend_type>label</frontend_type>
1505
+ <frontend_model>email_connector/adminhtml_system_dynamic_upsell</frontend_model>
1506
+ <sort_order>80</sort_order>
1507
+ <show_in_default>1</show_in_default>
1508
+ <show_in_website>1</show_in_website>
1509
+ <show_in_store>0</show_in_store>
1510
+ </upsell_products_url>
1511
+ <crosssell_products_url translate="label" module="connector">
1512
+ <label>Cross-Sell Products URL</label>
1513
+ <frontend_type>label</frontend_type>
1514
+ <frontend_model>email_connector/adminhtml_system_dynamic_crosssell</frontend_model>
1515
+ <sort_order>90</sort_order>
1516
+ <show_in_default>1</show_in_default>
1517
+ <show_in_website>1</show_in_website>
1518
+ <show_in_store>0</show_in_store>
1519
+ </crosssell_products_url>
1520
+ <best_sellers_url translate="label" module="connector">
1521
+ <label>Best Sellers URL</label>
1522
+ <frontend_type>label</frontend_type>
1523
+ <frontend_model>email_connector/adminhtml_system_dynamic_bestsellers</frontend_model>
1524
+ <sort_order>100</sort_order>
1525
+ <show_in_default>1</show_in_default>
1526
+ <show_in_website>1</show_in_website>
1527
+ <show_in_store>0</show_in_store>
1528
+ </best_sellers_url>
1529
+ <most_viewed_url translate="label" module="connector">
1530
+ <label>Most Viewed URL</label>
1531
+ <frontend_type>label</frontend_type>
1532
+ <frontend_model>email_connector/adminhtml_system_dynamic_mostviewed</frontend_model>
1533
+ <sort_order>110</sort_order>
1534
+ <show_in_default>1</show_in_default>
1535
+ <show_in_website>1</show_in_website>
1536
+ <show_in_store>0</show_in_store>
1537
+ </most_viewed_url>
1538
+ <product_push_url translate="label" module="connector">
1539
+ <label>Product Push URL</label>
1540
+ <frontend_type>label</frontend_type>
1541
+ <frontend_model>email_connector/adminhtml_system_dynamic_productpush</frontend_model>
1542
+ <sort_order>130</sort_order>
1543
+ <show_in_default>1</show_in_default>
1544
+ <show_in_website>1</show_in_website>
1545
+ <show_in_store>0</show_in_store>
1546
+ </product_push_url>
1547
+ <recently_viewed_url translate="label" module="connector">
1548
+ <label>Recently Viewed</label>
1549
+ <frontend_type>label</frontend_type>
1550
+ <frontend_model>email_connector/adminhtml_system_dynamic_recentlyviewed</frontend_model>
1551
+ <sort_order>120</sort_order>
1552
+ <show_in_default>1</show_in_default>
1553
+ <show_in_website>1</show_in_website>
1554
+ <show_in_store>0</show_in_store>
1555
+ </recently_viewed_url>
1556
+ <transactional_email_heading translate="label" module="connector">
1557
+ <label>Transactional Emails</label>
1558
+ <frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
1559
+ <sort_order>140</sort_order>
1560
+ <show_in_default>1</show_in_default>
1561
+ <show_in_website>1</show_in_website>
1562
+ <show_in_store>0</show_in_store>
1563
+ </transactional_email_heading>
1564
+ <new_order_url translate="label" module="connector">
1565
+ <label>New Order</label>
1566
+ <frontend_type>label</frontend_type>
1567
+ <frontend_model>email_connector/adminhtml_system_url_neworder</frontend_model>
1568
+ <sort_order>150</sort_order>
1569
+ <show_in_default>1</show_in_default>
1570
+ <show_in_website>1</show_in_website>
1571
+ <show_in_store>0</show_in_store>
1572
+ </new_order_url>
1573
+ <new_order_guest_url translate="label" module="connector">
1574
+ <label>New Order for Guest</label>
1575
+ <frontend_type>label</frontend_type>
1576
+ <frontend_model>email_connector/adminhtml_system_url_neworderguest</frontend_model>
1577
+ <sort_order>160</sort_order>
1578
+ <show_in_default>1</show_in_default>
1579
+ <show_in_website>1</show_in_website>
1580
+ <show_in_store>0</show_in_store>
1581
+ </new_order_guest_url>
1582
+ <order_update_url translate="label" module="connector">
1583
+ <label>Order Update</label>
1584
+ <frontend_type>label</frontend_type>
1585
+ <frontend_model>email_connector/adminhtml_system_url_orderupdate</frontend_model>
1586
+ <sort_order>170</sort_order>
1587
+ <show_in_default>1</show_in_default>
1588
+ <show_in_website>1</show_in_website>
1589
+ <show_in_store>0</show_in_store>
1590
+ </order_update_url>
1591
+ <order_update_guest_url translate="label" module="connector">
1592
+ <label>Order Update for Guest</label>
1593
+ <frontend_type>label</frontend_type>
1594
+ <frontend_model>email_connector/adminhtml_system_url_orderupdateguest</frontend_model>
1595
+ <sort_order>180</sort_order>
1596
+ <show_in_default>1</show_in_default>
1597
+ <show_in_website>1</show_in_website>
1598
+ <show_in_store>0</show_in_store>
1599
+ </order_update_guest_url>
1600
+ <new_invoice_url translate="label" module="connector">
1601
+ <label>New Invoice</label>
1602
+ <frontend_type>label</frontend_type>
1603
+ <frontend_model>email_connector/adminhtml_system_url_newinvoice</frontend_model>
1604
+ <sort_order>190</sort_order>
1605
+ <show_in_default>1</show_in_default>
1606
+ <show_in_website>1</show_in_website>
1607
+ <show_in_store>0</show_in_store>
1608
+ </new_invoice_url>
1609
+ <new_invoice_guest_url translate="label" module="connector">
1610
+ <label>New Invoice for Guest</label>
1611
+ <frontend_type>label</frontend_type>
1612
+ <frontend_model>email_connector/adminhtml_system_url_newinvoiceguest</frontend_model>
1613
+ <sort_order>200</sort_order>
1614
+ <show_in_default>1</show_in_default>
1615
+ <show_in_website>1</show_in_website>
1616
+ <show_in_store>0</show_in_store>
1617
+ </new_invoice_guest_url>
1618
+ <invoice_update_url translate="label" module="connector">
1619
+ <label>Invoice Update</label>
1620
+ <frontend_type>label</frontend_type>
1621
+ <frontend_model>email_connector/adminhtml_system_url_invoiceupdate</frontend_model>
1622
+ <sort_order>210</sort_order>
1623
+ <show_in_default>1</show_in_default>
1624
+ <show_in_website>1</show_in_website>
1625
+ <show_in_store>0</show_in_store>
1626
+ </invoice_update_url>
1627
+ <invoice_update_guest_url translate="label" module="connector">
1628
+ <label>Invoice Update for Guest</label>
1629
+ <frontend_type>label</frontend_type>
1630
+ <frontend_model>email_connector/adminhtml_system_url_invoiceupdateguest</frontend_model>
1631
+ <sort_order>220</sort_order>
1632
+ <show_in_default>1</show_in_default>
1633
+ <show_in_website>1</show_in_website>
1634
+ <show_in_store>0</show_in_store>
1635
+ </invoice_update_guest_url>
1636
+ <new_creditmemo_url translate="label" module="connector">
1637
+ <label>New Credit Memo</label>
1638
+ <frontend_type>label</frontend_type>
1639
+ <frontend_model>email_connector/adminhtml_system_url_newcreditmemo</frontend_model>
1640
+ <sort_order>230</sort_order>
1641
+ <show_in_default>1</show_in_default>
1642
+ <show_in_website>1</show_in_website>
1643
+ <show_in_store>0</show_in_store>
1644
+ </new_creditmemo_url>
1645
+ <new_creditmemo_guest_url translate="label" module="connector">
1646
+ <label>New Credit Memo Guest</label>
1647
+ <frontend_type>label</frontend_type>
1648
+ <frontend_model>email_connector/adminhtml_system_url_newcreditmemoguest</frontend_model>
1649
+ <sort_order>240</sort_order>
1650
+ <show_in_default>1</show_in_default>
1651
+ <show_in_website>1</show_in_website>
1652
+ <show_in_store>0</show_in_store>
1653
+ </new_creditmemo_guest_url>
1654
+ <creditmemo_update_url translate="label" module="connector">
1655
+ <label>Credit Memo Update</label>
1656
+ <frontend_type>label</frontend_type>
1657
+ <frontend_model>email_connector/adminhtml_system_url_creditmemoupdate</frontend_model>
1658
+ <sort_order>250</sort_order>
1659
+ <show_in_default>1</show_in_default>
1660
+ <show_in_website>1</show_in_website>
1661
+ <show_in_store>0</show_in_store>
1662
+ </creditmemo_update_url>
1663
+ <creditmemo_update_guest_url translate="label" module="connector">
1664
+ <label>Credit Memo Update for Guest</label>
1665
+ <frontend_type>label</frontend_type>
1666
+ <frontend_model>email_connector/adminhtml_system_url_creditmemoupdateguest</frontend_model>
1667
+ <sort_order>260</sort_order>
1668
+ <show_in_default>1</show_in_default>
1669
+ <show_in_website>1</show_in_website>
1670
+ <show_in_store>0</show_in_store>
1671
+ </creditmemo_update_guest_url>
1672
+ <new_shipment_url translate="label" module="connector">
1673
+ <label>New Shipment</label>
1674
+ <frontend_type>label</frontend_type>
1675
+ <frontend_model>email_connector/adminhtml_system_url_newshipment</frontend_model>
1676
+ <sort_order>270</sort_order>
1677
+ <show_in_default>1</show_in_default>
1678
+ <show_in_website>1</show_in_website>
1679
+ <show_in_store>0</show_in_store>
1680
+ </new_shipment_url>
1681
+ <new_shipment_guest_url translate="label" module="connector">
1682
+ <label>New Shipment for Guest</label>
1683
+ <frontend_type>label</frontend_type>
1684
+ <frontend_model>email_connector/adminhtml_system_url_newshipmentguest</frontend_model>
1685
+ <sort_order>280</sort_order>
1686
+ <show_in_default>1</show_in_default>
1687
+ <show_in_website>1</show_in_website>
1688
+ <show_in_store>0</show_in_store>
1689
+ </new_shipment_guest_url>
1690
+ <shipment_update_url translate="label" module="connector">
1691
+ <label>Shipment Update</label>
1692
+ <frontend_type>label</frontend_type>
1693
+ <frontend_model>email_connector/adminhtml_system_url_shipmentupdate</frontend_model>
1694
+ <sort_order>290</sort_order>
1695
+ <show_in_default>1</show_in_default>
1696
+ <show_in_website>1</show_in_website>
1697
+ <show_in_store>0</show_in_store>
1698
+ </shipment_update_url>
1699
+ <shipment_update_guest_url translate="label" module="connector">
1700
+ <label>Shipment Update for Guest</label>
1701
+ <frontend_type>label</frontend_type>
1702
+ <frontend_model>email_connector/adminhtml_system_url_shipmentupdateguest</frontend_model>
1703
+ <sort_order>300</sort_order>
1704
+ <show_in_default>1</show_in_default>
1705
+ <show_in_website>1</show_in_website>
1706
+ <show_in_store>0</show_in_store>
1707
+ </shipment_update_guest_url>
1708
+ </fields>
1709
+ </external_dynamic_content_urls>
1710
+ <manual_product_search translate="label" module="connector">
1711
+ <label>Manual Product Push</label>
1712
+ <frontend_type>text</frontend_type>
1713
+ <sort_order>30</sort_order>
1714
+ <show_in_default>1</show_in_default>
1715
+ <show_in_website>1</show_in_website>
1716
+ <show_in_store>0</show_in_store>
1717
+ <expanded>1</expanded>
1718
+ <fields>
1719
+ <settings_title tranlate="label" module="connector">
1720
+ <label>Settings</label>
1721
+ <frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
1722
+ <sort_order>10</sort_order>
1723
+ <show_in_default>1</show_in_default>
1724
+ <show_in_website>1</show_in_website>
1725
+ <show_in_store>0</show_in_store>
1726
+ </settings_title>
1727
+ <display_type translate="label" module="connector">
1728
+ <label>Display Type</label>
1729
+ <frontend_type>select</frontend_type>
1730
+ <source_model>email_connector/adminhtml_source_dynamic_displaytype</source_model>
1731
+ <sort_order>50</sort_order>
1732
+ <show_in_default>1</show_in_default>
1733
+ <show_in_website>1</show_in_website>
1734
+ <show_in_store>0</show_in_store>
1735
+ </display_type>
1736
+ <items_to_display translate="label" module="connector">
1737
+ <label>Items To Display</label>
1738
+ <frontend_type>select</frontend_type>
1739
+ <source_model>email_connector/adminhtml_source_dynamic_gridview</source_model>
1740
+ <sort_order>60</sort_order>
1741
+ <show_in_website>1</show_in_website>
1742
+ <show_in_default>1</show_in_default>
1743
+ <show_in_store>0</show_in_store>
1744
+ </items_to_display>
1745
+ <products_push_title translate="label" module="connector">
1746
+ <label>Products</label>
1747
+ <frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
1748
+ <sort_order>80</sort_order>
1749
+ <show_in_default>1</show_in_default>
1750
+ <show_in_website>1</show_in_website>
1751
+ <show_in_store>0</show_in_store>
1752
+ </products_push_title>
1753
+ <products_push_items translate="label comment" module="connector">
1754
+ <label>Products</label>
1755
+ <frontend_type>text</frontend_type>
1756
+ <sort_order>90</sort_order>
1757
+ <show_in_default>1</show_in_default>
1758
+ <show_in_website>1</show_in_website>
1759
+ <show_in_store>0</show_in_store>
1760
+ <comment><![CDATA[Comma Separated Product Id's]]></comment>
1761
+ </products_push_items>
1762
+ </fields>
1763
+ </manual_product_search>
1764
+ <fallback_products translate="label" module="connector">
1765
+ <label>Fallback Products</label>
1766
+ <frontend_type>text</frontend_type>
1767
+ <sort_order>40</sort_order>
1768
+ <show_in_default>1</show_in_default>
1769
+ <show_in_website>1</show_in_website>
1770
+ <show_in_store>0</show_in_store>
1771
+ <fields>
1772
+ <product_list translate="label comment" module="connector">
1773
+ <label>Products</label>
1774
+ <frontend_type>text</frontend_type>
1775
+ <sort_order>10</sort_order>
1776
+ <show_in_default>1</show_in_default>
1777
+ <show_in_website>1</show_in_website>
1778
+ <show_in_store>0</show_in_store>
1779
+ <comment><![CDATA[Comma Separated Product Id's]]></comment>
1780
+ </product_list>
1781
+ </fields>
1782
+ </fallback_products>
1783
+ </groups>
1784
+ </connector_dynamic_content>
1785
+ <connector_transactional_emails translate="label" module="connector">
1786
+ <label>Transactional Emails</label>
1787
+ <tab>connector</tab>
1788
+ <frontend_type>text</frontend_type>
1789
+ <show_in_default>1</show_in_default>
1790
+ <show_in_website>1</show_in_website>
1791
+ <show_in_store>0</show_in_store>
1792
+ <sort_order>9000</sort_order>
1793
+ <groups>
1794
+ <credentials translate="label" module="connector">
1795
+ <label>API</label>
1796
+ <frontend_type>text</frontend_type>
1797
+ <sort_order>100</sort_order>
1798
+ <show_in_default>1</show_in_default>
1799
+ <show_in_website>1</show_in_website>
1800
+ <show_in_store>0</show_in_store>
1801
+ <expanded>1</expanded>
1802
+ <fields>
1803
+ <enabled translate="label" module="connector">
1804
+ <label>Enabled</label>
1805
+ <frontend_type>select</frontend_type>
1806
+ <source_model>adminhtml/system_config_source_yesno</source_model>
1807
+ <sort_order>10</sort_order>
1808
+ <show_in_default>1</show_in_default>
1809
+ <show_in_website>1</show_in_website>
1810
+ <show_in_store>0</show_in_store>
1811
+ </enabled>
1812
+ <api_username translate="label" module="connector">
1813
+ <label>API Username</label>
1814
+ <frontend_type>text</frontend_type>
1815
+ <frontend_model>email_connector/adminhtml_system_config_wrapper</frontend_model>
1816
+ <sort_order>10</sort_order>
1817
+ <show_in_default>1</show_in_default>
1818
+ <show_in_website>1</show_in_website>
1819
+ <show_in_store>0</show_in_store>
1820
+ <depends>
1821
+ <enabled>1</enabled>
1822
+ </depends>
1823
+ </api_username>
1824
+ <api_password translate="label" module="connector">
1825
+ <label>API Password</label>
1826
+ <frontend_type>password</frontend_type>
1827
+ <frontend_model>email_connector/adminhtml_system_emailapivalidate</frontend_model>
1828
+ <sort_order>20</sort_order>
1829
+ <show_in_default>1</show_in_default>
1830
+ <show_in_website>1</show_in_website>
1831
+ <show_in_store>0</show_in_store>
1832
+ <depends>
1833
+ <enabled>1</enabled>
1834
+ </depends>
1835
+ </api_password>
1836
+ <validator>
1837
+ <frontend_type>hidden</frontend_type>
1838
+ <frontend_model>email_connector/adminhtml_system_config_waitingfield</frontend_model>
1839
+ <sort_order>40</sort_order>
1840
+ <show_in_default>1</show_in_default>
1841
+ <show_in_website>1</show_in_website>
1842
+ <show_in_store>0</show_in_store>
1843
+ <can_be_empty>1</can_be_empty>
1844
+ </validator>
1845
+ </fields>
1846
+ </credentials>
1847
+ <email_settings translate="label" module="connector">
1848
+ <label>Email Settings</label>
1849
+ <frontend_type>text</frontend_type>
1850
+ <sort_order>200</sort_order>
1851
+ <show_in_default>1</show_in_default>
1852
+ <show_in_website>1</show_in_website>
1853
+ <show_in_store>1</show_in_store>
1854
+ <expanded>1</expanded>
1855
+ <fields>
1856
+ <from_address translate="label" module="connector">
1857
+ <label>From Address</label>
1858
+ <frontend_type>select</frontend_type>
1859
+ <source_model>email_connector/adminhtml_source_transactional_fromaddress</source_model>
1860
+ <sort_order>10</sort_order>
1861
+ <show_in_default>1</show_in_default>
1862
+ <show_in_website>1</show_in_website>
1863
+ <show_in_store>0</show_in_store>
1864
+ </from_address>
1865
+ <unsubscribe_link translate="label" module="connector">
1866
+ <label>Include Unsubscribe Link</label>
1867
+ <frontend_type>select</frontend_type>
1868
+ <source_model>adminhtml/system_config_source_yesno</source_model>
1869
+ <sort_order>20</sort_order>
1870
+ <show_in_default>1</show_in_default>
1871
+ <show_in_website>1</show_in_website>
1872
+ <show_in_store>0</show_in_store>
1873
+ </unsubscribe_link>
1874
+ <reply_action translate="label" module="connector">
1875
+ <label>Reply Action</label>
1876
+ <frontend_type>select</frontend_type>
1877
+ <source_model>email_connector/adminhtml_source_transactional_replyactions</source_model>
1878
+ <sort_order>30</sort_order>
1879
+ <show_in_default>1</show_in_default>
1880
+ <show_in_website>1</show_in_website>
1881
+ <show_in_store>0</show_in_store>
1882
+ </reply_action>
1883
+ <reply_address translate="label" module="connector">
1884
+ <label>Reply Address</label>
1885
+ <frontend_type>text</frontend_type>
1886
+ <sort_order>40</sort_order>
1887
+ <show_in_default>1</show_in_default>
1888
+ <show_in_website>1</show_in_website>
1889
+ <show_in_store>0</show_in_store>
1890
+ <depends><reply_action>WebMailForward</reply_action></depends>
1891
+ </reply_address>
1892
+ <send_copy translate="label" module="connector">
1893
+ <label>Send Copy</label>
1894
+ <frontend_type>text</frontend_type>
1895
+ <sort_order>50</sort_order>
1896
+ <show_in_default>1</show_in_default>
1897
+ <show_in_website>1</show_in_website>
1898
+ <show_in_store>0</show_in_store>
1899
+ </send_copy>
1900
+ </fields>
1901
+ </email_settings>
1902
+ <email_mapping translate="label" module="connector">
1903
+ <label>Email Mapping</label>
1904
+ <frontend_type>text</frontend_type>
1905
+ <sort_order>300</sort_order>
1906
+ <show_in_default>1</show_in_default>
1907
+ <show_in_website>1</show_in_website>
1908
+ <show_in_store>1</show_in_store>
1909
+ <expanded>1</expanded>
1910
+ <fields>
1911
+ <default_emails_title translate="label" module="connector">
1912
+ <label>Default Emails (All Modules)</label>
1913
+ <frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
1914
+ <sort_order>10</sort_order>
1915
+ <show_in_default>1</show_in_default>
1916
+ <show_in_website>1</show_in_website>
1917
+ <show_in_store>0</show_in_store>
1918
+ </default_emails_title>
1919
+ <default_email_templates translate="label" module="connector">
1920
+ <label>Templates</label>
1921
+ <frontend_model>email_connector/adminhtml_config_template_templatefields</frontend_model>
1922
+ <backend_model>adminhtml/system_config_backend_serialized_array</backend_model>
1923
+ <source_model>email_connector/adminhtml_source_transactional_defaultselect</source_model>
1924
+ <sort_order>20</sort_order>
1925
+ <show_in_default>1</show_in_default>
1926
+ <show_in_website>1</show_in_website>
1927
+ <show_in_store>0</show_in_store>
1928
+ </default_email_templates>
1929
+ <custom_emails_title translate="label" module="connector">
1930
+ <label>Custom Emails (Admin Transactional Emails)</label>
1931
+ <frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
1932
+ <sort_order>30</sort_order>
1933
+ <show_in_default>1</show_in_default>
1934
+ <show_in_website>1</show_in_website>
1935
+ <show_in_store>0</show_in_store>
1936
+ </custom_emails_title>
1937
+ <custom_email_templates translate="label" module="connector">
1938
+ <label>Templates</label>
1939
+ <frontend_model>email_connector/adminhtml_config_template_templatefields</frontend_model>
1940
+ <backend_model>adminhtml/system_config_backend_serialized_array</backend_model>
1941
+ <source_model>email_connector/adminhtml_source_transactional_customselect</source_model>
1942
+ <sort_order>40</sort_order>
1943
+ <show_in_default>1</show_in_default>
1944
+ <show_in_website>1</show_in_website>
1945
+ <show_in_store>0</show_in_store>
1946
+ </custom_email_templates>
1947
+ </fields>
1948
+ </email_mapping>
1949
+ </groups>
1950
+ </connector_transactional_emails>
1951
+ <connector_automation_studio translate="label" module="connector">
1952
+ <label>Automation</label>
1953
+ <tab>connector</tab>
1954
+ <frontend_type>text</frontend_type>
1955
+ <sort_order>4000</sort_order>
1956
+ <show_in_default>1</show_in_default>
1957
+ <show_in_website>1</show_in_website>
1958
+ <show_in_store>0</show_in_store>
1959
+ <groups>
1960
+ <automation translate="label" module="connector">
1961
+ <label>Automation</label>
1962
+ <frontend_type>text</frontend_type>
1963
+ <show_in_default>1</show_in_default>
1964
+ <show_in_website>1</show_in_website>
1965
+ <show_in_store>0</show_in_store>
1966
+ <expanded>1</expanded>
1967
+ <fields>
1968
+ <customer_automation translate="label" module="connector">
1969
+ <label>Customer Programme</label>
1970
+ <frontend_type>select</frontend_type>
1971
+ <source_model>email_connector/adminhtml_source_automation_programme</source_model>
1972
+ <show_in_default>1</show_in_default>
1973
+ <show_in_website>1</show_in_website>
1974
+ <show_in_store>0</show_in_store>
1975
+ <sort_order>100</sort_order>
1976
+ </customer_automation>
1977
+ <subscriber_automation>
1978
+ <label>Subscriber Programme</label>
1979
+ <frontend_type>select</frontend_type>
1980
+ <source_model>email_connector/adminhtml_source_automation_programme</source_model>
1981
+ <show_in_default>1</show_in_default>
1982
+ <show_in_website>1</show_in_website>
1983
+ <show_in_store>0</show_in_store>
1984
+ <sort_order>110</sort_order>
1985
+ </subscriber_automation>
1986
+ </fields>
1987
+ </automation>
1988
+ </groups>
1989
+ </connector_automation_studio>
1990
+ <connector_advanced_settings translate="label" module="connector">
1991
+ <label><![CDATA[Advanced Settings]]></label>
1992
+ <tab>connector</tab>
1993
+ <frontend_type>text</frontend_type>
1994
+ <sort_order>10000</sort_order>
1995
+ <show_in_default>1</show_in_default>
1996
+ <show_in_website>1</show_in_website>
1997
+ <show_in_store>0</show_in_store>
1998
+ <groups>
1999
+ <sync_limits translate="label" module="connector">
2000
+ <label>Transactional Data</label>
2001
+ <frontend_type>text</frontend_type>
2002
+ <sort_order>10</sort_order>
2003
+ <show_in_default>1</show_in_default>
2004
+ <show_in_website>1</show_in_website>
2005
+ <show_in_store>0</show_in_store>
2006
+ <fields>
2007
+ <orders translate="label" module="connector">
2008
+ <label>Transactional Data Import Limit Size</label>
2009
+ <frontend_type>select</frontend_type>
2010
+ <source_model>email_connector/adminhtml_source_advanced_transdata</source_model>
2011
+ <sort_order>40</sort_order>
2012
+ <show_in_default>1</show_in_default>
2013
+ <show_in_website>1</show_in_website>
2014
+ <show_in_store>0</show_in_store>
2015
+ </orders>
2016
+ <order_statuses translate="label" module="connector">
2017
+ <label>Import Orders With Order Status</label>
2018
+ <frontend_type>multiselect</frontend_type>
2019
+ <source_model>email_connector/adminhtml_source_orderstatus</source_model>
2020
+ <sort_order>50</sort_order>
2021
+ <show_in_default>1</show_in_default>
2022
+ <show_in_website>1</show_in_website>
2023
+ <show_in_store>0</show_in_store>
2024
+ <comment><![CDATA[Select multiple statuses by pressing Ctrl button while selecting]]></comment>
2025
+ </order_statuses>
2026
+ </fields>
2027
+ </sync_limits>
2028
+ <admin translate="label comment" module="connector">
2029
+ <label>Admin</label>
2030
+ <frontend_type>text</frontend_type>
2031
+ <sort_order>30</sort_order>
2032
+ <show_in_default>1</show_in_default>
2033
+ <show_in_website>1</show_in_website>
2034
+ <show_in_store>0</show_in_store>
2035
+ <comment><![CDATA[<p class="notice">ADVANCED</p>]]>
2036
+ </comment>
2037
+ <fields>
2038
+ <setup_data_fields translate="label comment" module="connector">
2039
+ <label>Automap Data Fields</label>
2040
+ <frontend_model>email_connector/adminhtml_system_advanced_setupdatafields</frontend_model>
2041
+ <sort_order>10</sort_order>
2042
+ <show_in_default>1</show_in_default>
2043
+ <show_in_website>1</show_in_website>
2044
+ <show_in_store>0</show_in_store>
2045
+ <comment><![CDATA[Create Datafields In Connector And Map Them. Including Customer, Address And Sales Information.]]></comment>
2046
+ </setup_data_fields>
2047
+ <delete_contact translate="label" module="connector">
2048
+ <label><![CDATA[Delete All Contact ID'S]]></label>
2049
+ <frontend_model>email_connector/adminhtml_system_advanced_deletecontactids</frontend_model>
2050
+ <sort_order>20</sort_order>
2051
+ <show_in_default>1</show_in_default>
2052
+ <show_in_website>1</show_in_website>
2053
+ <show_in_store>0</show_in_store>
2054
+ <comment><![CDATA[Remove the contact id's. When using different API username account from initial setup please click here to remove all.]]></comment>
2055
+ </delete_contact>
2056
+ <reimport_orders module="connector" translate="label">
2057
+ <label>Refresh Transactional Data</label>
2058
+ <frontend_model>email_connector/adminhtml_system_advanced_reimportorders</frontend_model>
2059
+ <sort_order>30</sort_order>
2060
+ <show_in_default>1</show_in_default>
2061
+ <show_in_website>1</show_in_website>
2062
+ <show_in_store>0</show_in_store>
2063
+ <comment><![CDATA[Refresh Order Transactional Data That Was Already Imported.]]></comment>
2064
+ </reimport_orders>
2065
+ <reimport_subscribers module="connector" translate="label">
2066
+ <label>Refresh Subscribers</label>
2067
+ <frontend_model>email_connector/adminhtml_system_advanced_reimportsubscribers</frontend_model>
2068
+ <sort_order>40</sort_order>
2069
+ <show_in_default>1</show_in_default>
2070
+ <show_in_website>1</show_in_website>
2071
+ <show_in_store>0</show_in_store>
2072
+ <comment><![CDATA[All Subscribers Will Be Marked For Import.]]></comment>
2073
+ </reimport_subscribers>
2074
+ <suppressed_contacts module="connector" translate="label">
2075
+ <label>Refresh Supressed Contacts</label>
2076
+ <frontend_model>email_connector/adminhtml_system_advanced_suppressedcontacts</frontend_model>
2077
+ <sort_order>40</sort_order>
2078
+ <show_in_default>1</show_in_default>
2079
+ <show_in_website>1</show_in_website>
2080
+ <show_in_store>0</show_in_store>
2081
+ <comment>Refresh Historically Suppressed contacts for 10years period.</comment>
2082
+ </suppressed_contacts>
2083
+ <memory_limit translate="label comment" module="connector">
2084
+ <label>Customer Sync Memory Default</label>
2085
+ <frontend_type>select</frontend_type>
2086
+ <source_model>adminhtml/system_config_source_yesno</source_model>
2087
+ <sort_order>50</sort_order>
2088
+ <show_in_default>1</show_in_default>
2089
+ <show_in_website>0</show_in_website>
2090
+ <show_in_store>0</show_in_store>
2091
+ <comment>Set to NO to use system default memory.</comment>
2092
+ </memory_limit>
2093
+ <batch_size translate="label comment" module="connector">
2094
+ <label>Customer Sync Batch Size</label>
2095
+ <frontend_type>text</frontend_type>
2096
+ <show_in_default>1</show_in_default>
2097
+ <show_in_website>1</show_in_website>
2098
+ <show_in_store>0</show_in_store>
2099
+ <sort_order>60</sort_order>
2100
+ <comment>Set the limit size for customers loaded for every sync.</comment>
2101
+ </batch_size>
2102
+ <debug_enabled translate="label comment" module="connector">
2103
+ <label>Debug Mode</label>
2104
+ <frontend_type>select</frontend_type>
2105
+ <source_model>adminhtml/system_config_source_yesno</source_model>
2106
+ <sort_order>70</sort_order>
2107
+ <show_in_default>1</show_in_default>
2108
+ <show_in_website>1</show_in_website>
2109
+ <show_in_store>0</show_in_store>
2110
+ </debug_enabled>
2111
+ <inline_styling translate="label comment" module="connector">
2112
+ <label>Transactional Emails Styling</label>
2113
+ <frontend_type>textarea</frontend_type>
2114
+ <sort_order>90</sort_order>
2115
+ <show_in_default>1</show_in_default>
2116
+ <show_in_website>1</show_in_website>
2117
+ <show_in_store>0</show_in_store>
2118
+ <comment>Styling entered here will apply to all dynamic content areas pulled from Magento for transactional emails.</comment>
2119
+ </inline_styling>
2120
+ <recommended_inline translate="label" module="connector">
2121
+ <label>Dynamic Content Styling</label>
2122
+ <frontend_type>textarea</frontend_type>
2123
+ <sort_order>100</sort_order>
2124
+ <show_in_default>1</show_in_default>
2125
+ <show_in_website>1</show_in_website>
2126
+ <show_in_store>0</show_in_store>
2127
+ <comment><![CDATA[Styling entered here will apply to all dynamic content areas pulled from Magento. Classes References Used : 'product-name', 'product-price', 'product-url']]></comment>
2128
+ </recommended_inline>
2129
+ </fields>
2130
+ </admin>
2131
+ </groups>
2132
+ </connector_advanced_settings>
2133
+ </sections>
2134
+ </config>
app/code/{local/Dotdigitalgroup/Email/sql/connector_setup → community/Dotdigitalgroup/Email/sql/email_connector_setup}/mysql4-install-0.1.0.php RENAMED
@@ -1,12 +1,4 @@
1
  <?php
2
- /**
3
- * mag17.
4
- *
5
- * User: chrisroseuk
6
- * Date: 30/04/2013
7
- * Time: 14:17
8
- *
9
- */
10
 
11
  $installer = $this;
12
  $installer->startSetup();
@@ -24,6 +16,7 @@ $setup->addAttribute('customer', 'dotmailer_contact_id', array(
24
  'visible' => 1,
25
  'required' => 0,
26
  'user_defined' => 0,
 
27
  ));
28
 
29
  $setup->addAttributeToGroup(
@@ -42,9 +35,9 @@ $adminData = array();
42
  $adminData[] = array(
43
  'severity' => 4,
44
  'date_added' => gmdate('Y-m-d H:i:s', time()),
45
- 'title' => 'Email Connector was installed. Remmenber to enable cronjob to make it working.',
46
- 'description' => 'Connector synchronization is based on the cronjob please make sure this is setup before running through configuration.',
47
- 'url' => ''
48
  );
49
 
50
  Mage::getModel('adminnotification/inbox')->parse($adminData);
1
  <?php
 
 
 
 
 
 
 
 
2
 
3
  $installer = $this;
4
  $installer->startSetup();
16
  'visible' => 1,
17
  'required' => 0,
18
  'user_defined' => 0,
19
+ ''
20
  ));
21
 
22
  $setup->addAttributeToGroup(
35
  $adminData[] = array(
36
  'severity' => 4,
37
  'date_added' => gmdate('Y-m-d H:i:s', time()),
38
+ 'title' => 'Email Connector Was Installed. Please Enter Your API Credentials & Ensure Cron Jobs Are Running On Your Site (Find Out More)',
39
+ 'description' => 'Email Connector Was Installed. Please Enter Your API Credentials & Ensure Cron Jobs Are Running On Your Site.',
40
+ 'url' => 'http://www.magentocommerce.com/wiki/1_-_installation_and_configuration/how_to_setup_a_cron_job'
41
  );
42
 
43
  Mage::getModel('adminnotification/inbox')->parse($adminData);
app/code/community/Dotdigitalgroup/Email/sql/email_connector_setup/mysql4-install-3.0.0.php ADDED
@@ -0,0 +1,307 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /** @var Mage_Eav_Model_Entity_Setup $installer */
4
+
5
+ $installer = $this;
6
+
7
+ $installer->startSetup();
8
+
9
+ /**
10
+ * create Contact table.
11
+ */
12
+ $contactTable = $installer->getTable('email_connector/contact');
13
+
14
+ if ($installer->getConnection()->isTableExists($contactTable)) {
15
+ $installer->getConnection()->dropTable($contactTable);
16
+ }
17
+
18
+ $table = $installer->getConnection()->newTable($contactTable);
19
+ $table->addColumn('email_contact_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
20
+ 'primary' => true,
21
+ 'identity' => true,
22
+ 'unsigned' => true,
23
+ 'nullable' => false
24
+ ), 'Primary Key')
25
+ ->addColumn('is_guest', Varien_Db_Ddl_Table::TYPE_SMALLINT, null, array(
26
+ 'unsigned' => true,
27
+ 'nullable' => true,
28
+ ), 'Is Guest')
29
+ ->addColumn('contact_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
30
+ 'unsigned' => true,
31
+ 'nullable' => true,
32
+ ), 'Connector Contact ID')
33
+ ->addColumn('customer_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
34
+ 'unsigned' => true,
35
+ 'nullable' => false,
36
+ ), 'Customer ID')
37
+ ->addColumn('website_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
38
+ 'unsigned' => true,
39
+ 'nullable' => false,
40
+ 'default' => '0'
41
+ ), 'Website ID')
42
+ ->addColumn('store_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
43
+ 'unsigned' => true,
44
+ 'nullable' => false,
45
+ 'default' => '0'
46
+ ), 'Store ID')
47
+ ->addColumn('email', Varien_Db_Ddl_Table::TYPE_TEXT, 255, array(
48
+ 'nullable' => false,
49
+ 'default' => ''
50
+ ), 'Customer Email')
51
+ ->addColumn('is_subscriber', Varien_Db_Ddl_Table::TYPE_SMALLINT, null, array(
52
+ 'unsigned' => true,
53
+ 'nullable' => true,
54
+ ), 'Is Subscriber')
55
+ ->addColumn('subscriber_status', Varien_Db_Ddl_Table::TYPE_SMALLINT, null, array(
56
+ 'unsigned' => true,
57
+ 'nullable' => true,
58
+ ), 'Subscriber status')
59
+ ->addColumn('email_imported', Varien_Db_Ddl_Table::TYPE_SMALLINT, null, array(
60
+ 'unsigned' => true,
61
+ 'nullable' => true,
62
+ ), 'Is Imported')
63
+ ->addColumn('subscriber_imported', Varien_Db_Ddl_Table::TYPE_SMALLINT, null, array(
64
+ 'unsigned' => true,
65
+ 'nullable' => true,
66
+ ), 'Subscriber Imported')
67
+ ->addColumn('suppressed', Varien_Db_Ddl_Table::TYPE_SMALLINT, null, array(
68
+ 'unsigned' => true,
69
+ 'nullable' => true,
70
+ ), 'Is Suppressed')
71
+ ->addIndex($this->getIdxName($contactTable, array('email_contact_id')),
72
+ array('email_contact_id'))
73
+ ->addIndex($this->getIdxName($contactTable, array('is_guest')),
74
+ array('is_guest'))
75
+ ->addIndex($this->getIdxName($contactTable, array('customer_id')),
76
+ array('customer_id'))
77
+ ->addIndex($this->getIdxName($contactTable, array('website_id')),
78
+ array('website_id'))
79
+ ->addIndex($this->getIdxName($contactTable, array('is_subscriber')),
80
+ array('is_subscriber'))
81
+ ->addIndex($this->getIdxName($contactTable, array('subscriber_status')),
82
+ array('subscriber_status'))
83
+ ->addIndex($this->getIdxName($contactTable, array('email_imported')),
84
+ array('email_imported'))
85
+ ->addIndex($this->getIdxName($contactTable, array('subscriber_imported')),
86
+ array('subscriber_imported'))
87
+ ->addIndex($this->getIdxName($contactTable, array('suppressed')),
88
+ array('suppressed'))
89
+
90
+ ->addForeignKey(
91
+ $installer->getFkName($contactTable, 'website_id', 'core/website', 'website_id'),
92
+ 'website_id', $installer->getTable('core/website'), 'website_id',
93
+ Varien_Db_Ddl_Table::ACTION_CASCADE, Varien_Db_Ddl_Table::ACTION_CASCADE)
94
+ ->setComment('Connector Contacts');
95
+ $installer->getConnection()->createTable($table);
96
+
97
+
98
+ /**
99
+ * Order table
100
+ */
101
+ $orderTable = $installer->getTable('email_connector/order');
102
+
103
+ if ($installer->getConnection()->isTableExists($orderTable)) {
104
+ $installer->getConnection()->dropTable($orderTable);
105
+ }
106
+
107
+ $table = $installer->getConnection()->newTable($orderTable);
108
+ $table->addColumn('email_order_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
109
+ 'primary' => true,
110
+ 'identity' => true,
111
+ 'unsigned' => true,
112
+ 'nullable' => false
113
+ ), 'Primary Key')
114
+ ->addColumn('order_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
115
+ 'unsigned' => true,
116
+ 'nullable' => false,
117
+ ), 'Order ID')
118
+ ->addColumn('order_status', Varien_Db_Ddl_Table::TYPE_TEXT, null, array(
119
+ 'unsigned' => true,
120
+ 'nullable' => false,
121
+ ), 'Order Status')
122
+ ->addColumn('quote_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
123
+ 'unsigned' => true,
124
+ 'nullable' => false,
125
+ ), 'Sales Quote ID')
126
+ ->addColumn('store_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
127
+ 'unsigned' => true,
128
+ 'nullable' => false,
129
+ 'default' => '0'
130
+ ), 'Store ID')
131
+ ->addColumn('email_imported', Varien_Db_Ddl_Table::TYPE_SMALLINT, null, array(
132
+ 'unsigned' => true,
133
+ 'nullable' => true,
134
+ ), 'Is Order Imported')
135
+ ->addColumn('created_at', Varien_Db_Ddl_Table::TYPE_TIMESTAMP, null, array(
136
+ ), 'Creation Time')
137
+ ->addColumn('updated_at', Varien_Db_Ddl_Table::TYPE_TIMESTAMP, null, array(
138
+ ), 'Update Time')
139
+ ->addIndex($this->getIdxName($orderTable, array('store_id')),
140
+ array('store_id'))
141
+ ->addIndex($this->getIdxName($orderTable, array('quote_id')),
142
+ array('quote_id'))
143
+
144
+ ->addForeignKey(
145
+ $installer->getFkName($orderTable, 'store_id', 'core/store', 'store_id'),
146
+ 'store_id', $installer->getTable('core/store'), 'store_id',
147
+ Varien_Db_Ddl_Table::ACTION_CASCADE, Varien_Db_Ddl_Table::ACTION_CASCADE)
148
+ ->setComment('Transactional Orders Data');
149
+ $installer->getConnection()->createTable($table);
150
+
151
+
152
+ /**
153
+ * Campaign table.
154
+ */
155
+ $campaignTable = $installer->getTable('email_connector/campaign');
156
+
157
+ if ($installer->getConnection()->isTableExists($campaignTable)) {
158
+ $installer->getConnection()->dropTable($campaignTable);
159
+ }
160
+
161
+ $table = $installer->getConnection()->newTable($campaignTable);
162
+ $table->addColumn('id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
163
+ 'primary' => true,
164
+ 'identity' => true,
165
+ 'unsigned' => true,
166
+ 'nullable' => false
167
+ ), 'Primary Key')
168
+ ->addColumn('campaign_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
169
+ 'unsigned' => true,
170
+ 'nullable' => false,
171
+ ), 'Campaign ID')
172
+ ->addColumn('email', Varien_Db_Ddl_Table::TYPE_TEXT, 255, array(
173
+ 'nullable' => false,
174
+ 'default' => ''
175
+ ), 'Contact Email')
176
+ ->addColumn('customer_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
177
+ 'unsigned' => true,
178
+ 'nullable' => false,
179
+ ), 'Customer ID')
180
+ ->addColumn('is_sent', Varien_Db_Ddl_Table::TYPE_SMALLINT, null, array(
181
+ 'unsigned' => true,
182
+ 'nullable' => true,
183
+ ), 'Is Sent')
184
+ ->addColumn('sent_at', Varien_Db_Ddl_Table::TYPE_TIMESTAMP, null, array(
185
+ ), 'Send Date')
186
+ ->addColumn('order_increment_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
187
+ 'unsigned' => true,
188
+ 'nullable' => false,
189
+ ), 'Order Increment ID')
190
+ ->addColumn('quote_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
191
+ 'unsigned' => true,
192
+ 'nullable' => false,
193
+ ), 'Sales Quote ID')
194
+ ->addColumn('message', Varien_Db_Ddl_Table::TYPE_TEXT, 255, array(
195
+ 'nullable' => false,
196
+ 'default' => ''
197
+ ), 'Errror Message')
198
+ ->addColumn('checkout_method', Varien_Db_Ddl_Table::TYPE_TEXT, 255, array(
199
+ 'nullable' => false,
200
+ 'default' => ''
201
+ ), 'Checkout Method Used')
202
+ ->addColumn('store_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
203
+ 'unsigned' => true,
204
+ 'nullable' => false,
205
+ 'default' => '0'
206
+ ), 'Store ID')
207
+ ->addColumn('event_name', Varien_Db_Ddl_Table::TYPE_TEXT, 255, array(
208
+ 'nullable' => false,
209
+ 'default' => ''
210
+ ), 'Event Name')
211
+ ->addColumn('created_at', Varien_Db_Ddl_Table::TYPE_TIMESTAMP, null, array(
212
+ ), 'Creation Time')
213
+ ->addColumn('updated_at', Varien_Db_Ddl_Table::TYPE_TIMESTAMP, null, array(
214
+ ), 'Update Time')
215
+
216
+ ->addIndex($this->getIdxName($campaignTable, array('store_id')),
217
+ array('store_id'))
218
+ ->addIndex($this->getIdxName($campaignTable, array('campaign_id')),
219
+ array('campaign_id'))
220
+ ->addIndex($this->getIdxName($campaignTable, array('email')),
221
+ array('email'))
222
+ ->addIndex($this->getIdxName($campaignTable, array('is_sent')),
223
+ array('is_sent'))
224
+ ->addForeignKey(
225
+ $installer->getFkName($campaignTable, 'store_id', 'core/store', 'store_id'),
226
+ 'store_id', $installer->getTable('core/store'), 'store_id',
227
+ Varien_Db_Ddl_Table::ACTION_CASCADE, Varien_Db_Ddl_Table::ACTION_CASCADE)
228
+ ->setComment('Connector Campaigns');
229
+ $installer->getConnection()->createTable($table);
230
+
231
+
232
+ /**
233
+ * Admin notification message
234
+ */
235
+
236
+ $adminData = array();
237
+ $adminData[] = array(
238
+ 'severity' => 4,
239
+ 'date_added' => gmdate('Y-m-d H:i:s', time()),
240
+ 'title' => 'Email Connector Was Installed. Please Enter Your API Credentials & Ensure Cron Jobs Are Running On Your Site (Find Out More)',
241
+ 'description' => 'Email Connector Was Installed. Please Enter Your API Credentials & Ensure Cron Jobs Are Running On Your Site.',
242
+ 'url' => 'http://www.magentocommerce.com/wiki/1_-_installation_and_configuration/how_to_setup_a_cron_job'
243
+ );
244
+
245
+ Mage::getModel('adminnotification/inbox')->parse($adminData);
246
+
247
+ /**
248
+ * Populate tables
249
+ */
250
+
251
+ //customers populate
252
+ $select = $installer->getConnection()->select()
253
+ ->from(
254
+ array('customer' => $this->getTable('customer_entity')),
255
+ array('customer_id' => 'entity_id','email','website_id','store_id')
256
+ );
257
+
258
+ $insertArray = array('customer_id','email','website_id','store_id');
259
+ $sqlQuery = $select->insertFromSelect($contactTable, $insertArray, false);
260
+ $installer->getConnection()->query($sqlQuery);
261
+
262
+ // subscribers that are not customers
263
+ $select = $installer->getConnection()->select()
264
+ ->from(
265
+ array('subscriber' => $this->getTable('newsletter_subscriber')),
266
+ array(
267
+ 'email' => 'subscriber_email',
268
+ 'col2' => new Zend_Db_Expr('1'),
269
+ 'col3' => new Zend_Db_Expr('1'),
270
+ 'store_id'
271
+ )
272
+ )
273
+ ->where('customer_id =?', 0 )
274
+ ->where('subscriber_status =?', 1);
275
+ $insertArray = array('email','is_subscriber','subscriber_status','store_id');
276
+ $sqlQuery = $select->insertFromSelect($contactTable, $insertArray, false);
277
+ $installer->getConnection()->query($sqlQuery);
278
+
279
+ //Insert and populate email order the table
280
+ $select = $installer->getConnection()->select()
281
+ ->from(
282
+ $this->getTable('sales/order'),
283
+ array('order_id' => 'entity_id', 'quote_id', 'store_id', 'created_at', 'updated_at', 'order_status' => 'status' )
284
+ );
285
+ $insertArray =
286
+ array('order_id', 'quote_id', 'store_id', 'created_at', 'updated_at', 'order_status');
287
+
288
+ $sqlQuery = $select->insertFromSelect($orderTable, $insertArray, false);
289
+ $installer->getConnection()->query($sqlQuery);
290
+
291
+ //Save all order statuses as string
292
+ $source = Mage::getModel('adminhtml/system_config_source_order_status');
293
+ $statuses = $source->toOptionArray();
294
+
295
+ if(count($statuses) > 0 && $statuses[0]['value'] == '')
296
+ array_shift($statuses);
297
+
298
+ $options = array();
299
+ foreach($statuses as $status) {
300
+ $options[] = $status['value'];
301
+ }
302
+ $statusString = implode(',',$options);
303
+
304
+ $configModel = Mage::getModel('core/config');
305
+ $configModel->saveConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_SYNC_ORDER_STATUS,$statusString);
306
+
307
+ $installer->endSetup();
app/code/{local/Dotdigitalgroup/Email/sql/connector_setup → community/Dotdigitalgroup/Email/sql/email_connector_setup}/mysql4-upgrade-1.1.1-1.1.2.php RENAMED
File without changes
app/code/community/Dotdigitalgroup/Email/sql/email_connector_setup/mysql4-upgrade-1.1.2-1.5.0.php ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ $installer = $this;
4
+
5
+ $installer->startSetup();
6
+
7
+
8
+ $installer->endSetup();
app/code/community/Dotdigitalgroup/Email/sql/email_connector_setup/mysql4-upgrade-1.5.0-2.0.0.php ADDED
@@ -0,0 +1,75 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+
4
+ $installer = $this;
5
+
6
+ $installer->startSetup();
7
+
8
+ try{
9
+
10
+ $installer->run(
11
+ "DROP TABLE IF EXISTS {$this->getTable('email_order')};
12
+ CREATE TABLE `{$this->getTable('email_order')}` (
13
+ `email_order_id` int(11) unsigned NOT NULL AUTO_INCREMENT,
14
+ `order_id` int(15) unsigned DEFAULT NULL,
15
+ `quote_id` int(15) unsigned DEFAULT NULL,
16
+ `store_id` smallint(5) unsigned DEFAULT NULL,
17
+ `email_imported` tinyint(1) DEFAULT NULL,
18
+ `created_at` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
19
+ `updated_at` datetime DEFAULT NULL,
20
+ PRIMARY KEY (`email_order_id`),
21
+ KEY `IDX_EMAIL_STORE_ID` (`store_id`),
22
+ KEY `IDX_EMAIL_QUOTE_ID` (`quote_id`),
23
+ CONSTRAINT `FK_EMAIL_STORE_ID_CORE_STORE_STORE_ID` FOREIGN KEY (`store_id`) REFERENCES `{$this->getTable('core_store')}` (`store_id`) ON DELETE SET NULL ON UPDATE CASCADE
24
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;"
25
+ );
26
+
27
+
28
+ //Insert and populate email order the table
29
+ $installer->run(
30
+ "INSERT IGNORE INTO `{$this->getTable('email_order')}` (`order_id`, `quote_id`, `store_id`, `created_at`, `updated_at`)
31
+ SELECT `entity_id`, `quote_id`, `store_id`, `created_at`, `updated_at`
32
+ FROM `{$this->getTable('sales/order')}`;"
33
+ );
34
+
35
+
36
+ $installer->run(
37
+ "DROP TABLE IF EXISTS {$this->getTable('email_contact')};
38
+ CREATE TABLE `{$this->getTable('email_contact')}` (
39
+ `email_contact_id` int(10) unsigned NOT NULL AUTO_INCREMENT,
40
+ `is_guest` smallint(1) DEFAULT NULL,
41
+ `contact_id` int(15) unsigned DEFAULT NULL,
42
+ `customer_id` int(10) unsigned DEFAULT NULL,
43
+ `website_id` smallint(5) unsigned DEFAULT NULL COMMENT 'Website Id',
44
+ `email` varchar(255) DEFAULT NULL,
45
+ `is_subscriber` tinyint(1)unsigned DEFAULT NULL,
46
+ `subscriber_status` int(10) unsigned DEFAULT '0',
47
+ `email_id` smallint(5) unsigned DEFAULT NULL,
48
+ `email_imported` tinyint(1) unsigned DEFAULT NULL,
49
+ `suppressed` smallint(1) DEFAULT NULL,
50
+ PRIMARY KEY (`email_contact_id`),
51
+ KEY `IDX_EMAIL_CONTACT_WEBSITE_ID` (`website_id`),
52
+ CONSTRAINT `FK_EMAIL_CONTACT_WEBSITE_ID_CORE_WEBSITE_WEBSITE_ID` FOREIGN KEY (`website_id`) REFERENCES `core_website` (`website_id`) ON DELETE SET NULL ON UPDATE CASCADE
53
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Email Contact Sync';"
54
+ );
55
+
56
+
57
+ //Insert and populate email contact table
58
+ $installer->run(
59
+ "INSERT IGNORE INTO `{$this->getTable('email_contact')}` (`customer_id`, `email`, `website_id`)
60
+ SELECT `entity_id`, `email`, `website_id`
61
+ FROM `{$this->getTable('customer_entity')}`;"
62
+ );
63
+
64
+ //Remove Order Attribute For Imported Data
65
+ $installer->removeAttribute('order', 'dotmailer_order_imported');
66
+ $installer->removeAttribute('customer', 'dotmailer_contact_id');
67
+
68
+
69
+ }catch (Exception $e){
70
+
71
+ Mage::log($e->getMessage());
72
+
73
+ }
74
+
75
+ $installer->endSetup();
app/code/community/Dotdigitalgroup/Email/sql/email_connector_setup/mysql4-upgrade-2.0.0-2.0.1.php ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+
4
+ $installer = $this;
5
+
6
+ $installer->startSetup();
7
+
8
+
9
+ $installer->endSetup();
app/code/community/Dotdigitalgroup/Email/sql/email_connector_setup/mysql4-upgrade-2.0.1-2.0.2.php ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ $installer = $this;
4
+
5
+ $installer->startSetup();
6
+
7
+
8
+ $installer->run(
9
+ "DROP TABLE IF EXISTS {$this->getTable('email_contact')};
10
+ CREATE TABLE `{$this->getTable('email_contact')}` (
11
+ `email_contact_id` int(10) unsigned NOT NULL AUTO_INCREMENT,
12
+ `is_guest` smallint(1) DEFAULT NULL,
13
+ `contact_id` int(15) unsigned DEFAULT NULL,
14
+ `customer_id` int(10) unsigned DEFAULT NULL,
15
+ `website_id` smallint(5) unsigned DEFAULT NULL COMMENT 'Website Id',
16
+ `email` varchar(255) DEFAULT NULL,
17
+ `is_subscriber` tinyint(1) unsigned DEFAULT NULL,
18
+ `subscriber_status` int(10) unsigned DEFAULT '0',
19
+ `subscriber_imported` tinyint(1) unsigned DEFAULT NULL,
20
+ `email_imported` tinyint(1) unsigned DEFAULT NULL,
21
+ `suppressed` smallint(1) DEFAULT NULL,
22
+ PRIMARY KEY (`email_contact_id`),
23
+ KEY `IDX_EMAIL_CONTACT_ID` (`email_contact_id`),
24
+ KEY `IDX_EMAIL_CONTACT_IS_GUEST` (`is_guest`),
25
+ KEY `IDX_EMAIL_CONTACT_CUSTOMER_ID` (`customer_id`),
26
+ KEY `IDX_EMAIL_CONTACT_WEBSITE_ID` (`website_id`),
27
+ KEY `IDX_EMAIL_CONTACT_IS_SUBSCRIBER` (`is_subscriber`),
28
+ KEY `IDX_EMAIL_CONTACT_SUBSCRIBER_STATUS` (`subscriber_status`),
29
+ KEY `IDX_EMAIL_CONTACT_SUBSCRIBER_IMPORTED` (`subscriber_imported`),
30
+ KEY `IDX_EMAIL_CONTACT_EMAIL_IMPORTED` (`email_imported`),
31
+ KEY `IDX_EMAIL_CONTACT_suppressed` (`suppressed`),
32
+ UNIQUE KEY `IDX_EMAIL_CONTACT_EMAIL` (`email`),
33
+ CONSTRAINT `FK_EMAIL_CONTACT_WEBSITE_ID_CORE_WEBSITE_WEBSITE_ID` FOREIGN KEY (`website_id`) REFERENCES `core_website` (`website_id`) ON DELETE SET NULL ON UPDATE CASCADE
34
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Email Contacts';"
35
+ );
36
+
37
+
38
+ //Insert and populate email contact table
39
+ $installer->run(
40
+ "INSERT IGNORE INTO `{$this->getTable('email_contact')}` (`customer_id`, `email`, `website_id`)
41
+ SELECT `entity_id`, `email`, `website_id`
42
+ FROM `{$this->getTable('customer_entity')}`;"
43
+ );
44
+
45
+ //Subscribers that are not customers
46
+ $installer->run("
47
+ INSERT IGNORE INTO {$this->getTable('email_contact')} (`email`, `is_subscriber`, `subscriber_status`)
48
+ SELECT `subscriber_email`, '1' as col2, '1' as col3 FROM `{$this->getTable('newsletter/subscriber')}` WHERE `customer_id` = 0 AND `subscriber_status` = 1;
49
+ ");
50
+
51
+
52
+ $installer->endSetup();
app/code/community/Dotdigitalgroup/Email/sql/email_connector_setup/mysql4-upgrade-2.0.3-2.0.4.php ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ $installer = $this;
4
+
5
+
6
+ $installer->startSetup();
7
+
8
+
9
+ $installer->run("
10
+ ALTER TABLE `{$this->getTable('email_contact')}`
11
+
12
+ DROP FOREIGN KEY `FK_EMAIL_CONTACT_WEBSITE_ID_CORE_WEBSITE_WEBSITE_ID`,
13
+ CHANGE COLUMN `website_id` `website_id` smallint(5) unsigned DEFAULT '0' AFTER `customer_id`;
14
+ ");
15
+
16
+ $installer->run("
17
+ UPDATE `{$this->getTable('email_contact')}` SET `website_id` = '0'
18
+ WHERE `website_id` IS NULL;
19
+ ");
20
+
21
+ $installer->run("
22
+ ALTER TABLE `{$this->getTable('email_contact')}`
23
+ ADD CONSTRAINT `FK_EMAIL_CONTACT_WEBSITE_ID_CORE_WEBSITE_WEBSITE_ID` FOREIGN KEY (`website_id`) REFERENCES `{$installer->getTable('core_website')}` (`website_id`) ON DELETE CASCADE ON UPDATE CASCADE;
24
+
25
+ ");
26
+
27
+
28
+ $installer->endSetup();
app/code/community/Dotdigitalgroup/Email/sql/email_connector_setup/mysql4-upgrade-2.0.4-2.0.5.php ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ $installer = $this;
4
+
5
+
6
+ $installer->startSetup();
7
+
8
+
9
+ $installer->endSetup();
app/code/community/Dotdigitalgroup/Email/sql/email_connector_setup/mysql4-upgrade-2.0.5-2.0.6.php ADDED
@@ -0,0 +1,103 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+
4
+ $installer = $this;
5
+
6
+ $installer->startSetup();
7
+ /**
8
+ * Campaign table.
9
+ */
10
+ $campaignTable = $installer->getTable('email_connector/campaign');
11
+
12
+ if ($installer->getConnection()->isTableExists($campaignTable)) {
13
+ $installer->getConnection()->dropTable($campaignTable);
14
+ }
15
+
16
+ $table = $installer->getConnection()->newTable($campaignTable);
17
+ $table->addColumn('id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
18
+ 'primary' => true,
19
+ 'identity' => true,
20
+ 'unsigned' => true,
21
+ 'nullable' => false
22
+ ), 'Primary Key')
23
+ ->addColumn('campaign_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
24
+ 'unsigned' => true,
25
+ 'nullable' => false,
26
+ ), 'Campaign ID')
27
+ ->addColumn('email', Varien_Db_Ddl_Table::TYPE_TEXT, 255, array(
28
+ 'nullable' => false,
29
+ 'default' => ''
30
+ ), 'Contact Email')
31
+ ->addColumn('customer_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
32
+ 'unsigned' => true,
33
+ 'nullable' => false,
34
+ ), 'Customer ID')
35
+ ->addColumn('is_sent', Varien_Db_Ddl_Table::TYPE_SMALLINT, null, array(
36
+ 'unsigned' => true,
37
+ 'nullable' => true,
38
+ ), 'Is Sent')
39
+ ->addColumn('sent_at', Varien_Db_Ddl_Table::TYPE_TIMESTAMP, null, array(
40
+ ), 'Send Date')
41
+ ->addColumn('order_increment_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
42
+ 'unsigned' => true,
43
+ 'nullable' => false,
44
+ ), 'Order Increment ID')
45
+ ->addColumn('quote_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
46
+ 'unsigned' => true,
47
+ 'nullable' => false,
48
+ ), 'Sales Quote ID')
49
+ ->addColumn('message', Varien_Db_Ddl_Table::TYPE_TEXT, 255, array(
50
+ 'nullable' => false,
51
+ 'default' => ''
52
+ ), 'Errror Message')
53
+ ->addColumn('checkout_method', Varien_Db_Ddl_Table::TYPE_TEXT, 255, array(
54
+ 'nullable' => false,
55
+ 'default' => ''
56
+ ), 'Checkout Method Used')
57
+ ->addColumn('store_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
58
+ 'unsigned' => true,
59
+ 'nullable' => false,
60
+ 'default' => '0'
61
+ ), 'Store ID')
62
+ ->addColumn('event_name', Varien_Db_Ddl_Table::TYPE_TEXT, 255, array(
63
+ 'nullable' => false,
64
+ 'default' => ''
65
+ ), 'Event Name')
66
+ ->addColumn('created_at', Varien_Db_Ddl_Table::TYPE_TIMESTAMP, null, array(
67
+ ), 'Creation Time')
68
+ ->addColumn('updated_at', Varien_Db_Ddl_Table::TYPE_TIMESTAMP, null, array(
69
+ ), 'Update Time')
70
+
71
+ ->addIndex($this->getIdxName($campaignTable, array('store_id')),
72
+ array('store_id'))
73
+ ->addIndex($this->getIdxName($campaignTable, array('campaign_id')),
74
+ array('campaign_id'))
75
+ ->addIndex($this->getIdxName($campaignTable, array('email')),
76
+ array('email'))
77
+ ->addIndex($this->getIdxName($campaignTable, array('is_sent')),
78
+ array('is_sent'))
79
+ ->addForeignKey(
80
+ $installer->getFkName($campaignTable, 'store_id', 'core/store', 'store_id'),
81
+ 'store_id', $installer->getTable('core/store'), 'store_id',
82
+ Varien_Db_Ddl_Table::ACTION_CASCADE, Varien_Db_Ddl_Table::ACTION_CASCADE)
83
+ ->setComment('Connector Campaigns');
84
+ $installer->getConnection()->createTable($table);
85
+
86
+ /**
87
+ * remove contact column
88
+ */
89
+ $installer->getConnection()->dropColumn($installer->getTable('email_connector/contact'), 'subscriber_imported');
90
+
91
+ /*
92
+ * Cleaning
93
+ */
94
+ $entityTypeId = $installer->getEntityTypeId('customer');
95
+ if ($installer->attributeExists($entityTypeId, 'dotmailer_contact_id'))
96
+ $installer->removeAttribute($entityTypeId, 'dotmailer_contact_id');
97
+
98
+ $entityTypeId = $installer->getEntityTypeId('order');
99
+ if($installer->attributeExists($entityTypeId, 'dotmailer_order_imported'))
100
+ $installer->removeAttribute($entityTypeId, 'dotmailer_order_imported');
101
+
102
+
103
+ $installer->endSetup();
app/code/community/Dotdigitalgroup/Email/sql/email_connector_setup/mysql4-upgrade-3.0.1-3.0.2.php ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ $installer = $this;
4
+
5
+
6
+ $installer->startSetup();
7
+
8
+ $admin = $this->getTable('admin/user');
9
+
10
+ $installer->getConnection()->addColumn($installer->getTable('admin/user'), 'refresh_token', array(
11
+ 'type' => Varien_Db_Ddl_Table::TYPE_TEXT,
12
+ 'length' => 256,
13
+ 'nullable' => true,
14
+ 'default' => null,
15
+ 'comment' => 'Email connector refresh token'
16
+ ));
17
+
18
+ $installer->endSetup();
app/code/community/Dotdigitalgroup/Email/sql/email_connector_setup/mysql4-upgrade-3.0.3-3.0.4.php ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ $installer = $this;
4
+
5
+
6
+ $installer->startSetup();
7
+
8
+ $campaignTable = $this->getTable('email_campaign');
9
+
10
+ $installer->getConnection()->modifyColumn($campaignTable, 'order_increment_id', 'VARCHAR(50)');
11
+
12
+ $installer->endSetup();
app/code/community/Dotdigitalgroup/Email/sql/email_connector_setup/mysql4-upgrade-3.0.4-3.0.5.php ADDED
@@ -0,0 +1,121 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /** @var Mage_Eav_Model_Entity_Setup $installer */
4
+
5
+ $installer = $this;
6
+
7
+ $installer->startSetup();
8
+
9
+ //Insert status column to email_order table
10
+ $orderTable = $installer->getTable('email_connector/order');
11
+
12
+ $installer->getConnection()->addColumn($orderTable, 'order_status', array(
13
+ 'type' => Varien_Db_Ddl_Table::TYPE_TEXT,
14
+ 'length' => 256,
15
+ 'nullable' => false,
16
+ 'default' => null,
17
+ 'comment' => 'Order Status'
18
+ ));
19
+
20
+ //populate order status in email_order table
21
+
22
+ //select
23
+ $select = $installer->getConnection()->select();
24
+
25
+ //join
26
+ $select->joinLeft(
27
+ array('sfo' => $installer->getTable('sales/order')),
28
+ "eo.order_id = sfo.entity_id",
29
+ array('order_status' => 'sfo.status')
30
+ );
31
+
32
+ //update query from select
33
+ $updateSql = $select->crossUpdateFromSelect(array('eo' => $orderTable));
34
+
35
+ //run query
36
+ $installer->getConnection()->query($updateSql);
37
+
38
+
39
+ /**
40
+ * create table
41
+ */
42
+ $createTable = $installer->getTable('email_connector/create');
43
+
44
+ if ($installer->getConnection()->isTableExists($createTable)) {
45
+ $installer->getConnection()->dropTable($createTable);
46
+ }
47
+
48
+ $table = $installer->getConnection()->newTable($createTable);
49
+ $table->addColumn('id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
50
+ 'primary' => true,
51
+ 'identity' => true,
52
+ 'unsigned' => true,
53
+ 'nullable' => false
54
+ ), 'Primary Key')
55
+ ->addColumn('email', Varien_Db_Ddl_Table::TYPE_TEXT, 255, array(
56
+ 'nullable' => false,
57
+ 'default' => ''
58
+ ), 'Email')
59
+ ->addColumn('from_name', Varien_Db_Ddl_Table::TYPE_TEXT, 255, array(
60
+ 'nullable' => false,
61
+ 'default' => ''
62
+ ), 'From Name')
63
+ ->addColumn('website_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
64
+ 'unsigned' => true,
65
+ 'nullable' => false,
66
+ 'default' => '0'
67
+ ), 'Website ID')
68
+ ->addColumn('name', Varien_Db_Ddl_Table::TYPE_TEXT, null, array(
69
+ 'unsigned' => true,
70
+ 'nullable' => false,
71
+ ), 'Template Name')
72
+ ->addColumn('subject', Varien_Db_Ddl_Table::TYPE_TEXT, null, array(
73
+ 'unsigned' => true,
74
+ 'nullable' => false,
75
+ ), 'Subject')
76
+ ->addColumn('html_content', Varien_Db_Ddl_Table::TYPE_TEXT, null, array(
77
+ 'unsigned' => true,
78
+ 'nullable' => false,
79
+ ), 'Html Content')
80
+ ->addColumn('plain_text_content', Varien_Db_Ddl_Table::TYPE_TEXT, null, array(
81
+ 'unsigned' => true,
82
+ 'nullable' => false,
83
+ ), 'Plain Text Content')
84
+ ->addColumn('created_at', Varien_Db_Ddl_Table::TYPE_TIMESTAMP, null, array(
85
+ ), 'Creation Time')
86
+ ->addColumn('message', Varien_Db_Ddl_Table::TYPE_TEXT, 255, array(
87
+ 'nullable' => false,
88
+ 'default' => ''
89
+ ), 'Error Message')
90
+ ->addColumn('is_created', Varien_Db_Ddl_Table::TYPE_SMALLINT, null, array(
91
+ 'unsigned' => true,
92
+ 'nullable' => true,
93
+ ), 'Is Created')
94
+ ->addColumn('copy', Varien_Db_Ddl_Table::TYPE_TEXT, 255, array(
95
+ 'nullable' => false,
96
+ 'default' => ''
97
+ ), 'Copy Email')
98
+ ->addIndex($this->getIdxName($createTable, array('is_created')),
99
+ array('is_created'))
100
+
101
+ ->setComment('Transactional Orders Data');
102
+ $installer->getConnection()->createTable($table);
103
+
104
+ //Save all order statuses as string to extension's config value
105
+ $source = Mage::getModel('adminhtml/system_config_source_order_status');
106
+ $statuses = $source->toOptionArray();
107
+
108
+ if(count($statuses) > 0 && $statuses[0]['value'] == '')
109
+ array_shift($statuses);
110
+
111
+ $options = array();
112
+ foreach($statuses as $status) {
113
+ $options[] = $status['value'];
114
+ }
115
+ $statusString = implode(',',$options);
116
+
117
+ $configModel = Mage::getModel('core/config');
118
+ $configModel->saveConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_SYNC_ORDER_STATUS,$statusString);
119
+
120
+ $installer->endSetup();
121
+
app/code/local/Dotdigitalgroup/Email/Block/Adminhtml/System/Bestsellers.php DELETED
@@ -1,18 +0,0 @@
1
- <?php
2
-
3
- class Dotdigitalgroup_Email_Block_Adminhtml_System_Bestsellers extends Mage_Adminhtml_Block_System_Config_Form_Field
4
- {
5
- protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
6
- {
7
- $baseUr = preg_replace('/index.php\//', '', Mage::getBaseUrl());
8
- $code = Mage::helper('connector')->getPasscode();
9
- $order = Mage::helper('connector')->getLastOrderNo();
10
- if(!strlen($code)) $code = '[PLEASE SET UP A PASSCODE]';
11
- if(!$order) $order = '[PLEASE MAP THE LAST ORDER NO]';
12
- $text = $baseUr . 'connector/email/products/order/@' . $order . '@/code/' . $code . '/mode/bestsellers';
13
- $element->setData('value', $text);
14
- $element->setData('disabled', 'disabled');
15
- return parent::_getElementHtml($element);
16
-
17
- }
18
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Dotdigitalgroup/Email/Block/Adminhtml/System/Config/Gridlist.php DELETED
@@ -1,104 +0,0 @@
1
- <?php
2
-
3
- class Dotdigitalgroup_Email_Block_Adminhtml_System_Config_Gridlist extends Mage_Adminhtml_Block_System_Config_Form_Field
4
- {
5
- protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
6
- {
7
- // Get the default HTML for this option
8
- $html = parent::_getElementHtml($element);
9
-
10
-
11
- $jQuery = '<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js" ></script>';
12
-
13
- $jQuery .='
14
- <script type="text/javascript">
15
- jQuery.noConflict();
16
- jQuery(document).ready(function() {
17
- var gridOptions = {
18
- "4" : "4",
19
- "8" : "8",
20
- "12" : "12",
21
- "16" : "16",
22
- "20" : "20",
23
- "24" : "24",
24
- "28" : "28",
25
- "32" : "32"
26
-
27
- };
28
- var listOptions = {
29
- "2" : "2",
30
- "4" : "4",
31
- "6" : "6",
32
- "8" : "8"
33
- }
34
-
35
- jQuery("#dynamic_content_products_related_display_type").change(function(){
36
-
37
- var display_type = jQuery(this).closest("tr").next().find("select");
38
- var display_mode = jQuery(this).val();
39
- changeOptions(display_type, display_mode);
40
-
41
-
42
- });
43
-
44
- jQuery("#dynamic_content_products_upsell_display_type").change(function(){
45
- var display_type = jQuery(this).closest("tr").next().find("select");
46
- var display_mode = jQuery(this).val();
47
- changeOptions(display_type, display_mode);
48
-
49
- });
50
- jQuery("#dynamic_content_products_crosssell_display_type").change(function(){
51
- var display_type = jQuery(this).closest("tr").next().find("select");
52
- var display_mode = jQuery(this).val();
53
- changeOptions(display_type, display_mode);
54
- });
55
- jQuery("#dynamic_content_products_best_display_type").change(function(){
56
- var display_type = jQuery(this).closest("tr").next().find("select");
57
- var display_mode = jQuery(this).val();
58
- changeOptions(display_type, display_mode);
59
- });
60
- jQuery("#dynamic_content_products_most_viewed_display_type").change(function(){
61
- var display_type = jQuery(this).closest("tr").next().find("select");
62
- var display_mode = jQuery(this).val();
63
- changeOptions(display_type, display_mode);
64
- });
65
- jQuery("#dynamic_content_manual_product_search_display_type").change(function(){
66
- var display_type = jQuery(this).closest("tr").next().find("select");
67
- var display_mode = jQuery(this).val();
68
- changeOptions(display_type, display_mode);
69
- });
70
- jQuery("#dynamic_content_products_recently_viewed_display_type").change(function(){
71
- var display_type = jQuery(this).closest("tr").next().find("select");
72
- var display_mode = jQuery(this).val();
73
- changeOptions(display_type, display_mode);
74
- });
75
-
76
- function changeOptions(display_type, display_mode){
77
- if(display_mode == "list"){
78
- display_type.empty();
79
-
80
- jQuery.each(listOptions, function(key, value) {
81
- display_type.append(jQuery("<option></option>")
82
- .attr("value", value).text(key));
83
- });
84
-
85
- }
86
- if(display_mode == "grid"){
87
- display_type.empty();
88
- jQuery.each(gridOptions, function(key, value) {
89
- display_type.append(jQuery("<option></option>")
90
- .attr("value", value).text(key));
91
- });
92
- }
93
- }
94
-
95
- });
96
- </script>';
97
-
98
- $html .= $jQuery;
99
-
100
- return $html;
101
- }
102
-
103
-
104
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Dotdigitalgroup/Email/Block/Adminhtml/System/Config/Insertvariable.php DELETED
@@ -1,13 +0,0 @@
1
- <?php
2
-
3
- class Dotdigitalgroup_Email_Block_Adminhtml_System_Config_Insertvariable extends Mage_Adminhtml_Block_System_Config_Form_Field
4
- {
5
- public function _getElementHtml($element){
6
-
7
- $element->setData('onclick', 'templateControl.openVariableChooser();return false;');
8
-
9
-
10
- return parent::_getElementHtml($element);
11
- }
12
-
13
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Dotdigitalgroup/Email/Block/Adminhtml/System/Config/Messagedefault.php DELETED
@@ -1,46 +0,0 @@
1
- <?php
2
-
3
- class Dotdigitalgroup_Email_Block_Adminhtml_System_Config_Messagedefault extends Mage_Adminhtml_Block_System_Config_Form_Field
4
- {
5
- const DEFAULT_TEXT = 'Default SMS Text';
6
-
7
- protected function _getElementHtml(Varien_Data_Form_Element_Abstract$element){
8
-
9
-
10
- $element->setData('placeholder', self::DEFAULT_TEXT);
11
-
12
- $element->setData('after_element_html', "
13
-
14
- <a href='#' onclick=\"injectText('sms_section_sms_message_one_message', '{{var order_number}}');return false;\">Insert Order Number</a>
15
- <a href='#' onclick=\"injectText('sms_section_sms_message_one_message', '{{var customer_name}}');return false;\">Insert Customer Name</a>
16
-
17
- <script type='text/javascript'>
18
-
19
- function addText(text){
20
- $('sms_section_sms_message_one_message').value += text;
21
- }
22
-
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
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Dotdigitalgroup/Email/Block/Adminhtml/System/Config/Smsmessagefour.php DELETED
@@ -1,23 +0,0 @@
1
- <?php
2
-
3
- class Dotdigitalgroup_Email_Block_Adminhtml_System_Config_Smsmessagefour extends Mage_Adminhtml_Block_System_Config_Form_Field
4
- {
5
- const DEFAULT_TEXT = 'Default SMS Text';
6
-
7
- protected function _getElementHtml(Varien_Data_Form_Element_Abstract$element){
8
-
9
-
10
- $element->setData('placeholder', self::DEFAULT_TEXT);
11
-
12
- $element->setData('after_element_html', "
13
-
14
- <a href='#' onclick=\"injectText('sms_section_sms_message_four_message', '{{var order_number}}');return false;\">Insert Order Number</a>
15
- <a href='#' onclick=\"injectText('sms_section_sms_message_four_message', '{{var customer_name}}');return false;\">Insert Customer Name</a>
16
-
17
-
18
- ");
19
- return parent::_getElementHtml($element);
20
- }
21
-
22
-
23
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Dotdigitalgroup/Email/Block/Adminhtml/System/Config/Smsmessagethree.php DELETED
@@ -1,23 +0,0 @@
1
- <?php
2
-
3
- class Dotdigitalgroup_Email_Block_Adminhtml_System_Config_Smsmessagethree extends Mage_Adminhtml_Block_System_Config_Form_Field
4
- {
5
- const DEFAULT_TEXT = 'Default SMS Text';
6
-
7
- protected function _getElementHtml(Varien_Data_Form_Element_Abstract$element){
8
-
9
-
10
- $element->setData('placeholder', self::DEFAULT_TEXT);
11
-
12
- $element->setData('after_element_html', "
13
-
14
- <a href='#' onclick=\"injectText('sms_section_sms_message_three_message', '{{var order_number}}');return false;\">Insert Order Number</a>
15
- <a href='#' onclick=\"injectText('sms_section_sms_message_three_message', '{{var customer_name}}');return false;\">Insert Customer Name</a>
16
-
17
-
18
- ");
19
- return parent::_getElementHtml($element);
20
- }
21
-
22
-
23
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Dotdigitalgroup/Email/Block/Adminhtml/System/Config/Smsmessagetwo.php DELETED
@@ -1,23 +0,0 @@
1
- <?php
2
-
3
- class Dotdigitalgroup_Email_Block_Adminhtml_System_Config_Smsmessagetwo extends Mage_Adminhtml_Block_System_Config_Form_Field
4
- {
5
- const DEFAULT_TEXT = 'Default SMS Text';
6
-
7
- protected function _getElementHtml(Varien_Data_Form_Element_Abstract$element){
8
-
9
-
10
- $element->setData('placeholder', self::DEFAULT_TEXT);
11
-
12
- $element->setData('after_element_html', "
13
-
14
- <a href='#' onclick=\"injectText('sms_section_sms_message_two_message', '{{var order_number}}');return false;\">Insert Order Number</a>
15
- <a href='#' onclick=\"injectText('sms_section_sms_message_two_message', '{{var customer_name}}');return false;\">Insert Customer Name</a>
16
-
17
-
18
- ");
19
- return parent::_getElementHtml($element);
20
- }
21
-
22
-
23
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Dotdigitalgroup/Email/Block/Adminhtml/System/Config/Validator.php DELETED
@@ -1,73 +0,0 @@
1
- <?php
2
-
3
-
4
- class Dotdigitalgroup_Email_Block_Adminhtml_System_Config_Validator extends Mage_Adminhtml_Block_System_Config_Form_Field
5
- {
6
-
7
- protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
8
- {
9
-
10
- // Get the default HTML for this option
11
- $html = parent::_getElementHtml($element);
12
-
13
- // Set up additional JavaScript for our validation using jQuery.
14
-
15
- $jquery = '<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js" ></script>';
16
-
17
- $html .=$jquery;
18
-
19
- $javaScript = "
20
- <script type=\"text/javascript\">
21
-
22
- jQuery.noConflict();
23
-
24
- jQuery(document).ready(function() {
25
- // Handler for .ready() called.
26
-
27
- // Hide our validation block
28
- jQuery('#row_connector_data_field_settings_customer_data_validator').hide();
29
-
30
- // Add listener for changing select box
31
- jQuery('#connector_data_field_settings_customer_data select').on('change', function() {
32
-
33
- var currentSelection = jQuery(this).val();
34
- var currentDropdownId = jQuery(this).attr('id');
35
-
36
- // foreach of the select fields on our mapping page:
37
- jQuery('select').each(function(){
38
- var thisId = jQuery(this).attr('id');
39
- if (thisId != currentDropdownId) {
40
-
41
- var currentLabel = jQuery('label[for=\\'' + thisId + '\\']').text();
42
- var thisVal = jQuery(this).val();
43
-
44
- switch (thisVal) {
45
- case '0':
46
- // ignore DO NOT MAP fields
47
- break;
48
- case currentSelection:
49
- // warning, that field is already mapped somewhere else - reset that value to 'Do not map''
50
- alert('Warning! You have overwritten: '+currentLabel);
51
- jQuery(this).val(0);
52
- break;
53
- default:
54
- break;
55
- break;
56
- }
57
-
58
- }
59
-
60
- });
61
-
62
- });
63
-
64
- });
65
-
66
-
67
- </script>";
68
-
69
- $html .= $javaScript;
70
- return $html;
71
- }
72
-
73
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Dotdigitalgroup/Email/Block/Adminhtml/System/Config/Waitingfield.php DELETED
@@ -1,43 +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
- protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
7
- {
8
- // Get the default HTML for this option
9
- $html = parent::_getElementHtml($element);
10
-
11
- $html .= sprintf('<div id="loadingmask" style="position: fixed;">
12
- <div class="loader" id="loading-mask-loader">
13
- <img src="%sskin/adminhtml/default/default/images/ajax-loader-tr.gif" alt="%s"/>%s', preg_replace('/index.php\//', '', $this->getBaseUrl()), $this->__('Loading...'), $this->__('Loading...'))
14
- . '<div id="loading-mask"></div></div>';
15
-
16
- $jQuery = '<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js" ></script>';
17
-
18
- $jQuery .='
19
- <script type="text/javascript">
20
- jQuery.noConflict();
21
- jQuery(document).ready(function() {
22
- //hide the load image field
23
- jQuery("#row_connector_api_settings_api_credentials_validator .scope-label").hide();
24
- var loadingmask = jQuery("#loadingmask");
25
- loadingmask.hide();
26
- loadingmask.css({top : "50\%", left: "50\%"})
27
-
28
- jQuery("button").click(function(){
29
-
30
- jQuery("body").css({"background-color": "black", "opacity": "0.4"});
31
-
32
- loadingmask.show();
33
- loadingmask.css({"display": "block", "opacity" : "1"});
34
- })
35
- });
36
- </script>';
37
-
38
- $html .= $jQuery;
39
-
40
- return $html;
41
- }
42
-
43
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Dotdigitalgroup/Email/Block/Adminhtml/System/Couponinfo.php DELETED
@@ -1,18 +0,0 @@
1
- <?php
2
-
3
- class Dotdigitalgroup_Email_Block_Adminhtml_System_Couponinfo extends Mage_Adminhtml_Block_System_Config_Form_Field
4
- {
5
- protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
6
- {
7
- $baseUr = preg_replace('/index.php\//', '', Mage::getBaseUrl());
8
- $code = Mage::helper('connector')->getPasscode();
9
- if(!strlen($code))
10
- $code = '[PLEASE SET UP A PASSCODE]';
11
- $text = $baseUr . 'connector/email/coupon/id/[INSERT ID HERE]/code/'. $code;
12
-
13
- $element->setData('value', $text);
14
- $element->setData('disabled', 'disabled');
15
- return parent::_getElementHtml($element);
16
- }
17
-
18
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Dotdigitalgroup/Email/Block/Adminhtml/System/Crosssell.php DELETED
@@ -1,20 +0,0 @@
1
- <?php
2
-
3
- class Dotdigitalgroup_Email_Block_Adminhtml_System_Crosssell extends Mage_Adminhtml_Block_System_Config_Form_Field
4
- {
5
- protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
6
- {
7
- $baseUr = preg_replace('/index.php\//', '', Mage::getBaseUrl());
8
- $helper = Mage::helper('connector');
9
- $code = $helper->getPasscode();
10
- $order = $helper->getLastOrderNo();
11
-
12
- if(!strlen($code) && !strlen($order)) $code = '[PLEASE SET UP A PASSCODE]';
13
- if(!$order) $order = '[PLEASE MAP THE LAST ORDER NO]';
14
-
15
- $text = $baseUr . 'connector/email/products/order/@' . $order . '@/code/' . $code . '/mode/crosssell';
16
- $element->setData('value', $text);
17
- $element->setData('disabled', 'disabled');
18
- return parent::_getElementHtml($element);
19
- }
20
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Dotdigitalgroup/Email/Block/Adminhtml/System/Lostbasket.php DELETED
@@ -1,19 +0,0 @@
1
- <?php
2
-
3
- class Dotdigitalgroup_Email_Block_Adminhtml_System_Lostbasket extends Mage_Adminhtml_Block_System_Config_Form_Field
4
- {
5
-
6
- protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
7
- {
8
- $baseUr = preg_replace('/index.php\//', '', Mage::getBaseUrl());
9
- $code = Mage::helper('connector')->getPasscode();
10
- if(!strlen($code))
11
- $code = '[PLEASE SET UP A PASSCODE]';
12
- $text = $baseUr . 'connector/email/basket/email/@EMAIL@/code/'. $code;
13
-
14
- $element->setData('value', $text);
15
- $element->setData('disabled', 'disabled');
16
- return parent::_getElementHtml($element);
17
- }
18
-
19
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Dotdigitalgroup/Email/Block/Adminhtml/System/Mostviewed.php DELETED
@@ -1,18 +0,0 @@
1
- <?php
2
-
3
- class Dotdigitalgroup_Email_Block_Adminhtml_System_Mostviewed extends Mage_Adminhtml_Block_System_Config_Form_Field
4
- {
5
- protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
6
- {
7
- $baseUr = preg_replace('/index.php\//', '', Mage::getBaseUrl());
8
- $code = Mage::helper('connector')->getPasscode();
9
- $order = Mage::helper('connector')->getLastOrderNo();
10
- if(!strlen($code)) $code = '[PLEASE SET UP A PASSCODE]';
11
- if(!$order) $order = '[PLEASE MAP THE LAST ORDER NO]';
12
- $text = $baseUr . 'connector/email/products/order/@' . $order . '@/code/' . $code . '/mode/mostviewed';
13
- $element->setData('value', $text);
14
- $element->setData('disabled', 'disabled');
15
- return parent::_getElementHtml($element);
16
-
17
- }
18
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Dotdigitalgroup/Email/Block/Adminhtml/System/Productpush.php DELETED
@@ -1,19 +0,0 @@
1
- <?php
2
-
3
- class Dotdigitalgroup_Email_Block_Adminhtml_System_Productpush extends Mage_Adminhtml_Block_System_Config_Form_Field
4
- {
5
- protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
6
- {
7
- $baseUr = preg_replace('/index.php\//', '', Mage::getBaseUrl());
8
- $helper = Mage::helper('connector');
9
- $code = $helper->getPasscode();
10
- $order = $helper->getLastOrderNo();
11
- if(!strlen($code)) $code = '[PLEASE SET UP A PASSCODE]';
12
- if(!$order) $order = '[PLEASE MAP THE LAST ORDER NO]';
13
- $text = $baseUr . 'connector/email/products/order/@' . $order . '@/code/' . $code . '/mode/productpush';
14
- $element->setData('value', $text);
15
- $element->setData('disabled', 'disabled');
16
- return parent::_getElementHtml($element);
17
-
18
- }
19
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Dotdigitalgroup/Email/Block/Adminhtml/System/Recentlyviewed.php DELETED
@@ -1,20 +0,0 @@
1
- <?php
2
- class Dotdigitalgroup_Email_Block_Adminhtml_System_Recentlyviewed extends Mage_Adminhtml_Block_System_Config_Form_Field
3
- {
4
- protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
5
- {
6
- $baseUr = preg_replace('/index.php\//', '', Mage::getBaseUrl());
7
- $helper = Mage::helper('connector');
8
- $code = $helper->getPasscode();
9
-
10
- $customerId = $helper->getMappedCustomerId();
11
-
12
- if(!strlen($code)) $code = '[PLEASE SET UP A PASSCODE]';
13
- if(!$customerId) $customerId = '[PLEASE MAP THE CUSTOMER ID]';
14
- $text = $baseUr . 'connector/email/products/customer/@' . $customerId . '@/code/' . $code . '/mode/recentlyviewed';
15
- $element->setData('value', $text);
16
- $element->setData('disabled', 'disabled');
17
- return parent::_getElementHtml($element);
18
-
19
- }
20
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Dotdigitalgroup/Email/Block/Adminhtml/System/Related.php DELETED
@@ -1,19 +0,0 @@
1
- <?php
2
-
3
- class Dotdigitalgroup_Email_Block_Adminhtml_System_Related extends Mage_Adminhtml_Block_System_Config_Form_Field
4
- {
5
- protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
6
- {
7
- $baseUr = preg_replace('/index.php\//', '', Mage::getBaseUrl());
8
- $helper = Mage::helper('connector');
9
- $code = $helper->getPasscode();
10
- $order = $helper->getLastOrderNo();
11
- if(!strlen($code)) $code = '[PLEASE SET UP A PASSCODE]';
12
- if(!$order) $order = '[PLEASE MAP THE LAST ORDER NO]';
13
- $text = $baseUr . 'connector/email/products/order/@' . $order . '@/code/' . $code . '/mode/related';
14
- $element->setData('value', $text);
15
-
16
- return parent::_getElementHtml($element);
17
-
18
- }
19
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Dotdigitalgroup/Email/Block/Adminhtml/System/Upsell.php DELETED
@@ -1,19 +0,0 @@
1
- <?php
2
- class Dotdigitalgroup_Email_Block_Adminhtml_System_Upsell extends Mage_Adminhtml_Block_System_Config_Form_Field
3
- {
4
- protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
5
- {
6
- $baseUr = preg_replace('/index.php\//', '', Mage::getBaseUrl());
7
- $helper = Mage::helper('connector');
8
- $code = $helper->getPasscode();
9
- $order = $helper->getLastOrderNo();
10
-
11
- if(!strlen($code)) $code = '[PLEASE SET UP A PASSCODE]';
12
- if(!$order) $order = '[PLEASE MAP THE LAST ORDER NO]';
13
-
14
- $text = $baseUr . 'connector/email/products/order/@' . $order . '@/code/' . $code . '/mode/upsell';
15
- $element->setData('value', $text);
16
-
17
- return parent::_getElementHtml($element);
18
- }
19
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Dotdigitalgroup/Email/Block/Debug/Forcecustomersync.php DELETED
@@ -1,21 +0,0 @@
1
- <?php
2
-
3
- class Dotdigitalgroup_Email_Block_Debug_Forcecustomersync extends Mage_Adminhtml_Block_System_Config_Form_Field
4
- {
5
-
6
- protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element) {
7
- $this->setElement($element);
8
- return $this->_getAddRowButtonHtml($this->__('Sync Customer Data Now'));
9
- }
10
-
11
- protected function _getAddRowButtonHtml($title) {
12
- $url = Mage::helper('adminhtml')->getUrl("connector/debug/forcecustomersync");
13
-
14
- return $this->getLayout()->createBlock('adminhtml/widget_button')
15
- ->setType('button')
16
- ->setLabel($this->__($title))
17
- ->setOnClick("window.location.href='" . $url . "'")
18
- ->toHtml();
19
- }
20
-
21
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Dotdigitalgroup/Email/Block/Debug/Forcelostbasketsync.php DELETED
@@ -1,21 +0,0 @@
1
- <?php
2
-
3
- class Dotdigitalgroup_Email_Block_Debug_Forcelostbasketsync extends Mage_Adminhtml_Block_System_Config_Form_Field
4
- {
5
-
6
- protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element) {
7
- $this->setElement($element);
8
- return $this->_getAddRowButtonHtml($this->__('Sync Lost Baskets Now'));
9
- }
10
-
11
- protected function _getAddRowButtonHtml($title) {
12
- $url = Mage::helper('adminhtml')->getUrl("connector/debug/forcelostbasketsync");
13
-
14
- return $this->getLayout()->createBlock('adminhtml/widget_button')
15
- ->setType('button')
16
- ->setLabel($this->__($title))
17
- ->setOnClick("window.location.href='" . $url . "'")
18
- ->toHtml();
19
- }
20
-
21
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Dotdigitalgroup/Email/Block/Debug/Forcesuppressedsync.php DELETED
@@ -1,21 +0,0 @@
1
- <?php
2
-
3
- class Dotdigitalgroup_Email_Block_Debug_Forcesuppressedsync extends Mage_Adminhtml_Block_System_Config_Form_Field
4
- {
5
-
6
- protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element) {
7
- $this->setElement($element);
8
- return $this->_getAddRowButtonHtml($this->__('Sync Suppressed Data Now'));
9
- }
10
-
11
- protected function _getAddRowButtonHtml($title) {
12
- $url = Mage::helper('adminhtml')->getUrl("connector/debug/forcesuppressed");
13
-
14
- return $this->getLayout()->createBlock('adminhtml/widget_button')
15
- ->setType('button')
16
- ->setLabel($this->__($title))
17
- ->setOnClick("window.location.href='" . $url . "'")
18
- ->toHtml();
19
- }
20
-
21
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Dotdigitalgroup/Email/Block/Debug/Rescuenow.php DELETED
@@ -1,21 +0,0 @@
1
- <?php
2
-
3
- class Dotdigitalgroup_Email_Block_Debug_Rescuenow extends Mage_Adminhtml_Block_System_Config_Form_Field
4
- {
5
-
6
- protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element) {
7
- $this->setElement($element);
8
- return $this->_getAddRowButtonHtml($this->__('Send Lost Basket Campaigns Now'));
9
- }
10
-
11
- protected function _getAddRowButtonHtml($title) {
12
- $url = Mage::helper('adminhtml')->getUrl("connector/debug/rescuenow");
13
-
14
- return $this->getLayout()->createBlock('adminhtml/widget_button')
15
- ->setType('button')
16
- ->setLabel($this->__($title))
17
- ->setOnClick("window.location.href='" . $url . "'")
18
- ->toHtml();
19
- }
20
-
21
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Dotdigitalgroup/Email/Block/Debug/Testcredentials.php DELETED
@@ -1,21 +0,0 @@
1
- <?php
2
-
3
- class Dotdigitalgroup_Email_Block_Debug_Testcredentials extends Mage_Adminhtml_Block_System_Config_Form_Field
4
- {
5
-
6
- protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element) {
7
- $this->setElement($element);
8
- return $this->_getAddRowButtonHtml($this->__('Test Credentials'));
9
- }
10
-
11
- protected function _getAddRowButtonHtml($title) {
12
- $url = Mage::helper('adminhtml')->getUrl("connector/debug/testcredentials");
13
-
14
- return $this->getLayout()->createBlock('adminhtml/widget_button')
15
- ->setType('button')
16
- ->setLabel($this->__($title))
17
- ->setOnClick("window.location.href='" . $url . "'")
18
- ->toHtml();
19
- }
20
-
21
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Dotdigitalgroup/Email/Block/Debug/Transactionalsync.php DELETED
@@ -1,20 +0,0 @@
1
- <?php
2
-
3
- class Dotdigitalgroup_Email_Block_Debug_Transactionalsync extends Mage_Adminhtml_Block_System_Config_Form_Field
4
- {
5
- protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element) {
6
- $this->setElement($element);
7
- return $this->_getAddRowButtonHtml($this->__('Run Baskets/Orders Synchronization'));
8
- }
9
-
10
- protected function _getAddRowButtonHtml($title) {
11
- $url = Mage::helper('adminhtml')->getUrl("connector/debug/transactionalSync");
12
-
13
- return $this->getLayout()->createBlock('adminhtml/widget_button')
14
- ->setType('button')
15
- ->setLabel($this->__($title))
16
- ->setOnClick("window.location.href='" . $url . "'")
17
- ->toHtml();
18
- }
19
-
20
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Dotdigitalgroup/Email/Block/Products.php DELETED
@@ -1,53 +0,0 @@
1
- <?php
2
-
3
- class Dotdigitalgroup_Email_Block_Products extends Mage_Core_Block_Template
4
- {
5
- /**
6
- * get the products to display for table
7
- */
8
- public function getRecommendedProducts()
9
- {
10
- //get all params
11
- $params = $this->getRequest()->getParams();
12
- $productsToDisplay = array();
13
-
14
- if(isset($params['customer'])){
15
- $productRecommended = new Dotdigitalgroup_Email_Model_Dynamic_Recommended();
16
- $productsToDisplay = $productRecommended->getProducts();
17
- $orderId = false;
18
-
19
- }else{
20
-
21
- $orderId = $params['order'];
22
- }
23
-
24
-
25
-
26
- if($orderId){
27
- $orderModel = Mage::getModel('sales/order')->load($orderId);
28
- if($orderModel->getId()){
29
- //order products
30
- $productRecommended = new Dotdigitalgroup_Email_Model_Dynamic_Recommended($orderModel);
31
-
32
- //get the order items recommendations
33
- $productsToDisplay = $productRecommended->getProducts();
34
- }
35
- }
36
-
37
- return $productsToDisplay;
38
- }
39
-
40
-
41
- public function getPriceHtml($product)
42
- {
43
- $this->setTemplate('connector/price.phtml');
44
- $this->setProduct($product);
45
- return $this->toHtml();
46
- }
47
-
48
- public function getMode()
49
- {
50
- return Mage::helper('connector/recommended')->getMode();
51
-
52
- }
53
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Dotdigitalgroup/Email/Helper/Api/DotNetExample.php DELETED
@@ -1,182 +0,0 @@
1
- <?php
2
- /**
3
- * mag17.
4
- *
5
- * User: chrisroseuk
6
- * Date: 19/04/2013
7
- * Time: 17:10
8
- *
9
- */
10
-
11
- /*
12
- *
13
- * using System;
14
- using System.Collections.Generic;
15
- using System.IO;
16
- using System.Net;
17
- using System.Text;
18
- using System.Threading;
19
- using Newtonsoft.Json;
20
-
21
- namespace Email.ImportContacts
22
- {
23
- class Program
24
- {
25
- private const string UserName = "";
26
- private const string Password = "";
27
- private const int AddressBookId = 1188372; //Your address book here
28
-
29
- static void Main(string[] args)
30
- {
31
- AppDomain.CurrentDomain.UnhandledException += PrintUnhandledException;
32
-
33
- ApiContactImport contactImport = ImportContactsFromFile();
34
- ApiContactImport contactImportResult = WaitUntilImportFinishes(contactImport);
35
- PrintContactImport(contactImportResult);
36
-
37
- Dictionary<String, String> contactImportReport = GetContactImportReport(contactImportResult.Id);
38
- PrintContactImportReport(contactImportReport);
39
-
40
- String csvReport = GetContactImportFaults(contactImportResult.Id);
41
- PrintCsvReport(csvReport);
42
- }
43
-
44
- private static String GetContactImportFaults(Guid importId)
45
- {
46
- string url = String.Format("https://apiconnector.com/v2/contacts/import/{0}/report-faults", importId);
47
- HttpWebRequest request = CreateRequest(url);
48
- String result = ReadResultAsString(request);
49
- return result;
50
- }
51
-
52
- private static void PrintCsvReport(string csvReport)
53
- {
54
- Console.WriteLine();
55
- Console.WriteLine(csvReport);
56
- }
57
-
58
- private static Dictionary<string, string> GetContactImportReport(Guid importId)
59
- {
60
- string url = String.Format("https://apiconnector.com/v2/contacts/import/{0}/report", importId);
61
- HttpWebRequest request = CreateRequest(url);
62
- Dictionary<string, string> result = ReadResult<Dictionary<string, string>>(request);
63
- return result;
64
- }
65
-
66
- private static ApiContactImport WaitUntilImportFinishes(ApiContactImport importResult)
67
- {
68
- ApiContactImport result = importResult;
69
-
70
- while (result.Status == ApiContactImportStatuses.NotFinished)
71
- {
72
- Thread.Sleep(TimeSpan.FromSeconds(10));
73
-
74
- HttpWebRequest request = CreateRequest("https://apiconnector.com/v2/contacts/import/" + importResult.Id);
75
- result = ReadResult<ApiContactImport>(request);
76
- }
77
-
78
- return result;
79
- }
80
-
81
- private static ApiContactImport ImportContactsFromFile()
82
- {
83
- string url = String.Format("https://apiconnector.com/v2/address-books/{0}/contacts/import", AddressBookId);
84
- HttpWebRequest request = CreateRequest(url);
85
- request.Method = "POST";
86
-
87
- AddContactsToRequest(request);
88
-
89
- ApiContactImport result = ReadResult<ApiContactImport>(request);
90
- return result;
91
- }
92
-
93
- private static void AddContactsToRequest(HttpWebRequest request)
94
- {
95
- String boundary = Guid.NewGuid().ToString("N");
96
- request.ContentType = String.Format(@"multipart/form-data; boundary=""{0}""", boundary);
97
-
98
- using (BinaryWriter writer = new BinaryWriter(request.GetRequestStream()))
99
- {
100
- writer.Write(Encoding.UTF8.GetBytes("\r\n--" + boundary + "\r\n"));
101
-
102
- const string headerTemplate = "Content-Disposition: form-data; name=\"{0}\"; filename=\"{1}\"\r\n\r\n";
103
- string header = string.Format(headerTemplate, "Contacts", "Contacts.csv");
104
-
105
- byte[] headerbytes = Encoding.UTF8.GetBytes(header);
106
- writer.Write(headerbytes);
107
-
108
- byte[] contacts = File.ReadAllBytes("Contacts.csv");
109
- writer.Write(contacts);
110
-
111
- writer.Write(Encoding.UTF8.GetBytes("\r\n--" + boundary + "--\r\n"));
112
- }
113
- }
114
-
115
- private static HttpWebRequest CreateRequest(string url)
116
- {
117
- HttpWebRequest request = WebRequest.Create(url) as HttpWebRequest;
118
- String base64 = Convert.ToBase64String(Encoding.UTF8.GetBytes(UserName + ":" + Password));
119
- request.Headers.Add("Authorization", "Basic " + base64);
120
-
121
- return request;
122
- }
123
-
124
- private static void PrintContactImport(ApiContactImport importResult)
125
- {
126
- Console.WriteLine("Import Id = {0}", importResult.Id);
127
- Console.WriteLine("Import Status = {0}", importResult.Status);
128
- }
129
-
130
- private static void PrintContactImportReport(Dictionary<String, String> contactImportReport)
131
- {
132
- Console.WriteLine();
133
- foreach (KeyValuePair<string, string> pair in contactImportReport)
134
- {
135
- Console.WriteLine("{0,-20} = {1}", pair.Key, pair.Value);
136
- }
137
- }
138
-
139
- private static String ReadResultAsString(WebRequest request)
140
- {
141
- String result;
142
-
143
- using (WebResponse response = request.GetResponse())
144
- {
145
- using (StreamReader reader = new StreamReader(response.GetResponseStream()))
146
- {
147
- result = reader.ReadToEnd();
148
- }
149
- }
150
-
151
- return result;
152
- }
153
-
154
- private static TResult ReadResult<TResult>(WebRequest request)
155
- {
156
- TResult result;
157
-
158
- using (WebResponse response = request.GetResponse())
159
- {
160
- using (StreamReader reader = new StreamReader(response.GetResponseStream()))
161
- {
162
- JsonSerializer serializer = new JsonSerializer();
163
- using (JsonTextReader jsonReader = new JsonTextReader(reader))
164
- {
165
- result = serializer.Deserialize<TResult>(jsonReader);
166
- }
167
- }
168
- }
169
-
170
- return result;
171
- }
172
-
173
- private static void PrintUnhandledException(object sender, UnhandledExceptionEventArgs e)
174
- {
175
- Console.WriteLine(e.ExceptionObject);
176
- }
177
- }
178
- }
179
- *
180
- *
181
- *
182
- */
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Dotdigitalgroup/Email/Helper/Api/Restrequest.php DELETED
@@ -1,298 +0,0 @@
1
- <?php
2
-
3
- class Dotdigitalgroup_Email_Helper_Api_Restrequest extends Dotdigitalgroup_Email_Helper_Data
4
- {
5
- protected $url;
6
- protected $verb;
7
- protected $requestBody;
8
- protected $requestLength;
9
- protected $username;
10
- protected $password;
11
- protected $acceptType;
12
- protected $responseBody;
13
- protected $responseInfo;
14
-
15
- public function __construct() // ($url = null, $verb = 'GET', $requestBody = null)
16
- {
17
- $this->url = null; //$url;
18
- $this->verb = null; //$verb;
19
- $this->requestBody = null; //$requestBody;
20
- $this->requestLength = 0;
21
- $this->username = Mage::getStoreConfig('connector_api_settings/api_credentials/username');
22
- $this->password = Mage::getStoreConfig('connector_api_settings/api_credentials/password');
23
- $this->acceptType = 'application/json';
24
- $this->responseBody = null;
25
- $this->responseInfo = null;
26
-
27
- if ($this->requestBody !== null)
28
- {
29
- $this->buildPostBody();
30
- }
31
-
32
- //parent::__construct();
33
- }
34
-
35
- private function prettyPrint( $json )
36
- {
37
- $result = '';
38
- $level = 0;
39
- $prev_char = '';
40
- $in_quotes = false;
41
- $ends_line_level = NULL;
42
- $json_length = strlen( $json );
43
-
44
- for( $i = 0; $i < $json_length; $i++ ) {
45
- $char = $json[$i];
46
- $new_line_level = NULL;
47
- $post = "";
48
- if( $ends_line_level !== NULL ) {
49
- $new_line_level = $ends_line_level;
50
- $ends_line_level = NULL;
51
- }
52
- if( $char === '"' && $prev_char != '\\' ) {
53
- $in_quotes = !$in_quotes;
54
- } else if( ! $in_quotes ) {
55
- switch( $char ) {
56
- case '}': case ']':
57
- $level--;
58
- $ends_line_level = NULL;
59
- $new_line_level = $level;
60
- break;
61
-
62
- case '{': case '[':
63
- $level++;
64
- case ',':
65
- $ends_line_level = $level;
66
- break;
67
-
68
- case ':':
69
- $post = " ";
70
- break;
71
-
72
- case " ": case "\t": case "\n": case "\r":
73
- $char = "";
74
- $ends_line_level = $new_line_level;
75
- $new_line_level = NULL;
76
- break;
77
- }
78
- }
79
- if( $new_line_level !== NULL ) {
80
- $result .= "\n".str_repeat( "\t", $new_line_level );
81
- }
82
- $result .= $char.$post;
83
- $prev_char = $char;
84
- }
85
-
86
- return $result;
87
- }
88
-
89
- // returns the object as JSON
90
- public function toJSON($pretty=false){
91
-
92
- if (!$pretty) {
93
- return json_encode($this->expose());
94
- }
95
- else {
96
- return $this->prettyPrint(json_encode($this->expose()));
97
- }
98
- }
99
-
100
- // exposes the class as an array of objects
101
- public function expose() {
102
-
103
- return get_object_vars($this);
104
-
105
- }
106
-
107
-
108
- public function flush ()
109
- {
110
- $this->requestBody = null;
111
- $this->requestLength = 0;
112
- $this->verb = 'GET';
113
- $this->responseBody = null;
114
- $this->responseInfo = null;
115
- }
116
-
117
- public function execute ()
118
- {
119
- $ch = curl_init();
120
- $this->setAuth($ch);
121
-
122
- try
123
- {
124
- switch (strtoupper($this->verb))
125
- {
126
- case 'GET':
127
- $this->executeGet($ch);
128
- break;
129
- case 'POST':
130
- $this->executePost($ch);
131
- break;
132
- case 'PUT':
133
- $this->executePut($ch);
134
- break;
135
- case 'DELETE':
136
- $this->executeDelete($ch);
137
- break;
138
- default:
139
- throw new InvalidArgumentException('Current verb (' . $this->verb . ') is an invalid REST verb.');
140
- }
141
- }
142
- catch (InvalidArgumentException $e)
143
- {
144
- curl_close($ch);
145
- throw $e;
146
- }
147
- catch (Exception $e)
148
- {
149
- curl_close($ch);
150
- throw $e;
151
- }
152
-
153
- }
154
-
155
- public function buildPostBody($data = null)
156
- {
157
- $data = ($data !== null)? $data : $this->requestBody;
158
-
159
- if (!is_array($data)){
160
- throw new InvalidArgumentException('Invalid data input for postBody. Array expected');
161
- }
162
-
163
- $data = http_build_query($data, '', '&');
164
- $this->requestBody = $data;
165
- }
166
-
167
- protected function executeGet ($ch)
168
- {
169
- $this->doExecute($ch);
170
- }
171
-
172
- protected function executePost ($ch)
173
- {
174
- if (!is_string($this->requestBody))
175
- {
176
- $this->buildPostBody();
177
- }
178
-
179
- curl_setopt($ch, CURLOPT_POSTFIELDS, $this->requestBody);
180
- curl_setopt($ch, CURLOPT_POST, 1);
181
-
182
- $this->doExecute($ch);
183
- }
184
-
185
- protected function executePut($ch)
186
- {
187
- if (!is_string($this->requestBody)){
188
- $this->buildPostBody();
189
- }
190
-
191
- $this->requestLength = strlen($this->requestBody);
192
-
193
- $fh = fopen('php://memory', 'rw');
194
- fwrite($fh, $this->requestBody);
195
- rewind($fh);
196
-
197
- curl_setopt($ch, CURLOPT_INFILE, $fh);
198
- curl_setopt($ch, CURLOPT_INFILESIZE, $this->requestLength);
199
- curl_setopt($ch, CURLOPT_PUT, true);
200
-
201
- $this->doExecute($ch);
202
-
203
- fclose($fh);
204
- }
205
-
206
- protected function executeDelete ($ch)
207
- {
208
- curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'DELETE');
209
-
210
- $this->doExecute($ch);
211
- }
212
-
213
- protected function doExecute (&$curlHandle)
214
- {
215
- $this->setCurlOpts($curlHandle);
216
- $this->responseBody = curl_exec($curlHandle);
217
- $this->responseInfo = curl_getinfo($curlHandle);
218
-
219
- curl_close($curlHandle);
220
- }
221
-
222
- protected function setCurlOpts (&$curlHandle)
223
- {
224
- curl_setopt($curlHandle, CURLOPT_TIMEOUT, 10);
225
- curl_setopt($curlHandle, CURLOPT_URL, $this->url);
226
- curl_setopt($curlHandle, CURLOPT_RETURNTRANSFER, true);
227
- curl_setopt($curlHandle, CURLOPT_HTTPHEADER, array ('Accept: ' . $this->acceptType ,'Content-Type: application/json'));
228
- }
229
-
230
- protected function setAuth (&$curlHandle)
231
- {
232
- if ($this->username !== null && $this->password !== null)
233
- {
234
- curl_setopt($curlHandle, CURLAUTH_BASIC, CURLAUTH_DIGEST);
235
- curl_setopt($curlHandle, CURLOPT_USERPWD, $this->username . ':' . $this->password);
236
- }
237
- }
238
-
239
- public function getAcceptType ()
240
- {
241
- return $this->acceptType;
242
- }
243
-
244
- public function setAcceptType ($acceptType)
245
- {
246
- $this->acceptType = $acceptType;
247
- }
248
-
249
- public function getPassword ()
250
- {
251
- return $this->password;
252
- }
253
-
254
- public function setPassword ($password)
255
- {
256
- $this->password = $password;
257
- }
258
-
259
- public function getResponseBody ()
260
- {
261
- return $this->responseBody;
262
- }
263
-
264
- public function getResponseInfo ()
265
- {
266
- return $this->responseInfo;
267
- }
268
-
269
- public function getUrl ()
270
- {
271
- return $this->url;
272
- }
273
-
274
- public function setUrl ($url)
275
- {
276
- $this->url = $url;
277
- }
278
-
279
- public function getUsername ()
280
- {
281
- return $this->username;
282
- }
283
-
284
- public function setUsername ($username)
285
- {
286
- $this->username = $username;
287
- }
288
-
289
- public function getVerb ()
290
- {
291
- return $this->verb;
292
- }
293
-
294
- public function setVerb ($verb)
295
- {
296
- $this->verb = $verb;
297
- }
298
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Dotdigitalgroup/Email/Helper/Data.php DELETED
@@ -1,96 +0,0 @@
1
- <?php
2
- /*
3
- * empty helper to keep admin from breaking
4
- */
5
- class Dotdigitalgroup_Email_Helper_Data extends Mage_Core_Helper_Abstract
6
- {
7
- const XML_PATH_PASSCODE = 'connector_advanced_settings/external/passcode';
8
- const XML_PATH_LAST_ORDER_NO = 'connector_data_field_settings/customer_data/last_order_no';
9
- const XML_PATH_MAPPING_CUSTOMER_ID = 'connector_data_field_settings/customer_data/customer_id';
10
- const XML_PATH_ENABLED_LOGS = 'connector_advanced_settings/admin/debug';
11
-
12
-
13
- /**
14
- * return the time scheldule for the cronjob
15
- * @param $code
16
- * @return mixed
17
- */
18
- public function getSchelduledAtCronjob($code)
19
- {
20
- /* @var $collection Mage_Cron_Model_Resource_Schedule_Collection */
21
- $collection = Mage::getModel('cron/schedule')->getCollection();
22
- $collection->addFieldToFilter('job_code', $code)
23
- ->addFieldToFilter('status', Mage_Cron_Model_Schedule::STATUS_PENDING)
24
- ->addOrder('scheduled_at', Varien_Data_Collection_Db::SORT_ORDER_DESC)
25
- ->getSelect()->limit(1);
26
- $schedule = $collection->getFirstItem();
27
-
28
- $scheduleAt = $schedule->getData('scheduled_at');
29
-
30
- return $scheduleAt;
31
- }
32
-
33
- public function auth($authRequest)
34
- {
35
- if($authRequest == Mage::getStoreConfig(self::XML_PATH_PASSCODE)){
36
- return true;
37
- }
38
-
39
- if($this->isEnabledLogs())
40
- $this->log('authenication failed : ' . $authRequest , null, 'auth.log');
41
- exit();
42
- }
43
-
44
- public function getMappedCustomerId()
45
- {
46
- return Mage::getStoreConfig(self::XML_PATH_MAPPING_CUSTOMER_ID);
47
- }
48
-
49
- public function getPasscode()
50
- {
51
- return Mage::getStoreConfig(self::XML_PATH_PASSCODE);
52
- }
53
-
54
- public function getLastOrderNo()
55
- {
56
- return Mage::getStoreConfig(self::XML_PATH_LAST_ORDER_NO);
57
-
58
- }
59
-
60
- public function log($data, $level = Zend_Log::DEBUG, $filename = 'api.log')
61
- {
62
- if($this->isEnabledLogs()){
63
- $filename = 'connector_' . $filename;
64
-
65
- Mage::log($data, $level, $filename, $force = true);
66
- }
67
- }
68
-
69
- public function isEnabledLogs()
70
- {
71
- return (bool) Mage::getStoreConfig(self::XML_PATH_ENABLED_LOGS);
72
- }
73
-
74
- public function isOrderTransactionalEnabled()
75
- {
76
- return (bool) Mage::getStoreConfig(Dotdigitalgroup_Email_Model_Sales_Order::XML_PATH_TRANSACTIONAL_DATA_ENABLED);
77
- }
78
-
79
- public function isCustomerSyncEnabled()
80
- {
81
- return (bool) Mage::getStoreConfig(Dotdigitalgroup_Email_Model_Customer_Customer::XML_PATH_CUSTOMER_SYNC_ENABLE);
82
- }
83
-
84
- public function getConnectorVersion()
85
- {
86
-
87
- $modules = (array) Mage::getConfig()->getNode('modules')->children();
88
-
89
- if(isset($modules['Dotdigitalgroup_Email'])){
90
-
91
- $moduleName = $modules['Dotdigitalgroup_Email'];
92
- return $moduleName->version;
93
- }
94
- return '';
95
- }
96
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Dotdigitalgroup/Email/Helper/Recommended.php DELETED
@@ -1,191 +0,0 @@
1
- <?php
2
-
3
- class Dotdigitalgroup_Email_Helper_Recommended extends Mage_Core_Helper_Abstract
4
- {
5
- const XML_PATH_RELATED_PRODUCTS_TYPE = 'dynamic_content/products/related_display_type';
6
- const XML_PATH_UPSELL_PRODUCTS_TYPE = 'dynamic_content/products/upsell_display_type';
7
- const XML_PATH_CROSSSELL_PRODUCTS_TYPE = 'dynamic_content/products/crosssell_display_type';
8
- const XML_PATH_BESTSELLER_PRODUCT_TYPE = 'dynamic_content/products/best_display_type';
9
- const XML_PATH_MOSTVIEWED_PRODUCT_TYPE = 'dynamic_content/products/most_viewed_display_type';
10
- const XML_PATH_RECENTLYVIEWED_PRODUCT_TYPE = 'dynamic_content/products/recently_viewed_display_type';
11
- const XML_PATH_PRODUCTPUSH_TYPE = 'dynamic_content/manual_product_search/display_type';
12
-
13
-
14
- const XML_PATH_RELATED_PRODUCTS_ITEMS = 'dynamic_content/products/related_items_to_display';
15
- const XML_PATH_UPSELL_PRODUCTS_ITEMS = 'dynamic_content/products/upsell_items_to_display';
16
- const XML_PATH_CROSSSELL_PRODUCTS_ITEMS = 'dynamic_content/products/crosssell_items_to_display';
17
- const XML_PATH_BESTSELLER_PRODUCT_ITEMS = 'dynamic_content/products/best_items_to_display';
18
- const XML_PATH_MOSTVIEWED_PRODUCT_ITEMS = 'dynamic_content/products/most_viewed_items_to_display';
19
- const XML_PATH_RECENTLYVIEWED_PRODUCT_ITEMS = 'dynamic_content/products/recently_viewed_items_to_display';
20
- const XML_PATH_PRODUCTPUSH_DISPLAY_ITEMS = 'dynamic_content/manual_product_search/items_to_display';
21
-
22
-
23
- const XML_PATH_BESTSELLER_TIME_PERIOD = 'dynamic_content/products/best_time_period';
24
- const XML_PATH_MOSTVIEWED_TIME_PERIOD = 'dynamic_content/products/most_viewed_time_period';
25
-
26
- const XML_PATH_FALLBACK_PRODUCTS_ITEMS = 'dynamic_content/fallback_products/product_list';
27
-
28
- const XML_PATH_PRODUCTPUSH_ITEMS = 'dynamic_content/manual_product_search/products_push_list';
29
-
30
- public $periods = array('week', 'month', 'year');
31
-
32
-
33
- /**
34
- * product recommendation type
35
- * @var string
36
- */
37
-
38
-
39
- /**
40
- * Dispay mode
41
- * @return mixed|string grid:list
42
- */
43
- public function getMode()
44
- {
45
- $mode = Mage::app()->getRequest()->getParam('mode');
46
- $type = '';
47
- if($mode){
48
- switch($mode){
49
- case 'related':
50
- $type = $this->getRelatedProductsType();
51
- break;
52
- case 'upsell':
53
- $type = $this->getUpsellProductsType();
54
- break;
55
- case 'crosssell':
56
- $type = $this->getCrosssellProductsType();
57
- break;
58
- case 'bestsellers':
59
- $type = $this->getBestSellerProductsType();
60
- break;
61
- case 'mostviewed':
62
- $type = $this->getMostViewedProductsType();
63
- break;
64
- case 'recentlyviewed':
65
- $type = $this->getRecentlyviewedProductsType();
66
- break;
67
- case 'productpush':
68
- $type = $this->getProductpushProductsType();
69
- }
70
- }
71
-
72
- return $type;
73
- }
74
-
75
- public function getRelatedProductsType($storeId = 0)
76
- {
77
- return Mage::getStoreConfig(self::XML_PATH_RELATED_PRODUCTS_TYPE, $storeId);
78
- }
79
-
80
- public function getUpsellProductsType($storeId = 0)
81
- {
82
- return Mage::getStoreConfig(self::XML_PATH_UPSELL_PRODUCTS_TYPE, $storeId);
83
-
84
- }
85
-
86
- public function getCrosssellProductsType($storeId = 0)
87
- {
88
- return Mage::getStoreConfig(self::XML_PATH_CROSSSELL_PRODUCTS_TYPE, $storeId);
89
- }
90
-
91
- public function getBestSellerProductsType($storeId = 0)
92
- {
93
- return Mage::getStoreConfig(self::XML_PATH_BESTSELLER_PRODUCT_TYPE, $storeId);
94
- }
95
-
96
- public function getMostViewedProductsType($storeId = 0)
97
- {
98
- return Mage::getStoreConfig(self::XML_PATH_MOSTVIEWED_PRODUCT_TYPE, $storeId);
99
- }
100
-
101
- public function getRecentlyviewedProductsType($storeId = 0)
102
- {
103
- return Mage::getStoreConfig(self::XML_PATH_RECENTLYVIEWED_PRODUCT_TYPE, $storeId);
104
- }
105
-
106
- public function getProductpushProductsType($storeId = 0)
107
- {
108
- return Mage::getStoreConfig(self::XML_PATH_PRODUCTPUSH_TYPE, $storeId);
109
- }
110
-
111
-
112
-
113
- /**
114
- * Limit of products displayed
115
- * @return int|mixed
116
- */
117
- public function getLimit()
118
- {
119
- $mode = Mage::registry('mode');
120
- $limit = 0;
121
- if($mode){
122
- switch($mode){
123
- case 'related':
124
- $limit = Mage::getStoreConfig(self::XML_PATH_RELATED_PRODUCTS_ITEMS);
125
- break;
126
- case 'upsell':
127
- $limit = Mage::getStoreConfig(self::XML_PATH_UPSELL_PRODUCTS_ITEMS);
128
- break;
129
- case 'crosssell':
130
- $limit = Mage::getStoreConfig(self::XML_PATH_CROSSSELL_PRODUCTS_ITEMS);
131
- break;
132
- case 'bestsellers':
133
- $limit = Mage::getStoreConfig(self::XML_PATH_BESTSELLER_PRODUCT_ITEMS);
134
- break;
135
- case 'mostviewed':
136
- $limit = Mage::getStoreConfig(self::XML_PATH_MOSTVIEWED_PRODUCT_ITEMS);
137
- break;
138
- case 'recentlyviewed':
139
- $limit = Mage::getStoreConfig(self::XML_PATH_RECENTLYVIEWED_PRODUCT_ITEMS);
140
- break;
141
- case 'productpush':
142
- $limit = Mage::getStoreConfig(self::XML_PATH_PRODUCTPUSH_DISPLAY_ITEMS);
143
- }
144
- }
145
-
146
- return $limit;
147
- }
148
-
149
- public function getFallbackIds(){
150
- $fallbackIds = Mage::getStoreConfig(self::XML_PATH_FALLBACK_PRODUCTS_ITEMS);
151
- if($fallbackIds)
152
- return explode(',', Mage::getStoreConfig(self::XML_PATH_FALLBACK_PRODUCTS_ITEMS));
153
- return array();
154
- }
155
-
156
- public function getTimeFromConfig($config)
157
- {
158
- $now = new Zend_Date();
159
- $period = '';
160
- if($config == 'mostviewed')
161
- $period = Mage::getStoreConfig(self::XML_PATH_MOSTVIEWED_TIME_PERIOD);
162
- elseif($config == 'bestsellers')
163
- $period = Mage::getStoreConfig(self::XML_PATH_BESTSELLER_TIME_PERIOD);
164
- elseif($config == 'recentlyviewed')
165
- $period = Mage::getStoreConfig(self::XML_PATH_MOSTVIEWED_TIME_PERIOD);
166
-
167
- if($period == 'week'){
168
- $sub = Zend_Date::WEEK;
169
- }elseif($period == 'month'){
170
- $sub = Zend_Date::MONTH;
171
- }elseif($period == 'year'){
172
- $sub = Zend_Date::YEAR;
173
- }
174
-
175
- if(isset($sub)){
176
- $period = $now->sub(1, $sub);
177
-
178
- return $period->tostring(Zend_Date::ISO_8601);
179
- }
180
- }
181
-
182
- public function getProductPushIds($storeId = 0)
183
- {
184
- $productIds = Mage::getStoreConfig(self::XML_PATH_PRODUCTPUSH_ITEMS, $storeId);
185
-
186
- return explode(',', $productIds);
187
-
188
- }
189
-
190
-
191
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Dotdigitalgroup/Email/Model/Account/Test.php DELETED
@@ -1,40 +0,0 @@
1
- <?php
2
-
3
- class Dotdigitalgroup_Email_Model_Account_Test extends Dotdigitalgroup_Email_Model_Api_Rest
4
- {
5
- const TEST_API_USERNAME = 'apiuser-2c692ba1bbd2@apiconnector.com';
6
- const TEST_API_PASSWORD = 'Magento2013';
7
- const TEST_API_CAMPAIGN = '2643928';
8
- const TEST_CONTACT_ID = '13';
9
- const TEST_CONTACT_EMAIL = 'ben.staveley@dotmailer.co.uk';
10
-
11
- public function test($api_user = null, $api_password = null)
12
- {
13
- if($api_user && $api_password){
14
- $this->_api_user = $api_user;
15
- $this->_api_password = $api_password;
16
- }
17
- $response = array('errors' => 0, 'message' => '');
18
- $result = $this->testAccount();
19
- if(!$result){
20
- $response['errors'] = true;
21
- $response['message'] = 'Invalid API Credentials.';
22
- }
23
- $this->sendInstallConfirmation();
24
-
25
- return $response;
26
- }
27
-
28
- public function sendInstallConfirmation()
29
- {
30
- $this->_api_user = self::TEST_API_USERNAME;
31
- $this->_api_password = self::TEST_API_PASSWORD;
32
- $testEmail = self::TEST_CONTACT_EMAIL;
33
- $contactId = self::TEST_CONTACT_ID;
34
- $campaignId = self::TEST_API_CAMPAIGN;
35
-
36
- // send initial info
37
- $this->sendIntallInfo($testEmail, $contactId, $campaignId);
38
-
39
- }
40
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Dotdigitalgroup/Email/Model/Api/Rest.php DELETED
@@ -1,729 +0,0 @@
1
- <?php
2
-
3
- class Dotdigitalgroup_Email_Model_Api_Rest extends Mage_Core_Model_Abstract
4
- {
5
- const REST_WAIT_UPLOAD_TIME = 5;
6
- //rest api data
7
- const REST_ACCOUNT_INFO = 'https://apiconnector.com/v2/account-info';
8
- const REST_CONTACTS = 'https://apiconnector.com/v2/contacts/';
9
- const REST_CONTACTS_IMPORT = 'https://apiconnector.com/v2/contacts/import/';
10
- const REST_ADDRESS_BOOKS = 'https://apiconnector.com/v2/address-books';
11
- const REST_DATA_FILEDS = 'https://apiconnector.com/v2/data-fields';
12
- const REST_TRANSACTIONAL_DATA_IMPORT = 'https://apiconnector.com/v2/contacts/transactional-data/import/';
13
- const REST_SINGLE_TRANSACTIONAL_DATA_IMPORT = 'https://apiconnector.com/v2/contacts/transactional-data/';
14
- const REST_CAMPAIGN_SEND = 'https://apiconnector.com/v2/campaigns/send';
15
- const REST_CONTACTS_SUPPRESSED_SINCE = 'https://apiconnector.com/v2/contacts/suppressed-since/';
16
- const REST_DATA_FIELDS_CAMPAIGNS = 'https://apiconnector.com/v2/campaigns';
17
- const REST_SMS_MESSAGE_SEND_TO = 'https://apiconnector.com/v2/sms-messages/send-to/';
18
- //rest error responces
19
- const REST_CONTACT_NOT_FOUND = 'Error: ERROR_CONTACT_NOT_FOUND';
20
- const REST_STATUS_IMPORT_REPORT_NOT_FOUND = 'Import is not processed yet or completed with error. ERROR_IMPORT_REPORT_NOT_FOUND';
21
- const REST_STATUS_REPORT_NOTFINISHED = 'NotFinished';
22
- const REST_TRANSACTIONAL_DATA_NOT_EXISTS = 'Error: ERROR_TRANSACTIONAL_DATA_DOES_NOT_EXIST';
23
- const REST_API_USAGE_EXCEEDED = 'Your account has generated excess API activity and is being temporarily capped. Please contact support. ERROR_APIUSAGE_EXCEEDED';
24
-
25
- protected $_api_user;
26
- protected $_api_password;
27
- protected $_customers_file_slug = 'customer_sync';
28
- protected $_subscribers_file_slug = 'subscriber_sync';
29
- protected $_api_helper;
30
- protected $_subscribers_address_book_id;
31
- protected $_customers_address_book_id;
32
- protected $_filename;
33
- protected $_subscribers_filename;
34
- protected $_customers_filename;
35
- protected $_limit = 10;
36
- protected $_address_book_id;
37
- public $fileHelper; /** @var Dotdigitalgroup_Email_Helper_File */
38
- protected $_helper;
39
- public $result = array('error' => false, 'message' => '');
40
- protected $_log_filename = 'api.log';
41
-
42
- public function __construct()
43
- {
44
- // connect to default
45
- $this->_api_user = Mage::getStoreConfig(Dotdigitalgroup_Email_Model_Customer_Customer::XML_PATH_CONNECTOR_API_USERNAME);
46
- $this->_api_password = Mage::getStoreConfig(Dotdigitalgroup_Email_Model_Customer_Customer::XML_PATH_CONNECTOR_API_PASSWORD);
47
- $this->_helper = Mage::helper('connector');
48
- }
49
-
50
- /**
51
- * Deletes all contacts from a given address book.
52
- * @param $addressBooks
53
- * @return mixed
54
- */
55
- protected function deleteAddressBookContacts($addressBooks) {
56
-
57
- foreach ($addressBooks as $addressBookId) {
58
-
59
- // skip if contact Id is null otherwise the API will delete ALL contacts from the address book!!!
60
- if ($addressBookId==null) continue;
61
- $ch = curl_init("https://apiconnector.com/v2/address-books/{$addressBookId}/contacts/");
62
- curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "DELETE");
63
- curl_setopt($ch, CURLOPT_USERPWD, $this->_api_user . ':' . $this->_api_password);
64
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
65
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
66
-
67
- // delete the contact from the address book
68
- $result = curl_exec($ch);
69
- $result = json_decode($result);
70
- }
71
- }
72
-
73
-
74
- /**
75
- * Bulk creates, or bulk updates, contacts. Import format can either be CSV or Excel.
76
- * Must include one column called "Email". Any other columns will attempt to map to your custom data fields.
77
- * The ID of returned object can be used to query import progress.
78
- * @param $filename
79
- * @param $addressBookId
80
- * @return mixed
81
- */
82
- protected function postAddressBookContactsImport($filename, $addressBookId)
83
- {
84
- // ...the API request
85
- $uploadUrl = "https://apiconnector.com/v2/address-books/{$addressBookId}/contacts/import";
86
- $ch = curl_init($uploadUrl);
87
- curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
88
- curl_setopt($ch, CURLOPT_USERPWD, $this->_api_user . ':' . $this->_api_password);
89
- curl_setopt($ch, CURLOPT_POSTFIELDS, array (
90
- 'file' => '@'.$this->fileHelper->getFilePath($filename)
91
- ));
92
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
93
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
94
- curl_setopt($ch, CURLOPT_HTTPHEADER, array(
95
- 'Content-Type: multipart/form-data')
96
- );
97
- // send contacts to address book
98
- $result = curl_exec($ch);
99
- $result = json_decode($result);
100
-
101
- return $result;
102
- }
103
-
104
- /**
105
- * Adds a contact to a given address book.
106
- * @param $addressBookId
107
- * @param $contactAPI
108
- * @return mixed
109
- */
110
- public function postAddressBookContacts($addressBookId, $contactAPI)
111
- {
112
- $data_string = json_encode($contactAPI);
113
- $url = self::REST_ADDRESS_BOOKS . '/' . $addressBookId . '/contacts';
114
- $ch = curl_init($url);
115
- curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
116
- curl_setopt($ch, CURLOPT_USERPWD, $this->_api_user . ':' . $this->_api_password);
117
- curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
118
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
119
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
120
- curl_setopt($ch, CURLOPT_HTTPHEADER, array(
121
- 'Content-Type: application/json',
122
- 'Content-Length: ' . strlen($data_string))
123
- );
124
-
125
- // send campaign
126
- $result = curl_exec($ch);
127
- $result = json_decode($result);
128
-
129
- return $result;
130
- }
131
-
132
- /**
133
- * Deletes all contacts from a given address book.
134
- * @param $addressBookId
135
- * @param $contactId
136
- */
137
- public function deleteAddressBookContact($addressBookId, $contactId)
138
- {
139
- $url = self::REST_ADDRESS_BOOKS . '/' . $addressBookId . '/contacts/' . $contactId;
140
- $ch = curl_init($url);
141
- curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "DELETE");
142
- curl_setopt($ch, CURLOPT_USERPWD, $this->_api_user . ':' . $this->_api_password);
143
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
144
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
145
- curl_setopt($ch, CURLOPT_HTTPHEADER, array(
146
- 'Content-Type: application/json'
147
- ));
148
- $result = curl_exec($ch);
149
- }
150
-
151
- /**
152
- * Gets a report with statistics about what was successfully imported, and what was unable to be imported.
153
- * @param $importId
154
- * @return mixed
155
- */
156
- public function getContactsImportReport($importId)
157
- {
158
- $reportUrl = self::REST_CONTACTS_IMPORT . "{$importId}/report";
159
- $ch = curl_init($reportUrl);
160
- curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");
161
- curl_setopt($ch, CURLOPT_USERPWD, $this->_api_user . ':' . $this->_api_password);
162
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
163
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
164
- curl_setopt($ch, CURLOPT_HTTPHEADER, array(
165
- 'Content-Type: application/json')
166
- );
167
- // get the report
168
- $result = curl_exec($ch);
169
- $result = json_decode($result);
170
- return $result;
171
- }
172
-
173
- public function getContacts($skip = 0, $limit = 1000)
174
- {
175
- $allContactsUrl = self::REST_CONTACTS . '?select=' . $limit . '&skip=' . $skip;
176
- $ch = curl_init($allContactsUrl);
177
- curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET');
178
- curl_setopt($ch, CURLOPT_USERPWD, $this->_api_user . ':' . $this->_api_password);
179
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
180
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
181
- curl_setopt($ch, CURLOPT_HTTPHEADER, array(
182
- 'Content-Type: application/json'
183
- ));
184
- $data = curl_exec($ch);
185
- $result = json_decode($data);
186
-
187
- return $result;
188
- }
189
-
190
- public function getContactByEmail($email)
191
- {
192
- $contactInfoUrl = self::REST_CONTACTS . $email;
193
- $ch = curl_init($contactInfoUrl);
194
- curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET');
195
- curl_setopt($ch, CURLOPT_USERPWD, $this->_api_user . ':' . $this->_api_password);
196
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
197
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
198
- curl_setopt($ch, CURLOPT_HTTPHEADER, array(
199
- 'Content-Type: application/json'
200
- ));
201
-
202
- $data = curl_exec($ch);
203
- $result = json_decode($data);
204
-
205
- return $result;
206
- }
207
- public function getContactById($contactId)
208
- {
209
- $contactInfoUrl = self::REST_CONTACTS . $contactId;
210
- $ch = curl_init($contactInfoUrl);
211
- curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET');
212
- curl_setopt($ch, CURLOPT_USERPWD, $this->_api_user . ':' . $this->_api_password);
213
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
214
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
215
- curl_setopt($ch, CURLOPT_HTTPHEADER, array(
216
- 'Content-Type: application/json'
217
- ));
218
-
219
- $data = curl_exec($ch);
220
- $result = json_decode($data);
221
-
222
- return $result;
223
- }
224
-
225
- /**
226
- * Creates an address book.
227
- * @return mixed
228
- */
229
- public function postAddressBooks()
230
- {
231
- $contactInfoUrl = self::REST_ADDRESS_BOOKS;
232
- $ch = curl_init($contactInfoUrl);
233
- curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET');
234
- curl_setopt($ch, CURLOPT_USERPWD, $this->_api_user . ':' . $this->_api_password);
235
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
236
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
237
- curl_setopt($ch, CURLOPT_HTTPHEADER, array(
238
- 'Content-Type: application/json'
239
- ));
240
- $data = curl_exec($ch);
241
- $result = json_decode($data);
242
- return $result;
243
- }
244
-
245
- /**
246
- * Creates a campaign.
247
- * @return mixed
248
- */
249
- protected function postCampaigns(){
250
- $contactInfoUrl = self::REST_DATA_FIELDS_CAMPAIGNS;
251
- $ch = curl_init($contactInfoUrl);
252
- curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET');
253
- curl_setopt($ch, CURLOPT_USERPWD, $this->_api_user . ':' . $this->_api_password);
254
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
255
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
256
- curl_setopt($ch, CURLOPT_HTTPHEADER, array(
257
- 'Content-Type: application/json'
258
- ));
259
- $data = curl_exec($ch);
260
- $result = json_decode($data);
261
- return $result;
262
- }
263
-
264
- /**
265
- * Creates a data field within the account.
266
- * @return mixed
267
- */
268
- protected function postDataFields() {
269
- $contactInfoUrl = self::REST_DATA_FILEDS;
270
- $ch_contact = curl_init($contactInfoUrl);
271
- curl_setopt($ch_contact, CURLOPT_CUSTOMREQUEST, 'GET');
272
- curl_setopt($ch_contact, CURLOPT_USERPWD, $this->_api_user . ':' . $this->_api_password);
273
- curl_setopt($ch_contact, CURLOPT_RETURNTRANSFER, true);
274
- curl_setopt($ch_contact, CURLOPT_SSL_VERIFYPEER, false);
275
- curl_setopt($ch_contact, CURLOPT_HTTPHEADER, array(
276
- 'Content-Type: application/json'
277
- ));
278
- $data = curl_exec($ch_contact);
279
- $result = json_decode($data);
280
- return $result;
281
- }
282
-
283
- /**
284
- * Bulk creates, or bulk updates, contacts. Import format can either be CSV or Excel.
285
- * Must include one column called "Email". Any other columns will attempt to map to your custom data fields.
286
- * The ID of returned object can be used to query import progress.
287
- * @param bool $waitFinished
288
- * @return mixed
289
- */
290
- private function postContactsImport($waitFinished = false){
291
- $importUrl = self::REST_CONTACTS_IMPORT;
292
- $ch = curl_init($importUrl);
293
- curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
294
- curl_setopt($ch, CURLOPT_USERPWD, $this->_api_user . ':' . $this->_api_password);
295
- curl_setopt($ch, CURLOPT_POSTFIELDS, array (
296
- 'file' => '@'.$this->getFilePath($this->_filename)
297
- ));
298
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
299
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
300
- curl_setopt($ch, CURLOPT_HTTPHEADER, array(
301
- 'Content-Type: multipart/form-data')
302
- );
303
- $result = curl_exec($ch);
304
- $result = json_decode($result);
305
-
306
- if($waitFinished)
307
- $this->waitFinishedImport($result->id);
308
- return $result;
309
- }
310
- public function updateContact($contactId, $data)
311
- {
312
- $data_string = json_encode($data);
313
- $contactInfoUrl = self::REST_CONTACTS . $contactId;
314
- $ch = curl_init($contactInfoUrl);
315
- curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT");
316
- curl_setopt($ch, CURLOPT_POST, true);
317
- curl_setopt($ch, CURLOPT_USERPWD, $this->_api_user . ':' . $this->_api_password);
318
- curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
319
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
320
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
321
- curl_setopt($ch, CURLOPT_HTTPHEADER, array(
322
- 'Content-Type: application/json',
323
- 'Content-Length: ' . strlen($data_string))
324
- );
325
- $data = curl_exec($ch);
326
- $result = json_decode($data);
327
- return $result;
328
- }
329
-
330
- /**
331
- * Send connector campaings
332
- * @param $campaignId
333
- * @param $contacts
334
- * @return mixed
335
- */
336
- public function sendCampaign($campaignId, $contacts)
337
- {
338
- $data = array(
339
- 'username' => $this->_api_user,
340
- 'password' => $this->_api_password,
341
- "campaignId" => $campaignId,
342
- "ContactIds" => $contacts
343
- );
344
-
345
- $this->_helper->log($data, null, $this->_log_filename);
346
- $data_string = json_encode($data);
347
- $campaignUrl = self::REST_CAMPAIGN_SEND;
348
- $ch = curl_init($campaignUrl);
349
- curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
350
- curl_setopt($ch, CURLOPT_USERPWD, $this->_api_user . ':' . $this->_api_password);
351
- curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
352
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
353
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
354
- curl_setopt($ch, CURLOPT_HTTPHEADER, array(
355
- 'Content-Type: application/json',
356
- 'Content-Length: ' . strlen($data_string))
357
- );
358
-
359
- // send campaign
360
- $result = curl_exec($ch);
361
- $result = json_decode($result);
362
- $this->_helper->log($result, null, $this->_log_filename);
363
-
364
- return $result;
365
- }
366
- private function waitFinishedImport($importId){
367
-
368
- do{
369
- // wait until do the report status call
370
- sleep(self::REST_WAIT_UPLOAD_TIME);
371
- // ...the API request
372
- // Create a GET request
373
-
374
- $reportUrl = self::REST_CONTACTS_IMPORT . "{$importId}/report";
375
- $ch = curl_init($reportUrl);
376
- curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");
377
- curl_setopt($ch, CURLOPT_USERPWD, $this->_api_user . ':' . $this->_api_password);
378
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
379
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
380
- curl_setopt($ch, CURLOPT_HTTPHEADER, array(
381
- 'Content-Type: application/json')
382
- );
383
-
384
- // get the report
385
- $result = curl_exec($ch);
386
- $result = json_decode($result);
387
-
388
- }while(isset($result->message) && $result->message == self::REST_STATUS_REPORT_NOTFINISHED);
389
-
390
- }
391
-
392
- /**
393
- * create new connector contact
394
- * @param $email
395
- * @return mixed
396
- */
397
- public function createNewContact($email)
398
- {
399
- $data = array(
400
- 'Email' => $email,
401
- 'EmailType' => 'Html'
402
- );
403
- $data_string = json_encode($data);
404
- $ch = curl_init(self::REST_CONTACTS);
405
- curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
406
- curl_setopt($ch, CURLOPT_USERPWD, $this->_api_user . ':' . $this->_api_password);
407
- curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
408
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
409
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
410
- curl_setopt($ch, CURLOPT_HTTPHEADER, array(
411
- 'Content-Type: application/json',
412
- 'Content-Length: ' . strlen($data_string))
413
- );
414
- $result = curl_exec($ch);
415
- $result = json_decode($result);
416
-
417
- return $result;
418
- }
419
-
420
- public function sendIntallInfo($testEmail, $contactId, $campaignId)
421
- {
422
- $numProducts = Mage::getModel('catalog/product')->getCollection()->getSize();
423
- $numCustomers = Mage::getModel('customer/customer')->getCollection()->getSize();
424
-
425
- $data = array(
426
- 'Email' => $testEmail,
427
- 'EmailType' => 'Html',
428
- 'DataFields' => array(
429
- array(
430
- 'Key' => 'INSTALLCUSTOMERS',
431
- 'Value' => (string)$numCustomers),
432
- array(
433
- 'Key' => 'INSTALLPRODUCTS',
434
- 'Value' => (string)$numProducts),
435
- array(
436
- 'Key' => 'INSTALLURL',
437
- 'Value' => Mage::getBaseUrl()),
438
- array(
439
- 'Key' => 'INSTALLAPI',
440
- 'Value' => implode(',' , $this->getWebsiteAccounts())),
441
- array(
442
- 'Key' => 'PHPMEMORY',
443
- 'Value' => ini_get('memory_limit') . ', V=' . Mage::helper('connector')->getConnectorVersion()
444
- )
445
- )
446
- );
447
-
448
- $this->updateContact($contactId, $data);
449
- $this->sendCampaign($campaignId, array($contactId));
450
-
451
- return ;
452
- }
453
- private function getWebsiteAccounts()
454
- {
455
- $accounts = array();
456
- $websites = Mage::app()->getWebsites();
457
- foreach ($websites as $website) {
458
- $websiteId = $website->getWebsiteId();
459
- $websiteModel = Mage::app()->getWebsite($websiteId);
460
- $apiUsername = $websiteModel->getConfig('connector_api_settings/api_credentials/username');
461
- if(! in_array($apiUsername, $accounts))
462
- $accounts[] = $apiUsername;
463
- }
464
- return $accounts;
465
- }
466
-
467
- protected function getSuppressedSince($dateString)
468
- {
469
- $suppressedUrl = self::REST_CONTACTS_SUPPRESSED_SINCE . $dateString;
470
- $ch = curl_init($suppressedUrl);
471
- curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");
472
- curl_setopt($ch, CURLOPT_USERPWD, $this->_api_user . ':' . $this->_api_password);
473
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
474
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
475
- curl_setopt($ch, CURLOPT_HTTPHEADER, array(
476
- 'Content-Type: application/json'
477
- ));
478
-
479
- // get the list of suppressed contacts
480
- $data = curl_exec($ch);
481
- $data = json_decode($data);
482
-
483
- return $data;
484
-
485
- }
486
- public function sendMultiTransactionalData($ordersData, $collectionName = 'Order')
487
- {
488
- $orders = array();
489
- foreach ($ordersData as $order) {
490
- if(isset($order->connector_id)){
491
- $orders[] = array(
492
- 'Key' => $order->id,
493
- 'ContactIdentifier' => $order->connector_id,
494
- 'Json' => json_encode($order->expose())
495
- );
496
- }
497
- }
498
-
499
- $data_string = json_encode($orders);
500
- $transactionalUrl = self::REST_TRANSACTIONAL_DATA_IMPORT . $collectionName;
501
-
502
- $ch = curl_init($transactionalUrl);
503
- curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
504
- curl_setopt($ch, CURLOPT_USERPWD, $this->_api_user . ':' . $this->_api_password);
505
- curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
506
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
507
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
508
- curl_setopt($ch, CURLOPT_HTTPHEADER, array(
509
- 'Content-Type: application/json',
510
- 'Content-Length: ' . strlen($data_string))
511
- );
512
-
513
- // send contacts to connector
514
- $result = curl_exec($ch);
515
- $result = json_decode($result);
516
-
517
- return $result;
518
- }
519
- protected function sendTransactionalData($quoteData, $collectionName = 'Basket')
520
- {
521
- // check if the transactional data is already set
522
- $transactionalUrl = self::REST_SINGLE_TRANSACTIONAL_DATA_IMPORT . $collectionName . '/' . $quoteData->id ;
523
- $ch = curl_init($transactionalUrl);
524
- curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");
525
- curl_setopt($ch, CURLOPT_USERPWD, $this->_api_user . ':' . $this->_api_password);
526
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
527
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
528
- curl_setopt($ch, CURLOPT_HTTPHEADER, array(
529
- 'Content-Type: application/json'
530
- ));
531
- $result = curl_exec($ch);
532
- $result = json_decode($result);
533
-
534
- if(isset($result->message) && $result->message == self::REST_TRANSACTIONAL_DATA_NOT_EXISTS)
535
- $transactionalUrl = self::REST_SINGLE_TRANSACTIONAL_DATA_IMPORT . $collectionName ;
536
- else
537
- $transactionalUrl = self::REST_SINGLE_TRANSACTIONAL_DATA_IMPORT . $collectionName . '/' . $result->key ;
538
-
539
-
540
- $data = array(
541
- 'Key' => $quoteData->id,
542
- 'ContactIdentifier' => $quoteData->connector_id,
543
- 'Json' => json_encode($quoteData->expose())
544
- );
545
-
546
-
547
- $data_string = json_encode($data);
548
-
549
- $ch = curl_init($transactionalUrl);
550
- curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
551
- curl_setopt($ch, CURLOPT_USERPWD, $this->_api_user . ':' . $this->_api_password);
552
- curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
553
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
554
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
555
- curl_setopt($ch, CURLOPT_HTTPHEADER, array(
556
- 'Content-Type: application/json',
557
- 'Content-Length: ' . strlen($data_string))
558
- );
559
-
560
- // send contacts to connector
561
- $result = curl_exec($ch);
562
- $result = json_decode($result);
563
-
564
- return $result;
565
- }
566
-
567
- public function sendOrderTransactionalData($order, $collectionName = 'Order', $key = '')
568
- {
569
- $data = array(
570
- 'Key' => $order->id,
571
- 'ContactIdentifier' => $order->connector_id,
572
- 'Json' => json_encode($order->expose())
573
- );
574
-
575
-
576
- $data_string = json_encode($data);
577
-
578
- $transactionalUrl = self::REST_SINGLE_TRANSACTIONAL_DATA_IMPORT . $collectionName . '/' . $key;
579
-
580
- $ch = curl_init($transactionalUrl);
581
- curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
582
- curl_setopt($ch, CURLOPT_USERPWD, $this->_api_user . ':' . $this->_api_password);
583
- curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
584
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
585
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
586
- curl_setopt($ch, CURLOPT_HTTPHEADER, array(
587
- 'Content-Type: application/json',
588
- 'Content-Length: ' . strlen($data_string))
589
- );
590
-
591
- // send contacts to connector
592
- $result = curl_exec($ch);
593
- $result = json_decode($result);
594
-
595
- if(! isset($result->message)){
596
- $this->removeTransactionalData($order->connector_id, 'Basket');
597
- }
598
-
599
- return $result;
600
- }
601
- public function deleteContactsTransactionalData($collectionName = 'Order', $key = '')
602
- {
603
-
604
- $transactionalUrl = self::REST_SINGLE_TRANSACTIONAL_DATA_IMPORT . $collectionName . '/' . $key;
605
-
606
- $ch = curl_init($transactionalUrl);
607
- curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "DELETE");
608
- curl_setopt($ch, CURLOPT_USERPWD, $this->_api_user . ':' . $this->_api_password);
609
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
610
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
611
-
612
- // send contacts to connector
613
- $result = curl_exec($ch);
614
- $result = json_decode($result);
615
-
616
-
617
- return $result;
618
- }
619
-
620
- public function removeTransactionalData($contactId, $collectionName)
621
- {
622
- $transactionalUrl = 'https://apiconnector.com/v2/contacts/' . $contactId . '/transactional-data/' . $collectionName ;
623
- $ch = curl_init($transactionalUrl);
624
- curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "DELETE");
625
- curl_setopt($ch, CURLOPT_USERPWD, $this->_api_user . ':' . $this->_api_password);
626
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
627
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
628
- curl_setopt($ch, CURLOPT_HTTPHEADER, array(
629
- 'Content-Type: application/json'
630
- ));
631
- $result = curl_exec($ch);
632
-
633
- }
634
-
635
- public function testAccount()
636
- {
637
- $url = self::REST_ACCOUNT_INFO;
638
- $ch = curl_init($url);
639
- curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");
640
- curl_setopt($ch, CURLOPT_USERPWD, $this->_api_user . ':' . $this->_api_password);
641
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
642
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
643
- $result = curl_exec($ch);
644
- $result = json_decode($result);
645
- if(isset($result->message)){
646
- return false;
647
- }
648
-
649
- return true;
650
- }
651
-
652
- public function getAddressBookContacts($bookId, $skip = 0)
653
- {
654
- /**
655
- * https://apiconnector.com/v2/address-books/{addressBookId}/contacts?withFullData={withFullData}&select={select}&skip={skip}
656
- */
657
- $url = self::REST_ADDRESS_BOOKS . '/' . $bookId . '/contacts' . '?skip=' . $skip;
658
-
659
- $ch = curl_init($url);
660
- curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");
661
- curl_setopt($ch, CURLOPT_USERPWD, $this->_api_user . ':' . $this->_api_password);
662
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
663
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
664
- $result = curl_exec($ch);
665
- $result = json_decode($result);
666
- return $result;
667
-
668
- }
669
-
670
- /**
671
- * Send a single SMS message.
672
- * @param $number
673
- * @param $message
674
- * @return mixed
675
- */
676
- public function postSmsMessagesSendTo($telephoneNumber, $message)
677
- {
678
- $data = array('Message' => $message);
679
- $data_string = json_encode($data);
680
- $ch = curl_init(self::REST_SMS_MESSAGE_SEND_TO . $telephoneNumber);
681
- curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
682
- curl_setopt($ch, CURLOPT_USERPWD, $this->_api_user . ':' . $this->_api_password);
683
- curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
684
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
685
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
686
- curl_setopt($ch, CURLOPT_HTTPHEADER, array(
687
- 'Content-Type: application/json',
688
- 'Content-Length: ' . strlen($data_string))
689
- );
690
- $result = curl_exec($ch);
691
- $result = json_decode($result);
692
- return $result;
693
- }
694
-
695
- public function postContactsTransactionalDataImport($collectionName, $data = array())
696
- {
697
- $import = array();
698
-
699
- foreach ($data as $one) {
700
-
701
- $import[] = array(
702
- 'Key' => $one->getId(),
703
- 'ContactIdentifier' => $one->getCustomerId(),
704
- 'Json' => json_encode($one->expose())
705
- );
706
- }
707
-
708
- $data_string = json_encode($import);
709
-
710
- $transactionalUrl = self::REST_TRANSACTIONAL_DATA_IMPORT . $collectionName;
711
-
712
- $ch = curl_init($transactionalUrl);
713
- curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
714
- curl_setopt($ch, CURLOPT_USERPWD, $this->_api_user . ':' . $this->_api_password);
715
- curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
716
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
717
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
718
- curl_setopt($ch, CURLOPT_HTTPHEADER, array(
719
- 'Content-Type: application/json',
720
- 'Content-Length: ' . strlen($data_string))
721
- );
722
-
723
- // send contacts to connector
724
- $result = curl_exec($ch);
725
- $result = json_decode($result);
726
-
727
- return $result;
728
- }
729
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Dotdigitalgroup/Email/Model/Connector/Customer.php DELETED
@@ -1,286 +0,0 @@
1
- <?php
2
-
3
- class Dotdigitalgroup_Email_Model_Connector_Customer{
4
-
5
- // Unique identifier for Dotmail: Email
6
- private $_email;
7
-
8
- // Customer Info Data
9
- private $_firstname;
10
- private $_lastname;
11
- private $_dob;
12
- private $_gender;
13
- private $_title;
14
- private $_website_created_on;
15
- private $_store_created_on;
16
- private $_account_created;
17
- private $_last_logged_in;
18
- private $_customer_group;
19
- // Customer Address Data
20
- private $_billing_address_1;
21
- private $_billing_address_2;
22
- private $_billing_city;
23
- private $_billing_country;
24
- private $_billing_postcode;
25
- private $_billing_telephone;
26
- private $_delivery_address_1;
27
- private $_delivery_address_2;
28
- private $_delivery_city;
29
- private $_delivery_country;
30
- private $_delivery_postcode;
31
- private $_delivery_telephone;
32
- // Customer Sales Data
33
- private $_total_orders;
34
- private $_average_order_value;
35
- private $_total_spend;
36
- private $_last_order;
37
- private $_last_order_no;
38
- // Newletter subscriber?
39
- private $_is_subscribed_to_newsletter;
40
- private $_dotmailer_contact_id;
41
- private $_customer_id;
42
-
43
- /**
44
- 'firstname',
45
- 'lastname',
46
- 'dob',
47
- 'gender',
48
- 'title',
49
- 'website_created_on',
50
- 'store_created_on',
51
- 'account_created',
52
- 'last_logged_in',
53
- 'customer_group',
54
- 'billing_address_1',
55
- 'billing_address_2',
56
- 'billing_city',
57
- 'billing_country',
58
- 'billing_postcode',
59
- 'billing_telephone',
60
- 'delivery_address_1',
61
- 'delivery_address_2',
62
- 'delivery_city',
63
- 'delivery_country',
64
- 'delivery_postcode',
65
- 'delivery_telephone',
66
- 'total_orders',
67
- 'average_order_value',
68
- 'total_spend',
69
- 'last_order',
70
- 'last_order_no'
71
- *
72
- */
73
-
74
- public function getEmail()
75
- {
76
- return $this->_email;
77
- }
78
-
79
-
80
- public function setDotmailerContactId($dotmailer_contact_id)
81
- {
82
- $this->_dotmailer_contact_id = $dotmailer_contact_id;
83
- }
84
-
85
- public function getDotmailerContactId()
86
- {
87
- return $this->_dotmailer_contact_id;
88
- }
89
-
90
- public function isSubscribed()
91
- {
92
- return $this->_is_subscribed_to_newsletter;
93
- }
94
-
95
- private $_mapping_hash;
96
-
97
-
98
- // class constructor - takes
99
- public function __construct(Mage_Customer_Model_Customer $customer, $mapping_hash){
100
-
101
- $this->_mapping_hash = $mapping_hash;
102
-
103
- // map each attribute from the $customer parameter (collection item) to the corresponding scoped variable in this class
104
- $this->id = $customer->getId();
105
- $this->_email = $customer->getEmail();
106
- $this->_firstname = $customer->getFirstname();
107
- $this->_lastname = $customer->getLastname();
108
- $this->_dob = $customer->getDob();
109
- $this->_gender = $this->getCustomerGender($customer->getGender());
110
- $this->_title = $customer->getPrefix();
111
-
112
- $this->_website_created_on = $this->getWebsiteName($customer->getWebsiteId());
113
- $this->_store_created_on = $this->getStoreName($customer->getStoreId());
114
- $this->_account_created = $customer->getCreatedAt();
115
- $this->_last_logged_in = $customer->getLastLoggedIn();
116
- $this->_customer_group = $this->getCustomerGroup($customer->getGroupId());
117
- $this->_billing_address_1 = $this->getStreet($customer->getBillingStreet(), 1);
118
- $this->_billing_address_2 = $this->getStreet($customer->getBillingStreet(), 2);
119
-
120
- $this->_billing_city = $customer->getBillingCity();
121
- $this->_billing_country = $customer->getBillingCountryCode();
122
- $this->_billing_postcode = $customer->getBillingPostcode();
123
- $this->_billing_telephone = $customer->getBillingTelephone();
124
-
125
- $this->_delivery_address_1 = $this->getStreet($customer->getShippingStreet(), 1);
126
- $this->_delivery_address_2 = $this->getStreet($customer->getShippingStreet(), 2);
127
-
128
- $this->_delivery_city = $customer->getShippingCity();
129
- $this->_delivery_country = $customer->getShippingCountryCode();
130
- $this->_delivery_postcode = $customer->getShippingPostcode();
131
- $this->_delivery_telephone = $customer->getShippingTelephone();
132
-
133
- $this->_total_orders = $customer->getTotalOrders();
134
- $this->_average_order_value = $customer->getAverageOrderValue();
135
- $this->_total_spend = $customer->getTotalSpend();
136
-
137
- $lastOrder = new Zend_Date($customer->getLastPurchase());
138
- //$this->_last_order = $lastOrder->toString(Zend_Date::ISO_8601);
139
- $this->_last_order = $customer->getLastPurchase();
140
- $this->_last_order_no = $customer->getLastOrderNo();
141
-
142
- $this->_is_subscribed_to_newsletter = ($customer->getSubscriberStatus() == Mage_Newsletter_Model_Subscriber::STATUS_SUBSCRIBED)? true : false;
143
- $this->_dotmailer_contact_id = $customer->getDotmailerContactId();
144
- $this->_customer_id = $customer->getId();
145
- }
146
-
147
- public function toCSVArray() {
148
-
149
- // no iterating, just create an array()
150
-
151
- $result = array();
152
-
153
- // Email is the only required field in the CSV upload
154
- $result[] = $this->_email;
155
-
156
- if ($this->_mapping_hash[0]!="0") $result[] = $this->_firstname;
157
- if ($this->_mapping_hash[1]!="0") $result[] = $this->_lastname;
158
- if ($this->_mapping_hash[2]!="0") $result[] = $this->_dob;
159
- if ($this->_mapping_hash[3]!="0") $result[] = $this->_gender;
160
- if ($this->_mapping_hash[4]!="0") $result[] = $this->_title;
161
-
162
- if ($this->_mapping_hash[5]!="0") $result[] = $this->_website_created_on;
163
- if ($this->_mapping_hash[6]!="0") $result[] = $this->_store_created_on;
164
- if ($this->_mapping_hash[7]!="0") $result[] = $this->_account_created;
165
- if ($this->_mapping_hash[8]!="0") $result[] = $this->_last_logged_in;
166
- if ($this->_mapping_hash[9]!="0") $result[] = $this->_customer_group;
167
-
168
- if ($this->_mapping_hash[10]!="0") $result[] = $this->_billing_address_1;
169
- if ($this->_mapping_hash[11]!="0") $result[] = $this->_billing_address_2;
170
- if ($this->_mapping_hash[12]!="0") $result[] = $this->_billing_city;
171
- if ($this->_mapping_hash[13]!="0") $result[] = $this->_billing_country;
172
- if ($this->_mapping_hash[14]!="0") $result[] = $this->_billing_postcode;
173
- if ($this->_mapping_hash[15]!="0") $result[] = $this->_billing_telephone;
174
-
175
- if ($this->_mapping_hash[16]!="0") $result[] = $this->_delivery_address_1;
176
- if ($this->_mapping_hash[17]!="0") $result[] = $this->_delivery_address_2;
177
- if ($this->_mapping_hash[18]!="0") $result[] = $this->_delivery_city;
178
- if ($this->_mapping_hash[19]!="0") $result[] = $this->_delivery_country;
179
- if ($this->_mapping_hash[20]!="0") $result[] = $this->_delivery_postcode;
180
- if ($this->_mapping_hash[21]!="0") $result[] = $this->_delivery_telephone;
181
-
182
- if ($this->_mapping_hash[22]!="0") $result[] = $this->_total_orders;
183
- if ($this->_mapping_hash[23]!="0") $result[] = $this->_average_order_value;
184
- if ($this->_mapping_hash[24]!="0") $result[] = $this->_total_spend;
185
- if ($this->_mapping_hash[25]!="0") $result[] = $this->_last_order;
186
- if ($this->_mapping_hash[26]!="0") $result[] = $this->_last_order_no;
187
- if ($this->_mapping_hash[27]!="0") $result[] = $this->_customer_id;
188
-
189
- $result[] = 'Html';
190
-
191
- return $result;
192
-
193
- }
194
-
195
- // returns the object as JSON
196
- public function toJSON(){
197
-
198
- return json_encode($this->expose());
199
-
200
- }
201
-
202
- // exposes the class as an array of objects
203
- public function expose() {
204
-
205
- return get_object_vars($this);
206
-
207
- }
208
-
209
- /**
210
- * return the gender text label
211
- * @param $genderId customer option id
212
- * @return string
213
- */
214
- public function getCustomerGender($genderId)
215
- {
216
- if(is_numeric($genderId)){
217
- $gender = Mage::getResourceModel('customer/customer')
218
- ->getAttribute('gender')
219
- ->getSource()
220
- ->getOptionText($genderId)
221
- ;
222
- return $gender;
223
- }
224
-
225
- return '';
226
- }
227
-
228
- /**
229
- * get the street name by line number
230
- * @param $street
231
- * @param $line
232
- * @return string
233
- */
234
- public function getStreet($street, $line)
235
- {
236
- $street = explode("\n", $street);
237
- if($line == 1){
238
- return $street[0];
239
- }
240
- if(isset($street[$line -1])){
241
-
242
- return $street[$line - 1];
243
- }else{
244
-
245
- return '';
246
- }
247
- }
248
-
249
- /**
250
- * get website name
251
- * @param $websiteId
252
- * @return null|string
253
- */
254
- public function getWebsiteName($websiteId)
255
- {
256
- $website = Mage::app()->getWebsite($websiteId);
257
- if($website)
258
- return $website->getName();
259
-
260
- return '';
261
- }
262
-
263
- public function getStoreName($storeId)
264
- {
265
- $store = Mage::app()->getStore($storeId);
266
- if($store)
267
- return $store->getName();
268
-
269
- return '';
270
- }
271
-
272
- /**
273
- * get the group name
274
- * @param $groupId
275
- * @return string
276
- */
277
- public function getCustomerGroup($groupId)
278
- {
279
- $group = Mage::getModel('customer/group')->load($groupId);
280
- if($group){
281
- return $group->getCode();
282
- }
283
- return '';
284
- }
285
-
286
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Dotdigitalgroup/Email/Model/Connector/Order.php DELETED
@@ -1,118 +0,0 @@
1
- <?php
2
-
3
- class Dotdigitalgroup_Email_Model_Connector_Order
4
- {
5
- public $id;
6
- public $connector_id;
7
- public $customer_id;
8
- protected $store_name;
9
- protected $purchase_date;
10
- protected $delivery_address;
11
- protected $billing_address;
12
- protected $products = array();
13
- protected $order_subtotal;
14
- protected $discount_ammount;
15
- protected $order_total;
16
- public $quote_id;
17
-
18
- /**
19
- * set the order information
20
- * @param Mage_Sales_Model_Order $orderData
21
- */
22
- public function __construct(Mage_Sales_Model_Order $orderData)
23
- {
24
- $this->id = $orderData->getIncrementId();
25
- $this->store_name = $orderData->getStoreName();
26
-
27
- $created_at = new Zend_Date($orderData->getCreatedAt(), Zend_Date::ISO_8601);
28
- $this->purchase_date = $created_at->toString(Zend_Date::ISO_8601);
29
- $this->customer_id = $orderData->getCustomerId();
30
-
31
- $customerModel = Mage::getModel('customer/customer')->load($this->customer_id);
32
- if(!$customerModel->getDotmailerContactId()){
33
- Mage::helper('connector')->log('dotmailer id not found : ' . $customerModel->getDotmailerContactId() . ' ' . $this->customer_id . ' ' . $this->id);
34
- }
35
-
36
-
37
-
38
- $this->connector_id = $customerModel->getDotmailerContactId();
39
- $this->quote_id = $orderData->getQuoteId();
40
-
41
- /**
42
- * billing and shipping address
43
- */
44
- $deliveryData = $orderData->getShippingAddress()->getData();
45
- $this->delivery_address = array(
46
- 'delivery_address_1' => $this->getStreet($deliveryData['street'], 1),
47
- 'delivery_address_2' => $this->getStreet($deliveryData['street'], 2),
48
- 'delivery_city' => $deliveryData['city'],
49
- 'delivery_country' => $deliveryData['country_id'],
50
- 'delivery_postcode' => $deliveryData['postcode']
51
- );
52
- $billingData = $orderData->getBillingAddress()->getData();
53
- $this->billing_address = array(
54
- 'billing_address_1' => $this->getStreet($billingData['street'], 1),
55
- 'billing_address_2' => $this->getStreet($billingData['street'], 2),
56
- 'billing_city' => $billingData['city'],
57
- 'billing_country' => $billingData['country_id'],
58
- 'billing_postcode' => $billingData['postcode'],
59
- );
60
- //order products information
61
- $products = $orderData->getAllItems();
62
- $categories = array();
63
- foreach ($products as $productItem) {
64
- // product model
65
- $product = $productItem->getProduct();
66
- if($product){
67
- // category names
68
- $categoryCollection = $product->getCategoryCollection()
69
- ->addAttributeToSelect('name');
70
-
71
- foreach ($categoryCollection as $cat) {
72
- $categories[] = $cat->getName();
73
- }
74
- $categoryNames = implode(',', $categories);
75
- }
76
-
77
- $this->products[] = array(
78
- 'name' => $productItem->getName(),
79
- 'sku' => $productItem->getSku(),
80
- 'category' => $categoryNames,
81
- 'qty' => (int)number_format($productItem->getData('qty_ordered'), 2),
82
- 'price' => (float)number_format($productItem->getPrice(), 2),
83
- );
84
- }
85
- $this->order_subtotal = (float)number_format($orderData->getData('subtotal'), 2);
86
- $this->discount_ammount = (float)number_format($orderData->getData('discount_amount'), 2);
87
- $orderTotal = abs($orderData->getData('grand_total') - $orderData->getTotalRefunded());
88
- $this->order_total = (float)number_format($orderTotal, 2);
89
-
90
- }
91
- /**
92
- * get the street name by line number
93
- * @param $street
94
- * @param $line
95
- * @return string
96
- */
97
- private function getStreet($street, $line)
98
- {
99
- $street = explode("\n", $street);
100
- if($line == 1){
101
- return $street[0];
102
- }
103
- if(isset($street[$line -1])){
104
-
105
- return $street[$line - 1];
106
- }else{
107
-
108
- return '';
109
- }
110
- }
111
- // exposes the class as an array of objects
112
- public function expose() {
113
-
114
- return get_object_vars($this);
115
-
116
- }
117
-
118
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Dotdigitalgroup/Email/Model/Connector/Quote.php DELETED
@@ -1,75 +0,0 @@
1
- <?php
2
-
3
- class Dotdigitalgroup_Email_Model_Connector_Quote
4
- {
5
-
6
- public $id;
7
- public $connector_id;
8
- public $customer_id;
9
- protected $store_name;
10
- protected $create_date;
11
- protected $update_date;
12
- protected $delivery_address;
13
- protected $billing_address;
14
- protected $products = array();
15
- protected $order_subtotal;
16
- protected $order_total;
17
-
18
- /**
19
- * set the quote information
20
- * @param Mage_Sales_Model_Quote $quote
21
- */
22
- public function __construct(Mage_Sales_Model_Quote $quote)
23
- {
24
- $this->id = $quote->getId();
25
- $this->customer_id = $quote->getCustomerId();
26
- $customerModel = Mage::getModel('customer/customer')->load($this->customer_id);
27
- $this->connector_id = $customerModel->getData('dotmailer_contact_id');
28
-
29
- $this->store_name = $this->getStoreName($quote->getStoreId());
30
- $this->order_subtotal = (float)number_format($quote->getSubtotal(), 2);
31
- $this->order_total = (float)number_format($quote->getGrandTotal(), 2);
32
-
33
- $created_at = new Zend_Date($quote->getCreatedAt(), Zend_Date::ISO_8601);
34
- $updated_at = new Zend_Date($quote->getUpdatedAt(), Zend_Date::ISO_8601);
35
- $this->create_date = $created_at->toString(Zend_Date::ISO_8601);
36
- $this->update_date = $updated_at->toString(Zend_Date::ISO_8601);
37
-
38
- $items = $quote->getAllVisibleItems();
39
- foreach ($items as $product) {
40
- $this->products[] = array(
41
- 'name' => $product->getName(),
42
- 'sku' => $product->getSku(),
43
- 'category' => $this->getCategory($product),
44
- 'qty' => (float)number_format($product->getQty(), 2),
45
- 'price' => (float)number_format($product->getPrice(), 2)
46
- );
47
- }
48
- }
49
- private function getStoreName($storeId)
50
- {
51
- $storeModel = Mage::getModel('core/store')->load($storeId);
52
- return $storeModel->getName();
53
- }
54
- private function getCategory($product)
55
- {
56
- $product = Mage::getModel('catalog/product')->load($product->getProductId());
57
- $categories = $product->getCategoryCollection()
58
- ->addAttributeToSelect('name');
59
- $categoryNames = array();
60
- foreach ($categories as $cat) {
61
- $categoryNames[] = $cat->getName();
62
- }
63
-
64
- $categoryNames = implode(',', $categoryNames);
65
- return $categoryNames;
66
-
67
- }
68
- // exposes the class as an array of objects
69
- public function expose() {
70
-
71
- return get_object_vars($this);
72
-
73
- }
74
-
75
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Dotdigitalgroup/Email/Model/Connector/Wishlist.php DELETED
@@ -1,86 +0,0 @@
1
- <?php
2
-
3
- class Dotdigitalgroup_Email_Model_Connector_Wishlist
4
- {
5
- protected $id;
6
- protected $customer_id;
7
- protected $connector_id;
8
-
9
- public $name;
10
-
11
- public $items = array();
12
-
13
- protected $total_wishlist_value;
14
-
15
- public function __construct($customer){
16
-
17
- $this->setConnectorId($customer->getDotmailerContactId());
18
- $this->setCustomerId($customer->id);
19
- }
20
-
21
- /**
22
- * @param mixed $connector_id
23
- */
24
- public function setConnectorId($connector_id)
25
- {
26
- $this->connector_id = $connector_id;
27
- }
28
-
29
- /**
30
- * @return mixed
31
- */
32
- public function getConnectorId()
33
- {
34
- return $this->connector_id;
35
- }
36
-
37
-
38
- /**
39
- * @param mixed $customer_id
40
- */
41
- public function setCustomerId($customer_id)
42
- {
43
- $this->customer_id = $customer_id;
44
- }
45
-
46
-
47
- /**
48
- * @return mixed
49
- */
50
- public function getCustomerId()
51
- {
52
- return $this->customer_id;
53
- }
54
-
55
- /**
56
- * @param mixed $id
57
- */
58
- public function setId($id)
59
- {
60
- $this->id = $id;
61
- }
62
-
63
- /**
64
- * @return mixed
65
- */
66
- public function getId()
67
- {
68
- return $this->id;
69
- }
70
-
71
- public function setItem($item)
72
- {
73
- $this->items[] = $item->expose();
74
-
75
- $this->total_wishlist_value += $item->getTotalValueOfProduct();
76
- }
77
-
78
- public function expose() {
79
-
80
- return get_object_vars($this);
81
-
82
- }
83
-
84
-
85
-
86
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Dotdigitalgroup/Email/Model/Cron.php DELETED
@@ -1,58 +0,0 @@
1
- <?php
2
- class Dotdigitalgroup_Email_Model_Cron
3
- {
4
- /**
5
- * CRON FOR CUSTOMER SYNC
6
- */
7
- public function customersync()
8
- {
9
- if(Mage::getStoreConfig(Dotdigitalgroup_Email_Model_Customer_Customer::XML_PATH_CUSTOMER_SYNC_ENABLE))
10
- Mage::getModel('connector/customer_customer')->sync();
11
- return;
12
- }
13
-
14
- /**
15
- * CRON FOR LOST BASKET
16
- */
17
- public function lostbasketssync()
18
- {
19
- //look for lost baskets
20
- Mage::getModel('connector/sales_quote')->proccessCampaigns();
21
- $helper = Mage::helper('connector');
22
- if($helper->isOrderTransactionalEnabled()){
23
- //send transactional data and mark as imported
24
- Mage::getModel('connector/sales_order')->sync();
25
- }
26
- if($helper->isCustomerSyncEnabled()){
27
- //check for customer that have no connector id
28
- $numUpdated = Mage::getModel('connector/customer_customer')->syncContacts();
29
- Mage::helper('connector')->log('SYNC CONTACTS : '. $numUpdated);
30
- }
31
- }
32
-
33
- /**
34
- * CRON FOR SUPRESSED CONTACTS
35
- */
36
- public function suppressedsync()
37
- {
38
- if(Mage::getStoreConfig(Dotdigitalgroup_Email_Model_Customer_Customer::XML_PATH_CUSTOMER_SUPPRESSED_ENABLE)){
39
- //check suppressed contacts from connector
40
- Mage::getModel('connector/customer_suppressed')->unsubscribe();
41
- }
42
-
43
- }
44
-
45
- /**
46
- * CLEAN ARHIVED FOLDERS
47
- */
48
-
49
- public function cleaning()
50
- {
51
- $helper = Mage::helper('connector/file');
52
- $archivedFolder = $helper->getArchiveFolder();
53
- $result = $helper->deleteDir($archivedFolder);
54
- Mage::helper('connector')->log('Cleaning cronjob result : ' . $result, null, 'api.log');
55
- return $result;
56
- }
57
-
58
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Dotdigitalgroup/Email/Model/Customer/Customer.php DELETED
@@ -1,480 +0,0 @@
1
- <?php
2
-
3
- class Dotdigitalgroup_Email_Model_Customer_Customer extends Dotdigitalgroup_Email_Model_Api_Rest
4
- {
5
- // xml configuration
6
- const XML_PATH_CONNECTOR_API_USERNAME = 'connector_api_settings/api_credentials/username';
7
- const XML_PATH_CONNECTOR_API_PASSWORD = 'connector_api_settings/api_credentials/password';
8
- const XML_PATH_CUSTOMER_SYNC_ENABLE = 'connector_sync_settings/sync_customer_schedule/enabled';
9
- const XML_PATH_CUSTOMER_SYNC_LIMIT = 'connector_advanced_settings/sync_limits/contact';
10
- const XML_PATH_CUSTOMER_SUPPRESSED_ENABLE = 'connector_sync_settings/sync_suppressed_schedule/enabled';
11
- const XML_PATH_CUSTOMERS_ADDRESS_BOOK_ID = 'connector_data_field_settings/address_book/customers';
12
- const XML_PATH_CUSTOMERS_SUPPRESSED_INTERVAL = 'connector_sync_settings/sync_suppressed_schedule/frequency';
13
- const XML_PATH_GUEST_ADDRESS_BOOK_ID = 'connector_data_field_settings/address_book/guest';
14
- const XML_PATH_CUSTOMER_WISHLIST_ENABLED = 'connector_sync_settings/transactional_data/wishlist_enabled';
15
-
16
- const FORCE_CUSTOMERS_YEARS = '10';
17
-
18
- protected $_customers_address_book_id;
19
- protected $_customers = array();
20
- protected $_mapping_hash;
21
- protected $_website; // website model
22
- private $countSubscribers = 0;
23
- private $countCustomers = 0;
24
-
25
- protected $accounts = array();// api accounts
26
- protected $wishlists = array();// wishlists
27
- protected $_proccessing;
28
- protected $_websiteId;
29
- public $apiLimit = 450;
30
-
31
- public function sync()
32
- {
33
- /** @var Dotdigitalgroup_Email_Helper_Data $helper */
34
- $helper = Mage::helper('connector');
35
- $helper->log('Start customer sync..', null, $this->_log_filename);
36
- $result = array('error' => false, 'message' => "Done.");
37
-
38
- // check for default settings to use memory limit
39
- if(Mage::getStoreConfig('connector_advanced_settings/admin/memory_limit'))
40
- $this->allowResourceFullExecution();
41
-
42
- // get all websites
43
- foreach(Mage::app()->getWebsites() as $website){
44
-
45
- // skip any actions if sync disabled
46
- if(! $website->getConfig(self::XML_PATH_CUSTOMER_SYNC_ENABLE))
47
- continue;
48
- //API credentials
49
- $this->_api_user = $website->getConfig(self::XML_PATH_CONNECTOR_API_USERNAME);
50
- $this->_api_password = $website->getConfig(self::XML_PATH_CONNECTOR_API_PASSWORD);
51
-
52
- if(strlen($this->_api_user) > 10 && strlen($this->_api_password)){
53
-
54
- $result = $this->exportCustomersForWebsite($website);
55
- if($website->getConfig(self::XML_PATH_CUSTOMER_WISHLIST_ENABLED)){
56
- $this->exportWishlistsForWebsite($website);
57
- }
58
- }else{
59
- $result['error'] = true;
60
- $message = 'The Credentials For Website :' . $website->getCode() . ' is not set!';
61
- $result['message'] = $message;
62
- $helper->log($message, null, $this->_log_filename);
63
- }
64
- }
65
- //set result check
66
- if($this->countCustomers != 0){
67
-
68
- $message = 'Total Exported : ' . $this->countCustomers . ' Customers, ' . $this->countSubscribers . ' Subscribers.';
69
-
70
- $result['message'] = $message;
71
- $helper->log($message, null, $this->_log_filename);
72
- }else{
73
- $result['error'] = true;
74
- $message = 'Check the logs for more information, the number of updated customers is : 0.';
75
- $result['message'] = $message;
76
- }
77
-
78
- $helper->log('Customer sync end!', null, $this->_log_filename);
79
- return $result;
80
- }
81
-
82
- /**
83
- * Get the customer for the website
84
- * @param bool $websiteId
85
- * @return mixed
86
- */
87
- public function getContactsCustomers($websiteId = false)
88
- {
89
- /** @var Mage_Customer_Model_Customer $customerCollection */
90
- $customerCollection = Mage::getModel('customer/customer')->getCollection()
91
- ->addAttributeToSelect('dotmailer_contact_id')
92
- ->addAttributeToFilter('dotmailer_contact_id', array('notnull' => true), 'left')
93
- ;
94
- if($websiteId !== false)
95
- $customerCollection->addAttributeToFilter('website_id', $websiteId);
96
-
97
- return $customerCollection;
98
- }
99
-
100
- private function countNumOfContacts($contacts)
101
- {
102
- $total = 0;
103
- // Get contacts number with contact id
104
- foreach ($contacts as $contact) {
105
- if($contact->getDotmailerContactId())
106
- $total++;
107
- }
108
- unset($contacts);
109
- return $total;
110
- }
111
-
112
- public function syncContacts()
113
- {
114
- $updated = 0;
115
- /**
116
- * Customers at website level
117
- */
118
- foreach (Mage::app()->getWebsites(true) as $website) {
119
- $websiteId = $website->getId();
120
- $missingContacts = $this->getMissingContacts($websiteId, $this->apiLimit);
121
- Mage::helper('connector')->log('API LIMIT : ' . $this->apiLimit, null, 'api.log');
122
- Mage::helper('connector')->log($missingContacts->count(), null, 'api.log');
123
- if(count($missingContacts) == 0)
124
- continue;
125
- //save customer and trigger the obsever
126
- foreach($missingContacts as $customer){
127
- try{
128
- $customer->save();
129
- $updated++;
130
- //limit the number of updated contacts
131
- if($this->apiLimit == $updated){
132
- return $updated;
133
- }
134
- }catch (Exception $e){
135
- Mage::logException($e);
136
- }
137
- }
138
- }
139
- return $updated;
140
- }
141
- public function getMissingContacts($websiteId = null, $limit = 200)
142
- {
143
- $customerCollection = Mage::getModel('customer/customer')->getCollection()
144
- ->addAttributeToSelect('dotmailer_contact_id')
145
- ->addAttributeToFilter('dotmailer_contact_id', array('null' => true), 'left')
146
- ->setPageSize($limit)
147
- ;
148
- if($websiteId !== null)
149
- $customerCollection->addAttributeToFilter('website_id', $websiteId);
150
-
151
- return $customerCollection;
152
- }
153
- public function getTotalNumberCustomers()
154
- {
155
- $customers = Mage::getModel('customer/customer')->getCollection();
156
- $totalCustomers = $customers->getSize();
157
-
158
- return $totalCustomers;
159
- }
160
-
161
- public function countSkipContacts($contacts = false, $websiteId)
162
- {
163
- if($contacts)
164
- $numContactIds = $this->countNumOfContacts($contacts);
165
- else
166
- $numContactIds = count($this->getContactsCustomers($websiteId));
167
-
168
-
169
- return $numContactIds;
170
- }
171
-
172
- /**
173
- * @param Mage_Core_Model_Website $website
174
- * @return $this
175
- */
176
- public function exportCustomersForWebsite(Mage_Core_Model_Website $website)
177
- {
178
- $websiteCode = $website->getCode();
179
- $websiteId = $website->getId();
180
- $customer_filename = $websiteCode . '_' . $this->_customers_file_slug . '_' . date('d-M-Y_hms') . '.csv';
181
- $subscriber_filename = $websiteCode . '_' . $this->_subscribers_file_slug . '_' . date('d-M-Y_hms') . '.csv';
182
- $helper = Mage::helper('connector');
183
-
184
- $helper->log('customer filename : ' . $customer_filename . ', subscriber filename : ' . $subscriber_filename, null, $this->_log_filename);
185
-
186
- $pageNum = 1;
187
- $pageSize = $website->getConfig('connector_advanced_settings/admin/batch_size');
188
- if($pageSize == '') $pageSize = 5000;
189
- $this->fileHelper = Mage::helper('connector/file');
190
-
191
- do{
192
- $time_start = microtime(true);
193
-
194
- $currentBatch = $this->getCustomersToExport($pageSize, $pageNum, $this->getMappingHash($website), $website->getId());
195
- $condition = count($currentBatch);
196
- //write the csv headers
197
- if($pageNum == 1 && count($currentBatch)){
198
- $this->fileHelper->outputCSV($this->fileHelper->getFilePath($customer_filename), $this->getCsvHeaderArray($website));
199
- $this->fileHelper->outputCSV($this->fileHelper->getFilePath($subscriber_filename), array('Email', 'emailType'));
200
- }
201
- foreach ($currentBatch as $customer) {
202
-
203
- /**
204
- * Send wishlist as transactional data
205
- */
206
- if($website->getConfig(self::XML_PATH_CUSTOMER_WISHLIST_ENABLED)){
207
- $this->setWishlists($customer, $website);
208
- }
209
- // check if customer is subscribed
210
- if($customer->isSubscribed()){
211
- // save data for subscribers
212
- $this->fileHelper->outputCSV($this->fileHelper->getFilePath($subscriber_filename), array($customer->getEmail(), 'Html'));
213
- $this->countSubscribers++;
214
- }
215
-
216
- // save data for csutomers
217
- $this->fileHelper->outputCSV($this->fileHelper->getFilePath($customer_filename), $customer->toCSVArray());
218
- $this->countCustomers++;
219
- }
220
- $time_end = microtime(true);
221
- $time_in_seconds = $time_end - $time_start;
222
-
223
- $helper->log('-----------------------------------------------execution time :' . gmdate("H:i:s", $time_in_seconds), null, $this->_log_filename);
224
- $pageNum++;
225
- unset($currentBatch);
226
-
227
- }while( $condition == $pageSize );
228
-
229
- $storeIds = Mage::getModel('core/website')->load($websiteId)
230
- ->getStoreIds();
231
- $subscriberModel = new Dotdigitalgroup_Email_Model_Newsletter_Subscriber();
232
- $subscribersNotCustomers = $subscriberModel->getSubscribersNotCustomers($storeIds);
233
-
234
- foreach ($subscribersNotCustomers as $one) {
235
- $this->fileHelper->outputCSV($this->fileHelper->getFilePath($subscriber_filename), array($one->getSubscriberEmail()));
236
- $this->countSubscribers++;
237
- }
238
-
239
- /**
240
- * Save customers and subscribers to address books
241
- */
242
- $this->postAddressBookContactsImport($customer_filename, $website->getConfig(self::XML_PATH_CUSTOMERS_ADDRESS_BOOK_ID));
243
- $this->postAddressBookContactsImport($subscriber_filename, $website->getConfig(Dotdigitalgroup_Email_Model_Newsletter_Subscriber::XML_PATH_SUBSCRIBERS_ADDRESS_BOOK_ID));
244
-
245
- //If successful, archive the CSV file and Log something in the Magento Log - success/failure
246
- if(file_exists($this->fileHelper->getFilePath($customer_filename)) && file_exists($this->fileHelper->getFilePath($subscriber_filename))){
247
- $this->fileHelper->archiveCSV($customer_filename);
248
- $this->fileHelper->archiveCSV($subscriber_filename);
249
- }
250
- return $this;
251
-
252
- }
253
-
254
- private function exportWishlistsForWebsite(Mage_Core_Model_Website $website){
255
-
256
- $this->_api_user = $website->getConfig(self::XML_PATH_CONNECTOR_API_USERNAME);
257
- $this->_api_password = $website->getConfig(self::XML_PATH_CONNECTOR_API_PASSWORD);
258
- //wishlists for the website key
259
- if(isset($this->wishlists[$website->getId()])){
260
-
261
- //send wishlists as transactional data
262
- $wishlists = $this->wishlists[$website->getId()];
263
-
264
- $this->postContactsTransactionalDataImport($collectionName = 'Wishlist', $wishlists);
265
- }
266
- }
267
-
268
- public function getCustomersToExport($pageSize = 0, $pageNum = 1, $mappingHash, $websiteId)
269
- {
270
- // the filtering and aggregation of all the customer data here
271
- $customers = array();
272
- $helper = Mage::helper('connector');
273
-
274
- $customerCollection = Mage::getModel('customer/customer')->getCollection()
275
- ->addAttributeToSelect('email')
276
- ->addAttributeToSelect('firstname')
277
- ->addAttributeToSelect('lastname')
278
- ->addAttributeToSelect('dob')
279
- ->addAttributeToSelect('gender')
280
- ->addAttributeToSelect('prefix')
281
- ->addAttributeToSelect('website_id')
282
- ->addAttributeToSelect('store_id')
283
- ->addAttributeToSelect('created_at')
284
- ->addAttributeToSelect('last_logged_in')
285
- ->addAttributeToSelect('group_id')
286
- ->addAttributeToSelect('dob')
287
- ->addAttributeToSelect('dotmailer_contact_id')
288
-
289
- ->addAttributeToFilter('website_id', $websiteId)
290
-
291
- ->joinAttribute('billing_street', 'customer_address/street', 'default_billing', null, 'left')
292
- ->joinAttribute('billing_city', 'customer_address/city', 'default_billing', null, 'left')
293
- ->joinAttribute('billing_country_code', 'customer_address/country_id', 'default_billing', null, 'left')
294
- ->joinAttribute('billing_postcode', 'customer_address/postcode', 'default_billing', null, 'left')
295
- ->joinAttribute('billing_telephone', 'customer_address/telephone', 'default_billing', null, 'left')
296
- ->joinAttribute('billing_region', 'customer_address/region', 'default_billing', null, 'left')
297
- ->joinAttribute('shipping_street', 'customer_address/street', 'default_shipping', null, 'left')
298
- ->joinAttribute('shipping_city', 'customer_address/city', 'default_shipping', null, 'left')
299
- ->joinAttribute('shipping_country_code', 'customer_address/country_id', 'default_shipping', null, 'left')
300
- ->joinAttribute('shipping_postcode', 'customer_address/postcode', 'default_shipping', null, 'left')
301
- ->joinAttribute('shipping_telephone', 'customer_address/telephone', 'default_shipping', null, 'left')
302
- ->joinAttribute('shipping_region', 'customer_address/region', 'default_shipping', null, 'left')
303
- ->joinTable('newsletter/subscriber','subscriber_email=email',array('subscriber_status' => 'subscriber_status'), null, 'left')
304
-
305
- ;
306
- if( $pageSize ){
307
- $customerCollection->setPage($pageNum, $pageSize);
308
- }
309
-
310
- $customer_log = Mage::getSingleton('core/resource')->getTableName('log_customer');
311
- $sales_flat_order_grid = Mage::getSingleton('core/resource')->getTableName('sales_flat_order_grid');
312
- $sales_flat_order = Mage::getSingleton('core/resource')->getTableName('sales_flat_order');
313
-
314
- // get the last login from the log_customer table
315
- $customerCollection->getSelect()->columns(array('last_logged_in' => new Zend_Db_Expr ("(SELECT login_at
316
- FROM $customer_log
317
- WHERE customer_id =e.entity_id
318
- ORDER BY log_id DESC
319
- LIMIT 1)")));
320
-
321
- // customer order information
322
- $alias = 'subselect';
323
- $subselect = Mage::getModel('Varien_Db_Select',
324
- Mage::getSingleton('core/resource')->getConnection('core_read')
325
- )->from($sales_flat_order_grid, array(
326
- 'customer_id as s_customer_id',
327
- 'sum(grand_total) as total_spend',
328
- 'count(*) as total_orders',
329
- 'avg(grand_total) as average_order_value',
330
- )
331
- )->group('customer_id')
332
- ;
333
- $customerCollection->getSelect()->columns(array(
334
- 'last_purchase' => new Zend_Db_Expr("(SELECT created_at
335
- FROM $sales_flat_order
336
- WHERE customer_id =e.entity_id
337
- ORDER BY created_at DESC
338
- LIMIT 1)"),
339
- 'last_order_no' => new Zend_Db_Expr("(SELECT entity_id
340
- FROM $sales_flat_order
341
- WHERE customer_id =e.entity_id
342
- ORDER BY created_at DESC
343
- LIMIT 1)")
344
- ));
345
-
346
- $customerCollection->getSelect()
347
- ->joinLeft(array($alias => $subselect),
348
- "{$alias}.s_customer_id = e.entity_id");
349
-
350
-
351
-
352
- $time = microtime(true);
353
- // create a customer object for each item in our collection
354
- foreach ($customerCollection as $item) {
355
-
356
- $customers[] = new Dotdigitalgroup_Email_Model_Connector_Customer($item, $mappingHash);
357
- }
358
-
359
- unset($customerCollection);
360
- $end_time = microtime(true);
361
- $end = $end_time - $time;
362
-
363
-
364
- $helper->log($pageSize . ': page' . $pageNum . ' for website: ' . $websiteId, null, $this->_log_filename);
365
- $helper->log('created dotmailer customers from collection: ' . gmdate("H:i:s", $end), null, $this->_log_filename);
366
-
367
- return $customers;
368
- }
369
-
370
- protected function allowResourceFullExecution() {
371
-
372
- /* it may be needed to set maximum execution time of the script to longer,
373
- * like 60 minutes than usual */
374
- set_time_limit ( 7200 );
375
-
376
- /* and memory to 512 megabytes */
377
- ini_set ( 'memory_limit', '512M' );
378
-
379
- return $this;
380
- }
381
- function convert($size)
382
- {
383
- $unit=array('b','kb','mb','gb','tb','pb');
384
- return @round($size/pow(1024,($i=floor(log($size,1024)))),2).' '.$unit[$i];
385
- }
386
-
387
- /**
388
- * Create an array of columns we have chosen to map in our System->Config
389
- * @param Mage_Core_Model_Website $website
390
- * @return array
391
- */
392
- public function getCsvHeaderArray(Mage_Core_Model_Website $website) {
393
-
394
- $result = array();
395
-
396
- $result[] = 'Email';
397
-
398
- foreach ($this->getMappingHash($website) as $header) {
399
- if ($header != "0") $result[] = $header;
400
- }
401
- $result[] = 'emailType';
402
-
403
- return $result;
404
- }
405
-
406
- /**
407
- * Gets the datafield mapping hash from the system config
408
- * @param Mage_Core_Model_Website $website
409
- * @return array
410
- */
411
- protected function getMappingHash(Mage_Core_Model_Website $website){
412
-
413
-
414
- $customer_fields = array(
415
- 'customer_data/firstname',
416
- 'customer_data/lastname',
417
- 'customer_data/dob',
418
- 'customer_data/gender',
419
- 'customer_data/title',
420
- 'customer_data/website_created_on',
421
- 'customer_data/store_created_on',
422
- 'customer_data/account_created',
423
- 'customer_data/last_logged_in',
424
- 'customer_data/customer_group',
425
- 'customer_data/billing_address_1',
426
- 'customer_data/billing_address_2',
427
- 'customer_data/billing_city',
428
- 'customer_data/billing_country',
429
- 'customer_data/billing_postcode',
430
- 'customer_data/billing_telephone',
431
- 'customer_data/delivery_address_1',
432
- 'customer_data/delivery_address_2',
433
- 'customer_data/delivery_city',
434
- 'customer_data/delivery_country',
435
- 'customer_data/delivery_postcode',
436
- 'customer_data/delivery_telephone',
437
- 'customer_data/total_orders',
438
- 'customer_data/average_order_value',
439
- 'customer_data/total_spend',
440
- 'customer_data/last_order',
441
- 'customer_data/last_order_no',
442
- 'customer_data/customer_id'
443
- );
444
-
445
- $result = array();
446
-
447
- foreach ($customer_fields as $field) {
448
-
449
- $result[] = $website->getConfig('connector_data_field_settings/' . $field);
450
-
451
- }
452
- return $result;
453
- }
454
-
455
- public function setWishlists($customer, $website)
456
- {
457
- $customerId = $customer->id;
458
- $wishList = Mage::getModel('wishlist/wishlist')->loadByCustomer($customerId);
459
-
460
- /** @var $connectorWishlist */
461
- $connectorWishlist = new Dotdigitalgroup_Email_Model_Connector_Wishlist($customer);
462
- $connectorWishlist->setId($wishList->getId());
463
-
464
- $wishListItemCollection = $wishList->getItemCollection();
465
-
466
- if (count($wishListItemCollection)) {
467
- foreach ($wishListItemCollection as $item) {
468
- /* @var $product Mage_Catalog_Model_Product */
469
- $product = $item->getProduct();
470
- $connectorItem = new Dotdigitalgroup_Email_Model_Customer_Wishlist_Item($product);
471
- $connectorItem->setQty($item->getQty());
472
- $connectorItem->setPrice($product);
473
- $connectorWishlist->setItem($connectorItem);//store for wishlists
474
- }
475
- //set wishlists for later use
476
- $this->wishlists[$website->getId()][] = $connectorWishlist;
477
- }
478
- }
479
-
480
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Dotdigitalgroup/Email/Model/Customer/Suppressed.php DELETED
@@ -1,85 +0,0 @@
1
- <?php
2
-
3
- class Dotdigitalgroup_Email_Model_Customer_Suppressed extends Dotdigitalgroup_Email_Model_Api_Rest
4
- {
5
-
6
- private $suppressedContacts = array();
7
-
8
- public function unsubscribe($force = false)
9
- {
10
- // result of sync
11
- $result = array('errors' => false, 'message' => '', 'customers');
12
- $result['customers'] = 0;
13
- $date = new Zend_Date();
14
-
15
- /**
16
- * 1. calculate from frequency
17
- */
18
- if(! $force){
19
- $frequency = Mage::getStoreConfig(Dotdigitalgroup_Email_Model_Customer_Customer::XML_PATH_CUSTOMERS_SUPPRESSED_INTERVAL);
20
- // get the frequency of sinse date
21
- switch($frequency){
22
- case('H'):
23
- $date = $date->subHour(1);
24
- break;
25
- case('D'):
26
- $date = $date->subDay(1);
27
- break;
28
- case('W'):
29
- $date = $date->subWeek(1);
30
- break;
31
- case('M'):
32
- $date = $date->subMonth(1);
33
- break;
34
- }
35
- }else{
36
-
37
- // force sync all customers
38
- $date = $date->subYear(Dotdigitalgroup_Email_Model_Customer_Customer::FORCE_CUSTOMERS_YEARS);
39
- }
40
-
41
- // datetime format string
42
- $dateString = $date->toString(Zend_Date::W3C);
43
- /**
44
- * Sync all suppressed for each store
45
- */
46
- foreach (Mage::app()->getWebsites(true) as $website) {
47
- $this->_api_user = $website->getConfig(Dotdigitalgroup_Email_Model_Customer_Customer::XML_PATH_CONNECTOR_API_USERNAME);
48
- $this->_api_password = $website->getConfig(Dotdigitalgroup_Email_Model_Customer_Customer::XML_PATH_CONNECTOR_API_PASSWORD);
49
- $contacts = $this->getSuppressedSince($dateString);
50
- if(! empty($contacts)){
51
- foreach ($contacts as $suppressed){
52
- $contactEmail = false;
53
- if(isset($suppressed->suppressedContact)){
54
-
55
- $contactEmail = $suppressed->suppressedContact->email;
56
- $contactId = $suppressed->suppressedContact->id;
57
- }
58
-
59
- if($contactEmail){
60
- try{
61
- /**
62
- * 3. Unsubscribe customer
63
- */
64
- $newsletterModel = Mage::getModel('newsletter/subscriber')->loadByEmail($contactEmail);
65
- if($newsletterModel->getStatus() == Mage_Newsletter_Model_Subscriber::STATUS_SUBSCRIBED){
66
- $unsubscribe = $newsletterModel->setStatus(Mage_Newsletter_Model_Subscriber::STATUS_UNSUBSCRIBED);
67
- $unsubscribe->save();
68
- // remove from subscriber address-book
69
- $this->deleteAddressBookContact($website->getConfig(Dotdigitalgroup_Email_Model_Newsletter_Subscriber::XML_PATH_SUBSCRIBERS_ADDRESS_BOOK_ID), $contactId);
70
- $this->suppressedContacts[$newsletterModel->getSubscriberEmail()] = $newsletterModel->getSubscriberEmail();
71
- }
72
- }catch (Exception $e){
73
- $result['errors'] = true;
74
- $result['message'] = 'Error Saving Customer!';
75
- }
76
- }
77
- }
78
- }
79
- }
80
- $result['customers'] = count($this->suppressedContacts);
81
-
82
- return $result;
83
- }
84
-
85
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Dotdigitalgroup/Email/Model/Dynamic/Product/Mapper.php DELETED
@@ -1,90 +0,0 @@
1
- <?php
2
-
3
- class Dotdigitalgroup_Email_Model_Dynamic_Product_Mapper extends Mage_Core_Model_Abstract
4
- {
5
- protected $_max_per_child;
6
-
7
- protected $_num_order_items;
8
-
9
- protected $_helper;
10
-
11
- public $_products = array();
12
-
13
- public $filename = 'mapper.log';
14
-
15
- public function __construct($num_order_items)
16
- {
17
- $this->_helper = Mage::helper('connector');
18
- $items_to_display = Mage::helper('connector/recommended')->getLimit();
19
- if($num_order_items < $items_to_display)
20
- $this->_max_per_child = number_format($items_to_display / $num_order_items);
21
- $this->_helper->log('max items per child : ' . $this->_max_per_child . ', items to display : ' . $items_to_display . ', number of order items : ' . $num_order_items, null, $this->filename);
22
-
23
- }
24
-
25
- /**
26
- * Set the products with parent limit
27
- * @param $products
28
- */
29
- public function setProducts($products)
30
- {
31
- $count = 0;
32
- foreach ($products as $product) {
33
- if($count < $this->_max_per_child)
34
- $this->setProduct($product);
35
- $count++;
36
- }
37
-
38
- }
39
- public function setProduct(Mage_Catalog_Model_Product $product)
40
- {
41
- $productId = $product->getEntityId();
42
-
43
- if(!isset($this->_products[$productId])){
44
- $this->_products[$productId] = $product;
45
- return true;
46
- }
47
- return false;
48
- }
49
-
50
- public function countProducts()
51
- {
52
- return count($this->_products);
53
- }
54
-
55
- public function getProducts()
56
- {
57
- return $this->_products;
58
- }
59
-
60
- public function getFallbackProducts($limit)
61
- {
62
- $count = 0;
63
- $fallbackIds = Mage::helper('connector/recommended')->getFallbackIds();
64
- $this->_helper->log('fallback products from helper : '. count($fallbackIds), null, $this->filename);
65
-
66
- if(!empty($fallbackIds)){
67
- foreach ($fallbackIds as $id) {
68
- /** @var Mage_Catalog_Model_Product $product */
69
- $product = Mage::getModel('catalog/product')->load($id);
70
-
71
- if($product->getEntityId()){
72
-
73
- $result = $this->setProduct($product);
74
- if($result)
75
- $count++;
76
-
77
- }
78
-
79
- $this->_helper->log('result for products ' . $this->countProducts() . ', count : ' . $count . ', limit : ' . $limit, null, $this->filename);
80
-
81
- if($count == $limit){
82
-
83
- break;
84
- }
85
- }
86
- }
87
-
88
- return;
89
- }
90
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Dotdigitalgroup/Email/Model/Dynamic/Recommended.php DELETED
@@ -1,228 +0,0 @@
1
- <?php
2
-
3
- class Dotdigitalgroup_Email_Model_Dynamic_Recommended extends Dotdigitalgroup_Email_Model_Dynamic_Product_Mapper
4
- {
5
- protected $_result_limit;
6
-
7
- protected $_storeId;//order store id
8
-
9
- protected $_order_items = 0;//order product items
10
-
11
- protected $_num_order_items;//number of items from order
12
-
13
- protected $_productMapper;
14
-
15
- protected $_is_log_enabled;
16
-
17
- protected $_helper;
18
-
19
- /**
20
- * @param $orderModel
21
- */
22
- public function __construct(Mage_Sales_Model_Order $orderModel = null)
23
- {
24
- if($orderModel){
25
- $this->_storeId = $orderModel->getStoreId();
26
- $this->_order_items = $orderModel->getAllItems();
27
- }
28
- $this->_num_order_items = count($this->_order_items);
29
- $this->_productMapper = new Dotdigitalgroup_Email_Model_Dynamic_Product_Mapper($this->_num_order_items);
30
- $this->_helper = Mage::helper('connector/recommended');
31
- $this->_result_limit = $this->_helper->getLimit();
32
- }
33
-
34
- /**
35
- * Get the recommended products
36
- * @return array
37
- */
38
- public function getProducts()
39
- {
40
- $mode = Mage::registry('mode');
41
- if($mode == 'related' || $mode == 'upsell' || $mode == 'crosssell'){
42
-
43
- //set the order items
44
- $this->setOrderItems();
45
- }else{
46
- //set products directly without looking for order items
47
- $this->setRecommendedProduct();
48
- }
49
-
50
- return $this->_productMapper->getProducts();
51
- }
52
-
53
- public function setOrderItems()
54
- {
55
- foreach ($this->_order_items as $item) {
56
- $productId = $item->getProductId();
57
- /** @var Mage_Catalog_Model_Product $product */
58
- $product = Mage::getModel('catalog/product')->load($productId);//make sure the product is loaded
59
-
60
- $this->setRecommendedProduct($product);
61
- }
62
-
63
- if($this->_productMapper->countProducts() < $this->_result_limit){
64
- $limit = $this->_result_limit - $this->_productMapper->countProducts();
65
- $this->_productMapper->getFallbackProducts($limit);
66
- }
67
-
68
- return $this->_productMapper->getProducts();
69
- }
70
-
71
- public function setRecommendedProduct(Mage_Catalog_Model_Product $productModel = null)
72
- {
73
- //array of products to display
74
- $products = array();
75
-
76
- $mode = Mage::registry('mode');
77
- switch($mode){
78
- case 'related':
79
- $products = $productModel->getRelatedProducts();
80
- break;
81
- case 'upsell':
82
- $products = $productModel->getUpSellProducts();
83
- break;
84
- case 'crosssell':
85
- $products = $productModel->getCrossSellProducts();
86
- break;
87
- case 'bestsellers':
88
- $products = $this->getBestSellersProducts();
89
- break;
90
- case 'mostviewed':
91
- $products = $this->getMostViewedProducts();
92
- break;
93
- case 'recentlyviewed':
94
- $products = $this->getRecentlyViewedProducts();
95
- break;
96
- case 'productpush':
97
- $products = $this->getPushProducts();
98
- break;
99
- }
100
- if($mode == 'related' || $mode == 'upsell' || $mode == 'crosssell'){
101
-
102
- $this->_productMapper->setProducts($products, $this->_result_limit);
103
- }
104
-
105
-
106
- Mage::helper('connector')->log('number of all recommended products : ' . $this->_productMapper->countProducts() . ', max : ' . $this->_result_limit, null, $this->filename);
107
-
108
- }
109
- public function getNumberOfOrderItems()
110
- {
111
- return $this->_order_items;
112
- }
113
-
114
- /**
115
- * Best Selling products
116
- * @return array
117
- */
118
- public function getBestSellersProducts()
119
- {
120
- $limit = $this->_helper->getLimit();
121
- $from = $this->_helper->getTimeFromConfig($config = 'bestsellers');
122
- $to = new Zend_Date();
123
- $to = $to->toString(Zend_Date::ISO_8601);
124
-
125
- $productCollection = Mage::getResourceModel('reports/product_collection')
126
- ->addOrderedQty($from, $to)
127
- ->addAttributeToSelect('*')
128
- ->addAttributeToSelect(array('name', 'price', 'small_image')) //edit to suit tastes
129
- ->setOrder('ordered_qty', 'desc') //best sellers on top
130
- ->setPageSize($limit);
131
-
132
- $productCollection->addAttributeToFilter('status', Mage_Catalog_Model_Product_Status::STATUS_ENABLED);
133
- $productCollection->addAttributeToFilter('visibility', Mage_Catalog_Model_Product_Visibility::VISIBILITY_BOTH);
134
-
135
- foreach ($productCollection as $_product) {
136
- $this->_productMapper->setProduct($_product);
137
- }
138
-
139
- return array();
140
- }
141
-
142
- /**
143
- * Most viwed products
144
- * @return array
145
- */
146
- public function getMostViewedProducts()
147
- {
148
- $limit = $this->_helper->getLimit();
149
- $from = $this->_helper->getTimeFromConfig($config = 'mostviewed');
150
-
151
- $to = new Zend_Date();
152
- $to = $to->toString(Zend_Date::ISO_8601);
153
- $productCollection = Mage::getResourceModel('reports/product_collection')
154
- ->addViewsCount()
155
- ->addViewsCount($from, $to)
156
- ->setPageSize($limit);
157
-
158
- $productCollection->addAttributeToFilter('status', Mage_Catalog_Model_Product_Status::STATUS_ENABLED);
159
- $productCollection->addAttributeToFilter('visibility', Mage_Catalog_Model_Product_Visibility::VISIBILITY_BOTH);
160
-
161
- foreach ($productCollection as $_product) {
162
- $this->_productMapper->setProduct($_product);
163
- }
164
-
165
-
166
- return $this->_productMapper->getProducts();
167
- }
168
-
169
- /**
170
- * Recently viewed products
171
- * @return $this
172
- */
173
- public function getRecentlyViewedProducts()
174
- {
175
- $customerId = Mage::registry('customer');
176
- $helper = Mage::helper('connector');
177
- $helper->log('recentlyviewed customer : ' . $customerId, null, $this->filename);
178
- if($customerId){
179
-
180
- $limit = $this->_helper->getLimit();
181
-
182
- //login customer to receive the recent products
183
- $session = Mage::getSingleton('customer/session');
184
- $session->loginById($customerId);
185
-
186
- /** @var Mage_Reports_Block_Product_Viewed $collection */
187
- $collection = Mage::getSingleton('Mage_Reports_Block_Product_Viewed');
188
- $items = $collection->getItemsCollection()
189
- ->setPageSize($limit)
190
- ;
191
-
192
-
193
- foreach ($items as $product) {
194
- $this->_productMapper->setProduct($product);
195
- }
196
-
197
-
198
- return $this->_productMapper->getProducts();
199
- }else{
200
-
201
- $helper->log('Get recently viewd products, customer id not found : ' . $customerId, null, $this->filename);
202
- }
203
-
204
- return null;
205
- }
206
-
207
- public function getPushProducts()
208
- {
209
- $productIds = $this->_helper->getProductPushIds();
210
-
211
- Mage::helper('connector')->log('proudcts push ids : ' . implode(',', $productIds), null, $this->filename);
212
-
213
-
214
- $productCollection = Mage::getModel('catalog/product')->getCollection()
215
- ->addAttributeToFilter('entity_id', array('in' => $productIds))
216
- ->setPageSize(Mage::helper('connector/recommended')->getLimit())
217
- ;
218
-
219
- foreach ($productCollection as $_product) {
220
- $this->_productMapper->setProduct($_product);
221
-
222
- }
223
-
224
- return $this->_productMapper->getProducts();
225
- }
226
-
227
-
228
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Dotdigitalgroup/Email/Model/Newsletter/Subscriber.php DELETED
@@ -1,19 +0,0 @@
1
- <?php
2
-
3
- class Dotdigitalgroup_Email_Model_Newsletter_Subscriber extends Mage_Core_Helper_Abstract
4
- {
5
- const XML_PATH_SUBSCRIBERS_ADDRESS_BOOK_ID = 'connector_data_field_settings/address_book/subscribers';
6
-
7
- // select subscribers that are not registred as customers
8
- public function getSubscribersNotCustomers($storeIds = array())
9
- {
10
- $newsletterCollection = Mage::getModel('newsletter/subscriber')->getCollection()
11
- ->addFieldToFilter('main_table.customer_id', array('eq' => 0))
12
- ->addFieldToFilter('subscriber_status', array('eq' => Mage_Newsletter_Model_Subscriber::STATUS_SUBSCRIBED))
13
- ->addStoreFilter($storeIds)
14
- ;
15
-
16
- return $newsletterCollection;
17
- }
18
-
19
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Dotdigitalgroup/Email/Model/Observer.php DELETED
@@ -1,189 +0,0 @@
1
- <?php
2
-
3
- class Dotdigitalgroup_Email_Model_Observer extends Dotdigitalgroup_Email_Model_Api_Rest
4
- {
5
- /**
6
- * Create new contact or update info also check for email change
7
- * event: customer_save_before
8
- * @param Varien_Event_Observer $observer
9
- * @return $this
10
- */
11
- public function handleCustomerSaveBefore(Varien_Event_Observer $observer)
12
- {
13
- // skip update customer for first time sync
14
- if(! Mage::registry('first_time_sync')){
15
-
16
- /* @var $customer Mage_Customer_Model_Customer */
17
- $customer = $observer->getEvent()->getCustomer();
18
- $email = $customer->getEmail();
19
- $websiteId = $customer->getWebsiteId();
20
- $subscribed = $customer->getIsSubscribed();
21
-
22
- $this->_api_user = Mage::app()->getWebsite($websiteId)->getConfig(Dotdigitalgroup_Email_Model_Customer_Customer::XML_PATH_CONNECTOR_API_USERNAME);
23
- $this->_api_password = Mage::app()->getWebsite($websiteId)->getConfig(Dotdigitalgroup_Email_Model_Customer_Customer::XML_PATH_CONNECTOR_API_PASSWORD);
24
- $subscribersAddressBook = Mage::app()->getWebsite($websiteId)->getConfig(Dotdigitalgroup_Email_Model_Newsletter_Subscriber::XML_PATH_SUBSCRIBERS_ADDRESS_BOOK_ID);
25
-
26
- if($customer->getData('dotmailer_contact_id')){
27
- $dotmailerId = $customer->getData('dotmailer_contact_id');
28
- //get contact infrmation by id
29
- $response = $this->getContactById($dotmailerId);
30
-
31
- //check for matching email
32
- if(isset($response->email)){
33
- if($email != $response->email){
34
- $data = array(
35
- 'Email' => $email,
36
- 'EmailType' => 'Html'
37
- );
38
- //update the contact with same id - different email
39
- $this->updateContact($dotmailerId, $data);
40
- }
41
-
42
- if(!$subscribed && $response->status == 'Subscribed'){
43
- $this->deleteAddressBookContact($subscribersAddressBook, $response->id);
44
- }
45
- }
46
- }else{
47
- //get contact info by email
48
- $response = $this->getContactByEmail($email);
49
- //create new contact and add to address books
50
- if(isset($response->message) && $response->message == Dotdigitalgroup_Email_Model_Api_Rest::REST_CONTACT_NOT_FOUND){
51
- $contactApi = $this->createNewContact($email);
52
- $this->postAddressBookContacts(Mage::getStoreConfig(Dotdigitalgroup_Email_Model_Customer_Customer::XML_PATH_CUSTOMERS_ADDRESS_BOOK_ID), $contactApi);
53
-
54
- if($subscribed){
55
- $this->postAddressBookContacts($subscribersAddressBook, $contactApi);
56
- }
57
- }
58
- }
59
-
60
- if(isset($response->id))
61
- $customer->setData('dotmailer_contact_id', $response->id);//set the id from contact info
62
- }
63
- return $this;
64
- }
65
- /**
66
- * event: sales_order_save_after
67
- * @param Varien_Event_Observer $observer
68
- * @return $this
69
- */
70
- public function handleSalesOrderSaveAfter(Varien_Event_Observer $observer)
71
- {
72
- $order = $observer->getEvent()->getOrder();
73
- $storeId = $order->getStoreId();
74
- $customerId = $order->getCustomerId();
75
-
76
- $customerModel = Mage::getModel('customer/customer')->load($customerId);
77
-
78
-
79
- if(!$customerModel->getData('dotmailer_contact_id'))
80
- $customerModel->save();
81
-
82
- $this->_api_user = Mage::getStoreConfig(Dotdigitalgroup_Email_Model_Customer_Customer::XML_PATH_CONNECTOR_API_USERNAME, $storeId);
83
- $this->_api_password = Mage::getStoreConfig(Dotdigitalgroup_Email_Model_Customer_Customer::XML_PATH_CONNECTOR_API_PASSWORD, $storeId);
84
- $is_enabled = Mage::getStoreConfig(Dotdigitalgroup_Email_Model_Sales_Order::XML_PATH_TRANSACTIONAL_DATA_ENABLED, $storeId);
85
-
86
- // store scope enabled
87
- if($is_enabled){
88
- $dotmailer = new Dotdigitalgroup_Email_Model_Connector_Order($order);
89
- $this->sendOrderTransactionalData($dotmailer, 'Order');
90
- }
91
-
92
-
93
- return $this;
94
- }
95
-
96
- /**
97
- * event: quote_save_after
98
- * @param Varien_Event_Observer $observer
99
- * @return $this
100
- */
101
- public function handleSalesQuoteSaveAfter(Varien_Event_Observer $observer)
102
- {
103
- $quote = $observer->getQuote();
104
- $customerIsNotGuest = $quote->getCustomerId();
105
- $storeId = $quote->getStoreId();
106
-
107
- $this->_api_user = Mage::getStoreConfig(Dotdigitalgroup_Email_Model_Customer_Customer::XML_PATH_CONNECTOR_API_USERNAME, $storeId);
108
- $this->_api_password = Mage::getStoreConfig(Dotdigitalgroup_Email_Model_Customer_Customer::XML_PATH_CONNECTOR_API_PASSWORD, $storeId);
109
- $is_enabled = Mage::getStoreConfig(Dotdigitalgroup_Email_Model_Sales_Order::XML_PATH_TRANSACTIONAL_DATA_ENABLED, $storeId);
110
-
111
- // save quotes that are active
112
- if($customerIsNotGuest && $is_enabled && $quote->getIsActive()){
113
- $dotmailer = new Dotdigitalgroup_Email_Model_Connector_Quote($quote);
114
- $this->sendTransactionalData($dotmailer, 'Basket');
115
- }
116
-
117
- return $this;
118
- }
119
-
120
- public function handleSalesOrderStatusChange(Varien_Event_Observer $observer)
121
- {
122
- $order = $observer->getEvent()->getOrder();
123
- $status = $order->getStatus();
124
-
125
- /**
126
- * SMS functinality
127
- */
128
- $smsStatusOne = Mage::getStoreConfig(Dotdigitalgroup_Email_Model_Sales_Sms::XML_PATH_SMS_MESSAGE_ONE_STATUS);
129
- $smsStatusTwo = Mage::getStoreConfig(Dotdigitalgroup_Email_Model_Sales_Sms::XML_PATH_SMS_MESSAGE_TWO_STATUS);
130
- $smsStatusThree = Mage::getStoreConfig(Dotdigitalgroup_Email_Model_Sales_Sms::XML_PATH_SMS_MESSAGE_THREE_STATUS);
131
- $smsStatusFour = Mage::getStoreConfig(Dotdigitalgroup_Email_Model_Sales_Sms::XML_PATH_SMS_MESSAGE_FOUR_STATUS);
132
- $smsModel = new Dotdigitalgroup_Email_Model_Sales_Sms();
133
-
134
- switch($status){
135
- case $smsStatusOne:
136
- $smsModel->sendMessage($order, 'ONE');
137
- break;
138
- case $smsStatusTwo:
139
- $smsModel->sendMessage($order, 'TWO');
140
- break;
141
- case $smsStatusThree:
142
- $smsModel->sendMessage($order, 'THREE');
143
- break;
144
- case $smsStatusFour:
145
- $smsModel->sendMessage($order, 'FOUR');
146
- break;
147
- }
148
-
149
- return $this;
150
- }
151
-
152
- public function handleSalesOrderRefund(Varien_Event_Observer $observer)
153
- {
154
- $creditmemo = $observer->getEvent()->getCreditmemo();
155
- $storeId = $creditmemo->getStoreId();
156
-
157
- $this->_api_user = Mage::getStoreConfig(Dotdigitalgroup_Email_Model_Customer_Customer::XML_PATH_CONNECTOR_API_USERNAME, $storeId);
158
- $this->_api_password = Mage::getStoreConfig(Dotdigitalgroup_Email_Model_Customer_Customer::XML_PATH_CONNECTOR_API_PASSWORD, $storeId);
159
- $is_enabled = Mage::getStoreConfig(Dotdigitalgroup_Email_Model_Sales_Order::XML_PATH_TRANSACTIONAL_DATA_ENABLED, $storeId);
160
- $order = $creditmemo->getOrder();
161
-
162
- // store scope enabled
163
- if($is_enabled){
164
- $connectorOrder = new Dotdigitalgroup_Email_Model_Connector_Order($order);
165
- $result = $this->sendOrderTransactionalData($connectorOrder, 'Order', $order->getIncrementId());
166
- $this->_helper->log($result, null, $this->_log_filename);
167
-
168
- }
169
-
170
- return $this;
171
- }
172
- public function hangleSalesOrderCancel(Varien_Event_Observer $observer)
173
- {
174
- $order = $observer->getEvent()->getOrder();
175
- $storeId = $order->getStoreId();
176
- $key = $order->getIncrementId();
177
-
178
- $this->_api_user = Mage::getStoreConfig(Dotdigitalgroup_Email_Model_Customer_Customer::XML_PATH_CONNECTOR_API_USERNAME, $storeId);
179
- $this->_api_password = Mage::getStoreConfig(Dotdigitalgroup_Email_Model_Customer_Customer::XML_PATH_CONNECTOR_API_PASSWORD, $storeId);
180
- $is_enabled = Mage::getStoreConfig(Dotdigitalgroup_Email_Model_Sales_Order::XML_PATH_TRANSACTIONAL_DATA_ENABLED, $storeId);
181
-
182
- if($is_enabled)
183
- $this->deleteContactsTransactionalData('Order', $key);
184
-
185
-
186
-
187
- return $this;
188
- }
189
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Dotdigitalgroup/Email/Model/Order.php DELETED
@@ -1,33 +0,0 @@
1
- <?php
2
-
3
- class Dotdigitalgroup_Email_Model_Order extends Mage_Sales_Model_Order
4
- {
5
- protected function _setState($state, $status = false, $comment = '', $isCustomerNotified = null, $shouldProtectState = false)
6
- {
7
- // dispatch an event before we attempt to do anything
8
- Mage::dispatchEvent('sales_order_status_before', array('order' => $this, 'state' => $state, 'status' => $status, 'comment' => $comment, 'isCustomerNotified' => $isCustomerNotified, 'shouldProtectState' => $shouldProtectState));
9
-
10
- // attempt to set the specified state
11
- if ($shouldProtectState) {
12
- if ($this->isStateProtected($state)) {
13
- Mage::throwException(Mage::helper('sales')->__('The Order State "%s" must not be set manually.', $state));
14
- }
15
- }
16
- $this->setData('state', $state);
17
-
18
- // add status history
19
- if ($status) {
20
- if ($status === true) {
21
- $status = $this->getConfig()->getStateDefaultStatus($state);
22
- }
23
- $this->setStatus($status);
24
- $history = $this->addStatusHistoryComment($comment, false); // no sense to set $status again
25
- $history->setIsCustomerNotified($isCustomerNotified); // for backwards compatibility
26
- }
27
-
28
- // dispatch an event after status has changed
29
- Mage::dispatchEvent('sales_order_status_after', array('order' => $this, 'state' => $state, 'status' => $status, 'comment' => $comment, 'isCustomerNotified' => $isCustomerNotified, 'shouldProtectState' => $shouldProtectState));
30
-
31
- return $this;
32
- }
33
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Dotdigitalgroup/Email/Model/Sales/Order.php DELETED
@@ -1,96 +0,0 @@
1
- <?php
2
-
3
- class Dotdigitalgroup_Email_Model_Sales_Order extends Dotdigitalgroup_Email_Model_Api_Rest
4
- {
5
- const XML_PATH_TRANSACTIONAL_DATA_ENABLED = 'connector_sync_settings/transactional_data/order_enabled';
6
- const XML_PATH_TRANSACTIONAL_DATA_SYNC_LIMIT = 'connector_advanced_settings/sync_limits/orders';
7
-
8
- protected $accounts = array();
9
-
10
- /**
11
- * initial sync the transactional data
12
- * @return array
13
- */
14
- public function sync()
15
- {
16
- // Initialise a return hash containing results of our sync attempt
17
- $this->_searchAccounts();
18
-
19
- foreach ($this->accounts as $account){
20
- if(count($account->getOrders())){
21
- $this->sendMultiTransactionalData($account->getOrders(), 'Order');
22
-
23
- }
24
-
25
- unset($this->accounts[$account->getApiUsername()]);
26
- }
27
- return $this;
28
- }
29
-
30
- /**
31
- *Search the configuration data per website
32
- */
33
- private function _searchAccounts()
34
- {
35
- foreach (Mage::app()->getWebsites() as $website){
36
- $enabled = $website->getConfig(self::XML_PATH_TRANSACTIONAL_DATA_ENABLED);
37
-
38
- if(!$enabled)
39
- continue;
40
-
41
- $this->_api_user = $website->getConfig(Dotdigitalgroup_Email_Model_Customer_Customer::XML_PATH_CONNECTOR_API_USERNAME);
42
- $limit = $website->getConfig(self::XML_PATH_TRANSACTIONAL_DATA_SYNC_LIMIT);
43
-
44
- if(!isset($this->accounts[$this->_api_user])){
45
- $account = new Dotdigitalgroup_Email_Model_Connector_Account();
46
- $account->setApiUsername($this->_api_user);
47
- $account->setApiPassword($this->_api_password);
48
- $this->accounts[$this->_api_user] = $account;
49
- }
50
- $this->accounts[$this->_api_user]->setOrders($this->getConnectorOrders($limit));
51
- }
52
- }
53
-
54
- /**
55
- * get all connector orders data
56
- * @param $limit
57
- * @return array
58
- */
59
- public function getConnectorOrders($limit = 100)
60
- {
61
- $orders = $customers = array();
62
- $orderCollection = Mage::getModel('sales/order')->getCollection()
63
- ->addAttributeToFilter('dotmailer_order_imported', array('null' => true), 'left')
64
- ->setPageSize($limit);
65
-
66
- $this->_helper->log('GET CONNECTOR ORDERS ' . $orderCollection->count() . ' limit ' . $limit, null, $this->_log_filename);
67
-
68
- //mark as imported for customers with contact id
69
- foreach ($orderCollection as $order) {
70
- try {
71
- $customerEmail = $order->getCustomerEmail();
72
- $storeId = $order->getStoreId();
73
- $this->setStoreId(Mage::app()->getStore(true)->getId());
74
- $websiteId = Mage::getModel('core/store')->load($storeId)->getWebsiteId();
75
-
76
- $customerModel = Mage::getModel('customer/customer')->setWebsiteId($websiteId)
77
- ->loadByEmail($customerEmail);
78
-
79
- if($customerModel){
80
- $contactId = $customerModel->getData('dotmailer_contact_id');
81
- if($contactId){
82
- $orders[] = new Dotdigitalgroup_Email_Model_Connector_Order($order);
83
- $order->setData('dotmailer_order_imported', 1);
84
- $order->save();
85
- }
86
- }
87
- }catch(Exception $e){
88
-
89
-
90
- $this->_helper->log($order->getIncrementId(), null, $this->_log_filename);
91
- $this->_helper->log($e->getMessage(), null, $this->_log_filename);
92
- }
93
- }
94
- return $orders;
95
- }
96
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Dotdigitalgroup/Email/Model/Sales/Quote.php DELETED
@@ -1,289 +0,0 @@
1
- <?php
2
-
3
- class Dotdigitalgroup_Email_Model_Sales_Quote extends Dotdigitalgroup_Email_Model_Api_Rest
4
- {
5
- //xml path configuration
6
- const XML_PATH_LOSTBASKET_1_ENABLED = 'lostbaskets/customers/enabled_1';
7
- const XML_PATH_LOSTBASKET_2_ENABLED = 'lostbaskets/customers/enabled_2';
8
- const XML_PATH_LOSTBASKET_3_ENABLED = 'lostbaskets/customers/enabled_3';
9
-
10
- const XML_PATH_LOSTBASKET_1_INTERVAL = 'lost_basket_settings/customers/send_after_1';
11
- const XML_PATH_LOSTBASKET_2_INTERVAL = 'lost_basket_settings/customers/send_after_2';
12
- const XML_PATH_LOSTBASKET_3_INTERVAL = 'lost_basket_settings/customers/send_after_3';
13
-
14
- const XML_PATH_TRIGGER_1_CAMPAIGN = 'lost_basket_settings/customers/campaign_1';
15
- const XML_PATH_TRIGGER_2_CAMPAIGN = 'lost_basket_settings/customers/campaign_2';
16
- const XML_PATH_TRIGGER_3_CAMPAIGN = 'lost_basket_settings/customers/campaign_3';
17
-
18
- const XML_PATH_GUEST_LOSTBASKET_1_ENABLED = 'lostbaskets/guests/enabled_1';
19
- const XML_PATH_GUEST_LOSTBASKET_2_ENABLED = 'lostbaskets/guests/enabled_2';
20
- const XML_PATH_GUEST_LOSTBASKET_3_ENABLED = 'lostbaskets/guests/enabled_3';
21
-
22
- const XML_PATH_GUEST_LOSTBASKET_1_INTERVAL = 'lost_basket_settings/guests/send_after_1';
23
- const XML_PATH_GUEST_LOSTBASKET_2_INTERVAL = 'lost_basket_settings/guests/send_after_2';
24
- const XML_PATH_GUEST_LOSTBASKET_3_INTERVAL = 'lost_basket_settings/guests/send_after_3';
25
-
26
- const XML_PATH_GUEST_LOSTBASKET_1_CAMPAIGN = 'lost_basket_settings/guests/campaign_1';
27
- const XML_PATH_GUEST_LOSTBASKET_2_CAMPAIGN = 'lost_basket_settings/guests/campaign_2';
28
- const XML_PATH_GUEST_LOSTBASKET_3_CAMPAIGN = 'lost_basket_settings/guests/campaign_3';
29
-
30
- const XML_PATH_TEST_LOSTBASKET_EMAIL = 'lost_basket_settings/test/email';
31
-
32
-
33
- /**
34
- * send the lost baskets to campains
35
- * @return array
36
- */
37
- public function proccessCampaigns()
38
- {
39
- foreach (Mage::app()->getStores(true) as $store){
40
-
41
- //skip any action if all lost basket campaings are disabled
42
- if(!$store->getConfig(self::XML_PATH_LOSTBASKET_1_ENABLED) && !$store->getConfig(self::XML_PATH_LOSTBASKET_2_ENABLED) &&
43
- !$store->getConfig(self::XML_PATH_LOSTBASKET_3_ENABLED) && !$store->getConfig(self::XML_PATH_GUEST_LOSTBASKET_1_ENABLED) &&
44
- !$store->getconfig(self::XML_PATH_GUEST_LOSTBASKET_2_ENABLED) && !$store->getConfig(self::XML_PATH_GUEST_LOSTBASKET_3_ENABLED)
45
- )continue;
46
-
47
- // set credentials for every store
48
- $storeId = $store->getId();
49
- $this->_api_user = $store->getConfig(Dotdigitalgroup_Email_Model_Customer_Customer::XML_PATH_CONNECTOR_API_USERNAME);
50
- $this->_api_password = $store->getConfig(Dotdigitalgroup_Email_Model_Customer_Customer::XML_PATH_CONNECTOR_API_PASSWORD);
51
-
52
- /**
53
- * Customers campaings
54
- */
55
-
56
- //first campign
57
- if($store->getConfig(self::XML_PATH_LOSTBASKET_1_ENABLED)){
58
-
59
- $contacts = array();
60
- $from = Zend_Date::now()->subMinute($store->getConfig(self::XML_PATH_LOSTBASKET_1_INTERVAL));
61
- $to = clone($from);
62
- $from->sub('5', Zend_Date::MINUTE);
63
- // lost baskets
64
- $quoteCollection = $this->_getStoreQuotes($storeId, $from->toString('YYYY-MM-dd HH:mm:ss'), $to->toString('YYYY-MM-dd HH:mm:ss'));
65
- if(count($quoteCollection)){
66
-
67
- // get collection contacts id
68
- foreach ($quoteCollection as $quote) {
69
- $customerId = $quote->getCustomerId();
70
- $dotmailerContactId = $this->_getContactIdByCustomerId($customerId);
71
-
72
- if($dotmailerContactId)
73
- $contacts[] = $dotmailerContactId;
74
- }
75
- //check for empty contacts to avoid mass emails
76
- if(!empty($contacts))
77
- $this->sendCampaign($store->getConfig(self::XML_PATH_TRIGGER_1_CAMPAIGN), $contacts);
78
- }
79
- }
80
-
81
- //second campaign
82
- if($store->getConfig(self::XML_PATH_LOSTBASKET_2_ENABLED)){
83
- $contacts = array();
84
- $from = Zend_Date::now()->subHour($store->getConfig(self::XML_PATH_LOSTBASKET_2_INTERVAL));
85
- $to = clone($from);
86
- $from->sub('5', Zend_Date::MINUTE);
87
- // lost baskets
88
- $quoteCollection = $this->_getStoreQuotes($storeId, $from->toString('YYYY-MM-dd HH:mm:ss'), $to->toString('YYYY-MM-dd HH:mm:ss'));
89
- if(count($quoteCollection)){
90
- // get collection contacts id
91
- foreach ($quoteCollection as $quote) {
92
- $customerId = $quote->getCustomerId();
93
- $dotmailerContactId = $this->_getContactIdByCustomerId($customerId);
94
- if($dotmailerContactId)
95
- $contacts[] = $dotmailerContactId;
96
- }
97
- if(!empty($contacts))
98
- $this->sendCampaign($store->getConfig(self::XML_PATH_TRIGGER_2_CAMPAIGN), $contacts);
99
- }
100
- }
101
-
102
- //third campign
103
- if($store->getConfig(self::XML_PATH_LOSTBASKET_3_ENABLED)){
104
- $contacts = array();
105
- $from = Zend_Date::now()->subHour($store->getConfig(self::XML_PATH_LOSTBASKET_3_INTERVAL));
106
- $to = clone($from);
107
- $from->sub('5', Zend_Date::MINUTE);
108
- // lost baskets
109
- $quoteCollection = $this->_getStoreQuotes($storeId, $from->toString('YYYY-MM-dd HH:mm:ss'), $to->toString('YYYY-MM-dd HH:mm:ss'));
110
- if(count($quoteCollection)){
111
- // get collection contacts id
112
- foreach ($quoteCollection as $quote) {
113
- $customerId = $quote->getCustomerId();
114
- $dotmailerContactId = $this->_getContactIdByCustomerId($customerId);
115
- if($dotmailerContactId)
116
- $contacts[] = $dotmailerContactId;
117
- }
118
- if(!empty($contacts))
119
- $this->sendCampaign($store->getConfig(self::XML_PATH_TRIGGER_3_CAMPAIGN), $contacts);
120
- }
121
- }
122
- /**
123
- * Guests campaings
124
- */
125
- //first guest campaign
126
- if($store->getConfig(self::XML_PATH_GUEST_LOSTBASKET_1_ENABLED))
127
- {
128
- $contacts = array();
129
- $from = Zend_Date::now()->subMinute($store->getConfig(self::XML_PATH_GUEST_LOSTBASKET_1_INTERVAL));
130
- $to = clone($from);
131
- $from->sub('5', Zend_Date::MINUTE);
132
- $quoteCollection = $this->_getStoreQuotes($storeId, $from->toString('YYYY-MM-dd HH:mm:ss'), $to->toString('YYYY-MM-dd HH:mm:ss'), true);
133
- if(count($quoteCollection)){
134
- // get collection contacts id
135
- foreach ($quoteCollection as $quote) {
136
- $email = $quote->getCustomerEmail();
137
- //check if the customer exists
138
- $response = $this->getContactByEmail($email);
139
-
140
- if(isset($response->message) && $response->message == self::REST_CONTACT_NOT_FOUND){
141
- //create new contact before sending campaign
142
- $contactAPI = $this->createNewContact($email);
143
- if(!isset($contactAPI->message))
144
- $response = $this->postAddressBookContacts($store->getConfig(Dotdigitalgroup_Email_Model_Customer_Customer::XML_PATH_GUEST_ADDRESS_BOOK_ID), $contactAPI);
145
- }
146
- $contacts[] = $response->id;
147
- }
148
- if(!empty($contacts))
149
- $this->sendCampaign($store->getConfig(self::XML_PATH_GUEST_LOSTBASKET_1_CAMPAIGN), $contacts);
150
- }
151
- }
152
- // second guest campaign
153
- if($store->getConfig(self::XML_PATH_GUEST_LOSTBASKET_2_ENABLED))
154
- {
155
- $contacts = array();
156
- $from = Zend_Date::now()->subHour($store->getConfig(self::XML_PATH_GUEST_LOSTBASKET_2_INTERVAL));
157
- $to = clone($from);
158
- $from->sub('5', Zend_Date::MINUTE);
159
- // lost baskets
160
- $quoteCollection = $this->_getStoreQuotes($storeId, $from->toString('YYYY-MM-dd HH:mm:ss'), $to->toString('YYYY-MM-dd HH:mm:ss'), true);
161
- if(count($quoteCollection)){
162
- // get collection contacts id
163
- foreach ($quoteCollection as $quote) {
164
- $email = $quote->getCustomerEmail();
165
- //check if the customer exists
166
- $response = $this->getContactByEmail($email);
167
- if(isset($response->message) && $response->message == self::REST_CONTACT_NOT_FOUND){
168
- //create new contact before sending campaign
169
- $contactAPI = $this->createNewContact($email);
170
- if(!isset($contactAPI->message))
171
- $this->postAddressBookContacts($store->getConfig(Dotdigitalgroup_Email_Model_Customer_Customer::XML_PATH_GUEST_ADDRESS_BOOK_ID), $contactAPI);
172
- }
173
- $contacts[] = $response->id;
174
- }
175
- if(!empty($contacts))
176
- $this->sendCampaign($store->getConfig(self::XML_PATH_GUEST_LOSTBASKET_2_CAMPAIGN), $contacts);
177
- }
178
- }
179
- //third guest campaign
180
- if($store->getConfig(self::XML_PATH_GUEST_LOSTBASKET_3_ENABLED)){
181
- $contacts = array();
182
- $from = Zend_Date::now()->subHour($store->getConfig(self::XML_PATH_GUEST_LOSTBASKET_3_INTERVAL));
183
- $to = clone($from);
184
- $from->sub('5', Zend_Date::MINUTE);
185
-
186
- // lost baskets
187
- $quoteCollection = $this->_getStoreQuotes($storeId, $from->toString('YYYY-MM-dd HH:mm:ss'), $to->toString('YYYY-MM-dd HH:mm:ss'), true);
188
- if(count($quoteCollection)){
189
- // get collection contacts id
190
- foreach ($quoteCollection as $quote) {
191
- $email = $quote->getCustomerEmail();
192
- //check if the customer exists
193
- $response = $this->getContactByEmail($email);
194
-
195
- if(isset($response->message) && $response->message == self::REST_CONTACT_NOT_FOUND){
196
- //create new contact before sending campaign
197
- $contactAPI = $this->createNewContact($email);
198
- if(!isset($contactAPI->message))
199
- $this->postAddressBookContacts($store->getConfig(Dotdigitalgroup_Email_Model_Customer_Customer::XML_PATH_GUEST_ADDRESS_BOOK_ID), $contactAPI);
200
- }
201
- $contacts[] = $response->id;
202
- }
203
- if(!empty($contacts))
204
- $this->sendCampaign($store->getConfig(self::XML_PATH_GUEST_LOSTBASKET_3_CAMPAIGN), $contacts);
205
- }
206
- }
207
- }
208
- return;
209
- }
210
-
211
- /**
212
- * @param $storeId
213
- * @param null $from
214
- * @param null $to
215
- * @param bool $guest
216
- * @return Varien_Data_Collection_Db
217
- */
218
- private function _getStoreQuotes($storeId, $from = null, $to = null, $guest = false){
219
-
220
- $salesCollection = Mage::getResourceModel('sales/quote_collection')
221
- ->addFieldToFilter('is_active',1)
222
- ->addFieldToFilter('items_count', array('gt' => 0))
223
- ->addFieldToFilter('customer_email', array('neq' => ''))
224
- ->addFieldToFilter('store_id', $storeId)
225
- ->addFieldToFilter('updated_at',array(
226
- 'from' => $from,
227
- 'to' => $to,
228
- 'date' => true)
229
- );
230
- if($guest)
231
- $salesCollection->addFieldToFilter('checkout_method' , Mage_Checkout_Model_Type_Onepage::METHOD_GUEST);
232
-
233
- return $salesCollection->load();
234
- }
235
-
236
- private function _getContactIdByCustomerId($customerId)
237
- {
238
- $customerModel = Mage::getModel('customer/customer')->load($customerId);
239
-
240
- if($customerModel){
241
- return $customerModel->getData('dotmailer_contact_id');
242
- }
243
- return false;
244
-
245
- }
246
- public function forceProccess()
247
- {
248
- $result = array('errors' => false, 'message' => '');
249
- $contacts = array();
250
- $customerEmail = Mage::getStoreConfig(self::XML_PATH_TEST_LOSTBASKET_EMAIL);
251
-
252
-
253
- $salesCollection = Mage::getResourceModel('sales/quote_collection')
254
- ->addFieldToFilter('is_active',1)
255
- ->addFieldToFilter('items_count', array('gt' => 0))
256
- ->addFieldToFilter('customer_id', array('neq' => ''))
257
- ->addFieldToFilter('customer_email', $customerEmail)
258
-
259
- //->addFieldToFilter('store_id', $storeId)
260
- ;
261
- $salesCollection->getSelect()->order("updated_at desc");
262
-
263
-
264
- $quote = $salesCollection->getFirstItem();
265
-
266
- if($quote){
267
-
268
- $contactId = $this->_getContactIdByCustomerId($quote->getCustomerId());
269
-
270
- if($contactId)
271
- $contacts[] = $contactId;
272
-
273
- if(!empty($contacts)){
274
-
275
- $responce = $this->sendCampaign(Mage::getStoreConfig(self::XML_PATH_TRIGGER_1_CAMPAIGN), $contacts);
276
- if(isset($responce->message)){
277
- $result['errors'] = true;
278
- $result['message'] = $responce->message;
279
- }else{
280
-
281
- $result['message'] = 'First Test Campaign Sent ';
282
- }
283
- }
284
- }
285
- return $result;
286
-
287
- }
288
-
289
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Dotdigitalgroup/Email/Model/Sales/Sms.php DELETED
@@ -1,70 +0,0 @@
1
- <?php
2
-
3
- class Dotdigitalgroup_Email_Model_Sales_Sms extends Dotdigitalgroup_Email_Model_Api_Rest
4
- {
5
- const XML_PATH_SMS_MESSAGE_ONE_STATUS = 'sms_section/sms_message_one/order_status';
6
- const XML_PATH_SMS_MESSAGE_TWO_STATUS = 'sms_section/sms_message_two/order_status';
7
- const XML_PATH_SMS_MESSAGE_THREE_STATUS = 'sms_section/sms_message_three/order_status';
8
- const XML_PATH_SMS_MESSAGE_FOUR_STATUS = 'sms_section/sms_message_four/order_status';
9
-
10
- const XML_PATH_SMS_MESSAGE_ONE = 'sms_section/sms_message_one/message';
11
- const XML_PATH_SMS_MESSAGE_TWO = 'sms_section/sms_message_two/message';
12
- const XML_PATH_SMS_MESSAGE_THREE = 'sms_section/sms_message_three/message';
13
- const XML_PATH_SMS_MESSAGE_FOUR = 'sms_section/sms_message_four/message';
14
-
15
- public $_available = array('/customer_name/', '/order_number/', '/{{var /', '/}}/');
16
-
17
- public function sendMessage($order, $number)
18
- {
19
- $storeId = $order->getStoreId();
20
- $billing = $order->getBillingAddress();
21
- $customerTelephone = $billing->getTelephone();
22
-
23
- $message = Mage::getStoreConfig(constant('self::XML_PATH_SMS_MESSAGE_' . $number), $storeId);
24
-
25
- $message = $this->_processVariables($order, $message);
26
-
27
-
28
- $pattern = "/^(\+44\s?7\d{3}|\(?07\d{3}\)?)\s?\d{3}\s?\d{3}$/";
29
-
30
- $match = preg_match($pattern, $customerTelephone);
31
- $this->_helper->log('sms number to send : ' . $customerTelephone, null, $this->_log_filename);
32
-
33
- if ($match != false) {
34
- $telephoneNumber = preg_replace('/\A(0){1}+/', '+44', $customerTelephone);
35
- Mage::helper('connector')->log($telephoneNumber, null, 'api.log');
36
- $this->postSmsMessagesSendTo($telephoneNumber, $message);
37
- } else {
38
-
39
- $this->_helper->log('telephone number not valid ' . $customerTelephone, null, $this->_log_filename);
40
- }
41
- }
42
-
43
- /**
44
- * @param $order
45
- * @param $message
46
- * @return mixed
47
- */
48
- protected function _processVariables($order, $message)
49
- {
50
- $helper = Mage::helper('connector');
51
- if(preg_match('/{{var/', $message)){
52
-
53
- $firstname = $order->getCustomerFirstname();
54
-
55
- $replacemant = array();
56
- $replacemant[] = $firstname;
57
- $replacemant[] = $order->getIncrementId();
58
- $replacemant[] = '';
59
- $replacemant[] = '';
60
-
61
- $message = preg_replace($this->_available, $replacemant, $message);
62
-
63
- $helper->log($message, null, $this->_log_filename);
64
-
65
- }
66
-
67
- return $message;
68
- }
69
-
70
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Dotdigitalgroup/Email/Model/System/Config/Backend/Syncschedule/Customer.php DELETED
@@ -1,50 +0,0 @@
1
- <?php
2
-
3
- class Dotdigitalgroup_Email_Model_System_Config_Backend_Syncschedule_Customer extends Mage_Core_Model_Config_Data
4
- {
5
- const CRON_STRING_PATH = 'connector_sync_settings/sync_customer_schedule/cronschedule';
6
-
7
- /**
8
- * Cron settings after save
9
- *
10
- *
11
- */
12
- protected function _afterSave()
13
- {
14
-
15
- $enabled = $this->getData('groups/sync_customer_schedule/fields/enabled/value');
16
- $time = $this->getData('groups/sync_customer_schedule/fields/time/value');
17
- $frequency = $this->getData('groups/sync_customer_schedule/fields/frequency/value');
18
-
19
- $frequencyHourly = Dotdigitalgroup_Email_Model_System_Config_Source_Syncfrequency::CRON_HOURLY;
20
- $frequencyDaily = Dotdigitalgroup_Email_Model_System_Config_Source_Syncfrequency::CRON_DAILY;
21
- $frequencyWeekly = Dotdigitalgroup_Email_Model_System_Config_Source_Syncfrequency::CRON_WEEKLY;
22
- $frequencyMonthly = Dotdigitalgroup_Email_Model_System_Config_Source_Syncfrequency::CRON_MONTHLY;
23
-
24
- if ($enabled) {
25
- $cronDayOfWeek = date('N');
26
- $cronExprArray = array(
27
- ($frequency == $frequencyHourly) ? intval($time[1]) : '*', # Minute
28
- ($frequency == $frequencyDaily) ? intval($time[0]) : '*', # Hour
29
- ($frequency == $frequencyMonthly) ? '1' : '*', # Day of the Month
30
- '*', # Month of the Year
31
- ($frequency == $frequencyWeekly) ? $cronDayOfWeek : '*', # Day of the Week
32
- );
33
- $cronExprString = join(' ', $cronExprArray);
34
- }
35
- else {
36
- $cronExprString = '';
37
- }
38
-
39
- try {
40
- // store config $cronExprString
41
- Mage::getModel('core/config_data')
42
- ->load(self::CRON_STRING_PATH, 'path')
43
- ->setValue($cronExprString)
44
- ->setPath(self::CRON_STRING_PATH)
45
- ->save();
46
- }catch (Exception $e) {
47
- Mage::throwException('Unable to save the cron expression.');
48
- }
49
- }
50
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Dotdigitalgroup/Email/Model/System/Config/Backend/Syncschedule/Suppressed.php DELETED
@@ -1,54 +0,0 @@
1
- <?php
2
-
3
- class Dotdigitalgroup_Email_Model_System_Config_Backend_Syncschedule_Suppressed extends Mage_Core_Model_Config_Data
4
- {
5
- const CRON_STRING_PATH = 'connector_sync_settings/sync_suppressed_schedule/cronschedulesupp';
6
-
7
- /**
8
- * Cron settings after save
9
- *
10
- *
11
- */
12
- protected function _afterSave()
13
- {
14
-
15
- $enabled = $this->getData('groups/sync_suppressed_schedule/fields/enabled/value');
16
- $time = $this->getData('groups/sync_suppressed_schedule/fields/time/value');
17
- $frequency = $this->getData('groups/sync_suppressed_schedule/fields/frequency/value');
18
-
19
- $frequencyHourly = Dotdigitalgroup_Email_Model_System_Config_Source_Syncfrequency::CRON_HOURLY;
20
- $frequencyDaily = Dotdigitalgroup_Email_Model_System_Config_Source_Syncfrequency::CRON_DAILY;
21
- $frequencyWeekly = Dotdigitalgroup_Email_Model_System_Config_Source_Syncfrequency::CRON_WEEKLY;
22
- $frequencyMonthly = Dotdigitalgroup_Email_Model_System_Config_Source_Syncfrequency::CRON_MONTHLY;
23
-
24
- if ($enabled) {
25
- $cronDayOfWeek = date('N');
26
- $cronExprArray = array(
27
- ($frequency == $frequencyHourly) ? intval($time[1]) : '*', # Minute
28
- ($frequency == $frequencyDaily) ? intval($time[0]) : '*', # Hour
29
- ($frequency == $frequencyMonthly) ? '1' : '*', # Day of the Month
30
- '*', # Month of the Year
31
- ($frequency == $frequencyWeekly) ? $cronDayOfWeek : '*', # Day of the Week
32
- );
33
- $cronExprString = join(' ', $cronExprArray);
34
- }
35
- else {
36
- $cronExprString = '';
37
- }
38
-
39
- try {
40
- // store config $cronExprString
41
-
42
-
43
- Mage::getModel('core/config_data')
44
- ->load(self::CRON_STRING_PATH, 'path')
45
- ->setValue($cronExprString)
46
- ->setPath(self::CRON_STRING_PATH)
47
- ->save();
48
-
49
- }
50
- catch (Exception $e) {
51
- Mage::throwException('Unable to save the cron expression.');
52
- }
53
- }
54
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Dotdigitalgroup/Email/Model/System/Config/Source/Activebasket.php DELETED
@@ -1,12 +0,0 @@
1
- <?php
2
-
3
- class Dotdigitalgroup_Email_Model_System_Config_Source_Activebasket
4
- {
5
- function toOptionArray()
6
- {
7
- return array(
8
- array('value' => '0', 'label' => Mage::helper('connector')->__('Success Page')),
9
- array('value' => '1', 'label' => Mage::helper('connector')->__('Complete Order'))
10
- );
11
- }
12
- }
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Dotdigitalgroup/Email/Model/System/Config/Source/Addressbooks.php DELETED
@@ -1,30 +0,0 @@
1
- <?php
2
-
3
- class Dotdigitalgroup_Email_Model_System_Config_Source_Addressbooks extends Dotdigitalgroup_Email_Model_Api_Rest
4
- {
5
- // Returns the account's datafields
6
- public function toOptionArray()
7
- {
8
- $fields = array();
9
- //load the configuration for website select in admin
10
- $websiteName = Mage::app()->getRequest()->getParam('website');
11
- if(! empty($websiteName)){
12
- $websites = Mage::getModel('core/website')->getCollection()
13
- ->addFieldToFilter('code', $websiteName);
14
- $website = $websites->getFirstItem();
15
- $this->_api_user = $website->getConfig(Dotdigitalgroup_Email_Model_Customer_Customer::XML_PATH_CONNECTOR_API_USERNAME);
16
- $this->_api_password = $website->getConfig(Dotdigitalgroup_Email_Model_Customer_Customer::XML_PATH_CONNECTOR_API_PASSWORD);
17
- }
18
- $addressBooks = $this->postAddressBooks();
19
-
20
- //set up fields with book id and label
21
- foreach ($addressBooks as $book){
22
-
23
- if(isset($book->id))
24
- $fields[] = array('value' => $book->id, 'label' => $book->name);
25
- }
26
-
27
- return $fields;
28
- }
29
-
30
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Dotdigitalgroup/Email/Model/System/Config/Source/Campaigns.php DELETED
@@ -1,30 +0,0 @@
1
- <?php
2
- /**
3
- * Date: 15/04/2013
4
- * Time: 13:46
5
- */
6
- class Dotdigitalgroup_Email_Model_System_Config_Source_Campaigns extends Dotdigitalgroup_Email_Model_Api_Rest
7
- {
8
-
9
- // Returns the account's datafields
10
- public function toOptionArray()
11
- {
12
- $fields = array();
13
- $websiteName = Mage::app()->getRequest()->getParam('website');
14
- if(! empty($websiteName)){
15
- $websites = Mage::getModel('core/website')->getCollection()
16
- ->addFieldToFilter('code', $websiteName);
17
- $website = $websites->getFirstItem();
18
- $this->_api_user = $website->getConfig(Dotdigitalgroup_Email_Model_Customer_Customer::XML_PATH_CONNECTOR_API_USERNAME);
19
- $this->_api_password = $website->getConfig(Dotdigitalgroup_Email_Model_Customer_Customer::XML_PATH_CONNECTOR_API_PASSWORD);
20
- }
21
- $campaigns = $this->postCampaigns();
22
- foreach ($campaigns as $one){
23
- if(isset($one->id))
24
- $fields[] = array('value' => $one->id, 'label' => $one->name);
25
- }
26
-
27
- return $fields;
28
- }
29
-
30
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Dotdigitalgroup/Email/Model/System/Config/Source/Datafields.php DELETED
@@ -1,35 +0,0 @@
1
- <?php
2
- /**
3
- * Date: 15/04/2013
4
- * Time: 13:46
5
- */
6
- class Dotdigitalgroup_Email_Model_System_Config_Source_Datafields extends Dotdigitalgroup_Email_Model_Api_Rest
7
- {
8
-
9
- // Returns the account's datafields
10
- public function toOptionArray()
11
- {
12
- $fields = array();
13
- //load the configuration for website select in admin
14
- $websiteName = Mage::app()->getRequest()->getParam('website');
15
- if(! empty($websiteName)){
16
- $websites = Mage::getModel('core/website')->getCollection()
17
- ->addFieldToFilter('code', $websiteName);
18
- $website = $websites->getFirstItem();
19
- $this->_api_user = $website->getConfig(Dotdigitalgroup_Email_Model_Customer_Customer::XML_PATH_CONNECTOR_API_USERNAME);
20
- $this->_api_password = $website->getConfig(Dotdigitalgroup_Email_Model_Customer_Customer::XML_PATH_CONNECTOR_API_PASSWORD);
21
- }
22
-
23
- // Add a "Do Not Map" Option
24
- $fields[] = array('value' => 0, 'label' => 'Do Not Map');
25
-
26
- $datafileds = $this->postDataFields();
27
- foreach ($datafileds as $datafield) {
28
- if(isset($datafield->name))
29
- $fields[] = array('value' => $datafield->name, 'label' => $datafield->name);
30
- }
31
-
32
- return $fields;
33
- }
34
-
35
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Dotdigitalgroup/Email/Model/System/Config/Source/Displayifnot.php DELETED
@@ -1,12 +0,0 @@
1
- <?php
2
-
3
- class Dotdigitalgroup_Email_Model_System_Config_Source_Displayifnot
4
- {
5
- public function toOptionArray()
6
- {
7
- return array(
8
- array('value' => 'best-sellers', 'label' => Mage::helper('connector')->__('Best Sellers')),
9
- array('value' => 'most-viewed', 'label' => Mage::helper('connector')->__('Most Viewed'))
10
- );
11
- }
12
- }
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Dotdigitalgroup/Email/Model/System/Config/Source/Orderstatus.php DELETED
@@ -1,16 +0,0 @@
1
- <?php
2
-
3
- class Dotdigitalgroup_Email_Model_System_Config_Source_Orderstatus
4
- {
5
- public function toOptionArray(){
6
-
7
- $statusCollection = Mage::getModel('sales/order_status')->getCollection();
8
- $statuses = array();
9
-
10
- foreach ($statusCollection as $one) {
11
- $statuses[] = array('value' => $one->getStatus(), 'label' => Mage::helper('connector')->__($one->getLabel()));
12
- }
13
-
14
- return $statuses;
15
- }
16
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Dotdigitalgroup/Email/Model/System/Config/Source/Sendcampain.php DELETED
@@ -1,30 +0,0 @@
1
- <?php
2
-
3
- class Dotdigitalgroup_Email_Model_System_Config_Source_SendCampain
4
- {
5
- /**
6
- * send to campain options hours
7
- * @return array
8
- */
9
- public function toOptionArray()
10
- {
11
- return array(
12
- array('value'=>1 , 'label'=>Mage::helper('adminhtml')->__('1 Hour')),
13
- array('value'=>2 , 'label'=>Mage::helper('adminhtml')->__('2 Hours')),
14
- array('value'=>3 , 'label'=>Mage::helper('adminhtml')->__('3 Hours')),
15
- array('value'=>4 , 'label'=>Mage::helper('adminhtml')->__('4 Hours')),
16
- array('value'=>5 , 'label'=>Mage::helper('adminhtml')->__('5 Hours')),
17
- array('value'=>6 , 'label'=>Mage::helper('adminhtml')->__('6 Hours')),
18
- array('value'=>12 , 'label'=>Mage::helper('adminhtml')->__('12 Hours')),
19
- array('value'=>36 , 'label'=>Mage::helper('adminhtml')->__('36 Hours')),
20
- array('value'=>48 , 'label'=>Mage::helper('adminhtml')->__('48 Hours')),
21
- array('value'=>60 , 'label'=>Mage::helper('adminhtml')->__('60 Hours')),
22
- array('value'=>72 , 'label'=>Mage::helper('adminhtml')->__('72 Hours')),
23
- array('value'=>84 , 'label'=>Mage::helper('adminhtml')->__('84 Hours')),
24
- array('value'=>96 , 'label'=>Mage::helper('adminhtml')->__('96 Hours')),
25
- array('value'=>108 , 'label'=>Mage::helper('adminhtml')->__('108 Hours')),
26
- array('value'=>120 , 'label'=>Mage::helper('adminhtml')->__('120 Hours')),
27
- );
28
-
29
- }
30
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Dotdigitalgroup/Email/Model/System/Config/Source/Syncfrequency.php DELETED
@@ -1,40 +0,0 @@
1
- <?php
2
-
3
- class Dotdigitalgroup_Email_Model_System_Config_Source_Syncfrequency
4
- {
5
-
6
- protected static $_options;
7
-
8
- const CRON_HOURLY = 'H';
9
- const CRON_DAILY = 'D';
10
- const CRON_WEEKLY = 'W';
11
- const CRON_MONTHLY = 'M';
12
-
13
- public function toOptionArray()
14
- {
15
- if (!self::$_options) {
16
- self::$_options = array(
17
- array(
18
- 'label' => Mage::helper('cron')->__('Hourly'),
19
- 'value' => self::CRON_HOURLY,
20
- ),
21
- array(
22
- 'label' => Mage::helper('cron')->__('Daily'),
23
- 'value' => self::CRON_DAILY,
24
- ),
25
- array(
26
- 'label' => Mage::helper('cron')->__('Weekly'),
27
- 'value' => self::CRON_WEEKLY,
28
- ),
29
- array(
30
- 'label' => Mage::helper('cron')->__('Monthly'),
31
- 'value' => self::CRON_MONTHLY,
32
- ),
33
- );
34
- }
35
- return self::$_options;
36
- }
37
-
38
-
39
-
40
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Dotdigitalgroup/Email/Model/System/Config/Source/Timeperiod.php DELETED
@@ -1,13 +0,0 @@
1
- <?php
2
-
3
- class Dotdigitalgroup_Email_Model_System_Config_Source_Timeperiod
4
- {
5
- public function toOptionArray()
6
- {
7
- return array(
8
- array('value' => 'week', 'label' => Mage::helper('connector')->__('Week')),
9
- array('value' => 'month', 'label' => Mage::helper('connector')->__('Month')),
10
- array('value' => 'year', 'label' => Mage::helper('connector')->__('Year'))
11
- );
12
- }
13
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Dotdigitalgroup/Email/Test/Model/Product.php DELETED
@@ -1,18 +0,0 @@
1
- <?php
2
- class Dotdigitalgroup_Email_Test_Model_Product extends EcomDev_PHPUnit_Test_Case
3
- {
4
-
5
- public function testIfTheAnswerToTheUniverseIs42()
6
- {
7
-
8
- $productModel = Mage::getModel('catalog/product')->load(39);
9
-
10
-
11
- $price = $productModel->getPrice();
12
-
13
- $this->assertEquals('20', $price);
14
-
15
-
16
-
17
- }
18
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Dotdigitalgroup/Email/controllers/Adminhtml/DebugController.php DELETED
@@ -1,125 +0,0 @@
1
- <?php
2
-
3
- class Dotdigitalgroup_Email_Adminhtml_DebugController extends Mage_Adminhtml_Controller_Action
4
- {
5
-
6
- public function forcecustomersyncAction()
7
- {
8
- $result = Mage::getModel('connector/customer_customer')->sync();
9
-
10
- if ($result['error']) {
11
- Mage::getSingleton('adminhtml/session')->addError($result['message']);
12
- }else {
13
- Mage::getSingleton('adminhtml/session')->addSuccess($result['message']);
14
- }
15
- $this->_redirectReferer();
16
- }
17
-
18
- public function forcelostbasketsyncAction()
19
- {
20
-
21
- $result = Mage::getModel('connector/sales_quote')->forceProccess();
22
-
23
- if ($result['errors'])
24
- Mage::getSingleton('adminhtml/session')->addError($result['message']);
25
- else
26
- Mage::getSingleton('adminhtml/session')->addSuccess($result['message']);
27
-
28
- $this->_redirectReferer();
29
- }
30
-
31
- public function forcesuppressedAction()
32
- {
33
- // forse sync
34
- $result = Mage::getModel('connector/customer_suppressed')->unsubscribe(true);
35
-
36
- if($result['errors']){
37
- Mage::getSingleton('adminhtml/session')->addError($result['message']);
38
- }else{
39
-
40
- if($result['customers'] > 0)
41
- Mage::getSingleton('adminhtml/session')->addSuccess('Customers Unsubscribed : ' . $result['customers']);
42
- else
43
- Mage::getSingleton('adminhtml/session')->addSuccess('Done.');
44
- }
45
-
46
- $this->_redirectReferer();
47
- }
48
-
49
- public function testCredentialsAction()
50
- {
51
- /**
52
- * Test account API
53
- */
54
- $testResult = Mage::getModel('connector/account_test')->test();
55
-
56
- if($testResult['errors']){
57
- Mage::getSingleton('adminhtml/session')->addError($testResult['message']);
58
- }else{
59
- Mage::getSingleton('adminhtml/session')->addSuccess('API Credentials Valid.');
60
- }
61
- $this->_redirectReferer();
62
- }
63
- public function transactionalSyncAction()
64
- {
65
-
66
- Mage::register('force_transactional', true);
67
- $initialSync = Mage::getModel('connector/sales_order')->sync();
68
-
69
- if ($initialSync['errors'])
70
- Mage::getSingleton('adminhtml/session')->addError($initialSync['message']);
71
- else
72
- Mage::getSingleton('adminhtml/session')->addSuccess($initialSync['message']);
73
-
74
- $this->_redirectReferer();
75
- }
76
- public function deletecontactsidAction()
77
- {
78
- Mage::register('first_time_sync', true);
79
- $customerModel = new Dotdigitalgroup_Email_Model_Customer_Customer();
80
- $customers = $customerModel->getContactsCustomers();
81
- $numUpdated = 0;
82
- if($customers->getSize()){
83
- foreach ($customers as $one){
84
- try{
85
- $customer = Mage::getModel('customer/customer')->load($one->getId());
86
- $customer->setData('dotmailer_contact_id', null);
87
- $customer->save();
88
- }catch(Exception $e){
89
- Mage::helper('connector')->log($e->getMessage(), null, 'api.log');
90
- }
91
- $numUpdated++;
92
- }
93
- }
94
- Mage::unregister('first_time_sync');
95
- if($numUpdated);
96
- Mage::getModel('adminhtml/session')->addSuccess('Number Of Contacts Id Removed :'. $numUpdated);
97
- $this->_redirectReferer();
98
- }
99
-
100
- public function countcontactsAction()
101
- {
102
- $customer = new Dotdigitalgroup_Email_Model_Customer_Customer();
103
- $contacts = $customer->getContactsCustomers();
104
- $total = $customer->getTotalNumberCustomers();
105
- $numMissing = $contacts->getSize();
106
-
107
- Mage::getModel('adminhtml/session')->addSuccess('Customers No: ' . $total . ', With Contact Id No: ' . $numMissing);
108
- $this->_redirectReferer();
109
- }
110
-
111
- public function ajaxvalidationAction()
112
- {
113
- $result = 'Validation failed!';
114
- $api_user = $this->getRequest()->getParam('api_user');
115
- $api_password = $this->getRequest()->getParam('api_password');
116
- $testResult = Mage::getModel('connector/account_test')->test($api_user, $api_password);
117
- if($testResult['errors'] == false){
118
- $result = 'Valid';
119
- }
120
-
121
- $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
122
- }
123
-
124
-
125
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Dotdigitalgroup/Email/controllers/EmailController.php DELETED
@@ -1,133 +0,0 @@
1
- <?php
2
-
3
- class Dotdigitalgroup_Email_EmailController extends Mage_Core_Controller_Front_Action
4
- {
5
- public function indexAction()
6
- {
7
- //Get current layout state
8
- $this->loadLayout();
9
-
10
- $this->renderLayout();
11
- }
12
-
13
-
14
- /**
15
- * Params
16
- * code - security check
17
- * order - order id
18
- * products type :
19
- * 1.related
20
- * 2.upsell
21
- * 3.cross sell
22
- * 4.best sellers
23
- * 5.most viewed
24
- * 6.recently viewed
25
- *
26
- */
27
- public function productsAction()
28
- {
29
- //get all params
30
- $params = $this->getRequest()->getParams();
31
-
32
- if(!isset($params['code']) || !isset($params['mode'])){
33
-
34
- exit();
35
- }
36
- //authenticate before proceed
37
- Mage::helper('connector')->auth($params['code']);
38
- Mage::register('mode', $params['mode']);
39
- if(isset($params['customer']))
40
- Mage::register('customer', $params['customer']);
41
- $this->loadLayout();
42
- $this->renderLayout();
43
-
44
- }
45
-
46
- public function couponAction()
47
- {
48
- $this->loadLayout();
49
- $this->renderLayout();
50
- }
51
- public function basketAction()
52
- {
53
- $this->loadLayout();
54
- $this->renderLayout();
55
- }
56
-
57
- public function logAction()
58
- {
59
- //@todo allow from these Ips
60
- $allowedIps = array(
61
-
62
- );
63
-
64
- //file name param
65
- $file = $this->getRequest()->getParam('file');
66
- $fileName = $file . '.log';
67
- $filePath = Mage::getBaseDir('log') . DIRECTORY_SEPARATOR . $fileName;
68
-
69
- $this->_prepareDownloadResponse($fileName, array(
70
- 'type' => 'filename',
71
- 'value' => $filePath
72
- ));
73
- exit();
74
-
75
- }
76
-
77
- public function resetimportedorderdataAction()
78
- {
79
- $orderCollection = Mage::getResourceModel('sales/order_collection');
80
- foreach ($orderCollection as $one) {
81
-
82
- try{
83
-
84
- $one->setData('dotmailer_order_imported', null);
85
- $one->save();
86
- }catch(Exception $e){
87
- Mage::logException($e);
88
- }
89
- }
90
-
91
- }
92
-
93
- public function saveMissingIdCustomerAction()
94
- {
95
- $customer = Mage::getModel('connector/customer_customer')->getMissingContacts();
96
- $helper = Mage::helper('connector');
97
- $helper->log('number of miss ids : ' . count($customer));
98
- foreach ($customer as $one) {
99
- try{
100
- $helper->log($one->getEmail());
101
- $one->save();
102
- }catch(Exception $e){
103
- $helper->log($e->getMessage());
104
-
105
- }
106
-
107
- }
108
-
109
- }
110
-
111
- public function importAllTransactionalDataAction()
112
- {
113
- $orderCollection = Mage::getModel('sales/order')->getCollection();
114
- $helper = Mage::helper('connector');
115
- $helper->log('import all transactional data : ' . $orderCollection->getSize());
116
- foreach($orderCollection as $one){
117
-
118
- $order = Mage::getModel('connector/connector_order', $one);
119
- if($order->connector_id)
120
- $orders[] = $order;
121
- }
122
- $helper->log('orders created : ' . count($orders));
123
- $rest = Mage::getModel('connector/api_rest');
124
-
125
- try{
126
- $result = $rest->sendMultiTransactionalData($orders, 'Order');
127
- $helper->log($result);
128
- }catch(Exception $e){
129
- $helper->log($e->getMessage());
130
- }
131
-
132
- }
133
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Dotdigitalgroup/Email/etc/adminhtml.xml DELETED
@@ -1,43 +0,0 @@
1
- <?xml version="1.0"?>
2
- <config>
3
- <acl>
4
- <resources>
5
- <admin>
6
- <children>
7
- <system>
8
- <children>
9
- <config>
10
- <children>
11
- <connector_api_settings translate="title">
12
- <title><![CDATA[API Credentials]]></title>
13
- </connector_api_settings>
14
- <connector_sync_settings translate="title">
15
- <title><![CDATA[Sync Settings]]></title>
16
- </connector_sync_settings>
17
- <connector_data_field_settings translate="title">
18
- <title><![CDATA[Data Field Mapping]]></title>
19
- </connector_data_field_settings>
20
- <connector_roi_page_tracking_settings translate="title">
21
- <title><![CDATA[ROI & Tracking]]></title>
22
- </connector_roi_page_tracking_settings>
23
- <lost_basket_settings translate="title">
24
- <title><![CDATA[Lost Baskets]]></title>
25
- </lost_basket_settings>
26
- <sms_section translate="title">
27
- <title><![CDATA[SMS Section]]></title>
28
- </sms_section>
29
- <dynamic_content translate="label">
30
- <title><![CDATA[Dynamic Content]]></title>
31
- </dynamic_content>
32
- <connector_advanced_settings translate="title">
33
- <title><![CDATA[Advanced Settings]]></title>
34
- </connector_advanced_settings>
35
- </children>
36
- </config>
37
- </children>
38
- </system>
39
- </children>
40
- </admin>
41
- </resources>
42
- </acl>
43
- </config>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Dotdigitalgroup/Email/etc/config.xml DELETED
@@ -1,289 +0,0 @@
1
- <?xml version="1.0"?>
2
- <config>
3
-
4
- <modules>
5
- <Dotdigitalgroup_Email>
6
- <version>1.5.1</version>
7
- </Dotdigitalgroup_Email>
8
- </modules>
9
- <frontend>
10
- <routers>
11
- <connector>
12
- <use>standard</use>
13
- <args>
14
- <module>Dotdigitalgroup_Email</module>
15
- <frontName>connector</frontName>
16
- </args>
17
- </connector>
18
- </routers>
19
- <layout>
20
- <updates>
21
- <connector>
22
- <file>connector.xml</file>
23
- </connector>
24
- </updates>
25
- </layout>
26
- </frontend>
27
- <global>
28
- <models>
29
- <connector>
30
- <class>Dotdigitalgroup_Email_Model</class>
31
- </connector>
32
- <sales>
33
- <rewrite>
34
- <order>Dotdigitalgroup_Email_Model_Order</order>
35
- </rewrite>
36
- </sales>
37
- </models>
38
- <helpers>
39
- <connector>
40
- <class>Dotdigitalgroup_Email_Helper</class>
41
- </connector>
42
- </helpers>
43
- <blocks>
44
- <connector>
45
- <class>Dotdigitalgroup_Email_Block</class>
46
- </connector>
47
- </blocks>
48
-
49
- <resources>
50
- <connector_setup>
51
- <setup>
52
- <module>Dotdigitalgroup_Email</module>
53
- <class>Mage_Sales_Model_Mysql4_Setup</class>
54
- </setup>
55
- <connection>
56
- <use>core_setup</use>
57
- </connection>
58
- </connector_setup>
59
- <customer_write>
60
- <connection>
61
- <use>core_write</use>
62
- </connection>
63
- </customer_write>
64
- <customer_read>
65
- <connection>
66
- <use>core_read</use>
67
- </connection>
68
- </customer_read>
69
- </resources>
70
- <events>
71
- <customer_save_before>
72
- <observers>
73
- <contactid>
74
- <class>Dotdigitalgroup_Email_Model_Observer</class>
75
- <method>handleCustomerSaveBefore</method>
76
- </contactid>
77
- </observers>
78
- </customer_save_before>
79
- <sales_order_save_after>
80
- <observers>
81
- <connector_checkout_type_onepage_save_order_after>
82
- <class>Dotdigitalgroup_Email_Model_Observer</class>
83
- <method>handleSalesOrderSaveAfter</method>
84
- </connector_checkout_type_onepage_save_order_after>
85
- </observers>
86
- </sales_order_save_after>
87
- <sales_quote_save_after>
88
- <observers>
89
- <connector_quote_save_after>
90
- <type>singleton</type>
91
- <class>Dotdigitalgroup_Email_Model_Observer</class>
92
- <method>handleSalesQuoteSaveAfter</method>
93
- </connector_quote_save_after>
94
- </observers>
95
- </sales_quote_save_after>
96
- <sales_order_creditmemo_save_after>
97
- <observers>
98
- <connector_sales_order_payment_refund>
99
- <class>Dotdigitalgroup_Email_Model_Observer</class>
100
- <method>handleSalesOrderRefund</method>
101
- </connector_sales_order_payment_refund>
102
- </observers>
103
- </sales_order_creditmemo_save_after>
104
- <order_cancel_after>
105
- <observers>
106
- <connector_sales_order_cancel>
107
- <class>Dotdigitalgroup_Email_Model_Observer</class>
108
- <method>hangleSalesOrderCancel</method>
109
- </connector_sales_order_cancel>
110
- </observers>
111
- </order_cancel_after>
112
-
113
- <sales_order_status_after>
114
- <observers>
115
- <connector_sales_order_status_change>
116
- <class>Dotdigitalgroup_Email_Model_Observer</class>
117
- <method>handleSalesOrderStatusChange</method>
118
- </connector_sales_order_status_change>
119
- </observers>
120
- </sales_order_status_after>
121
- </events>
122
- </global>
123
-
124
- <adminhtml>
125
- <layout>
126
- <updates>
127
- <connector>
128
- <file>connector.xml</file>
129
- </connector>
130
- </updates>
131
- </layout>
132
- </adminhtml>
133
-
134
-
135
- <admin>
136
- <routers>
137
- <connector>
138
- <use>admin</use>
139
- <args>
140
- <modules>
141
- <connector before="Mage_Adminhtml">Dotdigitalgroup_Email_Adminhtml</connector>
142
- </modules>
143
- <module>Dotdigitalgroup_Email_Adminhtml</module>
144
- <frontName>connector</frontName>
145
- </args>
146
- </connector>
147
- </routers>
148
- </admin>
149
-
150
- <crontab>
151
- <jobs>
152
- <dotdigitalgroup_email_customer_sync>
153
- <run><model>connector/cron::customersync</model></run>
154
- <schedule>
155
- <config_path>connector_sync_settings/sync_customer_schedule/cronschedule</config_path>
156
- </schedule>
157
- </dotdigitalgroup_email_customer_sync>
158
- <dotdigitalgroup_email_lostbaskets_sync>
159
- <run><model>connector/cron::lostbasketssync</model></run>
160
- <schedule>
161
- <cron_expr>*/5 * * * *</cron_expr>
162
- </schedule>
163
- </dotdigitalgroup_email_lostbaskets_sync>
164
- <dotdigitalgroup_email_suppressed_sync>
165
- <run><model>connector/cron::suppressedsync</model></run>
166
- <schedule>
167
- <config_path>connector_sync_settings/sync_suppressed_schedule/cronschedulesupp</config_path>
168
- </schedule>
169
- </dotdigitalgroup_email_suppressed_sync>
170
- <dotdigitalgroup_email_cleaner>
171
- <run><model>connector/cron::cleaning</model></run>
172
- <schedule>
173
- <cron_expr>0 0 1 * * </cron_expr>
174
- </schedule>
175
- </dotdigitalgroup_email_cleaner>
176
- </jobs>
177
- </crontab>
178
- <default>
179
- <connector_api_settings>
180
- <api_credentials>
181
- <username></username>
182
- <password></password>
183
- </api_credentials>
184
- </connector_api_settings>
185
- <connector_sync_settings>
186
- <sync_customer_schedule>
187
- <enabled>0</enabled>
188
- <cronschedule></cronschedule>
189
- </sync_customer_schedule>
190
- <sync_suppressed_schedule>
191
- <enabled>0</enabled>
192
- <cronschedulesupp></cronschedulesupp>
193
- </sync_suppressed_schedule>
194
- <transactional_data>
195
- <enabled>0</enabled>
196
- </transactional_data>
197
- </connector_sync_settings>
198
- <connector_data_field_settings>
199
- <customer_data>
200
- <firstname></firstname>
201
- <lastname></lastname>
202
- <dob></dob>
203
- <gender></gender>
204
- <website_created_on></website_created_on>
205
- <store_created_on></store_created_on>
206
- <account_created></account_created>
207
- <last_logged_in></last_logged_in>
208
- <customer_group></customer_group>
209
- </customer_data>
210
- <customer_address>
211
- <billing_address_1></billing_address_1>
212
- <billing_address_2></billing_address_2>
213
- <billing_city></billing_city>
214
- <billing_country></billing_country>
215
- <billing_postcode></billing_postcode>
216
- <billing_telephone></billing_telephone>
217
- <delivery_address_1></delivery_address_1>
218
- <delivery_address_2></delivery_address_2>
219
- <delivery_city></delivery_city>
220
- <delivery_country></delivery_country>
221
- <delivery_postcode></delivery_postcode>
222
- <delivery_telephone></delivery_telephone>
223
- </customer_address>
224
- <customer_sales>
225
- <total_orders></total_orders>
226
- <average_order_value></average_order_value>
227
- <total_spend></total_spend>
228
- </customer_sales>
229
- </connector_data_field_settings>
230
-
231
- <connector_roi_page_tracking_settings>
232
- <page_tracking>
233
- <enabled></enabled>
234
- </page_tracking>
235
- <roi_tracking>
236
- <enabled></enabled>
237
- </roi_tracking>
238
- </connector_roi_page_tracking_settings>
239
- <connector_newsletter_subscription_settings>
240
- <customers_subscription_management>
241
- <default></default>
242
- </customers_subscription_management>
243
- <subscribers_subscription_management>
244
- <default></default>
245
- </subscribers_subscription_management>
246
- </connector_newsletter_subscription_settings>
247
- <lost_basket_settings>
248
- <customers>
249
- <enabled_1></enabled_1>
250
- <send_after_1></send_after_1>
251
- <campaign_1></campaign_1>
252
- <enabled_2></enabled_2>
253
- <send_after_2></send_after_2>
254
- <campaign_2></campaign_2>
255
- <enabled_3></enabled_3>
256
- <send_after_3></send_after_3>
257
- <campaign_3></campaign_3>
258
- </customers>
259
- <guests>
260
- <enabled_1></enabled_1>
261
- <send_after_1></send_after_1>
262
- <campaign_1></campaign_1>
263
- <enabled_2></enabled_2>
264
- <send_after_2></send_after_2>
265
- <campaign_2></campaign_2>
266
- <enabled_3></enabled_3>
267
- <send_after_3></send_after_3>
268
- <campaign_3></campaign_3>
269
- </guests>
270
- </lost_basket_settings>
271
- <connector_advanced_settings>
272
- <sync_limits>
273
- <contact>500</contact>
274
- <orders>500</orders>
275
- </sync_limits>
276
- <admin>
277
- <memory_limit></memory_limit>
278
- <batch_size>5000</batch_size>
279
- </admin>
280
- </connector_advanced_settings>
281
- </default>
282
- <phpunit>
283
- <suite>
284
- <modules>
285
- <Dotdigitalgroup_Email />
286
- </modules>
287
- </suite>
288
- </phpunit>
289
- </config>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Dotdigitalgroup/Email/etc/system.xml DELETED
@@ -1,1610 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <config>
3
- <tabs>
4
- <connector translate="label">
5
- <label>EMAIL</label>
6
- <sort_order>1000</sort_order>
7
- </connector>
8
- </tabs>
9
- <sections>
10
- <connector_api_settings translate="label">
11
- <label><![CDATA[API Credentials]]></label>
12
- <tab>connector</tab>
13
- <frontend_type>text</frontend_type>
14
- <sort_order>1000</sort_order>
15
- <show_in_default>1</show_in_default>
16
- <show_in_website>1</show_in_website>
17
- <show_in_store>0</show_in_store>
18
- <groups>
19
- <api_credentials>
20
- <label>API Settings</label>
21
- <frontend_type>text</frontend_type>
22
- <sort_order>10</sort_order>
23
- <show_in_default>1</show_in_default>
24
- <show_in_website>1</show_in_website>
25
- <show_in_store>0</show_in_store>
26
- <expanded>1</expanded>
27
- <fields>
28
- <username>
29
- <label>API Username</label>
30
- <frontend_type>text</frontend_type>
31
- <frontend_model>connector/adminhtml_system_config_wrapper</frontend_model>
32
- <sort_order>10</sort_order>
33
- <show_in_default>1</show_in_default>
34
- <show_in_website>1</show_in_website>
35
- <show_in_store>0</show_in_store>
36
- <validate>validate-length minimum-length-36</validate>
37
- </username>
38
- <password>
39
- <label>API Password</label>
40
- <frontend_type>password</frontend_type>
41
- <frontend_model>connector/adminhtml_system_config_password</frontend_model>
42
- <sort_order>20</sort_order>
43
- <show_in_default>1</show_in_default>
44
- <show_in_website>1</show_in_website>
45
- <show_in_store>0</show_in_store>
46
- </password>
47
- <initialsync translate="label">
48
- <label>Test API Credentials</label>
49
- <frontend_model>connector/debug_testcredentials</frontend_model>
50
- <sort_order>30</sort_order>
51
- <show_in_default>1</show_in_default>
52
- <show_in_website>1</show_in_website>
53
- <show_in_store>0</show_in_store>
54
- <comment>*Please save your settings before clicking here! Use this button to test the account.</comment>
55
- </initialsync>
56
- <validator>
57
- <label></label>
58
- <frontend_type>hidden</frontend_type>
59
- <frontend_model>connector/adminhtml_system_config_waitingfield</frontend_model>
60
- <sort_order>50</sort_order>
61
- <show_in_default>1</show_in_default>
62
- <show_in_website>1</show_in_website>
63
- <show_in_store>0</show_in_store>
64
- <can_be_empty>1</can_be_empty>
65
- </validator>
66
- </fields>
67
- </api_credentials>
68
- </groups>
69
- </connector_api_settings>
70
- <connector_sync_settings translate="label">
71
- <!-- you can put anything inbetween the CDATA tags (including image tags) -->
72
- <label><![CDATA[Sync Settings]]></label>
73
- <!-- this relates to the value in tab -->
74
- <tab>connector</tab>
75
- <frontend_type>text</frontend_type>
76
- <sort_order>3000</sort_order>
77
- <show_in_default>1</show_in_default>
78
- <show_in_website>1</show_in_website>
79
- <show_in_store>0</show_in_store>
80
- <groups>
81
- <sync_customer_schedule>
82
- <label>Customer Data and Subscribers Sync Schedule</label>
83
- <frontend_type>text</frontend_type>
84
- <sort_order>10</sort_order>
85
- <show_in_default>1</show_in_default>
86
- <show_in_website>1</show_in_website>
87
- <show_in_store>0</show_in_store>
88
- <expanded>1</expanded>
89
- <fields>
90
- <enabled translate="label">
91
- <label>Enabled</label>
92
- <frontend_type>select</frontend_type>
93
- <source_model>adminhtml/system_config_source_yesno</source_model>
94
- <sort_order>10</sort_order>
95
- <show_in_default>1</show_in_default>
96
- <show_in_website>1</show_in_website>
97
- <show_in_store>0</show_in_store>
98
- </enabled>
99
- <time translate="label">
100
- <label>Start Time</label>
101
- <frontend_type>time</frontend_type>
102
- <backend_model>connector/system_config_backend_syncschedule_customer</backend_model>
103
- <sort_order>20</sort_order>
104
- <show_in_default>1</show_in_default>
105
- <show_in_website>0</show_in_website>
106
- <show_in_store>0</show_in_store>
107
- <depends><enabled>1</enabled></depends>
108
- </time>
109
- <frequency translate="label">
110
- <label>Frequency</label>
111
- <frontend_type>select</frontend_type>
112
- <source_model>connector/system_config_source_syncfrequency</source_model>
113
- <backend_model>connector/system_config_backend_syncschedule_customer</backend_model>
114
- <sort_order>30</sort_order>
115
- <show_in_default>1</show_in_default>
116
- <show_in_website>0</show_in_website>
117
- <show_in_store>0</show_in_store>
118
- <comment>Note: For Weekly and Monthly frequency, the day of the week/month will be today</comment>
119
- <depends><enabled>1</enabled></depends>
120
- </frequency>
121
- <force_sync translate="label">
122
- <label></label>
123
- <frontend_model>connector/debug_forcecustomersync</frontend_model>
124
- <sort_order>50</sort_order>
125
- <show_in_default>1</show_in_default>
126
- <show_in_website>0</show_in_website>
127
- <show_in_store>0</show_in_store>
128
- <comment>Use this button force the data synchronization to run now</comment>
129
- </force_sync>
130
- <validator>
131
- <label></label>
132
- <frontend_type>hidden</frontend_type>
133
- <frontend_model>connector/adminhtml_system_config_waitingfield</frontend_model>
134
- <sort_order>60</sort_order>
135
- <show_in_default>1</show_in_default>
136
- <show_in_website>0</show_in_website>
137
- <show_in_store>0</show_in_store>
138
- <can_be_empty>1</can_be_empty>
139
- </validator>
140
- </fields>
141
- </sync_customer_schedule>
142
- <sync_suppressed_schedule>
143
- <label>Suppressed Data Sync Schedule</label>
144
- <frontend_type>text</frontend_type>
145
- <sort_order>20</sort_order>
146
- <show_in_default>1</show_in_default>
147
- <show_in_website>1</show_in_website>
148
- <show_in_store>0</show_in_store>
149
- <expanded>1</expanded>
150
- <fields>
151
- <enabled translate="label">
152
- <label>Enabled</label>
153
- <frontend_type>select</frontend_type>
154
- <source_model>adminhtml/system_config_source_yesno</source_model>
155
- <sort_order>2</sort_order>
156
- <show_in_default>1</show_in_default>
157
- <show_in_website>1</show_in_website>
158
- <show_in_store>0</show_in_store>
159
- </enabled>
160
- <time translate="label">
161
- <label>Start Time</label>
162
- <frontend_type>time</frontend_type>
163
- <backend_model>connector/system_config_backend_syncschedule_suppressed</backend_model>
164
- <sort_order>3</sort_order>
165
- <show_in_default>1</show_in_default>
166
- <show_in_website>0</show_in_website>
167
- <show_in_store>0</show_in_store>
168
- <depends><enabled>1</enabled></depends>
169
- </time>
170
- <frequency translate="label">
171
- <label>Frequency</label>
172
- <frontend_type>select</frontend_type>
173
- <source_model>connector/system_config_source_syncfrequency</source_model>
174
- <backend_model>connector/system_config_backend_syncschedule_suppressed</backend_model>
175
- <sort_order>4</sort_order>
176
- <show_in_default>1</show_in_default>
177
- <show_in_website>0</show_in_website>
178
- <show_in_store>0</show_in_store>
179
- <comment>Note: For Weekly and Monthly frequency, the day of the week/month will be today</comment>
180
- <depends><enabled>1</enabled></depends>
181
- </frequency>
182
- <force_sync translate="label">
183
- <label></label>
184
- <frontend_model>connector/debug_forcesuppressedsync</frontend_model>
185
- <sort_order>20</sort_order>
186
- <show_in_default>1</show_in_default>
187
- <show_in_website>0</show_in_website>
188
- <show_in_store>0</show_in_store>
189
- <comment>Use this button force the suppressed data synchronization to run now</comment>
190
- </force_sync>
191
- </fields>
192
- </sync_suppressed_schedule>
193
- <transactional_data translate="label">
194
- <label><![CDATA[ Transactional data settings]]></label>
195
- <frontend_type>text</frontend_type>
196
- <sort_order>30</sort_order>
197
- <show_in_default>1</show_in_default>
198
- <show_in_website>1</show_in_website>
199
- <show_in_store>0</show_in_store>
200
- <fields>
201
- <order_info_title translate="label">
202
- <label>Order/Basket Information</label>
203
- <frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
204
- <sort_order>10</sort_order>
205
- <show_in_default>1</show_in_default>
206
- <show_in_website>1</show_in_website>
207
- <show_in_store>0</show_in_store>
208
- </order_info_title>
209
- <order_enabled translate="label">
210
- <label>Enabled</label>
211
- <frontend_type>select</frontend_type>
212
- <source_model>adminhtml/system_config_source_yesno</source_model>
213
- <sort_order>20</sort_order>
214
- <show_in_default>1</show_in_default>
215
- <show_in_website>1</show_in_website>
216
- <show_in_store>0</show_in_store>
217
- </order_enabled>
218
- <wishlist_tile translate="label">
219
- <label>Wish List Information</label>
220
- <frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
221
- <sort_order>30</sort_order>
222
- <show_in_default>1</show_in_default>
223
- <show_in_website>1</show_in_website>
224
- <show_in_store>0</show_in_store>
225
- </wishlist_tile>
226
- <wishlist_enabled translate="label">
227
- <label>Enabled</label>
228
- <frontend_type>select</frontend_type>
229
- <source_model>adminhtml/system_config_source_yesno</source_model>
230
- <sort_order>40</sort_order>
231
- <show_in_default>1</show_in_default>
232
- <show_in_website>1</show_in_website>
233
- <show_in_store>0</show_in_store>
234
- </wishlist_enabled>
235
- </fields>
236
- </transactional_data>
237
- </groups>
238
- </connector_sync_settings>
239
- <connector_data_field_settings translate="label">
240
- <label><![CDATA[Data Mapping]]></label>
241
- <tab>connector</tab>
242
- <frontend_type>text</frontend_type>
243
- <sort_order>2000</sort_order>
244
- <show_in_default>1</show_in_default>
245
- <show_in_website>1</show_in_website>
246
- <show_in_store>0</show_in_store>
247
- <groups>
248
- <customer_data>
249
- <label>Data Field Mapping</label>
250
- <frontend_type>text</frontend_type>
251
- <sort_order>20</sort_order>
252
- <show_in_default>1</show_in_default>
253
- <show_in_website>1</show_in_website>
254
- <show_in_store>0</show_in_store>
255
- <expanded>1</expanded>
256
- <fields>
257
- <customer_title translate="label">
258
- <label>Customer Information</label>
259
- <frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
260
- <sort_order>10</sort_order>
261
- <show_in_default>1</show_in_default>
262
- <show_in_website>1</show_in_website>
263
- <show_in_store>0</show_in_store>
264
- </customer_title>
265
-
266
- <customer_id translate="label">
267
- <label>Customer ID</label>
268
- <frontend_type>select</frontend_type>
269
- <source_model>connector/system_config_source_datafields</source_model>
270
- <sort_order>20</sort_order>
271
- <show_in_default>1</show_in_default>
272
- <show_in_website>1</show_in_website>
273
- <show_in_store>0</show_in_store>
274
- <comment>Please map the customer id, if you want to use the dynamic content.</comment>
275
- </customer_id>
276
- <title>
277
- <label>Title</label>
278
- <frontend_type>select</frontend_type>
279
- <source_model>connector/system_config_source_datafields</source_model>
280
- <sort_order>30</sort_order>
281
- <show_in_default>1</show_in_default>
282
- <show_in_website>1</show_in_website>
283
- <show_in_store>0</show_in_store>
284
- </title>
285
-
286
- <firstname>
287
- <label>First Name</label>
288
- <frontend_type>select</frontend_type>
289
- <source_model>connector/system_config_source_datafields</source_model>
290
- <sort_order>40</sort_order>
291
- <show_in_default>1</show_in_default>
292
- <show_in_website>1</show_in_website>
293
- <show_in_store>0</show_in_store>
294
- </firstname>
295
- <lastname>
296
- <label>Last Name</label>
297
- <frontend_type>select</frontend_type>
298
- <source_model>connector/system_config_source_datafields</source_model>
299
- <sort_order>50</sort_order>
300
- <show_in_default>1</show_in_default>
301
- <show_in_website>1</show_in_website>
302
- <show_in_store>0</show_in_store>
303
- </lastname>
304
- <dob>
305
- <label>D.O.B.</label>
306
- <frontend_type>select</frontend_type>
307
- <source_model>connector/system_config_source_datafields</source_model>
308
- <sort_order>60</sort_order>
309
- <show_in_default>1</show_in_default>
310
- <show_in_website>1</show_in_website>
311
- <show_in_store>0</show_in_store>
312
- </dob>
313
- <gender>
314
- <label>Gender</label>
315
- <frontend_type>select</frontend_type>
316
- <source_model>connector/system_config_source_datafields</source_model>
317
- <sort_order>70</sort_order>
318
- <show_in_default>1</show_in_default>
319
- <show_in_website>1</show_in_website>
320
- <show_in_store>0</show_in_store>
321
- </gender>
322
- <website_created_on>
323
- <label>Website Created On</label>
324
- <frontend_type>select</frontend_type>
325
- <source_model>connector/system_config_source_datafields</source_model>
326
- <sort_order>80</sort_order>
327
- <show_in_default>1</show_in_default>
328
- <show_in_website>1</show_in_website>
329
- <show_in_store>0</show_in_store>
330
- </website_created_on>
331
- <store_created_on>
332
- <label>Store Created On</label>
333
- <frontend_type>select</frontend_type>
334
- <source_model>connector/system_config_source_datafields</source_model>
335
- <sort_order>90</sort_order>
336
- <show_in_default>1</show_in_default>
337
- <show_in_website>1</show_in_website>
338
- <show_in_store>0</show_in_store>
339
- </store_created_on>
340
- <account_created>
341
- <label>Account Created Date</label>
342
- <frontend_type>select</frontend_type>
343
- <source_model>connector/system_config_source_datafields</source_model>
344
- <sort_order>100</sort_order>
345
- <show_in_default>1</show_in_default>
346
- <show_in_website>1</show_in_website>
347
- <show_in_store>0</show_in_store>
348
- </account_created>
349
- <last_logged_in>
350
- <label>Last Logged In Date</label>
351
- <frontend_type>select</frontend_type>
352
- <source_model>connector/system_config_source_datafields</source_model>
353
- <sort_order>110</sort_order>
354
- <show_in_default>1</show_in_default>
355
- <show_in_website>1</show_in_website>
356
- <show_in_store>0</show_in_store>
357
- </last_logged_in>
358
- <customer_group>
359
- <label>Customer Group</label>
360
- <frontend_type>select</frontend_type>
361
- <source_model>connector/system_config_source_datafields</source_model>
362
- <sort_order>120</sort_order>
363
- <show_in_default>1</show_in_default>
364
- <show_in_website>1</show_in_website>
365
- <show_in_store>0</show_in_store>
366
- </customer_group>
367
- <address_title translate="label">
368
- <label>Address Information</label>
369
- <frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
370
- <sort_order>130</sort_order>
371
- <show_in_default>1</show_in_default>
372
- <show_in_website>1</show_in_website>
373
- <show_in_store>0</show_in_store>
374
- </address_title>
375
- <billing_address_1>
376
- <label>Billing Address Line 1</label>
377
- <frontend_type>select</frontend_type>
378
- <source_model>connector/system_config_source_datafields</source_model>
379
- <sort_order>140</sort_order>
380
- <show_in_default>1</show_in_default>
381
- <show_in_website>1</show_in_website>
382
- <show_in_store>0</show_in_store>
383
- </billing_address_1>
384
- <billing_address_2>
385
- <label>Billing Address Line 2</label>
386
- <frontend_type>select</frontend_type>
387
- <source_model>connector/system_config_source_datafields</source_model>
388
- <sort_order>150</sort_order>
389
- <show_in_default>1</show_in_default>
390
- <show_in_website>1</show_in_website>
391
- <show_in_store>0</show_in_store>
392
- </billing_address_2>
393
- <billing_city>
394
- <label>Billing City</label>
395
- <frontend_type>select</frontend_type>
396
- <source_model>connector/system_config_source_datafields</source_model>
397
- <sort_order>160</sort_order>
398
- <show_in_default>1</show_in_default>
399
- <show_in_website>1</show_in_website>
400
- <show_in_store>0</show_in_store>
401
- </billing_city>
402
- <billing_country>
403
- <label>Billing Country</label>
404
- <frontend_type>select</frontend_type>
405
- <source_model>connector/system_config_source_datafields</source_model>
406
- <sort_order>170</sort_order>
407
- <show_in_default>1</show_in_default>
408
- <show_in_website>1</show_in_website>
409
- <show_in_store>0</show_in_store>
410
- </billing_country>
411
- <billing_postcode>
412
- <label>Billing Zip/Postcode</label>
413
- <frontend_type>select</frontend_type>
414
- <source_model>connector/system_config_source_datafields</source_model>
415
- <sort_order>180</sort_order>
416
- <show_in_default>1</show_in_default>
417
- <show_in_website>1</show_in_website>
418
- <show_in_store>0</show_in_store>
419
- </billing_postcode>
420
- <billing_telephone>
421
- <label>Billing Telephone</label>
422
- <frontend_type>select</frontend_type>
423
- <source_model>connector/system_config_source_datafields</source_model>
424
- <sort_order>190</sort_order>
425
- <show_in_default>1</show_in_default>
426
- <show_in_website>1</show_in_website>
427
- <show_in_store>0</show_in_store>
428
- </billing_telephone>
429
- <delivery_address_1>
430
- <label>Delivery Address Line 1</label>
431
- <frontend_type>select</frontend_type>
432
- <source_model>connector/system_config_source_datafields</source_model>
433
- <sort_order>200</sort_order>
434
- <show_in_default>1</show_in_default>
435
- <show_in_website>1</show_in_website>
436
- <show_in_store>0</show_in_store>
437
- </delivery_address_1>
438
- <delivery_address_2>
439
- <label>Delivery Address Line 2</label>
440
- <frontend_type>select</frontend_type>
441
- <source_model>connector/system_config_source_datafields</source_model>
442
- <sort_order>210</sort_order>
443
- <show_in_default>1</show_in_default>
444
- <show_in_website>1</show_in_website>
445
- <show_in_store>0</show_in_store>
446
- </delivery_address_2>
447
- <delivery_city>
448
- <label>Delivery City</label>
449
- <frontend_type>select</frontend_type>
450
- <source_model>connector/system_config_source_datafields</source_model>
451
- <sort_order>220</sort_order>
452
- <show_in_default>1</show_in_default>
453
- <show_in_website>1</show_in_website>
454
- <show_in_store>0</show_in_store>
455
- </delivery_city>
456
- <delivery_country>
457
- <label>Delivery Country</label>
458
- <frontend_type>select</frontend_type>
459
- <source_model>connector/system_config_source_datafields</source_model>
460
- <sort_order>230</sort_order>
461
- <show_in_default>1</show_in_default>
462
- <show_in_website>1</show_in_website>
463
- <show_in_store>0</show_in_store>
464
- </delivery_country>
465
- <delivery_postcode>
466
- <label>Delivery Zip/Postcode</label>
467
- <frontend_type>select</frontend_type>
468
- <source_model>connector/system_config_source_datafields</source_model>
469
- <sort_order>240</sort_order>
470
- <show_in_default>1</show_in_default>
471
- <show_in_website>1</show_in_website>
472
- <show_in_store>0</show_in_store>
473
- </delivery_postcode>
474
- <delivery_telephone>
475
- <label>Delivery Telephone</label>
476
- <frontend_type>select</frontend_type>
477
- <source_model>connector/system_config_source_datafields</source_model>
478
- <sort_order>250</sort_order>
479
- <show_in_default>1</show_in_default>
480
- <show_in_website>1</show_in_website>
481
- <show_in_store>0</show_in_store>
482
- </delivery_telephone>
483
- <sales_title translate="label">
484
- <label>Sales Information</label>
485
- <frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
486
- <sort_order>260</sort_order>
487
- <show_in_default>1</show_in_default>
488
- <show_in_website>1</show_in_website>
489
- <show_in_store>0</show_in_store>
490
- </sales_title>
491
- <total_orders>
492
- <label>Total Number of Orders</label>
493
- <frontend_type>select</frontend_type>
494
- <source_model>connector/system_config_source_datafields</source_model>
495
- <sort_order>270</sort_order>
496
- <show_in_default>1</show_in_default>
497
- <show_in_website>1</show_in_website>
498
- <show_in_store>0</show_in_store>
499
- </total_orders>
500
- <average_order_value>
501
- <label>Average Order Value</label>
502
- <frontend_type>select</frontend_type>
503
- <source_model>connector/system_config_source_datafields</source_model>
504
- <sort_order>280</sort_order>
505
- <show_in_default>1</show_in_default>
506
- <show_in_website>1</show_in_website>
507
- <show_in_store>0</show_in_store>
508
- </average_order_value>
509
- <total_spend>
510
- <label>Total Spend</label>
511
- <frontend_type>select</frontend_type>
512
- <source_model>connector/system_config_source_datafields</source_model>
513
- <sort_order>290</sort_order>
514
- <show_in_default>1</show_in_default>
515
- <show_in_website>1</show_in_website>
516
- <show_in_store>0</show_in_store>
517
- </total_spend>
518
- <last_order translate="label">
519
- <label>Last Purchase Date</label>
520
- <frontend_type>select</frontend_type>
521
- <source_model>connector/system_config_source_datafields</source_model>
522
- <sort_order>300</sort_order>
523
- <show_in_default>1</show_in_default>
524
- <show_in_website>1</show_in_website>
525
- <show_in_store>0</show_in_store>
526
- </last_order>
527
- <last_order_no translate="label">
528
- <label>Last Order No</label>
529
- <frontend_type>select</frontend_type>
530
- <source_model>connector/system_config_source_datafields</source_model>
531
- <sort_order>310</sort_order>
532
- <show_in_default>1</show_in_default>
533
- <show_in_website>1</show_in_website>
534
- <show_in_store>0</show_in_store>
535
- </last_order_no>
536
- <validator>
537
- <label>Validation Block</label>
538
- <frontend_type>select</frontend_type>
539
- <source_model>connector/system_config_source_datafields</source_model>
540
- <frontend_model>connector/adminhtml_system_config_validator</frontend_model>
541
- <sort_order>320</sort_order>
542
- <show_in_default>1</show_in_default>
543
- <show_in_website>1</show_in_website>
544
- <show_in_store>0</show_in_store>
545
- <can_be_empty>1</can_be_empty>
546
- <expanded>1</expanded>
547
- </validator>
548
- </fields>
549
- </customer_data>
550
- <address_book translate="label">
551
- <label>Address Book Mapping</label>
552
- <sort_order>10</sort_order>
553
- <show_in_default>1</show_in_default>
554
- <show_in_website>1</show_in_website>
555
- <show_in_store>0</show_in_store>
556
- <expanded>1</expanded>
557
- <fields>
558
- <customers>
559
- <label>Add Customers to</label>
560
- <frontend_type>select</frontend_type>
561
- <source_model>connector/system_config_source_addressbooks</source_model>
562
- <sort_order>10</sort_order>
563
- <show_in_default>1</show_in_default>
564
- <show_in_website>1</show_in_website>
565
- <show_in_store>0</show_in_store>
566
- </customers>
567
- <subscribers>
568
- <label>Add Subscribers to</label>
569
- <frontend_type>select</frontend_type>
570
- <source_model>connector/system_config_source_addressbooks</source_model>
571
- <sort_order>20</sort_order>
572
- <show_in_default>1</show_in_default>
573
- <show_in_website>1</show_in_website>
574
- <show_in_store>0</show_in_store>
575
- </subscribers>
576
- <guest>
577
- <label>Add Guests to</label>
578
- <frontend_type>select</frontend_type>
579
- <source_model>connector/system_config_source_addressbooks</source_model>
580
- <sort_order>30</sort_order>
581
- <show_in_default>1</show_in_default>
582
- <show_in_website>1</show_in_website>
583
- <show_in_store>0</show_in_store>
584
- </guest>
585
- </fields>
586
- </address_book>
587
- </groups>
588
- </connector_data_field_settings>
589
- <connector_roi_page_tracking_settings translate="label">
590
- <label><![CDATA[ROI & Tracking]]></label>
591
- <tab>connector</tab>
592
- <frontend_type>text</frontend_type>
593
- <sort_order>4000</sort_order>
594
- <show_in_default>1</show_in_default>
595
- <show_in_website>1</show_in_website>
596
- <show_in_store>0</show_in_store>
597
- <groups>
598
- <page_tracking>
599
- <label>Page Tracking</label>
600
- <frontend_type>text</frontend_type>
601
- <sort_order>10</sort_order>
602
- <show_in_default>1</show_in_default>
603
- <show_in_website>1</show_in_website>
604
- <show_in_store>0</show_in_store>
605
- <expanded>1</expanded>
606
- <fields>
607
- <enabled translate="label">
608
- <label>Enabled</label>
609
- <frontend_type>select</frontend_type>
610
- <source_model>adminhtml/system_config_source_yesno</source_model>
611
- <sort_order>10</sort_order>
612
- <show_in_default>1</show_in_default>
613
- <show_in_website>1</show_in_website>
614
- <show_in_store>0</show_in_store>
615
- </enabled>
616
- </fields>
617
- </page_tracking>
618
- <roi_tracking>
619
- <label>ROI Tracking</label>
620
- <frontend_type>text</frontend_type>
621
- <sort_order>20</sort_order>
622
- <show_in_default>1</show_in_default>
623
- <show_in_website>1</show_in_website>
624
- <show_in_store>0</show_in_store>
625
- <expanded>1</expanded>
626
- <fields>
627
- <enabled translate="label">
628
- <label>Enabled</label>
629
- <frontend_type>select</frontend_type>
630
- <source_model>adminhtml/system_config_source_yesno</source_model>
631
- <sort_order>10</sort_order>
632
- <show_in_default>1</show_in_default>
633
- <show_in_website>1</show_in_website>
634
- <show_in_store>0</show_in_store>
635
- </enabled>
636
- </fields>
637
- </roi_tracking>
638
- </groups>
639
- </connector_roi_page_tracking_settings>
640
- <lost_basket_settings translate="label">
641
- <label><![CDATA[Lost Baskets]]></label>
642
- <tab>connector</tab>
643
- <frontend_type>text</frontend_type>
644
- <sort_order>6000</sort_order>
645
- <show_in_default>1</show_in_default>
646
- <show_in_website>1</show_in_website>
647
- <show_in_store>1</show_in_store>
648
- <groups>
649
- <active>
650
- <label>Lost Baskets Settings</label>
651
- <frontend_type>text</frontend_type>
652
- <sort_order>100</sort_order>
653
- <show_in_default>0</show_in_default>
654
- <show_in_website>0</show_in_website>
655
- <show_in_store>0</show_in_store>
656
- <fields>
657
- <active translate="label">
658
- <label>Consider Order complete for lost baskets</label>
659
- <frontend_type>select</frontend_type>
660
- <source_model>connector/system_config_source_activebasket</source_model>
661
- <sort_order>10</sort_order>
662
- <show_in_default>1</show_in_default>
663
- <show_in_website>1</show_in_website>
664
- <show_in_store>0</show_in_store>
665
- </active>
666
- </fields>
667
- </active>
668
- <customers>
669
- <label>Customers</label>
670
- <frontend_type>text</frontend_type>
671
- <sort_order>10</sort_order>
672
- <show_in_default>1</show_in_default>
673
- <show_in_website>1</show_in_website>
674
- <show_in_store>1</show_in_store>
675
- <expanded>1</expanded>
676
- <fields>
677
- <heading_1 translate="label">
678
- <label>Lost basket 1</label>
679
- <frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
680
- <sort_order>10</sort_order>
681
- <show_in_default>1</show_in_default>
682
- <show_in_website>1</show_in_website>
683
- <show_in_store>1</show_in_store>
684
- </heading_1>
685
- <enabled_1 translate="label">
686
- <label>Enabled/Disabled</label>
687
- <frontend_type>select</frontend_type>
688
- <config_path>lostbaskets/customers/enabled_1</config_path>
689
- <source_model>adminhtml/system_config_source_enabledisable</source_model>
690
- <sort_order>20</sort_order>
691
- <show_in_default>1</show_in_default>
692
- <show_in_website>1</show_in_website>
693
- <show_in_store>1</show_in_store>
694
- </enabled_1>
695
- <send_after_1>
696
- <label>Send after (min)</label>
697
- <frontend_type>select</frontend_type>
698
- <source_model>connector/system_config_source_lostbasket</source_model>
699
- <sort_order>30</sort_order>
700
- <show_in_default>1</show_in_default>
701
- <show_in_website>1</show_in_website>
702
- <show_in_store>1</show_in_store>
703
- </send_after_1>
704
- <campaign_1>
705
- <label>Campaign To Send</label>
706
- <frontend_type>select</frontend_type>
707
- <source_model>connector/system_config_source_campaigns</source_model>
708
- <sort_order>40</sort_order>
709
- <show_in_default>1</show_in_default>
710
- <show_in_website>1</show_in_website>
711
- <show_in_store>1</show_in_store>
712
- </campaign_1>
713
- <heading_2 translate="label">
714
- <label>Lost basket 2</label>
715
- <frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
716
- <sort_order>50</sort_order>
717
- <show_in_default>1</show_in_default>
718
- <show_in_website>1</show_in_website>
719
- <show_in_store>1</show_in_store>
720
- </heading_2>
721
- <enabled_2 translate="label">
722
- <label>Enabled/Disabled</label>
723
- <frontend_type>select</frontend_type>
724
- <config_path>lostbaskets/customers/enabled_2</config_path>
725
- <source_model>adminhtml/system_config_source_enabledisable</source_model>
726
- <sort_order>60</sort_order>
727
- <show_in_default>1</show_in_default>
728
- <show_in_website>1</show_in_website>
729
- <show_in_store>1</show_in_store>
730
- </enabled_2>
731
- <send_after_2>
732
- <label>Send after (hrs)</label>
733
- <frontend_type>select</frontend_type>
734
- <source_model>connector/system_config_source_sendcampain</source_model>
735
- <sort_order>70</sort_order>
736
- <show_in_default>1</show_in_default>
737
- <show_in_website>1</show_in_website>
738
- <show_in_store>1</show_in_store>
739
- </send_after_2>
740
- <campaign_2>
741
- <label>Campaign to send</label>
742
- <frontend_type>select</frontend_type>
743
- <source_model>connector/system_config_source_campaigns</source_model>
744
- <sort_order>80</sort_order>
745
- <show_in_default>1</show_in_default>
746
- <show_in_website>1</show_in_website>
747
- <show_in_store>1</show_in_store>
748
- </campaign_2>
749
- <heading_3 translate="label">
750
- <label>Lost basket 3 </label>
751
- <frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
752
- <sort_order>90</sort_order>
753
- <show_in_default>1</show_in_default>
754
- <show_in_website>1</show_in_website>
755
- <show_in_store>1</show_in_store>
756
- </heading_3>
757
- <enabled_3 translate="label">
758
- <label>Enabled/Disabled</label>
759
- <frontend_type>select</frontend_type>
760
- <config_path>lostbaskets/customers/enabled_3</config_path>
761
- <source_model>adminhtml/system_config_source_enabledisable</source_model>
762
- <sort_order>100</sort_order>
763
- <show_in_default>1</show_in_default>
764
- <show_in_website>1</show_in_website>
765
- <show_in_store>1</show_in_store>
766
- </enabled_3>
767
- <send_after_3>
768
- <label>Send after (hrs)</label>
769
- <frontend_type>select</frontend_type>
770
- <source_model>connector/system_config_source_sendcampain</source_model>
771
- <sort_order>110</sort_order>
772
- <show_in_default>1</show_in_default>
773
- <show_in_website>1</show_in_website>
774
- <show_in_store>1</show_in_store>
775
- </send_after_3>
776
- <campaign_3>
777
- <label>Campaign to send</label>
778
- <frontend_type>select</frontend_type>
779
- <source_model>connector/system_config_source_campaigns</source_model>
780
- <sort_order>120</sort_order>
781
- <show_in_default>1</show_in_default>
782
- <show_in_website>1</show_in_website>
783
- <show_in_store>1</show_in_store>
784
- </campaign_3>
785
- </fields>
786
- </customers>
787
- <guests>
788
- <label>Guests</label>
789
- <frontend_type>text</frontend_type>
790
- <sort_order>20</sort_order>
791
- <show_in_default>1</show_in_default>
792
- <show_in_website>1</show_in_website>
793
- <show_in_store>1</show_in_store>
794
- <fields>
795
- <heading_1 translate="label">
796
- <label>Lost basket 1</label>
797
- <frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
798
- <sort_order>10</sort_order>
799
- <show_in_default>1</show_in_default>
800
- <show_in_website>1</show_in_website>
801
- <show_in_store>1</show_in_store>
802
- </heading_1>
803
- <enabled_1 translate="label">
804
- <label>Enabled/Disabled</label>
805
- <frontend_type>select</frontend_type>
806
- <config_path>lostbaskets/guests/enabled_1</config_path>
807
- <source_model>adminhtml/system_config_source_enabledisable</source_model>
808
- <sort_order>20</sort_order>
809
- <show_in_default>1</show_in_default>
810
- <show_in_website>1</show_in_website>
811
- <show_in_store>1</show_in_store>
812
- </enabled_1>
813
- <send_after_1>
814
- <label>Send after (min)</label>
815
- <frontend_type>select</frontend_type>
816
- <source_model>connector/system_config_source_lostbasket</source_model>
817
- <sort_order>30</sort_order>
818
- <show_in_default>1</show_in_default>
819
- <show_in_website>1</show_in_website>
820
- <show_in_store>1</show_in_store>
821
- </send_after_1>
822
- <campaign_1>
823
- <label>Campaign To Send</label>
824
- <frontend_type>select</frontend_type>
825
- <source_model>connector/system_config_source_campaigns</source_model>
826
- <sort_order>40</sort_order>
827
- <show_in_default>1</show_in_default>
828
- <show_in_website>1</show_in_website>
829
- <show_in_store>1</show_in_store>
830
- </campaign_1>
831
-
832
- <heading_2 translate="label">
833
- <label>Lost basket 2</label>
834
- <frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
835
- <sort_order>50</sort_order>
836
- <show_in_default>1</show_in_default>
837
- <show_in_website>1</show_in_website>
838
- <show_in_store>1</show_in_store>
839
- </heading_2>
840
- <enabled_2 translate="label">
841
- <label>Enabled/Disabled</label>
842
- <frontend_type>select</frontend_type>
843
- <config_path>lostbaskets/guests/enabled_2</config_path>
844
- <source_model>adminhtml/system_config_source_enabledisable</source_model>
845
- <sort_order>60</sort_order>
846
- <show_in_default>1</show_in_default>
847
- <show_in_website>1</show_in_website>
848
- <show_in_store>1</show_in_store>
849
- </enabled_2>
850
- <send_after_2>
851
- <label>Send after (hrs)</label>
852
- <frontend_type>select</frontend_type>
853
- <source_model>connector/system_config_source_sendcampain</source_model>
854
- <sort_order>70</sort_order>
855
- <show_in_default>1</show_in_default>
856
- <show_in_website>1</show_in_website>
857
- <show_in_store>1</show_in_store>
858
- </send_after_2>
859
- <campaign_2>
860
- <label>Campaign to send</label>
861
- <frontend_type>select</frontend_type>
862
- <source_model>connector/system_config_source_campaigns</source_model>
863
- <sort_order>80</sort_order>
864
- <show_in_default>1</show_in_default>
865
- <show_in_website>1</show_in_website>
866
- <show_in_store>1</show_in_store>
867
- </campaign_2>
868
-
869
- <heading_3 translate="label">
870
- <label>Lost basket 3 </label>
871
- <frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
872
- <sort_order>90</sort_order>
873
- <show_in_default>1</show_in_default>
874
- <show_in_website>1</show_in_website>
875
- <show_in_store>1</show_in_store>
876
- </heading_3>
877
- <enabled_3 translate="label">
878
- <label>Enabled/Disabled</label>
879
- <frontend_type>select</frontend_type>
880
- <config_path>lostbaskets/guests/enabled_3</config_path>
881
- <source_model>adminhtml/system_config_source_enabledisable</source_model>
882
- <sort_order>100</sort_order>
883
- <show_in_default>1</show_in_default>
884
- <show_in_website>1</show_in_website>
885
- <show_in_store>1</show_in_store>
886
- </enabled_3>
887
- <send_after_3>
888
- <label>Send after (hrs)</label>
889
- <frontend_type>select</frontend_type>
890
- <source_model>connector/system_config_source_sendcampain</source_model>
891
- <sort_order>110</sort_order>
892
- <show_in_default>1</show_in_default>
893
- <show_in_website>1</show_in_website>
894
- <show_in_store>1</show_in_store>
895
- </send_after_3>
896
- <campaign_3>
897
- <label>Campaign to send</label>
898
- <frontend_type>select</frontend_type>
899
- <source_model>connector/system_config_source_campaigns</source_model>
900
- <sort_order>120</sort_order>
901
- <show_in_default>1</show_in_default>
902
- <show_in_website>1</show_in_website>
903
- <show_in_store>1</show_in_store>
904
- </campaign_3>
905
- </fields>
906
- </guests>
907
- <test>
908
- <label>Test</label>
909
- <frontend_type>text</frontend_type>
910
- <sort_order>30</sort_order>
911
- <show_in_default>1</show_in_default>
912
- <show_in_website>1</show_in_website>
913
- <show_in_store>1</show_in_store>
914
- <fields>
915
- <email translate="label">
916
- <label>Test Email</label>
917
- <frontend_type>text</frontend_type>
918
- <sort_order>10</sort_order>
919
- <show_in_default>1</show_in_default>
920
- <show_in_website>1</show_in_website>
921
- <show_in_store>0</show_in_store>
922
- <comment>Enter the email for customer to test lost basket, with the first lost basket campaign.</comment>
923
- </email>
924
- <force_test translate="label">
925
- <label></label>
926
- <frontend_model>connector/debug_forcelostbasketsync</frontend_model>
927
- <sort_order>50</sort_order>
928
- <show_in_default>1</show_in_default>
929
- <show_in_website>0</show_in_website>
930
- <show_in_store>0</show_in_store>
931
- <comment>Use this button force the data synchronization to run now</comment>
932
- </force_test>
933
- </fields>
934
- </test>
935
- </groups>
936
- </lost_basket_settings>
937
- <sms_section translate="label">
938
- <label><![CDATA[SMS]]></label>
939
- <tab>connector</tab>
940
- <frontend_type>text</frontend_type>
941
- <sort_order>7000</sort_order>
942
- <show_in_default>1</show_in_default>
943
- <show_in_website>1</show_in_website>
944
- <show_in_store>1</show_in_store>
945
- <groups>
946
- <sms_message_one translate="label">
947
- <label>SMS Message 1</label>
948
- <frontend_type>text</frontend_type>
949
- <sort_order>10</sort_order>
950
- <show_in_default>1</show_in_default>
951
- <show_in_website>1</show_in_website>
952
- <show_in_store>1</show_in_store>
953
- <fields>
954
- <enabled translate="label">
955
- <label>Enabled</label>
956
- <frontend_type>select</frontend_type>
957
- <source_model>adminhtml/system_config_source_yesno</source_model>
958
- <sort_order>10</sort_order>
959
- <show_in_default>1</show_in_default>
960
- <show_in_website>1</show_in_website>
961
- <show_in_store>1</show_in_store>
962
- </enabled>
963
- <order_status translate="label">
964
- <label>Order Status</label>
965
- <sort_order>20</sort_order>
966
- <frontend_type>select</frontend_type>
967
- <source_model>connector/system_config_source_orderstatus</source_model>
968
- <show_in_default>1</show_in_default>
969
- <show_in_website>1</show_in_website>
970
- <show_in_store>1</show_in_store>
971
- </order_status>
972
- <message translate="label">
973
- <label>Message</label>
974
- <frontend_type>textarea</frontend_type>
975
- <frontend_model>connector/adminhtml_system_config_smsmessageone</frontend_model>
976
- <sort_order>30</sort_order>
977
- <show_in_default>1</show_in_default>
978
- <show_in_website>1</show_in_website>
979
- <show_in_store>1</show_in_store>
980
- <validate>validate-length maximum-length-110</validate>
981
- </message>
982
- </fields>
983
-
984
- </sms_message_one>
985
- <sms_message_two translate="label">
986
- <label>SMS Message 2</label>
987
- <frontend_type>text</frontend_type>
988
- <sort_order>20</sort_order>
989
- <show_in_default>1</show_in_default>
990
- <show_in_website>1</show_in_website>
991
- <show_in_store>1</show_in_store>
992
- <fields>
993
- <enabled translate="label">
994
- <label>Enabled</label>
995
- <frontend_type>select</frontend_type>
996
- <source_model>adminhtml/system_config_source_yesno</source_model>
997
- <sort_order>10</sort_order>
998
- <show_in_default>1</show_in_default>
999
- <show_in_website>1</show_in_website>
1000
- <show_in_store>1</show_in_store>
1001
- </enabled>
1002
- <order_status translate="label">
1003
- <label>Order Status</label>
1004
- <sort_order>20</sort_order>
1005
- <frontend_type>select</frontend_type>
1006
- <source_model>connector/system_config_source_orderstatus</source_model>
1007
- <show_in_default>1</show_in_default>
1008
- <show_in_website>1</show_in_website>
1009
- <show_in_store>1</show_in_store>
1010
- </order_status>
1011
- <message translate="label">
1012
- <label>Message</label>
1013
- <frontend_type>textarea</frontend_type>
1014
- <frontend_model>connector/adminhtml_system_config_smsmessagetwo</frontend_model>
1015
- <sort_order>30</sort_order>
1016
- <show_in_default>1</show_in_default>
1017
- <show_in_website>1</show_in_website>
1018
- <show_in_store>1</show_in_store>
1019
- <validate>validate-length maximum-length-110</validate>
1020
- </message>
1021
- </fields>
1022
-
1023
- </sms_message_two>
1024
- <sms_message_three translate="label">
1025
- <label>SMS Message 3</label>
1026
- <frontend_type>text</frontend_type>
1027
- <sort_order>30</sort_order>
1028
- <show_in_default>1</show_in_default>
1029
- <show_in_website>1</show_in_website>
1030
- <show_in_store>1</show_in_store>
1031
- <fields>
1032
- <enabled translate="label">
1033
- <label>Enabled</label>
1034
- <frontend_type>select</frontend_type>
1035
- <source_model>adminhtml/system_config_source_yesno</source_model>
1036
- <sort_order>10</sort_order>
1037
- <show_in_default>1</show_in_default>
1038
- <show_in_website>1</show_in_website>
1039
- <show_in_store>1</show_in_store>
1040
- </enabled>
1041
- <order_status translate="label">
1042
- <label>Order Status</label>
1043
- <sort_order>20</sort_order>
1044
- <frontend_type>select</frontend_type>
1045
- <source_model>connector/system_config_source_orderstatus</source_model>
1046
- <show_in_default>1</show_in_default>
1047
- <show_in_website>1</show_in_website>
1048
- <show_in_store>1</show_in_store>
1049
- </order_status>
1050
- <message translate="label">
1051
- <label>Message</label>
1052
- <frontend_type>textarea</frontend_type>
1053
- <frontend_model>connector/adminhtml_system_config_smsmessagethree</frontend_model>
1054
- <sort_order>30</sort_order>
1055
- <show_in_default>1</show_in_default>
1056
- <show_in_website>1</show_in_website>
1057
- <show_in_store>1</show_in_store>
1058
- <validate>validate-length maximum-length-110</validate>
1059
- </message>
1060
- </fields>
1061
- </sms_message_three>
1062
- <sms_message_four translate="label">
1063
- <label>SMS Message 4</label>
1064
- <frontend_type>text</frontend_type>
1065
- <sort_order>40</sort_order>
1066
- <show_in_default>1</show_in_default>
1067
- <show_in_website>1</show_in_website>
1068
- <show_in_store>1</show_in_store>
1069
- <fields>
1070
- <enabled translate="label">
1071
- <label>Enabled</label>
1072
- <frontend_type>select</frontend_type>
1073
- <source_model>adminhtml/system_config_source_yesno</source_model>
1074
- <sort_order>10</sort_order>
1075
- <show_in_default>1</show_in_default>
1076
- <show_in_website>1</show_in_website>
1077
- <show_in_store>1</show_in_store>
1078
- </enabled>
1079
- <order_status translate="label">
1080
- <label>Order Status</label>
1081
- <sort_order>20</sort_order>
1082
- <frontend_type>select</frontend_type>
1083
- <source_model>connector/system_config_source_orderstatus</source_model>
1084
- <show_in_default>1</show_in_default>
1085
- <show_in_website>1</show_in_website>
1086
- <show_in_store>1</show_in_store>
1087
- </order_status>
1088
- <message translate="label">
1089
- <label>Message</label>
1090
- <frontend_type>textarea</frontend_type>
1091
- <frontend_model>connector/adminhtml_system_config_smsmessagefour</frontend_model>
1092
- <sort_order>30</sort_order>
1093
- <show_in_default>1</show_in_default>
1094
- <show_in_website>1</show_in_website>
1095
- <show_in_store>1</show_in_store>
1096
- <validate>validate-length maximum-length-110</validate>
1097
- </message>
1098
- </fields>
1099
-
1100
- </sms_message_four>
1101
- </groups>
1102
- </sms_section>
1103
- <dynamic_content translate="label">
1104
- <label><![CDATA[Dynamic Content]]></label>
1105
- <tab>connector</tab>
1106
- <frontend_type>text</frontend_type>
1107
- <sort_order>8000</sort_order>
1108
- <show_in_default>1</show_in_default>
1109
- <show_in_website>1</show_in_website>
1110
- <show_in_store>0</show_in_store>
1111
- <groups>
1112
- <products translate="label">
1113
- <label>Dynamic Products</label>
1114
- <frontend_type>text</frontend_type>
1115
- <sort_order>10</sort_order>
1116
- <show_in_default>1</show_in_default>
1117
- <show_in_website>1</show_in_website>
1118
- <show_in_store>0</show_in_store>
1119
- <expanded>1</expanded>
1120
- <fields>
1121
- <related translate="label">
1122
- <label>Related Products</label>
1123
- <frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
1124
- <sort_order>10</sort_order>
1125
- <show_in_default>1</show_in_default>
1126
- <show_in_website>1</show_in_website>
1127
- <show_in_store>0</show_in_store>
1128
- </related>
1129
- <related_display_type translate="label">
1130
- <label>Display Type</label>
1131
- <frontend_type>select</frontend_type>
1132
- <source_model>connector/system_config_source_displaytype</source_model>
1133
- <sort_order>20</sort_order>
1134
- <show_in_default>1</show_in_default>
1135
- <show_in_website>1</show_in_website>
1136
- <show_in_store>0</show_in_store>
1137
- </related_display_type>
1138
- <related_items_to_display translate="label">
1139
- <label>Items To Display</label>
1140
- <frontend_type>select</frontend_type>
1141
- <source_model>connector/system_config_source_gridview</source_model>
1142
- <sort_order>30</sort_order>
1143
- <show_in_website>1</show_in_website>
1144
- <show_in_default>1</show_in_default>
1145
- <show_in_store>0</show_in_store>
1146
- </related_items_to_display>
1147
-
1148
- <upsell translate="label">
1149
- <label>Up Sell Products</label>
1150
- <frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
1151
- <sort_order>40</sort_order>
1152
- <show_in_default>1</show_in_default>
1153
- <show_in_website>1</show_in_website>
1154
- <show_in_store>0</show_in_store>
1155
- </upsell>
1156
- <upsell_display_type translate="label">
1157
- <label>Display Type</label>
1158
- <frontend_type>select</frontend_type>
1159
- <source_model>connector/system_config_source_displaytype</source_model>
1160
- <sort_order>50</sort_order>
1161
- <show_in_default>1</show_in_default>
1162
- <show_in_website>1</show_in_website>
1163
- <show_in_store>0</show_in_store>
1164
- </upsell_display_type>
1165
- <upsell_items_to_display translate="label">
1166
- <label>Items To Display</label>
1167
- <frontend_type>select</frontend_type>
1168
- <source_model>connector/system_config_source_gridview</source_model>
1169
- <sort_order>60</sort_order>
1170
- <show_in_website>1</show_in_website>
1171
- <show_in_default>1</show_in_default>
1172
- <show_in_store>0</show_in_store>
1173
- </upsell_items_to_display>
1174
-
1175
- <crosssell translate="label">
1176
- <label>Cross Sell Products</label>
1177
- <frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
1178
- <sort_order>70</sort_order>
1179
- <show_in_default>1</show_in_default>
1180
- <show_in_website>1</show_in_website>
1181
- <show_in_store>0</show_in_store>
1182
- </crosssell>
1183
- <crosssell_display_type translate="label">
1184
- <label>Display Type</label>
1185
- <frontend_type>select</frontend_type>
1186
- <source_model>connector/system_config_source_displaytype</source_model>
1187
- <sort_order>80</sort_order>
1188
- <show_in_default>1</show_in_default>
1189
- <show_in_website>1</show_in_website>
1190
- <show_in_store>0</show_in_store>
1191
- </crosssell_display_type>
1192
- <crosssell_items_to_display translate="label">
1193
- <label>Items To Display</label>
1194
- <frontend_type>select</frontend_type>
1195
- <source_model>connector/system_config_source_gridview</source_model>
1196
- <sort_order>90</sort_order>
1197
- <show_in_website>1</show_in_website>
1198
- <show_in_default>1</show_in_default>
1199
- <show_in_store>0</show_in_store>
1200
- </crosssell_items_to_display>
1201
-
1202
- <best translate="label">
1203
- <label>Best Sellers</label>
1204
- <frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
1205
- <sort_order>100</sort_order>
1206
- <show_in_default>1</show_in_default>
1207
- <show_in_website>1</show_in_website>
1208
- <show_in_store>0</show_in_store>
1209
- </best>
1210
- <best_display_type translate="label">
1211
- <label>Display Type</label>
1212
- <frontend_type>select</frontend_type>
1213
- <source_model>connector/system_config_source_displaytype</source_model>
1214
- <sort_order>110</sort_order>
1215
- <show_in_default>1</show_in_default>
1216
- <show_in_website>1</show_in_website>
1217
- <show_in_store>0</show_in_store>
1218
- </best_display_type>
1219
- <best_items_to_display translate="label">
1220
- <label>Items To Display</label>
1221
- <frontend_type>select</frontend_type>
1222
- <source_model>connector/system_config_source_gridview</source_model>
1223
- <sort_order>120</sort_order>
1224
- <show_in_website>1</show_in_website>
1225
- <show_in_default>1</show_in_default>
1226
- <show_in_store>0</show_in_store>
1227
- </best_items_to_display>
1228
- <best_time_period translate="label">
1229
- <label>Time Period</label>
1230
- <frontend_type>select</frontend_type>
1231
- <source_model>connector/system_config_source_timeperiod</source_model>
1232
- <sort_order>130</sort_order>
1233
- <show_in_default>1</show_in_default>
1234
- <show_in_website>1</show_in_website>
1235
- <show_in_store>0</show_in_store>
1236
- </best_time_period>
1237
-
1238
- <most_viewed translate="label">
1239
- <label>Most Viewed</label>
1240
- <frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
1241
- <sort_order>140</sort_order>
1242
- <show_in_default>1</show_in_default>
1243
- <show_in_website>1</show_in_website>
1244
- <show_in_store>0</show_in_store>
1245
- </most_viewed>
1246
- <most_viewed_display_type translate="label">
1247
- <label>Display Type</label>
1248
- <frontend_type>select</frontend_type>
1249
- <source_model>connector/system_config_source_displaytype</source_model>
1250
- <sort_order>150</sort_order>
1251
- <show_in_default>1</show_in_default>
1252
- <show_in_website>1</show_in_website>
1253
- <show_in_store>0</show_in_store>
1254
- </most_viewed_display_type>
1255
- <most_viewed_items_to_display translate="label">
1256
- <label>Items To Display</label>
1257
- <frontend_type>select</frontend_type>
1258
- <source_model>connector/system_config_source_gridview</source_model>
1259
- <sort_order>160</sort_order>
1260
- <show_in_website>1</show_in_website>
1261
- <show_in_default>1</show_in_default>
1262
- <show_in_store>0</show_in_store>
1263
- </most_viewed_items_to_display>
1264
- <most_viewed_time_period translate="label">
1265
- <label>Time Period</label>
1266
- <frontend_type>select</frontend_type>
1267
- <source_model>connector/system_config_source_timeperiod</source_model>
1268
- <sort_order>170</sort_order>
1269
- <show_in_default>1</show_in_default>
1270
- <show_in_website>1</show_in_website>
1271
- <show_in_store>0</show_in_store>
1272
- </most_viewed_time_period>
1273
-
1274
- <recently_viewed translate="label">
1275
- <label>Recently Viewed</label>
1276
- <frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
1277
- <sort_order>180</sort_order>
1278
- <show_in_default>1</show_in_default>
1279
- <show_in_website>1</show_in_website>
1280
- <show_in_store>0</show_in_store>
1281
- </recently_viewed>
1282
- <recently_viewed_display_type translate="label">
1283
- <label>Display Type</label>
1284
- <frontend_type>select</frontend_type>
1285
- <source_model>connector/system_config_source_displaytype</source_model>
1286
- <sort_order>190</sort_order>
1287
- <show_in_default>1</show_in_default>
1288
- <show_in_website>1</show_in_website>
1289
- <show_in_store>0</show_in_store>
1290
- </recently_viewed_display_type>
1291
- <recently_viewed_items_to_display translate="label">
1292
- <label>items To Display</label>
1293
- <frontend_type>select</frontend_type>
1294
- <source_model>connector/system_config_source_gridview</source_model>
1295
- <sort_order>200</sort_order>
1296
- <show_in_default>1</show_in_default>
1297
- <show_in_website>1</show_in_website>
1298
- <show_in_store>0</show_in_store>
1299
- </recently_viewed_items_to_display>
1300
-
1301
- <validator>
1302
- <label></label>
1303
- <frontend_type>hidden</frontend_type>
1304
- <frontend_model>connector/adminhtml_system_config_gridlist</frontend_model>
1305
- <sort_order>210</sort_order>
1306
- <show_in_default>1</show_in_default>
1307
- <show_in_website>1</show_in_website>
1308
- <show_in_store>0</show_in_store>
1309
- <can_be_empty>1</can_be_empty>
1310
- </validator>
1311
- </fields>
1312
-
1313
- </products>
1314
- <manual_product_search translate="label">
1315
- <label>Manual Product Push</label>
1316
- <frontend_type>text</frontend_type>
1317
- <sort_order>20</sort_order>
1318
- <show_in_default>1</show_in_default>
1319
- <show_in_website>1</show_in_website>
1320
- <show_in_store>0</show_in_store>
1321
- <expanded>1</expanded>
1322
- <fields>
1323
- <settings tranlate="label">
1324
- <label>Settings</label>
1325
- <frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
1326
- <sort_order>10</sort_order>
1327
- <show_in_default>1</show_in_default>
1328
- <show_in_website>1</show_in_website>
1329
- <show_in_store>0</show_in_store>
1330
- </settings>
1331
- <display_type translate="label">
1332
- <label>Display Type</label>
1333
- <frontend_type>select</frontend_type>
1334
- <source_model>connector/system_config_source_displaytype</source_model>
1335
- <sort_order>50</sort_order>
1336
- <show_in_default>1</show_in_default>
1337
- <show_in_website>1</show_in_website>
1338
- <show_in_store>0</show_in_store>
1339
- </display_type>
1340
- <items_to_display translate="label">
1341
- <label>Items To Display</label>
1342
- <frontend_type>select</frontend_type>
1343
- <source_model>connector/system_config_source_gridview</source_model>
1344
- <sort_order>60</sort_order>
1345
- <show_in_website>1</show_in_website>
1346
- <show_in_default>1</show_in_default>
1347
- <show_in_store>0</show_in_store>
1348
- </items_to_display>
1349
- <products_push translate="label">
1350
- <label>Products</label>
1351
- <frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
1352
- <sort_order>80</sort_order>
1353
- <show_in_default>1</show_in_default>
1354
- <show_in_website>1</show_in_website>
1355
- <show_in_store>0</show_in_store>
1356
- </products_push>
1357
- <products_push_items translate="label">
1358
- <label>Products</label>
1359
- <frontend_type>text</frontend_type>
1360
- <sort_order>90</sort_order>
1361
- <show_in_default>1</show_in_default>
1362
- <show_in_website>1</show_in_website>
1363
- <show_in_store>0</show_in_store>
1364
- <comment><![CDATA[Comma Separated Product Id's]]></comment>
1365
- </products_push_items>
1366
- </fields>
1367
- </manual_product_search>
1368
- <fallback_products translate="label">
1369
- <label>Fallback Products</label>
1370
- <frontend_type>text</frontend_type>
1371
- <sort_order>30</sort_order>
1372
- <show_in_default>1</show_in_default>
1373
- <show_in_website>1</show_in_website>
1374
- <show_in_store>0</show_in_store>
1375
- <fields>
1376
- <product_list translate="label">
1377
- <label>Products</label>
1378
- <frontend_type>text</frontend_type>
1379
- <sort_order>10</sort_order>
1380
- <show_in_default>1</show_in_default>
1381
- <show_in_website>1</show_in_website>
1382
- <show_in_store>0</show_in_store>
1383
- <comment><![CDATA[Comma Separated Product Id's]]></comment>
1384
- </product_list>
1385
- </fields>
1386
- </fallback_products>
1387
- </groups>
1388
- </dynamic_content>
1389
- <connector_advanced_settings translate="label">
1390
- <label><![CDATA[Advanced Settings]]></label>
1391
- <tab>connector</tab>
1392
- <frontend_type>text</frontend_type>
1393
- <sort_order>9000</sort_order>
1394
- <show_in_default>1</show_in_default>
1395
- <show_in_website>1</show_in_website>
1396
- <show_in_store>1</show_in_store>
1397
- <groups>
1398
- <sync_limits>
1399
- <label>Transactional Sync Limit</label>
1400
- <frontend_type>text</frontend_type>
1401
- <sort_order>10</sort_order>
1402
- <show_in_default>1</show_in_default>
1403
- <show_in_website>1</show_in_website>
1404
- <show_in_store>0</show_in_store>
1405
- <fields>
1406
- <orders translate="label">
1407
- <label>Historical import limit</label>
1408
- <frontend_type>select</frontend_type>
1409
- <source_model>connector/system_config_source_orderlimit</source_model>
1410
- <sort_order>40</sort_order>
1411
- <show_in_default>1</show_in_default>
1412
- <show_in_website>1</show_in_website>
1413
- <show_in_store>0</show_in_store>
1414
- </orders>
1415
- </fields>
1416
- </sync_limits>
1417
- <external translate="label">
1418
- <label><![CDATA[External Dynamic Content]]></label>
1419
- <frontend_type>text</frontend_type>
1420
- <sort_order>20</sort_order>
1421
- <show_in_default>1</show_in_default>
1422
- <show_in_website>1</show_in_website>
1423
- <show_in_store>0</show_in_store>
1424
- <fields>
1425
- <passcode translate="label">
1426
- <label>Passcode</label>
1427
- <frontend_type>text</frontend_type>
1428
- <sort_order>10</sort_order>
1429
- <show_in_default>1</show_in_default>
1430
- <show_in_website>1</show_in_website>
1431
- <show_in_store>0</show_in_store>
1432
- <comment><![CDATA[Recommended: Set a passcode so that basket contents and coupon codes can only be viewed if the following passcode is sent with the request.]]></comment>
1433
- </passcode>
1434
- <lost_basket_title translate="label">
1435
- <label>Lost Baskets</label>
1436
- <frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
1437
- <sort_order>20</sort_order>
1438
- <show_in_default>1</show_in_default>
1439
- <show_in_website>1</show_in_website>
1440
- <show_in_store>0</show_in_store>
1441
- </lost_basket_title>
1442
-
1443
- <lost_basket_url translate="label">
1444
- <label>Baskets Content URL</label>
1445
- <frontend_type>label</frontend_type>
1446
- <frontend_model>connector/adminhtml_system_lostbasket</frontend_model>
1447
- <sort_order>30</sort_order>
1448
- <show_in_default>1</show_in_default>
1449
- <show_in_website>1</show_in_website>
1450
- <show_in_store>0</show_in_store>
1451
- </lost_basket_url>
1452
- <coupon_code_title title="label">
1453
- <label>Coupon Codes</label>
1454
- <frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
1455
- <sort_order>40</sort_order>
1456
- <show_in_website>1</show_in_website>
1457
- <show_in_default>1</show_in_default>
1458
- <show_in_store>0</show_in_store>
1459
- </coupon_code_title>
1460
- <coupon_code_url translate="label">
1461
- <label>Coupon Codes URL</label>
1462
- <frontend_type>label</frontend_type>
1463
- <frontend_model>connector/adminhtml_system_couponinfo</frontend_model>
1464
- <sort_order>50</sort_order>
1465
- <show_in_default>1</show_in_default>
1466
- <show_in_website>1</show_in_website>
1467
- <show_in_store>0</show_in_store>
1468
- </coupon_code_url>
1469
-
1470
- <dynamic_content_url translate="label">
1471
- <label>Dynamic Content</label>
1472
- <frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
1473
- <sort_order>60</sort_order>
1474
- <show_in_default>1</show_in_default>
1475
- <show_in_website>1</show_in_website>
1476
- <show_in_store>0</show_in_store>
1477
- </dynamic_content_url>
1478
- <related_products_url translate="label">
1479
- <label>Related Products URL</label>
1480
- <frontend_type>label</frontend_type>
1481
- <frontend_model>connector/adminhtml_system_related</frontend_model>
1482
- <sort_order>70</sort_order>
1483
- <show_in_default>1</show_in_default>
1484
- <show_in_website>1</show_in_website>
1485
- <show_in_store>0</show_in_store>
1486
- </related_products_url>
1487
- <upsell_products_url translate="label">
1488
- <label>Up Sell Products URL</label>
1489
- <frontend_type>label</frontend_type>
1490
- <frontend_model>connector/adminhtml_system_upsell</frontend_model>
1491
- <sort_order>80</sort_order>
1492
- <show_in_default>1</show_in_default>
1493
- <show_in_website>1</show_in_website>
1494
- <show_in_store>0</show_in_store>
1495
- </upsell_products_url>
1496
- <crosssell_products_url translate="label">
1497
- <label>Cross Sell Products URL</label>
1498
- <frontend_type>label</frontend_type>
1499
- <frontend_model>connector/adminhtml_system_crosssell</frontend_model>
1500
- <sort_order>90</sort_order>
1501
- <show_in_default>1</show_in_default>
1502
- <show_in_website>1</show_in_website>
1503
- <show_in_store>0</show_in_store>
1504
- </crosssell_products_url>
1505
-
1506
- <best_sellers_url translate="label">
1507
- <label>Best Sellers URL</label>
1508
- <frontend_type>label</frontend_type>
1509
- <frontend_model>connector/adminhtml_system_bestsellers</frontend_model>
1510
- <sort_order>100</sort_order>
1511
- <show_in_default>1</show_in_default>
1512
- <show_in_website>1</show_in_website>
1513
- <show_in_store>0</show_in_store>
1514
- </best_sellers_url>
1515
- <most_viewed_url translate="label">
1516
- <label>Most Viewed URL</label>
1517
- <frontend_type>label</frontend_type>
1518
- <frontend_model>connector/adminhtml_system_mostviewed</frontend_model>
1519
- <sort_order>110</sort_order>
1520
- <show_in_default>1</show_in_default>
1521
- <show_in_website>1</show_in_website>
1522
- <show_in_store>0</show_in_store>
1523
- </most_viewed_url>
1524
- <product_push_url translate="label">
1525
- <label>Product Push URL</label>
1526
- <frontend_type>label</frontend_type>
1527
- <frontend_model>connector/adminhtml_system_productpush</frontend_model>
1528
- <sort_order>120</sort_order>
1529
- <show_in_default>1</show_in_default>
1530
- <show_in_website>1</show_in_website>
1531
- <show_in_store>0</show_in_store>
1532
- </product_push_url>
1533
- <recently_viewed_url translate="label">
1534
- <label>Recently Viewed</label>
1535
- <frontend_type>label</frontend_type>
1536
- <frontend_model>connector/adminhtml_system_recentlyviewed</frontend_model>
1537
- <sort_order>130</sort_order>
1538
- <show_in_default>1</show_in_default>
1539
- <show_in_website>1</show_in_website>
1540
- <show_in_store>0</show_in_store>
1541
- </recently_viewed_url>
1542
- </fields>
1543
- </external>
1544
- <admin translate="label">
1545
- <label>Admin</label>
1546
- <frontend_type>text</frontend_type>
1547
- <sort_order>30</sort_order>
1548
- <show_in_default>1</show_in_default>
1549
- <show_in_default>1</show_in_default>
1550
- <show_in_store>0</show_in_store>
1551
- <fields>
1552
- <admin_title translate="label">
1553
- <label>Contacts ID's</label>
1554
- <frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
1555
- <sort_order>10</sort_order>
1556
- <show_in_default>1</show_in_default>
1557
- <show_in_website>1</show_in_website>
1558
- <show_in_store>0</show_in_store>
1559
- </admin_title>
1560
- <count_customers translate="label">
1561
- <label>Count Customers with ID</label>
1562
- <frontend_model>connector/debug_countcontacts</frontend_model>
1563
- <sort_order>20</sort_order>
1564
- <show_in_default>1</show_in_default>
1565
- <show_in_website>1</show_in_website>
1566
- <show_in_store>0</show_in_store>
1567
- </count_customers>
1568
- <delete_contact translate="label">
1569
- <label>Delete All Contact ID's</label>
1570
- <frontend_model>connector/debug_deletecontacts</frontend_model>
1571
- <sort_order>30</sort_order>
1572
- <show_in_default>1</show_in_default>
1573
- <show_in_website>1</show_in_website>
1574
- <show_in_store>0</show_in_store>
1575
- </delete_contact>
1576
- <memory_limit translate="label">
1577
- <label>Memory Limit</label>
1578
- <frontend_type>select</frontend_type>
1579
- <source_model>adminhtml/system_config_source_yesno</source_model>
1580
- <show_in_default>1</show_in_default>
1581
- <show_in_website>0</show_in_website>
1582
- <show_in_store>0</show_in_store>
1583
- <sort_order>40</sort_order>
1584
- <comment>Set to NO to use system default memory.</comment>
1585
- </memory_limit>
1586
- <batch_size translate="label">
1587
- <label>Customer Sync Batch Size</label>
1588
- <frontend_type>text</frontend_type>
1589
- <show_in_default>1</show_in_default>
1590
- <show_in_website>1</show_in_website>
1591
- <show_in_store>0</show_in_store>
1592
- <sort_order>50</sort_order>
1593
- <comment>Set the limit size for customers loaded in memory.</comment>
1594
- </batch_size>
1595
- <debug translate="label">
1596
- <label>Debug Mode</label>
1597
- <frontend_type>select</frontend_type>
1598
- <source_model>adminhtml/system_config_source_yesno</source_model>
1599
- <sort_order>50</sort_order>
1600
- <show_in_default>1</show_in_default>
1601
- <show_in_website>1</show_in_website>
1602
- <show_in_store>1</show_in_store>
1603
- <comment>Set to YES to allow creating log files</comment>
1604
- </debug>
1605
- </fields>
1606
- </admin>
1607
- </groups>
1608
- </connector_advanced_settings>
1609
- </sections>
1610
- </config>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/local/Varien/Data/Collection.php DELETED
@@ -1,818 +0,0 @@
1
- <?php
2
- /**
3
- * Magento
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the Open Software License (OSL 3.0)
8
- * that is bundled with this package in the file LICENSE.txt.
9
- * It is also available through the world-wide-web at this URL:
10
- * http://opensource.org/licenses/osl-3.0.php
11
- * If you did not receive a copy of the license and are unable to
12
- * obtain it through the world-wide-web, please send an email
13
- * to license@magentocommerce.com so we can send you a copy immediately.
14
- *
15
- * DISCLAIMER
16
- *
17
- * Do not edit or add to this file if you wish to upgrade Magento to newer
18
- * versions in the future. If you wish to customize Magento for your
19
- * needs please refer to http://www.magentocommerce.com for more information.
20
- *
21
- * @category Varien
22
- * @package Varien_Data
23
- * @copyright Copyright (c) 2008 Irubin Consulting Inc. DBA Varien (http://www.varien.com)
24
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
- */
26
-
27
- /**
28
- * Data collection
29
- *
30
- * @category Varien
31
- * @package Varien_Data
32
- * @author Magento Core Team <core@magentocommerce.com>
33
- */
34
- class Varien_Data_Collection implements IteratorAggregate, Countable
35
- {
36
- const SORT_ORDER_ASC = 'ASC';
37
- const SORT_ORDER_DESC = 'DESC';
38
-
39
- /**
40
- * Collection items
41
- *
42
- * @var array
43
- */
44
- protected $_items = array();
45
-
46
- /**
47
- * Item object class name
48
- *
49
- * @var string
50
- */
51
- protected $_itemObjectClass = 'Varien_Object';
52
-
53
- /**
54
- * Order configuration
55
- *
56
- * @var array
57
- */
58
- protected $_orders = array();
59
-
60
- /**
61
- * Filters configuration
62
- *
63
- * @var array
64
- */
65
- protected $_filters = array();
66
-
67
- /**
68
- * Filter rendered flag
69
- *
70
- * @var bool
71
- */
72
- protected $_isFiltersRendered = false;
73
-
74
- /**
75
- * Current page number for items pager
76
- *
77
- * @var int
78
- */
79
- protected $_curPage = 1;
80
-
81
- /**
82
- * Pager page size
83
- *
84
- * if page size is false, then we works with all items
85
- *
86
- * @var int | false
87
- */
88
- protected $_pageSize = false;
89
-
90
- /**
91
- * Total items number
92
- *
93
- * @var int
94
- */
95
- protected $_totalRecords;
96
-
97
- /**
98
- * Loading state flag
99
- *
100
- * @var bool
101
- */
102
- protected $_isCollectionLoaded;
103
-
104
- protected $_cacheKey;
105
-
106
- protected $_cacheTags = array();
107
-
108
- protected $_cacheLifetime = 86400;
109
-
110
- /**
111
- * Additional collection flags
112
- *
113
- * @var array
114
- */
115
- protected $_flags = array();
116
-
117
- public function __construct()
118
- {
119
-
120
- }
121
-
122
- /**
123
- * Add collection filter
124
- *
125
- * @param string $field
126
- * @param string $value
127
- * @param string $type and|or|string
128
- */
129
- public function addFilter($field, $value, $type = 'and')
130
- {
131
- $filter = new Varien_Object(); // implements ArrayAccess
132
- $filter['field'] = $field;
133
- $filter['value'] = $value;
134
- $filter['type'] = strtolower($type);
135
-
136
- $this->_filters[] = $filter;
137
- $this->_isFiltersRendered = false;
138
- return $this;
139
- }
140
-
141
- /**
142
- * Search for a filter by specified field
143
- *
144
- * Multiple filters can be matched if an array is specified:
145
- * - 'foo' -- get the first filter with field name 'foo'
146
- * - array('foo') -- get all filters with field name 'foo'
147
- * - array('foo', 'bar') -- get all filters with field name 'foo' or 'bar'
148
- * - array() -- get all filters
149
- *
150
- * @param string|array $field
151
- * @return Varien_Object|array|null
152
- */
153
- public function getFilter($field)
154
- {
155
- if (is_array($field)) {
156
- // empty array: get all filters
157
- if (empty($field)) {
158
- return $this->_filters;
159
- }
160
- // non-empty array: collect all filters that match specified field names
161
- $result = array();
162
- foreach ($this->_filters as $filter) {
163
- if (in_array($filter['field'], $field)) {
164
- $result[] = $filter;
165
- }
166
- }
167
- return $result;
168
- }
169
-
170
- // get a first filter by specified name
171
- foreach ($this->_filters as $filter) {
172
- if ($filter['field'] === $field) {
173
- return $filter;
174
- }
175
- }
176
- }
177
-
178
- /**
179
- * Retrieve collection loading status
180
- *
181
- * @return bool
182
- */
183
- public function isLoaded()
184
- {
185
- return $this->_isCollectionLoaded;
186
- }
187
-
188
- /**
189
- * Set collection loading status flag
190
- *
191
- * @param unknown_type $flag
192
- * @return unknown
193
- */
194
- protected function _setIsLoaded($flag = true)
195
- {
196
- $this->_isCollectionLoaded = $flag;
197
- return $this;
198
- }
199
-
200
- /**
201
- * Get current collection page
202
- *
203
- * @param int $displacement
204
- * @return int
205
- */
206
- public function getCurPage($displacement = 0)
207
- {
208
- if ($this->_curPage + $displacement < 1) {
209
- return 1;
210
- }
211
- elseif ($this->_curPage + $displacement > $this->getLastPageNumber()) {
212
- return $this->getLastPageNumber();
213
- } else {
214
- return $this->_curPage + $displacement;
215
- }
216
- }
217
-
218
- /**
219
- * Retrieve collection last page number
220
- *
221
- * @return int
222
- */
223
- public function getLastPageNumber()
224
- {
225
- $collectionSize = (int) $this->getSize();
226
- if (0 === $collectionSize) {
227
- return 1;
228
- }
229
- elseif($this->_pageSize) {
230
- return ceil($collectionSize/$this->_pageSize);
231
- }
232
- else{
233
- return 1;
234
- }
235
- }
236
-
237
- /**
238
- * Retrieve collection page size
239
- *
240
- * @return int
241
- */
242
- public function getPageSize()
243
- {
244
- return $this->_pageSize;
245
- }
246
-
247
- /**
248
- * Retrieve collection all items count
249
- *
250
- * @return int
251
- */
252
- public function getSize()
253
- {
254
- $this->load();
255
- if (is_null($this->_totalRecords)) {
256
- $this->_totalRecords = count($this->getItems());
257
- }
258
- return intval($this->_totalRecords);
259
- }
260
-
261
- /**
262
- * Retrieve collection first item
263
- *
264
- * @return Varien_Object
265
- */
266
- public function getFirstItem()
267
- {
268
- $this->load();
269
-
270
- if (count($this->_items)) {
271
- reset($this->_items);
272
- return current($this->_items);
273
- }
274
-
275
- return new $this->_itemObjectClass();
276
- }
277
-
278
- /**
279
- * Retrieve collection last item
280
- *
281
- * @return Varien_Object
282
- */
283
- public function getLastItem()
284
- {
285
- $this->load();
286
-
287
- if (count($this->_items)) {
288
- return end($this->_items);
289
- }
290
-
291
- return new $this->_itemObjectClass();
292
- }
293
-
294
- /**
295
- * Retrieve collection items
296
- *
297
- * @return array
298
- */
299
- public function getItems()
300
- {
301
- $this->load();
302
- return $this->_items;
303
- }
304
-
305
- /**
306
- * Retrieve field values from all items
307
- *
308
- * @param string $colName
309
- * @return array
310
- */
311
- public function getColumnValues($colName)
312
- {
313
- $this->load();
314
-
315
- $col = array();
316
- foreach ($this->getItems() as $item) {
317
- $col[] = $item->getData($colName);
318
- }
319
- return $col;
320
- }
321
-
322
- /**
323
- * Search all items by field value
324
- *
325
- * @param string $column
326
- * @param mixed $value
327
- * @return array
328
- */
329
- public function getItemsByColumnValue($column, $value)
330
- {
331
- $this->load();
332
-
333
- $res = array();
334
- foreach ($this as $item) {
335
- if ($item->getData($column)==$value) {
336
- $res[] = $item;
337
- }
338
- }
339
- return $res;
340
- }
341
-
342
- /**
343
- * Search first item by field value
344
- *
345
- * @param string $column
346
- * @param mixed $value
347
- * @return Varien_Object || null
348
- */
349
- public function getItemByColumnValue($column, $value)
350
- {
351
- $this->load();
352
-
353
- foreach ($this as $item) {
354
- if ($item->getData($column)==$value) {
355
- return $item;
356
- }
357
- }
358
- return null;
359
- }
360
-
361
- /**
362
- * Adding item to item array
363
- *
364
- * @param Varien_Object $item
365
- * @return Varien_Data_Collection
366
- */
367
- public function addItem(Varien_Object $item)
368
- {
369
- $itemId = $this->_getItemId($item);
370
-
371
- if (!is_null($itemId)) {
372
- if (isset($this->_items[$itemId])) {
373
- //throw new Exception('Item ('.get_class($item).') with the same id "'.$item->getId().'" already exist');
374
- }
375
- $this->_items[$itemId] = $item;
376
- } else {
377
- $this->_addItem($item);
378
- }
379
- return $this;
380
- }
381
-
382
- /**
383
- * Add item that has no id to collection
384
- *
385
- * @param Varien_Object $item
386
- * @return Varien_Data_Collection
387
- */
388
- protected function _addItem($item)
389
- {
390
- $this->_items[] = $item;
391
- return $this;
392
- }
393
-
394
- /**
395
- * Retrieve item id
396
- *
397
- * @param Varien_Object $item
398
- * @return mixed
399
- */
400
- protected function _getItemId(Varien_Object $item)
401
- {
402
- return $item->getId();
403
- }
404
-
405
- /**
406
- * Retrieve ids of all tems
407
- *
408
- * @return array
409
- */
410
- public function getAllIds()
411
- {
412
- $ids = array();
413
- foreach ($this->getItems() as $item) {
414
- $ids[] = $this->_getItemId($item);
415
- }
416
- return $ids;
417
- }
418
-
419
- /**
420
- * Remove item from collection by item key
421
- *
422
- * @param mixed $key
423
- * @return Varien_Data_Collection
424
- */
425
- public function removeItemByKey($key)
426
- {
427
- if (isset($this->_items[$key])) {
428
- unset($this->_items[$key]);
429
- }
430
- return $this;
431
- }
432
-
433
- /**
434
- * Clear collection
435
- *
436
- * @return Varien_Data_Collection
437
- */
438
- public function clear()
439
- {
440
- $this->_setIsLoaded(false);
441
- $this->_items = array();
442
- return $this;
443
- }
444
-
445
- /**
446
- * Walk through the collection and run model method or external callback
447
- * with optional arguments
448
- *
449
- * Returns array with results of callback for each item
450
- *
451
- * @param string $method
452
- * @param array $args
453
- * @return array
454
- */
455
- public function walk($callback, array $args=array())
456
- {
457
- $results = array();
458
- $useItemCallback = is_string($callback) && strpos($callback, '::')===false;
459
- foreach ($this->getItems() as $id=>$item) {
460
- if ($useItemCallback) {
461
- $cb = array($item, $callback);
462
- } else {
463
- $cb = $callback;
464
- array_unshift($args, $item);
465
- }
466
- $results[$id] = call_user_func_array($cb, $args);
467
- }
468
- return $results;
469
- }
470
-
471
- public function each($obj_method, $args=array())
472
- {
473
- foreach ($args->_items as $k => $item) {
474
- $args->_items[$k] = call_user_func($obj_method, $item);
475
- }
476
- }
477
-
478
- /**
479
- * Setting data for all collection items
480
- *
481
- * @param mixed $key
482
- * @param mixed $value
483
- * @return Varien_Data_Collection
484
- */
485
- public function setDataToAll($key, $value=null)
486
- {
487
- if (is_array($key)) {
488
- foreach ($key as $k=>$v) {
489
- $this->setDataToAll($k, $v);
490
- }
491
- return $this;
492
- }
493
- foreach ($this->getItems() as $item) {
494
- $item->setData($key, $value);
495
- }
496
- return $this;
497
- }
498
-
499
- /**
500
- * Set current page
501
- *
502
- * @param int $page
503
- * @return Varien_Data_Collection
504
- */
505
- public function setCurPage($page)
506
- {
507
- $this->_curPage = $page;
508
- return $this;
509
- }
510
-
511
- /**
512
- * Set collection page size
513
- *
514
- * @param int $size
515
- * @return Varien_Data_Collection
516
- */
517
- public function setPageSize($size)
518
- {
519
- $this->_pageSize = $size;
520
- return $this;
521
- }
522
-
523
- /**
524
- * Set select order
525
- *
526
- * @param string $field
527
- * @param string $direction
528
- * @return Varien_Data_Collection
529
- */
530
- public function setOrder($field, $direction = self::SORT_ORDER_DESC)
531
- {
532
- $this->_orders[$field] = $direction;
533
- return $this;
534
- }
535
-
536
- /**
537
- * Set collection item class name
538
- *
539
- * @param string $className
540
- * @return Varien_Data_Collection
541
- */
542
- function setItemObjectClass($className)
543
- {
544
- $className = Mage::getConfig()->getModelClassName($className);
545
- /**
546
- * is_subclass_of($className, 'Varien_Object') - Segmentation fault in php 5.2.3
547
- */
548
- /*if (!is_subclass_of($className, 'Varien_Object')) {
549
- throw new Exception($className.' does not extends from Varien_Object');
550
- }*/
551
- $this->_itemObjectClass = $className;
552
- return $this;
553
- }
554
-
555
- /**
556
- * Retrieve collection empty item
557
- *
558
- * @return Varien_Object
559
- */
560
- public function getNewEmptyItem()
561
- {
562
- return new $this->_itemObjectClass();
563
- }
564
-
565
- /**
566
- * Render sql select conditions
567
- *
568
- * @return Varien_Data_Collection
569
- */
570
- protected function _renderFilters()
571
- {
572
- return $this;
573
- }
574
-
575
- /**
576
- * Render sql select orders
577
- *
578
- * @return Varien_Data_Collection
579
- */
580
- protected function _renderOrders()
581
- {
582
- return $this;
583
- }
584
-
585
- /**
586
- * Render sql select limit
587
- *
588
- * @return Varien_Data_Collection
589
- */
590
- protected function _renderLimit()
591
- {
592
- return $this;
593
- }
594
-
595
- /**
596
- * Set select distinct
597
- *
598
- * @param bool $flag
599
- */
600
- public function distinct($flag)
601
- {
602
- return $this;
603
- }
604
-
605
- /**
606
- * Load data
607
- *
608
- * @return Varien_Data_Collection
609
- */
610
- public function loadData($printQuery = false, $logQuery = false)
611
- {
612
- return $this;
613
- }
614
-
615
- /**
616
- * Load data
617
- *
618
- * @return Varien_Data_Collection
619
- */
620
- public function load($printQuery = false, $logQuery = false)
621
- {
622
- return $this->loadData($printQuery, $logQuery);
623
- }
624
-
625
- /**
626
- * Convert collection to XML
627
- *
628
- * @return string
629
- */
630
- public function toXml()
631
- {
632
- $xml = '<?xml version="1.0" encoding="UTF-8"?>
633
- <collection>
634
- <totalRecords>'.$this->_totalRecords.'</totalRecords>
635
- <items>';
636
-
637
- foreach ($this as $item) {
638
- $xml.=$item->toXml();
639
- }
640
- $xml.= '</items>
641
- </collection>';
642
- return $xml;
643
- }
644
-
645
- /**
646
- * Convert collection to array
647
- *
648
- * @return array
649
- */
650
- public function toArray($arrRequiredFields = array())
651
- {
652
- $arrItems = array();
653
- $arrItems['totalRecords'] = $this->getSize();
654
-
655
- $arrItems['items'] = array();
656
- foreach ($this as $item) {
657
- $arrItems['items'][] = $item->toArray($arrRequiredFields);
658
- }
659
- return $arrItems;
660
- }
661
-
662
- /**
663
- * Convert items array to array for select options
664
- *
665
- * return items array
666
- * array(
667
- * $index => array(
668
- * 'value' => mixed
669
- * 'label' => mixed
670
- * )
671
- * )
672
- *
673
- * @param string $valueField
674
- * @param string $labelField
675
- * @return array
676
- */
677
- protected function _toOptionArray($valueField='id', $labelField='name', $additional=array())
678
- {
679
- $res = array();
680
- $additional['value'] = $valueField;
681
- $additional['label'] = $labelField;
682
-
683
- foreach ($this as $item) {
684
- foreach ($additional as $code => $field) {
685
- $data[$code] = $item->getData($field);
686
- }
687
- $res[] = $data;
688
- }
689
- return $res;
690
- }
691
-
692
- public function toOptionArray()
693
- {
694
- return $this->_toOptionArray();
695
- }
696
-
697
- public function toOptionHash()
698
- {
699
- return $this->_toOptionHash();
700
- }
701
-
702
- /**
703
- * Convert items array to hash for select options
704
- *
705
- * return items hash
706
- * array($value => $label)
707
- *
708
- * @param string $valueField
709
- * @param string $labelField
710
- * @return array
711
- */
712
- protected function _toOptionHash($valueField='id', $labelField='name')
713
- {
714
- $res = array();
715
- foreach ($this as $item) {
716
- $res[$item->getData($valueField)] = $item->getData($labelField);
717
- }
718
- return $res;
719
- }
720
-
721
- /**
722
- * Retrieve item by id
723
- *
724
- * @param mixed $idValue
725
- * @return Varien_Object
726
- */
727
- public function getItemById($idValue)
728
- {
729
- $this->load();
730
- if (isset($this->_items[$idValue])) {
731
- return $this->_items[$idValue];
732
- }
733
- return null;
734
- }
735
-
736
- /**
737
- * Implementation of IteratorAggregate::getIterator()
738
- */
739
- public function getIterator()
740
- {
741
- $this->load();
742
- return new ArrayIterator($this->_items);
743
- }
744
-
745
- /**
746
- * Retireve count of collection loaded items
747
- *
748
- * @return int
749
- */
750
- public function count()
751
- {
752
- $this->load();
753
-
754
- return count($this->_items);
755
- }
756
-
757
- public function setCacheKey($key)
758
- {
759
- $this->_cacheKey = $key;
760
- return $this;
761
- }
762
-
763
- public function getCacheKey()
764
- {
765
- return $this->_cacheKey;
766
- }
767
-
768
- public function setCacheTags($tags)
769
- {
770
- $this->_cacheTags = $tags;
771
- return $this;
772
- }
773
-
774
- public function getCacheTags()
775
- {
776
- return $this->_cacheTags;
777
- }
778
-
779
- public function getCacheLifetime()
780
- {
781
- return $this->_cacheLifetime;
782
- }
783
-
784
- /**
785
- * Retrieve Flag
786
- *
787
- * @param string $flag
788
- * @return mixed
789
- */
790
- public function getFlag($flag)
791
- {
792
- return isset($this->_flags[$flag]) ? $this->_flags[$flag] : null;
793
- }
794
-
795
- /**
796
- * Set Flag
797
- *
798
- * @param string $flag
799
- * @param mixed $value
800
- * @return Varien_Data_Collection
801
- */
802
- public function setFlag($flag, $value = null)
803
- {
804
- $this->_flags[$flag] = $value;
805
- return $this;
806
- }
807
-
808
- /**
809
- * Has Flag
810
- *
811
- * @param string $flag
812
- * @return bool
813
- */
814
- public function hasFlag($flag)
815
- {
816
- return array_key_exists($flag, $this->_flags);
817
- }
818
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/design/adminhtml/default/default/layout/connector/email.xml ADDED
@@ -0,0 +1,78 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <adminhtml_email_dashboard_index>
4
+ <reference name="left">
5
+ <block type="adminhtml/system_config_switcher" name="store_switcher" as="store_switcher"
6
+ template="connector/dashboard/switcher.phtml">
7
+ <action method="setUseConfirm">
8
+ <params>0</params>
9
+ </action>
10
+ </block>
11
+ </reference>
12
+ <reference name="content">
13
+ <block type="email_connector/adminhtml_dashboard_content" template="connector/dashboard/content.phtml">
14
+ </block>
15
+ </reference>
16
+ </adminhtml_email_dashboard_index>
17
+ <adminhtml_email_contact_index>
18
+ <reference name="menu">
19
+ <action method="setActive">
20
+ <menupath>email_contact/email_connector_contact</menupath>
21
+ </action>
22
+ </reference>
23
+ <reference name="content">
24
+ <block type="email_connector/adminhtml_contact" name="email_contact">
25
+ <block type="adminhtml/store_switcher" name="store_switcher" as="store_switcher">
26
+ <action method="setUseConfirm"><params>0</params></action>
27
+ </block>
28
+ </block>
29
+ </reference>
30
+ </adminhtml_email_contact_index>
31
+ <adminhtml_email_contact_grid>
32
+ <block type="core/text_list" name="root" output="toHtml">
33
+ <block type="email_connector/adminhtml_contact_grid" name="contact_grid"/>
34
+ </block>
35
+ </adminhtml_email_contact_grid>
36
+ <adminhtml_email_contact_edit>
37
+ <reference name="menu">
38
+ <action method="setActive">
39
+ <menupath>email_contact</menupath>
40
+ </action>
41
+ </reference>
42
+ <reference name="content">
43
+ <block type="email_connector/adminhtml_contact_edit" name="email_contact_edit">
44
+ </block>
45
+ </reference>
46
+ </adminhtml_email_contact_edit>
47
+ <adminhtml_email_campaign_index>
48
+ <reference name="menu">
49
+ <action method="setActive">
50
+ <menupath>email_contact/email_connector_campaign</menupath>
51
+ </action>
52
+ </reference>
53
+ <reference name="content">
54
+ <block type="email_connector/adminhtml_campaign" name="email_campaign">
55
+ <block type="adminhtml/store_switcher" name="store_switcher" as="store_switcher">
56
+ <action method="setUseConfirm"><params>0</params></action>
57
+ </block>
58
+ </block>
59
+ </reference>
60
+ </adminhtml_email_campaign_index>
61
+ <adminhtml_email_campaign_grid>
62
+ <block type="core/text_list" name="root" output="toHtml">
63
+ <block type="email_connector/adminhtml_campaign_grid" name="campaign_grid"/>
64
+ </block>
65
+ </adminhtml_email_campaign_grid>
66
+ <adminhtml_email_campaign_edit>
67
+ <reference name="menu">
68
+ <action method="setActive">
69
+ <menupath>email_contact/email_conector_campaign</menupath>
70
+ </action>
71
+ </reference>
72
+ <reference name="content">
73
+ <block type="email_connector/adminhtml_campaign_edit" name="email_campaign_edit">
74
+ </block>
75
+ </reference>
76
+ </adminhtml_email_campaign_edit>
77
+
78
+ </config>
app/design/adminhtml/default/default/template/connector/dashboard/accountbar.phtml ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php if( sizeof($this->getTotals()) > 0 ): ?>
2
+ <?php foreach( $this->getTotals() as $_total ): ?>
3
+ <div class="entry-edit" style="width: 400px">
4
+ <div class="entry-edit-head"><h4><?php echo $_total['label'] ?></h4></div>
5
+ <fieldset class="a-center bold">
6
+ <span class="nowrap" style="font-size:18px;color:#EA7601;"><?php echo $_total['value'] ?><span style="font-size:14px; color:#686868;"><?php echo $_total['decimals'] ?></span></span>
7
+ </fieldset>
8
+ </div>
9
+ <?php endforeach; ?>
10
+ <?php endif; ?>
app/design/adminhtml/default/default/template/connector/dashboard/content.phtml ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ <div class="content-header">
2
+ <table cellspacing="0">
3
+ <tr>
4
+ <td style="<?php echo $this->getHeaderWidth() ?>"><?php echo $this->getHeaderHtml() ?></td>
5
+ <td class="form-buttons"><?php echo $this->getButtonsHtml() ?></td>
6
+ </tr>
7
+ </table>
8
+ </div>
app/design/adminhtml/default/default/template/connector/dashboard/switcher.phtml ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <div class="switcher">
2
+ <label for="store_switcher"><?php echo $this->__('Current Website') ?></label>
3
+ <?php echo $this->getHintHtml() ?>
4
+ <select id="store_switcher" class="system-config-store-switcher" onchange="location.href=this.options[this.selectedIndex].getAttribute('url')">
5
+ <?php foreach ($this->getStoreSelectOptions() as $_value => $_option): ?>
6
+ <?php if (isset($_option['is_group'])): ?>
7
+ <?php if ($_option['is_close']): ?>
8
+ </optgroup>
9
+ <?php else: ?>
10
+ <optgroup label="<?php echo $this->escapeHtml($_option['label']) ?>" style="<?php echo $_option['style'] ?>">
11
+ <?php endif; ?>
12
+ <?php continue ?>
13
+ <?php endif; ?>
14
+ <option value="<?php echo $this->escapeHtml($_value) ?>" url="<?php echo $_option['url'] ?>" <?php echo $_option['selected'] ? 'selected="selected"' : '' ?> style="<?php echo $_option['style'] ?>">
15
+ <?php echo $this->escapeHtml($_option['label']) ?>
16
+ </option>
17
+ <?php endforeach ?>
18
+ </select>
19
+ <?php if (Mage::getSingleton('admin/session')->isAllowed('system/store')): ?>
20
+ <p style="margin:10px 0 0;">
21
+ <a href="<?php echo $this->getUrl('*/system_store') ?>"><?php echo $this->__('Manage Stores') ?></a>
22
+ </p>
23
+ <?php endif; ?>
24
+ </div>
app/design/adminhtml/default/default/template/connector/grid.phtml ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <div class="content-header">
2
+ <table cellspacing="0">
3
+ <tr>
4
+ <td style="width:50%;"><h3 class="icon-head <?php echo $this->getHeadClass();?>"><?php echo $this->getHeaderText(); ?></h3></td>
5
+ <td class="a-right">
6
+ <?php echo $this->getButtonsHtml() ?>
7
+ </td>
8
+ </tr>
9
+ </table>
10
+ </div>
11
+ <?php if ( !Mage::app()->isSingleStoreMode() ): ?>
12
+ <?php echo $this->getChildHtml('store_switcher');?>
13
+ <?php endif;?>
14
+ <div>
15
+ <?php echo $this->getGridHtml() ?>
16
+ </div>
app/design/adminhtml/default/default/template/connector/system/config/createdatafield.phtml ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ <form action="<?php echo $this->getFormUrl(); ?>" id="connector_create_datafield" method="post">
3
+ <?php // echo $this->getBlockHtml('formkey')?>
4
+ <?php echo $this->getButtonHtml(); ?>
5
+ </form>
6
+
7
+
8
+ <form action="<?php echo $this->getPreviewUrl() ?>" method="post" id="emv_template_preview_form" target="_blank" >
9
+ <?php echo $this->getBlockHtml('formkey')?>
10
+ <div class="no-display">
11
+ <input type="hidden" id="preview_mage_template_id" name="mage_template_id" value="" />
12
+ <input type="hidden" id="preview_emv_send_mail_mode_id" name="emv_send_mail_mode_id" value="" />
13
+ <input type="hidden" id="preview_emv_template_id" name="emv_template_id" value="" />
14
+ <input type="hidden" id="preview_emv_account_id" name="emv_account_id" value="" />
15
+ <div id="preview-attribute-value"></div>
16
+ </div>
17
+ </form>
app/design/frontend/base/default/layout/connector.xml CHANGED
@@ -10,28 +10,20 @@
10
  <block type="checkout/onepage_success" name="checkout.roi" as="connector.roi" template="connector/roi_code.phtml"/>
11
  </reference>
12
  </checkout_onepage_success>
13
- <connector_email_products>
14
- <reference name="root">
15
- <action method="setTemplate"><template>page/blank.phtml</template></action>
16
- </reference>
17
- <reference name="content">
18
- <block type="connector/products" name="email.products" as="email.products" template="page/connector/products.phtml"/>
19
- </reference>
20
- </connector_email_products>
21
  <connector_email_coupon>
22
  <reference name="root">
23
  <action method="setTemplate"><template>page/blank.phtml</template></action>
24
  </reference>
25
  <reference name="content">
26
- <block type="connector/coupon" name="email.coupon" as="email.coupon" template="connector/coupon.phtml"/>
27
  </reference>
28
  </connector_email_coupon>
29
- <connector_email_basket>
30
  <reference name="root">
31
  <action method="setTemplate"><template>page/blank.phtml</template></action>
32
  </reference>
33
  <reference name="content">
34
- <block type="connector/basket" name="email.basket" as="email.basket" template="connector/basket.phtml"/>
35
  </reference>
36
- </connector_email_basket>
37
  </layout>
10
  <block type="checkout/onepage_success" name="checkout.roi" as="connector.roi" template="connector/roi_code.phtml"/>
11
  </reference>
12
  </checkout_onepage_success>
 
 
 
 
 
 
 
 
13
  <connector_email_coupon>
14
  <reference name="root">
15
  <action method="setTemplate"><template>page/blank.phtml</template></action>
16
  </reference>
17
  <reference name="content">
18
+ <block type="email_connector/coupon" name="email.coupon" as="email.coupon" template="connector/coupon.phtml"/>
19
  </reference>
20
  </connector_email_coupon>
21
+ <connector_order_update>
22
  <reference name="root">
23
  <action method="setTemplate"><template>page/blank.phtml</template></action>
24
  </reference>
25
  <reference name="content">
26
+ <block type="email_connector/order_update" name="connector.order.update" as="connector.order.update" template="connector/sales/order/update.phtml"/>
27
  </reference>
28
+ </connector_order_update>
29
  </layout>
app/design/frontend/base/default/template/connector/basket.phtml CHANGED
@@ -39,7 +39,7 @@ $helper = Mage::helper('core');
39
  ?>
40
  <tr>
41
  <td style="padding: 1px; border-bottom: 1px solid #cbd3d4; border-right: 1px solid #cbd3d4;">
42
- <img alt="" src="<?php echo $img;?>" width="85" align="absmiddle" border="0" height="85">
43
  </td>
44
  <td style="padding: 1px; border-bottom: 1px solid #cbd3d4; border-right: 1px solid #cbd3d4;">Product Name : <a href="<?php echo $productUrl;?>"><?php echo $name . '</a></br>'. $inStock;?></td>
45
  <td style="padding: 1px; border-bottom: 1px solid #cbd3d4; border-right: 1px solid #cbd3d4;"><?php echo (int)$one->getQty();?></td>
39
  ?>
40
  <tr>
41
  <td style="padding: 1px; border-bottom: 1px solid #cbd3d4; border-right: 1px solid #cbd3d4;">
42
+ <img alt="" src="<?php echo $img;?>" width="85" align="middle" border="0" height="85">
43
  </td>
44
  <td style="padding: 1px; border-bottom: 1px solid #cbd3d4; border-right: 1px solid #cbd3d4;">Product Name : <a href="<?php echo $productUrl;?>"><?php echo $name . '</a></br>'. $inStock;?></td>
45
  <td style="padding: 1px; border-bottom: 1px solid #cbd3d4; border-right: 1px solid #cbd3d4;"><?php echo (int)$one->getQty();?></td>
app/design/frontend/base/default/template/connector/creditmemo/items.phtml ADDED
@@ -0,0 +1,140 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php $_order = $this->getOrder();
2
+ $creditmemoItems = $this->getCreditmemoItems();
3
+ ?>
4
+ <table cellspacing="0" cellpadding="0" border="0" width="650">
5
+ <thead>
6
+ <tr>
7
+ <th align="left" width="325" bgcolor="#EAEAEA" style="font-size:13px; padding:5px 9px 6px 9px; line-height:1em;">Item</th>
8
+ <th align="left" width="325" bgcolor="#EAEAEA" style="font-size:13px; padding:5px 9px 6px 9px; line-height:1em;">SKU</th>
9
+ <th align="left" width="325" bgcolor="#EAEAEA" style="font-size:13px; padding:5px 9px 6px 9px; line-height:1em;">Qty</th>
10
+ <th align="left" width="325" bgcolor="#EAEAEA" style="font-size:13px; padding:5px 9px 6px 9px; line-height:1em;">Subtotal</th>
11
+ </tr>
12
+ </thead>
13
+ <tbody>
14
+
15
+
16
+ <?php $i=0; foreach ($creditmemoItems as $_item): $i++ ?>
17
+ <?php
18
+ if($_item->getParentItemId()) continue;?>
19
+ <tr <?php echo $i%2?'bgcolor="#eeeded"':'' ?>>
20
+ <td valign="top" style="font-size:12px; padding:7px 9px 9px 9px; border-left:1px solid #EAEAEA; border-bottom:1px solid #EAEAEA; border-right:1px solid #EAEAEA;" width="70%"><?php echo $_item->getName() ?></td>
21
+ <td valign="top" style="font-size:12px; padding:7px 9px 9px 9px; border-left:1px solid #EAEAEA; border-bottom:1px solid #EAEAEA; border-right:1px solid #EAEAEA;"><?php echo $_item->getSku();?></td>
22
+ <td valign="top" style="font-size:12px; padding:7px 9px 9px 9px; border-left:1px solid #EAEAEA; border-bottom:1px solid #EAEAEA; border-right:1px solid #EAEAEA;"><?php echo sprintf('%s', $_item->getQtyOrdered()) ?></td>
23
+ <td valign="top" style="font-size:12px; padding:7px 9px 9px 9px; border-left:1px solid #EAEAEA; border-bottom:1px solid #EAEAEA; border-right:1px solid #EAEAEA;">
24
+ <?php if ($this->helper('tax')->displayCartPriceExclTax() || $this->helper('tax')->displayCartBothPrices()): ?>
25
+ <?php if ($this->helper('tax')->displayCartBothPrices()): ?>
26
+ <span class="label"><?php echo $this->__('Excl. Tax'); ?>:</span>
27
+ <?php endif; ?>
28
+ <?php if (Mage::helper('weee')->typeOfDisplay($_item, array(0, 1, 4), 'email', $_order->getStore())): ?>
29
+ <?php echo $_order->formatPrice($_item->getRowTotal()+$_item->getWeeeTaxAppliedRowAmount()+$_item->getWeeeTaxRowDisposition()); ?>
30
+ <?php else: ?>
31
+ <?php echo $_order->formatPrice($_item->getRowTotal()) ?>
32
+ <?php endif; ?>
33
+
34
+ <?php if (Mage::helper('weee')->getApplied($_item)): ?>
35
+ <br />
36
+ <?php if (Mage::helper('weee')->typeOfDisplay($_item, 1, 'email', $_order->getStore())): ?>
37
+ <small>
38
+ <?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
39
+ <span class="nobr"><?php echo $tax['title']; ?>: <?php echo $_order->formatPrice($tax['row_amount'],true,true); ?></span><br />
40
+ <?php endforeach; ?>
41
+ </small>
42
+ <?php elseif (Mage::helper('weee')->typeOfDisplay($_item, 2, 'email', $_order->getStore())): ?>
43
+ <?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
44
+ <span class="nobr"><small><?php echo $tax['title']; ?>: <?php echo $_order->formatPrice($tax['row_amount_incl_tax'],true,true); ?></small></span><br />
45
+ <?php endforeach; ?>
46
+ <?php elseif (Mage::helper('weee')->typeOfDisplay($_item, 4, 'email', $_order->getStore())): ?>
47
+ <small>
48
+ <?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
49
+ <span class="nobr"><?php echo $tax['title']; ?>: <?php echo $_order->formatPrice($tax['row_amount_incl_tax'],true,true); ?></span><br />
50
+ <?php endforeach; ?>
51
+ </small>
52
+ <?php endif; ?>
53
+
54
+ <?php if (Mage::helper('weee')->typeOfDisplay($_item, 2, 'email', $_order->getStore())): ?>
55
+ <br />
56
+ <span class="nobr"><?php echo Mage::helper('weee')->__('Total'); ?>:<br /> <?php echo $_order->formatPrice($_item->getCalculationPrice()+$_item->getWeeeTaxAppliedRowAmount()+$_item->getWeeeTaxRowDisposition()); ?></span>
57
+ <?php endif; ?>
58
+ <?php endif; ?>
59
+ <?php endif; ?>
60
+
61
+
62
+ <?php if ($this->helper('tax')->displayCartPriceInclTax() || $this->helper('tax')->displayCartBothPrices()): ?>
63
+ <?php if ($this->helper('tax')->displayCartBothPrices()): ?>
64
+ <br /><span class="label"><?php echo $this->__('Incl. Tax'); ?>:</span>
65
+ <?php endif; ?>
66
+ <?php $_incl = $this->helper('checkout')->getSubtotalInclTax($_item); ?>
67
+ <?php if (Mage::helper('weee')->typeOfDisplay($_item, array(0, 1, 4), 'email', $_order->getStore())): ?>
68
+ <?php echo $_order->formatPrice($_incl+$_item->getWeeeTaxAppliedRowAmount()); ?>
69
+ <?php else: ?>
70
+ <?php echo $_order->formatPrice($_incl-$_item->getWeeeTaxRowDisposition()) ?>
71
+ <?php endif; ?>
72
+ <?php if (Mage::helper('weee')->getApplied($_item)): ?>
73
+ <br />
74
+ <?php if (Mage::helper('weee')->typeOfDisplay($_item, 1, 'email', $_order->getStore())): ?>
75
+ <small>
76
+ <?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
77
+ <span class="nobr"><?php echo $tax['title']; ?>: <?php echo $_order->formatPrice($tax['row_amount'],true,true); ?></span><br />
78
+ <?php endforeach; ?>
79
+ </small>
80
+ <?php elseif (Mage::helper('weee')->typeOfDisplay($_item, 2, 'email', $_order->getStore())): ?>
81
+ <?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
82
+ <span class="nobr"><small><?php echo $tax['title']; ?>: <?php echo $_order->formatPrice($tax['row_amount_incl_tax'],true,true); ?></small></span><br />
83
+ <?php endforeach; ?>
84
+ <?php elseif (Mage::helper('weee')->typeOfDisplay($_item, 4, 'email', $_order->getStore())): ?>
85
+ <small>
86
+ <?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
87
+ <span class="nobr"><?php echo $tax['title']; ?>: <?php echo $_order->formatPrice($tax['row_amount_incl_tax'],true,true); ?></span><br />
88
+ <?php endforeach; ?>
89
+ </small>
90
+ <?php endif; ?>
91
+
92
+ <?php if (Mage::helper('weee')->typeOfDisplay($_item, 2, 'email', $_order->getStore())): ?>
93
+ <span class="nobr"><?php echo Mage::helper('weee')->__('Total incl. tax'); ?>:<br /> <?php echo $_order->formatPrice($_incl+$_item->getWeeeTaxAppliedRowAmount()); ?></span>
94
+ <?php endif; ?>
95
+ <?php endif; ?>
96
+ <?php endif; ?>
97
+ </td>
98
+ </tr>
99
+ <?php endforeach ?>
100
+
101
+ </tbody>
102
+ <tfoot>
103
+
104
+ <tr>
105
+ <td></td>
106
+ <td colspan="2" align="right" style="padding:3px 9px"><?php echo Mage::helper('sales')->__('Subtotal') ?></td>
107
+ <td align="right" style="padding:3px 9px"><?php echo $_order->formatPrice($_order->getSubtotal()) ?></td>
108
+ </tr>
109
+ <?php
110
+
111
+ if ($_order->getDiscountAmount() > 0): ?>
112
+ <tr>
113
+ <td></td>
114
+ <td colspan="2" align="right" style="padding:3px 9px"><?php echo Mage::helper('sales')->__('Discount') ?></td>
115
+ <td align="right" style="padding:3px 9px"><?php echo $_order->formatPrice($_order->getDiscountAmount()) ?></td>
116
+ </tr>
117
+ <?php endif; ?>
118
+ <?php if ($_order->getShippingAmount() > 0): ?>
119
+ <tr>
120
+ <td></td>
121
+ <td colspan="2" align="right" style="padding:3px 9px"><?php echo Mage::helper('sales')->__('Shipping Amount') ?></td>
122
+ <td align="right" style="padding:3px 9px"><?php echo $_order->formatPrice($_order->getShippingAmount()) ?></td>
123
+ </tr>
124
+ <?php endif; ?>
125
+ <?php if ($_order->getTaxAmount() > 0): ?>
126
+ <tr>
127
+ <td></td>
128
+ <td colspan="2" align="right" style="padding:3px 9px"><?php echo Mage::helper('sales')->__('Tax Amount') ?></td>
129
+ <td align="right" style="padding:3px 9px"><?php echo $_order->formatPrice($_order->getTaxAmount()) ?></td>
130
+ </tr>
131
+ <?php endif; ?>
132
+ <tr>
133
+ <td></td>
134
+ <td colspan="2" align="right" style="padding:3px 9px"><strong><?php echo Mage::helper('sales')->__('Grand Total') ?></strong></td>
135
+ <td align="right" style="padding:6px 9px"><strong><?php echo $_order->formatPrice($_order->getGrandTotal()) ?></strong></td>
136
+ </tr>
137
+ </tfoot>
138
+ </table>
139
+
140
+
app/design/frontend/base/default/template/connector/creditmemo/new.phtml ADDED
@@ -0,0 +1,77 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php $order = $this->getOrder();
2
+ $creditmemo = $order->getCreditmemosCollection()->getFirstItem();
3
+ $paymentBlock = Mage::helper('payment')->getInfoBlock($order->getPayment());
4
+ ?>
5
+ <style>
6
+ <?php echo Mage::getStoreConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_TRANSACTIONAL_STYLING);?>
7
+ </style>
8
+ <body style="font-family:Verdana, Arial, Helvetica, sans-serif; font-size:12px; margin:0; padding:0;">
9
+ <div style="font-family:Verdana, Arial, Helvetica, sans-serif; font-size:12px; margin:0; padding:0;">
10
+ <table cellspacing="0" cellpadding="0" border="0" width="100%">
11
+ <tr>
12
+ <td align="center" valign="top" style="padding:20px 0 20px 0">
13
+ <!-- [ header starts here] -->
14
+ <table bgcolor="#FFFFFF" cellspacing="0" cellpadding="10" border="0" width="650" style="border:1px solid #E0E0E0;">
15
+ <!-- [ middle starts here] -->
16
+ <tr>
17
+ <td>
18
+ <h2 style="font-size:18px; font-weight:normal; margin:0;">Your Credit Memo #<?php echo $creditmemo->getIncrementId();?> for Order #<?php echo $order->getIncrementId();?></h2>
19
+ </td>
20
+ </tr>
21
+ <tr>
22
+ <td>
23
+ <table cellspacing="0" cellpadding="0" border="0" width="650">
24
+ <thead>
25
+ <tr>
26
+ <th align="left" width="325" bgcolor="#EAEAEA" style="font-size:13px; padding:5px 9px 6px 9px; line-height:1em;">Billing Information:</th>
27
+ <th width="10"></th>
28
+ <th align="left" width="325" bgcolor="#EAEAEA" style="font-size:13px; padding:5px 9px 6px 9px; line-height:1em;">Payment Method:</th>
29
+ </tr>
30
+ </thead>
31
+ <tbody>
32
+ <tr>
33
+ <td valign="top" style="font-size:12px; padding:7px 9px 9px 9px; border-left:1px solid #EAEAEA; border-bottom:1px solid #EAEAEA; border-right:1px solid #EAEAEA;">
34
+ <?php echo $order->getBillingAddress()->format('html');?>
35
+ </td>
36
+ <td>&nbsp;</td>
37
+ <td valign="top" style="font-size:12px; padding:7px 9px 9px 9px; border-left:1px solid #EAEAEA; border-bottom:1px solid #EAEAEA; border-right:1px solid #EAEAEA;">
38
+ <?php echo $paymentBlock->toHtml();?>
39
+ </td>
40
+ </tr>
41
+ </tbody>
42
+ </table>
43
+ <br/>
44
+ <?php if($order->getIsNotVirtual()):?>
45
+ <table cellspacing="0" cellpadding="0" border="0" width="650">
46
+ <thead>
47
+ <tr>
48
+ <th align="left" width="325" bgcolor="#EAEAEA" style="font-size:13px; padding:5px 9px 6px 9px; line-height:1em;">Shipping Information:</th>
49
+ <th width="10"></th>
50
+ <th align="left" width="325" bgcolor="#EAEAEA" style="font-size:13px; padding:5px 9px 6px 9px; line-height:1em;">Shipping Method:</th>
51
+ </tr>
52
+ </thead>
53
+ <tbody>
54
+ <tr>
55
+ <td valign="top" style="font-size:12px; padding:7px 9px 9px 9px; border-left:1px solid #EAEAEA; border-bottom:1px solid #EAEAEA; border-right:1px solid #EAEAEA;">
56
+ <?php echo $order->getShippingAddress()->format('html');?>
57
+ &nbsp;
58
+ </td>
59
+ <td>&nbsp;</td>
60
+ <td valign="top" style="font-size:12px; padding:7px 9px 9px 9px; border-left:1px solid #EAEAEA; border-bottom:1px solid #EAEAEA; border-right:1px solid #EAEAEA;">
61
+ <?php echo $order->getShippingDescription();?>
62
+ &nbsp;
63
+ </td>
64
+ </tr>
65
+ </tbody>
66
+ </table>
67
+ <br/>
68
+ <?php endif;?>
69
+ <?php echo $this->getChildHtml('connector_creditmemo_items');?>
70
+ </td>
71
+ </tr>
72
+ </table>
73
+ </td>
74
+ </tr>
75
+ </table>
76
+ </div>
77
+ </body>
app/design/frontend/base/default/template/connector/creditmemo/newguest.phtml ADDED
@@ -0,0 +1,78 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php $order = $this->getOrder();
2
+ $creditmemo = $order->getCreditmemosCollection()->getFirstItem();
3
+ $billing = $order->getBillingAddress();
4
+ $paymentBlock = Mage::helper('payment')->getInfoBlock($order->getPayment());
5
+ ?>
6
+ <style>
7
+ <?php echo Mage::getStoreConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_TRANSACTIONAL_STYLING);?>
8
+ </style>
9
+ <body style=" font-family:Verdana, Arial, Helvetica, sans-serif; font-size:12px; margin:0; padding:0;">
10
+ <div style=" font-family:Verdana, Arial, Helvetica, sans-serif; font-size:12px; margin:0; padding:0;">
11
+ <table cellspacing="0" cellpadding="0" border="0" width="100%">
12
+ <tr>
13
+ <td align="center" valign="top" style="padding:20px 0 20px 0">
14
+ <!-- [ header starts here] -->
15
+ <table bgcolor="#FFFFFF" cellspacing="0" cellpadding="10" border="0" width="650" style="border:1px solid #E0E0E0;">
16
+ <!-- [ middle starts here] -->
17
+ <tr>
18
+ <td>
19
+ <h2 style="font-size:18px; font-weight:normal; margin:0;">Your Credit Memo #<?php echo $creditmemo->getIncrementId();?> for Order #<?php echo $order->getIncrementId();?></h2>
20
+ </td>
21
+ </tr>
22
+ <tr>
23
+ <td>
24
+ <table cellspacing="0" cellpadding="0" border="0" width="650">
25
+ <thead>
26
+ <tr>
27
+ <th align="left" width="325" bgcolor="#EAEAEA" style="font-size:13px; padding:5px 9px 6px 9px; line-height:1em;">Billing Information:</th>
28
+ <th width="10"></th>
29
+ <th align="left" width="325" bgcolor="#EAEAEA" style="font-size:13px; padding:5px 9px 6px 9px; line-height:1em;">Payment Method:</th>
30
+ </tr>
31
+ </thead>
32
+ <tbody>
33
+ <tr>
34
+ <td valign="top" style="font-size:12px; padding:7px 9px 9px 9px; border-left:1px solid #EAEAEA; border-bottom:1px solid #EAEAEA; border-right:1px solid #EAEAEA;">
35
+ <?php echo $order->getBillingAddress()->format('html');?>
36
+ </td>
37
+ <td>&nbsp;</td>
38
+ <td valign="top" style="font-size:12px; padding:7px 9px 9px 9px; border-left:1px solid #EAEAEA; border-bottom:1px solid #EAEAEA; border-right:1px solid #EAEAEA;">
39
+ <?php echo $paymentBlock->toHtml();?>
40
+ </td>
41
+ </tr>
42
+ </tbody>
43
+ </table>
44
+ <br/>
45
+ <?php if($order->getIsNotVirtual()):?>
46
+ <table cellspacing="0" cellpadding="0" border="0" width="650">
47
+ <thead>
48
+ <tr>
49
+ <th align="left" width="325" bgcolor="#EAEAEA" style="font-size:13px; padding:5px 9px 6px 9px; line-height:1em;">Shipping Information:</th>
50
+ <th width="10"></th>
51
+ <th align="left" width="325" bgcolor="#EAEAEA" style="font-size:13px; padding:5px 9px 6px 9px; line-height:1em;">Shipping Method:</th>
52
+ </tr>
53
+ </thead>
54
+ <tbody>
55
+ <tr>
56
+ <td valign="top" style="font-size:12px; padding:7px 9px 9px 9px; border-left:1px solid #EAEAEA; border-bottom:1px solid #EAEAEA; border-right:1px solid #EAEAEA;">
57
+ <?php echo $order->getShippingAddress()->format('html');?>
58
+ &nbsp;
59
+ </td>
60
+ <td>&nbsp;</td>
61
+ <td valign="top" style="font-size:12px; padding:7px 9px 9px 9px; border-left:1px solid #EAEAEA; border-bottom:1px solid #EAEAEA; border-right:1px solid #EAEAEA;">
62
+ <?php echo $order->getShippingDescription();?>
63
+ &nbsp;
64
+ </td>
65
+ </tr>
66
+ </tbody>
67
+ </table>
68
+ <br/>
69
+ <?php endif;?>
70
+ <?php echo $this->getChildHtml('connector_creditmemo_items');?>
71
+ </td>
72
+ </tr>
73
+ </table>
74
+ </td>
75
+ </tr>
76
+ </table>
77
+ </div>
78
+ </body>
app/design/frontend/base/default/template/connector/creditmemo/update.phtml ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php $order = $this->getOrder();
2
+ $creditmemo = $order->getCreditmemosCollection()->getFirstItem();
3
+ $comment = $creditmemo->getCommentsCollection()->getFirstItem()->getComment();
4
+ ?>
5
+ <style>
6
+ <?php echo Mage::getStoreConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_TRANSACTIONAL_STYLING);?>
7
+ </style>
8
+ <body style="font-family:Verdana, Arial, Helvetica, sans-serif; font-size:12px; margin:0; padding:0;">
9
+ <div style="font-family:Verdana, Arial, Helvetica, sans-serif; font-size:12px; margin:0; padding:0;">
10
+ <table cellspacing="0" cellpadding="0" border="0" height="100%" width="100%">
11
+ <tr>
12
+ <td align="center" valign="top" style="padding:20px 0 20px 0">
13
+ <!-- [ header starts here] -->
14
+ <table bgcolor="#FFFFFF" cellspacing="0" cellpadding="10" border="0" width="650" style="border:1px solid #E0E0E0;">
15
+ <!-- [ middle starts here] -->
16
+ <tr>
17
+ <td valign="top">
18
+ <p style="font-size:12px; line-height:16px; margin:0 0 10px 0;">
19
+ Your order # <?php echo $order->getIncrementId();?> has been <br/>
20
+ <strong><?php echo $order->getStatusLabel();?></strong>.
21
+ </p>
22
+ <p style="font-size:12px; line-height:16px; margin:0 0 10px 0;">You can check the status of your order by <a href="<?php echo $this->getBaseUrl();?>customer/account/" style="color:#1E7EC8;">logging into your account</a>.</p>
23
+ <p style="font-size:12px; line-height:16px; margin:0 0 10px 0;"><?php echo $comment;?></p>
24
+ </td>
25
+ </tr>
26
+ </table>
27
+ </td>
28
+ </tr>
29
+ </table>
30
+ </div>
31
+ </body>
app/design/frontend/base/default/template/connector/creditmemo/updateguest.phtml ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php $order = $this->getOrder();
2
+ $creditmemo = $order->getCreditmemosCollection()->getFirstItem();
3
+ $billing = $order->getBillingAddress();
4
+ $comment = $creditmemo->getCommentsCollection()->getFirstItem()->getComment();
5
+ ?>
6
+ <style>
7
+ <?php echo Mage::getStoreConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_TRANSACTIONAL_STYLING);?>
8
+ </style>
9
+ <body style="font-family:Verdana, Arial, Helvetica, sans-serif; font-size:12px; margin:0; padding:0;">
10
+ <div style="font-family:Verdana, Arial, Helvetica, sans-serif; font-size:12px; margin:0; padding:0;">
11
+ <table cellspacing="0" cellpadding="0" border="0" height="100%" width="100%">
12
+ <tr>
13
+ <td align="center" valign="top" style="padding:20px 0 20px 0">
14
+ <!-- [ header starts here] -->
15
+ <table bgcolor="#FFFFFF" cellspacing="0" cellpadding="10" border="0" width="650" style="border:1px solid #E0E0E0;">
16
+ <!-- [ middle starts here] -->
17
+ <tr>
18
+ <td valign="top">
19
+ <p style="font-size:12px; line-height:16px; margin:0 0 10px 0;">
20
+ Your order # <?php echo $order->getIncrementId();?> has been <br/>
21
+ <strong><?php echo $order->getStatusLabel();?></strong>.
22
+ </p>
23
+ <p style="font-size:12px; line-height:16px; margin:0 0 10px 0;"><?php echo $comment;?></p>
24
+ </td>
25
+ </tr>
26
+ </table>
27
+ </td>
28
+ </tr>
29
+ </table>
30
+ </div>
31
+ </body>
app/design/frontend/base/default/template/connector/customer.phtml ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ $products = $this->getRecommendedProducts();
3
+ $displayType = $this->getDisplayType();
4
+ $i = 0;
5
+ foreach ($products as $key => $_product) :?>
6
+ <?php if($i == 0):?>
7
+ <table border="0" bordercolor="#FFCC00" width="147" cellpadding="0" cellspacing="0" style='font-family:arial; border-collapse: collapse; font-size:12;'><tr>
8
+ <?php endif;?>
9
+ <?php
10
+ //LIST MODE
11
+ if($displayType == 'list'){
12
+ echo '</tr><tr>';
13
+ }?>
14
+
15
+ <td style="vertical-align: text-top; padding-right: 2px;">
16
+
17
+ <a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" class="product-image"><img src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize(135); ?>" width="140" height="135" alt="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" align="middle" /></a>
18
+
19
+ <div align="center"><b><?php echo substr($_product->getName(), 0, 40);?></b></div>
20
+
21
+ <div align="center"><?php echo $this->getPriceHtml($_product, true);?></div>
22
+ <div align="center"><a href="<?php echo $_product->getProductUrl();?>">View Now</a></div>
23
+ </td>