Remarkety_Mgconnector - Version 1.5.1.2

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

Files changed (22) hide show
  1. CHANGELOG.txt +25 -0
  2. app/code/community/Remarkety/Mgconnector/Block/Adminhtml/Install/Welcome/Store.php +12 -1
  3. app/code/community/Remarkety/Mgconnector/Block/Adminhtml/Queue/Configure/Form.php +53 -27
  4. app/code/community/Remarkety/Mgconnector/Block/Adminhtml/Queue/Grid.php +29 -21
  5. app/code/community/Remarkety/Mgconnector/Block/Tracking/Base.php +6 -1
  6. app/code/community/Remarkety/Mgconnector/Helper/Configuration.php +87 -1
  7. app/code/community/Remarkety/Mgconnector/Model/Core.php +244 -16
  8. app/code/community/Remarkety/Mgconnector/Model/Core/Api.php +49 -0
  9. app/code/community/Remarkety/Mgconnector/Model/Extension/RewardPoints/Observer/AbstractObserver.php +2 -3
  10. app/code/community/Remarkety/Mgconnector/Model/Extension/RewardPoints/Observer/MagestoreRewardPoints.php +9 -0
  11. app/code/community/Remarkety/Mgconnector/Model/Install.php +17 -0
  12. app/code/community/Remarkety/Mgconnector/Model/Observer.php +755 -164
  13. app/code/community/Remarkety/Mgconnector/Model/Webtracking.php +32 -4
  14. app/code/community/Remarkety/Mgconnector/controllers/Adminhtml/InstallController.php +62 -6
  15. app/code/community/Remarkety/Mgconnector/controllers/Adminhtml/QueueController.php +21 -9
  16. app/code/community/Remarkety/Mgconnector/etc/api.xml +18 -0
  17. app/code/community/Remarkety/Mgconnector/etc/config.xml +105 -4
  18. app/code/community/Remarkety/Mgconnector/sql/mgconnector_setup/mysql4-upgrade-1.4.10.4-1.5.0.0.php +24 -0
  19. app/code/community/Remarkety/Mgconnector/sql/mgconnector_setup/mysql4-upgrade-1.5.0.0-1.5.0.1.php +24 -0
  20. app/design/adminhtml/default/default/template/mgconnector/install/welcome/store.phtml +10 -2
  21. app/design/frontend/base/default/template/mgconnector/tracking/general.phtml +1 -1
  22. 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->getRemarketyPublicId($_store->getStoreId());
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
- '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
- $button = $fieldset->addField(
 
 
 
 
 
 
 
 
 
 
 
 
 
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
- 'header' => $helper->__('Next Attempt'),
90
- 'width' => '200px',
91
- 'type' => 'datetime',
92
- 'index' => 'next_attempt'
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
- return ($this->getRemarketyPublicId() !== false);
 
 
 
 
 
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
- public function getValue($key, $default = null)
 
 
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
- $url = Mage::helper('mgconnector/urls')->getValue($product_id, $mage_store_view_id);
1278
- if (!empty($url)) {
1279
- $url = $storeUrl . $url;
1280
- if (Mage::getStoreConfig('catalog/seo/product_url_suffix', $mage_store_view_id)) {
1281
- $url .= Mage::getStoreConfig('catalog/seo/product_url_suffix', $mage_store_view_id);
 
 
 
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 (!empty($url)) {
1290
- return $url;
1291
- } else {
1292
- $getProductUrl = $product->getProductUrl();
1293
- $this->_debug(__FUNCTION__, "getProductUrl: " . $getProductUrl, null, '');
1294
- return $getProductUrl;
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, $mage_store_view_id);
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
- if (empty($subscriber)) {
 
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
- private function loadProduct($productId)
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->_queueRequest(
38
  'customers/update',
39
  $customerData,
40
- 1,
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://api-events.remarkety.com/v1';
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
- Mage::register(
216
- 'remarkety_customer_save_observer_executed_' . $this->_customer->getId(),
217
- true
218
- );
 
 
219
 
220
  return $this;
221
  }
222
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
223
  public function triggerSubscribeUpdate($observer)
224
  {
225
- $this->_subscriber = $observer->getEvent()->getSubscriber();
 
 
 
 
 
 
 
 
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
- 'customers/create',
240
- $this->_prepareCustomerSubscribtionUpdateData(true)
 
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
- 'customers/update',
265
- $this->_prepareCustomerSubscribtionDeleteData()
 
266
  );
267
  }
268
 
@@ -276,28 +753,128 @@ class Remarkety_Mgconnector_Model_Observer
276
  return $this;
277
  }
278
 
 
 
 
 
279
  $this->makeRequest(
280
- 'customers/delete',
281
  array(
282
  'id' => (int)$this->_customer->getId(),
283
- 'email' => $this->_customer->getEmail(),
284
- )
285
  );
286
 
287
  return $this;
288
  }
289
 
290
- public function triggerProductSave($observer)
291
- {
292
- // TODO - Need to implement
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
293
  return $this;
294
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
295
 
296
  protected function _customerRegistration()
297
  {
298
  $this->makeRequest(
299
- 'customers/create',
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
- 'customers/update',
311
- $this->_prepareCustomerUpdateData()
 
312
  );
 
313
  }
314
 
315
- return $this;
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
- self::REMARKETY_EVENTS_ENDPOINT,
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 + (int)$this->_intervals[$attempt - 1] * 60;
 
 
 
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
- $arr = array(
514
- 'id' => (int)$this->_customer->getId(),
515
- 'email' => $this->_customer->getEmail(),
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($this->_customer->getId());
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($_queue->getEventType(),
 
661
  unserialize($_queue->getPayload()),
 
662
  $resetAttempts ? 1 : ($_queue->getAttempts() + 1),
663
- $_queue->getId());
664
- }
665
- if ($result) {
666
- Mage::getModel('mgconnector/queue')
667
- ->load($_queue->getId())
668
- ->delete();
669
- $sent++;
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('products/update', array('storeId' => $storeId, 'products' => $data), 1, null);
710
  } else {
711
- $this->makeRequest('products/update', array('storeId' => $storeId, 'products' => $data));
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->_prepareProductData($product, $store->getStoreId(), $storeUrls[$store->getStoreId()]);
789
  $i++;
790
  }
791
  }
@@ -800,42 +1366,67 @@ class Remarkety_Mgconnector_Model_Observer
800
  return true;
801
  }
802
 
803
- private function _prepareProductData($product,$mage_store_id,$storeUrl)
804
  {
805
- $product->setStoreId($mage_store_id)->setCustomerGroupId(0);
806
-
807
- $productData = $product->toArray();
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
- $cats = Mage::getModel('mgconnector/core')->_productCategories($product);
813
- $categoriesNames = array();
814
- foreach($cats as $catName){
815
- $categoriesNames[] = array('name' => $catName);
816
  }
817
- $productData['categories'] = $categoriesNames;
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
- $parent_id = Mage::getModel('mgconnector/core')->getProductParentId($product);
832
- if($parent_id !== false){
833
- $productData['parent_id'] = $parent_id;
 
 
 
 
 
834
  }
 
835
 
836
- $productData = $this->_filter_output_data($productData, $this->response_mask['product']);
 
 
 
 
 
 
 
 
837
 
838
- return $productData;
 
 
 
 
 
 
 
 
 
839
  }
840
 
 
 
 
 
 
 
841
  }
13
 
14
  class Remarkety_Mgconnector_Model_Observer
