Listrak_Remarketing - Version 1.0.3

Version Notes

Stable build

Download this release

Release Info

Developer Listrak
Extension Listrak_Remarketing
Version 1.0.3
Comparing to
See all releases


Version 1.0.3

Files changed (59) hide show
  1. app/code/community/Listrak/Remarketing/Block/Adminhtml/Abandonedcartreport.php +15 -0
  2. app/code/community/Listrak/Remarketing/Block/Adminhtml/Abandonedcartreport/Grid.php +111 -0
  3. app/code/community/Listrak/Remarketing/Block/Adminhtml/Emailcapture.php +15 -0
  4. app/code/community/Listrak/Remarketing/Block/Adminhtml/Emailcapture/Edit.php +27 -0
  5. app/code/community/Listrak/Remarketing/Block/Adminhtml/Emailcapture/Edit/Form.php +20 -0
  6. app/code/community/Listrak/Remarketing/Block/Adminhtml/Emailcapture/Edit/Tab/Form.php +38 -0
  7. app/code/community/Listrak/Remarketing/Block/Adminhtml/Emailcapture/Edit/Tabs.php +26 -0
  8. app/code/community/Listrak/Remarketing/Block/Adminhtml/Emailcapture/Grid.php +53 -0
  9. app/code/community/Listrak/Remarketing/Block/Adminhtml/Notifications.php +20 -0
  10. app/code/community/Listrak/Remarketing/Block/Ecjs.php +122 -0
  11. app/code/community/Listrak/Remarketing/Helper/Data.php +33 -0
  12. app/code/community/Listrak/Remarketing/Model/Abandonedcart.php +40 -0
  13. app/code/community/Listrak/Remarketing/Model/Abandonedcart/Api.php +50 -0
  14. app/code/community/Listrak/Remarketing/Model/Abandonedcart/Api/V2.php +8 -0
  15. app/code/community/Listrak/Remarketing/Model/Apiextension.php +12 -0
  16. app/code/community/Listrak/Remarketing/Model/Apiextension/Api.php +185 -0
  17. app/code/community/Listrak/Remarketing/Model/Apiextension/Api/V2.php +8 -0
  18. app/code/community/Listrak/Remarketing/Model/Click.php +31 -0
  19. app/code/community/Listrak/Remarketing/Model/Click/Api.php +49 -0
  20. app/code/community/Listrak/Remarketing/Model/Click/Api/V2.php +8 -0
  21. app/code/community/Listrak/Remarketing/Model/Emailcapture.php +12 -0
  22. app/code/community/Listrak/Remarketing/Model/Log.php +35 -0
  23. app/code/community/Listrak/Remarketing/Model/Log/Api.php +52 -0
  24. app/code/community/Listrak/Remarketing/Model/Log/Api/V2.php +8 -0
  25. app/code/community/Listrak/Remarketing/Model/Mysql4/Abandonedcart.php +57 -0
  26. app/code/community/Listrak/Remarketing/Model/Mysql4/Abandonedcart/Collection.php +44 -0
  27. app/code/community/Listrak/Remarketing/Model/Mysql4/Apiextension.php +54 -0
  28. app/code/community/Listrak/Remarketing/Model/Mysql4/Click.php +64 -0
  29. app/code/community/Listrak/Remarketing/Model/Mysql4/Click/Collection.php +20 -0
  30. app/code/community/Listrak/Remarketing/Model/Mysql4/Emailcapture.php +17 -0
  31. app/code/community/Listrak/Remarketing/Model/Mysql4/Emailcapture/Collection.php +11 -0
  32. app/code/community/Listrak/Remarketing/Model/Mysql4/Log.php +17 -0
  33. app/code/community/Listrak/Remarketing/Model/Mysql4/Log/Collection.php +17 -0
  34. app/code/community/Listrak/Remarketing/Model/Mysql4/Session.php +94 -0
  35. app/code/community/Listrak/Remarketing/Model/Mysql4/Session/Collection.php +25 -0
  36. app/code/community/Listrak/Remarketing/Model/Mysql4/Subscriberupdate.php +17 -0
  37. app/code/community/Listrak/Remarketing/Model/Mysql4/Subscriberupdate/Collection.php +11 -0
  38. app/code/community/Listrak/Remarketing/Model/Observer.php +79 -0
  39. app/code/community/Listrak/Remarketing/Model/Session.php +69 -0
  40. app/code/community/Listrak/Remarketing/Model/Subscriber.php +22 -0
  41. app/code/community/Listrak/Remarketing/Model/Subscriberupdate.php +12 -0
  42. app/code/community/Listrak/Remarketing/controllers/Adminhtml/AbandonedcartreportController.php +35 -0
  43. app/code/community/Listrak/Remarketing/controllers/Adminhtml/EmailcaptureController.php +125 -0
  44. app/code/community/Listrak/Remarketing/controllers/CartController.php +60 -0
  45. app/code/community/Listrak/Remarketing/controllers/ConfigController.php +30 -0
  46. app/code/community/Listrak/Remarketing/controllers/EmailController.php +55 -0
  47. app/code/community/Listrak/Remarketing/controllers/TroubleshootingController.php +10 -0
  48. app/code/community/Listrak/Remarketing/etc/adminhtml.xml +60 -0
  49. app/code/community/Listrak/Remarketing/etc/api.xml +152 -0
  50. app/code/community/Listrak/Remarketing/etc/config.xml +168 -0
  51. app/code/community/Listrak/Remarketing/etc/system.xml +67 -0
  52. app/code/community/Listrak/Remarketing/etc/wsdl.xml +624 -0
  53. app/code/community/Listrak/Remarketing/etc/wsi.xml +82 -0
  54. app/code/community/Listrak/Remarketing/sql/listrak_remarketing_setup/mysql4-install-1.0.0.php +85 -0
  55. app/code/community/Listrak/Remarketing/sql/listrak_remarketing_setup/mysql4-upgrade-1.0.0-1.0.1.php +17 -0
  56. app/design/adminhtml/default/default/layout/remarketing.xml +13 -0
  57. app/design/frontend/base/default/layout/remarketing.xml +13 -0
  58. app/etc/modules/Listrak_Remarketing.xml +14 -0
  59. package.xml +26 -0
