Version Notes
No comments
Download this release
Release Info
Developer | Remarkety |
Extension | Remarkety_Mgconnector |
Version | 1.5.1.2 |
Comparing to | |
See all releases |
Code changes from version 1.4.10.3 to 1.5.1.2
- CHANGELOG.txt +25 -0
- app/code/community/Remarkety/Mgconnector/Block/Adminhtml/Install/Welcome/Store.php +12 -1
- app/code/community/Remarkety/Mgconnector/Block/Adminhtml/Queue/Configure/Form.php +53 -27
- app/code/community/Remarkety/Mgconnector/Block/Adminhtml/Queue/Grid.php +29 -21
- app/code/community/Remarkety/Mgconnector/Block/Tracking/Base.php +6 -1
- app/code/community/Remarkety/Mgconnector/Helper/Configuration.php +87 -1
- app/code/community/Remarkety/Mgconnector/Model/Core.php +244 -16
- app/code/community/Remarkety/Mgconnector/Model/Core/Api.php +49 -0
- app/code/community/Remarkety/Mgconnector/Model/Extension/RewardPoints/Observer/AbstractObserver.php +2 -3
- app/code/community/Remarkety/Mgconnector/Model/Extension/RewardPoints/Observer/MagestoreRewardPoints.php +9 -0
- app/code/community/Remarkety/Mgconnector/Model/Install.php +17 -0
- app/code/community/Remarkety/Mgconnector/Model/Observer.php +755 -164
- app/code/community/Remarkety/Mgconnector/Model/Webtracking.php +32 -4
- app/code/community/Remarkety/Mgconnector/controllers/Adminhtml/InstallController.php +62 -6
- app/code/community/Remarkety/Mgconnector/controllers/Adminhtml/QueueController.php +21 -9
- app/code/community/Remarkety/Mgconnector/etc/api.xml +18 -0
- app/code/community/Remarkety/Mgconnector/etc/config.xml +105 -4
- app/code/community/Remarkety/Mgconnector/sql/mgconnector_setup/mysql4-upgrade-1.4.10.4-1.5.0.0.php +24 -0
- app/code/community/Remarkety/Mgconnector/sql/mgconnector_setup/mysql4-upgrade-1.5.0.0-1.5.0.1.php +24 -0
- app/design/adminhtml/default/default/template/mgconnector/install/welcome/store.phtml +10 -2
- app/design/frontend/base/default/template/mgconnector/tracking/general.phtml +1 -1
- package.xml +5 -5
CHANGELOG.txt
CHANGED
@@ -1,3 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
1.4.10.2
|
2 |
-------
|
3 |
Products should not be taken from flat catalog table if enabled
|
1 |
+
1.5.1.2
|
2 |
+
--------
|
3 |
+
Detect cart email from session if visitor subscribed before creating the cart
|
4 |
+
|
5 |
+
1.5.1.1
|
6 |
+
--------
|
7 |
+
Configurable using Magento's internal methods to get product url
|
8 |
+
|
9 |
+
1.5.1.0
|
10 |
+
--------
|
11 |
+
Support push events (for transactional emails and more)
|
12 |
+
|
13 |
+
1.4.10.5
|
14 |
+
--------
|
15 |
+
Change webtracking source script to be from CloudFront CDN
|
16 |
+
|
17 |
+
1.4.10.4
|
18 |
+
--------
|
19 |
+
Get customer birthday
|
20 |
+
|
21 |
+
1.4.10.3
|
22 |
+
--------
|
23 |
+
Bugfix - Properly unsubscribe users. Before, would create an empty unsubscribe record if the email did not exist
|
24 |
+
(Thanks to John Carlson @ www.surethingweb.com)
|
25 |
+
|
26 |
1.4.10.2
|
27 |
-------
|
28 |
Products should not be taken from flat catalog table if enabled
|
app/code/community/Remarkety/Mgconnector/Block/Adminhtml/Install/Welcome/Store.php
CHANGED
@@ -18,6 +18,8 @@ class Remarkety_Mgconnector_Block_Adminhtml_Install_Welcome_Store extends Mage_A
|
|
18 |
*/
|
19 |
$wtModel = Mage::getModel('mgconnector/webtracking');
|
20 |
|
|
|
|
|
21 |
$stores = array();
|
22 |
|
23 |
foreach (Mage::app()->getWebsites() as $_website) {
|
@@ -34,7 +36,7 @@ class Remarkety_Mgconnector_Block_Adminhtml_Install_Welcome_Store extends Mage_A
|
|
34 |
|
35 |
foreach ($_group->getStores() as $_store) {
|
36 |
$isInstalled = $_store->getConfig(Remarkety_Mgconnector_Model_Install::XPATH_INSTALLED);
|
37 |
-
$webtracking = $wtModel->
|
38 |
$stores[$_website->getCode()]['store_groups'][$_group->getGroupId()]['store_views'][$_store->getCode()] = array(
|
39 |
'name' => $_store->getName(),
|
40 |
'id' => $_store->getStoreId(),
|
@@ -58,4 +60,13 @@ class Remarkety_Mgconnector_Block_Adminhtml_Install_Welcome_Store extends Mage_A
|
|
58 |
return false;
|
59 |
}
|
60 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
61 |
}
|
18 |
*/
|
19 |
$wtModel = Mage::getModel('mgconnector/webtracking');
|
20 |
|
21 |
+
|
22 |
+
|
23 |
$stores = array();
|
24 |
|
25 |
foreach (Mage::app()->getWebsites() as $_website) {
|
36 |
|
37 |
foreach ($_group->getStores() as $_store) {
|
38 |
$isInstalled = $_store->getConfig(Remarkety_Mgconnector_Model_Install::XPATH_INSTALLED);
|
39 |
+
$webtracking = $wtModel->isEnabled($_store->getStoreId());
|
40 |
$stores[$_website->getCode()]['store_groups'][$_group->getGroupId()]['store_views'][$_store->getCode()] = array(
|
41 |
'name' => $_store->getName(),
|
42 |
'id' => $_store->getStoreId(),
|
60 |
return false;
|
61 |
}
|
62 |
}
|
63 |
+
|
64 |
+
public function isWebhooksEnabled(){
|
65 |
+
/**
|
66 |
+
* @var $configHelper Remarkety_Mgconnector_Helper_Configuration
|
67 |
+
*/
|
68 |
+
$configHelper = Mage::helper('mgconnector/configuration');
|
69 |
+
|
70 |
+
return $configHelper->isWebhooksEnabled();
|
71 |
+
}
|
72 |
}
|
app/code/community/Remarkety/Mgconnector/Block/Adminhtml/Queue/Configure/Form.php
CHANGED
@@ -16,12 +16,12 @@ class Remarkety_Mgconnector_Block_Adminhtml_Queue_Configure_Form extends Mage_Ad
|
|
16 |
*/
|
17 |
protected function _prepareForm()
|
18 |
{
|
19 |
-
$form = new Varien_Data_Form(
|
20 |
array(
|
21 |
'id' => 'edit_form',
|
22 |
'action' => $this->getUrl('*/queue/save'),
|
23 |
'method' => 'post',
|
24 |
-
)
|
25 |
);
|
26 |
$form->setFieldContainerIdPrefix('data');
|
27 |
$form->setUseContainer(true);
|
@@ -34,23 +34,23 @@ class Remarkety_Mgconnector_Block_Adminhtml_Queue_Configure_Form extends Mage_Ad
|
|
34 |
)
|
35 |
);
|
36 |
|
37 |
-
$fieldset->addField(
|
38 |
'mode', 'hidden', array(
|
39 |
'name' => 'data[mode]',
|
40 |
'value' => 'configuration',
|
41 |
-
)
|
42 |
);
|
43 |
|
44 |
if(!$this->checkAPIKey()) {
|
45 |
-
$fieldset->addField(
|
46 |
'api_warning', 'note', array(
|
47 |
'text' => '<span style="color: red;">' . $this->__('Attention! Remarkety\'s API key is not the same as the Magento API key. Please set it below.') . '</span>'.
|
48 |
' <a target="_blank" href="https://support.remarkety.com/hc/en-us/articles/209184646-Synchronizing-the-API-key">More Info</a>.',
|
49 |
-
)
|
50 |
);
|
51 |
}
|
52 |
|
53 |
-
$fieldset->addField(
|
54 |
'api_key', 'text', array(
|
55 |
'label' => $this->__('API Key:'),
|
56 |
'name' => 'data[api_key]',
|
@@ -60,10 +60,10 @@ class Remarkety_Mgconnector_Block_Adminhtml_Queue_Configure_Form extends Mage_Ad
|
|
60 |
) . '</small>',
|
61 |
'value' => Mage::getStoreConfig('remarkety/mgconnector/api_key'),
|
62 |
'style' => 'float:left',
|
63 |
-
)
|
64 |
);
|
65 |
|
66 |
-
$fieldset->addField(
|
67 |
'intervals', 'text', array(
|
68 |
'label' => $this->__('Intervals:'),
|
69 |
'name' => 'data[intervals]',
|
@@ -77,10 +77,10 @@ class Remarkety_Mgconnector_Block_Adminhtml_Queue_Configure_Form extends Mage_Ad
|
|
77 |
) . '</small>',
|
78 |
'value' => Mage::getStoreConfig('remarkety/mgconnector/intervals'),
|
79 |
'style' => 'float:left',
|
80 |
-
)
|
81 |
);
|
82 |
|
83 |
-
$fieldset->addField(
|
84 |
'bypasscache', 'checkbox', array(
|
85 |
'label' => $this->__('Bypass page cache for website tracking:'),
|
86 |
'name' => 'data[bypasscache]',
|
@@ -90,10 +90,10 @@ class Remarkety_Mgconnector_Block_Adminhtml_Queue_Configure_Form extends Mage_Ad
|
|
90 |
'value' => 1,
|
91 |
'checked' => \Remarkety_Mgconnector_Model_Webtracking::getBypassCache() ? 'checked' : '',
|
92 |
'style' => 'float:left',
|
93 |
-
)
|
94 |
);
|
95 |
|
96 |
-
$fieldset->addField(
|
97 |
'markgroupparent', 'checkbox', array(
|
98 |
'label' => $this->__('Mark grouped product as parent of associated products'),
|
99 |
'name' => 'data[markgroupparent]',
|
@@ -103,36 +103,62 @@ class Remarkety_Mgconnector_Block_Adminhtml_Queue_Configure_Form extends Mage_Ad
|
|
103 |
'value' => 1,
|
104 |
'checked' => Mage::getStoreConfig('remarkety/mgconnector/mark_group_parent') ? 'checked' : '',
|
105 |
'style' => 'float:left',
|
106 |
-
)
|
107 |
);
|
108 |
|
109 |
-
$fieldset->addField(
|
110 |
'simpleproductstandalone', 'checkbox', array(
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
120 |
);
|
121 |
|
122 |
-
$
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
123 |
'button', 'note', array(
|
124 |
'label' => false,
|
125 |
'name' => 'button',
|
126 |
'after_element_html' => '<button type="button" class="save" onclick="editForm.submit();"><span><span>'
|
127 |
. $this->__('Save') . '</span></span></button>',
|
128 |
-
)
|
129 |
);
|
130 |
$button->getRenderer()->setTemplate('mgconnector/element.phtml');
|
131 |
|
132 |
return parent::_prepareForm();
|
133 |
}
|
134 |
|
135 |
-
private function checkAPIKey()
|
136 |
{
|
137 |
try {
|
138 |
$uModel = Mage::getModel('api/user');
|
16 |
*/
|
17 |
protected function _prepareForm()
|
18 |
{
|
19 |
+
$form = new Varien_Data_Form(
|
20 |
array(
|
21 |
'id' => 'edit_form',
|
22 |
'action' => $this->getUrl('*/queue/save'),
|
23 |
'method' => 'post',
|
24 |
+
)
|
25 |
);
|
26 |
$form->setFieldContainerIdPrefix('data');
|
27 |
$form->setUseContainer(true);
|
34 |
)
|
35 |
);
|
36 |
|
37 |
+
$fieldset->addField(
|
38 |
'mode', 'hidden', array(
|
39 |
'name' => 'data[mode]',
|
40 |
'value' => 'configuration',
|
41 |
+
)
|
42 |
);
|
43 |
|
44 |
if(!$this->checkAPIKey()) {
|
45 |
+
$fieldset->addField(
|
46 |
'api_warning', 'note', array(
|
47 |
'text' => '<span style="color: red;">' . $this->__('Attention! Remarkety\'s API key is not the same as the Magento API key. Please set it below.') . '</span>'.
|
48 |
' <a target="_blank" href="https://support.remarkety.com/hc/en-us/articles/209184646-Synchronizing-the-API-key">More Info</a>.',
|
49 |
+
)
|
50 |
);
|
51 |
}
|
52 |
|
53 |
+
$fieldset->addField(
|
54 |
'api_key', 'text', array(
|
55 |
'label' => $this->__('API Key:'),
|
56 |
'name' => 'data[api_key]',
|
60 |
) . '</small>',
|
61 |
'value' => Mage::getStoreConfig('remarkety/mgconnector/api_key'),
|
62 |
'style' => 'float:left',
|
63 |
+
)
|
64 |
);
|
65 |
|
66 |
+
$fieldset->addField(
|
67 |
'intervals', 'text', array(
|
68 |
'label' => $this->__('Intervals:'),
|
69 |
'name' => 'data[intervals]',
|
77 |
) . '</small>',
|
78 |
'value' => Mage::getStoreConfig('remarkety/mgconnector/intervals'),
|
79 |
'style' => 'float:left',
|
80 |
+
)
|
81 |
);
|
82 |
|
83 |
+
$fieldset->addField(
|
84 |
'bypasscache', 'checkbox', array(
|
85 |
'label' => $this->__('Bypass page cache for website tracking:'),
|
86 |
'name' => 'data[bypasscache]',
|
90 |
'value' => 1,
|
91 |
'checked' => \Remarkety_Mgconnector_Model_Webtracking::getBypassCache() ? 'checked' : '',
|
92 |
'style' => 'float:left',
|
93 |
+
)
|
94 |
);
|
95 |
|
96 |
+
$fieldset->addField(
|
97 |
'markgroupparent', 'checkbox', array(
|
98 |
'label' => $this->__('Mark grouped product as parent of associated products'),
|
99 |
'name' => 'data[markgroupparent]',
|
103 |
'value' => 1,
|
104 |
'checked' => Mage::getStoreConfig('remarkety/mgconnector/mark_group_parent') ? 'checked' : '',
|
105 |
'style' => 'float:left',
|
106 |
+
)
|
107 |
);
|
108 |
|
109 |
+
$fieldset->addField(
|
110 |
'simpleproductstandalone', 'checkbox', array(
|
111 |
+
'label' => $this->__('Get images and urls independently for simple products'),
|
112 |
+
'name' => 'data[simpleproductstandalone]',
|
113 |
+
'after_element_html' => '<small style="float:left;width:100%;">' . $this->__(
|
114 |
+
'Enable this checkbox if simple products that are related to configurable products have their own images and urls'
|
115 |
+
) . '</small>',
|
116 |
+
'value' => 1,
|
117 |
+
'checked' => Mage::getStoreConfig('remarkety/mgconnector/configurable_standalone') ? 'checked' : '',
|
118 |
+
'style' => 'float:left',
|
119 |
+
)
|
120 |
+
);
|
121 |
+
|
122 |
+
$fieldset->addField(
|
123 |
+
'product_url_internal', 'checkbox', array(
|
124 |
+
'label' => $this->__('Use Magento\'s internal methods to get product urls'),
|
125 |
+
'name' => 'data[product_url_internal]',
|
126 |
+
'after_element_html' => '<small style="float:left;width:100%;">' . $this->__(
|
127 |
+
'Enabling this feature may cause performance issues.'
|
128 |
+
) . '</small>',
|
129 |
+
'value' => 1,
|
130 |
+
'checked' => Mage::getStoreConfig(Remarkety_Mgconnector_Helper_Configuration::XPATH_INTERNAL_PRODUCT_URL) ? 'checked' : '',
|
131 |
+
'style' => 'float:left',
|
132 |
+
)
|
133 |
);
|
134 |
|
135 |
+
$fieldset->addField(
|
136 |
+
'forceasyncwebhooks', 'checkbox', array(
|
137 |
+
'label' => $this->__('Force webhooks to make requests asynchronous using queue'),
|
138 |
+
'name' => 'data[forceasyncwebhooks]',
|
139 |
+
'after_element_html' => '<small style="float:left;width:100%;">' . $this->__(
|
140 |
+
'Enabling this checkbox will cause a delay sending Remarkety transactional events'
|
141 |
+
) . '</small>',
|
142 |
+
'value' => 1,
|
143 |
+
'checked' => Mage::getStoreConfig('remarkety/mgconnector/forceasyncwebhooks') ? 'checked' : '',
|
144 |
+
'style' => 'float:left',
|
145 |
+
)
|
146 |
+
);
|
147 |
+
|
148 |
+
$button = $fieldset->addField(
|
149 |
'button', 'note', array(
|
150 |
'label' => false,
|
151 |
'name' => 'button',
|
152 |
'after_element_html' => '<button type="button" class="save" onclick="editForm.submit();"><span><span>'
|
153 |
. $this->__('Save') . '</span></span></button>',
|
154 |
+
)
|
155 |
);
|
156 |
$button->getRenderer()->setTemplate('mgconnector/element.phtml');
|
157 |
|
158 |
return parent::_prepareForm();
|
159 |
}
|
160 |
|
161 |
+
private function checkAPIKey()
|
162 |
{
|
163 |
try {
|
164 |
$uModel = Mage::getModel('api/user');
|
app/code/community/Remarkety/Mgconnector/Block/Adminhtml/Queue/Grid.php
CHANGED
@@ -47,50 +47,58 @@ class Remarkety_Mgconnector_Block_Adminhtml_Queue_Grid extends Mage_Adminhtml_Bl
|
|
47 |
{
|
48 |
$helper = Mage::helper('mgconnector');
|
49 |
|
50 |
-
$this->addColumn(
|
51 |
'queue_id', array(
|
52 |
'header' => $helper->__('Queue #'),
|
53 |
'width' => '50px',
|
54 |
'type' => 'number',
|
55 |
'index' => 'queue_id'
|
56 |
-
)
|
57 |
);
|
58 |
-
$this->addColumn(
|
59 |
'event_type', array(
|
60 |
'header' => $helper->__('Event Type'),
|
61 |
'index' => 'event_type',
|
62 |
'renderer' => 'Remarkety_Mgconnector_Block_Adminhtml_Queue_Grid_Column_Renderer_EventType',
|
63 |
-
)
|
64 |
);
|
65 |
-
$this->addColumn(
|
66 |
'status', array(
|
67 |
'header' => $helper->__('Status'),
|
68 |
'width' => '200px',
|
69 |
'renderer' => 'Remarkety_Mgconnector_Block_Adminhtml_Queue_Grid_Column_Renderer_Status',
|
70 |
'index' => 'status'
|
71 |
-
)
|
72 |
);
|
73 |
-
$this->addColumn(
|
74 |
'attempts', array(
|
75 |
'header' => $helper->__('Attempts'),
|
76 |
-
'index' => 'attempts'
|
77 |
-
|
|
|
78 |
);
|
79 |
-
$this->addColumn(
|
80 |
'last_attempt', array(
|
81 |
'header' => $helper->__('Last Attempt'),
|
82 |
'width' => '200px',
|
83 |
'type' => 'datetime',
|
84 |
'index' => 'last_attempt'
|
85 |
-
)
|
86 |
);
|
87 |
-
$this->addColumn(
|
88 |
'next_attempt', array(
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
94 |
);
|
95 |
|
96 |
return parent::_prepareColumns();
|
@@ -112,19 +120,19 @@ class Remarkety_Mgconnector_Block_Adminhtml_Queue_Grid extends Mage_Adminhtml_Bl
|
|
112 |
$this->setMassactionIdField('queue_id');
|
113 |
$this->getMassactionBlock()->setFormFieldName('queue');
|
114 |
|
115 |
-
$this->getMassactionBlock()->addItem(
|
116 |
'resend', array(
|
117 |
'label' => $this->__('Resend'),
|
118 |
'url' => $this->getUrl('*/*/massResend')
|
119 |
-
)
|
120 |
);
|
121 |
|
122 |
-
$this->getMassactionBlock()->addItem(
|
123 |
'delete', array(
|
124 |
'label' => $this->__('Delete'),
|
125 |
'url' => $this->getUrl('*/*/massDelete'),
|
126 |
'confirm' => $this->__('Really delete all these events?')
|
127 |
-
)
|
128 |
);
|
129 |
|
130 |
return $this;
|
47 |
{
|
48 |
$helper = Mage::helper('mgconnector');
|
49 |
|
50 |
+
$this->addColumn(
|
51 |
'queue_id', array(
|
52 |
'header' => $helper->__('Queue #'),
|
53 |
'width' => '50px',
|
54 |
'type' => 'number',
|
55 |
'index' => 'queue_id'
|
56 |
+
)
|
57 |
);
|
58 |
+
$this->addColumn(
|
59 |
'event_type', array(
|
60 |
'header' => $helper->__('Event Type'),
|
61 |
'index' => 'event_type',
|
62 |
'renderer' => 'Remarkety_Mgconnector_Block_Adminhtml_Queue_Grid_Column_Renderer_EventType',
|
63 |
+
)
|
64 |
);
|
65 |
+
$this->addColumn(
|
66 |
'status', array(
|
67 |
'header' => $helper->__('Status'),
|
68 |
'width' => '200px',
|
69 |
'renderer' => 'Remarkety_Mgconnector_Block_Adminhtml_Queue_Grid_Column_Renderer_Status',
|
70 |
'index' => 'status'
|
71 |
+
)
|
72 |
);
|
73 |
+
$this->addColumn(
|
74 |
'attempts', array(
|
75 |
'header' => $helper->__('Attempts'),
|
76 |
+
'index' => 'attempts',
|
77 |
+
'width' => '200px'
|
78 |
+
)
|
79 |
);
|
80 |
+
$this->addColumn(
|
81 |
'last_attempt', array(
|
82 |
'header' => $helper->__('Last Attempt'),
|
83 |
'width' => '200px',
|
84 |
'type' => 'datetime',
|
85 |
'index' => 'last_attempt'
|
86 |
+
)
|
87 |
);
|
88 |
+
$this->addColumn(
|
89 |
'next_attempt', array(
|
90 |
+
'header' => $helper->__('Next Attempt'),
|
91 |
+
'width' => '200px',
|
92 |
+
'type' => 'datetime',
|
93 |
+
'index' => 'next_attempt'
|
94 |
+
)
|
95 |
+
);
|
96 |
+
|
97 |
+
$this->addColumn(
|
98 |
+
'last_error', array(
|
99 |
+
'header' => $helper->__('Last Error Message'),
|
100 |
+
'index' => 'last_error_message'
|
101 |
+
)
|
102 |
);
|
103 |
|
104 |
return parent::_prepareColumns();
|
120 |
$this->setMassactionIdField('queue_id');
|
121 |
$this->getMassactionBlock()->setFormFieldName('queue');
|
122 |
|
123 |
+
$this->getMassactionBlock()->addItem(
|
124 |
'resend', array(
|
125 |
'label' => $this->__('Resend'),
|
126 |
'url' => $this->getUrl('*/*/massResend')
|
127 |
+
)
|
128 |
);
|
129 |
|
130 |
+
$this->getMassactionBlock()->addItem(
|
131 |
'delete', array(
|
132 |
'label' => $this->__('Delete'),
|
133 |
'url' => $this->getUrl('*/*/massDelete'),
|
134 |
'confirm' => $this->__('Really delete all these events?')
|
135 |
+
)
|
136 |
);
|
137 |
|
138 |
return $this;
|
app/code/community/Remarkety/Mgconnector/Block/Tracking/Base.php
CHANGED
@@ -3,7 +3,12 @@ class Remarkety_Mgconnector_Block_Tracking_Base extends Mage_Core_Block_Template
|
|
3 |
{
|
4 |
public function isWebtrackingActivated()
|
5 |
{
|
6 |
-
|
|
|
|
|
|
|
|
|
|
|
7 |
}
|
8 |
|
9 |
public function getRemarketyPublicId()
|
3 |
{
|
4 |
public function isWebtrackingActivated()
|
5 |
{
|
6 |
+
$store = Mage::app()->getStore();
|
7 |
+
/**
|
8 |
+
* @var $m Remarkety_Mgconnector_Model_Webtracking
|
9 |
+
*/
|
10 |
+
$m = Mage::getModel('mgconnector/webtracking');
|
11 |
+
return ($m->isEnabled($store));
|
12 |
}
|
13 |
|
14 |
public function getRemarketyPublicId()
|
app/code/community/Remarkety/Mgconnector/Helper/Configuration.php
CHANGED
@@ -3,8 +3,11 @@
|
|
3 |
class Remarkety_Mgconnector_Helper_Configuration extends Mage_Core_Helper_Abstract
|
4 |
{
|
5 |
private $_cache = array();
|
|
|
6 |
|
7 |
-
|
|
|
|
|
8 |
{
|
9 |
// Check if the key is in our cache
|
10 |
if (key_exists($key, $this->_cache))
|
@@ -27,4 +30,87 @@ class Remarkety_Mgconnector_Helper_Configuration extends Mage_Core_Helper_Abstra
|
|
27 |
return $default;
|
28 |
|
29 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
30 |
}
|
3 |
class Remarkety_Mgconnector_Helper_Configuration extends Mage_Core_Helper_Abstract
|
4 |
{
|
5 |
private $_cache = array();
|
6 |
+
private $_installedStores = false;
|
7 |
|
8 |
+
const XPATH_INTERNAL_PRODUCT_URL = 'remarkety/mgconnector/product_url_internal';
|
9 |
+
|
10 |
+
public function getValue($key, $default = null)
|
11 |
{
|
12 |
// Check if the key is in our cache
|
13 |
if (key_exists($key, $this->_cache))
|
30 |
return $default;
|
31 |
|
32 |
}
|
33 |
+
|
34 |
+
/**
|
35 |
+
* Get a list of stores that has Remarkety installed
|
36 |
+
* @return array
|
37 |
+
*/
|
38 |
+
public function getInstalledStores(){
|
39 |
+
if($this->_installedStores === false) {
|
40 |
+
$this->_installedStores = array();
|
41 |
+
$stores = Mage::app()->getStores(false);
|
42 |
+
/**
|
43 |
+
* @var $store Mage_Core_Model_Store
|
44 |
+
*/
|
45 |
+
foreach ($stores as $storeId => $store) {
|
46 |
+
$isInstalled = $store->getConfig(Remarkety_Mgconnector_Model_Install::XPATH_INSTALLED);
|
47 |
+
if(!empty($isInstalled)){
|
48 |
+
$this->_installedStores[] = $storeId;
|
49 |
+
}
|
50 |
+
}
|
51 |
+
}
|
52 |
+
return $this->_installedStores;
|
53 |
+
}
|
54 |
+
|
55 |
+
/**
|
56 |
+
* Check if a specific store id has Remarkety installed
|
57 |
+
* @param $storeId
|
58 |
+
* @return bool
|
59 |
+
*/
|
60 |
+
public function isStoreInstalled($storeId){
|
61 |
+
if(!$this->_installedStores) {
|
62 |
+
/**
|
63 |
+
* @var $store Mage_Core_Model_Store
|
64 |
+
*/
|
65 |
+
$store = Mage::app()->getStore($storeId);
|
66 |
+
$isInstalled = $store->getConfig(Remarkety_Mgconnector_Model_Install::XPATH_INSTALLED);
|
67 |
+
return !empty($isInstalled);
|
68 |
+
}
|
69 |
+
return in_array($storeId, $this->getInstalledStores());
|
70 |
+
}
|
71 |
+
|
72 |
+
/**
|
73 |
+
* Check if a specific store id has Remarkety installed
|
74 |
+
* @param $storeId
|
75 |
+
* @return bool
|
76 |
+
*/
|
77 |
+
public function isWebhooksEnabled($storeId = null){
|
78 |
+
/**
|
79 |
+
* @var $store Mage_Core_Model_Store
|
80 |
+
*/
|
81 |
+
$isInstalled = Mage::getStoreConfig(Remarkety_Mgconnector_Model_Install::XPATH_WEBHOOKS_ENABLED);
|
82 |
+
|
83 |
+
if(!empty($isInstalled)){
|
84 |
+
if(empty($storeId)){
|
85 |
+
return true;
|
86 |
+
}
|
87 |
+
|
88 |
+
$store = Mage::app()->getStore($storeId);
|
89 |
+
$storeId = $this->getRemarketyPublicId($store);
|
90 |
+
return !empty($storeId);
|
91 |
+
}
|
92 |
+
return false;
|
93 |
+
}
|
94 |
+
|
95 |
+
public function isProductWebhooksEnabled(){
|
96 |
+
$isDisabled = Mage::getStoreConfig(Remarkety_Mgconnector_Model_Install::XPATH_PRODUCT_WEBHOOKS_DISABLED);
|
97 |
+
return empty($isDisabled);
|
98 |
+
}
|
99 |
+
|
100 |
+
/**
|
101 |
+
* @param null $store
|
102 |
+
* @return bool
|
103 |
+
*/
|
104 |
+
public function getRemarketyPublicId($store = null)
|
105 |
+
{
|
106 |
+
$store = is_null($store) ? Mage::app()->getStore() : $store;
|
107 |
+
$store_id = is_numeric($store) ? $store : $store->getStoreId();
|
108 |
+
$id = Mage::getStoreConfig(Remarkety_Mgconnector_Model_Webtracking::RM_STORE_ID, $store_id);
|
109 |
+
return (empty($id) || is_null($id)) ? false : $id;
|
110 |
+
}
|
111 |
+
|
112 |
+
public static function getProductUrlFromMagento(){
|
113 |
+
$val = Mage::getStoreConfig(self::XPATH_INTERNAL_PRODUCT_URL);
|
114 |
+
return !empty($val);
|
115 |
+
}
|
116 |
}
|
app/code/community/Remarkety/Mgconnector/Model/Core.php
CHANGED
@@ -39,6 +39,7 @@ class Remarkety_Mgconnector_Model_Core extends Mage_Core_Model_Abstract
|
|
39 |
private $response_mask = array(
|
40 |
'customer' => array(
|
41 |
'entity_id',
|
|
|
42 |
'firstname',
|
43 |
'lastname',
|
44 |
'email',
|
@@ -1251,6 +1252,7 @@ class Remarkety_Mgconnector_Model_Core extends Mage_Core_Model_Abstract
|
|
1251 |
$this->_debug(__FUNCTION__, "Start - prod id " . $product->getId(), null, '');
|
1252 |
$url = '';
|
1253 |
$visibility = $product->getVisibility();
|
|
|
1254 |
if ($visibility == 1 || !in_array($product->type_id, $this->_groupedTypes)) {
|
1255 |
$parentId = null;
|
1256 |
if (!$this->simpleProductsStandalone) {
|
@@ -1266,6 +1268,7 @@ class Remarkety_Mgconnector_Model_Core extends Mage_Core_Model_Abstract
|
|
1266 |
if (!is_null($parentId)) {
|
1267 |
$this->_debug(__FUNCTION__, "parent id " . $parentId, null, '');
|
1268 |
$product_id = $parentId;
|
|
|
1269 |
} else {
|
1270 |
$product_id = $product->getId();
|
1271 |
}
|
@@ -1273,30 +1276,38 @@ class Remarkety_Mgconnector_Model_Core extends Mage_Core_Model_Abstract
|
|
1273 |
$product_id = $product->getId();
|
1274 |
}
|
1275 |
|
|
|
1276 |
try {
|
1277 |
-
$
|
1278 |
-
if
|
1279 |
-
$url = $
|
1280 |
-
if (
|
1281 |
-
$url
|
|
|
|
|
|
|
1282 |
}
|
|
|
1283 |
}
|
1284 |
-
$this->_debug(__FUNCTION__, "after setStoreId getProductUrl: " . $url, null, '');
|
1285 |
} catch (Exception $e) {
|
1286 |
$this->_log(__FUNCTION__, "failed after setStoreId: ", $e->getMessage(), '');
|
1287 |
}
|
1288 |
|
1289 |
-
if
|
1290 |
-
|
1291 |
-
}
|
1292 |
-
|
1293 |
-
|
1294 |
-
|
1295 |
}
|
1296 |
|
|
|
|
|
|
|
|
|
1297 |
}
|
1298 |
|
1299 |
-
public function getImageUrl($product, $type = 'image', $mage_store_view_id)
|
1300 |
{
|
1301 |
|
1302 |
$url = '';
|
@@ -1315,7 +1326,7 @@ class Remarkety_Mgconnector_Model_Core extends Mage_Core_Model_Abstract
|
|
1315 |
|
1316 |
if (!is_null($parentId)) {
|
1317 |
$this->_debug(__FUNCTION__, null, "parent id: " . $parentId, '');
|
1318 |
-
$product = $this->loadProduct($parentId
|
1319 |
}
|
1320 |
} else {
|
1321 |
$this->_debug(__FUNCTION__, null, "configurable prod id" . $product->getId(), '');
|
@@ -1398,7 +1409,8 @@ class Remarkety_Mgconnector_Model_Core extends Mage_Core_Model_Abstract
|
|
1398 |
$this->_debug(__FUNCTION__, REMARKETY_MGCONNECTOR_CALLED_STATUS, null, $myArgs);
|
1399 |
$subscriber = Mage::getModel('newsletter/subscriber')->loadByEmail($email);
|
1400 |
|
1401 |
-
|
|
|
1402 |
$msg = 'Given subscriber does not exist';
|
1403 |
$this->_debug(__FUNCTION__, REMARKETY_MGCONNECTOR_FAILED_STATUS, $msg, $myArgs);
|
1404 |
return $this->_wrapResponse(null, REMARKETY_MGCONNECTOR_FAILED_STATUS, $msg);
|
@@ -1426,7 +1438,7 @@ class Remarkety_Mgconnector_Model_Core extends Mage_Core_Model_Abstract
|
|
1426 |
return $this->configurable_product_model;
|
1427 |
}
|
1428 |
|
1429 |
-
|
1430 |
{
|
1431 |
if (!isset($this->_productCache[$productId])) {
|
1432 |
$this->_productCache[$productId] = Mage::getModel("catalog/product")->load($productId);
|
@@ -1514,6 +1526,222 @@ class Remarkety_Mgconnector_Model_Core extends Mage_Core_Model_Abstract
|
|
1514 |
|
1515 |
$this->simpleProductsStandalone = Mage::getStoreConfig('remarkety/mgconnector/configurable_standalone');
|
1516 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1517 |
}
|
1518 |
|
1519 |
|
39 |
private $response_mask = array(
|
40 |
'customer' => array(
|
41 |
'entity_id',
|
42 |
+
'dob',
|
43 |
'firstname',
|
44 |
'lastname',
|
45 |
'email',
|
1252 |
$this->_debug(__FUNCTION__, "Start - prod id " . $product->getId(), null, '');
|
1253 |
$url = '';
|
1254 |
$visibility = $product->getVisibility();
|
1255 |
+
$parentProduct = null;
|
1256 |
if ($visibility == 1 || !in_array($product->type_id, $this->_groupedTypes)) {
|
1257 |
$parentId = null;
|
1258 |
if (!$this->simpleProductsStandalone) {
|
1268 |
if (!is_null($parentId)) {
|
1269 |
$this->_debug(__FUNCTION__, "parent id " . $parentId, null, '');
|
1270 |
$product_id = $parentId;
|
1271 |
+
$parentProduct = $this->loadProduct($parentId);
|
1272 |
} else {
|
1273 |
$product_id = $product->getId();
|
1274 |
}
|
1276 |
$product_id = $product->getId();
|
1277 |
}
|
1278 |
|
1279 |
+
|
1280 |
try {
|
1281 |
+
$useInternalMethods = Mage::helper('mgconnector/configuration')->getProductUrlFromMagento();
|
1282 |
+
if(!$useInternalMethods){
|
1283 |
+
$url = Mage::helper('mgconnector/urls')->getValue($product_id, $mage_store_view_id);
|
1284 |
+
if (!empty($url)) {
|
1285 |
+
$url = $storeUrl . $url;
|
1286 |
+
if (Mage::getStoreConfig('catalog/seo/product_url_suffix', $mage_store_view_id)) {
|
1287 |
+
$url .= Mage::getStoreConfig('catalog/seo/product_url_suffix', $mage_store_view_id);
|
1288 |
+
}
|
1289 |
}
|
1290 |
+
$this->_debug(__FUNCTION__, "after setStoreId getProductUrl: " . $url, null, '');
|
1291 |
}
|
|
|
1292 |
} catch (Exception $e) {
|
1293 |
$this->_log(__FUNCTION__, "failed after setStoreId: ", $e->getMessage(), '');
|
1294 |
}
|
1295 |
|
1296 |
+
if(empty($url) && !empty($parentProduct)){
|
1297 |
+
$url = $parentProduct->getProductUrl();
|
1298 |
+
}
|
1299 |
+
|
1300 |
+
if(empty($url) && !empty($product)){
|
1301 |
+
$url = $product->getProductUrl();
|
1302 |
}
|
1303 |
|
1304 |
+
$this->_debug(__FUNCTION__, "getProductUrl: " . $url, null, '');
|
1305 |
+
|
1306 |
+
return $url;
|
1307 |
+
|
1308 |
}
|
1309 |
|
1310 |
+
public function getImageUrl($product, $type = 'image', $mage_store_view_id = null)
|
1311 |
{
|
1312 |
|
1313 |
$url = '';
|
1326 |
|
1327 |
if (!is_null($parentId)) {
|
1328 |
$this->_debug(__FUNCTION__, null, "parent id: " . $parentId, '');
|
1329 |
+
$product = $this->loadProduct($parentId);
|
1330 |
}
|
1331 |
} else {
|
1332 |
$this->_debug(__FUNCTION__, null, "configurable prod id" . $product->getId(), '');
|
1409 |
$this->_debug(__FUNCTION__, REMARKETY_MGCONNECTOR_CALLED_STATUS, null, $myArgs);
|
1410 |
$subscriber = Mage::getModel('newsletter/subscriber')->loadByEmail($email);
|
1411 |
|
1412 |
+
$data = $subscriber->getData();
|
1413 |
+
if (empty($data)) {
|
1414 |
$msg = 'Given subscriber does not exist';
|
1415 |
$this->_debug(__FUNCTION__, REMARKETY_MGCONNECTOR_FAILED_STATUS, $msg, $myArgs);
|
1416 |
return $this->_wrapResponse(null, REMARKETY_MGCONNECTOR_FAILED_STATUS, $msg);
|
1438 |
return $this->configurable_product_model;
|
1439 |
}
|
1440 |
|
1441 |
+
public function loadProduct($productId)
|
1442 |
{
|
1443 |
if (!isset($this->_productCache[$productId])) {
|
1444 |
$this->_productCache[$productId] = Mage::getModel("catalog/product")->load($productId);
|
1526 |
|
1527 |
$this->simpleProductsStandalone = Mage::getStoreConfig('remarkety/mgconnector/configurable_standalone');
|
1528 |
}
|
1529 |
+
|
1530 |
+
public function getQueueSize($mage_store_view_id)
|
1531 |
+
{
|
1532 |
+
register_shutdown_function('handleShutdown');
|
1533 |
+
$myArgs = func_get_args();
|
1534 |
+
|
1535 |
+
try {
|
1536 |
+
$this->_debug(__FUNCTION__, REMARKETY_MGCONNECTOR_CALLED_STATUS, null, $myArgs);
|
1537 |
+
// $store_views = $this->_store_views_in_group($mage_store_view_id);
|
1538 |
+
$queue = Mage::getModel('mgconnector/queue')->getCollection();
|
1539 |
+
$queue->addFieldToFilter('store_id', array('eq' => $mage_store_view_id));
|
1540 |
+
$count = $queue->getSize();
|
1541 |
+
$ret = array('count' => $count);
|
1542 |
+
|
1543 |
+
$this->_debug(__FUNCTION__, REMARKETY_MGCONNECTOR_SUCCESS_STATUS, null, '');
|
1544 |
+
return $this->_wrapResponse($ret, REMARKETY_MGCONNECTOR_SUCCESS_STATUS);
|
1545 |
+
} catch (Exception $e) {
|
1546 |
+
$this->_log(__FUNCTION__, REMARKETY_MGCONNECTOR_FAILED_STATUS, $e->getMessage(), $myArgs);
|
1547 |
+
return $this->_wrapResponse(null, REMARKETY_MGCONNECTOR_FAILED_STATUS, $e->getMessage());
|
1548 |
+
}
|
1549 |
+
}
|
1550 |
+
|
1551 |
+
public function getQueueItems($mage_store_view_id, $limit = null, $page = null, $minId = null, $maxId = null)
|
1552 |
+
{
|
1553 |
+
try {
|
1554 |
+
$myArgs = func_get_args();
|
1555 |
+
|
1556 |
+
$this->_debug(__FUNCTION__, REMARKETY_MGCONNECTOR_CALLED_STATUS, null, $myArgs);
|
1557 |
+
|
1558 |
+
$collection = Mage::getModel('mgconnector/queue')->getCollection();
|
1559 |
+
$collection->addFieldToFilter('store_id', array('eq' => $mage_store_view_id));
|
1560 |
+
|
1561 |
+
if(!empty($minId)){
|
1562 |
+
$collection->addFieldToFilter('queue_id', array('gteq' => $minId));
|
1563 |
+
}
|
1564 |
+
|
1565 |
+
if(!empty($maxId)){
|
1566 |
+
$collection->addFieldToFilter('queue_id', array('lteq' => $maxId));
|
1567 |
+
}
|
1568 |
+
|
1569 |
+
$pageSize = null;
|
1570 |
+
$pageNumber = 1; // Note that page numbers begin at 1 and remarkety starts at 0
|
1571 |
+
if ($limit != null) {
|
1572 |
+
$pageSize = $limit;
|
1573 |
+
}
|
1574 |
+
|
1575 |
+
if ($page != null) {
|
1576 |
+
if (!is_null($pageSize)) {
|
1577 |
+
$pageNumber = $page + 1; // Note that page numbers begin at 1 and remarkety starts at 0
|
1578 |
+
}
|
1579 |
+
}
|
1580 |
+
|
1581 |
+
if (!is_null($pageSize)) {
|
1582 |
+
$collection->getSelect()->limit($pageSize, ($pageNumber-1)*$pageSize);
|
1583 |
+
}
|
1584 |
+
$data = array();
|
1585 |
+
foreach ($collection as $queueEvent) {
|
1586 |
+
$event = $queueEvent->toArray();
|
1587 |
+
$event['payload'] = json_encode(unserialize($event['payload']));
|
1588 |
+
$data[] = $event;
|
1589 |
+
}
|
1590 |
+
$this->_debug(__FUNCTION__, REMARKETY_MGCONNECTOR_SUCCESS_STATUS, null, $myArgs);
|
1591 |
+
return $this->_wrapResponse($data, REMARKETY_MGCONNECTOR_SUCCESS_STATUS);
|
1592 |
+
} catch (Exception $e) {
|
1593 |
+
$this->_log(__FUNCTION__, REMARKETY_MGCONNECTOR_FAILED_STATUS, $e->getMessage(), $myArgs);
|
1594 |
+
return $this->_wrapResponse(null, REMARKETY_MGCONNECTOR_FAILED_STATUS, $e->getMessage());
|
1595 |
+
}
|
1596 |
+
}
|
1597 |
+
|
1598 |
+
public function deleteQueueItems($mage_store_view_id, $minId = null, $maxId = null){
|
1599 |
+
try {
|
1600 |
+
$myArgs = func_get_args();
|
1601 |
+
|
1602 |
+
$this->_debug(__FUNCTION__, REMARKETY_MGCONNECTOR_CALLED_STATUS, null, $myArgs);
|
1603 |
+
|
1604 |
+
$collection = Mage::getModel('mgconnector/queue')->getCollection();
|
1605 |
+
$collection->addFieldToFilter('store_id', array('eq' => $mage_store_view_id));
|
1606 |
+
|
1607 |
+
if(!empty($minId)){
|
1608 |
+
$collection->addFieldToFilter('queue_id', array('gteq' => $minId));
|
1609 |
+
}
|
1610 |
+
|
1611 |
+
if(!empty($maxId)){
|
1612 |
+
$collection->addFieldToFilter('queue_id', array('lteq' => $maxId));
|
1613 |
+
}
|
1614 |
+
|
1615 |
+
$toDelete = $collection->count();
|
1616 |
+
$itemsDeleted = 0;
|
1617 |
+
|
1618 |
+
foreach ($collection as $item) {
|
1619 |
+
$this->_debug(__FUNCTION__, REMARKETY_MGCONNECTOR_CALLED_STATUS, "inside delete events loop", array('id' => $item->getId()));
|
1620 |
+
$item->delete();
|
1621 |
+
$itemsDeleted++;
|
1622 |
+
}
|
1623 |
+
|
1624 |
+
$this->_debug(__FUNCTION__, REMARKETY_MGCONNECTOR_SUCCESS_STATUS, null, $myArgs);
|
1625 |
+
|
1626 |
+
return $this->_wrapResponse(array(
|
1627 |
+
'totalMatching' => $toDelete,
|
1628 |
+
'totalDeleted' => $itemsDeleted
|
1629 |
+
), REMARKETY_MGCONNECTOR_SUCCESS_STATUS);
|
1630 |
+
|
1631 |
+
} catch (Exception $e) {
|
1632 |
+
$this->_log(__FUNCTION__, REMARKETY_MGCONNECTOR_FAILED_STATUS, $e->getMessage(), $myArgs);
|
1633 |
+
return $this->_wrapResponse(null, REMARKETY_MGCONNECTOR_FAILED_STATUS, $e->getMessage());
|
1634 |
+
}
|
1635 |
+
}
|
1636 |
+
|
1637 |
+
public function retryQueueItems($mage_store_view_id, $limit = null, $page = null, $minId = null, $maxId = null)
|
1638 |
+
{
|
1639 |
+
try {
|
1640 |
+
$myArgs = func_get_args();
|
1641 |
+
|
1642 |
+
$this->_debug(__FUNCTION__, REMARKETY_MGCONNECTOR_CALLED_STATUS, null, $myArgs);
|
1643 |
+
|
1644 |
+
$collection = Mage::getModel('mgconnector/queue')->getCollection();
|
1645 |
+
$collection->addFieldToFilter('store_id', array('eq' => $mage_store_view_id));
|
1646 |
+
|
1647 |
+
if(!empty($minId)){
|
1648 |
+
$collection->addFieldToFilter('queue_id', array('gteq' => $minId));
|
1649 |
+
}
|
1650 |
+
|
1651 |
+
if(!empty($maxId)){
|
1652 |
+
$collection->addFieldToFilter('queue_id', array('lteq' => $maxId));
|
1653 |
+
}
|
1654 |
+
|
1655 |
+
$pageSize = null;
|
1656 |
+
$pageNumber = 1; // Note that page numbers begin at 1 and remarkety starts at 0
|
1657 |
+
if ($limit != null) {
|
1658 |
+
$pageSize = $limit;
|
1659 |
+
}
|
1660 |
+
|
1661 |
+
if ($page != null) {
|
1662 |
+
if (!is_null($pageSize)) {
|
1663 |
+
$pageNumber = $page + 1; // Note that page numbers begin at 1 and remarkety starts at 0
|
1664 |
+
}
|
1665 |
+
}
|
1666 |
+
|
1667 |
+
if (!is_null($pageSize)) {
|
1668 |
+
$collection->getSelect()->limit($pageSize, ($pageNumber-1)*$pageSize);
|
1669 |
+
}
|
1670 |
+
|
1671 |
+
$observer = Mage::getModel('mgconnector/observer');
|
1672 |
+
$itemsSent = $observer->resend($collection);
|
1673 |
+
|
1674 |
+
$this->_debug(__FUNCTION__, REMARKETY_MGCONNECTOR_SUCCESS_STATUS, null, $myArgs);
|
1675 |
+
return $this->_wrapResponse(array(
|
1676 |
+
'totalMatching' => $collection->count(),
|
1677 |
+
'sentSuccessfully' => $itemsSent
|
1678 |
+
), REMARKETY_MGCONNECTOR_SUCCESS_STATUS);
|
1679 |
+
} catch (Exception $e) {
|
1680 |
+
$this->_log(__FUNCTION__, REMARKETY_MGCONNECTOR_FAILED_STATUS, $e->getMessage(), $myArgs);
|
1681 |
+
return $this->_wrapResponse(null, REMARKETY_MGCONNECTOR_FAILED_STATUS, $e->getMessage());
|
1682 |
+
}
|
1683 |
+
}
|
1684 |
+
|
1685 |
+
public function getConfig($mage_store_id, $configName, $scope)
|
1686 |
+
{
|
1687 |
+
register_shutdown_function('handleShutdown');
|
1688 |
+
$myArgs = func_get_args();
|
1689 |
+
|
1690 |
+
try {
|
1691 |
+
$this->_debug(__FUNCTION__, REMARKETY_MGCONNECTOR_CALLED_STATUS, null, $myArgs);
|
1692 |
+
$configPath = 'remarkety/mgconnector/' . $configName;
|
1693 |
+
$value = null;
|
1694 |
+
switch($scope){
|
1695 |
+
case 'stores':
|
1696 |
+
$store = Mage::app()->getStore($mage_store_id);
|
1697 |
+
if($store) {
|
1698 |
+
$value = $store->getConfig($configPath);
|
1699 |
+
}
|
1700 |
+
break;
|
1701 |
+
default:
|
1702 |
+
$value = Mage::getStoreConfig($configPath);
|
1703 |
+
}
|
1704 |
+
|
1705 |
+
$this->_debug(__FUNCTION__, REMARKETY_MGCONNECTOR_SUCCESS_STATUS, null, '');
|
1706 |
+
return $this->_wrapResponse(Array(
|
1707 |
+
'value' => $value
|
1708 |
+
), REMARKETY_MGCONNECTOR_SUCCESS_STATUS);
|
1709 |
+
} catch (Exception $e) {
|
1710 |
+
$this->_log(__FUNCTION__, REMARKETY_MGCONNECTOR_FAILED_STATUS, $e->getMessage(), $myArgs);
|
1711 |
+
return $this->_wrapResponse(null, REMARKETY_MGCONNECTOR_FAILED_STATUS, $e->getMessage());
|
1712 |
+
}
|
1713 |
+
}
|
1714 |
+
|
1715 |
+
public function setConfig($mage_store_id, $configName, $scope, $newValue)
|
1716 |
+
{
|
1717 |
+
register_shutdown_function('handleShutdown');
|
1718 |
+
$myArgs = func_get_args();
|
1719 |
+
|
1720 |
+
try {
|
1721 |
+
$this->_debug(__FUNCTION__, REMARKETY_MGCONNECTOR_CALLED_STATUS, null, $myArgs);
|
1722 |
+
$configPath = 'remarkety/mgconnector/' . $configName;
|
1723 |
+
$value = null;
|
1724 |
+
if($scope !== 'stores'){
|
1725 |
+
$scope = 'default';
|
1726 |
+
$mage_store_id = 0;
|
1727 |
+
}
|
1728 |
+
Mage::getModel('core/config')->saveConfig(
|
1729 |
+
$configPath,
|
1730 |
+
$newValue,
|
1731 |
+
$scope,
|
1732 |
+
$mage_store_id
|
1733 |
+
);
|
1734 |
+
|
1735 |
+
Mage::app()->getCacheInstance()->cleanType('config');
|
1736 |
+
Mage::dispatchEvent('adminhtml_cache_refresh_type', array('type' => 'config'));
|
1737 |
+
|
1738 |
+
$this->_debug(__FUNCTION__, REMARKETY_MGCONNECTOR_SUCCESS_STATUS, null, '');
|
1739 |
+
return $this->_wrapResponse(true, REMARKETY_MGCONNECTOR_SUCCESS_STATUS);
|
1740 |
+
} catch (Exception $e) {
|
1741 |
+
$this->_log(__FUNCTION__, REMARKETY_MGCONNECTOR_FAILED_STATUS, $e->getMessage(), $myArgs);
|
1742 |
+
return $this->_wrapResponse(null, REMARKETY_MGCONNECTOR_FAILED_STATUS, $e->getMessage());
|
1743 |
+
}
|
1744 |
+
}
|
1745 |
}
|
1746 |
|
1747 |
|
app/code/community/Remarkety/Mgconnector/Model/Core/Api.php
CHANGED
@@ -275,4 +275,53 @@ class Remarkety_Mgconnector_Model_Core_Api
|
|
275 |
$ret = $myModel->getProductsCount($mage_view_id);
|
276 |
return $ret;
|
277 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
278 |
}
|
275 |
$ret = $myModel->getProductsCount($mage_view_id);
|
276 |
return $ret;
|
277 |
}
|
278 |
+
|
279 |
+
public function getQueueSize($mage_store_view_id, $returnLog = 0)
|
280 |
+
{
|
281 |
+
$myModel = Mage::getModel("mgconnector/core");
|
282 |
+
if ($returnLog)
|
283 |
+
$myModel->sendLogInResponse();
|
284 |
+
return $myModel->getQueueSize($mage_store_view_id);
|
285 |
+
}
|
286 |
+
|
287 |
+
public function getQueueItems($mage_store_view_id,
|
288 |
+
$limit = null,
|
289 |
+
$page = null,
|
290 |
+
$minId = null,
|
291 |
+
$maxId = null,
|
292 |
+
$returnLog = 0)
|
293 |
+
{
|
294 |
+
$myModel = Mage::getModel("mgconnector/core");
|
295 |
+
if ($returnLog)
|
296 |
+
$myModel->sendLogInResponse();
|
297 |
+
return $myModel->getQueueItems($mage_store_view_id, $limit, $page, $minId, $maxId);
|
298 |
+
}
|
299 |
+
|
300 |
+
public function retryQueueItems($mage_store_view_id, $limit = null, $page = null, $minId = null, $maxId = null, $returnLog = 0){
|
301 |
+
$myModel = Mage::getModel("mgconnector/core");
|
302 |
+
if ($returnLog)
|
303 |
+
$myModel->sendLogInResponse();
|
304 |
+
return $myModel->retryQueueItems($mage_store_view_id, $limit, $page, $minId, $maxId);
|
305 |
+
}
|
306 |
+
|
307 |
+
public function deleteQueueItems($mage_store_view_id, $minId = null, $maxId = null, $returnLog = 0){
|
308 |
+
$myModel = Mage::getModel("mgconnector/core");
|
309 |
+
if ($returnLog)
|
310 |
+
$myModel->sendLogInResponse();
|
311 |
+
return $myModel->deleteQueueItems($mage_store_view_id, $minId, $maxId);
|
312 |
+
}
|
313 |
+
|
314 |
+
public function getConfig($mage_store_id, $configName, $scope, $returnLog = 0){
|
315 |
+
$myModel = Mage::getModel("mgconnector/core");
|
316 |
+
if ($returnLog)
|
317 |
+
$myModel->sendLogInResponse();
|
318 |
+
return $myModel->getConfig($mage_store_id, $configName, $scope);
|
319 |
+
}
|
320 |
+
|
321 |
+
public function setConfig($mage_store_id, $configName, $scope, $newValue, $returnLog = 0){
|
322 |
+
$myModel = Mage::getModel("mgconnector/core");
|
323 |
+
if ($returnLog)
|
324 |
+
$myModel->sendLogInResponse();
|
325 |
+
return $myModel->setConfig($mage_store_id, $configName, $scope, $newValue);
|
326 |
+
}
|
327 |
}
|
app/code/community/Remarkety/Mgconnector/Model/Extension/RewardPoints/Observer/AbstractObserver.php
CHANGED
@@ -34,11 +34,10 @@ abstract class Remarkety_Mgconnector_Model_Extension_RewardPoints_Observer_Abstr
|
|
34 |
$customerData['rewards'] = $rewardPointsData;
|
35 |
|
36 |
//queue customer update event
|
37 |
-
$this->
|
38 |
'customers/update',
|
39 |
$customerData,
|
40 |
-
|
41 |
-
null
|
42 |
);
|
43 |
|
44 |
return $this;
|
34 |
$customerData['rewards'] = $rewardPointsData;
|
35 |
|
36 |
//queue customer update event
|
37 |
+
$this->makeRequest(
|
38 |
'customers/update',
|
39 |
$customerData,
|
40 |
+
$this->_customer->getStore()->getId()
|
|
|
41 |
);
|
42 |
|
43 |
return $this;
|
app/code/community/Remarkety/Mgconnector/Model/Extension/RewardPoints/Observer/MagestoreRewardPoints.php
CHANGED
@@ -35,6 +35,10 @@ class Remarkety_Mgconnector_Model_Extension_RewardPoints_Observer_MagestoreRewar
|
|
35 |
return $this;
|
36 |
}
|
37 |
|
|
|
|
|
|
|
|
|
38 |
$rewardPointsCustomerModel = Mage::getModel('rewardpoints/customer')
|
39 |
->load($transactionModel->getCustomerId(), 'customer_id');
|
40 |
|
@@ -55,6 +59,11 @@ class Remarkety_Mgconnector_Model_Extension_RewardPoints_Observer_MagestoreRewar
|
|
55 |
->load($transactionModel->getCustomerId());
|
56 |
$this->sendCustomerUpdateRequest($rewardPointsData);
|
57 |
|
|
|
|
|
|
|
|
|
|
|
58 |
return $this;
|
59 |
}
|
60 |
}
|
35 |
return $this;
|
36 |
}
|
37 |
|
38 |
+
if (Mage::registry('remarkety_customer_save_observer_executed_' . $transactionModel->getCustomerId()) || !$transactionModel->getCustomerId()) {
|
39 |
+
return $this;
|
40 |
+
}
|
41 |
+
|
42 |
$rewardPointsCustomerModel = Mage::getModel('rewardpoints/customer')
|
43 |
->load($transactionModel->getCustomerId(), 'customer_id');
|
44 |
|
59 |
->load($transactionModel->getCustomerId());
|
60 |
$this->sendCustomerUpdateRequest($rewardPointsData);
|
61 |
|
62 |
+
Mage::register(
|
63 |
+
'remarkety_customer_save_observer_executed_' . $transactionModel->getCustomerId(),
|
64 |
+
true
|
65 |
+
);
|
66 |
+
|
67 |
return $this;
|
68 |
}
|
69 |
}
|
app/code/community/Remarkety/Mgconnector/Model/Install.php
CHANGED
@@ -54,6 +54,15 @@ class Remarkety_Mgconnector_Model_Install
|
|
54 |
*/
|
55 |
const XPATH_INSTALLED = 'remarkety/mgconnector/installed';
|
56 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
57 |
/**
|
58 |
* Install data
|
59 |
*
|
@@ -471,6 +480,14 @@ class Remarkety_Mgconnector_Model_Install
|
|
471 |
*/
|
472 |
$m = Mage::getModel('mgconnector/webtracking');
|
473 |
$m->setRemarketyPublicId($storeId, $response['storePublicId']);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
474 |
}
|
475 |
|
476 |
$connection->commit();
|
54 |
*/
|
55 |
const XPATH_INSTALLED = 'remarkety/mgconnector/installed';
|
56 |
|
57 |
+
/**
|
58 |
+
*
|
59 |
+
*/
|
60 |
+
const XPATH_WEBHOOKS_ENABLED = 'remarkety/mgconnector/webhooks';
|
61 |
+
|
62 |
+
const XPATH_WEBTRACKING_ENABLED = 'remarkety/mgconnector/webtracking';
|
63 |
+
|
64 |
+
const XPATH_PRODUCT_WEBHOOKS_DISABLED = 'remarkety/mgconnector/product_webhooks_disable';
|
65 |
+
|
66 |
/**
|
67 |
* Install data
|
68 |
*
|
480 |
*/
|
481 |
$m = Mage::getModel('mgconnector/webtracking');
|
482 |
$m->setRemarketyPublicId($storeId, $response['storePublicId']);
|
483 |
+
|
484 |
+
$m->setEnabled($storeId, true);
|
485 |
+
|
486 |
+
Mage::getModel('core/config')->saveConfig(
|
487 |
+
self::XPATH_WEBHOOKS_ENABLED,
|
488 |
+
true,
|
489 |
+
'default'
|
490 |
+
);
|
491 |
}
|
492 |
|
493 |
$connection->commit();
|
app/code/community/Remarkety/Mgconnector/Model/Observer.php
CHANGED
@@ -13,12 +13,22 @@ if (!defined("REMARKETY_LOG"))
|
|
13 |
|
14 |
class Remarkety_Mgconnector_Model_Observer
|
15 |
{
|
16 |
-
const REMARKETY_EVENTS_ENDPOINT = 'https://
|
17 |
const REMARKETY_METHOD = 'POST';
|
18 |
const REMARKETY_TIMEOUT = 2;
|
19 |
const REMARKETY_VERSION = 0.9;
|
20 |
const REMARKETY_PLATFORM = 'MAGENTO';
|
21 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
22 |
protected $_token = null;
|
23 |
protected $_intervals = null;
|
24 |
protected $_customer = null;
|
@@ -30,6 +40,9 @@ class Remarkety_Mgconnector_Model_Observer
|
|
30 |
protected $_address = null;
|
31 |
protected $_origAddressData = null;
|
32 |
|
|
|
|
|
|
|
33 |
private $response_mask = array(
|
34 |
'product' => array(
|
35 |
'id',
|
@@ -53,6 +66,18 @@ class Remarkety_Mgconnector_Model_Observer
|
|
53 |
)
|
54 |
);
|
55 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
56 |
public function __construct()
|
57 |
{
|
58 |
$this->_token = Mage::getStoreConfig('remarkety/mgconnector/api_key');
|
@@ -61,9 +86,402 @@ class Remarkety_Mgconnector_Model_Observer
|
|
61 |
$intervals = "1,3,10";
|
62 |
}
|
63 |
$this->_intervals = explode(',', $intervals);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
64 |
}
|
65 |
|
|
|
|
|
|
|
|
|
|
|
|
|
66 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
67 |
|
68 |
public function triggerCustomerAddressBeforeUpdate($observer)
|
69 |
{
|
@@ -122,6 +540,10 @@ class Remarkety_Mgconnector_Model_Observer
|
|
122 |
$this->_address = $observer->getEvent()->getCustomerAddress();
|
123 |
$this->_customer = $this->_address->getCustomer();
|
124 |
|
|
|
|
|
|
|
|
|
125 |
if (Mage::registry('remarkety_customer_save_observer_executed_' . $this->_customer->getId())) {
|
126 |
return $this;
|
127 |
}
|
@@ -134,17 +556,21 @@ class Remarkety_Mgconnector_Model_Observer
|
|
134 |
return $this;
|
135 |
}
|
136 |
|
137 |
-
$this->_customerUpdate()
|
|
|
|
|
|
|
|
|
|
|
138 |
|
139 |
-
Mage::register(
|
140 |
-
'remarkety_customer_save_observer_executed_' . $this->_customer->getId(),
|
141 |
-
true
|
142 |
-
);
|
143 |
|
144 |
return $this;
|
145 |
}
|
146 |
|
147 |
private function shouldUpdateRule($rule){
|
|
|
|
|
|
|
148 |
$now = new DateTime();
|
149 |
$currentFromDate = new DateTime($rule->getFromDate());
|
150 |
$currentToDate = new DateTime($rule->getToDate());
|
@@ -202,27 +628,57 @@ class Remarkety_Mgconnector_Model_Observer
|
|
202 |
{
|
203 |
$this->_customer = $observer->getEvent()->getCustomer();
|
204 |
|
|
|
|
|
|
|
|
|
205 |
if (Mage::registry('remarkety_customer_save_observer_executed_' . $this->_customer->getId()) || !$this->_customer->getId()) {
|
206 |
return $this;
|
207 |
}
|
208 |
|
209 |
if ($this->_customer->getOrigData() === null) {
|
210 |
$this->_customerRegistration();
|
|
|
211 |
} else {
|
212 |
-
$this->_customerUpdate();
|
213 |
}
|
214 |
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
|
|
|
|
219 |
|
220 |
return $this;
|
221 |
}
|
222 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
223 |
public function triggerSubscribeUpdate($observer)
|
224 |
{
|
225 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
226 |
|
227 |
$loggedIn = Mage::getSingleton('customer/session')->isLoggedIn();
|
228 |
|
@@ -235,9 +691,24 @@ class Remarkety_Mgconnector_Model_Observer
|
|
235 |
return $this;
|
236 |
}
|
237 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
238 |
$this->makeRequest(
|
239 |
-
|
240 |
-
$
|
|
|
241 |
);
|
242 |
|
243 |
$email = $this->_subscriber->getSubscriberEmail();
|
@@ -259,10 +730,16 @@ class Remarkety_Mgconnector_Model_Observer
|
|
259 |
public function triggerSubscribeDelete($observer)
|
260 |
{
|
261 |
$this->_subscriber = $observer->getEvent()->getSubscriber();
|
|
|
|
|
|
|
|
|
262 |
if (!Mage::registry('remarkety_subscriber_deleted_' . $this->_subscriber->getEmail()) && $this->_subscriber->getId()) {
|
|
|
263 |
$this->makeRequest(
|
264 |
-
|
265 |
-
$this->_prepareCustomerSubscribtionDeleteData()
|
|
|
266 |
);
|
267 |
}
|
268 |
|
@@ -276,28 +753,128 @@ class Remarkety_Mgconnector_Model_Observer
|
|
276 |
return $this;
|
277 |
}
|
278 |
|
|
|
|
|
|
|
|
|
279 |
$this->makeRequest(
|
280 |
-
|
281 |
array(
|
282 |
'id' => (int)$this->_customer->getId(),
|
283 |
-
'email' => $this->_customer->getEmail()
|
284 |
-
)
|
285 |
);
|
286 |
|
287 |
return $this;
|
288 |
}
|
289 |
|
290 |
-
public function
|
291 |
-
|
292 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
293 |
return $this;
|
294 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
295 |
|
296 |
protected function _customerRegistration()
|
297 |
{
|
298 |
$this->makeRequest(
|
299 |
-
|
300 |
-
$this->_prepareCustomerUpdateData()
|
|
|
301 |
);
|
302 |
|
303 |
return $this;
|
@@ -307,12 +884,14 @@ class Remarkety_Mgconnector_Model_Observer
|
|
307 |
{
|
308 |
if ($this->_hasDataChanged()) {
|
309 |
$this->makeRequest(
|
310 |
-
|
311 |
-
$this->_prepareCustomerUpdateData()
|
|
|
312 |
);
|
|
|
313 |
}
|
314 |
|
315 |
-
return
|
316 |
}
|
317 |
|
318 |
protected function _hasDataChanged()
|
@@ -355,6 +934,10 @@ class Remarkety_Mgconnector_Model_Observer
|
|
355 |
}
|
356 |
}
|
357 |
}
|
|
|
|
|
|
|
|
|
358 |
if (!$this->_hasDataChanged && $this->_address && $this->_origAddressData) {
|
359 |
$validate = array(
|
360 |
'street',
|
@@ -363,6 +946,8 @@ class Remarkety_Mgconnector_Model_Observer
|
|
363 |
'postcode',
|
364 |
'country_id',
|
365 |
'telephone',
|
|
|
|
|
366 |
);
|
367 |
$addressDiffKeys = array_keys(
|
368 |
array_diff(
|
@@ -393,7 +978,7 @@ class Remarkety_Mgconnector_Model_Observer
|
|
393 |
);
|
394 |
}
|
395 |
|
396 |
-
protected function _getHeaders($eventType, $payload)
|
397 |
{
|
398 |
$domain = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
|
399 |
$url = parse_url($domain);
|
@@ -410,27 +995,63 @@ class Remarkety_Mgconnector_Model_Observer
|
|
410 |
$headers[] = 'X-Magento-Store-Id: ' . $payload['storeId'];
|
411 |
} elseif (isset($payload['store_id'])) {
|
412 |
$headers[] = 'X-Magento-Store-Id: ' . $payload['store_id'];
|
|
|
|
|
|
|
|
|
|
|
413 |
}
|
414 |
|
415 |
return $headers;
|
416 |
}
|
417 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
418 |
public function makeRequest(
|
419 |
$eventType,
|
420 |
$payload,
|
|
|
421 |
$attempt = 1,
|
422 |
$queueId = null
|
423 |
) {
|
424 |
try {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
425 |
$client = new Zend_Http_Client(
|
426 |
-
|
427 |
$this->_getRequestConfig($eventType)
|
428 |
);
|
429 |
$payload = array_merge(
|
430 |
$payload,
|
431 |
$this->_getPayloadBase($eventType)
|
432 |
);
|
433 |
-
$headers = $this->_getHeaders($eventType, $payload);
|
434 |
unset($payload['storeId']);
|
435 |
$json = json_encode($payload);
|
436 |
|
@@ -452,32 +1073,40 @@ class Remarkety_Mgconnector_Model_Observer
|
|
452 |
case '401':
|
453 |
throw new Exception('Request failed, probably wrong API key or inactive account.');
|
454 |
default:
|
|
|
455 |
$this->_queueRequest(
|
456 |
$eventType,
|
457 |
$payload,
|
458 |
$attempt,
|
459 |
-
$queueId
|
|
|
|
|
460 |
);
|
461 |
}
|
462 |
} catch (Exception $e) {
|
463 |
-
$this->_queueRequest($eventType, $payload, $attempt, $queueId);
|
464 |
}
|
465 |
|
466 |
return false;
|
467 |
}
|
468 |
|
469 |
-
protected function _queueRequest($eventType, $payload, $attempt, $queueId)
|
470 |
{
|
471 |
$queueModel = Mage::getModel('mgconnector/queue');
|
472 |
|
473 |
-
if(!empty($this->_intervals[$attempt-1])) {
|
474 |
$now = time();
|
475 |
-
$nextAttempt = $now
|
|
|
|
|
|
|
476 |
if ($queueId) {
|
477 |
$queueModel->load($queueId);
|
478 |
$queueModel->setAttempts($attempt);
|
479 |
$queueModel->setLastAttempt(date("Y-m-d H:i:s", $now));
|
480 |
$queueModel->setNextAttempt(date("Y-m-d H:i:s", $nextAttempt));
|
|
|
|
|
481 |
} else {
|
482 |
$queueModel->setData(
|
483 |
array(
|
@@ -486,6 +1115,8 @@ class Remarkety_Mgconnector_Model_Observer
|
|
486 |
'attempts' => $attempt,
|
487 |
'last_attempt' => date("Y-m-d H:i:s", $now),
|
488 |
'next_attempt' => date("Y-m-d H:i:s", $nextAttempt),
|
|
|
|
|
489 |
)
|
490 |
);
|
491 |
}
|
@@ -510,102 +1141,21 @@ class Remarkety_Mgconnector_Model_Observer
|
|
510 |
|
511 |
protected function _prepareCustomerUpdateData()
|
512 |
{
|
513 |
-
$
|
514 |
-
|
515 |
-
|
516 |
-
'created_at' => date(
|
517 |
-
'c',
|
518 |
-
strtotime($this->_customer->getCreatedAt())
|
519 |
-
),
|
520 |
-
'first_name' => $this->_customer->getFirstname(),
|
521 |
-
'last_name' => $this->_customer->getLastname(),
|
522 |
-
'store_id' => $this->_customer->getStoreId(),
|
523 |
-
//'extra_info' => array(),
|
524 |
-
);
|
525 |
-
|
526 |
-
$isSubscribed = $this->_customer->getIsSubscribed();
|
527 |
-
if ($isSubscribed === null) {
|
528 |
-
$subscriber = Mage::getModel('newsletter/subscriber')
|
529 |
-
->loadByEmail($this->_customer->getEmail());
|
530 |
-
if ($subscriber->getId()) {
|
531 |
-
$isSubscribed = $subscriber->getData('subscriber_status') == Mage_Newsletter_Model_Subscriber::STATUS_SUBSCRIBED;
|
532 |
-
} else {
|
533 |
-
$isSubscribed = false;
|
534 |
-
}
|
535 |
-
}
|
536 |
-
$arr = array_merge(
|
537 |
-
$arr,
|
538 |
-
array('accepts_marketing' => (bool)$isSubscribed)
|
539 |
-
);
|
540 |
-
|
541 |
-
if ($title = $this->_customer->getPrefix()) {
|
542 |
-
$arr = array_merge($arr, array('title' => $title));
|
543 |
-
}
|
544 |
-
|
545 |
-
if ($dob = $this->_customer->getDob()) {
|
546 |
-
$arr = array_merge($arr, array('birthdate' => $dob));
|
547 |
-
}
|
548 |
-
|
549 |
-
if ($gender = $this->_customer->getGender()) {
|
550 |
-
$arr = array_merge($arr, array('gender' => $gender));
|
551 |
-
}
|
552 |
-
|
553 |
-
if ($address = $this->_customer->getDefaultBillingAddress()) {
|
554 |
-
$street = $address->getStreet();
|
555 |
-
$arr = array_merge(
|
556 |
-
$arr,
|
557 |
-
array(
|
558 |
-
'default_address' => array(
|
559 |
-
'address1' => isset($street[0]) ? $street[0] : '',
|
560 |
-
'address2' => isset($street[1]) ? $street[1] : '',
|
561 |
-
'city' => $address->getCity(),
|
562 |
-
'province' => $address->getRegion(),
|
563 |
-
'phone' => $address->getTelephone(),
|
564 |
-
'country_code' => $address->getCountryId(),
|
565 |
-
'zip' => $address->getPostcode(),
|
566 |
-
),
|
567 |
-
)
|
568 |
-
);
|
569 |
-
}
|
570 |
-
|
571 |
-
$tags = $this->_getCustomerProductTags();
|
572 |
-
if (!empty($tags) && $tags->getSize()) {
|
573 |
-
$tagsArr = array();
|
574 |
-
foreach ($tags as $_tag) {
|
575 |
-
$tagsArr[] = $_tag->getName();
|
576 |
-
}
|
577 |
-
$arr = array_merge($arr, array('tags' => $tagsArr));
|
578 |
-
}
|
579 |
-
|
580 |
-
if ($group = Mage::getModel('customer/group')->load($this->_customer->getGroupId())) {
|
581 |
-
$arr = array_merge($arr, array(
|
582 |
-
'groups' => array(
|
583 |
-
array(
|
584 |
-
'id' => (int)$this->_customer->getGroupId(),
|
585 |
-
'name' => $group->getCustomerGroupCode(),
|
586 |
-
),
|
587 |
-
),
|
588 |
-
));
|
589 |
-
}
|
590 |
-
|
591 |
-
$extensionHelper = Mage::helper('mgconnector/extension');
|
592 |
-
$rewardPointsInstance = $extensionHelper
|
593 |
-
->getRewardPointsIntegrationInstance();
|
594 |
-
if ($rewardPointsInstance !== false) {
|
595 |
-
$arr['rewards'] = $rewardPointsInstance
|
596 |
-
->getCustomerUpdateData($this->_customer->getId());
|
597 |
-
}
|
598 |
-
|
599 |
-
return $arr;
|
600 |
}
|
601 |
|
602 |
-
protected function _getCustomerProductTags()
|
603 |
{
|
|
|
|
|
|
|
604 |
$tags = Mage::getModel('tag/tag')->getResourceCollection();
|
605 |
if (!empty($tags)) {
|
606 |
$tags = $tags
|
607 |
->joinRel()
|
608 |
-
->addCustomerFilter($
|
609 |
}
|
610 |
|
611 |
return $tags;
|
@@ -643,6 +1193,12 @@ class Remarkety_Mgconnector_Model_Observer
|
|
643 |
return $arr;
|
644 |
}
|
645 |
|
|
|
|
|
|
|
|
|
|
|
|
|
646 |
public function resend($queueItems, $resetAttempts = false)
|
647 |
{
|
648 |
$sent = 0;
|
@@ -651,23 +1207,31 @@ class Remarkety_Mgconnector_Model_Observer
|
|
651 |
if($_queue->getEventType() == "catalogruleupdated"){
|
652 |
//create queue for price rule update
|
653 |
$ruleData = unserialize($_queue->getPayload());
|
|
|
|
|
|
|
|
|
|
|
654 |
$ruleId = isset($ruleData['ruleId']) ? $ruleData['ruleId'] : false;
|
655 |
if($ruleId){
|
656 |
$result = $this->sendProductPrices($ruleId);
|
657 |
}
|
658 |
} else {
|
659 |
//send event to remarkety
|
660 |
-
$result = $this->makeRequest(
|
|
|
661 |
unserialize($_queue->getPayload()),
|
|
|
662 |
$resetAttempts ? 1 : ($_queue->getAttempts() + 1),
|
663 |
-
$_queue->getId()
|
664 |
-
|
665 |
-
|
666 |
-
|
667 |
-
->
|
668 |
-
|
669 |
-
|
670 |
}
|
|
|
671 |
}
|
672 |
|
673 |
return $sent;
|
@@ -706,17 +1270,19 @@ class Remarkety_Mgconnector_Model_Observer
|
|
706 |
protected function _productsUpdate($storeId, $data, $toQueue = false)
|
707 |
{
|
708 |
if($toQueue){
|
709 |
-
$this->_queueRequest(
|
710 |
} else {
|
711 |
-
$this->makeRequest(
|
712 |
}
|
713 |
-
|
714 |
return $this;
|
715 |
}
|
716 |
|
717 |
|
718 |
public function sendProductPrices($ruleId = null)
|
719 |
{
|
|
|
|
|
|
|
720 |
// Fix for scenario when method is called directly as cron.
|
721 |
if (is_object($ruleId)) {
|
722 |
$ruleId = null;
|
@@ -785,7 +1351,7 @@ class Remarkety_Mgconnector_Model_Observer
|
|
785 |
$product = Mage::getModel('catalog/product')->load($productId);
|
786 |
$pWebsites = $product->getWebsiteIds();
|
787 |
if(in_array($websiteId, $pWebsites)) {
|
788 |
-
$rows[] = $this->
|
789 |
$i++;
|
790 |
}
|
791 |
}
|
@@ -800,42 +1366,67 @@ class Remarkety_Mgconnector_Model_Observer
|
|
800 |
return true;
|
801 |
}
|
802 |
|
803 |
-
|
804 |
{
|
805 |
-
|
806 |
-
|
807 |
-
|
808 |
-
$productData['base_image'] = array('src' => Mage::getModel('mgconnector/core')->getImageUrl($product, 'image', $mage_store_id));
|
809 |
-
$productData['small_image'] = array('src' => Mage::getModel('mgconnector/core')->getImageUrl($product, 'small', $mage_store_id));
|
810 |
-
$productData['thumbnail_image'] = array('src' => Mage::getModel('mgconnector/core')->getImageUrl($product, 'thumbnail', $mage_store_id));
|
811 |
|
812 |
-
|
813 |
-
|
814 |
-
|
815 |
-
|
816 |
}
|
817 |
-
|
818 |
-
|
819 |
-
$price = Mage::getModel('catalogrule/rule')->calcProductPriceRule($product,$product->getPrice());
|
820 |
-
$productData['price'] = empty($price) ? $product->getFinalPrice() : $price;
|
821 |
-
$productData['special_price'] = $product->getSpecialPrice();
|
822 |
-
|
823 |
-
$prodUrl = Mage::getModel('mgconnector/core')->getProdUrl($product, $storeUrl, $mage_store_id);
|
824 |
-
$productData['id'] = $productData['entity_id'];
|
825 |
-
$productData['url'] = $prodUrl;
|
826 |
-
$productData['title'] = Mage::getModel('mgconnector/core')->getProductName($product, $mage_store_id);
|
827 |
-
$productData['enabled'] = $product->isSalable() && $product->isVisibleInSiteVisibility();
|
828 |
-
$productData['visibility'] = $product->getVisibility();
|
829 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
830 |
|
831 |
-
|
832 |
-
|
833 |
-
|
|
|
|
|
|
|
|
|
|
|
834 |
}
|
|
|
835 |
|
836 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
837 |
|
838 |
-
|
|
|
|
|