15
  {
16
+ const REMARKETY_EVENTS_ENDPOINT = 'https://webhooks.remarkety.com/webhooks';
17
  const REMARKETY_METHOD = 'POST';
18
  const REMARKETY_TIMEOUT = 2;
19
  const REMARKETY_VERSION = 0.9;
20
  const REMARKETY_PLATFORM = 'MAGENTO';
21
 
22
+ const EVENT_ORDERS_CREATED = 'orders/create';
23
+ const EVENT_ORDERS_UPDATED = 'orders/updated';
24
+ const EVENT_ORDERS_DELETE = 'orders/delete';
25
+ const EVENT_CUSTOMERS_CREATED = 'customers/create';
26
+ const EVENT_CUSTOMERS_UPDATED = 'customers/update';
27
+ const EVENT_CUSTOMERS_DELETE = 'customers/delete';
28
+ const EVENT_PRODUCTS_CREATED = 'products/create';
29
+ const EVENT_PRODUCTS_UPDATED = 'products/update';
30
+ const EVENT_PRODUCTS_DELETED = 'products/delete';
31
+
32
  protected $_token = null;
33
  protected $_intervals = null;
34
  protected $_customer = null;
40
  protected $_address = null;
41
  protected $_origAddressData = null;
42
 
43
+ protected $_sentEventsHash = array();
44
+ protected $_productStoreIds;
45
+
46
  private $response_mask = array(
47
  'product' => array(
48
  'id',
66
  )
67
  );
68
 
69
+ /**
70
+ * @var $_configHelp Remarkety_Mgconnector_Helper_Configuration
71
+ */
72
+ private $_configHelp;
73
+
74
+ /**
75
+ * @var $rmCore Remarkety_Mgconnector_Model_Core
76
+ */
77
+ private $_rmCore;
78
+
79
+ private $_forceAsync = false;
80
+
81
  public function __construct()
82
  {
83
  $this->_token = Mage::getStoreConfig('remarkety/mgconnector/api_key');
86
  $intervals = "1,3,10";
87
  }
88
  $this->_intervals = explode(',', $intervals);
89
+ $this->_configHelp = Mage::helper('mgconnector/configuration');
90
+ $this->_rmCore = Mage::getModel("mgconnector/core");
91
+
92
+ $this->_forceAsync = Mage::helper('mgconnector/configuration')->getValue('forceasyncwebhooks', false);
93
+ }
94
+
95
+ private function _log($function, $status, $message, $data, $logLevel = Zend_Log::DEBUG)
96
+ {
97
+ $logMsg = implode(REMARKETY_LOG_SEPARATOR, array($function, $status, $message, json_encode($data)));
98
+ // $force = ($status != REMARKETY_MGCONNECTOR_CALLED_STATUS);
99
+ Mage::log($logMsg, $logLevel, REMARKETY_LOG);
100
+ }
101
+
102
+ public function triggerOrderUpdate($observer){
103
+ $order = $observer->getOrder();
104
+ if(!$this->_configHelp->isWebhooksEnabled($order->getStore()->getId())){
105
+ return $this;
106
+ }
107
+
108
+ $eventType = self::EVENT_ORDERS_UPDATED;
109
+ if ($order->getOrigData() === null) {
110
+ $eventType = self::EVENT_ORDERS_CREATED;
111
+ }
112
+
113
+ $data = $this->serializeOrder($order);
114
+ $this->makeRequest($eventType, $data, $order->getStore()->getId());
115
+ }
116
+
117
+ /**
118
+ * @param array $address
119
+ * @return array
120
+ */
121
+ private function serializeAddress($address){
122
+ $country = Mage::getModel('directory/country')->loadByCode($address['country_id']);
123
+ return array(
124
+ 'first_name' => $address['firstname'],
125
+ 'last_name' => $address['lastname'],
126
+ 'city' => $address['city'],
127
+ 'street' => $address['street'],
128
+ 'country_code' => $address['country_id'],
129
+ 'country' => $country->getName(),
130
+ 'zip' => $address['postcode'],
131
+ 'phone' => $address['telephone'],
132
+ 'region' => $address['region']
133
+ );
134
+ }
135
+
136
+ /**
137
+ * @param Mage_Customer_Model_Customer $customer
138
+ * @return array
139
+ */
140
+ public function serializeCustomer($customer){
141
+
142
+ $groupModel = Mage::getModel("customer/group");
143
+ $groups = array();
144
+ $group_id = $customer->getGroupId();
145
+ if(!empty($group_id)) {
146
+ $groupModel->load($customer->getGroupId());
147
+ $groupName = $groupModel->getCustomerGroupCode();
148
+ $groups[] = array(
149
+ 'id' => $customer->getGroupId(),
150
+ 'name' => $groupName
151
+ );
152
+ }
153
+
154
+ $subscriberModel = Mage::getModel("newsletter/subscriber");
155
+ $subscriberModel->loadByEmail($customer->getEmail());
156
+
157
+ $billingAddress = $customer->getDefaultBillingAddress();
158
+ $customerAddress = $billingAddress ? $billingAddress : $customer->getDefaultShippingAddress();
159
+
160
+ $tags = $this->_getCustomerProductTags($customer);
161
+ $tagsArr = array();
162
+ if (!empty($tags) && $tags->getSize()) {
163
+ foreach ($tags as $_tag) {
164
+ $tagsArr[] = $_tag->getName();
165
+ }
166
+ }
167
+
168
+ if($customer->getIsSubscribed()){
169
+ $allowed = true;
170
+ } else {
171
+ $allowed = $subscriberModel->isSubscribed();
172
+ }
173
+
174
+ $gender = $customer->getResource()->getAttribute("gender");
175
+ $genderVal = null;
176
+ if ($gender->usesSource()) {
177
+ $genderVal = $gender->getSource()->getOptionText($customer->getGender());
178
+ }
179
+
180
+ $info = array(
181
+ 'id' => $customer->getId(),
182
+ 'storeId' => $customer->getStore()->getId(),
183
+ 'accepts_marketing' => $allowed,
184
+ 'birthdate' => $customer->getDob(),
185
+ 'email' => $customer->getEmail(),
186
+ 'title' => $customer->getPrefix(),
187
+ 'first_name' => $customer->getFirstname(),
188
+ 'last_name' => $customer->getLastname(),
189
+ 'groups' => $groups,
190
+ 'created_at' => $customer->getCreatedAt(),
191
+ 'updated_at' => $customer->getUpdatedAt(),
192
+ 'guest' => false,
193
+ 'default_address' => $customerAddress ? $this->serializeAddress($customerAddress->getData()) : null,
194
+ 'tags' => $tagsArr,
195
+ 'gender' => !empty($genderVal) ? $genderVal : null
196
+ );
197
+ $extensionHelper = Mage::helper('mgconnector/extension');
198
+ $rewardPointsInstance = $extensionHelper
199
+ ->getRewardPointsIntegrationInstance();
200
+ if ($rewardPointsInstance !== false) {
201
+ $info['rewards'] = $rewardPointsInstance
202
+ ->getCustomerUpdateData($customer->getId());
203
+ }
204
+
205
+ return $info;
206
+ }
207
+
208
+ /**
209
+ * @param $orderId
210
+ * @return string|null
211
+ */
212
+ private function loadPaymentMethod($orderId)
213
+ {
214
+
215
+ $paymentsCollection = Mage::getModel("sales/order_payment")
216
+ ->getCollection()
217
+ ->addOrder('main_table.entity_id', 'DESC')
218
+ ->addAttributeToFilter('main_table.parent_id', array('eq' => $orderId))
219
+ ->addAttributeToSelect('parent_id')
220
+ ->addAttributeToSelect('method');
221
+
222
+
223
+ foreach ($paymentsCollection as $payment) {
224
+ $row = $payment->toArray();
225
+ $method = $row['method'];
226
+ $methodName = Mage::getStoreConfig('payment/' . $method . '/title');
227
+ if (!empty($methodName)) {
228
+ return $methodName;
229
+ } else {
230
+ return $method;
231
+ }
232
+ }
233
+
234
+ return null;
235
+ }
236
+
237
+ /**
238
+ * @param Mage_Sales_Model_Order $order
239
+ * @return bool|array
240
+ */
241
+ public function serializeOrder($order){
242
+
243
+ $orderData = $order->toArray();
244
+ if (!empty($orderData['relation_child_id'])) {
245
+ return false;
246
+ }
247
+
248
+
249
+ $shippingAddress = null;
250
+ if (isset($orderData['shipping_address_id']) && $orderData['shipping_address_id']) {
251
+ $shippingAddress = Mage::getModel('sales/order_address')->load($orderData['shipping_address_id'])->toArray();
252
+ }
253
+ $billingAddress = null;
254
+ if (isset($orderData['billing_address_id']) && $orderData['billing_address_id']) {
255
+ $billingAddress = Mage::getModel('sales/order_address')->load($orderData['billing_address_id'])->toArray();
256
+ }
257
+
258
+ /**
259
+ * @var $rmCore Remarkety_Mgconnector_Model_Core
260
+ */
261
+ $rmCore = Mage::getModel("mgconnector/core");
262
+
263
+ $customerAddress = null;
264
+ if($orderData['customer_is_guest']) {
265
+ $subscriberModel = Mage::getModel("newsletter/subscriber");
266
+ $subscriberModel->loadByEmail($orderData['customer_email']);
267
+
268
+ $customerAddress = !empty($billingAddress) ? $billingAddress : $shippingAddress;
269
+ $customerInfo = array(
270
+ 'id' => $orderData['customer_id'],
271
+ 'accepts_marketing' => $subscriberModel->isSubscribed(),
272
+ 'birthdate' => $orderData['customer_dob'],
273
+ 'email' => $orderData['customer_email'],
274
+ 'title' => $orderData['customer_prefix'],
275
+ 'first_name' => $orderData['customer_firstname'],
276
+ 'last_name' => $orderData['customer_lastname'],
277
+ 'groups' => array(),
278
+ 'created_at' => $orderData['created_at'],
279
+ 'updated_at' => $orderData['updated_at'],
280
+ 'guest' => true,
281
+ 'default_address' => $this->serializeAddress($customerAddress)
282
+ );
283
+ } else {
284
+ //get address for customer
285
+ $customer_id = $order->getCustomerId();
286
+ $customer = Mage::getModel('customer/customer')->load($customer_id);
287
+ $customerInfo = $this->serializeCustomer($customer);
288
+ }
289
+
290
+ $discounts = array();
291
+ if(!empty($orderData['coupon_code'])){
292
+ $discounts[] = array(
293
+ 'code' => $orderData['coupon_code'],
294
+ 'amount' => (float)$orderData['discount_amount']
295
+ );
296
+ }
297
+
298
+ $line_items = array();
299
+ $itemsCollection = $order->getAllVisibleItems();
300
+ $store = $order->getStore();
301
+ $storeUrl = $store->getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB, true);
302
+ $store_id = $store->getId();
303
+
304
+ /**
305
+ * @var $item Mage_Sales_Model_Order_Item
306
+ */
307
+ foreach ($itemsCollection as $item) {
308
+ try {
309
+ $enabled = $item->getProduct()->getIsSalable();
310
+ if($enabled){
311
+ $enabled = $item->getProduct()->isVisibleInCatalog() || $item->getProduct()->isVisibleInSiteVisibility();
312
+ }
313
+
314
+ $images = $this->getProductImages($item->getProduct());
315
+
316
+ $itemArr = array(
317
+ 'product_parent_id' => $rmCore->getProductParentId($item->getProduct()),
318
+ 'product_id' => $item->getProductId(),
319
+ 'quantity' => (float)$item->getQtyOrdered(),
320
+ 'sku' => $item->getSku(),
321
+ 'name' => $item->getName(),
322
+ 'title' => $rmCore->getProductName($item->getProduct(), $store_id),
323
+ 'price' => (float)$item->getBasePrice(),
324
+ 'product_exists' => $enabled,
325
+ 'url' => $rmCore->getProdUrl($item->getProduct(), $storeUrl, $store_id),
326
+ 'images' => $images
327
+ );
328
+
329
+ $line_items[] = $itemArr;
330
+ } catch (Exception $e) {
331
+ $this->_log(__FUNCTION__, 'Error in handling order items for order ID ' . $orderData['entity_id'], $e->getMessage(), $orderData, Zend_Log::ERR);
332
+ }
333
+ }
334
+
335
+ $shipping_lines = array();
336
+ $shipmentCollection = Mage::getResourceModel('sales/order_shipment_collection')
337
+ ->setOrderFilter($order)
338
+ ->load();
339
+ /**
340
+ * @var $shipment Mage_Sales_Model_Order_Shipment
341
+ */
342
+ foreach ($shipmentCollection as $shipment){
343
+ /**
344
+ * @var $tracknum Mage_Sales_Model_Order_Shipment_Track
345
+ */
346
+ foreach($shipment->getAllTracks() as $tracknum)
347
+ {
348
+ $shipping_lines[] = array(
349
+ 'title' => $tracknum->getTitle(),
350
+ 'tracking_number' => $tracknum->getNumber()
351
+ );
352
+ }
353
+
354
+ }
355
+
356
+ $data = array(
357
+ 'storeId' => $store->getId(),
358
+ 'id' => (empty($orderData['original_increment_id'])) ? $orderData['increment_id'] : $orderData['original_increment_id'],
359
+ 'name' => $orderData['increment_id'],
360
+ 'created_at' => $orderData['created_at'],
361
+ 'updated_at' => $orderData['updated_at'],
362
+ 'currency' => $orderData['order_currency_code'],
363
+ 'discount_codes' => $discounts,
364
+ 'email' => $orderData['customer_email'],
365
+ 'payment_method' => $this->loadPaymentMethod($order->getId()),
366
+ 'fulfillment_status' => '',
367
+ 'line_items' => $line_items,
368
+ 'note' => $orderData['customer_note'],
369
+ 'status' => array(
370
+ 'code' => $order->getStatus(),
371
+ 'name' => $order->getStatusLabel(),
372
+ ),
373
+ 'subtotal_price' => $orderData['subtotal'],
374
+ 'taxes_included' => true,
375
+ 'total_discounts' => $orderData['discount_amount'],
376
+ 'total_price' => $orderData['grand_total'],
377
+ 'total_shipping' => $orderData['shipping_amount'],
378
+ 'total_tax' => $orderData['tax_amount'],
379
+ 'customer' => $customerInfo,
380
+ 'shipping_address' => $this->serializeAddress($shippingAddress),
381
+ 'billing_address' => $this->serializeAddress($billingAddress),
382
+ 'shipping_lines' => $shipping_lines
383
+ );
384
+ return $data;
385
+ }
386
+
387
+ private function getProductImages($product){
388
+ /**
389
+ * @var $rmCore Remarkety_Mgconnector_Model_Core
390
+ */
391
+ $rmCore = Mage::getModel("mgconnector/core");
392
+
393
+ $images = array();
394
+ $baseImage = $rmCore->getImageUrl($product, 'image');
395
+ if(!empty($baseImage)){
396
+ $images[] = array(
397
+ 'src' => $baseImage,
398
+ 'type' => 'base_image'
399
+ );
400
+ }
401
+ $smallImage = $rmCore->getImageUrl($product, 'small');
402
+ if(!empty($smallImage)){
403
+ $images[] = array(
404
+ 'src' => $smallImage,
405
+ 'type' => 'small_image'
406
+ );
407
+ }
408
+ $thumbnailImage = $rmCore->getImageUrl($product, 'thumbnail');
409
+ if(!empty($thumbnailImage)){
410
+ $images[] = array(
411
+ 'src' => $thumbnailImage,
412
+ 'type' => 'thumbnail_image'
413
+ );
414
+ }
415
+ return $images;
416
  }
417
 
418
+ /**
419
+ * @param Mage_Catalog_Model_Product $product
420
+ * @param $storeId
421
+ * @return array
422
+ */
423
+ public function serializeProduct($product, $storeId){
424
 
425
+ /**
426
+ * @var $rmCore Remarkety_Mgconnector_Model_Core
427
+ */
428
+ $rmCore = Mage::getModel("mgconnector/core");
429
+
430
+ $store = Mage::App()->getStore($storeId);
431
+ $storeUrl = $store->getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB, true);
432
+
433
+ $categories = $rmCore->_productCategories($product);
434
+ $categories = array_map(function ($val) {
435
+ return array(
436
+ 'name' => $val
437
+ );
438
+ }, $categories);
439
+
440
+ $now = Mage::getSingleton('core/date')->timestamp(time());
441
+ $rules = Mage::getResourceModel('catalogrule/rule');
442
+ $price = $rules->getRulePrice($now, $store->getWebsiteId(), 0, $product->getId());
443
+ $price = empty($price) ? $product->getFinalPrice() : (float)$price;
444
+ $special_price = $product->getSpecialPrice();
445
+
446
+ $stocklevel = (int)Mage::getModel('cataloginventory/stock_item')
447
+ ->loadByProduct($product)->getQty();
448
+
449
+ $originalStore = Mage::app()->getStore();
450
+ Mage::app()->setCurrentStore($storeId);
451
+ $product = $rmCore->loadProduct($product->getId());
452
+ $stores = $product->getStoreIds();
453
+ if(!in_array($storeId, $stores)){
454
+ $enabled = false;
455
+ } else {
456
+ $enabled = $product->isAvailable() && ($product->isVisibleInCatalog() || $product->isVisibleInSiteVisibility());
457
+ }
458
+ $url = $rmCore->getProdUrl($product, $storeUrl, $storeId);
459
+ Mage::app()->setCurrentStore($originalStore->getId());
460
+
461
+ $data = array(
462
+ 'id' => $product->getId(),
463
+ 'sku' => $product->getSku(),
464
+ 'title' => $rmCore->getProductName($product, $storeId),
465
+ 'body_html' => '',
466
+ 'categories' => $categories,
467
+ 'created_at' => $product->getCreatedAt(),
468
+ 'updated_at' => $product->getUpdatedAt(),
469
+ 'images' => $this->getProductImages($product),
470
+ 'enabled' => $enabled,
471
+ 'price' => $price,
472
+ 'special_price' => $special_price,
473
+ 'url' => $url,
474
+ 'parent_id' => $rmCore->getProductParentId($product),
475
+ 'variants' => array(
476
+ array(
477
+ 'inventory_quantity' => $stocklevel,
478
+ 'price' => $price
479
+ )
480
+ )
481
+ );
482
+
483
+ return $data;
484
+ }
485
 
