Listrak_Remarketing - Version 1.1.5

Version Notes

Added support for product brand and category.
Added support for configurable products.
Added support for WS-I compliant API.

Download this release

Release Info

Developer Magento Core Team
Extension Listrak_Remarketing
Version 1.1.5
Comparing to
See all releases


Code changes from version 1.1.4 to 1.1.5

Files changed (63) hide show
  1. app/code/community/Listrak/Remarketing/Block/Adminhtml/Abandonedcartreport.php +7 -7
  2. app/code/community/Listrak/Remarketing/Block/Adminhtml/Abandonedcartreport/Grid.php +86 -86
  3. app/code/community/Listrak/Remarketing/Block/Adminhtml/Emailcapture/Edit/Tab/Form.php +26 -26
  4. app/code/community/Listrak/Remarketing/Block/Adminhtml/Notifications.php +18 -10
  5. app/code/community/Listrak/Remarketing/Block/Adminhtml/Productattributes.php +48 -0
  6. app/code/community/Listrak/Remarketing/Block/Adminhtml/Productattributes/Edit.php +24 -0
  7. app/code/community/Listrak/Remarketing/Block/Adminhtml/Productattributes/Edit/Form.php +21 -0
  8. app/code/community/Listrak/Remarketing/Block/Adminhtml/Productattributes/Edit/Tab/Form/Brand.php +31 -0
  9. app/code/community/Listrak/Remarketing/Block/Adminhtml/Productattributes/Edit/Tab/Form/Categories.php +46 -0
  10. app/code/community/Listrak/Remarketing/Block/Adminhtml/Productattributes/Edit/Tabs.php +49 -0
  11. app/code/community/Listrak/Remarketing/Block/Adminhtml/Productattributes/Grid.php +79 -0
  12. app/code/community/Listrak/Remarketing/Block/Adminhtml/Productattributes/Init/Brands.php +31 -0
  13. app/code/community/Listrak/Remarketing/Block/Adminhtml/Productattributes/Init/Brands/Form.php +67 -0
  14. app/code/community/Listrak/Remarketing/Block/Ecjs.php +14 -14
  15. app/code/community/Listrak/Remarketing/Block/Modal.php +7 -7
  16. app/code/community/Listrak/Remarketing/Helper/Data.php +61 -33
  17. app/code/community/Listrak/Remarketing/Helper/Product.php +214 -0
  18. app/code/community/Listrak/Remarketing/Helper/Product/Attribute/Set/Map.php +42 -0
  19. app/code/community/Listrak/Remarketing/Model/Abandonedcart.php +5 -5
  20. app/code/community/Listrak/Remarketing/Model/Abandonedcart/Api.php +6 -4
  21. app/code/community/Listrak/Remarketing/Model/Apiextension/Api.php +278 -222
  22. app/code/community/Listrak/Remarketing/Model/Click.php +6 -6
  23. app/code/community/Listrak/Remarketing/Model/Click/Api.php +6 -6
  24. app/code/community/Listrak/Remarketing/Model/Emailcapture.php +4 -4
  25. app/code/community/Listrak/Remarketing/Model/Log.php +4 -4
  26. app/code/community/Listrak/Remarketing/Model/Log/Api.php +3 -3
  27. app/code/community/Listrak/Remarketing/Model/Mysql4/Abandonedcart.php +34 -34
  28. app/code/community/Listrak/Remarketing/Model/Mysql4/Abandonedcart/Collection.php +14 -14
  29. app/code/community/Listrak/Remarketing/Model/Mysql4/Click.php +19 -19
  30. app/code/community/Listrak/Remarketing/Model/Mysql4/Click/Collection.php +7 -7
  31. app/code/community/Listrak/Remarketing/Model/Mysql4/Emailcapture.php +6 -6
  32. app/code/community/Listrak/Remarketing/Model/Mysql4/Emailcapture/Collection.php +3 -3
  33. app/code/community/Listrak/Remarketing/Model/Mysql4/Log.php +6 -6
  34. app/code/community/Listrak/Remarketing/Model/Mysql4/Log/Collection.php +8 -8
  35. app/code/community/Listrak/Remarketing/Model/Mysql4/Product/Attribute/Set/Map.php +20 -0
  36. app/code/community/Listrak/Remarketing/Model/Mysql4/Product/Attribute/Set/Map/Collection.php +92 -0
  37. app/code/community/Listrak/Remarketing/Model/Mysql4/Review/Update.php +19 -19
  38. app/code/community/Listrak/Remarketing/Model/Mysql4/Session.php +22 -21
  39. app/code/community/Listrak/Remarketing/Model/Mysql4/Session/Collection.php +7 -7
  40. app/code/community/Listrak/Remarketing/Model/Mysql4/Subscriberupdate.php +6 -6
  41. app/code/community/Listrak/Remarketing/Model/Observer.php +73 -73
  42. app/code/community/Listrak/Remarketing/Model/Product/Attribute/Set/Map.php +81 -0
  43. app/code/community/Listrak/Remarketing/Model/Product/Attributes.php +37 -0
  44. app/code/community/Listrak/Remarketing/Model/Product/Category/Source.php +16 -0
  45. app/code/community/Listrak/Remarketing/Model/Review/Update.php +37 -37
  46. app/code/community/Listrak/Remarketing/Model/Session.php +4 -4
  47. app/code/community/Listrak/Remarketing/Model/Subscriber.php +12 -12
  48. app/code/community/Listrak/Remarketing/controllers/Adminhtml/AbandonedcartreportController.php +23 -23
  49. app/code/community/Listrak/Remarketing/controllers/Adminhtml/EmailcaptureController.php +101 -101
  50. app/code/community/Listrak/Remarketing/controllers/Adminhtml/ProductattributesController.php +142 -0
  51. app/code/community/Listrak/Remarketing/controllers/CartController.php +4 -5
  52. app/code/community/Listrak/Remarketing/etc/adminhtml.xml +18 -9
  53. app/code/community/Listrak/Remarketing/etc/config.xml +122 -116
  54. app/code/community/Listrak/Remarketing/etc/system.xml +114 -94
  55. app/code/community/Listrak/Remarketing/etc/wsdl.xml +888 -861
  56. app/code/community/Listrak/Remarketing/etc/wsi.xml +1142 -78
  57. app/code/community/Listrak/Remarketing/sql/listrak_remarketing_setup/mysql4-install-1.0.0.php +0 -14
  58. app/code/community/Listrak/Remarketing/sql/listrak_remarketing_setup/mysql4-upgrade-1.1.4-1.1.5.php +43 -0
  59. app/design/adminhtml/default/default/layout/remarketing.xml +5 -5
  60. app/design/adminhtml/default/default/template/listrak/remarketing/productattributes.phtml +21 -0
  61. app/design/adminhtml/default/default/template/listrak/remarketing/productattributes/form/categories.phtml +137 -0
  62. app/design/adminhtml/default/default/template/listrak/remarketing/productattributes/form/initbrands.phtml +44 -0
  63. package.xml +7 -5