app/code/community/Listrak/Remarketing/Block/Adminhtml/Abandonedcartreport.php ADDED
@@ -0,0 +1,15 @@
1
+ <?php
2
+ // Listrak Remarketing Magento Extension Ver. 1.0.0
3
+ // © 2011 Listrak, Inc.
4
+
5
+ class Listrak_Remarketing_Block_Adminhtml_Abandonedcartreport extends Mage_Adminhtml_Block_Widget_Grid_Container
6
+ {
7
+ public function __construct()
8
+ {
9
+ $this->_controller = 'adminhtml_abandonedcartreport';
10
+ $this->_blockGroup = 'remarketing';
11
+ $this->_headerText = Mage::helper('remarketing')->__('Abandoned Carts');
12
+ parent::__construct();
13
+ $this->_removeButton('add');
14
+ }
15
+ }
app/code/community/Listrak/Remarketing/Block/Adminhtml/Abandonedcartreport/Grid.php ADDED
@@ -0,0 +1,111 @@
1
+ <?php
2
+ // Listrak Remarketing Magento Extension Ver. 1.0.0
3
+ // © 2011 Listrak, Inc.
4
+
5
+ class Listrak_Remarketing_Block_Adminhtml_Abandonedcartreport_Grid extends Mage_Adminhtml_Block_Widget_Grid
6
+ {
7
+ public function __construct()
8
+ {
9
+ parent::__construct();
10
+ $this->setId('abandonedCartsGrid');
11
+ $this->setDefaultSort('updated_at');
12
+ $this->setDefaultDir('DESC');
13
+ $this->setSaveParametersInSession(true);
14
+ }
15
+
16
+ protected function _prepareCollection()
17
+ {
18
+ $reportTimeout = Mage::getStoreConfig('remarketing/abandonedcarts/abandoned_cart_report_timeout') * 60;
19
+
20
+ $startDate = gmdate('Y-m-d H:i:s', time() - $reportTimeout);
21
+ $collection = Mage::getModel('listrak/abandonedcart')->getCollection()
22
+ ->addFieldToFilter('main_table.updated_at',array('lt'=>$startDate));
23
+ $collection->_prepareForReport = true;
24
+
25
+ $this->setCollection($collection);
26
+ return parent::_prepareCollection();
27
+ }
28
+
29
+ protected function _prepareColumns()
30
+ {
31
+ $this->addColumn('is_customer', array(
32
+ 'header' =>Mage::helper('remarketing')->__('Registered'),
33
+ 'index' =>'is_customer',
34
+ 'width' =>'75px',
35
+ 'sortable' => false,
36
+ 'filter' => false
37
+ ));
38
+
39
+ $this->addColumn('session_id', array(
40
+ 'header' =>Mage::helper('remarketing')->__('Session Id'),
41
+ 'index' =>'session_id',
42
+ 'width' =>'250px',
43
+ 'sortable' => false,
44
+ 'filter' => false
45
+ ));
46
+
47
+ $this->addColumn('customer_name', array(
48
+ 'header' =>Mage::helper('remarketing')->__('Customer Name'),
49
+ 'index' =>'customer_name',
50
+ 'sortable' => false,
51
+ 'filter' => false
52
+ ));
53
+
54
+ $this->addColumn('email', array(
55
+ 'header' =>Mage::helper('remarketing')->__('Email'),
56
+ 'index' =>'email',
57
+ 'sortable' => false,
58
+ 'filter' => false
59
+ ));
60
+
61
+ $this->addColumn('items_count', array(
62
+ 'header' =>Mage::helper('remarketing')->__('# Items'),
63
+ 'width' =>'80px',
64
+ 'align' =>'right',
65
+ 'index' =>'items_qty',
66
+ 'sortable' =>false,
67
+ 'type' =>'number',
68
+ 'filter' => false
69
+ ));
70
+
71
+ $this->addColumn('total', array(
72
+ 'header' =>Mage::helper('remarketing')->__('Total'),
73
+ 'width' =>'80px',
74
+ 'type' =>'currency',
75
+ 'currency_code' => (string) Mage::getStoreConfig(Mage_Directory_Model_Currency::XML_PATH_CURRENCY_DEFAULT),
76
+ 'index' =>'grand_total',
77
+ 'sortable' =>false,
78
+ 'renderer' =>'adminhtml/report_grid_column_renderer_currency',
79
+ 'filter' => false
80
+ ));
81
+
82
+ $this->addColumn('created_at', array(
83
+ 'header' =>Mage::helper('remarketing')->__('Creation Date'),
84
+ 'width' =>'170px',
85
+ 'type' =>'datetime',
86
+ 'index' =>'created_at',
87
+ //'filter_index'=>'main_table.created_at',
88
+ 'sortable' =>false,
89
+ 'filter' => false
90
+ ));
91
+
92
+ $this->addColumn('updated_at', array(
93
+ 'header' =>Mage::helper('remarketing')->__('Abandon Date'),
94
+ 'width' =>'170px',
95
+ 'type' =>'datetime',
96
+ 'index' =>'updated_at',
97
+ //'filter_index'=>'main_table.updated_at',
98
+ 'sortable' =>false,
99
+ 'filter' => false
100
+ ));
101
+
102
+ return parent::_prepareColumns();
103
+ }
104
+
105
+ public function getRowUrl($row)
106
+ {
107
+ return FALSE;
108
+ }
109
+
110
+
111
+ }
app/code/community/Listrak/Remarketing/Block/Adminhtml/Emailcapture.php ADDED
@@ -0,0 +1,15 @@
1
+ <?php
2
+ // Listrak Remarketing Magento Extension Ver. 1.0.0
3
+ // © 2011 Listrak, Inc.
4
+
5
+ class Listrak_Remarketing_Block_Adminhtml_EmailCapture extends Mage_Adminhtml_Block_Widget_Grid_Container
6
+ {
7
+ public function __construct()
8
+ {
9
+ $this->_controller = 'adminhtml_emailcapture';
10
+ $this->_blockGroup = 'remarketing';
11
+ $this->_headerText = Mage::helper('remarketing')->__('Field Manager');
12
+ $this->_addButtonLabel = Mage::helper('remarketing')->__('Add Field');
13
+ parent::__construct();
14
+ }
15
+ }
app/code/community/Listrak/Remarketing/Block/Adminhtml/Emailcapture/Edit.php ADDED
@@ -0,0 +1,27 @@
1
+ <?php
2
+ // Listrak Remarketing Magento Extension Ver. 1.0.0
3
+ // © 2011 Listrak, Inc.
4
+
5
+ class Listrak_Remarketing_Block_Adminhtml_EmailCapture_Edit extends Mage_Adminhtml_Block_Widget_Form_Container
6
+ {
7
+ public function __construct()
8
+ {
9
+ parent::__construct();
10
+
11
+ $this->_objectId = 'id';
12
+ $this->_blockGroup = 'remarketing';
13
+ $this->_controller = 'adminhtml_emailcapture';
14
+
15
+ $this->_updateButton('save', 'label', Mage::helper('remarketing')->__('Save Field'));
16
+ $this->_updateButton('delete', 'label', Mage::helper('remarketing')->__('Delete Field'));
17
+ }
18
+
19
+ public function getHeaderText()
20
+ {
21
+ if( Mage::registry('emailcapture_data') && Mage::registry('emailcapture_data')->getId() ) {
22
+ return Mage::helper('remarketing')->__("Edit Field");
23
+ } else {
24
+ return Mage::helper('remarketing')->__('Add Field');
25
+ }
26
+ }
27
+ }
app/code/community/Listrak/Remarketing/Block/Adminhtml/Emailcapture/Edit/Form.php ADDED
@@ -0,0 +1,20 @@
1
+ <?php
2
+ // Listrak Remarketing Magento Extension Ver. 1.0.0
3
+ // © 2011 Listrak, Inc.
4
+
5
+ class Listrak_Remarketing_Block_Adminhtml_EmailCapture_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
6
+ {
7
+ protected function _prepareForm()
8
+ {
9
+ $form = new Varien_Data_Form(array(
10
+ 'id' => 'edit_form',
11
+ 'action' => $this->getUrl('*/*/save', array('id' => $this->getRequest()->getParam('id'))),
12
+ 'method' => 'post',
13
+ )
14
+ );
15
+
16
+ $form->setUseContainer(true);
17
+ $this->setForm($form);
18
+ return parent::_prepareForm();
19
+ }
20
+ }
app/code/community/Listrak/Remarketing/Block/Adminhtml/Emailcapture/Edit/Tab/Form.php ADDED
@@ -0,0 +1,38 @@
1
+ <?php
2
+ // Listrak Remarketing Magento Extension Ver. 1.0.0
3
+ // © 2011 Listrak, Inc.
4
+
5
+ class Listrak_Remarketing_Block_Adminhtml_EmailCapture_Edit_Tab_Form extends Mage_Adminhtml_Block_Widget_Form
6
+ {
7
+ protected function _prepareForm()
8
+ {
9
+ $form = new Varien_Data_Form();
10
+ $this->setForm($form);
11
+ $fieldset = $form->addFieldset('emailcapture_form', array('legend'=>Mage::helper('remarketing')->__('Field information')));
12
+
13
+ $fieldset->addField('page', 'text', array(
14
+ 'label' => Mage::helper('remarketing')->__('Page'),
15
+ 'class' => 'required-entry',
16
+ 'required' => true,
17
+ 'name' => 'page',
18
+ 'after_element_html' => '<p class="note"><span>For example: /checkout/onepage/index. Each URL has 3 parts. If yours does not have 3 parts, fill the last with "index". You can also use wildcard character "*" to capture field on all pages in the store.</span></p>'
19
+ ));
20
+
21
+ $fieldset->addField('field_id', 'text', array(
22
+ 'label' => Mage::helper('remarketing')->__('Field ID'),
23
+ 'name' => 'field_id',
24
+ 'required' => true,
25
+ 'class' => 'required-entry',
26
+ 'after_element_html' => '<p class="note"><span>Field id attribute. You can check it in HTML code preview.</span></p>'
27
+ ));
28
+
29
+ if (Mage::getSingleton('adminhtml/session')->getEmailCaptureData())
30
+ {
31
+ $form->setValues(Mage::getSingleton('adminhtml/session')->getEmailCaptureData());
32
+ Mage::getSingleton('adminhtml/session')->setEmailCaptureData(null);
33
+ } elseif (Mage::registry('emailcapture_data')) {
34
+ $form->setValues(Mage::registry('emailcapture_data')->getData());
35
+ }
36
+ return parent::_prepareForm();
37
+ }
38
+ }
app/code/community/Listrak/Remarketing/Block/Adminhtml/Emailcapture/Edit/Tabs.php ADDED
@@ -0,0 +1,26 @@
1
+ <?php
2
+ // Listrak Remarketing Magento Extension Ver. 1.0.0
3
+ // © 2011 Listrak, Inc.
4
+
5
+ class Listrak_Remarketing_Block_Adminhtml_EmailCapture_Edit_Tabs extends Mage_Adminhtml_Block_Widget_Tabs
6
+ {
7
+
8
+ public function __construct()
9
+ {
10
+ parent::__construct();
11
+ $this->setId('emailcapture_tabs');
12
+ $this->setDestElementId('edit_form');
13
+ $this->setTitle(Mage::helper('remarketing')->__('Field Information'));
14
+ }
15
+
16
+ protected function _beforeToHtml()
17
+ {
18
+ $this->addTab('form_section', array(
19
+ 'label' => Mage::helper('remarketing')->__('Field Information'),
20
+ 'title' => Mage::helper('remarketing')->__('Field Information'),
21
+ 'content' => $this->getLayout()->createBlock('remarketing/adminhtml_emailcapture_edit_tab_form')->toHtml(),
22
+ ));
23
+
24
+ return parent::_beforeToHtml();
25
+ }
26
+ }
app/code/community/Listrak/Remarketing/Block/Adminhtml/Emailcapture/Grid.php ADDED
@@ -0,0 +1,53 @@
1
+ <?php
2
+ // Listrak Remarketing Magento Extension Ver. 1.0.0
3
+ // © 2011 Listrak, Inc.
4
+
5
+ class Listrak_Remarketing_Block_Adminhtml_EmailCapture_Grid extends Mage_Adminhtml_Block_Widget_Grid
6
+ {
7
+ public function __construct()
8
+ {
9
+ parent::__construct();
10
+ $this->setId('emailcaptureGrid');
11
+ $this->setDefaultSort('emailcapture_id');
12
+ $this->setDefaultDir('ASC');
13
+ $this->setSaveParametersInSession(true);
14
+ }
15
+
16
+ protected function _prepareCollection()
17
+ {
18
+ $collection = Mage::getModel('listrak/emailcapture')->getCollection();
19
+ $this->setCollection($collection);
20
+ return parent::_prepareCollection();
21
+ }
22
+
23
+ protected function _prepareColumns()
24
+ {
25
+ $this->addColumn('emailcapture_id', array(
26
+ 'header' => Mage::helper('remarketing')->__('ID'),
27
+ 'align' =>'right',
28
+ 'width' => '50px',
29
+ 'index' => 'emailcapture_id',
30
+ ));
31
+
32
+ $this->addColumn('page', array(
33
+ 'header' => Mage::helper('remarketing')->__('Page'),
34
+ 'align' =>'left',
35
+ 'index' => 'page',
36
+ ));
37
+
38
+ $this->addColumn('field_id', array(
39
+ 'header' => Mage::helper('remarketing')->__('Field ID'),
40
+ 'align' => 'left',
41
+ 'index' => 'field_id',
42
+ ));
43
+
44
+ return parent::_prepareColumns();
45
+ }
46
+
47
+ public function getRowUrl($row)
48
+ {
49
+ return $this->getUrl('*/*/edit', array('id' => $row->getId()));
50
+ }
51
+
52
+
53
+ }
app/code/community/Listrak/Remarketing/Block/Adminhtml/Notifications.php ADDED
@@ -0,0 +1,20 @@
1
+ <?php
2
+ // Listrak Remarketing Magento Extension Ver. 1.0.0
3
+ // © 2011 Listrak, Inc.
4
+
5
+ class Listrak_Remarketing_Block_Adminhtml_Notifications extends Mage_Core_Block_Text
6
+ {
7
+ protected function _toHtml()
8
+ {
9
+ $html = "";
10
+
11
+ if(!Mage::helper('remarketing')->checkSetupStatus()) {
12
+ $html = "<div class='notification-global'>The Listrak module requires a Listrak account. Please " .
13
+ "<a href='http://www.listrak.com/partners/magento-extension.aspx'>fill out our form</a> to get an account. ".
14
+ "If you already have a Listrak account, please contact your account manager " .
15
+ "or <a href='mailto:support@listrak.com'>support@listrak.com</a>.</div>";
16
+ }
17
+
18
+ return $html;
19
+ }
20
+ }
app/code/community/Listrak/Remarketing/Block/Ecjs.php ADDED
@@ -0,0 +1,122 @@
1
+ <?php
2
+ // Listrak Remarketing Magento Extension Ver. 1.0.0
3
+ // © 2011 Listrak, Inc.
4
+ /**
5
+ arrEcjs = [];
6
+ arrEcjs.push({id:'billing:email', fn:function() _ecjs(1, $(this).value)});
7
+ arrEcjs.push({id:'login:email', fn:function() _ecjs(2, $(this).value)});
8
+
9
+ function ecjsInit() {
10
+ for(var i = 0; i < arrEcjs.length; i++) {
11
+ $(arrEcjs[i].id).stopObserving('change', arrEcjs[i].fn);
12
+ $(arrEcjs[i].id).observe('change', arrEcjs[i].fn);
13
+ }
14
+ }
15
+
16
+ Ajax.Responders.register({
17
+ onComplete: function() {
18
+ ecjsInit();
19
+ }
20
+ });
21
+
22
+
23
+ */
24
+
25
+ class Listrak_Remarketing_Block_Ecjs extends Mage_Core_Block_Text
26
+ {
27
+
28
+ public function getPageName()
29
+ {
30
+ return $this->_getData('page_name');
31
+ }
32
+
33
+ public function getMatchingPages()
34
+ {
35
+ $fullMatches = array();
36
+
37
+ try {
38
+ $route = Mage::app()->getRequest()->getRouteName();
39
+ $controller = Mage::app()->getRequest()->getControllerName();
40
+ $action = Mage::app()->getRequest()->getActionName();
41
+
42
+ $matches = array();
43
+ $matches[] = '/' . $route . '/' . $controller . '/' . $action . '/';
44
+ $matches[] = '/' . $route . '/' . $controller . '/' . $action;
45
+ $matches[] = '/' . $route . '/' . $controller . '/*';
46
+ $matches[] = '/' . $route . '/' . $controller . '/';
47
+ $matches[] = '/' . $route . '/*/*';
48
+ $matches[] = '/' . $route . '/*';
49
+ $matches[] = '/*/*/*';
50
+ $matches[] = '/*/*';
51
+ $matches[] = '/*';
52
+ $matches[] = '';
53
+
54
+ if(strtolower($action) == 'index') {
55
+ $matches[] = '/' . $route . '/' . $controller;
56
+ }
57
+ if(strtolower($action) == 'index' && strtolower($controller) == 'index') {
58
+ $matches[] = '/' . $route;
59
+ }
60
+
61
+ foreach($matches as $match) {
62
+ $fullMatches[] = $match;
63
+ if($match && $match{0} && $match{0} == '/') {
64
+ $fullMatches[] = substr($match, 1);
65
+ }
66
+ }
67
+ }
68
+ catch(Exception $ex) {
69
+ Mage::getModel("listrak/log")->addException($ex);
70
+ }
71
+
72
+ return $fullMatches;
73
+ }
74
+
75
+ protected function _toHtml()
76
+ {
77
+ $collections = Mage::getModel('listrak/emailcapture')->getCollection()->addFieldToFilter('page', $this->getMatchingPages());
78
+
79
+ if($collections && $collections->count()) {
80
+ $html = array();
81
+ $observed = array();
82
+
83
+ $html[] = '<script type="text/javascript">';
84
+ $html[] = 'arrEcjs = [];';
85
+ $html[] = 'function _ecjs(ecid,email) { new Ajax.Request("' . $this->getAjaxUrl() . '", {parameters:{cid: ecid, email: email}}); }';
86
+ $html[] = 'function ecjsInit() {' .
87
+ 'for(var ecjsi = 0; ecjsi < arrEcjs.length; ecjsi++) {' .
88
+ '$(arrEcjs[ecjsi].id).stopObserving("change", arrEcjs[ecjsi].fn);' .
89
+ '$(arrEcjs[ecjsi].id).observe("change", arrEcjs[ecjsi].fn);' .
90
+ '}' .
91
+ '}';
92
+
93
+ foreach($collections as $observer) {
94
+ if(!in_array($observer->getFieldId(), $observed)) {
95
+ $html[] = 'arrEcjs.push({id:"'. $observer->getFieldId() .'", fn: function() { _ecjs('. $observer->getEmailcaptureId() . ', $(this).value);}});';
96
+ $observed[] = $observer->getFieldId();
97
+ }
98
+ }
99
+
100
+ $html[] = 'document.observe("dom:loaded", function() { ecjsInit(); ';
101
+ $html[] = 'Ajax.Responders.register({' .
102
+ 'onComplete: function() {' .
103
+ 'ecjsInit();' .
104
+ '}' .
105
+ '});});';
106
+
107
+ if($observed && count($observed) === 0) {
108
+ return "";
109
+ }
110
+
111
+ $html[] = '</script>';
112
+ return implode("\n", $html);
113
+ }
114
+
115
+ return "";
116
+ }
117
+
118
+ public function getAjaxUrl()
119
+ {
120
+ return Mage::getUrl('remarketing/email', array('_secure' => Mage::app()->getStore()->isCurrentlySecure()));
121
+ }
122
+ }
app/code/community/Listrak/Remarketing/Helper/Data.php ADDED
@@ -0,0 +1,33 @@
1
+ <?php
2
+ // Listrak Remarketing Magento Extension Ver. 1.0.0
3
+ // © 2011 Listrak, Inc.
4
+
5
+ class Listrak_Remarketing_Helper_Data extends Mage_Core_Helper_Abstract
6
+ {
7
+ public function gen_uuid() {
8
+ return sprintf( '%04x%04x-%04x-%04x-%04x-%04x%04x%04x',
9
+ // 32 bits for "time_low"
10
+ mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff ),
11
+
12
+ // 16 bits for "time_mid"
13
+ mt_rand( 0, 0xffff ),
14
+
15
+ // 16 bits for "time_hi_and_version",
16
+ // four most significant bits holds version number 4
17
+ mt_rand( 0, 0x0fff ) | 0x4000,
18
+
19
+ // 16 bits, 8 bits for "clk_seq_hi_res",
20
+ // 8 bits for "clk_seq_low",
21
+ // two most significant bits holds zero and one for variant DCE1.1
22
+ mt_rand( 0, 0x3fff ) | 0x8000,
23
+
24
+ // 48 bits for "node"
25
+ mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff )
26
+ );
27
+ }
28
+
29
+ public function checkSetupStatus() {
30
+ return Mage::getStoreConfig('remarketing/config/account_created');
31
+ }
32
+ }
33
+
app/code/community/Listrak/Remarketing/Model/Abandonedcart.php ADDED
@@ -0,0 +1,40 @@
1
+ <?php
2
+ // Listrak Remarketing Magento Extension Ver. 1.0.0
3
+ // © 2011 Listrak, Inc.
4
+
5
+ class Listrak_Remarketing_Model_Abandonedcart extends Mage_Core_Model_Abstract
6
+ {
7
+ public function _construct()
8
+ {
9
+ parent::_construct();
10
+ $this->_init('listrak/abandonedcart');
11
+ }
12
+
13
+ public function prepareForReport() {
14
+ $session = $this->getSession();
15
+ $customer = $session->getCustomer();
16
+ $this->setSessionId($session->getSessionId());
17
+
18
+ if($customer && $customer->getId()) {
19
+ $this->setCustomerName($customer->getFirstname() . ' ' . $customer->getLastname());
20
+ $this->setEmail($customer->getEmail());
21
+ $this->setIsCustomer('true');
22
+ }
23
+ else {
24
+ $this->setCustomerName('');
25
+ $this->setIsCustomer('false');
26
+
27
+ if(is_array($session->getEmails()) && count($session->getEmails()) > 0) {
28
+ foreach($session->getEmails() as $email) {
29
+ $this->setEmail($this->getEmail() . $email["email"] . ', ');
30
+ }
31
+
32
+ $this->setEmail(trim($this->getEmail(),", "));
33
+ }
34
+ else {
35
+
36
+ }
37
+ }
38
+
39
+ }
40
+ }
app/code/community/Listrak/Remarketing/Model/Abandonedcart/Api.php ADDED
@@ -0,0 +1,50 @@
1
+ <?php
2
+ // Listrak Remarketing Magento Extension Ver. 1.0.0
3
+ // © 2011 Listrak, Inc.
4
+
5
+ class Listrak_Remarketing_Model_Abandonedcart_Api extends Mage_Api_Model_Resource_Abstract {
6
+
7
+ public function items($storeId = 1, $startDate = NULL, $endDate = NULL, $perPage, $page) {
8
+
9
+ if ($startDate === NULL || !strtotime($startDate)) {
10
+ $this->_fault('incorrect_date');
11
+ }
12
+
13
+ if ($endDate === NULL || !strtotime($endDate)) {
14
+ $this->_fault('incorrect_date');
15
+ }
16
+
17
+ $collection = Mage::getModel('listrak/abandonedcart')
18
+ ->getCollection()
19
+ ->addFieldToFilter('main_table.updated_at',array('from'=>$startDate, 'to'=>$endDate))
20
+ ->setPageSize($perPage)->setCurPage($page)
21
+ ->addStoreFilter($storeId)
22
+ ->setOrder('updated_at', 'ASC');
23
+
24
+ $result = array();
25
+
26
+ foreach($collection as $item) {
27
+ $result[] = $item;
28
+ }
29
+
30
+ return $result;
31
+ }
32
+
33
+ public function purge($storeId = 1, $endDate = NULL) {
34
+ if ($endDate === NULL || !strtotime($endDate)) {
35
+ $this->_fault('incorrect_date');
36
+ }
37
+
38
+ $sessions = Mage::getModel("listrak/session")->getCollection()
39
+ ->addFieldToFilter('main_table.updated_at', array('lt' => $endDate))
40
+ ->addStoreFilter($storeId);
41
+
42
+ $count = $sessions->count();
43
+
44
+ foreach($sessions as $s) {
45
+ $s->delete();
46
+ }
47
+
48
+ return $count;
49
+ }
50
+ }
app/code/community/Listrak/Remarketing/Model/Abandonedcart/Api/V2.php ADDED
@@ -0,0 +1,8 @@
1
+ <?php
2
+ // Listrak Remarketing Magento Extension Ver. 1.0.0
3
+ // © 2011 Listrak, Inc.
4
+
5
+ class Listrak_Remarketing_Model_Abandonedcart_Api_V2 extends Listrak_Remarketing_Model_Abandonedcart_Api {
6
+
7
+ }
8
+
app/code/community/Listrak/Remarketing/Model/Apiextension.php ADDED
@@ -0,0 +1,12 @@
1
+ <?php
2
+ // Listrak Remarketing Magento Extension Ver. 1.0.0
3
+ // © 2011 Listrak, Inc.
4
+
5
+ class Listrak_Remarketing_Model_Apiextension extends Mage_Core_Model_Abstract
6
+ {
7
+ public function _construct()
8
+ {
9
+ parent::_construct();
10
+ $this->_init('listrak/apiextension');
11
+ }
12
+ }
app/code/community/Listrak/Remarketing/Model/Apiextension/Api.php ADDED
@@ -0,0 +1,185 @@
1
+ <?php
2
+ // Listrak Remarketing Magento Extension Ver. 1.0.0
3
+ // © 2011 Listrak, Inc.
4
+
5
+ class Listrak_Remarketing_Model_Apiextension_Api extends Mage_Api_Model_Resource_Abstract {
6
+
7
+ public function products($storeId = 1, $perPage = 50, $page = 1) {
8
+ $collection = Mage::getModel('catalog/product')->getCollection()
9
+ ->addStoreFilter($storeId)
10
+ ->addAttributeToSelect('*')
11
+ ->addFieldToFilter('type_id', array('neq'=>'configurable'))
12
+ ->setPageSize($perPage)
13
+ ->setCurPage($page);
14
+
15
+ $result = array();
16
+ $productInfo = array('entity_id' => '', 'sku' => '', 'name' => '', 'price' => '',
17
+ 'special_price' => '', 'special_from_date' => '', 'special_to_date' => '',
18
+ 'cost' => '', 'description' => '', 'short_description' => '', 'weight' => '',
19
+ 'url_key' => '', 'url_path' => '', 'image' => '', 'small_image' => '', 'thumbnail' => '');
20
+
21
+ foreach ($collection as $product) {
22
+ $item = array_intersect_key($product->toArray(), $productInfo);
23
+ $result[] = $item;
24
+ }
25
+
26
+ return $result;
27
+ }
28
+
29
+ public function subscribers($storeId = 1, $startDate = NULL, $perPage = 50, $page = 1) {
30
+ if ($startDate === NULL || !strtotime($startDate)) {
31
+ $this->_fault('incorrect_date');
32
+ }
33
+
34
+ $result = array();
35
+
36
+ $collection = Mage::getModel("listrak/apiextension")->getResource()->subscribers($storeId, $startDate, $perPage, $page);
37
+
38
+ foreach($collection as $item) {
39
+ $result[] = $item;
40
+ }
41
+
42
+ return $result;
43
+ }
44
+
45
+ public function subscribersPurge($endDate = NULL) {
46
+ if ($endDate === NULL || !strtotime($endDate)) {
47
+ $this->_fault('incorrect_date');
48
+ }
49
+
50
+ $collection = Mage::getModel("listrak/subscriberupdate")->getCollection()
51
+ ->addFieldToFilter('updated_at', array('lt' => $endDate));
52
+
53
+ $count = $collection->count();
54
+
55
+ foreach($collection as $c) {
56
+ $c->delete();
57
+ }
58
+
59
+ return $count;
60
+ }
61
+
62
+ public function customers($storeId = 1, $websiteId = 1, $perPage = 50, $page = 1) {
63
+ $collection = Mage::getModel('customer/customer')->getCollection()
64
+ ->addFieldToFilter('store_id',$storeId)
65
+ ->addAttributeToSelect('*')
66
+ ->setPageSize($perPage)
67
+ ->setCurPage($page);
68
+
69
+ $results = array();
70
+ $fields = array('entity_id' => '', 'firstname' => '', 'lastname' => '', 'email' => '', 'website_id' => '', 'store_id' => '');
71
+
72
+ foreach($collection as $customer) {
73
+ $item = $customer->toArray();
74
+ $results[] = array_intersect_key($item, $fields);
75
+ }
76
+
77
+ return $results;
78
+ }
79
+
80
+ public function orderStatus($storeId = 1, $startDate = NULL, $endDate = NULL, $perPage = 50, $page = 1, $filters = NULL) {
81
+ $collection = Mage::getModel("sales/order")->getCollection()
82
+ ->addFieldToFilter('store_id', $storeId)
83
+ ->addAttributeToSelect('increment_id')
84
+ ->addAttributeToSelect('updated_at')
85
+ ->addAttributeToSelect('status')
86
+ ->addFieldToFilter('updated_at',array('from'=>$startDate, 'to'=>$endDate))
87
+ ->addFieldToFilter('status', array('neq'=>'pending'))
88
+ ->setPageSize($perPage)->setCurPage($page)
89
+ ->setOrder('created_at', 'ASC');
90
+
91
+ if (is_array($filters)) {
92
+ try {
93
+ foreach ($filters as $field => $value) {
94
+ if (isset($this->_attributesMap['order'][$field])) {
95
+ $field = $this->_attributesMap['order'][$field];
96
+ }
97
+
98
+ $collection->addFieldToFilter($field, $value);
99
+ }
100
+ } catch (Mage_Core_Exception $e) {
101
+ $this->_fault('filters_invalid', $e->getMessage());
102
+ }
103
+ }
104
+
105
+ $results = array();
106
+
107
+ foreach($collection as $collectionItem) {
108
+ $results[] = $collectionItem;
109
+ }
110
+
111
+ return $results;
112
+ }
113
+
114
+ public function orders($storeId = 1, $startDate = NULL, $endDate = NULL, $perPage = 50, $page = 1) {
115
+ if ($startDate === NULL || !strtotime($startDate)) {
116
+ $this->_fault('incorrect_date');
117
+ }
118
+
119
+ if ($endDate === NULL || !strtotime($endDate)) {
120
+ $this->_fault('incorrect_date');
121
+ }
122
+
123
+ $collection = Mage::getModel("sales/order")->getCollection()
124
+ ->addAttributeToSelect('increment_id')
125
+ ->addFieldToFilter('created_at',array('from'=>$startDate, 'to'=>$endDate))
126
+ ->setPageSize($perPage)->setCurPage($page)
127
+ ->addFieldToFilter('store_id', $storeId)
128
+ ->setOrder('created_at', 'ASC');
129
+
130
+
131
+ $apiModel = Mage::getModel("sales/order_api");
132
+
133
+ $results = array();
134
+
135
+ $info_fields = array('created_at'=>'', 'status'=>'', 'customer_firstname'=>'', 'customer_lastname'=>'',
136
+ 'customer_email'=>'', 'order_id'=>'', 'subtotal'=>'', 'tax_amount'=>'', 'grand_total'=>'',
137
+ 'shipping_amount'=>'', 'billing_firstname'=>'');
138
+
139
+ $address_fields = array('firstname' => '', 'lastname' => '', 'company' => '', 'address1' => '',
140
+ 'address2' => '', 'city' => '', 'region' => '', 'postcode' => '', 'country' => '');
141
+
142
+ foreach($collection as $collectionItem) {
143
+ $res = array();
144
+ $item = $apiModel->info($collectionItem->getIncrementId());
145
+ $res["info"] = array_intersect_key($item, $info_fields);
146
+ $res["info"]["order_id"] = $collectionItem->getIncrementId();
147
+ $res["shipping_address"] = array_intersect_key($item["shipping_address"], $address_fields);
148
+ $res["billing_address"] = array_intersect_key($item["billing_address"], $address_fields);
149
+ $res["product"] = array();
150
+ foreach($item["items"] as $orderItem) {
151
+ if($orderItem["product_type"] != "configurable")
152
+ $res["product"][] = $orderItem;
153
+ }
154
+ $res["session"] = Mage::getModel("listrak/session")->load($item["quote_id"], 'quote_id');
155
+ $results[] = $res;
156
+ }
157
+
158
+ return $results;
159
+ }
160
+
161
+ public function info() {
162
+ $result = array();
163
+ $result["ini"] = array();
164
+
165
+ $subModel = Mage::getModel("newsletter/subscriber");
166
+ $result["subscriberClass"] = get_class($subModel);
167
+
168
+ $result["modules"] = array();
169
+ $modules = (array)Mage::getConfig()->getNode('modules')->children();
170
+
171
+ foreach($modules as $key => $value) {
172
+ $valueArray = $value->asCanonicalArray();
173
+ $result["modules"][] = "name=$key, version=" . $valueArray["version"] .", isActive=" . $valueArray["active"];
174
+ }
175
+
176
+ $ini = array("session.gc_maxlifetime", "session.cookie_lifetime", "session.gc_divisor", "session.gc_probability");
177
+
178
+ foreach($ini as $iniParam) {
179
+ $result["ini"][] = "$iniParam=" . ini_get($iniParam);
180
+ }
181
+
182
+ return $result;
183
+ }
184
+ }
185
+
app/code/community/Listrak/Remarketing/Model/Apiextension/Api/V2.php ADDED
@@ -0,0 +1,8 @@
1
+ <?php
2
+ // Listrak Remarketing Magento Extension Ver. 1.0.0
3
+ // © 2011 Listrak, Inc.
4
+
5
+ class Listrak_Remarketing_Model_Apiextension_Api_V2 extends Listrak_Remarketing_Model_Apiextension_Api {
6
+
7
+ }
8
+
app/code/community/Listrak/Remarketing/Model/Click.php ADDED
@@ -0,0 +1,31 @@
1
+ <?php
2
+ // Listrak Remarketing Magento Extension Ver. 1.0.0
3
+ // © 2011 Listrak, Inc.
4
+
5
+ class Listrak_Remarketing_Model_Click extends Mage_Core_Model_Abstract
6
+ {
7
+ public function _construct()
8
+ {
9
+ parent::_construct();
10
+ $this->_init('listrak/click');
11
+ }
12
+
13
+ public function checkForClick() {
14
+ foreach($_GET as $key => $value) {
15
+ if(stripos($key, 'trk_') !== false) {
16
+ $this->recordClick();
17
+ break;
18
+ }
19
+ }
20
+ }
21
+
22
+ private function recordClick() {
23
+ $this->setTokenUid(Mage::helper('remarketing')->gen_uuid());
24
+ $this->setClickDate(gmdate('Y-m-d H:i:s'));
25
+ $this->setSessionId(Mage::getSingleton('listrak/session')->getId());
26
+ $this->setQuerystring($_SERVER['QUERY_STRING']);
27
+ $this->save();
28
+
29
+ Mage::getModel('core/cookie')->set('ltktrk', $this->getTokenUid(), TRUE, NULL, NULL, NULL, TRUE);
30
+ }
31
+ }
app/code/community/Listrak/Remarketing/Model/Click/Api.php ADDED
@@ -0,0 +1,49 @@
1
+ <?php
2
+ // Listrak Remarketing Magento Extension Ver. 1.0.0
3
+ // © 2011 Listrak, Inc.
4
+
5
+ class Listrak_Remarketing_Model_Click_Api extends Mage_Api_Model_Resource_Abstract {
6
+
7
+ public function items($storeId = 1, $startDate = NULL, $endDate = NULL, $perPage = 50, $page = 1) {
8
+
9
+ if ($startDate === NULL || !strtotime($startDate)) {
10
+ $this->_fault('incorrect_date');
11
+ }
12
+
13
+ if ($endDate === NULL || !strtotime($endDate)) {
14
+ $this->_fault('incorrect_date');
15
+ }
16
+
17
+ $clicks = Mage::getModel("listrak/click")->getCollection()
18
+ ->addFieldToFilter('click_date',array('from'=>$startDate, 'to'=>$endDate))
19
+ ->setPageSize($perPage)->setCurPage($page);
20
+
21
+ $clicks->addStoreFilter($storeId);
22
+
23
+ $result = array();
24
+
25
+ foreach($clicks as $item) {
26
+ $result[] = $item;
27
+ }
28
+
29
+ return $result;
30
+ }
31
+
32
+ public function purge($storeId = 1, $endDate) {
33
+ if($endDate === NULL || !strtotime($endDate)) {
34
+ $this->_fault('incorrect_date');
35
+ }
36
+
37
+ $clicks = Mage::getModel("listrak/click")->getCollection()
38
+ ->addFieldToFilter('click_date', array('lt' => $endDate))
39
+ ->addStoreFilter($storeId);
40
+
41
+ $count = $clicks->count();
42
+
43
+ foreach($clicks as $click){
44
+ $click->delete();
45
+ }
46
+
47
+ return $count;
48
+ }
49
+ }
app/code/community/Listrak/Remarketing/Model/Click/Api/V2.php ADDED
@@ -0,0 +1,8 @@
1
+ <?php
2
+ // Listrak Remarketing Magento Extension Ver. 1.0.0
3
+ // © 2011 Listrak, Inc.
4
+
5
+ class Listrak_Remarketing_Model_Click_Api_V2 extends Listrak_Remarketing_Model_Click_Api {
6
+
7
+ }
8
+
app/code/community/Listrak/Remarketing/Model/Emailcapture.php ADDED
@@ -0,0 +1,12 @@
1
+ <?php
2
+ // Listrak Remarketing Magento Extension Ver. 1.0.0
3
+ // © 2011 Listrak, Inc.
4
+
5
+ class Listrak_Remarketing_Model_Emailcapture extends Mage_Core_Model_Abstract {
6
+
7
+ public function _construct()
8
+ {
9
+ parent::_construct();
10
+ $this->_init('listrak/emailcapture');
11
+ }
12
+ }
app/code/community/Listrak/Remarketing/Model/Log.php ADDED
@@ -0,0 +1,35 @@
1
+ <?php
2
+ // Listrak Remarketing Magento Extension Ver. 1.0.0
3
+ // © 2011 Listrak, Inc.
4
+
5
+ class Listrak_Remarketing_Model_Log extends Mage_Core_Model_Abstract
6
+ {
7
+ const LOGTYPE_MESSAGE = 1;
8
+ const LOGTYPE_EXCEPTION = 2;
9
+
10
+ public function _construct()
11
+ {
12
+ parent::_construct();
13
+ $this->_init('listrak/log');
14
+ }
15
+
16
+ public function addMessage($msg, $storeId = NULL) {
17
+ if($storeId == NULL) {
18
+ $storeId = Mage::app()->getStore()->getStoreId();
19
+ }
20
+ $this->setMessage($msg);
21
+ $this->setLogTypeId(self::LOGTYPE_MESSAGE);
22
+ $this->setStoreId($storeId);
23
+ $this->save();
24
+ }
25
+
26
+ public function addException($msg, $storeId = NULL) {
27
+ if($storeId == NULL) {
28
+ $storeId = Mage::app()->getStore()->getStoreId();
29
+ }
30
+ $this->setMessage($msg);
31
+ $this->setLogTypeId(self::LOGTYPE_EXCEPTION);
32
+ $this->setStoreId($storeId);
33
+ $this->save();
34
+ }
35
+ }
app/code/community/Listrak/Remarketing/Model/Log/Api.php ADDED
@@ -0,0 +1,52 @@
1
+ <?php
2
+ // Listrak Remarketing Magento Extension Ver. 1.0.0
3
+ // © 2011 Listrak, Inc.
4
+
5
+ class Listrak_Remarketing_Model_Log_Api extends Mage_Api_Model_Resource_Abstract {
6
+
7
+ public function items($storeId = 1, $startDate = NULL, $endDate = NULL, $perPage = 50, $page = 1, $logTypeId = 0) {
8
+
9
+ if ($startDate === NULL || !strtotime($startDate)) {
10
+ $this->_fault('incorrect_date');
11
+ }
12
+
13
+ if ($endDate === NULL || !strtotime($endDate)) {
14
+ $this->_fault('incorrect_date');
15
+ }
16
+
17
+ $logs = Mage::getModel("listrak/log")->getCollection()
18
+ ->addFieldToFilter('date_entered',array('from'=>$startDate, 'to'=>$endDate))
19
+ ->setPageSize($perPage)->setCurPage($page)
20
+ ->addStoreFilter($storeId);
21
+
22
+ $result = array();
23
+
24
+ foreach($logs as $item) {
25
+ $result[] = $item;
26
+ }
27
+
28
+ return $result;
29
+ }
30
+
31
+ public function purge($storeId = 1, $endDate = NULL) {
32
+ if($endDate === NULL || !strtotime($endDate)) {
33
+ $this->_fault('incorrect_date');
34
+ }
35
+
36
+ $logs = Mage::getModel("listrak/log")->getCollection()
37
+ ->addFieldToFilter('date_entered', array('lt' => $endDate))
38
+ ->addStoreFilter($storeId);
39
+
40
+ $count = $logs->count();
41
+
42
+ foreach($logs as $log){
43
+ $log->delete();
44
+ }
45
+
46
+ return $count;
47
+ }
48
+
49
+ public function toggle($storeId = 1, $onOff) {
50
+ return $onOff;
51
+ }
52
+ }
app/code/community/Listrak/Remarketing/Model/Log/Api/V2.php ADDED
@@ -0,0 +1,8 @@
1
+ <?php
2
+ // Listrak Remarketing Magento Extension Ver. 1.0.0
3
+ // © 2011 Listrak, Inc.
4
+
5
+ class Listrak_Remarketing_Model_Log_Api_V2 extends Listrak_Remarketing_Model_Log_Api {
6
+
7
+ }
8
+
app/code/community/Listrak/Remarketing/Model/Mysql4/Abandonedcart.php ADDED
@@ -0,0 +1,57 @@
1
+ <?php
2
+ // Listrak Remarketing Magento Extension Ver. 1.0.0
3
+ // © 2011 Listrak, Inc.
4
+
5
+ class Listrak_Remarketing_Model_Mysql4_Abandonedcart extends Mage_Core_Model_Mysql4_Abstract
6
+ {
7
+ protected $_read;
8
+
9
+ protected $_write;
10
+
11
+ public function _construct()
12
+ {
13
+ $this->_init('listrak/session','id');
14
+ $this->_read = $this->_getReadAdapter();
15
+ $this->_write = $this->_getWriteAdapter();
16
+ }
17
+
18
+ protected function _afterLoad(Mage_Core_Model_Abstract $object) {
19
+ $object->setSession(Mage::getModel("listrak/session")->load($object->getId()));
20
+
21
+ $this->loadCart($object);
22
+
23
+ return parent::_afterLoad($object);
24
+ }
25
+
26
+ protected function loadCart(Mage_Core_Model_Abstract $object) {
27
+ $product_fields = array(
28
+ 'entity_id'=>'', 'sku'=>'', 'name'=>'', 'price'=>'', 'special_price'=>'',
29
+ 'special_from_date'=>'', 'special_to_date'=>'', 'cost'=>'', 'description'=>'',
30
+ 'short_description'=>'', 'weight'=>'', 'url_key'=>'', 'url_path'=>'',
31
+ 'image'=>'', 'small_image'=>'', 'thumbnail'=>'', 'qty'=>'');
32
+
33
+ $fields = array(
34
+ 'item_id' => 'q.item_id',
35
+ 'quote_id' => 'q.quote_id',
36
+ 'product_id' => 'q.product_id',
37
+ 'qty' => 'q.qty');
38
+
39
+ $products = array();
40
+
41
+ $qiSelect = $this->_read->select()
42
+ ->from(array('q' => $this->getTable('sales/quote_item')), $fields)
43
+ ->where('q.quote_id = ?', $object->getQuoteId())
44
+ ->where('q.product_type <> "configurable"');
45
+
46
+ $qiResult = $this->_read->fetchAll($qiSelect);
47
+
48
+ foreach($qiResult as $qi) {
49
+ $product = Mage::getModel('catalog/product')->load($qi['product_id']);
50
+ $qitem = array_intersect_key($product->toArray(),$product_fields);
51
+ $qitem["qty"] = $qi["qty"];
52
+ $products[] = $qitem;
53
+ }
54
+
55
+ $object->setProducts($products);
56
+ }
57
+ }
app/code/community/Listrak/Remarketing/Model/Mysql4/Abandonedcart/Collection.php ADDED
@@ -0,0 +1,44 @@
1
+ <?php
2
+ // Listrak Remarketing Magento Extension Ver. 1.0.0
3
+ // © 2011 Listrak, Inc.
4
+
5
+ class Listrak_Remarketing_Model_Mysql4_Abandonedcart_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
6
+ {
7
+ public $_prepareForReport = false;
8
+
9
+ protected function _construct()
10
+ {
11
+ $this->_init('listrak/abandonedcart');
12
+ }
13
+
14
+ protected function _initSelect()
15
+ {
16
+ parent::_initSelect();
17
+
18
+ $this->getSelect()
19
+ ->join(array('q'=>$this->getTable('sales/quote')),
20
+ 'main_table.quote_id = q.entity_id',
21
+ array('items_qty','grand_total'))
22
+ ->joinLeft(array('qa' => $this->getTable('sales/quote_address')),
23
+ 'q.entity_id=qa.quote_id AND qa.address_type="billing"',
24
+ array('qa.firstname AS customer_firstName', 'qa.lastname AS customer_lastName'))
25
+ ->where('q.items_count > 0 AND q.is_active = 1');
26
+ }
27
+
28
+ public function addStoreFilter($storeIds)
29
+ {
30
+ $this->getSelect()->where('main_table.store_id IN (?)', $storeIds);
31
+ return $this;
32
+ }
33
+
34
+ protected function _afterLoad() {
35
+ foreach ($this->_items as $item) {
36
+ $item->afterLoad();
37
+ if($this->_prepareForReport === true) {
38
+ $item->prepareForReport();
39
+ }
40
+ }
41
+
42
+ return parent::_afterLoad();
43
+ }
44
+ }
app/code/community/Listrak/Remarketing/Model/Mysql4/Apiextension.php ADDED
@@ -0,0 +1,54 @@
1
+ <?php
2
+ // Listrak Remarketing Magento Extension Ver. 1.0.0
3
+ // © 2011 Listrak, Inc.
4
+
5
+ class Listrak_Remarketing_Model_Mysql4_Apiextension extends Mage_Core_Model_Mysql4_Abstract {
6
+
7
+ protected $_read;
8
+
9
+ protected $_write;
10
+
11
+ protected function _construct()
12
+ {
13
+ $this->_init('listrak/session', 'id');
14
+ $this->_read = $this->_getReadAdapter();
15
+ $this->_write = $this->_getWriteAdapter();
16
+ }
17
+
18
+ public function subscribers($storeId = 1, $startDate = NULL, $perPage = 50, $page = 1) {
19
+
20
+ $collection = Mage::getModel("newsletter/subscriber")->getCollection()
21
+ ->addStoreFilter($storeId)
22
+ ->setPageSize($perPage)
23
+ ->setCurPage($page);
24
+
25
+ $collection->getSelect()
26
+ ->join(array('su'=>$collection->getTable('listrak/subscriber_update')),
27
+ 'main_table.subscriber_id = su.subscriber_id',
28
+ array())
29
+ ->where('su.updated_at > ?', $startDate);
30
+
31
+ $collection->setOrder('su.updated_at', 'ASC');
32
+
33
+ foreach($collection as $c) {
34
+ switch($c->getSubscriberStatus()) {
35
+ case "1":
36
+ $c->setSubscriberStatus("subscribed");
37
+ break;
38
+ case "2":
39
+ $c->setSubscriberStatus("inactive");
40
+ break;
41
+ case "3":
42
+ $c->setSubscriberStatus("unsubscribed");
43
+ break;
44
+ case "4":
45
+ $c->setSubscriberStatus("unconfirmed");
46
+ break;
47
+ default:
48
+ break;
49
+ }
50
+ }
51
+
52
+ return $collection;
53
+ }
54
+ }
app/code/community/Listrak/Remarketing/Model/Mysql4/Click.php ADDED
@@ -0,0 +1,64 @@
1
+ <?php
2
+ // Listrak Remarketing Magento Extension Ver. 1.0.0
3
+ // © 2011 Listrak, Inc.
4
+
5
+ class Listrak_Remarketing_Model_Mysql4_Click extends Mage_Core_Model_Mysql4_Abstract {
6
+
7
+ protected $_read;
8
+
9
+ protected $_write;
10
+
11
+ protected function _construct()
12
+ {
13
+ $this->_init('listrak/click', 'click_id');
14
+ $this->_read = $this->_getReadAdapter();
15
+ $this->_write = $this->_getWriteAdapter();
16
+ }
17
+
18
+ public function loadByQuoteId($quoteId) {
19
+ $select = $this->_read->select()
20
+ ->from($this->getTable('listrak/session'))
21
+ ->where('quote_id=?',$quoteId)
22
+ ->join(array('c'=>$this->getTable('listrak/click')),
23
+ 'id = c.session_id',
24
+ array());
25
+
26
+ if($result = $this->_read->fetchAll($select)) {
27
+ return $result;
28
+ }
29
+
30
+ return array();
31
+ }
32
+
33
+ public function loadLatestByQuoteId($quoteId) {
34
+ $select = $this->_read->select()
35
+ ->from(array('c'=>$this->getTable('listrak/click')))
36
+ ->joinInner(array('s'=>$this->getTable('listrak/session')), 's.id = c.session_id', array())
37
+ ->where('s.quote_id = ?', $quoteId)
38
+ ->order('click_id', 'desc')
39
+ ->limit(0,1);
40
+
41
+ if($result = $this->_read->fetchRow($select)) {
42
+ return $result;
43
+ }
44
+ else {
45
+ return NULL;
46
+ }
47
+ }
48
+
49
+ public function loadLatestBySessionId($sid) {
50
+ $select = $this->_read->select()
51
+ ->from(array('c'=>$this->getTable('listrak/click')))
52
+ ->joinInner(array('s'=>$this->getTable('listrak/session')), 's.id = c.session_id', array())
53
+ ->where('s.session_id = ?', $sid)
54
+ ->order('click_id', 'desc')
55
+ ->limit(0,1);
56
+
57
+ if($result = $this->_read->fetchRow($select)) {
58
+ return $result;
59
+ }
60
+ else {
61
+ return NULL;
62
+ }
63
+ }
64
+ }
app/code/community/Listrak/Remarketing/Model/Mysql4/Click/Collection.php ADDED
@@ -0,0 +1,20 @@
1
+ <?php
2
+ // Listrak Remarketing Magento Extension Ver. 1.0.0
3
+ // © 2011 Listrak, Inc.
4
+
5
+ class Listrak_Remarketing_Model_Mysql4_Click_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
6
+ {
7
+
8
+ protected function _construct()
9
+ {
10
+ $this->_init('listrak/click');
11
+ }
12
+
13
+ public function addStoreFilter($storeId)
14
+ {
15
+ $this->getSelect()
16
+ ->join(array('s'=>$this->getTable('listrak/session')), 'main_table.session_id = s.id', array('store_id', 'session_id as session_uid'))
17
+ ->where('s.store_id IN (?)',$storeId);
18
+ return $this;
19
+ }
20
+ }
app/code/community/Listrak/Remarketing/Model/Mysql4/Emailcapture.php ADDED
@@ -0,0 +1,17 @@
1
+ <?php
2
+ // Listrak Remarketing Magento Extension Ver. 1.0.0
3
+ // © 2011 Listrak, Inc.
4
+
5
+ class Listrak_Remarketing_Model_Mysql4_Emailcapture extends Mage_Core_Model_Mysql4_Abstract {
6
+
7
+ protected $_read;
8
+
9
+ protected $_write;
10
+
11
+ protected function _construct()
12
+ {
13
+ $this->_init('listrak/emailcapture', 'emailcapture_id');
14
+ $this->_read = $this->_getReadAdapter();
15
+ $this->_write = $this->_getWriteAdapter();
16
+ }
17
+ }
app/code/community/Listrak/Remarketing/Model/Mysql4/Emailcapture/Collection.php ADDED
@@ -0,0 +1,11 @@
1
+ <?php
2
+ // Listrak Remarketing Magento Extension Ver. 1.0.0
3
+ // © 2011 Listrak, Inc.
4
+
5
+ class Listrak_Remarketing_Model_Mysql4_Emailcapture_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract {
6
+
7
+ protected function _construct()
8
+ {
9
+ $this->_init('listrak/emailcapture');
10
+ }
11
+ }
app/code/community/Listrak/Remarketing/Model/Mysql4/Log.php ADDED
@@ -0,0 +1,17 @@
1
+ <?php
2
+ // Listrak Remarketing Magento Extension Ver. 1.0.0
3
+ // © 2011 Listrak, Inc.
4
+
5
+ class Listrak_Remarketing_Model_Mysql4_Log extends Mage_Core_Model_Mysql4_Abstract {
6
+
7
+ protected $_read;
8
+
9
+ protected $_write;
10
+
11
+ protected function _construct()
12
+ {
13
+ $this->_init('listrak/log', 'id');
14
+ $this->_read = $this->_getReadAdapter();
15
+ $this->_write = $this->_getWriteAdapter();
16
+ }
17
+ }
app/code/community/Listrak/Remarketing/Model/Mysql4/Log/Collection.php ADDED
@@ -0,0 +1,17 @@
1
+ <?php
2
+ // Listrak Remarketing Magento Extension Ver. 1.0.0
3
+ // © 2011 Listrak, Inc.
4
+
5
+ class Listrak_Remarketing_Model_Mysql4_Log_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
6
+ {
7
+ protected function _construct()
8
+ {
9
+ $this->_init('listrak/log');
10
+ }
11
+
12
+ public function addStoreFilter($storeIds)
13
+ {
14
+ $this->getSelect()->where('main_table.store_id IN (?)', $storeIds);
15
+ return $this;
16
+ }
17
+ }
app/code/community/Listrak/Remarketing/Model/Mysql4/Session.php ADDED
@@ -0,0 +1,94 @@
1
+ <?php
2
+ // Listrak Remarketing Magento Extension Ver. 1.0.0
3
+ // © 2011 Listrak, Inc.
4
+
5
+ class Listrak_Remarketing_Model_Mysql4_Session extends Mage_Core_Model_Mysql4_Abstract {
6
+
7
+ protected $_read;
8
+
9
+ protected $_write;
10
+
11
+ protected function _construct()
12
+ {
13
+ $this->_init('listrak/session', 'id');
14
+ $this->_read = $this->_getReadAdapter();
15
+ $this->_write = $this->_getWriteAdapter();
16
+ }
17
+
18
+ protected function _afterLoad(Mage_Core_Model_Abstract $object) {
19
+ if($object->getCustomerId()) {
20
+ $cust = Mage::getModel("customer/customer")->load($object->getCustomerId());
21
+ if($cust) {
22
+ $object->setCustomer($cust);
23
+ }
24
+ }
25
+
26
+ if($object->getId()) {
27
+ $this->loadEmails($object);
28
+ $this->loadClicks($object);
29
+ }
30
+ return parent::_afterLoad($object);
31
+ }
32
+
33
+ public function loadBySessionId(Listrak_Remarketing_Model_Session $session) {
34
+ $select = $this->_read->select()
35
+ ->from($this->getTable('listrak/session'))
36
+ ->where('session_id=?',$session->getSessionId());
37
+
38
+ if($result = $this->_read->fetchRow($select)) {
39
+ $session->addData($result);
40
+ $session->loadEmails();
41
+ }
42
+ }
43
+
44
+ public function loadByQuoteId(Listrak_Remarketing_Model_Session $session) {
45
+ $select = $this->_read->select()
46
+ ->from($this->getTable('listrak/session'))
47
+ ->where('quote_id=?',$session->getQuoteId());
48
+
49
+ if($result = $this->_read->fetchRow($select)) {
50
+ $session->addData($result);
51
+ $session->loadEmails();
52
+ }
53
+ }
54
+
55
+ public function insertEmail(Listrak_Remarketing_Model_Session $session, $email, $emailcaptureId) {
56
+ if($session->getId()) {
57
+ $data = array();
58
+ $data['session_id'] = $session->getId();
59
+ $data['email'] = $email;
60
+ $data['emailcapture_id'] = $emailcaptureId;
61
+ $data['created_at'] = gmdate('Y-m-d H:i:s');
62
+ $this->_write->insert($this->getTable('listrak/session_email'), $data);
63
+ }
64
+ }
65
+
66
+ public function loadEmails(Listrak_Remarketing_Model_Session $session) {
67
+ $select = $this->_read->select()
68
+ ->from(array('se'=>$this->getTable('listrak/session_email')))
69
+ ->joinLeft(array('ec'=>$this->getTable('listrak/emailcapture')),
70
+ 'se.emailcapture_id = ec.emailcapture_id',
71
+ array('*'))
72
+ ->where('session_id=?',$session->getId());
73
+
74
+ $emails = $this->_read->fetchAll($select);
75
+ $session->setEmails($emails);
76
+ }
77
+
78
+ public function loadClicks(Listrak_Remarketing_Model_Session $session) {
79
+ $clicks = Mage::getModel("listrak/click")->getCollection()
80
+ ->addFieldToFilter('session_id',array('eq'=>$session->getId()));
81
+
82
+ $sessionClicks = array();
83
+
84
+ foreach($clicks as $click) {
85
+ $sessionClicks[] = $click;
86
+ }
87
+
88
+ $session->setClicks($sessionClicks);
89
+ }
90
+
91
+ public function deleteEmails($id) {
92
+ $del = $this->_write->delete($this->getTable("listrak/session_email"), "session_id = $id");
93
+ }
94
+ }
app/code/community/Listrak/Remarketing/Model/Mysql4/Session/Collection.php ADDED
@@ -0,0 +1,25 @@
1
+ <?php
2
+ // Listrak Remarketing Magento Extension Ver. 1.0.0
3
+ // © 2011 Listrak, Inc.
4
+
5
+ class Listrak_Remarketing_Model_Mysql4_Session_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract {
6
+
7
+ protected function _construct()
8
+ {
9
+ $this->_init('listrak/session');
10
+ }
11
+
12
+ public function addStoreFilter($storeIds)
13
+ {
14
+ $this->getSelect()->where('main_table.store_id IN (?)', $storeIds);
15
+ return $this;
16
+ }
17
+
18
+ protected function _afterLoad() {
19
+ foreach($this->_items as $i) {
20
+ $i->afterLoad();
21
+ }
22
+
23
+ return parent::_afterLoad();
24
+ }
25
+ }
app/code/community/Listrak/Remarketing/Model/Mysql4/Subscriberupdate.php ADDED
@@ -0,0 +1,17 @@
1
+ <?php
2
+ // Listrak Remarketing Magento Extension Ver. 1.0.0
3
+ // © 2011 Listrak, Inc.
4
+
5
+ class Listrak_Remarketing_Model_Mysql4_Subscriberupdate extends Mage_Core_Model_Mysql4_Abstract {
6
+
7
+ protected $_read;
8
+
9
+ protected $_write;
10
+
11
+ protected function _construct()
12
+ {
13
+ $this->_init('listrak/subscriber_update', 'id');
14
+ $this->_read = $this->_getReadAdapter();
15
+ $this->_write = $this->_getWriteAdapter();
16
+ }
17
+ }
app/code/community/Listrak/Remarketing/Model/Mysql4/Subscriberupdate/Collection.php ADDED
@@ -0,0 +1,11 @@
1
+ <?php
2
+ // Listrak Remarketing Magento Extension Ver. 1.0.0
3
+ // © 2011 Listrak, Inc.
4
+
5
+ class Listrak_Remarketing_Model_Mysql4_Subscriberupdate_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
6
+ {
7
+ protected function _construct()
8
+ {
9
+ $this->_init('listrak/subscriberupdate');
10
+ }
11
+ }
app/code/community/Listrak/Remarketing/Model/Observer.php ADDED
@@ -0,0 +1,79 @@
1
+ <?php
2
+ // Listrak Remarketing Magento Extension Ver. 1.0.0
3
+ // © 2011 Listrak, Inc.
4
+
5
+ class Listrak_Remarketing_Model_Observer {
6
+
7
+ public function sessionInit($observer) {
8
+ try {
9
+ $session = Mage::getSingleton('listrak/session');
10
+ $session->init();
11
+
12
+ $click = Mage::getModel('listrak/click');
13
+ $click->checkForClick();
14
+ }
15
+ catch(Exception $ex) {
16
+ Mage::getModel("listrak/log")->addException($ex);
17
+ }
18
+
19
+ return $this;
20
+ }
21
+
22
+ public function orderPlaced($observer) {
23
+ try {
24
+ $cs = Mage::getSingleton('core/session');
25
+ $cs->setIsListrakOrderMade(true);
26
+ }
27
+ catch(Exception $ex) {
28
+ Mage::getModel("listrak/log")->addException($ex);
29
+ }
30
+
31
+ return $this;
32
+ }
33
+
34
+ public function subscriberSaved($observer) {
35
+ try {
36
+ $s = $observer->getSubscriber();
37
+ $su = Mage::getModel("listrak/subscriberupdate")->load($s->getSubscriberId(), 'subscriber_id');
38
+
39
+ if(!$su->getData()) {
40
+ $su->setSubscriberId($s->getSubscriberId());
41
+ }
42
+
43
+ $su->setUpdatedAt(gmdate('Y-m-d H:i:s'));
44
+ $su->save();
45
+ }
46
+ catch(Exception $ex) {
47
+ Mage::getModel("listrak/log")->addException($ex);
48
+ }
49
+
50
+ return $this;
51
+ }
52
+
53
+ public function adminPageLoad($observer) {
54
+ try {
55
+ if(Mage::getSingleton('admin/session')->isFirstPageAfterLogin() && !Mage::helper('remarketing')->checkSetupStatus()) {
56
+ $ae = Mage::getModel("listrak/apiextension_api");
57
+ $sc = $ae->subscribersPurge(gmdate("Y-m-d H:i:s", time() - 604800));
58
+ Mage::getModel("listrak/log")->addMessage("Purged $sc subscriber update entries.");
59
+
60
+ foreach (Mage::app()->getStores() as $storeId => $store) {
61
+ $msg = "";
62
+ $ab = Mage::getModel("listrak/abandonedcart_api");
63
+ $cl = Mage::getModel("listrak/click_api");
64
+ $l = Mage::getModel("listrak/log_api");
65
+
66
+ $msg .= "Purged " . $ab->purge($storeId, gmdate("Y-m-d H:i:s", time() - 604800)) . " abandoned carts/sessions\n";
67
+ $msg .= "Purged " . $cl->purge($storeId, gmdate("Y-m-d H:i:s", time() - 604800)) . " clicks\n";
68
+ $msg .= "Purged " . $l->purge($storeId, gmdate("Y-m-d H:i:s", time() - 604800)) . " log entries";
69
+ Mage::getModel("listrak/log")->addMessage($msg, $storeId);
70
+ }
71
+ }
72
+ }
73
+ catch(Exception $ex) {
74
+ Mage::getModel("listrak/log")->addException($ex);
75
+ }
76
+
77
+ return $this;
78
+ }
79
+ }
app/code/community/Listrak/Remarketing/Model/Session.php ADDED
@@ -0,0 +1,69 @@
1
+ <?php
2
+ // Listrak Remarketing Magento Extension Ver. 1.0.0
3
+ // © 2011 Listrak, Inc.
4
+
5
+ class Listrak_Remarketing_Model_Session extends Mage_Core_Model_Abstract {
6
+
7
+ public function _construct()
8
+ {
9
+ parent::_construct();
10
+ $this->_init('listrak/session');
11
+ }
12
+
13
+ public function init() {
14
+ $ltksid = Mage::getModel('core/cookie')->get('ltksid');
15
+ $cust_session = Mage::getSingleton("customer/session");
16
+
17
+ if(!empty($ltksid)) {
18
+ $this->setSessionId($ltksid);
19
+ $this->getResource()->loadBySessionId($this);
20
+ }
21
+
22
+ if(!$this->getId()) {
23
+ $this->setSessionId(Mage::helper('remarketing')->gen_uuid());
24
+ $this->setCreatedAt(gmdate('Y-m-d H:i:s'));
25
+ $this->setIsNew(true);
26
+ Mage::getModel('core/cookie')->set('ltksid', $this->getSessionId(), TRUE, NULL, NULL, NULL, FALSE);
27
+ }
28
+
29
+ if($cust_session->isLoggedIn()) {
30
+ $this->setCustomerId($cust_session->getId());
31
+ }
32
+
33
+ $quoteId = Mage::helper('checkout/cart')->getQuote()->getId();
34
+
35
+ if($quoteId)
36
+ $this->setQuoteId($quoteId);
37
+
38
+ $this->setStoreId(Mage::app()->getStore()->getStoreId());
39
+ $this->setUpdatedAt(gmdate('Y-m-d H:i:s'));
40
+
41
+ if(strlen($this->getIps()) > 0) {
42
+ if(strpos($this->getIps(), $_SERVER["REMOTE_ADDR"]) === FALSE)
43
+ $this->setIps($this->getIps() . "," . $_SERVER["REMOTE_ADDR"]);
44
+ }
45
+ else {
46
+ $this->setIps($_SERVER["REMOTE_ADDR"]);
47
+ }
48
+
49
+ $this->save();
50
+
51
+ $cs = Mage::getSingleton('core/session');
52
+
53
+ if($cs->getIsListrakOrderMade()) {
54
+ Mage::getModel('core/cookie')->delete('ltksid');
55
+ $cs->setIsListrakOrderMade(false);
56
+ }
57
+
58
+ return $this;
59
+ }
60
+
61
+ public function loadEmails() {
62
+ $this->getResource()->loadEmails($this);
63
+ }
64
+
65
+ public function delete() {
66
+ $del = $this->getResource()->deleteEmails($this->getId());
67
+ parent::delete();
68
+ }
69
+ }
app/code/community/Listrak/Remarketing/Model/Subscriber.php ADDED
@@ -0,0 +1,22 @@
1
+ <?php
2
+ // Listrak Remarketing Magento Extension Ver. 1.0.0
3
+ // © 2011 Listrak, Inc.
4
+
5
+ class Listrak_Remarketing_Model_Subscriber extends Mage_Newsletter_Model_Subscriber {
6
+
7
+ public function sendConfirmationSuccessEmail() {
8
+ if(!Mage::getStoreConfig('remarketing/subscription/signup_success_email')) {
9
+ return $this;
10
+ }
11
+
12
+ return parent::sendConfirmationSuccessEmail();
13
+ }
14
+
15
+ public function sendUnsubscriptionEmail() {
16
+ if(!Mage::getStoreConfig('remarketing/subscription/unsubscribe_email')) {
17
+ return $this;
18
+ }
19
+
20
+ return parent::sendUnsubscriptionEmail();
21
+ }
22
+ }
app/code/community/Listrak/Remarketing/Model/Subscriberupdate.php ADDED
@@ -0,0 +1,12 @@
1
+ <?php
2
+ // Listrak Remarketing Magento Extension Ver. 1.0.0
3
+ // © 2011 Listrak, Inc.
4
+
5
+ class Listrak_Remarketing_Model_Subscriberupdate extends Mage_Core_Model_Abstract
6
+ {
7
+ public function _construct()
8
+ {
9
+ parent::_construct();
10
+ $this->_init('listrak/subscriberupdate');
11
+ }
12
+ }
app/code/community/Listrak/Remarketing/controllers/Adminhtml/AbandonedcartreportController.php ADDED
@@ -0,0 +1,35 @@
1
+ <?php
2
+ // Listrak Remarketing Magento Extension Ver. 1.0.0
3
+ // © 2011 Listrak, Inc.
4
+
5
+ class Listrak_Remarketing_Adminhtml_AbandonedcartreportController extends Mage_Adminhtml_Controller_Action
6
+ {
7
+ protected function _initAction()
8
+ {
9
+ $this->loadLayout()
10
+ ->_setActiveMenu('listrak_menu');
11
+ return $this;
12
+ }
13
+
14
+ public function indexAction() {
15
+ try {
16
+ $this->_initAction();
17
+ $this->_addContent($this->getLayout()->createBlock('remarketing/adminhtml_abandonedcartreport'));
18
+ $this->renderLayout();
19
+ } catch(Exception $e) {
20
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
21
+ Mage::getSingleton('adminhtml/session')->setEmailCaptureData($this->getRequest()->getPost());
22
+ $this->_redirect('adminhtml/dashboard');
23
+ return;
24
+ }
25
+
26
+ }
27
+
28
+ public function gridAction()
29
+ {
30
+ $this->loadLayout();
31
+ $this->getResponse()->setBody(
32
+ $this->getLayout()->createBlock('importedit/adminhtml_abandonedcartreport_grid')->toHtml()
33
+ );
34
+ }
35
+ }
app/code/community/Listrak/Remarketing/controllers/Adminhtml/EmailcaptureController.php ADDED
@@ -0,0 +1,125 @@
1
+ <?php
2
+ // Listrak Remarketing Magento Extension Ver. 1.0.0
3
+ // © 2011 Listrak, Inc.
4
+
5
+ class Listrak_Remarketing_Adminhtml_EmailCaptureController extends Mage_Adminhtml_Controller_Action
6
+ {
7
+
8
+ protected function _initAction()
9
+ {
10
+ $this->loadLayout()
11
+ ->_setActiveMenu('emailcapture')
12
+ ->_addBreadcrumb(Mage::helper('adminhtml')->__('Fields Manager'), Mage::helper('adminhtml')->__('Field Manager'));
13
+ return $this;
14
+ }
15
+
16
+ public function indexAction() {
17
+ try {
18
+ $this->_initAction();
19
+ $this->_addContent($this->getLayout()->createBlock('remarketing/adminhtml_emailcapture'));
20
+ $this->renderLayout();
21
+ } catch(Exception $e) {
22
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
23
+ Mage::getSingleton('adminhtml/session')->setEmailCaptureData($this->getRequest()->getPost());
24
+ $this->_redirect('adminhtml/dashboard');
25
+ return;
26
+ }
27
+
28
+ }
29
+
30
+ public function editAction()
31
+ {
32
+ try {
33
+ $emailcaptureId = $this->getRequest()->getParam('id');
34
+ $emailcaptureModel = Mage::getModel('listrak/emailcapture')->load($emailcaptureId);
35
+
36
+ if ($emailcaptureModel->getId() || $emailcaptureId == 0) {
37
+
38
+ Mage::register('emailcapture_data', $emailcaptureModel);
39
+
40
+ $this->loadLayout();
41
+ $this->_setActiveMenu('emailcapture');
42
+
43
+ $this->_addBreadcrumb(Mage::helper('adminhtml')->__('Item Manager'), Mage::helper('adminhtml')->__('Item Manager'));
44
+ $this->_addBreadcrumb(Mage::helper('adminhtml')->__('Item News'), Mage::helper('adminhtml')->__('Item News'));
45
+
46
+ $this->getLayout()->getBlock('head')->setCanLoadExtJs(true);
47
+
48
+ $this->_addContent($this->getLayout()->createBlock('remarketing/adminhtml_emailcapture_edit'))
49
+ ->_addLeft($this->getLayout()->createBlock('remarketing/adminhtml_emailcapture_edit_tabs'));
50
+
51
+ $this->renderLayout();
52
+ } else {
53
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('remarketing')->__('Item does not exist'));
54
+ $this->_redirect('*/*/');
55
+ }
56
+ } catch (Exception $e) {
57
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
58
+ Mage::getSingleton('adminhtml/session')->setEmailCaptureData($this->getRequest()->getPost());
59
+ $this->_redirect('*/*/index', array('id' => $this->getRequest()->getParam('id')));
60
+ return;
61
+ }
62
+ }
63
+
64
+ public function newAction()
65
+ {
66
+ $this->_forward('edit');
67
+ }
68
+
69
+ public function saveAction()
70
+ {
71
+ if ( $this->getRequest()->getPost() ) {
72
+ try {
73
+ $postData = $this->getRequest()->getPost();
74
+ $emailcaptureModel = Mage::getModel('listrak/emailcapture');
75
+
76
+ $emailcaptureModel->setId($this->getRequest()->getParam('id'))
77
+ ->setPage($postData['page'])
78
+ ->setFieldId($postData['field_id'])
79
+ ->save();
80
+
81
+ Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('adminhtml')->__('Item was successfully saved'));
82
+ Mage::getSingleton('adminhtml/session')->setEmailCaptureData(false);
83
+
84
+ $this->_redirect('*/*/');
85
+ return;
86
+ } catch (Exception $e) {
87
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
88
+ Mage::getSingleton('adminhtml/session')->setEmailCaptureData($this->getRequest()->getPost());
89
+ $this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
90
+ return;
91
+ }
92
+ }
93
+ $this->_redirect('*/*/');
94
+ }
95
+
96
+ public function deleteAction()
97
+ {
98
+ if( $this->getRequest()->getParam('id') > 0 ) {
99
+ try {
100
+ $emailcaptureModel = Mage::getModel('listrak/emailcapture');
101
+
102
+ $emailcaptureModel->setId($this->getRequest()->getParam('id'))
103
+ ->delete();
104
+
105
+ Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('adminhtml')->__('Item was successfully deleted'));
106
+ $this->_redirect('*/*/');
107
+ } catch (Exception $e) {
108
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
109
+ $this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
110
+ }
111
+ }
112
+ $this->_redirect('*/*/');
113
+ }
114
+ /**
115
+ * Product grid for AJAX request.
116
+ * Sort and filter result for example.
117
+ */
118
+ public function gridAction()
119
+ {
120
+ $this->loadLayout();
121
+ $this->getResponse()->setBody(
122
+ $this->getLayout()->createBlock('importedit/adminhtml_emailcapture_grid')->toHtml()
123
+ );
124
+ }
125
+ }
app/code/community/Listrak/Remarketing/controllers/CartController.php ADDED
@@ -0,0 +1,60 @@
1
+ <?php
2
+ // Listrak Remarketing Magento Extension Ver. 1.0.0
3
+ // © 2011 Listrak, Inc.
4
+
5
+ class Listrak_Remarketing_CartController extends Mage_Core_Controller_Front_Action
6
+ {
7
+ public function indexAction() {
8
+ return $this;
9
+