486
  public function triggerCustomerAddressBeforeUpdate($observer)
487
  {
540
  $this->_address = $observer->getEvent()->getCustomerAddress();
541
  $this->_customer = $this->_address->getCustomer();
542
 
543
+ if(!$this->_configHelp->isStoreInstalled($this->_customer->getStore()->getId())){
544
+ return $this;
545
+ }
546
+
547
  if (Mage::registry('remarkety_customer_save_observer_executed_' . $this->_customer->getId())) {
548
  return $this;
549
  }
556
  return $this;
557
  }
558
 
559
+ if($this->_customerUpdate()){
560
+ Mage::register(
561
+ 'remarkety_customer_save_observer_executed_' . $this->_customer->getId(),
562
+ true
563
+ );
564
+ }
565
 
 
 
 
 
566
 
567
  return $this;
568
  }
569
 
570
  private function shouldUpdateRule($rule){
571
+ if(!$this->shouldSendProductUpdates()){
572
+ return false;
573
+ }
574
  $now = new DateTime();
575
  $currentFromDate = new DateTime($rule->getFromDate());
576
  $currentToDate = new DateTime($rule->getToDate());
628
  {
629
  $this->_customer = $observer->getEvent()->getCustomer();
630
 
631
+ if(!$this->_configHelp->isStoreInstalled($this->_customer->getStore()->getId())){
632
+ return $this;
633
+ }
634
+
635
  if (Mage::registry('remarkety_customer_save_observer_executed_' . $this->_customer->getId()) || !$this->_customer->getId()) {
636
  return $this;
637
  }
638
 
639
  if ($this->_customer->getOrigData() === null) {
640
  $this->_customerRegistration();
641
+ $done = true;
642
  } else {
643
+ $done = $this->_customerUpdate();
644
  }
645
 
646
+ if($done) {
647
+ Mage::register(
648
+ 'remarkety_customer_save_observer_executed_' . $this->_customer->getId(),
649
+ true
650
+ );
651
+ }
652
 
653
  return $this;
654
  }
655
 
656
+ public function triggerCartUpdated($observer){
657
+ try {
658
+ $cart = $observer->getCart();
659
+ if($cart){
660
+ $quote = $cart->getQuote();
661
+ $email = Mage::getSingleton('customer/session')->getSubscriberEmail();
662
+ if ($email && $quote && !is_null($quote->getId()) && is_null($quote->getCustomerEmail())) {
663
+ $quote->setCustomerEmail($email)->save();
664
+ }
665
+ }
666
+ } catch (Exception $ex){
667
+ $this->_log('triggerCartUpdated', '', $ex->getMessage(), null, Zend_Log::ERR);
668
+ }
669
+ }
670
+
671
  public function triggerSubscribeUpdate($observer)
672
  {
673
+ /**
674
+ * @var $subscriber Mage_Newsletter_Model_Subscriber
675
+ */
676
+ $subscriber = $observer->getEvent()->getSubscriber();
677
+ $this->_subscriber = $subscriber;
678
+
679
+ if(!$this->_configHelp->isStoreInstalled($this->_subscriber->getStoreId())){
680
+ return $this;
681
+ }
682
 
683
  $loggedIn = Mage::getSingleton('customer/session')->isLoggedIn();
684
 
691
  return $this;
692
  }
693
 
694
+ $new = $subscriber->isObjectNew();
695
+
696
+
697
+ if($this->_subscriber->getCustomerId()){
698
+ $customer = Mage::getModel('customer/customer')->load($this->_subscriber->getCustomerId());
699
+ $data = $this->serializeCustomer($customer);
700
+ Mage::register(
701
+ 'remarkety_customer_save_observer_executed_' . $customer->getId(),
702
+ true
703
+ );
704
+
705
+ } else {
706
+ $data = $this->_prepareCustomerSubscribtionUpdateData(true);
707
+ }
708
  $this->makeRequest(
709
+ $new ? self::EVENT_CUSTOMERS_CREATED : self::EVENT_CUSTOMERS_UPDATED,
710
+ $data,
711
+ $this->_subscriber->getStoreId()
712
  );
713
 
714
  $email = $this->_subscriber->getSubscriberEmail();
730
  public function triggerSubscribeDelete($observer)
731
  {
732
  $this->_subscriber = $observer->getEvent()->getSubscriber();
733
+ if(!$this->_configHelp->isStoreInstalled($this->_subscriber->getStoreId())){
734
+ return $this;
735
+ }
736
+
737
  if (!Mage::registry('remarkety_subscriber_deleted_' . $this->_subscriber->getEmail()) && $this->_subscriber->getId()) {
738
+
739
  $this->makeRequest(
740
+ self::EVENT_CUSTOMERS_UPDATED,
741
+ $this->_prepareCustomerSubscribtionDeleteData(),
742
+ $this->_subscriber->getStoreId()
743
  );
744
  }
745
 
753
  return $this;
754
  }
755
 
756
+ if(!$this->_configHelp->isStoreInstalled($this->_customer->getStore()->getId())){
757
+ return $this;
758
+ }
759
+
760
  $this->makeRequest(
761
+ self::EVENT_CUSTOMERS_DELETE,
762
  array(
763
  'id' => (int)$this->_customer->getId(),
764
+ 'email' => $this->_customer->getEmail()
765
+ ), $this->_customer->getStore()->getId()
766
  );
767
 
768
  return $this;
769
  }
770
 
771
+ public function triggerProductDeleteBefore($observer){
772
+ /**
773
+ * @var $product Mage_Catalog_Model_Product
774
+ */
775
+ $product = $observer->getProduct();
776
+ $this->_productStoreIds = $product->getStoreIds();
777
+ }
778
+ public function triggerProductDelete($observer){
779
+
780
+
781
+ /**
782
+ * @var $product Mage_Catalog_Model_Product
783
+ */
784
+ $product = $observer->getProduct();
785
+ //should send this event to all relevant stores
786
+ foreach($this->_productStoreIds as $storeId) {
787
+ if($this->_configHelp->isWebhooksEnabled($storeId)) {
788
+ $this->makeRequest(self::EVENT_PRODUCTS_DELETED, array(
789
+ 'id' => $product->getId()
790
+ ), $storeId);
791
+ }
792
+ }
793
  return $this;
794
  }
795
+ public function triggerCategoryChangeProducts($observer){
796
+ if(!$this->shouldSendProductUpdates()){
797
+ return $this;
798
+ }
799
+
800
+ $ids = $observer->getProductIds();
801
+ if(!empty($ids)){
802
+ foreach ($ids as $productId){
803
+ $product = $this->_rmCore->loadProduct($productId);
804
+ $this->productUpdate($product, $product->getStoreIds(), self::EVENT_PRODUCTS_UPDATED);
805
+ }
806
+ }
807
+ }
808
+
809
+ public function triggerProductSaveBefore($observer){
810
+ /**
811
+ * We need to store the original store ids to make sure to update removed store
812
+ * Also in commit_after we cant get the store ids for some reason
813
+ */
814
+ if(!$this->shouldSendProductUpdates()){
815
+ return $this;
816
+ }
817
+ $product = $observer->getProduct();
818
+
819
+ $dbStores = array();
820
+ if ($product->getOrigData() !== null) {
821
+ $productDb = Mage::getModel("catalog/product")->load($product->getId());
822
+ $dbStores = $productDb->getStoreIds();
823
+ }
824
+ $ids = array_merge($dbStores, $product->getStoreIds());
825
+ $this->_productStoreIds = array_unique($ids);
826
+ }
827
+ public function triggerProductSaveCommit($observer){
828
+ if(!$this->shouldSendProductUpdates()){
829
+ return $this;
830
+ }
831
+ $product = $observer->getProduct();
832
+ $storeIds = $this->_productStoreIds;
833
+ if ($product->getOrigData() === null) {
834
+ $eventType = self::EVENT_PRODUCTS_CREATED;
835
+ } else {
836
+ $eventType = self::EVENT_PRODUCTS_UPDATED;
837
+ }
838
+ $this->productUpdate($product, $storeIds, $eventType);
839
+
840
+ return $this;
841
+ }
842
+
843
+ private function productUpdate($product, $storeIds, $eventType){
844
+ $childProducts = array();
845
+ $grouped = array(
846
+ Mage_Catalog_Model_Product_Type::TYPE_CONFIGURABLE,
847
+ Mage_Catalog_Model_Product_Type::TYPE_GROUPED
848
+ );
849
+ if(in_array($product->getTypeId(), $grouped)){
850
+ $childProductsIds = Mage::helper('mgconnector/links')->getSimpleIds($product->getId());
851
+ if(!empty($childProductsIds)) {
852
+ foreach ($childProductsIds as $childProductsId) {
853
+ $childProducts[] = $this->_rmCore->loadProduct($childProductsId);
854
+ }
855
+ }
856
+ }
857
+
858
+ foreach($storeIds as $storeId) {
859
+ if ($this->_configHelp->isWebhooksEnabled($storeId)) {
860
+ $data = $this->serializeProduct($product, $storeId);
861
+ $this->makeRequest($eventType, $data, $storeId);
862
+ if(!empty($childProducts)){
863
+ foreach ($childProducts as $childProduct) {
864
+ $data = $this->serializeProduct($childProduct, $storeId);
865
+ $this->makeRequest($eventType, $data, $storeId);
866
+ }
867
+ }
868
+ }
869
+ }
870
+ }
871
 
872
  protected function _customerRegistration()
873
  {
874
  $this->makeRequest(
875
+ self::EVENT_CUSTOMERS_CREATED,
876
+ $this->_prepareCustomerUpdateData(),
877
+ $this->_customer->getStore()->getId()
878
  );
879
 
880
  return $this;
884
  {
885
  if ($this->_hasDataChanged()) {
886
  $this->makeRequest(
887
+ self::EVENT_CUSTOMERS_UPDATED,
888
+ $this->_prepareCustomerUpdateData(),
889
+ $this->_customer->getStore()->getId()
890
  );
891
+ return true;
892
  }
893
 
894
+ return false;
895
  }
896
 
897
  protected function _hasDataChanged()
934
  }
935
  }
936
  }
937
+ if (!$this->_hasDataChanged && $this->_address && empty($this->_origAddressData)) {
938
+ //new address
939
+ $this->_hasDataChanged = true;
940
+ }
941
  if (!$this->_hasDataChanged && $this->_address && $this->_origAddressData) {
942
  $validate = array(
943
  'street',
946
  'postcode',
947
  'country_id',
948
  'telephone',
949
+ 'firstname',
950
+ 'lastname'
951
  );
952
  $addressDiffKeys = array_keys(
953
  array_diff(
978
  );
979
  }
980
 
981
+ protected function _getHeaders($eventType, $payload, $storeId = null)
982
  {
983
  $domain = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
984
  $url = parse_url($domain);
995
  $headers[] = 'X-Magento-Store-Id: ' . $payload['storeId'];
996
  } elseif (isset($payload['store_id'])) {
997
  $headers[] = 'X-Magento-Store-Id: ' . $payload['store_id'];
998
+ } elseif (!empty($storeId)){
999
+ $headers[] = 'X-Magento-Store-Id: ' . $storeId;
1000
+ } else {
1001
+ $store = Mage::app()->getStore();
1002
+ $headers[] = 'X-Magento-Store-Id: ' . $store->getId();
1003
  }
1004
 
1005
  return $headers;
1006
  }