app/code/community/Listrak/Remarketing/Block/Adminhtml/Abandonedcartreport.php CHANGED
@@ -4,12 +4,12 @@
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
}
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 CHANGED
@@ -4,108 +4,108 @@
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
}
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/Edit/Tab/Form.php CHANGED
@@ -4,35 +4,35 @@
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
}
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/Notifications.php CHANGED
@@ -4,17 +4,25 @@
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
}
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
+ if (strpos(Mage::helper('core/url')->getCurrentUrl(), "/adminhtml_productattributes/") === false
19
+ && Mage::helper('remarketing')->displayAttributeSetNotification()
20
+ ) {
21
+ $html .= "<div class='notification-global'>Brand attribute has not been defined for one or more attribute sets. Please " .
22
+ "<a href='" . Mage::helper('adminhtml')->getUrl('remarketing/adminhtml_productattributes/index') . "'>click here</a>, " .
23
+ "or go to Listrak > Product Attributes to review your current settings.</div>";
24
+ }
25
+
26
+ return $html;
27
+ }
28
}
app/code/community/Listrak/Remarketing/Block/Adminhtml/Productattributes.php ADDED
@@ -0,0 +1,48 @@
1
+ <?php
2
+ // Listrak Remarketing Magento Extension Ver. 1.1.5
3
+ // � 2013 Listrak, Inc.
4
+
5
+ class Listrak_Remarketing_Block_Adminhtml_ProductAttributes extends Mage_Adminhtml_Block_Widget_Container
6
+ {
7
+ public function __construct()
8
+ {
9
+ parent::__construct();
10
+ $this->_controller = 'adminhtml_productattributes';
11
+ $this->_removeButton('add');
12
+
13
+ $this->setTemplate('listrak/remarketing/productattributes.phtml');
14
+ }
15
+
16
+ public function _prepareLayout()
17
+ {
18
+ $this->setChild('grid', $this->getLayout()->createBlock('remarketing/adminhtml_productattributes_grid'));
19
+ $this->setChild('init_brands', $this->getLayout()->createBlock('remarketing/adminhtml_productattributes_init_brands'));
20
+ return parent::_prepareLayout();
21
+ }
22
+
23
+ public function getInitBrandsHtml()
24
+ {
25
+ return $this->getChildHtml('init_brands');
26
+ }
27
+
28
+ public function getGridHtml()
29
+ {
30
+ return $this->getChildHtml('grid');
31
+ }
32
+
33
+ public function setsWithoutBrandAttribute()
34
+ {
35
+ $sets = array();
36
+
37
+ $allSets = Mage::registry('productattribute_sets');
38
+ foreach($allSets as $set)
39
+ {
40
+ if ($set->getBrandAttributeCode() == null)
41
+ array_push($sets, $set);
42
+ }
43
+
44
+ return $sets;
45
+ }
46
+ }
47
+
48
+ ?>
app/code/community/Listrak/Remarketing/Block/Adminhtml/Productattributes/Edit.php ADDED
@@ -0,0 +1,24 @@
1
+ <?php
2
+ // Listrak Remarketing Magento Extension Ver. 1.1.5
3
+ // � 2013 Listrak, Inc.
4
+
5
+ class Listrak_Remarketing_Block_Adminhtml_ProductAttributes_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_productattributes';
14
+
15
+ $this->_removeButton('delete');
16
+ }
17
+
18
+ public function getHeaderText()
19
+ {
20
+ return Mage::registry('productattribute_data')->getAttributeSetName();
21
+ }
22
+ }
23
+
24
+ ?>
app/code/community/Listrak/Remarketing/Block/Adminhtml/Productattributes/Edit/Form.php ADDED
@@ -0,0 +1,21 @@
1
+ <?php
2
+ // Listrak Remarketing Magento Extension Ver. 1.1.5
3
+ // � 2013 Listrak, Inc.
4
+
5
+ class Listrak_Remarketing_Block_Adminhtml_Productattributes_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
+ $form->setUseContainer(true);
16
+ $this->setForm($form);
17
+ return parent::_prepareForm();
18
+ }
19
+ }
20
+
21
+ ?>
app/code/community/Listrak/Remarketing/Block/Adminhtml/Productattributes/Edit/Tab/Form/Brand.php ADDED
@@ -0,0 +1,31 @@
1
+ <?php
2
+ // Listrak Remarketing Magento Extension Ver. 1.1.5
3
+ // � 2013 Listrak, Inc.
4
+
5
+ class Listrak_Remarketing_Block_Adminhtml_Productattributes_Edit_Tab_Form_Brand 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('productattribute_form', array('legend'=>Mage::helper('remarketing')->__('Field information')));
12
+
13
+ $attributeCodes = array();
14
+ $attributeCodes[''] = '- No Brand Attribute -';
15
+ foreach($this->getAttributeOptions() as $key => $value)
16
+ {
17
+ $attributeCodes[$key] = $value;
18
+ }
19
+
20
+ $fieldset->addField('brand_attribute', 'select', array(
21
+ 'label' => Mage::helper('remarketing')->__('Brand Attribute'),
22
+ 'name' => 'brand_attribute',
23
+ 'values' => $attributeCodes,
24
+ 'value' => Mage::registry('productattribute_data')->getBrandAttributeCode()
25
+ ));
26
+
27
+ return parent::_prepareForm();
28
+ }
29
+ }
30
+
31
+ ?>
app/code/community/Listrak/Remarketing/Block/Adminhtml/Productattributes/Edit/Tab/Form/Categories.php ADDED
@@ -0,0 +1,46 @@
1
+ <?php
2
+ // Listrak Remarketing Magento Extension Ver. 1.1.5
3
+ // � 2013 Listrak, Inc.
4
+
5
+ class Listrak_Remarketing_Block_Adminhtml_Productattributes_Edit_Tab_Form_Categories extends Mage_Adminhtml_Block_Widget
6
+ {
7
+ public function __construct()
8
+ {
9
+ parent::__construct();
10
+ $this->setTemplate('listrak/remarketing/productattributes/form/categories.phtml');
11
+
12
+ $this->setModel(Mage::registry('productattribute_data'));
13
+ }
14
+
15
+ public function getCategoriesSource()
16
+ {
17
+ if ($this->getUseConfigCategoriesSource())
18
+ {
19
+ return $this->getConfigCategoriesSource();
20
+ }
21
+
22
+ return $this->getModel()->getCategoriesSource();
23
+ }
24
+
25
+ public function getConfigCategoriesSource()
26
+ {
27
+ return Mage::helper('remarketing')->categoriesSource();
28
+ }
29
+
30
+ public function getUseConfigCategoriesSource()
31
+ {
32
+ return $this->getModel()->getUseConfigCategoriesSource();
33
+ }
34
+
35
+ public function getCategoryAttributeCode()
36
+ {
37
+ return $this->getModel()->getCategoryAttributeCode();
38
+ }
39
+
40
+ public function getSubcategoryAttributeCode()
41
+ {
42
+ return $this->getModel()->getSubcategoryAttributeCode();
43
+ }
44
+ }
45
+
46
+ ?>
app/code/community/Listrak/Remarketing/Block/Adminhtml/Productattributes/Edit/Tabs.php ADDED
@@ -0,0 +1,49 @@
1
+ <?php
2
+ // Listrak Remarketing Magento Extension Ver. 1.1.5
3
+ // � 2013 Listrak, Inc.
4
+
5
+ class Listrak_Remarketing_Block_Adminhtml_Productattributes_Edit_Tabs extends Mage_Adminhtml_Block_Widget_Tabs
6
+ {
7
+ public function __construct()
8
+ {
9
+ parent::__construct();
10
+
11
+ $this->setId('productattributes_map_tabs');
12
+ $this->setDestElementId('edit_form');
13
+ $this->setTitle(Mage::helper('remarketing')->__('Map Attributes'));
14
+ }
15
+
16
+ public function _prepareLayout()
17
+ {
18
+ $attributeCodes = $this->attributeSetAttributes(Mage::registry('productattribute_data')->getAttributeSetId());
19
+
20
+ $this->addTab('productattributes_brand', array(
21
+ 'label' => Mage::helper('remarketing')->__('Brand'),
22
+ 'content' => $this->getLayout()->createBlock('remarketing/adminhtml_productattributes_edit_tab_form_brand')->setAttributeOptions($attributeCodes)->toHtml()
23
+ ));
24
+
25
+ $this->addTab('productattributes_categories', array(
26
+ 'label' => Mage::helper('remarketing')->__('Category and Subcategory'),
27
+ 'content' => $this->getLayout()->createBlock('remarketing/adminhtml_productattributes_edit_tab_form_categories')->setAttributeOptions($attributeCodes)->toHtml()
28
+ ));
29
+ }
30
+
31
+ private function attributeSetAttributes($setId)
32
+ {
33
+ $collection = Mage::getResourceModel('catalog/product_attribute_collection')
34
+ ->setAttributeSetFilter($setId)
35
+ ->addVisibleFilter();
36
+
37
+ $attributes = array();
38
+ foreach($collection as $value)
39
+ {
40
+ $attributes[$value->getAttributeCode()] = $value->getFrontendLabel() . ' (' . $value->getAttributeCode() . ')';
41
+ }
42
+
43
+ asort($attributes);
44
+
45
+ return $attributes;
46
+ }
47
+ }
48
+
49
+ ?>
app/code/community/Listrak/Remarketing/Block/Adminhtml/Productattributes/Grid.php ADDED
@@ -0,0 +1,79 @@
1
+ <?php
2
+ // Listrak Remarketing Magento Extension Ver. 1.1.5
3
+ // � 2013 Listrak, Inc.
4
+
5
+ class Listrak_Remarketing_Block_Adminhtml_ProductAttributes_Grid extends Mage_Adminhtml_Block_Widget_Grid
6
+ {
7
+ public function __construct()
8
+ {
9
+ parent::__construct();
10
+ $this->setId('productattributesGrid');
11
+ $this->setDefaultSort('attribute_set_name');
12
+ $this->setDefaultDir('ASC');
13
+ $this->setSaveParametersInSession(false);
14
+ }
15
+
16
+ protected function _prepareCollection()
17
+ {
18
+ $collection = Mage::registry('productattribute_sets');
19
+
20
+ // prepare visible fields
21
+ foreach($collection as $item)
22
+ {
23
+ $item->setFrontendCategoriesSource($item->frontendCategoriesSource());
24
+ $item->setFrontendBrandAttribute($item->frontendBrandAttribute());
25
+ $item->setFrontendCategoryAttribute($item->frontendCategoryAttribute());
26
+ $item->setFrontendSubcategoryAttribute($item->frontendSubcategoryAttribute());
27
+ }
28
+
29
+ $this->setCollection($collection);
30
+ return parent::_prepareCollection();
31
+ }
32
+
33
+ protected function _prepareColumns()
34
+ {
35
+ $this->addColumn('attribute_set', array(
36
+ 'header' => Mage::helper('remarketing')->__('Attribute Set Name'),
37
+ 'align' => 'left',
38
+ 'index' => 'attribute_set_name',
39
+ 'filter' => false
40
+ ));
41
+
42
+ $this->addColumn('brand_attribute', array(
43
+ 'header' => Mage::helper('remarketing')->__('Brand Attribute'),
44
+ 'align' => 'left',
45
+ 'index' => 'frontend_brand_attribute',
46
+ 'filter' => false
47
+ ));
48
+
49
+ $this->addColumn('categories_source', array(
50
+ 'header' => Mage::helper('remarketing')->__('Category Source'),
51
+ 'align' => 'left',
52
+ 'index' => 'frontend_categories_source',
53
+ 'filter' => false
54
+ ));
55
+
56
+ $this->addColumn('category_attribute', array(
57
+ 'header' => Mage::helper('remarketing')->__('Category Attribute'),
58
+ 'align' => 'left',
59
+ 'index' => 'frontend_category_attribute',
60
+ 'filter' => false
61
+ ));
62
+
63
+ $this->addColumn('subcategory_attribute', array(
64
+ 'header' => Mage::helper('remarketing')->__('Subcategory Attribute'),
65
+ 'align' => 'left',
66
+ 'index' => 'frontend_subcategory_attribute',
67
+ 'filter' => false
68
+ ));
69
+
70
+ return parent::_prepareColumns();
71
+ }
72
+
73
+ public function getRowUrl($row)
74
+ {
75
+ return $this->getUrl('*/*/edit', array('id' => $row->getId()));
76
+ }
77
+ }
78
+
79
+ ?>
app/code/community/Listrak/Remarketing/Block/Adminhtml/Productattributes/Init/Brands.php ADDED
@@ -0,0 +1,31 @@
1
+ <?php
2
+ // Listrak Remarketing Magento Extension Ver. 1.1.5
3
+ // � 2013 Listrak, Inc.
4
+
5
+ class Listrak_Remarketing_Block_Adminhtml_Productattributes_Init_Brands extends Mage_Adminhtml_Block_Template
6
+ {
7
+ public function __construct()
8
+ {
9
+ parent::__construct();
10
+ $this->setTemplate('listrak/remarketing/productattributes/form/initbrands.phtml');
11
+ }
12
+
13
+ public function _prepareLayout()
14
+ {
15
+ $this->setChild('form', $this->getLayout()->createBlock('remarketing/adminhtml_productattributes_init_brands_form'));
16
+ $this->setChild('form-elements', $this->getLayout()->createBlock('remarketing/adminhtml_productattributes_init_brands_form_attributes'));
17
+ return parent::_prepareLayout();
18
+ }
19
+
20
+ public function getFormHtml()
21
+ {
22
+ return $this->getChildHtml('form');
23
+ }
24
+
25
+ public function getFormElementsHtml()
26
+ {
27
+ return $this->getChildHtml('form-elements');
28
+ }
29
+ }
30
+
31
+ ?>
app/code/community/Listrak/Remarketing/Block/Adminhtml/Productattributes/Init/Brands/Form.php ADDED
@@ -0,0 +1,67 @@
1
+ <?php
2
+ // Listrak Remarketing Magento Extension Ver. 1.1.5
3
+ // � 2013 Listrak, Inc.
4
+
5
+ class Listrak_Remarketing_Block_Adminhtml_Productattributes_Init_Brands_Form extends Mage_Adminhtml_Block_Widget_Form
6
+ {
7
+ protected function _prepareForm()
8
+ {
9
+ $form = new Varien_Data_Form(array(
10
+ 'id' => 'bulk_form',
11
+ 'action' => $this->getUrl('*/*/bulkassign'),
12
+ 'method' => 'post'
13
+ ));
14
+
15
+ $attributeCodes = array();
16
+ $attributeCodes[''] = '- No Brand Attribute -';
17
+ foreach($this->availableAttributes() as $key => $value)
18
+ {
19
+ $attributeCodes[$key] = $value;
20
+ }
21
+
22
+ $form->addField('bulkassign_attribute', 'select', array(
23
+ 'label' => Mage::helper('remarketing')->__('Attribute'),
24
+ 'name' => 'bulkassign_attribute',
25
+ 'values' => $attributeCodes
26
+ ));
27
+
28
+ $form->addField('bulkassign_submit', 'button', array(
29
+ 'class' => 'form-button',
30
+ 'value' => Mage::helper('remarketing')->__('Set')
31
+ ));
32
+
33
+ $form->setUseContainer(true);
34
+ $this->setForm($form);
35
+ return parent::_prepareForm();
36
+ }
37
+
38
+ public function availableAttributes()
39
+ {
40
+ $everything = Mage::registry('productattribute_sets');
41
+ $attributes = array();
42
+
43
+ foreach($everything as $item)
44
+ {
45
+ if ($item->getBrandAttributeCode() == null)
46
+ {
47
+ //get the attributes for this attribute set and add them to the attributes array
48
+ $collection = Mage::getResourceModel('catalog/product_attribute_collection')
49
+ ->setAttributeSetFilter($item->getAttributeSetId())
50
+ ->addVisibleFilter();
51
+ foreach($collection as $attribute)
52
+ {
53
+ if (!array_key_exists($attribute->getAttributeCode(), $attributes))
54
+ {
55
+ $attributes[$attribute->getAttributeCode()] = $attribute->getFrontendLabel() . ' ('. $attribute->getAttributeCode() . ')';
56
+ }
57
+ }
58
+ }
59
+ }
60
+
61
+ asort($attributes);
62
+
63
+ return $attributes;
64
+ }
65
+ }
66
+
67
+ ?>
app/code/community/Listrak/Remarketing/Block/Ecjs.php CHANGED
@@ -5,10 +5,10 @@
5
class Listrak_Remarketing_Block_Ecjs extends Mage_Core_Block_Text
6
{
7
8
- public function getPageName()
9
- {
10
- return $this->_getData('page_name');
11
- }
12
13
public function getMatchingPages()
14
{
@@ -54,9 +54,9 @@ class Listrak_Remarketing_Block_Ecjs extends Mage_Core_Block_Text
54
55
protected function _toHtml()
56
{
57
- if (!Mage::helper('remarketing')->coreEnabled())
58
- return "";
59
-
60
$collections = Mage::getModel('listrak/emailcapture')->getCollection()->addFieldToFilter('page', $this->getMatchingPages());
61
62
if($collections && $collections->count()) {
@@ -67,12 +67,12 @@ class Listrak_Remarketing_Block_Ecjs extends Mage_Core_Block_Text
67
$html[] = 'arrEcjs = [];';
68
$html[] = 'function _ecjs(ecid,email) { new Ajax.Request("' . $this->getAjaxUrl() . '", {parameters:{cid: ecid, email: email}}); }';
69
$html[] = 'function ecjsInit() {' .
70
- 'for(var ecjsi = 0; ecjsi < arrEcjs.length; ecjsi++) {' .
71
- 'if($(arrEcjs[ecjsi].id)) {' .
72
- '$(arrEcjs[ecjsi].id).stopObserving("change", arrEcjs[ecjsi].fn);' .
73
- '$(arrEcjs[ecjsi].id).observe("change", arrEcjs[ecjsi].fn);' .
74
- '}' .
75
- '}' .
76
'}';
77
78
foreach($collections as $observer) {
@@ -85,7 +85,7 @@ class Listrak_Remarketing_Block_Ecjs extends Mage_Core_Block_Text
85
$html[] = 'document.observe("dom:loaded", function() { ecjsInit(); ';
86
$html[] = 'Ajax.Responders.register({' .
87
'onComplete: function() {' .
88
- 'ecjsInit();' .
89
'}' .
90
'});});';
91
5
class Listrak_Remarketing_Block_Ecjs extends Mage_Core_Block_Text
6
{
7
8
+ public function getPageName()
9
+ {
10
+ return $this->_getData('page_name');
11
+ }
12
13
public function getMatchingPages()
14
{
54
55
protected function _toHtml()
56
{
57
+ if (!Mage::helper('remarketing')->coreEnabled())
58
+ return "";
59
+
60
$collections = Mage::getModel('listrak/emailcapture')->getCollection()->addFieldToFilter('page', $this->getMatchingPages());
61
62
if($collections && $collections->count()) {
67
$html[] = 'arrEcjs = [];';
68
$html[] = 'function _ecjs(ecid,email) { new Ajax.Request("' . $this->getAjaxUrl() . '", {parameters:{cid: ecid, email: email}}); }';
69
$html[] = 'function ecjsInit() {' .
70
+ 'for(var ecjsi = 0; ecjsi < arrEcjs.length; ecjsi++) {' .
71
+ 'if($(arrEcjs[ecjsi].id)) {' .
72
+ '$(arrEcjs[ecjsi].id).stopObserving("change", arrEcjs[ecjsi].fn);' .
73
+ '$(arrEcjs[ecjsi].id).observe("change", arrEcjs[ecjsi].fn);' .
74
+ '}' .
75
+ '}' .
76
'}';
77
78
foreach($collections as $observer) {
85
$html[] = 'document.observe("dom:loaded", function() { ecjsInit(); ';
86
$html[] = 'Ajax.Responders.register({' .
87
'onComplete: function() {' .
88
+ 'ecjsInit();' .
89
'}' .
90
'});});';
91
app/code/community/Listrak/Remarketing/Block/Modal.php CHANGED
@@ -5,16 +5,16 @@
5
class Listrak_Remarketing_Block_Modal extends Mage_Core_Block_Text
6
{
7
8
- public function getPageName()
9
- {
10
- return $this->_getData('page_name');
11
- }
12
13
protected function _toHtml()
14
{
15
- if (!Mage::helper("remarketing")->coreEnabled())
16
- return "";
17
-
18
$merchantID = Mage::getStoreConfig('remarketing/modal/listrakMerchantID');
19
if(!Mage::getStoreConfig('remarketing/modal/enabled') || strlen(Mage::getStoreConfig('remarketing/modal/scriptLocation')) < 1 || strlen(trim($merchantID)) < 12) {
20
return "";
5
class Listrak_Remarketing_Block_Modal extends Mage_Core_Block_Text
6
{
7
8
+ public function getPageName()
9
+ {
10
+ return $this->_getData('page_name');
11
+ }
12
13
protected function _toHtml()
14
{
15
+ if (!Mage::helper("remarketing")->coreEnabled())
16
+ return "";
17
+
18
$merchantID = Mage::getStoreConfig('remarketing/modal/listrakMerchantID');
19
if(!Mage::getStoreConfig('remarketing/modal/enabled') || strlen(Mage::getStoreConfig('remarketing/modal/scriptLocation')) < 1 || strlen(trim($merchantID)) < 12) {
20
return "";
app/code/community/Listrak/Remarketing/Helper/Data.php CHANGED
@@ -4,48 +4,76 @@
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
- public function coreEnabled() {
34
- return Mage::getStoreConfig('remarketing/modules/core');
35
- }
36
-
37
- public function reviewsEnabled() {
38
- return Mage::getStoreConfig('remarketing/modules/reviews');
39
- }
40
-
41
- public function requireCoreEnabled() {
42
- if (!$this->coreEnabled())
43
- throw new Exception('Listrak core functionality has been turned off in the System Configuration.');
44
- }
45
-
46
- public function requireReviewsEnabled() {
47
- if (!$this->reviewsEnabled())
48
- throw new Exception('Listrak reviews API has been turned off in the System Configuration.');
49
- }
50
}
51
4
5
class Listrak_Remarketing_Helper_Data extends Mage_Core_Helper_Abstract
6
{
7
+ private $customer_groups;
8
+
9
+ public function setGroupNameAndGenderNameForCustomer($customer) {
10
+ if ($customer_groups == null) {
11
+ $customer_groups = array();
12
+ foreach (Mage::getModel('customer/group')->getCollection() as $group)
13
+ $customer_groups[$group['customer_group_id']] = $group['customer_group_code'];
14
+ }
15
+ if (array_key_exists($customer->getGroupId(), $customer_groups))
16
+ $customer->setGroupName($customer_groups[$customer->getGroupId()]);
17
+ $customer->setGenderName(Mage::getResourceSingleton('customer/customer')->getAttribute('gender')->getSource()->getOptionText($customer->getGender()));
18
+ }
19
+
20
public function gen_uuid() {
21
+ return sprintf( '%04x%04x-%04x-%04x-%04x-%04x%04x%04x',
22
+ // 32 bits for "time_low"
23
+ mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff ),
24
25
+ // 16 bits for "time_mid"
26
+ mt_rand( 0, 0xffff ),
27
28
+ // 16 bits for "time_hi_and_version",
29
+ // four most significant bits holds version number 4
30
+ mt_rand( 0, 0x0fff ) | 0x4000,
31
32
+ // 16 bits, 8 bits for "clk_seq_hi_res",
33
+ // 8 bits for "clk_seq_low",
34
+ // two most significant bits holds zero and one for variant DCE1.1
35
+ mt_rand( 0, 0x3fff ) | 0x8000,
36
37
+ // 48 bits for "node"
38
+ mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff )
39
+ );
40
}
41
42
public function checkSetupStatus() {
43
return Mage::getStoreConfig('remarketing/config/account_created');
44
}
45
+
46
+ public function displayAttributeSetNotification() {
47
+ return (Mage::helper('remarketing/product_attribute_set_map')->newAttributeSetsCollection()->count() > 0);
48
+ }
49
+
50
+ public function coreEnabled() {
51
+ return Mage::getStoreConfig('remarketing/modules/core');
52
+ }
53
+
54
+ public function reviewsEnabled() {
55
+ return Mage::getStoreConfig('remarketing/modules/reviews');
56
+ }
57
+
58
+ public function requireCoreEnabled() {
59
+ if (!$this->coreEnabled())
60
+ throw new Exception('Listrak core functionality has been turned off in the System Configuration.');
61
+ }
62
+
63
+ public function requireReviewsEnabled() {
64
+ if (!$this->reviewsEnabled())
65
+ throw new Exception('Listrak reviews API has been turned off in the System Configuration.');
66
+ }
67
+
68
+ public function categoriesSource() {
69
+ return Mage::getStoreConfig('remarketing/productcategories/categories_source');
70
+ }
71
+
72
+ public function getCategoryRootIdForStore($storeId)
73
+ {
74
+ return Mage::getModel('core/store_group')
75
+ ->load(Mage::getModel('core/store')->load($storeId)->getGroupId())
76
+ ->getRootCategoryId();
77
+ }
78
}
79
app/code/community/Listrak/Remarketing/Helper/Product.php ADDED
@@ -0,0 +1,214 @@
1
+ <?php
2
+ // Listrak Remarketing Magento Extension Ver. 1.1.5
3
+ // � 2013 Listrak, Inc.
4
+
5
+ class Listrak_Remarketing_Helper_Product extends Mage_Core_Helper_Abstract
6
+ {
7
+ private $parentsById = array();
8
+ private $attributeSets = null;
9
+ private $categoryNames = array();
10
+ private $baseDir = null;
11
+ private $baseMediaPath = null;
12
+ private $imageModel = null;
13
+
14
+ public function getProductEntity($product, $includeBrandAndCategory = true, $includeInventory = true, $includeConfigurableAttributes = true) {
15
+ $result = array();
16
+
17
+ $result['entity_id'] = $product->getEntityId();
18
+ $result['sku'] = $product->getSku();
19
+ $result['name'] = $product->getName();
20
+ $result['price'] = $product->getPrice();
21
+ $result['special_price'] = $product->getSpecialPrice();
22
+ $result['special_from_date'] = $product->getSpecialFromDate();
23
+ $result['special_to_date'] = $product->getSpecialToDate();
24
+ $result['cost'] = $product->getCost();
25
+ $result['description'] = $product->getDescription();
26
+ $result['short_description'] = $product->getShortDescription();
27
+ $result['weight'] = $product->getWeight();
28
+ $result['url_key'] = $product->getUrlKey();
29
+ if ($product->isVisibleInSiteVisibility())
30
+ $result['url_path'] = $product->getUrlPath();
31
+
32
+ $thumbnailProduct = $small_imageProduct = $imageProduct = $product;
33
+ $parentProduct = $this->getParentProduct($product);
34
+ if ($parentProduct != null)
35
+ {
36
+ $result['parent_id'] = $parentProduct->getEntityId();
37
+ $result['parent_sku'] = $parentProduct->getSku();
38
+
39
+ if (!$product->isVisibleInSiteVisibility()) {
40
+ $result['name'] = $parentProduct->getName();
41
+ $result['url_path'] = $parentProduct->getUrlPath();
42
+ $result['url_key'] = $parentProduct->getUrlKey();
43
+ }
44
+
45
+ $useParent = Mage_Catalog_Model_Product_Type::TYPE_CONFIGURABLE == $parentProduct->getTypeId() && Mage::getStoreConfig(Mage_Checkout_Block_Cart_Item_Renderer_Configurable::CONFIGURABLE_PRODUCT_IMAGE) == Mage_Checkout_Block_Cart_Item_Renderer_Configurable::USE_PARENT_IMAGE;
46
+ if (!$product->getData('image') || ($product->getData('image') == 'no_selection') || $useParent) $imageProduct = $parentProduct;
47
+ if (!$product->getData('small_image') || ($product->getData('small_image') == 'no_selection') || $useParent) $small_imageProduct = $parentProduct;
48
+ if (!$product->getData('thumbnail') || ($product->getData('thumbnail') == 'no_selection') || $useParent) $thumbnailProduct = $parentProduct;
49
+
50
+ if ($includeConfigurableAttributes && Mage_Catalog_Model_Product_Type::TYPE_CONFIGURABLE == $parentProduct->getTypeId())
51
+ foreach ($parentProduct->getTypeInstance(true)->getUsedProductAttributes($parentProduct) as $attribute)
52
+ {
53
+ if (!array_key_exists('configurable_attributes', $result)) $result['configurable_attributes'] = array();
54
+ $attr = array();
55
+ $attr['attribute_name'] = $attribute->getFrontend()->getLabel();
56
+ $attr['value'] = $product->getAttributeText($attribute->getAttributeCode());
57
+ $result['configurable_attributes'][] = $attr;
58
+ }
59
+ }
60
+ $result['image'] = $this->getProductImage($imageProduct, 'image');
61
+ $result['small_image'] = $this->getProductImage($small_imageProduct, 'small_image');
62
+ $result['thumbnail'] = $this->getProductImage($thumbnailProduct, 'thumbnail');
63
+
64
+ if ($includeBrandAndCategory)
65
+ {
66
+ $setSettings = $this->getProductAttributeSetSettings($product);
67
+
68
+ if ($setSettings['brandAttribute'] != null)
69
+ $result['brand'] = $product->getAttributeText($setSettings['brandAttribute']);
70
+
71
+ if ($setSettings['catFromMagento'])
72
+ {
73
+ $categories = $this->getCategoryIds($product, $categoryRootId);
74
+ if (array_key_exists('category_id', $categories))
75
+ {
76
+ $catId = $categories['category_id'];
77
+ if (!array_key_exists($catId, $categoryNames))
78
+ $categoryNames[$catId] = $this->getCategoryName($catId);
79
+
80
+ $result['category'] = $categoryNames[$catId];
81
+ }
82
+ if (array_key_exists('sub_category_id', $categories))
83
+ {
84
+ $catId = $categories['sub_category_id'];
85
+ if (!array_key_exists($catId, $categoryNames))
86
+ $categoryNames[$catId] = $this->getCategoryName($catId);
87
+
88
+ $result['sub_category'] = $categoryNames[$catId];
89
+ }
90
+ }
91
+ else if ($setSettings['catFromAttributes'])
92
+ {
93
+ if ($setSettings['categoryAttribute'] != null)
94
+ $result['category'] = $product->getAttributeText($setSettings['categoryAttribute']);
95
+
96
+ if ($setSettings['subcategoryAttribute'] != null)
97
+ $result['sub_category'] = $product->getAttributeText($setSettings['subcategoryAttribute']);
98
+ }
99
+ }
100
+
101
+ if ($includeInventory)
102
+ {
103
+ $result['in_stock'] = $product->isAvailable() ? "true" : "false";
104
+ $stockItem = $product->getStockItem();
105
+ if ($stockItem)
106
+ $result['qty_on_hand'] = $stockItem->getStockQty();
107
+ }
108
+
109
+ $result['type'] = $product->getTypeId();
110
+
111
+ return $result;
112
+ }
113
+
114
+
115
+ private function getProductImage($product, $imageType) {
116
+ if ($baseDir == null) $baseDir = Mage::getBaseDir();
117
+ if ($baseMediaPath == null) $baseMediaPath = Mage::getSingleton('catalog/product_media_config')->getBaseMediaPath();
118
+ if ($imageModel == null) $imageModel = Mage::getModel('catalog/product_image');
119
+ $imageModel->setDestinationSubdir($imageType);
120
+ try {
121
+ $imageModel->setBaseFile($product->getData($imageType));
122
+ $imageBaseFile = $imageModel->getBaseFile();
123
+ if (!(false === strpos($imageBaseFile, $baseMediaPath)))
124
+ return substr($imageBaseFile, strlen($baseMediaPath));
125
+ return '/../../..'.substr($imageBaseFile, strlen($baseDir));
126
+ }
127
+ catch (Exception $e) {
128
+ return null;
129
+ }
130
+ }
131
+
132
+ private function getParentProduct($product)
133
+ {
134
+ $parentIds = Mage::getModel('catalog/product_type_configurable')
135
+ ->getParentIdsByChild($product->getEntityId());
136
+
137
+ if (is_array($parentIds) && count($parentIds) > 0)
138
+ {
139
+ if (count($parentIds) > 1) Mage::getModel("listrak/log")->addException("Product has multiple parents: sku=" . $product->getSku() . " parentIds=" . implode(', ', $parentIds));
140
+
141
+ $parentId = $parentIds[0];
142
+ if ($parentId != null)
143
+ {
144
+ if (!array_key_exists($parentId, $parentsById))
145
+ $parentsById[$parentId] = Mage::getModel('catalog/product')
146
+ ->load($parentId);
147
+ return $parentsById[$parentId];
148
+ }
149
+ }
150
+
151
+ return null;
152
+ }
153
+
154
+ private function getProductAttributeSetSettings($product) {
155
+ if ($attributeSets == null) {
156
+ $categoryRootId = Mage::helper('remarketing')->getCategoryRootIdForStore($storeId);
157
+
158
+ $attributeSets = array(0 => array(
159
+ //default values
160
+ 'brandAttribute' => null,
161
+ 'catFromMagento' => true,
162
+ 'catFromAttributes' => false,
163
+ 'categoryAttribute' => null,
164
+ 'subcategoryAttribute' => null
165
+ ));
166
+
167
+ $attributeSetSettings = Mage::getModel('listrak/product_attribute_set_map')
168
+ ->getCollection();
169
+ foreach($attributeSetSettings as $setSettings)
170
+ {
171
+ $attributeSets[$setSettings->getAttributeSetId()] = array(
172
+ 'brandAttribute' => $setSettings->getBrandAttributeCode(),
173
+ 'catFromMagento' => $setSettings->finalCategoriesSource() == 'default',
174
+ 'catFromAttributes' => $setSettings->finalCategoriesSource() == 'attributes',
175
+ 'categoryAttribute' => $setSettings->getCategoryAttributeCode(),
176
+ 'subcategoryAttribute' => $setSettings->getSubcategoryAttributeCode()
177
+ );
178
+ }
179
+ }
180
+ return array_key_exists($product->getAttributeSetId(), $attributeSets) ? $attributeSets[$product->getAttributeSetId()] : $attributeSets[0];
181
+ }
182
+
183
+ private function getCategoryIds($product, $categoryRootId = null)
184
+ {
185
+ $categories = $product->getCategoryCollection();
186
+ $final = array();
187
+
188
+ foreach($categories as $category)
189
+ {
190
+ $pathIds = $category->getPathIds();
191
+ if ($categoryRootId == null || $pathIds[1] == $categoryRootId)
192
+ {
193
+ if (count($pathIds) > 2)
194
+ $final['category_id'] = $pathIds[2];
195
+ if (count($pathIds) > 3)
196
+ $final['sub_category_id'] = $pathIds[3];
197
+
198
+ break;
199
+ }
200
+ }
201
+
202
+ return $final;
203
+ }
204
+
205
+ private function getCategoryName($categoryId)
206
+ {
207
+ $category = Mage::getModel('catalog/category')
208
+ ->load($categoryId);
209
+
210
+ if ($category != null)
211
+ return $category->getName();
212
+ }
213
+ }
214
+ ?>
app/code/community/Listrak/Remarketing/Helper/Product/Attribute/Set/Map.php ADDED
@@ -0,0 +1,42 @@
1
+ <?php
2
+ // Listrak Remarketing Magento Extension Ver. 1.1.5
3
+ // � 2013 Listrak, Inc.
4
+
5
+ class Listrak_Remarketing_Helper_Product_Attribute_Set_Map extends Mage_Core_Helper_Abstract
6
+ {
7
+ public function ensureDataConsistency()
8
+ {
9
+ $newSets = $this->newAttributeSetsCollection();
10
+
11
+ // add the new product attribute sets to our table
12
+ foreach($newSets as $set)
13
+ {
14
+ Mage::getModel('listrak/product_attribute_set_map')
15
+ ->setAttributeSetId($set->getAttributeSetId())
16
+ ->save();
17
+ }
18
+ }
19
+
20
+ public function newAttributeSetsCollection()
21
+ {
22
+ $r = Mage::getSingleton('core/resource');
23
+
24
+ // all product attribute sets
25
+ $allProductSets = Mage::getResourceModel('eav/entity_attribute_set_collection')
26
+ ->setEntityTypeFilter(Mage::getModel('catalog/product')->getResource()->getTypeId());
27
+
28
+ // the sets already in the table
29
+ $model = new Varien_Db_Select(Mage::getResourceModel('listrak/product_attribute_set_map')->getReadConnection());
30
+ $model
31
+ ->from(array('current' => $r->getTableName('listrak/product_attribute_set_map')))
32
+ ->where('main_table.attribute_set_id = current.attribute_set_id');
33
+
34
+ // new product attribute sets
35
+ $allProductSets->getSelect()
36
+ ->where('NOT EXISTS (' . $model . ')');
37
+
38
+ return $allProductSets;
39
+ }
40
+ }
41
+
42
+ ?>
app/code/community/Listrak/Remarketing/Model/Abandonedcart.php CHANGED
@@ -4,11 +4,11 @@
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();
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();
app/code/community/Listrak/Remarketing/Model/Abandonedcart/Api.php CHANGED
@@ -4,9 +4,11 @@
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
- Mage::helper('remarketing')->requireCoreEnabled();
9
-
10
if ($startDate === NULL || !strtotime($startDate)) {
11
$this->_fault('incorrect_date');
12
}
@@ -18,7 +20,7 @@ class Listrak_Remarketing_Model_Abandonedcart_Api extends Mage_Api_Model_Resourc
18
$storeIdArray = explode(',', $storeId);
19
20
$collection = Mage::getModel('listrak/abandonedcart')
21
- ->getCollection()
22
->addFieldToFilter('main_table.updated_at',array('from'=>$startDate, 'to'=>$endDate))
23
->setPageSize($perPage)->setCurPage($page)
24
->addStoreFilter($storeIdArray)
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
+ Mage::helper('remarketing')->requireCoreEnabled();
9
+
10
+ Mage::app()->setCurrentStore($storeId);
11
+
12
if ($startDate === NULL || !strtotime($startDate)) {
13
$this->_fault('incorrect_date');
14
}
20
$storeIdArray = explode(',', $storeId);
21
22
$collection = Mage::getModel('listrak/abandonedcart')
23
+ ->getCollection()
24
->addFieldToFilter('main_table.updated_at',array('from'=>$startDate, 'to'=>$endDate))
25
->setPageSize($perPage)->setCurPage($page)
26
->addStoreFilter($storeIdArray)
app/code/community/Listrak/Remarketing/Model/Apiextension/Api.php CHANGED
@@ -1,223 +1,279 @@
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
- Mage::helper('remarketing')->requireCoreEnabled();
9
-
10
- $collection = Mage::getModel('catalog/product')->getCollection()
11
- ->addStoreFilter($storeId)
12
- ->addAttributeToSelect('*')
13
- ->addFieldToFilter('type_id', array('neq'=>'configurable'))
14
- ->setPageSize($perPage)
15
- ->setCurPage($page);
16
-
17
- $subquery = Mage::getSingleton('core/resource')
18
- ->getConnection('core_read')
19
- ->select()
20
- ->from($collection->getTable('catalog/product_super_link'), array('product_id', 'parent_id'))
21
- ->group('product_id')
22
- ->having('COUNT(*) = 1');
23
-
24
- $collection->getSelect()
25
- ->joinLeft( array('psl'=>$subquery), 'e.entity_id = psl.product_id', array())
26
- ->joinLeft( array('pp'=>$collection->getTable('catalog/product')), 'psl.parent_id = pp.entity_id', array('parent_id' => 'pp.entity_id', 'parent_sku' => 'pp.sku'));
27
-
28
- $result = array();
29
- $productInfo = array('entity_id' => '', 'sku' => '', 'name' => '', 'price' => '',
30
- 'special_price' => '', 'special_from_date' => '', 'special_to_date' => '',
31
- 'cost' => '', 'description' => '', 'short_description' => '', 'weight' => '',
32
- 'url_key' => '', 'url_path' => '', 'image' => '', 'small_image' => '', 'thumbnail' => '',
33
- 'parent_id' => '', 'parent_sku' => '');
34
-
35
- foreach ($collection as $product) {
36
- $item = array_intersect_key($product->toArray(), $productInfo);
37
- $result[] = $item;
38
- }
39
-
40
- return $result;
41
- }
42
-
43
- public function subscribers($storeId = 1, $startDate = NULL, $perPage = 50, $page = 1) {
44
- Mage::helper('remarketing')->requireCoreEnabled();
45
-
46
- if ($startDate === NULL || !strtotime($startDate)) {
47
- $this->_fault('incorrect_date');
48
- }
49
-
50
- $result = array();
51
-
52
- $collection = Mage::getModel("listrak/apiextension")->getResource()->subscribers($storeId, $startDate, $perPage, $page);
53
-
54
- foreach($collection as $item) {
55
- $result[] = $item;
56
- }
57
-
58
- return $result;
59
- }
60
-
61
- public function subscribersPurge($endDate = NULL) {
62
- if ($endDate === NULL || !strtotime($endDate)) {
63
- $this->_fault('incorrect_date');
64
- }
65
-
66
- $collection = Mage::getModel("listrak/subscriberupdate")->getCollection()
67
- ->addFieldToFilter('updated_at', array('lt' => $endDate));
68
-
69
- $count = $collection->count();
70
-
71
- foreach($collection as $c) {
72
- $c->delete();
73
- }
74
-
75
- return $count;
76
- }
77
-
78
- public function customers($storeId = 1, $websiteId = 1, $perPage = 50, $page = 1) {
79
- Mage::helper('remarketing')->requireCoreEnabled();
80
-
81
- $collection = Mage::getModel('customer/customer')->getCollection()
82
- ->addFieldToFilter('store_id',$storeId)
83
- ->addAttributeToSelect('*')
84
- ->setPageSize($perPage)
85
- ->setCurPage($page);
86
-
87
- $results = array();
88
- $fields = array('entity_id' => '', 'firstname' => '', 'lastname' => '', 'email' => '', 'website_id' => '', 'store_id' => '');
89
-
90
- foreach($collection as $customer) {
91
- $item = $customer->toArray();
92
- $results[] = array_intersect_key($item, $fields);
93
- }
94
-
95
- return $results;
96
- }
97
-
98
- public function orderStatus($storeId = 1, $startDate = NULL, $endDate = NULL, $perPage = 50, $page = 1, $filters = NULL) {
99
- Mage::helper('remarketing')->requireCoreEnabled();
100
-
101
- $collection = Mage::getModel("sales/order")->getCollection()
102
- ->addFieldToFilter('store_id', $storeId)
103
- ->addAttributeToSelect('increment_id')
104
- ->addAttributeToSelect('updated_at')
105
- ->addAttributeToSelect('status')
106
- ->addFieldToFilter('updated_at',array('from'=>$startDate, 'to'=>$endDate))
107
- ->addFieldToFilter('status', array('neq'=>'pending'))
108
- ->setPageSize($perPage)->setCurPage($page)
109
- ->setOrder('updated_at', 'ASC');
110
-
111
- if (is_array($filters)) {
112
- try {
113
- foreach ($filters as $field => $value) {
114
- if (isset($this->_attributesMap['order'][$field])) {
115
- $field = $this->_attributesMap['order'][$field];
116
- }
117
-
118
- $collection->addFieldToFilter($field, $value);
119
- }
120
- } catch (Mage_Core_Exception $e) {
121
- $this->_fault('filters_invalid', $e->getMessage());
122
- }
123
- }
124
-
125
- $results = array();
126
-
127
- foreach($collection as $collectionItem) {
128
- $results[] = $collectionItem;
129
- }
130
-
131
- return $results;
132
- }
133
-
134
- public function orders($storeId = 1, $startDate = NULL, $endDate = NULL, $perPage = 50, $page = 1) {
135
- Mage::helper('remarketing')->requireCoreEnabled();
136
-
137
- if ($startDate === NULL || !strtotime($startDate)) {
138
- $this->_fault('incorrect_date');
139
- }
140
-
141
- if ($endDate === NULL || !strtotime($endDate)) {
142
- $this->_fault('incorrect_date');
143
- }
144
-
145
- $collection = Mage::getModel("sales/order")->getCollection()
146
- ->addAttributeToSelect('increment_id')
147
- ->addFieldToFilter('created_at',array('from'=>$startDate, 'to'=>$endDate))
148
- ->setPageSize($perPage)->setCurPage($page)
149
- ->addFieldToFilter('store_id', $storeId)
150
- ->setOrder('created_at', 'ASC');
151
-
152
-
153
- $apiModel = Mage::getModel("sales/order_api");
154
-
155
- $results = array();
156
-
157
- $info_fields = array('created_at'=>'', 'status'=>'', 'customer_firstname'=>'', 'customer_lastname'=>'',
158
- 'customer_email'=>'', 'order_id'=>'', 'subtotal'=>'', 'tax_amount'=>'', 'grand_total'=>'',
159
- 'shipping_amount'=>'', 'billing_firstname'=>'');
160
-
161
- $address_fields = array('firstname' => '', 'lastname' => '', 'company' => '', 'address1' => '',
162
- 'address2' => '', 'city' => '', 'region' => '', 'postcode' => '', 'country' => '');
163
-
164
- foreach($collection as $collectionItem) {
165
- $res = array();
166
- $item = $apiModel->info($collectionItem->getIncrementId());
167
- $res["info"] = array_intersect_key($item, $info_fields);
168
- $res["info"]["order_id"] = $collectionItem->getIncrementId();
169
- $res["shipping_address"] = array_intersect_key($item["shipping_address"], $address_fields);
170
- $res["billing_address"] = array_intersect_key($item["billing_address"], $address_fields);
171
- $res["product"] = array();
172
- foreach($item["items"] as $orderItem) {
173
- if($orderItem["product_type"] != "configurable")
174
- $res["product"][] = $orderItem;
175
- }
176
- $res["session"] = Mage::getModel("listrak/session")->load($item["quote_id"], 'quote_id');
177
- $results[] = $res;
178
- }
179
-
180
- return $results;
181
- }
182
-
183
- public function info() {
184
- $result = array();
185
- $result["magentoVersion"] = Mage::getVersion();
186
- $result["listrakSettings"] = array(
187
- "coreEnabled" => Mage::helper('remarketing')->coreEnabled() ? "true" : "false",
188
- "reviewsApiEnabled" => Mage::helper('remarketing')->reviewsEnabled() ? "true" : "false"
189
- );
190
- $result["ini"] = array();
191
-
192
- $subModel = Mage::getModel("newsletter/subscriber");
193
- $orderModel = Mage::getModel("sales/order");
194
- $productModel = Mage::getModel('catalog/product');
195
-
196
- $result["classes"] = get_class($subModel) .','. get_class($orderModel) .','. get_class($orderModel->getCollection()) .','.
197
- get_class($productModel) .','. get_class($productModel->getCollection());
198
-
199
- $ra = Mage::getSingleton('core/resource')->getConnection('core_read');
200
- $numSessions = $ra->fetchRow("select count(*) as c from " . Mage::getModel("listrak/session")->getResource()->getTable("listrak/session"));
201
- $numSubUpdates = $ra->fetchRow("select count(*) as c from " . Mage::getModel("listrak/subscriberupdate")->getResource()->getTable("listrak/subscriber_update"));
202
- $numClicks = $ra->fetchRow("select count(*) as c from " . Mage::getModel("listrak/click")->getResource()->getTable("listrak/click"));
203
-
204
- $result["counts"] = $numSessions['c'] .','. $numSubUpdates['c'] .','. $numClicks['c'];
205
-
206
- $result["modules"] = array();
207
- $modules = (array)Mage::getConfig()->getNode('modules')->children();
208
-
209
- foreach($modules as $key => $value) {
210
- $valueArray = $value->asCanonicalArray();
211
- $result["modules"][] = "name=$key, version=" . $valueArray["version"] .", isActive=" . $valueArray["active"];
212
- }
213
-
214
- $ini = array("session.gc_maxlifetime", "session.cookie_lifetime", "session.gc_divisor", "session.gc_probability");
215
-
216
- foreach($ini as $iniParam) {
217
- $result["ini"][] = "$iniParam=" . ini_get($iniParam);
218
- }
219
-
220
- return $result;
221
- }
222
- }
223
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
+ {
9
+ Mage::helper('remarketing')->requireCoreEnabled();
10
+
11
+ Mage::app()->setCurrentStore($storeId);
12
+
13
+ $collection = Mage::getModel('catalog/product')->getCollection()
14
+ ->addStoreFilter($storeId)
15
+ ->addAttributeToSelect('*')
16
+ ->setPageSize($perPage)
17
+ ->setCurPage($page)
18
+ ->load();
19
+
20
+ Mage::getModel('cataloginventory/stock')->addItemsToProducts($collection);
21
+
22
+ $results = array();
23
+
24
+ foreach ($collection as $product)
25
+ $results[] = Mage::helper('remarketing/product')->getProductEntity($product);
26
+
27
+ return $results;
28
+ }
29
+
30
+ public function subscribers($storeId = 1, $startDate = NULL, $perPage = 50, $page = 1) {
31
+ Mage::helper('remarketing')->requireCoreEnabled();
32
+
33
+ if ($startDate === NULL || !strtotime($startDate)) {
34
+ $this->_fault('incorrect_date');
35
+ }
36
+
37
+ $result = array();
38
+
39
+ $collection = Mage::getModel("listrak/apiextension")->getResource()->subscribers($storeId, $startDate, $perPage, $page);
40
+
41
+ foreach($collection as $item) {
42
+ $result[] = $item;
43
+ }
44
+
45
+ return $result;
46
+ }
47
+
48
+ public function subscribersPurge($endDate = NULL) {
49
+ if ($endDate === NULL || !strtotime($endDate)) {
50
+ $this->_fault('incorrect_date');
51
+ }
52
+
53
+ $collection = Mage::getModel("listrak/subscriberupdate")->getCollection()
54
+ ->addFieldToFilter('updated_at', array('lt' => $endDate));
55
+
56
+ $count = $collection->count();
57
+
58
+ foreach($collection as $c) {
59
+ $c->delete();
60
+ }
61
+
62
+ return $count;
63
+ }
64
+
65
+ public function customers($storeId = 1, $websiteId = 1, $perPage = 50, $page = 1) {
66
+ Mage::helper('remarketing')->requireCoreEnabled();
67
+
68
+ Mage::app()->setCurrentStore($storeId);
69
+
70
+ $collection = Mage::getModel('customer/customer')->getCollection()
71
+ ->addFieldToFilter('store_id',$storeId)
72
+ ->addAttributeToSelect('*')
73
+ ->setPageSize($perPage)
74
+ ->setCurPage($page);
75
+
76
+ $results = array();
77
+
78
+ foreach($collection as $customer) {
79
+ $results[] = $this->getCustomerArray($customer);
80
+ }
81
+
82
+ return $results;
83
+ }
84
+
85
+ private function getCustomerArray($customer) {
86
+ $fields = array('entity_id' => '', 'firstname' => '', 'lastname' => '', 'email' => '', 'website_id' => '', 'store_id' => '', 'group_id' => '', 'gender_name' => '', 'dob' => '', 'group_name' => '');
87
+ Mage::helper('remarketing')->setGroupNameAndGenderNameForCustomer($customer);
88
+ return array_intersect_key($customer->toArray(), $fields);
89
+ }
90
+
91
+ public function orderStatus($storeId = 1, $startDate = NULL, $endDate = NULL, $perPage = 50, $page = 1, $filters = NULL) {
92
+ Mage::helper('remarketing')->requireCoreEnabled();
93
+
94
+ $collection = Mage::getModel("sales/order")->getCollection()
95
+ ->addFieldToFilter('store_id', $storeId)
96
+ ->addAttributeToSelect('increment_id')
97
+ ->addAttributeToSelect('updated_at')
98
+ ->addAttributeToSelect('status')
99
+ ->addFieldToFilter('updated_at',array('from'=>$startDate, 'to'=>$endDate))
100
+ ->addFieldToFilter('status', array('neq'=>'pending'))
101
+ ->setPageSize($perPage)->setCurPage($page)
102
+ ->setOrder('updated_at', 'ASC');
103
+
104
+ if (is_array($filters)) {
105
+ try {
106
+ foreach ($filters as $field => $value) {
107
+ if (isset($this->_attributesMap['order'][$field])) {
108
+ $field = $this->_attributesMap['order'][$field];
109
+ }
110
+
111
+ $collection->addFieldToFilter($field, $value);
112
+ }
113
+ } catch (Mage_Core_Exception $e) {
114
+ $this->_fault('filters_invalid', $e->getMessage());
115
+ }
116
+ }
117
+
118
+ $results = array();
119
+
120
+ foreach($collection as $collectionItem) {
121
+ $results[] = $collectionItem;
122
+ }
123
+
124
+ return $results;
125
+ }
126
+
127
+ public function orders($storeId = 1, $startDate = NULL, $endDate = NULL, $perPage = 50, $page = 1) {
128
+ Mage::helper('remarketing')->requireCoreEnabled();
129
+
130
+ Mage::app()->setCurrentStore($storeId);
131
+
132
+ if ($startDate === NULL || !strtotime($startDate)) {
133
+ $this->_fault('incorrect_date');
134
+ }
135
+
136
+ if ($endDate === NULL || !strtotime($endDate)) {
137
+ $this->_fault('incorrect_date');
138
+ }
139
+
140
+ $orders = Mage::getModel('sales/order')->getCollection()
141
+ ->addFieldToFilter('created_at', array('from'=>$startDate, 'to'=>$endDate))
142
+ ->addFieldToFilter('store_id', $storeId)
143
+ ->setPageSize($perPage)->setCurPage($page)
144
+ ->setOrder('created_at', 'ASC');
145
+
146
+ $results = array();
147
+
148
+ foreach($orders as $order) {
149
+ $result = array();
150
+ $result['info']['entity_id'] = $order->getEntityId();
151
+ $result['info']['order_id'] = $order->getIncrementId();
152
+ $result['info']['status'] = $order->getStatus();;
153
+ $result['info']['customer_firstname'] = $order->getCustomerFirstname();
154
+ $result['info']['customer_lastname'] = $order->getCustomerLastname();
155
+ $result['info']['customer_email'] = $order->getCustomerEmail();
156
+ $result['info']['subtotal'] = $order->getSubtotal();
157
+ $result['info']['tax_amount'] = $order->getTaxAmount();
158
+ $result['info']['shipping_amount'] = $order->getShippingAmount();
159
+ $result['info']['grand_total'] = $order->getGrandTotal();
160
+ $result['info']['billing_firstname'] = $order->getBillingFirstname();
161
+ $result['info']['created_at'] = $order->getCreatedAt();
162
+ $result['info']['updated_at'] = $order->getUpdatedAt();
163
+
164
+ $shipping = $order->getShippingAddress();
165
+ $result['shipping_address']['firstname'] = $shipping->getFirstname();
166
+ $result['shipping_address']['lastname'] = $shipping->getLastname();
167
+ $result['shipping_address']['company'] = $shipping->getCompany();
168
+ $result['shipping_address']['street'] = implode(', ', $shipping->getStreet());
169
+ $result['shipping_address']['city'] = $shipping->getCity();
170
+ $result['shipping_address']['region'] = $shipping->getRegion();
171
+ $result['shipping_address']['postcode'] = $shipping->getPostcode();
172
+ $result['shipping_address']['country'] = $shipping->getCountry();
173
+
174
+ $billing = $order->getbillingAddress();
175
+ $result['billing_address']['firstname'] = $billing->getFirstname();
176
+ $result['billing_address']['lastname'] = $billing->getLastname();
177
+ $result['billing_address']['company'] = $billing->getCompany();
178
+ $result['billing_address']['street'] = implode(', ', $billing->getStreet());
179
+ $result['billing_address']['city'] = $billing->getCity();
180
+ $result['billing_address']['region'] = $billing->getRegion();
181
+ $result['billing_address']['postcode'] = $billing->getPostcode();
182
+ $result['billing_address']['country'] = $billing->getCountry();
183
+
184
+ $result['session'] = Mage::getModel("listrak/session")->load($order->getQuoteId(), 'quote_id');
185
+
186
+ $result['product'] = array();
187
+ foreach($order->getAllItems() as $item) {
188
+ if($item->getParentItem()) continue;
189
+ $result['product'][] = $this->getOrderItemProductEntity($item, $storeId);
190
+ }
191
+ if ($order->getCustomerId()) {
192
+ $customer = Mage::getModel("customer/customer")->load($order->getCustomerId());
193
+ if ($customer) {
194
+ $result['customer'] = $this->getCustomerArray($customer);
195
+ }
196
+ }
197
+
198
+ $results[] = $result;
199
+ }
200
+
201
+ return $results;
202
+ }
203
+
204
+ private function getOrderItemProductEntity($item, $storeId)
205
+ {
206
+ $productModel = Mage::getModel('catalog/product')->load($item->getProductId());
207
+ $productType = $productModel->getTypeId();
208
+ $childrenItems = $item->getChildrenItems();
209
+ $childrenItemsCount = count($childrenItems);
210
+ if (Mage_Catalog_Model_Product_Type::TYPE_CONFIGURABLE == $productType && $childrenItemsCount > 0)
211
+ {
212
+ $productModel = Mage::getModel('catalog/product')->load($childrenItems[0]->getProductId());
213
+ }
214
+ $product = array();
215
+ if ($productModel != null)
216
+ {
217
+ $product['sku'] = $productModel->getSku();
218
+ $product['name'] = $productModel->getName();
219
+ $product['product_price'] = $productModel->getPrice();
220
+ }
221
+ else
222
+ {
223
+ $product['sku'] = $item->getProductOptionByCode('simple_sku') ? $item->getProductOptionByCode('simple_sku') : $item->getSku();
224
+ $product['name'] = $item->getName();
225
+ }
226
+ $product['price'] = $item->getPrice();
227
+ $product['qty_ordered'] = $item->getQtyOrdered();
228
+ if (Mage_Catalog_Model_Product_Type::TYPE_BUNDLE == $productType && $childrenItemsCount > 0)
229
+ {
230
+ $product['bundle_items'] = array();
231
+ foreach ($childrenItems as $childItem)
232
+ {
233
+ $product['bundle_items'][] = $this->getOrderItemProductEntity($childItem, $storeId);
234
+ }
235
+ }
236
+ return $product;
237
+ }
238
+
239
+ public function info() {
240
+ $result = array();
241
+ $result["magentoVersion"] = Mage::getVersion();
242
+ $result["listrakSettings"] = array(
243
+ "coreEnabled" => Mage::helper('remarketing')->coreEnabled() ? "true" : "false",
244
+ "reviewsApiEnabled" => Mage::helper('remarketing')->reviewsEnabled() ? "true" : "false"
245
+ );
246
+ $result["ini"] = array();
247
+
248
+ $subModel = Mage::getModel("newsletter/subscriber");
249
+ $orderModel = Mage::getModel("sales/order");
250
+ $productModel = Mage::getModel('catalog/product');
251
+
252
+ $result["classes"] = get_class($subModel) .','. get_class($orderModel) .','. get_class($orderModel->getCollection()) .','.
253
+ get_class($productModel) .','. get_class($productModel->getCollection());
254
+
255
+ $ra = Mage::getSingleton('core/resource')->getConnection('core_read');
256
+ $numSessions = $ra->fetchRow("select count(*) as c from " . Mage::getModel("listrak/session")->getResource()->getTable("listrak/session"));
257
+ $numSubUpdates = $ra->fetchRow("select count(*) as c from " . Mage::getModel("listrak/subscriberupdate")->getResource()->getTable("listrak/subscriber_update"));
258
+ $numClicks = $ra->fetchRow("select count(*) as c from " . Mage::getModel("listrak/click")->getResource()->getTable("listrak/click"));
259
+
260
+ $result["counts"] = $numSessions['c'] .','. $numSubUpdates['c'] .','. $numClicks['c'];
261
+
262
+ $result["modules"] = array();
263
+ $modules = (array)Mage::getConfig()->getNode('modules')->children();
264
+
265
+ foreach($modules as $key => $value) {
266
+ $valueArray = $value->asCanonicalArray();
267
+ $result["modules"][] = "name=$key, version=" . $valueArray["version"] .", isActive=" . $valueArray["active"];
268
+ }
269
+
270
+ $ini = array("session.gc_maxlifetime", "session.cookie_lifetime", "session.gc_divisor", "session.gc_probability");
271
+
272
+ foreach($ini as $iniParam) {
273
+ $result["ini"][] = "$iniParam=" . ini_get($iniParam);
274
+ }
275
+
276
+ return $result;
277
+ }
278
+ }
279
app/code/community/Listrak/Remarketing/Model/Click.php CHANGED
@@ -4,16 +4,16 @@
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(Mage::app()->getRequest()->getParams() as $key => $value) {
15
- if(stripos($key, 'trk_') !== false) {
16
- $this->recordClick();
17
break;
18
}
19
}
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(Mage::app()->getRequest()->getParams() as $key => $value) {
15
+ if(stripos($key, 'trk_') !== false) {
16
+ $this->recordClick();
17
break;
18
}
19
}
app/code/community/Listrak/Remarketing/Model/Click/Api.php CHANGED
@@ -4,10 +4,10 @@
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
- Mage::helper('remarketing')->requireCoreEnabled();
9
-
10
- if ($startDate === NULL || !strtotime($startDate)) {
11
$this->_fault('incorrect_date');
12
}
13
@@ -15,7 +15,7 @@ class Listrak_Remarketing_Model_Click_Api extends Mage_Api_Model_Resource_Abstra
15
$this->_fault('incorrect_date');
16
}
17
18
- $clicks = Mage::getModel("listrak/click")->getCollection()
19
->addFieldToFilter('click_date',array('from'=>$startDate, 'to'=>$endDate))
20
->setPageSize($perPage)->setCurPage($page);
21
@@ -27,7 +27,7 @@ class Listrak_Remarketing_Model_Click_Api extends Mage_Api_Model_Resource_Abstra
27
$result[] = $item;
28
}
29
30
- return $result;
31
}
32
33
public function purge($storeId = 1, $endDate) {
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
+ Mage::helper('remarketing')->requireCoreEnabled();
9
+
10
+ if ($startDate === NULL || !strtotime($startDate)) {
11
$this->_fault('incorrect_date');
12
}
13
15
$this->_fault('incorrect_date');
16
}
17
18
+ $clicks = Mage::getModel("listrak/click")->getCollection()
19
->addFieldToFilter('click_date',array('from'=>$startDate, 'to'=>$endDate))
20
->setPageSize($perPage)->setCurPage($page);
21
27
$result[] = $item;
28
}
29
30
+ return $result;
31
}
32
33
public function purge($storeId = 1, $endDate) {
app/code/community/Listrak/Remarketing/Model/Emailcapture.php CHANGED
@@ -5,8 +5,8 @@
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
}
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 CHANGED
@@ -7,11 +7,11 @@ class Listrak_Remarketing_Model_Log extends Mage_Core_Model_Abstract
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) {
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) {
app/code/community/Listrak/Remarketing/Model/Log/Api.php CHANGED
@@ -4,8 +4,8 @@
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
- if ($startDate === NULL || !strtotime($startDate)) {
9
$this->_fault('incorrect_date');
10
}
11
@@ -13,7 +13,7 @@ class Listrak_Remarketing_Model_Log_Api extends Mage_Api_Model_Resource_Abstract
13
$this->_fault('incorrect_date');
14
}
15
16
- $logs = Mage::getModel("listrak/log")->getCollection()
17
->addFieldToFilter('date_entered',array('from'=>$startDate, 'to'=>$endDate))
18
->setPageSize($perPage)->setCurPage($page)
19
->addStoreFilter($storeId);
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
+ if ($startDate === NULL || !strtotime($startDate)) {
9
$this->_fault('incorrect_date');
10
}
11
13
$this->_fault('incorrect_date');
14
}
15
16
+ $logs = Mage::getModel("listrak/log")->getCollection()
17
->addFieldToFilter('date_entered',array('from'=>$startDate, 'to'=>$endDate))
18
->setPageSize($perPage)->setCurPage($page)
19
->addStoreFilter($storeId);
app/code/community/Listrak/Remarketing/Model/Mysql4/Abandonedcart.php CHANGED
@@ -4,16 +4,16 @@
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()));
@@ -24,37 +24,37 @@ class Listrak_Remarketing_Model_Mysql4_Abandonedcart extends Mage_Core_Model_Mys
24
}
25
26
protected function loadCart(Mage_Core_Model_Abstract $object) {
27
- $product_fields = array(
28
- 'entity_id'=>'', 'sku'=>'', 'name'=>'',
29
- 'special_price' => '', 'special_from_date' => '', 'special_to_date' => '',
30
- 'cost'=>'', 'description'=>'',
31
- 'short_description'=>'', 'weight'=>'', 'url_key'=>'', 'url_path'=>'',
32
- 'image'=>'', 'small_image'=>'', 'thumbnail'=>'', 'qty'=>'');
33
-
34
- $fields = array(
35
- 'item_id' => 'q.item_id',
36
- 'quote_id' => 'q.quote_id',
37
- 'product_id' => 'q.product_id',
38
- 'qty' => 'q.qty',
39
- 'price' => 'q.price');
40
-
41
$products = array();
42
43
- $qiSelect = $this->_read->select()
44
- ->from(array('q' => $this->getTable('sales/quote_item')), $fields)
45
- ->where('q.quote_id = ?', $object->getQuoteId())
46
- ->where('q.product_type <> "configurable"');
47
-
48
- $qiResult = $this->_read->fetchAll($qiSelect);
49
-
50
- foreach($qiResult as $qi) {
51
- $product = Mage::getModel('catalog/product')->load($qi['product_id']);
52
- $qitem = array_intersect_key($product->toArray(),$product_fields);
53
- $qitem["qty"] = $qi["qty"];
54
- $qitem["price"] = $qi["price"];
55
- $products[] = $qitem;
56
}
57
58
$object->setProducts($products);
59
}
60
}
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()));
24
}
25
26
protected function loadCart(Mage_Core_Model_Abstract $object) {
27
$products = array();
28
29
+ foreach(Mage::getModel('sales/quote')->load($object->getQuoteId())->getAllVisibleItems() as $item) {
30
+ $products[] = $this->getCartProductEntity($item, $object->getStoreId());
31
}
32
33
$object->setProducts($products);
34
}
35
+
36
+ private function getCartProductEntity($item, $storeId)
37
+ {
38
+ $productModel = Mage::getModel('catalog/product')->load($item->getProductId());
39
+ $productType = $productModel->getTypeId();
40
+ $children = $item->getChildren();
41
+ $childrenCount = count($children);
42
+ if (Mage_Catalog_Model_Product_Type::TYPE_CONFIGURABLE == $productType && $childrenCount > 0)
43
+ {
44
+ $productModel = Mage::getModel('catalog/product')->load($children[0]->getProductId());
45
+ }
46
+ $product = Mage::helper('remarketing/product')->getProductEntity($productModel, false, false, false);
47
+ $product["qty"] = $item->getQty();
48
+ $product["price"] = $item->getCalculationPrice();
49
+ if (Mage_Catalog_Model_Product_Type::TYPE_BUNDLE == $productType && $childrenCount > 0)
50
+ {
51
+ $product['bundle_items'] = array();
52
+ foreach ($children as $child)
53
+ {
54
+ $product['bundle_items'][] = $this->getCartProductEntity($child, $storeId);
55
+ }
56
+ }
57
+ return $product;
58
+ }
59
+
60
}
app/code/community/Listrak/Remarketing/Model/Mysql4/Abandonedcart/Collection.php CHANGED
@@ -6,31 +6,31 @@ class Listrak_Remarketing_Model_Mysql4_Abandonedcart_Collection extends Mage_Cor
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
->where('q.items_count > 0 AND q.is_active = 1');
23
}
24
25
public function addStoreFilter($storeIds)
26
- {
27
- $this->getSelect()->where('main_table.store_id IN (?)', $storeIds);
28
- return $this;
29
- }
30
31
protected function _afterLoad() {
32
- foreach ($this->_items as $item) {
33
- $item->afterLoad();
34
if($this->_prepareForReport === true) {
35
$item->prepareForReport();
36
}
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
->where('q.items_count > 0 AND q.is_active = 1');
23
}
24
25
public function addStoreFilter($storeIds)
26
+ {
27
+ $this->getSelect()->where('main_table.store_id IN (?)', $storeIds);
28
+ return $this;
29
+ }
30
31
protected function _afterLoad() {
32
+ foreach ($this->_items as $item) {
33
+ $item->afterLoad();
34
if($this->_prepareForReport === true) {
35
$item->prepareForReport();
36
}
app/code/community/Listrak/Remarketing/Model/Mysql4/Click.php CHANGED
@@ -4,43 +4,43 @@
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
}
@@ -48,15 +48,15 @@ class Listrak_Remarketing_Model_Mysql4_Click extends Mage_Core_Model_Mysql4_Abst
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
}
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
}
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
}
app/code/community/Listrak/Remarketing/Model/Mysql4/Click/Collection.php CHANGED
@@ -4,15 +4,15 @@
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', 'pi_id'))
17
->where('s.store_id IN (?)',$storeId);
18
return $this;
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', 'pi_id'))
17
->where('s.store_id IN (?)',$storeId);
18
return $this;
app/code/community/Listrak/Remarketing/Model/Mysql4/Emailcapture.php CHANGED
@@ -4,14 +4,14 @@
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
}
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 CHANGED
@@ -5,7 +5,7 @@
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
}
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 CHANGED
@@ -4,14 +4,14 @@
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
}
4
5
class Listrak_Remarketing_Model_Mysql4_Log extends Mage_Core_Model_Mysql4_Abstract {
6
7
+ protected $_read;
8
9
+ protected $_write;
10