dotmailermagento - Version 3.3.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.3.2
Comparing to
See all releases


Code changes from version 1.5.1 to 3.3.2

Files changed (260) 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 +212 -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.php +18 -0
  9. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Config/Customdatafields.php +112 -0
  10. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Config/Select.php +14 -0
  11. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Config/Template/Templatefields.php +188 -0
  12. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Contact.php +18 -0
  13. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Contact/Edit.php +36 -0
  14. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Contact/Edit/Form.php +26 -0
  15. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Contact/Grid.php +207 -0
  16. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Dashboard.php +52 -0
  17. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Dashboard/Switcher.php +92 -0
  18. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Dashboard/Tabs.php +58 -0
  19. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Dashboard/Tabs/Analysis.php +61 -0
  20. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Dashboard/Tabs/Analysis/Abandonedcarts.php +57 -0
  21. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Dashboard/Tabs/Analysis/Customer.php +55 -0
  22. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Dashboard/Tabs/Analysis/Rfm.php +91 -0
  23. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Dashboard/Tabs/Analysis/Sales.php +54 -0
  24. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Dashboard/Tabs/Analysis/Subscriber.php +56 -0
  25. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Dashboard/Tabs/Config.php +120 -0
  26. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Dashboard/Tabs/General.php +107 -0
  27. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Dashboard/Tabs/General/Data.php +43 -0
  28. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Dashboard/Tabs/Status.php +1625 -0
  29. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Order.php +15 -0
  30. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Order/Grid.php +110 -0
  31. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Review.php +15 -0
  32. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Review/Grid.php +109 -0
  33. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Sales/Order/Creditmemo/View.php +196 -0
  34. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Advanced/.DS_Store +0 -0
  35. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Advanced/Deletecontactids.php +22 -0
  36. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Advanced/Notification.php +11 -0
  37. app/code/{local/Dotdigitalgroup/Email/Block/Debug/Countcontacts.php → community/Dotdigitalgroup/Email/Block/Adminhtml/System/Advanced/Reimportorders.php} +7 -6
  38. app/code/{local/Dotdigitalgroup/Email/Block/Debug/Deletecontacts.php → community/Dotdigitalgroup/Email/Block/Adminhtml/System/Advanced/Reimportsubscribers.php} +7 -6
  39. app/code/{local/Dotdigitalgroup/Email/Block/Debug/Initialsync.php → community/Dotdigitalgroup/Email/Block/Adminhtml/System/Advanced/Resetcustomersimport.php} +9 -7
  40. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Advanced/Runcontactsync.php +22 -0
  41. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Advanced/Runordersync.php +22 -0
  42. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Advanced/Runreviewsync.php +22 -0
  43. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Advanced/Runsubscribersync.php +22 -0
  44. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Advanced/Runwishlistsync.php +22 -0
  45. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Advanced/Setupdatafields.php +24 -0
  46. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Advanced/Suppressedcontacts.php +23 -0
  47. app/code/{local/Dotdigitalgroup/Email/Block/Adminhtml/System/Config/Password.php → community/Dotdigitalgroup/Email/Block/Adminhtml/System/Ajaxvalidate.php} +1 -1
  48. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Automation/Connect.php +41 -0
  49. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Config/Addressbook.php +39 -0
  50. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Config/Datafield.php +41 -0
  51. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Config/Resetcontacts.php +28 -0
  52. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Config/Resetguests.php +28 -0
  53. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Config/Resetsubscribers.php +28 -0
  54. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Config/Validator.php +87 -0
  55. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Config/Waitingfield.php +65 -0
  56. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Config/Wrapper.php +59 -0
  57. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Dynamic/Addressbookbutton.php +22 -0
  58. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Dynamic/Basket/Crosssell.php +26 -0
  59. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Dynamic/Basket/Related.php +27 -0
  60. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Dynamic/Basket/Upsell.php +25 -0
  61. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Dynamic/Bestsellers.php +24 -0
  62. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Dynamic/Couponinfo.php +26 -0
  63. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Dynamic/Creditmemonew.php +25 -0
  64. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Dynamic/Crosssell.php +26 -0
  65. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Dynamic/Datafieldbutton.php +21 -0
  66. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Dynamic/Fallbackchooser.php +25 -0
  67. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Dynamic/Fallbackcontainer.php +27 -0
  68. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Dynamic/Gridlist.php +106 -0
  69. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Dynamic/Lostbasket.php +23 -0
  70. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Dynamic/Manualchooser.php +25 -0
  71. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Dynamic/Manualcontainer.php +27 -0
  72. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Dynamic/Mostviewed.php +21 -0
  73. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Dynamic/Nosto.php +22 -0
  74. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Dynamic/Productpush.php +21 -0
  75. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Dynamic/Recentlyviewed.php +24 -0
  76. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Dynamic/Related.php +26 -0
  77. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Dynamic/Review.php +29 -0
  78. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Dynamic/Upsell.php +24 -0
  79. app/code/{local/Dotdigitalgroup/Email/Block/Adminhtml/System/Config/Wrapper.php → community/Dotdigitalgroup/Email/Block/Adminhtml/System/Emailapivalidate.php} +9 -8
  80. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Sms/Smsmessagefour.php +24 -0
  81. app/code/{local/Dotdigitalgroup/Email/Block/Adminhtml/System/Config → community/Dotdigitalgroup/Email/Block/Adminhtml/System/Sms}/Smsmessageone.php +13 -8
  82. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Sms/Smsmessagethree.php +26 -0
  83. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Sms/Smsmessagetwo.php +25 -0
  84. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Url/Creditmemoupdate.php +32 -0
  85. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Url/Creditmemoupdateguest.php +30 -0
  86. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Url/Customerconfirmation.php +36 -0
  87. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Url/Customerconfirmed.php +36 -0
  88. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Url/Customernew.php +36 -0
  89. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Url/Invoiceupdate.php +33 -0
  90. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Url/Invoiceupdateguest.php +33 -0
  91. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Url/Newcreditmemo.php +36 -0
  92. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Url/Newcreditmemoguest.php +35 -0
  93. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Url/Newinvoice.php +34 -0
  94. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Url/Newinvoiceguest.php +34 -0
  95. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Url/Neworder.php +33 -0
  96. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Url/Neworderguest.php +32 -0
  97. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Url/Newshipment.php +34 -0
  98. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Url/Newshipmentguest.php +33 -0
  99. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Url/Orderupdate.php +31 -0
  100. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Url/Orderupdateguest.php +31 -0
  101. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Url/Shipmentupdate.php +33 -0
  102. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Url/Shipmentupdateguest.php +32 -0
  103. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Widget/Chooser/Product.php +163 -0
  104. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Wishlist.php +15 -0
  105. app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Wishlist/Grid.php +120 -0
  106. app/code/{local → community}/Dotdigitalgroup/Email/Block/Basket.php +28 -9
  107. app/code/{local → community}/Dotdigitalgroup/Email/Block/Coupon.php +13 -12
  108. app/code/community/Dotdigitalgroup/Email/Block/Order.php +83 -0
  109. app/code/community/Dotdigitalgroup/Email/Block/Order/Creditmemo.php +48 -0
  110. app/code/community/Dotdigitalgroup/Email/Block/Order/Invoice.php +39 -0
  111. app/code/community/Dotdigitalgroup/Email/Block/Order/Shipping.php +39 -0
  112. app/code/community/Dotdigitalgroup/Email/Block/Products.php +67 -0
  113. app/code/community/Dotdigitalgroup/Email/Block/Recommended/Bestsellers.php +65 -0
  114. app/code/community/Dotdigitalgroup/Email/Block/Recommended/Mostviewed.php +66 -0
  115. app/code/community/Dotdigitalgroup/Email/Block/Recommended/Products.php +194 -0
  116. app/code/community/Dotdigitalgroup/Email/Block/Recommended/Push.php +66 -0
  117. app/code/community/Dotdigitalgroup/Email/Block/Recommended/Quoteproducts.php +149 -0
  118. app/code/community/Dotdigitalgroup/Email/Block/Recommended/Recentlyviewed.php +73 -0
  119. app/code/community/Dotdigitalgroup/Email/Helper/Config.php +190 -0
  120. app/code/community/Dotdigitalgroup/Email/Helper/Data.php +512 -0
  121. app/code/{local → community}/Dotdigitalgroup/Email/Helper/File.php +78 -29
  122. app/code/community/Dotdigitalgroup/Email/Helper/Recommended.php +178 -0
  123. app/code/community/Dotdigitalgroup/Email/Helper/Review.php +90 -0
  124. app/code/community/Dotdigitalgroup/Email/Helper/Transactional.php +298 -0
  125. app/code/community/Dotdigitalgroup/Email/Model/Abstract/Rest.php +435 -0
  126. app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Dashboard/Content.php +121 -0
  127. app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Dashboard/Tabs/Analysis/Abandoned.php +59 -0
  128. app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Dashboard/Tabs/Analysis/Customer.php +48 -0
  129. app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Dashboard/Tabs/Analysis/Orders.php +122 -0
  130. app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Dashboard/Tabs/Analysis/Rfm.php +173 -0
  131. app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Dashboard/Tabs/Analysis/Subscriber.php +91 -0
  132. app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Observer.php +214 -0
  133. app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Source/Addressbooks.php +51 -0
  134. app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Source/Advanced/Abandonedlimit.php +43 -0
  135. app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Source/Advanced/Attributes.php +22 -0
  136. app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Source/Advanced/Frequency.php +15 -0
  137. app/code/{local/Dotdigitalgroup/Email/Model/System/Config/Source/Orderlimit.php → community/Dotdigitalgroup/Email/Model/Adminhtml/Source/Advanced/Transdata.php} +1 -1
  138. app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Source/Automation/Programme.php +32 -0
  139. app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Source/Campaigns.php +54 -0
  140. app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Source/Contact/Imported.php +17 -0
  141. app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Source/Customer/Attributes/Select.php +34 -0
  142. app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Source/Datafields.php +55 -0
  143. app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Source/Datamapping/Datafieldaccess.php +17 -0
  144. app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Source/Datamapping/Datafieldtype.php +22 -0
  145. app/code/{local/Dotdigitalgroup/Email/Model/System/Config/Source → community/Dotdigitalgroup/Email/Model/Adminhtml/Source/Dynamic}/Displaytype.php +7 -2
  146. app/code/{local/Dotdigitalgroup/Email/Model/System/Config/Source → community/Dotdigitalgroup/Email/Model/Adminhtml/Source/Dynamic}/Gridview.php +6 -1
  147. app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Source/Lostbaskets/Interval.php +40 -0
  148. app/code/{local/Dotdigitalgroup/Email/Model/System/Config/Source/Lostbasket.php → community/Dotdigitalgroup/Email/Model/Adminhtml/Source/Lostbaskets/Intervalminute.php} +1 -1
  149. app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Source/Orderstatus.php +28 -0
  150. app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Source/Reviews/Campaigns.php +48 -0
  151. app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Source/Reviews/Delay.php +26 -0
  152. app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Source/Sweettooth/Yesno.php +26 -0
  153. app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Source/Transactional/Campaigns.php +57 -0
  154. app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Source/Transactional/Customselect.php +19 -0
  155. app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Source/Transactional/Defaultselect.php +31 -0
  156. app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Source/Transactional/Fromaddress.php +57 -0
  157. app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Source/Transactional/Replyactions.php +22 -0
  158. app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Source/Transactional/Sendtype.php +21 -0
  159. app/code/community/Dotdigitalgroup/Email/Model/Apiconnector/Client.php +1251 -0
  160. app/code/community/Dotdigitalgroup/Email/Model/Apiconnector/Contact.php +326 -0
  161. app/code/community/Dotdigitalgroup/Email/Model/Apiconnector/Customer.php +647 -0
  162. app/code/community/Dotdigitalgroup/Email/Model/Apiconnector/Test.php +79 -0
  163. app/code/community/Dotdigitalgroup/Email/Model/Campaign.php +419 -0
  164. app/code/community/Dotdigitalgroup/Email/Model/Config.php +65 -0
  165. app/code/{local → community}/Dotdigitalgroup/Email/Model/Connector/Account.php +10 -8
  166. app/code/community/Dotdigitalgroup/Email/Model/Connector/Campaign.php +100 -0
  167. app/code/community/Dotdigitalgroup/Email/Model/Connector/Datafield.php +333 -0
  168. app/code/community/Dotdigitalgroup/Email/Model/Connector/Order.php +279 -0
  169. app/code/community/Dotdigitalgroup/Email/Model/Contact.php +290 -0
  170. app/code/community/Dotdigitalgroup/Email/Model/Controller/Observer.php +43 -0
  171. app/code/community/Dotdigitalgroup/Email/Model/Cron.php +121 -0
  172. app/code/community/Dotdigitalgroup/Email/Model/Customer.php +20 -0
  173. app/code/community/Dotdigitalgroup/Email/Model/Customer/Guest.php +67 -0
  174. app/code/community/Dotdigitalgroup/Email/Model/Customer/Observer.php +316 -0
  175. app/code/community/Dotdigitalgroup/Email/Model/Customer/Review.php +240 -0
  176. app/code/community/Dotdigitalgroup/Email/Model/Customer/Review/Rating.php +46 -0
  177. app/code/community/Dotdigitalgroup/Email/Model/Customer/Wishlist.php +120 -0
  178. app/code/{local → community}/Dotdigitalgroup/Email/Model/Customer/Wishlist/Item.php +25 -12
  179. app/code/community/Dotdigitalgroup/Email/Model/Email/Template.php +357 -0
  180. app/code/community/Dotdigitalgroup/Email/Model/Feed.php +88 -0
  181. app/code/community/Dotdigitalgroup/Email/Model/Newsletter/Observer.php +134 -0
  182. app/code/community/Dotdigitalgroup/Email/Model/Newsletter/Sub.php +12 -0
  183. app/code/community/Dotdigitalgroup/Email/Model/Newsletter/Subscriber.php +185 -0
  184. app/code/community/Dotdigitalgroup/Email/Model/Order.php +142 -0
  185. app/code/community/Dotdigitalgroup/Email/Model/Resource/Campaign.php +13 -0
  186. app/code/community/Dotdigitalgroup/Email/Model/Resource/Campaign/Collection.php +13 -0
  187. app/code/community/Dotdigitalgroup/Email/Model/Resource/Config.php +14 -0
  188. app/code/community/Dotdigitalgroup/Email/Model/Resource/Config/Collection.php +14 -0
  189. app/code/community/Dotdigitalgroup/Email/Model/Resource/Contact.php +14 -0
  190. app/code/community/Dotdigitalgroup/Email/Model/Resource/Contact/Collection.php +25 -0
  191. app/code/community/Dotdigitalgroup/Email/Model/Resource/Order.php +12 -0
  192. app/code/community/Dotdigitalgroup/Email/Model/Resource/Order/Collection.php +18 -0
  193. app/code/community/Dotdigitalgroup/Email/Model/Resource/Review.php +13 -0
  194. app/code/community/Dotdigitalgroup/Email/Model/Resource/Review/Collection.php +13 -0
  195. app/code/community/Dotdigitalgroup/Email/Model/Resource/Setup.php +26 -0
  196. app/code/community/Dotdigitalgroup/Email/Model/Resource/Wishlist.php +13 -0
  197. app/code/community/Dotdigitalgroup/Email/Model/Resource/Wishlist/Collection.php +13 -0
  198. app/code/community/Dotdigitalgroup/Email/Model/Review.php +123 -0
  199. app/code/community/Dotdigitalgroup/Email/Model/Sales/Observer.php +211 -0
  200. app/code/community/Dotdigitalgroup/Email/Model/Sales/Order.php +323 -0
  201. app/code/community/Dotdigitalgroup/Email/Model/Sales/Quote.php +257 -0
  202. app/code/community/Dotdigitalgroup/Email/Model/Sms/Campaign.php +112 -0
  203. app/code/community/Dotdigitalgroup/Email/Model/Sweettooth/Observer.php +21 -0
  204. app/code/community/Dotdigitalgroup/Email/Model/Wishlist.php +178 -0
  205. app/code/community/Dotdigitalgroup/Email/controllers/Adminhtml/ConnectorController.php +339 -0
  206. app/code/community/Dotdigitalgroup/Email/controllers/Adminhtml/Email/AutomationController.php +109 -0
  207. app/code/community/Dotdigitalgroup/Email/controllers/Adminhtml/Email/CampaignController.php +252 -0
  208. app/code/community/Dotdigitalgroup/Email/controllers/Adminhtml/Email/ContactController.php +192 -0
  209. app/code/community/Dotdigitalgroup/Email/controllers/Adminhtml/Email/DashboardController.php +91 -0
  210. app/code/community/Dotdigitalgroup/Email/controllers/Adminhtml/Email/OrderController.php +26 -0
  211. app/code/community/Dotdigitalgroup/Email/controllers/Adminhtml/Email/ReviewController.php +26 -0
  212. app/code/community/Dotdigitalgroup/Email/controllers/Adminhtml/Email/WishlistController.php +26 -0
  213. app/code/community/Dotdigitalgroup/Email/controllers/Adminhtml/Widget/ChooserController.php +19 -0
  214. app/code/community/Dotdigitalgroup/Email/controllers/AjaxController.php +21 -0
  215. app/code/community/Dotdigitalgroup/Email/controllers/CreditmemoController.php +69 -0
  216. app/code/community/Dotdigitalgroup/Email/controllers/DynamicContentController.php +31 -0
  217. app/code/community/Dotdigitalgroup/Email/controllers/EmailController.php +147 -0
  218. app/code/community/Dotdigitalgroup/Email/controllers/InvoiceController.php +71 -0
  219. app/code/community/Dotdigitalgroup/Email/controllers/OrderController.php +71 -0
  220. app/code/community/Dotdigitalgroup/Email/controllers/ProductsController.php +112 -0
  221. app/code/community/Dotdigitalgroup/Email/controllers/QuoteproductsController.php +94 -0
  222. app/code/community/Dotdigitalgroup/Email/controllers/ReportController.php +62 -0
  223. app/code/community/Dotdigitalgroup/Email/controllers/ShippingController.php +84 -0
  224. app/code/community/Dotdigitalgroup/Email/etc/adminhtml.xml +170 -0
  225. app/code/community/Dotdigitalgroup/Email/etc/config.xml +633 -0
  226. app/code/community/Dotdigitalgroup/Email/etc/files.yaml +302 -0
  227. app/code/community/Dotdigitalgroup/Email/etc/system.xml +2550 -0
  228. app/code/{local/Dotdigitalgroup/Email/sql/connector_setup → community/Dotdigitalgroup/Email/sql/email_connector_setup}/mysql4-install-0.1.0.php +4 -11
  229. app/code/community/Dotdigitalgroup/Email/sql/email_connector_setup/mysql4-install-3.0.0.php +307 -0
  230. 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
  231. app/code/community/Dotdigitalgroup/Email/sql/email_connector_setup/mysql4-upgrade-1.1.2-1.5.0.php +8 -0
  232. app/code/community/Dotdigitalgroup/Email/sql/email_connector_setup/mysql4-upgrade-1.5.0-2.0.0.php +75 -0
  233. app/code/community/Dotdigitalgroup/Email/sql/email_connector_setup/mysql4-upgrade-2.0.0-2.0.1.php +9 -0
  234. app/code/community/Dotdigitalgroup/Email/sql/email_connector_setup/mysql4-upgrade-2.0.1-2.0.2.php +52 -0
  235. app/code/community/Dotdigitalgroup/Email/sql/email_connector_setup/mysql4-upgrade-2.0.3-2.0.4.php +28 -0
  236. app/code/community/Dotdigitalgroup/Email/sql/email_connector_setup/mysql4-upgrade-2.0.4-2.0.5.php +9 -0
  237. app/code/community/Dotdigitalgroup/Email/sql/email_connector_setup/mysql4-upgrade-2.0.5-2.0.6.php +103 -0
  238. app/code/community/Dotdigitalgroup/Email/sql/email_connector_setup/mysql4-upgrade-3.0.1-3.0.2.php +18 -0
  239. app/code/community/Dotdigitalgroup/Email/sql/email_connector_setup/mysql4-upgrade-3.0.3-3.0.4.php +12 -0
  240. app/code/community/Dotdigitalgroup/Email/sql/email_connector_setup/mysql4-upgrade-3.0.4-3.0.5.php +121 -0
  241. app/code/community/Dotdigitalgroup/Email/sql/email_connector_setup/mysql4-upgrade-3.1.2-3.1.3.php +123 -0
  242. app/code/community/Dotdigitalgroup/Email/sql/email_connector_setup/mysql4-upgrade-3.2.1-3.3.0.php +151 -0
  243. app/code/community/Dotdigitalgroup/Email/sql/email_connector_setup/mysql4-upgrade-3.3.0-3.3.1.php +151 -0
  244. app/code/community/Dotdigitalgroup/Mailcheck/Helper/Data.php +6 -0
  245. app/code/community/Dotdigitalgroup/Mailcheck/etc/config.xml +31 -0
  246. app/code/community/Dotdigitalgroup/Mailcheck/etc/jstranslator.xml +5 -0
  247. app/code/community/Dotdigitalgroup/Mailcheck/etc/system.xml +28 -0
  248. app/code/local/Dotdigitalgroup/Email/Block/Adminhtml/System/Bestsellers.php +0 -18
  249. app/code/local/Dotdigitalgroup/Email/Block/Adminhtml/System/Config/Gridlist.php +0 -104
  250. app/code/local/Dotdigitalgroup/Email/Block/Adminhtml/System/Config/Insertvariable.php +0 -13
  251. app/code/local/Dotdigitalgroup/Email/Block/Adminhtml/System/Config/Messagedefault.php +0 -46
  252. app/code/local/Dotdigitalgroup/Email/Block/Adminhtml/System/Config/Smsmessagefour.php +0 -23
  253. app/code/local/Dotdigitalgroup/Email/Block/Adminhtml/System/Config/Smsmessagethree.php +0 -23
  254. app/code/local/Dotdigitalgroup/Email/Block/Adminhtml/System/Config/Smsmessagetwo.php +0 -23
  255. app/code/local/Dotdigitalgroup/Email/Block/Adminhtml/System/Config/Validator.php +0 -73
  256. app/code/local/Dotdigitalgroup/Email/Block/Adminhtml/System/Config/Waitingfield.php +0 -43
  257. app/code/local/Dotdigitalgroup/Email/Block/Adminhtml/System/Couponinfo.php +0 -18
  258. app/code/local/Dotdigitalgroup/Email/Block/Adminhtml/System/Crosssell.php +0 -20
  259. app/code/local/Dotdigitalgroup/Email/Block/Adminhtml/System/Lostbasket.php +0 -19
  260. app/code/local/Dotdigitalgroup/Email/{Block/Adminhtml/System/Mostviewed.php → Bloc} +0 -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,212 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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('created_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_created', array(
45
+ 'header' => Mage::helper('connector')->__('Is Created'),
46
+ 'align' => 'center',
47
+ 'width' => '20px',
48
+ 'index' => 'is_created',
49
+ 'escape' => true,
50
+ 'type' => 'options',
51
+ 'renderer' => 'email_connector/adminhtml_column_renderer_imported',
52
+ 'options' => array(
53
+ '1' => 'Is Created',
54
+ 'null' => 'Not Created'
55
+ ),
56
+ 'filter_condition_callback' => array($this, 'filterCallbackContact')
57
+ ))->addColumn('is_sent', array(
58
+ 'header' => Mage::helper('connector')->__('Is Sent'),
59
+ 'align' => 'center',
60
+ 'width' => '20px',
61
+ 'index' => 'is_sent',
62
+ 'escape' => true,
63
+ 'type' => 'options',
64
+ 'renderer' => 'email_connector/adminhtml_column_renderer_imported',
65
+ 'options' => array(
66
+ '1' => 'Is Send',
67
+ 'null' => 'Not Send'
68
+ ),
69
+ 'filter_condition_callback' => array($this, 'filterCallbackContact')
70
+ ))->addColumn('is_copy', array(
71
+ 'header' => Mage::helper('connector')->__('Is Copy'),
72
+ 'align' => 'center',
73
+ 'width' => '20px',
74
+ 'index' => 'is_copy',
75
+ 'escape' => true,
76
+ 'type' => 'options',
77
+ 'renderer' => 'email_connector/adminhtml_column_renderer_imported',
78
+ 'options' => array(
79
+ '1' => 'Is A Copy',
80
+ 'null' => 'Not A Copy'
81
+ ),
82
+ 'filter_condition_callback' => array($this, 'filterCallbackContact')
83
+ ))->addColumn('order_increment_id', array(
84
+ 'header' => Mage::helper('connector')->__('Increment ID'),
85
+ 'align' => 'left',
86
+ 'width' => '50px',
87
+ 'index' => 'order_increment_id',
88
+ 'type' => 'number',
89
+ 'escape' => true
90
+ ))->addColumn('create_message', array(
91
+ 'header' => Mage::helper('connector')->__('Create Message'),
92
+ 'align' => 'left',
93
+ 'width' => '300px',
94
+ 'index' => 'create_message',
95
+ 'type' => 'text',
96
+ 'escape' => true
97
+ ))->addColumn('contact_message', array(
98
+ 'header' => Mage::helper('connector')->__('Contact Message'),
99
+ 'align' => 'left',
100
+ 'width' => '300px',
101
+ 'index' => 'contact_message',
102
+ 'type' => 'text',
103
+ 'escape' => true
104
+ ))->addColumn('message', array(
105
+ 'header' => Mage::helper('connector')->__('Send Message'),
106
+ 'align' => 'left',
107
+ 'width' => '300px',
108
+ 'index' => 'message',
109
+ 'type' => 'text',
110
+ 'escape' => true
111
+ ))->addColumn('event_name', array(
112
+ 'header' => Mage::helper('connector')->__('Email Name'),
113
+ 'align' => 'left',
114
+ 'index' => 'event_name',
115
+ 'width' => '100px',
116
+ 'type' => 'string',
117
+ 'escape' => true,
118
+ ))->addColumn('created_at', array(
119
+ 'header' => Mage::helper('connector')->__('Created At'),
120
+ 'align' => 'center',
121
+ 'width' => '100px',
122
+ 'index' => 'created_at',
123
+ 'type' => 'datetime',
124
+ 'escape' => true
125
+ ))->addColumn('updated_at', array(
126
+ 'header' => Mage::helper('connector')->__('Updated At'),
127
+ 'align' => 'center',
128
+ 'width' => '100px',
129
+ 'index' => 'updated_at',
130
+ 'type' => 'datetime',
131
+ 'escape' => true
132
+ ))->addColumn('sent_at', array(
133
+ 'header' => Mage::helper('connector')->__('Sent At'),
134
+ 'align' => 'center',
135
+ 'width' => '100px',
136
+ 'index' => 'sent_at',
137
+ 'type' => 'datetime',
138
+ 'escape' => true
139
+ ));
140
+ if (!Mage::app()->isSingleStoreMode()) {
141
+ $this->addColumn('website_id', array(
142
+ 'header' => Mage::helper('customer')->__('Website'),
143
+ 'align' => 'center',
144
+ 'width' => '80px',
145
+ 'type' => 'options',
146
+ 'options' => Mage::getSingleton('adminhtml/system_store')->getWebsiteOptionHash(true),
147
+ 'index' => 'website_id',
148
+ ));
149
+ }
150
+
151
+ $this->addExportType('*/*/exportCsv', Mage::helper('connector')->__('CSV'));
152
+ return parent::_prepareColumns();
153
+ }
154
+
155
+ /**
156
+ * Get the store selected.
157
+ * @return Mage_Core_Model_Store
158
+ * @throws Exception
159
+ */
160
+ protected function _getStore()
161
+ {
162
+ $storeId = (int) $this->getRequest()->getParam('store', 0);
163
+ return Mage::app()->getStore($storeId);
164
+ }
165
+
166
+
167
+ /**
168
+ * @return $this|Mage_Adminhtml_Block_Widget_Grid
169
+ */
170
+ protected function _prepareMassaction()
171
+ {
172
+ $this->setMassactionIdField('id');
173
+ $this->getMassactionBlock()->setFormFieldName('campaign');
174
+ $this->getMassactionBlock()->addItem('delete', array (
175
+ 'label'=> Mage::helper('connector')->__('Delete'),
176
+ 'url' => $this->getUrl('*/*/massDelete'),
177
+ 'confirm' => Mage::helper('connector')->__('Are you sure?')
178
+ )
179
+ );
180
+
181
+ $this->getMassactionBlock()->addItem('resend', array('label'=>Mage::helper('connector')->__('Resend'),'url'=>$this->getUrl('*/*/massResend')));
182
+ $this->getMassactionBlock()->addItem('re-create', array('label'=>Mage::helper('connector')->__('Recreate'),'url'=>$this->getUrl('*/*/massRecreate')));
183
+ return $this;
184
+ }
185
+
186
+ /**
187
+ * Grid selected url.
188
+ * @return string
189
+ */
190
+ public function getGridUrl()
191
+ {
192
+ return $this->getUrl('*/*/grid', array('_current'=>true));
193
+ }
194
+ /**
195
+ * Custom callback action for the campaign.
196
+ *
197
+ * @param $collection
198
+ * @param $column
199
+ */
200
+ public function filterCallbackContact($collection, $column)
201
+ {
202
+ $field = $column->getFilterIndex() ? $column->getFilterIndex() : $column->getIndex();
203
+ $value = $column->getFilter()->getValue();
204
+
205
+ if ($value == 'null') {
206
+ $collection->addFieldToFilter($field, array('null' => true) );
207
+ } else {
208
+ $collection->addFieldToFilter($field, array('notnull' => true));
209
+ }
210
+ }
211
+
212
+ }
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.php ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dotdigitalgroup_Email_Block_Adminhtml_Config extends Mage_Adminhtml_Block_Widget_Grid_Container
4
+ {
5
+ /**
6
+ * Set the template.
7
+ */
8
+ public function __construct()
9
+ {
10
+ $this->_controller = 'adminhtml_config';
11
+ $this->_blockGroup = 'email_connector';
12
+ parent::__construct();
13
+ $this->_headerText = Mage::helper('connector')->__('Config');
14
+ $this->_removeButton('add');
15
+
16
+ $this->setTemplate('connector/grid.phtml');
17
+ }
18
+ }
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,188 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ * From address
23
+ */
24
+ protected $_getFromadddressRenderer;
25
+
26
+ /**
27
+ * Construct.
28
+ */
29
+ public function __construct()
30
+ {
31
+ $this->_addAfter = false;
32
+ $this->_addButtonLabel = Mage::helper('adminhtml')->__('Map Template');
33
+ parent::__construct();
34
+
35
+ }
36
+
37
+ protected function _prepareToRender()
38
+ {
39
+ $this->_getDatafieldRenderer = null;
40
+ $this->_getTemplateRenderer = null;
41
+ $this->_getSendtypeRenderer = null;
42
+ $this->addColumn('template',
43
+ array(
44
+ 'label' => Mage::helper('adminhtml')->__('Magento Template'),
45
+ 'style' => 'width:120px',
46
+ )
47
+ );
48
+ $this->addColumn('sendtype', array(
49
+ 'label' => Mage::helper('adminhtml')->__('Send Type'),
50
+ 'style' => 'width:120px',
51
+ )
52
+ );
53
+ $this->addColumn('datafield', array(
54
+ 'label' => Mage::helper('adminhtml')->__("Campaign Template <br> (Need For Design + Send)"),
55
+ 'style' => 'width:120px',
56
+ )
57
+ );
58
+ $this->addColumn('fromaddress', array(
59
+ 'label' => Mage::helper('adminhtml')->__("From Address"),
60
+ 'style' => 'width:120px',
61
+ )
62
+ );
63
+ $this->addColumn('attachmentid', array(
64
+ 'label' => Mage::helper('adminhtml')->__("Attachment Id"),
65
+ 'style' => 'width:120px',
66
+ )
67
+ );
68
+ }
69
+
70
+ protected function _renderCellTemplate($columnName)
71
+ {
72
+ $inputName = $this->getElement()->getName() . '[#{_id}][' . $columnName . ']';
73
+ if ($columnName=="template") {
74
+ return $this->_getTemplateRenderer()
75
+ ->setName($inputName)
76
+ ->setTitle($columnName)
77
+ ->setExtraParams('style="width:160px"')
78
+ ->setOptions(
79
+ $this->getElement()->getValues()
80
+ )
81
+ ->toHtml();
82
+ } elseif ($columnName == "sendtype") {
83
+ return $this->_getSendtypeRenderer()
84
+ ->setName($inputName)
85
+ ->setTitle($columnName)
86
+ ->setExtraParams('style="width:160px"')
87
+ ->setOptions(Mage::getModel('email_connector/adminhtml_source_transactional_sendtype')->toOptionArray())
88
+ ->toHtml();
89
+ } elseif ($columnName == "datafield") {
90
+ return $this->_getDatafieldRenderer()
91
+ ->setName($inputName)
92
+ ->setTitle($columnName)
93
+ ->setExtraParams('style="width:160px"')
94
+ ->setOptions(Mage::getModel('email_connector/adminhtml_source_transactional_campaigns')->toOptionArray())
95
+ ->toHtml();
96
+ } elseif ($columnName == "fromaddress") {
97
+ return $this->_getFromadddressRenderer()
98
+ ->setName($inputName)
99
+ ->setTitle($columnName)
100
+ ->setExtraParams('style="width:160px"')
101
+ ->setOptions(Mage::getModel('email_connector/adminhtml_source_transactional_fromaddress')->toOptionArray())
102
+ ->toHtml();
103
+ }
104
+
105
+ return parent::_renderCellTemplate($columnName);
106
+ }
107
+
108
+ /**
109
+ * Assign extra parameters to row
110
+ *
111
+ * @param Varien_Object $row
112
+ */
113
+ protected function _prepareArrayRow(Varien_Object $row)
114
+ {
115
+
116
+ $row->setData(
117
+ 'option_extra_attr_' . $this->_getTemplateRenderer()->calcOptionHash($row->getData('template')),
118
+ 'selected="selected"'
119
+ );
120
+
121
+ $row->setData(
122
+ 'option_extra_attr_' . $this->_getSendtypeRenderer()->calcOptionHash($row->getData('sendtype')),
123
+ 'selected="selected"'
124
+ );
125
+
126
+ $row->setData(
127
+ 'option_extra_attr_' . $this->_getDatafieldRenderer()->calcOptionHash($row->getData('datafield')),
128
+ 'selected="selected"'
129
+ );
130
+
131
+ $row->setData(
132
+ 'option_extra_attr_' . $this->_getFromadddressRenderer()->calcOptionHash($row->getData('fromaddress')),
133
+ 'selected="selected"'
134
+ );
135
+ }
136
+
137
+ protected function _getTemplateRenderer()
138
+ {
139
+ if (!$this->_getTemplateRenderer) {
140
+ $this->_getTemplateRenderer = $this->getLayout()
141
+ ->createBlock('email_connector/adminhtml_config_select')
142
+ ->setIsRenderToJsTemplate(true);
143
+ }
144
+ return $this->_getTemplateRenderer;
145
+ }
146
+
147
+ protected function _getDatafieldRenderer()
148
+ {
149
+ if (!$this->_getDatafieldRenderer) {
150
+ $this->_getDatafieldRenderer = $this->getLayout()
151
+ ->createBlock('email_connector/adminhtml_config_select')
152
+ ->setIsRenderToJsTemplate(true);
153
+ }
154
+ return $this->_getDatafieldRenderer;
155
+ }
156
+
157
+ protected function _getSendtypeRenderer()
158
+ {
159
+ if (!$this->_getSendtypeRenderer) {
160
+ $this->_getSendtypeRenderer = $this->getLayout()
161
+ ->createBlock('email_connector/adminhtml_config_select')
162
+ ->setIsRenderToJsTemplate(true);
163
+ }
164
+ return $this->_getSendtypeRenderer;
165
+ }
166
+
167
+ protected function _getFromadddressRenderer()
168
+ {
169
+ if (!$this->_getFromadddressRenderer) {
170
+ $this->_getFromadddressRenderer = $this->getLayout()
171
+ ->createBlock('email_connector/adminhtml_config_select')
172
+ ->setIsRenderToJsTemplate(true);
173
+ }
174
+ return $this->_getFromadddressRenderer;
175
+ }
176
+
177
+ public function _toHtml()
178
+ {
179
+ if(count($this->getElement()->getValues())){
180
+ return '<input type="hidden" id="'.$this->getElement()->getHtmlId().'"/>'.parent::_toHtml();
181
+ }
182
+ else {
183
+ return "<p class='notice'>". Mage::helper('adminhtml')->__("There are no email templates to map.") . "</p>";
184
+ }
185
+
186
+ }
187
+
188
+ }
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,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+
25
+ $website = 0;
26
+ //request store param
27
+ if ($store = $this->getRequest()->getParam('store')) {
28
+ $website = Mage::app()->getStore($store)->getWebsite();
29
+ //website param
30
+ } elseif ($this->getRequest()->getParam('website')) {
31
+ $website = $this->getRequest()->getParam('website');
32
+ }
33
+
34
+ $apiUsername = Mage::helper('connector')->getApiUsername($website);
35
+ $apiPassword = Mage::helper('connector')->getApiPassword($website);
36
+
37
+ //api get account info
38
+ $data = Mage::getModel('email_connector/apiconnector_client')
39
+ ->setApiUsername($apiUsername)
40
+ ->setApiPassword($apiPassword)
41
+ ->getAccountInfo();
42
+
43
+ //check if properties for the data exists
44
+ if (isset($data->properties)) {
45
+ foreach ( $data->properties as $one ) {
46
+ //add total for the api calls
47
+ $this->addTotal( $this->__( $one->name ), $one->value, true );
48
+ }
49
+ }
50
+ }
51
+
52
+ }
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Dashboard/Switcher.php ADDED
@@ -0,0 +1,92 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dotdigitalgroup_Email_Block_Adminhtml_Dashboard_Switcher extends Mage_Adminhtml_Block_Template
4
+ {
5
+ protected function _prepareLayout()
6
+ {
7
+ $this->setTemplate('system/config/switcher.phtml');
8
+ return parent::_prepareLayout();
9
+ }
10
+
11
+ /**
12
+ *
13
+ * @return array
14
+ */
15
+ public function getStoreSelectOptions()
16
+ {
17
+ $section = $this->getRequest()->getParam('section');
18
+
19
+ $curWebsite = $this->getRequest()->getParam('website');
20
+ $curStore = $this->getRequest()->getParam('store');
21
+
22
+ $storeModel = Mage::getSingleton('adminhtml/system_store');
23
+ /* @var $storeModel Mage_Adminhtml_Model_System_Store */
24
+
25
+ $url = Mage::getModel('adminhtml/url');
26
+
27
+ $options = array();
28
+ $options['default'] = array(
29
+ 'label' => Mage::helper('adminhtml')->__('Default Config'),
30
+ 'url' => $url->getUrl('*/*/*', array('section'=>$section)),
31
+ 'selected' => !$curWebsite && !$curStore,
32
+ 'style' => 'background:#ccc; font-weight:bold;',
33
+ );
34
+
35
+ foreach ($storeModel->getWebsiteCollection() as $website) {
36
+ $websiteShow = false;
37
+ foreach ($storeModel->getGroupCollection() as $group) {
38
+ if ($group->getWebsiteId() != $website->getId()) {
39
+ continue;
40
+ }
41
+ $groupShow = false;
42
+ foreach ($storeModel->getStoreCollection() as $store) {
43
+ if ($store->getGroupId() != $group->getId()) {
44
+ continue;
45
+ }
46
+ if (!$websiteShow) {
47
+ $websiteShow = true;
48
+ $options['website_' . $website->getId()] = array(
49
+ 'label' => $website->getName(),
50
+ 'url' => $url->getUrl('*/*/*', array('section'=>$section, 'website'=>$website->getId())),
51
+ 'selected' => !$curStore && $curWebsite == $website->getId(),
52
+ 'style' => 'padding-left:16px; background:#DDD; font-weight:bold;',
53
+ );
54
+ }
55
+ if (!$groupShow) {
56
+ $groupShow = true;
57
+ $options['group_' . $group->getId() . '_open'] = array(
58
+ 'is_group' => true,
59
+ 'is_close' => false,
60
+ 'label' => $group->getName(),
61
+ 'style' => 'padding-left:32px;'
62
+ );
63
+ }
64
+ $options['store_' . $store->getId()] = array(
65
+ 'label' => $store->getName(),
66
+ 'url' => $url->getUrl('*/*/*', array('section'=>$section, 'store'=>$store->getId())),
67
+ 'selected' => $curStore == $store->getId(),
68
+ 'style' => '',
69
+ );
70
+ }
71
+ if ($groupShow) {
72
+ $options['group_' . $group->getId() . '_close'] = array(
73
+ 'is_group' => true,
74
+ 'is_close' => true,
75
+ );
76
+ }
77
+ }
78
+ }
79
+
80
+ return $options;
81
+ }
82
+
83
+ /**
84
+ * Return store switcher hint html
85
+ *
86
+ * @return mixed
87
+ */
88
+ public function getHintHtml()
89
+ {
90
+ return Mage::getBlockSingleton('adminhtml/store_switcher')->getHintHtml();
91
+ }
92
+ }
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Dashboard/Tabs.php ADDED
@@ -0,0 +1,58 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dotdigitalgroup_Email_Block_Adminhtml_Dashboard_Tabs extends Mage_Adminhtml_Block_Widget_Tabs
4
+ {
5
+
6
+ public function __construct()
7
+ {
8
+ parent::__construct();
9
+ $this->setId('connector_dashboard_tabs');
10
+ $this->setTitle($this->__('Dashboards' ));
11
+ $this->setTemplate('connector/dashboard/tabs.phtml');
12
+ }
13
+
14
+ /**
15
+ * set tabs
16
+ *
17
+ * @return Mage_Core_Block_Abstract
18
+ * @throws Exception
19
+ */
20
+ protected function _beforeToHtml()
21
+ {
22
+ $this->addTab(
23
+ 'general',
24
+ array (
25
+ 'label' => $this->__('Account Information'),
26
+ 'title' => $this->__('Account Information'),
27
+ 'content' => $this->getLayout()->createBlock('email_connector/adminhtml_dashboard_tabs_general')->toHtml(),
28
+ )
29
+ );
30
+ $this->addTab(
31
+ 'status',
32
+ array (
33
+ 'label' => $this->__('Connector Status'),
34
+ 'title' => $this->__('Connector Status'),
35
+ 'url' => $this->getUrl('*/*/statusGrid'),
36
+ 'class' => 'ajax',
37
+ 'active' => true
38
+ )
39
+ );
40
+ $this->addTab(
41
+ 'analysis',
42
+ array (
43
+ 'label' => $this->__('Data Analysis'),
44
+ 'title' => $this->__('Data Analysis'),
45
+ 'content' => $this->getLayout()->createBlock('email_connector/adminhtml_dashboard_tabs_analysis')->toHtml()
46
+ )
47
+ );
48
+ $this->addTab(
49
+ 'config',
50
+ array (
51
+ 'label' => $this->__('API Status'),
52
+ 'title' => $this->__('API Status'),
53
+ 'content' => $this->getLayout()->createBlock('email_connector/adminhtml_dashboard_tabs_config')->toHtml()
54
+ )
55
+ );
56
+ return parent::_beforeToHtml();
57
+ }
58
+ }
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Dashboard/Tabs/Analysis.php ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dotdigitalgroup_Email_Block_Adminhtml_Dashboard_Tabs_Analysis extends Mage_Adminhtml_Block_Dashboard_Bar
4
+ {
5
+ /**
6
+ * set template
7
+ *
8
+ * @throws Exception
9
+ */
10
+ public function __construct()
11
+ {
12
+ parent::_construct();
13
+ $this->setTemplate('connector/dashboard/tabs/analysis/index.phtml');
14
+ }
15
+
16
+ /**
17
+ * Prepare the layout. set child blocks
18
+ *
19
+ * @return Mage_Core_Block_Abstract|void
20
+ * @throws Exception
21
+ */
22
+ protected function _prepareLayout()
23
+ {
24
+ $this->setChild('sales',
25
+ $this->getLayout()->createBlock('email_connector/adminhtml_dashboard_tabs_analysis_sales')
26
+ );
27
+ $this->setChild('abandoned_cart',
28
+ $this->getLayout()->createBlock('email_connector/adminhtml_dashboard_tabs_analysis_abandonedcarts')
29
+ );
30
+ $this->setChild('customer',
31
+ $this->getLayout()->createBlock('email_connector/adminhtml_dashboard_tabs_analysis_customer')
32
+ );
33
+ $this->setChild('subscriber',
34
+ $this->getLayout()->createBlock('email_connector/adminhtml_dashboard_tabs_analysis_subscriber')
35
+ );
36
+ $this->setChild('rfm',
37
+ $this->getLayout()->createBlock('email_connector/adminhtml_dashboard_tabs_analysis_rfm')
38
+ );
39
+ parent::_prepareLayout();
40
+ }
41
+
42
+ /**
43
+ * get Tab content title
44
+ *
45
+ * @return string
46
+ */
47
+ public function getTitle()
48
+ {
49
+ return "Marketing Automation Data Analysis";
50
+ }
51
+
52
+ /**
53
+ * get column width
54
+ *
55
+ * @return string
56
+ */
57
+ public function getColumnWidth()
58
+ {
59
+ return "290px";
60
+ }
61
+ }
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Dashboard/Tabs/Analysis/Abandonedcarts.php ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dotdigitalgroup_Email_Block_Adminhtml_Dashboard_Tabs_Analysis_Abandonedcarts extends Dotdigitalgroup_Email_Block_Adminhtml_Dashboard_Tabs_Analysis
4
+ {
5
+ protected $_store = 0;
6
+ protected $_group = 0;
7
+ protected $_website = 0;
8
+
9
+ /**
10
+ * set template
11
+ *
12
+ * @throws Exception
13
+ */
14
+ public function __construct()
15
+ {
16
+ parent::_construct();
17
+
18
+ $this->_store = $this->getRequest()->getParam('store');
19
+ $this->_group = $this->getRequest()->getParam('group');
20
+ $this->_website = $this->getRequest()->getParam('website');
21
+ $this->setTemplate('connector/dashboard/tabs/data.phtml');
22
+ }
23
+
24
+ /**
25
+ * Prepare the layout.
26
+ *
27
+ * @return Mage_Core_Block_Abstract|void
28
+ * @throws Exception
29
+ */
30
+ protected function _prepareLayout()
31
+ {
32
+ $lifetimeAbanodned = $this->getAbandonedCartInformationForTab();
33
+ $this->addTotal($this->__('Total Abandoned Cart Lost Revenue'), $lifetimeAbanodned->getLifetime());
34
+ $this->addTotal($this->__('Average Abandoned Cart Lost Revenue'), $lifetimeAbanodned->getAverage());
35
+ $this->addTotal($this->__('Total Number Of Abandoned Carts'), $lifetimeAbanodned->getTotalCount(), true);
36
+ $this->addTotal($this->__('Average Abandoned Carts Created Per Day'), $lifetimeAbanodned->getDayCount(), true);
37
+ }
38
+
39
+ /**
40
+ * get abandoned cart information for tab from abandoned analysis model
41
+ *
42
+ * @return Varien_Object
43
+ */
44
+ protected function getAbandonedCartInformationForTab()
45
+ {
46
+ $abandonedAnalysisModel = Mage::getModel('email_connector/adminhtml_dashboard_tabs_analysis_abandoned');
47
+ return $abandonedAnalysisModel->getLifeTimeAbandoned($this->_store, $this->_website, $this->_group);
48
+ }
49
+
50
+ /**
51
+ * @return string
52
+ */
53
+ public function getTitle()
54
+ {
55
+ return "Abandoned Carts";
56
+ }
57
+ }
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Dashboard/Tabs/Analysis/Customer.php ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dotdigitalgroup_Email_Block_Adminhtml_Dashboard_Tabs_Analysis_Customer extends Dotdigitalgroup_Email_Block_Adminhtml_Dashboard_Tabs_Analysis
4
+ {
5
+ protected $_store = 0;
6
+ protected $_group = 0;
7
+ protected $_website = 0;
8
+
9
+ /**
10
+ * set template
11
+ *
12
+ * @throws Exception
13
+ */
14
+ public function __construct()
15
+ {
16
+ parent::_construct();
17
+
18
+ $this->_store = $this->getRequest()->getParam('store');
19
+ $this->_group = $this->getRequest()->getParam('group');
20
+ $this->_website = $this->getRequest()->getParam('website');
21
+ $this->setTemplate('connector/dashboard/tabs/data.phtml');
22
+ }
23
+
24
+ /**
25
+ * Prepare the layout.
26
+ *
27
+ * @return Mage_Core_Block_Abstract|void
28
+ * @throws Exception
29
+ */
30
+ protected function _prepareLayout()
31
+ {
32
+ $lifetimeCustomer = $this->getCustomerInformationForTab();
33
+ $this->addTotal($this->__('Total Number Of Customers'), $lifetimeCustomer->getTotalCount(), true);
34
+ $this->addTotal($this->__('Average Customers Created Per Day'), $lifetimeCustomer->getDayCount(), true);
35
+ }
36
+
37
+ /**
38
+ * get customer information for tab from customer analysis model
39
+ *
40
+ * @return Varien_Object
41
+ */
42
+ protected function getCustomerInformationForTab()
43
+ {
44
+ $customerAnalysisModel = Mage::getModel('email_connector/adminhtml_dashboard_tabs_analysis_customer');
45
+ return $customerAnalysisModel->getLifeTimeTimeCustomer($this->_store, $this->_website, $this->_group);
46
+ }
47
+
48
+ /**
49
+ * @return string
50
+ */
51
+ public function getTitle()
52
+ {
53
+ return "Customers";
54
+ }
55
+ }
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Dashboard/Tabs/Analysis/Rfm.php ADDED
@@ -0,0 +1,91 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dotdigitalgroup_Email_Block_Adminhtml_Dashboard_Tabs_Analysis_Rfm extends Dotdigitalgroup_Email_Block_Adminhtml_Dashboard_Tabs_Analysis
4
+ {
5
+ protected $rfm = array();
6
+ protected $_store = 0;
7
+ protected $_group = 0;
8
+ protected $_website = 0;
9
+
10
+ /**
11
+ * set template
12
+ *
13
+ * @throws Exception
14
+ */
15
+ public function __construct()
16
+ {
17
+ parent::_construct();
18
+
19
+ $this->_store = $this->getRequest()->getParam('store');
20
+ $this->_group = $this->getRequest()->getParam('group');
21
+ $this->_website = $this->getRequest()->getParam('website');
22
+ $this->setTemplate('connector/dashboard/tabs/analysis/rfm.phtml');
23
+ }
24
+
25
+ /**
26
+ * Prepare the layout.
27
+ *
28
+ * @return Mage_Core_Block_Abstract|void
29
+ * @throws Exception
30
+ */
31
+ protected function _prepareLayout()
32
+ {
33
+ $rfmAnalysisModel = Mage::getModel('email_connector/adminhtml_dashboard_tabs_analysis_rfm');
34
+ $this->rfm = $rfmAnalysisModel->getPreparedRfm($this->_store, $this->_website, $this->_group);
35
+ foreach($this->rfm['Monetary'] as $key => $value)
36
+ {
37
+ $this->rfm['Monetary'][$key] = $this->format($value);
38
+ }
39
+ }
40
+
41
+ /**
42
+ * @return array
43
+ */
44
+ protected function getRfm()
45
+ {
46
+ foreach($this->rfm as $k => $type){
47
+ foreach($type as $p => $value){
48
+ if($value == '')
49
+ $this->rfm[$k][$p] = '0';
50
+ }
51
+ }
52
+ return $this->rfm;
53
+ }
54
+
55
+ /**
56
+ * get currency
57
+ *
58
+ * @return Mage_Directory_Model_Currency
59
+ * @throws Exception
60
+ * @throws Mage_Core_Exception
61
+ */
62
+ public function getCurrency()
63
+ {
64
+ if ($this->_store) {
65
+ $currencyCode = Mage::app()->getStore($this->getRequest()->getParam('store'))->getBaseCurrency();
66
+ } else if ($this->_website){
67
+ $currencyCode = Mage::app()->getWebsite($this->getRequest()->getParam('website'))->getBaseCurrency();
68
+ } else if ($this->_group){
69
+ $currencyCode = Mage::app()->getGroup($this->getRequest()->getParam('group'))->getWebsite()->getBaseCurrency();
70
+ } else {
71
+ $currencyCode = Mage::app()->getStore()->getBaseCurrency();
72
+ }
73
+ return $currencyCode;
74
+ }
75
+
76
+ /**
77
+ * format price from currency
78
+ *
79
+ * @param $price
80
+ * @return string
81
+ */
82
+ public function format($price)
83
+ {
84
+ return $this->getCurrency()->format($price);
85
+ }
86
+
87
+ public function getTitle()
88
+ {
89
+ return $this->__("RFM Matrix") . "(<a href='https://econsultancy.com/blog/64481-finding-your-best-customers-with-the-rfm-matrix' target='_blank'>" . $this->__("Find out more") . "</a>)";
90
+ }
91
+ }
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Dashboard/Tabs/Analysis/Sales.php ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dotdigitalgroup_Email_Block_Adminhtml_Dashboard_Tabs_Analysis_Sales extends Dotdigitalgroup_Email_Block_Adminhtml_Dashboard_Tabs_Analysis
4
+ {
5
+ protected $_store = 0;
6
+ protected $_group = 0;
7
+ protected $_website = 0;
8
+
9
+ /**
10
+ * set template
11
+ *
12
+ * @throws Exception
13
+ */
14
+ public function __construct()
15
+ {
16
+ parent::_construct();
17
+
18
+ $this->_store = $this->getRequest()->getParam('store');
19
+ $this->_group = $this->getRequest()->getParam('group');
20
+ $this->_website = $this->getRequest()->getParam('website');
21
+ $this->setTemplate('connector/dashboard/tabs/data.phtml');
22
+ }
23
+
24
+ /**
25
+ * Prepare the layout.
26
+ *
27
+ * @return Mage_Core_Block_Abstract|void
28
+ * @throws Exception
29
+ */
30
+ protected function _prepareLayout()
31
+ {
32
+ $lifetimeSales = $this->getSalesInformationForTab();
33
+ $this->addTotal($this->__('Total Sales Revenue'), $lifetimeSales->getLifetime());
34
+ $this->addTotal($this->__('Average Order Value'), $lifetimeSales->getAverage());
35
+ $this->addTotal($this->__('Total Number Of Orders'), $lifetimeSales->getTotalCount(), true);
36
+ $this->addTotal($this->__('Average Orders Created Per Day'), $lifetimeSales->getDayCount(), true);
37
+ }
38
+
39
+ /**
40
+ * get sales information from order analysis model
41
+ *
42
+ * @return Varien_Object
43
+ */
44
+ protected function getSalesInformationForTab()
45
+ {
46
+ $orderAnalysisModel = Mage::getModel('email_connector/adminhtml_dashboard_tabs_analysis_orders');
47
+ return $orderAnalysisModel->getLifetimeSales($this->_store, $this->_website, $this->_group);
48
+ }
49
+
50
+ public function getTitle()
51
+ {
52
+ return "Sales";
53
+ }
54
+ }
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Dashboard/Tabs/Analysis/Subscriber.php ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dotdigitalgroup_Email_Block_Adminhtml_Dashboard_Tabs_Analysis_Subscriber extends Dotdigitalgroup_Email_Block_Adminhtml_Dashboard_Tabs_Analysis
4
+ {
5
+ protected $_store = 0;
6
+ protected $_group = 0;
7
+ protected $_website = 0;
8
+
9
+ /**
10
+ * set template
11
+ *
12
+ * @throws Exception
13
+ */
14
+ public function __construct()
15
+ {
16
+ parent::_construct();
17
+
18
+ $this->_store = $this->getRequest()->getParam('store');
19
+ $this->_group = $this->getRequest()->getParam('group');
20
+ $this->_website = $this->getRequest()->getParam('website');
21
+ $this->setTemplate('connector/dashboard/tabs/data.phtml');
22
+ }
23
+
24
+ /**
25
+ * Prepare the layout.
26
+ *
27
+ * @return Mage_Core_Block_Abstract|void
28
+ * @throws Exception
29
+ */
30
+ protected function _prepareLayout()
31
+ {
32
+ $lifetimeSubscribers = $this->getSubscriberInformationForTab();
33
+ $this->addTotal($this->__('Total Number Of Subscribers'), $lifetimeSubscribers->getTotalSubscriber(), true);
34
+ $this->addTotal($this->__('Subscribers Who Are Also Customers'), $lifetimeSubscribers->getTotalSubscriberCustomer(), true);
35
+ $this->addTotal($this->__('Average Subscribers Created Per Day'), $lifetimeSubscribers->getSubscribersPerDay(), true);
36
+ }
37
+
38
+ /**
39
+ * get subscriber information for tab from subscriber analysis model
40
+ *
41
+ * @return Varien_Object
42
+ */
43
+ protected function getSubscriberInformationForTab()
44
+ {
45
+ $subscriberAnalysisModel = Mage::getModel('email_connector/adminhtml_dashboard_tabs_analysis_subscriber');
46
+ return $subscriberAnalysisModel->getLifetimeSubscribers($this->_store, $this->_website, $this->_group);
47
+ }
48
+
49
+ /**
50
+ * @return string
51
+ */
52
+ public function getTitle()
53
+ {
54
+ return "Subscribers";
55
+ }
56
+ }
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Dashboard/Tabs/Config.php ADDED
@@ -0,0 +1,120 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dotdigitalgroup_Email_Block_Adminhtml_Dashboard_Tabs_Config extends Mage_Adminhtml_Block_Dashboard_Bar
4
+ {
5
+ /**
6
+ * set template
7
+ *
8
+ * @throws Exception
9
+ */
10
+ public function __construct()
11
+ {
12
+ parent::_construct();
13
+ $this->setTemplate('connector/dashboard/tabs/config.phtml');
14
+ }
15
+
16
+ /**
17
+ * Prepare the layout. set child blocks
18
+ *
19
+ * @return Mage_Core_Block_Abstract|void
20
+ * @throws Exception
21
+ */
22
+ protected function _prepareLayout()
23
+ {
24
+
25
+ }
26
+
27
+ /**
28
+ * get Tab content title
29
+ *
30
+ * @return string
31
+ */
32
+ public function getTitle()
33
+ {
34
+ return 'Dashboard';
35
+ }
36
+
37
+ /**
38
+ * Load the config data.
39
+ * @return array
40
+ */
41
+ public function getConfigData()
42
+ {
43
+ //config data collection
44
+ $collection = Mage::getModel('email_connector/config')->getCollection()
45
+ ->addFieldToFilter('path', array('neq' => 'connector_api_hour_trigger'))
46
+ ->addFieldToFilter('is_api', true);
47
+
48
+ $data = $collection->getData();
49
+
50
+ return $data;
51
+ }
52
+
53
+ /**
54
+ * Get the time trigger from collection.
55
+ * @return mixed
56
+ */
57
+ public function getTimeTrigger()
58
+ {
59
+ $timeData = Mage::getModel('email_connector/config')->getCollection()
60
+ ->addFieldToFilter('path', Dotdigitalgroup_Email_Helper_Config::CONNECTOR_EMAIL_CONFIG_HOUR_TRIGGER)
61
+ ->setPageSize(1)
62
+ ->getFirstItem();
63
+
64
+ return $timeData->getValue();
65
+ }
66
+
67
+ /**
68
+ * Format the date string.
69
+ * @param $date
70
+ *
71
+ * @return string
72
+ */
73
+ public function formatDateString($date)
74
+ {
75
+ if ($date) {
76
+ $date = new Zend_Date($date);
77
+ return $date->toString(Zend_Date::DATETIME);
78
+ }
79
+ return 'First Time Run';
80
+ }
81
+
82
+ /**
83
+ * get column width
84
+ *
85
+ * @return string
86
+ */
87
+ public function getColumnWidth()
88
+ {
89
+ return "620px";
90
+ }
91
+
92
+
93
+ /**
94
+ * Get doc desription for the Apiconnector reflection class.
95
+ * reutrn the comment for each method.
96
+ * @param $method
97
+ *
98
+ * @return string
99
+ */
100
+ public function getDocDocument($method)
101
+ {
102
+ //reflection class for client
103
+ $rc = new ReflectionClass('Dotdigitalgroup_Email_Model_Apiconnector_Client');
104
+
105
+ //method data
106
+ $meth = $rc->getMethod( $method );
107
+ //grab the doc block for the method
108
+ $docCommment = $meth->getDocComment();
109
+
110
+ //select only the first text
111
+ preg_match( '/([A-Z])+.*\./', $docCommment, $matches );
112
+
113
+ if ( isset( $matches[0] ) ) {
114
+ //return only selected text
115
+ return $matches[0];
116
+ }
117
+ //return all doc block
118
+ return $docCommment;
119
+ }
120
+ }
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Dashboard/Tabs/General.php ADDED
@@ -0,0 +1,107 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dotdigitalgroup_Email_Block_Adminhtml_Dashboard_Tabs_General extends Mage_Adminhtml_Block_Dashboard_Bar
4
+ {
5
+ protected $group = array();
6
+
7
+ /**
8
+ * Set the template.
9
+ */
10
+ public function __construct()
11
+ {
12
+ $this->initiateGroupArray();
13
+ parent::_construct();
14
+ $this->setTemplate('connector/dashboard/tabs/general/index.phtml');
15
+ }
16
+
17
+ /**
18
+ * Prepare the layout.
19
+ *
20
+ * @return Mage_Core_Block_Abstract|void
21
+ * @throws Exception
22
+ */
23
+ protected function _prepareLayout()
24
+ {
25
+ $website = 0;
26
+ if ($store = $this->getRequest()->getParam('store')) {
27
+ $website = Mage::app()->getStore($store)->getWebsite();
28
+ } elseif ($this->getRequest()->getParam('website')) {
29
+ $website = $this->getRequest()->getParam('website');
30
+ }
31
+ $apiUsername = Mage::helper('connector')->getApiUsername($website);
32
+ $apiPassword = Mage::helper('connector')->getApiPassword($website);
33
+ $data = Mage::getModel('email_connector/apiconnector_client')
34
+ ->setApiUsername($apiUsername)
35
+ ->setApiPassword($apiPassword)
36
+ ->getAccountInfo();
37
+
38
+ if(isset($data->id))
39
+ $this->prepareGroupArray($data);
40
+
41
+ $this->_setChild();
42
+
43
+ parent::_prepareLayout();
44
+ }
45
+
46
+ protected function _setChild()
47
+ {
48
+ foreach($this->group as $key => $data){
49
+ $this->setChild($key,
50
+ $this->getLayout()->createBlock('email_connector/adminhtml_dashboard_tabs_general_data', '', $data)
51
+ );
52
+ }
53
+ }
54
+
55
+ protected function prepareGroupArray($data)
56
+ {
57
+ foreach ($data->properties as $one) {
58
+ foreach($this->group as $key => $type){
59
+ if(array_key_exists($one->name, $type)){
60
+ $this->group[$key][$one->name] = $one->value;
61
+ }
62
+ }
63
+ }
64
+ }
65
+
66
+ protected function initiateGroupArray()
67
+ {
68
+ $this->group['account'] = array(
69
+ 'Title' => 'Account',
70
+ 'Name' => $this->__('Not Available'),
71
+ 'MainMobilePhoneNumber' => $this->__('Not Available'),
72
+ 'MainEmail' => $this->__('Not Available'),
73
+ 'AvailableEmailSendsCredits' => $this->__('Not Available')
74
+ );
75
+ $this->group['data'] = array(
76
+ 'Title' => 'Data',
77
+ 'TransactionalDataAllowanceInMegabytes' => $this->__('Not Available'),
78
+ 'TransactionalDataUsageInMegabytes' => $this->__('Not Available')
79
+ );
80
+ $this->group['api'] = array(
81
+ 'Title' => 'Api',
82
+ 'APILocale' => $this->__('Not Available'),
83
+ 'ApiCallsInLastHour' => $this->__('Not Available'),
84
+ 'ApiCallsRemaining' => $this->__('Not Available')
85
+ );
86
+ }
87
+
88
+ /**
89
+ * get Tab content title
90
+ *
91
+ * @return string
92
+ */
93
+ public function getTitle()
94
+ {
95
+ return "Connector Account Information";
96
+ }
97
+
98
+ /**
99
+ * get column width
100
+ *
101
+ * @return string
102
+ */
103
+ public function getColumnWidth()
104
+ {
105
+ return "400px;";
106
+ }
107
+ }
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Dashboard/Tabs/General/Data.php ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dotdigitalgroup_Email_Block_Adminhtml_Dashboard_Tabs_General_Data extends Dotdigitalgroup_Email_Block_Adminhtml_Dashboard_Tabs_General
4
+ {
5
+ protected $data = array();
6
+ protected $title = "";
7
+
8
+ /**
9
+ * set template
10
+ * @param $info
11
+ * @throws Exception
12
+ */
13
+ public function __construct($info = array())
14
+ {
15
+ $this->title = $info['Title'];
16
+ unset($info['Title']);
17
+ $this->data = $info;
18
+
19
+ parent::_construct();
20
+ $this->setTemplate('connector/dashboard/tabs/data.phtml');
21
+ }
22
+
23
+ /**
24
+ * Prepare the layout.
25
+ *
26
+ * @return Mage_Core_Block_Abstract|void
27
+ * @throws Exception
28
+ */
29
+ protected function _prepareLayout()
30
+ {
31
+ foreach($this->data as $key => $value){
32
+ $this->addTotal($this->__($key), $value, true);
33
+ }
34
+ }
35
+
36
+ /**
37
+ * @return string
38
+ */
39
+ public function getTitle()
40
+ {
41
+ return $this->title;
42
+ }
43
+ }
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Dashboard/Tabs/Status.php ADDED
@@ -0,0 +1,1625 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dotdigitalgroup_Email_Block_Adminhtml_Dashboard_Tabs_Status extends Mage_Adminhtml_Block_Widget implements Mage_Adminhtml_Block_Widget_Tab_Interface
4
+ {
5
+
6
+ const CONNECTOR_DASHBOARD_PASSED = 'available';
7
+ const CONNECTOR_DASHBOARD_WARRNING = 'connector_warning';
8
+ const CONNECTOR_DASHBOARD_FAILED = 'error';
9
+
10
+ const FAST_FIX_MESSAGE = 'Fast Fix Available, Click To Enable The Mapping And Redirect Back.';
11
+
12
+ private $_checkpoints = array(
13
+ 'extention_installed' => 'Extension And CURL Installed',
14
+ 'cron_running' => 'Cron running',
15
+ 'address_book_mapped' => 'Address Book Mapping',
16
+ 'roi_tracking_enabled' => 'ROI And Page Tracking',
17
+ 'transactional_emails' => 'Transactional Emails',
18
+ 'file_permission_setttings' => 'File Permission Settings',
19
+ 'missing_files' => 'Missing Files',
20
+ 'contact_sync_enabled' => 'Contact Sync Enabled',
21
+ 'contact_syncing' => 'Contacts Syncing',
22
+ 'subscriber_sync_enabled' => 'Subscribers Sync Enabled',
23
+ 'subscribers_syncing' => 'Subscribers Syncing',
24
+ 'automation_active' => 'Automation Programs Active',
25
+ 'abandoned_carts_enabled' => 'Abandoned Carts Enabled',
26
+ 'data_field_mapped' => 'Data Field Mapped',
27
+ 'valid_api_credentials' => 'API Credentials',
28
+ 'order_enabled' => 'Order Sync Enabled',
29
+ 'custom_order_attributes' => 'Custom Order Attributes',
30
+ 'order_syncing' => 'Orders Syncing',
31
+ 'last_abandoned_cart_sent_day' => 'Last Abandoned Cart Sent Day',
32
+ 'review_enabled' => 'Review Sync Enabled',
33
+ 'review_syncing' => 'Review Syncing',
34
+ 'review_campaign_status' => 'Review Status',
35
+ 'wishlist_enabled' => 'Wishlist Enabled',
36
+ 'wishlist_syncing' => 'Wishlist Syncing',
37
+ 'easy_email_capture_enabled' => 'Easy Email Capture Enabled',
38
+ 'disable_newsletter_success_enabled' => 'Disable Newsletter Success Enabled',
39
+ 'conflict_check' => 'Conflict Check',
40
+ 'system_information' => 'System Information'
41
+
42
+ );
43
+ /**
44
+ * Set the template.
45
+ */
46
+ public function __construct()
47
+ {
48
+ parent::_construct();
49
+
50
+ $this->setTemplate('connector/dashboard/status.phtml');
51
+ }
52
+
53
+ /**
54
+ * Prepare the layout.
55
+ *
56
+ * @return Mage_Core_Block_Abstract|void
57
+ * @throws Exception
58
+ */
59
+ protected function _prepareLayout()
60
+ {
61
+ }
62
+
63
+ public function canShowTab()
64
+ {
65
+ return true;
66
+ }
67
+ public function isHidden()
68
+ {
69
+ return true;
70
+ }
71
+
72
+ public function getTabLabel()
73
+ {
74
+ return Mage::helper('connector')->__('Marketing Automation System Status');
75
+ }
76
+
77
+ public function getTabTitle()
78
+ {
79
+ return Mage::helper('connector')->__('Marketing Automation System Status');
80
+ }
81
+
82
+ /**
83
+ * Collapse key for the fieldset state.
84
+ * @param $key
85
+ *
86
+ * @return bool
87
+ */
88
+ protected function _getCollapseState($key)
89
+ {
90
+ $extra = Mage::getSingleton('admin/session')->getUser()->getExtra();
91
+ if (isset($extra['configState'][$key])) {
92
+ return $extra['configState'][$key];
93
+ }
94
+
95
+ return false;
96
+ }
97
+
98
+ public function getCheckpoints() {
99
+ return $this->_checkpoints;
100
+ }
101
+
102
+
103
+ public function addCheckpoint($checkpoint)
104
+ {
105
+ $this->_checkpoints[$checkpoint->getName()] = $checkpoint;
106
+ }
107
+
108
+ /**
109
+ * Extension modules and curl check.
110
+ * @return Dotdigitalgroup_Email_Model_Adminhtml_Dashboard_Content
111
+ */
112
+ public function extentionInstalled()
113
+ {
114
+ $resultContent = Mage::getModel('email_connector/adminhtml_dashboard_content');
115
+
116
+ $resultContent->setStyle(self::CONNECTOR_DASHBOARD_PASSED)
117
+ ->setTitle('Extension Status : ')
118
+ ->setMessage('Extension active and PHP Curl extension installed.');
119
+
120
+ $installed = (bool)Mage::getConfig()->getModuleConfig('Dotdigitalgroup_Email')->is('active', 'true');
121
+
122
+ if (! $installed || ! function_exists('curl_version')) {
123
+ $resultContent->setStyle( self::CONNECTOR_DASHBOARD_FAILED );
124
+ $resultContent->setMessage('Sync May Not Work Properly.');
125
+ $resultContent->setHowto((! function_exists('curl_version'))? 'PHP Curl extention not found !' : 'PHP and Curl extension installed');
126
+ }
127
+ return $resultContent;
128
+ }
129
+
130
+ /**
131
+ * Check cron for the customer sync.
132
+ * @return array
133
+ */
134
+ public function cronRunning()
135
+ {
136
+ $resultContent = Mage::getModel('email_connector/adminhtml_dashboard_content');
137
+ $resultContent->setStyle(self::CONNECTOR_DASHBOARD_PASSED)
138
+ ->setTitle('Cron Status : ')
139
+ ->setMessage('Cron is running.');
140
+ $message = 'No cronjob task found. Check if cron is configured correctly.';
141
+ $howToSetupCron = 'For more information <a href="http://www.magentocommerce.com/wiki/1_-_installation_and_configuration/how_to_setup_a_cron_job">how to setup the Magento cronjob.</a>';
142
+ $lastCustomerSync = Mage::getModel('email_connector/cron')->getLastCustomerSync();
143
+
144
+ if ($lastCustomerSync === false) {
145
+ $resultContent->setStyle(self::CONNECTOR_DASHBOARD_FAILED)
146
+ ->setHowto($howToSetupCron);
147
+ } else {
148
+ $timespan = Mage::helper('connector')->dateDiff($lastCustomerSync);
149
+ //last cron was less then 5min
150
+ if ($timespan <= 5 * 60) {
151
+ $resultContent->setTitle('Cronjob is working : ');
152
+ $message = sprintf('(Last execution: %s minute(s) ago) ', round($timespan/60));
153
+ } elseif ($timespan > 5 * 60 && $timespan <= 60 * 60 ) {
154
+ //last cron execution was between 15min and 60min
155
+ $resultContent->setTitle('Last customer sync : ' )
156
+ ->setStyle(self::CONNECTOR_DASHBOARD_FAILED);
157
+ $message = sprintf(' %s minutes. ', round($timespan/60));
158
+ } else {
159
+ //last cron was more then an hour
160
+ $resultContent->setStyle(self::CONNECTOR_DASHBOARD_FAILED)
161
+ ->setHowto('Last customer sync is older than one hour.')
162
+ ->setHowto($howToSetupCron);
163
+ }
164
+ }
165
+
166
+ $resultContent->setMessage($message);
167
+ return $resultContent;
168
+ }
169
+
170
+ /**
171
+ * Address Book Mapping.
172
+ * @return Dotdigitalgroup_Email_Model_Adminhtml_Dashboard_Content
173
+ */
174
+ public function addressBookMapped()
175
+ {
176
+ $resultContent = Mage::getModel('email_connector/adminhtml_dashboard_content');
177
+ $resultContent->setStyle(self::CONNECTOR_DASHBOARD_PASSED)
178
+ ->setTitle('Configuration For Address Book Status : ')
179
+ ->setMessage('Looks Great.');
180
+
181
+ foreach (Mage::app()->getWebsites() as $website ) {
182
+
183
+ $websiteName = $website->getName();
184
+ $link = Mage::helper('adminhtml')->getUrl('*/system_config/edit/section/connector_sync_settings/website/' . $website->getCode());
185
+
186
+ $customerMapped = ($website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMERS_ADDRESS_BOOK_ID))? true :
187
+ 'Not mapped!';
188
+ $subscriberMapped = ($website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_SUBSCRIBERS_ADDRESS_BOOK_ID))? true :
189
+ 'Not mapped!';
190
+ $guestMapped = ($website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_GUEST_ADDRESS_BOOK_ID))? true :
191
+ 'Not mapped!';
192
+
193
+ if ($customerMapped !== true || $subscriberMapped !== true || $guestMapped !== true) {
194
+ $resultContent->setStyle(self::CONNECTOR_DASHBOARD_FAILED)
195
+ ->setMessage('')
196
+ ->setTable(array(
197
+ 'Website' => $websiteName,
198
+ 'Customers' => ($customerMapped !== true)? $customerMapped . ' <a href="' . $link . '">configuration</a>' : 'Mapped.',
199
+ 'Subscribers' => ($subscriberMapped !== true)? $subscriberMapped . ' <a href="' . $link . '">configuration</a>' : 'Mapped.',
200
+ 'Guests' => ($guestMapped !== true)? $guestMapped . ' <a href="' . $link . '">configuration</a>' : 'Mapped.'
201
+ ));
202
+ }
203
+ }
204
+
205
+ return $resultContent;
206
+ }
207
+
208
+ /**
209
+ * ROI Tracking.
210
+ * @return Dotdigitalgroup_Email_Model_Adminhtml_Dashboard_Content
211
+ */
212
+ public function roiTrackingEnabled()
213
+ {
214
+ $resultContent = Mage::getModel('email_connector/adminhtml_dashboard_content');
215
+ $resultContent->setStyle(self::CONNECTOR_DASHBOARD_PASSED)
216
+ ->setTitle('ROI Tracking Status : ')
217
+ ->setMessage('Looks Great.');
218
+
219
+ $valid = true;
220
+ foreach ( Mage::app()->getWebsites() as $website ) {
221
+ $websiteName = $website->getName();
222
+
223
+ $roiConfig = ($website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_ROI_TRACKING_ENABLED))? true : 'Not Mapped! ';
224
+ $pageTracking = ($website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_PAGE_TRACKING_ENABLED))? true : 'Not Mapped! ';
225
+ //not mapped show options
226
+ if ($roiConfig !== true || $pageTracking !== true) {
227
+
228
+ //links to enable and get redirected back
229
+ $roiUrl = Mage::helper('adminhtml')->getUrl('*/connector/enablewebsiteconfiguration', array('path' => 'XML_PATH_CONNECTOR_ROI_TRACKING_ENABLED', 'website' => $website->getId()));
230
+ $pageUrl = Mage::helper('adminhtml')->getUrl('*/connector/enablewebsiteconfiguration', array('path' => 'XML_PATH_CONNECTOR_PAGE_TRACKING_ENABLED', 'website' => $website->getId()));
231
+
232
+ $resultContent->setStyle(self::CONNECTOR_DASHBOARD_FAILED)
233
+ ->setMessage('')
234
+ ->setTable(array(
235
+ 'Website' => $websiteName,
236
+ 'ROI' => ($roiConfig !== true)? $roiConfig . ' <a href="' . $roiUrl . '">enable</a>' : 'Mapped.',
237
+ 'PAGE' => ($pageTracking !== true)? $pageTracking . ' <a href="' . $pageUrl . '">enable</a>' : 'Mapped.'
238
+ ));
239
+ $valid = false;
240
+ }
241
+ }
242
+ //validation failed
243
+ if (! $valid) {
244
+ $resultContent->setHowto(self::FAST_FIX_MESSAGE);
245
+ }
246
+
247
+ return $resultContent;
248
+ }
249
+
250
+ /**
251
+ * Transactional Data.
252
+ * @return Dotdigitalgroup_Email_Model_Adminhtml_Dashboard_Content
253
+ */
254
+ public function transactionalEmails()
255
+ {
256
+ $resultContent = Mage::getModel('email_connector/adminhtml_dashboard_content');
257
+ $resultContent->setStyle(self::CONNECTOR_DASHBOARD_PASSED)
258
+ ->setTitle('Transactional Emails Status : ')
259
+ ->setMessage('Enabled.')
260
+ ;
261
+
262
+ $valid = true;
263
+ foreach ( Mage::app()->getWebsites() as $website ) {
264
+ $websiteName = $website->getName();
265
+ $transactional = ($website->getConfig(Dotdigitalgroup_Email_Helper_Transactional::XML_PATH_TRANSACTIONAL_API_ENABLED))? true : 'Disabled! ';
266
+ if ($transactional !== true){
267
+ $url = Mage::helper('adminhtml')->getUrl('*/connector/enablewebsiteconfiguration', array('path' => 'XML_PATH_TRANSACTIONAL_API_ENABLED', 'website' => $website->getId()));
268
+ $resultContent->setStyle(self::CONNECTOR_DASHBOARD_FAILED)
269
+ ->setMessage('')
270
+ ->setTable(array(
271
+ 'Website' => $websiteName,
272
+ 'Status' => ($transactional)? $transactional . ' <a href="' . $url . '">enable</a>' : 'Enabled.'
273
+ ));
274
+ $valid = false;
275
+ }
276
+ }
277
+ //validation failed
278
+ if (! $valid) {
279
+ $resultContent->setHowto(self::FAST_FIX_MESSAGE);
280
+ }
281
+
282
+ return $resultContent;
283
+ }
284
+
285
+ /**
286
+ * File Permissions.
287
+ * @return Dotdigitalgroup_Email_Model_Adminhtml_Dashboard_Content
288
+ */
289
+ public function filePermissionSetttings()
290
+ {
291
+ $resultContent = Mage::getModel('email_connector/adminhtml_dashboard_content');
292
+ $resultContent->setStyle(self::CONNECTOR_DASHBOARD_PASSED)
293
+ ->setTitle('Files/Folders Permission Settings : ')
294
+ ->setMessage('Looks Great.');
295
+
296
+ /**
297
+ * Arhive and email export directories.
298
+ */
299
+ $emailDir = Mage::getBaseDir('var') . DIRECTORY_SEPARATOR . 'export' . DIRECTORY_SEPARATOR . 'email';
300
+ $archiveDir = Mage::getBaseDir('var') . DIRECTORY_SEPARATOR . 'export' . DIRECTORY_SEPARATOR . 'email' . DIRECTORY_SEPARATOR . 'archive';
301
+
302
+ $checkEmail = Mage::helper('connector/file')->getPathPermission($emailDir);
303
+ $checkArchive = Mage::helper('connector/file')->getPathPermission($archiveDir);
304
+
305
+ //file persmission failed
306
+ if ($checkEmail != 755 && $checkEmail != 777 || $checkArchive != 755 && $checkArchive != 777) {
307
+ $resultContent->setStyle(self::CONNECTOR_DASHBOARD_FAILED)
308
+ ->setMessage('Wrong Permission For Directory : 777 or 755');
309
+
310
+ //list of directory permission checked
311
+ if ($checkEmail != 755 || $checkEmail != 777)
312
+ $resultContent->setHowto( $emailDir . ' is set to : ' . $checkEmail);
313
+ if ($checkArchive != 755 || $checkArchive != 777)
314
+ $resultContent->setHowto( $archiveDir . ' is set to : ' . $checkArchive);
315
+ }
316
+
317
+ return $resultContent;
318
+ }
319
+
320
+ /**
321
+ * Check for missing files.
322
+ * @return Dotdigitalgroup_Email_Model_Adminhtml_Dashboard_Content
323
+ */
324
+ public function missingFiles()
325
+ {
326
+ $resultContent = Mage::getModel('email_connector/adminhtml_dashboard_content');
327
+
328
+ $resultContent->setStyle(self::CONNECTOR_DASHBOARD_PASSED)
329
+ ->setTitle('Missing Files : ')
330
+ ->setMessage('Looks Great.');
331
+
332
+ $filePath = Mage::getModuleDir('etc', Dotdigitalgroup_Email_Helper_Config::MODULE_NAME).DS.'files.yaml';
333
+ $config = Zend_Config_Yaml::decode(file_get_contents($filePath));
334
+
335
+ /**
336
+ * Code dirs.
337
+ */
338
+ $etcDir = Mage::getModuleDir('etc', Dotdigitalgroup_Email_Helper_Config::MODULE_NAME);
339
+ $controllerDir = Mage::getModuleDir('controllers', Dotdigitalgroup_Email_Helper_Config::MODULE_NAME);
340
+ $sqlDir = Mage::getModuleDir('sql', Dotdigitalgroup_Email_Helper_Config::MODULE_NAME);
341
+ $localeDir = Mage::getBaseDir('locale');
342
+ $rootDir = Mage::getModuleDir('', Dotdigitalgroup_Email_Helper_Config::MODULE_NAME);
343
+ $blockDir = $rootDir .DS. 'Block';
344
+ $helperDir = $rootDir .DS. 'Helper';
345
+ $modelDir = $rootDir .DS. 'Model';
346
+
347
+ /**
348
+ * Design dir.
349
+ */
350
+ $designDir = Mage::getBaseDir('design');
351
+
352
+ /**
353
+ * Skin dir.
354
+ */
355
+ $skinDir = Mage::getBaseDir('skin');
356
+
357
+ /**
358
+ * Js dir
359
+ */
360
+ $jsDir = Mage::getBaseDir('base') . DS . 'js';
361
+
362
+ /**
363
+ * lib dir
364
+ */
365
+ $libDir = Mage::getBaseDir('lib');
366
+
367
+ $filesToCheck = array($config['etc'], $config['controllers'], $config['sql'], $config['locale'], $config['block'],
368
+ $config['helper'], $config['model'], $config['design'], $config['skin'], $config['lib'], $config['js']);
369
+ $pathToCheck = array($etcDir, $controllerDir, $sqlDir, $localeDir, $blockDir, $helperDir,
370
+ $modelDir, $designDir, $skinDir, $libDir, $jsDir);
371
+ foreach ( $filesToCheck as $subdir ) {
372
+ foreach ( $subdir as $path ) {
373
+ $file = $pathToCheck[0] . DS . str_replace( '#', DS, $path );
374
+
375
+ if ( !file_exists( $file ) ) {
376
+ $resultContent->setStyle( self::CONNECTOR_DASHBOARD_FAILED )
377
+ ->setMessage('')
378
+ ->setHowto('File not found : ' . $file );
379
+ }
380
+ }
381
+ array_shift($pathToCheck);
382
+ }
383
+
384
+ return $resultContent;
385
+ }
386
+
387
+ /**
388
+ * Contact Sync Status.
389
+ * @return Dotdigitalgroup_Email_Model_Adminhtml_Dashboard_Content
390
+ */
391
+ public function contactSyncEnabled()
392
+ {
393
+ $resultContent = Mage::getModel('email_connector/adminhtml_dashboard_content');
394
+ $resultContent->setStyle(self::CONNECTOR_DASHBOARD_PASSED)
395
+ ->setTitle('Contacts Sync Status : ')
396
+ ->setMessage('Looks Great.');
397
+
398
+ $valid = true;
399
+ foreach ( Mage::app()->getWebsites() as $website ) {
400
+ $websiteName = $website->getName();
401
+ $contact = ($website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_SYNC_CONTACT_ENABLED))? true : 'Disabled!';
402
+ //disabled show data table
403
+ if ($contact !== true){
404
+ //redirection url to enable website config
405
+ $url = Mage::helper('adminhtml')->getUrl('*/connector/enablewebsiteconfiguration', array('path' => 'XML_PATH_CONNECTOR_SYNC_CONTACT_ENABLED', 'website' => $website->getId()));
406
+ $resultContent->setStyle(self::CONNECTOR_DASHBOARD_FAILED)
407
+ ->setMessage('')
408
+ ->setTable(array(
409
+ 'Website' => $websiteName,
410
+ 'Status' => ($contact)? $contact . ' <a href="' . $url . '">enable</a>' : 'Enabled.'
411
+ ))
412
+ ;
413
+ $valid = false;
414
+ }
415
+ }
416
+ //validation failed
417
+ if (! $valid) {
418
+ $resultContent->setHowto(self::FAST_FIX_MESSAGE);
419
+ }
420
+
421
+ return $resultContent;
422
+ }
423
+
424
+ /**
425
+ * Check if contact is syncing by counting the number of contacts imported.
426
+ * @return Dotdigitalgroup_Email_Model_Adminhtml_Dashboard_Content
427
+ */
428
+ public function contactSyncing()
429
+ {
430
+ //content to render
431
+ $resultContent = Mage::getModel('email_connector/adminhtml_dashboard_content');
432
+ $resultContent->setStyle(self::CONNECTOR_DASHBOARD_PASSED)
433
+ ->setTitle('Contacts Sync : ')
434
+ ->setMessage('Looks Great.');
435
+ $contactModel = Mage::getModel('email_connector/contact');
436
+
437
+ //global email duplicates
438
+ if (Mage::getResourceModel('customer/customer')->findEmailDuplicates()) {
439
+
440
+ //duplicate email customers
441
+ $customers = Mage::helper('connector')->getCustomersWithDuplicateEmails();
442
+ $customerEmails = implode(', ', $customers->getColumnValues('email'));
443
+ //render the email duplicates
444
+ $resultContent->setHowto('Found Duplicate Customers Emails :')
445
+ ->setHowto($customerEmails);
446
+ }
447
+
448
+ foreach ( Mage::app()->getWebsites() as $website ) {
449
+
450
+ $websiteId = $website->getId();
451
+ //total customers for website
452
+ $countCustomers = Mage::getModel('customer/customer')->getCollection()
453
+ ->addAttributeToFilter('website_id', $websiteId)
454
+ ->getSize();
455
+
456
+ //skip if no customers
457
+ if (! $countCustomers)
458
+ continue;
459
+
460
+ //total contacts from customer address book
461
+ $customerAddressBook = $this->_getAddressBookContacts($website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMERS_ADDRESS_BOOK_ID), $website);
462
+ $countAddressbookContacts = ($customerAddressBook)? $customerAddressBook->contacts : 0;
463
+ //total contacts as customers
464
+ $countCustomerContacts = $contactModel->getNumberCustomerContacts($websiteId);
465
+
466
+ //suppressed contacts
467
+ $suppressed = $contactModel->getNumberCustomerSuppressed($websiteId);
468
+
469
+ //table data
470
+ $tableData = array(
471
+ 'Website' => $website->getName(),
472
+ 'Total Customers/Contacts' => $countCustomers . '/ ' . $countCustomerContacts,
473
+ 'Customer AddressBook Contacts' => ($customerAddressBook)? $customerAddressBook->name . ' : ' . $countAddressbookContacts : 'Not Mapped.',
474
+ 'Suppressed' => $suppressed,
475
+ 'Synced' => $contactModel->getNumberCustomerSynced($websiteId)
476
+ );
477
+
478
+ //number of customers not match, try to update
479
+ if ($countCustomers != $countCustomerContacts) {
480
+
481
+ $url = Mage::helper('adminhtml')->getUrl('*/connector/populatecontacts', array('type' => 'customers', 'website' => $website->getId()));
482
+ $link = ' <a href="' . $url . '"> populate</a>';
483
+ $tableData['Status'] = 'Customers not matching the contact table. ' . $link;
484
+ //customers not synced yet
485
+ } elseif ($countCustomers > $countCustomerContacts + $suppressed){
486
+ $tableData['Status'] = 'Syncing..';
487
+ //all customers syned.
488
+ } else {
489
+ $tableData['Status'] = 'Synced';
490
+ }
491
+
492
+ //not valid response remove status
493
+ if (!$countAddressbookContacts)
494
+ unset($tableData['Status']);
495
+
496
+ //no contacts
497
+ if (! $countCustomers) {
498
+
499
+ $resultContent->setStyle(self::CONNECTOR_DASHBOARD_FAILED)
500
+ ->setTitle('Contacts Sync (ignore if you have reset contacts for reimport) : ')
501
+ ->setMessage('');
502
+ $tableData['Status'] = 'No Imported Contacts Found!';
503
+ unset($tableData['Imported Contacts']);
504
+ }
505
+
506
+ $resultContent->setTable($tableData);
507
+ }
508
+
509
+ return $resultContent;
510
+ }
511
+
512
+ /**
513
+ * Check for subscribers sync status.
514
+ * @return Dotdigitalgroup_Email_Model_Adminhtml_Dashboard_Content
515
+ */
516
+ public function subscriberSyncEnabled()
517
+ {
518
+ $resultContent = Mage::getModel('email_connector/adminhtml_dashboard_content');
519
+ $resultContent->setStyle(self::CONNECTOR_DASHBOARD_PASSED)
520
+ ->setTitle('Subscribers Sync Status : ')
521
+ ->setMessage('Looks Great.');
522
+
523
+ $passed = true;
524
+ foreach ( Mage::app()->getWebsites() as $website ) {
525
+ $websiteName = $website->getName();
526
+ $contact = ($website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_SYNC_SUBSCRIBER_ENABLED))? true :
527
+ 'Disabled!';
528
+ //disabled show data table
529
+ if ($contact !== true){
530
+ //redirection url to enable website config
531
+ $url = Mage::helper('adminhtml')->getUrl('*/connector/enablewebsiteconfiguration', array('path' => 'XML_PATH_CONNECTOR_SYNC_SUBSCRIBER_ENABLED', 'website' => $website->getId()));
532
+ $resultContent->setStyle(self::CONNECTOR_DASHBOARD_FAILED)
533
+ ->setMessage('')
534
+ ->setTable(array(
535
+ 'Website' => $websiteName,
536
+ 'Status' => ($contact)? $contact . ' <a href="' . $url . '">enable</a>' : 'Enabled.'
537
+ ));
538
+ $passed = false;
539
+ }
540
+ }
541
+ //if validation not passed
542
+ if (! $passed)
543
+ $resultContent->setHowto(self::FAST_FIX_MESSAGE);
544
+
545
+ return $resultContent;
546
+ }
547
+
548
+ /**
549
+ * Subscribers syncing status.
550
+ * @return Dotdigitalgroup_Email_Model_Adminhtml_Dashboard_Content
551
+ */
552
+ public function subscribersSyncing()
553
+ {
554
+ $resultContent = Mage::getModel('email_connector/adminhtml_dashboard_content');
555
+ $resultContent->setStyle(self::CONNECTOR_DASHBOARD_PASSED)
556
+ ->setTitle('Subscribers Sync : ')
557
+ ->setMessage('Looks Great.');
558
+ $contactModel = Mage::getModel('email_connector/contact');
559
+
560
+ foreach ( Mage::app()->getWebsites() as $website ) {
561
+ $websiteId = $website->getId();
562
+ $websiteName = $website->getName();
563
+ $storeIds = $website->getStoreIds();
564
+ //total subscribers
565
+ $countSubscribers = Mage::getModel('newsletter/subscriber')->getCollection()
566
+ ->useOnlySubscribed()
567
+ ->addStoreFilter($storeIds)
568
+ ->getSize();
569
+ //skip if no subscriber
570
+ if (! $countSubscribers)
571
+ continue;
572
+
573
+ //total contacts subscribed
574
+ $countSubscribedContacts = $contactModel->getNumberSubscribers($websiteId);
575
+ //total contacts subscribed imported
576
+ $countSubscribersImported = $contactModel->getNumberSubscribersSynced($websiteId);
577
+
578
+ //number of address
579
+ $countAddressbookContacts = $this->_getAddressBookContacts($website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_SUBSCRIBERS_ADDRESS_BOOK_ID), $website);
580
+
581
+ $tableData = array(
582
+ 'Website' => $websiteName,
583
+ 'Total Subscribers/Contacts' => $countSubscribers . '/ ' . $countSubscribedContacts,
584
+ 'Subscriber AddressBook Contacts' => ($countAddressbookContacts)? $countAddressbookContacts->name . ' : ' . $countAddressbookContacts->contacts : 'Not Mapped.',
585
+ 'Imported' => $countSubscribersImported
586
+ );
587
+
588
+ $tableData['Status'] = '';
589
+
590
+ //no imported contacts
591
+ if (! $countSubscribersImported) {
592
+
593
+ $tableData['Status'] = 'No Imported Subscribers Found.';
594
+ $resultContent->setStyle(self::CONNECTOR_DASHBOARD_FAILED)
595
+ ->setTitle('Subscriber Sync (ignore if you have reset subscribers for reimport) : ')
596
+ ->setMessage('');
597
+ }
598
+ $resultContent->setTable($tableData);
599
+ }
600
+
601
+ return $resultContent;
602
+ }
603
+ //check the mapped programs are active
604
+ public function automationActive()
605
+ {
606
+ $disableCustomer = $disableSubscriber = $disableOrder = $disableGuestOrder = $disableReviews = $disableWishlist = '';
607
+ $resultContent = Mage::getModel('email_connector/adminhtml_dashboard_content');
608
+ $resultContent->setStyle(self::CONNECTOR_DASHBOARD_PASSED)
609
+ ->setTitle('Automation Program Status :')
610
+ ->setMessage('');
611
+
612
+ foreach ( Mage::app()->getWebsites() as $website ) {
613
+ $customerProgram = $website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_AUTOMATION_STUDIO_CUSTOMER);
614
+ $subscriberProgram = $website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_AUTOMATION_STUDIO_SUBSCRIBER);
615
+ $orderProgram = $website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_AUTOMATION_STUDIO_ORDER);
616
+ $guestOrderProgram = $website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_AUTOMATION_STUDIO_GUEST_ORDER);
617
+ $reviewsProgram = $website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_AUTOMATION_STUDIO_REVIEW);
618
+ $wishlistProgram = $website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_AUTOMATION_STUDIO_WISHLIST);
619
+
620
+ //programs
621
+ $cusProgram = $this->_getWebisteProgram($customerProgram, $website);
622
+ $subProgram = $this->_getWebisteProgram($subscriberProgram, $website);
623
+ $orderProgram = $this->_getWebisteProgram($orderProgram, $website);
624
+ $guestOrderProgram = $this->_getWebisteProgram($guestOrderProgram, $website);
625
+ $reviewsProgram = $this->_getWebisteProgram($reviewsProgram, $website);
626
+ $wishlistProgram = $this->_getWebisteProgram($wishlistProgram, $website);
627
+
628
+ //check for wishlist program
629
+ if ($wishlistProgram) {
630
+
631
+ if ($wishlistProgram->status != 'Active') {
632
+
633
+ //set the status as failed
634
+ $resultContent->setStyle(self::CONNECTOR_DASHBOARD_FAILED)
635
+ ->setMessage(' Consider to disable not active programs');
636
+
637
+ $disableWishlist = Mage::helper( 'adminhtml' )->getUrl( '*/connector/enablewebsiteconfiguration', array(
638
+ 'path' => 'XML_PATH_CONNECTOR_AUTOMATION_STUDIO_WISHLIST',
639
+ 'value' => '0',
640
+ 'website' => $website->getId()
641
+ )
642
+ );
643
+ $disableWishlist = 'Deactivated! <a href="' . $disableWishlist . '">click</a> to disable';
644
+
645
+ } else {
646
+
647
+ $disableWishlist = $wishlistProgram->status;
648
+ }
649
+ }
650
+
651
+ //check for order program
652
+ if ($orderProgram) {
653
+
654
+ if ($orderProgram->status != 'Active') {
655
+
656
+ //set the status as failed
657
+ $resultContent->setStyle(self::CONNECTOR_DASHBOARD_FAILED)
658
+ ->setMessage(' Consider to disable not active programs');
659
+
660
+ $disableOrder = Mage::helper( 'adminhtml' )->getUrl( '*/connector/enablewebsiteconfiguration', array(
661
+ 'path' => 'XML_PATH_CONNECTOR_AUTOMATION_STUDIO_ORDER',
662
+ 'value' => '0',
663
+ 'website' => $website->getId()
664
+ )
665
+ );
666
+ $disableOrder = 'Deactivated! <a href="' . $disableOrder . '">click</a> to disable';
667
+
668
+ } else {
669
+
670
+ $disableOrder = $orderProgram->status;
671
+ }
672
+ }
673
+
674
+ //check for review program
675
+ if ($reviewsProgram) {
676
+
677
+ if ($reviewsProgram->status != 'Active') {
678
+
679
+ //set the status as failed
680
+ $resultContent->setStyle(self::CONNECTOR_DASHBOARD_FAILED)
681
+ ->setMessage(' Consider to disable not active programs');
682
+
683
+ $disableReviews = Mage::helper( 'adminhtml' )->getUrl( '*/connector/enablewebsiteconfiguration', array(
684
+ 'path' => 'XML_PATH_CONNECTOR_AUTOMATION_STUDIO_REVIEW',
685
+ 'value' => '0',
686
+ 'website' => $website->getId()
687
+ )
688
+ );
689
+ $disableReviews = 'Deactivated! <a href="' . $disableReviews . '">click</a> to disable';
690
+
691
+ } else {
692
+
693
+ $disableReviews = $reviewsProgram->status;
694
+ }
695
+ }
696
+
697
+ //check for guest order program
698
+ if ($guestOrderProgram) {
699
+
700
+ if ($guestOrderProgram->status != 'Active') {
701
+
702
+ //set the status as failed
703
+ $resultContent->setStyle(self::CONNECTOR_DASHBOARD_FAILED)
704
+ ->setMessage(' Consider to disable not active programs');
705
+
706
+ $disableGuestOrder = Mage::helper( 'adminhtml' )->getUrl( '*/connector/enablewebsiteconfiguration', array(
707
+ 'path' => 'XML_PATH_CONNECTOR_AUTOMATION_STUDIO_GUEST_ORDER',
708
+ 'value' => '0',
709
+ 'website' => $website->getId()
710
+ )
711
+ );
712
+ $disableGuestOrder = 'Deactivated! <a href="' . $disableGuestOrder . '">click</a> to disable';
713
+
714
+ } else {
715
+
716
+ $disableGuestOrder = $guestOrderProgram->status;
717
+ }
718
+ }
719
+
720
+ //check for customer program
721
+ if ($cusProgram) {
722
+
723
+ if ($cusProgram->status != 'Active') {
724
+
725
+ //set the status as failed
726
+ $resultContent->setStyle(self::CONNECTOR_DASHBOARD_FAILED)
727
+ ->setMessage(' Consider to disable not active programs');
728
+
729
+ $disableCustomer = Mage::helper( 'adminhtml' )->getUrl( '*/connector/enablewebsiteconfiguration', array(
730
+ 'path' => 'XML_PATH_CONNECTOR_AUTOMATION_STUDIO_CUSTOMER',
731
+ 'value' => '0',
732
+ 'website' => $website->getId()
733
+ )
734
+ );
735
+ $disableCustomer = 'Deactivated! <a href="' . $disableCustomer . '">click</a> to disable';
736
+
737
+ } else {
738
+
739
+ $disableCustomer = $cusProgram->status;
740
+ }
741
+ }
742
+
743
+ //check for subscriber program
744
+ if ($subProgram) {
745
+
746
+ if ($subProgram->status != 'Active') {
747
+ // set the status failed
748
+ $resultContent->setStyle(self::CONNECTOR_DASHBOARD_FAILED)
749
+ ->setMessage(' Consider to disable not active programs');
750
+
751
+ //link to disbale config
752
+ $disableSubscriber = Mage::helper( 'adminhtml' )->getUrl( '*/connector/enablewebsiteconfiguration', array(
753
+ 'path' => 'XML_PATH_CONNECTOR_AUTOMATION_STUDIO_SUBSCRIBER',
754
+ 'value' => '0',
755
+ 'website' => $website->getId()
756
+ )
757
+ );
758
+ $disableSubscriber = 'Deactivated <a href="' . $disableSubscriber . '">click</a> to disable';
759
+
760
+ } else {
761
+ $disableSubscriber = $subProgram->status;
762
+ }
763
+ }
764
+
765
+ $tableData = array(
766
+ 'Website' => $website->getName(),
767
+ 'Customer Program' => (isset($cusProgram->name))? $cusProgram->name : 'Disabled',
768
+ 'Customer Status' => (isset($cusProgram->status))? $disableCustomer : '',
769
+ 'Subscriber Program' => (isset($subProgram->name))? $subProgram->name : 'Disabled',
770
+ 'Subscriber Status' => (isset($subProgram->status))? $disableSubscriber : '',
771
+ 'Order Program' => (isset($orderProgram->name))? $orderProgram->name : 'Disabled',
772
+ 'Order Status' => (isset($orderProgram->status))? $disableOrder : '',
773
+ 'Guest Order Program' => (isset($guestOrderProgram->name))? $guestOrderProgram->name : 'Disabled',
774
+ 'Guest Order Status' => (isset($guestOrderProgram->status))? $disableGuestOrder : '',
775
+ 'Review Program' => (isset($reviewsProgram->name))? $reviewsProgram->name : 'Disabled',
776
+ 'Review Status' => (isset($reviewsProgram->status))? $disableReviews : '',
777
+ 'Wishlist Program' => (isset($wishlistProgram->name))? $wishlistProgram->name : 'Disabled',
778
+ 'Wishlist Status' => (isset($wishlistProgram->status))? $disableWishlist : '',
779
+ );
780
+
781
+ //set the content with table data
782
+ $resultContent->setTable($tableData);
783
+
784
+ }
785
+
786
+ return $resultContent;
787
+ }
788
+
789
+ /**
790
+ * Abandoned carts status.
791
+ * @return Dotdigitalgroup_Email_Model_Adminhtml_Dashboard_Content
792
+ */
793
+ public function abandonedCartsEnabled()
794
+ {
795
+ $resultContent = Mage::getModel('email_connector/adminhtml_dashboard_content');
796
+
797
+ $resultContent->setStyle(self::CONNECTOR_DASHBOARD_PASSED)
798
+ ->setTitle('Abandoned Carts Status : ')
799
+ ->setMessage('Looks Great.');
800
+
801
+ foreach ( Mage::app()->getWebsites() as $website ) {
802
+ $websiteName = $website->getName();
803
+ $abandonedCusomer_1 = ($website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_ABANDONED_CARTS_ENABLED_1))? true :
804
+ 'Disabled!';
805
+ $abandonedCusomer_2 = ($website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_ABANDONED_CARTS_ENABLED_2))? true :
806
+ 'Disabled!';
807
+ $abandonedCusomer_3 = ($website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_ABANDONED_CARTS_ENABLED_3))? true :
808
+ 'Disabled!';
809
+ $abandonedGuest_1 = ($website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_GUEST_ABANDONED_CARTS_ENABLED_1))? true :
810
+ 'Disabled!';
811
+ $abandonedGuest_2 = ($website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_GUEST_ABANDONED_CARTS_ENABLED_2))? true :
812
+ 'Disabled!';
813
+ $abandonedGuest_3 = ($website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_GUEST_ABANDONED_CARTS_ENABLED_3))? true :
814
+ 'Disabled!';
815
+
816
+ if ($abandonedCusomer_1 !== true || $abandonedCusomer_2 !== true || $abandonedCusomer_3 !== true || $abandonedGuest_1 !== true || $abandonedGuest_2 !== true || $abandonedGuest_3 !== true){
817
+ //customer abandoned links to enable
818
+ $customer1 = Mage::helper('adminhtml')->getUrl('*/connector/enablewebsiteconfiguration', array('path' => 'XML_PATH_CONNECTOR_CUSTOMER_ABANDONED_CARTS_ENABLED_1', 'website' => $website->getId()));
819
+ $customer2 = Mage::helper('adminhtml')->getUrl('*/connector/enablewebsiteconfiguration', array('path' => 'XML_PATH_CONNECTOR_CUSTOMER_ABANDONED_CARTS_ENABLED_2', 'website' => $website->getId()));
820
+ $customer3 = Mage::helper('adminhtml')->getUrl('*/connector/enablewebsiteconfiguration', array('path' => 'XML_PATH_CONNECTOR_CUSTOMER_ABANDONED_CARTS_ENABLED_3', 'website' => $website->getId()));
821
+ //guests abandoned links to enable
822
+ $guest1 = Mage::helper('adminhtml')->getUrl('*/connector/enablewebsiteconfiguration', array('path' => 'XML_PATH_CONNECTOR_GUEST_ABANDONED_CARTS_ENABLED_1', 'website' => $website->getId()));
823
+ $guest2 = Mage::helper('adminhtml')->getUrl('*/connector/enablewebsiteconfiguration', array('path' => 'XML_PATH_CONNECTOR_GUEST_ABANDONED_CARTS_ENABLED_2', 'website' => $website->getId()));
824
+ $guest3 = Mage::helper('adminhtml')->getUrl('*/connector/enablewebsiteconfiguration', array('path' => 'XML_PATH_CONNECTOR_GUEST_ABANDONED_CARTS_ENABLED_3', 'website' => $website->getId()));
825
+
826
+
827
+ $resultContent->setStyle( self::CONNECTOR_DASHBOARD_FAILED)
828
+ ->setMessage('Don\'t forget to map')
829
+ ->setTable(array(
830
+ 'Website' => $websiteName,
831
+ 'Customer Abandoned 1' => ($abandonedCusomer_1 !== true)? $abandonedCusomer_1 . ' <a href="' . $customer1 . '">enable</a>' : 'Enabled',
832
+ 'Customer Abandoned 2' => ($abandonedCusomer_2 !== true)? $abandonedCusomer_2 . ' <a href="' . $customer2 . '">enable</a>' : 'Enabled',
833
+ 'Customer Abandoned 3' => ($abandonedCusomer_3 !== true)? $abandonedCusomer_3 . ' <a href="' . $customer3 . '">enable</a>' : 'Enabled',
834
+ 'Guest Abandoned 1' => ($abandonedGuest_1 !== true)? $abandonedGuest_1 . ' <a href="' . $guest1 . '">enable</a>' : 'Enabled',
835
+ 'Guest Abandoned 2' => ($abandonedGuest_2 !== true)? $abandonedGuest_2 . ' <a href="' . $guest2 . '">enable</a>' : 'Enabled',
836
+ 'Guest Abandoned 3' => ($abandonedGuest_3 !== true)? $abandonedGuest_3 . ' <a href="' . $guest3 . '">enable</a>' : 'Enabled',
837
+ ));
838
+ }
839
+ }
840
+
841
+ return $resultContent;
842
+ }
843
+
844
+ /**
845
+ * Crazy mapping checking.
846
+ * @return Dotdigitalgroup_Email_Model_Adminhtml_Dashboard_Content
847
+ */
848
+ public function dataFieldMapped()
849
+ {
850
+ $resultContent = Mage::getModel('email_connector/adminhtml_dashboard_content');
851
+
852
+ $resultContent->setStyle(self::CONNECTOR_DASHBOARD_PASSED)
853
+ ->setTitle('Default Datafields Mapped Status : ')
854
+ ->setMessage('All Datafields Are Mapped.');
855
+
856
+ foreach ( Mage::app()->getWebsites() as $website ) {
857
+ $passed = true;
858
+ $mapped = 0;
859
+ $tableData = array();
860
+ //website name for table data
861
+ $websiteName = $website->getName();
862
+ $tableData['Website'] = $websiteName;
863
+ if (! $website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_ID)) {
864
+ $passed = false;
865
+ $mapped++;
866
+ }
867
+ if (! $website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_FIRSTNAME)) {
868
+ $passed = false;
869
+ $mapped++;
870
+ }
871
+ if (! $website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_LASTNAME)) {
872
+ $passed = false;
873
+ $mapped++;
874
+ }
875
+ if (! $website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_DOB)) {
876
+ $passed = false;
877
+ $mapped++;
878
+ }
879
+ if (! $website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_GENDER)) {
880
+ $passed = false;
881
+ $mapped++;
882
+ }
883
+ if (! $website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_WEBSITE_NAME)) {
884
+ $passed = false;
885
+ $mapped++;
886
+ }
887
+ if (! $website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_STORE_NAME)) {
888
+ $passed = false;
889
+ $mapped++;
890
+ }
891
+ if (! $website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_CREATED_AT)) {
892
+ $passed = false;
893
+ $mapped++;
894
+ }
895
+ if (! $website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_LAST_LOGGED_DATE)) {
896
+ $passed = false;
897
+ $mapped++;
898
+ }
899
+ if (! $website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_CUSTOMER_GROUP)) {
900
+ $passed = false;
901
+ $mapped++;
902
+ }
903
+ if (! $website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_REVIEW_COUNT)) {
904
+ $passed = false;
905
+ $mapped++;
906
+ }
907
+ if (! $website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_LAST_REVIEW_DATE)) {
908
+ $passed = false;
909
+ $mapped++;
910
+ }
911
+ if (! $website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_BILLING_ADDRESS_1)) {
912
+ $passed = false;
913
+ $mapped++;
914
+ }
915
+ if (! $website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_BILLING_ADDRESS_2)) {
916
+ $passed = false;
917
+ $mapped++;
918
+ }
919
+ if (! $website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_BILLING_CITY)) {
920
+ $passed = false;
921
+ $mapped++;
922
+ }
923
+ if (! $website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_BILLING_STATE)) {
924
+ $passed = false;
925
+ $mapped++;
926
+ }
927
+ if (! $website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_BILLING_COUNTRY)) {
928
+ $passed = false;
929
+ $mapped++;
930
+ }
931
+ if (! $website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_BILLING_POSTCODE)) {
932
+ $passed = false;
933
+ $mapped++;
934
+ }
935
+ if (! $website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_BILLING_TELEPHONE)) {
936
+ $passed = false;
937
+ $mapped++;
938
+ }
939
+ if (! $website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_DELIVERY_ADDRESS_1)) {
940
+ $passed = false;
941
+ $mapped++;
942
+ }
943
+ if (! $website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_DELIVERY_ADDRESS_2)) {
944
+ $passed = false;
945
+ $mapped++;
946
+ }
947
+ if (! $website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_DELIVERY_CITY)) {
948
+ $passed = false;
949
+ $mapped++;
950
+ }
951
+ if (! $website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_DELIVERY_STATE)) {
952
+ $passed = false;
953
+ $mapped++;
954
+ }
955
+ if (! $website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_DELIVERY_COUNTRY)) {
956
+ $passed = false;
957
+ $mapped++;
958
+ }
959
+ if (! $website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_DELIVERY_POSTCODE)) {
960
+ $passed = false;
961
+ $mapped++;
962
+ }
963
+ if (! $website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_DELIVERY_TELEPHONE)) {
964
+ $passed = false;
965
+ $mapped++;
966
+ }
967
+ if (! $website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_TOTAL_NUMBER_ORDER)) {
968
+ $passed = false;
969
+ $mapped++;
970
+ }
971
+ if (! $website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_AOV)) {
972
+ $passed = false;
973
+ $mapped++;
974
+ }
975
+ if (! $website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_TOTAL_SPEND)) {
976
+ $passed = false;
977
+ $mapped++;
978
+ }
979
+ if (! $website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_LAST_ORDER_DATE)) {
980
+ $passed = false;
981
+ $mapped++;
982
+ }
983
+ if (! $website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_LAST_ORDER_ID)) {
984
+ $passed = false;
985
+ $mapped++;
986
+ }
987
+ if (! $website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_MAPPING_CUSTOMER_TOTALREFUND)) {
988
+ $passed = false;
989
+ $mapped++;
990
+ }
991
+ if (! $website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_SUBSCRIBER_STATUS)) {
992
+ $passed = false;
993
+ $mapped++;
994
+ }
995
+ $tableData['Mapped Percentage'] = number_format((1 - $mapped / 32) * 100, 2) . ' %';
996
+ //mapping not complete.
997
+ if (! $passed ){
998
+ $url = Mage::helper('adminhtml')->getUrl('*/system_config/edit/section/connector_data_mapping/website/' . $website->getCode());
999
+ $resultContent->setStyle( self::CONNECTOR_DASHBOARD_FAILED)
1000
+ ->setMessage('Click <a href="' . $url . '">here</a> to change mapping configuration.')
1001
+ ;
1002
+ }
1003
+ $resultContent->setTable($tableData);
1004
+ }
1005
+
1006
+ return $resultContent;
1007
+ }
1008
+
1009
+
1010
+ /**
1011
+ * Validate API Credentials.
1012
+ * @return Dotdigitalgroup_Email_Model_Adminhtml_Dashboard_Content
1013
+ */
1014
+ public function validApiCredentials()
1015
+ {
1016
+ $resultContent = Mage::getModel('email_connector/adminhtml_dashboard_content');
1017
+ $resultContent->setStyle(self::CONNECTOR_DASHBOARD_PASSED)
1018
+ ->setTitle('API Credentials Status : ')
1019
+ ->setMessage('Valid.');
1020
+ $helper = Mage::helper('connector');
1021
+ foreach ( Mage::app()->getWebsites() as $website ) {
1022
+ $websiteName = $website->getName();
1023
+ $websiteId = $website->getId();
1024
+
1025
+ $apiUsername = $helper->getApiUsername($websiteId);
1026
+ $apiPassword = $helper->getApiPassword($websiteId);
1027
+
1028
+ $api = Mage::getModel('email_connector/apiconnector_test')->ajaxvalidate($apiUsername, $apiPassword);
1029
+
1030
+ if ($api != 'Credentials Valid.') {
1031
+ $url = Mage::helper('adminhtml')->getUrl('*/system_config/edit/section/connector_api_credentials/website/' . $website->getCode());
1032
+
1033
+ $resultContent->setStyle( self::CONNECTOR_DASHBOARD_FAILED)
1034
+ ->setMessage('')
1035
+ ->setTable(array(
1036
+ 'Website' => $websiteName,
1037
+ 'Status' => $api,
1038
+ 'Fast Fix' => 'Click <a href="' . $url . '">here</a> to enter new api credentials.'
1039
+ ));
1040
+ }
1041
+ }
1042
+
1043
+ return $resultContent;
1044
+ }
1045
+
1046
+ /**
1047
+ * Order sync enabled.
1048
+ * @return Dotdigitalgroup_Email_Model_Adminhtml_Dashboard_Content
1049
+ */
1050
+ public function orderEnabled()
1051
+ {
1052
+ $resultContent = Mage::getModel('email_connector/adminhtml_dashboard_content');
1053
+ $resultContent->setStyle(self::CONNECTOR_DASHBOARD_PASSED)
1054
+ ->setTitle('Order Sync : ')
1055
+ ->setMessage('Enabled.');
1056
+
1057
+ $passed = true;
1058
+ foreach ( Mage::app()->getWebsites() as $website ) {
1059
+ $websiteName = $website->getName();
1060
+ $order = ($website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_SYNC_ORDER_ENABLED))? true :
1061
+ 'Disabled!';
1062
+
1063
+ if ($order !== true){
1064
+
1065
+ $url = Mage::helper('adminhtml')->getUrl('*/connector/enablewebsiteconfiguration', array('path' => 'XML_PATH_CONNECTOR_SYNC_ORDER_ENABLED', 'website' => $website->getId()));
1066
+ $resultContent->setStyle( self::CONNECTOR_DASHBOARD_FAILED)
1067
+ ->setMessage('')
1068
+ ->setTable(array(
1069
+ 'Website' => $websiteName,
1070
+ 'Status' => $order . ' <a href="' . $url . '">enable</a>'
1071
+ ));
1072
+ $passed = false;
1073
+ }
1074
+ }
1075
+ //validation failed
1076
+ if (! $passed) {
1077
+ $resultContent->setHowto(self::FAST_FIX_MESSAGE);
1078
+ }
1079
+
1080
+ return $resultContent;
1081
+ }
1082
+
1083
+ /**
1084
+ * check if any custom order attribute selected
1085
+ * @return Dotdigitalgroup_Email_Model_Adminhtml_Dashboard_Content
1086
+ */
1087
+ public function customOrderAttributes()
1088
+ {
1089
+ $resultContent = Mage::getModel('email_connector/adminhtml_dashboard_content');
1090
+ $resultContent->setStyle(self::CONNECTOR_DASHBOARD_PASSED)
1091
+ ->setTitle('Custom Order Attributes : ')
1092
+ ->setMessage('Selected.');
1093
+
1094
+ foreach ( Mage::app()->getWebsites() as $website ) {
1095
+ $websiteName = $website->getName();
1096
+ $customOrderAttibute = ($website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOM_ORDER_ATTRIBUTES))? true : false;
1097
+
1098
+ if ($customOrderAttibute !== true){
1099
+ $resultContent->setStyle( self::CONNECTOR_DASHBOARD_FAILED)
1100
+ ->setTitle('Custom order attribute not selected (ignore if you do not want to import custom order attributes) :')
1101
+ ->setMessage('')
1102
+ ->setTable(array(
1103
+ 'Website' => $websiteName,
1104
+ 'Status' => 'No Custom Order Attribute Selected'
1105
+ ));
1106
+ }
1107
+ }
1108
+
1109
+ return $resultContent;
1110
+ }
1111
+
1112
+ /**
1113
+ * Check if any orders are imported.
1114
+ * @return Dotdigitalgroup_Email_Model_Adminhtml_Dashboard_Content
1115
+ */
1116
+ public function orderSyncing()
1117
+ {
1118
+ $resultContent = Mage::getModel('email_connector/adminhtml_dashboard_content');
1119
+ $resultContent->setStyle(self::CONNECTOR_DASHBOARD_PASSED)
1120
+ ->setTitle('Order Syncing : ')
1121
+ ->setMessage('Looks Great.');
1122
+
1123
+ foreach ( Mage::app()->getWebsites() as $website ) {
1124
+ $websiteName = $website->getName();
1125
+ $storeIds = $website->getStoreIds();
1126
+
1127
+ //numbser of orders marked as imported
1128
+ $numOrders = Mage::getModel('email_connector/order')->getCollection()
1129
+ ->addFieldToFilter('email_imported', 1)
1130
+ ->addFieldToFilter('store_id', array('in', $storeIds))->getSize();
1131
+
1132
+ if (! $numOrders) {
1133
+ $resultContent->setStyle( self::CONNECTOR_DASHBOARD_FAILED)
1134
+ ->setTitle('Order Syncing (ignore if you have reset orders for reimport) :')
1135
+ ->setMessage('')
1136
+ ->setTable(array(
1137
+ 'Website' => $websiteName,
1138
+ 'Status' => 'No Imported Orders Found'
1139
+ ));
1140
+ }
1141
+ }
1142
+
1143
+ return $resultContent;
1144
+
1145
+ }
1146
+
1147
+ /**
1148
+ * review sync enabled.
1149
+ * @return Dotdigitalgroup_Email_Model_Adminhtml_Dashboard_Content
1150
+ * Display the transactional data for orders to be removed.
1151
+ */
1152
+ public function reviewEnabled()
1153
+ {
1154
+ $resultContent = Mage::getModel('email_connector/adminhtml_dashboard_content');
1155
+ $resultContent->setStyle(self::CONNECTOR_DASHBOARD_PASSED)
1156
+ ->setTitle('Review Sync : ')
1157
+ ->setMessage('Enabled.');
1158
+
1159
+ foreach ( Mage::app()->getWebsites() as $website ) {
1160
+ $websiteName = $website->getName();
1161
+ $review = ($website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_SYNC_REVIEW_ENABLED))? true :
1162
+ 'Disabled';
1163
+
1164
+ if ($review !== true){
1165
+ $url = Mage::helper('adminhtml')->getUrl('*/connector/enablewebsiteconfiguration', array('path' => 'XML_PATH_CONNECTOR_SYNC_REVIEW_ENABLED', 'website' => $website->getId()));
1166
+ $resultContent->setStyle( self::CONNECTOR_DASHBOARD_FAILED)
1167
+ ->setMessage('Don\'t forget to enable if you want to sync reviews.' )
1168
+ ->setTable(array(
1169
+ 'Website' => $websiteName,
1170
+ 'Status' => $review,
1171
+ 'Fast Fix' => 'Click <a href="' . $url . '">here </a>to enable.'
1172
+ ));
1173
+ }
1174
+ }
1175
+ return $resultContent;
1176
+ }
1177
+
1178
+ /**
1179
+ * Check if any reviews are imported.
1180
+ * @return Dotdigitalgroup_Email_Model_Adminhtml_Dashboard_Content
1181
+ */
1182
+ public function reviewSyncing()
1183
+ {
1184
+ $resultContent = Mage::getModel('email_connector/adminhtml_dashboard_content');
1185
+ $resultContent->setStyle(self::CONNECTOR_DASHBOARD_PASSED)
1186
+ ->setTitle('Review Syncing : ')
1187
+ ->setMessage('Looks Great.');
1188
+
1189
+ foreach ( Mage::app()->getWebsites() as $website ) {
1190
+ $websiteName = $website->getName();
1191
+ $storeIds = $website->getStoreIds();
1192
+
1193
+ //number of reviews marked as imported
1194
+ $numReview = Mage::getModel('email_connector/review')->getCollection()
1195
+ ->addFieldToFilter('review_imported', 1)
1196
+ ->addFieldToFilter('store_id', array('in', $storeIds))
1197
+ ->getSize();
1198
+
1199
+ //total reviews
1200
+ $totalReview = Mage::getModel('email_connector/review')->getCollection()
1201
+ ->addFieldToFilter('store_id', array('in', $storeIds))
1202
+ ->getSize();
1203
+
1204
+ $tableData = array(
1205
+ 'Website' => $websiteName,
1206
+ 'Total Reviews' => $totalReview,
1207
+ 'Imported' => $numReview
1208
+ );
1209
+
1210
+ $tableData['Status'] = 'Importing';
1211
+
1212
+ if (! $numReview) {
1213
+ $tableData['Status'] = 'No Imported Review Found.';
1214
+ $resultContent->setStyle(self::CONNECTOR_DASHBOARD_FAILED)
1215
+ ->setTitle('Review Sync (ignore if you have reset wishlist) : ')
1216
+ ->setMessage('');
1217
+ }
1218
+ $resultContent->setTable($tableData);
1219
+ }
1220
+ return $resultContent;
1221
+ }
1222
+
1223
+ /**
1224
+ * review campaign enabled.
1225
+ * @return Dotdigitalgroup_Email_Model_Adminhtml_Dashboard_Content
1226
+ */
1227
+ public function reviewCampaignStatus()
1228
+ {
1229
+ $resultContent = Mage::getModel('email_connector/adminhtml_dashboard_content');
1230
+
1231
+ $resultContent->setStyle(self::CONNECTOR_DASHBOARD_PASSED)
1232
+ ->setTitle('Review Status : ')
1233
+ ->setMessage('Looks Great.');
1234
+
1235
+ foreach ( Mage::app()->getWebsites() as $website ) {
1236
+ $websiteName = $website->getName();
1237
+ $enabled = ($website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_REVIEWS_ENABLED))? true :
1238
+ 'Disabled ';
1239
+ $orderStatus = ($website->getConfig(Dotdigitalgroup_Email_Helper_Review::XML_PATH_REVIEW_STATUS))? true :
1240
+ 'Disabled ';
1241
+ $delayPeriod = ($website->getConfig(Dotdigitalgroup_Email_Helper_Review::XML_PATH_REVIEW_DELAY))? true :
1242
+ 'Disabled ';
1243
+ $newProduct = ($website->getConfig(Dotdigitalgroup_Email_Helper_Review::XML_PATH_REVIEW_NEW_PRODUCT))? true :
1244
+ 'Disabled ';
1245
+ $campaign = ($website->getConfig(Dotdigitalgroup_Email_Helper_Review::XML_PATH_REVIEW_CAMPAIGN))? true :
1246
+ 'Disabled ';
1247
+
1248
+ if ($enabled !== true || $orderStatus !== true || $delayPeriod !== true || $newProduct !== true || $campaign !== true){
1249
+ $enabledUrl = Mage::helper('adminhtml')->getUrl('*/connector/enablewebsiteconfiguration', array('path' => 'XML_PATH_REVIEWS_ENABLED', 'website' => $website->getId()));
1250
+
1251
+ $resultContent->setStyle( self::CONNECTOR_DASHBOARD_FAILED)
1252
+ ->setMessage('Don\'t forget to map')
1253
+ ->setTable(array(
1254
+ 'Website' => $websiteName,
1255
+ 'Enabled' => ($enabled !== true)? $enabled . '<a href="' . $enabledUrl . '">Click to enable</a>' : 'Enabled',
1256
+ 'Order Status' => ($orderStatus !== true)? 'Not Set' : 'Enabled',
1257
+ 'Delay Period' => ($delayPeriod !== true)? 'Not Set' : 'Enabled',
1258
+ 'New Product Only' => ($newProduct !== true)? 'Not Set' : 'Enabled',
1259
+ 'Campaign To Select' => ($campaign !== true)? 'Not Set' : 'Enabled',
1260
+ ));
1261
+ }
1262
+ }
1263
+ return $resultContent;
1264
+ }
1265
+
1266
+ /**
1267
+ * Get the last date for abandaned carts.
1268
+ * @return Dotdigitalgroup_Email_Model_Adminhtml_Dashboard_Content
1269
+ */
1270
+ public function lastAbandonedCartSentDay()
1271
+ {
1272
+ $resultContent = Mage::getModel('email_connector/adminhtml_dashboard_content');
1273
+ $resultContent->setStyle(self::CONNECTOR_DASHBOARD_PASSED)
1274
+ ->setTitle('Last Abandoned Summary : ');
1275
+
1276
+ foreach ( Mage::app()->getWebsites() as $website ) {
1277
+
1278
+ $websiteName = $website->getName();
1279
+ $client = Mage::helper('connector')->getWebsiteApiClient($website);
1280
+
1281
+ //customer carts
1282
+ $customerCampaign1 = $website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_ABANDONED_CAMPAIGN_1);
1283
+ $customerCampaign2 = $website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_ABANDONED_CAMPAIGN_2);
1284
+ $customerCampaign3 = $website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMER_ABANDONED_CAMPAIGN_3);
1285
+
1286
+ //guests carts
1287
+ $guestCampaign1 = $website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_GUEST_ABANDONED_CAMPAIGN_1);
1288
+ $guestCampaign2 = $website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_GUEST_ABANDONED_CAMPAIGN_2);
1289
+ $guestCampaign3 = $website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_GUEST_ABANDONED_CAMPAIGN_3);
1290
+
1291
+
1292
+ //date customer carts
1293
+
1294
+ $cusDateSent1 = ($customerCampaign1)? $client->getCampaignSummary($customerCampaign1) : '';
1295
+ $cusDateSent2 = ($customerCampaign2)? $client->getCampaignSummary($customerCampaign2) : '';
1296
+ $cusDateSent3 = ($customerCampaign3)? $client->getCampaignSummary($customerCampaign3) : '';
1297
+
1298
+ //date guest carts
1299
+ $resGuest1 = ($guestCampaign1)? $client->getCampaignSummary($guestCampaign1) : '';
1300
+ $resGuest2 = ($guestCampaign2)? $client->getCampaignSummary($guestCampaign2) : '';
1301
+ $resGuest3 = ($guestCampaign3)? $client->getCampaignSummary($guestCampaign3) : '';
1302
+
1303
+ /**
1304
+ * Customers.
1305
+ */
1306
+ $customerCampaign1 = (isset($cusDateSent1->dateSent)? $cusDateSent1->dateSent : 'Not Sent/Selected');
1307
+ $customerCampaign2 = (isset($cusDateSent2->dateSent)? $cusDateSent2->dateSent : 'Not Sent/Selected');
1308
+ $customerCampaign3 = (isset($cusDateSent3->dateSent)? $cusDateSent3->dateSent : 'Not Sent/Selected');
1309
+
1310
+ /**
1311
+ * Guests.
1312
+ */
1313
+ $guestCampaign1 = (isset($resGuest1->dateSent)? $resGuest1->dateSent : 'Not Sent/Selected');
1314
+ $guestCampaign2 = (isset($resGuest2->dateSent)? $resGuest2->dateSent : 'Not Sent/Selected');
1315
+ $guestCampaign3 = (isset($resGuest3->dateSent)? $resGuest3->dateSent : 'Not Sent/Selected');
1316
+
1317
+
1318
+ $resultContent->setTable(array(
1319
+ 'Website' => $websiteName,
1320
+ 'Customer Campaign 1' => $customerCampaign1,
1321
+ 'Customer Campaign 2' => $customerCampaign2,
1322
+ 'Customer Campaign 3' => $customerCampaign3,
1323
+ 'Guest Campaign 1' => $guestCampaign1,
1324
+ 'Guest Campaign 2' => $guestCampaign2,
1325
+ 'Guest Campaign 3' => $guestCampaign3
1326
+ ));
1327
+ }
1328
+
1329
+ return $resultContent;
1330
+ }
1331
+
1332
+ /**
1333
+ * Conflict checker.
1334
+ * @return Dotdigitalgroup_Email_Model_Adminhtml_Dashboard_Content
1335
+ */
1336
+ public function conflictCheck()
1337
+ {
1338
+ /**
1339
+ * Check the API accounts for different websites and posible mapping conflicts.
1340
+ */
1341
+ $resultContent = Mage::getModel('email_connector/adminhtml_dashboard_content');
1342
+ $resultContent->setStyle(self::CONNECTOR_DASHBOARD_PASSED)
1343
+ ->setTitle('Conflict Status : ')
1344
+ ->setMessage('Looks Great.')
1345
+ ;
1346
+
1347
+ $lastApi = false;
1348
+ foreach ( Mage::app()->getWebsites() as $website )
1349
+ {
1350
+ $apiUsername = $website->getConfig( Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_API_USERNAME );
1351
+ if ($lastApi === false)
1352
+ $lastApi = $apiUsername;
1353
+ //check difference for the previous api usename
1354
+ if ($lastApi != $apiUsername) {
1355
+ $resultContent->setStyle(self::CONNECTOR_DASHBOARD_FAILED)
1356
+ ->setMessage('Possible configuration conflict.')
1357
+ ->setTable( array(
1358
+ 'Website' => $website->getName(),
1359
+ 'Multiple API Usernames' => $apiUsername
1360
+ ));
1361
+ $lastApi = $apiUsername;
1362
+ }
1363
+ }
1364
+
1365
+ return $resultContent;
1366
+ }
1367
+
1368
+ /**
1369
+ * System information about the version used and the memory limits.
1370
+ *
1371
+ * @return Dotdigitalgroup_Email_Model_Adminhtml_Dashboard_Content
1372
+ */
1373
+ public function systemInformation()
1374
+ {
1375
+ $resultContent = Mage::getModel('email_connector/adminhtml_dashboard_content');
1376
+ $resultContent->setStyle(self::CONNECTOR_DASHBOARD_PASSED);
1377
+
1378
+ //compatibility with the old versions
1379
+ if (version_compare(Mage::getVersion(), '1.6.2.0', '>')) {
1380
+ $version = 'Magento ' . Mage::getEdition() . ' ' . Mage::getVersion() . 'V';
1381
+ } else {
1382
+ $version = 'Magento version : ' . Mage::getVersion() . 'V';
1383
+ }
1384
+
1385
+ $fh = @fopen('/proc/meminfo', 'r');
1386
+ $mem = 0;
1387
+ if ($fh) {
1388
+ while ($line = fgets($fh)) {
1389
+ $pieces = array();
1390
+ if (preg_match('^MemTotal:\s+(\d+)\skB$^', $line, $pieces)) {
1391
+ $mem = $pieces[1];
1392
+ break;
1393
+ }
1394
+ }
1395
+ fclose($fh);
1396
+ }
1397
+ if ($mem > 0) {
1398
+ $mem = $mem / 1024 . 'M';
1399
+ } else {
1400
+ $mem = $this->_getTopMemoryInfo();
1401
+ }
1402
+
1403
+ //check for php version
1404
+ $resultContent->setHowTo('PHP version : V' . PHP_VERSION)
1405
+ ->setHowto('PHP Memory : ' . $mem)
1406
+ ->setHowto('PHP Max Execution Time : ' . ini_get('max_execution_time') . ' sec')
1407
+ ->setHowto($version)
1408
+ ->setHowto('Connector version : V' . Mage::helper('connector')->getConnectorVersion());
1409
+
1410
+ return $resultContent;
1411
+ }
1412
+
1413
+
1414
+ /**
1415
+ * Returns memory size. Alternative way
1416
+ *
1417
+ * @return string|null
1418
+ */
1419
+ public function _getTopMemoryInfo()
1420
+ {
1421
+ $memInfo = exec('top -l 1 | head -n 10 | grep PhysMem');
1422
+ $memInfo = str_ireplace('PhysMem: ', '', $memInfo);
1423
+
1424
+ if (!empty($memInfo)) {
1425
+ return $memInfo;
1426
+ } else {
1427
+ return null;
1428
+ }
1429
+ }
1430
+
1431
+ /**
1432
+ * Check if the mapped program is active.
1433
+
1434
+ */
1435
+ protected function _getWebisteProgram($program, $website) {
1436
+ $client = Mage::helper('connector')->getWebsiteApiClient($website);
1437
+
1438
+ if (! $client || !$program){
1439
+ return false;
1440
+ }
1441
+
1442
+ $data = $client->getProgramById($program);
1443
+
1444
+ if (isset($data->message))
1445
+ return false;
1446
+
1447
+
1448
+ return $data;
1449
+ }
1450
+
1451
+ /**
1452
+ * Get the contacts address book.
1453
+ * @param $addressBook
1454
+ * @param $webiste
1455
+ *
1456
+ * @return bool|null
1457
+ */
1458
+ protected function _getAddressBookContacts($addressBook, $webiste) {
1459
+ $client = Mage::helper('connector')->getWebsiteApiClient($webiste);
1460
+
1461
+ if (! $client && $addressBook)
1462
+ return false;
1463
+
1464
+ $response = $client->getAddressBookById($addressBook);
1465
+
1466
+ if (isset($response->message))
1467
+ return false;
1468
+ return $response;
1469
+ }
1470
+
1471
+ /**
1472
+ * Get the method name
1473
+ * @param $name
1474
+ *
1475
+ * @return string
1476
+ */
1477
+ public function getFormatedMethodName($name)
1478
+ {
1479
+ //version that not support the lcfirst method
1480
+ if(function_exists('lcfirst') === false) {
1481
+
1482
+ $method = strtolower(substr(uc_words($name, '') ,0,1)).substr(uc_words($name, ''), 1);
1483
+
1484
+ } else {
1485
+ $method = lcfirst(uc_words($name, ''));
1486
+ }
1487
+
1488
+ return $method;
1489
+ }
1490
+
1491
+ /**
1492
+ * easy email capture enabled
1493
+ * @return Dotdigitalgroup_Email_Model_Adminhtml_Dashboard_Content
1494
+ */
1495
+ public function easyEmailCaptureEnabled()
1496
+ {
1497
+ $resultContent = Mage::getModel('email_connector/adminhtml_dashboard_content');
1498
+ $resultContent->setStyle(self::CONNECTOR_DASHBOARD_PASSED)
1499
+ ->setTitle('Easy Email Capture : ')
1500
+ ->setMessage('Enabled.');
1501
+
1502
+ foreach ( Mage::app()->getWebsites() as $website ) {
1503
+ $websiteName = $website->getName();
1504
+ $enabled = ($website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_EMAIL_CAPTURE))? true :
1505
+ 'Disabled';
1506
+
1507
+ if ($enabled !== true){
1508
+ $url = Mage::helper('adminhtml')->getUrl('*/connector/enablewebsiteconfiguration', array('path' => 'XML_PATH_CONNECTOR_EMAIL_CAPTURE', 'website' => $website->getId()));
1509
+ $resultContent->setStyle( self::CONNECTOR_DASHBOARD_FAILED)
1510
+ ->setMessage('Don\'t forget to enable if you want to enable easy email capture.' )
1511
+ ->setTable(array(
1512
+ 'Website' => $websiteName,
1513
+ 'Status' => $enabled,
1514
+ 'Fast Fix' => 'Click <a href="' . $url . '">here </a>to enable.'
1515
+ ));
1516
+ }
1517
+ }
1518
+ return $resultContent;
1519
+ }
1520
+
1521
+ /**
1522
+ * disabled newsletter success enabled
1523
+ * @return Dotdigitalgroup_Email_Model_Adminhtml_Dashboard_Content
1524
+ */
1525
+ public function disableNewsletterSuccessEnabled()
1526
+ {
1527
+ $resultContent = Mage::getModel('email_connector/adminhtml_dashboard_content');
1528
+ $resultContent->setStyle(self::CONNECTOR_DASHBOARD_PASSED)
1529
+ ->setTitle('Disable Newsletter Success : ')
1530
+ ->setMessage('Enabled.');
1531
+
1532
+ foreach ( Mage::app()->getWebsites() as $website ) {
1533
+ $websiteName = $website->getName();
1534
+ $enabled = ($website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_DISABLE_NEWSLETTER_SUCCESS))? true :
1535
+ 'Disabled';
1536
+
1537
+ if ($enabled !== true){
1538
+ $url = Mage::helper('adminhtml')->getUrl('*/connector/enablewebsiteconfiguration', array('path' => 'XML_PATH_CONNECTOR_DISABLE_NEWSLETTER_SUCCESS', 'website' => $website->getId()));
1539
+ $resultContent->setStyle( self::CONNECTOR_DASHBOARD_FAILED)
1540
+ ->setMessage('Don\'t forget to enable if you want to disable Magento newsletter success email.' )
1541
+ ->setTable(array(
1542
+ 'Website' => $websiteName,
1543
+ 'Status' => $enabled,
1544
+ 'Fast Fix' => 'Click <a href="' . $url . '">here </a>to enable.'
1545
+ ));
1546
+ }
1547
+ }
1548
+ return $resultContent;
1549
+ }
1550
+
1551
+ /**
1552
+ * wishlist sync enabled.
1553
+ * @return Dotdigitalgroup_Email_Model_Adminhtml_Dashboard_Content
1554
+ */
1555
+ public function wishlistEnabled()
1556
+ {
1557
+ $resultContent = Mage::getModel('email_connector/adminhtml_dashboard_content');
1558
+ $resultContent->setStyle(self::CONNECTOR_DASHBOARD_PASSED)
1559
+ ->setTitle('Wishlist Sync : ')
1560
+ ->setMessage('Enabled.');
1561
+
1562
+ foreach ( Mage::app()->getWebsites() as $website ) {
1563
+ $websiteName = $website->getName();
1564
+ $wishlist = ($website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_SYNC_WISHLIST_ENABLED))? true :
1565
+ 'Disabled';
1566
+
1567
+ if ($wishlist !== true){
1568
+ $url = Mage::helper('adminhtml')->getUrl('*/connector/enablewebsiteconfiguration', array('path' => 'XML_PATH_CONNECTOR_SYNC_WISHLIST_ENABLED', 'website' => $website->getId()));
1569
+ $resultContent->setStyle( self::CONNECTOR_DASHBOARD_FAILED)
1570
+ ->setMessage('Don\'t forget to enable if you want to sync wishlist.' )
1571
+ ->setTable(array(
1572
+ 'Website' => $websiteName,
1573
+ 'Status' => $wishlist,
1574
+ 'Fast Fix' => 'Click <a href="' . $url . '">here </a>to enable.'
1575
+ ));
1576
+ }
1577
+ }
1578
+ return $resultContent;
1579
+ }
1580
+
1581
+ /**
1582
+ * Check if any wishlist are imported.
1583
+ * @return Dotdigitalgroup_Email_Model_Adminhtml_Dashboard_Content
1584
+ */
1585
+ public function wishlistSyncing()
1586
+ {
1587
+ $resultContent = Mage::getModel('email_connector/adminhtml_dashboard_content');
1588
+ $resultContent->setStyle(self::CONNECTOR_DASHBOARD_PASSED)
1589
+ ->setTitle('Wishlist Syncing : ')
1590
+ ->setMessage('Looks Great.');
1591
+
1592
+ foreach ( Mage::app()->getWebsites() as $website ) {
1593
+ $websiteName = $website->getName();
1594
+ $storeIds = $website->getStoreIds();
1595
+
1596
+ //number of wishlist marked as imported
1597
+ $numWishlist = Mage::getModel('email_connector/wishlist')->getCollection()
1598
+ ->addFieldToFilter('wishlist_imported', 1)
1599
+ ->addFieldToFilter('store_id', array('in', $storeIds))
1600
+ ->getSize();
1601
+
1602
+ //total wishlist
1603
+ $totalWishlist = Mage::getModel('email_connector/wishlist')->getCollection()
1604
+ ->addFieldToFilter('store_id', array('in', $storeIds))
1605
+ ->getSize();
1606
+
1607
+ $tableData = array(
1608
+ 'Website' => $websiteName,
1609
+ 'Total Wishlist' => $totalWishlist,
1610
+ 'Imported' => $numWishlist
1611
+ );
1612
+
1613
+ $tableData['Status'] = 'Importing';
1614
+
1615
+ if (! $numWishlist) {
1616
+ $tableData['Status'] = 'No Imported Wishlist Found.';
1617
+ $resultContent->setStyle(self::CONNECTOR_DASHBOARD_FAILED)
1618
+ ->setTitle('Wishlist Sync (ignore if you have reset wishlist) : ')
1619
+ ->setMessage('');
1620
+ }
1621
+ $resultContent->setTable($tableData);
1622
+ }
1623
+ return $resultContent;
1624
+ }
1625
+ }
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,110 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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('created_at', array(
76
+ 'header' => Mage::helper('connector')->__('Created At'),
77
+ 'width' => '50px',
78
+ 'align' => 'center',
79
+ 'index' => 'created_at',
80
+ 'type' => 'datetime',
81
+ 'escape' => true,
82
+ ))->addColumn('updated_at', array(
83
+ 'header' => Mage::helper('connector')->__('Updated At'),
84
+ 'width' => '50px',
85
+ 'align' => 'center',
86
+ 'index' => 'updated_at',
87
+ 'type' => 'datetime',
88
+ 'escape' => true,
89
+ ));
90
+
91
+ return parent::_prepareColumns();
92
+ }
93
+
94
+ /**
95
+ * Callback action for the imported subscribers/contacts.
96
+ *
97
+ * @param $collection
98
+ * @param $column
99
+ */
100
+ public function filterCallbackContact($collection, $column)
101
+ {
102
+ $field = $column->getFilterIndex() ? $column->getFilterIndex() : $column->getIndex();
103
+ $value = $column->getFilter()->getValue();
104
+ if ($value == 'null') {
105
+ $collection->addFieldToFilter($field, array('null' => true));
106
+ } else {
107
+ $collection->addFieldToFilter($field, array('notnull' => true));
108
+ }
109
+ }
110
+ }
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Review.php ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dotdigitalgroup_Email_Block_Adminhtml_Review 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_review';
11
+ $this->_headerText = Mage::helper('connector')->__('Email Review(s)');
12
+
13
+ $this->_removeButton('add');
14
+ }
15
+ }
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Review/Grid.php ADDED
@@ -0,0 +1,109 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dotdigitalgroup_Email_Block_Adminhtml_Review_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('id');
11
+ $this->setId('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/review_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('review_id', array(
45
+ 'header' => Mage::helper('connector')->__('Review ID'),
46
+ 'align' => 'left',
47
+ 'width' => '50px',
48
+ 'index' => 'review_id',
49
+ 'type' => 'number',
50
+ 'escape' => true
51
+ ))->addColumn('customer_id', array(
52
+ 'header' => Mage::helper('connector')->__('Customer ID'),
53
+ 'align' => 'left',
54
+ 'width' => '50px',
55
+ 'index' => 'customer_id',
56
+ 'type' => 'number',
57
+ 'escape' => true
58
+ ))->addColumn('store_id', array(
59
+ 'header' => Mage::helper('connector')->__('Store ID'),
60
+ 'width' => '50px',
61
+ 'index' => 'store_id',
62
+ 'type' => 'number',
63
+ 'escape' => true,
64
+ ))->addColumn('review_imported', array(
65
+ 'header' => Mage::helper('connector')->__('Review Imported'),
66
+ 'align' => 'center',
67
+ 'width' => '50px',
68
+ 'index' => 'review_imported',
69
+ 'type' => 'options',
70
+ 'escape' => true,
71
+ 'renderer' => 'email_connector/adminhtml_column_renderer_imported',
72
+ 'options' => Mage::getModel('email_connector/adminhtml_source_contact_imported')->getOptions(),
73
+ 'filter_condition_callback' => array($this, 'filterCallbackContact')
74
+ ))->addColumn('created_at', array(
75
+ 'header' => Mage::helper('connector')->__('Created At'),
76
+ 'width' => '50px',
77
+ 'align' => 'center',
78
+ 'index' => 'created_at',
79
+ 'type' => 'datetime',
80
+ 'escape' => true,
81
+ ))->addColumn('updated_at', array(
82
+ 'header' => Mage::helper('connector')->__('Updated At'),
83
+ 'width' => '50px',
84
+ 'align' => 'center',
85
+ 'index' => 'updated_at',
86
+ 'type' => 'datetime',
87
+ 'escape' => true,
88
+ ));
89
+
90
+ return parent::_prepareColumns();
91
+ }
92
+
93
+ /**
94
+ * Callback action for the imported subscribers/contacts.
95
+ *
96
+ * @param $collection
97
+ * @param $column
98
+ */
99
+ public function filterCallbackContact($collection, $column)
100
+ {
101
+ $field = $column->getFilterIndex() ? $column->getFilterIndex() : $column->getIndex();
102
+ $value = $column->getFilter()->getValue();
103
+ if ($value == 'null') {
104
+ $collection->addFieldToFilter($field, array('null' => true));
105
+ } else {
106
+ $collection->addFieldToFilter($field, array('notnull' => true));
107
+ }
108
+ }
109
+ }
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/.DS_Store ADDED
Binary file
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/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Advanced/Notification.php ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dotdigitalgroup_Email_Block_Adminhtml_System_Advanced_Notification extends Mage_Adminhtml_Block_System_Config_Form_Field
4
+ {
5
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
6
+ {
7
+ $element->setValue(Mage::app()->loadCache(Dotdigitalgroup_Email_Helper_Config::CONNECTOR_FEED_LAST_CHECK_TIME));
8
+ $format = Mage::app()->getLocale()->getDateTimeFormat(Mage_Core_Model_Locale::FORMAT_TYPE_MEDIUM);
9
+ return Mage::app()->getLocale()->date(intval($element->getValue()))->toString($format);
10
+ }
11
+ }
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/{local/Dotdigitalgroup/Email/Block/Debug/Initialsync.php → community/Dotdigitalgroup/Email/Block/Adminhtml/System/Advanced/Resetcustomersimport.php} RENAMED
@@ -1,14 +1,16 @@
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')
@@ -17,4 +19,4 @@ class Dotdigitalgroup_Email_Block_Debug_Initialsync extends Mage_Adminhtml_Block
17
  ->toHtml();
18
  }
19
 
20
- }
1
  <?php
2
+ class Dotdigitalgroup_Email_Block_Adminhtml_System_Advanced_Resetcustomersimport 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/resetcustomersimport");
14
 
15
  return $this->getLayout()->createBlock('adminhtml/widget_button')
16
  ->setType('button')
19
  ->toHtml();
20
  }
21
 
22
+ }
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Advanced/Runcontactsync.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dotdigitalgroup_Email_Block_Adminhtml_System_Advanced_Runcontactsync 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/runcontactsync");
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/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Advanced/Runordersync.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dotdigitalgroup_Email_Block_Adminhtml_System_Advanced_Runordersync 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/runordersync");
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/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Advanced/Runreviewsync.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dotdigitalgroup_Email_Block_Adminhtml_System_Advanced_Runreviewsync 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/runreviewsync");
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/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Advanced/Runsubscribersync.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dotdigitalgroup_Email_Block_Adminhtml_System_Advanced_Runsubscribersync 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/runsubscribersync");
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/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Advanced/Runwishlistsync.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dotdigitalgroup_Email_Block_Adminhtml_System_Advanced_Runwishlistsync 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/runwishlistsync");
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/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/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Advanced/Suppressedcontacts.php ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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')
18
+ ->setLabel($this->__($title))
19
+ ->setOnClick("window.location.href='" . $url . "'")
20
+ ->toHtml();
21
+ }
22
+
23
+ }
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,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ //disable for ssl missing
17
+ if (!$ssl) {
18
+ $disabled = true;
19
+ }
20
+
21
+ $adminUser = Mage::getSingleton('admin/session')->getUser();
22
+ $refreshToken = $adminUser->getRefreshToken();
23
+ $title = ($refreshToken)? $this->__('Disconnect') : $this->__('Connect');
24
+ $url = ($refreshToken)? $this->getUrl('*/email_automation/disconnect') : $url;
25
+
26
+ return $this->getLayout()->createBlock('adminhtml/widget_button')
27
+ ->setType('button')
28
+ ->setLabel($this->__($title))
29
+ ->setDisabled($disabled)
30
+ ->setOnClick("window.location.href='" . $url . "'")
31
+ ->toHtml();
32
+ }
33
+
34
+ private function _checkForSecureUrl() {
35
+ $baseUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB, true);
36
+ if (!preg_match('/https/',$baseUrl)) {
37
+ return false;
38
+ }
39
+ return $this;
40
+ }
41
+ }
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Config/Addressbook.php ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 visibility = $('connector_sync_settings_dynamic_addressbook_visibility').value;
22
+ var reloadurl = '{$url}';
23
+ if(name && visibility){
24
+ new Ajax.Request(reloadurl, {
25
+ method: 'post',
26
+ parameters: {'name' : name, 'visibility' : visibility, 'website': '$website'},
27
+ onComplete: function(transport) {
28
+ window.location.reload();
29
+ }
30
+ });
31
+ }
32
+ return false;
33
+ }
34
+ </script>"
35
+ );
36
+
37
+ return parent::_getElementHtml($element);
38
+ }
39
+ }
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Config/Datafield.php ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 datafield_default = $('connector_data_mapping_dynamic_datafield_datafield_default').value;
23
+ var datafield_access = $('connector_data_mapping_dynamic_datafield_datafield_access').value;
24
+
25
+ var reloadurl = '{$url}';
26
+
27
+ if(datafield_name && datafield_type && datafield_default && datafield_access){
28
+ new Ajax.Request(reloadurl, {
29
+ method: 'post',
30
+ parameters: {'name' : datafield_name, 'type' : datafield_type, 'default' : datafield_default, 'access' : datafield_access, 'website': '$website'},
31
+ onComplete: function(transport) {
32
+ window.location.reload();
33
+ }
34
+ });
35
+ }
36
+ return false;}</script>"
37
+ );
38
+
39
+ return parent::_getElementHtml($element);
40
+ }
41
+ }
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Config/Resetcontacts.php ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dotdigitalgroup_Email_Block_Adminhtml_System_Config_Resetcontacts extends Mage_Adminhtml_Block_System_Config_Form_Field
4
+ {
5
+ public function _getElementHtml(Varien_Data_Form_Element_Abstract$element){
6
+
7
+ $element->setData('onchange', "resetContacts();");
8
+ //url to reset the contacs
9
+ $url = Mage::helper('adminhtml')->getUrl('*/connector/resetcontactsajax');
10
+
11
+ $element->setData('after_element_html', "
12
+ <script>
13
+ function resetContacts(){
14
+ new Ajax.Request('{$url}', {
15
+ method: 'get',
16
+ onComplete: function(transport) {
17
+ }
18
+ });
19
+ return false;
20
+ }
21
+ </script>
22
+ ");
23
+
24
+ return parent::_getElementHtml($element);
25
+
26
+
27
+ }
28
+ }
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Config/Resetguests.php ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dotdigitalgroup_Email_Block_Adminhtml_System_Config_Resetguests extends Mage_Adminhtml_Block_System_Config_Form_Field
4
+ {
5
+ public function _getElementHtml(Varien_Data_Form_Element_Abstract$element){
6
+
7
+ $element->setData('onchange', "resetGuests();");
8
+ //url to reset the guests
9
+ $url = Mage::helper('adminhtml')->getUrl('*/connector/ajaxresetguests');
10
+
11
+ $element->setData('after_element_html', "
12
+ <script>
13
+ function resetGuests(){
14
+ new Ajax.Request('{$url}', {
15
+ method: 'get',
16
+ onComplete: function(transport) {
17
+ }
18
+ });
19
+ return false;
20
+ }
21
+ </script>
22
+ ");
23
+
24
+ return parent::_getElementHtml($element);
25
+
26
+
27
+ }
28
+ }
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Config/Resetsubscribers.php ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dotdigitalgroup_Email_Block_Adminhtml_System_Config_Resetsubscribers extends Mage_Adminhtml_Block_System_Config_Form_Field
4
+ {
5
+ public function _getElementHtml(Varien_Data_Form_Element_Abstract$element){
6
+
7
+ $element->setData('onchange', "resetSubscribers();");
8
+ //url to reset the subscribers
9
+ $url = Mage::helper('adminhtml')->getUrl('*/connector/ajaxresetsubscribers');
10
+
11
+ $element->setData('after_element_html', "
12
+ <script>
13
+ function resetSubscribers(){
14
+ new Ajax.Request('{$url}', {
15
+ method: 'get',
16
+ onComplete: function(transport) {
17
+ }
18
+ });
19
+ return false;
20
+ }
21
+ </script>
22
+ ");
23
+
24
+ return parent::_getElementHtml($element);
25
+
26
+
27
+ }
28
+ }
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/Basket/Crosssell.php ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dotdigitalgroup_Email_Block_Adminhtml_System_Dynamic_Basket_Crosssell extends Mage_Adminhtml_Block_System_Config_Form_Field
4
+ {
5
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
6
+ {
7
+ //base url
8
+ $baseUrl = Mage::helper('connector')->generateDynamicUrl();
9
+ //config passcode
10
+ $passcode = Mage::helper('connector')->getPasscode();
11
+ //last quote id for dynamic page
12
+ $lastQuoteId = Mage::helper('connector')->getLastQuoteId();
13
+
14
+ if (!strlen($passcode))
15
+ $passcode = '[PLEASE SET UP A PASSCODE]';
16
+ //alert message for last order id is not mapped
17
+ if (!$lastQuoteId)
18
+ $lastQuoteId = '[PLEASE MAP THE LAST QUOTE ID]';
19
+
20
+ //full url for dynamic content
21
+ $text = sprintf('%sconnector/quoteproducts/crosssell/code/%s/quote_id/@%s@', $baseUrl, $passcode, $lastQuoteId);
22
+ $element->setData('value', $text);
23
+
24
+ return parent::_getElementHtml($element);
25
+ }
26
+ }
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Dynamic/Basket/Related.php ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dotdigitalgroup_Email_Block_Adminhtml_System_Dynamic_Basket_Related extends Mage_Adminhtml_Block_System_Config_Form_Field
4
+ {
5
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
6
+ {
7
+ //passcode to append for url
8
+ $passcode = Mage::helper('connector')->getPasscode();
9
+ //last quote id for dynamic page
10
+ $lastQuoteId = Mage::helper('connector')->getLastQuoteId();
11
+
12
+ if (!strlen($passcode))
13
+ $passcode = '[PLEASE SET UP A PASSCODE]';
14
+ //alert message for last order id is not mapped
15
+ if (!$lastQuoteId)
16
+ $lastQuoteId = '[PLEASE MAP THE LAST QUOTE ID]';
17
+
18
+ //generate the base url and display for default store id
19
+ $baseUrl = Mage::helper('connector')->generateDynamicUrl();
20
+
21
+ //display the full url
22
+ $text = sprintf('%sconnector/quoteproducts/related/code/%s/quote_id/@%s@', $baseUrl, $passcode, $lastQuoteId);
23
+ $element->setData('value', $text);
24
+
25
+ return parent::_getElementHtml($element);
26
+ }
27
+ }
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Dynamic/Basket/Upsell.php ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Dotdigitalgroup_Email_Block_Adminhtml_System_Dynamic_Basket_Upsell extends Mage_Adminhtml_Block_System_Config_Form_Field
3
+ {
4
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
5
+ {
6
+ //passcode to append for url
7
+ $passcode = Mage::helper('connector')->getPasscode();
8
+ //last quote id for dynamic page
9
+ $lastQuoteId = Mage::helper('connector')->getLastQuoteId();
10
+
11
+ if (!strlen($passcode))
12
+ $passcode = '[PLEASE SET UP A PASSCODE]';
13
+ //alert message for last order id is not mapped
14
+ if (!$lastQuoteId)
15
+ $lastQuoteId = '[PLEASE MAP THE LAST QUOTE ID]';
16
+
17
+ //generate the base url and display for default store id
18
+ $baseUrl = Mage::helper('connector')->generateDynamicUrl();
19
+
20
+ $text = sprintf('%sconnector/quoteproducts/upsell/code/%s/quote_id/@%s@', $baseUrl, $passcode, $lastQuoteId);
21
+ $element->setData('value', $text);
22
+
23
+ return parent::_getElementHtml($element);
24
+ }
25
+ }
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Dynamic/Bestsellers.php ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ //base url
9
+ $baseUrl = Mage::helper('connector')->generateDynamicUrl();
10
+
11
+ //config passcode
12
+ $passcode = Mage::helper('connector')->getPasscode();
13
+
14
+ if (!strlen($passcode))
15
+ $passcode = '[PLEASE SET UP A PASSCODE]';
16
+
17
+ //full url
18
+ $text = sprintf('%sconnector/report/bestsellers/code/%s', $baseUrl, $passcode);
19
+ $element->setData('value', $text);
20
+ $element->setData('disabled', 'disabled');
21
+
22
+ return parent::_getElementHtml($element);
23
+ }
24
+ }
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Dynamic/Couponinfo.php ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ //base url
9
+ $baseUrl = Mage::helper('connector')->generateDynamicUrl();
10
+
11
+
12
+ //config code
13
+ $code = Mage::helper('connector')->getPasscode();
14
+
15
+ if (!strlen($code))
16
+ $code = '[PLEASE SET UP A PASSCODE]';
17
+
18
+ //full url
19
+ $text = $baseUrl . 'connector/email/coupon/id/[INSERT ID HERE]/code/'. $code . '/@EMAIL@';
20
+
21
+ $element->setData('value', $text);
22
+ $element->setData('disabled', 'disabled');
23
+ return parent::_getElementHtml($element);
24
+ }
25
+
26
+ }
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Dynamic/Creditmemonew.php ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ //base url
8
+ $baseUrl = Mage::helper('connector')->generateDynamicUrl();
9
+
10
+ //config code
11
+ $code = Mage::helper('connector')->getPasscode();
12
+ $orderId = Mage::helper('connector')->getMappedOrderId();
13
+
14
+ //message to set up the passcode
15
+ if (!strlen($code))
16
+ $code = '[PLEASE SET UP A PASSCODE]';
17
+ //full url for dynamic content
18
+ $text = sprintf('%s/connector/creditmemo/new/code/%s/id/@%s@', $baseUrl, $code, $orderId);
19
+
20
+ $element->setData('value', $text);
21
+
22
+ return parent::_getElementHtml($element);
23
+ }
24
+
25
+ }
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
+ //base url
8
+ $baseUrl = Mage::helper('connector')->generateDynamicUrl();
9
+ //config passcode
10
+ $passcode = Mage::helper('connector')->getPasscode();
11
+ //last order id for dynamic page
12
+ $lastOrderId = Mage::helper('connector')->getLastOrderId();
13
+
14
+ if (!strlen($passcode))
15
+ $passcode = '[PLEASE SET UP A PASSCODE]';
16
+ //alert message for last order id is not mapped
17
+ if (!$lastOrderId)
18
+ $lastOrderId = '[PLEASE MAP THE LAST ORDER ID]';
19
+
20
+ //full url for dynamic content
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/Fallbackchooser.php ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dotdigitalgroup_Email_Block_Adminhtml_System_Dynamic_Fallbackchooser 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->__("Choose Products"));
10
+ }
11
+
12
+ protected function _getAddRowButtonHtml($title)
13
+ {
14
+ $action = 'getFallbackProductChooser(\'' . Mage::getUrl(
15
+ '*/widget_chooser/product/form/fallback_product_selector',
16
+ array('_secure' => Mage::app()->getStore()->isAdminUrlSecure())
17
+ ) . '?isAjax=true\'); return false;';
18
+
19
+ return $this->getLayout()->createBlock('adminhtml/widget_button')
20
+ ->setType('button')
21
+ ->setLabel($this->__($title))
22
+ ->setOnClick($action)
23
+ ->toHtml();
24
+ }
25
+ }
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Dynamic/Fallbackcontainer.php ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dotdigitalgroup_Email_Block_Adminhtml_System_Dynamic_Fallbackcontainer 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
10
+ "<script type='text/javascript'>
11
+ var fallback_product_selector = new ConnectorProductSelectorForm('connector_dynamic_content_fallback_products_product_list');
12
+ //ajax call and handler
13
+ getFallbackProductChooser = function (url) {
14
+ new Ajax.Request(
15
+ url, {
16
+ method: 'post',
17
+ onSuccess: function (b) {
18
+ var a = $('connector-fallback-product-chooser-container');
19
+ a.update(b.responseText);
20
+ a.scrollTo()
21
+ }
22
+ })
23
+ };
24
+ </script>
25
+ <div id = 'connector-fallback-product-chooser-container'></div>";
26
+ }
27
+ }
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,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ //base url for dynamic content
10
+ $baseUrl = Mage::helper('connector')->generateDynamicUrl();
11
+ $code = Mage::helper('connector')->getPasscode();
12
+
13
+ //config passcode
14
+ if(!strlen($code))
15
+ $code = '[PLEASE SET UP A PASSCODE]';
16
+ // full url
17
+ $text = $baseUrl . 'connector/email/basket/email/@EMAIL@/code/'. $code;
18
+
19
+ $element->setData('value', $text);
20
+ return parent::_getElementHtml($element);
21
+ }
22
+
23
+ }
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Dynamic/Manualchooser.php ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dotdigitalgroup_Email_Block_Adminhtml_System_Dynamic_Manualchooser 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->__("Choose Products"));
10
+ }
11
+
12
+ protected function _getAddRowButtonHtml($title)
13
+ {
14
+ $action = 'getManualProductChooser(\'' . Mage::getUrl(
15
+ '*/widget_chooser/product/form/manual_product_selector',
16
+ array('_secure' => Mage::app()->getStore()->isAdminUrlSecure())
17
+ ) . '?isAjax=true\'); return false;';
18
+
19
+ return $this->getLayout()->createBlock('adminhtml/widget_button')
20
+ ->setType('button')
21
+ ->setLabel($this->__($title))
22
+ ->setOnClick($action)
23
+ ->toHtml();
24
+ }
25
+ }
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Dynamic/Manualcontainer.php ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dotdigitalgroup_Email_Block_Adminhtml_System_Dynamic_Manualcontainer 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
10
+ "<script type='text/javascript'>
11
+ var manual_product_selector = new ConnectorProductSelectorForm('connector_dynamic_content_manual_product_search_products_push_items');
12
+ //ajax call and handler
13
+ getManualProductChooser = function (url) {
14
+ new Ajax.Request(
15
+ url, {
16
+ method: 'post',
17
+ onSuccess: function (b) {
18
+ var a = $('connector-product-chooser-container');
19
+ a.update(b.responseText);
20
+ a.scrollTo()
21
+ }
22
+ })
23
+ };
24
+ </script>
25
+ <div id = 'connector-product-chooser-container'></div>";
26
+ }
27
+ }
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Dynamic/Mostviewed.php ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ //base url for dynamic content
9
+ $baseUrl = Mage::helper('connector')->generateDynamicUrl();
10
+ $passcode = Mage::helper('connector')->getPasscode();
11
+
12
+ if (!strlen($passcode))
13
+ $passcode = '[PLEASE SET UP A PASSCODE]';
14
+
15
+ //full url for dynamic content
16
+ $text = sprintf('%sconnector/report/mostviewed/code/%s', $baseUrl, $passcode);
17
+ $element->setData('value', $text);
18
+
19
+ return parent::_getElementHtml($element);
20
+ }
21
+ }
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Dynamic/Nosto.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dotdigitalgroup_Email_Block_Adminhtml_System_Dynamic_Nosto extends Mage_Adminhtml_Block_System_Config_Form_Field
4
+ {
5
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
6
+ {
7
+ //passcode to append for url
8
+ $passcode = Mage::helper('connector')->getPasscode();
9
+
10
+ if(!strlen($passcode))
11
+ $passcode = '[PLEASE SET UP A PASSCODE]';
12
+
13
+ //generate the base url and display for default store id
14
+ $baseUrl = Mage::helper('connector')->generateDynamicUrl();
15
+
16
+ //display the full url
17
+ $text = sprintf('%sconnector/products/nosto/code/%s/slot/@SLOT_NAME@/email/@EMAIL@', $baseUrl, $passcode);
18
+ $element->setData('value', $text);
19
+
20
+ return parent::_getElementHtml($element);
21
+ }
22
+ }
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/System/Dynamic/Productpush.php ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ //generate base url
9
+ $baseUrl = Mage::helper('connector')->generateDynamicUrl();
10
+ $passcode = Mage::helper('connector')->getPasscode();
11
+
12
+ if (!strlen($passcode))
13
+ $passcode = '[PLEASE SET UP A PASSCODE]';
14
+
15
+ //full url for dynamic content
16
+ $text = sprintf('%sconnector/products/push/code/%s', $baseUrl, $passcode);
17
+ $element->setData('value', $text);
18
+
19
+ return parent::_getElementHtml($element);
20
+ }
21
+ }
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
+ //generate base url for dynamic content
7
+ $baseUrl = Mage::helper('connector')->generateDynamicUrl();
8
+
9
+ //config passcode
10
+ $passcode = Mage::helper('connector')->getPasscode();
11
+ $customerId = Mage::helper('connector')->getMappedCustomerId();
12
+
13
+ if (!strlen($passcode))
14
+ $passcode = '[PLEASE SET UP A PASSCODE]';
15
+ if (!$customerId)
16
+ $customerId = '[PLEASE MAP THE CUSTOMER ID]';
17
+ //dynamic content url
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
+ //passcode to append for url
8
+ $passcode = Mage::helper('connector')->getPasscode();
9
+ //last order id witch information will be generated
10
+ $lastOrderId = Mage::helper('connector')->getLastOrderId();
11
+
12
+ if(!strlen($passcode))
13
+ $passcode = '[PLEASE SET UP A PASSCODE]';
14
+ if(!$lastOrderId)
15
+ $lastOrderId = '[PLEASE MAP THE LAST ORDER ID]';
16
+
17
+ //generate the base url and display for default store id
18
+ $baseUrl = Mage::helper('connector')->generateDynamicUrl();
19
+
20
+ //display the full url
21
+ $text = sprintf('%sconnector/products/related/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/Review.php ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dotdigitalgroup_Email_Block_Adminhtml_System_Dynamic_Review extends Mage_Adminhtml_Block_System_Config_Form_Field
4
+ {
5
+
6
+ /** label */
7
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
8
+ {
9
+ //passcode to append for url
10
+ $passcode = Mage::helper('connector')->getPasscode();
11
+ //last order id witch information will be generated
12
+ $lastOrderId = Mage::helper('connector')->getLastOrderId();
13
+
14
+ if(!strlen($passcode))
15
+ $passcode = '[PLEASE SET UP A PASSCODE]';
16
+ if(!$lastOrderId)
17
+ $lastOrderId = '[PLEASE MAP THE LAST ORDER ID]';
18
+
19
+ //generate the base url and display for default store id
20
+ $baseUrl = Mage::helper('connector')->generateDynamicUrl();
21
+
22
+ //display the full url
23
+ $text = sprintf('%sconnector/email/review/code/%s/order_id/@%s@', $baseUrl, $passcode, $lastOrderId);
24
+ $element->setData('value', $text);
25
+
26
+ return parent::_getElementHtml($element);
27
+ }
28
+
29
+ }
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
+ //passcode to append for url
7
+ $passcode = Mage::helper('connector')->getPasscode();
8
+ //last order id witch information will be generated
9
+ $lastOrderid = Mage::helper('connector')->getLastOrderId();
10
+
11
+ if(!strlen($passcode))
12
+ $passcode = '[PLEASE SET UP A PASSCODE]';
13
+ if(!$lastOrderid)
14
+ $lastOrderid = '[PLEASE MAP THE LAST ORDER ID]';
15
+
16
+ //generate the base url and display for default store id
17
+ $baseUrl = Mage::helper('connector')->generateDynamicUrl();
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/community/Dotdigitalgroup/Email/Block/Adminhtml/Widget/Chooser/Product.php ADDED
@@ -0,0 +1,163 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dotdigitalgroup_Email_Block_Adminhtml_Widget_Chooser_Product extends Mage_Adminhtml_Block_Widget_Grid
4
+ {
5
+
6
+ public function __construct($arguments=array())
7
+ {
8
+ parent::__construct($arguments);
9
+
10
+ if ($this->getRequest()->getParam('current_grid_id')) {
11
+ $this->setId($this->getRequest()->getParam('current_grid_id'));
12
+ } else {
13
+ $this->setId('skuChooserGrid_'.$this->getId());
14
+ }
15
+
16
+ //change to 10
17
+ $this->setDefaultLimit(10);
18
+ $form = $this->getJsFormObject();
19
+ $this->setRowClickCallback("$form.chooserGridRowClick.bind($form)");
20
+ $this->setCheckboxCheckCallback("$form.chooserGridCheckboxCheck.bind($form)");
21
+ $this->setRowInitCallback("$form.chooserGridRowInit.bind($form)");
22
+ $this->setDefaultSort('entity_id');
23
+ $this->setUseAjax(true);
24
+ if ($this->getRequest()->getParam('collapse')) {
25
+ $this->setIsCollapsed(true);
26
+ }
27
+ }
28
+
29
+ /**
30
+ * Retrieve quote store object
31
+ * @return Mage_Core_Model_Store
32
+ */
33
+ public function getStore()
34
+ {
35
+ return Mage::app()->getStore();
36
+ }
37
+
38
+ protected function _addColumnFilterToCollection($column)
39
+ {
40
+ // Set custom filter for in product flag
41
+ if ($column->getId() == 'in_products') {
42
+ $selected = $this->_getSelectedProducts();
43
+ if (empty($selected)) {
44
+ $selected = '';
45
+ }
46
+ if ($column->getFilter()->getValue()) {
47
+ $this->getCollection()->addFieldToFilter('entity_id', array('in'=>$selected));
48
+ } else {
49
+ $this->getCollection()->addFieldToFilter('entity_id', array('nin'=>$selected));
50
+ }
51
+ } else {
52
+ parent::_addColumnFilterToCollection($column);
53
+ }
54
+ return $this;
55
+ }
56
+
57
+ /**
58
+ * Prepare Catalog Product Collection for attribute SKU in Promo Conditions SKU chooser
59
+ *
60
+ * @return Mage_Adminhtml_Block_Promo_Widget_Chooser_Sku
61
+ */
62
+ protected function _prepareCollection()
63
+ {
64
+ $collection = Mage::getResourceModel('catalog/product_collection')
65
+ ->setStoreId(0)
66
+ ->addAttributeToSelect('name', 'type_id', 'attribute_set_id');
67
+
68
+ $this->setCollection($collection);
69
+
70
+ return parent::_prepareCollection();
71
+ }
72
+
73
+ /**
74
+ * Define Cooser Grid Columns and filters
75
+ *
76
+ * @return Mage_Adminhtml_Block_Promo_Widget_Chooser_Sku
77
+ */
78
+ protected function _prepareColumns()
79
+ {
80
+ $this->addColumn('in_products', array(
81
+ 'header_css_class' => 'a-center',
82
+ 'type' => 'checkbox',
83
+ 'name' => 'in_products',
84
+ 'values' => $this->_getSelectedProducts(),
85
+ 'align' => 'center',
86
+ 'index' => 'entity_id',
87
+ 'use_index' => true,
88
+ ));
89
+
90
+ $this->addColumn('entity_id', array(
91
+ 'header' => Mage::helper('sales')->__('ID'),
92
+ 'sortable' => true,
93
+ 'width' => '60px',
94
+ 'index' => 'entity_id'
95
+ ));
96
+
97
+ $this->addColumn('type',
98
+ array(
99
+ 'header'=> Mage::helper('catalog')->__('Type'),
100
+ 'width' => '60px',
101
+ 'index' => 'type_id',
102
+ 'type' => 'options',
103
+ 'options' => Mage::getSingleton('catalog/product_type')->getOptionArray(),
104
+ ));
105
+
106
+ $sets = Mage::getResourceModel('eav/entity_attribute_set_collection')
107
+ ->setEntityTypeFilter(Mage::getModel('catalog/product')->getResource()->getTypeId())
108
+ ->load()
109
+ ->toOptionHash();
110
+
111
+ $this->addColumn('set_name',
112
+ array(
113
+ 'header'=> Mage::helper('catalog')->__('Attrib. Set Name'),
114
+ 'width' => '100px',
115
+ 'index' => 'attribute_set_id',
116
+ 'type' => 'options',
117
+ 'options' => $sets,
118
+ ));
119
+
120
+ $this->addColumn('chooser_sku', array(
121
+ 'header' => Mage::helper('sales')->__('SKU'),
122
+ 'name' => 'chooser_sku',
123
+ 'width' => '80px',
124
+ 'index' => 'sku'
125
+ ));
126
+ $this->addColumn('chooser_name', array(
127
+ 'header' => Mage::helper('sales')->__('Product Name'),
128
+ 'name' => 'chooser_name',
129
+ 'index' => 'name'
130
+ ));
131
+
132
+ return parent::_prepareColumns();
133
+ }
134
+
135
+ public function getGridUrl()
136
+ {
137
+ return $this->getUrl('*/*/product', array(
138
+ '_current' => true,
139
+ 'current_grid_id' => $this->getId(),
140
+ 'collapse' => null
141
+ ));
142
+ }
143
+
144
+ protected function _getSelectedProducts()
145
+ {
146
+ $products = $this->getRequest()->getPost('selected', array());
147
+
148
+ return $products;
149
+ }
150
+
151
+ /**
152
+ * set default limit
153
+ *
154
+ * @param $limit
155
+ * @return $this
156
+ */
157
+ public function setDefaultLimit($limit)
158
+ {
159
+ $this->_defaultLimit = $limit;
160
+ return $this;
161
+ }
162
+ }
163
+
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Wishlist.php ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dotdigitalgroup_Email_Block_Adminhtml_Wishlist 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_wishlist';
11
+ $this->_headerText = Mage::helper('connector')->__('Email Wishlist(s)');
12
+
13
+ $this->_removeButton('add');
14
+ }
15
+ }
app/code/community/Dotdigitalgroup/Email/Block/Adminhtml/Wishlist/Grid.php ADDED
@@ -0,0 +1,120 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dotdigitalgroup_Email_Block_Adminhtml_Wishlist_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('id');
11
+ $this->setId('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/wishlist_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('wishlist_id', array(
45
+ 'header' => Mage::helper('connector')->__('Wishlist ID'),
46
+ 'align' => 'left',
47
+ 'width' => '50px',
48
+ 'index' => 'wishlist_id',
49
+ 'type' => 'number',
50
+ 'escape' => true
51
+ ))->addColumn('item_count', array(
52
+ 'header' => Mage::helper('connector')->__('Item Count'),
53
+ 'align' => 'left',
54
+ 'width' => '50px',
55
+ 'index' => 'item_count',
56
+ 'type' => 'number',
57
+ 'escape' => true
58
+ ))->addColumn('customer_id', array(
59
+ 'header' => Mage::helper('connector')->__('Customer ID'),
60
+ 'align' => 'left',
61
+ 'width' => '50px',
62
+ 'index' => 'customer_id',
63
+ 'type' => 'number',
64
+ 'escape' => true
65
+ ))->addColumn('wishlist_imported', array(
66
+ 'header' => Mage::helper('connector')->__('Wishlist Imported'),
67
+ 'align' => 'center',
68
+ 'width' => '50px',
69
+ 'index' => 'wishlist_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('wishlist_modified', array(
76
+ 'header' => Mage::helper('connector')->__('Wishlist Modified'),
77
+ 'align' => 'center',
78
+ 'width' => '50px',
79
+ 'index' => 'wishlist_modified',
80
+ 'type' => 'options',
81
+ 'escape' => true,
82
+ 'renderer' => 'email_connector/adminhtml_column_renderer_imported',
83
+ 'options' => Mage::getModel('email_connector/adminhtml_source_contact_imported')->getOptions(),
84
+ 'filter_condition_callback' => array($this, 'filterCallbackContact')
85
+ ))->addColumn('created_at', array(
86
+ 'header' => Mage::helper('connector')->__('Created At'),
87
+ 'width' => '50px',
88
+ 'align' => 'center',
89
+ 'index' => 'created_at',
90
+ 'type' => 'datetime',
91
+ 'escape' => true,
92
+ ))->addColumn('updated_at', array(
93
+ 'header' => Mage::helper('connector')->__('Updated At'),
94
+ 'width' => '50px',
95
+ 'align' => 'center',
96
+ 'index' => 'updated_at',
97
+ 'type' => 'datetime',
98
+ 'escape' => true,
99
+ ));
100
+
101
+ return parent::_prepareColumns();
102
+ }
103
+
104
+ /**
105
+ * Callback action for the imported subscribers/contacts.
106
+ *
107
+ * @param $collection
108
+ * @param $column
109
+ */
110
+ public function filterCallbackContact($collection, $column)
111
+ {
112
+ $field = $column->getFilterIndex() ? $column->getFilterIndex() : $column->getIndex();
113
+ $value = $column->getFilter()->getValue();
114
+ if ($value == 'null') {
115
+ $collection->addFieldToFilter($field, array('null' => true));
116
+ } else {
117
+ $collection->addFieldToFilter($field, array('notnull' => true));
118
+ }
119
+ }
120
+ }
app/code/{local → community}/Dotdigitalgroup/Email/Block/Basket.php RENAMED
@@ -4,12 +4,19 @@ 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
 
15
  $email = $params['email'];
@@ -19,22 +26,34 @@ class Dotdigitalgroup_Email_Block_Basket extends Mage_Core_Block_Template
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
+ throw new Exception('Basket no email or code is set');
20
  Mage::helper('connector')->auth($params['code']);
21
 
22
  $email = $params['email'];
26
 
27
  //last active guest basket
28
  $quoteModel = Mage::getResourceModel('sales/quote_collection')
29
+ ->addFieldToFilter('is_active', 1)
30
  ->addFieldToFilter('items_count', array('gt' => 0))
31
  ->addFieldToFilter('customer_email', $email)
32
+ ->setOrder('updated_at', 'DESC')
33
+ ->setPageSize(1);
 
34
 
35
  $quoteModel = $quoteModel->getFirstItem();
36
+
37
+ //check for any quote for this email, don't want to render further
38
+ if (! $quoteModel->getId()) {
39
+ throw new Exception('no quote found for email : ' . $email);
40
+ }
41
+
42
  $this->_quote = $quoteModel;
43
 
44
+ //Start environment emulation of the specified store
45
+ $storeId = $quoteModel->getStoreId();
46
+ $appEmulation = Mage::getSingleton('core/app_emulation');
47
+ $appEmulation->startEnvironmentEmulation($storeId);
48
 
49
+ return $quoteModel->getAllItems();
50
  }
51
 
52
+ /**
53
+ * Grand total.
54
+ *
55
+ * @return mixed
56
+ */
57
  public function getGrandTotal()
58
  {
59
  return $this->_quote->getGrandTotal();
app/code/{local → community}/Dotdigitalgroup/Email/Block/Coupon.php RENAMED
@@ -2,11 +2,16 @@
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'];
12
  $authCode = $params['code'];
@@ -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
+ throw new Exception('Coupon no id or code is set');
15
  //coupon rule id
16
  $couponCodeId = $params['id'];
17
  $authCode = $params['code'];
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/Order.php ADDED
@@ -0,0 +1,83 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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::unregister('order_id'); // additional measure
33
+ Mage::register('order_id', $orderId);
34
+ }
35
+ if (! $order) {
36
+ $order = Mage::getModel('sales/order')->load($orderId);
37
+ Mage::unregister('current_order'); // additional measure
38
+ Mage::register('current_order', $order);
39
+ }
40
+
41
+ return $order;
42
+ }
43
+
44
+ /**
45
+ * Filter items for review. If a customer has already placed a review for a product then exclude the product.
46
+ *
47
+ * @param array $items
48
+ * @param int $websiteId
49
+ * @return mixed
50
+ */
51
+ public function filterItemsForReview($items, $websiteId)
52
+ {
53
+ if (!count($items))
54
+ return;
55
+
56
+ $order = $this->getOrder();
57
+
58
+ //if customer is guest then no need to filter any items
59
+ if($order->getCustomerIsGuest())
60
+ return $items;
61
+
62
+ if(!Mage::helper('connector/review')->isNewProductOnly($websiteId))
63
+ return $items;
64
+
65
+ $customerId = $order->getCustomerId();
66
+
67
+ foreach($items as $key => $item)
68
+ {
69
+ $productId = $item->getProduct()->getId();
70
+
71
+ $collection = Mage::getModel('review/review')->getCollection();
72
+ $collection->addCustomerFilter($customerId)
73
+ ->addStoreFilter($order->getStoreId())
74
+ ->addFieldToFilter('main_table.entity_pk_value', $productId);
75
+
76
+ //remove item if customer has already placed review on this item
77
+ if($collection->getSize())
78
+ unset($items[$key]);
79
+ }
80
+
81
+ return $items;
82
+ }
83
+ }
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_Sales_Model_Order
19
+ * @throws Exception
20
+ */
21
+ public function getOrder()
22
+ {
23
+ $orderId = Mage::registry('order_id');
24
+ $order = Mage::registry('current_order');
25
+ if (! $orderId) {
26
+ $orderId = Mage::app()->getRequest()->getParam('order_id');
27
+ Mage::register('order_id', $orderId);
28
+ }
29
+ if (! $order) {
30
+ $order = Mage::getModel('sales/order')->load($orderId);
31
+ Mage::register('current_order', $order);
32
+ }
33
+ if (! $order->hasCreditmemos()) {
34
+ throw new Exception('TE - no creditmemo for order : '. $orderId);
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_Sales_Model_Order
18
+ * @throws Exception
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->hasInvoices()) {
33
+ throw new Exception('TE - no invoice for order : '. $orderId);
34
+ }
35
+
36
+ return $order;
37
+ }
38
+
39
+ }
app/code/community/Dotdigitalgroup/Email/Block/Order/Shipping.php ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ * @return Mage_Sales_Model_Order
17
+ * @throws Exception
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
+ throw new Exception('TE - no shipments for order : '. $orderId);
33
+ }
34
+
35
+ return $order;
36
+
37
+ }
38
+
39
+ }
app/code/community/Dotdigitalgroup/Email/Block/Products.php ADDED
@@ -0,0 +1,67 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ $storeId = $orderModel->getStoreId();
29
+ $appEmulation = Mage::getSingleton('core/app_emulation');
30
+ $appEmulation->startEnvironmentEmulation($storeId);
31
+ //order products
32
+ $productRecommended = Mage::getModel('email_connector/dynamic_recommended', $orderModel);
33
+ $productRecommended->setMode($mode);
34
+
35
+ //get the order items recommendations
36
+ $productsToDisplay = $productRecommended->getProducts();
37
+ }
38
+ }
39
+
40
+ return $productsToDisplay;
41
+ }
42
+
43
+
44
+ /**
45
+ * Price html block.
46
+ *
47
+ * @param $product
48
+ *
49
+ * @return string
50
+ */
51
+ public function getPriceHtml($product)
52
+ {
53
+ $this->setTemplate('connector/price.phtml');
54
+ $this->setProduct($product);
55
+ return $this->toHtml();
56
+ }
57
+
58
+ /**
59
+ * Display type mode.
60
+ * @return mixed|string
61
+ */
62
+ public function getDisplayType()
63
+ {
64
+ return Mage::helper('connector/recommended')->getDisplayType();
65
+
66
+ }
67
+ }
app/code/community/Dotdigitalgroup/Email/Block/Recommended/Bestsellers.php ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ $mode = $this->getRequest()->getActionName();
25
+ $limit = Mage::helper('connector/recommended')->getDisplayLimitByMode($mode);
26
+ $from = Mage::helper('connector/recommended')->getTimeFromConfig($mode);
27
+ $to = Zend_Date::now()->toString(Zend_Date::ISO_8601);
28
+
29
+ $productCollection = Mage::getResourceModel('reports/product_collection')
30
+ ->addAttributeToSelect('*')
31
+ ->addOrderedQty($from, $to)
32
+ ->setOrder('ordered_qty', 'desc')
33
+ ->setPageSize($limit);
34
+
35
+ Mage::getSingleton('cataloginventory/stock')->addInStockFilterToCollection($productCollection);
36
+ $productCollection->addAttributeToFilter('is_saleable', TRUE);
37
+
38
+ return $productCollection;
39
+ }
40
+
41
+ /**
42
+ * Display type mode.
43
+ *
44
+ * @return mixed|string
45
+ */
46
+ public function getMode()
47
+ {
48
+ return Mage::helper('connector/recommended')->getDisplayType();
49
+
50
+ }
51
+
52
+ /**
53
+ * Price html.
54
+ * @param $product
55
+ *
56
+ * @return string
57
+ */
58
+ public function getPriceHtml($product)
59
+ {
60
+ $this->setTemplate('connector/product/price.phtml');
61
+ $this->setProduct($product);
62
+ return $this->toHtml();
63
+ }
64
+
65
+ }
app/code/community/Dotdigitalgroup/Email/Block/Recommended/Mostviewed.php ADDED
@@ -0,0 +1,66 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ //@todo localize this value
29
+ $to = Zend_Date::now()->toString(Zend_Date::ISO_8601);
30
+
31
+ $productCollection = Mage::getResourceModel('reports/product_collection')
32
+ ->addViewsCount($from, $to)
33
+ ->setPageSize($limit);
34
+
35
+ foreach ($productCollection as $_product) {
36
+ $productId = $_product->getId();
37
+ $product = Mage::getModel('catalog/product')->load($productId);
38
+ if($product->isSalable())
39
+ $productsToDisplay[] = $product;
40
+ }
41
+
42
+ return $productsToDisplay;
43
+ }
44
+
45
+
46
+ /**
47
+ * Display mode type.
48
+ * @return mixed|string
49
+ */
50
+ public function getMode()
51
+ {
52
+ return Mage::helper('connector/recommended')->getDisplayType();
53
+ }
54
+
55
+ /**
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/Products.php ADDED
@@ -0,0 +1,194 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dotdigitalgroup_Email_Block_Recommended_Products extends Mage_Core_Block_Template
4
+ {
5
+ /**
6
+ * Slot div name.
7
+ * @var string
8
+ */
9
+ public $slot;
10
+
11
+ /**
12
+ * Prepare layout, set the template.
13
+ * @return Mage_Core_Block_Abstract|void
14
+ */
15
+ protected function _prepareLayout()
16
+ {
17
+ if ($root = $this->getLayout()->getBlock('root')) {
18
+ $root->setTemplate('page/blank.phtml');
19
+ }
20
+ }
21
+
22
+ /**
23
+ * get the products to display for table
24
+ */
25
+ public function getLoadedProductCollection()
26
+ {
27
+ //products to be diplayd for recommended pages
28
+ $productsToDisplay = array();
29
+ $orderId = $this->getRequest()->getParam('order_id');
30
+ //display mode based on the action name
31
+ $mode = $this->getRequest()->getActionName();
32
+ $orderModel = Mage::getModel('sales/order')->load($orderId);
33
+ //number of product items to be displayed
34
+ $limit = Mage::helper('connector/recommended')->getDisplayLimitByMode($mode);
35
+ $orderItems = $orderModel->getAllItems();
36
+ $numItems = count($orderItems);
37
+
38
+ //no product found to display
39
+ if ($numItems == 0 || ! $limit) {
40
+ return array();
41
+ }elseif (count($orderItems) > $limit) {
42
+ $maxPerChild = 1;
43
+ } else {
44
+ $maxPerChild = number_format($limit / count($orderItems));
45
+ }
46
+
47
+ Mage::helper('connector')->log('DYNAMIC PRODUCTS : limit ' . $limit . ' products : ' . $numItems . ', max per child : '. $maxPerChild);
48
+
49
+ foreach ($orderItems as $item) {
50
+ $i = 0;
51
+ $productId = $item->getProductId();
52
+ //parent product
53
+ $productModel = Mage::getModel('catalog/product')->load($productId);
54
+ //check for product exists
55
+ if ($productModel->getId()) {
56
+ //get single product for current mode
57
+ $recommendedProducts = $this->_getRecommendedProduct($productModel, $mode);
58
+ foreach ($recommendedProducts as $product) {
59
+ //load child product
60
+ $product = Mage::getModel('catalog/product')->load($product->getId());
61
+ //check if still exists
62
+ if ($product->getId() && count($productsToDisplay) < $limit && $i <= $maxPerChild && $product->isSaleable() && !$product->getParentId()) {
63
+ //we have a product to display
64
+ $productsToDisplay[$product->getId()] = $product;
65
+ $i++;
66
+ }
67
+ }
68
+ }
69
+ //have reached the limit don't loop for more
70
+ if (count($productsToDisplay) == $limit) {
71
+ break;
72
+ }
73
+ }
74
+
75
+ //check for more space to fill up the table with fallback products
76
+ if (count($productsToDisplay) < $limit) {
77
+ $fallbackIds = Mage::helper('connector/recommended')->getFallbackIds();
78
+
79
+ foreach ($fallbackIds as $productId) {
80
+ $product = Mage::getModel('catalog/product')->load($productId);
81
+ if($product->isSaleable())
82
+ $productsToDisplay[$product->getId()] = $product;
83
+ //stop the limit was reached
84
+ if (count($productsToDisplay) == $limit) {
85
+ break;
86
+ }
87
+ }
88
+ }
89
+
90
+ Mage::helper('connector')->log('loaded product to display ' . count($productsToDisplay));
91
+ return $productsToDisplay;
92
+ }
93
+
94
+ /**
95
+ * Product related items.
96
+ *
97
+ * @param Mage_Catalog_Model_Product $productModel
98
+ * @param $mode
99
+ *
100
+ * @return array
101
+ */
102
+ private function _getRecommendedProduct(Mage_Catalog_Model_Product $productModel, $mode)
103
+ {
104
+ //array of products to display
105
+ $products = array();
106
+ switch($mode){
107
+ case 'related':
108
+ $products = $productModel->getRelatedProducts();
109
+ break;
110
+ case 'upsell':
111
+ $products = $productModel->getUpSellProducts();
112
+ break;
113
+ case 'crosssell':
114
+ $products = $productModel->getCrossSellProducts();
115
+ break;
116
+
117
+ }
118
+
119
+ return $products;
120
+ }
121
+
122
+ /**
123
+ * Diplay mode type.
124
+ *
125
+ * @return mixed|string
126
+ */
127
+ public function getMode()
128
+ {
129
+ return Mage::helper('connector/recommended')->getDisplayType();
130
+
131
+ }
132
+
133
+ /**
134
+ * Number of the colums.
135
+ * @return int|mixed
136
+ * @throws Exception
137
+ */
138
+ public function getColumnCount()
139
+ {
140
+ return Mage::helper('connector/recommended')->getDisplayLimitByMode($this->getRequest()->getActionName());
141
+ }
142
+
143
+ /**
144
+ * Price html.
145
+ * @param $product
146
+ *
147
+ * @return string
148
+ */
149
+ public function getPriceHtml($product)
150
+ {
151
+ $this->setTemplate('connector/product/price.phtml');
152
+ $this->setProduct($product);
153
+ return $this->toHtml();
154
+ }
155
+
156
+
157
+ /**
158
+ * Nosto products data.
159
+ * @return object
160
+ */
161
+ public function getNostoProducts()
162
+ {
163
+ $client = Mage::getModel('email_connector/apiconnector_client');
164
+ //slot name, div id
165
+ $slot = Mage::app()->getRequest()->getParam('slot', false);
166
+
167
+ //email recommendation
168
+ $email = Mage::app()->getRequest()->getParam('email', false);
169
+
170
+ //no valid data for nosto recommendation
171
+ if (!$slot || ! $email)
172
+ return false;
173
+ else
174
+ $this->slot = $slot;
175
+
176
+ //html data from nosto
177
+ $data = $client->getNostoProducts($slot, $email);
178
+
179
+ //check for valid response
180
+ if (! isset($data->$email) && !isset($data->$email->$slot))
181
+ return false;
182
+ return $data->$email->$slot;
183
+ }
184
+
185
+ /**
186
+ * Slot name.
187
+ * Should be called after getNostoProducts.
188
+ * @return string
189
+ */
190
+ public function getSlotName()
191
+ {
192
+ return $this->slot;
193
+ }
194
+ }
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/Quoteproducts.php ADDED
@@ -0,0 +1,149 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dotdigitalgroup_Email_Block_Recommended_Quoteproducts 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
+ //products to be diplayd for recommended pages
22
+ $productsToDisplay = array();
23
+ $quoteId = $this->getRequest()->getParam('quote_id');
24
+ //display mode based on the action name
25
+ $mode = $this->getRequest()->getActionName();
26
+ $quoteModel = Mage::getModel('sales/quote')->load($quoteId);
27
+ //number of product items to be displayed
28
+ $limit = Mage::helper('connector/recommended')->getDisplayLimitByMode($mode);
29
+ $quoteItems = $quoteModel->getAllItems();
30
+ $numItems = count($quoteItems);
31
+
32
+ //no product found to display
33
+ if ($numItems == 0 || ! $limit) {
34
+ return array();
35
+ }elseif (count($quoteItems) > $limit) {
36
+ $maxPerChild = 1;
37
+ } else {
38
+ $maxPerChild = number_format($limit / count($quoteItems));
39
+ }
40
+
41
+ Mage::helper('connector')->log('DYNAMIC QUOTE PRODUCTS : limit ' . $limit . ' products : ' . $numItems . ', max per child : '. $maxPerChild);
42
+
43
+ foreach ($quoteItems as $item) {
44
+ $i = 0;
45
+ $productId = $item->getProductId();
46
+ //parent product
47
+ $productModel = Mage::getModel('catalog/product')->load($productId);
48
+ //check for product exists
49
+ if ($productModel->getId()) {
50
+ //get single product for current mode
51
+ $recommendedProducts = $this->_getRecommendedProduct($productModel, $mode);
52
+ foreach ($recommendedProducts as $product) {
53
+ //load child product
54
+ $product = Mage::getModel('catalog/product')->load($product->getId());
55
+ //check if still exists
56
+ if ($product->getId() && count($productsToDisplay) < $limit && $i <= $maxPerChild && $product->isSaleable() && !$product->getParentId()) {
57
+ //we have a product to display
58
+ $productsToDisplay[$product->getId()] = $product;
59
+ $i++;
60
+ }
61
+ }
62
+ }
63
+ //have reached the limit don't loop for more
64
+ if (count($productsToDisplay) == $limit) {
65
+ break;
66
+ }
67
+ }
68
+
69
+ //check for more space to fill up the table with fallback products
70
+ if (count($productsToDisplay) < $limit) {
71
+ $fallbackIds = Mage::helper('connector/recommended')->getFallbackIds();
72
+
73
+ foreach ($fallbackIds as $productId) {
74
+ $product = Mage::getModel('catalog/product')->load($productId);
75
+ if($product->isSaleable())
76
+ $productsToDisplay[$product->getId()] = $product;
77
+ //stop the limit was reached
78
+ if (count($productsToDisplay) == $limit) {
79
+ break;
80
+ }
81
+ }
82
+ }
83
+
84
+ Mage::helper('connector')->log('quote - loaded product to display ' . count($productsToDisplay));
85
+ return $productsToDisplay;
86
+ }
87
+
88
+ /**
89
+ * Product related items.
90
+ *
91
+ * @param Mage_Catalog_Model_Product $productModel
92
+ * @param $mode
93
+ *
94
+ * @return array
95
+ */
96
+ private function _getRecommendedProduct(Mage_Catalog_Model_Product $productModel, $mode)
97
+ {
98
+ //array of products to display
99
+ $products = array();
100
+ switch($mode){
101
+ case 'related':
102
+ $products = $productModel->getRelatedProducts();
103
+ break;
104
+ case 'upsell':
105
+ $products = $productModel->getUpSellProducts();
106
+ break;
107
+ case 'crosssell':
108
+ $products = $productModel->getCrossSellProducts();
109
+ break;
110
+
111
+ }
112
+
113
+ return $products;
114
+ }
115
+
116
+ /**
117
+ * Diplay mode type.
118
+ *
119
+ * @return mixed|string
120
+ */
121
+ public function getMode()
122
+ {
123
+ return Mage::helper('connector/recommended')->getDisplayType();
124
+
125
+ }
126
+
127
+ /**
128
+ * Number of the colums.
129
+ * @return int|mixed
130
+ * @throws Exception
131
+ */
132
+ public function getColumnCount()
133
+ {
134
+ return Mage::helper('connector/recommended')->getDisplayLimitByMode($this->getRequest()->getActionName());
135
+ }
136
+
137
+ /**
138
+ * Price html.
139
+ * @param $product
140
+ *
141
+ * @return string
142
+ */
143
+ public function getPriceHtml($product)
144
+ {
145
+ $this->setTemplate('connector/product/price.phtml');
146
+ $this->setProduct($product);
147
+ return $this->toHtml();
148
+ }
149
+ }
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,190 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dotdigitalgroup_Email_Helper_Config
4
+ {
5
+ const MODULE_NAME = 'Dotdigitalgroup_Email';
6
+
7
+ /**
8
+ * API SECTION.
9
+ */
10
+ //API settings
11
+ const XML_PATH_CONNECTOR_API_ENABLED = 'connector_api_credentials/api/enabled';
12
+ const XML_PATH_CONNECTOR_API_USERNAME = 'connector_api_credentials/api/username';
13
+ const XML_PATH_CONNECTOR_API_PASSWORD = 'connector_api_credentials/api/password';
14
+ const XML_PATH_CONNECTOR_CLIENT_ID = 'connector_api_credentials/oauth/client_id';
15
+ const XML_PATH_CONNECTOR_CLIENT_SECRET_ID = 'connector_api_credentials/oauth/client_key';
16
+
17
+ /**
18
+ * SMS SECTION.
19
+ */
20
+ //enabled
21
+ const XML_PATH_CONNECTOR_SMS_ENABLED_1 = 'connector_sms/sms_one/enabled';
22
+ const XML_PATH_CONNECTOR_SMS_ENABLED_2 = 'connector_sms/sms_two/enabled';
23
+ const XML_PATH_CONNECTOR_SMS_ENABLED_3 = 'connector_sms/sms_three/enabled';
24
+ const XML_PATH_CONNECTOR_SMS_ENABLED_4 = 'connector_sms/sms_four/enabled';
25
+ //status
26
+ const XML_PATH_CONNECTOR_SMS_STATUS_1 = 'connector_sms/sms_one/status';
27
+ const XML_PATH_CONNECTOR_SMS_STATUS_2 = 'connector_sms/sms_two/status';
28
+ const XML_PATH_CONNECTOR_SMS_STATUS_3 = 'connector_sms/sms_three/status';
29
+ const XML_PATH_CONNECTOR_SMS_STATUS_4 = 'connector_sms/sms_four/status';
30
+ //message
31
+ const XML_PATH_CONNECTOR_SMS_MESSAGE_1 = 'connector_sms/sms_one/message';
32
+ const XML_PATH_CONNECTOR_SMS_MESSAGE_2 = 'connector_sms/sms_two/message';
33
+ const XML_PATH_CONNECTOR_SMS_MESSAGE_3 = 'connector_sms/sms_three/message';
34
+ const XML_PATH_CONNECTOR_SMS_MESSAGE_4 = 'connector_sms/sms_four/message';
35
+
36
+ /**
37
+ * SYNC SECTION.
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
+ const XML_PATH_CONNECTOR_SYNC_REVIEW_ENABLED = 'connector_sync_settings/sync/review_enabled';
44
+
45
+ const XML_PATH_CONNECTOR_CUSTOMERS_ADDRESS_BOOK_ID = 'connector_sync_settings/address_book/customers';
46
+ const XML_PATH_CONNECTOR_SUBSCRIBERS_ADDRESS_BOOK_ID = 'connector_sync_settings/address_book/subscribers';
47
+ const XML_PATH_CONNECTOR_GUEST_ADDRESS_BOOK_ID = 'connector_sync_settings/address_book/guests';
48
+ // Mapping
49
+ const XML_PATH_CONNECTOR_MAPPING_LAST_ORDER_ID = 'connector_data_mapping/customer_data/last_order_id';
50
+ const XML_PATH_CONNECTOR_MAPPING_LAST_QUOTE_ID = 'connector_data_mapping/customer_data/last_quote_id';
51
+ const XML_PATH_CONNECTOR_MAPPING_CUSTOMER_ID = 'connector_data_mapping/customer_data/customer_id';
52
+ const XML_PATH_CONNECTOR_MAPPING_CUSTOM_DATAFIELDS = 'connector_data_mapping/customer_data/custom_attributes';
53
+ const XML_PATH_CONNECTOR_MAPPING_CUSTOMER_STORENAME = 'connector_data_mapping/customer_data/store_name';
54
+ const XML_PATH_CONNECTOR_MAPPING_CUSTOMER_TOTALREFUND = 'connector_data_mapping/customer_data/total_refund';
55
+ const XML_PATH_CONNECTOR_MAPPING_SWEETTOOTH_ACTIVE = 'connector_data_mapping/sweet_tooth/active';
56
+
57
+
58
+ /**
59
+ * Abandoned Carts.
60
+ */
61
+ const XML_PATH_CONNECTOR_CUSTOMER_ABANDONED_CARTS_ENABLED_1 = 'connector_lost_baskets/customers/enabled_1';
62
+ const XML_PATH_CONNECTOR_CUSTOMER_ABANDONED_CAMPAIGN_1 = 'connector_lost_baskets/customers/campaign_1';
63
+ const XML_PATH_CONNECTOR_CUSTOMER_ABANDONED_CARTS_ENABLED_2 = 'connector_lost_baskets/customers/enabled_2';
64
+ const XML_PATH_CONNECTOR_CUSTOMER_ABANDONED_CAMPAIGN_2 = 'connector_lost_baskets/customers/campaign_2';
65
+ const XML_PATH_CONNECTOR_CUSTOMER_ABANDONED_CARTS_ENABLED_3 = 'connector_lost_baskets/customers/enabled_3';
66
+ const XML_PATH_CONNECTOR_CUSTOMER_ABANDONED_CAMPAIGN_3 = 'connector_lost_baskets/customers/campaign_3';
67
+ const XML_PATH_CONNECTOR_GUEST_ABANDONED_CARTS_ENABLED_1 = 'connector_lost_baskets/guests/enabled_1';
68
+ const XML_PATH_CONNECTOR_GUEST_ABANDONED_CAMPAIGN_1 = 'connector_lost_baskets/guests/campaign_1';
69
+ const XML_PATH_CONNECTOR_GUEST_ABANDONED_CARTS_ENABLED_2 = 'connector_lost_baskets/guests/enabled_2';
70
+ const XML_PATH_CONNECTOR_GUEST_ABANDONED_CAMPAIGN_2 = 'connector_lost_baskets/guests/campaign_2';
71
+ const XML_PATH_CONNECTOR_GUEST_ABANDONED_CARTS_ENABLED_3 = 'connector_lost_baskets/guests/enabled_3';
72
+ const XML_PATH_CONNECTOR_GUEST_ABANDONED_CAMPAIGN_3 = 'connector_lost_baskets/guests/campaign_3';
73
+
74
+ /**
75
+ * Datafields Mapping.
76
+ */
77
+ const XML_PATH_CONNECTOR_CUSTOMER_ID = 'connector_data_mapping/customer_data/customer_id';
78
+ const XML_PATH_CONNECTOR_CUSTOMER_FIRSTNAME = 'connector_data_mapping/customer_data/firstname';
79
+ const XML_PATH_CONNECTOR_CUSTOMER_LASTNAME = 'connector_data_mapping/customer_data/lastname';
80
+ const XML_PATH_CONNECTOR_CUSTOMER_DOB = 'connector_data_mapping/customer_data/dob';
81
+ const XML_PATH_CONNECTOR_CUSTOMER_GENDER = 'connector_data_mapping/customer_data/gender';
82
+ const XML_PATH_CONNECTOR_CUSTOMER_WEBSITE_NAME = 'connector_data_mapping/customer_data/website_name';
83
+ const XML_PATH_CONNECTOR_CUSTOMER_STORE_NAME = 'connector_data_mapping/customer_data/store_name';
84
+ const XML_PATH_CONNECTOR_CUSTOMER_CREATED_AT = 'connector_data_mapping/customer_data/created_at';
85
+ const XML_PATH_CONNECTOR_CUSTOMER_LAST_LOGGED_DATE = 'connector_data_mapping/customer_data/last_logged_date';
86
+ const XML_PATH_CONNECTOR_CUSTOMER_CUSTOMER_GROUP = 'connector_data_mapping/customer_data/customer_group';
87
+ const XML_PATH_CONNECTOR_CUSTOMER_REVIEW_COUNT = 'connector_data_mapping/customer_data/review_count';
88
+ const XML_PATH_CONNECTOR_CUSTOMER_LAST_REVIEW_DATE = 'connector_data_mapping/customer_data/last_review_date';
89
+ const XML_PATH_CONNECTOR_CUSTOMER_BILLING_ADDRESS_1 = 'connector_data_mapping/customer_data/billing_address_1';
90
+ const XML_PATH_CONNECTOR_CUSTOMER_BILLING_ADDRESS_2 = 'connector_data_mapping/customer_data/billing_address_2';
91
+ const XML_PATH_CONNECTOR_CUSTOMER_BILLING_CITY = 'connector_data_mapping/customer_data/billing_city';
92
+ const XML_PATH_CONNECTOR_CUSTOMER_BILLING_STATE = 'connector_data_mapping/customer_data/billing_state';
93
+ const XML_PATH_CONNECTOR_CUSTOMER_BILLING_COUNTRY = 'connector_data_mapping/customer_data/billing_country';
94
+ const XML_PATH_CONNECTOR_CUSTOMER_BILLING_POSTCODE = 'connector_data_mapping/customer_data/billing_postcode';
95
+ const XML_PATH_CONNECTOR_CUSTOMER_BILLING_TELEPHONE = 'connector_data_mapping/customer_data/billing_telephone';
96
+ const XML_PATH_CONNECTOR_CUSTOMER_DELIVERY_ADDRESS_1 = 'connector_data_mapping/customer_data/delivery_address_1';
97
+ const XML_PATH_CONNECTOR_CUSTOMER_DELIVERY_ADDRESS_2 = 'connector_data_mapping/customer_data/delivery_address_2';
98
+ const XML_PATH_CONNECTOR_CUSTOMER_DELIVERY_CITY = 'connector_data_mapping/customer_data/delivery_city';
99
+ const XML_PATH_CONNECTOR_CUSTOMER_DELIVERY_STATE = 'connector_data_mapping/customer_data/delivery_state';
100
+ const XML_PATH_CONNECTOR_CUSTOMER_DELIVERY_COUNTRY = 'connector_data_mapping/customer_data/delivery_country';
101
+ const XML_PATH_CONNECTOR_CUSTOMER_DELIVERY_POSTCODE = 'connector_data_mapping/customer_data/delivery_postcode';
102
+ const XML_PATH_CONNECTOR_CUSTOMER_DELIVERY_TELEPHONE = 'connector_data_mapping/customer_data/delivery_telephone';
103
+ const XML_PATH_CONNECTOR_CUSTOMER_TOTAL_NUMBER_ORDER = 'connector_data_mapping/customer_data/number_of_orders';
104
+ const XML_PATH_CONNECTOR_CUSTOMER_AOV = 'connector_data_mapping/customer_data/average_order_value';
105
+ const XML_PATH_CONNECTOR_CUSTOMER_TOTAL_SPEND = 'connector_data_mapping/customer_data/total_spend';
106
+ const XML_PATH_CONNECTOR_CUSTOMER_LAST_ORDER_DATE = 'connector_data_mapping/customer_data/last_order_date';
107
+ const XML_PATH_CONNECTOR_CUSTOMER_LAST_ORDER_ID = 'connector_data_mapping/customer_data/last_order_id';
108
+ const XML_PATH_CONNECTOR_CUSTOMER_TOTAL_REFUND = 'connector_data_mapping/customer_data/total_refund';
109
+ const XML_PATH_CONNECTOR_CUSTOMER_SUBSCRIBER_STATUS = 'connector_data_mapping/customer_data/subscriber_status';
110
+
111
+ /**
112
+ * Dynamic Content
113
+ */
114
+ const XML_PATH_CONNECTOR_DYNAMIC_CONTENT_PASSCODE = 'connector_dynamic_content/external_dynamic_content_urls/passcode';
115
+ const XML_PATH_CONNECTOR_DYNAMIC_CONTENT_NOSTO = 'connector_dynamic_content/nosto_recommendation/api';
116
+
117
+ /**
118
+ * CONFIGURATION SECTION.
119
+ */
120
+ const XML_PATH_CONNECTOR_SYNC_ORDER_STATUS = 'connector_configuration/transactional_data/order_statuses';
121
+ const XML_PATH_CONNECTOR_CUSTOM_ORDER_ATTRIBUTES = 'connector_configuration/transactional_data/order_custom_attributes';
122
+ const XML_PATH_CONNECTOR_EMAIL_CAPTURE = 'connector_configuration/abandoned_carts/email_capture';
123
+ const XML_PATH_CONNECTOR_ABANDONED_CART_LIMIT = 'connector_configuration/abandoned_carts/limits';
124
+ const XML_PATH_CONNECTOR_DISABLE_NEWSLETTER_SUCCESS = 'connector_configuration/admin/disable_newsletter_success';
125
+ const XML_PATH_CONNECTOR_DISABLE_CUSTOMER_SUCCESS = 'connector_configuration/admin/disable_customer_success';
126
+ const XML_PATH_CONNECTOR_DYNAMIC_STYLING = 'connector_configuration/admin/recommended_inline';
127
+ const XML_PATH_CONNECTOR_RESOURCE_ALLOCATION = 'connector_developer_settings/import_settings/memory_limit';
128
+ const XML_PATH_CONNECTOR_SYNC_LIMIT = 'connector_developer_settings/import_settings/batch_size';
129
+ const XML_PATH_CONNECTOR_TRANSACTIONAL_DATA_SYNC_LIMIT = 'connector_developer_settings/import_settings/orders';
130
+ const XML_PATH_CONNECTOR_ABANDONED_CART_SHELL = 'connector_developer_settings/abandoned_cart/shell';
131
+ const XML_PATH_CONNECTOR_SETUP_DATAFIELDS = 'connector_developer_settings/sync_settings/setup_data_fields';
132
+ const XML_PATH_CONNECTOR_ADVANCED_DEBUG_ENABLED = 'connector_developer_settings/debug/debug_enabled';
133
+ const XML_PATH_CONNECTOR_DEBUG_API_CALLS = 'connector_developer_settings/debug/debug_api_calls';
134
+ const XML_PATH_RAYGUN_APPLICATION_CODE = 'connector_developer_settings/debug/raygun_code';
135
+ const XML_PATH_CONNECTOR_FEED_ENABLED = 'connector_developer_settings/feed_configuration/feed_enabled';
136
+ const XML_PATH_CONNECTOR_FEED_URL = 'connector_developer_settings/feed_configuration/feed_url';
137
+ const XML_PATH_CONNECTOR_FEED_FREQUENCY = 'connector_developer_settings/feed_configuration/frequency';
138
+ const XML_PATH_CONNECTOR_FEED_USE_HTTPS = 'connector_developer_settings/feed_configuration/use_https';
139
+
140
+
141
+ /**
142
+ * Automation studio.
143
+ */
144
+ const XML_PATH_CONNECTOR_AUTOMATION_STUDIO_CUSTOMER = 'connector_automation_studio/automation/customer_automation';
145
+ const XML_PATH_CONNECTOR_AUTOMATION_STUDIO_SUBSCRIBER = 'connector_automation_studio/automation/subscriber_automation';
146
+ const XML_PATH_CONNECTOR_AUTOMATION_STUDIO_ORDER = 'connector_automation_studio/automation/order_automation';
147
+ const XML_PATH_CONNECTOR_AUTOMATION_STUDIO_GUEST_ORDER = 'connector_automation_studio/automation/guest_order_automation';
148
+ const XML_PATH_CONNECTOR_AUTOMATION_STUDIO_REVIEW = 'connector_automation_studio/automation/review_automation';
149
+ CONST XML_PATH_CONNECTOR_AUTOMATION_STUDIO_WISHLIST = 'connector_automation_studio/automation/wishlist_automation';
150
+
151
+
152
+ /**
153
+ * ROI SECTION.
154
+ */
155
+ const XML_PATH_CONNECTOR_ROI_TRACKING_ENABLED = 'connector_roi_tracking/roi_tracking/enabled';
156
+ const XML_PATH_CONNECTOR_PAGE_TRACKING_ENABLED = 'connector_roi_tracking/page_tracking/enabled';
157
+
158
+ /**
159
+ * OAUTH
160
+ */
161
+ const API_CONNECTOR_URL_AUTHORISE = 'https://my.dotmailer.com/OAuth2/authorise.aspx?';
162
+ const API_CONNECTOR_URL_TOKEN = 'https://my.dotmailer.com/OAuth2/Tokens.ashx';
163
+ const API_CONNECTOR_URL_LOG_USER = 'https://my.dotmailer.com/?oauthtoken=';
164
+
165
+ /**
166
+ * Email Config.
167
+ */
168
+ const CONNECTOR_EMAIL_CONFIG_LAST_RUN = 'connector_api_last_call';
169
+ const CONNECTOR_EMAIL_CONFIG_HOUR_TRIGGER = 'connector_api_hour_trigger';
170
+ const CONNECTOR_FEED_LAST_CHECK_TIME = 'connector_feed_last_check_time';
171
+
172
+
173
+ /**
174
+ * Transactional Emails.
175
+ */
176
+ const XML_PATH_TRANSACTIONAL_API_ENABLED = 'connector_transactional_emails/credentials/enabled';
177
+
178
+ /**
179
+ * Reviews
180
+ */
181
+ const XML_PATH_REVIEWS_ENABLED = 'connector_reviews/settings/enabled';
182
+
183
+ /**
184
+ * Nosto
185
+ */
186
+ const API_ENDPOINT = 'https://api.nosto.com';
187
+ const API_ENDPOINT_TEST = 'https://test.api.nosto.com';
188
+
189
+
190
+ }
app/code/community/Dotdigitalgroup/Email/Helper/Data.php ADDED
@@ -0,0 +1,512 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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->getRaygunClient()->Send('Authentication failed with code :' . $authRequest);
34
+ throw new Exception('Authentication failed : ' . $authRequest);
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 getLastQuoteId()
61
+ {
62
+ return Mage::getStoreConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_MAPPING_LAST_QUOTE_ID);
63
+
64
+ }
65
+
66
+ public function log($data, $level = Zend_Log::DEBUG, $filename = 'api.log')
67
+ {
68
+ if ($this->getDebugEnabled()) {
69
+ $filename = 'connector_' . $filename;
70
+
71
+ Mage::log($data, $level, $filename, $force = true);
72
+ }
73
+ }
74
+
75
+ public function getDebugEnabled()
76
+ {
77
+ return (bool) Mage::getStoreConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_ADVANCED_DEBUG_ENABLED);
78
+ }
79
+
80
+ public function getConnectorVersion()
81
+ {
82
+ $modules = (array) Mage::getConfig()->getNode('modules')->children();
83
+ if (isset($modules['Dotdigitalgroup_Email'])) {
84
+ $moduleName = $modules['Dotdigitalgroup_Email'];
85
+ return $moduleName->version;
86
+ }
87
+ return '';
88
+ }
89
+
90
+
91
+ public function getPageTrackingEnabled()
92
+ {
93
+ return (bool)Mage::getStoreConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_PAGE_TRACKING_ENABLED);
94
+ }
95
+
96
+ public function getRoiTrackingEnabled()
97
+ {
98
+ return (bool)Mage::getStoreConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_ROI_TRACKING_ENABLED);
99
+ }
100
+
101
+ public function getResourceAllocationEnabled()
102
+ {
103
+ return (bool)Mage::getStoreConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_RESOURCE_ALLOCATION);
104
+ }
105
+
106
+ public function getMappedStoreName($website)
107
+ {
108
+ $mapped = $website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_MAPPING_CUSTOMER_STORENAME);
109
+ $storeName = ($mapped)? $mapped : '';
110
+ return $storeName;
111
+ }
112
+
113
+ /**
114
+ * Get the contact id for the custoemer based on website id.
115
+ * @param $email
116
+ * @param $websiteId
117
+ *
118
+ * @return bool
119
+ */
120
+ public function getContactId($email, $websiteId)
121
+ {
122
+ $client = $this->getWebsiteApiClient($websiteId);
123
+ $response = $client->postContacts($email);
124
+
125
+ if (isset($response->message))
126
+ return $response->message;
127
+
128
+ return $response->id;
129
+ }
130
+
131
+ public function getCustomerAddressBook($website)
132
+ {
133
+ $website = Mage::app()->getWebsite($website);
134
+ return $website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMERS_ADDRESS_BOOK_ID);
135
+ }
136
+
137
+ public function getSubscriberAddressBook($website)
138
+ {
139
+ $website = Mage::app()->getWebsite($website);
140
+ return $website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_SUBSCRIBERS_ADDRESS_BOOK_ID);
141
+ }
142
+
143
+ public function getGuestAddressBook($website)
144
+ {
145
+ $website = Mage::app()->getWebsite($website);
146
+ return $website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_GUEST_ADDRESS_BOOK_ID);
147
+ }
148
+
149
+ /**
150
+ * @return $this
151
+ */
152
+ public function allowResourceFullExecution()
153
+ {
154
+ if ($this->getResourceAllocationEnabled()) {
155
+
156
+ /* it may be needed to set maximum execution time of the script to longer,
157
+ * like 60 minutes than usual */
158
+ set_time_limit(7200);
159
+
160
+ /* and memory to 512 megabytes */
161
+ ini_set('memory_limit', '512M');
162
+ }
163
+ return $this;
164
+ }
165
+ public function convert($size)
166
+ {
167
+ $unit=array('b','kb','mb','gb','tb','pb');
168
+ return @round($size/pow(1024,($i=floor(log($size,1024)))),2).' '.$unit[$i];
169
+ }
170
+
171
+ /**
172
+ * @return string
173
+ */
174
+ public function getStringWebsiteApiAccounts()
175
+ {
176
+ $accounts = array();
177
+ foreach (Mage::app()->getWebsites() as $website) {
178
+ $websiteId = $website->getId();
179
+ $apiUsername = $this->getApiUsername($website);
180
+ $accounts[$apiUsername] = $apiUsername . ', websiteId: ' . $websiteId . ' name ' . $website->getName();
181
+ }
182
+ return implode('</br>', $accounts);
183
+ }
184
+
185
+ public function getCustomAttributes($website = 0)
186
+ {
187
+ $website = Mage::app()->getWebsite($website);
188
+ return unserialize($website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_MAPPING_CUSTOM_DATAFIELDS));
189
+ }
190
+
191
+ /**
192
+ * @param $path
193
+ * @param null|string|bool|int|Mage_Core_Model_Website $websiteId
194
+ * @return mixed
195
+ */
196
+ public function getWebsiteConfig($path, $websiteId = 0)
197
+ {
198
+ $website = Mage::app()->getWebsite($websiteId);
199
+ return $website->getConfig($path);
200
+ }
201
+
202
+ /**
203
+ * Api client by website.
204
+ *
205
+ * @param int $website
206
+ *
207
+ * @return bool|Dotdigitalgroup_Email_Model_Apiconnector_Client
208
+ */
209
+ public function getWebsiteApiClient($website = 0)
210
+ {
211
+ if (! $apiUsername = $this->getApiUsername($website) || ! $apiPassword = $this->getApiPassword($website))
212
+ return false;
213
+
214
+ $client = Mage::getModel('email_connector/apiconnector_client');
215
+ $client->setApiUsername($this->getApiUsername($website))
216
+ ->setApiPassword($this->getApiPassword($website));
217
+
218
+ return $client;
219
+ }
220
+
221
+ /**
222
+ * Retrieve authorisation code.
223
+ */
224
+ public function getCode()
225
+ {
226
+ $adminUser = Mage::getSingleton('admin/session')->getUser();
227
+ $code = $adminUser->getEmailCode();
228
+
229
+ return $code;
230
+ }
231
+
232
+ /**
233
+ * Autorisation url.
234
+ * @return string
235
+ */
236
+ public function getAuthoriseUrl()
237
+ {
238
+ $clientId = Mage::getStoreConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CLIENT_ID);
239
+ $baseUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB, true);
240
+ $callback = $baseUrl . 'connector/email/callback';
241
+ $adminUser = Mage::getSingleton('admin/session')->getUser();
242
+
243
+ //query params
244
+ $params = array(
245
+ 'redirect_uri' => $callback,
246
+ 'scope' => 'Account',
247
+ 'state' => $adminUser->getId(),
248
+ 'response_type' => 'code'
249
+ );
250
+ $url = Dotdigitalgroup_Email_Helper_Config::API_CONNECTOR_URL_AUTHORISE . http_build_query($params) . '&client_id=' . $clientId;
251
+
252
+ return $url;
253
+ }
254
+
255
+ /**
256
+ * order status config value
257
+ * @param int $website
258
+ * @return mixed order status
259
+ */
260
+ public function getConfigSelectedStatus($website = 0)
261
+ {
262
+ $status = $this->getWebsiteConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_SYNC_ORDER_STATUS, $website);
263
+ if($status)
264
+ return explode(',',$status);
265
+ else
266
+ return false;
267
+ }
268
+
269
+ public function getConfigSelectedCustomOrderAttributes($website = 0)
270
+ {
271
+ $customAttributes = $this->getWebsiteConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOM_ORDER_ATTRIBUTES, $website);
272
+ if($customAttributes)
273
+ return explode(',',$customAttributes);
274
+ else
275
+ return false;
276
+ }
277
+
278
+ /**
279
+ * check sweet tooth installed/active status
280
+ * @return boolean
281
+ */
282
+ public function isSweetToothEnabled()
283
+ {
284
+ return (bool)Mage::getConfig()->getModuleConfig('TBT_Rewards')->is('active', 'true');
285
+ }
286
+
287
+ /**
288
+ * check sweet tooth installed/active status and active status
289
+ * @param Mage_Core_Model_Website $website
290
+ * @return boolean
291
+ */
292
+ public function isSweetToothToGo($website)
293
+ {
294
+ $stMappingStatus = $this->getWebsiteConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_MAPPING_SWEETTOOTH_ACTIVE, $website);
295
+ if($stMappingStatus && $this->isSweetToothEnabled()) return true;
296
+ return false;
297
+ }
298
+
299
+ public function setConnectorContactToReImport($customerId)
300
+ {
301
+ $contactModel = Mage::getModel('email_connector/contact');
302
+ $contactModel
303
+ ->loadByCustomerId($customerId)
304
+ ->setEmailImported(Dotdigitalgroup_Email_Model_Contact::EMAIL_CONTACT_NOT_IMPORTED)
305
+ ->save();
306
+ }
307
+
308
+ /**
309
+ * Diff between to times;
310
+ *
311
+ * @param $time1
312
+ * @param $time2
313
+ * @return int
314
+ */
315
+ public function dateDiff($time1, $time2=NULL) {
316
+ if (is_null($time2)) {
317
+ $time2 = Mage::getModel('core/date')->date();
318
+ }
319
+ $time1 = strtotime($time1);
320
+ $time2 = strtotime($time2);
321
+ return $time2 - $time1;
322
+ }
323
+
324
+
325
+ /**
326
+ * Disable website config when the request is made admin area only!
327
+ * @param $path
328
+ *
329
+ * @throws Mage_Core_Exception
330
+ */
331
+ public function disableConfigForWebsite($path)
332
+ {
333
+ $scopeId = 0;
334
+ if ($website = Mage::app()->getRequest()->getParam('website')) {
335
+ $scope = 'websites';
336
+ $scopeId = Mage::app()->getWebsite($website)->getId();
337
+ } else {
338
+ $scope = "default";
339
+ }
340
+ $config = Mage::getConfig();
341
+ $config->saveConfig($path, 0, $scope, $scopeId);
342
+ $config->cleanCache();
343
+ }
344
+
345
+ /**
346
+ * number of customers with duplicate emails, emails as total number
347
+ * @return Mage_Customer_Model_Resource_Customer_Collection
348
+ */
349
+ public function getCustomersWithDuplicateEmails( ) {
350
+ $customers = Mage::getModel('customer/customer')->getCollection();
351
+
352
+ //duplicate emails
353
+ $customers->getSelect()
354
+ ->columns(array('emails' => 'COUNT(e.entity_id)'))
355
+ ->group('email')
356
+ ->having('emails > ?', 1);
357
+
358
+ return $customers;
359
+ }
360
+
361
+ /**
362
+ * Create new raygun client.
363
+ *
364
+ * @return bool|\Raygun4php\RaygunClient
365
+ */
366
+ public function getRaygunClient()
367
+ {
368
+ $code = Mage::getstoreConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_RAYGUN_APPLICATION_CODE);
369
+
370
+ if ($this->raygunEnabled()) {
371
+ require_once Mage::getBaseDir('lib') . DS . 'Raygun4php' . DS . 'RaygunClient.php';
372
+ return new Raygun4php\RaygunClient($code, false, true);
373
+ }
374
+
375
+ return false;
376
+ }
377
+
378
+ /**
379
+ * Raygun logs.
380
+ * @param int $errno
381
+ * @param $message
382
+ * @param string $filename
383
+ * @param int $line
384
+ * @param array $tags
385
+ *
386
+ * @return int|null
387
+ */
388
+ public function rayLog($errno = 100, $message, $filename = 'helper/data.php', $line = 1, $tags = array())
389
+ {
390
+ $client = $this->getRaygunClient();
391
+ if ($client) {
392
+ //use tags to log the client baseurl
393
+ if (empty($tags))
394
+ $tags = array(Mage::getBaseUrl('web'));
395
+ //send message
396
+ $code = $client->SendError( $errno, $message, $filename, $line, $tags );
397
+
398
+ return $code;
399
+ }
400
+
401
+ return false;
402
+ }
403
+
404
+
405
+ /**
406
+ * check for raygun application and if enabled.
407
+ * @param int $websiteId
408
+ *
409
+ * @return mixed
410
+ * @throws Mage_Core_Exception
411
+ */
412
+ public function raygunEnabled($websiteId = 0)
413
+ {
414
+ $website = Mage::app()->getWebsite($websiteId);
415
+
416
+ return (bool)$website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_RAYGUN_APPLICATION_CODE);
417
+
418
+ }
419
+
420
+
421
+ /**
422
+ * Create new config if the config was not found.
423
+ * mark the account api datafields was created
424
+ * @param $value
425
+ * @param string $scope
426
+ *
427
+ * @return bool
428
+ */
429
+ public function isConfigCreatedForPath( $value, $scope = 'default' )
430
+ {
431
+ $configModel = Mage::getModel('email_connector/config');
432
+
433
+ //we use path as the transactional usename config value
434
+ $path = Dotdigitalgroup_Email_Helper_Transactional::XML_PATH_TRANSACTIONAL_API_USERNAME;
435
+
436
+ $itemConfig = $configModel->getCollection()
437
+ ->addFieldToFilter('path', $path)
438
+ ->addFieldToFilter('value', $value)
439
+ ->addFieldToFilter('scope', $scope)
440
+ ->getFirstItem();
441
+
442
+ //config was created
443
+ if ($itemConfig->getId()) {
444
+ return true;
445
+ }
446
+
447
+ //new config save data
448
+ $itemConfig->setPath($path)
449
+ ->setScope($scope)
450
+ ->setValue($value)
451
+ ->save();
452
+ return false;
453
+ }
454
+
455
+ /**
456
+ * Generate the baseurl for the default store
457
+ * dynamic content will be displayed
458
+ * @return string
459
+ * @throws Mage_Core_Exception
460
+ */
461
+ public function generateDynamicUrl()
462
+ {
463
+ $website = Mage::app()->getRequest()->getParam('website', false);
464
+
465
+ //set website url for the default store id
466
+ $website = ($website)? Mage::app()->getWebsite( $website ) : 0;
467
+
468
+ $defaultGroup = Mage::app()->getWebsite($website)
469
+ ->getDefaultGroup();
470
+
471
+ if (! $defaultGroup)
472
+ return $mage = Mage::app()->getStore()->getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
473
+
474
+ //base url
475
+ $baseUrl = Mage::app()->getStore($defaultGroup->getDefaultStore())->getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK);
476
+
477
+ return $baseUrl;
478
+
479
+ }
480
+
481
+ /**
482
+ *
483
+ *
484
+ * @param int $store
485
+ * @return mixed
486
+ */
487
+ public function isNewsletterSuccessDisabled($store = 0)
488
+ {
489
+ return Mage::getStoreConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_DISABLE_NEWSLETTER_SUCCESS, $store);
490
+ }
491
+
492
+ /**
493
+ * get sales_flat_order table description
494
+ *
495
+ * @return array
496
+ */
497
+ public function getOrderTableDescription()
498
+ {
499
+ $resource = Mage::getSingleton('core/resource');
500
+ $readConnection = $resource->getConnection('core_read');
501
+ $salesTable = $resource->getTableName('sales/order');
502
+ return $readConnection->describeTable($salesTable);
503
+ }
504
+
505
+ /**
506
+ * @return bool
507
+ */
508
+ public function getEasyEmailCapture()
509
+ {
510
+ return Mage::getStoreConfigFlag(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_EMAIL_CAPTURE);
511
+ }
512
+ }
app/code/{local → community}/Dotdigitalgroup/Email/Helper/File.php RENAMED
@@ -1,10 +1,10 @@
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
 
 
 
8
  /**
9
  * Location of files we are building
10
  */
@@ -15,8 +15,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 +25,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 +71,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 +92,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 +112,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 +123,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 +136,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 +160,49 @@ 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
 
6
+ const FILE_FULL_ACCESS_PERMISSION = '777';
7
+
8
  /**
9
  * Location of files we are building
10
  */
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
  } // end
26
 
27
 
28
+ public function getOutputFolder()
29
+ {
30
  $this->pathExists($this->_output_folder);
31
  return $this->_output_folder;
32
  } // end
33
 
34
+ public function getArchiveFolder()
35
+ {
36
  $this->pathExists($this->_output_archive_folder);
37
  return $this->_output_archive_folder;
38
  } // end
39
 
40
  /* Return the full filepath */
41
+ public function getFilePath($filename)
42
+ {
43
  return $this->getOutputFolder() . DS . $filename;
44
  }
45
 
46
+ public function archiveCSV($filename)
47
+ {
48
  $this->moveFile($this->getOutputFolder(), $this->getArchiveFolder(), $filename);
49
  }
50
 
51
  /**
52
  * Moves the output file from one folder to the next
53
+ * @param $source_folder
54
+ * @param $dest_folder
55
+ * @param $filename
56
  */
57
+ public function moveFile($source_folder, $dest_folder, $filename )
58
+ {
59
  // generate the full file paths
60
  $source_filepath = $source_folder . DS . $filename;
61
  $dest_filepath = $dest_folder . DS . $filename;
71
  * @param $filepath
72
  * @param $csv
73
  */
74
+ public function outputForceQuotesCSV($filepath, $csv)
75
+ {
76
  $fqCsv = $this->arrayToCsv($csv,chr(9),'"',true,false);
77
  // Open for writing only; place the file pointer at the end of the file. If the file does not exist, attempt to create it.
78
  $fp = fopen($filepath, "a");
79
 
80
  // for some reason passing the preset delimiter/enclosure variables results in error
81
+ // $this->delimiter $this->enclosure
82
+ if (fwrite($fp, $fqCsv) == 0 ) {
83
  Mage::throwException('Problem writing CSV file');
84
  }
85
  fclose($fp);
92
  * @param $filepath
93
  * @param $csv
94
  */
95
+ public function outputCSV($filepath, $csv)
96
+ {
97
  // Open for writing only; place the file pointer at the end of the file. If the file does not exist, attempt to create it.
98
  $handle = fopen($filepath, "a");
99
 
100
  // for some reason passing the preset delimiter/enclosure variables results in error
101
+ //$this->delimiter $this->enclosure
102
+ if (fputcsv($handle, $csv, ',', '"') == 0 ) {
103
  Mage::throwException('Problem writing CSV file');
104
  }
105
 
112
  * If the path does not exist then create it
113
  * @param string $path
114
  */
115
+ public function pathExists($path)
116
+ {
117
+ if (!is_dir($path)) {
118
  mkdir($path, 0777, true);
119
  } // end
120
 
123
  } // end
124
 
125
 
126
+ protected function arrayToCsv( array &$fields, $delimiter, $enclosure, $encloseAll = false, $nullToMysqlNull = false )
127
+ {
128
  $delimiter_esc = preg_quote($delimiter, '/');
129
  $enclosure_esc = preg_quote($enclosure, '/');
130
 
136
  }
137
 
138
  // Enclose fields containing $delimiter, $enclosure or whitespace
139
+ if ($encloseAll || preg_match( "/(?:${delimiter_esc}|${enclosure_esc}|\s)/", $field )) {
140
  $output[] = $enclosure . str_replace($enclosure, $enclosure . $enclosure, $field) . $enclosure;
141
+ } else {
 
142
  $output[] = $field;
143
  }
144
  }
160
  }
161
 
162
 
163
+ public function getWebsiteCustomerMappingDatafields($website)
164
+ {
165
+ $store = $website->getDefaultStore();
166
+ $mappedData = Mage::getStoreConfig('connector_data_mapping/customer_data', $store);
167
+ unset($mappedData['custom_attributes']);
168
+
169
+ $mappedRewardData = $this->getWebsiteCustomerRewardMappingDatafields($website);
170
+ if($mappedRewardData) $mappedData = array_merge($mappedData, $mappedRewardData);
171
+
172
+ foreach ($mappedData as $key => $value) {
173
+ if (! $value)
174
+ unset($mappedData[$key]);
175
+ }
176
+
177
+ return $mappedData;
178
+ }
179
+
180
+ public function getWebsiteCustomerRewardMappingDatafields($website)
181
+ {
182
+ $helper = Mage::helper('connector');
183
+ if($helper->isSweetToothToGo($website)) {
184
+ $store = $website->getDefaultStore();
185
+ $mappedData = Mage::getStoreConfig('connector_data_mapping/sweet_tooth', $store);
186
+ unset($mappedData['active']);
187
+ return $mappedData;
188
+ }
189
+ return false;
190
+ }
191
+
192
+ /**
193
+ * @param $path
194
+ *
195
+ * @return bool
196
+ */
197
+ public function getPathPermission($path) {
198
+
199
+ //check for directory created before looking into permission
200
+ if (is_dir($path)) {
201
+ clearstatcache( null, $path );
202
+
203
+ return decoct( fileperms( $path ) & 0777 );
204
+ }
205
+ //the file is not created and return the passing value
206
+ return 755;
207
+ }
208
  }
app/code/community/Dotdigitalgroup/Email/Helper/Recommended.php ADDED
@@ -0,0 +1,178 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ *
105
+ * @return int|mixed
106
+ */
107
+ public function getDisplayLimitByMode($mode)
108
+ {
109
+ $result = 0;
110
+
111
+ switch($mode){
112
+ case 'related':
113
+ $result = Mage::getStoreConfig(self::XML_PATH_RELATED_PRODUCTS_ITEMS);
114
+ break;
115
+ case 'upsell':
116
+ $result = Mage::getStoreConfig(self::XML_PATH_UPSELL_PRODUCTS_ITEMS);
117
+ break;
118
+ case 'crosssell':
119
+ $result = Mage::getStoreConfig(self::XML_PATH_CROSSSELL_PRODUCTS_ITEMS);
120
+ break;
121
+ case 'bestsellers':
122
+ $result = Mage::getStoreConfig(self::XML_PATH_BESTSELLER_PRODUCT_ITEMS);
123
+ break;
124
+ case 'mostviewed':
125
+ $result = Mage::getStoreConfig(self::XML_PATH_MOSTVIEWED_PRODUCT_ITEMS);
126
+ break;
127
+ case 'recentlyviewed':
128
+ $result = Mage::getStoreConfig(self::XML_PATH_RECENTLYVIEWED_PRODUCT_ITEMS);
129
+ break;
130
+ case 'push':
131
+ $result = Mage::getStoreConfig(self::XML_PATH_PRODUCTPUSH_DISPLAY_ITEMS);
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 = '';
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
+ }elseif($config == 'recentlyviewed')
154
+ $period = Mage::getStoreConfig(self::XML_PATH_MOSTVIEWED_TIME_PERIOD);
155
+
156
+ if ($period == 'week') {
157
+ $sub = Zend_Date::WEEK;
158
+ } elseif ($period == 'month' || $period == 'M') {
159
+ $sub = Zend_Date::MONTH;
160
+ } elseif ($period == 'year') {
161
+ $sub = Zend_Date::YEAR;
162
+ }
163
+
164
+ if (isset($sub)) {
165
+ $period = $now->sub(1, $sub);
166
+
167
+ return $period->tostring(Zend_Date::ISO_8601);
168
+ }
169
+ }
170
+
171
+ public function getProductPushIds()
172
+ {
173
+ $productIds = Mage::getStoreConfig(self::XML_PATH_PRODUCTPUSH_ITEMS);
174
+
175
+ return explode(',', $productIds);
176
+ }
177
+
178
+ }
app/code/community/Dotdigitalgroup/Email/Helper/Review.php ADDED
@@ -0,0 +1,90 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dotdigitalgroup_Email_Helper_Review extends Mage_Core_Helper_Abstract
4
+ {
5
+ /**
6
+ * configs
7
+ */
8
+ const XML_PATH_REVIEW_STATUS = 'connector_reviews/settings/status';
9
+ const XML_PATH_REVIEW_DELAY = 'connector_reviews/settings/delay';
10
+ const XML_PATH_REVIEW_NEW_PRODUCT = 'connector_reviews/settings/new_product';
11
+ const XML_PATH_REVIEW_CAMPAIGN = 'connector_reviews/settings/campaign';
12
+ const XML_PATH_REVIEW_ANCHOR = 'connector_reviews/settings/anchor';
13
+ const XML_PATH_REVIEW_DISPLAY_TYPE = 'connector_dynamic_content/products/review_display_type';
14
+
15
+ /**
16
+ * get config value on website level
17
+ *
18
+ * @param $path
19
+ * @param $website
20
+ * @return mixed
21
+ */
22
+ public function getReviewWebsiteSettings($path, $website)
23
+ {
24
+ $helper = Mage::helper('connector');
25
+ return $helper->getWebsiteConfig($path, $website);
26
+ }
27
+
28
+ /**
29
+ * @param $website
30
+ * @return boolean
31
+ */
32
+ public function isEnabled($website)
33
+ {
34
+ return $this->getReviewWebsiteSettings(Dotdigitalgroup_Email_Helper_Config::XML_PATH_REVIEWS_ENABLED, $website);
35
+ }
36
+
37
+ /**
38
+ * @param $website
39
+ * @return string
40
+ */
41
+ public function getOrderStatus($website)
42
+ {
43
+ return $this->getReviewWebsiteSettings(self::XML_PATH_REVIEW_STATUS, $website);
44
+ }
45
+
46
+ /**
47
+ * @param $website
48
+ * @return int
49
+ */
50
+ public function getDelay($website)
51
+ {
52
+ return $this->getReviewWebsiteSettings(self::XML_PATH_REVIEW_DELAY, $website);
53
+ }
54
+
55
+ /**
56
+ * @param $website
57
+ * @return boolean
58
+ */
59
+ public function isNewProductOnly($website)
60
+ {
61
+ return $this->getReviewWebsiteSettings(self::XML_PATH_REVIEW_NEW_PRODUCT, $website);
62
+ }
63
+
64
+ /**
65
+ * @param $website
66
+ * @return int
67
+ */
68
+ public function getCampaign($website)
69
+ {
70
+ return $this->getReviewWebsiteSettings(self::XML_PATH_REVIEW_CAMPAIGN, $website);
71
+ }
72
+
73
+ /**
74
+ * @param $website
75
+ * @return string
76
+ */
77
+ public function getAnchor($website)
78
+ {
79
+ return $this->getReviewWebsiteSettings(self::XML_PATH_REVIEW_ANCHOR, $website);
80
+ }
81
+
82
+ /**
83
+ * @param $website
84
+ * @return string
85
+ */
86
+ public function getDisplayType($website)
87
+ {
88
+ return $this->getReviewWebsiteSettings(self::XML_PATH_REVIEW_DISPLAY_TYPE, $website);
89
+ }
90
+ }
app/code/community/Dotdigitalgroup/Email/Helper/Transactional.php ADDED
@@ -0,0 +1,298 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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_TEMPLATE = 'template';
19
+ const MAP_COLUMN_KEY_SENDTYPE = 'sendtype';
20
+ const MAP_COLUMN_KEY_CAMPAIGN = 'campaign';
21
+ const MAP_COLUMN_KEY_DATAFIELD = 'datafield';
22
+ const MAP_COLUMN_KEY_FROM_ADDRESS = 'fromaddress';
23
+ const MAP_COLUMN_KEY_ATTACHMENT_ID = 'attachmentid';
24
+
25
+ const TRANSACTIONAL_SENDTYPE_SYSTEM_DEFAULT = '0';
26
+ const TRANSACTIONAL_SENDTYPE_VIA_CONNECTOR = '1';
27
+ const TRANSACTIOANL_SNEDTYPE_DESIGN_VIA_CONNECTOR = '2';
28
+
29
+
30
+
31
+ /**
32
+ * Get the api enabled.
33
+ *
34
+ * @return mixed
35
+ */
36
+ public function isEnabled()
37
+ {
38
+ return Mage::getStoreConfigFlag(self::XML_PATH_TRANSACTIONAL_API_ENABLED);
39
+ }
40
+
41
+ /**
42
+ * Get api username.
43
+ *
44
+ * @param mixed $website
45
+ *
46
+ * @return mixed
47
+ * @throws Mage_Core_Exception
48
+ */
49
+ public function getApiUsername($website = 0)
50
+ {
51
+ $website = Mage::app()->getWebsite($website);
52
+
53
+ return $website->getConfig(self::XML_PATH_TRANSACTIONAL_API_USERNAME);
54
+ }
55
+
56
+ /**
57
+ * Get api password.
58
+ *
59
+ * @param mixed $website
60
+ *
61
+ * @return mixed
62
+ * @throws Mage_Core_Exception
63
+ */
64
+ public function getApiPassword($website = 0)
65
+ {
66
+ $website = Mage::app()->getWebsite($website);
67
+
68
+ return $website->getConfig(self::XML_PATH_TRANSACTIONAL_API_PASSWORD);
69
+ }
70
+
71
+ /**
72
+ * Website by name.
73
+ * @param $websiteName
74
+ *
75
+ * @return Varien_Object
76
+ */
77
+ public function getWebsiteByName($websiteName)
78
+ {
79
+ $website = Mage::getModel('core/website')->getCollection()
80
+ ->addFieldToFilter('code', $websiteName)->getFirstItem();
81
+
82
+ return $website;
83
+ }
84
+
85
+ /**
86
+ * Find template lable by id.
87
+ * @param mixed $templateId
88
+ *
89
+ * @return string
90
+ */
91
+ public function getTemplateLabelById($templateId)
92
+ {
93
+ $default = Mage::getModel('email_connector/adminhtml_source_transactional_defaultselect')->toOptionArray();
94
+ $custom = Mage::getModel('email_connector/adminhtml_source_transactional_customselect')->toOptionArray();
95
+ $all = array_merge($default,$custom);
96
+
97
+ $label = "";
98
+ foreach($all as $one){
99
+ if($one['value'] == $templateId) {
100
+ $label = $one['label'];
101
+ break;
102
+ }
103
+ }
104
+ return $label;
105
+ }
106
+
107
+ /**
108
+ * get all templates mapping
109
+ * @param $storeId
110
+ * @return array
111
+ */
112
+ public function getAllTemplateMapping($storeId){
113
+ $allTemplateMapping = array();
114
+
115
+ $defaultTemplateMapping = $this->getDefaultEmailTemplates($storeId);
116
+ $customTemplateMapping = $this->getCustomEmailTemplates($storeId);
117
+
118
+ if(is_array($defaultTemplateMapping) && is_array($customTemplateMapping))
119
+ {
120
+ $allTemplateMapping = array_merge($defaultTemplateMapping, $customTemplateMapping);
121
+ }
122
+ elseif(is_array($defaultTemplateMapping))
123
+ {
124
+ $allTemplateMapping = $defaultTemplateMapping;
125
+ }
126
+ elseif(is_array($customTemplateMapping))
127
+ {
128
+ $allTemplateMapping = $customTemplateMapping;
129
+ }
130
+
131
+ return $allTemplateMapping;
132
+ }
133
+
134
+ /**
135
+ * Transactional emails check for campaign id if it's mapped.
136
+ * Default Emails stored in magento
137
+ *
138
+ * @param $templateId
139
+ * @param $key
140
+ * @param null $storeId
141
+ * @return bool|mixed
142
+ */
143
+ public function getMapping($templateId, $key ,$storeId = null)
144
+ {
145
+ $allTemplateMapping = $this->getAllTemplateMapping($storeId);
146
+ $isMapped = false;
147
+
148
+ foreach($allTemplateMapping as $templateMapping)
149
+ {
150
+ if($isMapped = $this->findTemplateIdInArray($templateId, $templateMapping))
151
+ break;
152
+ }
153
+
154
+ if(is_array($isMapped) && $key == self::MAP_COLUMN_KEY_DATAFIELD)
155
+ return $isMapped[self::MAP_COLUMN_KEY_DATAFIELD];
156
+
157
+ if(is_array($isMapped) && $key == self::MAP_COLUMN_KEY_SENDTYPE)
158
+ return $isMapped[self::MAP_COLUMN_KEY_SENDTYPE];
159
+
160
+ if(is_array($isMapped) && $key == self::MAP_COLUMN_KEY_FROM_ADDRESS)
161
+ return $isMapped[self::MAP_COLUMN_KEY_FROM_ADDRESS];
162
+
163
+ if(is_array($isMapped) && $key == self::MAP_COLUMN_KEY_ATTACHMENT_ID)
164
+ return $isMapped[self::MAP_COLUMN_KEY_ATTACHMENT_ID];
165
+
166
+ return $isMapped;
167
+ }
168
+
169
+ /**
170
+ * find template id in array
171
+ * @param mixed $id
172
+ * @param array $data
173
+ *
174
+ * @return mixed
175
+ */
176
+ public function findTemplateIdInArray($id, $data)
177
+ {
178
+ $result = false;
179
+ foreach($data as $key => $value){
180
+ if($key == 'template' && $value == $id) {
181
+ $result = $data;
182
+ break;
183
+ }
184
+ }
185
+ return $result;
186
+ }
187
+
188
+ /**
189
+ * get un-serialised config value for all default email templates for all modules
190
+ *
191
+ * @return array
192
+ */
193
+ public function getDefaultEmailTemplates($storeId = null)
194
+ {
195
+ return unserialize(Mage::getStoreConfig(self::XML_PATH_CONNECTOR_TRANSACTIONAL_EMAIL_DEFAULT, $storeId));
196
+ }
197
+
198
+ /**
199
+ * get un-serialised config value for custom templates
200
+ *
201
+ * @return array
202
+ */
203
+ public function getCustomEmailTemplates($storeId = null)
204
+ {
205
+ return unserialize(Mage::getStoreConfig(self::XML_PATH_CONNECTOR_TRANSACTIONAL_EMAIL_CUSTOM, $storeId));
206
+ }
207
+
208
+ /**
209
+ * Get the contact id for the custoemer based on website id.
210
+ * @param $email
211
+ * @param $websiteId
212
+ * @return string contact_id
213
+ */
214
+ public function getContactId($email, $websiteId)
215
+ {
216
+ $client = $this->getWebsiteApiClient($websiteId);
217
+ $response = $client->postContacts($email);
218
+ if (isset($response->message))
219
+ return $response->message;
220
+ return $response->id;
221
+ }
222
+
223
+ /**
224
+ * Update contact default datafields.
225
+ *
226
+ * @param $contacData
227
+ */
228
+ public function updateContactData($contacData)
229
+ {
230
+ $client = $this->getWebsiteApiClient($contacData->getWebsite());
231
+ $email = $contacData->getCustomerEmail();
232
+ /**
233
+ * Transactional account data default datafields.
234
+ */
235
+ $data = array(
236
+ array(
237
+ 'Key' => 'LAST_ORDER_ID',
238
+ 'Value' => $contacData->getOrderId()),
239
+ array(
240
+ 'Key' => 'CUSTOMER_ID',
241
+ 'Value' => $contacData->getCustomerId()),
242
+ array(
243
+ 'Key' => 'ORDER_INCREMENT_ID',
244
+ 'Value' => $contacData->getOrderIncrementId()),
245
+ array(
246
+ 'Key' => 'WEBSITE_NAME',
247
+ 'Value' => $contacData->getWebsiteName()),
248
+ array(
249
+ 'Key' => 'STORE_NAME',
250
+ 'Value' => $contacData->getStoreName()),
251
+ array(
252
+ 'Key' => 'LAST_ORDER_DATE',
253
+ 'Value' => $contacData->getOrderDate())
254
+ );
255
+ $client->updateContactDatafieldsByEmail($email, $data);
256
+ }
257
+
258
+ /**
259
+ * Api client by website.
260
+ * @param int $website
261
+ * @return Dotdigitalgroup_Email_Model_Apiconnector_Client
262
+ */
263
+ public function getWebsiteApiClient($website = 0)
264
+ {
265
+ $client = Mage::getModel('email_connector/apiconnector_client');
266
+ $website = Mage::app()->getWebsite($website);
267
+ if ($website) {
268
+ $client->setApiUsername($this->getApiUsername($website))
269
+ ->setApiPassword($this->getApiPassword($website));
270
+ }
271
+ return $client;
272
+ }
273
+
274
+ public function getEmailSettings($path, $websiteId)
275
+ {
276
+ $helper = Mage::helper('connector');
277
+ return $helper->getWebsiteConfig($path, $websiteId);
278
+ }
279
+
280
+ public function getFromAddress($websiteId){
281
+ return $this->getEmailSettings(self::XML_PATH_CONNECTOR_TRANSACTIONAL_FROM_ADDRESS, $websiteId);
282
+ }
283
+
284
+ public function getReplyAction($websiteId){
285
+ return $this->getEmailSettings(self::XML_PATH_CONNECTOR_TRANSACTIONAL_REPLY_ACTION, $websiteId);
286
+ }
287
+
288
+ public function getReplyAddress($websiteId){
289
+ return $this->getEmailSettings(self::XML_PATH_CONNECTOR_TRANSACTIONAL_REPLY_ADDRESS, $websiteId);
290
+ }
291
+
292
+ public function getSendCopy($websiteId){
293
+ return $this->getEmailSettings(self::XML_PATH_CONNECTOR_TRANSACTIONAL_SEND_COPY, $websiteId);
294
+ }
295
+ public function getUnsubscribeLink($websiteId){
296
+ return $this->getEmailSettings(self::XML_PATH_CONNECTOR_TRANSACTIONAL_UNSUBSCRIBE_LINK, $websiteId);
297
+ }
298
+ }
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/Dashboard/Content.php ADDED
@@ -0,0 +1,121 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Class Dotdigitalgroup_Email_Model_Adminhtml_Dashboard_Content
5
+ */
6
+ class Dotdigitalgroup_Email_Model_Adminhtml_Dashboard_Content
7
+ {
8
+
9
+ /**
10
+ * css style that can be used to alert based on result
11
+ * @var
12
+ */
13
+ public $style;
14
+
15
+ /**
16
+ * @return mixed
17
+ */
18
+ public function getTitle() {
19
+ return $this->title;
20
+ }
21
+
22
+ /**
23
+ * @param $title
24
+ *
25
+ * @return $this
26
+ */
27
+ public function setTitle( $title ) {
28
+ $this->title = $title;
29
+ return $this;
30
+ }
31
+
32
+ /**
33
+ * title to be displayed as a key for the status
34
+ * @var
35
+ */
36
+ public $title;
37
+
38
+ /**
39
+ * message to be displayd in the body
40
+ * @var
41
+ */
42
+ public $message;
43
+
44
+ /**
45
+ * how to fix message
46
+ * @var
47
+ */
48
+ public $howto = array();
49
+
50
+ /**
51
+ * @return mixed
52
+ */
53
+
54
+ /**
55
+ * table data
56
+ * @var
57
+ */
58
+ public $table = array();
59
+
60
+ public function getHowto() {
61
+ return $this->howto;
62
+ }
63
+
64
+ /**
65
+ * @param $howto
66
+ *
67
+ * @return $this
68
+ */
69
+ public function setHowto( $howto ) {
70
+ $this->howto[] = $howto;
71
+ return $this;
72
+ }
73
+
74
+ /**
75
+ * @return mixed
76
+ */
77
+ public function getMessage() {
78
+ return $this->message;
79
+ }
80
+
81
+ /**
82
+ * @param $message
83
+ *
84
+ * @return $this
85
+ */
86
+ public function setMessage( $message ) {
87
+ $this->message = $message;
88
+ return $this;
89
+ }
90
+
91
+ /**
92
+ * @return mixed
93
+ */
94
+ public function getStyle() {
95
+ return $this->style;
96
+ }
97
+
98
+ /**
99
+ * @param $style
100
+ *
101
+ * @return $this
102
+ */
103
+ public function setStyle( $style ) {
104
+ $this->style = $style;
105
+ return $this;
106
+ }
107
+
108
+ public function setTable($table)
109
+ {
110
+ $this->table[] = $table;
111
+ return $this;
112
+ }
113
+
114
+ public function getTable() {
115
+ return $this->table;
116
+ }
117
+
118
+
119
+
120
+
121
+ }
app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Dashboard/Tabs/Analysis/Abandoned.php ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dotdigitalgroup_Email_Model_Adminhtml_Dashboard_Tabs_Analysis_Abandoned extends Mage_Core_Model_Abstract
4
+ {
5
+ protected $storeIds;
6
+
7
+ /**
8
+ * prepare collection and needed columns
9
+ *
10
+ * @return Mage_Sales_Model_Resource_Quote_Collection
11
+ */
12
+ protected function getPreparedCollection()
13
+ {
14
+ $collection = Mage::getResourceModel('sales/quote_collection');
15
+ $collection
16
+ ->addFieldToFilter('items_count', array('neq' => '0'))
17
+ ->addFieldToFilter('main_table.is_active', '1')
18
+ ->setOrder('updated_at');
19
+
20
+ if (is_array($this->storeIds) && !empty($this->storeIds)) {
21
+ $collection->addFieldToFilter('store_id', array('in' => $this->storeIds));
22
+ }
23
+
24
+ $adapter = $collection->getConnection();
25
+ $averageExpr = $adapter->getCheckSql(
26
+ 'COUNT(main_table.entity_id) > 0',
27
+ 'SUM(main_table.subtotal)/COUNT(main_table.entity_id)',
28
+ 0);
29
+
30
+ $collection->getSelect()->columns(array(
31
+ 'lifetime' => 'SUM(main_table.subtotal)',
32
+ 'average' => $averageExpr,
33
+ 'total_count' => "COUNT(main_table.entity_id)",
34
+ 'day_count' => "ROUND(COUNT(main_table.entity_id) / DATEDIFF(date(MAX(main_table.updated_at)) , date(MIN(main_table.updated_at))), 2)"
35
+ ));
36
+ return $collection;
37
+ }
38
+
39
+ /**
40
+ * @param int $store
41
+ * @param int $website
42
+ * @param int $group
43
+ * @return Varien_Object
44
+ * @throws Mage_Core_Exception
45
+ */
46
+ public function getLifeTimeAbandoned($store = 0, $website = 0, $group =0)
47
+ {
48
+ if ($store) {
49
+ $this->storeIds = array($store => $store);
50
+ } else if ($website){
51
+ $storeIds = Mage::app()->getWebsite($website)->getStoreIds();
52
+ $this->storeIds = $storeIds;
53
+ } else if ($group){
54
+ $storeIds = Mage::app()->getGroup($group)->getStoreIds();
55
+ $this->storeIds = $storeIds;
56
+ }
57
+ return $this->getPreparedCollection()->getFirstItem();
58
+ }
59
+ }
app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Dashboard/Tabs/Analysis/Customer.php ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dotdigitalgroup_Email_Model_Adminhtml_Dashboard_Tabs_Analysis_Customer extends Mage_Core_Model_Abstract
4
+ {
5
+ protected $storeIds;
6
+
7
+ /**
8
+ * prepare collection and needed columns
9
+ *
10
+ * @return Mage_Customer_Model_Resource_Customer_Collection
11
+ */
12
+ protected function getPreparedCollection()
13
+ {
14
+ $collection = Mage::getResourceModel('customer/customer_collection');
15
+
16
+ if (is_array($this->storeIds) && !empty($this->storeIds)) {
17
+ $collection->addAttributeToFilter('store_id', array('in' => $this->storeIds));
18
+ }
19
+
20
+ $collection->getSelect()->columns(array(
21
+ 'total_count' => "COUNT(*)",
22
+ 'day_count' => "ROUND(COUNT(*) / DATEDIFF(date(MAX(created_at)) , date(MIN(created_at))), 2)"
23
+ ));
24
+
25
+ return $collection;
26
+ }
27
+
28
+ /**
29
+ * @param int $store
30
+ * @param int $website
31
+ * @param int $group
32
+ * @return Varien_Object
33
+ * @throws Mage_Core_Exception
34
+ */
35
+ public function getLifeTimeTimeCustomer($store = 0, $website = 0, $group =0)
36
+ {
37
+ if ($store) {
38
+ $this->storeIds = array($store => $store);
39
+ } else if ($website){
40
+ $storeIds = Mage::app()->getWebsite($website)->getStoreIds();
41
+ $this->storeIds = $storeIds;
42
+ } else if ($group){
43
+ $storeIds = Mage::app()->getGroup($group)->getStoreIds();
44
+ $this->storeIds = $storeIds;
45
+ }
46
+ return $this->getPreparedCollection()->getFirstItem();
47
+ }
48
+ }
app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Dashboard/Tabs/Analysis/Orders.php ADDED
@@ -0,0 +1,122 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dotdigitalgroup_Email_Model_Adminhtml_Dashboard_Tabs_Analysis_Orders extends Mage_Core_Model_Abstract
4
+ {
5
+ /**
6
+ * calculate sales and prepare columns
7
+ *
8
+ * @param int $isFilter
9
+ * @return Mage_Reports_Model_Resource_Order_Collection
10
+ */
11
+ protected function calculateSales($isFilter = 0)
12
+ {
13
+ $collection = Mage::getResourceModel('reports/order_collection');
14
+
15
+ $statuses = Mage::getSingleton('sales/config')
16
+ ->getOrderStatusesForState(Mage_Sales_Model_Order::STATE_CANCELED);
17
+
18
+ if (empty($statuses)) {
19
+ $statuses = array(0);
20
+ }
21
+ $adapter = $collection->getConnection();
22
+
23
+ if (Mage::getStoreConfig('sales/dashboard/use_aggregated_data')) {
24
+ $collection->setMainTable('sales/order_aggregated_created');
25
+ $collection->removeAllFieldsFromSelect();
26
+ $averageExpr = $adapter->getCheckSql(
27
+ 'SUM(main_table.orders_count) > 0',
28
+ 'SUM(main_table.total_revenue_amount)/SUM(main_table.orders_count)',
29
+ 0);
30
+ $collection->getSelect()->columns(array(
31
+ 'lifetime' => 'SUM(main_table.total_revenue_amount)',
32
+ 'average' => $averageExpr,
33
+ 'total_count' => "SUM(main_table.orders_count)",
34
+ 'day_count' => "ROUND(SUM(main_table.orders_count) / DATEDIFF(date(MAX(period)) , date(MIN(period))), 2)"
35
+ ));
36
+
37
+ if (!$isFilter) {
38
+ $collection->addFieldToFilter('store_id',
39
+ array('eq' => Mage::app()->getStore(Mage_Core_Model_Store::ADMIN_CODE)->getId())
40
+ );
41
+ }
42
+ $collection->getSelect()->where('main_table.order_status NOT IN(?)', $statuses);
43
+ } else {
44
+ $collection->setMainTable('sales/order');
45
+ $collection->removeAllFieldsFromSelect();
46
+
47
+ $expr = $this->_getSalesAmountExpression($collection);
48
+
49
+ if ($isFilter == 0) {
50
+ $expr = '(' . $expr . ') * main_table.base_to_global_rate';
51
+ }
52
+
53
+ $collection->getSelect()
54
+ ->columns(array(
55
+ 'lifetime' => "SUM({$expr})",
56
+ 'average' => "AVG({$expr})",
57
+ 'total_count' => "COUNT({$expr})",
58
+ 'day_count' => "ROUND(COUNT({$expr}) / DATEDIFF(date(MAX(created_at)) , date(MIN(created_at))), 2)"
59
+ ))
60
+ ->where('main_table.status NOT IN(?)', $statuses)
61
+ ->where('main_table.state NOT IN(?)', array(
62
+ Mage_Sales_Model_Order::STATE_NEW,
63
+ Mage_Sales_Model_Order::STATE_PENDING_PAYMENT)
64
+ );
65
+ }
66
+ return $collection;
67
+ }
68
+
69
+ /**
70
+ * get sales amount expression
71
+ *
72
+ * @param $collection
73
+ * @return string
74
+ */
75
+ protected function _getSalesAmountExpression($collection)
76
+ {
77
+ $adapter = $collection->getConnection();
78
+ $expressionTransferObject = new Varien_Object(array(
79
+ 'expression' => '%s - %s - %s - (%s - %s - %s)',
80
+ 'arguments' => array(
81
+ $adapter->getIfNullSql('main_table.base_total_invoiced', 0),
82
+ $adapter->getIfNullSql('main_table.base_tax_invoiced', 0),
83
+ $adapter->getIfNullSql('main_table.base_shipping_invoiced', 0),
84
+ $adapter->getIfNullSql('main_table.base_total_refunded', 0),
85
+ $adapter->getIfNullSql('main_table.base_tax_refunded', 0),
86
+ $adapter->getIfNullSql('main_table.base_shipping_refunded', 0),
87
+ )
88
+ ));
89
+
90
+ return vsprintf(
91
+ $expressionTransferObject->getExpression(),
92
+ $expressionTransferObject->getArguments()
93
+ );
94
+
95
+ }
96
+
97
+ /**
98
+ * @param int $store
99
+ * @param int $website
100
+ * @param int $group
101
+ * @return Varien_Object
102
+ * @throws Mage_Core_Exception
103
+ */
104
+ public function getLifetimeSales($store = 0, $website = 0, $group =0)
105
+ {
106
+ $isFilter = $store || $website || $group;
107
+ $collection = $this->calculateSales($isFilter);
108
+
109
+ if ($store) {
110
+ $collection->addFieldToFilter('store_id', $store);
111
+ } else if ($website){
112
+ $storeIds = Mage::app()->getWebsite($website)->getStoreIds();
113
+ $collection->addFieldToFilter('store_id', array('in' => $storeIds));
114
+ } else if ($group){
115
+ $storeIds = Mage::app()->getGroup($group)->getStoreIds();
116
+ $collection->addFieldToFilter('store_id', array('in' => $storeIds));
117
+ }
118
+
119
+ $collection->load();
120
+ return $collection->getFirstItem();
121
+ }
122
+ }
app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Dashboard/Tabs/Analysis/Rfm.php ADDED
@@ -0,0 +1,173 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dotdigitalgroup_Email_Model_Adminhtml_Dashboard_Tabs_Analysis_Rfm extends Mage_Core_Model_Abstract
4
+ {
5
+ protected $rfm = array();
6
+ protected $_store = 0;
7
+ protected $_group = 0;
8
+ protected $_website = 0;
9
+
10
+ const RECENCY = 'Recency';
11
+ const FREQUENCY = 'Frequency';
12
+ const MONETARY = 'Monetary';
13
+
14
+ /**
15
+ * prepare collection and needed columns
16
+ *
17
+ * @return Mage_Sales_Model_Resource_Order_Collection
18
+ * @throws Mage_Core_Exception
19
+ */
20
+ protected function getPreparedCollection()
21
+ {
22
+ $statuses = Mage::getSingleton('sales/config')
23
+ ->getOrderStatusesForState(Mage_Sales_Model_Order::STATE_CANCELED);
24
+ if (empty($statuses)) {
25
+ $statuses = array(0);
26
+ }
27
+
28
+ $collection = Mage::getResourceModel('sales/order_collection');
29
+ $collection
30
+ ->addFieldToFilter('status', array('nin' => $statuses))
31
+ ->addFieldToFilter('state',
32
+ array('nin' => array(
33
+ Mage_Sales_Model_Order::STATE_NEW,
34
+ Mage_Sales_Model_Order::STATE_PENDING_PAYMENT)
35
+ )
36
+ )
37
+ ->addFieldToFilter('customer_id', array('neq' => 'null'))
38
+ ->addOrder('created_at');
39
+
40
+ if ($this->_store) {
41
+ $collection->addFieldToFilter('store_id', $this->_store);
42
+ } else if ($this->_website){
43
+ $storeIds = Mage::app()->getWebsite($this->_website)->getStoreIds();
44
+ $collection->addFieldToFilter('store_id', array('in' => $storeIds));
45
+ } else if ($this->_group){
46
+ $storeIds = Mage::app()->getGroup($this->_group)->getStoreIds();
47
+ $collection->addFieldToFilter('store_id', array('in' => $storeIds));
48
+ }
49
+
50
+ $expr = $this->_getSalesAmountExpression($collection);
51
+ $isFilter = $this->_store || $this->_website || $this->_group;
52
+ if ($isFilter == 0) {
53
+ $expr = '(' . $expr . ') * main_table.base_to_global_rate';
54
+ }
55
+
56
+ $collection->getSelect()
57
+ ->reset(Zend_Db_Select::COLUMNS)
58
+ ->columns(array(
59
+ 'customer_total_orders' => "count(*)",
60
+ 'customer_average_order_value' => "SUM({$expr})/count(*)",
61
+ 'last_order_days_ago' => "DATEDIFF(date(NOW()) , date(MAX(created_at)))"
62
+ ))
63
+ ->group('customer_id');
64
+
65
+ return $collection;
66
+ }
67
+
68
+ /**
69
+ * calculate quartiles
70
+ *
71
+ * @param $array
72
+ * @return array
73
+ */
74
+ protected function calculateQuartile($array){
75
+ if(count($array) == 0)
76
+ return array(
77
+ "Low" => 0,
78
+ "Medium" => 0,
79
+ "High" => 0
80
+ );
81
+
82
+ sort($array);
83
+ $count = count($array);
84
+
85
+ $first = intval(round (.25 * ( $count + 1 )));
86
+ $second = intval(round(.50 * ( $count + 1 )));
87
+ $third = intval(round(.75 * ( $count + 1 )));
88
+
89
+ if(!array_key_exists($first, $array))
90
+ $first = $this->getClosest($first, $array);
91
+
92
+ if(!array_key_exists($second, $array))
93
+ $second = $this->getClosest($second, $array);
94
+
95
+ if(!array_key_exists($third, $array))
96
+ $third = $this->getClosest($third, $array);
97
+
98
+ return array(
99
+ "Low" => $array[$first],
100
+ "Medium" => $array[$second],
101
+ "High" => $array[$third]
102
+ );
103
+ }
104
+
105
+ /**
106
+ * find closest index key from array
107
+ *
108
+ * @param $search
109
+ * @param $arr
110
+ * @return mix
111
+ */
112
+ protected function getClosest($search, $arr) {
113
+ $closest = null;
114
+ foreach($arr as $key => $value) {
115
+ if($search == $key)
116
+ return $search;
117
+ if($closest == null || abs($search - $closest) > abs($key - $search)) {
118
+ $closest = $key;
119
+ }
120
+ }
121
+ return $closest;
122
+ }
123
+
124
+ /**
125
+ * prepare rfm data
126
+ */
127
+ protected function prepareRfm()
128
+ {
129
+ $collection = $this->getPreparedCollection();
130
+
131
+ $this->rfm[self::FREQUENCY] = $this->calculateQuartile($collection->getColumnValues('customer_total_orders'));
132
+ $this->rfm[self::RECENCY] = $this->calculateQuartile($collection->getColumnValues('last_order_days_ago'));
133
+ $this->rfm[self::MONETARY] = $this->calculateQuartile($collection->getColumnValues('customer_average_order_value'));
134
+ }
135
+
136
+ protected function _getSalesAmountExpression($collection)
137
+ {
138
+ $adapter = $collection->getConnection();
139
+ $expressionTransferObject = new Varien_Object(array(
140
+ 'expression' => '%s - %s - %s - (%s - %s - %s)',
141
+ 'arguments' => array(
142
+ $adapter->getIfNullSql('main_table.base_total_invoiced', 0),
143
+ $adapter->getIfNullSql('main_table.base_tax_invoiced', 0),
144
+ $adapter->getIfNullSql('main_table.base_shipping_invoiced', 0),
145
+ $adapter->getIfNullSql('main_table.base_total_refunded', 0),
146
+ $adapter->getIfNullSql('main_table.base_tax_refunded', 0),
147
+ $adapter->getIfNullSql('main_table.base_shipping_refunded', 0),
148
+ )
149
+ ));
150
+
151
+ return vsprintf(
152
+ $expressionTransferObject->getExpression(),
153
+ $expressionTransferObject->getArguments()
154
+ );
155
+
156
+ }
157
+
158
+ /**
159
+ * @param int $store
160
+ * @param int $website
161
+ * @param int $group
162
+ * @return array
163
+ */
164
+ public function getPreparedRfm($store = 0, $website = 0, $group =0)
165
+ {
166
+ $this->_store = $store;
167
+ $this->_group = $group;
168
+ $this->_website = $website;
169
+
170
+ $this->prepareRfm();
171
+ return $this->rfm;
172
+ }
173
+ }
app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Dashboard/Tabs/Analysis/Subscriber.php ADDED
@@ -0,0 +1,91 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dotdigitalgroup_Email_Model_Adminhtml_Dashboard_Tabs_Analysis_Subscriber extends Mage_Core_Model_Abstract
4
+ {
5
+ protected $storeIds;
6
+
7
+ protected function calculateOperationalDaysFromOrder()
8
+ {
9
+ $collection = Mage::getResourceModel('sales/order_collection');
10
+ $collection->addFieldToSelect('created_at');
11
+
12
+ if (is_array($this->storeIds) && !empty($this->storeIds)) {
13
+ $collection->addFieldToFilter('store_id', array('in' => $this->storeIds));
14
+ }
15
+
16
+ $collection->getSelect()->columns(array(
17
+ 'days' => "DATEDIFF(date(NOW()) , date(MIN(created_at)))"
18
+ ));
19
+ return $collection->getFirstItem()->getDays();
20
+ }
21
+
22
+ protected function _getCollection(){
23
+ $collection = Mage::getResourceModel('newsletter/subscriber_collection');
24
+ $collection->addFieldToFilter('subscriber_status', array('neq' => '3'));
25
+
26
+ if (is_array($this->storeIds) && !empty($this->storeIds)) {
27
+ $collection->addFieldToFilter('store_id', array('in' => $this->storeIds));
28
+ }
29
+ return $collection;
30
+ }
31
+
32
+ /**
33
+ * prepare collection
34
+ *
35
+ * @return Varien_Object
36
+ */
37
+ protected function getPreparedCollection()
38
+ {
39
+ //all active subscribers
40
+ $collection = $this->_getCollection();
41
+ $totalSubscribers = $collection->count();
42
+
43
+ //all active subscribers who are also customers
44
+ $customerSubscribers = $this->_getCollection();
45
+ $customerSubscribers->addFieldToFilter('customer_id', array('neq' => '0'));
46
+ $customerSubscriberCount = $customerSubscribers->count();
47
+
48
+ $days = $this->calculateOperationalDaysFromOrder();
49
+ if($days)
50
+ $subscribersPerDay = number_format($totalSubscribers/$days, 2);
51
+ else
52
+ $subscribersPerDay = $totalSubscribers;
53
+
54
+ $resultObject = new Varien_Object;
55
+ $resultObject
56
+ ->setTotalSubscriber($totalSubscribers)
57
+ ->setTotalSubscriberCustomer($customerSubscriberCount)
58
+ ->setSubscribersPerDay($subscribersPerDay);
59
+
60
+ return $resultObject;
61
+ }
62
+
63
+ /**
64
+ * @param int $store
65
+ * @param int $website
66
+ * @param int $group
67
+ * @return Varien_Object
68
+ * @throws Mage_Core_Exception
69
+ */
70
+ public function getLifetimeSubscribers($store = 0, $website = 0, $group =0)
71
+ {
72
+ if ($store) {
73
+ $this->storeIds = array($store => $store);
74
+ } else if ($website){
75
+ $storeIds = Mage::app()->getWebsite($website)->getStoreIds();
76
+ $this->storeIds = $storeIds;
77
+ } else if ($group){
78
+ $storeIds = Mage::app()->getGroup($group)->getStoreIds();
79
+ $this->storeIds = $storeIds;
80
+ }
81
+ return $this->getPreparedCollection();
82
+ }
83
+
84
+ /**
85
+ * @return string
86
+ */
87
+ public function getTitle()
88
+ {
89
+ return "Subscribers Analytical Data";
90
+ }
91
+ }
app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Observer.php ADDED
@@ -0,0 +1,214 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ /**
19
+ * check for addressbook mapping and disable if no address selected.
20
+ */
21
+ $this->_checkAddressBookMapping(Mage::app()->getRequest()->getParam('website'));
22
+
23
+ return $this;
24
+ }
25
+
26
+ /**
27
+ * API Transactional Section.
28
+ * Default data fields for transactional account.
29
+ * @return $this
30
+ */
31
+ public function saveConfigForTransactional()
32
+ {
33
+ //check for the datafields created for this api account
34
+ $username = Mage::helper('connector/transactional')->getApiUsername();
35
+ $configCreated = Mage::helper('connector')->isConfigCreatedForPath($username);
36
+
37
+ // no need to creat new datafields for this account
38
+ if ($configCreated) {
39
+ return $this;
40
+ }
41
+
42
+ //create default datafields for new api account
43
+ $client = Mage::getModel('email_connector/apiconnector_client');
44
+ $username = Mage::helper('connector/transactional')->getApiUsername();
45
+ $password = Mage::helper('connector/transactional')->getApiPassword();
46
+ $client->setApiUsername($username)->setApiPassword($password);
47
+
48
+ //required datafields for transactional
49
+ $dataFields = Mage::getModel('email_connector/connector_datafield')->getTransactionalDefaultDatafields();
50
+
51
+ foreach ($dataFields as $field) {
52
+ //create the datafields
53
+ $client->postDataFields($field);
54
+ }
55
+ return $this;
56
+ }
57
+
58
+ /**
59
+ * Check if the transactional data feature is enabled
60
+ * To use the wishlist and order sync this needs to be enabled.
61
+ */
62
+ public function checkFeatureActive()
63
+ {
64
+ //scope to retrieve the website id
65
+ $scopeId = 0;
66
+ if ($website = Mage::app()->getRequest()->getParam('website')) {
67
+ //use webiste
68
+ $scope = 'websites';
69
+ $scopeId = Mage::app()->getWebsite($website)->getId();
70
+ } else {
71
+ //set to default
72
+ $scope = "default";
73
+ }
74
+ //webiste by id
75
+ $website = Mage::app()->getWebsite($scopeId);
76
+
77
+ //configuration saved for the wishlist and order sync
78
+ $wishlistEnabled = $website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_SYNC_WISHLIST_ENABLED, $scope, $scopeId);
79
+ $orderEnabled = $website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_SYNC_ORDER_ENABLED);
80
+
81
+ //only for modification for order and wishlist
82
+ if ($orderEnabled || $wishlistEnabled) {
83
+ //client by website id
84
+ $client = Mage::helper('connector')->getWebsiteApiClient($scopeId);
85
+
86
+ //call request for account info
87
+ $response = $client->getAccountInfo();
88
+
89
+ //properties must be checked
90
+ if (isset($response->properties)) {
91
+ $accountInfo = $response->properties;
92
+ $result = $this->_checkForOption(Dotdigitalgroup_Email_Model_Apiconnector_Client::REST_API_TRANSACTIONAL_DATA_ALLOWANCE, $accountInfo);
93
+
94
+ //account is disabled to use transactional data
95
+ if (! $result) {
96
+ $message = 'Transactional Data For This Account Is Disabled. Call Support To Enable.';
97
+ //send admin message
98
+ Mage::getSingleton('adminhtml/session')->addError($message);
99
+
100
+ //send raygun message for trans data
101
+ Mage::helper('connector')->rayLog('100', $message);
102
+ //disable the config for wishlist and order sync
103
+ $config = Mage::getConfig();
104
+ $config->saveConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_SYNC_WISHLIST_ENABLED, 0, $scope, $scopeId);
105
+ $config->saveConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_SYNC_ORDER_ENABLED, 0, $scope, $scopeId);
106
+ $config->cleanCache();
107
+ }
108
+ }
109
+ }
110
+
111
+ return $this;
112
+
113
+ }
114
+
115
+ /**
116
+ * API Credentials.
117
+ * Installation and validation confirmation.
118
+ * @return $this
119
+ */
120
+ public function actionConfigSaveApi()
121
+ {
122
+ $groups = Mage::app()->getRequest()->getPost('groups');
123
+ if (isset($groups['api']['fields']['username']['inherit']) || isset($groups['api']['fields']['password']['inherit']))
124
+ return $this;
125
+
126
+ $apiUsername = isset($groups['api']['fields']['username']['value'])? $groups['api']['fields']['username']['value'] : false;
127
+ $apiPassword = isset($groups['api']['fields']['password']['value'])? $groups['api']['fields']['password']['value'] : false;
128
+ //skip if the inherit option is selected
129
+ if ($apiUsername && $apiPassword) {
130
+ Mage::helper('connector')->log('----VALIDATING ACCOUNT---');
131
+ $testModel = Mage::getModel('email_connector/apiconnector_test');
132
+ $isValid = $testModel->validate($apiUsername, $apiPassword);
133
+ if ($isValid) {
134
+ /**
135
+ * Create account contact datafields
136
+ */
137
+ $client = Mage::getModel('email_connector/apiconnector_client');
138
+ $client->setApiUsername($apiUsername)
139
+ ->setApiPassword($apiPassword);
140
+ $datafields = Mage::getModel('email_connector/connector_datafield')->getDefaultDataFields();
141
+ foreach ($datafields as $datafield) {
142
+ $client->postDataFields($datafield);
143
+ }
144
+ /**
145
+ * Send install info
146
+ */
147
+ $testModel->sendInstallConfirmation();
148
+ } else {
149
+ /**
150
+ * Disable invalid Api credentials
151
+ */
152
+ $scopeId = 0;
153
+ if ($website = Mage::app()->getRequest()->getParam('website')) {
154
+ $scope = 'websites';
155
+ $scopeId = Mage::app()->getWebsite($website)->getId();
156
+ } else {
157
+ $scope = "default";
158
+ }
159
+ $config = Mage::getConfig();
160
+ $config->saveConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_API_ENABLED, 0, $scope, $scopeId);
161
+ $config->cleanCache();
162
+ }
163
+ Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('connector')->__('API Credentials Valid.'));
164
+ }
165
+ return $this;
166
+ }
167
+
168
+ private function _checkAddressBookMapping( $website ) {
169
+
170
+ $helper = Mage::helper('connector');
171
+ $customerAddressBook = $helper->getWebsiteConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CUSTOMERS_ADDRESS_BOOK_ID, $website);
172
+ $subscriberAddressBook = $helper->getWebsiteConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_SUBSCRIBERS_ADDRESS_BOOK_ID, $website);
173
+
174
+ if (! $customerAddressBook && $helper->getWebsiteConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_SYNC_CONTACT_ENABLED, $website)){
175
+
176
+ $helper->disableConfigForWebsite(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_SYNC_CONTACT_ENABLED);
177
+ Mage::getSingleton('adminhtml/session')->addNotice('The Contact Sync Disabled - No Addressbook Selected !');
178
+ }
179
+ if (! $subscriberAddressBook && $helper->getWebsiteConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_SYNC_SUBSCRIBER_ENABLED, $website)) {
180
+ $helper->disableConfigForWebsite( Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_SYNC_SUBSCRIBER_ENABLED );
181
+ Mage::getSingleton('adminhtml/session')->addNotice('The Subscriber Sync Disabled - No Addressbook Selected !');
182
+ }
183
+
184
+ }
185
+
186
+ /**
187
+ * Check for name option in array.
188
+ *
189
+ * @param $name
190
+ * @param $data
191
+ *
192
+ * @return bool
193
+ */
194
+ private function _checkForOption($name, $data) {
195
+ //loop for all options
196
+ foreach ( $data as $one ) {
197
+
198
+ if ($one->name == $name) {
199
+ return true;
200
+ }
201
+ }
202
+
203
+ return false;
204
+ }
205
+
206
+ /**
207
+ * Update Feed for latest releases.
208
+ *
209
+ */
210
+ public function updateFeed()
211
+ {
212
+ Mage::getModel('email_connector/feed')->checkForUpgrade();
213
+ }
214
+ }
app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Source/Addressbooks.php ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ // Add a "Do Not Map" Option
14
+ $fields[] = array('value' => 0, 'label' => Mage::helper('connector')->__('-- Please Select --'));
15
+ $website = Mage::app()->getRequest()->getParam('website');
16
+
17
+ $enabled = Mage::helper('connector')->isEnabled($website);
18
+
19
+ //get address books options
20
+ if ($enabled) {
21
+ $client = Mage::getModel( 'email_connector/apiconnector_client' );
22
+ $client->setApiUsername( Mage::helper( 'connector' )->getApiUsername( $website ) )
23
+ ->setApiPassword( Mage::helper( 'connector' )->getApiPassword( $website ) );
24
+
25
+ $savedAddressBooks = Mage::registry( 'addressbooks' );
26
+ //get saved address books from registry
27
+ if ( $savedAddressBooks ) {
28
+ $addressBooks = $savedAddressBooks;
29
+ } else {
30
+ // api all address books
31
+ $addressBooks = $client->getAddressBooks();
32
+ Mage::register( 'addressbooks', $addressBooks );
33
+ }
34
+
35
+ //set the error message to the select option
36
+ if ( isset( $addressBooks->message ) ) {
37
+ $fields[] = array( 'value' => 0, 'label' => Mage::helper( 'connector' )->__( '-- Please Select --' ) );
38
+ }
39
+
40
+ //set up fields with book id and label
41
+ foreach ( $addressBooks as $book ) {
42
+ if ( isset( $book->id ) ) {
43
+ $fields[] = array( 'value' => $book->id, 'label' => $book->name );
44
+ }
45
+ }
46
+ }
47
+
48
+ return $fields;
49
+ }
50
+
51
+ }
app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Source/Advanced/Abandonedlimit.php ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dotdigitalgroup_Email_Model_Adminhtml_Source_Advanced_Abandonedlimit
4
+ {
5
+
6
+ /**
7
+ * available times
8
+ * @var array
9
+ */
10
+ protected $_times = array(0,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
+
24
+ if ($i == 0)
25
+ $row = array('value' => $one, 'label' => Mage::helper('connector')->__('No Limit'));
26
+ elseif ($i == 1) {
27
+ $row = array(
28
+ 'value' => $one,
29
+ 'label' => Mage::helper( 'connector' )->__( $one . ' Hour' )
30
+ );
31
+ } else {
32
+ $row = array(
33
+ 'value' => $one,
34
+ 'label' => Mage::helper( 'connector' )->__( $one . ' Hours' )
35
+ );
36
+ }
37
+ $result[] = $row;
38
+ $i++;
39
+ }
40
+
41
+ return $result;
42
+ }
43
+ }
app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Source/Advanced/Attributes.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dotdigitalgroup_Email_Model_Adminhtml_Source_Advanced_Attributes
4
+ {
5
+ /**
6
+ * Returns custom order attributes
7
+ * @return array
8
+ */
9
+ public function toOptionArray()
10
+ {
11
+ $fields = Mage::helper('connector')->getOrderTableDescription();
12
+
13
+ $customFields = array();
14
+ foreach($fields as $key => $field){
15
+ $customFields[] = array(
16
+ 'value' => $field['COLUMN_NAME'],
17
+ 'label' => $field['COLUMN_NAME']
18
+ );
19
+ }
20
+ return $customFields;
21
+ }
22
+ }
app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Source/Advanced/Frequency.php ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dotdigitalgroup_Email_Model_Adminhtml_Source_Advanced_Frequency
4
+ {
5
+ public function toOptionArray()
6
+ {
7
+ return array(
8
+ array('value' => '1', 'label' => Mage::helper('connector')->__('1 Hour')),
9
+ array('value' => '2', 'label' => Mage::helper('connector')->__('2 Hours')),
10
+ array('value' => '6', 'label' => Mage::helper('connector')->__('6 Hours')),
11
+ array('value' => '12', 'label' => Mage::helper('connector')->__('12 Hours')),
12
+ array('value' => '24', 'label' => Mage::helper('connector')->__('24 Hours'))
13
+ );
14
+ }
15
+ }
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,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ $fields[] = array('value' => '0', 'label' => Mage::helper('connector')->__('-- Disabled --'));
13
+ if ($websiteName) {
14
+ $website = Mage::app()->getWebsite($websiteName);
15
+ }
16
+
17
+ if (Mage::helper('connector')->isEnabled($website)) {
18
+
19
+ $client = Mage::helper( 'connector' )->getWebsiteApiClient( $website );
20
+ $programmes = $client->getPrograms();
21
+
22
+ foreach ( $programmes as $one ) {
23
+ if ( isset( $one->id ) ) {
24
+ $fields[] = array( 'value' => $one->id, 'label' => Mage::helper( 'connector' )->__( $one->name ) );
25
+ }
26
+ }
27
+ }
28
+
29
+ return $fields;
30
+ }
31
+
32
+ }
app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Source/Campaigns.php ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ $fields[] = array('value' => '0', 'label' => Mage::helper('connector')->__('-- Please Select --'));
19
+
20
+ if ($websiteName) {
21
+ $website = Mage::app()->getWebsite($websiteName);
22
+ }
23
+
24
+ $enabled = Mage::helper('connector')->isEnabled($website);
25
+
26
+ //api enabled get campaigns
27
+ if ($enabled) {
28
+ $client = Mage::helper( 'connector' )->getWebsiteApiClient( $website );
29
+
30
+ $savedCampaigns = Mage::registry( 'savedcampigns' );
31
+
32
+ //get campaigns from registry
33
+ if ( $savedCampaigns ) {
34
+ $campaigns = $savedCampaigns;
35
+ } else {
36
+ $campaigns = $client->getCampaigns();
37
+ Mage::unregister( 'savedcampigns' );
38
+ Mage::register( 'savedcampigns', $campaigns );
39
+ }
40
+
41
+ foreach ( $campaigns as $one ) {
42
+ if ( isset( $one->id ) ) {
43
+ $fields[] = array(
44
+ 'value' => $one->id,
45
+ 'label' => Mage::helper( 'connector' )->__( addslashes( $one->name ) )
46
+ );
47
+ }
48
+ }
49
+ }
50
+
51
+ return $fields;
52
+ }
53
+
54
+ }
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,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dotdigitalgroup_Email_Model_Adminhtml_Source_Datafields
4
+ {
5
+ /**
6
+ * Datafields option.
7
+ * @return array
8
+ */
9
+ public function toOptionArray()
10
+ {
11
+ $fields = array();
12
+ $helper = Mage::helper('connector');
13
+ //default data option
14
+ $fields[] = array('value' => 0, 'label' => Mage::helper('connector')->__('-- Please Select --'));
15
+
16
+ $website = Mage::app()->getRequest()->getParam('website', 0);
17
+ $client = $helper->getWebsiteApiClient($website);
18
+
19
+ //get datafields options
20
+ if ($helper->isEnabled($website)) {
21
+
22
+ $savedDatafields = Mage::registry( 'datafields' );
23
+
24
+ //get saved datafileds from registry
25
+ if ( $savedDatafields ) {
26
+ $datafields = $savedDatafields;
27
+ } else {
28
+ //grab the datafields request and save to register
29
+ $datafields = $client->getDataFields();
30
+ Mage::register( 'datafields', $datafields );
31
+ }
32
+
33
+ //set the api error message for the first option
34
+ if ( isset( $datafields->message ) ) {
35
+
36
+ //message
37
+ $fields[] = array( 'value' => 0, 'label' => Mage::helper( 'connector' )->__( $datafields->message ) );
38
+
39
+ } else {
40
+
41
+ //loop for all datafields option
42
+ foreach ( $datafields as $datafield ) {
43
+ if ( isset( $datafield->name ) ) {
44
+ $fields[] = array(
45
+ 'value' => $datafield->name,
46
+ 'label' => Mage::helper( 'connector' )->__( $datafield->name )
47
+ );
48
+ }
49
+ }
50
+ }
51
+ }
52
+
53
+ return $fields;
54
+ }
55
+ }
app/code/community/Dotdigitalgroup/Email/Model/Adminhtml/Source/Datamapping/Datafieldaccess.php ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dotdigitalgroup_Email_Model_Adminhtml_Source_Datamapping_Datafieldaccess
4
+ {
5
+ /**
6
+ * @return array
7
+ */
8
+ public function toOptionArray()
9
+ {
10
+ $dataType = array(
11
+ array('value' => 'Private', 'label' => Mage::helper('connector')->__('Private')),
12
+ array('value' => 'Public', 'label' => Mage::helper('connector')->__('Public')),
13
+ );
14
+
15
+ return $dataType;
16
+ }
17
+ }
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')->__('Yes/No'))
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/{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/Reviews/Campaigns.php ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dotdigitalgroup_Email_Model_Adminhtml_Source_Reviews_Campaigns
4
+ {
5
+
6
+ /**
7
+ * Returns account's Campaigns.
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
+ $website = Mage::app()->getRequest()->getParam('website', false);
18
+ if ($website) {
19
+ $website = Mage::app()->getWebsite($website);
20
+ } else {
21
+ $website = 0;
22
+ }
23
+ $client->setApiUsername(Mage::helper('connector')->getApiUsername($website));
24
+ $client->setApiPassword(Mage::helper('connector')->getApiPassword($website));
25
+
26
+ $savedCampaigns = Mage::registry('savedcampignsforreview');
27
+
28
+ if ($savedCampaigns) {
29
+ $campaigns = $savedCampaigns;
30
+ } else {
31
+ $campaigns = $client->getCampaigns();
32
+ Mage::unregister('savedcampignsforreview');
33
+ Mage::register('savedcampignsforreview', $campaigns);
34
+ }
35
+
36
+ $fields[] = array('value' => '0', 'label' => Mage::helper('connector')->__('-- Please Select --'));
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/Reviews/Delay.php ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dotdigitalgroup_Email_Model_Adminhtml_Source_Reviews_Delay
4
+ {
5
+ /**
6
+ * Returns the values for field delay
7
+ * @return array
8
+ */
9
+ public function toOptionArray()
10
+ {
11
+ return array(
12
+ array('value' => '', 'label' => Mage::helper('connector')->__('-- Please Select --')),
13
+ array('value' => 1, 'label' => '1'),
14
+ array('value' => 2, 'label' => '2'),
15
+ array('value' => 3, 'label' => '3'),
16
+ array('value' => 4, 'label' => '4'),
17
+ array('value' => 5, 'label' => '5'),
18
+ array('value' => 6, 'label' => '6'),
19
+ array('value' => 7, 'label' => '7'),
20
+ array('value' => 14, 'label' => '14'),
21
+ array('value' => 30, 'label' => '30'),
22
+ array('value' => 60, 'label' => '60'),
23
+ array('value' => 90, 'label' => '90')
24
+ );
25
+ }
26
+ }
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,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dotdigitalgroup_Email_Model_Adminhtml_Source_Transactional_Campaigns
4
+ {
5
+
6
+ /**
7
+ * Option with campaign data.
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
+ //website param
18
+ $websiteName = Mage::app()->getRequest()->getParam('website', false);
19
+ if ($websiteName) {
20
+ $website = Mage::app()->getWebsite($websiteName);
21
+ } else {
22
+ $website = 0;
23
+ $website = Mage::app()->getWebsite($website);
24
+ }
25
+
26
+ //default option
27
+ $fields[] = array('value' => '0', 'label' => Mage::helper('connector')->__('-- Use system default --'));
28
+
29
+ if (!$website->getConfig(Dotdigitalgroup_Email_Helper_Transactional::XML_PATH_TRANSACTIONAL_API_ENABLED))
30
+ return $fields;
31
+
32
+ //set client credentials
33
+ $client->setApiUsername(Mage::helper('connector/transactional')->getApiUsername($website))
34
+ ->setApiPassword(Mage::helper('connector/transactional')->getApiPassword($website));
35
+
36
+ //campaigns from registry
37
+ $savedCampaigns = Mage::registry('savedcampigns');
38
+
39
+ //current campaings from registry
40
+ if ($savedCampaigns) {
41
+ $campaigns = $savedCampaigns;
42
+ } else {
43
+ //save into registry
44
+ $campaigns = $client->getCampaigns();
45
+ Mage::unregister('savedcampigns');
46
+ Mage::register('savedcampigns', $campaigns);
47
+ }
48
+
49
+ //add campign options
50
+ foreach ( $campaigns as $one ) {
51
+ if ( isset( $one->id ) )
52
+ $fields[] = array( 'value' => $one->id, 'label' => Mage::helper( 'connector' )->__( addslashes($one->name)) );
53
+ }
54
+
55
+ return $fields;
56
+ }
57
+ }
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,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ //website param
18
+ $websiteName = Mage::app()->getRequest()->getParam('website', false);
19
+ if ($websiteName) {
20
+ $website = Mage::app()->getWebsite($websiteName);
21
+ } else {
22
+ //not set use default
23
+ $website = 0;
24
+ $website = Mage::app()->getWebsite($website);
25
+ }
26
+
27
+ //default option
28
+ $fields[] = array('value' => '0', 'label' => Mage::helper('connector')->__('-- Please select --'));
29
+
30
+ //transactional disabled return defualt option
31
+ if (! $website->getConfig(Dotdigitalgroup_Email_Helper_Transactional::XML_PATH_TRANSACTIONAL_API_ENABLED))
32
+ return $fields;
33
+
34
+ //set api credentials
35
+ $client->setApiUsername(Mage::helper('connector/transactional')->getApiUsername($website))
36
+ ->setApiPassword(Mage::helper('connector/transactional')->getApiPassword($website));
37
+
38
+ $savedFromAddressList = Mage::registry('savedFromAddressList');
39
+ //load from regirstry
40
+ if ($savedFromAddressList) {
41
+ $fromAddressList = $savedFromAddressList;
42
+ } else {
43
+ // retrive the transactionals
44
+ $fromAddressList = $client->getCustomFromAddresses();
45
+ Mage::unregister('savedFromAddressList');
46
+ Mage::register('savedFromAddressList', $fromAddressList);
47
+ }
48
+
49
+ //add all options
50
+ foreach ($fromAddressList as $one) {
51
+ if(isset($one->id))
52
+ $fields[] = array('value' => $one->id, 'label' => Mage::helper('connector')->__($one->email));
53
+ }
54
+
55
+ return $fields;
56
+ }
57
+ }
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' => Dotdigitalgroup_Email_Helper_Transactional::TRANSACTIONAL_SENDTYPE_SYSTEM_DEFAULT, 'label' => Mage::helper('connector')->__('-- Use system default --')),
15
+ array('value' => Dotdigitalgroup_Email_Helper_Transactional::TRANSACTIONAL_SENDTYPE_VIA_CONNECTOR, 'label' => Mage::helper('connector')->__('-- Send via connector --')),
16
+ array('value' => Dotdigitalgroup_Email_Helper_Transactional::TRANSACTIOANL_SNEDTYPE_DESIGN_VIA_CONNECTOR, '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,1251 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ const REST_API_AUTHORIZATION_DENIED = 'Authorization has been denied for this request.';
36
+ const REST_API_TRANSACTIONAL_DATA_ALLOWANCE = 'TransactionalDataAllowanceInMegabytes';
37
+
38
+ protected $_customers_file_slug = 'customer_sync';
39
+ protected $_subscribers_file_slug = 'subscriber_sync';
40
+ protected $_api_helper;
41
+ protected $_subscribers_address_book_id;
42
+ protected $_customers_address_book_id;
43
+ protected $_filename;
44
+ protected $_subscribers_filename;
45
+ protected $_customers_filename;
46
+ protected $_limit = 10;
47
+ protected $_address_book_id;
48
+ public $fileHelper; /** @var Dotdigitalgroup_Email_Helper_File */
49
+ public $result = array('error' => false, 'message' => '');
50
+
51
+
52
+ public $apiCalls = array(
53
+ 'getContactById' => 'get_contact_by_id',
54
+ 'postAddressBookContactsImport' => 'post_address_book_contacts_import',
55
+ 'postAddressBookContacts' => 'post_address_book_contacts',
56
+ 'deleteAddressBookContact' => 'delete_address_book_contact',
57
+ 'getContactsImportReport' => 'get_contacts_import',
58
+ 'getContactByEmail' => 'get_contact_by_email',
59
+ 'getAddressBooks' => 'get_address_books',
60
+ 'postAddressBooks' => 'post_address_books',
61
+ 'getAddressBookById' => 'get_address_book_by_id',
62
+ 'getCampaigns' => 'get_campaigns',
63
+ 'postDataFields' => 'post_data_fields',
64
+ 'deleteDataField' => 'delete_data_field',
65
+ 'getDataFields' => 'get_data_fields',
66
+ 'updateContact' => 'update_contact',
67
+ 'deleteContact' => 'delete_contact',
68
+ 'updateContactDatafieldsByEmail' => 'update_contact_datafields_by_email',
69
+ 'postCampaignsSend' => 'post_campaigns_send',
70
+ 'postContacts' => 'post_contacts',
71
+ 'getContactsSuppressedSinceDate' => 'get_contacts_suppressed_sinse_date',
72
+ 'postContactsTransactionalDataImport' => 'post_contacts_transactional_data_import',
73
+ 'postContactsTransactionalData' => 'post_contacts_transactional_data',
74
+ 'getContactsTransactionalDataByKey' => 'get_contacts_transactional_data_by_key',
75
+ 'deleteContactTransactionalData' => 'delete_contact_transactional_data',
76
+ 'getAccountInfo' => 'get_account_info',
77
+ 'postSmsMessagesSendTo' => 'post_sms_message_send_to',
78
+ 'deleteAddressBookContactsInbulk' => 'delete_addess_book_contacts_in_bulk',
79
+ 'postContactsResubscribe' => 'post_contacts_resubscribe',
80
+ 'getCustomFromAddresses' => 'get_custom_fromaddresses',
81
+ 'postCampaign' => 'post_campaign',
82
+ 'getPrograms' => 'get_programs',
83
+ 'postProgramsEnrolments' => 'post_programs_enrolments',
84
+ 'getProgramById' => 'get_program_by_id',
85
+ 'getCampaignSummary' => 'get_campaign_summary',
86
+ 'deleteContactsTransactionalData' => 'delete_contacts_transactional_data'
87
+ );
88
+
89
+
90
+
91
+ /**
92
+ * constructor.
93
+ */
94
+ public function __construct()
95
+ {
96
+ parent::__construct();
97
+ }
98
+
99
+ /**
100
+ * Excluded api response that we don't want to send.
101
+ * @var array
102
+ */
103
+ public $exludeMessages = array(
104
+ 'ERROR_PROGRAM_NOT_ACTIVE', 'ERROR_CONTACT_SUPPRESSED', 'ERROR_NON_UNIQUE_DATAFIELD', 'Authorization has been denied for this request.'
105
+ );
106
+
107
+ /**
108
+ * @param $apiUsername
109
+ * @param $apiPassword
110
+ * @return bool|mixed
111
+ */
112
+ public function validate($apiUsername, $apiPassword)
113
+ {
114
+ if ($apiUsername && $apiPassword) {
115
+ $this->setApiUsername($apiUsername)
116
+ ->setApiPassword($apiPassword);
117
+ $accountInfo = $this->getAccountInfo();
118
+ if (isset($accountInfo->message)) {
119
+ Mage::getSingleton('adminhtml/session')->addError($accountInfo->message);
120
+ $message = 'VALIDATION ERROR : ' . $accountInfo->message;
121
+ Mage::helper('connector')->log($message);
122
+ Mage::helper('connector')->rayLog('100', $message, 'apiconnector/client.php', __LINE__);
123
+ return false;
124
+ }
125
+ return $accountInfo;
126
+ }
127
+ return false;
128
+ }
129
+ /**
130
+ * Gets a contact by ID. Unsubscribed or suppressed contacts will not be retrieved.
131
+ * @param $id
132
+ * @return null
133
+ */
134
+ public function getContactById($id)
135
+ {
136
+ $this->_addApiCall($this->apiCalls[__FUNCTION__]);
137
+
138
+ $url = self::REST_CONTACTS . $id;
139
+ $this->setUrl($url)
140
+ ->setVerb('GET');
141
+ $response = $this->execute();
142
+
143
+ if(isset($response->message)) {
144
+ $message = 'GET CONTACT INFO ID ' . $url . ', ' . $response->message;
145
+ Mage::helper( 'connector' )->log( $message );
146
+ if (! in_array($response->message, $this->exludeMessages))
147
+ Mage::helper('connector')->rayLog('100', $message, 'apiconnector/client.php', __LINE__);
148
+ }
149
+
150
+ return $response;
151
+ }
152
+
153
+ /**
154
+ * Bulk creates, or bulk updates, contacts. Import format can either be CSV or Excel.
155
+ * Must include one column called "Email". Any other columns will attempt to map to your custom data fields.
156
+ * The ID of returned object can be used to query import progress.
157
+ * @param $filename
158
+ * @param $addressBookId
159
+ * @return mixed
160
+ */
161
+
162
+ public function postAddressBookContactsImport($filename, $addressBookId)
163
+ {
164
+ $this->_addApiCall($this->apiCalls[__FUNCTION__]);
165
+ $url = "https://apiconnector.com/v2/address-books/{$addressBookId}/contacts/import";
166
+ $helper = Mage::helper('connector');
167
+
168
+ $ch = curl_init($url);
169
+ curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
170
+ curl_setopt($ch, CURLOPT_USERPWD, $this->getApiUsername() . ':' . $this->getApiPassword());
171
+
172
+ //case the deprication of @filename for uploading
173
+ if (function_exists('curl_file_create')) {
174
+ curl_setopt($ch, CURLOPT_SAFE_UPLOAD, false);
175
+ $args['file'] = curl_file_create(Mage::helper('connector/file')->getFilePath($filename), 'text/csv');
176
+ curl_setopt($ch, CURLOPT_POSTFIELDS, $args);
177
+
178
+ } else {
179
+ //standart use of curl file
180
+ curl_setopt($ch, CURLOPT_POSTFIELDS, array (
181
+ 'file' => '@'.Mage::helper('connector/file')->getFilePath($filename)
182
+ ));
183
+ }
184
+
185
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
186
+ curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
187
+ curl_setopt($ch, CURLOPT_HTTPHEADER, array(
188
+ 'Content-Type: multipart/form-data')
189
+ );
190
+
191
+ // send contacts to address book
192
+ $result = curl_exec($ch);
193
+ $result = json_decode($result);
194
+ if (isset($result->message)) {
195
+ $message = 'POST ADDRESS BOOK ' . $addressBookId . ', CONTACT IMPORT : ' . ' filename ' . $filename . ' Username ' . $this->getApiUsername() . $result->message;
196
+ $helper->log($message);
197
+ Mage::helper('connector')->log($result);
198
+ Mage::helper('connector')->rayLog('100', $message, 'apiconnector/client.php', __LINE__);
199
+ }
200
+ return $result;
201
+ }
202
+
203
+ /**
204
+ * Adds a contact to a given address book.
205
+ * @param $addressBookId
206
+ * @param $apiContact
207
+ * @return mixed|null
208
+ */
209
+ public function postAddressBookContacts($addressBookId, $apiContact)
210
+ {
211
+ $this->_addApiCall($this->apiCalls[__FUNCTION__]);
212
+
213
+ $url = self::REST_ADDRESS_BOOKS . $addressBookId . '/contacts';
214
+ $this->setUrl($url)
215
+ ->setVerb("POST")
216
+ ->buildPostBody($apiContact);
217
+
218
+ $response = $this->execute();
219
+ if (isset($response->message)) {
220
+ $message = 'POST ADDRESS BOOK CONTACTS ' . $url . ', ' . $response->message;
221
+ Mage::helper('connector')->log($message);
222
+ if (! in_array($response->message, $this->exludeMessages))
223
+ Mage::helper('connector')->rayLog('100', $message, 'apiconnector/client.php', __LINE__);
224
+ }
225
+
226
+ return $response;
227
+ }
228
+
229
+ /**
230
+ * Deletes all contacts from a given address book.
231
+ * @param $addressBookId
232
+ * @param $contactId
233
+ * @return null
234
+ */
235
+ public function deleteAddressBookContact($addressBookId, $contactId)
236
+ {
237
+ $this->_addApiCall($this->apiCalls[__FUNCTION__]);
238
+
239
+ $url = self::REST_ADDRESS_BOOKS . $addressBookId . '/contacts/' . $contactId;
240
+ $this->setUrl($url)
241
+ ->setVerb('DELETE');
242
+ $response = $this->execute();
243
+ if (isset($response->message)) {
244
+ $message = 'DELETE ADDRESS BOOK CONTACT ' . $url . ', ' . $response->message;
245
+ Mage::helper( 'connector' )->log( $message );
246
+ if (! in_array($response->message, $this->exludeMessages))
247
+ Mage::helper('connector')->rayLog('100', $message, 'apiconnector/client.php', __LINE__);
248
+ }
249
+
250
+ return $response;
251
+ }
252
+
253
+ /**
254
+ * Gets a report with statistics about what was successfully imported, and what was unable to be imported.
255
+ * @param $importId
256
+ * @return mixed
257
+ */
258
+ public function getContactsImportReport($importId)
259
+ {
260
+ $this->_addApiCall($this->apiCalls[__FUNCTION__]);
261
+
262
+ $url = self::REST_CONTACTS_IMPORT . $importId . "/report";
263
+ $this->setUrl($url)
264
+ ->setVerb('GET');
265
+ $response = $this->execute();
266
+ if (isset($response->message)) {
267
+ $message = 'GET CONTACTS IMPORT REPORT . ' . $url . ' message : ' . $response->message;
268
+ Mage::helper( 'connector' )->log( $message );
269
+ if (! in_array($response->message, $this->exludeMessages))
270
+ Mage::helper( 'connector' )->rayLog( '100', $message, 'apiconnector/client.php', __LINE__);
271
+ }
272
+ return $response;
273
+ }
274
+
275
+ /**
276
+ * Gets a contact by email address.
277
+ * @param $email
278
+ * @return mixed
279
+ */
280
+ public function getContactByEmail($email)
281
+ {
282
+ $this->_addApiCall($this->apiCalls[__FUNCTION__]);
283
+
284
+ $url = self::REST_CONTACTS . $email;
285
+ $this->setUrl($url)
286
+ ->setVerb('GET');
287
+
288
+ //should create new one if not exists?!?
289
+ $response = $this->execute();
290
+ if (isset($response->message)) {
291
+ $message = 'GET CONTACT BY email : ' . $email . ' ' . $response->message;
292
+ Mage::helper('connector')->log($message);
293
+ if (! in_array($response->message, $this->exludeMessages))
294
+ Mage::helper('connector')->rayLog('100', $message, 'apiconnector/client.php', __LINE__);
295
+ }
296
+
297
+ return $response;
298
+ }
299
+
300
+ /**
301
+ * Get all address books.
302
+ * @return null
303
+ */
304
+ public function getAddressBooks()
305
+ {
306
+ $this->_addApiCall($this->apiCalls[__FUNCTION__]);
307
+
308
+ $url = self::REST_ADDRESS_BOOKS;
309
+ $this->setUrl($url)
310
+ ->setVerb("GET");
311
+
312
+ $response = $this->execute();
313
+ if (isset($response->message)) {
314
+ $message = 'GET ALL ADDRESS BOOKS : ' . $url . ', ' . $response->message;
315
+ Mage::helper('connector')->log($message);
316
+ if (! in_array($response->message, $this->exludeMessages))
317
+ Mage::helper('connector')->rayLog('100', $message, 'apiconnector/client.php', __LINE__);
318
+ }
319
+ return $response;
320
+ }
321
+
322
+ /**
323
+ * Gets an address book by ID.
324
+ * @param $id
325
+ *
326
+ * @return null
327
+ * @throws Exception
328
+ */
329
+ public function getAddressBookById($id)
330
+ {
331
+ $this->_addApiCall($this->apiCalls[__FUNCTION__]);
332
+ $url = self::REST_ADDRESS_BOOKS . $id;
333
+
334
+ $this->setUrl($url)
335
+ ->setVerb('GET');
336
+
337
+ $response = $this->execute();
338
+
339
+ if (isset($response->message)) {
340
+ $message = 'GET ADDRESS BOOK BY ID '. $id . ', ' . $response->message;
341
+ Mage::helper("connector")->log($message);
342
+ }
343
+
344
+ return $response;
345
+ }
346
+
347
+ /**
348
+ * Creates an address book.
349
+ * @param $name
350
+ * @return null
351
+ */
352
+ public function postAddressBooks($name, $visibility = 'Public')
353
+ {
354
+ $this->_addApiCall($this->apiCalls[__FUNCTION__]);
355
+
356
+ $data = array(
357
+ 'Name' => $name,
358
+ 'Visibility' => $visibility
359
+ );
360
+ $url = self::REST_ADDRESS_BOOKS;
361
+ $this->setUrl($url)
362
+ ->setVerb('POST')
363
+ ->buildPostBody($data);
364
+
365
+ $response = $this->execute();
366
+ if (isset($response->message)) {
367
+ $message = 'Postaddressbooks ' . $response->message . ', url :' . $url ;
368
+ Mage::helper('connector')->log($message);
369
+ if (! in_array($response->message, $this->exludeMessages))
370
+ Mage::helper('connector')->rayLog('100', $message, 'apiconnector/client.php', __LINE__);
371
+ }
372
+ return $response;
373
+ }
374
+
375
+ /**
376
+ * Get list of all campaigns.
377
+ * @return mixed
378
+ */
379
+ public function getCampaigns()
380
+ {
381
+ $this->_addApiCall($this->apiCalls[__FUNCTION__]);
382
+
383
+ $url = self::REST_DATA_FIELDS_CAMPAIGNS;
384
+ $this->setUrl($url)
385
+ ->setVerb('GET');
386
+
387
+ $response = $this->execute();
388
+
389
+ if (isset($response->message)) {
390
+ $message = 'GET CAMPAIGNS ' . $response->message . ' api user : ' . $this->getApiUsername();
391
+ Mage::helper('connector')->log($message);
392
+ if (! in_array($response->message, $this->exludeMessages))
393
+ Mage::helper('connector')->rayLog('100', $message, 'apiconnector/client.php', __LINE__);
394
+ }
395
+
396
+ return $response;
397
+ }
398
+
399
+ /**
400
+ * Creates a data field within the account.
401
+ * @param $data string/array
402
+ * @param string $type string, numeric, date, boolean
403
+ * @param string $visibility public, private
404
+ * @param bool $defaultValue
405
+ * @return mixed
406
+ */
407
+ public function postDataFields($data, $type = 'String', $visibility = 'public', $defaultValue = false)
408
+ {
409
+ $this->_addApiCall($this->apiCalls[__FUNCTION__]);
410
+
411
+ $url = self::REST_DATA_FILEDS;
412
+ //set default value for the numeric datatype
413
+ if($type == 'numeric' && !$defaultValue)
414
+ $defaultValue = 0;
415
+ //set data for the string datatype
416
+ if (is_string($data)) {
417
+ $data = array(
418
+ 'Name' => $data,
419
+ 'Type' => $type,
420
+ 'Visibility' => $visibility
421
+ );
422
+ //default value
423
+ if($defaultValue)
424
+ $data['DefaultValue'] = $defaultValue;
425
+ }
426
+ $this->setUrl($url)
427
+ ->buildPostBody($data)
428
+ ->setVerb('POST');
429
+
430
+ $response = $this->execute();
431
+
432
+ if (isset($response->message)) {
433
+ $message = 'POST CREATE DATAFIELDS ' . $response->message;
434
+ Mage::helper('connector')->log($message);
435
+ Mage::helper('connector')->log($data);
436
+ if (! in_array($response->message, $this->exludeMessages))
437
+ Mage::helper('connector')->rayLog('100', $message, 'apiconnector/client.php', __LINE__);
438
+ }
439
+
440
+ return $response;
441
+ }
442
+
443
+ /**
444
+ * Deletes a data field within the account.
445
+ * @param $name
446
+ *
447
+ * @return mixed
448
+ */
449
+ public function deleteDataField($name)
450
+ {
451
+ $this->_addApiCall($this->apiCalls[__FUNCTION__]);
452
+
453
+ $url = self::REST_DATA_FILEDS . '/' . $name;
454
+ $request = Mage::helper('connector/api_restrequest');
455
+ $request->setUrl($url)
456
+ ->setVerb('DELETE');
457
+
458
+ $response = $request->execute();
459
+ if (isset($response->message)) {
460
+ $message = 'DELETE DATA FIELD :' . $name . ' ' . $response->message;
461
+ Mage::helper('connector')->log($message);
462
+ if (! in_array($response->message, $this->exludeMessages))
463
+ Mage::helper('connector')->rayLog('100', $message, 'apiconnector/client.php', __LINE__);
464
+ }
465
+ return $request->execute();
466
+ }
467
+
468
+ /**
469
+ * Lists the data fields within the account.
470
+ * @return mixed
471
+ */
472
+ public function getDataFields()
473
+ {
474
+ $this->_addApiCall($this->apiCalls[__FUNCTION__]);
475
+
476
+ $url = self::REST_DATA_FILEDS;
477
+ $this->setUrl($url)
478
+ ->setVerb('GET');
479
+
480
+ $response = $this->execute();
481
+ if (isset($response->message)) {
482
+ $message = 'GET ALL DATAFIELDS ' . $response->message;
483
+ Mage::helper('connector')->log($message);
484
+ if (! in_array($response->message, $this->exludeMessages))
485
+ Mage::helper('connector')->rayLog('100', $message, 'apiconnector/client.php', __LINE__);
486
+ }
487
+
488
+ return $response;
489
+ }
490
+
491
+ /**
492
+ * Updates a contact.
493
+ * @param $contactId
494
+ * @param $data
495
+ * @return object
496
+ */
497
+ public function updateContact($contactId, $data)
498
+ {
499
+ $this->_addApiCall($this->apiCalls[__FUNCTION__]);
500
+
501
+ $url = self::REST_CONTACTS . $contactId;
502
+ $this->setUrl($url)
503
+ ->setVerb('PUT')
504
+ ->buildPostBody($data);
505
+
506
+ $response = $this->execute();
507
+ if (isset($response->message)) {
508
+ $message = 'ERROR : UPDATE SINGLE CONTACT : ' . $url . ' message : ' . $response->message;
509
+ Mage::helper('connector')->log($message);
510
+ Mage::helper('connector')->log($data);
511
+ if (! in_array($response->message, $this->exludeMessages))
512
+ Mage::helper('connector')->rayLog('100', $message, 'apiconnector/client.php', __LINE__);
513
+ }
514
+
515
+ return $response;
516
+ }
517
+
518
+ /**
519
+ * Deletes a contact.
520
+ * @param $contactId
521
+ * @return null
522
+ */
523
+ public function deleteContact($contactId)
524
+ {
525
+ $this->_addApiCall($this->apiCalls[__FUNCTION__]);
526
+
527
+ $url = self::REST_CONTACTS . $contactId;
528
+ $this->setUrl($url)
529
+ ->setVerb('DELETE');
530
+
531
+ $response = $this->execute();
532
+
533
+ if (isset($response->message)) {
534
+ $message = 'DELETE CONTACT : ' . $url . ', ' . $response->message;
535
+ Mage::helper('connector')->log($message);
536
+ if (! in_array($response->message, $this->exludeMessages))
537
+ Mage::helper('connector')->rayLog('100', $message, 'apiconnector/client.php', __LINE__);
538
+ }
539
+ return $response;
540
+ }
541
+
542
+ /**
543
+ * Update contact datafields by email.
544
+ * @param $email
545
+ * @param $dataFields
546
+ *
547
+ * @return null
548
+ * @throws Exception
549
+ */
550
+ public function updateContactDatafieldsByEmail($email, $dataFields)
551
+ {
552
+ $this->_addApiCall($this->apiCalls[__FUNCTION__]);
553
+
554
+ $apiContact = $this->postContacts($email);
555
+ //do not create for non contact id set
556
+ if (! isset($apiContact->id)) {
557
+ return $apiContact;
558
+ } else {
559
+ //get the contact id for this email
560
+ $contactId = $apiContact->id;
561
+ }
562
+ $data = array(
563
+ 'Email' => $email,
564
+ 'EmailType' => 'Html');
565
+ $data['DataFields'] = $dataFields;
566
+ $url = self::REST_CONTACTS . $contactId;
567
+ $this->setUrl($url)
568
+ ->setVerb('PUT')
569
+ ->buildPostBody($data);
570
+
571
+ $response = $this->execute();
572
+ if (isset($response->message)) {
573
+ $message = 'ERROR: UPDATE CONTACT DATAFIELD ' . $url . ' message : ' . $response->message;
574
+ Mage::helper('connector')->log($message);
575
+ Mage::helper('connector')->log($data);
576
+ if (! in_array($response->message, $this->exludeMessages))
577
+ Mage::helper('connector')->rayLog('100', $message, 'apiconnector/client.php', __LINE__);
578
+ }
579
+
580
+ return $response;
581
+ }
582
+
583
+ /**
584
+ * Sends a specified campaign to one or more address books, segments or contacts at a specified time.
585
+ * Leave the address book array empty to send to All Contacts.
586
+ * @param $campaignId
587
+ * @param $contacts
588
+ * @return mixed
589
+ */
590
+ public function postCampaignsSend($campaignId, $contacts)
591
+ {
592
+ $this->_addApiCall($this->apiCalls[__FUNCTION__]);
593
+
594
+ $helper = Mage::helper('connector');
595
+ $data = array(
596
+ 'username' => $this->getApiUsername(),
597
+ 'password' => $this->getApiPassword(),
598
+ "campaignId" => $campaignId,
599
+ "ContactIds" => $contacts
600
+ );
601
+ $this->setUrl(self::REST_CAMPAIGN_SEND)
602
+ ->setVerb('POST')
603
+ ->buildPostBody($data);
604
+
605
+ $response = $this->execute();
606
+ if (isset($response->message)) {
607
+ $message = 'SENDING CAMPAIGN ' . $response->message;
608
+ $helper->log($message);
609
+ $helper->log($data);
610
+ if (! in_array($response->message, $this->exludeMessages))
611
+ Mage::helper('connector')->rayLog('100', $message, 'apiconnector/client.php', __LINE__);
612
+ }
613
+
614
+ return $response;
615
+ }
616
+
617
+ /**
618
+ * Creates a contact.
619
+ * @param $email
620
+ * @return mixed
621
+ */
622
+ public function postContacts($email)
623
+ {
624
+ $this->_addApiCall($this->apiCalls[__FUNCTION__]);
625
+
626
+ $url = self::REST_CONTACTS;
627
+ $data = array(
628
+ 'Email' => $email,
629
+ 'EmailType' => 'Html',
630
+ );
631
+ $this->setUrl($url)
632
+ ->setVerb('POST')
633
+ ->buildPostBody($data);
634
+
635
+ $response = $this->execute();
636
+ if (isset($response->message)) {
637
+ $message = 'CREATE A NEW CONTACT : ' . $email . ' , url ' . $url . ', ' . $response->message;
638
+ Mage::helper('connector')->log($message);
639
+ if (! in_array($response->message, $this->exludeMessages))
640
+ Mage::helper('connector')->rayLog('100', $message, 'apiconnector/client.php', __LINE__);
641
+ }
642
+
643
+ return $response;
644
+ }
645
+
646
+ /**
647
+ * @param $testEmail
648
+ * @param $contactId
649
+ * @param $campaignId
650
+ */
651
+ public function sendIntallInfo($testEmail, $contactId, $campaignId)
652
+ {
653
+ $helper = Mage::helper('connector');
654
+ $productSize= Mage::getModel('catalog/product')->getCollection()->getSize();
655
+ $customerSize = Mage::getModel('customer/customer')->getCollection()->getSize();
656
+
657
+ $data = array(
658
+ 'Email' => $testEmail,
659
+ 'EmailType' => 'Html',
660
+ 'DataFields' => array(
661
+ array(
662
+ 'Key' => 'INSTALLCUSTOMERS',
663
+ 'Value' => (string)$customerSize),
664
+ array(
665
+ 'Key' => 'INSTALLPRODUCTS',
666
+ 'Value' => (string)$productSize),
667
+ array(
668
+ 'Key' => 'INSTALLURL',
669
+ 'Value' => Mage::getBaseUrl('web')),
670
+ array(
671
+ 'Key' => 'INSTALLAPI',
672
+ 'Value' => Mage::helper('connector')->getStringWebsiteApiAccounts()),
673
+ array(
674
+ 'Key' => 'PHPMEMORY',
675
+ 'Value' => ini_get('memory_limit') . ', Version = ' . $helper->getConnectorVersion()
676
+ )
677
+ )
678
+ );
679
+ $helper->log('SENDING INSTALL INFO DATA...', Zend_Log::INFO, 'api.log');
680
+ $helper->log($data);
681
+ Mage::helper('connector')->rayLog('100', 'SENDING INSTALL INFO DATA...', 'apiconnector/client.php', __LINE__);
682
+ /**
683
+ * Update data fields for a contact
684
+ */
685
+ $this->updateContact($contactId, $data);
686
+ /**
687
+ * Send Install info campaign
688
+ */
689
+ $this->postCampaignsSend($campaignId, array($contactId));
690
+
691
+ return;
692
+ }
693
+
694
+
695
+ /**
696
+ * Gets a list of suppressed contacts after a given date along with the reason for suppression.
697
+ * @param $dateString
698
+ * @param $select
699
+ * @param $skip
700
+ * @return object
701
+ */
702
+ public function getContactsSuppressedSinceDate($dateString, $select = 1000, $skip = 0)
703
+ {
704
+ $this->_addApiCall($this->apiCalls[__FUNCTION__]);
705
+
706
+ $url = self::REST_CONTACTS_SUPPRESSED_SINCE . $dateString . '?select=' . $select . '&skip=' . $skip;
707
+ $this->setUrl($url)
708
+ ->setVerb("GET");
709
+
710
+ $response = $this->execute();
711
+
712
+ if (isset($response->message)) {
713
+ $message = 'GET CONTACTS SUPPRESSED SINSE : ' . $dateString . ' select ' . $select . ' skip : ' . $skip . ' response : ' . $response->message;
714
+ Mage::helper('connector')->log($message);
715
+ if (! in_array($response->message, $this->exludeMessages))
716
+ Mage::helper('connector')->rayLog('100', $message, 'apiconnector/client.php', __LINE__);
717
+ }
718
+
719
+ return $response;
720
+ }
721
+
722
+ /**
723
+ * Adds multiple pieces of transactional data to contacts asynchronously, returning an identifier that can be used to check for import progress.
724
+ * @param $collectionName
725
+ * @param $transactionalData
726
+ * @return object
727
+ */
728
+ public function postContactsTransactionalDataImport($transactionalData, $collectionName = 'Orders')
729
+ {
730
+ $this->_addApiCall($this->apiCalls[__FUNCTION__]);
731
+
732
+ $orders = array();
733
+ foreach ($transactionalData as $one) {
734
+ if (isset($one->email)) {
735
+ $orders[] = array(
736
+ 'Key' => $one->id,
737
+ 'ContactIdentifier' => $one->email,
738
+ 'Json' => json_encode($one->expose())
739
+ );
740
+ }
741
+ }
742
+ $url = self::REST_TRANSACTIONAL_DATA_IMPORT . $collectionName;
743
+ $this->setURl($url)
744
+ ->setVerb('POST')
745
+ ->buildPostBody($orders);
746
+
747
+ $response = $this->execute();
748
+
749
+ if (isset($response->message)) {
750
+ $message = ' SEND MULTI TRANSACTIONAL DATA ' . $response->message;
751
+ Mage::helper('connector')->log($message);
752
+ if (! in_array($response->message, $this->exludeMessages))
753
+ Mage::helper('connector')->rayLog('100', $message, 'apiconnector/client.php', __LINE__);
754
+ }
755
+
756
+ return $response;
757
+ }
758
+
759
+ /**
760
+ * Adds a single piece of transactional data to a contact.
761
+ *
762
+ * @param $data
763
+ * @param string $name
764
+ * @return null
765
+ */
766
+ public function postContactsTransactionalData($data, $name = 'Orders')
767
+ {
768
+ $this->_addApiCall($this->apiCalls[__FUNCTION__]);
769
+
770
+ $getData = $this->getContactsTransactionalDataByKey($name, $data->id);
771
+ if(isset($getData->message) && $getData->message == self::REST_TRANSACTIONAL_DATA_NOT_EXISTS){
772
+ $url = self::REST_TRANSACTIONAL_DATA . $name;
773
+ }else{
774
+ $url = self::REST_TRANSACTIONAL_DATA . $name . '/' . $getData->key ;
775
+ }
776
+ $apiData = array(
777
+ 'Key' => $data->id,
778
+ 'Json' => json_encode($data->expose())
779
+ );
780
+
781
+ $this->setUrl($url)
782
+ ->setVerb('POST')
783
+ ->buildPostBody($apiData);
784
+ $response = $this->execute();
785
+ if (isset($response->message)) {
786
+ $message = 'POST CONTACTS TRANSACTIONAL DATA ' . $response->message;
787
+ Mage::helper('connector')->log($message);
788
+ Mage::helper('connector')->log($apiData);
789
+ if (! in_array($response->message, $this->exludeMessages))
790
+ Mage::helper('connector')->rayLog('100', $message, 'apiconnector/client.php', __LINE__);
791
+ }
792
+
793
+ return $response;
794
+ }
795
+
796
+ /**
797
+ * Gets a piece of transactional data by key.
798
+ * @param $name
799
+ * @param $key
800
+ * @return null
801
+ */
802
+ public function getContactsTransactionalDataByKey($name, $key)
803
+ {
804
+ $this->_addApiCall($this->apiCalls[__FUNCTION__]);
805
+
806
+ $url = self::REST_TRANSACTIONAL_DATA . $name . '/' . $key;
807
+ $this->setUrl($url)
808
+ ->setVerb('GET');
809
+ $response = $this->execute();
810
+ if (isset($response->message)) {
811
+ $message = 'GET CONTACTS TRANSACTIONAL DATA name: ' . $name . ' key: ' . $key . ' ' . $response->message;
812
+ Mage::helper('connector')->log($message);
813
+ if (! in_array($response->message, $this->exludeMessages))
814
+ Mage::helper('connector')->rayLog('100', $message, 'apiconnector/client.php', __LINE__);
815
+ }
816
+
817
+ return $response;
818
+ }
819
+
820
+ /**
821
+ * Deletes all transactional data for a contact.
822
+ * @param $email
823
+ * @param string $collectionName
824
+ * @return object
825
+ */
826
+ public function deleteContactTransactionalData($email, $collectionName = 'Orders')
827
+ {
828
+ $this->_addApiCall($this->apiCalls[__FUNCTION__]);
829
+
830
+ $url = 'https://apiconnector.com/v2/contacts/' . $email . '/transactional-data/' . $collectionName ;
831
+ $this->setUrl($url)
832
+ ->setVerb('DELETE');
833
+ $response = $this->execute();
834
+ if (isset($response->message)) {
835
+
836
+ $message = 'DELETE CONTACT TRANSACTIONAL DATA : ' . $url . ' ' . $response->message;
837
+ Mage::helper('connector')->log($message);
838
+ if (! in_array($response->message, $this->exludeMessages))
839
+ Mage::helper('connector')->rayLog('100', $message, 'apiconnector/client.php', __LINE__);
840
+ }
841
+
842
+ return $response;
843
+ }
844
+
845
+ /**
846
+ * Gets a summary of information about the current status of the account.
847
+ * @return mixed
848
+ */
849
+ public function getAccountInfo()
850
+ {
851
+ $this->_addApiCall($this->apiCalls[__FUNCTION__]);
852
+ $url = self::REST_ACCOUNT_INFO;
853
+ $this->setUrl($url)
854
+ ->setVerb('GET');
855
+
856
+ $response = $this->execute();
857
+ if (isset($response->message)) {
858
+ $message = 'GET ACCOUNT INFO for api user : ' . $this->getApiUsername() . ' ' . $response->message;
859
+ Mage::helper('connector')->log($message);
860
+ if (! in_array($response->message, $this->exludeMessages))
861
+ Mage::helper('connector')->rayLog('100', $message, 'apiconnector/client.php', __LINE__);
862
+ }
863
+
864
+ return $response;
865
+ }
866
+
867
+ /**
868
+ * Send a single SMS message.
869
+ * @param $telephoneNumber
870
+ * @param $message
871
+ * @return object
872
+ */
873
+ public function postSmsMessagesSendTo($telephoneNumber, $message)
874
+ {
875
+ $this->_addApiCall($this->apiCalls[__FUNCTION__]);
876
+
877
+ $data = array('Message' => $message);
878
+ $url = self::REST_SMS_MESSAGE_SEND_TO . $telephoneNumber;
879
+ $this->setUrl($url)
880
+ ->setVerb('POST')
881
+ ->buildPostBody($data);
882
+
883
+ $response = $this->execute();
884
+ if (isset($response->message)) {
885
+ $message = 'POST SMS MESSAGE SEND to ' . $telephoneNumber . ' message: ' . $message . ' error: ' . $response->message;
886
+ Mage::helper('connector')->log($message);
887
+ if (! in_array($response->message, $this->exludeMessages))
888
+ Mage::helper('connector')->rayLog('100', $message, 'apiconnector/client.php', __LINE__);
889
+ }
890
+
891
+ return $response;
892
+ }
893
+
894
+
895
+ /**
896
+ * Deletes multiple contacts from an address book.
897
+ * @param $addressBookId
898
+ * @param $contactIds
899
+ * @return object
900
+ */
901
+ public function deleteAddressBookContactsInbulk($addressBookId, $contactIds)
902
+ {
903
+ $this->_addApiCall($this->apiCalls[__FUNCTION__]);
904
+
905
+ $url = 'https://apiconnector.com/v2/address-books/' . $addressBookId . '/contacts/inbulk';
906
+ $data = array('ContactIds' => array($contactIds[0]));
907
+ $this->setUrl($url)
908
+ ->setVerb('DELETE')
909
+ ->buildPostBody($data);
910
+
911
+ $response = $this->execute();
912
+ if (isset($response->message)) {
913
+ $message = 'DELETE BULK ADDRESS BOOK CONTACTS ' . $response->message . ' address book ' . $addressBookId;
914
+ Mage::helper('connector')->log($message);
915
+ if (! in_array($response->message, $this->exludeMessages))
916
+ Mage::helper('connector')->rayLog('100', $message, 'apiconnector/client.php', __LINE__);
917
+ }
918
+ return $response;
919
+ }
920
+
921
+ /**
922
+ * Resubscribes a previously unsubscribed contact.
923
+ *
924
+ * @param $apiContact
925
+ */
926
+ public function postContactsResubscribe($apiContact)
927
+ {
928
+ $this->_addApiCall($this->apiCalls[__FUNCTION__]);
929
+
930
+ $url = self::REST_CONTACTS_RESUBSCRIBE;
931
+ $data = array(
932
+ 'UnsubscribedContact' => $apiContact
933
+ );
934
+ $this->setUrl($url)
935
+ ->setVerb("POST")
936
+ ->buildPostBody($data);
937
+
938
+ $response = $this->execute();
939
+ if (isset($response->message)) {
940
+ $message = 'Resubscribe : ' . $url . ', message :' . $response->message;
941
+ Mage::helper('connector')->log($message);
942
+ Mage::helper('connector')->log($data);
943
+ if (! in_array($response->message, $this->exludeMessages))
944
+ Mage::helper('connector')->rayLog('100', $message, 'apiconnector/client.php', __LINE__);
945
+ }
946
+ }
947
+
948
+ /**
949
+ * Gets all custom from addresses which can be used in a campaign.
950
+ *
951
+ * @return null
952
+ * @throws Exception
953
+ */
954
+
955
+ public function getCustomFromAddresses()
956
+ {
957
+ $this->_addApiCall($this->apiCalls[__FUNCTION__]);
958
+
959
+ $url = self::REST_CAMPAIGN_FROM_ADDRESS_LIST;
960
+ $this->setUrl($url)
961
+ ->setVerb('GET');
962
+
963
+ $response = $this->execute();
964
+
965
+ if (isset($response->message)) {
966
+
967
+ $message = 'GET CampaignFromAddressList ' . $response->message . ' api user : ' . $this->getApiUsername();
968
+ Mage::helper('connector')->log($message);
969
+ if (! in_array($response->message, $this->exludeMessages))
970
+ Mage::helper('connector')->rayLog('100', $message, 'apiconnector/client.php', __LINE__);
971
+ }
972
+
973
+ return $response;
974
+ }
975
+
976
+ /**
977
+ * Creates a campaign.
978
+ * @param $data
979
+ *
980
+ * @return null
981
+ * @throws Exception
982
+ */
983
+ public function postCampaign($data)
984
+ {
985
+ $this->_addApiCall($this->apiCalls[__FUNCTION__]);
986
+
987
+ $url = self::REST_CREATE_CAMPAIGN;
988
+ $this->setURl($url)
989
+ ->setVerb('POST')
990
+ ->buildPostBody($data);
991
+
992
+ $response = $this->execute();
993
+
994
+ if (isset($response->message)) {
995
+ $message = ' CREATE CAMPAIGN ' . $response->message;
996
+ Mage::helper('connector')->log($message);
997
+ if (! in_array($response->message, $this->exludeMessages))
998
+ Mage::helper('connector')->rayLog('100', $message, 'apiconnector/client.php', __LINE__);
999
+ }
1000
+
1001
+ return $response;
1002
+ }
1003
+
1004
+ /**
1005
+ * Gets all programs.
1006
+ * https://api.dotmailer.com/v2/programs?select={select}&skip={skip}
1007
+ */
1008
+ public function getPrograms()
1009
+ {
1010
+ $this->_addApiCall($this->apiCalls[__FUNCTION__]);
1011
+
1012
+ $url = 'https://api.dotmailer.com/v2/programs';
1013
+
1014
+ $this->setUrl($url)
1015
+ ->setVerb('GET');
1016
+
1017
+ $response = $this->execute();
1018
+
1019
+ if (isset($response->message)) {
1020
+ $message = 'Get programmes : ' . $response->message ;
1021
+ Mage::helper( 'connector' )->log($message);
1022
+ if (! in_array($response->message, $this->exludeMessages))
1023
+ Mage::helper('connector')->rayLog('100', $message, 'apiconnector/client.php', __LINE__);
1024
+ }
1025
+
1026
+ return $response;
1027
+ }
1028
+
1029
+ /**
1030
+ * Creates an enrolment.
1031
+ * @param $data
1032
+ *
1033
+ * @return null
1034
+ * @throws Exception
1035
+ */
1036
+ public function postProgramsEnrolments($data)
1037
+ {
1038
+ $this->_addApiCall($this->apiCalls[__FUNCTION__]);
1039
+
1040
+ $url = self::REST_PROGRAM_ENROLMENTS;
1041
+ $this->setUrl($url)
1042
+ ->setVerb('POST')
1043
+ ->buildPostBody($data);
1044
+
1045
+ $response = $this->execute();
1046
+ if (isset($response->message)) {
1047
+ $message = 'Post programs enrolments : ' . $response->message;
1048
+ Mage::helper('connector')->log($message);
1049
+ Mage::helper('connector')->log($data);
1050
+ if (! in_array($response->message, $this->exludeMessages))
1051
+ Mage::helper('connector')->rayLog('100', $message, 'apiconnector/client.php', __LINE__);
1052
+ }
1053
+
1054
+ return $response;
1055
+ }
1056
+
1057
+ /**
1058
+ * Gets a program by id.
1059
+ * @param $id
1060
+ *
1061
+ * @return null
1062
+ * @throws Exception
1063
+ */
1064
+ public function getProgramById( $id )
1065
+ {
1066
+ $this->_addApiCall($this->apiCalls[__FUNCTION__]);
1067
+
1068
+ $url = self::REST_PROGRAM . $id;
1069
+ $this->setUrl($url)
1070
+ ->setVerb('GET');
1071
+
1072
+ $response = $this->execute();
1073
+ if (isset($response->message)) {
1074
+ $message = 'Get program by id ' . $id . ', ' . $response->message;
1075
+ Mage::helper('connector')->log($message);
1076
+ if (! in_array($response->message, $this->exludeMessages))
1077
+ Mage::helper("connector")->rayLog(100, $message, 'apiconnector/client.php', __LINE__);
1078
+
1079
+ }
1080
+
1081
+ return $response;
1082
+ }
1083
+
1084
+ /**
1085
+ * Gets a summary of reporting information for a specified campaign.
1086
+ * @param $campaignId
1087
+ *
1088
+ * @return null
1089
+ * @throws Exception
1090
+ */
1091
+ public function getCampaignSummary($campaignId)
1092
+ {
1093
+ $this->_addApiCall($this->apiCalls[__FUNCTION__]);
1094
+
1095
+ $url = 'https://apiconnector.com/v2/campaigns/' . $campaignId . '/summary';
1096
+
1097
+ $this->setUrl($url)
1098
+ ->setVerb('GET');
1099
+ $response = $this->execute();
1100
+
1101
+ if (isset($response->message)) {
1102
+ $message = 'Get Campaign Summary ' . $response->message . ' ,url : ' . $url;
1103
+ Mage::helper('connector')->log( $message );
1104
+ if (! in_array($response->message, $this->exludeMessages))
1105
+ Mage::helper('connector')->rayLog(100, $message, 'apiconnector/client.php', __LINE__);
1106
+ }
1107
+
1108
+ return $response;
1109
+ }
1110
+
1111
+ private function _addApiCall($path, $scope = 'default'){
1112
+ //log all api calls
1113
+ if (Mage::getStoreConfigFlag(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_DEBUG_API_CALLS))
1114
+ Mage::helper('connector')->log('Api call was made with path : ' . $path);
1115
+
1116
+ $configModel = Mage::getModel('email_connector/config');
1117
+ $configLastRun = $configModel->getHourTrigger();
1118
+
1119
+ try {
1120
+
1121
+ // check for last hour reset
1122
+ if ($configLastRun) {
1123
+
1124
+ //last run found let's check the difference
1125
+ $configLastRun = Mage::app()->getLocale()->date($configLastRun);
1126
+ $now = Mage::app()->getLocale()->date();
1127
+
1128
+ // reset the time and calls for the last hour or older by date
1129
+ if ($now->compareHour($configLastRun) == 1 || $now->compareDay($configLastRun) == 1){
1130
+
1131
+ // update the hour trigger
1132
+ $hourTriggerModel = Mage::getModel('email_connector/config')->getCollection()
1133
+ ->addFieldToFilter('path', Dotdigitalgroup_Email_Helper_Config::CONNECTOR_EMAIL_CONFIG_HOUR_TRIGGER)
1134
+ ->getFirstItem();
1135
+ //reset trigger
1136
+ $hourTriggerModel->setValue($now->toString(Zend_Date::ISO_8601))
1137
+ ->setScope($scope)
1138
+ ->save();
1139
+
1140
+ //reseting the api calls
1141
+ $this->_resetConfigApiCallsForLastHour();
1142
+ } else {
1143
+
1144
+ // increment the number for api call
1145
+ $apiCount = $configModel->getValueByPath($path);
1146
+ $value = $apiCount->getValue();
1147
+ $apiCount->setScope($scope)
1148
+ ->setIsApi('1')
1149
+ ->setValue(++$value)
1150
+ ->save();
1151
+ }
1152
+
1153
+ } else {
1154
+ // save the current date
1155
+ $date = Mage::getModel('core/date')->date(Zend_Date::ISO_8601);
1156
+ $configModel->setPath(Dotdigitalgroup_Email_Helper_Config::CONNECTOR_EMAIL_CONFIG_HOUR_TRIGGER)
1157
+ ->setScope($scope)
1158
+ ->setValue($date)
1159
+ ->save();
1160
+ }
1161
+ }catch (Exception $e){
1162
+ Mage::logException($e);
1163
+ }
1164
+
1165
+ }
1166
+
1167
+ private function _resetConfigApiCallsForLastHour() {
1168
+ foreach ( $this->apiCalls as $key => $path ) {
1169
+ $config = Mage::getModel('email_connector/config')->getCollection()
1170
+ ->addFieldToFilter('is_api', true)
1171
+ ->addFieldToFilter('path', $path)
1172
+ ->getFirstItem()
1173
+ ;
1174
+
1175
+ $config->setPath($path)
1176
+ ->setValue(0)
1177
+ ->save();
1178
+ }
1179
+ }
1180
+
1181
+ /**
1182
+ * Deletes a piece of transactional data by key.
1183
+ * @param $key
1184
+ * @param string $collectionName
1185
+ * @return object
1186
+ */
1187
+ public function deleteContactsTransactionalData($key, $collectionName = 'Orders')
1188
+ {
1189
+ $this->_addApiCall($this->apiCalls[__FUNCTION__]);
1190
+
1191
+ $url = 'https://apiconnector.com/v2/contacts/transactional-data/' . $collectionName .'/' . $key ;
1192
+ $this->setUrl($url)
1193
+ ->setVerb('DELETE');
1194
+ $response = $this->execute();
1195
+ if (isset($response->message))
1196
+ Mage::helper('connector')->log('DELETE CONTACTS TRANSACTIONAL DATA : ' . $url . ' ' . $response->message);
1197
+
1198
+ return $response;
1199
+ }
1200
+
1201
+ /**
1202
+ * Adds a document to a campaign as an attachment.
1203
+ * @param $campaignId
1204
+ * @param $data
1205
+ *
1206
+ * @return object
1207
+ * @throws Exception
1208
+ */
1209
+ public function postCampaignAttachments($campaignId, $data)
1210
+ {
1211
+ $url = self::REST_CREATE_CAMPAIGN . "/$campaignId/attachments";
1212
+ $this->setURl($url)
1213
+ ->setVerb('POST')
1214
+ ->buildPostBody($data);
1215
+ $result = $this->execute();
1216
+ if (isset($result->message)) {
1217
+ Mage::helper('connector')->log(' CAMPAIGN ATTACHMENT ' . $result->message);
1218
+ }
1219
+ return $result;
1220
+ }
1221
+
1222
+
1223
+ public function getNostoProducts($slotName, $email)
1224
+ {
1225
+ $recommended = Dotdigitalgroup_Email_Helper_Config::API_ENDPOINT . '/recommendations/email';
1226
+ $token = Mage::getStoreConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_DYNAMIC_CONTENT_NOSTO);
1227
+
1228
+ //check for strin length
1229
+ if (strlen($slotName) > 1 && strlen($email) > 1) {
1230
+
1231
+ $recommended .= '?elements=' . $slotName;
1232
+ $recommended .= '&emails=' . $email;
1233
+ }
1234
+
1235
+ $this->setApiUsername('')
1236
+ ->setApiPassword($token)
1237
+ ->setUrl($recommended)
1238
+ ->setVerb('GET');
1239
+
1240
+ $result = $this->execute();
1241
+
1242
+ if (isset($result->message)) {
1243
+ $message = $result->message;
1244
+ Mage::helper('connector')->log($message);
1245
+ Mage::helper("connector")->log("Nosto recommendation slot name : $slotName , email : $email");
1246
+ }
1247
+
1248
+ return $result;
1249
+ }
1250
+
1251
+ }
app/code/community/Dotdigitalgroup/Email/Model/Apiconnector/Contact.php ADDED
@@ -0,0 +1,326 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dotdigitalgroup_Email_Model_Apiconnector_Contact
4
+ {
5
+ private $_start;
6
+ private $_countCustomers = 0;
7
+
8
+ /**
9
+ * Contact sync.
10
+ *
11
+ * @return array
12
+ */
13
+ public function sync()
14
+ {
15
+ $result = array('success' => true, 'message' => '');
16
+ /** @var Dotdigitalgroup_Email_Helper_Data $helper */
17
+ $helper = Mage::helper('connector');
18
+ $this->_start = microtime(true);
19
+ //resourse allocation
20
+ $helper->allowResourceFullExecution();
21
+ foreach (Mage::app()->getWebsites(true) as $website) {
22
+ $enabled = Mage::helper('connector')->getWebsiteConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_API_ENABLED, $website);
23
+ $sync = Mage::helper('connector')->getWebsiteConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_SYNC_CONTACT_ENABLED, $website);
24
+ if ($enabled && $sync) {
25
+
26
+ if (!$this->_countCustomers)
27
+ $helper->log('---------- Start customer sync ----------');
28
+ $numUpdated = $this->exportCustomersForWebsite($website);
29
+ // show message for any number of customers
30
+ if ($numUpdated)
31
+ $result['message'] .= '</br>' . $website->getName() . ', updated customers = ' . $numUpdated;
32
+ }
33
+ }
34
+ //sync proccessed
35
+ if ($this->_countCustomers) {
36
+ $message = 'Total time for sync : ' . gmdate( "H:i:s", microtime( true ) - $this->_start ) . ', Total updated = ' . $this->_countCustomers;
37
+ $helper->log( $message );
38
+ $message .= $result['message'];
39
+ $result['message'] = $message;
40
+ }
41
+
42
+ return $result;
43
+ }
44
+
45
+ /**
46
+ * Execute the contact sync for the website
47
+ * number of customer synced.
48
+ * @param Mage_Core_Model_Website $website
49
+ *
50
+ * @return int|void
51
+ */
52
+ public function exportCustomersForWebsite(Mage_Core_Model_Website $website)
53
+ {
54
+ $updated = 0;
55
+ $customers = $headers = $allMappedHash = array();
56
+ $helper = Mage::helper('connector');
57
+ $pageSize = $helper->getWebsiteConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_SYNC_LIMIT, $website);
58
+ //skip if the mapping field is missing
59
+ if ( !$helper->getCustomerAddressBook($website))
60
+ return;
61
+ $fileHelper = Mage::helper('connector/file');
62
+ $contactModel = Mage::getModel('email_connector/contact');
63
+ $client = Mage::helper('connector')->getWebsiteApiClient($website);
64
+ $contacts = $contactModel->getContactsToImportForWebsite($website->getId(), $pageSize);
65
+
66
+ // no contacts for this webiste
67
+ if (!count($contacts))
68
+ return;
69
+ //create customer filename
70
+ $customersFile = strtolower($website->getCode() . '_customers_' . date('d_m_Y_Hi') . '.csv');
71
+ $helper->log('Customers file : ' . $customersFile);
72
+
73
+ //get customer ids
74
+ $customerIds = array();
75
+ foreach ($contacts as $contact) {
76
+ $customerIds[] = $contact->getCustomerId();
77
+ //remove contact with customer id set and no customer
78
+ if ($contact->getCustomerId() && ! Mage::getModel('customer/customer')->load($contact->getCustomerId())->getId())
79
+ $contact->delete();
80
+ }
81
+
82
+ //customer collection
83
+ $customerCollection = $this->getCollection($customerIds, $website);
84
+
85
+ /**
86
+ * HEADERS.
87
+ */
88
+ $mappedHash = $fileHelper->getWebsiteCustomerMappingDatafields($website);
89
+ $headers = $mappedHash;
90
+ //custom customer attributes
91
+ $customAttributes = $helper->getCustomAttributes($website);
92
+ foreach ($customAttributes as $data) {
93
+ $headers[] = $data['datafield'];
94
+ $allMappedHash[$data['attribute']] = $data['datafield'];
95
+ }
96
+ $headers[] = 'Email';
97
+ $headers[] = 'EmailType';
98
+ $fileHelper->outputCSV($fileHelper->getFilePath($customersFile), $headers);
99
+ /**
100
+ * END HEADERS.
101
+ */
102
+
103
+
104
+ foreach ($customerCollection as $customer) {
105
+ $contactModel = Mage::getModel('email_connector/contact')->loadByCustomerEmail($customer->getEmail(), $website->getId());
106
+ //remove contact with customer id set and no customer
107
+ if(!$contactModel->getId()){
108
+ Mage::helper("connector")->log('delete contact email :' . $customer->getEmail());
109
+ $contactModel->delete();
110
+ continue;
111
+ }
112
+ /**
113
+ * DATA.
114
+ */
115
+ $connectorCustomer = Mage::getModel('email_connector/apiconnector_customer', $mappedHash);
116
+ $connectorCustomer->setCustomerData($customer);
117
+ //count number of customers
118
+ $customers[] = $connectorCustomer;
119
+ foreach ($customAttributes as $data) {
120
+ $attribute = $data['attribute'];
121
+ $value = $customer->getData($attribute);
122
+ $connectorCustomer->setData($value);
123
+ }
124
+ //contact email and email type
125
+ $connectorCustomer->setData($customer->getEmail());
126
+ $connectorCustomer->setData('Html');
127
+ // save csv file data for customers
128
+ $fileHelper->outputCSV($fileHelper->getFilePath($customersFile), $connectorCustomer->toCSVArray());
129
+
130
+ /**
131
+ * END DATA.
132
+ */
133
+
134
+ //mark the contact as imported
135
+ $contactModel->setEmailImported(Dotdigitalgroup_Email_Model_Contact::EMAIL_CONTACT_IMPORTED);
136
+ $subscriber = Mage::getModel('newsletter/subscriber')->loadByEmail($customer->getEmail());
137
+ if ($subscriber->isSubscribed()) {
138
+ $contactModel->setIsSubscriber(1)
139
+ ->setSubscriberStatus($subscriber->getSubscriberStatus());
140
+ }
141
+
142
+ $contactModel->save();
143
+ $updated++;
144
+ }
145
+ $customerNum = count($customers);
146
+ $helper->log('Website : ' . $website->getName() . ', customers = ' . $customerNum);
147
+ $helper->log('---------------------------- execution time :' . gmdate("H:i:s", microtime(true) - $this->_start));
148
+
149
+ if (is_file($fileHelper->getFilePath($customersFile))) {
150
+ //import contacts
151
+ if ($updated > 0)
152
+ $client->postAddressBookContactsImport($customersFile, $helper->getCustomerAddressBook($website));
153
+ //archive file on success
154
+ $fileHelper->archiveCSV($customersFile);
155
+ }
156
+ $this->_countCustomers += $updated;
157
+ return $customerNum;
158
+ }
159
+
160
+ /**
161
+ * Sync a single contact.
162
+ *
163
+ * @param null $contactId
164
+ *
165
+ * @return mixed
166
+ * @throws Mage_Core_Exception
167
+ */
168
+ public function syncContact($contactId = null)
169
+ {
170
+ if ($contactId)
171
+ $contact = Mage::getModel('email_connector/contact')->load($contactId);
172
+ else {
173
+ $contact = Mage::registry('current_contact');
174
+ }
175
+ if (! $contact->getId()) {
176
+ Mage::getSingleton('adminhtml/session')->addError('No contact found!');
177
+ return false;
178
+ }
179
+
180
+ $websiteId = $contact->getWebsiteId();
181
+ $website = Mage::app()->getWebsite($websiteId);
182
+ $updated = 0;
183
+ $customers = $headers = $allMappedHash = array();
184
+ $helper = Mage::helper('connector');
185
+ $helper->log('---------- Start single customer sync ----------');
186
+ //skip if the mapping field is missing
187
+ if(!$helper->getCustomerAddressBook($website))
188
+ return false;
189
+ $fileHelper = Mage::helper('connector/file');
190
+
191
+ $customerId = $contact->getCustomerId();
192
+ if (!$customerId) {
193
+ Mage::getSingleton('adminhtml/session')->addError('Cannot manually sync guests!');
194
+ return false;
195
+ }
196
+ $client = Mage::helper('connector')->getWebsiteApiClient($website);
197
+
198
+ //create customer filename
199
+ $customersFile = strtolower($website->getCode() . '_customers_' . date('d_m_Y_Hi') . '.csv');
200
+ $helper->log('Customers file : ' . $customersFile);
201
+
202
+ /**
203
+ * HEADERS.
204
+ */
205
+ $mappedHash = $fileHelper->getWebsiteCustomerMappingDatafields($website);
206
+ $headers = $mappedHash;
207
+ //custom customer attributes
208
+ $customAttributes = $helper->getCustomAttributes($website);
209
+ foreach ($customAttributes as $data) {
210
+ $headers[] = $data['datafield'];
211
+ $allMappedHash[$data['attribute']] = $data['datafield'];
212
+ }
213
+
214
+ $headers[] = 'Email';
215
+ $headers[] = 'EmailType';
216
+ $fileHelper->outputCSV($fileHelper->getFilePath($customersFile), $headers);
217
+ /**
218
+ * END HEADERS.
219
+ */
220
+ $customerCollection = $this->getCollection(array($customerId));
221
+
222
+ foreach ($customerCollection as $customer) {
223
+ $contactModel = Mage::getModel('email_connector/contact')->loadByCustomerEmail($customer->getEmail(), $websiteId);
224
+ //skip contacts without customer id
225
+ if (!$contactModel->getId())
226
+ continue;
227
+ /**
228
+ * DATA.
229
+ */
230
+ $connectorCustomer = Mage::getModel('email_connector/apiconnector_customer', $mappedHash);
231
+ $connectorCustomer->setCustomerData($customer);
232
+ //count number of customers
233
+ $customers[] = $connectorCustomer;
234
+ foreach ($customAttributes as $data) {
235
+ $attribute = $data['attribute'];
236
+ $value = $customer->getData($attribute);
237
+ $connectorCustomer->setData($value);
238
+ }
239
+ //contact email and email type
240
+ $connectorCustomer->setData($customer->getEmail());
241
+ $connectorCustomer->setData('Html');
242
+ // save csv file data for customers
243
+ $fileHelper->outputCSV($fileHelper->getFilePath($customersFile), $connectorCustomer->toCSVArray());
244
+
245
+ /**
246
+ * END DATA.
247
+ */
248
+
249
+ //mark the contact as imported
250
+ $contactModel->setEmailImported(Dotdigitalgroup_Email_Model_Contact::EMAIL_CONTACT_IMPORTED);
251
+ $subscriber = Mage::getModel('newsletter/subscriber')->loadByEmail($customer->getEmail());
252
+ if ($subscriber->isSubscribed()) {
253
+ $contactModel->setIsSubscriber('1')
254
+ ->setSubscriberStatus($subscriber->getSubscriberStatus());
255
+ }
256
+
257
+ $contactModel->save();
258
+ $updated++;
259
+ }
260
+
261
+ if (is_file($fileHelper->getFilePath($customersFile))) {
262
+ //import contacts
263
+ if ($updated > 0)
264
+ $client->postAddressBookContactsImport($customersFile, $helper->getCustomerAddressBook($website));
265
+ //archive file on success
266
+ $fileHelper->archiveCSV($customersFile);
267
+ }
268
+ return $contact->getEmail();
269
+ }
270
+
271
+
272
+ /**
273
+ * get customer collection
274
+ * @param $customerIds
275
+ * @return Mage_Eav_Model_Entity_Collection_Abstract
276
+ * @throws Mage_Core_Exception
277
+ */
278
+ public function getCollection($customerIds)
279
+ {
280
+ $customerCollection = Mage::getResourceModel('customer/customer_collection')
281
+ ->addNameToSelect()
282
+ ->addAttributeToSelect('*')
283
+ ->joinAttribute('billing_street', 'customer_address/street', 'default_billing', null, 'left')
284
+ ->joinAttribute('billing_city', 'customer_address/city', 'default_billing', null, 'left')
285
+ ->joinAttribute('billing_country_code', 'customer_address/country_id', 'default_billing', null, 'left')
286
+ ->joinAttribute('billing_postcode', 'customer_address/postcode', 'default_billing', null, 'left')
287
+ ->joinAttribute('billing_telephone', 'customer_address/telephone', 'default_billing', null, 'left')
288
+ ->joinAttribute('billing_region', 'customer_address/region', 'default_billing', null, 'left')
289
+ ->joinAttribute('shipping_street', 'customer_address/street', 'default_shipping', null, 'left')
290
+ ->joinAttribute('shipping_city', 'customer_address/city', 'default_shipping', null, 'left')
291
+ ->joinAttribute('shipping_country_code','customer_address/country_id', 'default_shipping', null, 'left')
292
+ ->joinAttribute('shipping_postcode', 'customer_address/postcode', 'default_shipping', null, 'left')
293
+ ->joinAttribute('shipping_telephone', 'customer_address/telephone', 'default_shipping', null, 'left')
294
+ ->joinAttribute('shipping_region', 'customer_address/region', 'default_shipping', null, 'left')
295
+ ->addAttributeToFilter('entity_id', array('in' => $customerIds));
296
+ $customer_log = Mage::getSingleton('core/resource')->getTableName('log_customer');
297
+ $sales_flat_order_grid = Mage::getSingleton('core/resource')->getTableName('sales_flat_order_grid');
298
+ $sales_flat_quote = Mage::getSingleton('core/resource')->getTableName('sales_flat_quote');
299
+
300
+ // get the last login date from the log_customer table
301
+ $customerCollection->getSelect()->columns(
302
+ 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)")));
303
+
304
+ // customer order information
305
+ $alias = 'subselect';
306
+ $subselect = Mage::getModel('Varien_Db_Select', Mage::getSingleton('core/resource')->getConnection('core_read'))
307
+ ->from($sales_flat_order_grid, array(
308
+ 'customer_id as s_customer_id',
309
+ 'sum(grand_total) as total_spend',
310
+ 'count(*) as number_of_orders',
311
+ 'avg(grand_total) as average_order_value',
312
+ )
313
+ )->group('customer_id')
314
+ ;
315
+ $customerCollection->getSelect()->columns(array(
316
+ '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)"),
317
+ '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)"),
318
+ 'last_quote_id' => new Zend_Db_Expr("(SELECT entity_id FROM $sales_flat_quote WHERE customer_id = e.entity_id ORDER BY created_at DESC LIMIT 1)")
319
+ )
320
+ );
321
+ $customerCollection->getSelect()
322
+ ->joinLeft(array($alias => $subselect), "{$alias}.s_customer_id = e.entity_id");
323
+
324
+ return $customerCollection;
325
+ }
326
+ }
app/code/community/Dotdigitalgroup/Email/Model/Apiconnector/Customer.php ADDED
@@ -0,0 +1,647 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ private $subscriber_status = array(
18
+ Mage_Newsletter_Model_Subscriber::STATUS_SUBSCRIBED => 'Subscribed',
19
+ Mage_Newsletter_Model_Subscriber::STATUS_NOT_ACTIVE => 'Not Active',
20
+ Mage_Newsletter_Model_Subscriber::STATUS_UNSUBSCRIBED => 'Unsubscribed',
21
+ Mage_Newsletter_Model_Subscriber::STATUS_UNCONFIRMED => 'Unconfirmed'
22
+ );
23
+
24
+ /**
25
+ * constructor, mapping hash to map.
26
+ *
27
+ * @param $mappingHash
28
+ */
29
+ public function __construct( $mappingHash)
30
+ {
31
+ $this->setMappigHash($mappingHash);
32
+ }
33
+
34
+ /**
35
+ * Set key value data.
36
+ *
37
+ * @param $data
38
+ */
39
+ public function setData($data)
40
+ {
41
+ $this->customerData[] = $data;
42
+ }
43
+
44
+ /**
45
+ * Set customer data.
46
+ *
47
+ * @param Mage_Customer_Model_Customer $customer
48
+ */
49
+ public function setCustomerData(Mage_Customer_Model_Customer $customer)
50
+ {
51
+ $this->customer = $customer;
52
+ $this->setReviewCollection();
53
+ $website = $customer->getStore()->getWebsite();
54
+
55
+ if($website && Mage::helper('connector')->isSweetToothToGo($website))
56
+ $this->setRewardCustomer($customer);
57
+
58
+ foreach ($this->getMappingHash() as $key => $field) {
59
+
60
+ /**
61
+ * call user function based on the attribute mapped.
62
+ */
63
+ $function = 'get';
64
+ $exploded = explode('_', $key);
65
+ foreach ($exploded as $one) {
66
+ $function .= ucfirst($one);
67
+ }
68
+ try{
69
+ $value = call_user_func(array('self', $function));
70
+ $this->customerData[$key] = $value;
71
+ }catch (Exception $e){
72
+ Mage::logException($e);
73
+ }
74
+ }
75
+ }
76
+
77
+ public function setReviewCollection()
78
+ {
79
+ $customer_id = $this->customer->getId();
80
+ $collection = Mage::getModel('review/review')->getCollection()
81
+ ->addCustomerFilter($customer_id)
82
+ ->setOrder('review_id','DESC');
83
+ $this->reviewCollection = $collection;
84
+ }
85
+
86
+ public function getReviewCount()
87
+ {
88
+ return count($this->reviewCollection);
89
+ }
90
+
91
+ public function getLastReviewDate(){
92
+ if(count($this->reviewCollection))
93
+ return $this->reviewCollection->getFirstItem()->getCreatedAt();
94
+ return '';
95
+ }
96
+
97
+ /**
98
+ * Set reward customer
99
+ *
100
+ * @param Mage_Customer_Model_Customer $customer
101
+ */
102
+ public function setRewardCustomer(Mage_Customer_Model_Customer $customer)
103
+ {
104
+ //get tbt reward customer
105
+ $tbt_reward = Mage::getModel('rewards/customer')->getRewardsCustomer($customer);
106
+ $this->rewardCustomer = $tbt_reward;
107
+
108
+ //get transfers collection from tbt reward. only active and order by last updated.
109
+ $lastTransfers = $tbt_reward->getTransfers()
110
+ ->selectOnlyActive()
111
+ ->addOrder('last_update_ts', Varien_Data_Collection::SORT_ORDER_DESC);
112
+
113
+ $spent = $earn = null;
114
+
115
+ foreach($lastTransfers as $transfer) {
116
+ // if transfer quantity is greater then 0 then this is last points earned date. keep checking until earn is not null
117
+ if(is_null($earn) && $transfer->getQuantity() > 0){
118
+ $earn = $transfer->getEffectiveStart();
119
+ }
120
+ // id transfer quantity is less then 0 then this is last points spent date. keep checking until spent is not null
121
+ else if(is_null($spent) && $transfer->getQuantity() < 0) {
122
+ $spent = $transfer->getEffectiveStart();
123
+ }
124
+ // break if both spent and earn are not null (a value has been assigned)
125
+ if(!is_null($spent) && !is_null($earn)) {
126
+ break;
127
+ }
128
+ }
129
+
130
+ // if earn is not null (has a value) then assign the value to property
131
+ if($earn)
132
+ $this->rewardLastEarned = $earn;
133
+ // if spent is not null (has a value) then assign the value to property
134
+ if($spent)
135
+ $this->rewardLastSpent = $spent;
136
+
137
+ $tbt_expiry = Mage::getSingleton('rewards/expiry')
138
+ ->getExpiryDate($tbt_reward);
139
+
140
+ // if there is an expiry (has a value) then assign the value to property
141
+ if($tbt_expiry) $this->rewardExpiry = $tbt_expiry;
142
+ }
143
+
144
+ /**
145
+ * get customer id.
146
+ *
147
+ * @return mixed
148
+ */
149
+ public function getCustomerId()
150
+ {
151
+ return $this->customer->getId();
152
+ }
153
+
154
+ /**
155
+ * get first name.
156
+ *
157
+ * @return mixed
158
+ */
159
+ public function getFirstname(){
160
+ return $this->customer->getFirstname();
161
+ }
162
+
163
+ /**
164
+ * get last name.
165
+ *
166
+ * @return mixed
167
+ */
168
+ public function getLastname()
169
+ {
170
+ return $this->customer->getLastname();
171
+ }
172
+
173
+ /**
174
+ * get date of birth.
175
+ *
176
+ * @return mixed
177
+ */
178
+ public function getDob()
179
+ {
180
+ return $this->customer->getDob();
181
+ }
182
+
183
+ /**
184
+ * get customer gender.
185
+ *
186
+ * @return bool|string
187
+ */
188
+ public function getGender()
189
+ {
190
+ return $this->_getCustomerGender();
191
+ }
192
+
193
+ /**
194
+ * get customer prefix.
195
+ *
196
+ * @return mixed
197
+ */
198
+ public function getPrefix()
199
+ {
200
+ return $this->customer->getPrefix();
201
+ }
202
+
203
+ /**
204
+ * get customer suffix.
205
+ *
206
+ * @return mixed
207
+ */
208
+ public function getSuffix()
209
+ {
210
+ return $this->customer->getSuffix();
211
+ }
212
+
213
+ /**
214
+ * get website name.
215
+ *
216
+ * @return string
217
+ */
218
+ public function getWebsiteName()
219
+ {
220
+ return $this->_getWebsiteName();
221
+ }
222
+
223
+ /**
224
+ * get store name.
225
+ *
226
+ * @return null|string
227
+ */
228
+ public function getStoreName()
229
+ {
230
+ return $this->_getStoreName();
231
+ }
232
+
233
+ /**
234
+ * get customer created at date.
235
+ *
236
+ * @return mixed
237
+ */
238
+ public function getCreatedAt()
239
+ {
240
+ return $this->customer->getCreatedAt();
241
+ }
242
+
243
+ /**
244
+ * get customer last logged in date.
245
+ *
246
+ * @return mixed
247
+ */
248
+ public function getLastLoggedDate()
249
+ {
250
+ return $this->customer->getLastLoggedDate();
251
+ }
252
+
253
+ /**
254
+ * get cutomer group.
255
+ *
256
+ * @return string
257
+ */
258
+ public function getCustomerGroup()
259
+ {
260
+ return $this->_getCustomerGroup();
261
+ }
262
+
263
+ /**
264
+ * get billing address line 1.
265
+ *
266
+ * @return string
267
+ */
268
+ public function getBillingAddress1()
269
+ {
270
+ return $this->_getStreet($this->customer->getBillingStreet(), 1);
271
+ }
272
+
273
+ /**
274
+ * get billing address line 2.
275
+ *
276
+ * @return string
277
+ */
278
+ public function getBillingAddress2()
279
+ {
280
+ return $this->_getStreet($this->customer->getBillingStreet(), 2);
281
+ }
282
+
283
+ /**
284
+ * get billing city.
285
+ *
286
+ * @return mixed
287
+ */
288
+ public function getBillingCity()
289
+ {
290
+ return $this->customer->getBillingCity();
291
+ }
292
+
293
+ /**
294
+ * get billing country.
295
+ *
296
+ * @return mixed
297
+ */
298
+ public function getBillingCountry()
299
+ {
300
+ return $this->customer->getBillingCountryCode();
301
+ }
302
+
303
+ /**
304
+ * get billing state.
305
+ *
306
+ * @return mixed
307
+ */
308
+ public function getBillingState()
309
+ {
310
+ return $this->customer->getBillingRegion();
311
+ }
312
+
313
+ /**
314
+ * get billing postcode.
315
+ *
316
+ * @return mixed
317
+ */
318
+ public function getBillingPostcode()
319
+ {
320
+ return $this->customer->getBillingPostcode();
321
+ }
322
+
323
+ /**
324
+ * get billing phone.
325
+ *
326
+ * @return mixed
327
+ */
328
+ public function getBillingTelephone()
329
+ {
330
+ return $this->customer->getBillingTelephone();
331
+ }
332
+
333
+ /**
334
+ * get delivery address line 1.
335
+ *
336
+ * @return string
337
+ */
338
+ public function getDeliveryAddress1()
339
+ {
340
+ return $this->_getStreet($this->customer->getShippingStreet(), 1);
341
+ }
342
+
343
+ /**
344
+ * get delivery addrss line 2.
345
+ *
346
+ * @return string
347
+ */
348
+ public function getDeliveryAddress2()
349
+ {
350
+ return $this->_getStreet($this->customer->getShippingStreet(), 2);
351
+ }
352
+
353
+ /**
354
+ * get delivery city.
355
+ *
356
+ * @return mixed
357
+ */
358
+ public function getDeliveryCity()
359
+ {
360
+ return $this->customer->getShippingCity();
361
+ }
362
+
363
+ /**
364
+ * get delivery country.
365
+ *
366
+ * @return mixed
367
+ */
368
+ public function getDeliveryCountry(){
369
+ return $this->customer->getShippingCountryCode();
370
+ }
371
+
372
+ /**
373
+ * get delivery state.
374
+ *
375
+ * @return mixed
376
+ */
377
+ public function getDeliveryState()
378
+ {
379
+ return $this->customer->getShippingRegion();
380
+ }
381
+
382
+ /**
383
+ * get delivery postcode.
384
+ *
385
+ * @return mixed
386
+ */
387
+ public function getDeliveryPostcode()
388
+ {
389
+ return $this->customer->getShippingPostcode();
390
+ }
391
+
392
+ /**
393
+ * get delivery phone.
394
+ *
395
+ * @return mixed
396
+ */
397
+ public function getDeliveryTelephone(){
398
+ return $this->customer->getShippingTelephone();
399
+ }
400
+
401
+ /**
402
+ * get numbser of orders.
403
+ *
404
+ * @return mixed
405
+ */
406
+ public function getNumberOfOrders()
407
+ {
408
+ return $this->customer->getNumberOfOrders();
409
+ }
410
+
411
+ /**
412
+ * get average order value.
413
+ *
414
+ * @return mixed
415
+ */
416
+ public function getAverageOrderValue()
417
+ {
418
+ return $this->customer->getAverageOrderValue();
419
+ }
420
+
421
+ /**
422
+ * get total spend.
423
+ *
424
+ * @return mixed
425
+ */
426
+ public function getTotalSpend()
427
+ {
428
+ return $this->customer->getTotalSpend();
429
+ }
430
+
431
+ /**
432
+ * get last order date.
433
+ *
434
+ * @return mixed
435
+ */
436
+ public function getLastOrderDate()
437
+ {
438
+ return $this->customer->getLastOrderDate();
439
+ }
440
+
441
+ /**
442
+ * get last order id.
443
+ *
444
+ * @return mixed
445
+ */
446
+ public function getLastOrderId()
447
+ {
448
+ return $this->customer->getLastOrderId();
449
+ }
450
+
451
+ /**
452
+ * get last quote id.
453
+ *
454
+ * @return mixed
455
+ */
456
+ public function getLastQuoteId()
457
+ {
458
+ return $this->customer->getLastQuoteId();
459
+ }
460
+
461
+ /**
462
+ * get cutomer id.
463
+ *
464
+ * @return mixed
465
+ */
466
+ public function getId()
467
+ {
468
+ return $this->customer->getId();
469
+ }
470
+
471
+ /**
472
+ * get customer title.
473
+ *
474
+ * @return mixed
475
+ */
476
+ public function getTitle()
477
+ {
478
+ return $this->customer->getPrefix();
479
+ }
480
+
481
+ /**
482
+ * get total refund value.
483
+ *
484
+ * @return float|int
485
+ */
486
+ public function getTotalRefund()
487
+ {
488
+ $orders = Mage::getResourceModel('sales/order_collection')
489
+ ->addAttributeToFilter('customer_id', $this->customer->getId())
490
+ ;
491
+ $totalRefunded = 0;
492
+ foreach ($orders as $order) {
493
+ $refunded = $order->getTotalRefunded();
494
+ $totalRefunded += $refunded;
495
+ }
496
+
497
+ return $totalRefunded;
498
+ }
499
+
500
+ /**
501
+ * export to CSV.
502
+ *
503
+ * @return mixed
504
+ */
505
+ public function toCSVArray()
506
+ {
507
+ $result = $this->customerData;
508
+ return $result;
509
+ }
510
+
511
+ /**
512
+ * customer gender.
513
+ *
514
+ * @return bool|string
515
+ * @throws Mage_Core_Exception
516
+ */
517
+ private function _getCustomerGender()
518
+ {
519
+ $genderId = $this->customer->getGender();
520
+ if (is_numeric($genderId)) {
521
+ $gender = Mage::getResourceModel('customer/customer')
522
+ ->getAttribute('gender')
523
+ ->getSource()
524
+ ->getOptionText($genderId)
525
+ ;
526
+ return $gender;
527
+ }
528
+
529
+ return '';
530
+ }
531
+
532
+ private function _getStreet($street, $line){
533
+ $street = explode("\n", $street);
534
+ if(isset($street[$line - 1]))
535
+ return $street[$line - 1];
536
+ return '';
537
+ }
538
+
539
+ private function _getWebsiteName(){
540
+ $websiteId = $this->customer->getWebsiteId();
541
+ $website = Mage::app()->getWebsite($websiteId);
542
+ if($website)
543
+ return $website->getName();
544
+
545
+ return '';
546
+ }
547
+
548
+ private function _getStoreName()
549
+ {
550
+ $storeId = $this->customer->getStoreId();
551
+ $store = Mage::app()->getStore($storeId);
552
+ if($store)
553
+ return $store->getName();
554
+
555
+ return '';
556
+ }
557
+
558
+ /**
559
+ * @param mixed $mapping_hash
560
+ */
561
+ public function setMappingHash($mapping_hash)
562
+ {
563
+ $this->_mapping_hash = $mapping_hash;
564
+ }
565
+
566
+ /**
567
+ * @return mixed
568
+ */
569
+ public function getMappingHash()
570
+ {
571
+ return $this->_mapping_hash;
572
+ }
573
+
574
+ private function _getCustomerGroup(){
575
+ $groupId = $this->customer->getGroupId();
576
+ $group = Mage::getModel('customer/group')->load($groupId);
577
+ if($group){
578
+ return $group->getCode();
579
+ }
580
+ return '';
581
+ }
582
+
583
+ /**
584
+ * mapping hash value.
585
+ *
586
+ * @param $value
587
+ *
588
+ * @return $this
589
+ */
590
+ public function setMappigHash($value)
591
+ {
592
+ $this->_mapping_hash = $value;
593
+ return $this;
594
+ }
595
+
596
+ public function getRewardPointBalance()
597
+ {
598
+ return $this->cleanString($this->rewardCustomer->getPointsSummary());
599
+ }
600
+
601
+ public function getRewardPointPending()
602
+ {
603
+ return $this->cleanString($this->rewardCustomer->getPendingPointsSummary());
604
+ }
605
+
606
+ public function getRewardPointPendingTime()
607
+ {
608
+ return $this->cleanString($this->rewardCustomer->getPendingTimePointsSummary());
609
+ }
610
+
611
+ public function getRewardPointOnHold()
612
+ {
613
+ return $this->cleanString($this->rewardCustomer->getOnHoldPointsSummary());
614
+ }
615
+
616
+ public function getRewardPointExpiration()
617
+ {
618
+ if($this->rewardExpiry != "")
619
+ return Mage::getModel('core/date')->date('Y/m/d', strtotime($this->rewardExpiry));
620
+ return $this->rewardExpiry;
621
+ }
622
+
623
+ public function getRewardPointLastSpent()
624
+ {
625
+ return $this->rewardLastSpent;
626
+ }
627
+
628
+ public function getRewardPointLastEarn()
629
+ {
630
+ return $this->rewardLastEarned;
631
+ }
632
+
633
+ public function cleanString($string)
634
+ {
635
+ $cleanedString = preg_replace("/[^0-9]/","",$string);
636
+ if($cleanedString != "")
637
+ return (int) number_format($cleanedString, 0, '.', '');
638
+ return 0;
639
+ }
640
+
641
+ public function getSubscriberStatus()
642
+ {
643
+ $subscriber = Mage::getModel('newsletter/subscriber')->loadByCustomer($this->customer);
644
+ if($subscriber->getCustomerId())
645
+ return $this->subscriber_status[$subscriber->getSubscriberStatus()];
646
+ }
647
+ }
app/code/community/Dotdigitalgroup/Email/Model/Apiconnector/Test.php ADDED
@@ -0,0 +1,79 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 = 'TWFnZW50bzIwMTM=';
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 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(
69
+ base64_decode(self::TEST_API_PASSWORD));
70
+ $testEmail = self::TEST_CONTACT_EMAIL;
71
+ $contactId = self::TEST_CONTACT_ID;
72
+ $campaignId = self::TEST_API_CAMPAIGN;
73
+
74
+ /**
75
+ * send initial info
76
+ */
77
+ $this->sendIntallInfo($testEmail, $contactId, $campaignId);
78
+ }
79
+ }
app/code/community/Dotdigitalgroup/Email/Model/Campaign.php ADDED
@@ -0,0 +1,419 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ //campaign create vars
35
+ private $fromAddress;
36
+ private $replyAction;
37
+ private $replyAddress;
38
+ private $copyEmail;
39
+
40
+ /**
41
+ * @var object
42
+ */
43
+ public $transactionalClient;
44
+
45
+ /**
46
+ * constructor
47
+ */
48
+ public function _construct()
49
+ {
50
+ parent::_construct();
51
+ $this->_init('email_connector/campaign');
52
+
53
+ $this->transactionalClient = Mage::helper('connector/transactional')->getWebsiteApiClient();
54
+ }
55
+
56
+ /**
57
+ * @return $this|Mage_Core_Model_Abstract
58
+ */
59
+ protected function _beforeSave()
60
+ {
61
+ parent::_beforeSave();
62
+ $now = Mage::getSingleton('core/date')->gmtDate();
63
+ if ($this->isObjectNew()) {
64
+ $this->setCreatedAt($now);
65
+ }
66
+ $this->setUpdatedAt($now);
67
+ return $this;
68
+ }
69
+
70
+ /**
71
+ * @param $quoteId
72
+ * @param $storeId
73
+ * @return mixed
74
+ */
75
+ public function loadByQuoteId($quoteId, $storeId)
76
+ {
77
+ $collection = $this->getCollection()
78
+ ->addFieldToFilter('quote_id', $quoteId)
79
+ ->addFieldToFilter('store_id', $storeId);
80
+
81
+ if ($collection->getSize()) {
82
+ return $collection->getFirstItem();
83
+ } else {
84
+ $this->setQuoteId($quoteId)
85
+ ->setStoreId($storeId);
86
+ }
87
+
88
+ return $this;
89
+ }
90
+
91
+
92
+ /**
93
+ * Sending the campaigns.
94
+ */
95
+ public function sendCampaigns()
96
+ {
97
+ //create campaign first
98
+ $this->createEmailsToCampaigns();
99
+
100
+ //grab the emails not send
101
+ $emailsToSend = $this->_getEmailCampaigns();
102
+ $templateModel = Mage::getModel('email_connector/email_template');
103
+
104
+ foreach ($emailsToSend as $campaign) {
105
+
106
+ $email = $campaign->getEmail();
107
+ $storeId = $campaign->getStoreId();
108
+ $campaignId = $campaign->getCampaignId();
109
+ $store = Mage::app()->getStore($storeId);
110
+ $websiteId = $store->getWebsiteId();
111
+ $storeName = $store->getName();
112
+ $websiteName = $store->getWebsite()->getName();
113
+
114
+
115
+ if (!$campaignId) {
116
+ $campaign->setMessage('Missing campaign id: ' . $campaignId)
117
+ ->setIsSent(1)
118
+ ->save();
119
+ continue;
120
+ } elseif (!$email) {
121
+ $campaign->setMessage('Missing email : ' . $email)
122
+ ->setIsSent(1)
123
+ ->save();
124
+ continue;
125
+ }
126
+ try{
127
+ if ($campaign->getEventName() == 'Lost Basket') {
128
+ $client = Mage::helper('connector')->getWebsiteApiClient($websiteId);
129
+ $contactId = Mage::helper('connector')->getContactId($campaign->getEmail(), $websiteId);
130
+ if(is_numeric($contactId)) {
131
+
132
+ //update data field
133
+ $data = array(
134
+ array(
135
+ 'Key' => 'LAST_QUOTE_ID',
136
+ 'Value' => $campaign->getQuoteId()
137
+ )
138
+ );
139
+ $client->updateContactDatafieldsByEmail($campaign->getEmail(), $data);
140
+
141
+ $response = $client->postCampaignsSend($campaignId, array($contactId));
142
+ if (isset($response->message)) {
143
+ //update the failed to send email message
144
+ $campaign->setMessage($response->message)->setIsSent(1)->save();
145
+ }
146
+ $now = Mage::getSingleton('core/date')->gmtDate();
147
+ //record suscces
148
+ $campaign->setIsSent(1)
149
+ ->setMessage(NULL)
150
+ ->setSentAt($now)
151
+ ->save();
152
+ }else{
153
+ //update the failed to send email message- error message from post contact
154
+ $campaign->setContactMessage($contactId)->setIsSent(1)->save();
155
+ }
156
+ } elseif ($campaign->getEventName() == 'New Customer Account') {
157
+ $contactId = Mage::helper('connector/transactional')->getContactId($campaign->getEmail(), $websiteId);
158
+ if(is_numeric($contactId)){
159
+ Mage::helper('connector')->log($contactId);
160
+ $customerId = $campaign->getCustomerId();
161
+ $customer = Mage::getModel('customer/customer')->load($customerId);
162
+ $firstname = $customer->getFirstname();
163
+ $lastname = $customer->getLastname();
164
+ $data = array(
165
+ array(
166
+ 'Key' => 'STORE_NAME',
167
+ 'Value' => $storeName),
168
+ array(
169
+ 'Key' => 'WEBSITE_NAME',
170
+ 'Value' => $websiteName),
171
+ array(
172
+ 'Key' => 'FIRSTNAME',
173
+ 'Value' => $firstname),
174
+ array(
175
+ 'Key' => 'LASTNAME',
176
+ 'Value' => $lastname),
177
+ array(
178
+ 'Key' => 'CUSTOMER_ID',
179
+ 'Value' => $customerId)
180
+ );
181
+ // last order and last quote
182
+ $emailOrder = Mage::getModel('email_connector/sales_order');
183
+ $lastOrder = $emailOrder->getCustomerLastOrderId($customer);
184
+ $lastQuote = $emailOrder->getCustomerLastQuoteId($customer);
185
+
186
+ if($lastOrder){
187
+ $data[] = array(
188
+ 'Key' => 'LAST_ORDER_ID',
189
+ 'Value' => $lastOrder->getId()
190
+ );
191
+ }
192
+ if($lastQuote){
193
+ $data[] = array(
194
+ 'Key' => 'LAST_QUOTE_ID',
195
+ 'Value' => $lastQuote->getId()
196
+ );
197
+ }
198
+
199
+ $this->transactionalClient->updateContactDatafieldsByEmail($email, $data);
200
+
201
+ $response = $this->transactionalClient->postCampaignsSend($campaignId, array($contactId));
202
+ if (isset($response->message)) {
203
+ //update the failed to send email message
204
+ $campaign->setMessage($response->message)->setIsSent(1)->save();
205
+ } else {
206
+ $now = Mage::getSingleton('core/date')->gmtDate();
207
+ //record suscces
208
+ $campaign->setIsSent(1)
209
+ ->setMessage(NULL)
210
+ ->setSentAt($now)
211
+ ->save();
212
+ }
213
+ }else{
214
+ //update the failed to send email message- error message from post contact
215
+ $campaign->setContactMessage($contactId)->setIsSent(1)->save();
216
+ }
217
+
218
+ } elseif ($templateModel->getSalesEvent($campaign->getEventName()) or $campaign->getEventName() == 'Order Review') {
219
+ // transactional
220
+ $orderModel = Mage::getModel("sales/order")->loadByIncrementId($campaign->getOrderIncrementId());
221
+ $contactId = Mage::helper('connector/transactional')->getContactId($campaign->getEmail(), $websiteId);
222
+ if (is_numeric($contactId)) {
223
+ Mage::helper('connector')->log($contactId);
224
+ if ($orderModel->getCustomerId()) {
225
+ $firstname = $orderModel->getCustomerFirstname();
226
+ $lastname = $orderModel->getCustomerLastname();
227
+ } else {
228
+ $billing = $orderModel->getBillingAddress();
229
+ $firstname = $billing->getFirstname();
230
+ $lastname = $billing->getLastname();
231
+ }
232
+ $data = array(
233
+ array(
234
+ 'Key' => 'STORE_NAME',
235
+ 'Value' => $storeName),
236
+ array(
237
+ 'Key' => 'WEBSITE_NAME',
238
+ 'Value' => $websiteName),
239
+ array(
240
+ 'Key' => 'FIRSTNAME',
241
+ 'Value' => $firstname),
242
+ array(
243
+ 'Key' => 'LASTNAME',
244
+ 'Value' => $lastname),
245
+ array(
246
+ 'Key' => 'LAST_ORDER_ID',
247
+ 'Value' => $orderModel->getId()),
248
+ array(
249
+ 'Key' => 'LAST_QUOTE_ID',
250
+ 'Value' => $orderModel->getQuoteId()),
251
+ );
252
+ $this->transactionalClient->updateContactDatafieldsByEmail($email, $data);
253
+ $response = $this->transactionalClient->postCampaignsSend($campaignId, array($contactId));
254
+ if (isset($response->message)) {
255
+ //update the failed to send email message
256
+ $campaign->setMessage($response->message)->setIsSent(1)->save();
257
+ } else {
258
+ $now = Mage::getSingleton('core/date')->gmtDate();
259
+ //record suscces
260
+ $campaign->setIsSent(1)
261
+ ->setMessage(NULL)
262
+ ->setSentAt($now)
263
+ ->save();
264
+ }
265
+ }else{
266
+ //update the failed to send email message- error message from post contact
267
+ $campaign->setContactMessage($contactId)->setIsSent(1)->save();
268
+ }
269
+ }else{
270
+ $contactId = Mage::helper('connector/transactional')->getContactId($campaign->getEmail(), $websiteId);
271
+ if(is_numeric($contactId)){
272
+ Mage::helper('connector')->log($contactId);
273
+ $response = $this->transactionalClient->postCampaignsSend($campaignId, array($contactId));
274
+ if (isset($response->message)) {
275
+ //update the failed to send email message
276
+ $campaign->setMessage($response->message)->setIsSent(1)->save();
277
+ } else{
278
+ $now = Mage::getSingleton('core/date')->gmtDate();
279
+ //record suscces
280
+ $campaign->setIsSent(1)
281
+ ->setMessage(NULL)
282
+ ->setSentAt($now)
283
+ ->save();
284
+ }
285
+ }else{
286
+ //update the failed to send email message- error message from post contact
287
+ $campaign->setContactMessage($contactId)->setIsSent(1)->save();
288
+ }
289
+ }
290
+
291
+ }catch(Exception $e){
292
+ Mage::logException($e);
293
+ }
294
+ }
295
+ return;
296
+ }
297
+
298
+ /**
299
+ * @return mixed
300
+ */
301
+ private function _getEmailCampaigns()
302
+ {
303
+ $emailCollection = $this->getCollection();
304
+ $emailCollection->addFieldToFilter('is_sent', array('null' => true))
305
+ ->addFieldToFilter('campaign_id', array('notnull' => true))
306
+ ->addFieldToFilter('type', 1);
307
+ $emailCollection->getSelect()->order('campaign_id');
308
+ return $emailCollection;
309
+ }
310
+
311
+ /**
312
+ * create emails to campaigns
313
+ */
314
+ public function createEmailsToCampaigns()
315
+ {
316
+ $helper = Mage::helper('connector/transactional');
317
+ $emails = $this->getEmailsToCreateCampaigns();
318
+
319
+ foreach($emails as $email)
320
+ {
321
+ try {
322
+ $websiteId = $email->getWebsiteId();
323
+
324
+ if (!$this->fromAddress) {
325
+ if($email->getFromAddress())
326
+ $this->fromAddress = $email->getFromAddress();
327
+ else
328
+ $this->fromAddress = $helper->getFromAddress($websiteId);
329
+ }
330
+
331
+ if (!$this->replyAction)
332
+ $this->replyAction = $helper->getReplyAction($websiteId);
333
+ if ($this->replyAction == 'WebMailForward') {
334
+ if (!$this->replyAddress) {
335
+ $this->replyAddress = $helper->getReplyAddress($websiteId);
336
+ }
337
+ }
338
+ if (!$this->copyEmail)
339
+ $this->copyEmail = $helper->getSendCopy($websiteId);
340
+
341
+ if ($this->fromAddress && $this->replyAction) {
342
+ $data = array(
343
+ 'Name' => $email->getEventName(),
344
+ 'Subject' => $email->getSubject(),
345
+ 'FromName' => $email->getFromName(),
346
+ 'FromAddress' => $this->fromAddress,
347
+ 'HtmlContent' => $email->getHtmlContent(),
348
+ 'PlainTextContent' => $email->getPlainTextContent(),
349
+ 'ReplyAction' => $this->replyAction,
350
+ 'IsSplitTest' => false,
351
+ 'Status' => 'Unsent'
352
+ );
353
+ if ($this->replyAction == 'WebMailForward' && $this->replyAddress)
354
+ $data['ReplyToAddress'] = $this->replyAddress;
355
+ else
356
+ $data['ReplyToAddress'] = '';
357
+ }
358
+
359
+ if(isset($data)){
360
+ $client = Mage::helper('connector/transactional')->getWebsiteApiClient($websiteId);
361
+ $result = $client->postCampaign($data);
362
+ if (isset($result->message)) {
363
+ $email->setCreateMessage($result->message)
364
+ ->setIsCreated(1)
365
+ ->save();
366
+ continue;
367
+ }
368
+ Mage::helper('connector')->log('createEmailsToCampaigns ' . $result->id);
369
+
370
+ //attachment to campaign
371
+ if($email->getAttachmentId()){
372
+ $attachment = array(
373
+ 'id' => $email->getAttachmentId()
374
+ );
375
+ $attachmentResult = $client->postCampaignAttachments($result->id, $attachment);
376
+ if (isset($attachmentResult->message)) {
377
+ $email->setCreateMessage($attachmentResult->message)
378
+ ->setIsCreated(1)
379
+ ->save();
380
+ continue;
381
+ }
382
+ }
383
+
384
+ $email->setCampaignId($result->id)
385
+ ->setType(1)
386
+ ->setIsCreated(1)
387
+ ->save();
388
+
389
+ if($this->copyEmail){
390
+ $this->setEmail($this->copyEmail)
391
+ ->setIsCopy(1)
392
+ ->setCampaignId($result->id)
393
+ ->setEventName($email->getEventName())
394
+ ->setType(1)
395
+ ->setIsCreated(1)
396
+ ->save();
397
+ }
398
+ }
399
+ }catch(Exception $e){
400
+ Mage::logException($e);
401
+ }
402
+ }
403
+ }
404
+
405
+ /**
406
+ * get collection to create campaigns
407
+ *
408
+ * @param int $pageSize
409
+ * @return Mage_Eav_Model_Entity_Collection_Abstract
410
+ */
411
+ protected function getEmailsToCreateCampaigns($pageSize = 100)
412
+ {
413
+ $collection = $this->getCollection()
414
+ ->addFieldToFilter('is_created', array('null' => true))
415
+ ->addFieldToFilter('type', 2);
416
+ $collection->getSelect()->limit($pageSize);
417
+ return $collection;
418
+ }
419
+ }
app/code/community/Dotdigitalgroup/Email/Model/Config.php ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dotdigitalgroup_Email_Model_Config extends Mage_Core_Model_Abstract
4
+ {
5
+ public function _construct()
6
+ {
7
+ parent::_construct();
8
+ $this->_init('email_connector/config');
9
+ }
10
+
11
+ /**
12
+ * @return $this|Mage_Core_Model_Abstract
13
+ */
14
+ protected function _beforeSave()
15
+ {
16
+ $now = Mage::getSingleton('core/date')->gmtDate();
17
+ if ($this->isObjectNew()) {
18
+ $this->setCreatedAt($now);
19
+ }
20
+ $this->setUpdatedAt($now);
21
+
22
+ return parent::_beforeSave();
23
+ }
24
+
25
+
26
+ /**
27
+ * Get the date value for the hour trigger.
28
+ * Reset the api calls for more than an hour.
29
+ * @return bool
30
+ */
31
+ public function getHourTrigger()
32
+ {
33
+ $config = $this->getCollection()
34
+ ->addFieldToFilter('path', Dotdigitalgroup_Email_Helper_Config::CONNECTOR_EMAIL_CONFIG_HOUR_TRIGGER);
35
+ //found the config value
36
+ if ($config->getSize()) {
37
+ return $configData = $config->getFirstItem()->getValue();
38
+ }
39
+
40
+ return false;
41
+ }
42
+
43
+
44
+ /**
45
+ * Get the value for configuration path.
46
+ * @param $path
47
+ *
48
+ * @return mixed
49
+ */
50
+ public function getValueByPath( $path )
51
+ {
52
+ $collection = $this->getCollection()
53
+ ->addFieldToFilter('path', $path)
54
+ ->setPageSize(1);
55
+
56
+ //found the item
57
+ if ($collection->getSize()) {
58
+ return $collection->getFirstItem();
59
+ }
60
+
61
+ $this->setPath($path);
62
+ return $this;
63
+ }
64
+
65
+ }
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,333 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ 'last_quote_id' => array(
202
+ 'name' => 'LAST_QUOTE_ID',
203
+ 'type' => 'numeric',
204
+ 'visibility' => 'private',
205
+ ),
206
+ 'total_refund' => array(
207
+ 'name' => 'TOTAL_REFUND',
208
+ 'type' => 'numeric',
209
+ 'visibility' => 'private',
210
+ ),
211
+ 'review_count' => array(
212
+ 'name' => 'REVIEW_COUNT',
213
+ 'type' => 'numeric',
214
+ 'visibility' => 'private',
215
+ ),
216
+ 'last_review_date' => array(
217
+ 'name' => 'LAST_REVIEW_DATE',
218
+ 'type' => 'date',
219
+ 'visibility' => 'private',
220
+ ),
221
+ 'subscriber_status' => array(
222
+ 'name' => 'SUBSCRIBER_STATUS',
223
+ 'type' => 'string',
224
+ 'visibility' => 'private',
225
+ ),
226
+ );
227
+
228
+ /**
229
+ * transactional data default datafields.
230
+ *
231
+ * @var array
232
+ */
233
+ private $_transactionalDefaultDatafields = array(
234
+ array(
235
+ 'name' => 'CUSTOMER_ID',
236
+ 'type' => 'string',
237
+ 'visibility' => 'private',
238
+ ),array(
239
+ 'name' => 'LAST_ORDER_ID',
240
+ 'type' => 'numeric',
241
+ 'visibility' => 'private',
242
+ ),array(
243
+ 'name' => 'ORDER_INCREMENT_ID',
244
+ 'type' => 'numeric',
245
+ 'visibility' => 'private',
246
+ ),
247
+ array(
248
+ 'name' => 'WEBSITE_NAME',
249
+ 'type' => 'string',
250
+ 'visibility' => 'private',
251
+ ),
252
+ array(
253
+ 'name' => 'STORE_NAME',
254
+ 'type' => 'string',
255
+ 'visibility' => 'private',
256
+ ),
257
+ array(
258
+ 'name' => 'LAST_ORDER_DATE',
259
+ 'type' => 'date',
260
+ 'visibility' => 'private',
261
+ )
262
+ );
263
+
264
+ /**
265
+ * @param array $contactDatafields
266
+ */
267
+ public function setContactDatafields($contactDatafields)
268
+ {
269
+ $this->_contactDatafields = $contactDatafields;
270
+ }
271
+
272
+ /**
273
+ * @return array
274
+ */
275
+ public function getContactDatafields()
276
+ {
277
+ return $this->_contactDatafields;
278
+ }
279
+
280
+ /**
281
+ * @param array $transactionalDefaultDatafields
282
+ */
283
+ public function setTransactionalDefaultDatafields($transactionalDefaultDatafields)
284
+ {
285
+ $this->_transactionalDefaultDatafields = $transactionalDefaultDatafields;
286
+ }
287
+
288
+ /**
289
+ * @return array
290
+ */
291
+ public function getTransactionalDefaultDatafields()
292
+ {
293
+ return $this->_transactionalDefaultDatafields;
294
+ }
295
+
296
+ /**
297
+ * @param mixed $defaultDataFields
298
+ */
299
+ public function setDefaultDataFields($defaultDataFields)
300
+ {
301
+ $this->_defaultDataFields = $defaultDataFields;
302
+ }
303
+
304
+ /**
305
+ * @return mixed
306
+ */
307
+ public function getDefaultDataFields()
308
+ {
309
+ return $this->_defaultDataFields;
310
+ }
311
+
312
+ /**
313
+ * set a single datafield.
314
+ *
315
+ * @param $name
316
+ * @param $value
317
+ * @param string $type
318
+ * @param string $visibility
319
+ *
320
+ * @return array
321
+ */
322
+ public function setDatafield($name, $value, $type = 'string', $visibility = 'public')
323
+ {
324
+ $this->datafields[] = array(
325
+ 'name' => $name,
326
+ 'value' => $value,
327
+ 'type' => $type,
328
+ 'visibility' => $visibility
329
+ );
330
+ return $this->datafields;
331
+ }
332
+
333
+ }
app/code/community/Dotdigitalgroup/Email/Model/Connector/Order.php ADDED
@@ -0,0 +1,279 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ * @var array
78
+ */
79
+ public $custom = array();
80
+
81
+ /**
82
+ * set the order information
83
+ * @param Mage_Sales_Model_Order $orderData
84
+ */
85
+ public function __construct(Mage_Sales_Model_Order $orderData)
86
+ {
87
+ $customerModel = Mage::getModel('customer/customer');
88
+ $customerModel->load($orderData->getCustomerId());
89
+
90
+ $this->id = $orderData->getIncrementId();
91
+ $this->quote_id = $orderData->getQuoteId();
92
+ $this->email = $orderData->getCustomerEmail();
93
+ $this->store_name = $orderData->getStoreName();
94
+
95
+ $created_at = new Zend_Date($orderData->getCreatedAt(), Zend_Date::ISO_8601);
96
+
97
+ $this->purchase_date = $created_at->toString(Zend_Date::ISO_8601);
98
+ $this->delivery_method = $orderData->getShippingDescription();
99
+ $this->delivery_total = $orderData->getShippingAmount();
100
+ $this->currency = $orderData->getStoreCurrencyCode();
101
+
102
+ if ($payment = $orderData->getPayment())
103
+ $this->payment = $payment->getMethodInstance()->getTitle();
104
+ $this->couponCode = $orderData->getCouponCode();
105
+
106
+ /**
107
+ * custom order attributes
108
+ */
109
+ $helper = Mage::helper('connector');
110
+ $website = Mage::app()->getStore($orderData->getStore())->getWebsite();
111
+ $customAttributes = $helper->getConfigSelectedCustomOrderAttributes($website);
112
+ if($customAttributes){
113
+ $fields = $helper->getOrderTableDescription();
114
+ foreach($customAttributes as $customAttribute){
115
+ if(isset($fields[$customAttribute])){
116
+ $field = $fields[$customAttribute];
117
+ $value = $this->_getCustomAttributeValue($field, $orderData);
118
+ if($value)
119
+ $this->_assignCustom($field, $value);
120
+ }
121
+ }
122
+ }
123
+
124
+ /**
125
+ * Billing address.
126
+ */
127
+ if ($orderData->getBillingAddress()) {
128
+ $billingData = $orderData->getBillingAddress()->getData();
129
+ $this->billing_address = array(
130
+ 'billing_address_1' => $this->_getStreet($billingData['street'], 1),
131
+ 'billing_address_2' => $this->_getStreet($billingData['street'], 2),
132
+ 'billing_city' => $billingData['city'],
133
+ 'billing_region' => $billingData['region'],
134
+ 'billing_country' => $billingData['country_id'],
135
+ 'billing_postcode' => $billingData['postcode'],
136
+ );
137
+ }
138
+ /**
139
+ * Shipping address.
140
+ */
141
+ if ($orderData->getShippingAddress()) {
142
+ $shippingData = $orderData->getShippingAddress()->getData();
143
+
144
+ $this->delivery_address = array(
145
+ 'delivery_address_1' => $this->_getStreet($shippingData['street'], 1),
146
+ 'delivery_address_2' => $this->_getStreet($shippingData['street'], 2),
147
+ 'delivery_city' => $shippingData['city'],
148
+ 'delivery_region' => $shippingData['region'],
149
+ 'delivery_country' => $shippingData['country_id'],
150
+ 'delivery_postcode' => $shippingData['postcode']
151
+ );
152
+ }
153
+
154
+ /**
155
+ * Order items.
156
+ */
157
+ foreach ($orderData->getAllItems() as $productItem) {
158
+
159
+ //load product by product id, for compatibility
160
+ $product = Mage::getModel('catalog/product')->load($productItem->getProductId());
161
+
162
+ if ($product) {
163
+ // category names
164
+ $categoryCollection = $product->getCategoryCollection()
165
+ ->addAttributeToSelect( 'name' );
166
+
167
+ foreach ( $categoryCollection as $cat ) {
168
+ $categories = array();
169
+ $categories[] = $cat->getName();
170
+ $this->categories[]['Name'] = substr( implode( ', ', $categories ), 0, 244 );
171
+ }
172
+
173
+ $attributeSetModel = Mage::getModel( "eav/entity_attribute_set" );
174
+ $attributeSetModel->load( $product->getAttributeSetId() );
175
+ $attributeSetName = $attributeSetModel->getAttributeSetName();
176
+ $this->products[] = array(
177
+ 'name' => $productItem->getName(),
178
+ 'sku' => $productItem->getSku(),
179
+ 'qty' => (int) number_format( $productItem->getData( 'qty_ordered' ), 2 ),
180
+ 'price' => (float) number_format( $productItem->getPrice(), 2, '.', '' ),
181
+ 'attribute-set' => $attributeSetName
182
+ );
183
+ } else {
184
+ // when no product information is available limit to this data
185
+ $this->products[] = array(
186
+ 'name' => $productItem->getName(),
187
+ 'sku' => $productItem->getSku(),
188
+ 'qty' => (int) number_format( $productItem->getData( 'qty_ordered' ), 2 ),
189
+ 'price' => (float) number_format( $productItem->getPrice(), 2, '.', '' )
190
+ );
191
+ }
192
+ }
193
+
194
+ $this->order_subtotal = (float)number_format($orderData->getData('subtotal'), 2 , '.', '');
195
+ $this->discount_ammount = (float)number_format($orderData->getData('discount_amount'), 2 , '.', '');
196
+ $orderTotal = abs($orderData->getData('grand_total') - $orderData->getTotalRefunded());
197
+ $this->order_total = (float)number_format($orderTotal, 2 , '.', '');
198
+
199
+ return true;
200
+ }
201
+ /**
202
+ * get the street name by line number
203
+ * @param $street
204
+ * @param $line
205
+ * @return string
206
+ */
207
+ private function _getStreet($street, $line)
208
+ {
209
+ $street = explode("\n", $street);
210
+ if ($line == 1) {
211
+ return $street[0];
212
+ }
213
+ if (isset($street[$line -1])) {
214
+
215
+ return $street[$line - 1];
216
+ } else {
217
+
218
+ return '';
219
+ }
220
+ }
221
+
222
+ /**
223
+ * exposes the class as an array of objects.
224
+ * @return array
225
+ */
226
+ public function expose()
227
+ {
228
+ return get_object_vars($this);
229
+
230
+ }
231
+
232
+ private function _getCustomAttributeValue($field, $orderData)
233
+ {
234
+ $type = $field['DATA_TYPE'];
235
+
236
+ $function = 'get';
237
+ $exploded = explode('_', $field['COLUMN_NAME']);
238
+ foreach ($exploded as $one) {
239
+ $function .= ucfirst($one);
240
+ }
241
+
242
+ $value = null;
243
+ if($type == 'int' or $type == 'smallint'){
244
+ try{
245
+ $value = (int)$orderData->$function();
246
+ }catch (Exception $e){
247
+ Mage::logException($e);
248
+ }
249
+ }
250
+ if($type == 'decimal'){
251
+ try{
252
+ $value = (float)number_format($orderData->$function(), 2 , '.', '');
253
+ }catch (Exception $e){
254
+ Mage::logException($e);
255
+ }
256
+ }
257
+ if($type == 'timestamp' or $type == 'datetime'){
258
+ try{
259
+ $date = new Zend_Date($orderData->$function(), Zend_Date::ISO_8601);
260
+ $value = $date->toString(Zend_Date::ISO_8601);
261
+ }catch (Exception $e){
262
+ Mage::logException($e);
263
+ }
264
+ }
265
+
266
+ return $value;
267
+ }
268
+
269
+ /**
270
+ * create property on runtime
271
+ *
272
+ * @param $field
273
+ * @param $value
274
+ */
275
+ private function _assignCustom($field, $value)
276
+ {
277
+ $this->custom[$field['COLUMN_NAME']] = $value;
278
+ }
279
+ }
app/code/community/Dotdigitalgroup/Email/Model/Contact.php ADDED
@@ -0,0 +1,290 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ Mage::helper('connector')->rayLog('300', $e);
53
+ }
54
+ return $num;
55
+ }
56
+
57
+
58
+ /**
59
+ * Load contact by customer id
60
+ * @param $customerId
61
+ * @return mixed
62
+ */
63
+ public function loadByCustomerId($customerId)
64
+ {
65
+ $collection = $this->getCollection()
66
+ ->addFieldToFilter('customer_id', $customerId)
67
+ ->setPageSize(1);
68
+
69
+ if($collection->count())
70
+ return $collection->getFirstItem();
71
+
72
+ return $this;
73
+ }
74
+
75
+ /**
76
+ * get all customer contacts not imported for a website.
77
+ *
78
+ * @param $websiteId
79
+ * @param int $pageSize
80
+ *
81
+ * @return Dotdigitalgroup_Email_Model_Resource_Contact_Collection
82
+ */
83
+ public function getContactsToImportForWebsite($websiteId, $pageSize = 100)
84
+ {
85
+ $collection = $this->getCollection()
86
+ ->addFieldToFilter('website_id', $websiteId)
87
+ ->addFieldToFilter('email_imported', array('null' => true))
88
+ ->addFieldToFilter('customer_id', array('notnull' => true));
89
+
90
+ $collection->getSelect()->limit($pageSize);
91
+
92
+ return $collection;
93
+ }
94
+
95
+ /**
96
+ * Get missing contacts.
97
+ * @param $websiteId
98
+ * @param int $pageSize
99
+ * @return mixed
100
+ */
101
+ public function getMissingContacts($websiteId, $pageSize = 100)
102
+ {
103
+ $collection = $this->getCollection()
104
+ ->addFieldToFilter('contact_id', array('null' => true))
105
+ ->addFieldToFilter('suppressed', null)
106
+ ->addFieldToFilter('website_id', $websiteId);
107
+
108
+ $collection->getSelect()->limit($pageSize);
109
+
110
+ return $collection->load();
111
+ }
112
+
113
+ /**
114
+ * Load Contact by Email.
115
+ * @param $email
116
+ * @param $websiteId
117
+ * @return $this
118
+ */
119
+ public function loadByCustomerEmail($email, $websiteId)
120
+ {
121
+ $collection = $this->getCollection()
122
+ ->addFieldToFilter('email', $email)
123
+ ->addFieldToFilter('website_id', $websiteId)
124
+ ->setPageSize(1);
125
+
126
+ if ($collection->getSize()) {
127
+ return $collection->getFirstItem();
128
+ } else {
129
+ $this->setEmail($email)
130
+ ->setWebsiteId($websiteId);
131
+ }
132
+ return $this;
133
+ }
134
+
135
+ /**
136
+ * batch non imported subscribers for a website.
137
+ * @param $website
138
+ * @param int $limit
139
+ *
140
+ * @return Dotdigitalgroup_Email_Model_Resource_Contact_Collection
141
+ */
142
+ public function getSubscribersToImport($website, $limit = 1000)
143
+ {
144
+
145
+ $storeIds = $website->getStoreIds();
146
+ $collection = $this->getCollection()
147
+ ->addFieldToFilter('is_subscriber', array('notnull' => true))
148
+ ->addFieldToFilter('subscriber_imported', array('null' => true))
149
+ ->addFieldToFilter('store_id', array('in' => $storeIds));
150
+
151
+ $collection->getSelect()->limit($limit);
152
+
153
+ return $collection;
154
+ }
155
+
156
+ /**
157
+ * get all not imported guests for a website.
158
+ * @param $website
159
+ *
160
+ * @return Dotdigitalgroup_Email_Model_Resource_Contact_Collection
161
+ */
162
+ public function getGuests($website)
163
+ {
164
+ $guestCollection = $this->getCollection()
165
+ ->addFieldToFilter('is_guest', array('notnull' => true))
166
+ ->addFieldToFilter('email_imported', array('null' => true))
167
+ ->addFieldToFilter('website_id', $website->getId());
168
+ return $guestCollection->load();
169
+ }
170
+
171
+ public function getNumberOfImportedContacs()
172
+ {
173
+ $collection = $this->getCollection()
174
+ ->addFieldToFilter('email_imported', array('notnull' => true));
175
+
176
+ return $collection->getSize();
177
+ }
178
+
179
+
180
+ /**
181
+ * Set all imported subscribers for reimport.
182
+ *
183
+ * @return int
184
+ */
185
+ public function resetSubscribers() {
186
+
187
+ /** @var $coreResource Mage_Core_Model_Resource */
188
+ $coreResource = Mage::getSingleton( 'core/resource' );
189
+
190
+ /** @var $conn Varien_Db_Adapter_Pdo_Mysql */
191
+ $conn = $coreResource->getConnection( 'core_write' );
192
+
193
+ try {
194
+ $num = $conn->update(
195
+ $coreResource->getTableName( 'email_connector/contact' ),
196
+ array('subscriber_imported' => new Zend_Db_Expr( 'null' ) ),
197
+ $conn->quoteInto('subscriber_imported is ?', new Zend_Db_Expr('not null')));
198
+
199
+ } catch ( Exception $e ) {
200
+ Mage::logException($e);
201
+ Mage::helper('connector')->getRaygunClient()->SendException($e, array(Mage::getBaseUrl('web')));
202
+ }
203
+
204
+ return $num;
205
+ }
206
+
207
+ /**
208
+ * Get the number of customers for a website.
209
+ * @param int $websiteId
210
+ *
211
+ * @return int
212
+ */
213
+ public function getNumberCustomerContacts($websiteId = 0)
214
+ {
215
+ $countContacts = Mage::getModel('email_connector/contact')->getCollection()
216
+ ->addFieldToFilter('customer_id', array('gt' => '0'))
217
+ ->addFieldToFilter('website_id', $websiteId)
218
+ ->getSize();
219
+ return $countContacts;
220
+ }
221
+
222
+ /**
223
+ *
224
+ * Get number of suppressed contacts as customer.
225
+ * @param int $websiteId
226
+ *
227
+ * @return int
228
+ */
229
+ public function getNumberCustomerSuppressed( $websiteId = 0 )
230
+ {
231
+ $countContacts = Mage::getModel('email_connector/contact')->getCollection()
232
+ ->addFieldToFilter('customer_id', array('gt' => 0))
233
+ ->addFieldToFilter('website_id', $websiteId)
234
+ ->addFieldToFilter('suppressed', '1')
235
+ ->getSize();
236
+
237
+ return $countContacts;
238
+ }
239
+
240
+ /**
241
+ * Get number of synced customers.
242
+ * @param int $websiteId
243
+ *
244
+ * @return int
245
+ */
246
+ public function getNumberCustomerSynced( $websiteId = 0 )
247
+ {
248
+ $countContacts = Mage::getModel('email_connector/contact')->getCollection()
249
+ ->addFieldToFilter('customer_id', array('gt' => 0))
250
+ ->addFieldToFilter('website_id', $websiteId)
251
+ ->addFieldToFilter('email_imported' , '1')
252
+ ->getSize();
253
+
254
+ return $countContacts;
255
+
256
+ }
257
+
258
+ /**
259
+ * Get number of subscribers synced.
260
+ * @param int $websiteId
261
+ *
262
+ * @return int
263
+ */
264
+ public function getNumberSubscribersSynced( $websiteId = 0 )
265
+ {
266
+ $countContacts = Mage::getModel('email_connector/contact')->getCollection()
267
+ ->addFieldToFilter('subscriber_status', Dotdigitalgroup_Email_Model_Newsletter_Subscriber::STATUS_SUBSCRIBED)
268
+ ->addFieldToFilter('subscriber_imported', '1')
269
+ ->addFieldToFilter('website_id', $websiteId)
270
+ ->getSize();
271
+
272
+ return $countContacts;
273
+ }
274
+
275
+ /**
276
+ * Get number of subscribers.
277
+ * @param int $websiteId
278
+ *
279
+ * @return int
280
+ */
281
+ public function getNumberSubscribers( $websiteId = 0 )
282
+ {
283
+
284
+ $countContacts = Mage::getModel('email_connector/contact')->getCollection()
285
+ ->addFieldToFilter('subscriber_status', Dotdigitalgroup_Email_Model_Newsletter_Subscriber::STATUS_SUBSCRIBED)
286
+ ->addFieldToFilter('website_id', $websiteId)
287
+ ->getSize();
288
+ return $countContacts;
289
+ }
290
+ }
app/code/community/Dotdigitalgroup/Email/Model/Controller/Observer.php ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dotdigitalgroup_Email_Model_Controller_Observer
4
+ {
5
+ /**
6
+ * @param $observer
7
+ *
8
+ * @return $this
9
+ */
10
+ public function controllerActionPostdispatch( $observer )
11
+ {
12
+ //event data
13
+ $event = $observer->getEvent();
14
+
15
+ //check for module name is a match for current request
16
+ if ($event->getControllerAction()->getRequest()->getModuleName() == 'connector') {
17
+
18
+ //check if the geoip module is installed
19
+ $modules = Mage::getConfig()->getNode('modules')->children();
20
+ $modulesArray = (array)$modules;
21
+
22
+ //module installed make sure don't redirect
23
+ if (isset($modulesArray['Sandfox_GeoIP'])) {
24
+
25
+ //order id param
26
+ $orderId = $event->getControllerAction()->getRequest()->getParam( 'order_id', false );
27
+
28
+ //order id param is set
29
+ if ( $orderId ) {
30
+ $order = Mage::getModel( 'sales/order' )->load( $orderId );
31
+ $store = Mage::app()->getStore( $order->getStore() );
32
+ //order still exits and store name is different than the order
33
+ if ( $order->getId() && $store->getName() != Mage::app()->getStore()->getName()) {
34
+
35
+ //redirect to original store
36
+ $event->getControllerAction()->getResponse()->setRedirect( $store->getCurrentUrl( false ) );
37
+ }
38
+ }
39
+ }
40
+ }
41
+ return $this;
42
+ }
43
+ }
app/code/community/Dotdigitalgroup/Email/Model/Cron.php ADDED
@@ -0,0 +1,121 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ $result = Mage::getModel('email_connector/apiconnector_contact')->sync();
12
+ return $result;
13
+ }
14
+
15
+ /**
16
+ * CRON FOR LOST BASKET
17
+ */
18
+ public function lostBaskets()
19
+ {
20
+ //don't execute if the cron is running from shell
21
+ if (! Mage::getStoreConfigFlag(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_ABANDONED_CART_SHELL)) {
22
+ // send lost basket
23
+ Mage::getModel( 'email_connector/sales_quote' )->proccessLostBaskets();
24
+ }
25
+ }
26
+
27
+ /**
28
+ * CRON FOR SYNC REVIEWS and REGISTER ORDER REVIEW CAMPAIGNS
29
+ */
30
+ public function reviewsAndWishlist()
31
+ {
32
+ //sync reviews
33
+ $this->reviewSync();
34
+ //sync wishlist
35
+ Mage::getModel('email_connector/wishlist')->sync();
36
+ }
37
+
38
+ /**
39
+ * review sync
40
+ */
41
+ public function reviewSync()
42
+ {
43
+ //find orders to review and register campaign
44
+ Mage::getModel('email_connector/sales_order')->createReviewCampaigns();
45
+ //sync reviews
46
+ $result = Mage::getModel('email_connector/review')->sync();
47
+ return $result;
48
+ }
49
+
50
+ /**
51
+ * CRON FOR ORDER TRANSACTIONAL DATA
52
+ */
53
+ public function orderSync()
54
+ {
55
+ // send order
56
+ $result = Mage::getModel('email_connector/sales_order')->sync();
57
+ return $result;
58
+ }
59
+
60
+ /**
61
+ * CRON FOR SUBSCRIBERS AND GUEST CONTACTS
62
+ */
63
+ public function subscribersAndGuestSync()
64
+ {
65
+ //sync subscribers
66
+ $subscriberModel = Mage::getModel('email_connector/newsletter_subscriber');
67
+ $result = $subscriberModel->sync();
68
+
69
+ //unsubscribe suppressed contacts
70
+ $subscriberModel->unsubscribe();
71
+
72
+ //sync guests
73
+ Mage::getModel('email_connector/customer_guest')->sync();
74
+ return $result;
75
+ }
76
+
77
+ /**
78
+ * CRON FOR EMAILS SENDING
79
+ */
80
+ public function sendMappedEmails()
81
+ {
82
+ Mage::getModel('email_connector/campaign')->sendCampaigns();
83
+
84
+ return $this;
85
+ }
86
+
87
+ /**
88
+ * CLEAN ARHIVED FOLDERS
89
+ */
90
+ public function cleaning()
91
+ {
92
+ $helper = Mage::helper('connector/file');
93
+ $archivedFolder = $helper->getArchiveFolder();
94
+ $result = $helper->deleteDir($archivedFolder);
95
+ $message = 'Cleaning cronjob result : ' . $result;
96
+ $helper->log($message);
97
+ Mage::helper('connector')->rayLog('10', $message, 'model/cron.php');
98
+ return $result;
99
+ }
100
+
101
+
102
+ /**
103
+ * Last customer sync date.
104
+ * @return bool|string
105
+ */
106
+ public function getLastCustomerSync(){
107
+
108
+ $schedules = Mage::getModel('cron/schedule')->getCollection();
109
+ $schedules->getSelect()->limit(1)->order('executed_at DESC');
110
+ $schedules->addFieldToFilter('status', Mage_Cron_Model_Schedule::STATUS_SUCCESS);
111
+ $schedules->addFieldToFilter('job_code', 'connector_email_customer_sync');
112
+ $schedules->load();
113
+
114
+ if (count($schedules) == 0) {
115
+ return false;
116
+ }
117
+ $executedAt = $schedules->getFirstItem()->getExecutedAt();
118
+ return Mage::getModel('core/date')->date(NULL, $executedAt);
119
+ }
120
+
121
+ }
app/code/community/Dotdigitalgroup/Email/Model/Customer.php ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dotdigitalgroup_Email_Model_Customer extends Mage_Customer_Model_Customer
4
+ {
5
+ /**
6
+ * overwrites the default function
7
+ *
8
+ * @param string $type
9
+ * @param string $backUrl
10
+ * @param string $storeId
11
+ * @return Mage_Customer_Model_Customer|void
12
+ */
13
+ public function sendNewAccountEmail($type = 'registered', $backUrl = '', $storeId = '0')
14
+ {
15
+ if(Mage::getStoreConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_DISABLE_CUSTOMER_SUCCESS, $storeId))
16
+ return;
17
+
18
+ parent::sendNewAccountEmail($type = 'registered', $backUrl = '', $storeId = '0');
19
+ }
20
+ }
app/code/community/Dotdigitalgroup/Email/Model/Customer/Guest.php ADDED
@@ -0,0 +1,67 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ $this->_start = microtime(true);
16
+ foreach(Mage::app()->getWebsites() as $website) {
17
+
18
+ //check if the guest is mapped and enabled
19
+ $enabled = $helper->getGuestAddressBook($website);
20
+ $mapped = $website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_SYNC_SUBSCRIBER_ENABLED);
21
+ if ($enabled && $mapped) {
22
+
23
+ //ready to start sync
24
+ if (!$this->_countGuests)
25
+ $helper->log('----------- Start guest sync ----------');
26
+
27
+ //sync guests for website
28
+ $this->exportGuestPerWebsite($website);
29
+ }
30
+ }
31
+ if ($this->_countGuests)
32
+ $helper->log('---- End Guest total time for guest sync : ' . gmdate("H:i:s", microtime(true) - $this->_start));
33
+ }
34
+
35
+ public function exportGuestPerWebsite(Mage_Core_Model_Website $website)
36
+ {
37
+ $helper = Mage::helper('connector');
38
+ $fileHelper = Mage::helper('connector/file');
39
+ $guests = Mage::getModel('email_connector/contact')->getGuests($website);
40
+ if ($guests->getSize()) {
41
+ $client = Mage::helper('connector')->getWebsiteApiClient($website);
42
+ $guestFilename = strtolower($website->getCode() . '_guest_' . date('d_m_Y_Hi') . '.csv');
43
+ $helper->log('Guest file: ' . $guestFilename);
44
+ $storeName = $helper->getMappedStoreName($website);
45
+ $fileHelper->outputCSV($fileHelper->getFilePath($guestFilename), array('Email', 'emailType', $storeName));
46
+ foreach ($guests as $guest) {
47
+ $email = $guest->getEmail();
48
+ try{
49
+ $guest->setEmailImported(Dotdigitalgroup_Email_Model_Contact::EMAIL_CONTACT_IMPORTED)
50
+ ->save();
51
+ $storeName = $website->getName();
52
+ // save data for guests
53
+ $fileHelper->outputCSV($fileHelper->getFilePath($guestFilename), array($email, 'Html', $storeName));
54
+ $this->_countGuests++;
55
+ }catch (Exception $e){
56
+ Mage::logException($e);
57
+ }
58
+ }
59
+ if ($this->_countGuests) {
60
+ //Add to guest address book
61
+ $client->postAddressBookContactsImport($guestFilename, $helper->getGuestAddressBook($website));
62
+ }
63
+ //archive guest file
64
+ $fileHelper->archiveCSV($guestFilename);
65
+ }
66
+ }
67
+ }
app/code/community/Dotdigitalgroup/Email/Model/Customer/Observer.php ADDED
@@ -0,0 +1,316 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ $automationType = 'XML_PATH_CONNECTOR_AUTOMATION_STUDIO_CUSTOMER';
75
+ $this->_postCustomerToAutomation($email, $websiteId, $automationType);
76
+
77
+ return $this;
78
+ }
79
+
80
+ /**
81
+ * Remove the contact on customer delete.
82
+ *
83
+ * @param Varien_Event_Observer $observer
84
+ *
85
+ * @return $this
86
+ */
87
+ public function handleCustomerDeleteAfter(Varien_Event_Observer $observer)
88
+ {
89
+ $customer = $observer->getEvent()->getCustomer();
90
+ $email = $customer->getEmail();
91
+ $websiteId = $customer->getWebsiteId();
92
+ /**
93
+ * Remove contact.
94
+ */
95
+ try{
96
+ $contactModel = Mage::getModel('email_connector/contact')->loadByCustomerEmail($email, $websiteId);
97
+ if ($contactModel->getId()) {
98
+ //remove contact
99
+ $contactModel->delete();
100
+ }
101
+ //remove from account
102
+ $client = Mage::helper('connector')->getWebsiteApiClient($websiteId);
103
+ $apiContact = $client->postContacts($email);
104
+ if(! isset($apiContact->message) && isset($apiContact->id))
105
+ $client->deleteContact($apiContact->id);
106
+
107
+ }catch (Exception $e){
108
+ Mage::logException($e);
109
+ }
110
+ return $this;
111
+ }
112
+
113
+ /**
114
+ * enrol single contact to automation
115
+ *
116
+ * @param $email
117
+ * @param $websiteId
118
+ * @param $automationType
119
+ */
120
+ private function _postCustomerToAutomation( $email, $websiteId, $automationType) {
121
+ /**
122
+ * Automation Programme
123
+ */
124
+ $path = constant('Dotdigitalgroup_Email_Helper_Config::' . $automationType);
125
+ $automationCampaignId = Mage::helper('connector')->getWebsiteConfig($path, $websiteId);
126
+ $enabled = Mage::helper('connector')->getWebsiteConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_API_ENABLED, $websiteId);
127
+
128
+ //add customer to automation
129
+ if ($enabled && $automationCampaignId) {
130
+ Mage::helper( 'connector' )->log( 'AS - ' . $automationType . ' automation Campaign id : ' . $automationCampaignId );
131
+ $client = Mage::helper( 'connector' )->getWebsiteApiClient( $websiteId );
132
+ $apiContact = $client->postContacts($email);
133
+
134
+ // get a program by id
135
+ $program = $client->getProgramById($automationCampaignId);
136
+ /**
137
+ * id
138
+ * name
139
+ * status
140
+ * dateCreated
141
+ */
142
+ Mage::helper( 'connector' )->log( 'AS - get ' . $automationType . ' Program id : ' . $program->id);
143
+ //check for active program with status "Active"
144
+ if (isset($program->status) && $program->status == 'Active') {
145
+ $data = array(
146
+ 'Contacts' => array($apiContact->id),
147
+ 'ProgramId' => $program->id,
148
+ 'Status' => $program->status,
149
+ 'DateCreated' => $program->dateCreated,
150
+ 'AddressBooks' => array()
151
+ );
152
+ $client->postProgramsEnrolments($data);
153
+ }
154
+ }
155
+ }
156
+
157
+ /**
158
+ * Set contact to re-import if registered customer submitted a review. Save review in email_review table.
159
+ * @param Varien_Event_Observer $observer
160
+ * @return $this
161
+ */
162
+ public function reviewSaveAfter(Varien_Event_Observer $observer)
163
+ {
164
+ $dataObject = $observer->getEvent()->getDataObject();
165
+ if($dataObject->getCustomerId() && $dataObject->getStatusId() == '1'){
166
+ $customerId = $dataObject->getCustomerId();
167
+ $helper = Mage::helper('connector');
168
+ $helper->setConnectorContactToReImport($customerId);
169
+ //save review info in the table
170
+ $this->_registerReview($dataObject);
171
+ // send customer to automation mapped
172
+ $automationType = 'XML_PATH_CONNECTOR_AUTOMATION_STUDIO_REVIEW';
173
+ $customer = Mage::getModel('customer/customer')->load($customerId);
174
+ $email = $customer->getEmail();
175
+ $websiteId = $customer->getWebsiteId();
176
+ $this->_postCustomerToAutomation($email, $websiteId, $automationType);
177
+ }
178
+ return $this;
179
+ }
180
+
181
+ /**
182
+ * register review
183
+ *
184
+ * @param $review
185
+ */
186
+ private function _registerReview($review)
187
+ {
188
+ try{
189
+ $emailReview = Mage::getModel('email_connector/review');
190
+ $emailReview->setReviewId($review->getReviewId())
191
+ ->setCustomerId($review->getCustomerId())
192
+ ->setStoreId($review->getStoreId())
193
+ ->save();
194
+ }catch(Exception $e){
195
+ Mage::logException($e);
196
+ }
197
+ }
198
+
199
+ /**
200
+ * wishlist save after observer. save new wishlist in the email_wishlist table.
201
+ *
202
+ * @param Varien_Event_Observer $observer
203
+ * @return $this
204
+ */
205
+ public function wishlistSaveAfter(Varien_Event_Observer $observer)
206
+ {
207
+ //skip the version that has no wishlist observer
208
+ if (version_compare(Mage::getVersion(), '1.6.2.0', '<=')) {
209
+
210
+ return;
211
+ }
212
+ $dataObject = $observer->getEvent()->getDataObject();
213
+
214
+ if ($dataObject->getCustomerId()) {
215
+ //save wishlist info in the table
216
+ $this->_registerWishlist( $dataObject );
217
+ }
218
+ }
219
+
220
+ /**
221
+ * register wishlist
222
+ *
223
+ * @param $wishlist
224
+ */
225
+ private function _registerWishlist($wishlist)
226
+ {
227
+ try{
228
+ $emailWishlist = Mage::getModel('email_connector/wishlist');
229
+ $customer = Mage::getModel('customer/customer');
230
+
231
+ //if wishlist exist not to save again
232
+ if(!$emailWishlist->getWishlist($wishlist->getWishlistId())){
233
+ $customer->load($wishlist->getCustomerId());
234
+ $emailWishlist->setWishlistId($wishlist->getWishlistId())
235
+ ->setCustomerId($wishlist->getCustomerId())
236
+ ->setStoreId($customer->getStoreId())
237
+ ->save();
238
+ // send customer to automation mapped
239
+ $automationType = 'XML_PATH_CONNECTOR_AUTOMATION_STUDIO_WISHLIST';
240
+ $email = $customer->getEmail();
241
+ $websiteId = $customer->getWebsiteId();
242
+ $this->_postCustomerToAutomation($email, $websiteId, $automationType);
243
+ }
244
+ }catch(Exception $e){
245
+ Mage::logException($e);
246
+ }
247
+ }
248
+
249
+ /**
250
+ * wishlist item save after
251
+ *
252
+ * @param Varien_Event_Observer $observer
253
+ */
254
+ public function wishlistItemSaveAfter(Varien_Event_Observer $observer)
255
+ {
256
+ //skip the version that has no wishlist observer
257
+ if (version_compare(Mage::getVersion(), '1.6.2.0', '<=')) {
258
+ return;
259
+ }
260
+
261
+ $object = $observer->getEvent()->getDataObject();
262
+ $wishlist = Mage::getModel( 'wishlist/wishlist' )->load( $object->getWishlistId() );
263
+ $emailWishlist = Mage::getModel( 'email_connector/wishlist' );
264
+ try {
265
+ if ( $object->getWishlistId() ) {
266
+ $itemCount = count( $wishlist->getItemCollection() );
267
+ $item = $emailWishlist->getWishlist( $object->getWishlistId() );
268
+
269
+ if ( $item->getId() ) {
270
+ $preSaveItemCount = $item->getItemCount();
271
+
272
+ if ( $itemCount != $item->getItemCount() ) {
273
+ $item->setItemCount( $itemCount );
274
+ }
275
+
276
+ if ( $itemCount == 1 && $preSaveItemCount == 0 ) {
277
+ $item->setWishlistImported( null );
278
+ } elseif ( $item->getWishlistImported() ) {
279
+ $item->setWishlistModified( 1 );
280
+ }
281
+
282
+ $item->save();
283
+ }
284
+ }
285
+ } catch ( Exception $e ) {
286
+ Mage::logException( $e );
287
+ }
288
+
289
+ }
290
+
291
+ /**
292
+ * wishlist delete observer
293
+ *
294
+ * @param Varien_Event_Observer $observer
295
+ */
296
+ public function wishlistDeleteAfter(Varien_Event_Observer $observer)
297
+ {
298
+ $object = $observer->getEvent()->getDataObject();
299
+ $customer = Mage::getModel('customer/customer')->load($object->getCustomerId());
300
+ $website = Mage::app()->getStore($customer->getStoreId())->getWebsite();
301
+ $client = Mage::helper('connector')->getWebsiteApiClient($website);
302
+
303
+ //Remove wishlist
304
+ try{
305
+ $item = Mage::getModel('email_connector/wishlist')->getWishlist($object->getWishlistId());
306
+ if ($item->getId()) {
307
+ $result = $client->deleteContactsTransactionalData($item->getId(), 'Wishlist');
308
+ if (!isset($result->message)){
309
+ $item->delete();
310
+ }
311
+ }
312
+ }catch (Exception $e){
313
+ Mage::logException($e);
314
+ }
315
+ }
316
+ }
app/code/community/Dotdigitalgroup/Email/Model/Customer/Review.php ADDED
@@ -0,0 +1,240 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dotdigitalgroup_Email_Model_Customer_Review
4
+ {
5
+ /**
6
+ * @var int
7
+ */
8
+ public $id;
9
+
10
+ /**
11
+ * @var int
12
+ */
13
+ public $customer_id;
14
+
15
+ /**
16
+ * @var string
17
+ */
18
+ public $email;
19
+
20
+ /**
21
+ * @var string
22
+ */
23
+ public $product_name;
24
+
25
+ /**
26
+ * @var string
27
+ */
28
+ public $product_sku;
29
+
30
+ /**
31
+ * @var string
32
+ */
33
+ public $review_date;
34
+
35
+ /**
36
+ * @var string
37
+ */
38
+ public $website_name;
39
+
40
+ /**
41
+ * @var string
42
+ */
43
+ public $store_name;
44
+
45
+
46
+ /**
47
+ * constructor.
48
+ *
49
+ * @param Mage_Customer_Model_Customer $customer
50
+ */
51
+ public function __construct(Mage_Customer_Model_Customer $customer)
52
+ {
53
+
54
+ $this->setCustomerId($customer->getId());
55
+ $this->email = $customer->getEmail();
56
+ }
57
+
58
+ /**
59
+ * @param mixed $customer_id
60
+ */
61
+ public function setCustomerId($customer_id)
62
+ {
63
+ $this->customer_id = (int) $customer_id;
64
+ }
65
+
66
+ /**
67
+ * @return mixed
68
+ */
69
+ public function getCustomerId()
70
+ {
71
+ return (int) $this->customer_id;
72
+ }
73
+
74
+ /**
75
+ * @param $id
76
+ * @return $this
77
+ */
78
+ public function setId($id)
79
+ {
80
+ $this->id = (int) $id;
81
+ return $this;
82
+ }
83
+
84
+ /**
85
+ * @return mixed
86
+ */
87
+ public function getId()
88
+ {
89
+ return (int) $this->id;
90
+ }
91
+
92
+ /**
93
+ * create rating on runtime
94
+ *
95
+ * @param $rating_name
96
+ * @param $rating
97
+ */
98
+ public function createRating($rating_name, $rating)
99
+ {
100
+ $this->$rating_name = $rating->expose();
101
+ }
102
+
103
+ /**
104
+ * set review date.
105
+ *
106
+ * @param $date
107
+ * @return $this;
108
+ */
109
+ public function setReviewDate($date)
110
+ {
111
+ $created_at = new Zend_Date($date, Zend_Date::ISO_8601);
112
+
113
+ $this->review_date = $created_at->toString(Zend_Date::ISO_8601);;
114
+ return $this;
115
+ }
116
+
117
+ /**
118
+ * @return string
119
+ */
120
+ public function getReviewDate()
121
+ {
122
+ return $this->review_date;
123
+ }
124
+
125
+ /**
126
+ * set product
127
+ *
128
+ * @param Mage_Catalog_Model_Product $product
129
+ * @return $this
130
+ */
131
+ public function setProduct(Mage_Catalog_Model_Product $product)
132
+ {
133
+ $this->setProductName($product->getName());
134
+ $this->setProductSku($product->getSku());
135
+ return $this;
136
+ }
137
+
138
+ /**
139
+ * set review data
140
+ *
141
+ * @param Mage_Review_Model_Review $review $product
142
+ * @return $this
143
+ */
144
+ public function setReviewData(Mage_Review_Model_Review $review)
145
+ {
146
+ $store = Mage::app()->getStore($review->getStoreId());
147
+ $websiteName = $store->getWebsite()->getName();
148
+ $storeName = $store->getName();
149
+ $this->setId($review->getReviewId())
150
+ ->setWebsiteName($websiteName)
151
+ ->setStoreName($storeName)
152
+ ->setReviewDate($review->getCreatedAt());
153
+
154
+ return $this;
155
+ }
156
+
157
+ /**
158
+ * set product name
159
+ *
160
+ * @param $name
161
+ */
162
+ public function setProductName($name)
163
+ {
164
+ $this->product_name = $name;
165
+ }
166
+
167
+ /**
168
+ * @return string
169
+ */
170
+ public function getProductName()
171
+ {
172
+ return $this->product_name;
173
+ }
174
+
175
+ /**
176
+ * set product sku
177
+ *
178
+ * @param $sku
179
+ */
180
+ public function setProductSku($sku)
181
+ {
182
+ $this->product_sku = $sku;
183
+ }
184
+
185
+ /**
186
+ * @return string
187
+ */
188
+ public function getProductSku()
189
+ {
190
+ return $this->product_sku;
191
+ }
192
+
193
+ /**
194
+ * set website name
195
+ *
196
+ * @param $name
197
+ * @return $this
198
+ */
199
+ public function setWebsiteName($name)
200
+ {
201
+ $this->website_name = $name;
202
+ return $this;
203
+ }
204
+
205
+ /**
206
+ * @return string
207
+ */
208
+ public function getStoreName()
209
+ {
210
+ return $this->store_name;
211
+ }
212
+
213
+ /**
214
+ * set store name
215
+ *
216
+ * @param $name
217
+ * @return $this
218
+ */
219
+ public function setStoreName($name)
220
+ {
221
+ $this->store_name = $name;
222
+ return $this;
223
+ }
224
+
225
+ /**
226
+ * @return string
227
+ */
228
+ public function getWebsiteName()
229
+ {
230
+ return $this->website_name;
231
+ }
232
+
233
+ /**
234
+ * @return array
235
+ */
236
+ public function expose()
237
+ {
238
+ return get_object_vars($this);
239
+ }
240
+ }
app/code/community/Dotdigitalgroup/Email/Model/Customer/Review/Rating.php ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dotdigitalgroup_Email_Model_Customer_Review_Rating
4
+ {
5
+ /**
6
+ * @var int
7
+ */
8
+ public $rating_score;
9
+
10
+ /**
11
+ * constructor
12
+ *
13
+ * @param $rating
14
+ */
15
+ public function __construct($rating)
16
+ {
17
+ $this->setRatingScore($rating->getValue());
18
+ }
19
+
20
+ /**
21
+ * @param $score
22
+ *
23
+ * @return $this
24
+ */
25
+ public function setRatingScore($score)
26
+ {
27
+ $this->rating_score = (int)$score;
28
+ return $this;
29
+ }
30
+
31
+ /**
32
+ * @return int
33
+ */
34
+ public function getRatingScore()
35
+ {
36
+ return $this->rating_score;
37
+ }
38
+
39
+ /**
40
+ * @return array
41
+ */
42
+ public function expose()
43
+ {
44
+ return get_object_vars($this);
45
+ }
46
+ }
app/code/community/Dotdigitalgroup/Email/Model/Customer/Wishlist.php ADDED
@@ -0,0 +1,120 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ * @var string
31
+ */
32
+ public $updated_at;
33
+ /**
34
+ * constructor.
35
+ *
36
+ * @param Mage_Customer_Model_Customer $customer
37
+ */
38
+ public function __construct(Mage_Customer_Model_Customer $customer)
39
+ {
40
+
41
+ $this->setCustomerId($customer->getId());
42
+ $this->email = $customer->getEmail();
43
+ }
44
+
45
+ /**
46
+ * @param mixed $customer_id
47
+ */
48
+ public function setCustomerId($customer_id)
49
+ {
50
+ $this->customer_id = (int) $customer_id;
51
+ }
52
+
53
+ /**
54
+ * @return mixed
55
+ */
56
+ public function getCustomerId()
57
+ {
58
+ return (int) $this->customer_id;
59
+ }
60
+
61
+ /**
62
+ * @param $id
63
+ * @return $this
64
+ */
65
+ public function setId($id)
66
+ {
67
+ $this->id = (int) $id;
68
+ return $this;
69
+ }
70
+
71
+ /**
72
+ * @return mixed
73
+ */
74
+ public function getId()
75
+ {
76
+ return (int) $this->id;
77
+ }
78
+
79
+ /**
80
+ * set wishlist item.
81
+ *
82
+ * @param $item
83
+ */
84
+ public function setItem($item)
85
+ {
86
+ $this->items[] = $item->expose();
87
+
88
+ $this->total_wishlist_value += $item->getTotalValueOfProduct();
89
+ }
90
+
91
+ /**
92
+ * @return array
93
+ */
94
+ public function expose()
95
+ {
96
+ return get_object_vars($this);
97
+ }
98
+
99
+ /**
100
+ * set wishlist date.
101
+ *
102
+ * @param $date
103
+ * @return $this;
104
+ */
105
+ public function setUpdatedAt($date)
106
+ {
107
+ $date = new Zend_Date($date, Zend_Date::ISO_8601);
108
+
109
+ $this->updated_at = $date->toString(Zend_Date::ISO_8601);;
110
+ return $this;
111
+ }
112
+
113
+ /**
114
+ * @return string
115
+ */
116
+ public function getUpdatedAt()
117
+ {
118
+ return $this->updated_at;
119
+ }
120
+ }
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,357 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ * @var string
39
+ */
40
+ private $_templateId;
41
+
42
+ /**
43
+ * @var int
44
+ */
45
+ private $_storeId;
46
+
47
+ /**
48
+ * Send transactional email to recipient
49
+ *
50
+ * @see Mage_Core_Model_Email_Template::sendTransactional()
51
+ * @param string $templateId
52
+ * @param string|array $sender sneder information, can be declared as part of config path
53
+ * @param string $email recipient email
54
+ * @param string $name recipient name
55
+ * @param array $vars varianles which can be used in template
56
+ * @param int|null $storeId
57
+ * @return Mage_Core_Model_Email_Template
58
+ */
59
+ public function sendTransactional($templateId, $sender, $email, $name, $vars=array(), $storeId=null)
60
+ {
61
+ $this->_templateId = $templateId;
62
+ $sendType = Mage::helper('connector/transactional')->getMapping($templateId, Dotdigitalgroup_Email_Helper_Transactional::MAP_COLUMN_KEY_SENDTYPE, $storeId);
63
+ $transEnabled = Mage::getStoreConfig(Dotdigitalgroup_Email_Helper_Transactional::XML_PATH_TRANSACTIONAL_API_ENABLED, $storeId);
64
+ $campaignId = Mage::helper('connector/transactional')->getMapping($templateId,Dotdigitalgroup_Email_Helper_Transactional::MAP_COLUMN_KEY_DATAFIELD, $storeId);
65
+
66
+
67
+ //design and send. campaign id is needed for this option
68
+ if ($sendType == 2 && $transEnabled && $campaignId) {
69
+ if(is_array($email)) {
70
+ foreach($email as $one) {
71
+ $this->setSentSuccess($this->designAndSend($templateId, $vars, $campaignId, $one, $storeId));
72
+ }
73
+ } else {
74
+ $this->setSentSuccess($this->designAndSend($templateId, $vars, $campaignId, $email, $storeId));
75
+ }
76
+ return $this;
77
+ }
78
+
79
+ //send via connector
80
+ if($sendType == 1 && $transEnabled)
81
+ return $this->sendTransactionalForOptionViaConnector($sender, $email, $name, $vars, $storeId, $sendType);
82
+
83
+ // If Template ID is 'nosend', then simply return false
84
+ if ($templateId == 'nosend') {
85
+ return false;
86
+ }
87
+
88
+ //templates not mapped or mapped "Use System Default"
89
+ return parent::sendTransactional($templateId, $sender, $email, $name, $vars, $storeId);
90
+ }
91
+
92
+ /**
93
+ * send transactional for option "Send via connector"
94
+ *
95
+ * @param $templateId
96
+ * @param $sender
97
+ * @param $email
98
+ * @param $name
99
+ * @param array $vars
100
+ * @param null $storeId
101
+ * @param $sendType
102
+ * @return $this
103
+ * @throws Mage_Core_Exception
104
+ */
105
+ public function sendTransactionalForOptionViaConnector($sender, $email, $name, $vars = array(), $storeId = null, $sendType)
106
+ {
107
+ $templateId = $this->_templateId;
108
+ $this->setSentSuccess(false);
109
+ if (($storeId === null) && $this->getDesignConfig()->getStore()) {
110
+ $storeId = $this->getDesignConfig()->getStore();
111
+ }
112
+
113
+ if (is_numeric($templateId)) {
114
+ $this->load($templateId);
115
+ } else {
116
+ $localeCode = Mage::getStoreConfig('general/locale/code', $storeId);
117
+ $this->loadDefault($templateId, $localeCode);
118
+ }
119
+
120
+ if (!$this->getId()) {
121
+ throw Mage::exception('Mage_Core', Mage::helper('core')->__('Invalid transactional email code: %s', $templateId));
122
+ }
123
+
124
+ if (!is_array($sender)) {
125
+ $this->setSenderName(Mage::getStoreConfig('trans_email/ident_' . $sender . '/name', $storeId));
126
+ $this->setSenderEmail(Mage::getStoreConfig('trans_email/ident_' . $sender . '/email', $storeId));
127
+ } else {
128
+ $this->setSenderName($sender['name']);
129
+ $this->setSenderEmail($sender['email']);
130
+ }
131
+
132
+ if (!isset($vars['store'])) {
133
+ $vars['store'] = Mage::app()->getStore($storeId);
134
+ }
135
+ $this->setSentSuccess($this->send($email, $name, $vars, $sendType));
136
+ return $this;
137
+ }
138
+
139
+ /**
140
+ * Send mail to recipient
141
+ *
142
+ * @see Mage_Core_Model_Email_Template::send()
143
+ * @param array|string $email E-mail(s)
144
+ * @param array|string|null $name receiver name(s)
145
+ * @param array $variables template variables
146
+ * @param int $sendType
147
+ * @return boolean
148
+ **/
149
+ public function send($email, $name = null, array $variables = array(), $sendType = null)
150
+ {
151
+ //not mapped templates or mapped as "Use system default"
152
+ if($sendType == null)
153
+ return parent::send($email, $name, $variables);
154
+
155
+ $transEnabled = Mage::getStoreConfig(Dotdigitalgroup_Email_Helper_Transactional::XML_PATH_TRANSACTIONAL_API_ENABLED);
156
+ //mapped option "Send via connector"
157
+ if($sendType == 1 && $transEnabled)
158
+ return $this->sendViaConnector($email, $name, $variables);
159
+
160
+ }
161
+
162
+ /**
163
+ * send via connector
164
+ *
165
+ * @param $email
166
+ * @param $name
167
+ * @param $variables
168
+ * @return bool
169
+ * @throws Exception
170
+ */
171
+ public function sendViaConnector($email, $name, $variables)
172
+ {
173
+ $templateId = $this->_templateId;
174
+ $emails = array_values((array)$email);
175
+ $names = is_array($name) ? $name : (array)$name;
176
+ $names = array_values($names);
177
+ foreach ($emails as $key => $email) {
178
+ if (!isset($names[$key])) {
179
+ $names[$key] = substr($email, 0, strpos($email, '@'));
180
+ }
181
+ }
182
+ $variables['email'] = reset($emails);
183
+ $variables['name'] = reset($names);
184
+ $this->setUseAbsoluteLinks(true);
185
+
186
+ $store = $variables['store'];
187
+ $body = $this->getProcessedTemplate($variables, true);
188
+ $subject = $this->getProcessedTemplateSubject($variables);
189
+ $websiteId = $store->getWebsiteId();
190
+
191
+ $helper = Mage::helper('connector/transactional');
192
+ $templateName = $helper->getTemplateLabelById($this->getId());
193
+
194
+ if($helper->getUnsubscribeLink($websiteId))
195
+ $body .= '<br><br>' . $helper->__('Want to unsubscribe or change your details') . '<a href="http://$UNSUB$">' . $helper->__('Unsubscribe from this newsletter') . '</a>';
196
+
197
+ $fromAddress = Mage::helper('connector/transactional')->getMapping($templateId,Dotdigitalgroup_Email_Helper_Transactional::MAP_COLUMN_KEY_FROM_ADDRESS, $store->getId());
198
+ $attachmentId = Mage::helper('connector/transactional')->getMapping($templateId,Dotdigitalgroup_Email_Helper_Transactional::MAP_COLUMN_KEY_ATTACHMENT_ID, $store->getId());
199
+
200
+ foreach($emails as $email){
201
+ try{
202
+ $now = Mage::getSingleton('core/date')->gmtDate();
203
+ $emailCreate = Mage::getModel('email_connector/campaign');
204
+ $emailCreate
205
+ ->setEmail($email)
206
+ ->setFromName($this->getSenderName())
207
+ ->setFromAddress($fromAddress)
208
+ ->setWebsiteId($websiteId)
209
+ ->setEventName($templateName)
210
+ ->setSubject($subject)
211
+ ->setHtmlContent($body)
212
+ ->setPlainTextContent($helper->__('Want to unsubscribe or change your details?') . 'http://$UNSUB$')
213
+ ->setAttachmentId($attachmentId)
214
+ ->setCreatedAt($now)
215
+ ->setType(2)
216
+ ->save();
217
+ }catch (Exception $e) {
218
+ Mage::logException($e);
219
+ }
220
+ }
221
+ return true;
222
+ }
223
+
224
+ /**
225
+ * design and send
226
+ *
227
+ * @param $templateId
228
+ * @param $templateParams
229
+ * @param $campaignId
230
+ * @param $email
231
+ * @param $storeId
232
+ * @return bool
233
+ */
234
+ public function designAndSend($templateId, $templateParams, $campaignId, $email, $storeId)
235
+ {
236
+ if (array_key_exists($templateId, $this->_registered)) {
237
+ $this->_registerOrderCampaign($templateId, $templateParams, $campaignId);
238
+ return true;
239
+ }
240
+ if (array_key_exists($templateId, $this->_registeredCustomer)) {
241
+ $this->_registerCustomer($templateId, $templateParams, $campaignId);
242
+ return true;
243
+ }
244
+
245
+ $this->_registerOtherDesignAndSendCampaign($templateId, $campaignId, $email, $storeId);
246
+ return true;
247
+ }
248
+
249
+ /**
250
+ * register sales order campaign.
251
+ *
252
+ * @param $templateId
253
+ * @param $data
254
+ * @param $campaignId
255
+ */
256
+ protected function _registerOrderCampaign($templateId, $data, $campaignId)
257
+ {
258
+ $order = $data['order'];
259
+ $storeId = $order->getStoreId();
260
+ $websiteId = Mage::getModel('core/store')->load($storeId)->getWebsiteId();
261
+
262
+ Mage::helper('connector')->log('-- Sales Order :' . $campaignId);
263
+ try{
264
+ $now = Mage::getSingleton('core/date')->gmtDate();
265
+ //save email for sending
266
+ $emailCampaign = Mage::getModel('email_connector/campaign');
267
+ $emailCampaign->setOrderIncrementId($order->getRealOrderId())
268
+ ->setQuoteId($order->getQuoteId())
269
+ ->setEmail($order->getCustomerEmail())
270
+ ->setCustomerId($order->getCustomerId())
271
+ ->setStoreId($storeId)
272
+ ->setCampaignId($campaignId)
273
+ ->setEventName($this->_registered[$templateId])
274
+ ->setWebsiteId($websiteId)
275
+ ->setCreatedAt($now)
276
+ ;
277
+ $emailCampaign->save();
278
+ }catch (Exception $e){
279
+ Mage::logException($e);
280
+ }
281
+ }
282
+
283
+ /**
284
+ * register customer campaign.
285
+ *
286
+ * @param $templateId
287
+ * @param $data
288
+ * @param $campaignId
289
+ */
290
+ protected function _registerCustomer($templateId, $data, $campaignId)
291
+ {
292
+ $customer = $data['customer'];
293
+ Mage::helper('connector')->log('-- Customer campaign: ' . $campaignId);
294
+ try{
295
+ $now = Mage::getSingleton('core/date')->gmtDate();
296
+ //save email for sending
297
+ $emailCampaign = Mage::getModel('email_connector/campaign');
298
+ $emailCampaign->setEmail($customer->getEmail())
299
+ ->setCustomerId($customer->getId())
300
+ ->setStoreId($customer->getStoreId())
301
+ ->setCampaignId($campaignId)
302
+ ->setEventName($this->_registeredCustomer[$templateId])
303
+ ->setCreatedAt($now);
304
+ $emailCampaign->save();
305
+ }catch (Exception $e) {
306
+ Mage::logException($e);
307
+ }
308
+ }
309
+
310
+ /**
311
+ * design and send option. all campaign which are not in array _registered or array _registeredCustomer
312
+ *
313
+ * @param $templateId
314
+ * @param $campaignId
315
+ * @param $email
316
+ * @param $storeId
317
+ */
318
+ protected function _registerOtherDesignAndSendCampaign($templateId, $campaignId, $email, $storeId)
319
+ {
320
+ $helper = Mage::helper('connector/transactional');
321
+ Mage::helper('connector')->log('-- Other campaign: ' . $campaignId);
322
+ $websiteId = Mage::getModel('core/store')->load($storeId)->getWebsiteId();
323
+
324
+ try{
325
+ $now = Mage::getSingleton('core/date')->gmtDate();
326
+ if($email){
327
+ //save email for sending
328
+ $emailCampaign = Mage::getModel('email_connector/campaign');
329
+ $emailCampaign
330
+ ->setEmail($email)
331
+ ->setStoreId($storeId)
332
+ ->setCampaignId($campaignId)
333
+ ->setWebsiteId($websiteId)
334
+ ->setEventName($helper->getTemplateLabelById($templateId))
335
+ ->setCreatedAt($now);
336
+ $emailCampaign->save();
337
+ }
338
+ }catch (Exception $e) {
339
+ Mage::logException($e);
340
+ }
341
+ }
342
+
343
+ /**
344
+ * find template id in array _registered
345
+ *
346
+ * @param $templateId
347
+ * @return bool
348
+ */
349
+ public function getSalesEvent($templateId)
350
+ {
351
+ if (array_key_exists($templateId, $this->_registered))
352
+ return true;
353
+
354
+ return false;
355
+ }
356
+
357
+ }
app/code/community/Dotdigitalgroup/Email/Model/Feed.php ADDED
@@ -0,0 +1,88 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dotdigitalgroup_Email_Model_Feed extends Mage_AdminNotification_Model_Feed
4
+ {
5
+ /**
6
+ * Check for and extension update
7
+ *
8
+ * @return $this
9
+ */
10
+ public function checkForUpgrade()
11
+ {
12
+ //not enabled
13
+ if(! (bool)Mage::getStoreConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_FEED_ENABLED)) {
14
+ return;
15
+ }
16
+
17
+ //time this was last checked
18
+ if (($this->getFrequency() + $this->getLastUpdate()) > time()) {
19
+ return $this;
20
+ }
21
+
22
+ //data feed
23
+ $feedData = array();
24
+
25
+ $feedXml = $this->getFeedData();
26
+
27
+ if ($feedXml) {
28
+ foreach ($feedXml->release as $data) {
29
+
30
+ //only if the version number was updated for the connector
31
+ if (version_compare($data->version, Mage::helper('connector')->getConnectorVersion(), '>')) {
32
+
33
+ $feedData[] = array(
34
+ 'severity' => $data->severity,
35
+ 'date_added' => $this->getDate($data->date_added),
36
+ 'title' => (string) $data->title,
37
+ 'description' => (string) $data->description,
38
+ 'url' => (string) $data->link,
39
+ );
40
+ }
41
+ }
42
+
43
+ //admin notification with updated version
44
+ if ($feedData) {
45
+ Mage::getModel('adminnotification/inbox')->parse(array_reverse($feedData));
46
+ }
47
+
48
+ }
49
+ //set the last update check
50
+ $this->setLastUpdate();
51
+
52
+ return $this;
53
+ }
54
+
55
+ /**
56
+ * Set the last update time.
57
+ * @return $this|Mage_AdminNotification_Model_Feed
58
+ */
59
+ public function setLastUpdate()
60
+ {
61
+ Mage::app()->saveCache(time(), Dotdigitalgroup_Email_Helper_Config::CONNECTOR_FEED_LAST_CHECK_TIME);
62
+ return $this;
63
+ }
64
+
65
+ /**
66
+ * @return SimpleXMLElement|void
67
+ */
68
+ public function getFeedUrl()
69
+ {
70
+ if (is_null($this->_feedUrl)) {
71
+ $this->_feedUrl = (Mage::getStoreConfigFlag(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_FEED_USE_HTTPS) ? 'https://' : 'http://')
72
+ . Mage::getStoreConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_FEED_URL);
73
+ }
74
+
75
+ return $this->_feedUrl;
76
+ }
77
+
78
+
79
+
80
+ /**
81
+ * @return int|mixed
82
+ */
83
+ public function getFrequency()
84
+ {
85
+ return Mage::getStoreConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_FEED_FREQUENCY) * 3600;
86
+ }
87
+
88
+ }
app/code/community/Dotdigitalgroup/Email/Model/Newsletter/Observer.php ADDED
@@ -0,0 +1,134 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dotdigitalgroup_Email_Model_Newsletter_Observer
4
+ {
5
+
6
+ /**
7
+ * Change the subscribsion for an contact.
8
+ * Add new subscribers to an automation.
9
+ *
10
+ * @param Varien_Event_Observer $observer
11
+ *
12
+ * @return $this
13
+ */
14
+ public function handleNewsletterSubscriberSave(Varien_Event_Observer $observer)
15
+ {
16
+ $helper = Mage::helper('connector');
17
+ $subscriber = $observer->getEvent()->getSubscriber();
18
+ $storeId = $subscriber->getStoreId();
19
+ $email = $subscriber->getEmail();
20
+ $subscriberStatus = $subscriber->getSubscriberStatus();
21
+
22
+ $websiteId = Mage::app()->getStore($subscriber->getStoreId())->getWebsiteId();
23
+ $contactEmail = Mage::getModel('email_connector/contact')->loadByCustomerEmail($email, $websiteId);
24
+ try{
25
+ // send new subscriber to an automation
26
+ if (! Mage::getModel('newsletter/subscriber')->loadByEmail($email)->getId()) {
27
+
28
+ $this->_postSubscriberToAutomation($email, $websiteId);
29
+ }
30
+
31
+ // only for subsribers
32
+ if ($subscriberStatus == Mage_Newsletter_Model_Subscriber::STATUS_SUBSCRIBED) {
33
+
34
+ $client = Mage::helper('connector')->getWebsiteApiClient($websiteId);
35
+
36
+ //check for website client
37
+ if ($client) {
38
+ //set contact as subscribed
39
+ $contactEmail->setSubscriberStatus( $subscriberStatus )
40
+ ->setIsSubscriber('1');
41
+
42
+ $apiContact = $client->postContacts( $email );
43
+
44
+ //resubscribe suppressed contacts
45
+ if ( isset( $apiContact->status ) && $apiContact->status == 'Suppressed' ) {
46
+ $client->postContactsResubscribe( $apiContact );
47
+ }
48
+ }
49
+ // reset the subscriber as suppressed
50
+ $contactEmail->setSuppressed(null);
51
+
52
+ //not subscribed
53
+ } else {
54
+ //skip if contact is suppressed
55
+ if ($contactEmail->getSuppressed())
56
+ return $this;
57
+ //update contact id for the subscriber
58
+ $client = Mage::helper('connector')->getWebsiteApiClient($websiteId);
59
+ //check for website client
60
+ if ($client) {
61
+ $contactId = $contactEmail->getContactId();
62
+ //get the contact id
63
+ if ( !$contactId ) {
64
+ //if contact id is not set get the contact_id
65
+ $result = $client->postContacts( $email );
66
+ if ( isset( $result->id ) ) {
67
+ $contactId = $result->id;
68
+ } else {
69
+ //no contact id skip
70
+ $contactEmail->setSuppressed( '1' )
71
+ ->save();
72
+ return $this;
73
+ }
74
+ }
75
+ //remove contact from address book
76
+ $client->deleteAddressBookContact( $helper->getSubscriberAddressBook( $websiteId ), $contactId );
77
+ }
78
+ $contactEmail->setIsSubscriber(null)
79
+ ->setSubscriberStatus(Mage_Newsletter_Model_Subscriber::STATUS_UNSUBSCRIBED);
80
+ }
81
+
82
+ //update the contact
83
+ $contactEmail->setStoreId($storeId);
84
+ if (isset($contactId))
85
+ $contactEmail->setContactId($contactId);
86
+ //update contact
87
+ $contactEmail->save();
88
+
89
+ }catch(Exception $e){
90
+ Mage::logException($e);
91
+ Mage::helper('connector')->getRaygunClient()->SendException($e, array(Mage::getBaseUrl('web')));
92
+ }
93
+ return $this;
94
+ }
95
+
96
+
97
+ private function _postSubscriberToAutomation( $email, $websiteId ) {
98
+ /**
99
+ * Automation Programm
100
+ */
101
+ $subscriberAutoCamaignId = Mage::helper('connector')->getWebsiteConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_AUTOMATION_STUDIO_SUBSCRIBER, $websiteId);
102
+ $enabled = Mage::helper('connector')->getWebsiteConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_API_ENABLED, $websiteId);
103
+ //enabled and mapped
104
+ if ($enabled && $subscriberAutoCamaignId) {
105
+ Mage::helper( 'connector' )->log( 'AS - subscriber automation Campaign id : ' . $subscriberAutoCamaignId );
106
+ $client = Mage::helper( 'connector' )->getWebsiteApiClient( $websiteId );
107
+ //create new contact
108
+ $apiContact = $client->postContacts($email);
109
+
110
+ // get a program by id
111
+ $program = $client->getProgramById($subscriberAutoCamaignId);
112
+ /**
113
+ * id
114
+ * name
115
+ * status
116
+ * dateCreated
117
+ */
118
+ Mage::helper( 'connector' )->log( 'AS - get subscriber Program id : ' . $program->id);
119
+ //check for active program with status "Active"
120
+ if (isset($program->status) && $program->status == 'Active') {
121
+
122
+ $data = array(
123
+ 'Contacts' => array( $apiContact->id ),
124
+ 'ProgramId' => $program->id,
125
+ 'Status' => $program->status,
126
+ 'DateCreated' => $program->dateCreated,
127
+ 'AddressBooks' => array()
128
+ );
129
+ //add contact to automation enrolment
130
+ $client->postProgramsEnrolments( $data );
131
+ }
132
+ }
133
+ }
134
+ }
app/code/community/Dotdigitalgroup/Email/Model/Newsletter/Sub.php ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dotdigitalgroup_Email_Model_Newsletter_Sub extends Mage_Newsletter_Model_Subscriber
4
+ {
5
+ public function sendConfirmationSuccessEmail()
6
+ {
7
+ if (Mage::helper('connector')->isNewsletterSuccessDisabled($this->getStoreId()))
8
+ return $this;
9
+ else
10
+ parent::sendConfirmationSuccessEmail();
11
+ }
12
+ }
app/code/community/Dotdigitalgroup/Email/Model/Newsletter/Subscriber.php ADDED
@@ -0,0 +1,185 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ * Global number of subscriber updated.
14
+ * @var
15
+ */
16
+ protected $_countSubscriber = 0;
17
+
18
+ /**
19
+ * SUBSCRIBER SYNC.
20
+ * @return $this
21
+ */
22
+ public function sync()
23
+ {
24
+ $response = array('success' => true, 'message' => '');
25
+ /** @var Dotdigitalgroup_Email_Helper_Data $helper */
26
+ $helper = Mage::helper('connector');
27
+
28
+ $this->_start = microtime(true);
29
+
30
+ foreach (Mage::app()->getWebsites(true) as $website) {
31
+ //if subscriber is enabled and mapped
32
+ $enabled = (bool)$website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_SYNC_SUBSCRIBER_ENABLED);
33
+ $addressBook = $website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_SUBSCRIBERS_ADDRESS_BOOK_ID);
34
+
35
+ //enabled and mapped
36
+ if ( $enabled && $addressBook ) {
37
+
38
+ //ready to start sync
39
+ if (!$this->_countSubscriber)
40
+ $helper->log('---------------------- Start subscriber sync -------------------');
41
+
42
+ $numUpdated = $this->exportSubscribersPerWebsite($website);
43
+ // show message for any number of customers
44
+ if ($numUpdated)
45
+ $response['message'] .= '</br>' . $website->getName() . ', updated subscribers = ' . $numUpdated;
46
+
47
+ }
48
+ }
49
+
50
+ //global number of subscribers to set the message
51
+ if ($this->_countSubscriber) {
52
+ //reponse message
53
+ $message = 'Total time for sync : ' . gmdate("H:i:s", microtime(true) - $this->_start);
54
+
55
+ //put the message in front
56
+ $message .= $response['message'];
57
+ $result['message'] = $message;
58
+ }
59
+
60
+ return $response;
61
+ }
62
+
63
+ /**
64
+ * Export subscriber per website.
65
+ * @param Mage_Core_Model_Website $website
66
+ *
67
+ * @return int
68
+ */
69
+ public function exportSubscribersPerWebsite(Mage_Core_Model_Website $website)
70
+ {
71
+ $updated = 0;
72
+ $fileHelper = Mage::helper('connector/file');
73
+ $limit = $website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_SYNC_LIMIT);
74
+ $subscribers = Mage::getModel('email_connector/contact')->getSubscribersToImport($website, $limit);
75
+ if (count($subscribers)) {
76
+ $client = Mage::helper('connector')->getWebsiteApiClient($website);
77
+ $subscribersFilename = strtolower($website->getCode() . '_subscribers_' . date('d_m_Y_Hi') . '.csv');
78
+ //get mapped storename
79
+ $subscriberStorename = Mage::helper('connector')->getMappedStoreName($website);
80
+ //file headers
81
+ $fileHelper->outputCSV($fileHelper->getFilePath($subscribersFilename), array('Email', 'emailType', $subscriberStorename));
82
+ foreach ($subscribers as $subscriber) {
83
+ try{
84
+ $email = $subscriber->getEmail();
85
+ $subscriber->setSubscriberImported(1)->save();
86
+ $subscriber = Mage::getModel('newsletter/subscriber')->loadByEmail($email);
87
+ $storeName = Mage::app()->getStore($subscriber->getStoreId())->getName();
88
+ // save data for subscribers
89
+ $fileHelper->outputCSV($fileHelper->getFilePath($subscribersFilename), array($email, 'Html', $storeName));
90
+ $updated++;
91
+ }catch (Exception $e){
92
+ Mage::logException($e);
93
+ }
94
+ }
95
+ Mage::helper('connector')->log('Subscriber filename: ' . $subscribersFilename);
96
+ //Add to subscriber address book
97
+ $client->postAddressBookContactsImport($subscribersFilename, $website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_SUBSCRIBERS_ADDRESS_BOOK_ID));
98
+ $fileHelper->archiveCSV($subscribersFilename);
99
+ }
100
+ //add updated number for the website
101
+ $this->_countSubscriber += $updated;
102
+ return $updated;
103
+ }
104
+
105
+ /**
106
+ * Unsubscribe suppressed contacts.
107
+ * @param bool $force set 10years old
108
+ * @return mixed
109
+ */
110
+ public function unsubscribe($force = false)
111
+ {
112
+ $limit = 5;
113
+ $max_to_select = 1000;
114
+ $result['customers'] = 0;
115
+ $helper = Mage::helper('connector');
116
+ $date = Mage::app()->getLocale()->date()->subHour(1);
117
+ // force sync all customers
118
+ if($force)
119
+ $date = $date->subYear(10);
120
+ // datetime format string
121
+ $dateString = $date->toString(Zend_Date::W3C);
122
+ /**
123
+ * 1. Sync all suppressed for each store
124
+ */
125
+ foreach (Mage::app()->getWebsites(true) as $website) {
126
+
127
+ $enabled = (bool)$website->getConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_API_ENABLED);
128
+ $client = Mage::helper('connector')->getWebsiteApiClient($website);
129
+
130
+ //no enabled and valid credentials
131
+ if (! $enabled)
132
+ continue;
133
+
134
+ $contacts = array();
135
+ $skip = $i = 0;
136
+
137
+ //there is a maximum of request we need to loop to get more suppressed contacts
138
+ for ($i=0; $i<= $limit;$i++) {
139
+ $apiContacts = $client->getContactsSuppressedSinceDate($dateString, $max_to_select , $skip);
140
+
141
+ // skip no more contacts or the api request failed
142
+ if(empty($apiContacts) || isset($apiContacts->message))
143
+ break;
144
+
145
+ $contacts = array_merge($contacts, $apiContacts);
146
+ $skip += 1000;
147
+ }
148
+
149
+ $subscriberBookId = $helper->getSubscriberAddressBook($website);
150
+
151
+ // suppressed contacts to unsubscibe
152
+ foreach ($contacts as $apiContact) {
153
+ if (isset($apiContact->suppressedContact)) {
154
+ $suppressedContact = $apiContact->suppressedContact;
155
+ $email = $suppressedContact->email;
156
+ $contactId = $suppressedContact->id;
157
+ try{
158
+ /**
159
+ * 2. Remove subscriber from the address book.
160
+ */
161
+ $subscriber = Mage::getModel('newsletter/subscriber')->loadByEmail($email);
162
+ if ($subscriber->getStatus() == Mage_Newsletter_Model_Subscriber::STATUS_SUBSCRIBED) {
163
+ $subscriber->setStatus(Mage_Newsletter_Model_Subscriber::STATUS_UNSUBSCRIBED);
164
+ $subscriber->save();
165
+ // remove from subscriber address-book
166
+ $client->deleteAddressBookContact($subscriberBookId, $contactId);
167
+ }
168
+ //mark contact as suppressed and unsubscribe
169
+ $contactCollection = Mage::getModel('email_connector/contact')->getCollection()
170
+ ->addFieldToFilter('email', $email)
171
+ ->addFieldToFilter('website_id', $website->getId());
172
+ //unsubscribe from the email contact table.
173
+ foreach ($contactCollection as $contact) {
174
+ $contact->setIsSubscriber(null)
175
+ ->setSuppressed('1')->save();
176
+ }
177
+ }catch (Exception $e){
178
+ Mage::logException($e);
179
+ }
180
+ }
181
+ }
182
+ }
183
+ return $result;
184
+ }
185
+ }
app/code/community/Dotdigitalgroup/Email/Model/Order.php ADDED
@@ -0,0 +1,142 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ ->setPageSize(1);
41
+
42
+ if ($collection->count()) {
43
+ return $collection->getFirstItem();
44
+ } else {
45
+ $this->setOrderId($orderId)
46
+ ->setQuoteId($quoteId);
47
+ }
48
+ return $this;
49
+ }
50
+
51
+
52
+ /**
53
+ * @param $orderId
54
+ * @param $quoteId
55
+ * @param $storeId
56
+ *
57
+ * @return $this|Varien_Object
58
+ */
59
+ public function getEmailOrderRow($orderId, $quoteId, $storeId)
60
+ {
61
+ $collection = $this->getCollection()
62
+ ->addFieldToFilter('order_id', $orderId)
63
+ ->addFieldToFilter('quote_id', $quoteId)
64
+ ->addFieldToFilter('store_id', $storeId);
65
+
66
+ if ($collection->count()) {
67
+ return $collection->getFirstItem();
68
+ } else {
69
+ $now = Mage::getSingleton('core/date')->gmtDate();
70
+
71
+ $this->setOrderId($orderId)
72
+ ->setQuoteId($quoteId)
73
+ ->setStoreId($storeId)
74
+ ->setCreatedAt($now);
75
+ }
76
+ return $this;
77
+
78
+ }
79
+
80
+ /**
81
+ * Get all orders with particular status within certain days.
82
+ *
83
+ * @param $storeIds
84
+ * @param $limit
85
+ * @param $orderStatuses
86
+ *
87
+ * @return Dotdigitalgroup_Email_Model_Resource_Order_Collection
88
+ */
89
+ public function getOrdersToImport($storeIds, $limit, $orderStatuses)
90
+ {
91
+ $collection = $this->getCollection()
92
+ ->addFieldToFilter('email_imported', array('null' => true))
93
+ ->addFieldToFilter('store_id', array('in' => $storeIds))
94
+ ->addFieldToFilter('order_status', array('in' => $orderStatuses));
95
+
96
+ $collection->getSelect()->limit($limit);
97
+ return $collection->load();
98
+ }
99
+
100
+ /**
101
+ * Get all sent orders older then certain days.
102
+ *
103
+ * @param $storeIds
104
+ * @param $limit
105
+ *
106
+ * @return Dotdigitalgroup_Email_Model_Resource_Order_Collection
107
+ */
108
+ public function getAllSentOrders($storeIds, $limit)
109
+ {
110
+ $collection = $this->getCollection()
111
+ ->addFieldToFilter('email_imported', 1)
112
+ ->addFieldToFilter('store_id', array('in' => $storeIds));
113
+
114
+ $collection->getSelect()->limit($limit);
115
+ return $collection->load();
116
+ }
117
+
118
+ /**
119
+ * Reset the email order for reimport.
120
+ *
121
+ * @return int
122
+ */
123
+ public function resetOrders()
124
+ {
125
+ /** @var $coreResource Mage_Core_Model_Resource */
126
+ $coreResource = Mage::getSingleton('core/resource');
127
+
128
+ /** @var $conn Varien_Db_Adapter_Pdo_Mysql */
129
+ $conn = $coreResource->getConnection('core_write');
130
+ try{
131
+ $num = $conn->update($coreResource->getTableName('email_connector/order'),
132
+ array('email_imported' => new Zend_Db_Expr('null')),
133
+ $conn->quoteInto('email_imported is ?', new Zend_Db_Expr('not null'))
134
+ );
135
+ }catch (Exception $e){
136
+ Mage::logException($e);
137
+ }
138
+
139
+ return $num;
140
+ }
141
+
142
+ }
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/Config.php ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dotdigitalgroup_Email_Model_Resource_Config extends Mage_Core_Model_Mysql4_Abstract
4
+ {
5
+
6
+ /**
7
+ * constructor.
8
+ */
9
+ protected function _construct()
10
+ {
11
+ $this->_init('email_connector/config', 'email_config_id');
12
+
13
+ }
14
+ }
app/code/community/Dotdigitalgroup/Email/Model/Resource/Config/Collection.php ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dotdigitalgroup_Email_Model_Resource_Config_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/config');
12
+ }
13
+
14
+ }
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/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/Review.php ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dotdigitalgroup_Email_Model_Resource_Review extends Mage_Core_Model_Mysql4_Abstract
4
+ {
5
+ /**
6
+ * constructor.
7
+ */
8
+ protected function _construct()
9
+ {
10
+ $this->_init('email_connector/review', 'id');
11
+
12
+ }
13
+ }
app/code/community/Dotdigitalgroup/Email/Model/Resource/Review/Collection.php ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dotdigitalgroup_Email_Model_Resource_Review_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/review');
12
+ }
13
+ }
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/Resource/Wishlist.php ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dotdigitalgroup_Email_Model_Resource_Wishlist extends Mage_Core_Model_Mysql4_Abstract
4
+ {
5
+ /**
6
+ * constructor.
7
+ */
8
+ protected function _construct()
9
+ {
10
+ $this->_init('email_connector/wishlist', 'id');
11
+
12
+ }
13
+ }
app/code/community/Dotdigitalgroup/Email/Model/Resource/Wishlist/Collection.php ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dotdigitalgroup_Email_Model_Resource_Wishlist_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/wishlist');
12
+ }
13
+ }
app/code/community/Dotdigitalgroup/Email/Model/Review.php ADDED
@@ -0,0 +1,123 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dotdigitalgroup_Email_Model_Review extends Mage_Core_Model_Abstract
4
+ {
5
+ private $_start;
6
+ private $_countReviews;
7
+ private $_reviews;
8
+
9
+ const EMAIL_REVIEW_IMPORTED = 1;
10
+
11
+ /**
12
+ * constructor
13
+ */
14
+ public function _construct()
15
+ {
16
+ parent::_construct();
17
+ $this->_init('email_connector/review');
18
+ }
19
+
20
+ /**
21
+ * @return $this|Mage_Core_Model_Abstract
22
+ */
23
+ protected function _beforeSave()
24
+ {
25
+ parent::_beforeSave();
26
+ $now = Mage::getSingleton('core/date')->gmtDate();
27
+ if ($this->isObjectNew()) {
28
+ $this->setCreatedAt($now);
29
+ }else {
30
+ $this->setUpdatedAt($now);
31
+ }
32
+ return $this;
33
+ }
34
+
35
+ public function sync()
36
+ {
37
+ $response = array('success' => true, 'message' => '');
38
+ $helper = Mage::helper('connector');
39
+ $this->_countReviews = 0;
40
+ $this->_reviews = array();
41
+ $this->_start = microtime(true);
42
+ //resource allocation
43
+ $helper->allowResourceFullExecution();
44
+ foreach (Mage::app()->getWebsites(true) as $website) {
45
+
46
+ $enabled = Mage::helper('connector')->getWebsiteConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_API_ENABLED, $website);
47
+ $sync = Mage::helper('connector')->getWebsiteConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_SYNC_REVIEW_ENABLED, $website);
48
+
49
+ if ($enabled && $sync) {
50
+ //start the sync
51
+ if (! $this->_countReviews)
52
+ $helper->log('---------- Start reviews sync ----------');
53
+ $this->_exportReviewsForWebsite($website);
54
+ }
55
+
56
+ if (isset($this->_reviews[$website->getId()])) {
57
+ $reviews = $this->_reviews[$website->getId()];
58
+ //send reviews as transactional data
59
+ $client = Mage::helper('connector')->getWebsiteApiClient($website);
60
+ $client->postContactsTransactionalDataImport($reviews, 'Reviews');
61
+ $this->_countReviews += count($reviews);
62
+ }
63
+ }
64
+
65
+ if ($this->_countReviews) {
66
+ $message = 'Total time for sync : ' . gmdate( "H:i:s", microtime( true ) - $this->_start ) . ', Total synced = ' . $this->_countReviews;
67
+ $helper->log( $message );
68
+ $response['message'] = $message;
69
+ }
70
+ return $response;
71
+ }
72
+
73
+ private function _exportReviewsForWebsite(Mage_Core_Model_Website $website)
74
+ {
75
+ $limit = Mage::helper('connector')->getWebsiteConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_TRANSACTIONAL_DATA_SYNC_LIMIT, $website);
76
+ $reviews = $this->_getReviewsToExport($website, $limit);
77
+
78
+ if($reviews->getSize()){
79
+ foreach($reviews as $review){
80
+ try {
81
+ $mageReview = Mage::getModel('review/review')->load($review->getReviewId());
82
+
83
+ $product = Mage::getModel('catalog/product')
84
+ ->setStoreId($mageReview->getStoreId())
85
+ ->load($mageReview->getEntityPkValue());
86
+
87
+ $customer = Mage::getModel('customer/customer')->load($mageReview->getCustomerId());
88
+
89
+ $connectorReview = Mage::getModel('email_connector/customer_review', $customer)
90
+ ->setReviewData($mageReview)
91
+ ->setProduct($product);
92
+
93
+ $votesCollection = Mage::getModel('rating/rating_option_vote')
94
+ ->getResourceCollection()
95
+ ->setReviewFilter($mageReview->getReviewId());
96
+ $votesCollection->getSelect()->join(
97
+ array('rating'=> 'rating'),
98
+ 'rating.rating_id = main_table.rating_id',
99
+ array('rating_code' => 'rating.rating_code')
100
+ );
101
+
102
+ foreach($votesCollection as $ratingItem){
103
+ $rating = Mage::getModel('email_connector/customer_review_rating', $ratingItem);
104
+ $connectorReview->createRating($ratingItem->getRatingCode(), $rating);
105
+ }
106
+ $this->_reviews[$website->getId()][] = $connectorReview;
107
+ $review->setReviewImported(self::EMAIL_REVIEW_IMPORTED)->save();
108
+ }catch(Exception $e){
109
+ Mage::logException($e);
110
+ }
111
+ }
112
+ }
113
+ }
114
+
115
+ private function _getReviewsToExport(Mage_Core_Model_Website $website, $limit = 100)
116
+ {
117
+ return $this->getCollection()
118
+ ->addFieldToFilter('review_imported', array('null' => 'true'))
119
+ ->addFieldToFilter('store_id', array('in' => $website->getStoreIds()))
120
+ ->setPageSize($limit)
121
+ ->load();
122
+ }
123
+ }
app/code/community/Dotdigitalgroup/Email/Model/Sales/Observer.php ADDED
@@ -0,0 +1,211 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ if (! Mage::registry('sales_order_status_before'))
17
+ Mage::register('sales_order_status_before', $reloaded->getStatus());
18
+ return $this;
19
+ }
20
+ /**
21
+ * save/reset the order as transactional data.
22
+ *
23
+ * @param Varien_Event_Observer $observer
24
+ * @return $this
25
+ */
26
+ public function handleSalesOrderSaveAfter(Varien_Event_Observer $observer)
27
+ {
28
+ try{
29
+ $order = $observer->getEvent()->getOrder();
30
+ $status = $order->getStatus();
31
+ $storeId = $order->getStoreId();
32
+ // start app emulation
33
+ $appEmulation = Mage::getSingleton('core/app_emulation');
34
+ $initialEnvironmentInfo = $appEmulation->startEnvironmentEmulation($storeId);
35
+ $emailOrder = Mage::getModel('email_connector/order')->loadByOrderId($order->getEntityId(), $order->getQuoteId());
36
+ //reimport email order
37
+ $emailOrder->setUpdatedAt($order->getUpdatedAt())
38
+ ->setStoreId($storeId)
39
+ ->setOrderStatus($status);
40
+ if($emailOrder->getEmailImported() != Dotdigitalgroup_Email_Model_Contact::EMAIL_CONTACT_IMPORTED) {
41
+ $emailOrder->setEmailImported(null);
42
+ }
43
+
44
+ // check for order status change
45
+ $statusBefore = Mage::registry('sales_order_status_before');
46
+ if ( $status!= $statusBefore) {
47
+ //If order status has changed and order is already imported then set imported to null
48
+ if($emailOrder->getEmailImported() == Dotdigitalgroup_Email_Model_Contact::EMAIL_CONTACT_IMPORTED) {
49
+ $emailOrder->setEmailImported(Dotdigitalgroup_Email_Model_Contact::EMAIL_CONTACT_NOT_IMPORTED);
50
+ }
51
+ $smsCampaign = Mage::getModel('email_connector/sms_campaign', $order);
52
+ $smsCampaign->setStatus($status);
53
+ $smsCampaign->sendSms();
54
+ // set back the current store
55
+ $appEmulation->stopEnvironmentEmulation($initialEnvironmentInfo);
56
+ }
57
+ $emailOrder->save();
58
+
59
+ //admin oder when editing the first one is canceled
60
+ Mage::unregister('sales_order_status_before');
61
+ }catch(Exception $e){
62
+ Mage::logException($e);
63
+ }
64
+ return $this;
65
+ }
66
+
67
+
68
+ /**
69
+ * Create new order event.
70
+ * @param Varien_Event_Observer $observer
71
+ *
72
+ * @return $this
73
+ * @throws Mage_Core_Exception
74
+ */
75
+ public function handleSalesOrderPlaceAfter(Varien_Event_Observer $observer)
76
+ {
77
+ $data = new Varien_Object();
78
+ $order = $observer->getEvent()->getOrder();
79
+ $website = Mage::app()->getWebsite($order->getWebsiteId());
80
+ $websiteName = $website->getName();
81
+ if (Mage::helper('connector')->getWebsiteConfig(Dotdigitalgroup_Email_Helper_Transactional::XML_PATH_TRANSACTIONAL_API_ENABLED, $website)) {
82
+ $storeName = Mage::app()->getStore($order->getStoreId())->getName();
83
+ $data->setCustomerId($order->getCustomerId())
84
+ ->setCustomerEmail($order->getCustomerEmail())
85
+ ->setOrderId($order->getId())
86
+ ->setOrderIncrementId($order->getIncrementId())
87
+ ->setWebsiteName($websiteName)
88
+ ->setStoreName($storeName)
89
+ ->setWebsite($website)
90
+ ->setOrderDate($order->getCreatedAt());
91
+
92
+ Mage::helper('connector/transactional')->updateContactData($data);
93
+ }
94
+ //automation enrolment for order
95
+ if($order->getCustomerIsGuest()){
96
+ //send guest to automation mapped
97
+ $automationType = 'XML_PATH_CONNECTOR_AUTOMATION_STUDIO_GUEST_ORDER';
98
+ $email = $order->getCustomerEmail();
99
+ $websiteId = $order->getWebsiteId();
100
+ $this->_postCustomerToAutomation($email, $websiteId, $automationType);
101
+ }else{
102
+ //send customer to automation mapped
103
+ $automationType = 'XML_PATH_CONNECTOR_AUTOMATION_STUDIO_ORDER';
104
+ $email = $order->getCustomerEmail();
105
+ $websiteId = $order->getWebsiteId();
106
+ $this->_postCustomerToAutomation($email, $websiteId, $automationType);
107
+ }
108
+ return $this;
109
+ }
110
+
111
+ /**
112
+ * Sales order refund event.
113
+ *
114
+ * @param Varien_Event_Observer $observer
115
+ *
116
+ * @return $this
117
+ */
118
+ public function handleSalesOrderRefund(Varien_Event_Observer $observer)
119
+ {
120
+ $creditmemo = $observer->getEvent()->getCreditmemo();
121
+ $storeId = $creditmemo->getStoreId();
122
+ $order = $creditmemo->getOrder();
123
+ $orderId = $order->getEntityId();
124
+ $quoteId = $order->getQuoteId();
125
+
126
+ try{
127
+ /**
128
+ * Reimport transactional data.
129
+ */
130
+ $emailOrder = Mage::getModel('email_connector/order')->loadByOrderId($orderId, $quoteId, $storeId);
131
+ if (!$emailOrder->getId()) {
132
+ Mage::helper('connector')->log('ERROR Creditmemmo Order not found :' . $orderId . ', quote id : ' . $quoteId . ', store id ' . $storeId);
133
+ return $this;
134
+ }
135
+ $emailOrder->setEmailImported(Dotdigitalgroup_Email_Model_Contact::EMAIL_CONTACT_NOT_IMPORTED)->save();
136
+ }catch (Exception $e){
137
+ Mage::logException($e);
138
+ }
139
+
140
+ return $this;
141
+ }
142
+
143
+ /**
144
+ * Sales cancel order event, remove transactional data.
145
+ *
146
+ * @param Varien_Event_Observer $observer
147
+ *
148
+ * @return $this
149
+ */
150
+ public function hangleSalesOrderCancel(Varien_Event_Observer $observer)
151
+ {
152
+ $order = $observer->getEvent()->getOrder();
153
+ $storeId = $order->getStoreId();
154
+ $websiteId = Mage::app()->getStore($storeId)->getWebsiteId();
155
+ $customerEmail = $order->getCustomerEmail();
156
+ $helper = Mage::helper('connector');
157
+ if ($helper->isEnabled($websiteId)) {
158
+ $client = Mage::getModel('email_connector/apiconnector_client');
159
+ $client->setApiUsername($helper->getApiUsername($websiteId));
160
+ $client->setApiPassword($helper->getApiPassword($websiteId));
161
+ // delete the order transactional data
162
+ $client->deleteContactTransactionalData($customerEmail, 'Orders');
163
+ }
164
+
165
+ return $this;
166
+ }
167
+
168
+ /**
169
+ * enrol single contact to automation
170
+ *
171
+ * @param $email
172
+ * @param $websiteId
173
+ * @param $automationType
174
+ */
175
+ private function _postCustomerToAutomation( $email, $websiteId, $automationType) {
176
+ /**
177
+ * Automation Programme
178
+ */
179
+ $path = constant('Dotdigitalgroup_Email_Helper_Config::' . $automationType);
180
+ $automationCampaignId = Mage::helper('connector')->getWebsiteConfig($path, $websiteId);
181
+ $enabled = Mage::helper('connector')->getWebsiteConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_TRANSACTIONAL_API_ENABLED, $websiteId);
182
+
183
+ //add customer to automation
184
+ if ($enabled && $automationCampaignId) {
185
+ Mage::helper( 'connector' )->log( 'AS - ' . $automationType . ' automation Campaign id : ' . $automationCampaignId );
186
+ $client = Mage::helper( 'connector' )->getWebsiteApiClient( $websiteId );
187
+ $apiContact = $client->postContacts($email);
188
+
189
+ // get a program by id
190
+ $program = $client->getProgramById($automationCampaignId);
191
+ /**
192
+ * id
193
+ * name
194
+ * status
195
+ * dateCreated
196
+ */
197
+ Mage::helper( 'connector' )->log( 'AS - get ' . $automationType . ' Program id : ' . $program->id);
198
+ //check for active program with status "Active"
199
+ if (isset($program->status) && $program->status == 'Active') {
200
+ $data = array(
201
+ 'Contacts' => array($apiContact->id),
202
+ 'ProgramId' => $program->id,
203
+ 'Status' => $program->status,
204
+ 'DateCreated' => $program->dateCreated,
205
+ 'AddressBooks' => array()
206
+ );
207
+ $client->postProgramsEnrolments($data);
208
+ }
209
+ }
210
+ }
211
+ }
app/code/community/Dotdigitalgroup/Email/Model/Sales/Order.php ADDED
@@ -0,0 +1,323 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ * Global number of orders
20
+ * @var int
21
+ */
22
+ private $_countOrders = 0;
23
+
24
+ private $_reviewCollection = array();
25
+
26
+ /**
27
+ * initial sync the transactional data
28
+ * @return array
29
+ */
30
+ public function sync()
31
+ {
32
+ $response = array('success' => true, 'message' => '');
33
+ $client = Mage::getModel('email_connector/apiconnector_client');
34
+ // Initialise a return hash containing results of our sync attempt
35
+ $this->_searchAccounts();
36
+ foreach ($this->accounts as $account) {
37
+ $orders = $account->getOrders();
38
+ $numOrders = count($orders);
39
+ $this->_countOrders += $numOrders;
40
+ //send transactional for any number of orders set
41
+ if ($numOrders) {
42
+ $client->setApiUsername($account->getApiUsername())
43
+ ->setApiPassword($account->getApiPassword());
44
+ Mage::helper('connector')->log('--------- Order sync ---------- : ' . count($orders));
45
+ $client->postContactsTransactionalDataImport($orders, 'Orders');
46
+ Mage::helper('connector')->log('----------end order sync----------');
47
+ }
48
+ unset($this->accounts[$account->getApiUsername()]);
49
+ }
50
+
51
+ if ($this->_countOrders)
52
+ $response['message'] = 'Number of updated orders : ' . $this->_countOrders;
53
+ return $response;
54
+ }
55
+
56
+ /**
57
+ * Search the configuration data per website
58
+ */
59
+ private function _searchAccounts()
60
+ {
61
+ $helper = Mage::helper('connector');
62
+ foreach (Mage::app()->getWebsites(true) as $website) {
63
+ if ($helper->getWebsiteConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_SYNC_ORDER_ENABLED, $website)) {
64
+
65
+ $this->_apiUsername = $helper->getApiUsername($website);
66
+ $this->_apiPassword = $helper->getApiPassword($website);
67
+
68
+ // limit for orders included to sync
69
+ $limit = Mage::helper('connector')->getWebsiteConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_TRANSACTIONAL_DATA_SYNC_LIMIT, $website);
70
+ if (!isset($this->accounts[$this->_apiUsername])) {
71
+ $account = Mage::getModel('email_connector/connector_account')
72
+ ->setApiUsername($this->_apiUsername)
73
+ ->setApiPassword($this->_apiPassword);
74
+ $this->accounts[$this->_apiUsername] = $account;
75
+ }
76
+ $this->accounts[$this->_apiUsername]->setOrders($this->getConnectorOrders($website, $limit));
77
+ }
78
+ }
79
+ }
80
+
81
+ /**
82
+ * get all order to import.
83
+ * @param $website
84
+ * @param int $limit
85
+ * @return array
86
+ */
87
+ public function getConnectorOrders($website, $limit = 100)
88
+ {
89
+ $orders = $customers = array();
90
+ $storeIds = $website->getStoreIds();
91
+ $orderModel = Mage::getModel('email_connector/order');
92
+ if(empty($storeIds))
93
+ return array();
94
+
95
+ $helper = Mage::helper('connector');
96
+ $orderStatuses = $helper->getConfigSelectedStatus($website);
97
+
98
+ if($orderStatuses)
99
+ $orderCollection = $orderModel->getOrdersToImport($storeIds, $limit, $orderStatuses);
100
+ else
101
+ return array();
102
+
103
+ foreach ($orderCollection as $order) {
104
+ try {
105
+ $salesOrder = Mage::getModel('sales/order')->load($order->getOrderId());
106
+ $storeId = $order->getStoreId();
107
+ $websiteId = Mage::app()->getStore($storeId)->getWebsiteId();
108
+ /**
109
+ * Add guest to contacts table.
110
+ */
111
+ if ($salesOrder->getCustomerIsGuest()) {
112
+ $this->_createGuestContact($salesOrder->getCustomerEmail(), $websiteId, $storeId);
113
+ }
114
+ if ($salesOrder->getId()) {
115
+ $connectorOrder = Mage::getModel('email_connector/connector_order', $salesOrder);
116
+ $orders[] = $connectorOrder;
117
+ }
118
+ $order->setEmailImported(Dotdigitalgroup_Email_Model_Contact::EMAIL_CONTACT_IMPORTED)
119
+ ->save();
120
+ }catch(Exception $e){
121
+ Mage::logException($e);
122
+ }
123
+ }
124
+ return $orders;
125
+ }
126
+
127
+ /**
128
+ * Create a guest contact.
129
+ * @param $email
130
+ * @param $websiteId
131
+ * @param $storeId
132
+ *
133
+ * @return bool
134
+ */
135
+ private function _createGuestContact($email, $websiteId, $storeId){
136
+ try{
137
+ $client = Mage::helper('connector')->getWebsiteApiClient($websiteId);
138
+
139
+ //no api credentials or the guest has no been mapped
140
+ if (! $client || ! $addressBookId = Mage::helper('connector')->getGuestAddressBook($websiteId))
141
+ return false;
142
+ //check if contact exists, create if not
143
+ $contactApi = $client->postContacts($email);
144
+
145
+ //cannot continue error creating contact
146
+ if (isset($contactApi->message)) {
147
+ return false;
148
+ }
149
+
150
+ //add guest to address book
151
+ $response = $client->postAddressBookContacts($addressBookId, $contactApi);
152
+
153
+ //set contact as was found as guest and
154
+ $contactModel = Mage::getModel('email_connector/contact')->loadByCustomerEmail($email, $websiteId);
155
+ $contactModel->setIsGuest(1)
156
+ ->setStoreId($storeId)
157
+ ->setEmailImported(1);
158
+ //contact id
159
+ if (isset($contactApi->id))
160
+ $contactModel->setContactId();
161
+
162
+ //mark the contact as surpressed
163
+ if (isset($response->message) && $response->message == 'Contact is suppressed. ERROR_CONTACT_SUPPRESSED')
164
+ $contactModel->setSuppressed(1);
165
+
166
+ //save
167
+ $contactModel->save();
168
+
169
+ Mage::helper('connector')->log('-- guest found : ' . $email . ' website : ' . $websiteId . ' ,store : ' . $storeId);
170
+ }catch(Exception $e){
171
+ Mage::helper('connector')->getRaygunClient()->SendException($e, array(Mage::getBaseUrl('web')));
172
+ Mage::logException($e);
173
+ }
174
+
175
+ return true;
176
+ }
177
+
178
+ /**
179
+ * create review campaigns
180
+ *
181
+ * @return bool
182
+ */
183
+ public function createReviewCampaigns()
184
+ {
185
+ $this->searchOrdersForReview();
186
+
187
+ foreach($this->_reviewCollection as $websiteId => $collection){
188
+ $this->registerCampaign($collection, $websiteId);
189
+ }
190
+ }
191
+
192
+ /**
193
+ * register review campaign
194
+ *
195
+ * @param $collection
196
+ * @param $websiteId
197
+ *
198
+ * @throws Exception
199
+ */
200
+ private function registerCampaign($collection, $websiteId)
201
+ {
202
+ $helper = Mage::helper('connector/review');
203
+ $campaignId = $helper->getCampaign($websiteId);
204
+
205
+ if($campaignId) {
206
+ foreach ($collection as $order) {
207
+ Mage::helper('connector')->log('-- Order Review: ' . $order->getIncrementId() . ' Campaign Id: ' . $campaignId);
208
+
209
+ try {
210
+ $emailCampaign = Mage::getModel('email_connector/campaign');
211
+ $emailCampaign
212
+ ->setEmail($order->getCustomerEmail())
213
+ ->setStoreId($order->getStoreId())
214
+ ->setCampaignId($campaignId)
215
+ ->setEventName('Order Review')
216
+ ->setCreatedAt(Mage::getSingleton('core/date')->gmtDate())
217
+ ->setOrderIncrementId($order->getIncrementId())
218
+ ->setQuoteId($order->getQuoteId());
219
+
220
+ if($order->getCustomerId())
221
+ $emailCampaign->setCustomerId($order->getCustomerId());
222
+
223
+ $emailCampaign->save();
224
+ } catch (Exception $e) {
225
+ Mage::logException($e);
226
+ }
227
+ }
228
+ }
229
+ }
230
+
231
+ /**
232
+ * search for orders to review per website
233
+ */
234
+ private function searchOrdersForReview()
235
+ {
236
+ $helper = Mage::helper('connector/review');
237
+
238
+ foreach (Mage::app()->getWebsites(true) as $website){
239
+ if($helper->isEnabled($website) &&
240
+ $helper->getOrderStatus($website) &&
241
+ $helper->getDelay($website)){
242
+
243
+ $storeIds = $website->getStoreIds();
244
+ if(empty($storeIds))
245
+ return;
246
+
247
+ $orderStatusFromConfig = $helper->getOrderStatus($website);
248
+ $delayInDays = $helper->getDelay($website);
249
+
250
+ $campaignCollection = Mage::getModel('email_connector/campaign')->getCollection();
251
+ $campaignCollection
252
+ ->addFieldToFilter('event_name', 'Order Review')
253
+ ->load();
254
+
255
+ $campaignOrderIds = $campaignCollection->getColumnValues('order_increment_id');
256
+
257
+ $to = Mage::app()->getLocale()->date()
258
+ ->subDay($delayInDays);
259
+ $from = clone $to;
260
+ $to = $to->toString('YYYY-MM-dd HH:mm:ss');
261
+ $from = $from->subHour(2)
262
+ ->toString('YYYY-MM-dd HH:mm:ss');
263
+
264
+ $created = array( 'from' => $from, 'to' => $to, 'date' => true);
265
+
266
+ $collection = Mage::getModel('sales/order')->getCollection();
267
+ $collection->addFieldToFilter('status', $orderStatusFromConfig)
268
+ ->addFieldToFilter('created_at', $created)
269
+ ->addFieldToFilter('store_id', array('in' => $storeIds));
270
+
271
+ if(!empty($campaignOrderIds))
272
+ $collection->addFieldToFilter('increment_id', array('nin' => $campaignOrderIds));
273
+
274
+ $collection->load();
275
+
276
+ if($collection->getSize())
277
+ $this->_reviewCollection[$website->getId()] = $collection;
278
+ }
279
+ }
280
+ }
281
+
282
+ /**
283
+ * get customer last order id
284
+ *
285
+ * @param Mage_Customer_Model_Customer $customer
286
+ * @return bool|Varien_Object
287
+ */
288
+ public function getCustomerLastOrderId(Mage_Customer_Model_Customer $customer)
289
+ {
290
+ $storeIds = Mage::app()->getWebsite($customer->getWebsiteId())->getStoreIds();
291
+ $collection = Mage::getModel('sales/order')->getCollection();
292
+ $collection->addFieldToFilter('customer_id', $customer->getId())
293
+ ->addFieldToFilter('store_id', array('in' => $storeIds))
294
+ ->setPageSize(1)
295
+ ->setOrder('entity_id');
296
+
297
+ if ($collection->count())
298
+ return $collection->getFirstItem();
299
+ else
300
+ return false;
301
+ }
302
+
303
+ /**
304
+ * get customer last quote id
305
+ *
306
+ * @param Mage_Customer_Model_Customer $customer
307
+ * @return bool|Varien_Object
308
+ */
309
+ public function getCustomerLastQuoteId(Mage_Customer_Model_Customer $customer)
310
+ {
311
+ $storeIds = Mage::app()->getWebsite($customer->getWebsiteId())->getStoreIds();
312
+ $collection = Mage::getModel('sales/quote')->getCollection();
313
+ $collection->addFieldToFilter('customer_id', $customer->getId())
314
+ ->addFieldToFilter('store_id', array('in' => $storeIds))
315
+ ->setPageSize(1)
316
+ ->setOrder('entity_id');
317
+
318
+ if ($collection->count())
319
+ return $collection->getFirstItem();
320
+ else
321
+ return false;
322
+ }
323
+ }
app/code/community/Dotdigitalgroup/Email/Model/Sales/Quote.php ADDED
@@ -0,0 +1,257 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ * @param string $mode
44
+ */
45
+ public function proccessLostBaskets($mode = 'all')
46
+ {
47
+ /**
48
+ * Save lost baskets to be send in Send table.
49
+ */
50
+ $locale = Mage::app()->getLocale()->getLocale();
51
+
52
+ foreach (Mage::app()->getStores() as $store) {
53
+ $storeId = $store->getId();
54
+ $sendModel = Mage::getModel('email_connector/campaign');
55
+
56
+ if ($mode == 'all' || $mode == 'customers') {
57
+ /**
58
+ * Customers campaings
59
+ */
60
+ foreach ( $this->lostBasketCustomers as $num ) {
61
+ //customer enabled
62
+ if ( $this->_getLostBasketCustomerEnabled( $num, $storeId ) ) {
63
+
64
+ //number of the campaign use minutes
65
+ if ( $num == 1 ) {
66
+ $from = Zend_Date::now( $locale )->subMinute( $this->_getLostBasketCustomerInterval( $num, $storeId ) );
67
+ //other use hours
68
+ } else {
69
+ $from = Zend_Date::now( $locale )->subHour( $this->_getLostBasketCustomerInterval( $num, $storeId ) );
70
+ }
71
+
72
+ $to = clone( $from );
73
+ $from->sub( '5', Zend_Date::MINUTE );
74
+
75
+ //active quotes
76
+ $quoteCollection = $this->_getStoreQuotes( $from->toString( 'YYYY-MM-dd HH:mm' ), $to->toString( 'YYYY-MM-dd HH:mm' ), $guest = false, $storeId );
77
+
78
+ if ( $quoteCollection->getSize() ) {
79
+ Mage::helper( 'connector' )->log( 'Customer lost baskets : ' . $num . ', from : ' . $from->toString( 'YYYY-MM-dd HH:mm' ) . ':' . $to->toString( 'YYYY-MM-dd HH:mm' ) );
80
+ }
81
+
82
+ //campaign id for customers
83
+ $campaignId = $this->_getLostBasketCustomerCampaignId( $num, $storeId );
84
+ foreach ( $quoteCollection as $quote ) {
85
+
86
+ $email = $quote->getCustomerEmail();
87
+ //send email only if the interval limit passed, no emails during this interval
88
+ $campignFound = $this->_checkCustomerCartLimit( $email, $storeId );
89
+
90
+ //no campign found for interval pass
91
+ if ( !$campignFound ) {
92
+
93
+ //save lost basket for sending
94
+ $sendModel->loadByQuoteId( $quote->getId(), $storeId )
95
+ ->setEmail( $email )
96
+ ->setCustomerId( $quote->getCustomerId() )
97
+ ->setEventName( 'Lost Basket' )
98
+ ->setCampaignId( $campaignId )
99
+ ->setStoreId( $storeId )
100
+ ->setWebsiteId($store->getWebsiteId())
101
+ ->setIsSent( null )->save();
102
+ }
103
+ }
104
+ }
105
+
106
+ }
107
+ }
108
+ if ($mode == 'all' || $mode == 'guests') {
109
+ /**
110
+ * Guests campaigns
111
+ */
112
+ foreach ( $this->lostBasketGuests as $num ) {
113
+ if ( $this->_getLostBasketGuestEnabled( $num, $storeId ) ) {
114
+ if ( $num == 1 ) {
115
+ $from = Zend_Date::now( $locale )->subMinute( $this->_getLostBasketGuestIterval( $num, $storeId ) );
116
+ } else {
117
+ $from = Zend_Date::now( $locale )->subHour( $this->_getLostBasketGuestIterval( $num, $storeId ) );
118
+ }
119
+ $to = clone( $from );
120
+ $from->sub( '5', Zend_Date::MINUTE );
121
+ $quoteCollection = $this->_getStoreQuotes( $from->toString( 'YYYY-MM-dd HH:mm' ), $to->toString( 'YYYY-MM-dd HH:mm' ), $guest = true, $storeId );
122
+
123
+ if ( $quoteCollection->getSize() ) {
124
+ Mage::helper( 'connector' )->log( 'Guest lost baskets : ' . $num . ', from : ' . $from->toString( 'YYYY-MM-dd HH:mm' ) . ':' . $to->toString( 'YYYY-MM-dd HH:mm' ) );
125
+ }
126
+ $guestCampaignId = $this->_getLostBasketGuestCampaignId( $num, $storeId );
127
+ foreach ( $quoteCollection as $quote ) {
128
+ $email = $quote->getCustomerEmail();
129
+
130
+ //send email only if the interval limit passed, no emails during this interval
131
+ $campignFound = $this->_checkCustomerCartLimit( $email, $storeId );
132
+
133
+ //no campign found for interval pass
134
+ if ( !$campignFound ) {
135
+ //save lost basket for sending
136
+ $sendModel->loadByQuoteId( $quote->getId(), $storeId )
137
+ ->setEmail( $email )
138
+ ->setEventName( 'Lost Basket' )
139
+ ->setCheckoutMethod( 'Guest' )
140
+ ->setCampaignId( $guestCampaignId )
141
+ ->setStoreId( $storeId )
142
+ ->setWebsiteId($store->getWebsiteId())
143
+ ->setIsSent( null )->save();
144
+ }
145
+ }
146
+ }
147
+ }
148
+ }
149
+ }
150
+ }
151
+
152
+ private function _getLostBasketCustomerCampaignId($num, $storeId)
153
+ {
154
+ $store = Mage::app()->getStore($storeId);
155
+ return $store->getConfig(constant('self::XML_PATH_LOSTBASKET_CUSTOMER_CAMPAIGN_' . $num));
156
+ }
157
+ private function _getLostBasketGuestCampaignId($num, $storeId)
158
+ {
159
+ $store = Mage::app()->getStore($storeId);
160
+ return $store->getConfig(constant('self::XML_PATH_LOSTBASKET_GUEST_CAMPAIGN_'. $num));
161
+ }
162
+
163
+ private function _getLostBasketCustomerInterval($num, $storeId)
164
+ {
165
+ $store = Mage::app()->getstore($storeId);
166
+ return $store->getConfig(constant('self::XML_PATH_LOSTBASKET_CUSTOMER_INTERVAL_' . $num));
167
+ }
168
+
169
+ private function _getLostBasketGuestIterval($num, $storeId)
170
+ {
171
+ $store = Mage::app()->getStore($storeId);
172
+ return $store->getConfig(constant('self::XML_PATH_LOSTBASKET_GUEST_INTERVAL_' . $num));
173
+ }
174
+
175
+ protected function _getLostBasketCustomerEnabled($num, $storeId)
176
+ {
177
+ $store = Mage::app()->getStore($storeId);
178
+ $enabled = $store->getConfig(constant('self::XML_PATH_LOSTBASKET_CUSTOMER_ENABLED_' . $num));
179
+ return $enabled;
180
+
181
+ }
182
+
183
+ protected function _getLostBasketGuestEnabled($num, $storeId)
184
+ {
185
+ $store = Mage::app()->getStore($storeId);
186
+ return $store->getConfig(constant('self::XML_PATH_LOSTBASKET_GUEST_ENABLED_' . $num));
187
+ }
188
+
189
+ /**
190
+ * @param string $from
191
+ * @param string $to
192
+ * @param bool $guest
193
+ * @param int $storeId
194
+ * @return Mage_Eav_Model_Entity_Collection_Abstract
195
+ */
196
+ private function _getStoreQuotes($from = null, $to = null, $guest = false, $storeId = 0)
197
+ {
198
+ $updated = array(
199
+ 'from' => $from,
200
+ 'to' => $to,
201
+ 'date' => true);
202
+
203
+ $salesCollection = Mage::getResourceModel('sales/quote_collection')
204
+ ->addFieldToFilter('is_active', 1)
205
+ ->addFieldToFilter('items_count', array('gt' => 0))
206
+ ->addFieldToFilter('customer_email', array('neq' => ''))
207
+ ->addFieldToFilter('store_id', $storeId)
208
+ ->addFieldToFilter('updated_at', $updated);
209
+ if ($guest) {
210
+ $salesCollection->addFieldToFilter( 'customer_id', array( 'null' => true ) );
211
+ }
212
+
213
+ return $salesCollection;
214
+ }
215
+
216
+ /**
217
+ * Check customer campaign that was sent by a limit from config.
218
+ * Return false for any found for this period.
219
+ *
220
+ * @param $email
221
+ * @param $storeId
222
+ *
223
+ * @return bool
224
+ */
225
+ private function _checkCustomerCartLimit($email, $storeId) {
226
+
227
+ $cartLimit = Mage::getStoreConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_ABANDONED_CART_LIMIT, $storeId);
228
+ $locale = Mage::app()->getLocale()->getLocale();
229
+
230
+ //no limit is set skip
231
+ if (! $cartLimit)
232
+ return false;
233
+
234
+ //time diff
235
+ $to = Zend_Date::now($locale);
236
+ $from = Zend_Date::now($locale)->subHour($cartLimit);
237
+
238
+ $updated = array(
239
+ 'from' => $from,
240
+ 'to' => $to,
241
+ 'date' => true
242
+ );
243
+
244
+ //number of campigns during this time
245
+ $campaignLimit = Mage::getModel('email_connector/campaign')->getCollection()
246
+ ->addFieldToFilter('email', $email)
247
+ ->addFieldToFilter('event_name', 'Lost Basket')
248
+ ->addFieldToFilter('sent_at', $updated)
249
+ ->count()
250
+ ;
251
+
252
+ if ($campaignLimit)
253
+ return true;
254
+
255
+ return false;
256
+ }
257
+ }
app/code/community/Dotdigitalgroup/Email/Model/Sms/Campaign.php ADDED
@@ -0,0 +1,112 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ }
53
+ /**
54
+ * @return mixed
55
+ */
56
+ public function getStatus()
57
+ {
58
+ return $this->_status;
59
+ }
60
+
61
+ /**
62
+ * @param mixed $status
63
+ */
64
+ public function setStatus($status)
65
+ {
66
+ $this->_status = $status;
67
+ }
68
+
69
+ public function sendSms()
70
+ {
71
+ $website = Mage::app()->getStore($this->_storeId)->getWebsite();
72
+ $client = Mage::helper('connector')->getWebsiteApiClient($website);
73
+ //all available sms in config
74
+ foreach ($this->_allsms as $num) {
75
+
76
+ $enabled = (bool)Mage::getStoreConfig(constant('Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_SMS_ENABLED_' . $num));
77
+ if ($enabled) {
78
+ $status = Mage::getStoreConfig(constant('Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_SMS_STATUS_' . $num));
79
+ $message = $this->_processMessage(Mage::getStoreConfig(constant('Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_SMS_MESSAGE_' . $num)));
80
+ $match = preg_match(self::UK_TELEPHONE_PATTERN, $this->_customerTelephone);
81
+ if ($match != false) {
82
+ $codePhone = preg_replace('/\A(0){1}+/', '+44', $this->_customerTelephone);
83
+ //status and telephone valid
84
+ if ($this->_status == $status) {
85
+ Mage::helper('connector')->log('sending sms message with status : ' . $status . ' and ' . $codePhone);
86
+ $client->postSmsMessagesSendTo($codePhone, $message);
87
+ }
88
+ } else {
89
+ Mage::helper('connector')->log('SMS: phone not valid for UK : ' . $this->_customerTelephone);
90
+ }
91
+ }
92
+ }
93
+ }
94
+
95
+ /**
96
+ * @param $message
97
+ * @return mixed
98
+ */
99
+ protected function _processMessage($message)
100
+ {
101
+ $replacemant = array();
102
+ if (preg_match('/{{var/', $message)) {
103
+ $replacemant[] = $this->_customerFirstName;
104
+ $replacemant[] = $this->_incrementId;
105
+ $replacemant[] = '';
106
+ $replacemant[] = '';
107
+ $message = preg_replace($this->_vars, $replacemant, $message);
108
+ }
109
+ return substr($message, 0, 160);
110
+ }
111
+
112
+ }
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/Model/Wishlist.php ADDED
@@ -0,0 +1,178 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dotdigitalgroup_Email_Model_Wishlist extends Mage_Core_Model_Abstract
4
+ {
5
+ private $_start;
6
+ private $_wishlists;
7
+ private $_count = 0;
8
+
9
+ /**
10
+ * constructor
11
+ */
12
+ public function _construct()
13
+ {
14
+ parent::_construct();
15
+ $this->_init('email_connector/wishlist');
16
+ }
17
+
18
+ /**
19
+ * @return $this|Mage_Core_Model_Abstract
20
+ */
21
+ protected function _beforeSave()
22
+ {
23
+ parent::_beforeSave();
24
+ $now = Mage::getSingleton('core/date')->gmtDate();
25
+ if ($this->isObjectNew()) {
26
+ $this->setCreatedAt($now);
27
+ }else {
28
+ $this->setUpdatedAt($now);
29
+ }
30
+ return $this;
31
+ }
32
+
33
+ /**
34
+ * @param int $wishListId
35
+ * @return bool|Varien_Object
36
+ */
37
+ public function getWishlist($wishListId)
38
+ {
39
+ $collection = $this->getCollection()
40
+ ->addFieldToFilter('wishlist_id', $wishListId)
41
+ ->setPageSize(1);
42
+
43
+ if ($collection->count()) {
44
+ return $collection->getFirstItem();
45
+ }
46
+ return false;
47
+ }
48
+
49
+ public function sync()
50
+ {
51
+ $response = array('success' => true, 'message' => '');
52
+ $helper = Mage::helper('connector');
53
+ //resource allocation
54
+ $helper->allowResourceFullExecution();
55
+
56
+ foreach (Mage::app()->getWebsites(true) as $website) {
57
+ $enabled = Mage::helper('connector')->getWebsiteConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_SYNC_WISHLIST_ENABLED, $website);
58
+ if ($enabled) {
59
+ //using bulk api
60
+ $helper->log('---------- Start wishlist bulk sync ----------');
61
+ $this->_start = microtime(true);
62
+ $this->_exportWishlistForWebsite($website);
63
+ //send wishlist as transactional data
64
+ if (isset($this->_wishlists[$website->getId()])) {
65
+ $client = Mage::helper('connector')->getWebsiteApiClient($website);
66
+ $websiteWishlists = $this->_wishlists[$website->getId()];
67
+ //import wishlists in bulk
68
+ $client->postContactsTransactionalDataImport($websiteWishlists, 'Wishlist');
69
+ }
70
+ $message = 'Total time for wishlist bulk sync : ' . gmdate("H:i:s", microtime(true) - $this->_start);
71
+ $helper->log($message);
72
+
73
+ //using single api
74
+ $this->_exportWishlistForWebsiteInSingle($website);
75
+ }
76
+ }
77
+ $response['message'] = "wishlist updated: ". $this->_count;
78
+ return $response;
79
+ }
80
+
81
+ private function _exportWishlistForWebsite(Mage_Core_Model_Website $website)
82
+ {
83
+ //reset wishlists
84
+ $this->_wishlists = array();
85
+ $limit = Mage::helper('connector')->getWebsiteConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_TRANSACTIONAL_DATA_SYNC_LIMIT, $website);
86
+ $collection = $this->_getWishlistToImport($website, $limit);
87
+ foreach($collection as $emailWishlist){
88
+ $customer = Mage::getModel('customer/customer')->load($emailWishlist->getCustomerId());
89
+ $wishlist = Mage::getModel('wishlist/wishlist')->load($emailWishlist->getWishlistId());
90
+ /** @var $connectorWishlist */
91
+ $connectorWishlist = Mage::getModel('email_connector/customer_wishlist', $customer);
92
+ $connectorWishlist->setId($wishlist->getId())
93
+ ->setUpdatedAt($wishlist->getUpdatedAt());
94
+ $wishListItemCollection = $wishlist->getItemCollection();
95
+ if (count($wishListItemCollection)) {
96
+ foreach ($wishListItemCollection as $item) {
97
+ /* @var $product Mage_Catalog_Model_Product */
98
+ $product = $item->getProduct();
99
+ $wishlistItem = Mage::getModel('email_connector/customer_wishlist_item', $product)
100
+ ->setQty($item->getQty())
101
+ ->setPrice($product);
102
+ //store for wishlists
103
+ $connectorWishlist->setItem($wishlistItem);
104
+ $this->_count++;
105
+ }
106
+ //set wishlists for later use
107
+ $this->_wishlists[$website->getId()][] = $connectorWishlist;
108
+ $emailWishlist->setWishlistImported(1)->save();
109
+ }
110
+ }
111
+ }
112
+
113
+ private function _getWishlistToImport(Mage_Core_Model_Website $website, $limit = 100)
114
+ {
115
+ $collection = $this->getCollection()
116
+ ->addFieldToFilter('wishlist_imported', array('null' => true))
117
+ ->addFieldToFilter('store_id', array('in' => $website->getStoreIds()))
118
+ ->addFieldToFilter('item_count', array('gt' => 0));
119
+
120
+ $collection->getSelect()->limit($limit);
121
+ return $collection->load();
122
+ }
123
+
124
+ private function _exportWishlistForWebsiteInSingle(Mage_Core_Model_Website $website)
125
+ {
126
+ $helper = Mage::helper('connector');
127
+ $client = $helper->getWebsiteApiClient($website);
128
+ $limit = $helper->getWebsiteConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_TRANSACTIONAL_DATA_SYNC_LIMIT, $website);
129
+ $collection = $this->_getModifiedWishlistToImport($website, $limit);
130
+ foreach($collection as $emailWishlist){
131
+ $customer = Mage::getModel('customer/customer')->load($emailWishlist->getCustomerId());
132
+ $wishlist = Mage::getModel('wishlist/wishlist')->load($emailWishlist->getWishlistId());
133
+ /** @var $connectorWishlist */
134
+ $connectorWishlist = Mage::getModel('email_connector/customer_wishlist', $customer);
135
+ $connectorWishlist->setId($wishlist->getId());
136
+ $wishListItemCollection = $wishlist->getItemCollection();
137
+ if (count($wishListItemCollection)) {
138
+ foreach ($wishListItemCollection as $item) {
139
+ /* @var $product Mage_Catalog_Model_Product */
140
+ $product = $item->getProduct();
141
+ $wishlistItem = Mage::getModel('email_connector/customer_wishlist_item', $product)
142
+ ->setQty($item->getQty())
143
+ ->setPrice($product);
144
+ //store for wishlists
145
+ $connectorWishlist->setItem($wishlistItem);
146
+ $this->_count++;
147
+ }
148
+ //send wishlist as transactional data
149
+ $helper->log('---------- Start wishlist single sync ----------');
150
+ $this->_start = microtime(true);
151
+ //import single piece of transactional data
152
+ $result = $client->postContactsTransactionalData($connectorWishlist, 'Wishlist');
153
+ if (!isset($result->message)){
154
+ $emailWishlist->setWishlistModified(null)->save();
155
+ }
156
+ $message = 'Total time for wishlist single sync : ' . gmdate("H:i:s", microtime(true) - $this->_start);
157
+ $helper->log($message);
158
+ }else{
159
+ $result = $client->deleteContactsTransactionalData($wishlist->getId(), 'Wishlist');
160
+ if (!isset($result->message)){
161
+ $emailWishlist->setWishlistModified(null)->save();
162
+ }
163
+ $message = 'Total time for wishlist single sync : ' . gmdate("H:i:s", microtime(true) - $this->_start);
164
+ $helper->log($message);
165
+ }
166
+ }
167
+ }
168
+
169
+ private function _getModifiedWishlistToImport(Mage_Core_Model_Website $website, $limit = 100)
170
+ {
171
+ $collection = $this->getCollection()
172
+ ->addFieldToFilter('wishlist_modified', 1)
173
+ ->addFieldToFilter('store_id', array('in' => $website->getStoreIds()));
174
+
175
+ $collection->getSelect()->limit($limit);
176
+ return $collection->load();
177
+ }
178
+ }
app/code/community/Dotdigitalgroup/Email/controllers/Adminhtml/ConnectorController.php ADDED
@@ -0,0 +1,339 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ $num = Mage::getModel('email_connector/order')->resetOrders();
57
+ Mage::helper('connector')->log('-- Reset Orders for reimport : ' . $num);
58
+ Mage::getSingleton('adminhtml/session')->addSuccess('Done.');
59
+ $this->_redirectReferer();
60
+ }
61
+
62
+ /**
63
+ * Reset customers import.
64
+ */
65
+ public function resetcustomersimportAction()
66
+ {
67
+ Mage::getModel('email_connector/contact')->resetAllContacts();
68
+
69
+ Mage::getSingleton('adminhtml/session')->addSuccess('Done.');
70
+
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
+
107
+ /**
108
+ * Ajax API validation.
109
+ */
110
+ public function ajaxvalidationAction()
111
+ {
112
+ $params = $this->getRequest()->getParams();
113
+ $apiUsername = $params['api_username'];
114
+ // use javascript btoa function to encode the password
115
+
116
+ $apiPassword = base64_decode($params['api_password']);
117
+ $message = Mage::getModel('email_connector/apiconnector_test')->ajaxvalidate($apiUsername, $apiPassword);
118
+ $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($message));
119
+ }
120
+
121
+ /**
122
+ * Ajax request to reset the import for contacts.
123
+ */
124
+ public function resetcontactsajaxAction()
125
+ {
126
+ $numReseted = Mage::getModel('email_connector/contact')->resetAllContacts();
127
+ $message = array('reseted' => $numReseted);
128
+ $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($message));
129
+ }
130
+
131
+ /**
132
+ * Ajax requets to reset susbcribers for reimport.
133
+ */
134
+ public function ajaxresetsubscribersAction()
135
+ {
136
+ $num = Mage::getModel('email_connector/contact')->resetSubscribers();
137
+ $message = array('reseted' => $num);
138
+ $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($message));
139
+ }
140
+
141
+ /**
142
+ * Ajax request to reset orders for reimoport.
143
+ */
144
+ public function ajaxresetguestsAction()
145
+ {
146
+ $num = Mage::getModel('email_connector/order')->resetOrders();
147
+ $message = array('reseted' => $num);
148
+ $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($message));
149
+ }
150
+
151
+ public function createnewdatafieldAction()
152
+ {
153
+ //get params required for datafield
154
+ $request = $this->getRequest();
155
+ $name = $request->getParam('name', false);
156
+ $type = $request->getParam('type', false);
157
+ $default = $request->getParam('default', '');
158
+ $access = $request->getParam('access', false);
159
+ $website = $request->getParam('website', 0);
160
+
161
+ //api client for this website
162
+ $client = Mage::helper('connector')->getWebsiteApiClient($website);
163
+ //only if all data is available
164
+ if ($name && $type && $default && $access) {
165
+ //create datafield
166
+ $response = $client->postDataFields($name, $type, $access, $default);
167
+ //error creating datafield message
168
+ if (isset($response->message)) {
169
+ //send error message to backend
170
+ Mage::getSingleton('adminhtml/session')->addError($response->message);
171
+ Mage::helper('connector')->log($response->message);
172
+ } else {
173
+ //success message
174
+ Mage::getSingleton('adminhtml/session')->addSuccess('Datafield created : ' . $name);
175
+ }
176
+ } else {
177
+ $message = 'Name ' . $name . ', type ' . $type . ' default ' . $default . 'access ' . $access;
178
+ Mage::getSingleton('adminhtml/session')->addError('Datafield cannot be empty.');
179
+ Mage::helper('connector')->rayLog('100', $message);
180
+ }
181
+ }
182
+
183
+ /**
184
+ * Create new address book action.
185
+ */
186
+ public function createnewaddressbookAction()
187
+ {
188
+ $addressBookName = $this->getRequest()->getParam('name');
189
+ $visibility = $this->getRequest()->getParam('visibility');
190
+ $website = $this->getRequest()->getParam('website', 0);
191
+ $client = Mage::helper('connector')->getWebsiteApiClient($website);
192
+ if (strlen($addressBookName)) {
193
+ $response = $client->postAddressBooks($addressBookName, $visibility);
194
+ if (isset($response->message))
195
+ Mage::getSingleton('adminhtml/session')->addError($response->message);
196
+ else
197
+ Mage::getSingleton('adminhtml/session')->addSuccess('Address book : '. $addressBookName . ' created.');
198
+ }
199
+
200
+ }
201
+
202
+ public function reimoprtsubscribersAction()
203
+ {
204
+ $updated = Mage::getModel('email_connector/contact')->resetSubscribers();
205
+ if ($updated) {
206
+ Mage::getSingleton('adminhtml/session')->addSuccess('Done.');
207
+ } else {
208
+ Mage::getSingleton('adminhtml/session')->addNotice('No subscribers imported!');
209
+ }
210
+ $this->_redirectReferer();
211
+ }
212
+
213
+ /**
214
+ * path constant for config helper sent as string.
215
+ */
216
+ public function enablewebsiteconfigurationAction()
217
+ {
218
+ $path = $this->getRequest()->getParam('path');
219
+ $value = $this->getRequest()->getParam('value');
220
+ $website = $this->getRequest()->getParam('website', 0);
221
+
222
+ $path = constant('Dotdigitalgroup_Email_Helper_Config::' . $path);
223
+ $scope = 'websites';
224
+ $scopeId = $website;
225
+
226
+ $config = Mage::getConfig();
227
+
228
+ //use value 1 if not set
229
+ if (isset($value))
230
+ $config->saveConfig($path, $value, $scope, $scopeId);
231
+ else
232
+ $config->saveConfig($path, 1, $scope, $scopeId);
233
+
234
+ //clean cache
235
+ $config->cleanCache();
236
+
237
+ $this->_redirectReferer();
238
+ }
239
+
240
+ /**
241
+ * Populate the tables (customer-email_contact, subscribers-email_contact) with missing ones.
242
+ */
243
+ public function populatecontactsAction()
244
+ {
245
+
246
+ //type of data to bring up-to-date
247
+ $type = $this->getRequest()->getParam('type', false);
248
+ $website = $this->getRequest()->getParam('website', false);
249
+ //required data not set
250
+ if (!$type && $website == false) {
251
+ return ;
252
+ }
253
+
254
+ $contactTable = Mage::getSingleton('core/resource')->getTableName('email_connector/contact');
255
+
256
+ $customerCollection = Mage::getModel('customer/customer')->getCollection()
257
+ ->addFieldToFilter('website_id', $website);
258
+
259
+ $customerCollection->getSelect()
260
+ ->joinLeft(array('ec' => $contactTable), 'e.entity_id = ec.customer_id', array('customer_id' => 'ec.customer_id'))
261
+ ->where('ec.customer_id IS NULL');
262
+
263
+ //found customers t
264
+ if ($count = $customerCollection->getSize()) {
265
+ //trigger the save to update the contact table
266
+ foreach ( $customerCollection as $customer ) {
267
+ $customer->save();
268
+ }
269
+
270
+ Mage::getSingleton( 'adminhtml/session' )->addSuccess( "Total contacts populated : " . $count );
271
+ }
272
+ $this->_redirectReferer();
273
+ }
274
+
275
+ /**
276
+ * Trigger to run the contact sync.
277
+ */
278
+ public function runcontactsyncAction()
279
+ {
280
+ $result = Mage::getModel('email_connector/cron')->contactSync();
281
+
282
+ if ($result['message'])
283
+ Mage::getSingleton('adminhtml/session')->addSuccess($result['message']);
284
+
285
+ $this->_redirectReferer();
286
+ }
287
+
288
+ /**
289
+ * Trigger to run the subscriber sync.
290
+ */
291
+ public function runsubscribersyncAction()
292
+ {
293
+ $result = Mage::getModel('email_connector/cron')->subscribersAndGuestSync();
294
+
295
+ if ($result['message'])
296
+ Mage::getSingleton('adminhtml/session')->addSuccess($result['message']);
297
+
298
+ $this->_redirectReferer();
299
+ }
300
+
301
+ /**
302
+ * Trigger to run the order sync.
303
+ */
304
+ public function runordersyncAction()
305
+ {
306
+
307
+ $result = Mage::getModel('email_connector/cron')->orderSync();
308
+ if ($result['message'])
309
+ Mage::getSingleton('adminhtml/session')->addSuccess($result['message']);
310
+
311
+ $this->_redirectReferer();
312
+ }
313
+
314
+ /**
315
+ * Trigger to run the review sync.
316
+ */
317
+ public function runreviewsyncAction()
318
+ {
319
+
320
+ $result = Mage::getModel('email_connector/cron')->reviewSync();
321
+ if ($result['message'])
322
+ Mage::getSingleton('adminhtml/session')->addSuccess($result['message']);
323
+
324
+ $this->_redirectReferer();
325
+ }
326
+
327
+ /**
328
+ * Trigger to run the reviw sync.
329
+ */
330
+ public function runwishlistsyncAction()
331
+ {
332
+
333
+ $result = Mage::getModel('email_connector/wishlist')->sync();
334
+ if ($result['message'])
335
+ Mage::getSingleton('adminhtml/session')->addSuccess($result['message']);
336
+
337
+ $this->_redirectReferer();
338
+ }
339
+ }
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 . '&suppressfooter=true';
18
+
19
+ $block = $this->getLayout()
20
+ ->createBlock('core/text', 'connector_iframe')
21
+ ->setText(
22
+ "<iframe src=" . $loginuserUrl . " width=100% height=1650 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 code : ' . $code . ', params : ' . $params);
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,252 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ * Mass mark for recreate campaings.
174
+ */
175
+ public function massRecreateAction()
176
+ {
177
+ $campaignIds = $this->getRequest()->getParam('campaign');
178
+ $count = 0;
179
+ if (!is_array($campaignIds)) {
180
+ $this->_getSession()->addError($this->__('Please select campaigns.'));
181
+ } else {
182
+ try {
183
+ foreach ($campaignIds as $campaignId) {
184
+ $campaign = Mage::getSingleton('email_connector/campaign')->load($campaignId);
185
+ if($campaign->getSubject() && $campaign->getHtmlContent() && ($campaign->getIsSent() == NULL)){
186
+ $count++;
187
+ Mage::dispatchEvent('connector_controller_campaign_recreate', array('campaign' => $campaign));
188
+ $campaign->setIsCreated(null)->save();
189
+ }
190
+ elseif(($campaign->getIsSent() == NULL) && $campaign->getIsCopy() == 1){
191
+ $count++;
192
+ Mage::dispatchEvent('connector_controller_campaign_recreate', array('campaign' => $campaign));
193
+ $campaign->setIsCreated(null)->save();
194
+ }
195
+ }
196
+ $this->_getSession()->addSuccess(
197
+ Mage::helper('connector')->__('Total of %d record(s) have recreate.', $count)
198
+ );
199
+ } catch (Exception $e) {
200
+ $this->_getSession()->addError($e->getMessage());
201
+ }
202
+ }
203
+ $this->_redirect('*/*/index');
204
+ }
205
+
206
+
207
+ /**
208
+ * main page.
209
+ */
210
+ public function gridAction()
211
+ {
212
+ $this->loadLayout();
213
+ $this->renderLayout();
214
+ }
215
+
216
+ /**
217
+ * manage the campaigns.
218
+ *
219
+ * @return Dotdigitalgroup_Email_Model_Campaign
220
+ */
221
+ protected function _initAction()
222
+ {
223
+ $this->_title($this->__('Newsletter'))
224
+ ->_title($this->__('Manage Campaigns'));
225
+
226
+ $campaignId = (int) $this->getRequest()->getParam('id');
227
+ $campaign = Mage::getModel('email_connector/campaign');
228
+
229
+ if ($campaignId) {
230
+ $campaign->load($campaignId);
231
+ }
232
+ Mage::register('email_campaign', $campaign);
233
+ return $campaign;
234
+ }
235
+
236
+ /**
237
+ * Export campaigns to CSV file.
238
+ */
239
+ public function exportCsvAction()
240
+ {
241
+ $fileName = 'campaign.csv';
242
+ $content = $this->getLayout()->createBlock('email_connector/adminhtml_campaign_grid')
243
+ ->getCsvFile();
244
+ $this->_prepareDownloadResponse($fileName, $content);
245
+ }
246
+
247
+ protected function _isAllowed()
248
+ {
249
+ return Mage::getSingleton('admin/session')->isAllowed('newsletter/email_connetor/email_connector_campaign');
250
+ }
251
+
252
+ }
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,91 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dotdigitalgroup_Email_Adminhtml_Email_DashboardController extends Mage_Adminhtml_Controller_Action
4
+ {
5
+ /**
6
+ * post dispatch
7
+ */
8
+ public function postDispatch()
9
+ {
10
+ //check the api valid for any of the website
11
+ foreach ( Mage::app()->getWebsites( true ) as $website ) {
12
+
13
+ $passed = Mage::helper('connector')->isEnabled($website);
14
+
15
+ if (! $passed)
16
+ $this->_redirect('*/system_config/edit', array('section' => 'connector_api_credentials'));
17
+ }
18
+
19
+ }
20
+ /**
21
+ * main page.
22
+ */
23
+ public function indexAction()
24
+ {
25
+ $this->_title($this->__('Dashboard'));
26
+
27
+ $this->loadLayout();
28
+ $this->_setActiveMenu('email_connector');
29
+ $this->_addContent($this->getLayout()->createBlock('adminhtml/widget_container'))
30
+ ->_addLeft($this->getLayout()->createBlock ('email_connector/adminhtml_dashboard_tabs'));
31
+ $this->renderLayout();
32
+ }
33
+
34
+ /**
35
+ * Load Status Grid as ajax requst.
36
+ */
37
+ public function statusGridAction() {
38
+
39
+ $block = $this->getLayout()->createBlock('email_connector/adminhtml_dashboard_tabs_status');
40
+ $this->getResponse()->setBody($block->toHtml());
41
+
42
+ }
43
+
44
+ /**
45
+ * Ajax tab for config data.
46
+ */
47
+ public function emailConfigAction() {
48
+ $block = $this->getLayout()->createBlock('email_connector/adminhtml_dashboard_tabs_config');
49
+
50
+ $this->getResponse()->setBody($block->toHtml());
51
+ }
52
+
53
+ protected function _isAllowed()
54
+ {
55
+ return Mage::getSingleton('admin/session')->isAllowed('newsletter/email_connector/email_connector_dashboard');
56
+ }
57
+
58
+
59
+ /**
60
+ * Ajax save the state of expandbles fieldsets.
61
+ */
62
+ public function stateAction()
63
+ {
64
+ $configState = array(
65
+ $this->getRequest()->getParam('container') => $this->getRequest()->getParam('value')
66
+ );
67
+ $this->_saveState($configState);
68
+ }
69
+
70
+ protected function _saveState($configState = array())
71
+ {
72
+ $adminUser = Mage::getSingleton('admin/session')->getUser();
73
+ if (is_array($configState)) {
74
+ $extra = $adminUser->getExtra();
75
+ if (!is_array($extra)) {
76
+ $extra = array();
77
+ }
78
+ if (!isset($extra['configState'])) {
79
+ $extra['configState'] = array();
80
+ }
81
+ foreach ($configState as $fieldset => $state) {
82
+ $extra['configState'][$fieldset] = $state;
83
+ }
84
+ $adminUser->saveExtra($extra);
85
+ }
86
+
87
+ return true;
88
+ }
89
+
90
+
91
+ }
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/Adminhtml/Email/ReviewController.php ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dotdigitalgroup_Email_Adminhtml_Email_ReviewController 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_review'));
13
+ $this->getLayout()->getBlock('head')->setTitle('Connector Reviews');
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_review');
25
+ }
26
+ }
app/code/community/Dotdigitalgroup/Email/controllers/Adminhtml/Email/WishlistController.php ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dotdigitalgroup_Email_Adminhtml_Email_WishlistController 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_wishlist'));
13
+ $this->getLayout()->getBlock('head')->setTitle('Connector Wishlist(s)');
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_wishlist');
25
+ }
26
+ }
app/code/community/Dotdigitalgroup/Email/controllers/Adminhtml/Widget/ChooserController.php ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dotdigitalgroup_Email_Adminhtml_Widget_ChooserController extends Mage_Adminhtml_Controller_Action
4
+ {
5
+ /**
6
+ * ajax handler for product chooser
7
+ */
8
+ public function productAction()
9
+ {
10
+ $block = $this->getLayout()->createBlock(
11
+ 'email_connector/adminhtml_widget_chooser_product', 'email_connector_chooser_product',
12
+ array('js_form_object' => $this->getRequest()->getParam('form'),
13
+ ));
14
+
15
+ if ($block) {
16
+ $this->getResponse()->setBody($block->toHtml());
17
+ }
18
+ }
19
+ }
app/code/community/Dotdigitalgroup/Email/controllers/AjaxController.php ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dotdigitalgroup_Email_AjaxController extends Mage_Core_Controller_Front_Action
4
+ {
5
+ public function emailcaptureAction()
6
+ {
7
+ if($this->getRequest()->getParam('email') && Mage::getSingleton('checkout/session')->getQuote()){
8
+ $email = $this->getRequest()->getParam('email');
9
+ $quote = Mage::getSingleton('checkout/session')->getQuote();
10
+ if($quote->hasItems()){
11
+ try {
12
+ $quote->setCustomerEmail($email)->save();
13
+ Mage::helper('connector')->log('ajax emailCapture email: '. $email);
14
+ }catch(Exception $e){
15
+ Mage::logException($e);
16
+ Mage::helper('connector')->log('ajax emailCapture fail for email: '. $email);
17
+ }
18
+ }
19
+ }
20
+ }
21
+ }
app/code/community/Dotdigitalgroup/Email/controllers/CreditmemoController.php ADDED
@@ -0,0 +1,69 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ require_once 'Dotdigitalgroup' . DS . 'Email' . DS . 'controllers' . DS . 'DynamicContentController.php';
3
+
4
+ class Dotdigitalgroup_Email_CreditmemoController extends Dotdigitalgroup_Email_DynamicContentController
5
+ {
6
+
7
+ /**
8
+ * New creditmemo.
9
+ */
10
+ public function newAction()
11
+ {
12
+ $this->loadLayout();
13
+ $newOrder = $this->getLayout()->createBlock('email_connector/order_creditmemo', 'connector_creditmemo_new', array(
14
+ 'template' => 'connector/creditmemo/new.phtml'
15
+ ));
16
+ $this->getLayout()->getBlock('content')->append($newOrder);
17
+ $items = $this->getLayout()->createBlock('email_connector/order_creditmemo', 'connector_creditmemo_items', array(
18
+ 'template' => 'connector/creditmemo/items.phtml'
19
+ ));
20
+ $this->getLayout()->getBlock('connector_creditmemo_new')->append($items);
21
+ $this->renderLayout();
22
+ }
23
+
24
+ /**
25
+ * New guest action.
26
+ */
27
+ public function newguestAction()
28
+ {
29
+ $this->loadLayout();
30
+ $invoice = $this->getLayout()->createBlock('email_connector/order_invoice', 'connector_creditmemo_guest', array(
31
+ 'template' => 'connector/creditmemo/newguest.phtml'
32
+ ));
33
+ $this->getLayout()->getBlock('content')->append($invoice);
34
+ $items = $this->getLayout()->createBlock('email_connector/order_creditmemo', 'connector_creditmemo_items', array(
35
+ 'template' => 'connector/creditmemo/items.phtml'
36
+ ));
37
+ $this->getLayout()->getBlock('connector_creditmemo_guest')->append($items);
38
+
39
+ $this->renderLayout();
40
+
41
+ }
42
+
43
+ /**
44
+ * update creditmemo.
45
+ */
46
+ public function updateAction()
47
+ {
48
+ $this->loadLayout();
49
+ $newOrder = $this->getLayout()->createBlock('email_connector/order_creditmemo', 'connector_creditmemo_update', array(
50
+ 'template' => 'connector/creditmemo/update.phtml'
51
+ ));
52
+ $this->getLayout()->getBlock('content')->append($newOrder);
53
+
54
+ $this->renderLayout();
55
+ }
56
+
57
+ /**
58
+ * update guest.
59
+ */
60
+ public function updateguestAction()
61
+ {
62
+ $this->loadLayout();
63
+ $newOrder = $this->getLayout()->createBlock('email_connector/order_creditmemo', 'connector_creditmemo_update_guest', array(
64
+ 'template' => 'connector/creditmemo/updateguest.phtml'
65
+ ));
66
+ $this->getLayout()->getBlock('content')->append($newOrder);
67
+ $this->renderLayout();
68
+ }
69
+ }
app/code/community/Dotdigitalgroup/Email/controllers/DynamicContentController.php ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dotdigitalgroup_Email_DynamicContentController extends Mage_Core_Controller_Front_Action
4
+ {
5
+ /**
6
+ * @return Mage_Core_Controller_Front_Action|void
7
+ * @throws Exception
8
+ */
9
+ public function preDispatch()
10
+ {
11
+ //authenticate
12
+ Mage::helper('connector')->auth($this->getRequest()->getParam('code'));
13
+ $orderId = $this->getRequest()->getParam('order_id', false);
14
+ //check for order_id param
15
+ if ($orderId) {
16
+ $order = Mage::getModel('sales/order')->load($orderId);
17
+ //check if the order still exists
18
+ if ($order->getId()) {
19
+ $storeId = $order->getStoreId();
20
+ //start the emulation for order store
21
+ $appEmulation = Mage::getSingleton('core/app_emulation');
22
+ $appEmulation->startEnvironmentEmulation($storeId);
23
+ } else {
24
+ throw new Exception('TE invoice : order not found: ' . $orderId);
25
+ }
26
+ } else {
27
+ throw new Exception('TE invoice : order_id missing :' . $orderId);
28
+ }
29
+ parent::preDispatch();
30
+ }
31
+ }
app/code/community/Dotdigitalgroup/Email/controllers/EmailController.php ADDED
@@ -0,0 +1,147 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dotdigitalgroup_Email_EmailController extends Mage_Core_Controller_Front_Action
4
+ {
5
+ /**
6
+ * Generate coupon for a coupon code id.
7
+ */
8
+ public function couponAction()
9
+ {
10
+ //authenticate
11
+ Mage::helper('connector')->auth($this->getRequest()->getParam('code'));
12
+
13
+ $this->loadLayout();
14
+ //page root template
15
+ if ($root = $this->getLayout()->getBlock('root')) {
16
+ $root->setTemplate('page/blank.phtml');
17
+ }
18
+ //content template
19
+ $coupon = $this->getLayout()->createBlock('email_connector/coupon', 'connector_coupon', array(
20
+ 'template' => 'connector/coupon.phtml'
21
+ ));
22
+ $this->getLayout()->getBlock('content')->append($coupon);
23
+ $this->renderLayout();
24
+ }
25
+
26
+ /**
27
+ * Basket page to display the user items with specific email.
28
+ */
29
+ public function basketAction()
30
+ {
31
+ //authenticate
32
+ Mage::helper('connector')->auth($this->getRequest()->getParam('code'));
33
+ $this->loadLayout();
34
+ if ($root = $this->getLayout()->getBlock('root')) {
35
+ $root->setTemplate('page/blank.phtml');
36
+ }
37
+ $basket = $this->getLayout()->createBlock('email_connector/basket', 'connector_basket', array(
38
+ 'template' => 'connector/basket.phtml'
39
+ ));
40
+ $this->getLayout()->getBlock('content')->append($basket);
41
+ $this->renderLayout();
42
+ }
43
+
44
+ public function reviewAction()
45
+ {
46
+ //authenticate
47
+ Mage::helper('connector')->auth($this->getRequest()->getParam('code'));
48
+ $this->loadLayout();
49
+ $review = $this->getLayout()->createBlock('email_connector/order', 'connector_review', array(
50
+ 'template' => 'connector/review.phtml'
51
+ ));
52
+ $this->getLayout()->getBlock('content')->append($review);
53
+ $this->renderLayout();
54
+ }
55
+
56
+ /**
57
+ * Access Log files.
58
+ */
59
+ public function logAction()
60
+ {
61
+ //file name param
62
+ $fileName = $filePath = '';
63
+ $file = $this->getRequest()->getParam('file', false);
64
+ if ($file) {
65
+ $fileName = $file . '.log';
66
+ $filePath = Mage::getBaseDir( 'log' ) . DIRECTORY_SEPARATOR . $fileName;
67
+ } elseif ($csv = $this->getRequest()->getParam('archive', false)){
68
+ $fileName = $csv . '.csv';
69
+ $filePath = Mage::getBaseDir('export') . DIRECTORY_SEPARATOR . 'email' . DIRECTORY_SEPARATOR . 'archive' . DIRECTORY_SEPARATOR . $fileName;
70
+ }
71
+
72
+ $this->_prepareDownloadResponse($fileName, array(
73
+ 'type' => 'filename',
74
+ 'value' => $filePath
75
+ ));
76
+ return;
77
+ }
78
+
79
+ public function showAction() {
80
+ $list = array();
81
+
82
+ if ($handle = opendir(Mage::getBaseDir('export') . DIRECTORY_SEPARATOR . 'email' . DIRECTORY_SEPARATOR . 'archive')) {
83
+
84
+
85
+ while (false !== ($entry = readdir($handle))) {
86
+
87
+ if ($entry != "." && $entry != "..") {
88
+
89
+ $list[] = $entry;
90
+ }
91
+ }
92
+
93
+ closedir($handle);
94
+ }
95
+
96
+ foreach ( $list as $one ) {
97
+
98
+ echo $one . '</br>';
99
+ }
100
+ return;
101
+ }
102
+
103
+ /**
104
+ * Callback action for the automation studio.
105
+ */
106
+ public function callbackAction()
107
+ {
108
+ $code = $this->getRequest()->getParam('code', false);
109
+ $userId = $this->getRequest()->getParam('state');
110
+ $adminUser = Mage::getModel('admin/user')->load($userId);
111
+ $baseUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB, true);
112
+
113
+ //callback url
114
+ $callback = $baseUrl . 'connector/email/callback';
115
+
116
+ if ($code) {
117
+ $data = 'client_id=' . Mage::getStoreConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CLIENT_ID) .
118
+ '&client_secret=' . Mage::getStoreConfig(Dotdigitalgroup_Email_Helper_Config::XML_PATH_CONNECTOR_CLIENT_SECRET_ID) .
119
+ '&redirect_uri=' . $callback .
120
+ '&grant_type=authorization_code' .
121
+ '&code=' . $code;
122
+
123
+
124
+ $url = Dotdigitalgroup_Email_Helper_Config::API_CONNECTOR_URL_TOKEN;
125
+ $ch = curl_init();
126
+ curl_setopt($ch, CURLOPT_URL, $url);
127
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
128
+ curl_setopt($ch, CURLOPT_TIMEOUT, 10);
129
+ curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
130
+ curl_setopt($ch, CURLOPT_POST, count($data));
131
+ curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
132
+ curl_setopt($ch, CURLOPT_HTTPHEADER, array ('Content-Type: application/x-www-form-urlencoded'));
133
+
134
+
135
+ $response = json_decode(curl_exec($ch));
136
+ if ($response === false) {
137
+ Mage::helper('connector')->rayLog('100', 'Automaion studio number not found : ' . serialize($response));
138
+ Mage::helper('connector')->log("Error Number: " . curl_errno($ch));
139
+ }
140
+
141
+ //save the refresh token to the admin user
142
+ $adminUser->setRefreshToken($response->refresh_token)->save();
143
+ }
144
+ //redirect to automation index page
145
+ $this->_redirectReferer(Mage::helper('adminhtml')->getUrl('adminhtml/email_automation/index'));
146
+ }
147
+ }
app/code/community/Dotdigitalgroup/Email/controllers/InvoiceController.php ADDED
@@ -0,0 +1,71 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ require_once 'Dotdigitalgroup' . DS . 'Email' . DS . 'controllers' . DS . 'DynamicContentController.php';
3
+
4
+ class Dotdigitalgroup_Email_InvoiceController extends Dotdigitalgroup_Email_DynamicContentController
5
+ {
6
+ /**
7
+ * New invoice for order.
8
+ */
9
+ public function newAction()
10
+ {
11
+ $this->loadLayout();
12
+ //set content template
13
+ $invoiceNew = $this->getLayout()->createBlock('email_connector/order_invoice', 'connector_invoice_new', array(
14
+ 'template' => 'connector/invoice/new.phtml'
15
+ ));
16
+ $this->getLayout()->getBlock('content')->append($invoiceNew);
17
+ //invoice items
18
+ $items = $this->getLayout()->createBlock('email_connector/order_invoice', 'connector_order_items', array(
19
+ 'template' => 'connector/order/items.phtml'
20
+ ));
21
+ $this->getLayout()->getBlock('connector_invoice_new')->append($items);
22
+ $this->renderLayout();
23
+ }
24
+
25
+ /**
26
+ * New guest invoice.
27
+ */
28
+ public function newguestAction()
29
+ {
30
+ $this->loadLayout();
31
+ $invoiceGuest = $this->getLayout()->createBlock('email_connector/order_invoice', 'connector_invoiceguest_new', array(
32
+ 'template' => 'connector/invoice/newguest.phtml'
33
+ ));
34
+
35
+ $this->getLayout()->getBlock('content')->append($invoiceGuest);
36
+ $items = $this->getLayout()->createBlock('email_connector/order_invoice', 'connector_order_items', array(
37
+ 'template' => 'connector/order/items.phtml'
38
+ ));
39
+ //set invoice items
40
+ $this->getLayout()->getBlock('connector_invoiceguest_new')->append($items);
41
+ $this->renderLayout();
42
+ }
43
+
44
+ /**
45
+ * Invoice update information.
46
+ */
47
+ public function updateAction()
48
+ {
49
+ $this->loadLayout();
50
+ $invoice = $this->getLayout()->createBlock('email_connector/order_invoice', 'connector_invoice_update', array(
51
+ 'template' => 'connector/invoice/update.phtml'
52
+ ));
53
+ //set invoice content
54
+ $this->getLayout()->getBlock('content')->append($invoice);
55
+ $this->renderLayout();
56
+ }
57
+
58
+ /**
59
+ * Invoice guest.
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
+ //set invoice content
68
+ $this->getLayout()->getBlock('content')->append($invoice);
69
+ $this->renderLayout();
70
+ }
71
+ }
app/code/community/Dotdigitalgroup/Email/controllers/OrderController.php ADDED
@@ -0,0 +1,71 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ require_once 'Dotdigitalgroup' . DS . 'Email' . DS . 'controllers' . DS . 'DynamicContentController.php';
3
+
4
+ class Dotdigitalgroup_Email_OrderController extends Dotdigitalgroup_Email_DynamicContentController
5
+ {
6
+ /**
7
+ * Display new order content.
8
+ */
9
+ public function newAction()
10
+ {
11
+ $this->loadLayout();
12
+ //set content template
13
+ $newOrder = $this->getLayout()->createBlock('email_connector/order', 'connector_order', array(
14
+ 'template' => 'connector/order/new.phtml'
15
+ ));
16
+ $this->getLayout()->getBlock('content')->append($newOrder);
17
+ //set the items for this order
18
+ $items = $this->getLayout()->createBlock('email_connector/order', 'connector_order_items', array(
19
+ 'template' => 'connector/order/items.phtml'
20
+ ));
21
+ $this->getLayout()->getBlock('connector_order')->append($items);
22
+ $this->renderLayout();
23
+ }
24
+
25
+ /**
26
+ * New order for guest.
27
+ */
28
+ public function newguestAction()
29
+ {
30
+ $this->loadLayout();
31
+ //set content template
32
+ $newGuestOrder = $this->getLayout()->createBlock('email_connector/order', 'connector_order_guest', array(
33
+ 'template' => 'connector/order/newguest.phtml'
34
+ ));
35
+ $this->getLayout()->getBlock('content')->append($newGuestOrder);
36
+ //set the items for this order
37
+ $items = $this->getLayout()->createBlock('email_connector/order', 'connector_order_items', array(
38
+ 'template' => 'connector/order/items.phtml'
39
+ ));
40
+ $this->getLayout()->getBlock('connector_order_guest')->append($items);
41
+ $this->renderLayout();
42
+ }
43
+
44
+ /**
45
+ * Show order update information.
46
+ */
47
+ public function updateAction()
48
+ {
49
+ $this->loadLayout();
50
+ //set content template
51
+ $newOrder = $this->getLayout()->createBlock('email_connector/order', 'connector_order_update', array(
52
+ 'template' => 'connector/order/update.phtml'
53
+ ));
54
+ $this->getLayout()->getBlock('content')->append($newOrder);
55
+ $this->renderLayout();
56
+ }
57
+
58
+ /**
59
+ * Show order update for guest.
60
+ */
61
+ public function updateguestAction()
62
+ {
63
+ $this->loadLayout();
64
+ //set the content template
65
+ $newOrder = $this->getLayout()->createBlock('email_connector/order', 'connector_order_update_guest', array(
66
+ 'template' => 'connector/order/updateguest.phtml'
67
+ ));
68
+ $this->getLayout()->getBlock('content')->append($newOrder);
69
+ $this->renderLayout();
70
+ }
71
+ }
app/code/community/Dotdigitalgroup/Email/controllers/ProductsController.php ADDED
@@ -0,0 +1,112 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dotdigitalgroup_Email_ProductsController extends Mage_Core_Controller_Front_Action
4
+ {
5
+ /**
6
+ * @return Mage_Core_Controller_Front_Action|void
7
+ */
8
+ public function preDispatch()
9
+ {
10
+ Mage::helper('connector')->auth($this->getRequest()->getParam('code'));
11
+ //skip order_id check for this actions
12
+ $skip = array('push', 'nosto');
13
+ $actionName = $this->getRequest()->getActionName();
14
+ if (! in_array($actionName, $skip)) {
15
+ $orderId = $this->getRequest()->getParam('order_id', false);
16
+ //check for order id param
17
+ if ($orderId) {
18
+ //check if order still exists
19
+ $order = Mage::getModel('sales/order')->load($orderId);
20
+ if ($order->getId()) {
21
+ //start app emulation
22
+ $storeId = $order->getStoreId();
23
+ $appEmulation = Mage::getSingleton('core/app_emulation');
24
+ $appEmulation->startEnvironmentEmulation($storeId);
25
+ } else {
26
+ $message = 'Dynamic : order not found: ' . $orderId;
27
+ Mage::helper('connector')->log($message);
28
+ Mage::helper('connector')->rayLog('100', $message);
29
+ }
30
+ } else {
31
+ Mage::helper('connector')->log('Dynamic : order_id missing :' . $orderId);
32
+ }
33
+ }
34
+
35
+ parent::preDispatch();
36
+ }
37
+
38
+ /**
39
+ * Related products.
40
+ */
41
+ public function relatedAction()
42
+ {
43
+ $this->loadLayout();
44
+ $products = $this->getLayout()->createBlock('email_connector/recommended_products', 'connector_recommended_related', array(
45
+ 'template' => 'connector/product/list.phtml'
46
+ ));
47
+ //append related products
48
+ $this->getLayout()->getBlock('content')->append($products);
49
+
50
+ $this->renderLayout();
51
+
52
+ }
53
+
54
+ /**
55
+ * Crosssell products.
56
+ */
57
+ public function crosssellAction()
58
+ {
59
+ $this->loadLayout();
60
+ $products = $this->getLayout()->createBlock('email_connector/recommended_products', 'connector_recommended_crosssell', array(
61
+ 'template' => 'connector/product/list.phtml'
62
+ ));
63
+ //append crosssell products.
64
+ $this->getLayout()->getBlock('content')->append($products);
65
+
66
+ $this->renderLayout();
67
+ }
68
+
69
+ /**
70
+ * Upsell products.
71
+ */
72
+ public function upsellAction()
73
+ {
74
+ $this->loadLayout();
75
+ $products = $this->getLayout()->createBlock('email_connector/recommended_products', 'connector_recommended_upsell', array(
76
+ 'template' => 'connector/product/list.phtml'
77
+ ));
78
+ //append upsell products
79
+ $this->getLayout()->getBlock('content')->append($products);
80
+
81
+ $this->renderLayout();
82
+ }
83
+
84
+ /**
85
+ * Products that are set to manually push as related.
86
+ */
87
+ public function pushAction()
88
+ {
89
+ $this->loadLayout();
90
+ $products = $this->getLayout()->createBlock('email_connector/recommended_push', 'connector_product_push', array(
91
+ 'template' => 'connector/product/list.phtml'
92
+ ));
93
+ //append push products
94
+ $this->getLayout()->getBlock('content')->append($products);
95
+ $this->renderLayout();
96
+ }
97
+
98
+ /**
99
+ * Nosto recommendation action.
100
+ */
101
+ public function nostoAction()
102
+ {
103
+ $this->loadLayout();
104
+
105
+ $products = $this->getLayout()->createBlock('email_connector/recommended_products', 'connector_nosto_recommended', array(
106
+ 'template' => 'connector/product/nosto.phtml'
107
+ ));
108
+ $this->getLayout()->getBlock('content')->append($products);
109
+ $this->renderLayout();
110
+ }
111
+
112
+ }
app/code/community/Dotdigitalgroup/Email/controllers/QuoteproductsController.php ADDED
@@ -0,0 +1,94 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dotdigitalgroup_Email_QuoteproductsController extends Mage_Core_Controller_Front_Action
4
+ {
5
+ /**
6
+ * @return Mage_Core_Controller_Front_Action|void
7
+ */
8
+ public function preDispatch()
9
+ {
10
+ Mage::helper('connector')->auth($this->getRequest()->getParam('code'));
11
+ if ($this->getRequest()->getActionName() != 'push') {
12
+ $quoteId = $this->getRequest()->getParam('quote_id', false);
13
+ //check for quote id param
14
+ if ($quoteId) {
15
+ //check if quote exists
16
+ $quote = Mage::getModel('sales/quote')->load($quoteId);
17
+ if ($quote->getId()) {
18
+ //start app emulation
19
+ $storeId = $quote->getStoreId();
20
+ $appEmulation = Mage::getSingleton('core/app_emulation');
21
+ $appEmulation->startEnvironmentEmulation($storeId);
22
+ } else {
23
+ $message = 'Dynamic : Quote not found: ' . $quoteId;
24
+ Mage::helper('connector')->log($message);
25
+ Mage::helper('connector')->rayLog('100', $message);
26
+ }
27
+ } else {
28
+ Mage::helper('connector')->log('Dynamic : order_id missing :' . $quoteId);
29
+ }
30
+ }
31
+
32
+ parent::preDispatch();
33
+ }
34
+
35
+ /**
36
+ * Related products.
37
+ */
38
+ public function relatedAction()
39
+ {
40
+ $this->loadLayout();
41
+ $products = $this->getLayout()->createBlock('email_connector/recommended_quoteproducts', 'connector_recommended_quote_related', array(
42
+ 'template' => 'connector/product/list.phtml'
43
+ ));
44
+ //append related products
45
+ $this->getLayout()->getBlock('content')->append($products);
46
+
47
+ $this->renderLayout();
48
+
49
+ }
50
+
51
+ /**
52
+ * Crosssell products.
53
+ */
54
+ public function crosssellAction()
55
+ {
56
+ $this->loadLayout();
57
+ $products = $this->getLayout()->createBlock('email_connector/recommended_quoteproducts', 'connector_recommended_quote_crosssell', array(
58
+ 'template' => 'connector/product/list.phtml'
59
+ ));
60
+ //append crosssell products.
61
+ $this->getLayout()->getBlock('content')->append($products);
62
+
63
+ $this->renderLayout();
64
+ }
65
+
66
+ /**
67
+ * Upsell products.
68
+ */
69
+ public function upsellAction()
70
+ {
71
+ $this->loadLayout();
72
+ $products = $this->getLayout()->createBlock('email_connector/recommended_quoteproducts', 'connector_recommended_quote_upsell', array(
73
+ 'template' => 'connector/product/list.phtml'
74
+ ));
75
+ //append upsell products
76
+ $this->getLayout()->getBlock('content')->append($products);
77
+
78
+ $this->renderLayout();
79
+ }
80
+
81
+ /**
82
+ * Products that are set to manually push as related.
83
+ */
84
+ public function pushAction()
85
+ {
86
+ $this->loadLayout();
87
+ $products = $this->getLayout()->createBlock('email_connector/recommended_push', 'connector_product_push', array(
88
+ 'template' => 'connector/product/list.phtml'
89
+ ));
90
+ //append push products
91
+ $this->getLayout()->getBlock('content')->append($products);
92
+ $this->renderLayout();
93
+ }
94
+ }
app/code/community/Dotdigitalgroup/Email/controllers/ReportController.php ADDED
@@ -0,0 +1,62 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dotdigitalgroup_Email_ReportController extends Mage_Core_Controller_Front_Action
4
+ {
5
+ /**
6
+ * @return Mage_Core_Controller_Front_Action|void
7
+ */
8
+ public function preDispatch()
9
+ {
10
+ //authenticate
11
+ Mage::helper('connector')->auth($this->getRequest()->getParam('code'));
12
+ parent::preDispatch();
13
+ }
14
+
15
+ /**
16
+ * Bestsellers report.
17
+ */
18
+ public function bestsellersAction()
19
+ {
20
+ $this->loadLayout();
21
+ //set the content template
22
+ $products = $this->getLayout()->createBlock('email_connector/recommended_bestsellers', 'connector_customer', array(
23
+ 'template' => 'connector/product/list.phtml'
24
+ ));
25
+ $this->getLayout()->getBlock('content')->append($products);
26
+ $this->renderLayout();
27
+ }
28
+
29
+ /**
30
+ * Most viewed report.
31
+ */
32
+ public function mostviewedAction()
33
+ {
34
+ $this->loadLayout();
35
+ //set the content template
36
+ $products = $this->getLayout()->createBlock('email_connector/recommended_mostviewed', 'connector_customer', array(
37
+ 'template' => 'connector/product/list.phtml'
38
+ ));
39
+ $this->getLayout()->getBlock('content')->append($products);
40
+ $this->renderLayout();
41
+ }
42
+
43
+ /**
44
+ * Recently viewed products for customer.
45
+ */
46
+ public function recentlyviewedAction()
47
+ {
48
+ //customer id param
49
+ $customerId = $this->getRequest()->getParam('customer_id');
50
+ //no customer was found
51
+ if (! $customerId) {
52
+ throw new Exception('Recentlyviewed : no customer id : ' . $customerId);
53
+ }
54
+ $this->loadLayout();
55
+ //set content template
56
+ $products = $this->getLayout()->createBlock('email_connector/recommended_recentlyviewed', 'connector_customer', array(
57
+ 'template' => 'connector/product/list.phtml'
58
+ ));
59
+ $this->getLayout()->getBlock('content')->append($products);
60
+ $this->renderLayout();
61
+ }
62
+ }
app/code/community/Dotdigitalgroup/Email/controllers/ShippingController.php ADDED
@@ -0,0 +1,84 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ require_once 'Dotdigitalgroup' . DS . 'Email' . DS . 'controllers' . DS . 'DynamicContentController.php';
3
+
4
+ class Dotdigitalgroup_Email_ShippingController extends Dotdigitalgroup_Email_DynamicContentController
5
+ {
6
+ /**
7
+ * New shipping for this order.
8
+ */
9
+ public function newAction()
10
+ {
11
+ $this->loadLayout();
12
+ //set content template
13
+ $newOrder = $this->getLayout()->createBlock('email_connector/order_shipping', 'connector_shipping_new', array(
14
+ 'template' => 'connector/shipping/new.phtml'
15
+ ));
16
+ $this->getLayout()->getBlock('content')->append($newOrder);
17
+ //set content items
18
+ $items = $this->getLayout()->createBlock('email_connector/order', 'connector_shipping_items', array(
19
+ 'template' => 'connector/order/items.phtml'
20
+ ));
21
+ $this->getLayout()->getBlock('connector_shipping_new')->append($items);
22
+ //rewrite the items to dislpay the shipped ones
23
+ $items = $this->getLayout()->createBlock('email_connector/order_shipping', 'connector_shipping_track', array(
24
+ 'template' => 'email/order/shipment/track.phtml'
25
+ ));
26
+ $this->getLayout()->getBlock('connector_shipping_new')->append($items);
27
+ $this->renderLayout();
28
+ }
29
+
30
+ /**
31
+ * New shipping for guest.
32
+ */
33
+ public function newguestAction()
34
+ {
35
+ $this->loadLayout();
36
+ //set content template
37
+ $newOrder = $this->getLayout()->createBlock('email_connector/order_shipping', 'connector_shipping_newguest', array(
38
+ 'template' => 'connector/shipping/newguest.phtml'
39
+ ));
40
+ $this->getLayout()->getBlock('content')->append($newOrder);
41
+ //set content items
42
+ $items = $this->getLayout()->createBlock('email_connector/order', 'connector_shipping_items', array(
43
+ 'template' => 'connector/order/items.phtml'
44
+ ));
45
+ //new guest shipping items
46
+ $this->getLayout()->getBlock('connector_shipping_newguest')->append($items);
47
+ //rewrite the items to dislpay the shipped ones
48
+ $items = $this->getLayout()->createBlock('email_connector/order_shipping', 'connector_shipping_track', array(
49
+ 'template' => 'email/order/shipment/track.phtml'
50
+ ));
51
+ //items that was shipped
52
+ $this->getLayout()->getBlock('connector_shipping_newguest')->append($items);
53
+ $this->renderLayout();
54
+ }
55
+
56
+ /**
57
+ * Shipping update for this order.
58
+ */
59
+ public function updateAction()
60
+ {
61
+ $this->loadLayout();
62
+ //set the content template
63
+ $shippingUpdate = $this->getLayout()->createBlock('email_connector/order_shipping', 'connector_shipping_update', array(
64
+ 'template' => 'connector/shipping/update.phtml'
65
+ ));
66
+ //shipping update content
67
+ $this->getLayout()->getBlock('content')->append($shippingUpdate);
68
+ $this->renderLayout();
69
+ }
70
+
71
+ /**
72
+ * Shipping update for guests.
73
+ */
74
+ public function updateguestAction()
75
+ {
76
+ $this->loadLayout();
77
+ $shippingGuest = $this->getLayout()->createBlock('email_connector/order_shipping', 'connector_shipping_updateguest', array(
78
+ 'template' => 'connector/shipping/updateguest.phtml'
79
+ ));
80
+ //set shipping content
81
+ $this->getLayout()->getBlock('content')->append($shippingGuest);
82
+ $this->renderLayout();
83
+ }
84
+ }
app/code/community/Dotdigitalgroup/Email/etc/adminhtml.xml ADDED
@@ -0,0 +1,170 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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>35</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
+ <email_connector_review translate="title">
38
+ <title>Review Sync</title>
39
+ <sort_order>25</sort_order>
40
+ <action>adminhtml/email_review</action>
41
+ </email_connector_review>
42
+ <email_connector_wishlist translate="title">
43
+ <title>Wishlist Sync</title>
44
+ <sort_order>30</sort_order>
45
+ <action>adminhtml/email_wishlist</action>
46
+ </email_connector_wishlist>
47
+ </children>
48
+ </reports>
49
+ <email_configuration translate="title">
50
+ <title>Configuration</title>
51
+ <sort_order>40</sort_order>
52
+ <children>
53
+ <api_credentials translate="title">
54
+ <title>Api Credentials</title>
55
+ <sort_order>20</sort_order>
56
+ <action>adminhtml/system_config/edit/section/connector_api_credentials</action>
57
+ </api_credentials>
58
+ <data_mapping translate="title">
59
+ <title>Data Mapping</title>
60
+ <sort_order>30</sort_order>
61
+ <action>adminhtml/system_config/edit/section/connector_data_mapping</action>
62
+ </data_mapping>
63
+ <sync_settings translate="title">
64
+ <title>Sync Settings</title>
65
+ <sort_order>40</sort_order>
66
+ <action>adminhtml/system_config/edit/section/connector_sync_settings</action>
67
+ </sync_settings>
68
+ </children>
69
+ </email_configuration>
70
+ </children>
71
+ </email_connector>
72
+ </menu>
73
+ <acl>
74
+ <resources>
75
+ <admin>
76
+ <children>
77
+ <email_connector>
78
+ <title>Email Connector</title>
79
+ <children>
80
+ <email_connector_dashboard translate="title">
81
+ <title>Dashboard</title>
82
+ </email_connector_dashboard>
83
+ <automation_studio translate="title">
84
+ <title>Automation Studio</title>
85
+ </automation_studio>
86
+ <reports>
87
+ <title>Reports</title>
88
+ <children>
89
+ <email_connector_order translate="title">
90
+ <title>Email Connector Orders</title>
91
+ </email_connector_order>
92
+ <email_connector_campaign translate="title">
93
+ <title>Email Connector Campaigns</title>
94
+ </email_connector_campaign>
95
+ <email_connector_contact translate="title">
96
+ <title>Email Connector Contacts</title>
97
+ </email_connector_contact>
98
+ <email_connector_review translate="title">
99
+ <title>Email Connector Reviews</title>
100
+ </email_connector_review>
101
+ <email_connector_wishlist translate="title">
102
+ <title>Email Connector Wishlist</title>
103
+ </email_connector_wishlist>
104
+ </children>
105
+ </reports>
106
+ <email_configuration translate="title">
107
+ <title>Email Configuration</title>
108
+ <children>
109
+ <api_credentials translate="title">
110
+ <title>Api Credentials</title>
111
+ </api_credentials>
112
+ <data_mapping translate="title">
113
+ <title>Data Mapping</title>
114
+ </data_mapping>
115
+ <sync_settings translate="title">
116
+ <title>Sync Settings</title>
117
+ </sync_settings>
118
+ </children>
119
+ </email_configuration>
120
+ </children>
121
+ </email_connector>
122
+ <system>
123
+ <children>
124
+ <config>
125
+ <children>
126
+ <connector_api_credentials translate="title">
127
+ <title><![CDATA[Email API Credentials]]></title>
128
+ </connector_api_credentials>
129
+ <connector_sync_settings translate="title">
130
+ <title><![CDATA[Email Sync Settings]]></title>
131
+ </connector_sync_settings>
132
+ <connector_data_mapping translate="title">
133
+ <title><![CDATA[Email Data Field Mapping]]></title>
134
+ </connector_data_mapping>
135
+ <connector_roi_tracking translate="title">
136
+ <title><![CDATA[Email ROI & Tracking]]></title>
137
+ </connector_roi_tracking>
138
+ <connector_lost_baskets translate="title">
139
+ <title><![CDATA[Abandoned Carts]]></title>
140
+ </connector_lost_baskets>
141
+ <connector_reviews translate="title">
142
+ <title><![CDATA[Reviews]]></title>
143
+ </connector_reviews>
144
+ <connector_sms translate="title">
145
+ <title><![CDATA[Email SMS Section]]></title>
146
+ </connector_sms>
147
+ <connector_dynamic_content translate="title">
148
+ <title><![CDATA[Email Dynamic Content]]></title>
149
+ </connector_dynamic_content>
150
+ <connector_transactional_emails translate="title">
151
+ <title><![CDATA[Email Transactional Email]]></title>
152
+ </connector_transactional_emails>
153
+ <connector_automation_studio translate="title">
154
+ <title><![CDATA[Automation Studio]]></title>
155
+ </connector_automation_studio>
156
+ <connector_configuration translate="title">
157
+ <title><![CDATA[Configuration]]></title>
158
+ </connector_configuration>
159
+ <connector_developer_settings translate="title">
160
+ <title><![CDATA[Developer]]></title>
161
+ </connector_developer_settings>
162
+ </children>
163
+ </config>
164
+ </children>
165
+ </system>
166
+ </children>
167
+ </admin>
168
+ </resources>
169
+ </acl>
170
+ </config>
app/code/community/Dotdigitalgroup/Email/etc/config.xml ADDED
@@ -0,0 +1,633 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Dotdigitalgroup_Email>
5
+ <version>3.3.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
+ <events>
26
+             <controller_action_postdispatch>
27
+                 <observers>
28
+                     <connector_switcher>
29
+                         <class>Dotdigitalgroup_Email_Model_Controller_Observer</class>
30
+                         <method>controllerActionPostdispatch</method>
31
+                     </connector_switcher>
32
+                 </observers>
33
+             </controller_action_postdispatch>
34
+         </events>
35
+ </frontend>
36
+ <global>
37
+ <resources>
38
+ <email_connector_setup>
39
+ <setup>
40
+ <module>Dotdigitalgroup_Email</module>
41
+ <class>Dotdigitalgroup_Email_Model_Resource_Setup</class>
42
+ </setup>
43
+ </email_connector_setup>
44
+ </resources>
45
+ <models>
46
+ <email_connector>
47
+ <class>Dotdigitalgroup_Email_Model</class>
48
+ <resourceModel>email_connector_resource</resourceModel>
49
+ </email_connector>
50
+ <email_connector_resource>
51
+ <class>Dotdigitalgroup_Email_Model_Resource</class>
52
+ <entities>
53
+ <order>
54
+ <table>email_order</table>
55
+ </order>
56
+ <contact>
57
+ <table>email_contact</table>
58
+ </contact>
59
+ <campaign>
60
+ <table>email_campaign</table>
61
+ </campaign>
62
+ <create>
63
+ <table>email_create</table>
64
+ </create>
65
+ <config>
66
+ <table>email_config</table>
67
+ </config>
68
+ <review>
69
+ <table>email_review</table>
70
+ </review>
71
+ <wishlist>
72
+ <table>email_wishlist</table>
73
+ </wishlist>
74
+ </entities>
75
+ </email_connector_resource>
76
+ <core>
77
+ <rewrite>
78
+ <email_template>Dotdigitalgroup_Email_Model_Email_Template</email_template>
79
+ </rewrite>
80
+ </core>
81
+ <newsletter>
82
+ <rewrite>
83
+ <subscriber>Dotdigitalgroup_Email_Model_Newsletter_Sub</subscriber>
84
+ </rewrite>
85
+ </newsletter>
86
+ <customer>
87
+ <rewrite>
88
+ <customer>Dotdigitalgroup_Email_Model_Customer</customer>
89
+ </rewrite>
90
+ </customer>
91
+ </models>
92
+ <helpers>
93
+ <connector>
94
+ <class>Dotdigitalgroup_Email_Helper</class>
95
+ </connector>
96
+ </helpers>
97
+ <blocks>
98
+ <email_connector>
99
+ <class>Dotdigitalgroup_Email_Block</class>
100
+ </email_connector>
101
+ </blocks>
102
+ <events>
103
+
104
+ <admin_system_config_changed_section_connector_api_credentials>
105
+ <observers>
106
+ <connector_api_save>
107
+ <class>Dotdigitalgroup_Email_Model_Adminhtml_Observer</class>
108
+ <method>actionConfigSaveApi</method>
109
+ </connector_api_save>
110
+ </observers>
111
+ </admin_system_config_changed_section_connector_api_credentials>
112
+ <admin_system_config_changed_section_connector_transactional_emails>
113
+ <observers>
114
+ <connector_transactional_api>
115
+ <class>Dotdigitalgroup_Email_Model_Adminhtml_Observer</class>
116
+ <method>saveConfigForTransactional</method>
117
+ </connector_transactional_api>
118
+ </observers>
119
+ </admin_system_config_changed_section_connector_transactional_emails>
120
+ <admin_system_config_changed_section_connector_data_mapping>
121
+ <observers>
122
+ <connector_data_mapping_reset>
123
+ <class>Dotdigitalgroup_Email_Model_Adminhtml_Observer</class>
124
+ <method>actionConfigResetContacts</method>
125
+ </connector_data_mapping_reset>
126
+ </observers>
127
+ </admin_system_config_changed_section_connector_data_mapping>
128
+ <admin_system_config_changed_section_connector_sync_settings>
129
+ <observers>
130
+ <connector_sys_check_feature_active>
131
+ <class>Dotdigitalgroup_Email_Model_Adminhtml_Observer</class>
132
+ <method>checkFeatureActive</method>
133
+ </connector_sys_check_feature_active>
134
+ </observers>
135
+ </admin_system_config_changed_section_connector_sync_settings>
136
+ <customer_save_after>
137
+ <observers>
138
+ <connector_customer_save_after>
139
+ <class>Dotdigitalgroup_Email_Model_Customer_Observer</class>
140
+ <method>handleCustomerSaveBefore</method>
141
+ </connector_customer_save_after>
142
+ </observers>
143
+ </customer_save_after>
144
+ <customer_register_success>
145
+ <observers>
146
+ <connector_customer_register_success>
147
+ <type>singleton</type>
148
+ <class>Dotdigitalgroup_Email_Model_Customer_Observer</class>
149
+ <method>handleCustomerRegiterSuccess</method>
150
+ </connector_customer_register_success>
151
+ </observers>
152
+ </customer_register_success>
153
+ <customer_delete_after>
154
+ <observers>
155
+ <connector_customer_delete_after>
156
+ <class>Dotdigitalgroup_Email_Model_Customer_Observer</class>
157
+ <method>handleCustomerDeleteAfter</method>
158
+ </connector_customer_delete_after>
159
+ </observers>
160
+ </customer_delete_after>
161
+ <newsletter_subscriber_save_before>
162
+ <observers>
163
+ <connector_newsletter_subscriber_save_before>
164
+ <class>Dotdigitalgroup_Email_Model_Newsletter_Observer</class>
165
+ <method>handleNewsletterSubscriberSave</method>
166
+ </connector_newsletter_subscriber_save_before>
167
+ </observers>
168
+ </newsletter_subscriber_save_before>
169
+ <sales_order_place_after>
170
+ <observers>
171
+ <connector_record_sale>
172
+ <type>singleton</type>
173
+ <class>Dotdigitalgroup_Email_Model_Sales_Observer</class>
174
+ <method>handleSalesOrderPlaceAfter</method>
175
+ </connector_record_sale>
176
+ </observers>
177
+ </sales_order_place_after>
178
+ <sales_order_save_before>
179
+ <observers>
180
+ <connector_sales_save_before>
181
+ <class>Dotdigitalgroup_Email_Model_Sales_Observer</class>
182
+ <method>handleSalesOrderSaveBefore</method>
183
+ </connector_sales_save_before>
184
+ </observers>
185
+ </sales_order_save_before>
186
+ <sales_order_save_after>
187
+ <observers>
188
+ <connector_checkout_type_onepage_save_order_after>
189
+ <class>Dotdigitalgroup_Email_Model_Sales_Observer</class>
190
+ <method>handleSalesOrderSaveAfter</method>
191
+ </connector_checkout_type_onepage_save_order_after>
192
+ </observers>
193
+ </sales_order_save_after>
194
+ <sales_order_creditmemo_save_after>
195
+ <observers>
196
+ <connector_sales_order_payment_refund>
197
+ <class>Dotdigitalgroup_Email_Model_Sales_Observer</class>
198
+ <method>handleSalesOrderRefund</method>
199
+ </connector_sales_order_payment_refund>
200
+ </observers>
201
+ </sales_order_creditmemo_save_after>
202
+ <order_cancel_after>
203
+ <observers>
204
+ <connector_sales_order_cancel>
205
+ <class>Dotdigitalgroup_Email_Model_Sales_Observer</class>
206
+ <method>hangleSalesOrderCancel</method>
207
+ </connector_sales_order_cancel>
208
+ </observers>
209
+ </order_cancel_after>
210
+ <rewards_points_indexer_update>
211
+ <observers>
212
+ <connector_rewards_points_indexer_update>
213
+ <class>Dotdigitalgroup_Email_Model_Sweettooth_Observer</class>
214
+ <method>ConnectorRewardsPointsIndexerUpdate</method>
215
+ </connector_rewards_points_indexer_update>
216
+ </observers>
217
+ </rewards_points_indexer_update>
218
+ <review_save_after>
219
+ <observers>
220
+ <connector_review_save_after>
221
+ <class>Dotdigitalgroup_Email_Model_Customer_Observer</class>
222
+ <method>reviewSaveAfter</method>
223
+ </connector_review_save_after>
224
+ </observers>
225
+ </review_save_after>
226
+ <wishlist_save_after>
227
+ <observers>
228
+ <connector_wishlist_save_after>
229
+ <class>Dotdigitalgroup_Email_Model_Customer_Observer</class>
230
+ <method>wishlistSaveAfter</method>
231
+ </connector_wishlist_save_after>
232
+ </observers>
233
+ </wishlist_save_after>
234
+ <wishlist_item_save_after>
235
+ <observers>
236
+ <connector_wishlist_item_save_after>
237
+ <class>Dotdigitalgroup_Email_Model_Customer_Observer</class>
238
+ <method>wishlistItemSaveAfter</method>
239
+ </connector_wishlist_item_save_after>
240
+ </observers>
241
+ </wishlist_item_save_after>
242
+ <wishlist_delete_after>
243
+ <observers>
244
+ <connector_wishlist_delete_after>
245
+ <class>Dotdigitalgroup_Email_Model_Customer_Observer</class>
246
+ <method>wishlistDeleteAfter</method>
247
+ </connector_wishlist_delete_after>
248
+ </observers>
249
+ </wishlist_delete_after>
250
+ <wishlist_item_delete_after>
251
+ <observers>
252
+ <connector_wishlist_item_delete_after>
253
+ <class>Dotdigitalgroup_Email_Model_Customer_Observer</class>
254
+ <method>wishlistItemSaveAfter</method>
255
+ </connector_wishlist_item_delete_after>
256
+ </observers>
257
+ </wishlist_item_delete_after>
258
+ </events>
259
+ </global>
260
+ <adminhtml>
261
+ <layout>
262
+ <updates>
263
+ <connector_email>
264
+ <file>connector/email.xml</file>
265
+ </connector_email>
266
+ </updates>
267
+ </layout>
268
+ <events>
269
+ <controller_action_predispatch>
270
+ <observers>
271
+ <connector_feed>
272
+ <type>singleton</type>
273
+ <class>Dotdigitalgroup_Email_Model_Adminhtml_Observer</class>
274
+ <method>updateFeed</method>
275
+ </connector_feed>
276
+ </observers>
277
+ </controller_action_predispatch>
278
+ </events>
279
+ <translate>
280
+ <modules>
281
+ <Dotdigitalgroup_Email>
282
+ <files>
283
+ <default>Dotdigitalgroup_Email.csv</default>
284
+ </files>
285
+ </Dotdigitalgroup_Email>
286
+ </modules>
287
+ </translate>
288
+ </adminhtml>
289
+ <admin>
290
+ <routers>
291
+ <adminhtml>
292
+ <args>
293
+ <modules>
294
+ <Dotdigitalgroup_Email before="Mage_Adminhtml">Dotdigitalgroup_Email_Adminhtml</Dotdigitalgroup_Email>
295
+ </modules>
296
+ </args>
297
+ </adminhtml>
298
+ </routers>
299
+ </admin>
300
+ <crontab>
301
+ <jobs>
302
+ <connector_email_customer_sync>
303
+ <run><model>email_connector/cron::contactSync</model></run>
304
+ <schedule>
305
+ <cron_expr>*/15 * * * *</cron_expr>
306
+ </schedule>
307
+ </connector_email_customer_sync>
308
+ <connector_email_subscriber_and_guest_sync>
309
+ <run><model>email_connector/cron::subscribersAndGuestSync</model></run>
310
+ <schedule>
311
+ <cron_expr>*/15 * * * *</cron_expr>
312
+ </schedule>
313
+ </connector_email_subscriber_and_guest_sync>
314
+ <connector_email_lostbaskets>
315
+ <run><model>email_connector/cron::lostBaskets</model></run>
316
+ <schedule>
317
+ <cron_expr>*/5 * * * *</cron_expr>
318
+ </schedule>
319
+ </connector_email_lostbaskets>
320
+ <connector_email_reviews_and_wishlist>
321
+ <run>
322
+ <model>email_connector/cron::reviewsAndWishlist</model>
323
+ </run>
324
+ <schedule>
325
+ <cron_expr>0 * * * *</cron_expr>
326
+ </schedule>
327
+ </connector_email_reviews_and_wishlist>
328
+ <connector_email_campaign>
329
+ <run>
330
+ <model>email_connector/cron::sendMappedEmails</model>
331
+ </run>
332
+ <schedule>
333
+ <cron_expr>*/5 * * * *</cron_expr>
334
+ </schedule>
335
+ </connector_email_campaign>
336
+ <connector_email_order_sync>
337
+ <run><model>email_connector/cron::orderSync</model></run>
338
+ <schedule>
339
+ <cron_expr>*/15 * * * *</cron_expr>
340
+ </schedule>
341
+ </connector_email_order_sync>
342
+ <connector_email_cleaner>
343
+ <run><model>email_connector/cron::cleaning</model></run>
344
+ <schedule>
345
+ <cron_expr>0 0 1 * * </cron_expr>
346
+ </schedule>
347
+ </connector_email_cleaner>
348
+ </jobs>
349
+ </crontab>
350
+ <default>
351
+ <connector_api_credentials>
352
+ <api>
353
+ <enabled>0</enabled>
354
+ <username></username>
355
+ <password></password>
356
+ </api>
357
+ <oauth>
358
+ <client_id></client_id>
359
+ <client_key></client_key>
360
+ <test_connect></test_connect>
361
+ </oauth>
362
+ </connector_api_credentials>
363
+ <connector_sync_settings>
364
+ <address_book>
365
+ <customers>0</customers>
366
+ <subscribers>0</subscribers>
367
+ <guests>0</guests>
368
+ </address_book>
369
+ <sync>
370
+ <contact_enabled>0</contact_enabled>
371
+ <subscriber_enabled>0</subscriber_enabled>
372
+ <order_enabled>0</order_enabled>
373
+ <wishlist_enabled>0</wishlist_enabled>
374
+ <review_enabled>0</review_enabled>
375
+ </sync>
376
+ <dynamic_addressbook>
377
+ <addressbook_name></addressbook_name>
378
+ </dynamic_addressbook>
379
+ </connector_sync_settings>
380
+ <connector_data_mapping>
381
+ <customer_data>
382
+ <customer_id></customer_id>
383
+ <firstname></firstname>
384
+ <lastname></lastname>
385
+ <dob></dob>
386
+ <gender></gender>
387
+ <website_name></website_name>
388
+ <store_name></store_name>
389
+ <created_at></created_at>
390
+ <last_logged_date></last_logged_date>
391
+ <customer_group></customer_group>
392
+ <review_count></review_count>
393
+ <last_review_date></last_review_date>
394
+ <subscriber_status></subscriber_status>
395
+ <billing_address_1></billing_address_1>
396
+ <billing_address_2></billing_address_2>
397
+ <billing_city></billing_city>
398
+ <billing_state></billing_state>
399
+ <billing_country></billing_country>
400
+ <billing_postcode></billing_postcode>
401
+ <billing_telephone></billing_telephone>
402
+ <delivery_address_1></delivery_address_1>
403
+ <delivery_address_2></delivery_address_2>
404
+ <delivery_city></delivery_city>
405
+ <delivery_state></delivery_state>
406
+ <delivery_country></delivery_country>
407
+ <delivery_postcode></delivery_postcode>
408
+ <delivery_telephone></delivery_telephone>
409
+ <number_of_orders></number_of_orders>
410
+ <average_order_value></average_order_value>
411
+ <total_spend></total_spend>
412
+ <last_order_date></last_order_date>
413
+ <last_order_id></last_order_id>
414
+ <total_refund></total_refund>
415
+ <custom_attributes></custom_attributes>
416
+ <validator></validator>
417
+ </customer_data>
418
+ <dynamic_datafield>
419
+ <datafield_name></datafield_name>
420
+ <datafield_type></datafield_type>
421
+ <datafield_default></datafield_default>
422
+ <datafield_access></datafield_access>
423
+ </dynamic_datafield>
424
+ <sweet_tooth>
425
+ <active>0</active>
426
+ <reward_point_balance></reward_point_balance>
427
+ <reward_point_pending></reward_point_pending>
428
+ <reward_point_pending_time></reward_point_pending_time>
429
+ <reward_point_on_hold></reward_point_on_hold>
430
+ <reward_point_expiration></reward_point_expiration>
431
+ <reward_point_last_earn></reward_point_last_earn>
432
+ <reward_point_last_spent></reward_point_last_spent>
433
+ </sweet_tooth>
434
+ </connector_data_mapping>
435
+ <connector_roi_tracking>
436
+ <page_tracking>
437
+ <enabled>0</enabled>
438
+ </page_tracking>
439
+ <roi_tracking>
440
+ <enabled>0</enabled>
441
+ </roi_tracking>
442
+ </connector_roi_tracking>
443
+ <connector_lost_baskets>
444
+ <customers>
445
+ <enabled_1>0</enabled_1>
446
+ <send_after_1></send_after_1>
447
+ <campaign_1></campaign_1>
448
+ <enabled_2>0</enabled_2>
449
+ <send_after_2></send_after_2>
450
+ <campaign_2></campaign_2>
451
+ <enabled_3>0</enabled_3>
452
+ <send_after_3></send_after_3>
453
+ <campaign_3></campaign_3>
454
+ </customers>
455
+ <guests>
456
+ <enabled_1>0</enabled_1>
457
+ <send_after_1></send_after_1>
458
+ <campaign_1></campaign_1>
459
+ <enabled_2>0</enabled_2>
460
+ <send_after_2></send_after_2>
461
+ <campaign_2></campaign_2>
462
+ <enabled_3>0</enabled_3>
463
+ <send_after_3></send_after_3>
464
+ <campaign_3></campaign_3>
465
+ </guests>
466
+ </connector_lost_baskets>
467
+ <connector_sms>
468
+ <sms_one>
469
+ <enabled>0</enabled>
470
+ <status></status>
471
+ <message></message>
472
+ </sms_one>
473
+ <sms_two>
474
+ <enabled>0</enabled>
475
+ <status></status>
476
+ <message></message>
477
+ </sms_two>
478
+ <sms_three>
479
+ <enabled>0</enabled>
480
+ <status></status>
481
+ <message></message>
482
+ </sms_three>
483
+ <sms_four>
484
+ <enabled>0</enabled>
485
+ <status></status>
486
+ <message></message>
487
+ </sms_four>
488
+ </connector_sms>
489
+ <connector_dynamic_content>
490
+ <products>
491
+ <related_display_type>list</related_display_type>
492
+ <related_items_to_display>2</related_items_to_display>
493
+ <upsell_display_type>list</upsell_display_type>
494
+ <upsell_items_to_display>2</upsell_items_to_display>
495
+ <crosssell_display_type>list</crosssell_display_type>
496
+ <crosssell_items_to_display>2</crosssell_items_to_display>
497
+ <bestsellers_display_type>list</bestsellers_display_type>
498
+ <bestsellers_items_to_display>2</bestsellers_items_to_display>
499
+ <bestsellers_time_period></bestsellers_time_period>
500
+ <most_viewed_display_type>list</most_viewed_display_type>
501
+ <most_viewed_items_to_display>2</most_viewed_items_to_display>
502
+ <most_viewed_time_period></most_viewed_time_period>
503
+ <recently_viewed_display_type>list</recently_viewed_display_type>
504
+ <recently_viewed_items_to_display>2</recently_viewed_items_to_display>
505
+ <review_display_type>list</review_display_type>
506
+ </products>
507
+ <external_dynamic_content_urls>
508
+ <passcode>secret</passcode>
509
+ <lost_basket_url></lost_basket_url>
510
+ <review_url></review_url>
511
+ <coupon_code_url></coupon_code_url>
512
+ <dynamic_content_url></dynamic_content_url>
513
+ <related_products_url></related_products_url>
514
+ <upsell_products_url></upsell_products_url>
515
+ <crosssell_products_url></crosssell_products_url>
516
+ <best_sellers_url></best_sellers_url>
517
+ <most_viewed_url></most_viewed_url>
518
+ <product_push_url></product_push_url>
519
+ <recently_viewed_url></recently_viewed_url>
520
+ <new_order_url></new_order_url>
521
+ <new_order_guest_url></new_order_guest_url>
522
+ <order_update_url></order_update_url>
523
+ <order_update_guest_url></order_update_guest_url>
524
+ <new_invoice_url></new_invoice_url>
525
+ <new_invoice_guest_url></new_invoice_guest_url>
526
+ <invoice_update_url></invoice_update_url>
527
+ <invoice_update_guest_url></invoice_update_guest_url>
528
+ <new_creditmemo_url></new_creditmemo_url>
529
+ <new_creditmemo_guest_url></new_creditmemo_guest_url>
530
+ <creditmemo_update_url></creditmemo_update_url>
531
+ <creditmemo_update_guest_url></creditmemo_update_guest_url>
532
+ <new_shipment_url></new_shipment_url>
533
+ <new_shipment_guest_url></new_shipment_guest_url>
534
+ <shipment_update_url></shipment_update_url>
535
+ <shipment_update_guest_url></shipment_update_guest_url>
536
+ </external_dynamic_content_urls>
537
+ <manual_product_search>
538
+ <display_type>list</display_type>
539
+ <items_to_display>2</items_to_display>
540
+ <products_push_items></products_push_items>
541
+ </manual_product_search>
542
+ <fallback_products>
543
+ <product_list></product_list>
544
+ </fallback_products>
545
+ </connector_dynamic_content>
546
+ <connector_reviews>
547
+ <settings>
548
+ <enabled>0</enabled>
549
+ <status></status>
550
+ <delay></delay>
551
+ <new_product>0</new_product>
552
+ <campaign>0</campaign>
553
+ <anchor></anchor>
554
+ </settings>
555
+ </connector_reviews>
556
+ <connector_transactional_emails>
557
+ <credentials>
558
+ <enabled>0</enabled>
559
+ <api_username></api_username>
560
+ <api_password></api_password>
561
+ </credentials>
562
+ <email_settings>
563
+ <from_address></from_address>
564
+ <unsubscribe_link>1</unsubscribe_link>
565
+ <reply_action>Webmail</reply_action>
566
+ <reply_address></reply_address>
567
+ <send_copy></send_copy>
568
+ </email_settings>
569
+ <email_mapping>
570
+ <default_email_templates></default_email_templates>
571
+ <custom_email_templates></custom_email_templates>
572
+ </email_mapping>
573
+ </connector_transactional_emails>
574
+ <connector_automation_studio>
575
+ <automation>
576
+ <customer_automation>0</customer_automation>
577
+ <subscriber_automation>0</subscriber_automation>
578
+ <order_automation>0</order_automation>
579
+ <guest_order_automation>0</guest_order_automation>
580
+ <review_automation>0</review_automation>
581
+ <wishlist_automation>0</wishlist_automation>
582
+ </automation>
583
+ </connector_automation_studio>
584
+ <connector_configuration>
585
+ <transactional_data>
586
+ <order_statuses></order_statuses>
587
+ <order_custom_attributes></order_custom_attributes>
588
+ </transactional_data>
589
+ <abandoned_carts>
590
+ <email_capture>0</email_capture>
591
+ <limits></limits>
592
+ </abandoned_carts>
593
+ <admin>
594
+ <disable_newsletter_success>0</disable_newsletter_success>
595
+ <disable_customer_success>0</disable_customer_success>
596
+ <recommended_inline><![CDATA[table{font-family: arial, geneva, sans-serif; font-size:12px;}]]></recommended_inline>
597
+ </admin>
598
+ </connector_configuration>
599
+ <connector_developer_settings>
600
+ <import_settings>
601
+ <memory_limit>0</memory_limit>
602
+ <batch_size>10000</batch_size>
603
+ <orders>500</orders>
604
+ </import_settings>
605
+ <abandoned_cart>
606
+ <shell></shell>
607
+ </abandoned_cart>
608
+ <sync_settings>
609
+ <setup_data_fields></setup_data_fields>
610
+ <contact_sync></contact_sync>
611
+ <subscriber_sync></subscriber_sync>
612
+ <order_sync></order_sync>
613
+ <delete_contact></delete_contact>
614
+ <reimport_customers></reimport_customers>
615
+ <reimport_subscribers></reimport_subscribers>
616
+ <reimport_orders></reimport_orders>
617
+ <suppressed_contacts></suppressed_contacts>
618
+ </sync_settings>
619
+ <debug>
620
+ <debug_enabled>1</debug_enabled>
621
+ <debug_api_calls>0</debug_api_calls>
622
+ <raygun_code>JOWaQ4nf4Ox7eAFUvr+TAw==</raygun_code>
623
+ </debug>
624
+ <feed_configuration>
625
+ <feed_enabled>1</feed_enabled>
626
+ <feed_url>dotmailerformagento.co.uk/feed</feed_url>
627
+ <use_https>0</use_https>
628
+ <frequency>1</frequency>
629
+ <last_update></last_update>
630
+ </feed_configuration>
631
+ </connector_developer_settings>
632
+ </default>
633
+ </config>
app/code/community/Dotdigitalgroup/Email/etc/files.yaml ADDED
@@ -0,0 +1,302 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ etc:
2
+ - adminhtml.xml
3
+ - config.xml
4
+ - system.xml
5
+ controllers:
6
+ - Adminhtml#Email#AutomationController.php
7
+ - Adminhtml#Email#CampaignController.php
8
+ - Adminhtml#Email#ContactController.php
9
+ - Adminhtml#Email#DashboardController.php
10
+ - Adminhtml#Email#OrderController.php
11
+ - Adminhtml#Email#ReviewController.php
12
+ - Adminhtml#Email#WishlistController.php
13
+ - Adminhtml#Widget#ChooserController.php
14
+ - Adminhtml#ConnectorController.php
15
+ - CreditmemoController.php
16
+ - DynamicContentController.php
17
+ - EmailController.php
18
+ - InvoiceController.php
19
+ - OrderController.php
20
+ - ProductsController.php
21
+ - ReportController.php
22
+ - ShippingController.php
23
+ - AjaxController.php
24
+ - QuoteproductsController.php
25
+ sql:
26
+ - email_connector_setup#mysql4-install-0.1.0.php
27
+ - email_connector_setup#mysql4-install-3.0.0.php
28
+ - email_connector_setup#mysql4-upgrade-1.1.1-1.1.2.php
29
+ - email_connector_setup#mysql4-upgrade-1.1.2-1.5.0.php
30
+ - email_connector_setup#mysql4-upgrade-2.0.0-2.0.1.php
31
+ - email_connector_setup#mysql4-upgrade-2.0.1-2.0.2.php
32
+ - email_connector_setup#mysql4-upgrade-2.0.4-2.0.5.php
33
+ - email_connector_setup#mysql4-upgrade-2.0.5-2.0.6.php
34
+ - email_connector_setup#mysql4-upgrade-3.0.1-3.0.2.php
35
+ - email_connector_setup#mysql4-upgrade-3.0.3-3.0.4.php
36
+ - email_connector_setup#mysql4-upgrade-3.0.4-3.0.5.php
37
+ - email_connector_setup#mysql4-upgrade-3.1.2-3.1.3.php
38
+ - email_connector_setup#mysql4-upgrade-3.2.1-3.3.0.php
39
+ locale:
40
+ - en_US#Dotdigitalgroup_Email.csv
41
+ block:
42
+ - Adminhtml#Campaign#Edit#Form.php
43
+ - Adminhtml#Campaign#Edit.php
44
+ - Adminhtml#Campaign#Grid.php
45
+ - Adminhtml#Column#Renderer#Imported.php
46
+ - Adminhtml#Column#Renderer#Status.php
47
+ - Adminhtml#Column#Renderer#Sync.php
48
+ - Adminhtml#Config#Template#Templatefields.php
49
+ - Adminhtml#Config#Customdatafields.php
50
+ - Adminhtml#Config#Select.php
51
+ - Adminhtml#Contact#Edit#Form.php
52
+ - Adminhtml#Contact#Edit.php
53
+ - Adminhtml#Contact#Grid.php
54
+ - Adminhtml#Dashboard#Tabs#Analysis#Abandonedcarts.php
55
+ - Adminhtml#Dashboard#Tabs#Analysis#Customer.php
56
+ - Adminhtml#Dashboard#Tabs#Analysis#Rfm.php
57
+ - Adminhtml#Dashboard#Tabs#Analysis#Sales.php
58
+ - Adminhtml#Dashboard#Tabs#Analysis#Subscriber.php
59
+ - Adminhtml#Dashboard#Tabs#General#Data.php
60
+ - Adminhtml#Dashboard#Tabs#Analysis.php
61
+ - Adminhtml#Dashboard#Tabs#Config.php
62
+ - Adminhtml#Dashboard#Tabs#General.php
63
+ - Adminhtml#Dashboard#Tabs#Status.php
64
+ - Adminhtml#Dashboard#Switcher.php
65
+ - Adminhtml#Dashboard#Tabs.php
66
+ - Adminhtml#Order#Grid.php
67
+ - Adminhtml#Review#Grid.php
68
+ - Adminhtml#Sales#Order#Creditmemo#View.php
69
+ - Adminhtml#System#Advanced#Deletecontactids.php
70
+ - Adminhtml#System#Advanced#Notification.php
71
+ - Adminhtml#System#Advanced#Reimportorders.php
72
+ - Adminhtml#System#Advanced#Reimportsubscribers.php
73
+ - Adminhtml#System#Advanced#Resetcustomersimport.php
74
+ - Adminhtml#System#Advanced#Runcontactsync.php
75
+ - Adminhtml#System#Advanced#Runordersync.php
76
+ - Adminhtml#System#Advanced#Runreviewsync.php
77
+ - Adminhtml#System#Advanced#Runsubscribersync.php
78
+ - Adminhtml#System#Advanced#Runwishlistsync.php
79
+ - Adminhtml#System#Advanced#Setupdatafields.php
80
+ - Adminhtml#System#Advanced#Suppressedcontacts.php
81
+ - Adminhtml#System#Automation#Connect.php
82
+ - Adminhtml#System#Config#Addressbook.php
83
+ - Adminhtml#System#Config#Datafield.php
84
+ - Adminhtml#System#Config#Resetcontacts.php
85
+ - Adminhtml#System#Config#Resetguests.php
86
+ - Adminhtml#System#Config#Resetsubscribers.php
87
+ - Adminhtml#System#Config#Validator.php
88
+ - Adminhtml#System#Config#Waitingfield.php
89
+ - Adminhtml#System#Config#Wrapper.php
90
+ - Adminhtml#System#Dynamic#Basket#Crosssell.php
91
+ - Adminhtml#System#Dynamic#Basket#Related.php
92
+ - Adminhtml#System#Dynamic#Basket#Upsell.php
93
+ - Adminhtml#System#Dynamic#Addressbookbutton.php
94
+ - Adminhtml#System#Dynamic#Bestsellers.php
95
+ - Adminhtml#System#Dynamic#Couponinfo.php
96
+ - Adminhtml#System#Dynamic#Creditmemonew.php
97
+ - Adminhtml#System#Dynamic#Crosssell.php
98
+ - Adminhtml#System#Dynamic#Datafieldbutton.php
99
+ - Adminhtml#System#Dynamic#Fallbackchooser.php
100
+ - Adminhtml#System#Dynamic#Fallbackcontainer.php
101
+ - Adminhtml#System#Dynamic#Gridlist.php
102
+ - Adminhtml#System#Dynamic#Lostbasket.php
103
+ - Adminhtml#System#Dynamic#Manualchooser.php
104
+ - Adminhtml#System#Dynamic#Manualcontainer.php
105
+ - Adminhtml#System#Dynamic#Mostviewed.php
106
+ - Adminhtml#System#Dynamic#Nosto.php
107
+ - Adminhtml#System#Dynamic#Productpush.php
108
+ - Adminhtml#System#Dynamic#Recentlyviewed.php
109
+ - Adminhtml#System#Dynamic#Related.php
110
+ - Adminhtml#System#Dynamic#Review.php
111
+ - Adminhtml#System#Dynamic#Upsell.php
112
+ - Adminhtml#System#Sms#Smsmessagefour.php
113
+ - Adminhtml#System#Sms#Smsmessageone.php
114
+ - Adminhtml#System#Sms#Smsmessagethree.php
115
+ - Adminhtml#System#Sms#Smsmessagetwo.php
116
+ - Adminhtml#System#Url#Creditmemoupdate.php
117
+ - Adminhtml#System#Url#Creditmemoupdateguest.php
118
+ - Adminhtml#System#Url#Customerconfirmation.php
119
+ - Adminhtml#System#Url#Customerconfirmed.php
120
+ - Adminhtml#System#Url#Customernew.php
121
+ - Adminhtml#System#Url#Invoiceupdate.php
122
+ - Adminhtml#System#Url#Invoiceupdateguest.php
123
+ - Adminhtml#System#Url#Newcreditmemo.php
124
+ - Adminhtml#System#Url#Newcreditmemoguest.php
125
+ - Adminhtml#System#Url#Newinvoice.php
126
+ - Adminhtml#System#Url#Newinvoiceguest.php
127
+ - Adminhtml#System#Url#Neworder.php
128
+ - Adminhtml#System#Url#Neworderguest.php
129
+ - Adminhtml#System#Url#Newshipment.php
130
+ - Adminhtml#System#Url#Newshipmentguest.php
131
+ - Adminhtml#System#Url#Orderupdate.php
132
+ - Adminhtml#System#Url#Orderupdateguest.php
133
+ - Adminhtml#System#Url#Shipmentupdate.php
134
+ - Adminhtml#System#Url#Shipmentupdateguest.php
135
+ - Adminhtml#System#Ajaxvalidate.php
136
+ - Adminhtml#System#Emailapivalidate.php
137
+ - Adminhtml#Widget#Chooser#Product.php
138
+ - Adminhtml#Wishlist#Grid.php
139
+ - Adminhtml#Campaign.php
140
+ - Adminhtml#Config.php
141
+ - Adminhtml#Contact.php
142
+ - Adminhtml#Dashboard.php
143
+ - Adminhtml#Order.php
144
+ - Adminhtml#Review.php
145
+ - Adminhtml#Wishlist.php
146
+ - Order#Creditmemo.php
147
+ - Order#Invoice.php
148
+ - Order#Shipping.php
149
+ - Recommended#Bestsellers.php
150
+ - Recommended#Mostviewed.php
151
+ - Recommended#Products.php
152
+ - Recommended#Push.php
153
+ - Recommended#Quoteproducts.php
154
+ - Recommended#Recentlyviewed.php
155
+ - Basket.php
156
+ - Coupon.php
157
+ - Order.php
158
+ - Products.php
159
+ helper:
160
+ - Config.php
161
+ - Data.php
162
+ - File.php
163
+ - Recommended.php
164
+ - Review.php
165
+ - Transactional.php
166
+ model:
167
+ - Abstract#Rest.php
168
+ - Adminhtml#Dashboard#Tabs#Analysis#Abandoned.php
169
+ - Adminhtml#Dashboard#Tabs#Analysis#Customer.php
170
+ - Adminhtml#Dashboard#Tabs#Analysis#Orders.php
171
+ - Adminhtml#Dashboard#Tabs#Analysis#Rfm.php
172
+ - Adminhtml#Dashboard#Tabs#Analysis#Subscriber.php
173
+ - Adminhtml#Dashboard#Content.php
174
+ - Adminhtml#Source#Advanced#Abandonedlimit.php
175
+ - Adminhtml#Source#Advanced#Attributes.php
176
+ - Adminhtml#Source#Advanced#Frequency.php
177
+ - Adminhtml#Source#Advanced#Transdata.php
178
+ - Adminhtml#Source#Automation#Programme.php
179
+ - Adminhtml#Source#Contact#Imported.php
180
+ - Adminhtml#Source#Customer#Attributes#Select.php
181
+ - Adminhtml#Source#Datamapping#Datafieldtype.php
182
+ - Adminhtml#Source#Datamapping#Datafieldaccess.php
183
+ - Adminhtml#Source#Dynamic#Displaytype.php
184
+ - Adminhtml#Source#Dynamic#Gridview.php
185
+ - Adminhtml#Source#Lostbaskets#Interval.php
186
+ - Adminhtml#Source#Lostbaskets#Intervalminute.php
187
+ - Adminhtml#Source#Reviews#Campaigns.php
188
+ - Adminhtml#Source#Reviews#Delay.php
189
+ - Adminhtml#Source#Sweettooth#Yesno.php
190
+ - Adminhtml#Source#Transactional#Campaigns.php
191
+ - Adminhtml#Source#Transactional#Customselect.php
192
+ - Adminhtml#Source#Transactional#Defaultselect.php
193
+ - Adminhtml#Source#Transactional#Fromaddress.php
194
+ - Adminhtml#Source#Transactional#Replyactions.php
195
+ - Adminhtml#Source#Transactional#Sendtype.php
196
+ - Adminhtml#Source#Addressbooks.php
197
+ - Adminhtml#Source#Campaigns.php
198
+ - Adminhtml#Source#Datafields.php
199
+ - Adminhtml#Source#Orderstatus.php
200
+ - Adminhtml#Observer.php
201
+ - Apiconnector#Client.php
202
+ - Apiconnector#Contact.php
203
+ - Apiconnector#Customer.php
204
+ - Apiconnector#Test.php
205
+ - Connector#Account.php
206
+ - Connector#Campaign.php
207
+ - Connector#Datafield.php
208
+ - Connector#Order.php
209
+ - Controller#Observer.php
210
+ - Customer#Review#Rating.php
211
+ - Customer#Wishlist#Item.php
212
+ - Customer#Guest.php
213
+ - Customer#Observer.php
214
+ - Customer#Review.php
215
+ - Customer#Wishlist.php
216
+ - Email#Template.php
217
+ - Newsletter#Observer.php
218
+ - Newsletter#Sub.php
219
+ - Newsletter#Subscriber.php
220
+ - Resource#Campaign#Collection.php
221
+ - Resource#Config#Collection.php
222
+ - Resource#Contact#Collection.php
223
+ - Resource#Order#Collection.php
224
+ - Resource#Review#Collection.php
225
+ - Resource#Wishlist#Collection.php
226
+ - Resource#Campaign.php
227
+ - Resource#Config.php
228
+ - Resource#Contact.php
229
+ - Resource#Order.php
230
+ - Resource#Review.php
231
+ - Resource#Setup.php
232
+ - Resource#Wishlist.php
233
+ - Sales#Observer.php
234
+ - Sales#Order.php
235
+ - Sales#Quote.php
236
+ - Sms#Campaign.php
237
+ - Sweettooth#Observer.php
238
+ - Campaign.php
239
+ - Config.php
240
+ - Contact.php
241
+ - Cron.php
242
+ - Customer.php
243
+ - Feed.php
244
+ - Order.php
245
+ - Review.php
246
+ - Wishlist.php
247
+ design:
248
+ - adminhtml#default#default#layout#connector#email.xml
249
+ - adminhtml#default#default#template#connector#dashboard#tabs#analysis#index.phtml
250
+ - adminhtml#default#default#template#connector#dashboard#tabs#analysis#rfm.phtml
251
+ - adminhtml#default#default#template#connector#dashboard#tabs#general#index.phtml
252
+ - adminhtml#default#default#template#connector#dashboard#tabs#config.phtml
253
+ - adminhtml#default#default#template#connector#dashboard#tabs#data.phtml
254
+ - adminhtml#default#default#template#connector#dashboard#accountbar.phtml
255
+ - adminhtml#default#default#template#connector#dashboard#content.phtml
256
+ - adminhtml#default#default#template#connector#dashboard#status.phtml
257
+ - adminhtml#default#default#template#connector#dashboard#tabs.phtml
258
+ - adminhtml#default#default#template#connector#system#config#createdatafield.phtml
259
+ - adminhtml#default#default#template#connector#grid.phtml
260
+ - frontend#base#default#layout#connector.xml
261
+ - frontend#base#default#layout#mailcheck.xml
262
+ - frontend#base#default#template#connector#creditmemo#items.phtml
263
+ - frontend#base#default#template#connector#creditmemo#new.phtml
264
+ - frontend#base#default#template#connector#creditmemo#newguest.phtml
265
+ - frontend#base#default#template#connector#creditmemo#update.phtml
266
+ - frontend#base#default#template#connector#creditmemo#updateguest.phtml
267
+ - frontend#base#default#template#connector#invoice#new.phtml
268
+ - frontend#base#default#template#connector#invoice#newguest.phtml
269
+ - frontend#base#default#template#connector#invoice#update.phtml
270
+ - frontend#base#default#template#connector#invoice#updateguest.phtml
271
+ - frontend#base#default#template#connector#order#items.phtml
272
+ - frontend#base#default#template#connector#order#new.phtml
273
+ - frontend#base#default#template#connector#order#newguest.phtml
274
+ - frontend#base#default#template#connector#order#update.phtml
275
+ - frontend#base#default#template#connector#order#updateguest.phtml
276
+ - frontend#base#default#template#connector#product#list.phtml
277
+ - frontend#base#default#template#connector#product#nosto.phtml
278
+ - frontend#base#default#template#connector#product#price.phtml
279
+ - frontend#base#default#template#connector#shipping#new.phtml
280
+ - frontend#base#default#template#connector#shipping#newguest.phtml
281
+ - frontend#base#default#template#connector#shipping#update.phtml
282
+ - frontend#base#default#template#connector#shipping#updateguest.phtml
283
+ - frontend#base#default#template#connector#basket.phtml
284
+ - frontend#base#default#template#connector#coupon.phtml
285
+ - frontend#base#default#template#connector#email_capture.phtml
286
+ - frontend#base#default#template#connector#email_capture_init.phtml
287
+ - frontend#base#default#template#connector#review.phtml
288
+ - frontend#base#default#template#connector#roi_code.phtml
289
+ - frontend#base#default#template#connector#tracking_code.phtml
290
+ - frontend#base#default#template#mailcheck#scripts.phtml
291
+ - frontend#base#default#template#page#blank.phtml
292
+ skin:
293
+ - adminhtml#default#default#connector#dashboard.css
294
+ - frontend#base#default#js#mailcheck#init.js
295
+ shell:
296
+ - connector.php
297
+ lib:
298
+ - Raygun4php#RaygunClient.php
299
+ js:
300
+ - connector#selector.js
301
+ - mailcheck#magentoMailcheck.js
302
+ - mailcheck#mailcheck.min.js
app/code/community/Dotdigitalgroup/Email/etc/system.xml ADDED
@@ -0,0 +1,2550 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 module="connector">
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 comment" 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
+ <frontend_model>email_connector/adminhtml_system_config_resetcontacts</frontend_model>
124
+ <source_model>email_connector/adminhtml_source_addressbooks</source_model>
125
+ <sort_order>10</sort_order>
126
+ <show_in_default>1</show_in_default>
127
+ <show_in_website>1</show_in_website>
128
+ <show_in_store>0</show_in_store>
129
+ </customers>
130
+ <subscribers translate="label" module="connector">
131
+ <label>Add Subscribers To</label>
132
+ <frontend_type>select</frontend_type>
133
+ <frontend_model>email_connector/adminhtml_system_config_resetsubscribers</frontend_model>
134
+ <source_model>email_connector/adminhtml_source_addressbooks</source_model>
135
+ <sort_order>20</sort_order>
136
+ <show_in_default>1</show_in_default>
137
+ <show_in_website>1</show_in_website>
138
+ <show_in_store>0</show_in_store>
139
+ </subscribers>
140
+ <guests translate="label" module="connector">
141
+ <label>Add Guests To</label>
142
+ <frontend_type>select</frontend_type>
143
+ <frontend_model>email_connector/adminhtml_system_config_resetguests</frontend_model>
144
+ <source_model>email_connector/adminhtml_source_addressbooks</source_model>
145
+ <sort_order>30</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
+ </guests>
150
+ </fields>
151
+ </address_book>
152
+ <sync translate="label" module="connector">
153
+ <label>Sync</label>
154
+ <frontend_type>text</frontend_type>
155
+ <sort_order>20</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
+ <expanded>1</expanded>
160
+ <fields>
161
+ <contact_title translate="label" module="connector">
162
+ <label>Contact Sync</label>
163
+ <frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
164
+ <sort_order>10</sort_order>
165
+ <show_in_default>1</show_in_default>
166
+ <show_in_website>1</show_in_website>
167
+ <show_in_store>0</show_in_store>
168
+ </contact_title>
169
+ <contact_enabled translate="label" module="connector">
170
+ <label>Enabled</label>
171
+ <frontend_type>select</frontend_type>
172
+ <source_model>adminhtml/system_config_source_yesno</source_model>
173
+ <sort_order>20</sort_order>
174
+ <show_in_default>1</show_in_default>
175
+ <show_in_website>1</show_in_website>
176
+ <show_in_store>0</show_in_store>
177
+ </contact_enabled>
178
+ <subscriber_title translate="label" module="connector">
179
+ <label>Subscriber Sync</label>
180
+ <frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
181
+ <sort_order>50</sort_order>
182
+ <show_in_default>1</show_in_default>
183
+ <show_in_website>1</show_in_website>
184
+ <show_in_store>0</show_in_store>
185
+ </subscriber_title>
186
+ <subscriber_enabled translate="label" module="connector">
187
+ <label>Enabled</label>
188
+ <frontend_type>select</frontend_type>
189
+ <source_model>adminhtml/system_config_source_yesno</source_model>
190
+ <sort_order>60</sort_order>
191
+ <show_in_default>1</show_in_default>
192
+ <show_in_website>1</show_in_website>
193
+ <show_in_store>0</show_in_store>
194
+ </subscriber_enabled>
195
+ <order_title translate="label" module="connector">
196
+ <label>Order Sync</label>
197
+ <frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
198
+ <sort_order>70</sort_order>
199
+ <show_in_default>1</show_in_default>
200
+ <show_in_website>1</show_in_website>
201
+ <show_in_store>0</show_in_store>
202
+ </order_title>
203
+ <order_enabled translate="label" module="connector">
204
+ <label>Enabled</label>
205
+ <frontend_type>select</frontend_type>
206
+ <source_model>adminhtml/system_config_source_yesno</source_model>
207
+ <sort_order>80</sort_order>
208
+ <show_in_default>1</show_in_default>
209
+ <show_in_website>1</show_in_website>
210
+ <show_in_store>0</show_in_store>
211
+ </order_enabled>
212
+ <wishlist_title translate="label" module="connector">
213
+ <label>Wishlist Sync</label>
214
+ <frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
215
+ <sort_order>90</sort_order>
216
+ <show_in_default>1</show_in_default>
217
+ <show_in_website>1</show_in_website>
218
+ <show_in_store>0</show_in_store>
219
+ </wishlist_title>
220
+ <wishlist_enabled translate="label" module="connector">
221
+ <label>Enabled</label>
222
+ <frontend_type>select</frontend_type>
223
+ <source_model>adminhtml/system_config_source_yesno</source_model>
224
+ <sort_order>100</sort_order>
225
+ <show_in_default>1</show_in_default>
226
+ <show_in_website>1</show_in_website>
227
+ <show_in_store>0</show_in_store>
228
+ </wishlist_enabled>
229
+ <review_title translate="label" module="connector">
230
+ <label>Review Sync</label>
231
+ <frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
232
+ <sort_order>103</sort_order>
233
+ <show_in_default>1</show_in_default>
234
+ <show_in_website>1</show_in_website>
235
+ <show_in_store>0</show_in_store>
236
+ </review_title>
237
+ <review_enabled translate="label" module="connector">
238
+ <label>Enabled</label>
239
+ <frontend_type>select</frontend_type>
240
+ <source_model>adminhtml/system_config_source_yesno</source_model>
241
+ <sort_order>106</sort_order>
242
+ <show_in_default>1</show_in_default>
243
+ <show_in_website>1</show_in_website>
244
+ <show_in_store>0</show_in_store>
245
+ </review_enabled>
246
+ <validator>
247
+ <frontend_type>hidden</frontend_type>
248
+ <frontend_model>email_connector/adminhtml_system_config_waitingfield</frontend_model>
249
+ <sort_order>110</sort_order>
250
+ <show_in_default>1</show_in_default>
251
+ <show_in_website>1</show_in_website>
252
+ <show_in_store>0</show_in_store>
253
+ <can_be_empty>1</can_be_empty>
254
+ </validator>
255
+ </fields>
256
+ </sync>
257
+ <dynamic_addressbook translate="label" module="connector">
258
+ <label>Create Address Book</label>
259
+ <sort_order>30</sort_order>
260
+ <show_in_default>1</show_in_default>
261
+ <show_in_website>1</show_in_website>
262
+ <show_in_store>0</show_in_store>
263
+ <fields>
264
+ <addressbook_name translate="label" module="connector">
265
+ <label>Address Book Name</label>
266
+ <frontend_type>text</frontend_type>
267
+ <frontend_model>email_connector/adminhtml_system_config_addressbook</frontend_model>
268
+ <sort_order>10</sort_order>
269
+ <show_in_default>1</show_in_default>
270
+ <show_in_website>1</show_in_website>
271
+ <show_in_store>0</show_in_store>
272
+ </addressbook_name>
273
+ <visibility translate="label comment">
274
+ <label>Visibility</label>
275
+ <frontend_type>select</frontend_type>
276
+ <source_model>email_connector/adminhtml_source_datamapping_datafieldaccess</source_model>
277
+ <sort_order>20</sort_order>
278
+ <show_in_default>1</show_in_default>
279
+ <show_in_website>1</show_in_website>
280
+ <show_in_store>0</show_in_store>
281
+ <comment>Select if a contact can join/unsubscribe from the address book via the unsubscribe page</comment>
282
+ </visibility>
283
+ <addresbook_button translate="label button_label" module="connector">
284
+ <label />
285
+ <button_label>Create New Address Book</button_label>
286
+ <frontend_model>email_connector/adminhtml_system_dynamic_addressbookbutton</frontend_model>
287
+ <sort_order>30</sort_order>
288
+ <show_in_default>1</show_in_default>
289
+ <show_in_website>1</show_in_website>
290
+ <show_in_store>0</show_in_store>
291
+ </addresbook_button>
292
+ </fields>
293
+ </dynamic_addressbook>
294
+ </groups>
295
+ </connector_sync_settings>
296
+ <connector_data_mapping translate="label" module="connector">
297
+ <label><![CDATA[Data Mapping]]></label>
298
+ <tab>connector</tab>
299
+ <frontend_type>text</frontend_type>
300
+ <sort_order>2000</sort_order>
301
+ <show_in_default>1</show_in_default>
302
+ <show_in_website>1</show_in_website>
303
+ <show_in_store>0</show_in_store>
304
+ <groups>
305
+ <customer_data translate="label" module="connector">
306
+ <label>Data Fields Mapping</label>
307
+ <frontend_type>text</frontend_type>
308
+ <sort_order>20</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
+ <expanded>1</expanded>
313
+ <comment><![CDATA[<p class="notice">AUTOMAP AVAILABLE IN DEVELOPER SECTION TO MAP ALL DATAFIELDS.</p>]]></comment>
314
+ <fields>
315
+ <customer_title translate="label" module="connector">
316
+ <label>Customer Information</label>
317
+ <frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
318
+ <sort_order>10</sort_order>
319
+ <show_in_default>1</show_in_default>
320
+ <show_in_website>1</show_in_website>
321
+ <show_in_store>0</show_in_store>
322
+ </customer_title>
323
+ <title translate="label" module="connector">
324
+ <label>Title</label>
325
+ <frontend_type>select</frontend_type>
326
+ <source_model>email_connector/adminhtml_source_datafields</source_model>
327
+ <sort_order>20</sort_order>
328
+ <show_in_default>1</show_in_default>
329
+ <show_in_website>1</show_in_website>
330
+ <show_in_store>0</show_in_store>
331
+ </title>
332
+ <customer_id translate="label" module="connector">
333
+ <label>Customer ID</label>
334
+ <frontend_type>select</frontend_type>
335
+ <source_model>email_connector/adminhtml_source_datafields</source_model>
336
+ <sort_order>30</sort_order>
337
+ <show_in_default>1</show_in_default>
338
+ <show_in_website>1</show_in_website>
339
+ <show_in_store>0</show_in_store>
340
+ </customer_id>
341
+ <firstname translate="label" module="connector">
342
+ <label>First Name</label>
343
+ <frontend_type>select</frontend_type>
344
+ <source_model>email_connector/adminhtml_source_datafields</source_model>
345
+ <sort_order>40</sort_order>
346
+ <show_in_default>1</show_in_default>
347
+ <show_in_website>1</show_in_website>
348
+ <show_in_store>0</show_in_store>
349
+ </firstname>
350
+ <lastname translate="label" module="connector">
351
+ <label>Last Name</label>
352
+ <frontend_type>select</frontend_type>
353
+ <source_model>email_connector/adminhtml_source_datafields</source_model>
354
+ <sort_order>50</sort_order>
355
+ <show_in_default>1</show_in_default>
356
+ <show_in_website>1</show_in_website>
357
+ <show_in_store>0</show_in_store>
358
+ </lastname>
359
+ <dob translate="label" module="connector">
360
+ <label>D.O.B.</label>
361
+ <frontend_type>select</frontend_type>
362
+ <source_model>email_connector/adminhtml_source_datafields</source_model>
363
+ <sort_order>60</sort_order>
364
+ <show_in_default>1</show_in_default>
365
+ <show_in_website>1</show_in_website>
366
+ <show_in_store>0</show_in_store>
367
+ </dob>
368
+ <gender translate="label" module="connector">
369
+ <label>Gender</label>
370
+ <frontend_type>select</frontend_type>
371
+ <source_model>email_connector/adminhtml_source_datafields</source_model>
372
+ <sort_order>70</sort_order>
373
+ <show_in_default>1</show_in_default>
374
+ <show_in_website>1</show_in_website>
375
+ <show_in_store>0</show_in_store>
376
+ </gender>
377
+ <website_name translate="label" module="connector">
378
+ <label>Website Created On</label>
379
+ <frontend_type>select</frontend_type>
380
+ <source_model>email_connector/adminhtml_source_datafields</source_model>
381
+ <sort_order>80</sort_order>
382
+ <show_in_default>1</show_in_default>
383
+ <show_in_website>1</show_in_website>
384
+ <show_in_store>0</show_in_store>
385
+ </website_name>
386
+ <store_name translate="label" module="connector">
387
+ <label>Store Created On</label>
388
+ <frontend_type>select</frontend_type>
389
+ <source_model>email_connector/adminhtml_source_datafields</source_model>
390
+ <sort_order>90</sort_order>
391
+ <show_in_default>1</show_in_default>
392
+ <show_in_website>1</show_in_website>
393
+ <show_in_store>0</show_in_store>
394
+ </store_name>
395
+ <created_at translate="label" module="connector">
396
+ <label>Account Created Date</label>
397
+ <frontend_type>select</frontend_type>
398
+ <source_model>email_connector/adminhtml_source_datafields</source_model>
399
+ <sort_order>100</sort_order>
400
+ <show_in_default>1</show_in_default>
401
+ <show_in_website>1</show_in_website>
402
+ <show_in_store>0</show_in_store>
403
+ </created_at>
404
+ <last_logged_date translate="label" module="connector">
405
+ <label>Last Logged In Date</label>
406
+ <frontend_type>select</frontend_type>
407
+ <source_model>email_connector/adminhtml_source_datafields</source_model>
408
+ <sort_order>110</sort_order>
409
+ <show_in_default>1</show_in_default>
410
+ <show_in_website>1</show_in_website>
411
+ <show_in_store>0</show_in_store>
412
+ </last_logged_date>
413
+ <customer_group translate="label" module="connector">
414
+ <label>Customer Group</label>
415
+ <frontend_type>select</frontend_type>
416
+ <source_model>email_connector/adminhtml_source_datafields</source_model>
417
+ <sort_order>120</sort_order>
418
+ <show_in_default>1</show_in_default>
419
+ <show_in_website>1</show_in_website>
420
+ <show_in_store>0</show_in_store>
421
+ </customer_group>
422
+ <review_count translate="label" module="connector">
423
+ <label>Customer Review Count</label>
424
+ <frontend_type>select</frontend_type>
425
+ <source_model>email_connector/adminhtml_source_datafields</source_model>
426
+ <sort_order>121</sort_order>
427
+ <show_in_default>1</show_in_default>
428
+ <show_in_website>1</show_in_website>
429
+ <show_in_store>0</show_in_store>
430
+ </review_count>
431
+ <last_review_date translate="label" module="connector">
432
+ <label>Last Review Date</label>
433
+ <frontend_type>select</frontend_type>
434
+ <source_model>email_connector/adminhtml_source_datafields</source_model>
435
+ <sort_order>122</sort_order>
436
+ <show_in_default>1</show_in_default>
437
+ <show_in_website>1</show_in_website>
438
+ <show_in_store>0</show_in_store>
439
+ </last_review_date>
440
+ <subscriber_status translate="label" module="connector">
441
+ <label>Subscriber Status</label>
442
+ <frontend_type>select</frontend_type>
443
+ <source_model>email_connector/adminhtml_source_datafields</source_model>
444
+ <sort_order>123</sort_order>
445
+ <show_in_default>1</show_in_default>
446
+ <show_in_website>1</show_in_website>
447
+ <show_in_store>0</show_in_store>
448
+ </subscriber_status>
449
+ <address_title translate="label" module="connector">
450
+ <label>Address</label>
451
+ <frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
452
+ <sort_order>130</sort_order>
453
+ <show_in_default>1</show_in_default>
454
+ <show_in_website>1</show_in_website>
455
+ <show_in_store>0</show_in_store>
456
+ </address_title>
457
+ <billing_address_1 translate="label" module="connector">
458
+ <label>Billing Address Line 1</label>
459
+ <frontend_type>select</frontend_type>
460
+ <source_model>email_connector/adminhtml_source_datafields</source_model>
461
+ <sort_order>140</sort_order>
462
+ <show_in_default>1</show_in_default>
463
+ <show_in_website>1</show_in_website>
464
+ <show_in_store>0</show_in_store>
465
+ </billing_address_1>
466
+ <billing_address_2 translate="label" module="connector">
467
+ <label>Billing Address Line 2</label>
468
+ <frontend_type>select</frontend_type>
469
+ <source_model>email_connector/adminhtml_source_datafields</source_model>
470
+ <sort_order>150</sort_order>
471
+ <show_in_default>1</show_in_default>
472
+ <show_in_website>1</show_in_website>
473
+ <show_in_store>0</show_in_store>
474
+ </billing_address_2>
475
+ <billing_city translate="label" module="connector">
476
+ <label>Billing City</label>
477
+ <frontend_type>select</frontend_type>
478
+ <source_model>email_connector/adminhtml_source_datafields</source_model>
479
+ <sort_order>160</sort_order>
480
+ <show_in_default>1</show_in_default>
481
+ <show_in_website>1</show_in_website>
482
+ <show_in_store>0</show_in_store>
483
+ </billing_city>
484
+ <billing_state translate="label" module="connector">
485
+ <label>Billing State/Region</label>
486
+ <frontend_type>select</frontend_type>
487
+ <source_model>email_connector/adminhtml_source_datafields</source_model>
488
+ <sort_order>155</sort_order>
489
+ <show_in_default>1</show_in_default>
490
+ <show_in_website>1</show_in_website>
491
+ <show_in_store>0</show_in_store>
492
+ </billing_state>
493
+ <billing_country translate="label" module="connector">
494
+ <label>Billing Country</label>
495
+ <frontend_type>select</frontend_type>
496
+ <source_model>email_connector/adminhtml_source_datafields</source_model>
497
+ <sort_order>170</sort_order>
498
+ <show_in_default>1</show_in_default>
499
+ <show_in_website>1</show_in_website>
500
+ <show_in_store>0</show_in_store>
501
+ </billing_country>
502
+ <billing_postcode translate="label" module="connector">
503
+ <label>Billing Zip/Postcode</label>
504
+ <frontend_type>select</frontend_type>
505
+ <source_model>email_connector/adminhtml_source_datafields</source_model>
506
+ <sort_order>180</sort_order>
507
+ <show_in_default>1</show_in_default>
508
+ <show_in_website>1</show_in_website>
509
+ <show_in_store>0</show_in_store>
510
+ </billing_postcode>
511
+ <billing_telephone translate="label" module="connector">
512
+ <label>Billing Telephone</label>
513
+ <frontend_type>select</frontend_type>
514
+ <source_model>email_connector/adminhtml_source_datafields</source_model>
515
+ <sort_order>190</sort_order>
516
+ <show_in_default>1</show_in_default>
517
+ <show_in_website>1</show_in_website>
518
+ <show_in_store>0</show_in_store>
519
+ </billing_telephone>
520
+ <delivery_address_1 translate="label" module="connector">
521
+ <label>Delivery Address Line 1</label>
522
+ <frontend_type>select</frontend_type>
523
+ <source_model>email_connector/adminhtml_source_datafields</source_model>
524
+ <sort_order>200</sort_order>
525
+ <show_in_default>1</show_in_default>
526
+ <show_in_website>1</show_in_website>
527
+ <show_in_store>0</show_in_store>
528
+ </delivery_address_1>
529
+ <delivery_address_2 translate="label" module="connector">
530
+ <label>Delivery Address Line 2</label>
531
+ <frontend_type>select</frontend_type>
532
+ <source_model>email_connector/adminhtml_source_datafields</source_model>
533
+ <sort_order>210</sort_order>
534
+ <show_in_default>1</show_in_default>
535
+ <show_in_website>1</show_in_website>
536
+ <show_in_store>0</show_in_store>
537
+ </delivery_address_2>
538
+ <delivery_city translate="label" module="connector">
539
+ <label>Delivery City</label>
540
+ <frontend_type>select</frontend_type>
541
+ <source_model>email_connector/adminhtml_source_datafields</source_model>
542
+ <sort_order>220</sort_order>
543
+ <show_in_default>1</show_in_default>
544
+ <show_in_website>1</show_in_website>
545
+ <show_in_store>0</show_in_store>
546
+ </delivery_city>
547
+ <delivery_state translate="label" module="connector">
548
+ <label>Delivery State/Region</label>
549
+ <frontend_type>select</frontend_type>
550
+ <source_model>email_connector/adminhtml_source_datafields</source_model>
551
+ <sort_order>215</sort_order>
552
+ <show_in_default>1</show_in_default>
553
+ <show_in_website>1</show_in_website>
554
+ <show_in_store>0</show_in_store>
555
+ </delivery_state>
556
+ <delivery_country translate="label" module="connector">
557
+ <label>Delivery Country</label>
558
+ <frontend_type>select</frontend_type>
559
+ <source_model>email_connector/adminhtml_source_datafields</source_model>
560
+ <sort_order>230</sort_order>
561
+ <show_in_default>1</show_in_default>
562
+ <show_in_website>1</show_in_website>
563
+ <show_in_store>0</show_in_store>
564
+ </delivery_country>
565
+ <delivery_postcode translate="label" module="connector">
566
+ <label>Delivery Zip/Postcode</label>
567
+ <frontend_type>select</frontend_type>
568
+ <source_model>email_connector/adminhtml_source_datafields</source_model>
569
+ <sort_order>240</sort_order>
570
+ <show_in_default>1</show_in_default>
571
+ <show_in_website>1</show_in_website>
572
+ <show_in_store>0</show_in_store>
573
+ </delivery_postcode>
574
+ <delivery_telephone translate="label" module="connector">
575
+ <label>Delivery Telephone</label>
576
+ <frontend_type>select</frontend_type>
577
+ <source_model>email_connector/adminhtml_source_datafields</source_model>
578
+ <sort_order>250</sort_order>
579
+ <show_in_default>1</show_in_default>
580
+ <show_in_website>1</show_in_website>
581
+ <show_in_store>0</show_in_store>
582
+ </delivery_telephone>
583
+ <sales_title translate="label" module="connector">
584
+ <label>Sales</label>
585
+ <frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
586
+ <sort_order>260</sort_order>
587
+ <show_in_default>1</show_in_default>
588
+ <show_in_website>1</show_in_website>
589
+ <show_in_store>0</show_in_store>
590
+ </sales_title>
591
+ <number_of_orders translate="label" module="connector">
592
+ <label>Total Number of Orders</label>
593
+ <frontend_type>select</frontend_type>
594
+ <source_model>email_connector/adminhtml_source_datafields</source_model>
595
+ <sort_order>270</sort_order>
596
+ <show_in_default>1</show_in_default>
597
+ <show_in_website>1</show_in_website>
598
+ <show_in_store>0</show_in_store>
599
+ </number_of_orders>
600
+ <average_order_value translate="label" module="connector">
601
+ <label>Average Order Value</label>
602
+ <frontend_type>select</frontend_type>
603
+ <source_model>email_connector/adminhtml_source_datafields</source_model>
604
+ <sort_order>280</sort_order>
605
+ <show_in_default>1</show_in_default>
606
+ <show_in_website>1</show_in_website>
607
+ <show_in_store>0</show_in_store>
608
+ </average_order_value>
609
+ <total_spend translate="label" module="connector">
610
+ <label>Total Spend</label>
611
+ <frontend_type>select</frontend_type>
612
+ <source_model>email_connector/adminhtml_source_datafields</source_model>
613
+ <sort_order>290</sort_order>
614
+ <show_in_default>1</show_in_default>
615
+ <show_in_website>1</show_in_website>
616
+ <show_in_store>0</show_in_store>
617
+ </total_spend>
618
+ <last_order_date translate="label" module="connector">
619
+ <label>Last Purchase Date</label>
620
+ <frontend_type>select</frontend_type>
621
+ <source_model>email_connector/adminhtml_source_datafields</source_model>
622
+ <sort_order>300</sort_order>
623
+ <show_in_default>1</show_in_default>
624
+ <show_in_website>1</show_in_website>
625
+ <show_in_store>0</show_in_store>
626
+ </last_order_date>
627
+ <last_order_id translate="label" module="connector">
628
+ <label>Last Order ID</label>
629
+ <frontend_type>select</frontend_type>
630
+ <source_model>email_connector/adminhtml_source_datafields</source_model>
631
+ <sort_order>310</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
+ </last_order_id>
636
+ <last_quote_id translate="label" module="connector">
637
+ <label>Last Quote ID</label>
638
+ <frontend_type>select</frontend_type>
639
+ <source_model>email_connector/adminhtml_source_datafields</source_model>
640
+ <sort_order>315</sort_order>
641
+ <show_in_default>1</show_in_default>
642
+ <show_in_website>1</show_in_website>
643
+ <show_in_store>0</show_in_store>
644
+ </last_quote_id>
645
+ <total_refund translate="label">
646
+ <label>Total Refund</label>
647
+ <frontend_type>select</frontend_type>
648
+ <source_model>email_connector/adminhtml_source_datafields</source_model>
649
+ <show_in_default>1</show_in_default>
650
+ <show_in_website>1</show_in_website>
651
+ <show_in_store>0</show_in_store>
652
+ <sort_order>320</sort_order>
653
+ </total_refund>
654
+ <custom_title translate="label" module="connector">
655
+ <label>Custom Attributes</label>
656
+ <frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
657
+ <sort_order>330</sort_order>
658
+ <show_in_default>1</show_in_default>
659
+ <show_in_website>1</show_in_website>
660
+ <show_in_store>0</show_in_store>
661
+ </custom_title>
662
+ <custom_attributes translate="label" module="connector">
663
+ <label>Customer</label>
664
+ <frontend_model>email_connector/adminhtml_config_customdatafields</frontend_model>
665
+ <backend_model>adminhtml/system_config_backend_serialized_array</backend_model>
666
+ <source_model>email_connector/adminhtml_source_customer_attributes_select</source_model>
667
+ <sort_order>340</sort_order>
668
+ <show_in_default>1</show_in_default>
669
+ <show_in_website>1</show_in_website>
670
+ <show_in_store>0</show_in_store>
671
+ </custom_attributes>
672
+ <validator translate="label" module="connector">
673
+ <label>Validation Block</label>
674
+ <frontend_type>select</frontend_type>
675
+ <source_model>email_connector/adminhtml_source_datafields</source_model>
676
+ <frontend_model>email_connector/adminhtml_system_config_validator</frontend_model>
677
+ <sort_order>920</sort_order>
678
+ <show_in_default>1</show_in_default>
679
+ <show_in_website>1</show_in_website>
680
+ <show_in_store>0</show_in_store>
681
+ <can_be_empty>1</can_be_empty>
682
+ <expanded>1</expanded>
683
+ </validator>
684
+ </fields>
685
+ </customer_data>
686
+ <dynamic_datafield translate="label" module="connector">
687
+ <label>Create Data Field</label>
688
+ <sort_order>30</sort_order>
689
+ <show_in_default>1</show_in_default>
690
+ <show_in_website>1</show_in_website>
691
+ <show_in_store>0</show_in_store>
692
+ <fields>
693
+ <datafield_name translate="label comment" module="connector">
694
+ <label>Data Field Name</label>
695
+ <frontend_type>text</frontend_type>
696
+ <frontend_model>email_connector/adminhtml_system_config_datafield</frontend_model>
697
+ <sort_order>10</sort_order>
698
+ <show_in_default>1</show_in_default>
699
+ <show_in_website>1</show_in_website>
700
+ <show_in_store>0</show_in_store>
701
+ <comment>(Maximum of 20 characters)</comment>
702
+ </datafield_name>
703
+ <datafield_type translate="label" module="connector">
704
+ <label>Data Field Type</label>
705
+ <frontend_type>select</frontend_type>
706
+ <source_model>email_connector/adminhtml_source_datamapping_datafieldtype</source_model>
707
+ <sort_order>20</sort_order>
708
+ <show_in_default>1</show_in_default>
709
+ <show_in_website>1</show_in_website>
710
+ <show_in_store>0</show_in_store>
711
+ <expended>1</expended>
712
+ </datafield_type>
713
+ <datafield_default translate="label comment" module="connector">
714
+ <label>Default Value</label>
715
+ <frontend_type>text</frontend_type>
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
+ <comment>When sending a campaign that uses template personalisation, a default value ensures that a value is alwasy displayed even if a data field is blank.</comment>
721
+ </datafield_default>
722
+ <datafield_access translate="label comment" module="connector">
723
+ <label>Visibility</label>
724
+ <frontend_type>select</frontend_type>
725
+ <source_model>email_connector/adminhtml_source_datamapping_datafieldaccess</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
+ <comment>Make the field public if you want to allow your contacts to view and amend the data you hold on them in this field.</comment>
731
+ </datafield_access>
732
+ <datafield_button translate="label button_label" module="connector">
733
+ <label />
734
+ <button_label>Create New Data Field</button_label>
735
+ <frontend_model>email_connector/adminhtml_system_dynamic_datafieldbutton</frontend_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
+ </datafield_button>
741
+ </fields>
742
+ </dynamic_datafield>
743
+ <sweet_tooth>
744
+ <label>Sweet Tooth Rewards</label>
745
+ <sort_order>40</sort_order>
746
+ <show_in_default>1</show_in_default>
747
+ <show_in_website>1</show_in_website>
748
+ <show_in_store>0</show_in_store>
749
+ <fields>
750
+ <active translate="label comment" module="connector">
751
+ <label>Enabled</label>
752
+ <frontend_type>select</frontend_type>
753
+ <source_model>email_connector/adminhtml_source_sweettooth_yesno</source_model>
754
+ <sort_order>0</sort_order>
755
+ <show_in_default>1</show_in_default>
756
+ <show_in_website>1</show_in_website>
757
+ <show_in_store>0</show_in_store>
758
+ <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>
759
+ </active>
760
+ <title translate="label" module="connector">
761
+ <label>Data Fields Mapping</label>
762
+ <frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
763
+ <sort_order>10</sort_order>
764
+ <show_in_default>1</show_in_default>
765
+ <show_in_website>1</show_in_website>
766
+ <show_in_store>0</show_in_store>
767
+ <depends><active>1</active></depends>
768
+ </title>
769
+ <reward_point_balance translate="label" module="connector">
770
+ <label>Current Point Balance</label>
771
+ <frontend_type>select</frontend_type>
772
+ <source_model>email_connector/adminhtml_source_datafields</source_model>
773
+ <sort_order>20</sort_order>
774
+ <show_in_default>1</show_in_default>
775
+ <show_in_website>1</show_in_website>
776
+ <show_in_store>0</show_in_store>
777
+ <depends><active>1</active></depends>
778
+ </reward_point_balance>
779
+ <reward_point_pending translate="label" module="connector">
780
+ <label>Points Pending An Event</label>
781
+ <frontend_type>select</frontend_type>
782
+ <source_model>email_connector/adminhtml_source_datafields</source_model>
783
+ <sort_order>30</sort_order>
784
+ <show_in_default>1</show_in_default>
785
+ <show_in_website>1</show_in_website>
786
+ <show_in_store>0</show_in_store>
787
+ <depends><active>1</active></depends>
788
+ </reward_point_pending>
789
+ <reward_point_pending_time translate="label" module="connector">
790
+ <label>Points Pending A Date</label>
791
+ <frontend_type>select</frontend_type>
792
+ <source_model>email_connector/adminhtml_source_datafields</source_model>
793
+ <sort_order>40</sort_order>
794
+ <show_in_default>1</show_in_default>
795
+ <show_in_website>1</show_in_website>
796
+ <show_in_store>0</show_in_store>
797
+ <depends><active>1</active></depends>
798
+ </reward_point_pending_time>
799
+ <reward_point_on_hold translate="label" module="connector">
800
+ <label>Current On Hold Points</label>
801
+ <frontend_type>select</frontend_type>
802
+ <source_model>email_connector/adminhtml_source_datafields</source_model>
803
+ <sort_order>50</sort_order>
804
+ <show_in_default>1</show_in_default>
805
+ <show_in_website>1</show_in_website>
806
+ <show_in_store>0</show_in_store>
807
+ <depends><active>1</active></depends>
808
+ </reward_point_on_hold>
809
+ <reward_point_expiration translate="label" module="connector">
810
+ <label>Points Expiry Date</label>
811
+ <frontend_type>select</frontend_type>
812
+ <source_model>email_connector/adminhtml_source_datafields</source_model>
813
+ <sort_order>60</sort_order>
814
+ <show_in_default>1</show_in_default>
815
+ <show_in_website>1</show_in_website>
816
+ <show_in_store>0</show_in_store>
817
+ <depends><active>1</active></depends>
818
+ </reward_point_expiration>
819
+ <reward_point_last_earn translate="label" module="connector">
820
+ <label>Last Date Points Earned</label>
821
+ <frontend_type>select</frontend_type>
822
+ <source_model>email_connector/adminhtml_source_datafields</source_model>
823
+ <sort_order>70</sort_order>
824
+ <show_in_default>1</show_in_default>
825
+ <show_in_website>1</show_in_website>
826
+ <show_in_store>0</show_in_store>
827
+ <depends><active>1</active></depends>
828
+ </reward_point_last_earn>
829
+ <reward_point_last_spent translate="label" module="connector">
830
+ <label>Last Date Points Spent</label>
831
+ <frontend_type>select</frontend_type>
832
+ <source_model>email_connector/adminhtml_source_datafields</source_model>
833
+ <sort_order>70</sort_order>
834
+ <show_in_default>1</show_in_default>
835
+ <show_in_website>1</show_in_website>
836
+ <show_in_store>0</show_in_store>
837
+ <depends><active>1</active></depends>
838
+ </reward_point_last_spent>
839
+ </fields>
840
+ </sweet_tooth>
841
+ </groups>
842
+ </connector_data_mapping>
843
+ <connector_roi_tracking translate="label" module="connector">
844
+ <label><![CDATA[ROI & Tracking]]></label>
845
+ <tab>connector</tab>
846
+ <frontend_type>text</frontend_type>
847
+ <sort_order>5000</sort_order>
848
+ <show_in_default>1</show_in_default>
849
+ <show_in_website>1</show_in_website>
850
+ <show_in_store>0</show_in_store>
851
+ <groups>
852
+ <page_tracking translate="label" module="connector">
853
+ <label>Page Tracking</label>
854
+ <frontend_type>text</frontend_type>
855
+ <sort_order>10</sort_order>
856
+ <show_in_default>1</show_in_default>
857
+ <show_in_website>1</show_in_website>
858
+ <show_in_store>0</show_in_store>
859
+ <expanded>1</expanded>
860
+ <fields>
861
+ <enabled translate="label" module="connector">
862
+ <label>Enabled</label>
863
+ <frontend_type>select</frontend_type>
864
+ <source_model>adminhtml/system_config_source_yesno</source_model>
865
+ <sort_order>10</sort_order>
866
+ <show_in_default>1</show_in_default>
867
+ <show_in_website>1</show_in_website>
868
+ <show_in_store>0</show_in_store>
869
+ </enabled>
870
+ </fields>
871
+ </page_tracking>
872
+ <roi_tracking translate="label" module="connector">
873
+ <label>ROI Tracking</label>
874
+ <frontend_type>text</frontend_type>
875
+ <sort_order>20</sort_order>
876
+ <show_in_default>1</show_in_default>
877
+ <show_in_website>1</show_in_website>
878
+ <show_in_store>0</show_in_store>
879
+ <expanded>1</expanded>
880
+ <fields>
881
+ <enabled translate="label" module="connector">
882
+ <label>Enabled</label>
883
+ <frontend_type>select</frontend_type>
884
+ <source_model>adminhtml/system_config_source_yesno</source_model>
885
+ <sort_order>10</sort_order>
886
+ <show_in_default>1</show_in_default>
887
+ <show_in_website>1</show_in_website>
888
+ <show_in_store>0</show_in_store>
889
+ </enabled>
890
+ </fields>
891
+ </roi_tracking>
892
+ </groups>
893
+ </connector_roi_tracking>
894
+ <connector_lost_baskets translate="label" module="connector">
895
+ <label><![CDATA[Abandoned Carts]]></label>
896
+ <tab>connector</tab>
897
+ <frontend_type>text</frontend_type>
898
+ <sort_order>6000</sort_order>
899
+ <show_in_default>1</show_in_default>
900
+ <show_in_website>1</show_in_website>
901
+ <show_in_store>0</show_in_store>
902
+ <groups>
903
+ <customers translate="label" module="connector">
904
+ <label>Customers</label>
905
+ <frontend_type>text</frontend_type>
906
+ <sort_order>10</sort_order>
907
+ <show_in_default>1</show_in_default>
908
+ <show_in_website>1</show_in_website>
909
+ <show_in_store>1</show_in_store>
910
+ <expanded>1</expanded>
911
+ <fields>
912
+ <heading_1 translate="label" module="connector">
913
+ <label>Abandoned Cart 1</label>
914
+ <frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
915
+ <sort_order>10</sort_order>
916
+ <show_in_default>1</show_in_default>
917
+ <show_in_website>1</show_in_website>
918
+ <show_in_store>1</show_in_store>
919
+ </heading_1>
920
+ <enabled_1 translate="label" module="connector">
921
+ <label>Enabled/Disabled</label>
922
+ <frontend_type>select</frontend_type>
923
+ <source_model>adminhtml/system_config_source_enabledisable</source_model>
924
+ <sort_order>20</sort_order>
925
+ <show_in_default>1</show_in_default>
926
+ <show_in_website>1</show_in_website>
927
+ <show_in_store>1</show_in_store>
928
+ </enabled_1>
929
+ <send_after_1 translate="label" module="connector">
930
+ <label>Send After (min)</label>
931
+ <frontend_type>select</frontend_type>
932
+ <source_model>email_connector/adminhtml_source_lostbaskets_intervalminute</source_model>
933
+ <sort_order>30</sort_order>
934
+ <show_in_default>1</show_in_default>
935
+ <show_in_website>1</show_in_website>
936
+ <show_in_store>1</show_in_store>
937
+ </send_after_1>
938
+ <campaign_1 translate="label" module="connector">
939
+ <label>Campaign To Send</label>
940
+ <frontend_type>select</frontend_type>
941
+ <source_model>email_connector/adminhtml_source_campaigns</source_model>
942
+ <sort_order>40</sort_order>
943
+ <show_in_default>1</show_in_default>
944
+ <show_in_website>1</show_in_website>
945
+ <show_in_store>1</show_in_store>
946
+ </campaign_1>
947
+ <heading_2 translate="label" module="connector">
948
+ <label>Abandoned Cart 2</label>
949
+ <frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
950
+ <sort_order>50</sort_order>
951
+ <show_in_default>1</show_in_default>
952
+ <show_in_website>1</show_in_website>
953
+ <show_in_store>1</show_in_store>
954
+ </heading_2>
955
+ <enabled_2 translate="label" module="connector">
956
+ <label>Enabled/Disabled</label>
957
+ <frontend_type>select</frontend_type>
958
+ <source_model>adminhtml/system_config_source_enabledisable</source_model>
959
+ <sort_order>60</sort_order>
960
+ <show_in_default>1</show_in_default>
961
+ <show_in_website>1</show_in_website>
962
+ <show_in_store>1</show_in_store>
963
+ </enabled_2>
964
+ <send_after_2 translate="label" module="connector">
965
+ <label>Send After (hrs)</label>
966
+ <frontend_type>select</frontend_type>
967
+ <source_model>email_connector/adminhtml_source_lostbaskets_interval</source_model>
968
+ <sort_order>70</sort_order>
969
+ <show_in_default>1</show_in_default>
970
+ <show_in_website>1</show_in_website>
971
+ <show_in_store>1</show_in_store>
972
+ </send_after_2>
973
+ <campaign_2 translate="label" module="connector">
974
+ <label>Campaign To Send</label>
975
+ <frontend_type>select</frontend_type>
976
+ <source_model>email_connector/adminhtml_source_campaigns</source_model>
977
+ <sort_order>80</sort_order>
978
+ <show_in_default>1</show_in_default>
979
+ <show_in_website>1</show_in_website>
980
+ <show_in_store>1</show_in_store>
981
+ </campaign_2>
982
+ <heading_3 translate="label" module="connector">
983
+ <label>Abandoned Cart 3</label>
984
+ <frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
985
+ <sort_order>90</sort_order>
986
+ <show_in_default>1</show_in_default>
987
+ <show_in_website>1</show_in_website>
988
+ <show_in_store>1</show_in_store>
989
+ </heading_3>
990
+ <enabled_3 translate="label" module="connector">
991
+ <label>Enabled/Disabled</label>
992
+ <frontend_type>select</frontend_type>
993
+ <source_model>adminhtml/system_config_source_enabledisable</source_model>
994
+ <sort_order>100</sort_order>
995
+ <show_in_default>1</show_in_default>
996
+ <show_in_website>1</show_in_website>
997
+ <show_in_store>1</show_in_store>
998
+ </enabled_3>
999
+ <send_after_3 translate="label" module="connector">
1000
+ <label>Send After (hrs)</label>
1001
+ <frontend_type>select</frontend_type>
1002
+ <source_model>email_connector/adminhtml_source_lostbaskets_interval</source_model>
1003
+ <sort_order>110</sort_order>
1004
+ <show_in_default>1</show_in_default>
1005
+ <show_in_website>1</show_in_website>
1006
+ <show_in_store>1</show_in_store>
1007
+ </send_after_3>
1008
+ <campaign_3 translate="label" module="connector">
1009
+ <label>Campaign To Send</label>
1010
+ <frontend_type>select</frontend_type>
1011
+ <source_model>email_connector/adminhtml_source_campaigns</source_model>
1012
+ <sort_order>120</sort_order>
1013
+ <show_in_default>1</show_in_default>
1014
+ <show_in_website>1</show_in_website>
1015
+ <show_in_store>1</show_in_store>
1016
+ </campaign_3>
1017
+ </fields>
1018
+ </customers>
1019
+ <guests translate="label" module="connector">
1020
+ <label>Guests</label>
1021
+ <frontend_type>text</frontend_type>
1022
+ <sort_order>20</sort_order>
1023
+ <show_in_default>1</show_in_default>
1024
+ <show_in_website>1</show_in_website>
1025
+ <show_in_store>0</show_in_store>
1026
+ <fields>
1027
+ <heading_1 translate="label" module="connector">
1028
+ <label>Abandoned Cart 1</label>
1029
+ <frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
1030
+ <sort_order>10</sort_order>
1031
+ <show_in_default>1</show_in_default>
1032
+ <show_in_website>1</show_in_website>
1033
+ <show_in_store>0</show_in_store>
1034
+ </heading_1>
1035
+ <enabled_1 translate="label" module="connector">
1036
+ <label>Enabled/Disabled</label>
1037
+ <frontend_type>select</frontend_type>
1038
+ <source_model>adminhtml/system_config_source_enabledisable</source_model>
1039
+ <sort_order>20</sort_order>
1040
+ <show_in_default>1</show_in_default>
1041
+ <show_in_website>1</show_in_website>
1042
+ <show_in_store>0</show_in_store>
1043
+ </enabled_1>
1044
+ <send_after_1 translate="label" module="connector">
1045
+ <label>Send After (min)</label>
1046
+ <frontend_type>select</frontend_type>
1047
+ <source_model>email_connector/adminhtml_source_lostbaskets_intervalminute</source_model>
1048
+ <sort_order>30</sort_order>
1049
+ <show_in_default>1</show_in_default>
1050
+ <show_in_website>1</show_in_website>
1051
+ <show_in_store>0</show_in_store>
1052
+ </send_after_1>
1053
+ <campaign_1 translate="label" module="connector">
1054
+ <label>Campaign To Send</label>
1055
+ <frontend_type>select</frontend_type>
1056
+ <source_model>email_connector/adminhtml_source_campaigns</source_model>
1057
+ <sort_order>40</sort_order>
1058
+ <show_in_default>1</show_in_default>
1059
+ <show_in_website>1</show_in_website>
1060
+ <show_in_store>0</show_in_store>
1061
+ </campaign_1>
1062
+ <heading_2 translate="label" module="connector">
1063
+ <label>Abandoned Cart 2</label>
1064
+ <frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
1065
+ <sort_order>50</sort_order>
1066
+ <show_in_default>1</show_in_default>
1067
+ <show_in_website>1</show_in_website>
1068
+ <show_in_store>0</show_in_store>
1069
+ </heading_2>
1070
+ <enabled_2 translate="label" module="connector">
1071
+ <label>Enabled/Disabled</label>
1072
+ <frontend_type>select</frontend_type>
1073
+ <source_model>adminhtml/system_config_source_enabledisable</source_model>
1074
+ <sort_order>60</sort_order>
1075
+ <show_in_default>1</show_in_default>
1076
+ <show_in_website>1</show_in_website>
1077
+ <show_in_store>0</show_in_store>
1078
+ </enabled_2>
1079
+ <send_after_2 translate="label" module="connector">
1080
+ <label>Send After (hrs)</label>
1081
+ <frontend_type>select</frontend_type>
1082
+ <source_model>email_connector/adminhtml_source_lostbaskets_interval</source_model>
1083
+ <sort_order>70</sort_order>
1084
+ <show_in_default>1</show_in_default>
1085
+ <show_in_website>1</show_in_website>
1086
+ <show_in_store>0</show_in_store>
1087
+ </send_after_2>
1088
+ <campaign_2 translate="label" module="connector">
1089
+ <label>Campaign To Send</label>
1090
+ <frontend_type>select</frontend_type>
1091
+ <source_model>email_connector/adminhtml_source_campaigns</source_model>
1092
+ <sort_order>80</sort_order>
1093
+ <show_in_default>1</show_in_default>
1094
+ <show_in_website>1</show_in_website>
1095
+ <show_in_store>0</show_in_store>
1096
+ </campaign_2>
1097
+ <heading_3 translate="label" module="connector">
1098
+ <label>Abandoned Cart 3</label>
1099
+ <frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
1100
+ <sort_order>90</sort_order>
1101
+ <show_in_default>1</show_in_default>
1102
+ <show_in_website>1</show_in_website>
1103
+ <show_in_store>0</show_in_store>
1104
+ </heading_3>
1105
+ <enabled_3 translate="label" module="connector">
1106
+ <label>Enabled/Disabled</label>
1107
+ <frontend_type>select</frontend_type>
1108
+ <source_model>adminhtml/system_config_source_enabledisable</source_model>
1109
+ <sort_order>100</sort_order>
1110
+ <show_in_default>1</show_in_default>
1111
+ <show_in_website>1</show_in_website>
1112
+ <show_in_store>0</show_in_store>
1113
+ </enabled_3>
1114
+ <send_after_3 translate="label" module="connector">
1115
+ <label>Send After (hrs)</label>
1116
+ <frontend_type>select</frontend_type>
1117
+ <source_model>email_connector/adminhtml_source_lostbaskets_interval</source_model>
1118
+ <sort_order>110</sort_order>
1119
+ <show_in_default>1</show_in_default>
1120
+ <show_in_website>1</show_in_website>
1121
+ <show_in_store>0</show_in_store>
1122
+ </send_after_3>
1123
+ <campaign_3 translate="label" module="connector">
1124
+ <label>Campaign To Send</label>
1125
+ <frontend_type>select</frontend_type>
1126
+ <source_model>email_connector/adminhtml_source_campaigns</source_model>
1127
+ <sort_order>120</sort_order>
1128
+ <show_in_default>1</show_in_default>
1129
+ <show_in_website>1</show_in_website>
1130
+ <show_in_store>0</show_in_store>
1131
+ </campaign_3>
1132
+ </fields>
1133
+ </guests>
1134
+ </groups>
1135
+ </connector_lost_baskets>
1136
+ <connector_reviews translate="label" module="connector">
1137
+ <label><![CDATA[Reviews]]></label>
1138
+ <tab>connector</tab>
1139
+ <frontend_type>text</frontend_type>
1140
+ <sort_order>6500</sort_order>
1141
+ <show_in_default>1</show_in_default>
1142
+ <show_in_website>1</show_in_website>
1143
+ <show_in_store>1</show_in_store>
1144
+ <groups>
1145
+ <settings translate="label" module="connector">
1146
+ <label>Settings</label>
1147
+ <frontend_type>text</frontend_type>
1148
+ <sort_order>10</sort_order>
1149
+ <show_in_default>1</show_in_default>
1150
+ <show_in_website>1</show_in_website>
1151
+ <show_in_store>1</show_in_store>
1152
+ <expanded>1</expanded>
1153
+ <fields>
1154
+ <enabled translate="label" module="connector">
1155
+ <label>Enabled</label>
1156
+ <frontend_type>select</frontend_type>
1157
+ <source_model>adminhtml/system_config_source_yesno</source_model>
1158
+ <sort_order>10</sort_order>
1159
+ <show_in_default>1</show_in_default>
1160
+ <show_in_website>1</show_in_website>
1161
+ <show_in_store>0</show_in_store>
1162
+ </enabled>
1163
+ <status translate="label" module="connector">
1164
+ <label>Order Status</label>
1165
+ <sort_order>20</sort_order>
1166
+ <frontend_type>select</frontend_type>
1167
+ <source_model>adminhtml/system_config_source_order_status</source_model>
1168
+ <show_in_default>1</show_in_default>
1169
+ <show_in_website>1</show_in_website>
1170
+ <show_in_store>0</show_in_store>
1171
+ </status>
1172
+ <delay>
1173
+ <label>Delay Period (Days)</label>
1174
+ <sort_order>30</sort_order>
1175
+ <frontend_type>select</frontend_type>
1176
+ <source_model>email_connector/adminhtml_source_reviews_delay</source_model>
1177
+ <show_in_default>1</show_in_default>
1178
+ <show_in_website>1</show_in_website>
1179
+ <show_in_store>0</show_in_store>
1180
+ <comment><![CDATA[The system will send the reminder after the above mentioned amount of days upon order status selected above.]]></comment>
1181
+ </delay>
1182
+ <new_product>
1183
+ <label>New Product Only</label>
1184
+ <sort_order>40</sort_order>
1185
+ <frontend_type>select</frontend_type>
1186
+ <source_model>adminhtml/system_config_source_yesno</source_model>
1187
+ <show_in_default>1</show_in_default>
1188
+ <show_in_website>1</show_in_website>
1189
+ <show_in_store>0</show_in_store>
1190
+ <comment><![CDATA[Only include not purchased before products only.]]></comment>
1191
+ </new_product>
1192
+ <campaign>
1193
+ <label>Campaign To Send</label>
1194
+ <sort_order>50</sort_order>
1195
+ <frontend_type>select</frontend_type>
1196
+ <source_model>email_connector/adminhtml_source_reviews_campaigns</source_model>
1197
+ <show_in_default>1</show_in_default>
1198
+ <show_in_website>1</show_in_website>
1199
+ <show_in_store>0</show_in_store>
1200
+ </campaign>
1201
+ <anchor>
1202
+ <label>Reviews Anchor</label>
1203
+ <sort_order>60</sort_order>
1204
+ <frontend_type>text</frontend_type>
1205
+ <show_in_default>1</show_in_default>
1206
+ <show_in_website>1</show_in_website>
1207
+ <show_in_store>0</show_in_store>
1208
+ <comment><![CDATA[Please provide the anchor used on product pages for reviews e.g. #reviews]]></comment>
1209
+ </anchor>
1210
+ </fields>
1211
+ </settings>
1212
+ </groups>
1213
+ </connector_reviews>
1214
+ <connector_sms translate="label" module="connector">
1215
+ <label><![CDATA[SMS]]></label>
1216
+ <tab>connector</tab>
1217
+ <frontend_type>text</frontend_type>
1218
+ <sort_order>7000</sort_order>
1219
+ <show_in_default>1</show_in_default>
1220
+ <show_in_website>1</show_in_website>
1221
+ <show_in_store>1</show_in_store>
1222
+ <groups>
1223
+ <sms_one translate="label" module="connector">
1224
+ <label>SMS Message 1</label>
1225
+ <frontend_type>text</frontend_type>
1226
+ <sort_order>10</sort_order>
1227
+ <show_in_default>1</show_in_default>
1228
+ <show_in_website>1</show_in_website>
1229
+ <show_in_store>1</show_in_store>
1230
+ <fields>
1231
+ <enabled translate="label" module="connector">
1232
+ <label>Enabled</label>
1233
+ <frontend_type>select</frontend_type>
1234
+ <source_model>adminhtml/system_config_source_yesno</source_model>
1235
+ <sort_order>10</sort_order>
1236
+ <show_in_default>1</show_in_default>
1237
+ <show_in_website>1</show_in_website>
1238
+ <show_in_store>1</show_in_store>
1239
+ </enabled>
1240
+ <status translate="label" module="connector">
1241
+ <label>Order Status</label>
1242
+ <sort_order>20</sort_order>
1243
+ <frontend_type>select</frontend_type>
1244
+ <source_model>adminhtml/system_config_source_order_status</source_model>
1245
+ <show_in_default>1</show_in_default>
1246
+ <show_in_website>1</show_in_website>
1247
+ <show_in_store>1</show_in_store>
1248
+ </status>
1249
+ <message translate="label" module="connector">
1250
+ <label>Message</label>
1251
+ <frontend_type>textarea</frontend_type>
1252
+ <frontend_model>email_connector/adminhtml_system_sms_smsmessageone</frontend_model>
1253
+ <sort_order>30</sort_order>
1254
+ <show_in_default>1</show_in_default>
1255
+ <show_in_website>1</show_in_website>
1256
+ <show_in_store>1</show_in_store>
1257
+ <validate>validate-length maximum-length-160</validate>
1258
+ </message>
1259
+ </fields>
1260
+ </sms_one>
1261
+ <sms_two translate="label" module="connector">
1262
+ <label>SMS Message 2</label>
1263
+ <frontend_type>text</frontend_type>
1264
+ <sort_order>20</sort_order>
1265
+ <show_in_default>1</show_in_default>
1266
+ <show_in_website>1</show_in_website>
1267
+ <show_in_store>1</show_in_store>
1268
+ <fields>
1269
+ <enabled translate="label" module="connector">
1270
+ <label>Enabled</label>
1271
+ <frontend_type>select</frontend_type>
1272
+ <source_model>adminhtml/system_config_source_yesno</source_model>
1273
+ <sort_order>10</sort_order>
1274
+ <show_in_default>1</show_in_default>
1275
+ <show_in_website>1</show_in_website>
1276
+ <show_in_store>1</show_in_store>
1277
+ </enabled>
1278
+ <status translate="label" module="connector">
1279
+ <label>Order Status</label>
1280
+ <sort_order>20</sort_order>
1281
+ <frontend_type>select</frontend_type>
1282
+ <source_model>adminhtml/system_config_source_order_status</source_model>
1283
+ <show_in_default>1</show_in_default>
1284
+ <show_in_website>1</show_in_website>
1285
+ <show_in_store>1</show_in_store>
1286
+ </status>
1287
+ <message translate="label" module="connector">
1288
+ <label>Message</label>
1289
+ <frontend_type>textarea</frontend_type>
1290
+ <frontend_model>email_connector/adminhtml_system_sms_smsmessagetwo</frontend_model>
1291
+ <sort_order>30</sort_order>
1292
+ <show_in_default>1</show_in_default>
1293
+ <show_in_website>1</show_in_website>
1294
+ <show_in_store>1</show_in_store>
1295
+ <validate>validate-length maximum-length-160</validate>
1296
+ </message>
1297
+ </fields>
1298
+ </sms_two>
1299
+ <sms_three translate="label" module="connector">
1300
+ <label>SMS Message 3</label>
1301
+ <frontend_type>text</frontend_type>
1302
+ <sort_order>30</sort_order>
1303
+ <show_in_default>1</show_in_default>
1304
+ <show_in_website>1</show_in_website>
1305
+ <show_in_store>1</show_in_store>
1306
+ <fields>
1307
+ <enabled translate="label" module="connector">
1308
+ <label>Enabled</label>
1309
+ <frontend_type>select</frontend_type>
1310
+ <source_model>adminhtml/system_config_source_yesno</source_model>
1311
+ <sort_order>10</sort_order>
1312
+ <show_in_default>1</show_in_default>
1313
+ <show_in_website>1</show_in_website>
1314
+ <show_in_store>1</show_in_store>
1315
+ </enabled>
1316
+ <status translate="label" module="connector">
1317
+ <label>Order Status</label>
1318
+ <sort_order>20</sort_order>
1319
+ <frontend_type>select</frontend_type>
1320
+ <source_model>adminhtml/system_config_source_order_status</source_model>
1321
+ <show_in_default>1</show_in_default>
1322
+ <show_in_website>1</show_in_website>
1323
+ <show_in_store>1</show_in_store>
1324
+ </status>
1325
+ <message translate="label" module="connector">
1326
+ <label>Message</label>
1327
+ <frontend_type>textarea</frontend_type>
1328
+ <frontend_model>email_connector/adminhtml_system_sms_smsmessagethree</frontend_model>
1329
+ <sort_order>30</sort_order>
1330
+ <show_in_default>1</show_in_default>
1331
+ <show_in_website>1</show_in_website>
1332
+ <show_in_store>1</show_in_store>
1333
+ <validate>validate-length maximum-length-160</validate>
1334
+ </message>
1335
+ </fields>
1336
+ </sms_three>
1337
+ <sms_four translate="label" module="connector">
1338
+ <label>SMS Message 4</label>
1339
+ <frontend_type>text</frontend_type>
1340
+ <sort_order>40</sort_order>
1341
+ <show_in_default>1</show_in_default>
1342
+ <show_in_website>1</show_in_website>
1343
+ <show_in_store>1</show_in_store>
1344
+ <fields>
1345
+ <enabled translate="label" module="connector">
1346
+ <label>Enabled</label>
1347
+ <frontend_type>select</frontend_type>
1348
+ <source_model>adminhtml/system_config_source_yesno</source_model>
1349
+ <sort_order>10</sort_order>
1350
+ <show_in_default>1</show_in_default>
1351
+ <show_in_website>1</show_in_website>
1352
+ <show_in_store>1</show_in_store>
1353
+ </enabled>
1354
+ <status translate="label" module="connector">
1355
+ <label>Order Status</label>
1356
+ <sort_order>20</sort_order>
1357
+ <frontend_type>select</frontend_type>
1358
+ <source_model>adminhtml/system_config_source_order_status</source_model>
1359
+ <show_in_default>1</show_in_default>
1360
+ <show_in_website>1</show_in_website>
1361
+ <show_in_store>1</show_in_store>
1362
+ </status>
1363
+ <message translate="label" module="connector">
1364
+ <label>Message</label>
1365
+ <frontend_type>textarea</frontend_type>
1366
+ <frontend_model>email_connector/adminhtml_system_sms_smsmessagefour</frontend_model>
1367
+ <sort_order>30</sort_order>
1368
+ <show_in_default>1</show_in_default>
1369
+ <show_in_website>1</show_in_website>
1370
+ <show_in_store>1</show_in_store>
1371
+ <validate>validate-length maximum-length-160</validate>
1372
+ </message>
1373
+ </fields>
1374
+ </sms_four>
1375
+ </groups>
1376
+ </connector_sms>
1377
+ <connector_dynamic_content translate="label" module="connector">
1378
+ <label><![CDATA[Dynamic Content]]></label>
1379
+ <tab>connector</tab>
1380
+ <frontend_type>text</frontend_type>
1381
+ <sort_order>8000</sort_order>
1382
+ <show_in_default>1</show_in_default>
1383
+ <show_in_website>1</show_in_website>
1384
+ <show_in_store>0</show_in_store>
1385
+ <groups>
1386
+ <products translate="label" module="connector">
1387
+ <label>Dynamic Products</label>
1388
+ <frontend_type>text</frontend_type>
1389
+ <sort_order>20</sort_order>
1390
+ <show_in_default>1</show_in_default>
1391
+ <show_in_website>1</show_in_website>
1392
+ <show_in_store>0</show_in_store>
1393
+ <fields>
1394
+ <review translate="label" module="connector">
1395
+ <label>Reviews</label>
1396
+ <frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
1397
+ <sort_order>3</sort_order>
1398
+ <show_in_default>1</show_in_default>
1399
+ <show_in_website>1</show_in_website>
1400
+ <show_in_store>0</show_in_store>
1401
+ </review>
1402
+ <review_display_type translate="label" module="connector">
1403
+ <label>Display Type</label>
1404
+ <frontend_type>select</frontend_type>
1405
+ <source_model>email_connector/adminhtml_source_dynamic_displaytype</source_model>
1406
+ <sort_order>6</sort_order>
1407
+ <show_in_default>1</show_in_default>
1408
+ <show_in_website>1</show_in_website>
1409
+ <show_in_store>0</show_in_store>
1410
+ </review_display_type>
1411
+ <related translate="label" module="connector">
1412
+ <label>Related Products</label>
1413
+ <frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
1414
+ <sort_order>10</sort_order>
1415
+ <show_in_default>1</show_in_default>
1416
+ <show_in_website>1</show_in_website>
1417
+ <show_in_store>0</show_in_store>
1418
+ </related>
1419
+ <related_display_type translate="label" module="connector">
1420
+ <label>Display Type</label>
1421
+ <frontend_type>select</frontend_type>
1422
+ <source_model>email_connector/adminhtml_source_dynamic_displaytype</source_model>
1423
+ <sort_order>20</sort_order>
1424
+ <show_in_default>1</show_in_default>
1425
+ <show_in_website>1</show_in_website>
1426
+ <show_in_store>0</show_in_store>
1427
+ </related_display_type>
1428
+ <related_items_to_display translate="label" module="connector">
1429
+ <label>Items To Display</label>
1430
+ <frontend_type>select</frontend_type>
1431
+ <source_model>email_connector/adminhtml_source_dynamic_gridview</source_model>
1432
+ <sort_order>30</sort_order>
1433
+ <show_in_website>1</show_in_website>
1434
+ <show_in_default>1</show_in_default>
1435
+ <show_in_store>0</show_in_store>
1436
+ </related_items_to_display>
1437
+ <upsell translate="label" module="connector">
1438
+ <label>Up Sell Products</label>
1439
+ <frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
1440
+ <sort_order>40</sort_order>
1441
+ <show_in_default>1</show_in_default>
1442
+ <show_in_website>1</show_in_website>
1443
+ <show_in_store>0</show_in_store>
1444
+ </upsell>
1445
+ <upsell_display_type translate="label" module="connector">
1446
+ <label>Display Type</label>
1447
+ <frontend_type>select</frontend_type>
1448
+ <source_model>email_connector/adminhtml_source_dynamic_displaytype</source_model>
1449
+ <sort_order>50</sort_order>
1450
+ <show_in_default>1</show_in_default>
1451
+ <show_in_website>1</show_in_website>
1452
+ <show_in_store>0</show_in_store>
1453
+ </upsell_display_type>
1454
+ <upsell_items_to_display translate="label" module="connector">
1455
+ <label>Items To Display</label>
1456
+ <frontend_type>select</frontend_type>
1457
+ <source_model>email_connector/adminhtml_source_dynamic_gridview</source_model>
1458
+ <sort_order>60</sort_order>
1459
+ <show_in_website>1</show_in_website>
1460
+ <show_in_default>1</show_in_default>
1461
+ <show_in_store>0</show_in_store>
1462
+ </upsell_items_to_display>
1463
+ <crosssell translate="label" module="connector">
1464
+ <label>Cross Sell Products</label>
1465
+ <frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
1466
+ <sort_order>70</sort_order>
1467
+ <show_in_default>1</show_in_default>
1468
+ <show_in_website>1</show_in_website>
1469
+ <show_in_store>0</show_in_store>
1470
+ </crosssell>
1471
+ <crosssell_display_type translate="label" module="connector">
1472
+ <label>Display Type</label>
1473
+ <frontend_type>select</frontend_type>
1474
+ <source_model>email_connector/adminhtml_source_dynamic_displaytype</source_model>
1475
+ <sort_order>80</sort_order>
1476
+ <show_in_default>1</show_in_default>
1477
+ <show_in_website>1</show_in_website>
1478
+ <show_in_store>0</show_in_store>
1479
+ </crosssell_display_type>
1480
+ <crosssell_items_to_display translate="label" module="connector">
1481
+ <label>Items To Display</label>
1482
+ <frontend_type>select</frontend_type>
1483
+ <source_model>email_connector/adminhtml_source_dynamic_gridview</source_model>
1484
+ <sort_order>90</sort_order>
1485
+ <show_in_website>1</show_in_website>
1486
+ <show_in_default>1</show_in_default>
1487
+ <show_in_store>0</show_in_store>
1488
+ </crosssell_items_to_display>
1489
+ <bestsellers translate="label" module="connector">
1490
+ <label>Best Sellers</label>
1491
+ <frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
1492
+ <sort_order>100</sort_order>
1493
+ <show_in_default>1</show_in_default>
1494
+ <show_in_website>1</show_in_website>
1495
+ <show_in_store>0</show_in_store>
1496
+ </bestsellers>
1497
+ <bestsellers_display_type translate="label" module="connector">
1498
+ <label>Display Type</label>
1499
+ <frontend_type>select</frontend_type>
1500
+ <source_model>email_connector/adminhtml_source_dynamic_displaytype</source_model>
1501
+ <sort_order>110</sort_order>
1502
+ <show_in_default>1</show_in_default>
1503
+ <show_in_website>1</show_in_website>
1504
+ <show_in_store>0</show_in_store>
1505
+ </bestsellers_display_type>
1506
+ <bestsellers_items_to_display translate="label" module="connector">
1507
+ <label>Items To Display</label>
1508
+ <frontend_type>select</frontend_type>
1509
+ <source_model>email_connector/adminhtml_source_dynamic_gridview</source_model>
1510
+ <sort_order>120</sort_order>
1511
+ <show_in_website>1</show_in_website>
1512
+ <show_in_default>1</show_in_default>
1513
+ <show_in_store>0</show_in_store>
1514
+ </bestsellers_items_to_display>
1515
+ <bestsellers_time_period translate="label" module="connector">
1516
+ <label>Time Period</label>
1517
+ <frontend_type>select</frontend_type>
1518
+ <source_model>adminhtml/system_config_source_cron_frequency</source_model>
1519
+ <sort_order>130</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
+ </bestsellers_time_period>
1524
+ <most_viewed translate="label" module="connector">
1525
+ <label>Most Viewed</label>
1526
+ <frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
1527
+ <sort_order>140</sort_order>
1528
+ <show_in_default>1</show_in_default>
1529
+ <show_in_website>1</show_in_website>
1530
+ <show_in_store>0</show_in_store>
1531
+ </most_viewed>
1532
+ <most_viewed_display_type translate="label" module="connector">
1533
+ <label>Display Type</label>
1534
+ <frontend_type>select</frontend_type>
1535
+ <source_model>email_connector/adminhtml_source_dynamic_displaytype</source_model>
1536
+ <sort_order>150</sort_order>
1537
+ <show_in_default>1</show_in_default>
1538
+ <show_in_website>1</show_in_website>
1539
+ <show_in_store>0</show_in_store>
1540
+ </most_viewed_display_type>
1541
+ <most_viewed_items_to_display translate="label" module="connector">
1542
+ <label>Items To Display</label>
1543
+ <frontend_type>select</frontend_type>
1544
+ <source_model>email_connector/adminhtml_source_dynamic_gridview</source_model>
1545
+ <sort_order>160</sort_order>
1546
+ <show_in_website>1</show_in_website>
1547
+ <show_in_default>1</show_in_default>
1548
+ <show_in_store>0</show_in_store>
1549
+ </most_viewed_items_to_display>
1550
+ <most_viewed_time_period translate="label" module="connector">
1551
+ <label>Time Period</label>
1552
+ <frontend_type>select</frontend_type>
1553
+ <source_model>adminhtml/system_config_source_cron_frequency</source_model>
1554
+ <sort_order>170</sort_order>
1555
+ <show_in_default>1</show_in_default>
1556
+ <show_in_website>1</show_in_website>
1557
+ <show_in_store>0</show_in_store>
1558
+ </most_viewed_time_period>
1559
+ <recently_viewed translate="label" module="connector">
1560
+ <label>Recently Viewed</label>
1561
+ <frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
1562
+ <sort_order>180</sort_order>
1563
+ <show_in_default>1</show_in_default>
1564
+ <show_in_website>1</show_in_website>
1565
+ <show_in_store>0</show_in_store>
1566
+ </recently_viewed>
1567
+ <recently_viewed_display_type translate="label" module="connector">
1568
+ <label>Display Type</label>
1569
+ <frontend_type>select</frontend_type>
1570
+ <source_model>email_connector/adminhtml_source_dynamic_displaytype</source_model>
1571
+ <sort_order>190</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
+ </recently_viewed_display_type>
1576
+ <recently_viewed_items_to_display translate="label" module="connector">
1577
+ <label>items To Display</label>
1578
+ <frontend_type>select</frontend_type>
1579
+ <source_model>email_connector/adminhtml_source_dynamic_gridview</source_model>
1580
+ <sort_order>200</sort_order>
1581
+ <show_in_default>1</show_in_default>
1582
+ <show_in_website>1</show_in_website>
1583
+ <show_in_store>0</show_in_store>
1584
+ </recently_viewed_items_to_display>
1585
+ <validator module="connector">
1586
+ <frontend_type>hidden</frontend_type>
1587
+ <frontend_model>email_connector/adminhtml_system_dynamic_gridlist</frontend_model>
1588
+ <sort_order>210</sort_order>
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
+ <can_be_empty>1</can_be_empty>
1593
+ </validator>
1594
+ </fields>
1595
+ </products>
1596
+ <external_dynamic_content_urls translate="label" module="connector">
1597
+ <label><![CDATA[External Dynamic Content URL's]]></label>
1598
+ <frontend_type>text</frontend_type>
1599
+ <sort_order>10</sort_order>
1600
+ <show_in_default>1</show_in_default>
1601
+ <show_in_website>1</show_in_website>
1602
+ <show_in_store>0</show_in_store>
1603
+ <fields>
1604
+ <passcode translate="label comment" module="connector">
1605
+ <label>Passcode</label>
1606
+ <frontend_type>text</frontend_type>
1607
+ <sort_order>10</sort_order>
1608
+ <show_in_default>1</show_in_default>
1609
+ <show_in_website>1</show_in_website>
1610
+ <show_in_store>0</show_in_store>
1611
+ <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>
1612
+ </passcode>
1613
+ <lost_basket_title translate="label" module="connector">
1614
+ <label>Abandoned Carts</label>
1615
+ <frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
1616
+ <sort_order>20</sort_order>
1617
+ <show_in_default>1</show_in_default>
1618
+ <show_in_website>1</show_in_website>
1619
+ <show_in_store>0</show_in_store>
1620
+ </lost_basket_title>
1621
+ <lost_basket_url translate="label" module="connector">
1622
+ <label>Cart Content URL</label>
1623
+ <frontend_type>label</frontend_type>
1624
+ <frontend_model>email_connector/adminhtml_system_dynamic_lostbasket</frontend_model>
1625
+ <sort_order>30</sort_order>
1626
+ <show_in_default>1</show_in_default>
1627
+ <show_in_website>1</show_in_website>
1628
+ <show_in_store>0</show_in_store>
1629
+ </lost_basket_url>
1630
+ <review_title title="label" module="connector">
1631
+ <label>Reviews</label>
1632
+ <frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
1633
+ <sort_order>33</sort_order>
1634
+ <show_in_website>1</show_in_website>
1635
+ <show_in_default>1</show_in_default>
1636
+ <show_in_store>0</show_in_store>
1637
+ </review_title>
1638
+ <review_url translate="label" module="connector">
1639
+ <label>Order Contents</label>
1640
+ <frontend_type>label</frontend_type>
1641
+ <frontend_model>email_connector/adminhtml_system_dynamic_review</frontend_model>
1642
+ <sort_order>36</sort_order>
1643
+ <show_in_default>1</show_in_default>
1644
+ <show_in_website>1</show_in_website>
1645
+ <show_in_store>0</show_in_store>
1646
+ </review_url>
1647
+ <coupon_code_title title="label" module="connector">
1648
+ <label>Coupon Codes</label>
1649
+ <frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
1650
+ <sort_order>40</sort_order>
1651
+ <show_in_website>1</show_in_website>
1652
+ <show_in_default>1</show_in_default>
1653
+ <show_in_store>0</show_in_store>
1654
+ </coupon_code_title>
1655
+ <coupon_code_url translate="label" module="connector">
1656
+ <label>Coupon Codes URL</label>
1657
+ <frontend_type>label</frontend_type>
1658
+ <frontend_model>email_connector/adminhtml_system_dynamic_couponinfo</frontend_model>
1659
+ <sort_order>50</sort_order>
1660
+ <show_in_default>1</show_in_default>
1661
+ <show_in_website>1</show_in_website>
1662
+ <show_in_store>0</show_in_store>
1663
+ </coupon_code_url>
1664
+ <order_dynamic_content_url translate="label" module="connector">
1665
+ <label>Order Recommendation</label>
1666
+ <frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
1667
+ <sort_order>60</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
+ </order_dynamic_content_url>
1672
+ <related_products_url translate="label" module="connector">
1673
+ <label>Related Products URL</label>
1674
+ <frontend_type>label</frontend_type>
1675
+ <frontend_model>email_connector/adminhtml_system_dynamic_related</frontend_model>
1676
+ <sort_order>70</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
+ </related_products_url>
1681
+ <upsell_products_url translate="label" module="connector">
1682
+ <label>Up-Sell Products URL</label>
1683
+ <frontend_type>label</frontend_type>
1684
+ <frontend_model>email_connector/adminhtml_system_dynamic_upsell</frontend_model>
1685
+ <sort_order>80</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
+ </upsell_products_url>
1690
+ <crosssell_products_url translate="label" module="connector">
1691
+ <label>Cross-Sell Products URL</label>
1692
+ <frontend_type>label</frontend_type>
1693
+ <frontend_model>email_connector/adminhtml_system_dynamic_crosssell</frontend_model>
1694
+ <sort_order>90</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
+ </crosssell_products_url>
1699
+ <basket_dynamic_content_url translate="label" module="connector">
1700
+ <label>Cart Recommendation</label>
1701
+ <frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
1702
+ <sort_order>91</sort_order>
1703
+ <show_in_default>1</show_in_default>
1704
+ <show_in_website>1</show_in_website>
1705
+ <show_in_store>0</show_in_store>
1706
+ </basket_dynamic_content_url>
1707
+ <basket_related_products_url translate="label" module="connector">
1708
+ <label>Related Products URL</label>
1709
+ <frontend_type>label</frontend_type>
1710
+ <frontend_model>email_connector/adminhtml_system_dynamic_basket_related</frontend_model>
1711
+ <sort_order>92</sort_order>
1712
+ <show_in_default>1</show_in_default>
1713
+ <show_in_website>1</show_in_website>
1714
+ <show_in_store>0</show_in_store>
1715
+ </basket_related_products_url>
1716
+ <basket_upsell_products_url translate="label" module="connector">
1717
+ <label>Up-Sell Products URL</label>
1718
+ <frontend_type>label</frontend_type>
1719
+ <frontend_model>email_connector/adminhtml_system_dynamic_basket_upsell</frontend_model>
1720
+ <sort_order>93</sort_order>
1721
+ <show_in_default>1</show_in_default>
1722
+ <show_in_website>1</show_in_website>
1723
+ <show_in_store>0</show_in_store>
1724
+ </basket_upsell_products_url>
1725
+ <basket_crosssell_products_url translate="label" module="connector">
1726
+ <label>Cross-Sell Products URL</label>
1727
+ <frontend_type>label</frontend_type>
1728
+ <frontend_model>email_connector/adminhtml_system_dynamic_basket_crosssell</frontend_model>
1729
+ <sort_order>94</sort_order>
1730
+ <show_in_default>1</show_in_default>
1731
+ <show_in_website>1</show_in_website>
1732
+ <show_in_store>0</show_in_store>
1733
+ </basket_crosssell_products_url>
1734
+ <product_dynamic_content_url translate="label" module="connector">
1735
+ <label>Product Recommendation</label>
1736
+ <frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
1737
+ <sort_order>100</sort_order>
1738
+ <show_in_default>1</show_in_default>
1739
+ <show_in_website>1</show_in_website>
1740
+ <show_in_store>0</show_in_store>
1741
+ </product_dynamic_content_url>
1742
+ <best_sellers_url translate="label" module="connector">
1743
+ <label>Best Sellers URL</label>
1744
+ <frontend_type>label</frontend_type>
1745
+ <frontend_model>email_connector/adminhtml_system_dynamic_bestsellers</frontend_model>
1746
+ <sort_order>110</sort_order>
1747
+ <show_in_default>1</show_in_default>
1748
+ <show_in_website>1</show_in_website>
1749
+ <show_in_store>0</show_in_store>
1750
+ </best_sellers_url>
1751
+ <most_viewed_url translate="label" module="connector">
1752
+ <label>Most Viewed URL</label>
1753
+ <frontend_type>label</frontend_type>
1754
+ <frontend_model>email_connector/adminhtml_system_dynamic_mostviewed</frontend_model>
1755
+ <sort_order>120</sort_order>
1756
+ <show_in_default>1</show_in_default>
1757
+ <show_in_website>1</show_in_website>
1758
+ <show_in_store>0</show_in_store>
1759
+ </most_viewed_url>
1760
+ <product_push_url translate="label" module="connector">
1761
+ <label>Product Push URL</label>
1762
+ <frontend_type>label</frontend_type>
1763
+ <frontend_model>email_connector/adminhtml_system_dynamic_productpush</frontend_model>
1764
+ <sort_order>130</sort_order>
1765
+ <show_in_default>1</show_in_default>
1766
+ <show_in_website>1</show_in_website>
1767
+ <show_in_store>0</show_in_store>
1768
+ </product_push_url>
1769
+ <recently_viewed_url translate="label" module="connector">
1770
+ <label>Recently Viewed</label>
1771
+ <frontend_type>label</frontend_type>
1772
+ <frontend_model>email_connector/adminhtml_system_dynamic_recentlyviewed</frontend_model>
1773
+ <sort_order>140</sort_order>
1774
+ <show_in_default>1</show_in_default>
1775
+ <show_in_website>1</show_in_website>
1776
+ <show_in_store>0</show_in_store>
1777
+ </recently_viewed_url>
1778
+ </fields>
1779
+ </external_dynamic_content_urls>
1780
+ <manual_product_search translate="label" module="connector">
1781
+ <label>Manual Product Push</label>
1782
+ <frontend_type>text</frontend_type>
1783
+ <sort_order>30</sort_order>
1784
+ <show_in_default>1</show_in_default>
1785
+ <show_in_website>1</show_in_website>
1786
+ <show_in_store>0</show_in_store>
1787
+ <expanded>1</expanded>
1788
+ <fields>
1789
+ <settings_title tranlate="label" module="connector">
1790
+ <label>Settings</label>
1791
+ <frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
1792
+ <sort_order>10</sort_order>
1793
+ <show_in_default>1</show_in_default>
1794
+ <show_in_website>1</show_in_website>
1795
+ <show_in_store>0</show_in_store>
1796
+ </settings_title>
1797
+ <display_type translate="label" module="connector">
1798
+ <label>Display Type</label>
1799
+ <frontend_type>select</frontend_type>
1800
+ <source_model>email_connector/adminhtml_source_dynamic_displaytype</source_model>
1801
+ <sort_order>50</sort_order>
1802
+ <show_in_default>1</show_in_default>
1803
+ <show_in_website>1</show_in_website>
1804
+ <show_in_store>0</show_in_store>
1805
+ </display_type>
1806
+ <items_to_display translate="label" module="connector">
1807
+ <label>Items To Display</label>
1808
+ <frontend_type>select</frontend_type>
1809
+ <source_model>email_connector/adminhtml_source_dynamic_gridview</source_model>
1810
+ <sort_order>60</sort_order>
1811
+ <show_in_website>1</show_in_website>
1812
+ <show_in_default>1</show_in_default>
1813
+ <show_in_store>0</show_in_store>
1814
+ </items_to_display>
1815
+ <products_push_title translate="label" module="connector">
1816
+ <label>Products</label>
1817
+ <frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
1818
+ <sort_order>80</sort_order>
1819
+ <show_in_default>1</show_in_default>
1820
+ <show_in_website>1</show_in_website>
1821
+ <show_in_store>0</show_in_store>
1822
+ </products_push_title>
1823
+ <products_chooser_button translate="label comment" module="connector">
1824
+ <frontend_model>email_connector/adminhtml_system_dynamic_manualchooser</frontend_model>
1825
+ <sort_order>85</sort_order>
1826
+ <show_in_default>1</show_in_default>
1827
+ <show_in_website>1</show_in_website>
1828
+ <show_in_store>0</show_in_store>
1829
+ <comment><![CDATA[Click To Open Product Chooser. After Choosing Products Save Config.]]></comment>
1830
+ </products_chooser_button>
1831
+ <products_push_items translate="label comment" module="connector">
1832
+ <label>Products</label>
1833
+ <frontend_type>text</frontend_type>
1834
+ <sort_order>90</sort_order>
1835
+ <show_in_default>1</show_in_default>
1836
+ <show_in_website>1</show_in_website>
1837
+ <show_in_store>0</show_in_store>
1838
+ <comment><![CDATA[Comma Separated Product Id's]]></comment>
1839
+ </products_push_items>
1840
+ <products_chooser_container translate="label comment" module="connector">
1841
+ <frontend_model>email_connector/adminhtml_system_dynamic_manualcontainer</frontend_model>
1842
+ <sort_order>95</sort_order>
1843
+ <show_in_default>1</show_in_default>
1844
+ <show_in_website>1</show_in_website>
1845
+ <show_in_store>0</show_in_store>
1846
+ </products_chooser_container>
1847
+ </fields>
1848
+ </manual_product_search>
1849
+ <fallback_products translate="label" module="connector">
1850
+ <label>Fallback Products</label>
1851
+ <frontend_type>text</frontend_type>
1852
+ <sort_order>40</sort_order>
1853
+ <show_in_default>1</show_in_default>
1854
+ <show_in_website>1</show_in_website>
1855
+ <show_in_store>0</show_in_store>
1856
+ <fields>
1857
+ <products_chooser_button translate="label comment" module="connector">
1858
+ <frontend_model>email_connector/adminhtml_system_dynamic_fallbackchooser</frontend_model>
1859
+ <sort_order>5</sort_order>
1860
+ <show_in_default>1</show_in_default>
1861
+ <show_in_website>1</show_in_website>
1862
+ <show_in_store>0</show_in_store>
1863
+ <comment><![CDATA[Click To Open Product Chooser. After Choosing Products Save Config.]]></comment>
1864
+ </products_chooser_button>
1865
+ <product_list translate="label comment" module="connector">
1866
+ <label>Products</label>
1867
+ <frontend_type>text</frontend_type>
1868
+ <sort_order>10</sort_order>
1869
+ <show_in_default>1</show_in_default>
1870
+ <show_in_website>1</show_in_website>
1871
+ <show_in_store>0</show_in_store>
1872
+ <comment><![CDATA[Comma Separated Product Id's]]></comment>
1873
+ </product_list>
1874
+ <products_chooser_container translate="label comment" module="connector">
1875
+ <frontend_model>email_connector/adminhtml_system_dynamic_fallbackcontainer</frontend_model>
1876
+ <sort_order>15</sort_order>
1877
+ <show_in_default>1</show_in_default>
1878
+ <show_in_website>1</show_in_website>
1879
+ <show_in_store>0</show_in_store>
1880
+ </products_chooser_container>
1881
+ </fields>
1882
+ </fallback_products>
1883
+ <nosto_recommendation translate="label" module="connector">
1884
+ <label>Nosto Recommendations</label>
1885
+ <sort_order>50</sort_order>
1886
+ <show_in_default>1</show_in_default>
1887
+ <show_in_website>1</show_in_website>
1888
+ <show_in_store>0</show_in_store>
1889
+ <fields>
1890
+ <api translate="label" module="connector">
1891
+ <label>API key</label>
1892
+ <sort_order>10</sort_order>
1893
+ <show_in_default>1</show_in_default>
1894
+ <show_in_website>1</show_in_website>
1895
+ <show_in_store>0</show_in_store>
1896
+ </api>
1897
+ <dynamic_url traslate="label" module="connector">
1898
+ <label>Recommendation URL</label>
1899
+ <frontend_type>label</frontend_type>
1900
+ <frontend_model>email_connector/adminhtml_system_dynamic_nosto</frontend_model>
1901
+ <sort_order>20</sort_order>
1902
+ <show_in_default>1</show_in_default>
1903
+ <show_in_website>1</show_in_website>
1904
+ <show_in_store>0</show_in_store>
1905
+ <comment><![CDATA[Replace @SLOT_NAME@ with the slot name created in your Nosto account.]]></comment>
1906
+ </dynamic_url>
1907
+ </fields>
1908
+ </nosto_recommendation>
1909
+ </groups>
1910
+ </connector_dynamic_content>
1911
+ <connector_transactional_emails translate="label" module="connector">
1912
+ <label>Transactional Emails</label>
1913
+ <tab>connector</tab>
1914
+ <frontend_type>text</frontend_type>
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
+ <sort_order>9000</sort_order>
1919
+ <groups>
1920
+ <credentials translate="label" module="connector">
1921
+ <label>API</label>
1922
+ <frontend_type>text</frontend_type>
1923
+ <sort_order>100</sort_order>
1924
+ <show_in_default>1</show_in_default>
1925
+ <show_in_website>1</show_in_website>
1926
+ <show_in_store>0</show_in_store>
1927
+ <expanded>1</expanded>
1928
+ <fields>
1929
+ <enabled translate="label" module="connector">
1930
+ <label>Enabled</label>
1931
+ <frontend_type>select</frontend_type>
1932
+ <source_model>adminhtml/system_config_source_yesno</source_model>
1933
+ <sort_order>10</sort_order>
1934
+ <show_in_default>1</show_in_default>
1935
+ <show_in_website>1</show_in_website>
1936
+ <show_in_store>0</show_in_store>
1937
+ </enabled>
1938
+ <api_username translate="label" module="connector">
1939
+ <label>API Username</label>
1940
+ <frontend_type>text</frontend_type>
1941
+ <frontend_model>email_connector/adminhtml_system_config_wrapper</frontend_model>
1942
+ <sort_order>10</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
+ <depends>
1947
+ <enabled>1</enabled>
1948
+ </depends>
1949
+ </api_username>
1950
+ <api_password translate="label" module="connector">
1951
+ <label>API Password</label>
1952
+ <frontend_type>password</frontend_type>
1953
+ <frontend_model>email_connector/adminhtml_system_emailapivalidate</frontend_model>
1954
+ <sort_order>20</sort_order>
1955
+ <show_in_default>1</show_in_default>
1956
+ <show_in_website>1</show_in_website>
1957
+ <show_in_store>0</show_in_store>
1958
+ <depends>
1959
+ <enabled>1</enabled>
1960
+ </depends>
1961
+ </api_password>
1962
+ <validator>
1963
+ <frontend_type>hidden</frontend_type>
1964
+ <frontend_model>email_connector/adminhtml_system_config_waitingfield</frontend_model>
1965
+ <sort_order>40</sort_order>
1966
+ <show_in_default>1</show_in_default>
1967
+ <show_in_website>1</show_in_website>
1968
+ <show_in_store>0</show_in_store>
1969
+ <can_be_empty>1</can_be_empty>
1970
+ </validator>
1971
+ </fields>
1972
+ </credentials>
1973
+ <email_settings translate="label" module="connector">
1974
+ <label>Email Settings</label>
1975
+ <frontend_type>text</frontend_type>
1976
+ <sort_order>200</sort_order>
1977
+ <show_in_default>1</show_in_default>
1978
+ <show_in_website>1</show_in_website>
1979
+ <show_in_store>1</show_in_store>
1980
+ <expanded>1</expanded>
1981
+ <fields>
1982
+ <from_address translate="label" module="connector">
1983
+ <label>From Address</label>
1984
+ <frontend_type>select</frontend_type>
1985
+ <source_model>email_connector/adminhtml_source_transactional_fromaddress</source_model>
1986
+ <sort_order>10</sort_order>
1987
+ <show_in_default>1</show_in_default>
1988
+ <show_in_website>1</show_in_website>
1989
+ <show_in_store>0</show_in_store>
1990
+ </from_address>
1991
+ <unsubscribe_link translate="label" module="connector">
1992
+ <label>Include Unsubscribe Link</label>
1993
+ <frontend_type>select</frontend_type>
1994
+ <source_model>adminhtml/system_config_source_yesno</source_model>
1995
+ <sort_order>20</sort_order>
1996
+ <show_in_default>1</show_in_default>
1997
+ <show_in_website>1</show_in_website>
1998
+ <show_in_store>0</show_in_store>
1999
+ </unsubscribe_link>
2000
+ <reply_action translate="label" module="connector">
2001
+ <label>Reply Action</label>
2002
+ <frontend_type>select</frontend_type>
2003
+ <source_model>email_connector/adminhtml_source_transactional_replyactions</source_model>
2004
+ <sort_order>30</sort_order>
2005
+ <show_in_default>1</show_in_default>
2006
+ <show_in_website>1</show_in_website>
2007
+ <show_in_store>0</show_in_store>
2008
+ </reply_action>
2009
+ <reply_address translate="label" module="connector">
2010
+ <label>Reply Address</label>
2011
+ <frontend_type>text</frontend_type>
2012
+ <sort_order>40</sort_order>
2013
+ <show_in_default>1</show_in_default>
2014
+ <show_in_website>1</show_in_website>
2015
+ <show_in_store>0</show_in_store>
2016
+ <depends><reply_action>WebMailForward</reply_action></depends>
2017
+ </reply_address>
2018
+ <send_copy translate="label" module="connector">
2019
+ <label>Send Copy</label>
2020
+ <frontend_type>text</frontend_type>
2021
+ <sort_order>50</sort_order>
2022
+ <show_in_default>1</show_in_default>
2023
+ <show_in_website>1</show_in_website>
2024
+ <show_in_store>0</show_in_store>
2025
+ </send_copy>
2026
+ </fields>
2027
+ </email_settings>
2028
+ <email_mapping translate="label" module="connector">
2029
+ <label>Email Mapping</label>
2030
+ <frontend_type>text</frontend_type>
2031
+ <sort_order>300</sort_order>
2032
+ <show_in_default>1</show_in_default>
2033
+ <show_in_website>1</show_in_website>
2034
+ <show_in_store>1</show_in_store>
2035
+ <expanded>1</expanded>
2036
+ <fields>
2037
+ <default_emails_title translate="label" module="connector">
2038
+ <label>Default Emails (All Modules)</label>
2039
+ <frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
2040
+ <sort_order>10</sort_order>
2041
+ <show_in_default>1</show_in_default>
2042
+ <show_in_website>1</show_in_website>
2043
+ <show_in_store>0</show_in_store>
2044
+ </default_emails_title>
2045
+ <default_email_templates translate="label" module="connector">
2046
+ <label>Templates</label>
2047
+ <frontend_model>email_connector/adminhtml_config_template_templatefields</frontend_model>
2048
+ <backend_model>adminhtml/system_config_backend_serialized_array</backend_model>
2049
+ <source_model>email_connector/adminhtml_source_transactional_defaultselect</source_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
+ </default_email_templates>
2055
+ <custom_emails_title translate="label" module="connector">
2056
+ <label>Custom Emails (Admin Transactional Emails)</label>
2057
+ <frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
2058
+ <sort_order>30</sort_order>
2059
+ <show_in_default>1</show_in_default>
2060
+ <show_in_website>1</show_in_website>
2061
+ <show_in_store>0</show_in_store>
2062
+ </custom_emails_title>
2063
+ <custom_email_templates translate="label" module="connector">
2064
+ <label>Templates</label>
2065
+ <frontend_model>email_connector/adminhtml_config_template_templatefields</frontend_model>
2066
+ <backend_model>adminhtml/system_config_backend_serialized_array</backend_model>
2067
+ <source_model>email_connector/adminhtml_source_transactional_customselect</source_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
+ </custom_email_templates>
2073
+ </fields>
2074
+ </email_mapping>
2075
+ </groups>
2076
+ </connector_transactional_emails>
2077
+ <connector_automation_studio translate="label" module="connector">
2078
+ <label>Automation</label>
2079
+ <tab>connector</tab>
2080
+ <frontend_type>text</frontend_type>
2081
+ <sort_order>4000</sort_order>
2082
+ <show_in_default>1</show_in_default>
2083
+ <show_in_website>1</show_in_website>
2084
+ <show_in_store>0</show_in_store>
2085
+ <groups>
2086
+ <automation translate="label" module="connector">
2087
+ <label>Automation</label>
2088
+ <frontend_type>text</frontend_type>
2089
+ <show_in_default>1</show_in_default>
2090
+ <show_in_website>1</show_in_website>
2091
+ <show_in_store>0</show_in_store>
2092
+ <expanded>1</expanded>
2093
+ <fields>
2094
+ <customer_automation translate="label" module="connector">
2095
+ <label>Customer Program</label>
2096
+ <frontend_type>select</frontend_type>
2097
+ <source_model>email_connector/adminhtml_source_automation_programme</source_model>
2098
+ <show_in_default>1</show_in_default>
2099
+ <show_in_website>1</show_in_website>
2100
+ <show_in_store>0</show_in_store>
2101
+ <sort_order>100</sort_order>
2102
+ </customer_automation>
2103
+ <subscriber_automation>
2104
+ <label>Subscriber Program</label>
2105
+ <frontend_type>select</frontend_type>
2106
+ <source_model>email_connector/adminhtml_source_automation_programme</source_model>
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
+ <sort_order>110</sort_order>
2111
+ </subscriber_automation>
2112
+ <order_automation>
2113
+ <label>Customer Order</label>
2114
+ <frontend_type>select</frontend_type>
2115
+ <source_model>email_connector/adminhtml_source_automation_programme</source_model>
2116
+ <show_in_default>1</show_in_default>
2117
+ <show_in_website>1</show_in_website>
2118
+ <show_in_store>0</show_in_store>
2119
+ <sort_order>120</sort_order>
2120
+ </order_automation>
2121
+ <guest_order_automation>
2122
+ <label>Guest Order</label>
2123
+ <frontend_type>select</frontend_type>
2124
+ <source_model>email_connector/adminhtml_source_automation_programme</source_model>
2125
+ <show_in_default>1</show_in_default>
2126
+ <show_in_website>1</show_in_website>
2127
+ <show_in_store>0</show_in_store>
2128
+ <sort_order>130</sort_order>
2129
+ </guest_order_automation>
2130
+ <review_automation>
2131
+ <label>Submitted Review</label>
2132
+ <frontend_type>select</frontend_type>
2133
+ <source_model>email_connector/adminhtml_source_automation_programme</source_model>
2134
+ <show_in_default>1</show_in_default>
2135
+ <show_in_website>1</show_in_website>
2136
+ <show_in_store>0</show_in_store>
2137
+ <sort_order>140</sort_order>
2138
+ </review_automation>
2139
+ <wishlist_automation>
2140
+ <label>Created Wishlist</label>
2141
+ <frontend_type>select</frontend_type>
2142
+ <source_model>email_connector/adminhtml_source_automation_programme</source_model>
2143
+ <show_in_default>1</show_in_default>
2144
+ <show_in_website>1</show_in_website>
2145
+ <show_in_store>0</show_in_store>
2146
+ <sort_order>150</sort_order>
2147
+ </wishlist_automation>
2148
+ </fields>
2149
+ </automation>
2150
+ </groups>
2151
+ </connector_automation_studio>
2152
+ <connector_configuration translate="label" module="connector">
2153
+ <label>Configuration</label>
2154
+ <tab>connector</tab>
2155
+ <sort_order>10000</sort_order>
2156
+ <show_in_default>1</show_in_default>
2157
+ <show_in_website>1</show_in_website>
2158
+ <show_in_store>0</show_in_store>
2159
+ <groups>
2160
+ <transactional_data translate="label" module="connector">
2161
+ <label>Transactional Data</label>
2162
+ <sort_order>1000</sort_order>
2163
+ <show_in_default>1</show_in_default>
2164
+ <show_in_website>1</show_in_website>
2165
+ <show_in_store>0</show_in_store>
2166
+ <fields>
2167
+ <order_statuses translate="label comment" module="connector">
2168
+ <label>Import With Status</label>
2169
+ <frontend_type>multiselect</frontend_type>
2170
+ <source_model>email_connector/adminhtml_source_orderstatus</source_model>
2171
+ <sort_order>10</sort_order>
2172
+ <show_in_default>1</show_in_default>
2173
+ <show_in_website>1</show_in_website>
2174
+ <show_in_store>0</show_in_store>
2175
+ <comment><![CDATA[Select multiple statuses by pressing Ctrl button while selecting]]></comment>
2176
+ </order_statuses>
2177
+ <order_custom_attributes>
2178
+ <label>Order Custom Attributes</label>
2179
+ <frontend_type>multiselect</frontend_type>
2180
+ <source_model>email_connector/adminhtml_source_advanced_attributes</source_model>
2181
+ <sort_order>20</sort_order>
2182
+ <show_in_default>1</show_in_default>
2183
+ <show_in_website>1</show_in_website>
2184
+ <show_in_store>0</show_in_store>
2185
+ <comment><![CDATA[Select custom order attributes that you want to import with your order data. Select multiple by pressing Ctrl button while selecting.]]></comment>
2186
+ </order_custom_attributes>
2187
+ </fields>
2188
+ </transactional_data>
2189
+ <abandoned_carts translate="label" module="connector">
2190
+ <label>Abandoned Carts</label>
2191
+ <sort_order>2000</sort_order>
2192
+ <show_in_default>1</show_in_default>
2193
+ <show_in_website>1</show_in_website>
2194
+ <show_in_store>0</show_in_store>
2195
+ <fields>
2196
+ <email_capture translate="label comment" module="connector">
2197
+ <label>Easy Email Capture</label>
2198
+ <frontend_type>select</frontend_type>
2199
+ <source_model>adminhtml/system_config_source_yesno</source_model>
2200
+ <sort_order>10</sort_order>
2201
+ <show_in_default>1</show_in_default>
2202
+ <show_in_website>1</show_in_website>
2203
+ <show_in_store>0</show_in_store>
2204
+ <comment><![CDATA[Enable this if you have a checkout process that allows the visitor to
2205
+ enter their email address during the checkout, but it does not update quote table instantly.]]></comment>
2206
+ </email_capture>
2207
+ <limits translate="label comment" module="connector">
2208
+ <label>Abandoned Cart Limit</label>
2209
+ <frontend_type>select</frontend_type>
2210
+ <source_model>email_connector/adminhtml_source_advanced_abandonedlimit</source_model>
2211
+ <sort_order>20</sort_order>
2212
+ <show_in_default>1</show_in_default>
2213
+ <show_in_website>1</show_in_website>
2214
+ <show_in_store>0</show_in_store>
2215
+ <comment><![CDATA[Do not send an abandoned cart email to a contact if they have received a previous abandoned cart email in previous x hours.]]></comment>
2216
+ </limits>
2217
+ </fields>
2218
+ </abandoned_carts>
2219
+ <admin translate="label comment" module="connector">
2220
+ <label>Admin</label>
2221
+ <sort_order>3000</sort_order>
2222
+ <show_in_default>1</show_in_default>
2223
+ <show_in_website>1</show_in_website>
2224
+ <show_in_store>0</show_in_store>
2225
+ <fields>
2226
+ <disable_newsletter_success translate="label" module="connector">
2227
+ <label>Disable Newsletter Success</label>
2228
+ <frontend_type>select</frontend_type>
2229
+ <source_model>adminhtml/system_config_source_yesno</source_model>
2230
+ <sort_order>10</sort_order>
2231
+ <show_in_default>1</show_in_default>
2232
+ <show_in_website>1</show_in_website>
2233
+ <show_in_store>0</show_in_store>
2234
+ </disable_newsletter_success>
2235
+ <disable_customer_success translate="label" module="connector">
2236
+ <label>Disable Customer Success</label>
2237
+ <frontend_type>select</frontend_type>
2238
+ <source_model>adminhtml/system_config_source_yesno</source_model>
2239
+ <sort_order>20</sort_order>
2240
+ <show_in_default>1</show_in_default>
2241
+ <show_in_website>1</show_in_website>
2242
+ <show_in_store>0</show_in_store>
2243
+ </disable_customer_success>
2244
+ <dynamic_syling translate="label" module="connector">
2245
+ <label>Dynamic Styling</label>
2246
+ <frontend_type>textarea</frontend_type>
2247
+ <sort_order>30</sort_order>
2248
+ <show_in_default>1</show_in_default>
2249
+ <show_in_website>1</show_in_website>
2250
+ <show_in_store>0</show_in_store>
2251
+ <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>
2252
+ </dynamic_syling>
2253
+ </fields>
2254
+ </admin>
2255
+ </groups>
2256
+ </connector_configuration>
2257
+ <connector_developer_settings translate="label" module="connector">
2258
+ <label><![CDATA[Developer]]></label>
2259
+ <tab>connector</tab>
2260
+ <frontend_type>text</frontend_type>
2261
+ <sort_order>20000</sort_order>
2262
+ <show_in_default>1</show_in_default>
2263
+ <show_in_website>1</show_in_website>
2264
+ <show_in_store>0</show_in_store>
2265
+ <groups>
2266
+ <import_settings translate="label" module="connector">
2267
+ <label>Import Settings</label>
2268
+ <sort_order>1000</sort_order>
2269
+ <show_in_default>1</show_in_default>
2270
+ <show_in_website>1</show_in_website>
2271
+ <show_in_store>0</show_in_store>
2272
+ <fields>
2273
+ <memory_limit translate="label comment" module="connector">
2274
+ <label>Sync Memory Limit</label>
2275
+ <frontend_type>select</frontend_type>
2276
+ <source_model>adminhtml/system_config_source_yesno</source_model>
2277
+ <sort_order>10</sort_order>
2278
+ <show_in_default>1</show_in_default>
2279
+ <show_in_website>0</show_in_website>
2280
+ <show_in_store>0</show_in_store>
2281
+ <comment>Set to NO to use system default memory.</comment>
2282
+ </memory_limit>
2283
+ <batch_size translate="label comment" module="connector">
2284
+ <label>Contact Sync Size</label>
2285
+ <frontend_type>text</frontend_type>
2286
+ <sort_order>20</sort_order>
2287
+ <show_in_default>1</show_in_default>
2288
+ <show_in_website>1</show_in_website>
2289
+ <show_in_store>0</show_in_store>
2290
+ </batch_size>
2291
+ <orders translate="label" module="connector">
2292
+ <label>Data Sync Size</label>
2293
+ <frontend_type>select</frontend_type>
2294
+ <source_model>email_connector/adminhtml_source_advanced_transdata</source_model>
2295
+ <sort_order>30</sort_order>
2296
+ <show_in_default>1</show_in_default>
2297
+ <show_in_website>1</show_in_website>
2298
+ <show_in_store>0</show_in_store>
2299
+ </orders>
2300
+ </fields>
2301
+ </import_settings>
2302
+ <abandoned_cart translate="label" module="connector">
2303
+ <label>Abandoned Carts</label>
2304
+ <sort_order>2000</sort_order>
2305
+ <show_in_default>1</show_in_default>
2306
+ <show_in_website>1</show_in_website>
2307
+ <show_in_store>0</show_in_store>
2308
+ <fields>
2309
+ <shell translate="label comment" module="connector">
2310
+ <label>Run Abandoned Carts From Shell.</label>
2311
+ <frontend_type>select</frontend_type>
2312
+ <source_model>adminhtml/system_config_source_yesno</source_model>
2313
+ <sort_order>20</sort_order>
2314
+ <show_in_default>1</show_in_default>
2315
+ <show_in_website>1</show_in_website>
2316
+ <show_in_store>0</show_in_store>
2317
+ <comment><![CDATA[Use the shell command to run the Abandoned baskets campaigns. Select YES to run separate cron like this :
2318
+ </br><div style="border: 1px solid #808080; padding: 5px">
2319
+ <span class="nobr">*/5 * * * * /usr/bin/php /magentoroot/shell/connector.php -action baskets -mode all</span>
2320
+ <span class="nobr">*/5 * * * * /usr/bin/php /magentoroot/shell/connector.php -action baskets -mode customers </span>
2321
+ <span class="nobr">*/5 * * * * /usr/bin/php /magentoroot/shell/connector.php -action baskets -mode guests</span>
2322
+ </div>
2323
+ ]]></comment>
2324
+ </shell>
2325
+ </fields>
2326
+ </abandoned_cart>
2327
+ <sync_settings tranlate="label" module="connector">
2328
+ <label>Sync Settings</label>
2329
+ <frontend_type>text</frontend_type>
2330
+ <sort_order>3000</sort_order>
2331
+ <show_in_default>1</show_in_default>
2332
+ <show_in_website>1</show_in_website>
2333
+ <show_in_store>0</show_in_store>
2334
+ <fields>
2335
+ <setup_data_fields translate="label comment" module="connector">
2336
+ <label>Automap Data Fields</label>
2337
+ <frontend_model>email_connector/adminhtml_system_advanced_setupdatafields</frontend_model>
2338
+ <sort_order>10</sort_order>
2339
+ <show_in_default>1</show_in_default>
2340
+ <show_in_website>1</show_in_website>
2341
+ <show_in_store>0</show_in_store>
2342
+ <comment><![CDATA[Create Datafields In Connector And Map Them. Including Customer, Address And Sales Information.]]></comment>
2343
+ </setup_data_fields>
2344
+ <contact_title translate="label" module="connector">
2345
+ <label>Manually Run Sync</label>
2346
+ <frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
2347
+ <sort_order>20</sort_order>
2348
+ <show_in_default>1</show_in_default>
2349
+ <show_in_website>1</show_in_website>
2350
+ <show_in_store>0</show_in_store>
2351
+ </contact_title>
2352
+ <contact_sync translate="label comment" module="connector">
2353
+ <label>Contact Sync</label>
2354
+ <frontend_model>email_connector/adminhtml_system_advanced_runcontactsync</frontend_model>
2355
+ <sort_order>30</sort_order>
2356
+ <show_in_default>1</show_in_default>
2357
+ <show_in_website>1</show_in_website>
2358
+ <show_in_store>0</show_in_store>
2359
+ <comment><![CDATA[Run the contact sync manually.]]></comment>
2360
+ </contact_sync>
2361
+ <subscriber_sync tranlate="label comment" module="connector">
2362
+ <label>Subscriber Sync</label>
2363
+ <frontend_model>email_connector/adminhtml_system_advanced_runsubscribersync</frontend_model>
2364
+ <sort_order>40</sort_order>
2365
+ <show_in_default>1</show_in_default>
2366
+ <show_in_website>1</show_in_website>
2367
+ <show_in_store>0</show_in_store>
2368
+ <comment><![CDATA[Run the subscriber sync manually.]]></comment>
2369
+ </subscriber_sync>
2370
+ <order_sync tranlate="label comment" module="connector">
2371
+ <label>Order Sync</label>
2372
+ <frontend_model>email_connector/adminhtml_system_advanced_runordersync</frontend_model>
2373
+ <sort_order>50</sort_order>
2374
+ <show_in_default>1</show_in_default>
2375
+ <show_in_website>1</show_in_website>
2376
+ <show_in_store>0</show_in_store>
2377
+ <comment><![CDATA[Run the order sync manually.]]></comment>
2378
+ </order_sync>
2379
+ <wishlist_sync tranlate="label comment" module="connector">
2380
+ <label>Wishlist Sync</label>
2381
+ <frontend_model>email_connector/adminhtml_system_advanced_runwishlistsync</frontend_model>
2382
+ <sort_order>53</sort_order>
2383
+ <show_in_default>1</show_in_default>
2384
+ <show_in_website>1</show_in_website>
2385
+ <show_in_store>0</show_in_store>
2386
+ <comment><![CDATA[Run the wishlist sync manually.]]></comment>
2387
+ </wishlist_sync>
2388
+ <review_sync tranlate="label comment" module="connector">
2389
+ <label>Review Sync</label>
2390
+ <frontend_model>email_connector/adminhtml_system_advanced_runreviewsync</frontend_model>
2391
+ <sort_order>56</sort_order>
2392
+ <show_in_default>1</show_in_default>
2393
+ <show_in_website>1</show_in_website>
2394
+ <show_in_store>0</show_in_store>
2395
+ <comment><![CDATA[Run the review sync manually.]]></comment>
2396
+ </review_sync>
2397
+ <actions_title translate="label" module="connector">
2398
+ <label>Reset Sync Options</label>
2399
+ <frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
2400
+ <sort_order>60</sort_order>
2401
+ <show_in_default>1</show_in_default>
2402
+ <show_in_website>1</show_in_website>
2403
+ <show_in_store>0</show_in_store>
2404
+ </actions_title>
2405
+ <delete_contact translate="label comment" module="connector">
2406
+ <label><![CDATA[Delete All Contact ID'S]]></label>
2407
+ <frontend_model>email_connector/adminhtml_system_advanced_deletecontactids</frontend_model>
2408
+ <sort_order>70</sort_order>
2409
+ <show_in_default>1</show_in_default>
2410
+ <show_in_website>1</show_in_website>
2411
+ <show_in_store>0</show_in_store>
2412
+ <comment><![CDATA[Remove the contact id's. When using different API username account from initial setup please click here to remove all.]]></comment>
2413
+ </delete_contact>
2414
+ <reimport_customers translate="label comment" module="connector" >
2415
+ <label>Refresh Customers</label>
2416
+ <frontend_model>email_connector/adminhtml_system_advanced_resetcustomersimport</frontend_model>
2417
+ <sort_order>80</sort_order>
2418
+ <show_in_default>1</show_in_default>
2419
+ <show_in_website>1</show_in_website>
2420
+ <show_in_store>0</show_in_store>
2421
+ <comment><![CDATA[Mark all customers to be imported.]]></comment>
2422
+ </reimport_customers>
2423
+ <reimport_subscribers module="connector" translate="label comment">
2424
+ <label>Refresh Subscribers</label>
2425
+ <frontend_model>email_connector/adminhtml_system_advanced_reimportsubscribers</frontend_model>
2426
+ <sort_order>90</sort_order>
2427
+ <show_in_default>1</show_in_default>
2428
+ <show_in_website>1</show_in_website>
2429
+ <show_in_store>0</show_in_store>
2430
+ <comment><![CDATA[Mark all subscribers to be imported.]]></comment>
2431
+ </reimport_subscribers>
2432
+ <reimport_orders module="connector" translate="label comment">
2433
+ <label>Refresh Orders Data</label>
2434
+ <frontend_model>email_connector/adminhtml_system_advanced_reimportorders</frontend_model>
2435
+ <sort_order>100</sort_order>
2436
+ <show_in_default>1</show_in_default>
2437
+ <show_in_website>1</show_in_website>
2438
+ <show_in_store>0</show_in_store>
2439
+ <comment><![CDATA[Mark all order data to be imported.]]></comment>
2440
+ </reimport_orders>
2441
+ <suppressed_contacts module="connector" translate="label comment">
2442
+ <label>Refresh Supressions</label>
2443
+ <frontend_model>email_connector/adminhtml_system_advanced_suppressedcontacts</frontend_model>
2444
+ <sort_order>110</sort_order>
2445
+ <show_in_default>1</show_in_default>
2446
+ <show_in_website>1</show_in_website>
2447
+ <show_in_store>0</show_in_store>
2448
+ <comment>Refresh Historically Suppressed contacts for 10years period.</comment>
2449
+ </suppressed_contacts>
2450
+ </fields>
2451
+ </sync_settings>
2452
+ <debug translate="label" module="connector">
2453
+ <label>Debug</label>
2454
+ <sort_order>4000</sort_order>
2455
+ <show_in_default>1</show_in_default>
2456
+ <show_in_website>1</show_in_website>
2457
+ <show_in_store>0</show_in_store>
2458
+ <fields>
2459
+ <debug_enabled translate="label comment" module="connector">
2460
+ <label>Debug Mode</label>
2461
+ <frontend_type>select</frontend_type>
2462
+ <source_model>adminhtml/system_config_source_yesno</source_model>
2463
+ <sort_order>10</sort_order>
2464
+ <show_in_default>1</show_in_default>
2465
+ <show_in_website>1</show_in_website>
2466
+ <show_in_store>0</show_in_store>
2467
+ <comment>Log sync info into this file connector_api.log.</comment>
2468
+ </debug_enabled>
2469
+ <debug_api_calls translate="label comment" module="connector">
2470
+ <label>Debug All API Calls</label>
2471
+ <frontend_type>select</frontend_type>
2472
+ <source_model>adminhtml/system_config_source_yesno</source_model>
2473
+ <sort_order>20</sort_order>
2474
+ <show_in_default>1</show_in_default>
2475
+ <show_in_website>1</show_in_website>
2476
+ <show_in_store>0</show_in_store>
2477
+ <comment>Log all API calls into the connector_api.log file, debug mode must be enabled.</comment>
2478
+ <depends><debug_enabled>1</debug_enabled></depends>
2479
+ </debug_api_calls>
2480
+ <raygun_code translate="label" module="connector">
2481
+ <label>Raygun Application Code</label>
2482
+ <frontend_type>text</frontend_type>
2483
+ <sort_order>30</sort_order>
2484
+ <show_in_default>1</show_in_default>
2485
+ <show_in_website>1</show_in_website>
2486
+ <show_in_store>0</show_in_store>
2487
+ </raygun_code>
2488
+ </fields>
2489
+ </debug>
2490
+ <feed_configuration translate="label" module="connector">
2491
+ <label>Feed Configuration</label>
2492
+ <sort_order>5000</sort_order>
2493
+ <show_in_default>1</show_in_default>
2494
+ <show_in_website>1</show_in_website>
2495
+ <show_in_store>0</show_in_store>
2496
+ <fields>
2497
+ <feed_enabled translate="label" module="connector">
2498
+ <label>Enabled</label>
2499
+ <source_model>adminhtml/system_config_source_yesno</source_model>
2500
+ <frontend_type>select</frontend_type>
2501
+ <sort_order>20</sort_order>
2502
+ <show_in_default>1</show_in_default>
2503
+ <show_in_website>1</show_in_website>
2504
+ <show_in_store>0</show_in_store>
2505
+ </feed_enabled>
2506
+ <feed_url translate="label" module="connector">
2507
+ <label>Feed Url</label>
2508
+ <frontend_type>text</frontend_type>
2509
+ <sort_order>30</sort_order>
2510
+ <show_in_default>1</show_in_default>
2511
+ <show_in_website>1</show_in_website>
2512
+ <show_in_store>0</show_in_store>
2513
+ <depends><feed_enabled>1</feed_enabled></depends>
2514
+ </feed_url>
2515
+ <use_https translate="label" module="connector">
2516
+ <label>Use HTTPS to Get Feed</label>
2517
+ <frontend_type>select</frontend_type>
2518
+ <source_model>adminhtml/system_config_source_yesno</source_model>
2519
+ <sort_order>40</sort_order>
2520
+ <show_in_default>1</show_in_default>
2521
+ <show_in_website>1</show_in_website>
2522
+ <show_in_store>0</show_in_store>
2523
+ <depends><feed_enabled>1</feed_enabled></depends>
2524
+ </use_https>
2525
+ <frequency translate="label" module="connector">
2526
+ <label>Update Frequency</label>
2527
+ <frontend_type>select</frontend_type>
2528
+ <source_model>email_connector/adminhtml_source_advanced_frequency</source_model>
2529
+ <sort_order>50</sort_order>
2530
+ <show_in_default>1</show_in_default>
2531
+ <show_in_website>1</show_in_website>
2532
+ <show_in_store>0</show_in_store>
2533
+ <depends><feed_enabled>1</feed_enabled></depends>
2534
+ </frequency>
2535
+ <last_update translate="label">
2536
+ <label>Last Update</label>
2537
+ <frontend_type>label</frontend_type>
2538
+ <frontend_model>email_connector/adminhtml_system_advanced_notification</frontend_model>
2539
+ <sort_order>60</sort_order>
2540
+ <show_in_default>1</show_in_default>
2541
+ <show_in_website>1</show_in_website>
2542
+ <show_in_store>0</show_in_store>
2543
+ <depends><feed_enabled>1</feed_enabled></depends>
2544
+ </last_update>
2545
+ </fields>
2546
+ </feed_configuration>
2547
+ </groups>
2548
+ </connector_developer_settings>
2549
+ </sections>
2550
+ </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/community/Dotdigitalgroup/Email/sql/email_connector_setup/mysql4-upgrade-3.1.2-3.1.3.php ADDED
@@ -0,0 +1,123 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /** @var Mage_Eav_Model_Entity_Setup $installer */
4
+
5
+ $installer = $this;
6
+ $installer->startSetup();
7
+
8
+ //drop table
9
+ $createTable = $installer->getTable('email_create');
10
+ if ($installer->getConnection()->isTableExists($createTable)) {
11
+ $installer->getConnection()->dropTable($createTable);
12
+ }
13
+
14
+ //add columns to table
15
+ $campaignTable = $installer->getTable('email_connector/campaign');
16
+ $installer->getConnection()->addColumn($campaignTable, 'subject', array(
17
+ 'type' => Varien_Db_Ddl_Table::TYPE_TEXT,
18
+ 'unsigned' => true,
19
+ 'nullable' => false,
20
+ 'default' => '',
21
+ 'comment' => 'Email Subject'
22
+ ));
23
+ $installer->getConnection()->addColumn($campaignTable, 'html_content', array(
24
+ 'type' => Varien_Db_Ddl_Table::TYPE_TEXT,
25
+ 'unsigned' => true,
26
+ 'nullable' => false,
27
+ 'default' => '',
28
+ 'comment' => 'Email Html Content'
29
+ ));
30
+ $installer->getConnection()->addColumn($campaignTable, 'plain_text_content', array(
31
+ 'type' => Varien_Db_Ddl_Table::TYPE_TEXT,
32
+ 'unsigned' => true,
33
+ 'nullable' => false,
34
+ 'default' => '',
35
+ 'comment' => 'Email Plain Text Content'
36
+ ));
37
+ $installer->getConnection()->addColumn($campaignTable, 'from_name', array(
38
+ 'type' => Varien_Db_Ddl_Table::TYPE_TEXT,
39
+ 'unsigned' => true,
40
+ 'nullable' => false,
41
+ 'default' => '',
42
+ 'comment' => 'Email From Name'
43
+ ));
44
+ $installer->getConnection()->addColumn($campaignTable, 'create_message', array(
45
+ 'type' => Varien_Db_Ddl_Table::TYPE_TEXT,
46
+ 'unsigned' => true,
47
+ 'nullable' => false,
48
+ 'default' => '',
49
+ 'comment' => 'Create Campaign Message'
50
+ ));
51
+ $installer->getConnection()->addColumn($campaignTable, 'contact_message', array(
52
+ 'type' => Varien_Db_Ddl_Table::TYPE_TEXT,
53
+ 'unsigned' => true,
54
+ 'nullable' => false,
55
+ 'default' => '',
56
+ 'comment' => 'Contact Message'
57
+ ));
58
+ $installer->getConnection()->addColumn($campaignTable, 'is_created', array(
59
+ 'type' => Varien_Db_Ddl_Table::TYPE_SMALLINT,
60
+ 'unsigned' => true,
61
+ 'nullable' => true,
62
+ 'comment' => 'Is Campaign Created'
63
+ ));
64
+ $installer->getConnection()->addColumn($campaignTable, 'is_copy', array(
65
+ 'type' => Varien_Db_Ddl_Table::TYPE_SMALLINT,
66
+ 'unsigned' => true,
67
+ 'nullable' => true,
68
+ 'comment' => 'Is Copy'
69
+ ));
70
+ $installer->getConnection()->addColumn($campaignTable, 'type', array(
71
+ 'type' => Varien_Db_Ddl_Table::TYPE_SMALLINT,
72
+ 'unsigned' => true,
73
+ 'nullable' => false,
74
+ 'default' => '1',
75
+ 'comment' => 'Type. 1: Campaign, 2: Create'
76
+ ));
77
+ $installer->getConnection()->addColumn($campaignTable, 'website_id', array(
78
+ 'type' => Varien_Db_Ddl_Table::TYPE_INTEGER,
79
+ 'unsigned' => true,
80
+ 'nullable' => false,
81
+ 'default' => '0',
82
+ 'comment' => 'Website Id'
83
+ ));
84
+
85
+
86
+ /**
87
+ * create Config table.
88
+ */
89
+ $configTable = $installer->getTable('email_connector/config');
90
+
91
+ if ($installer->getConnection()->isTableExists($configTable)) {
92
+ $installer->getConnection()->dropTable($configTable);
93
+ }
94
+
95
+ $table = $installer->getConnection()->newTable($configTable);
96
+ $table->addColumn('email_config_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
97
+ 'primary' => true,
98
+ 'identity' => true,
99
+ 'unsigned' => true,
100
+ 'nullable' => false
101
+ ), 'Primary Key')
102
+ ->addColumn('path', Varien_Db_Ddl_Table::TYPE_VARCHAR, 255, array(
103
+ 'nullable' => true,
104
+ ), 'Config Path')
105
+ ->addColumn('scope', Varien_Db_Ddl_Table::TYPE_VARCHAR, 255, array(
106
+ 'nullable' => true,
107
+ ), 'Config Scope')
108
+ ->addColumn('value', Varien_Db_Ddl_Table::TYPE_TEXT, 255, array(
109
+ 'nullable' => false,
110
+ 'default' => ''
111
+ ), 'Config Value')
112
+ ->addColumn('is_api', Varien_Db_Ddl_Table::TYPE_SMALLINT, null, array(
113
+ 'unsigned' => true,
114
+ 'nullable' => true,
115
+ ), 'Only For Api Calls')
116
+ ->addColumn('created_at', Varien_Db_Ddl_Table::TYPE_TIMESTAMP, null, array(
117
+ ), 'Creation Time')
118
+ ->addColumn('updated_at', Varien_Db_Ddl_Table::TYPE_TIMESTAMP, null, array(
119
+ ), 'Update Time')
120
+ ->setComment('Connector Config Data');
121
+ $installer->getConnection()->createTable($table);
122
+
123
+ $installer->endSetup();
app/code/community/Dotdigitalgroup/Email/sql/email_connector_setup/mysql4-upgrade-3.2.1-3.3.0.php ADDED
@@ -0,0 +1,151 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /** @var Mage_Eav_Model_Entity_Setup $installer */
4
+
5
+ $installer = $this;
6
+ $installer->startSetup();
7
+
8
+ /**
9
+ * create review table
10
+ */
11
+ $reviewTable = $installer->getTable('email_connector/review');
12
+
13
+ //drop table if exist
14
+ if ($installer->getConnection()->isTableExists($reviewTable)) {
15
+ $installer->getConnection()->dropTable($reviewTable);
16
+ }
17
+
18
+ $table = $installer->getConnection()->newTable($reviewTable);
19
+ $table->addColumn('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('review_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
26
+ 'unsigned' => true,
27
+ 'nullable' => false,
28
+ ), 'Review Id')
29
+ ->addColumn('customer_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
30
+ 'unsigned' => true,
31
+ 'nullable' => false,
32
+ ), 'Customer ID')
33
+ ->addColumn('store_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
34
+ 'unsigned' => true,
35
+ 'nullable' => false,
36
+ ), 'Store Id')
37
+ ->addColumn('review_imported', Varien_Db_Ddl_Table::TYPE_SMALLINT, null, array(
38
+ 'unsigned' => true,
39
+ 'nullable' => true,
40
+ ), 'Review Imported')
41
+ ->addColumn('created_at', Varien_Db_Ddl_Table::TYPE_TIMESTAMP, null, array(
42
+ ), 'Creation Time')
43
+ ->addColumn('updated_at', Varien_Db_Ddl_Table::TYPE_TIMESTAMP, null, array(
44
+ ), 'Update Time')
45
+ ->setComment('Connector Reviews');
46
+ $installer->getConnection()->createTable($table);
47
+
48
+ //populate review table
49
+ $inCond = $installer->getConnection()->prepareSqlCondition('review_detail.customer_id', array('notnull' => true));
50
+ $select = $installer->getConnection()->select()
51
+ ->from(
52
+ array('review' => $this->getTable('review/review')),
53
+ array('review_id' => 'review.review_id','created_at' => 'review.created_at')
54
+ )
55
+ ->joinLeft(
56
+ array('review_detail' => $installer->getTable('review/review_detail')),
57
+ "review_detail.review_id = review.review_id",
58
+ array('store_id' => 'review_detail.store_id', 'customer_id' => 'review_detail.customer_id')
59
+ )
60
+ ->where($inCond);
61
+
62
+ $insertArray = array('review_id', 'created_at' ,'store_id', 'customer_id');
63
+ $sqlQuery = $select->insertFromSelect($reviewTable, $insertArray, false);
64
+ $installer->getConnection()->query($sqlQuery);
65
+
66
+ //add columns to table
67
+ $campaignTable = $installer->getTable('email_connector/campaign');
68
+
69
+ $installer->getConnection()->addColumn($campaignTable, 'from_address', array(
70
+ 'type' => Varien_Db_Ddl_Table::TYPE_TEXT,
71
+ 'unsigned' => true,
72
+ 'nullable' => true,
73
+ 'default' => null,
74
+ 'comment' => 'Email From Address'
75
+ ));
76
+ $installer->getConnection()->addColumn($campaignTable, 'attachment_id', array(
77
+ 'type' => Varien_Db_Ddl_Table::TYPE_INTEGER,
78
+ 'unsigned' => true,
79
+ 'nullable' => true,
80
+ 'default' => null,
81
+ 'comment' => 'Attachment Id'
82
+ ));
83
+
84
+ /**
85
+ * create wishlist table
86
+ */
87
+ $wishlistTable = $installer->getTable('email_connector/wishlist');
88
+
89
+ //drop table if exist
90
+ if ($installer->getConnection()->isTableExists($wishlistTable)) {
91
+ $installer->getConnection()->dropTable($wishlistTable);
92
+ }
93
+
94
+ $table = $installer->getConnection()->newTable($wishlistTable);
95
+ $table->addColumn('id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
96
+ 'primary' => true,
97
+ 'identity' => true,
98
+ 'unsigned' => true,
99
+ 'nullable' => false
100
+ ), 'Primary Key')
101
+ ->addColumn('wishlist_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
102
+ 'unsigned' => true,
103
+ 'nullable' => false,
104
+ ), 'Wishlist Id')
105
+ ->addColumn('item_count', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
106
+ 'unsigned' => true,
107
+ 'nullable' => false,
108
+ ), 'Item Count')
109
+ ->addColumn('customer_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
110
+ 'unsigned' => true,
111
+ 'nullable' => false,
112
+ ), 'Customer ID')
113
+ ->addColumn('store_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
114
+ 'unsigned' => true,
115
+ 'nullable' => false,
116
+ ), 'Store Id')
117
+ ->addColumn('wishlist_imported', Varien_Db_Ddl_Table::TYPE_SMALLINT, null, array(
118
+ 'unsigned' => true,
119
+ 'nullable' => true,
120
+ ), 'Wishlist Imported')
121
+ ->addColumn('wishlist_modified', Varien_Db_Ddl_Table::TYPE_SMALLINT, null, array(
122
+ 'unsigned' => true,
123
+ 'nullable' => true,
124
+ ), 'Wishlist Modified')
125
+ ->addColumn('created_at', Varien_Db_Ddl_Table::TYPE_TIMESTAMP, null, array(
126
+ ), 'Creation Time')
127
+ ->addColumn('updated_at', Varien_Db_Ddl_Table::TYPE_TIMESTAMP, null, array(
128
+ ), 'Update Time')
129
+ ->setComment('Connector Wishlist');
130
+ $installer->getConnection()->createTable($table);
131
+
132
+ //wishlist populate
133
+ $select = $installer->getConnection()->select()
134
+ ->from(
135
+ array('wishlist' => $installer->getTable('wishlist/wishlist')),
136
+ array('wishlist_id', 'customer_id', 'created_at' => 'updated_at')
137
+ )->joinLeft(
138
+ array('ce' => $installer->getTable('customer_entity')),
139
+ "wishlist.customer_id = ce.entity_id",
140
+ array('store_id')
141
+ )->joinInner(
142
+ array('wi' => $installer->getTable('wishlist_item')),
143
+ "wishlist.wishlist_id = wi.wishlist_id",
144
+ array('item_count' => 'count(wi.wishlist_id)')
145
+ )->group('wi.wishlist_id');
146
+
147
+ $insertArray = array('wishlist_id' ,'customer_id','created_at', 'store_id', 'item_count');
148
+ $sqlQuery = $select->insertFromSelect($wishlistTable, $insertArray, false);
149
+ $installer->getConnection()->query($sqlQuery);
150
+
151
+ $installer->endSetup();
app/code/community/Dotdigitalgroup/Email/sql/email_connector_setup/mysql4-upgrade-3.3.0-3.3.1.php ADDED
@@ -0,0 +1,151 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /** @var Mage_Eav_Model_Entity_Setup $installer */
4
+
5
+ $installer = $this;
6
+ $installer->startSetup();
7
+
8
+ /**
9
+ * create review table
10
+ */
11
+ $reviewTable = $installer->getTable('email_connector/review');
12
+
13
+ //drop table if exist
14
+ if ($installer->getConnection()->isTableExists($reviewTable)) {
15
+ $installer->getConnection()->dropTable($reviewTable);
16
+ }
17
+
18
+ $table = $installer->getConnection()->newTable($reviewTable);
19
+ $table->addColumn('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('review_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
26
+ 'unsigned' => true,
27
+ 'nullable' => false,
28
+ ), 'Review Id')
29
+ ->addColumn('customer_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
30
+ 'unsigned' => true,
31
+ 'nullable' => false,
32
+ ), 'Customer ID')
33
+ ->addColumn('store_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
34
+ 'unsigned' => true,
35
+ 'nullable' => false,
36
+ ), 'Store Id')
37
+ ->addColumn('review_imported', Varien_Db_Ddl_Table::TYPE_SMALLINT, null, array(
38
+ 'unsigned' => true,
39
+ 'nullable' => true,
40
+ ), 'Review Imported')
41
+ ->addColumn('created_at', Varien_Db_Ddl_Table::TYPE_TIMESTAMP, null, array(
42
+ ), 'Creation Time')
43
+ ->addColumn('updated_at', Varien_Db_Ddl_Table::TYPE_TIMESTAMP, null, array(
44
+ ), 'Update Time')
45
+ ->setComment('Connector Reviews');
46
+ $installer->getConnection()->createTable($table);
47
+
48
+ //populate review table
49
+ $inCond = $installer->getConnection()->prepareSqlCondition('review_detail.customer_id', array('notnull' => true));
50
+ $select = $installer->getConnection()->select()
51
+ ->from(
52
+ array('review' => $this->getTable('review/review')),
53
+ array('review_id' => 'review.review_id','created_at' => 'review.created_at')
54
+ )
55
+ ->joinLeft(
56
+ array('review_detail' => $installer->getTable('review/review_detail')),
57
+ "review_detail.review_id = review.review_id",
58
+ array('store_id' => 'review_detail.store_id', 'customer_id' => 'review_detail.customer_id')
59
+ )
60
+ ->where($inCond);
61
+
62
+ $insertArray = array('review_id', 'created_at' ,'store_id', 'customer_id');
63
+ $sqlQuery = $select->insertFromSelect($reviewTable, $insertArray, false);
64
+ $installer->getConnection()->query($sqlQuery);
65
+
66
+ //add columns to table
67
+ $campaignTable = $installer->getTable('email_connector/campaign');
68
+
69
+ $installer->getConnection()->addColumn($campaignTable, 'from_address', array(
70
+ 'type' => Varien_Db_Ddl_Table::TYPE_TEXT,
71
+ 'unsigned' => true,
72
+ 'nullable' => true,
73
+ 'default' => null,
74
+ 'comment' => 'Email From Address'
75
+ ));
76
+ $installer->getConnection()->addColumn($campaignTable, 'attachment_id', array(
77
+ 'type' => Varien_Db_Ddl_Table::TYPE_INTEGER,
78
+ 'unsigned' => true,
79
+ 'nullable' => true,
80
+ 'default' => null,
81
+ 'comment' => 'Attachment Id'
82
+ ));
83
+
84
+ /**
85
+ * create wishlist table
86
+ */
87
+ $wishlistTable = $installer->getTable('email_connector/wishlist');
88
+
89
+ //drop table if exist
90
+ if ($installer->getConnection()->isTableExists($wishlistTable)) {
91
+ $installer->getConnection()->dropTable($wishlistTable);
92
+ }
93
+
94
+ $table = $installer->getConnection()->newTable($wishlistTable);
95
+ $table->addColumn('id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
96
+ 'primary' => true,
97
+ 'identity' => true,
98
+ 'unsigned' => true,
99
+ 'nullable' => false
100
+ ), 'Primary Key')
101
+ ->addColumn('wishlist_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
102
+ 'unsigned' => true,
103
+ 'nullable' => false,
104
+ ), 'Wishlist Id')
105
+ ->addColumn('item_count', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
106
+ 'unsigned' => true,
107
+ 'nullable' => false,
108
+ ), 'Item Count')
109
+ ->addColumn('customer_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
110
+ 'unsigned' => true,
111
+ 'nullable' => false,
112
+ ), 'Customer ID')
113
+ ->addColumn('store_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
114
+ 'unsigned' => true,
115
+ 'nullable' => false,
116
+ ), 'Store Id')
117
+ ->addColumn('wishlist_imported', Varien_Db_Ddl_Table::TYPE_SMALLINT, null, array(
118
+ 'unsigned' => true,
119
+ 'nullable' => true,
120
+ ), 'Wishlist Imported')
121
+ ->addColumn('wishlist_modified', Varien_Db_Ddl_Table::TYPE_SMALLINT, null, array(
122
+ 'unsigned' => true,
123
+ 'nullable' => true,
124
+ ), 'Wishlist Modified')
125
+ ->addColumn('created_at', Varien_Db_Ddl_Table::TYPE_TIMESTAMP, null, array(
126
+ ), 'Creation Time')
127
+ ->addColumn('updated_at', Varien_Db_Ddl_Table::TYPE_TIMESTAMP, null, array(
128
+ ), 'Update Time')
129
+ ->setComment('Connector Wishlist');
130
+ $installer->getConnection()->createTable($table);
131
+
132
+ //wishlist populate
133
+ $select = $installer->getConnection()->select()
134
+ ->from(
135
+ array('wishlist' => $installer->getTable('wishlist/wishlist')),
136
+ array('wishlist_id', 'customer_id', 'created_at' => 'updated_at')
137
+ )->joinLeft(
138
+ array('ce' => $installer->getTable('customer_entity')),
139
+ "wishlist.customer_id = ce.entity_id",
140
+ array('store_id')
141
+ )->joinInner(
142
+ array('wi' => $installer->getTable('wishlist_item')),
143
+ "wishlist.wishlist_id = wi.wishlist_id",
144
+ array('item_count' => 'count(wi.wishlist_id)')
145
+ )->group('wi.wishlist_id');
146
+
147
+ $insertArray = array('wishlist_id' ,'customer_id','created_at', 'store_id', 'item_count');
148
+ $sqlQuery = $select->insertFromSelect($wishlistTable, $insertArray, false);
149
+ $installer->getConnection()->query($sqlQuery);
150
+
151
+ $installer->endSetup();
app/code/community/Dotdigitalgroup/Mailcheck/Helper/Data.php ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Dotdigitalgroup_Mailcheck_Helper_Data extends Mage_Core_Helper_Abstract
4
+ {
5
+
6
+ }
app/code/community/Dotdigitalgroup/Mailcheck/etc/config.xml ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Dotdigitalgroup_Mailcheck>
5
+ <version>1.0.0</version>
6
+ </Dotdigitalgroup_Mailcheck>
7
+ </modules>
8
+ <global>
9
+ <helpers>
10
+ <connector_mailcheck>
11
+ <class>Dotdigitalgroup_Mailcheck_Helper</class>
12
+ </connector_mailcheck>
13
+ </helpers>
14
+ </global>
15
+ <frontend>
16
+ <layout>
17
+ <updates>
18
+ <connector_mailcheck>
19
+ <file>mailcheck.xml</file>
20
+ </connector_mailcheck>
21
+ </updates>
22
+ </layout>
23
+ </frontend>
24
+ <default>
25
+ <connector_advanced_settings>
26
+ <mailcheck>
27
+ <enabled>0</enabled>
28
+ </mailcheck>
29
+ </connector_advanced_settings>
30
+ </default>
31
+ </config>
app/code/community/Dotdigitalgroup/Mailcheck/etc/jstranslator.xml ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
1
+ <jstranslator>
2
+ <mailcheck_suggestion translate="message" module="connector_mailcheck">
3
+ <message>Did you mean</message>
4
+ </mailcheck_suggestion>
5
+ </jstranslator>
app/code/community/Dotdigitalgroup/Mailcheck/etc/system.xml ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <config>
3
+ <sections>
4
+ <connector_configuration translate="label" module="connector">
5
+ <groups>
6
+ <mailcheck translate="label" module="connector">
7
+ <label>MailCheck Settings</label>
8
+ <frontend_type>text</frontend_type>
9
+ <sort_order>9999</sort_order>
10
+ <show_in_default>1</show_in_default>
11
+ <show_in_website>1</show_in_website>
12
+ <show_in_store>0</show_in_store>
13
+ <fields>
14
+ <enabled translate="label">
15
+ <label>Enabled</label>
16
+ <frontend_type>select</frontend_type>
17
+ <source_model>adminhtml/system_config_source_yesno</source_model>
18
+ <sort_order>1</sort_order>
19
+ <show_in_default>1</show_in_default>
20
+ <show_in_website>1</show_in_website>
21
+ <show_in_store>1</show_in_store>
22
+ </enabled>
23
+ </fields>
24
+ </mailcheck>
25
+ </groups>
26
+ </connector_configuration>
27
+ </sections>
28
+ </config>
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 → Bloc} RENAMED
File without changes