1007
 
1008
+ protected function shouldSendEvent($eventType, $payload, $storeId = null){
1009
+ $data = array(
1010
+ 'eventType' => $eventType,
1011
+ 'payload' => $payload,
1012
+ 'storeId' => $storeId
1013
+ );
1014
+ $hash = md5(serialize($data));
1015
+ if(array_key_exists($hash, $this->_sentEventsHash)){
1016
+ return false;
1017
+ }
1018
+ $this->_sentEventsHash[$hash] = true;
1019
+ return true;
1020
+ }
1021
  public function makeRequest(
1022
  $eventType,
1023
  $payload,
1024
+ $storeId,
1025
  $attempt = 1,
1026
  $queueId = null
1027
  ) {
1028
  try {
1029
+ if(!$this->shouldSendEvent($eventType, $payload, $storeId)){
1030
+ //safety for not sending the same event on same event
1031
+ $this->_log(__FUNCTION__, '', 'Event already sent', $payload);
1032
+ return true;
1033
+ }
1034
+
1035
+ if($this->_forceAsync && $attempt == 1 && empty($queueId)){
1036
+ $this->_queueRequest($eventType, $payload, 0, $queueId, $storeId);
1037
+ return true;
1038
+ }
1039
+
1040
+ $url = self::REMARKETY_EVENTS_ENDPOINT;
1041
+ $storeAppId = $this->_configHelp->getRemarketyPublicId($storeId);
1042
+ if($storeAppId){
1043
+ $url .= '?storeId=' . $storeAppId;
1044
+ }
1045
+
1046
  $client = new Zend_Http_Client(
1047
+ $url,
1048
  $this->_getRequestConfig($eventType)
1049
  );
1050
  $payload = array_merge(
1051
  $payload,
1052
  $this->_getPayloadBase($eventType)
1053
  );
1054
+ $headers = $this->_getHeaders($eventType, $payload, $storeId);
1055
  unset($payload['storeId']);
1056
  $json = json_encode($payload);
1057
 
1073
  case '401':
1074
  throw new Exception('Request failed, probably wrong API key or inactive account.');
1075
  default:
1076
+ $error = $response->getStatus() . ' ' . $response->getBody();
1077
  $this->_queueRequest(
1078
  $eventType,
1079
  $payload,
1080
  $attempt,
1081
+ $queueId,
1082
+ $storeId,
1083
+ $error
1084
  );
1085
  }
1086
  } catch (Exception $e) {
1087
+ $this->_queueRequest($eventType, $payload, $attempt, $queueId, $storeId, $e->getMessage());
1088
  }
1089
 
1090
  return false;
1091
  }
1092
 
1093
+ protected function _queueRequest($eventType, $payload, $attempt, $queueId, $storeId = null, $errorMessage = null)
1094
  {
1095
  $queueModel = Mage::getModel('mgconnector/queue');
1096
 
1097
+ if($attempt === 0 || !empty($this->_intervals[$attempt-1])) {
1098
  $now = time();
1099
+ $nextAttempt = $now;
1100
+ if($attempt !== 0){
1101
+ $nextAttempt = $now + (int)$this->_intervals[$attempt - 1] * 60;
1102
+ }
1103
  if ($queueId) {
1104
  $queueModel->load($queueId);
1105
  $queueModel->setAttempts($attempt);
1106
  $queueModel->setLastAttempt(date("Y-m-d H:i:s", $now));
1107
  $queueModel->setNextAttempt(date("Y-m-d H:i:s", $nextAttempt));
1108
+ $queueModel->setStoreId($storeId);
1109
+ $queueModel->setLastErrorMessage($errorMessage);
1110
  } else {
1111
  $queueModel->setData(
1112
  array(
1115
  'attempts' => $attempt,
1116
  'last_attempt' => date("Y-m-d H:i:s", $now),
1117
  'next_attempt' => date("Y-m-d H:i:s", $nextAttempt),
1118
+ 'store_id' => $storeId,
1119
+ 'last_error_message' => $errorMessage
1120
  )
1121
  );
1122
  }
1141
 
1142
  protected function _prepareCustomerUpdateData()
1143
  {
1144
+ $data = $this->serializeCustomer($this->_customer);
1145
+ $data['storeId'] = $this->_customer->getStore()->getId();
1146
+ return $data;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1147
  }
1148
 
1149
+ protected function _getCustomerProductTags($customer = null)
1150
  {
1151
+ if(is_null($customer)){
1152
+ $customer = $this->_customer;
1153
+ }
1154
  $tags = Mage::getModel('tag/tag')->getResourceCollection();
1155
  if (!empty($tags)) {
1156
  $tags = $tags
1157
  ->joinRel()
1158
+ ->addCustomerFilter($customer->getId());
1159
  }
1160
 
1161
  return $tags;
1193
  return $arr;
1194
  }
1195
 
1196
+ private function deleteQueueItem($itemId){
1197
+ Mage::getModel('mgconnector/queue')
1198
+ ->load($itemId)
1199
+ ->delete();
1200
+ }
1201
+
1202
  public function resend($queueItems, $resetAttempts = false)
1203
  {
1204
  $sent = 0;
1207
  if($_queue->getEventType() == "catalogruleupdated"){
1208
  //create queue for price rule update
1209
  $ruleData = unserialize($_queue->getPayload());
1210
+
1211
+ //delete the event from queue to make sure it's not running twice
1212
+ $this->deleteQueueItem($_queue->getId());
1213
+ $sent++;
1214
+
1215
  $ruleId = isset($ruleData['ruleId']) ? $ruleData['ruleId'] : false;
1216
  if($ruleId){
1217
  $result = $this->sendProductPrices($ruleId);
1218
  }
1219
  } else {
1220
  //send event to remarkety
1221
+ $result = $this->makeRequest(
1222
+ $_queue->getEventType(),
1223
  unserialize($_queue->getPayload()),
1224
+ $_queue->getStoreId(),
1225
  $resetAttempts ? 1 : ($_queue->getAttempts() + 1),
1226
+ $_queue->getId()
1227
+ );
1228
+ if ($result) {
1229
+ //delete the event from queue on success
1230
+ $this->deleteQueueItem($_queue->getId());
1231
+ $sent++;
1232
+ }
1233
  }
1234
+
1235
  }
1236
 
1237
  return $sent;
1270
  protected function _productsUpdate($storeId, $data, $toQueue = false)
1271
  {
1272
  if($toQueue){
1273
+ $this->_queueRequest(self::EVENT_PRODUCTS_UPDATED, array('products' => $data), 1, null, $storeId);
1274
  } else {
1275
+ $this->makeRequest(self::EVENT_PRODUCTS_UPDATED, array('products' => $data), $storeId);
1276
  }
 
1277
  return $this;
1278
  }
1279
 
1280
 
1281
  public function sendProductPrices($ruleId = null)
1282
  {
1283
+ if(!$this->shouldSendProductUpdates()){
1284
+ return false;
1285
+ }
1286
  // Fix for scenario when method is called directly as cron.
1287
  if (is_object($ruleId)) {
1288
  $ruleId = null;
1351
  $product = Mage::getModel('catalog/product')->load($productId);
1352
  $pWebsites = $product->getWebsiteIds();
1353
  if(in_array($websiteId, $pWebsites)) {
1354
+ $rows[] = $this->serializeProduct($product, $store->getStoreId());
1355
  $i++;
1356
  }
1357
  }
1366
  return true;
1367
  }
1368
 
1369
+ public function catalogInventorySave(Varien_Event_Observer $observer)
1370
  {
1371
+ if ($this->shouldSendProductUpdates()) {
1372
+ $event = $observer->getEvent();
1373
+ $_item = $event->getItem();
 
 
 
1374
 
1375
+ if ((int)$_item->getData('qty') != (int)$_item->getOrigData('qty')) {
1376
+ $product = $this->_rmCore->loadProduct($_item->getProductId());
1377
+ $this->productUpdate($product, $product->getStoreIds(), self::EVENT_PRODUCTS_UPDATED);
1378
+ }
1379
  }
1380
+ }
 
 
 
 
 
 
 
 
 
 
 
1381
 
1382
+ public function subtractQuoteInventory(Varien_Event_Observer $observer)
1383
+ {
1384
+ if ($this->shouldSendProductUpdates()) {
1385
+ $quote = $observer->getEvent()->getQuote();
1386
+ foreach ($quote->getAllItems() as $item) {
1387
+ $product = $this->_rmCore->loadProduct($item->getProductId());
1388
+ $this->productUpdate($product, $product->getStoreIds(), self::EVENT_PRODUCTS_UPDATED);
1389
+ }
1390
+ }
1391
+ }
1392
 
1393
+ public function revertQuoteInventory(Varien_Event_Observer $observer)
1394
+ {
1395
+ if ($this->shouldSendProductUpdates()) {
1396
+ $quote = $observer->getEvent()->getQuote();
1397
+ foreach ($quote->getAllItems() as $item) {
1398
+ $product = $this->_rmCore->loadProduct($item->getProductId());
1399
+ $this->productUpdate($product, $product->getStoreIds(), self::EVENT_PRODUCTS_UPDATED);
1400
+ }
1401
  }
1402
+ }
1403
 
1404
+ public function cancelOrderItem(Varien_Event_Observer $observer)
1405
+ {
1406
+ //update products inventory when item is removed from order
1407
+ if ($this->shouldSendProductUpdates()) {
1408
+ $item = $observer->getEvent()->getItem();
1409
+ $product = $this->_rmCore->loadProduct($item->getProductId());
1410
+ $this->productUpdate($product, $product->getStoreIds(), self::EVENT_PRODUCTS_UPDATED);
1411
+ }
1412
+ }
1413
 
1414
+ public function refundOrderInventory(Varien_Event_Observer $observer)
1415
+ {
1416
+ //update products inventory when order is refunded
1417
+ if ($this->shouldSendProductUpdates()) {
1418
+ $creditmemo = $observer->getEvent()->getCreditmemo();
1419
+ foreach ($creditmemo->getAllItems() as $item) {
1420
+ $product = $this->_rmCore->loadProduct($item->getProductId());
1421
+ $this->productUpdate($product, $product->getStoreIds(), self::EVENT_PRODUCTS_UPDATED);
1422
+ }
1423
+ }
1424
  }
1425
 
1426
+ private function shouldSendProductUpdates($storeId = null){
1427
+ if($this->_configHelp->isWebhooksEnabled($storeId)){
1428
+ return $this->_configHelp->isProductWebhooksEnabled();
1429
+ }
1430
+ return false;
1431
+ }
1432
  }
app/code/community/Remarkety/Mgconnector/Model/Webtracking.php CHANGED
@@ -5,12 +5,40 @@ Class Remarkety_Mgconnector_Model_Webtracking extends Mage_Core_Model_Abstract
5
  const RM_STORE_ID = 'remarkety/mgconnector/public_storeId';
6
  const RM_BYPASS_CACHE = 'remarkety/mgconnector/bypass_cache';
7
  const STORE_SCOPE = 'stores';
8
- public function getRemarketyPublicId($store = null)
9
- {
10
  $store = is_null($store) ? Mage::app()->getStore() : $store;
11
  $store_id = is_numeric($store) ? $store : $store->getStoreId();
12
- $id = Mage::getStoreConfig(self::RM_STORE_ID, $store_id);
13
- return (empty($id) || is_null($id)) ? false : $id;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
14
  }
15
 
16
  public function setRemarketyPublicId($store, $newId)
5
  const RM_STORE_ID = 'remarkety/mgconnector/public_storeId';
6
  const RM_BYPASS_CACHE = 'remarkety/mgconnector/bypass_cache';
7
  const STORE_SCOPE = 'stores';
8
+
9
+ public function isEnabled($store = null){
10
  $store = is_null($store) ? Mage::app()->getStore() : $store;
11
  $store_id = is_numeric($store) ? $store : $store->getStoreId();
12
+ $status = Mage::getStoreConfig(Remarkety_Mgconnector_Model_Install::XPATH_WEBTRACKING_ENABLED, $store_id);
13
+ if(is_null($status)){
14
+ //legacy support before we had the webtracking enabled param
15
+ $appId = $this->getRemarketyPublicId($store);
16
+ return !empty($appId);
17
+ }
18
+ return (empty($status)) ? false : true;
19
+ }
20
+
21
+ public function setEnabled($store = null, $status){
22
+ $store = is_null($store) ? Mage::app()->getStore() : $store;
23
+ $store_id = is_numeric($store) ? $store : $store->getStoreId();
24
+
25
+ Mage::getModel('core/config')->saveConfig(
26
+ Remarkety_Mgconnector_Model_Install::XPATH_WEBTRACKING_ENABLED,
27
+ $status,
28
+ self::STORE_SCOPE,
29
+ $store_id
30
+ );
31
+ Mage::app()->getCacheInstance()->cleanType('config');
32
+ Mage::dispatchEvent('adminhtml_cache_refresh_type', array('type' => 'config'));
33
+ }
34
+
35
+ public function getRemarketyPublicId($store = null)
36
+ {
37
+ /**
38
+ * @var $configHelper Remarkety_Mgconnector_Helper_Configuration
39
+ */
40
+ $configHelper = Mage::helper('mgconnector/configuration');
41
+ return $configHelper->getRemarketyPublicId($store);
42
  }
43
 
44
  public function setRemarketyPublicId($store, $newId)
app/code/community/Remarkety/Mgconnector/controllers/Adminhtml/InstallController.php CHANGED
@@ -16,7 +16,7 @@ class Remarkety_Mgconnector_Adminhtml_InstallController extends Mage_Adminhtml_C
16
  * @return bool
17
  */
18
 
19
- protected function _isAllowed()
20
  {
21
  return true;
22
  }
@@ -85,6 +85,61 @@ class Remarkety_Mgconnector_Adminhtml_InstallController extends Mage_Adminhtml_C
85
  ->renderLayout();
86
  }
87
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
88
  /**
89
  * Enable webtracking action
90
  */
@@ -93,7 +148,7 @@ class Remarkety_Mgconnector_Adminhtml_InstallController extends Mage_Adminhtml_C
93
  $store_id = $this->getRequest()->getParam('store');
94
  if(!is_numeric($store_id) || is_null($store_id)){
95
  throw new Exception("Missing store id");
96
- }
97
 
98
  /**
99
  * @var $m Remarkety_Mgconnector_Model_Webtracking
@@ -107,9 +162,10 @@ class Remarkety_Mgconnector_Adminhtml_InstallController extends Mage_Adminhtml_C
107
  $rmStoreId = $req->getStoreID($store_id);
108
  if($rmStoreId){
109
  $m->setRemarketyPublicId($store_id, $rmStoreId);
 
110
  Mage::app()->getCacheInstance()->cleanType('config');
111
  Mage::dispatchEvent('adminhtml_cache_refresh_type', array('type' => 'config'));
112
- }
113
 
114
  $this->_redirect('*/install/install', array('mode' => 'welcome'));
115
  }
@@ -122,13 +178,13 @@ class Remarkety_Mgconnector_Adminhtml_InstallController extends Mage_Adminhtml_C
122
  $store_id = $this->getRequest()->getParam('store');
123
  if(!is_numeric($store_id) || is_null($store_id)){
124
  throw new Exception("Missing store id");
125
- }
126
 
127
  /**
128
  * @var $m Remarkety_Mgconnector_Model_Webtracking
129
  */
130
  $m = Mage::getModel('mgconnector/webtracking');
131
- $m->setRemarketyPublicId($store_id, null);
132
  Mage::app()->getCacheInstance()->cleanType('config');
133
  Mage::dispatchEvent('adminhtml_cache_refresh_type', array('type' => 'config'));
134
  $this->_redirect('*/install/install', array('mode' => 'welcome'));
@@ -153,7 +209,7 @@ class Remarkety_Mgconnector_Adminhtml_InstallController extends Mage_Adminhtml_C
153
  * @param string $mode
154
  * @return string
155
  */
156
- protected function _getTitle($mode)
157
  {
158
  return ucwords(str_replace('_', ' - ', $mode));
159
  }
16
  * @return bool
17
  */
18
 
19
+ protected function _isAllowed()
20
  {
21
  return true;
22
  }
85
  ->renderLayout();
86
  }
87
 
88
+ public function enableWebhooksAction(){
89
+
90
+ /**
91
+ * @var $configHelper Remarkety_Mgconnector_Helper_Configuration
92
+ */
93
+ $configHelper = Mage::helper('mgconnector/configuration');
94
+
95
+ /**
96
+ * @var $m Remarkety_Mgconnector_Model_Webtracking
97
+ */
98
+ $m = Mage::getModel('mgconnector/webtracking');
99
+
100
+ /**
101
+ * @var $req Remarkety_Mgconnector_Model_Request
102
+ */
103
+ $req = Mage::getModel('mgconnector/request');
104
+
105
+ $stores = $configHelper->getInstalledStores();
106
+ foreach($stores as $store_id){
107
+ $store = Mage::app()->getStore($store_id);
108
+ $publicId = $m->getRemarketyPublicId($store);
109
+ if(empty($publicId)){
110
+ //get public store id from remarkety
111
+ $publicId = $req->getStoreID($store_id);
112
+ if($publicId){
113
+ $m->setRemarketyPublicId($store_id, $publicId);
114
+ //webtracking was disabled (didn't have store id), make sure it is still disabled
115
+ $m->setEnabled($store, false);
116
+ }
117
+ }
118
+ }
119
+
120
+ Mage::getModel('core/config')->saveConfig(
121
+ Remarkety_Mgconnector_Model_Install::XPATH_WEBHOOKS_ENABLED,
122
+ true,
123
+ 'default'
124
+ );
125
+
126
+ Mage::app()->getCacheInstance()->cleanType('config');
127
+ Mage::dispatchEvent('adminhtml_cache_refresh_type', array('type' => 'config'));
128
+ $this->_redirect('*/install/install', array('mode' => 'welcome'));
129
+ }
130
+
131
+ public function disableWebhooksAction(){
132
+ Mage::getModel('core/config')->saveConfig(
133
+ Remarkety_Mgconnector_Model_Install::XPATH_WEBHOOKS_ENABLED,
134
+ false,
135
+ 'default'
136
+ );
137
+
138
+ Mage::app()->getCacheInstance()->cleanType('config');
139
+ Mage::dispatchEvent('adminhtml_cache_refresh_type', array('type' => 'config'));
140
+ $this->_redirect('*/install/install', array('mode' => 'welcome'));
141
+ }
142
+
143
  /**
144
  * Enable webtracking action
145
  */
148
  $store_id = $this->getRequest()->getParam('store');
149
  if(!is_numeric($store_id) || is_null($store_id)){
150
  throw new Exception("Missing store id");
151
+ }
152
 
153
  /**
154
  * @var $m Remarkety_Mgconnector_Model_Webtracking
162
  $rmStoreId = $req->getStoreID($store_id);
163
  if($rmStoreId){
164
  $m->setRemarketyPublicId($store_id, $rmStoreId);
165
+ $m->setEnabled($store_id, true);
166
  Mage::app()->getCacheInstance()->cleanType('config');
167
  Mage::dispatchEvent('adminhtml_cache_refresh_type', array('type' => 'config'));
168
+ }
169
 
170
  $this->_redirect('*/install/install', array('mode' => 'welcome'));
171
  }
178
  $store_id = $this->getRequest()->getParam('store');
179
  if(!is_numeric($store_id) || is_null($store_id)){
180
  throw new Exception("Missing store id");
181
+ }
182
 
183
  /**
184
  * @var $m Remarkety_Mgconnector_Model_Webtracking
185
  */
186
  $m = Mage::getModel('mgconnector/webtracking');
187
+ $m->setEnabled($store_id, false);
188
  Mage::app()->getCacheInstance()->cleanType('config');
189
  Mage::dispatchEvent('adminhtml_cache_refresh_type', array('type' => 'config'));
190
  $this->_redirect('*/install/install', array('mode' => 'welcome'));
209
  * @param string $mode
210
  * @return string
211
  */
212
+ protected function _getTitle($mode)
213
  {
214
  return ucwords(str_replace('_', ' - ', $mode));
215
  }
app/code/community/Remarkety/Mgconnector/controllers/Adminhtml/QueueController.php CHANGED
@@ -16,7 +16,7 @@ class Remarkety_Mgconnector_Adminhtml_QueueController extends Mage_Adminhtml_Con
16
  * @return bool
17
  */
18
 
19
- protected function _isAllowed()
20
  {
21
  return true;
22
  }
@@ -63,7 +63,7 @@ class Remarkety_Mgconnector_Adminhtml_QueueController extends Mage_Adminhtml_Con
63
  $apiUser
64
  ->setNewApiKey($key)
65
  ->save();
66
- }
67
 
68
  if(isset($params['data']['bypasscache'])){
69
  Mage::getModel('core/config')->saveConfig(\Remarkety_Mgconnector_Model_Webtracking::RM_BYPASS_CACHE, true);
@@ -83,6 +83,18 @@ class Remarkety_Mgconnector_Adminhtml_QueueController extends Mage_Adminhtml_Con
83
  Mage::getModel('core/config')->saveConfig('remarkety/mgconnector/configurable_standalone', false);
84
  }
85
 
 
 
 
 
 
 
 
 
 
 
 
 
86
  Mage::app()->getCacheInstance()->cleanType('config');
87
  Mage::dispatchEvent('adminhtml_cache_refresh_type', array('type' => 'config'));
88
 
@@ -103,9 +115,9 @@ class Remarkety_Mgconnector_Adminhtml_QueueController extends Mage_Adminhtml_Con
103
  );
104
  }
105
 
106
- public function massResendAction()
107
  {
108
-
109
  $queueIds = $this->getRequest()->getParam('queue');
110
  if (!is_array($queueIds)) {
111
  Mage::getSingleton('adminhtml/session')->addError($this->__('Please select queue item(s)'));
@@ -125,13 +137,13 @@ class Remarkety_Mgconnector_Adminhtml_QueueController extends Mage_Adminhtml_Con
125
  Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
126
  }
127
  }
128
-
129
  $this->_redirect('*/queue/index');
130
  }
131
 
132
- public function massDeleteAction()
133
  {
134
-
135
  $queueIds = $this->getRequest()->getParam('queue');
136
  if (!is_array($queueIds)) {
137
  Mage::getSingleton('adminhtml/session')->addError($this->__('Please select queue item(s)'));
@@ -144,7 +156,7 @@ class Remarkety_Mgconnector_Adminhtml_QueueController extends Mage_Adminhtml_Con
144
  ->getSelect();
145
  foreach ($collection as $item) {
146
  $item->delete();
147
- }
148
 
149
  Mage::getSingleton('adminhtml/session')->addSuccess(
150
  Mage::helper('adminhtml')->__('Total of %d events(s) were deleted', count($queueIds))
@@ -153,7 +165,7 @@ class Remarkety_Mgconnector_Adminhtml_QueueController extends Mage_Adminhtml_Con
153
  Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
154
  }
155
  }
156
-
157
  $this->_redirect('*/queue/index');
158
  }
159
  }
16
  * @return bool
17
  */
18
 
19
+ protected function _isAllowed()
20
  {
21
  return true;
22
  }
63
  $apiUser
64
  ->setNewApiKey($key)
65
  ->save();
66
+ }
67
 
68
  if(isset($params['data']['bypasscache'])){
69
  Mage::getModel('core/config')->saveConfig(\Remarkety_Mgconnector_Model_Webtracking::RM_BYPASS_CACHE, true);
83
  Mage::getModel('core/config')->saveConfig('remarkety/mgconnector/configurable_standalone', false);
84
  }
85
 
86
+ if(isset($params['data']['product_url_internal'])){
87
+ Mage::getModel('core/config')->saveConfig('remarkety/mgconnector/product_url_internal', true);
88
+ } else {
89
+ Mage::getModel('core/config')->saveConfig('remarkety/mgconnector/product_url_internal', false);
90
+ }
91
+
92
+ if(isset($params['data']['forceasyncwebhooks'])){
93
+ Mage::getModel('core/config')->saveConfig('remarkety/mgconnector/forceasyncwebhooks', true);
94
+ } else {
95
+ Mage::getModel('core/config')->saveConfig('remarkety/mgconnector/forceasyncwebhooks', false);
96
+ }
97
+
98
  Mage::app()->getCacheInstance()->cleanType('config');
99
  Mage::dispatchEvent('adminhtml_cache_refresh_type', array('type' => 'config'));
100
 
115
  );
116
  }
117
 
118
+ public function massResendAction()
119
  {
120
+
121
  $queueIds = $this->getRequest()->getParam('queue');
122
  if (!is_array($queueIds)) {
123
  Mage::getSingleton('adminhtml/session')->addError($this->__('Please select queue item(s)'));
137
  Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
138
  }
139
  }
140
+
141
  $this->_redirect('*/queue/index');
142
  }
143
 
144
+ public function massDeleteAction()
145
  {
146
+
147
  $queueIds = $this->getRequest()->getParam('queue');
148
  if (!is_array($queueIds)) {
149
  Mage::getSingleton('adminhtml/session')->addError($this->__('Please select queue item(s)'));
156
  ->getSelect();
157
  foreach ($collection as $item) {
158
  $item->delete();
159
+ }
160
 
161
  Mage::getSingleton('adminhtml/session')->addSuccess(
162
  Mage::helper('adminhtml')->__('Total of %d events(s) were deleted', count($queueIds))
165
  Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
166
  }
167
  }
168
+
169
  $this->_redirect('*/queue/index');
170
  }
171
  }
app/code/community/Remarkety/Mgconnector/etc/api.xml CHANGED
@@ -45,6 +45,24 @@
45
  <getSubscriberCount translate="title" module="mgconnector">
46
  <title>Get newsletter subscriber count</title>
47
  </getSubscriberCount>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
48
  </methods>
49
  </mgconnector_core>
50
  </resources>
45
  <getSubscriberCount translate="title" module="mgconnector">
46
  <title>Get newsletter subscriber count</title>
47
  </getSubscriberCount>
48
+ <getQueueSize translate="title" module="mgconnector">
49
+ <title>Returns number of events in queue for a specific store_id</title>
50
+ </getQueueSize>
51
+ <getQueueItems translate="title" module="mgconnector">
52
+ <title>Returns events in queue for a specific store_id</title>
53
+ </getQueueItems>
54
+ <retryQueueItems translate="title" module="mgconnector">
55
+ <title>Retry events in queue for a specific store_id</title>
56
+ </retryQueueItems>
57
+ <deleteQueueItems translate="title" module="mgconnector">
58
+ <title>Delete events in queue for a specific store_id</title>
59
+ </deleteQueueItems>
60
+ <getConfig translate="title" module="mgconnector">
61
+ <title>Allows to remotely read Remarkety configuration</title>
62
+ </getConfig>
63
+ <setConfig translate="title" module="mgconnector">
64
+ <title>Allows to remotely update Remarkety configuration</title>
65
+ </setConfig>
66
  </methods>
67
  </mgconnector_core>
68
  </resources>
app/code/community/Remarkety/Mgconnector/etc/config.xml CHANGED
@@ -2,7 +2,7 @@
2
  <config>
3
  <modules>
4
  <Remarkety_Mgconnector>
5
- <version>1.4.10.3</version>
6
  </Remarkety_Mgconnector>
7
  </modules>
8
  <global>
@@ -45,6 +45,15 @@
45
  </mgconnector>
46
  </blocks>
47
  <events>
 
 
 
 
 
 
 
 
 
48
  <catalogrule_rule_save_before>
49
  <observers>
50
  <remarkety_catalogrule_rule_save_before>
@@ -54,15 +63,24 @@
54
  </remarkety_catalogrule_rule_save_before>
55
  </observers>
56
  </catalogrule_rule_save_before>
57
- <catalog_product_save_after>
 
 
 
 
 
 
 
 
 
58
  <observers>
59
  <remarkety_catalog_product_save_after>
60
  <type>singleton</type>
61
  <class>mgconnector/observer</class>
62
- <method>triggerProductSave</method>
63
  </remarkety_catalog_product_save_after>
64
  </observers>
65
- </catalog_product_save_after>
66
  <customer_save_after>
67
  <observers>
68
  <remarkety_customer_save_after_observer>
@@ -90,6 +108,15 @@
90
  </remarkety_customer_address_save_before_observer>
91
  </observers>
92
  </customer_address_save_before>
 
 
 
 
 
 
 
 
 
93
  <newsletter_subscriber_save_after>
94
  <observers>
95
  <remarkety_newsletter_subscriber_save_after_observer>
@@ -108,6 +135,24 @@
108
  </remarkety_newsletter_subscriber_delete_after_observer>
109
  </observers>
110
  </newsletter_subscriber_delete_after>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
111
  <customer_delete_commit_after>
112
  <observers>
113
  <remarkety_customer_delete_commit_after_observer>
@@ -135,6 +180,62 @@
135
  </remarkety_customer_rewardpoints_update>
136
  </observers>
137
  </rewardpoints_transaction_save_after>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
138
  </events>
139
  </global>
140
  <admin>
2
  <config>
3
  <modules>
4
  <Remarkety_Mgconnector>
5
+ <version>1.5.1.2</version>
6
  </Remarkety_Mgconnector>
7
  </modules>
8
  <global>
45
  </mgconnector>
46
  </blocks>
47
  <events>
48
+ <sales_order_save_commit_after>
49
+ <observers>
50
+ <remarkety_order_save_after_observer>
51
+ <type>singleton</type>
52
+ <class>mgconnector/observer</class>
53
+ <method>triggerOrderUpdate</method>
54
+ </remarkety_order_save_after_observer>
55
+ </observers>
56
+ </sales_order_save_commit_after>
57
  <catalogrule_rule_save_before>
58
  <observers>
59
  <remarkety_catalogrule_rule_save_before>
63
  </remarkety_catalogrule_rule_save_before>
64
  </observers>
65
  </catalogrule_rule_save_before>
66
+ <catalog_product_save_before>
67
+ <observers>
68
+ <remarkety_catalog_product_save_before>
69
+ <type>singleton</type>
70
+ <class>mgconnector/observer</class>
71
+ <method>triggerProductSaveBefore</method>
72
+ </remarkety_catalog_product_save_before>
73
+ </observers>
74
+ </catalog_product_save_before>
75
+ <catalog_product_save_commit_after>
76
  <observers>
77
  <remarkety_catalog_product_save_after>
78
  <type>singleton</type>
79
  <class>mgconnector/observer</class>
80
+ <method>triggerProductSaveCommit</method>
81
  </remarkety_catalog_product_save_after>
82
  </observers>
83
+ </catalog_product_save_commit_after>
84
  <customer_save_after>
85
  <observers>
86
  <remarkety_customer_save_after_observer>
108
  </remarkety_customer_address_save_before_observer>
109
  </observers>
110
  </customer_address_save_before>
111
+ <checkout_cart_save_after>
112
+ <observers>
113
+ <remarkety_checkout_cart_save_after_observer>
114
+ <type>singleton</type>
115
+ <class>mgconnector/observer</class>
116
+ <method>triggerCartUpdated</method>
117
+ </remarkety_checkout_cart_save_after_observer>
118
+ </observers>
119
+ </checkout_cart_save_after>
120
  <newsletter_subscriber_save_after>
121
  <observers>
122
  <remarkety_newsletter_subscriber_save_after_observer>
135
  </remarkety_newsletter_subscriber_delete_after_observer>
136
  </observers>
137
  </newsletter_subscriber_delete_after>
138
+ <catalog_product_delete_before>
139
+ <observers>
140
+ <remarkety_product_delete_after>
141
+ <type>singleton</type>
142
+ <class>mgconnector/observer</class>
143
+ <method>triggerProductDeleteBefore</method>
144
+ </remarkety_product_delete_after>
145
+ </observers>
146
+ </catalog_product_delete_before>
147
+ <catalog_product_delete_commit_after>
148
+ <observers>
149
+ <remarkety_product_delete_after>
150
+ <type>singleton</type>
151
+ <class>mgconnector/observer</class>
152
+ <method>triggerProductDelete</method>
153
+ </remarkety_product_delete_after>
154
+ </observers>
155
+ </catalog_product_delete_commit_after>
156
  <customer_delete_commit_after>
157
  <observers>
158
  <remarkety_customer_delete_commit_after_observer>
180
  </remarkety_customer_rewardpoints_update>
181
  </observers>
182
  </rewardpoints_transaction_save_after>
183
+
184
+ <cataloginventory_stock_item_save_commit_after>
185
+ <observers>
186
+ <remarkety_stockupdate>
187
+ <type>singleton</type>
188
+ <class>mgconnector/observer</class>
189
+ <method>catalogInventorySave</method>
190
+ </remarkety_stockupdate>
191
+ </observers>
192
+ </cataloginventory_stock_item_save_commit_after>
193
+ <sales_model_service_quote_submit_before>
194
+ <observers>
195
+ <remarkety_stockupdate>
196
+ <type>singleton</type>
197
+ <class>mgconnector/observer</class>
198
+ <method>subtractQuoteInventory</method>
199
+ </remarkety_stockupdate>
200
+ </observers>
201
+ </sales_model_service_quote_submit_before>
202
+ <sales_model_service_quote_submit_failure>
203
+ <observers>
204
+ <remarkety_stockupdate>
205
+ <type>singleton</type>
206
+ <class>mgconnector/observer</class>
207
+ <method>revertQuoteInventory</method>
208
+ </remarkety_stockupdate>
209
+ </observers>
210
+ </sales_model_service_quote_submit_failure>
211
+ <sales_order_item_cancel>
212
+ <observers>
213
+ <remarkety_stockupdate>
214
+ <type>singleton</type>
215
+ <class>mgconnector/observer</class>
216
+ <method>cancelOrderItem</method>
217
+ </remarkety_stockupdate>
218
+ </observers>
219
+ </sales_order_item_cancel>
220
+ <sales_order_creditmemo_save_after>
221
+ <observers>
222
+ <remarkety_stockupdate>
223
+ <type>singleton</type>
224
+ <class>mgconnector/observer</class>
225
+ <method>refundOrderInventory</method>
226
+ </remarkety_stockupdate>
227
+ </observers>
228
+ </sales_order_creditmemo_save_after>
229
+
230
+ <catalog_category_change_products>
231
+ <observers>
232
+ <remarkety_stockupdate>
233
+ <type>singleton</type>
234
+ <class>mgconnector/observer</class>
235
+ <method>triggerCategoryChangeProducts</method>
236
+ </remarkety_stockupdate>
237
+ </observers>
238
+ </catalog_category_change_products>
239
  </events>
240
  </global>
241
  <admin>
app/code/community/Remarkety/Mgconnector/sql/mgconnector_setup/mysql4-upgrade-1.4.10.4-1.5.0.0.php ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Upgrade script from version 1.4.10.4 to 1.5.0.0
5
+ *
6
+ * @category Remarkety
7
+ * @package Remarkety_Mgconnector
8
+ * @author Bnaya Livne <bnaya@remarkety.com>
9
+ */
10
+ $installer = $this;
11
+ $installer->startSetup();
12
+
13
+
14
+ $installer->getConnection()
15
+ ->addColumn(
16
+ $installer->getTable('mgconnector/queue'), 'store_id', array(
17
+ 'type' => Varien_Db_Ddl_Table::TYPE_NUMERIC,
18
+ 'nullable' => true,
19
+ 'default' => null,
20
+ 'comment' => 'Store view id to use in the requests',
21
+ )
22
+ );
23
+
24
+ $installer->endSetup();
app/code/community/Remarkety/Mgconnector/sql/mgconnector_setup/mysql4-upgrade-1.5.0.0-1.5.0.1.php ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Upgrade script from version 1.5.0.0 to 1.5.0.1
5
+ *
6
+ * @category Remarkety
7
+ * @package Remarkety_Mgconnector
8
+ * @author Bnaya Livne <bnaya@remarkety.com>
9
+ */
10
+ $installer = $this;
11
+ $installer->startSetup();
12
+
13
+
14
+ $installer->getConnection()
15
+ ->addColumn(
16
+ $installer->getTable('mgconnector/queue'), 'last_error_message', array(
17
+ 'type' => Varien_Db_Ddl_Table::TYPE_TEXT,
18
+ 'nullable' => true,
19
+ 'default' => null,
20
+ 'comment' => 'Last error message',
21
+ )
22
+ );
23
+
24
+ $installer->endSetup();
app/design/adminhtml/default/default/template/mgconnector/install/welcome/store.phtml CHANGED
@@ -2,7 +2,6 @@
2
  $stores = $this->getStoresStatus();
3
  $apiValid = $this->checkAPIKey();
4
 
5
- if (!$apiValid || \Remarkety_Mgconnector_Model_Install::isMultipleStores()) {
6
  ?>
7
 
8
  <div class="entry-edit">
@@ -16,6 +15,16 @@ if (!$apiValid || \Remarkety_Mgconnector_Model_Install::isMultipleStores()) {
16
  <strong style="color: red;">Attention! Remarkety's API key is not the same as the Magento API key. Please set it <a href="<?php echo $this->getUrl('*/queue/index'); ?>">here</a></strong>
17
  (<a target="_blank" href="https://support.remarkety.com/hc/en-us/articles/209184646-Synchronizing-the-API-key">More Info</a>).
18
  <?php endif; ?>
 
 
 
 
 
 
 
 
 
 
19
  <?php if (\Remarkety_Mgconnector_Model_Install::isMultipleStores()): ?>
20
  <table cellspacing="0" class="form-list">
21
  <tbody>
@@ -67,4 +76,3 @@ if (!$apiValid || \Remarkety_Mgconnector_Model_Install::isMultipleStores()) {
67
  </div>
68
  </div>
69
  </div>
70
- <?php } ?>
2
  $stores = $this->getStoresStatus();
3
  $apiValid = $this->checkAPIKey();
4
 
 
5
  ?>
6
 
7
  <div class="entry-edit">
15
  <strong style="color: red;">Attention! Remarkety's API key is not the same as the Magento API key. Please set it <a href="<?php echo $this->getUrl('*/queue/index'); ?>">here</a></strong>
16
  (<a target="_blank" href="https://support.remarkety.com/hc/en-us/articles/209184646-Synchronizing-the-API-key">More Info</a>).
17
  <?php endif; ?>
18
+
19
+ <?php if($this->isWebhooksEnabled()): ?>
20
+ <a href="<?php echo $this->getUrl('*/install/disableWebhooks') ?>"><?php echo $this->__('Disable Webhooks'); ?></a>
21
+ <?php else: ?>
22
+
23
+ <button id="install_webhooks_button" title="Save Category" type="button" class="scalable save" onclick="window.location = '<?php echo $this->getUrl('*/install/enableWebhooks') ?>'" style="">
24
+ <span><?php echo $this->__('Enable Webhooks'); ?></span>
25
+ </button>
26
+ <?php endif; ?>
27
+
28
  <?php if (\Remarkety_Mgconnector_Model_Install::isMultipleStores()): ?>
29
  <table cellspacing="0" class="form-list">
30
  <tbody>
76
  </div>
77
  </div>
78
  </div>
 
app/design/frontend/base/default/template/mgconnector/tracking/general.phtml CHANGED
@@ -18,7 +18,7 @@
18
  <script>(function(d, t) {
19
  var g = d.createElement(t),
20
  s = d.getElementsByTagName(t)[0];
21
- g.src = 'https://s3.amazonaws.com/downloads.remarkety.com/webtracking/remarkety.js';
22
  s.parentNode.insertBefore(g, s);
23
  }(document, 'script'));</script>
24
  <?php endif; ?>
18
  <script>(function(d, t) {
19
  var g = d.createElement(t),
20
  s = d.getElementsByTagName(t)[0];
21
+ g.src = 'https://d3ryumxhbd2uw7.cloudfront.net/webtracking/track.js';
22
  s.parentNode.insertBefore(g, s);
23
  }(document, 'script'));</script>
24
  <?php endif; ?>
package.xml CHANGED
@@ -1,7 +1,7 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Remarkety_Mgconnector</name>
4
- <version>1.4.10.3</version>
5
  <stability>stable</stability>
6
  <license uri="http://www.gnu.org/licenses/gpl-3.0.html">GPL v3</license>
7
  <channel>community</channel>
@@ -9,15 +9,15 @@
9
  <summary>Remarkety Magento Connector</summary>
10
  <description>Remarkety Magento Connector</description>
11
  <notes>No comments</notes>
12
- <date>2017-01-17</date>
13
- <time>9-21-08</time>
14
  <contents>
15
  <target name="magecommunity">
16
- <dir name="Remarkety"><dir name="Mgconnector"><dir name="Block"><dir name="Adminhtml"><dir name="Configuration"><dir name="Complete"><file name="Form.php" hash="e6dc10d742071fe8d041801d4ae605ff"/></dir><file name="Complete.php" hash="d816f575e8ef99c8dbb4440666963bd0"/><dir name="Configuration"><file name="Form.php" hash="861b674ee5ac1e384fd68e29bd59bb02"/></dir><file name="Configuration.php" hash="8f8c4988205d9d1e2c7cd23c27a9483f"/><dir name="Install"><file name="Form.php" hash="cede3e19bde805c40342ea26e1deeda5"/></dir><file name="Install.php" hash="9c093e25a8cc9a1fe16c87cfea2e3819"/><dir name="Upgrade"><file name="Form.php" hash="9af9dbeae95cbcdae2ec32632447f9c6"/></dir><file name="Upgrade.php" hash="93222bbdfff6b417b4b6ecbfc7c3d764"/></dir><file name="Configuration.php" hash="4df74b83acfbbe6e6fdaa708f0d9ba7e"/><dir name="Extension"><file name="RewardPoints.php" hash="82e320930f59dfd45e5aa73005118833"/></dir><dir name="Install"><dir name="Complete"><file name="Form.php" hash="fd219a65921dba3099ba77166f59e8da"/></dir><file name="Complete.php" hash="c20351873d05cde757620ae6458c1ec4"/><dir name="Install"><dir name="Create"><file name="Form.php" hash="af271c9df233ac8164dfa73216a524fc"/></dir><file name="Create.php" hash="bcd942c4fd64543c1b65001ec84d0d71"/><dir name="Login"><file name="Form.php" hash="bb431cadabe945c82df6cb921c5e2c30"/></dir><file name="Login.php" hash="6f7e30f2c36e56925be25496fde1e29a"/></dir><dir name="Upgrade"><file name="Form.php" hash="490a20b1e39d153af18e90844593c772"/></dir><file name="Upgrade.php" hash="5e30edfcc5954ccf65dcd36192356bed"/><dir name="Welcome"><file name="Form.php" hash="b4f135c3c0106a8391931d6d5865d599"/><file name="Store.php" hash="c4be91045c5ce42128f3c22350ac589b"/></dir><file name="Welcome.php" hash="de47e1c94e4073e2d2af94a0b5455250"/></dir><dir name="Queue"><dir name="Configure"><file name="Form.php" hash="4668539bf05e44ec9cdfcf2388277e9a"/></dir><file name="Configure.php" hash="87841e46d93c568bdd09304d016de589"/><dir name="Grid"><dir name="Column"><dir name="Renderer"><file name="EventType.php" hash="13fd2faaa07dc11d6052ab9e0c6a4261"/><file name="Status.php" hash="7f087c6d8e55b67d5a7781a31d1ed924"/></dir></dir></dir><file name="Grid.php" hash="f822b539114f10256a69333c8bf4a2e6"/></dir><file name="Queue.php" hash="b778ce9202431147083365b8021103d0"/></dir><dir name="Tracking"><file name="Base.php" hash="f80c74e11c575b27110505d51cb4d6fc"/><file name="General.php" hash="2fbff52cfe2924412376bbb4328068be"/><file name="Product.php" hash="11fd52b220b73fb5f2dc87a4684b056a"/></dir></dir><dir name="Helper"><file name="Configuration.php" hash="45084eee5817158fbf19959217797c6e"/><file name="Data.php" hash="e07e033f6594609aa78c82a45708dd85"/><file name="Extension.php" hash="5788a232ffaa32674b4bfc1e12e4ea98"/><file name="Links.php" hash="9f154ee8056f27f8b42f1a42880bb90a"/><file name="Urls.php" hash="2d431aa22e9cd1595c421502ecda62b8"/></dir><dir name="Model"><dir name="Core"><file name="Api.php" hash="fc55e8b87e999498bb14340db7e9cde4"/></dir><file name="Core.php" hash="eef9cd853e31fe9c2be18f559f29c732"/><dir name="Extension"><dir name="RewardPoints"><file name="AbstractIntegration.php" hash="4ac34942072ce49d2971065a82d1068c"/><file name="IntegrationInterface.php" hash="f95f9f1e243c9fd920d27b9299b90f72"/><file name="MagestoreRewardPoints.php" hash="70c4c74fedd4bfb717132d6d825e438d"/><dir name="Observer"><file name="AbstractObserver.php" hash="eb710b7582050de644de2a8402d759ec"/><file name="MagestoreRewardPoints.php" hash="bac2ae11f94aa923accb0437027b4bec"/></dir></dir></dir><file name="Install.php" hash="902f33bd045e653e9c4fed2ce632b26e"/><file name="Observer.php" hash="e772f5558f1167100bad4513db798d9b"/><file name="Queue.php" hash="afda656a56b9d44d2ce18a60fdce0912"/><file name="Recovery.php" hash="69bd78f2a3d92db91601cf2afa9c131c"/><file name="Request.php" hash="e7e8860a186ae21a7eee44f6f49d6a8c"/><dir name="Resource"><file name="Coupon.php" hash="6079c05e422e9c1ad5327fc881cee7e3"/><dir name="Queue"><file name="Collection.php" hash="61b5b2fb72b1cbc9465b8efa6f161e46"/></dir><file name="Queue.php" hash="fd9ce12e48148c2eb88db7336b43e5ac"/><dir name="Rule"><file name="Collection.php" hash="d38eed437f15d67b21c3be935053fea5"/></dir><file name="Setup.php" hash="5387a1470bf28911ba531ed88e156569"/></dir><file name="Webtracking.php" hash="e5b5f1d1bcd50d83e56ce8e3ba910de7"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="ConfigureController.php" hash="0b7a6beed2fc4eed01ad7c3363a73dbb"/><dir name="Extension"><file name="AbstractController.php" hash="fa816f490f29820c3b3faa17a3fc00e5"/><file name="RewardPointsController.php" hash="3e94e5ae4d467abf03f41e260b0421f9"/></dir><file name="InstallController.php" hash="be36853b940c958f29fe00535eea1df1"/><file name="MgconnectorController.php" hash="8eecb0d7625336661d2b541d64999f8a"/><file name="QueueController.php" hash="b8c8a0ab8c4efde1fdc9283a37f93b4e"/></dir><file name="RecoveryController.php" hash="a2493669b27287ceb4ada2f9128f5c08"/><file name="WebtrackingController.php" hash="03835c6f4760d203ed81dcea6b591de5"/></dir><dir name="etc"><file name="adminhtml.xml" hash="a417737a2225ef9f70b47eef77d75b7c"/><file name="api.xml" hash="9f6d5fd3330bb0640f97efc3f819e684"/><file name="config.xml" hash="47693b94dd2c037192b27ac5309288ba"/></dir><dir name="sql"><dir name="mgconnector_setup"><file name="mysql4-install-1.0.0.13.php" hash="6d0bc421987b0238e350003629e8c464"/><file name="mysql4-upgrade-1.0.0.13-1.0.0.14.php" hash="2c28f665f2a8f78cdfc0b121703734af"/><file name="mysql4-upgrade-1.0.0.14-1.0.0.15.php" hash="284433b68df4ce4e83389db33f4a197c"/><file name="mysql4-upgrade-1.0.0.14-1.1.0.0.php" hash="2042704f23d7337ba3d0901f662096a8"/><file name="mysql4-upgrade-1.1.0.5-1.1.0.6.php" hash="2cc5dc8b986cd4ea1a70519ca59a7be9"/><file name="mysql4-upgrade-1.1.2.8-1.1.2.9.php" hash="ef7be7f476ed01e81fe8f9a62b63d008"/><file name="mysql4-upgrade-1.1.2.8-1.3.0.0.php" hash="fef6b0ee2a43cd42036ca12915885794"/><file name="mysql4-upgrade-1.1.2.9-1.1.3.0.php" hash="4871718266ef707c3b136e6d5591ed25"/><file name="mysql4-upgrade-1.4.7.2-1.4.8.0.php" hash="d2b686bdedc6645a5c4f9609c6cea434"/></dir></dir></dir></dir></target>
17
  <target name="mageetc">
18
  <dir name="modules"><file name="Remarkety_Mgconnector.xml" hash="d584b234f653fbf34376e7dcb8caf117"/></dir></target>
19
  <target name="magedesign">
20
- <dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="mgconnector.xml" hash="f08b20d71711e3497822310184cc903f"/></dir><dir name="template"><dir name="mgconnector"><file name="element.phtml" hash="b956df05d4eeb30f5199a75deab74fbc"/><dir name="extension"><file name="rewardpoints.phtml" hash="bb7e14c4173c81403f9d61c77429c8e1"/></dir><dir name="install"><dir name="welcome"><file name="store.phtml" hash="cff8433cb12531d8527a062242baa51b"/></dir></dir><dir name="widget"><dir name="form"><dir name="renderer"><dir name="fieldset"><file name="element.phtml" hash="abd5b9848b714779ddecb4536c846395"/></dir></dir></dir></dir></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="mgconnector.xml" hash="81584e822ae52179c8fb1dfc48cb8a9f"/></dir><dir name="template"><dir name="mgconnector"><dir name="tracking"><file name="general.phtml" hash="2c70fc0acec678ab0003712e51e4540e"/><file name="product_view.phtml" hash="34c1d41a5b7c303b5a4a1e4ca1f8c0be"/></dir></dir></dir></dir></dir></dir></target>
21
  </contents>
22
  <compatible/>
23
  <dependencies>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Remarkety_Mgconnector</name>
4
+ <version>1.5.1.2</version>
5
  <stability>stable</stability>
6
  <license uri="http://www.gnu.org/licenses/gpl-3.0.html">GPL v3</license>
7
  <channel>community</channel>
9
  <summary>Remarkety Magento Connector</summary>
10
  <description>Remarkety Magento Connector</description>
11
  <notes>No comments</notes>
12
+ <date>2017-05-14</date>
13
+ <time>14-44-42</time>
14
  <contents>
15
  <target name="magecommunity">
16
+ <dir name="Remarkety"><dir name="Mgconnector"><dir name="Block"><dir name="Adminhtml"><dir name="Configuration"><dir name="Complete"><file name="Form.php" hash="e6dc10d742071fe8d041801d4ae605ff"/></dir><file name="Complete.php" hash="d816f575e8ef99c8dbb4440666963bd0"/><dir name="Configuration"><file name="Form.php" hash="861b674ee5ac1e384fd68e29bd59bb02"/></dir><file name="Configuration.php" hash="8f8c4988205d9d1e2c7cd23c27a9483f"/><dir name="Install"><file name="Form.php" hash="cede3e19bde805c40342ea26e1deeda5"/></dir><file name="Install.php" hash="9c093e25a8cc9a1fe16c87cfea2e3819"/><dir name="Upgrade"><file name="Form.php" hash="9af9dbeae95cbcdae2ec32632447f9c6"/></dir><file name="Upgrade.php" hash="93222bbdfff6b417b4b6ecbfc7c3d764"/></dir><file name="Configuration.php" hash="4df74b83acfbbe6e6fdaa708f0d9ba7e"/><dir name="Extension"><file name="RewardPoints.php" hash="82e320930f59dfd45e5aa73005118833"/></dir><dir name="Install"><dir name="Complete"><file name="Form.php" hash="fd219a65921dba3099ba77166f59e8da"/></dir><file name="Complete.php" hash="c20351873d05cde757620ae6458c1ec4"/><dir name="Install"><dir name="Create"><file name="Form.php" hash="af271c9df233ac8164dfa73216a524fc"/></dir><file name="Create.php" hash="bcd942c4fd64543c1b65001ec84d0d71"/><dir name="Login"><file name="Form.php" hash="bb431cadabe945c82df6cb921c5e2c30"/></dir><file name="Login.php" hash="6f7e30f2c36e56925be25496fde1e29a"/></dir><dir name="Upgrade"><file name="Form.php" hash="490a20b1e39d153af18e90844593c772"/></dir><file name="Upgrade.php" hash="5e30edfcc5954ccf65dcd36192356bed"/><dir name="Welcome"><file name="Form.php" hash="b4f135c3c0106a8391931d6d5865d599"/><file name="Store.php" hash="0eea3b94c83c8e4c3a4b1a022d5c02b4"/></dir><file name="Welcome.php" hash="de47e1c94e4073e2d2af94a0b5455250"/></dir><dir name="Queue"><dir name="Configure"><file name="Form.php" hash="a6c97ade5c3c3714f40dd121351f4902"/></dir><file name="Configure.php" hash="87841e46d93c568bdd09304d016de589"/><dir name="Grid"><dir name="Column"><dir name="Renderer"><file name="EventType.php" hash="13fd2faaa07dc11d6052ab9e0c6a4261"/><file name="Status.php" hash="7f087c6d8e55b67d5a7781a31d1ed924"/></dir></dir></dir><file name="Grid.php" hash="80be08c235836e185bec22d439d4e95b"/></dir><file name="Queue.php" hash="b778ce9202431147083365b8021103d0"/></dir><dir name="Tracking"><file name="Base.php" hash="ab4abb09bcff0e5465ed4ac6b8f78a6e"/><file name="General.php" hash="2fbff52cfe2924412376bbb4328068be"/><file name="Product.php" hash="11fd52b220b73fb5f2dc87a4684b056a"/></dir></dir><dir name="Helper"><file name="Configuration.php" hash="d969dee27dbf9dcf3fc5e76ebf5ce628"/><file name="Data.php" hash="e07e033f6594609aa78c82a45708dd85"/><file name="Extension.php" hash="5788a232ffaa32674b4bfc1e12e4ea98"/><file name="Links.php" hash="9f154ee8056f27f8b42f1a42880bb90a"/><file name="Urls.php" hash="2d431aa22e9cd1595c421502ecda62b8"/></dir><dir name="Model"><dir name="Core"><file name="Api.php" hash="3e87c7f2c0fc116ccba52e4f9e933ad2"/></dir><file name="Core.php" hash="37ee61793937affa32e1ea8189f3a99d"/><dir name="Extension"><dir name="RewardPoints"><file name="AbstractIntegration.php" hash="4ac34942072ce49d2971065a82d1068c"/><file name="IntegrationInterface.php" hash="f95f9f1e243c9fd920d27b9299b90f72"/><file name="MagestoreRewardPoints.php" hash="70c4c74fedd4bfb717132d6d825e438d"/><dir name="Observer"><file name="AbstractObserver.php" hash="c3842e2d9cf4714f1692422aee344fd8"/><file name="MagestoreRewardPoints.php" hash="a730c68034ca481fee11472677d3ab2e"/></dir></dir></dir><file name="Install.php" hash="40103918588761c11fd3abe846269761"/><file name="Observer.php" hash="7d73279e08ea5f7b35bbb906805a240d"/><file name="Queue.php" hash="afda656a56b9d44d2ce18a60fdce0912"/><file name="Recovery.php" hash="69bd78f2a3d92db91601cf2afa9c131c"/><file name="Request.php" hash="e7e8860a186ae21a7eee44f6f49d6a8c"/><dir name="Resource"><file name="Coupon.php" hash="6079c05e422e9c1ad5327fc881cee7e3"/><dir name="Queue"><file name="Collection.php" hash="61b5b2fb72b1cbc9465b8efa6f161e46"/></dir><file name="Queue.php" hash="fd9ce12e48148c2eb88db7336b43e5ac"/><dir name="Rule"><file name="Collection.php" hash="d38eed437f15d67b21c3be935053fea5"/></dir><file name="Setup.php" hash="5387a1470bf28911ba531ed88e156569"/></dir><file name="Webtracking.php" hash="215ef9c2e62d6312a336dab044eb691d"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="ConfigureController.php" hash="0b7a6beed2fc4eed01ad7c3363a73dbb"/><dir name="Extension"><file name="AbstractController.php" hash="fa816f490f29820c3b3faa17a3fc00e5"/><file name="RewardPointsController.php" hash="3e94e5ae4d467abf03f41e260b0421f9"/></dir><file name="InstallController.php" hash="ce0898cd92b4d581a2991287f9796029"/><file name="MgconnectorController.php" hash="8eecb0d7625336661d2b541d64999f8a"/><file name="QueueController.php" hash="1c8bfd4b778afbbcc99850f8ad27e3cf"/></dir><file name="RecoveryController.php" hash="a2493669b27287ceb4ada2f9128f5c08"/><file name="WebtrackingController.php" hash="03835c6f4760d203ed81dcea6b591de5"/></dir><dir name="etc"><file name="adminhtml.xml" hash="a417737a2225ef9f70b47eef77d75b7c"/><file name="api.xml" hash="fce44705bb4418403d2b9494bf32415c"/><file name="config.xml" hash="149cc672bdecefe7910626fe5175a55c"/></dir><dir name="sql"><dir name="mgconnector_setup"><file name="mysql4-install-1.0.0.13.php" hash="6d0bc421987b0238e350003629e8c464"/><file name="mysql4-upgrade-1.0.0.13-1.0.0.14.php" hash="2c28f665f2a8f78cdfc0b121703734af"/><file name="mysql4-upgrade-1.0.0.14-1.0.0.15.php" hash="284433b68df4ce4e83389db33f4a197c"/><file name="mysql4-upgrade-1.0.0.14-1.1.0.0.php" hash="2042704f23d7337ba3d0901f662096a8"/><file name="mysql4-upgrade-1.1.0.5-1.1.0.6.php" hash="2cc5dc8b986cd4ea1a70519ca59a7be9"/><file name="mysql4-upgrade-1.1.2.8-1.1.2.9.php" hash="ef7be7f476ed01e81fe8f9a62b63d008"/><file name="mysql4-upgrade-1.1.2.8-1.3.0.0.php" hash="fef6b0ee2a43cd42036ca12915885794"/><file name="mysql4-upgrade-1.1.2.9-1.1.3.0.php" hash="4871718266ef707c3b136e6d5591ed25"/><file name="mysql4-upgrade-1.4.10.4-1.5.0.0.php" hash="e4057db88fb1a28b0bdf5a8317cb7996"/><file name="mysql4-upgrade-1.4.7.2-1.4.8.0.php" hash="d2b686bdedc6645a5c4f9609c6cea434"/><file name="mysql4-upgrade-1.5.0.0-1.5.0.1.php" hash="6164dd763580d0dbcdd489250d800f86"/></dir></dir></dir></dir></target>
17
  <target name="mageetc">
18
  <dir name="modules"><file name="Remarkety_Mgconnector.xml" hash="d584b234f653fbf34376e7dcb8caf117"/></dir></target>
19
  <target name="magedesign">
20
+ <dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="mgconnector.xml" hash="f08b20d71711e3497822310184cc903f"/></dir><dir name="template"><dir name="mgconnector"><file name="element.phtml" hash="b956df05d4eeb30f5199a75deab74fbc"/><dir name="extension"><file name="rewardpoints.phtml" hash="bb7e14c4173c81403f9d61c77429c8e1"/></dir><dir name="install"><dir name="welcome"><file name="store.phtml" hash="c269c59ffe84cc803a5a3a5a0ad52559"/></dir></dir><dir name="widget"><dir name="form"><dir name="renderer"><dir name="fieldset"><file name="element.phtml" hash="abd5b9848b714779ddecb4536c846395"/></dir></dir></dir></dir></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="mgconnector.xml" hash="81584e822ae52179c8fb1dfc48cb8a9f"/></dir><dir name="template"><dir name="mgconnector"><dir name="tracking"><file name="general.phtml" hash="eda37da4c6f1df2b3c435713bd80053c"/><file name="product_view.phtml" hash="34c1d41a5b7c303b5a4a1e4ca1f8c0be"/></dir></dir></dir></dir></dir></dir></target>
21
  </contents>
22
  <compatible/>
23
  <dependencies>