Cue - Version 3.0.21

Version Notes

- Improvements and bug fixes

Download this release

Release Info

Developer Développeurs EnvoiMoinsCher.com
Extension Cue
Version 3.0.21
Comparing to
See all releases


Code changes from version 3.0.20 to 3.0.21

app/code/community/CueConnect/Cue/Block/Adminhtml/System/Config/.DS_Store ADDED
Binary file
app/code/community/CueConnect/Cue/Block/Adminhtml/System/Config/._.DS_Store ADDED
Binary file
app/code/community/CueConnect/Cue/Block/BaseCueBlock.php CHANGED
@@ -57,6 +57,15 @@ class CueConnect_Cue_Block_BaseCueBlock extends Mage_Core_Block_Template {
57
 
58
  return 1;
59
  }
 
 
 
 
 
 
 
 
 
60
 
61
  /**
62
  * return current product sku
57
 
58
  return 1;
59
  }
60
+
61
+ /**
62
+ * get environment
63
+ * @return integer
64
+ */
65
+ public function getEnv() {
66
+ $store = Mage::app()->getStore();
67
+ return $store->getConfig('cueconnect/environment/env');
68
+ }
69
 
70
  /**
71
  * return current product sku
app/code/community/CueConnect/Cue/Block/Checkout/Success/Share.php CHANGED
@@ -11,7 +11,6 @@
11
 
12
  class CueConnect_Cue_Block_Checkout_Success_Share extends CueConnect_Cue_Block_BaseCueBlock
13
  {
14
- const CUE_CART_TRACK_URL = 'https://api.cueconnect.com/imi/cart_track/json';
15
  protected $_firstProductSku = null;
16
  protected $_order = null;
17
  protected $_itemsData = null;
@@ -52,7 +51,7 @@ class CueConnect_Cue_Block_Checkout_Success_Share extends CueConnect_Cue_Block_B
52
  */
53
  public function getTrackingSource()
54
  {
55
- $str = self::CUE_CART_TRACK_URL .
56
  '?api_key=' . $this->getApiKey() .
57
  '&place_id=' . $this->getRetailerId() .
58
  '&email=' . $this->_getOrder()->getCustomerEmail() .
11
 
12
  class CueConnect_Cue_Block_Checkout_Success_Share extends CueConnect_Cue_Block_BaseCueBlock
13
  {
 
14
  protected $_firstProductSku = null;
15
  protected $_order = null;
16
  protected $_itemsData = null;
51
  */
52
  public function getTrackingSource()
53
  {
54
+ $str = Mage::helper('cueconnect')->getHost('api') . Mage::getStoreConfig('cueconnect/carttracking/url').
55
  '?api_key=' . $this->getApiKey() .
56
  '&place_id=' . $this->getRetailerId() .
57
  '&email=' . $this->_getOrder()->getCustomerEmail() .
app/code/community/CueConnect/Cue/Block/Navigation.php CHANGED
@@ -12,12 +12,13 @@
12
  class CueConnect_Cue_Block_Navigation extends Mage_Page_Block_Switch
13
  {
14
  public function addMyElistLink() {
 
15
  if (Mage::helper('core/data')->isModuleEnabled('CueConnect_Cue')) {
16
  if (Mage::helper('cueconnect')->isEnabled()) {
17
- if (Mage::helper('cueconnect')->isCollectionAuto()) {
18
  $parentBlock = $this->getParentBlock();
19
  if ($parentBlock) {
20
- $parentBlock->addLink('My List', $this->getUrl('apps/mylist'), 'My List', false, array(), 200, null, 'class="cue-stream"');
21
  }
22
  }
23
  }
12
  class CueConnect_Cue_Block_Navigation extends Mage_Page_Block_Switch
13
  {
14
  public function addMyElistLink() {
15
+
16
  if (Mage::helper('core/data')->isModuleEnabled('CueConnect_Cue')) {
17
  if (Mage::helper('cueconnect')->isEnabled()) {
18
+ if (Mage::helper('cueconnect')->setMyListLinkAuto()) {
19
  $parentBlock = $this->getParentBlock();
20
  if ($parentBlock) {
21
+ $parentBlock->addLink('My List', $this->getUrl('apps/mylist'), 'My List', false, array(), 200, null, '');
22
  }
23
  }
24
  }
app/code/community/CueConnect/Cue/Helper/Data.php CHANGED
@@ -14,16 +14,6 @@ class CueConnect_Cue_Helper_Data extends Mage_Core_Helper_Abstract
14
  const XML_PATH_MYLIST_ENABLED = 'cueconnect/collection/enabled';
15
  const XML_PATH_TRACKING_ENABLED = 'cueconnect/tracking/enabled';
16
 
17
- /**
18
- * Checks if My List is enabled
19
- *
20
- * @return bool
21
- */
22
- public function isMyListEnabled()
23
- {
24
- return Mage::getStoreConfigFlag(self::XML_PATH_MYLIST_ENABLED);
25
- }
26
-
27
  /**
28
  * Checks if Tracking is enabled
29
  *
@@ -35,86 +25,23 @@ class CueConnect_Cue_Helper_Data extends Mage_Core_Helper_Abstract
35
  }
36
 
37
  /**
38
- * Get webhook URL for adding customers to Cue
39
- *
40
- * @return string
41
- */
42
- public function getWebhookSaveCustomerUrl() {
43
-
44
- return Mage::getStoreConfig('cueconnect/webhook/save_customer/url');
45
- }
46
-
47
- /**
48
- * Get webhook auth key for adding customers to Cue
49
- *
50
- * @return string
51
- */
52
- public function getWebhookSaveCustomerKey() {
53
-
54
- return Mage::getStoreConfig('cueconnect/webhook/save_customer/key');
55
- }
56
-
57
- /**
58
- * Get webhook URL for adding marks to Cue
59
- *
60
- * @return string
61
- */
62
- public function getWebhookSaveMarkUrl() {
63
-
64
- return Mage::getStoreConfig('cueconnect/webhook/save_mark/url');
65
- }
66
-
67
- /**
68
- * Get webhook auth key for adding marks to Cue
69
- *
70
- * @return string
71
- */
72
- public function getWebhookSaveMarkKey() {
73
-
74
- return Mage::getStoreConfig('cueconnect/webhook/save_mark/key');
75
- }
76
-
77
- /**
78
- * Get webhook auth key for version change
79
- *
80
- * @return string
81
- */
82
- public function getWebhookSelectVersionKey() {
83
-
84
- return Mage::getStoreConfig('cueconnect/webhook/select_version/key');
85
- }
86
-
87
- /**
88
- * Get webhook url for version change
89
- *
90
- * @return string
91
- */
92
- public function getWebhookSelectVersionUrl() {
93
-
94
- return Mage::getStoreConfig('cueconnect/webhook/select_version/url');
95
- }
96
-
97
- /**
98
- * Get webhook auth key for price change
99
  *
100
  * @return string
101
  */
102
- public function getWebhookPriceChangedKey() {
103
 
104
- return Mage::getStoreConfig('cueconnect/webhook/price_changed/key');
105
- }
106
 
107
- /**
108
- * Get webhook url for price change
109
- *
110
- * @return string
111
- */
112
- public function getWebhookPriceChangedUrl() {
113
 
114
- return Mage::getStoreConfig('cueconnect/webhook/price_changed/url');
115
  }
116
 
117
-
118
  /**
119
  * Get retailer id from config
120
  *
@@ -124,33 +51,6 @@ class CueConnect_Cue_Helper_Data extends Mage_Core_Helper_Abstract
124
  return Mage::getStoreConfig('cueconnect/credentials/retailer_id');
125
  }
126
 
127
- /**
128
- * check if module is enabled
129
- *
130
- * @return string
131
- */
132
- public function isEnabled() {
133
- return Mage::getStoreConfig('cueconnect/enabled');
134
- }
135
-
136
-
137
-
138
- /**
139
- * Get webhook URL for adding marks to Cue
140
- *
141
- * @return string
142
- */
143
- public function getElistMode() {
144
- $mode = Mage::getStoreConfig('cueconnect/mode');
145
- if (is_array($mode)) {
146
- if (isset($mode['mode'])) {
147
- return $mode['mode'];
148
- }
149
- }
150
-
151
- return 1;
152
- }
153
-
154
  /**
155
  * Get api key
156
  *
@@ -165,9 +65,9 @@ class CueConnect_Cue_Helper_Data extends Mage_Core_Helper_Abstract
165
  *
166
  * @return bool
167
  */
168
- public function isCollectionAuto() {
169
- $enabled = Mage::getStoreConfig('cueconnect/collection');
170
 
 
171
  if (is_array($enabled)) {
172
  if (isset($enabled['enabled'])) {
173
  return $enabled['enabled'];
@@ -177,10 +77,6 @@ class CueConnect_Cue_Helper_Data extends Mage_Core_Helper_Abstract
177
  return 0;
178
  }
179
 
180
-
181
-
182
-
183
-
184
  /**
185
  * Get retailer object via SOAP
186
  *
@@ -201,6 +97,8 @@ class CueConnect_Cue_Helper_Data extends Mage_Core_Helper_Abstract
201
  return $result->data;
202
  }
203
 
 
 
204
  /**
205
  * Cut an array in multiple smaller array
206
  *
@@ -267,7 +165,6 @@ class CueConnect_Cue_Helper_Data extends Mage_Core_Helper_Abstract
267
  }
268
  }
269
 
270
-
271
  /**
272
  * Get WSSE Header
273
  *
@@ -293,7 +190,7 @@ class CueConnect_Cue_Helper_Data extends Mage_Core_Helper_Abstract
293
  * @deprecated
294
  */
295
  public function getWsUrl($service) {
296
- return Mage::getStoreConfig('cueconnect/webservice/url').$service."?wsdl";
297
  }
298
 
299
  /**
@@ -309,5 +206,121 @@ class CueConnect_Cue_Helper_Data extends Mage_Core_Helper_Abstract
309
  $client->__setSoapHeaders($header);
310
  return $client;
311
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
312
 
313
  }
14
  const XML_PATH_MYLIST_ENABLED = 'cueconnect/collection/enabled';
15
  const XML_PATH_TRACKING_ENABLED = 'cueconnect/tracking/enabled';
16
 
 
 
 
 
 
 
 
 
 
 
17
  /**
18
  * Checks if Tracking is enabled
19
  *
25
  }
26
 
27
  /**
28
+ * check if module is enabled
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
29
  *
30
  * @return string
31
  */
32
+ public function isEnabled() {
33
 
34
+ $status = Mage::getStoreConfig('cueconnect/enabled');
 
35
 
36
+ if(is_array($status)){
37
+ if (isset($status['enabled'])) {
38
+ return $status['enabled'];
39
+ }
40
+ }
 
41
 
42
+ return 0;
43
  }
44
 
 
45
  /**
46
  * Get retailer id from config
47
  *
51
  return Mage::getStoreConfig('cueconnect/credentials/retailer_id');
52
  }
53
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
54
  /**
55
  * Get api key
56
  *
65
  *
66
  * @return bool
67
  */
68
+ public function setMyListLinkAuto() {
 
69
 
70
+ $enabled = Mage::getStoreConfig('cueconnect/collection');
71
  if (is_array($enabled)) {
72
  if (isset($enabled['enabled'])) {
73
  return $enabled['enabled'];
77
  return 0;
78
  }
79
 
 
 
 
 
80
  /**
81
  * Get retailer object via SOAP
82
  *
97
  return $result->data;
98
  }
99
 
100
+
101
+
102
  /**
103
  * Cut an array in multiple smaller array
104
  *
165
  }
166
  }
167
 
 
168
  /**
169
  * Get WSSE Header
170
  *
190
  * @deprecated
191
  */
192
  public function getWsUrl($service) {
193
+ return $this->getHost('rapi').'/'.$service."?wsdl";
194
  }
195
 
196
  /**
206
  $client->__setSoapHeaders($header);
207
  return $client;
208
  }
209
+
210
+
211
+ /**
212
+ * Get webhook URL for adding customers to Cue
213
+ *
214
+ * @return string
215
+ */
216
+ public function getWebhookSaveCustomerUrl() {
217
+ return $this->getHost() . Mage::getStoreConfig('cueconnect/webhook/save_customer/url');
218
+ }
219
+
220
+ /**
221
+ * Get webhook auth key for adding customers to Cue
222
+ *
223
+ * @return string
224
+ */
225
+ public function getWebhookSaveCustomerKey() {
226
+
227
+ return Mage::getStoreConfig('cueconnect/webhook/save_customer/key');
228
+ }
229
+
230
+ /**
231
+ * Get webhook URL for adding marks to Cue
232
+ *
233
+ * @return string
234
+ */
235
+ public function getWebhookSaveMarkUrl() {
236
+
237
+ return $this->getHost() . Mage::getStoreConfig('cueconnect/webhook/save_mark/url');
238
+ }
239
+
240
+ /**
241
+ * Get webhook auth key for adding marks to Cue
242
+ *
243
+ * @return string
244
+ */
245
+ public function getWebhookSaveMarkKey() {
246
+
247
+ return Mage::getStoreConfig('cueconnect/webhook/save_mark/key');
248
+ }
249
+
250
+ /**
251
+ * Get webhook auth key for version change
252
+ *
253
+ * @return string
254
+ */
255
+ public function getWebhookConfigurationChangedKey() {
256
+
257
+ return Mage::getStoreConfig('cueconnect/webhook/configuration_changed/key');
258
+ }
259
+
260
+ /**
261
+ * Get webhook url for version change
262
+ *
263
+ * @return string
264
+ */
265
+ public function getWebhookConfigurationChangedUrl() {
266
+
267
+ return $this->getHost() . Mage::getStoreConfig('cueconnect/webhook/configuration_changed/url');
268
+ }
269
+
270
+ /**
271
+ * Get webhook auth key for product change
272
+ *
273
+ * @return string
274
+ */
275
+ public function getWebhookProductChangedKey() {
276
+
277
+ return Mage::getStoreConfig('cueconnect/webhook/product_changed/key');
278
+ }
279
+
280
+ /**
281
+ * Get webhook url for product change
282
+ *
283
+ * @return string
284
+ */
285
+ public function getWebhookProductChangedUrl() {
286
+
287
+ return $this->getHost() . Mage::getStoreConfig('cueconnect/webhook/product_changed/url');
288
+ }
289
+
290
+ /**
291
+ * Get webhook auth key for product deleted
292
+ *
293
+ * @return string
294
+ */
295
+ public function getWebhookProductDeletedKey() {
296
+
297
+ return Mage::getStoreConfig('cueconnect/webhook/product_deleted/key');
298
+ }
299
+
300
+ /**
301
+ * Get webhook url for product deleted
302
+ *
303
+ * @return string
304
+ */
305
+ public function getWebhookProductDeletedUrl() {
306
+
307
+ return $this->getHost() . Mage::getStoreConfig('cueconnect/webhook/product_deleted/url');
308
+ }
309
+
310
+ /**
311
+ * Get cue host depends on selected env
312
+ *
313
+ * @return string
314
+ */
315
+ public function getHost($application = 'business'){
316
+
317
+ $ext = Mage::getStoreConfig('cueconnect/environment/env');
318
+ if($ext && $ext != ''){
319
+ return 'https://'.$ext.'-'.$application.'.cueconnect.net';
320
+ }else{
321
+ return 'https://'.$application.'.cueconnect.com';
322
+ }
323
+
324
+ }
325
 
326
  }
app/code/community/CueConnect/Cue/Model/.CueConnect.php.swp ADDED
Binary file
app/code/community/CueConnect/Cue/Model/.Inmarkit.php.swp ADDED
Binary file
app/code/community/CueConnect/Cue/Model/Cueconnect.php CHANGED
@@ -15,16 +15,21 @@ class CueConnect_Cue_Model_CueConnect extends Mage_Core_Model_Abstract
15
  const CUE_SET_PAGE_SIZE = 20;
16
  const CUE_COLLECTION_PAGE_SIZE = 100;
17
  const CUE_ERROR_MESSAGE_PRODUCT_SYNC = 'An error occurred while synchronization product data with Cueconnect for
18
- the %s store. You can find more details in the log file.';
19
  const XML_PATH_PRODUCT_SYNC_STATUS = 'cueconnect/product_sync_%s/status';
20
  const XML_PATH_PRODUCT_LAST_SYNCED_PRODUCT = 'cueconnect/product_sync_%s/last_synced_product';
21
  const XML_PATH_PRODUCT_SYNC_SCHEDULED = 'cueconnect/product_sync/scheduled';
 
 
22
  const XML_PATH_CUE_SUPPORT_EMAIL = 'cueconnect/support/email';
23
  const XML_PATH_CUE_SUPPORT_NAME = 'cueconnect/support/name';
24
  const XML_PATH_CUE_SUPPORT_SUBJECT = 'cueconnect/support/subject';
25
  const PRODUCT_SYNC_FAILED = 'failed';
26
  const PRODUCT_SYNC_COMPLETE = 'complete';
27
  const PRODUCT_SYNC_PROCESSING = 'processing';
 
 
 
28
 
29
  protected $_cueLogin = false;
30
  protected $_cuePassword = false;
@@ -43,283 +48,6 @@ class CueConnect_Cue_Model_CueConnect extends Mage_Core_Model_Abstract
43
  public function _construct() {
44
  $this->_init('cueconnect/cueconnect');
45
  }
46
-
47
- /**
48
- * Execute export and put result in message box
49
- */
50
- public static function dailyExport() {
51
- if (Mage::getStoreConfig('cueconnect/cron/enabled')) {
52
- // Execute export() for each stores
53
- foreach (Mage::app()->getStores() as $store) {
54
- if ($store->getConfig('cueconnect/enabled/enabled')) {
55
- // Export
56
- $result = self::export($store);
57
-
58
- // Notification
59
- $inbox = Mage::getModel('adminnotification/inbox');
60
- if ($result['success']) {
61
- $inbox->addNotice(sprintf("%s products has been successfully synced with Cue.", $store->getName()), $result['message']);
62
- }
63
- else {
64
- $inbox->addCritical(sprintf("%s products has not been successfully synced with Cue.", $store->getName()), $result['message']);
65
- }
66
- }
67
- }
68
- }
69
- }
70
-
71
- /**
72
- * Execute export if manually asked and put result in message box
73
- */
74
- public static function manualExport() {
75
- // Check for demands
76
- $demand = Mage::getModel('cueconnect/demand');
77
- $awaiting_demands = Mage::getModel('cueconnect/demand')
78
- ->getCollection()
79
- ->addFilter('status', $demand::STATUS_WAITING);
80
-
81
- if (count($awaiting_demands)) {
82
- // Update demands
83
- foreach ($awaiting_demands as $awaiting_demand) {
84
- $awaiting_demand->setStatus($demand::STATUS_PROGRESSING);
85
- $awaiting_demand->setUpdatedAt(date('Y-m-d H:i:s'));
86
- $awaiting_demand->save();
87
- }
88
-
89
- // Execute export() for each stores
90
- foreach (Mage::app()->getStores() as $store) {
91
- if ($store->getConfig('cueconnect/enabled/enabled')) {
92
- // Export
93
- $result = self::export($store);
94
-
95
- // Log
96
- $log = $result['log'];
97
- $log['end_at'] = date('Y-m-d H:i:s');
98
-
99
- // Notification
100
- $inbox = Mage::getModel('adminnotification/inbox');
101
- if ($result['success']) {
102
- $inbox->addNotice(sprintf("%s products has been successfully synced with Cue.", $store->getName()), $result['message']);
103
- }
104
- else {
105
- $inbox->addCritical(sprintf("%s products has not been successfully synced with Cue.", $store->getName()), $result['message']);
106
- $log['status'] = 'error';
107
- }
108
-
109
- Mage::helper('cueconnect')->logExportProgress(json_encode($log));
110
- }
111
- }
112
-
113
- // Update demands
114
- foreach ($awaiting_demands as $awaiting_demand) {
115
- $awaiting_demand->setStatus($demand::STATUS_DONE);
116
- $awaiting_demand->setUpdatedAt(date('Y-m-d H:i:s'));
117
- $awaiting_demand->save();
118
- }
119
- }
120
- }
121
-
122
- /**
123
- * Export catalog products to Cue
124
- */
125
- public static function export($store) {
126
- // Log
127
- $log = array();
128
- $log['started_at'] = date('Y-m-d H:i:s');
129
- $log['status'] = "progressing";
130
- $log['store'] = $store->getName();
131
- Mage::helper('cueconnect')->logExportProgress(json_encode($log));
132
-
133
- // Check if crententials has been filled
134
- if (!$store->getConfig('cueconnect/credentials/login') || !$store->getConfig('cueconnect/credentials/password')) {
135
- $message = "Cue credentials are not filled.";
136
- return array('success' => false, 'message' => $message, 'log' => $log);
137
- }
138
-
139
- // Retailuser WS
140
- $soap_client = Mage::helper('cueconnect')->getSoapClient(
141
- Mage::helper('cueconnect')->getWsUrl('retailuser'),
142
- $store->getConfig('cueconnect/credentials/login'),
143
- $store->getConfig('cueconnect/credentials/password')
144
- );
145
-
146
- // Get place ID
147
- $place_id = null;
148
- try {
149
- $result = $soap_client->get(array(
150
- 'email' => $store->getConfig('cueconnect/credentials/login')
151
- ));
152
- $place_id = $result->data->id;
153
- }
154
- catch (Exception $e) {
155
- $message = $e->getMessage();
156
- return array('success' => false, 'message' => $message, 'log' => $log);
157
- }
158
-
159
- // Product WS
160
- $soap_client = Mage::helper('cueconnect')->getSoapClient(
161
- Mage::helper('cueconnect')->getWsUrl('product'),
162
- $store->getConfig('cueconnect/credentials/login'),
163
- $store->getConfig('cueconnect/credentials/password')
164
- );
165
-
166
- // Get Cue Catalog
167
- $cueconnect_products = array();
168
- $results = $soap_client->get(array('page' => 1, 'pagesize' => 100000, 'clipped' => false));
169
- foreach ($results->data as $result) {
170
- if ($result->sku) {
171
- $cueconnect_products[$result->sku] = $result;
172
- }
173
- }
174
-
175
- // Catalog products
176
- $catalog_products = Mage::getModel('catalog/product')
177
- ->getCollection()
178
- ->addAttributeToSelect('name')
179
- ->addAttributeToSelect('description')
180
- ->addAttributeToSelect('price')
181
- ->addAttributeToSelect('image')
182
- ->addAttributeToSelect('url_path')
183
- ->addStoreFilter($store->getId());
184
- $catalog_products_skus = array();
185
- $new_data = array();
186
- $updated_data = array();
187
- foreach ($catalog_products as $catalog_product) {
188
- $catalog_products_skus[] = $catalog_product->getSku();
189
-
190
- // Product image
191
- $icon = "http://www.cueconnect.com/images/no_image.gif";
192
- if ($catalog_product->getData('image')) {
193
- $icon = $catalog_product->getMediaConfig()->getMediaUrl($catalog_product->getData('image'));
194
- }
195
-
196
- // Product URL
197
- $url = $store->getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK).$catalog_product->getUrlPath();
198
-
199
- // Check if product exists in Cue database
200
- if (in_array($catalog_product->getSku(), array_keys($cueconnect_products))) {
201
- $updated_data[] = array(
202
- 'product_imic' => null,
203
- 'sku' => $catalog_product->getSku(),
204
- 'name' => $catalog_product->getName(),
205
- 'description' => $catalog_product->getDescription(),
206
- 'sms_name' => $catalog_product->getName(),
207
- 'sms_desc' => $catalog_product->getDescription(),
208
- 'url' => $url,
209
- 'taxonomy_id' => Mage::getStoreConfig('cueconnect/taxomomy_id'),
210
- 'icon' => $icon,
211
- 'live' => '1',
212
- 'price' => $catalog_product->getPrice()
213
- );
214
- }
215
- else {
216
- $new_data[] = array(
217
- 'sku' => $catalog_product->getSku(),
218
- 'upc' => uniqid(),
219
- 'name' => $catalog_product->getName(),
220
- 'description' => $catalog_product->getDescription(),
221
- 'sms_name' => $catalog_product->getName(),
222
- 'sms_desc' => $catalog_product->getDescription(),
223
- 'url' => $url,
224
- 'taxonomy_id' => Mage::getStoreConfig('cueconnect/taxomomy_id'),
225
- 'icon' => $icon,
226
- 'live' => '1',
227
- 'price' => $catalog_product->getPrice()
228
- );
229
- }
230
- }
231
- // Product to delete
232
- $skus_to_delete = array_diff(array_keys($cueconnect_products), $catalog_products_skus);
233
- $imics_to_delete = array();
234
- foreach ($skus_to_delete as $sku_to_delete) {
235
- $imics_to_delete[] = $cueconnect_products[$sku_to_delete]->product_imic;
236
- }
237
-
238
- // Log
239
- $log['total_products'] = count($catalog_products);
240
- $log['total_products_to_create'] = count($new_data);
241
- $log['total_products_to_update'] = count($updated_data);
242
- $log['total_products_to_delete'] = count($imics_to_delete);
243
- $log['total_products_created'] = 0;
244
- $log['total_products_updated'] = 0;
245
- $log['total_products_deleted'] = 0;
246
- Mage::helper('cueconnect')->logExportProgress(json_encode($log));
247
-
248
- // Send new data data to Cue (per slices)
249
- if (count($new_data)) {
250
- $new_data_slices = Mage::helper('cueconnect')->getSlicesFromArray($new_data, 20);
251
- foreach ($new_data_slices as $new_data_slice) {
252
- try {
253
- $soap_client->create(array(
254
- 'place_id' => $place_id,
255
- 'data' => $new_data_slice,
256
- 'count' => count($new_data_slice)
257
- ));
258
- // Log
259
- $log['total_products_created'] = $log['total_products_created'] + count($new_data_slice);
260
- Mage::helper('cueconnect')->logExportProgress(json_encode($log));
261
- }
262
- catch (Exception $e) {
263
- return array('success' => false, 'message' => $e->getMessage(), 'log' => $log);
264
- }
265
- }
266
- }
267
-
268
- // Send updated data data to Cue (per slices)
269
- if (count($updated_data)) {
270
- $updated_data_slices = Mage::helper('cueconnect')->getSlicesFromArray($updated_data, 20);
271
- foreach ($updated_data_slices as $updated_data_slice) {
272
- try {
273
- $soap_client->set(array(
274
- 'place_id' => $place_id,
275
- 'data' => $updated_data_slice,
276
- 'count' => count($updated_data_slice)
277
- ));
278
- // Log
279
- $log['total_products_updated'] = $log['total_products_updated'] + count($updated_data_slice);
280
- Mage::helper('cueconnect')->logExportProgress(json_encode($log));
281
- }
282
- catch (Exception $e) {
283
- return array('success' => false, 'message' => $e->getMessage(), 'log' => $log);
284
- }
285
- }
286
- }
287
-
288
- // Delete products which are not in the Magento catalog anymore
289
- if (count($imics_to_delete)) {
290
- $imics_to_delete_slices = Mage::helper('cueconnect')->getSlicesFromArray($imics_to_delete, 50);
291
- foreach ($imics_to_delete_slices as $imics_to_delete_slice) {
292
- try {
293
- $soap_client->delete(array(
294
- 'place_id' => $place_id,
295
- 'data' => $imics_to_delete_slice,
296
- 'count' => count($imics_to_delete_slice)
297
- ));
298
- // Log
299
- $log['total_products_deleted'] = $log['total_products_deleted'] + count($imics_to_delete_slice);
300
- Mage::helper('cueconnect')->logExportProgress(json_encode($log));
301
- }
302
- catch (Exception $e) {
303
- return array('success' => false, 'message' => $e->getMessage(), 'log' => $log);
304
- }
305
- }
306
- }
307
-
308
- // Log
309
- $log['end_at'] = date('Y-m-d H:i:s');
310
- $log['status'] = "done";
311
- Mage::helper('cueconnect')->logExportProgress(json_encode($log));
312
-
313
- // Return
314
- return array(
315
- 'success' => true,
316
- 'created_count' => count($new_data),
317
- 'updated_count' => count($updated_data),
318
- 'deleted_count' => count($imics_to_delete),
319
- 'message' => sprintf("%s product(s) has been created. %s product(s) has been updated. %s product(s) has been deleted.", count($new_data), count($updated_data), count($imics_to_delete)),
320
- 'log' => $log
321
- );
322
- }
323
 
324
  /**
325
  * Sync updated products data with CUE
@@ -346,13 +74,98 @@ class CueConnect_Cue_Model_CueConnect extends Mage_Core_Model_Abstract
346
  return $this->_errors;
347
  }
348
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
349
  /**
350
  * Cue data sync
351
  */
352
  public function sync()
353
  {
354
- Mage::getModel('cueconnect/observer')->syncAllCustomers();
355
- $this->syncAllProducts();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
356
  }
357
 
358
  /**
@@ -360,61 +173,71 @@ class CueConnect_Cue_Model_CueConnect extends Mage_Core_Model_Abstract
360
  *
361
  * @return bool
362
  */
363
- public function syncAllProducts()
364
  {
365
  $scheduled = Mage::getStoreConfigFlag(self::XML_PATH_PRODUCT_SYNC_SCHEDULED);
366
- if (!$scheduled) {
 
367
 
368
  return false;
369
  }
 
 
370
  $this->removeScheduleProductSync();
371
  foreach (Mage::app()->getStores() as $store) {
372
  $this->_errors = array();
373
  $this->_lastProductId = false;
374
  $this->_store = $store;
375
- $status = $this->_getProductSyncStatus();
376
- // Skip all if product sync is processing
377
- if ($status == self::PRODUCT_SYNC_PROCESSING) {
378
- return false;
379
- }
380
- // Skip store if product sync is complete
381
- if ($status == self::PRODUCT_SYNC_COMPLETE) {
382
- continue;
383
- }
384
- // check credentials and proceed with sync
385
- if ($this->_getCredentials() && $this->_getPlaceId()) {
386
- $this->_getProductSoap();
387
- if ($this->_productSoapClient) {
388
- $this->_setProductSyncStatus(self::PRODUCT_SYNC_PROCESSING);
389
- $this->_getCueProducts();
390
- $this->_syncAllProducts();
 
 
 
 
 
 
 
 
 
391
  }
392
  }
393
- $inbox = Mage::getModel('adminnotification/inbox');
394
  if (count($this->_errors)) {
395
- array_unshift($this->_errors, Mage::helper('cueconnect')->__('You can find more details below:'));
396
- $title = Mage::helper('cueconnect')->__(
397
- 'Product Synchronization has failed for the %s store, an email was sent to Cue Connect support.
398
- Contact us on %s for more information',
399
- $this->_store->getName(),
400
- Mage::getStoreConfig(self::XML_PATH_CUE_SUPPORT_EMAIL)
401
- );
402
- $inbox->addCritical($title, $this->_errors);
403
  $this->_setProductSyncStatus(self::PRODUCT_SYNC_FAILED);
404
- $message = Mage::helper('cueconnect')->__(
405
- 'Product Synchronization has failed for the %s store.',
406
- $this->_store->getName()
407
- );
408
- $message = $message . ' ' . implode(',', $this->_errors);
409
- $this->sendEmailToSupport($message);
410
- } else {
411
- $title = Mage::helper('cueconnect')->__(
412
- 'Products data has been successfully synced with Cue for the %s store',
413
- $this->_store->getName()
414
- );
415
- $description = Mage::helper('cueconnect')->__('Congratulation!') . ' ' . $title;
416
- $inbox->addNotice($title, $description);
417
- $this->_setProductSyncStatus(self::PRODUCT_SYNC_COMPLETE);
 
 
 
 
 
418
  }
419
  }
420
 
@@ -452,7 +275,7 @@ class CueConnect_Cue_Model_CueConnect extends Mage_Core_Model_Abstract
452
  {
453
  // Retailuser WS
454
  $soap_client = Mage::helper('cueconnect')->getSoapClient(
455
- Mage::helper('cueconnect')->getWsUrl('retailuser'),
456
  $this->_cueLogin,
457
  $this->_cuePassword
458
  );
@@ -464,11 +287,12 @@ class CueConnect_Cue_Model_CueConnect extends Mage_Core_Model_Abstract
464
  ));
465
  $this->_placeId = $result->data->id;
466
  } catch (Exception $e) {
467
- Mage::log($e->getMessage());
 
468
  $this->_errors[] = Mage::helper('cueconnect')->__(
469
  self::CUE_ERROR_MESSAGE_PRODUCT_SYNC,
470
  $this->_store->getName()
471
- );
472
 
473
  return false;
474
  }
@@ -569,9 +393,10 @@ class CueConnect_Cue_Model_CueConnect extends Mage_Core_Model_Abstract
569
  {
570
  $this->_updateData = array();
571
  $this->_newData = array();
 
572
  foreach ($productCollection as $product) {
573
  // Product image
574
- $icon = "http://www.cueconnect.com/images/no_image.gif";
575
  if ($product->getData('image')) {
576
  $icon = $product->getMediaConfig()->getMediaUrl($product->getData('image'));
577
  }
@@ -606,6 +431,7 @@ class CueConnect_Cue_Model_CueConnect extends Mage_Core_Model_Abstract
606
  protected function _addProducts()
607
  {
608
  if ($this->_newData) {
 
609
  $new_data_slices = Mage::helper('cueconnect')->getSlicesFromArray($this->_newData, self::CUE_SET_PAGE_SIZE);
610
  foreach ($new_data_slices as $new_data_slice) {
611
  try {
@@ -614,17 +440,14 @@ class CueConnect_Cue_Model_CueConnect extends Mage_Core_Model_Abstract
614
  'data' => $new_data_slice,
615
  'count' => count($new_data_slice)
616
  ));
617
- // TODO: check this if we need full log
618
- // Log
619
- // $log['total_products_created'] = $log['total_products_created'] + count($new_data_slice);
620
- // Mage::helper('cueconnect')->logExportProgress(json_encode($log));
621
  } catch (Exception $e) {
622
- Mage::log($e->getMessage());
 
623
  $this->_errors[] = Mage::helper('cueconnect')->__(
624
  self::CUE_ERROR_MESSAGE_PRODUCT_SYNC,
625
  $this->_store->getName()
626
- );
627
- // TODO: check this if we need full log
628
  //return array('success' => false, 'message' => $e->getMessage(), 'log' => $log);
629
  }
630
  }
@@ -640,22 +463,20 @@ class CueConnect_Cue_Model_CueConnect extends Mage_Core_Model_Abstract
640
  $updated_data_slices = Mage::helper('cueconnect')->getSlicesFromArray($this->_updateData, self::CUE_SET_PAGE_SIZE);
641
  foreach ($updated_data_slices as $updated_data_slice) {
642
  try {
 
643
  $this->_productSoapClient->set(array(
644
  'place_id' => $this->_placeId,
645
  'data' => $updated_data_slice,
646
  'count' => count($updated_data_slice)
647
  ));
648
- // TODO: check this if we need full log
649
- // Log
650
- // $log['total_products_updated'] = $log['total_products_updated'] + count($updated_data_slice);
651
- // Mage::helper('cueconnect')->logExportProgress(json_encode($log));
652
  } catch (Exception $e) {
653
- Mage::log($e->getMessage());
 
654
  $this->_errors[] = Mage::helper('cueconnect')->__(
655
  self::CUE_ERROR_MESSAGE_PRODUCT_SYNC,
656
  $this->_store->getName()
657
- );
658
- // TODO: check this if we need full log
659
  // return array('success' => false, 'message' => $e->getMessage(), 'log' => $log);
660
  }
661
  }
@@ -736,6 +557,7 @@ class CueConnect_Cue_Model_CueConnect extends Mage_Core_Model_Abstract
736
  }
737
  if ($actualCredentials) {
738
  $this->scheduleProductSync();
 
739
  }
740
 
741
  return false;
@@ -760,18 +582,52 @@ class CueConnect_Cue_Model_CueConnect extends Mage_Core_Model_Abstract
760
  Mage::app()->getCacheInstance()->cleanType('config');
761
  }
762
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
763
  /**
764
  * Send email to the CUE support
765
  *
766
  * @param string $message
767
  */
768
- public function sendEmailToSupport($message = 'hello')
769
  {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
770
  Mage::getModel('core/email')
771
  ->setType('html')
772
  ->setToName(Mage::getStoreConfig(self::XML_PATH_CUE_SUPPORT_NAME))
773
  ->setToEmail(Mage::getStoreConfig(self::XML_PATH_CUE_SUPPORT_EMAIL))
774
- ->setSubject(Mage::getStoreConfig(self::XML_PATH_CUE_SUPPORT_SUBJECT))
775
  ->setFromEmail(Mage::getStoreConfig('trans_email/ident_general/email'))
776
  ->setFromName(Mage::getStoreConfig('trans_email/ident_sales/name'))
777
  ->setBody($message)
15
  const CUE_SET_PAGE_SIZE = 20;
16
  const CUE_COLLECTION_PAGE_SIZE = 100;
17
  const CUE_ERROR_MESSAGE_PRODUCT_SYNC = 'An error occurred while synchronization product data with Cueconnect for
18
+ the %s store. Exception message - ';
19
  const XML_PATH_PRODUCT_SYNC_STATUS = 'cueconnect/product_sync_%s/status';
20
  const XML_PATH_PRODUCT_LAST_SYNCED_PRODUCT = 'cueconnect/product_sync_%s/last_synced_product';
21
  const XML_PATH_PRODUCT_SYNC_SCHEDULED = 'cueconnect/product_sync/scheduled';
22
+ const XML_PATH_CUSTOMER_SYNC_SCHEDULED = 'cueconnect/customer_sync/scheduled';
23
+ const XML_PATH_CUSTOMER_SYNC_STATUS = 'cueconnect/customer_sync_%s/status';
24
  const XML_PATH_CUE_SUPPORT_EMAIL = 'cueconnect/support/email';
25
  const XML_PATH_CUE_SUPPORT_NAME = 'cueconnect/support/name';
26
  const XML_PATH_CUE_SUPPORT_SUBJECT = 'cueconnect/support/subject';
27
  const PRODUCT_SYNC_FAILED = 'failed';
28
  const PRODUCT_SYNC_COMPLETE = 'complete';
29
  const PRODUCT_SYNC_PROCESSING = 'processing';
30
+ const CUSTOMER_SYNC_FAILED = 'failed';
31
+ const CUSTOMER_SYNC_COMPLETE = 'complete';
32
+ const CUSTOMER_SYNC_PROCESSING = 'processing';
33
 
34
  protected $_cueLogin = false;
35
  protected $_cuePassword = false;
48
  public function _construct() {
49
  $this->_init('cueconnect/cueconnect');
50
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
51
 
52
  /**
53
  * Sync updated products data with CUE
74
  return $this->_errors;
75
  }
76
 
77
+
78
+ /**
79
+ * get products by Ids
80
+ *
81
+ * @param array $productIds
82
+ * @return array
83
+ */
84
+ public function getProductsByIds($productIds)
85
+ {
86
+
87
+ foreach (Mage::app()->getStores() as $store) {
88
+ $this->_store = $store;
89
+ if (!$this->_getCredentials()) {
90
+ continue;
91
+ }
92
+
93
+ $productCollection = Mage::getModel('catalog/product')
94
+ ->getCollection()
95
+ ->addFieldToFilter('entity_id', array('in' => $productIds))
96
+ ->addAttributeToSelect('name')
97
+ ->addAttributeToSelect('description')
98
+ ->addAttributeToSelect('price')
99
+ ->addAttributeToSelect('image')
100
+ ->addAttributeToSelect('url_path')
101
+ ->addStoreFilter($this->_store->getId());
102
+
103
+ return $productCollection;
104
+
105
+ }
106
+
107
+ return false;
108
+ }
109
+
110
  /**
111
  * Cue data sync
112
  */
113
  public function sync()
114
  {
115
+
116
+ $storeId = Mage::app()
117
+ ->getWebsite(true)
118
+ ->getDefaultGroup()
119
+ ->getDefaultStoreId();
120
+ $store = Mage::getModel('core/store')->load($storeId);
121
+ $soap_auth = Mage::helper('cueconnect')->getRetailer($store);
122
+
123
+ if($soap_auth){
124
+
125
+ $this->_execSyncAllCustomers();
126
+ $this->_exeSyncAllProducts();
127
+
128
+
129
+ echo "=> Sync Done\n";
130
+
131
+ }else{
132
+ echo "\n\nERROR : CUE SOAP Credentials aren't Set Yet \n\n";
133
+ }
134
+
135
+
136
+
137
+
138
+ }
139
+
140
+ /**
141
+ * Sync all Customers with CUE
142
+ *
143
+ * @return bool
144
+ */
145
+ protected function _execSyncAllCustomers(){
146
+
147
+ // Check first if we need to sync
148
+ $scheduled = Mage::getStoreConfigFlag(self::XML_PATH_CUSTOMER_SYNC_SCHEDULED);
149
+ $remote_sync = Mage::getModel('cueconnect/observer')->getRemoteSyncStatus('customers');
150
+ if ($scheduled || $remote_sync){
151
+ echo "\nStart SyncAllCustomers\n";
152
+ $this->removeScheduleCustomerSync();
153
+ Mage::getModel('cueconnect/observer')->syncAllCustomers();
154
+ }else{
155
+
156
+ foreach (Mage::app()->getStores() as $store) {
157
+ $path = sprintf(self::XML_PATH_CUSTOMER_SYNC_STATUS, $store->getId());
158
+ $status = $store->getConfig($path);
159
+
160
+ if ($status == self::CUSTOMER_SYNC_FAILED || is_null($status)) {
161
+ // init sync since last sync failed
162
+ $this->scheduleCustomerSync();
163
+ }
164
+
165
+ }
166
+
167
+ }
168
+
169
  }
170
 
171
  /**
173
  *
174
  * @return bool
175
  */
176
+ public function _exeSyncAllProducts()
177
  {
178
  $scheduled = Mage::getStoreConfigFlag(self::XML_PATH_PRODUCT_SYNC_SCHEDULED);
179
+ $remote_sync = Mage::getModel('cueconnect/observer')->getRemoteSyncStatus('products');
180
+ if (!$scheduled && !$remote_sync) {
181
 
182
  return false;
183
  }
184
+
185
+ $retailerId = Mage::getStoreConfig('cueconnect/credentials/retailer_id');
186
  $this->removeScheduleProductSync();
187
  foreach (Mage::app()->getStores() as $store) {
188
  $this->_errors = array();
189
  $this->_lastProductId = false;
190
  $this->_store = $store;
191
+
192
+ if($remote_sync){
193
+ $this->_setProductSyncStatus(self::PRODUCT_SYNC_PROCESSING);
194
+ $this->_getCueProducts();
195
+ $this->_syncAllProducts();
196
+ }else{
197
+
198
+ $status = $this->_getProductSyncStatus();
199
+ // Skip all if product sync is processing
200
+ if ($status == self::PRODUCT_SYNC_PROCESSING) {
201
+ return false;
202
+ }
203
+ // Skip store if product sync is complete
204
+ if ($status == self::PRODUCT_SYNC_COMPLETE) {
205
+ continue;
206
+ }
207
+ // check credentials and proceed with sync
208
+ if ($this->_getCredentials() && $this->_getPlaceId()) {
209
+ $this->_getProductSoap();
210
+ if ($this->_productSoapClient) {
211
+ echo "\nStart SyncAllProducts\n";
212
+ $this->_setProductSyncStatus(self::PRODUCT_SYNC_PROCESSING);
213
+ $this->_getCueProducts();
214
+ $this->_syncAllProducts();
215
+ }
216
  }
217
  }
218
+
219
  if (count($this->_errors)) {
220
+
 
 
 
 
 
 
 
221
  $this->_setProductSyncStatus(self::PRODUCT_SYNC_FAILED);
222
+
223
+ $merchantEmail = Mage::getStoreConfig('cueconnect/credentials/login', $store->getId());
224
+ array_shift($this->_errors);
225
+ $number = 1;
226
+ $error_msg = '';
227
+ foreach ($this->_errors as $error) {
228
+ $error_msg .= $number . '. ' . $error . '<br/>';
229
+ ++$number;
230
+ }
231
+
232
+ // Email Cue Support
233
+ $this->sendEmailToSupport(
234
+ 'Cueconnect > _exeSyncAllProducts',
235
+ $store->getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB),
236
+ $store->getName(),
237
+ $retailerId,
238
+ $merchantEmail,
239
+ $error_msg);
240
+
241
  }
242
  }
243
 
275
  {
276
  // Retailuser WS
277
  $soap_client = Mage::helper('cueconnect')->getSoapClient(
278
+ Mage::helper('cueconnect')->getWsUrl('place'),
279
  $this->_cueLogin,
280
  $this->_cuePassword
281
  );
287
  ));
288
  $this->_placeId = $result->data->id;
289
  } catch (Exception $e) {
290
+ $message = $e->getMessage();
291
+ Mage::log($message);
292
  $this->_errors[] = Mage::helper('cueconnect')->__(
293
  self::CUE_ERROR_MESSAGE_PRODUCT_SYNC,
294
  $this->_store->getName()
295
+ ) . $message;
296
 
297
  return false;
298
  }
393
  {
394
  $this->_updateData = array();
395
  $this->_newData = array();
396
+
397
  foreach ($productCollection as $product) {
398
  // Product image
399
+ $icon = "https://www.cueconnect.com/images/no_image.gif";
400
  if ($product->getData('image')) {
401
  $icon = $product->getMediaConfig()->getMediaUrl($product->getData('image'));
402
  }
431
  protected function _addProducts()
432
  {
433
  if ($this->_newData) {
434
+
435
  $new_data_slices = Mage::helper('cueconnect')->getSlicesFromArray($this->_newData, self::CUE_SET_PAGE_SIZE);
436
  foreach ($new_data_slices as $new_data_slice) {
437
  try {
440
  'data' => $new_data_slice,
441
  'count' => count($new_data_slice)
442
  ));
 
 
 
 
443
  } catch (Exception $e) {
444
+ $message = $e->getMessage();
445
+ Mage::log($message);
446
  $this->_errors[] = Mage::helper('cueconnect')->__(
447
  self::CUE_ERROR_MESSAGE_PRODUCT_SYNC,
448
  $this->_store->getName()
449
+ ) . $message;
450
+ // TODO: send email to support
451
  //return array('success' => false, 'message' => $e->getMessage(), 'log' => $log);
452
  }
453
  }
463
  $updated_data_slices = Mage::helper('cueconnect')->getSlicesFromArray($this->_updateData, self::CUE_SET_PAGE_SIZE);
464
  foreach ($updated_data_slices as $updated_data_slice) {
465
  try {
466
+
467
  $this->_productSoapClient->set(array(
468
  'place_id' => $this->_placeId,
469
  'data' => $updated_data_slice,
470
  'count' => count($updated_data_slice)
471
  ));
 
 
 
 
472
  } catch (Exception $e) {
473
+ $message = $e->getMessage();
474
+ Mage::log($message);
475
  $this->_errors[] = Mage::helper('cueconnect')->__(
476
  self::CUE_ERROR_MESSAGE_PRODUCT_SYNC,
477
  $this->_store->getName()
478
+ ) . $message;
479
+ // TODO: Send email to support
480
  // return array('success' => false, 'message' => $e->getMessage(), 'log' => $log);
481
  }
482
  }
557
  }
558
  if ($actualCredentials) {
559
  $this->scheduleProductSync();
560
+ $this->scheduleCustomerSync(); // init sync setup
561
  }
562
 
563
  return false;
582
  Mage::app()->getCacheInstance()->cleanType('config');
583
  }
584
 
585
+ /**
586
+ * Schedule customer Sync. Set flat to 1
587
+ */
588
+ public function scheduleCustomerSync()
589
+ {
590
+ Mage::getModel('core/config')->saveConfig(self::XML_PATH_CUSTOMER_SYNC_SCHEDULED, 1);
591
+ Mage::app()->getCacheInstance()->cleanType('config');
592
+ }
593
+
594
+ /**
595
+ * Remove schedule Product Sync. Set flat to 0
596
+ */
597
+ public function removeScheduleCustomerSync()
598
+ {
599
+ Mage::getModel('core/config')->saveConfig(self::XML_PATH_CUSTOMER_SYNC_SCHEDULED, 0);
600
+ Mage::app()->getStore()->setConfig(self::XML_PATH_CUSTOMER_SYNC_SCHEDULED, 0);
601
+ Mage::app()->getCacheInstance()->cleanType('config');
602
+ }
603
+
604
  /**
605
  * Send email to the CUE support
606
  *
607
  * @param string $message
608
  */
609
+ public function sendEmailToSupport($action = 'N/A', $store_url = '', $store_name = '', $pid = '', $merchantEmail = '', $error = '')
610
  {
611
+ // Form email content
612
+ $subject = Mage::getStoreConfig(self::XML_PATH_CUE_SUPPORT_SUBJECT) . Mage::getBaseUrl (Mage_Core_Model_Store::URL_TYPE_WEB);
613
+ $message = $action.' has failed for '
614
+ . $store_url . ' website '
615
+ . $store_name. ' store '
616
+ . ' at ' . Mage::getModel('core/date')->date('H:i d-m-Y') . '<br/><br/>'
617
+ . 'Please check Technical debug bellow: ' . '<br/><br/>'
618
+ . 'Merchant ID: ' . $pid . '<br/>'
619
+ . 'Merchant email: ' . $merchantEmail . '<br/>'
620
+ . 'Platform: Magento' . '<br/>'
621
+ . 'Version: '.Mage::getVersion() . '<br/>'
622
+ . $error
623
+ ;
624
+
625
+ // send email
626
  Mage::getModel('core/email')
627
  ->setType('html')
628
  ->setToName(Mage::getStoreConfig(self::XML_PATH_CUE_SUPPORT_NAME))
629
  ->setToEmail(Mage::getStoreConfig(self::XML_PATH_CUE_SUPPORT_EMAIL))
630
+ ->setSubject($subject)
631
  ->setFromEmail(Mage::getStoreConfig('trans_email/ident_general/email'))
632
  ->setFromName(Mage::getStoreConfig('trans_email/ident_sales/name'))
633
  ->setBody($message)
app/code/community/CueConnect/Cue/Model/Observer.php CHANGED
@@ -21,278 +21,222 @@ class CueConnect_Cue_Model_Observer
21
 
22
  const SYNC_MASS_ACTION_NAME = 'cue_sync_mass_action';
23
 
 
 
 
 
 
24
  protected $_currentStoreId = false;
25
 
26
  /**
27
- * accessing e-List - used to sync saved items to Cue if not already done
28
- * @param Varien_Event_Observer $observer
 
29
  */
30
- public function viewElist(Varien_Event_Observer $observer) {
31
- if (Mage::getSingleton('customer/session')->isLoggedIn()) {
32
- $event = $observer->getEvent();
33
- $customer = $event->getCustomer();
34
 
35
- if ($customer) {
36
- $wishList = Mage::getModel('wishlist/wishlist')->loadByCustomer($customer);
 
 
 
 
37
 
38
- if ($wishList) {
39
- $wishListItemCollection = $wishList->getItemCollection();
40
 
41
- if (count($wishListItemCollection)) {
42
- foreach ($wishListItemCollection as $item) {
43
- $this->syncMark($item->getProduct(), $item->getDescription(), $customer);
44
- }
45
- }
46
- }
47
- }
48
- }
49
- }
50
 
51
 
52
  /**
53
- * Add e-List to menu
 
 
54
  * @param Varien_Event_Observer $observer
55
-
56
- public function regenerateMenu(Varien_Event_Observer $observer) {
57
- // if module is active
58
- if (!Mage::getStoreConfig('advanced/modules_disable_output/CueConnect_Cue')) {
59
- $layout = Mage::getSingleton('core/layout');
 
 
 
 
 
 
60
 
61
- // remove all the blocks you don't want
62
- //$layout->getUpdate()->addUpdate('<remove name="catalog.topnav"/>');
 
 
 
 
 
63
 
64
- // load layout updates by specified handles
65
- $layout->getUpdate()->load();
 
66
 
67
- // generate xml from collected text updates
68
- $layout->generateXml();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
69
 
70
- // generate blocks from xml layout
71
- $layout->generateBlocks();
72
  }
73
- }*/
74
-
75
-
76
 
77
  /**
78
- * sync customer account with Cue account after login
79
- * @param Varien_Event_Observer $observer
 
 
 
80
  */
81
- public function customerLogin(Varien_Event_Observer $observer) {
82
- if (Mage::getSingleton('customer/session')->isLoggedIn()) {
83
- $event = $observer->getEvent();
84
- $customer = $event->getCustomer();
 
 
 
85
 
86
- if ($customer) {
87
- $this->syncCustomer($customer);
88
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
89
  }
 
90
  }
91
 
92
 
93
- /**
94
- * sync magento customer profile with cue user (Magento -> Cue)
95
- * @param Varien_Event_Observer $observer
 
 
96
  */
97
- public function customerSaveProfile(Varien_Event_Observer $observer) {
98
- $event = $observer->getEvent();
99
- $customer = $event->getCustomer();
100
-
101
- if ($customer) {
102
- $this->syncCustomer($customer);
103
- }
104
- }
105
 
106
 
107
  /**
108
- * sync product data with e-List product (Magento -> Cue)
109
- * @param Varien_Event_Observer $observer [description]
 
 
110
  */
111
- public function updateProduct(Varien_Event_Observer $observer)
112
  {
113
- // Get catalog product
114
- $catalog_product = $observer->getEvent()->getProduct();
115
-
116
- // For each related stores
117
- foreach ($catalog_product->getStoreIds() as $store_id) {
118
- // Get store
119
- $store = Mage::getModel('core/store')->load($store_id);
120
- if ($store->getConfig('cueconnect/enabled/enabled')) {
121
- $cueLogin = $store->getConfig('cueconnect/credentials/login');
122
- $cuePassword = $store->getConfig('cueconnect/credentials/password');
123
- if (!$cueLogin || !$cuePassword) {
124
- $message = Mage::helper('cueconnect')->__(
125
- 'Please check the following Cue API Credentials: E-mail and Password for the %s store.',
126
- $store->getName()
127
- );
128
- Mage::getSingleton('adminhtml/session')->addError($message);
129
- continue;
130
- }
131
- // Retailuser SOAP client
132
- $soap_client = Mage::helper('cueconnect')->getSoapClient(
133
- Mage::helper('cueconnect')->getWsUrl('retailuser'),
134
- $store->getConfig('cueconnect/credentials/login'),
135
- $store->getConfig('cueconnect/credentials/password')
136
- );
137
-
138
- // Get place ID
139
- $place_id = null;
140
- try {
141
- $result = $soap_client->get(array(
142
- 'email' => $store->getConfig('cueconnect/credentials/login')
143
- ));
144
- $place_id = $result->data->id;
145
- }
146
- catch (Exception $e) {
147
- Mage::log($e->getMessage());
148
- $message = Mage::helper('cueconnect')->__(
149
- 'An error occurred while synchronization product data with Cueconnect for the %s store.
150
- You can find more details in the log file',
151
- $store->getName()
152
- );
153
- Mage::getSingleton('adminhtml/session')->addError($message);
154
- }
155
-
156
- if ($place_id) {
157
- // Product SOAP client
158
- $soap_client = Mage::helper('cueconnect')->getSoapClient(
159
- Mage::helper('cueconnect')->getWsUrl('product'),
160
- $store->getConfig('cueconnect/credentials/login'),
161
- $store->getConfig('cueconnect/credentials/password')
162
- );
163
 
164
- // Product icon
165
- $icon = "http://www.cueconnect.com/images/no_image.gif";
166
- if ($catalog_product->getData('image')) {
167
- $icon = $catalog_product->getMediaConfig()->getMediaUrl($catalog_product->getData('image'));
168
- }
 
169
 
170
- // Get product and update/create product
171
- try {
172
- $result = $soap_client->get(array(
173
- 'place_id' => $place_id,
174
- 'sku' => $catalog_product->getSku(),
175
- 'page' => 1,
176
- 'page_size' => 1
177
- ));
178
- if ($result && isset($result->data) && isset($result->data[0]) && isset($result->inpagecount) && $result->inpagecount) {
179
- $cueconnect_product = $result->data[0];
180
- $data = array(
181
- 'product_imic' => null,
182
- 'sku' => $catalog_product->getSku(),
183
- 'name' => $catalog_product->getName(),
184
- 'description' => $catalog_product->getDescription(),
185
- 'sms_name' => $catalog_product->getName(),
186
- 'sms_desc' => $catalog_product->getDescription(),
187
- 'url' => $catalog_product->getProductUrl(),
188
- 'taxonomy_id' => Mage::getStoreConfig('cueconnect/taxomomy_id'),
189
- 'icon' => $icon,
190
- 'live' => '1',
191
- 'price' => $catalog_product->getPrice()
192
- );
193
- $soap_client->set(array(
194
- 'place_id' => $place_id,
195
- 'data' => array(0 => $data),
196
- 'count' => 1
197
- ));
198
- }
199
- else {
200
- $data = array(
201
- 'sku' => $catalog_product->getSku(),
202
- 'upc' => uniqid(),
203
- 'name' => $catalog_product->getName(),
204
- 'description' => $catalog_product->getDescription(),
205
- 'sms_name' => $catalog_product->getName(),
206
- 'sms_desc' => $catalog_product->getDescription(),
207
- 'url' => $catalog_product->getProductUrl(),
208
- 'taxonomy_id' => Mage::getStoreConfig('cueconnect/taxomomy_id'),
209
- 'icon' => $icon,
210
- 'live' => '1',
211
- 'price' => $catalog_product->getPrice()
212
- );
213
- $soap_client->create(array(
214
- 'place_id' => $place_id,
215
- 'data' => array(0 => $data),
216
- 'count' => 1
217
- ));
218
- }
219
- }
220
- catch (Exception $e) {
221
- Mage::log($e->getMessage());
222
- $message = Mage::helper('cueconnect')->__(
223
- 'An error occurred while synchronization product data with Cueconnect for the %s store.
224
- You can find more details in the log file',
225
- $store->getName()
226
- );
227
- Mage::getSingleton('adminhtml/session')->addError($message);
228
- }
229
  }
 
 
230
  }
231
  }
232
  }
233
-
234
  /**
235
- * update config in Cue when updated in Magento (Magento -> Cue)
236
- * @param Varien_Event_Observer $observer
 
 
 
 
237
  */
238
- public function adminCueConnectUpdated(Varien_Event_Observer $observer)
239
  {
240
- $storeId = $observer->getEvent()->getStore();
241
- $store = Mage::getModel('core/store')->load($storeId);
242
- if ($store) {
243
- $post = Mage::app()->getRequest()->getPost();
244
- $version = $post['groups']['mode']['fields']['mode']['value'];
245
 
246
- $placeApiKey = $store->getConfig('cueconnect/credentials/api_key');
247
- $str = "v$version" . Mage::helper('cueconnect')->getWebhookSelectVersionKey() . Mage::helper('cueconnect')->getWebhookSelectVersionUrl() . $placeApiKey;
248
- $key = sha1($str) . '$' . $placeApiKey;
249
-
250
- $params = array(
251
- 'version' => $version
252
- );
253
 
254
- $retailerId = (int)$this->doRequest(Mage::helper('cueconnect')->getWebhookSelectVersionUrl(), $key, $params);
255
-
256
- if ($retailerId) {
257
- /*$config = new Mage_Core_Model_Config();
258
- $config->saveConfig('cueconnect/credentials/retailer_id', $retailerId, 'default', 1);
259
- Mage::app()->getCacheInstance()->cleanType('config');
260
- */
261
- Mage::getModel('core/config')->saveConfig('cueconnect/credentials/retailer_id', $retailerId);
262
- Mage::app()->getCacheInstance()->cleanType('config');
263
- }
264
- }
265
  }
266
 
267
  /**
268
- * update product in Cue when updated in Magento (Magento -> Cue)
 
 
269
  * @param Varien_Event_Observer $observer
 
270
  */
271
- public function adminProductUpdated(Varien_Event_Observer $observer)
272
- {
 
 
273
  $product = $observer->getEvent()->getProduct();
 
274
 
 
275
  if (Mage::registry('old_product_sku')) {
276
- $this->deleteOldSkuProduct($product->getStoreIds(), Mage::registry('old_product_sku'));
277
  Mage::unregister('old_product_sku');
278
  }
279
- // For each related stores
280
- foreach ($product->getStoreIds() as $storeId) {
281
- $store = Mage::getModel('core/store')->load($storeId);
282
- $placeApiKey = $store->getConfig('cueconnect/credentials/api_key');
 
283
 
284
- $str = $product->getSku() . Mage::helper('cueconnect')->getWebhookPriceChangedKey() . Mage::helper('cueconnect')->getWebhookPriceChangedUrl() . $product->getId();
285
 
 
 
286
  $key = sha1($str) . '$' . $placeApiKey;
287
 
 
288
  $width = Mage::getStoreConfig('cueconnect/image/width');
289
  $height = Mage::getStoreConfig('cueconnect/image/height');
290
-
291
  $image = 'https://www.cueconnect.com/images/no_image.gif';
292
  if ($product->getData('small_image') && $product->getData('small_image') !== 'no_selection') {
293
  $image = (string)Mage::helper('catalog/image')->init($product, 'small_image')->resize($width, $height);
294
  }
295
 
 
296
  $params = array(
297
  'id' => $product->getId(),
298
  'sku' => (string)$product->getSku(),
@@ -308,604 +252,343 @@ class CueConnect_Cue_Model_Observer
308
  'price' => number_format(Mage::helper('core')->currency($product->getPrice(), false, false), 2),
309
  );
310
 
311
- $url = Mage::helper('cueconnect')->getWebhookPriceChangedUrl();
312
 
313
- $this->doRequest($url, $key, $params);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
314
  }
315
- }
316
 
317
 
 
 
318
  /**
319
- * delete product from e-List when deleted in Magento (Magento -> Cue)
 
 
320
  * @param Varien_Event_Observer $observer
321
  */
322
  public function deleteProduct(Varien_Event_Observer $observer)
323
  {
324
  // Get catalog product
325
- $catalog_product = $observer->getEvent()->getProduct();
326
 
327
  // For each related stores
328
- foreach ($catalog_product->getStoreIds() as $store_id) {
329
- // Get store
330
- $store = Mage::getModel('core/store')->load($store_id);
331
- if ($store->getConfig('cueconnect/enabled/enabled')) {
332
- // Retailuser SOAP client
333
- $soap_client = Mage::helper('cueconnect')->getSoapClient(
334
- Mage::helper('cueconnect')->getWsUrl('retailuser'),
335
- $store->getConfig('cueconnect/credentials/login'),
336
- $store->getConfig('cueconnect/credentials/password')
337
- );
338
 
339
- // Get place ID
340
- $place_id = null;
341
- try {
342
- $result = $soap_client->get(array(
343
- 'email' => $store->getConfig('cueconnect/credentials/login')
344
- ));
345
- $place_id = $result->data->id;
346
- }
347
- catch (Exception $e) {
348
- Mage::log($e->getMessage());
349
- }
350
 
351
- // Product SOAP client
352
- $soap_client = Mage::helper('cueconnect')->getSoapClient(
353
- Mage::helper('cueconnect')->getWsUrl('product'),
354
- $store->getConfig('cueconnect/credentials/login'),
355
- $store->getConfig('cueconnect/credentials/password')
356
- );
 
 
 
 
 
357
 
358
- // Get and delete Cue Connect product
359
- try {
360
- $result = $soap_client->get(array(
361
- 'place_id' => $place_id,
362
- 'sku' => $catalog_product->getSku(),
363
- 'page' => 1,
364
- 'page_size' => 1
365
- ));
366
- if ($result && isset($result->data) && isset($result->data[0]) && isset($result->inpagecount) && $result->inpagecount) {
367
- $cueconnect_product = $result->data[0];
368
- $result = $soap_client->delete(array(
369
- 'place_id' => $place_id,
370
- 'data' => array($cueconnect_product->product_imic),
371
- 'count' => 1
372
- ));
373
- }
374
- }
375
- catch (Exception $e) {
376
- Mage::log($e->getMessage());
377
- $message = Mage::helper('cueconnect')->__(
378
- 'An error occurred while synchronization product data with Cueconnect for the %s store.
379
- You can find more details in the log file',
380
- $store->getName()
381
- );
382
- Mage::getSingleton('adminhtml/session')->addError($message);
383
- }
384
- }
385
  }
 
386
  }
387
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
388
 
389
  /**
390
- * sync function
391
- * @param Mage_Customer_Model_Customer $customer
 
 
392
  */
393
- protected function createCueUser($customer) {
394
- if ($customer) {
395
- $storeId = $customer->getStoreId();
396
- if (!$storeId && $this->_currentStoreId ) {
397
- $storeId = $this->_currentStoreId;
398
- }
399
- if (!$storeId) {
400
- $storeId = Mage::app()->getStore()->getStoreId();
401
- }
402
- if (!$storeId) {
403
- $storeId = Mage::app()->getDefaultStoreView()->getStoreId();
404
- }
405
 
406
- $store = Mage::getModel('core/store')->load($storeId);
407
- $placeApiKey = $store->getConfig('cueconnect/credentials/api_key');
408
 
409
- $str = Mage::helper('cueconnect')->getWebhookSaveCustomerKey() . Mage::helper('cueconnect')->getWebhookSaveCustomerUrl() . $customer->getId() . $customer->getEmail();
 
410
 
411
- $key = sha1($str) . '$' . $placeApiKey;
412
 
413
- $params = array(
414
- 'storeId' => $storeId,
415
- 'id' => $customer->getId(),
416
- 'email' => $customer->getEmail(),
417
- 'fullName' => $customer->getName(),
418
- 'firstName' => $customer->getFirstname(),
419
- 'lastName' => $customer->getLastname(),
420
- 'created' => $customer->getCreatedAt(),
421
- 'dob' => $customer->getDob(),
422
- 'gender' => $customer->getGender(),
423
- );
424
 
425
- $url = Mage::helper('cueconnect')->getWebhookSaveCustomerUrl();
426
- $response = $this->doRequest($url, $key, $params);
427
-
428
- // do POST - use curl
429
- /*if (function_exists('curl_version')) {
430
- try {
431
- $ch = curl_init();
432
- curl_setopt($ch, CURLOPT_URL, $url);
433
- curl_setopt($ch, CURLOPT_HEADER);
434
- curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
435
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
436
- curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
437
- curl_setopt($ch, CURLOPT_HTTPHEADER,array('X-Cue-Mage-Auth: ' . $key));
438
-
439
- $response = curl_exec($ch);
440
- $httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
441
-
442
- curl_close($ch);
443
-
444
- } catch (Exception $e) {
445
- Mage::log($e->getMessage());
446
- }
447
- }
448
- // do GET
449
- else {
450
- $params['key'] = $key;
451
- $queryString = '?' . http_build_query($params);
452
-
453
- try {
454
- $response = file_get_contents($url . $queryString);
455
- } catch (Exception $e) {
456
- Mage::log($e->getMessage());
457
- }
458
- }*/
459
 
460
- return $response;
461
- }
 
462
 
463
- return null;
464
- }
 
 
 
 
 
465
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
466
 
467
- protected function createCueProduct($product, $description, $customer)
468
- {
469
- if ($product && $customer) {
470
- $storeId = $customer->getStoreId();
471
- if (!$storeId) {
472
- $storeId = Mage::app()->getStore()->getStoreId();
473
- }
474
 
475
- $store = Mage::getModel('core/store')->load($storeId);
476
- $placeApiKey = $store->getConfig('cueconnect/credentials/api_key');
477
 
478
- $str = Mage::helper('cueconnect')->getWebhookSaveMarkKey() . Mage::helper('cueconnect')->getWebhookSaveMarkUrl() . $customer->getId() . $customer->getEmail();
 
479
 
480
- $key = sha1($str) . '$' . $placeApiKey;
 
481
 
482
- $width = Mage::getStoreConfig('cueconnect/image/width');
483
- $height = Mage::getStoreConfig('cueconnect/image/height');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
484
 
485
- $image = 'https://www.cueconnect.com/images/no_image.gif';
486
- if ($product->getData('small_image') && $product->getData('small_image') !== 'no_selection') {
487
- $image = (string)Mage::helper('catalog/image')->init($product, 'small_image')->resize($width, $height);
488
  }
489
 
490
- $params = array(
491
- // customer
492
- 'storeId' => $storeId,
493
- 'id' => $customer->getId(),
494
- 'email' => $customer->getEmail(),
495
- 'fullName' => $customer->getName(),
496
- 'firstName' => $customer->getFirstname(),
497
- 'lastName' => $customer->getLastname(),
498
- 'created' => $customer->getCreatedAt(),
499
- 'dob' => $customer->getDob(),
500
- 'gender' => $customer->getGender(),
501
 
502
- // product
503
- 'sku' => (string)$product->getSku(),
504
- 'name' => $product->getName(),
505
- 'description' => (string)$product->getDescription(),
506
- 'comment' => (string)$description,
507
- 'brand' => (string)$product->getAttributeText('manufacturer'),
508
- 'upc' => uniqid(),
509
- 'sms_name' => $product->getName(),
510
- 'sms_desc' => (string)$product->getDescription(),
511
- 'url' => $product->getProductUrl(),
512
- 'taxonomy_id' => Mage::getStoreConfig('cueconnect/taxomomy_id'),
513
- 'image' => $image,
514
- 'live' => '1',
515
- 'price' => number_format(Mage::helper('core')->currency($product->getPrice(), false, false), 2),
516
- );
517
-
518
- $url = Mage::helper('cueconnect')->getWebhookSaveMarkUrl();
519
- $response = $this->doRequest($url, $key, $params);
520
-
521
- // do POST - use curl
522
- /*if (function_exists('curl_version')) {
523
- try {
524
- $ch = curl_init();
525
- curl_setopt($ch, CURLOPT_URL, $url);
526
- curl_setopt($ch, CURLOPT_HEADER);
527
- curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
528
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
529
- curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
530
- curl_setopt($ch, CURLOPT_HTTPHEADER,array('X-Cue-Mage-Auth: ' . $key));
531
-
532
- $response = curl_exec($ch);
533
- $httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
534
-
535
- curl_close($ch);
536
-
537
- } catch (Exception $e) {
538
- Mage::log($e->getMessage());
539
- }
540
- }
541
- // do GET
542
- else {
543
- $params['key'] = $key;
544
- $queryString = '?' . http_build_query($params);
545
-
546
- try {
547
- $response = file_get_contents($url . $queryString);
548
- } catch (Exception $e) {
549
- Mage::log($e->getMessage());
550
- }
551
- }*/
552
-
553
- return $response;
554
- }
555
-
556
- return null;
557
  }
558
 
559
 
 
 
 
 
 
 
560
 
561
  /**
562
- * flag local user as synced and create Cue user
563
- * @param Mage_Customer_Model_Customer $customer
 
 
 
 
564
  */
565
- protected function syncCustomer($customer)
566
  {
567
- if ($customer) {
568
- $exception = false;
569
- /** @var CueConnect_Cue_Model_UserSync $userSyncModel*/
570
- $userSyncModel = Mage::getModel('cueconnect/userSync');
571
 
572
- if ($userSyncModel) {
573
- $row = $userSyncModel->getCollection()
574
- ->addFieldToFilter('customer_id', $customer->getId())
575
- ->addFieldToFilter('status', $userSyncModel::STATUS_DONE)
576
- ->getFirstItem();
577
-
578
- if (!$row->getData()) {
579
- $userSyncModel->setData(array(
580
- 'customer_id' => $customer->getId(),
581
- 'status' => $userSyncModel::STATUS_WAITING,
582
- 'created_at' => date('Y-m-d H:i:s')
583
- ));
584
 
585
- $id = $userSyncModel->save()->getId();
 
 
586
 
587
- // sync customer
588
- $response = $this->createCueUser($customer);
589
- $exception = ($response != 1);
590
 
591
- // update status
592
- $row = $userSyncModel->load($id);
593
- if ($row->getData()) {
594
- $row->addData(array(
595
- 'status' => ($response) ? $userSyncModel::STATUS_DONE : $userSyncModel::STATUS_ERROR,
596
- ));
597
- $row->save();
598
- }
599
- }
600
  }
601
 
602
- // if unable to save local flag, then sync customer with Cue anyway
603
- if ($exception) {
604
- $this->createCueUser($customer);
605
  }
606
- }
607
- }
608
 
 
 
 
 
 
 
 
 
609
 
610
- /**
611
- * copy native wishlist items to e-List saves when accessing e-List for first time
612
- * @param [type] $product
613
- * @param [type] $description
614
- * @param [type] $customer
615
- */
616
- protected function syncMark($product, $description, $customer)
617
- {
618
- if ($customer && $product) {
619
- $exception = false;
620
- $wishlistSyncModel = Mage::getModel('cueconnect/wishlistSync');
621
-
622
- if ($wishlistSyncModel) {
623
- $row = $wishlistSyncModel->getCollection()
624
- ->addFieldToFilter('product_id', $product->getId())
625
- ->addFieldToFilter('customer_id', $customer->getId())
626
- ->addFieldToFilter('status', $wishlistSyncModel::STATUS_DONE)
627
- ->getFirstItem();
628
-
629
- if (!$row->getData()) {
630
- $wishlistSyncModel->setData(array(
631
- 'customer_id' => $customer->getId(),
632
- 'product_id' => $product->getId(),
633
- 'status' => $wishlistSyncModel::STATUS_WAITING,
634
- 'created_at' => date('Y-m-d H:i:s')
635
- ));
636
-
637
- $id = $wishlistSyncModel->save()->getId();
638
-
639
- // sync product/customer
640
- $response = $this->createCueProduct($product, $description, $customer);
641
- $exception = ($response != 1);
642
 
643
- // update status
644
- $row = $wishlistSyncModel->load($id);
645
- if ($row->getData()) {
646
- $row->addData(array(
647
- 'status' => ($response) ? $wishlistSyncModel::STATUS_DONE : $wishlistSyncModel::STATUS_ERROR,
648
- ));
649
- $row->save();
 
650
  }
651
  }
652
- }
653
 
654
- // if unable to save local flag, then sync product/customer with Cue anyway => this means the op will be executed each time we access eList
655
- if ($exception) {
656
- $this->createCueProduct($product, $customer);
657
- }
658
- }
659
- }
660
-
661
-
662
-
663
- protected function doRequest($url, $key, $params)
664
- {
665
- $response = null;
666
 
667
- // do POST - use curl
668
- if (function_exists('curl_version')) {
669
- try {
670
- $ch = curl_init();
671
- curl_setopt($ch, CURLOPT_URL, $url);
672
- curl_setopt($ch, CURLOPT_HEADER, 0);
673
- curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
674
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
675
- curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
676
- curl_setopt($ch, CURLOPT_HTTPHEADER,array('X-Cue-Mage-Auth: ' . $key));
677
 
678
- $response = curl_exec($ch);
679
- $httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
680
-
681
- curl_close($ch);
682
-
683
- } catch (Exception $e) {
684
- Mage::log($e->getMessage());
685
- }
686
- }
687
- // do GET
688
- else {
689
- $params['key'] = $key;
690
- $queryString = '?' . http_build_query($params);
691
-
692
- try {
693
- $response = file_get_contents($url . $queryString);
694
- } catch (Exception $e) {
695
- Mage::log($e->getMessage());
696
  }
697
- }
698
 
699
- return $response;
700
- }
701
 
702
- /**
703
- * add link to the Main menu of a Magento site
704
- * @param Varien_Event_Observer $observer
705
- */
706
- public function addToTopmenu(Varien_Event_Observer $observer)
707
- {
708
- if (Mage::helper('cueconnect')->isMyListEnabled()) {
709
- $menu = $observer->getMenu();
710
- $tree = $menu->getTree();
711
- $node = new Varien_Data_Tree_Node(array(
712
- 'name' => 'My List',
713
- 'id' => 'mylist',
714
- 'url' => Mage::getUrl('apps/mylist'),
715
- 'class' => 'cue-stream'
716
- ), 'id', $tree, $menu);
717
- $menu->addChild($node);
718
  }
719
- }
720
 
721
- /**
722
- * Get order ids for the multishipping checkout, add it to session
723
- *
724
- * @param Varien_Event_Observer $observer
725
- */
726
- public function getOrderIds(Varien_Event_Observer $observer)
727
- {
728
- $orderIds = $observer->getOrderIds();
729
- if ($orderIds && count($orderIds)) {
730
- Mage::getSingleton('checkout/session')->setFirstOrderId($orderIds[0]);
731
- }
732
  }
733
 
734
  /**
735
- * Sync updated products data with CUE on product update attributes mass action
736
- *
737
- * @param Varien_Event_Observer $observer
738
- *
739
- * @return $this
740
- */
741
- public function productMassUpdate(Varien_Event_Observer $observer)
742
- {
743
- /** @var array $productIds */
744
- $productIds = $observer->getProductIds();
745
- $this->productUpdateExecute($productIds);
746
- }
747
-
748
- /**
749
- * Sync import products data with CUE
750
- *
751
- * @param Varien_Event_Observer $observer
752
- */
753
- public function productsImportUpdate(Varien_Event_Observer $observer)
754
- {
755
- $adapter = $observer->getEvent()->getAdapter();
756
- $productIds = $adapter->getAffectedEntityIds();
757
- $this->productUpdateExecute($productIds);
758
- }
759
-
760
- /**
761
- * Executed sync products data with CUE
762
- *
763
- * @param Array $productIds
764
  */
765
- protected function productUpdateExecute($productIds)
766
  {
767
- if (count($productIds)) {
768
- $this->syncProducts($productIds);
769
- }
770
 
771
- return $this;
772
  }
773
 
774
  /**
775
- * Sync updated products data with CUE on product update attributes mass action stock change
776
- *
777
- * @param Varien_Event_Observer $observer
778
  *
779
- * @return $this
 
 
 
 
 
780
  */
781
- public function productStockMassUpdate(Varien_Event_Observer $observer)
782
  {
783
- /** @var array $productIds */
784
- $productIds = $observer->getProducts();
785
- if (count($productIds)) {
786
- $this->syncProducts($productIds);
787
- }
788
-
789
- return $this;
790
- }
791
 
792
- /**
793
- * Sync updated products data with CUE
794
- *
795
- * @param [] $productIds
796
- *
797
- * @return $this
798
- */
799
- protected function syncProducts($productIds)
800
- {
801
- if (!Mage::registry(self::SYNC_MASS_ACTION_NAME)) {
802
- Mage::register(self::SYNC_MASS_ACTION_NAME, true);
803
- /** @var CueConnect_Cue_Model_CueConnect $productUpdateModel */
804
- $productUpdateModel = Mage::getModel('cueconnect/cueconnect');
805
- /** @var array $errors */
806
- $errors = $productUpdateModel->productsUpdate($productIds);
807
- /** @var Mage_Adminhtml_Model_Session $adminSession */
808
- $adminSession = Mage::getSingleton('adminhtml/session');
809
- /** @var string $error */
810
- foreach ($errors as $error) {
811
- $adminSession->addError($error);
812
- }
813
  }
814
-
815
- return $this;
816
  }
817
 
818
  /**
819
- * Sync all customers with CUE
820
- *
 
 
821
  * @return bool
822
  */
823
- public function syncAllCustomers()
824
- {
825
- // check if $scheduled sync
826
- $scheduled = Mage::getStoreConfigFlag(self::XML_PATH_CUSTOMER_SYNC_SCHEDULED);
827
- if (!$scheduled) {
828
-
829
- return false;
830
- }
831
- // check retailer_id
832
- $retailer_id = Mage::getStoreConfig('cueconnect/credentials/retailer_id');
833
- if (is_null($retailer_id)) {
834
 
835
- return false;
836
- }
837
- $this->removeScheduleCustomerSync();
838
 
839
- /** @var CueConnect_Cue_Model_CueConnect $cueModel */
840
- $cueModel = Mage::getModel('cueconnect/cueconnect');
841
- $notSyncPrev = $this->checkNotSyncedCustomer();
842
- $storeCollection = Mage::getModel('core/store')->getCollection()
843
- ->setLoadDefault(true);
844
- foreach ($storeCollection as $store) {
845
- $this->_currentStoreId = $store->getId();
846
- // return sync status for current store
847
- $status = $this->_getCustomerSyncStatus($store);
848
 
849
- // skip if customers sync for current store compleate
850
- if ($status == self::CUSTOMER_SYNC_COMPLETE) {
851
- continue;
852
  }
853
- // Skip all if customer sync is processing
854
- if ($status == self::CUSTOMER_SYNC_PROCESSING) {
855
- return false;
856
  }
857
-
858
- // set $status processing for current store
859
- $this->setCustomersSyncStatus(self::CUSTOMER_SYNC_PROCESSING);
860
- $customerCollection = Mage::getModel('customer/customer')->getCollection()
861
- ->addFieldToFilter('store_id', $this->_currentStoreId);
862
- foreach ($customerCollection as $customer) {
863
- $this->syncCustomer($customer);
864
  }
865
 
866
- //check the cueconnect_user_sync and find the customers with status - STATUS_ERROR (2) after sync
867
- $notSyncUserIds = $this->checkNotSyncedCustomer();
868
 
869
- /** @var Mage_AdminNotification_Model_Inbox $inbox */
870
- $inbox = Mage::getModel('adminnotification/inbox');
871
- if (count($notSyncPrev) < count($notSyncUserIds)) {
872
- $this->setCustomersSyncStatus(self::CUSTOMER_SYNC_FAILED);
873
- $title = Mage::helper('cueconnect')->__(
874
- 'Customers Synchronization has failed for the %s store, an email was sent to Cue Connect support.
875
- Contact us on %s for more information',
876
- $store->getName(),
877
- Mage::getStoreConfig($cueModel::XML_PATH_CUE_SUPPORT_EMAIL)
878
- );
879
- $message = Mage::helper('cueconnect')->__(
880
- 'Customer Synchronization has failed for the %s store.',
881
- $store->getName()
882
- );
883
- $cueModel->sendEmailToSupport($message);
884
- $notificationBody = Mage::helper('cueconnect')->__(
885
- 'Customer Synchronization for the %s store has failed for %s customer(s)',
886
- $store->getName(),
887
- count(array_diff($notSyncUserIds, $notSyncPrev))
888
- );
889
 
890
- $inbox->addCritical($title, $notificationBody);
891
- } else {
892
- $this->setCustomersSyncStatus(self::CUSTOMER_SYNC_COMPLETE);
893
- $title = Mage::helper('cueconnect')->__(
894
- 'Customer data has been successfully synced with Cue for the %s store',
895
- $store->getName()
896
- );
897
- $description = Mage::helper('cueconnect')->__('Congratulation!') . ' ' . $title;
898
- $inbox->addNotice($title, $description);
899
- }
900
 
901
- $notSyncPrev = $notSyncUserIds;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
902
 
 
903
  }
904
- }
905
 
 
 
906
 
907
  /**
908
- * check the cueconnect_user_sync and find the customers with status - STATUS_ERROR (2)
 
 
909
  */
910
  public function checkNotSyncedCustomer()
911
  {
@@ -922,8 +605,8 @@ class CueConnect_Cue_Model_Observer
922
  }
923
 
924
  /**
925
- * Set and save customers sync status for the store
926
- *
927
  * @param string $value
928
  */
929
  protected function setCustomersSyncStatus($value)
@@ -934,7 +617,8 @@ class CueConnect_Cue_Model_Observer
934
  }
935
 
936
  /**
937
- * Remove schedule customer Sync. Set flat to 0
 
938
  */
939
  public function removeScheduleCustomerSync()
940
  {
@@ -944,22 +628,19 @@ class CueConnect_Cue_Model_Observer
944
  }
945
 
946
  /**
947
- * Get customer Sync status for the store.
948
- *
949
- * @return mixed
950
  */
951
- protected function _getCustomerSyncStatus($store)
952
  {
953
- $path = sprintf(self::XML_PATH_CUSTOMER_SYNC_STATUS, $this->_currentStoreId);
954
- $status = $store->getConfig($path);
955
-
956
- return $status;
957
  }
958
 
959
-
960
  /**
961
  * Check customer sync status for the stores, return true when resync should be running.
962
- *
963
  * @return bool
964
  */
965
  public function isCustomerReSyncNeeded()
@@ -994,106 +675,253 @@ class CueConnect_Cue_Model_Observer
994
  }
995
 
996
  /**
997
- * Schedule customer Sync. Set flat to 1
 
998
  */
999
- public function scheduleCustomerSync()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1000
  {
1001
- Mage::getModel('core/config')->saveConfig(self::XML_PATH_CUSTOMER_SYNC_SCHEDULED, 1);
1002
- Mage::app()->getCacheInstance()->cleanType('config');
 
 
1003
  }
1004
 
1005
  /**
1006
- * Checked updated products SKU
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1007
  *
1008
- * @param Varien_Event_Observer $observer
 
 
 
 
 
 
 
 
 
 
 
 
1009
  */
1010
- public function detectProductSkuChanges($observer)
1011
  {
1012
- /* @var Mage_Catalog_Model_Product $product */
1013
- $product = $observer->getEvent()->getProduct();
 
 
1014
 
1015
- if ($product->hasDataChanges()) {
1016
  try {
1017
- /* @var string $newSku */
1018
- $newSku = ($product->getData('sku')) ? $product->getData('sku') : null;
1019
- /* @var string $oldSku */
1020
- $oldSku = ($product->getOrigData('sku')) ? $product->getOrigData('sku') : null;
 
 
 
 
 
 
 
 
1021
 
1022
- if ($newSku && $oldSku && ($newSku != $oldSku)) {
1023
- Mage::register('old_product_sku', $oldSku);
1024
- }
1025
  } catch (Exception $e) {
1026
- Mage::log($e->getTraceAsString(), null, 'product_changes_fault.log');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1027
  }
1028
  }
 
 
1029
  }
1030
 
1031
  /**
1032
- * Delete product from e-List when deleted in Magento or changed SKU
1033
- *
1034
- * @param array $storeIds
1035
- * @param string $sku
 
 
1036
  */
1037
- protected function deleteOldSkuProduct($storeIds, $sku)
1038
  {
1039
- // For each related stores
1040
- foreach ($storeIds as $store_id) {
1041
- // Get store
1042
- $store = Mage::getModel('core/store')->load($store_id);
1043
- if ($store->getConfig('cueconnect/enabled/enabled')) {
1044
- // Retailuser SOAP client
1045
- $soap_client = Mage::helper('cueconnect')->getSoapClient(
1046
- Mage::helper('cueconnect')->getWsUrl('retailuser'),
1047
- $store->getConfig('cueconnect/credentials/login'),
1048
- $store->getConfig('cueconnect/credentials/password')
1049
- );
1050
 
1051
- // Get place ID
1052
- $place_id = null;
1053
- try {
1054
- $result = $soap_client->get(array(
1055
- 'email' => $store->getConfig('cueconnect/credentials/login')
 
 
 
 
 
 
 
 
1056
  ));
1057
- $place_id = $result->data->id;
1058
- }
1059
- catch (Exception $e) {
1060
- Mage::log($e->getMessage());
1061
- }
1062
 
1063
- // Product SOAP client
1064
- $soap_client = Mage::helper('cueconnect')->getSoapClient(
1065
- Mage::helper('cueconnect')->getWsUrl('product'),
1066
- $store->getConfig('cueconnect/credentials/login'),
1067
- $store->getConfig('cueconnect/credentials/password')
1068
- );
1069
 
1070
- // Get and delete Cue Connect product
1071
- try {
1072
- $result = $soap_client->get(array(
1073
- 'place_id' => $place_id,
1074
- 'sku' => $sku,
1075
- 'page' => 1,
1076
- 'page_size' => 1
1077
- ));
1078
- if ($result && isset($result->data) && isset($result->data[0]) && isset($result->inpagecount) && $result->inpagecount) {
1079
- $cueconnect_product = $result->data[0];
1080
- $soap_client->delete(array(
1081
- 'place_id' => $place_id,
1082
- 'data' => array($cueconnect_product->product_imic),
1083
- 'count' => 1
1084
  ));
 
1085
  }
1086
  }
1087
- catch (Exception $e) {
1088
- Mage::log($e->getMessage());
1089
- $message = Mage::helper('cueconnect')->__(
1090
- 'An error occurred while synchronization product data with Cueconnect for the %s store.
1091
- You can find more details in the log file',
1092
- $store->getName()
1093
- );
1094
- Mage::getSingleton('adminhtml/session')->addError($message);
1095
- }
1096
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1097
  }
 
 
1098
  }
 
 
1099
  }
21
 
22
  const SYNC_MASS_ACTION_NAME = 'cue_sync_mass_action';
23
 
24
+ /**
25
+ * Current Store Id
26
+ *
27
+ * @var string $_currentStoreId
28
+ */
29
  protected $_currentStoreId = false;
30
 
31
  /**
32
+ * Current Store Name
33
+ *
34
+ * @var string $_currentStoreName
35
  */
36
+ protected $_currentStoreName = false;
 
 
 
37
 
38
+ /**
39
+ * Errors messages
40
+ *
41
+ * @var array $_errors
42
+ */
43
+ protected $_errors = array();
44
 
 
 
45
 
46
+
47
+ /**########################################################################################################################
48
+ *
49
+ * List of Function for > CUE Configuration
50
+ *
51
+ * ########################################################################################################################
52
+ */
 
 
53
 
54
 
55
  /**
56
+ * @action : Cue tools Status Sycn (Magento -> Cue)
57
+ * @description : Sync tools status "enabled/disabled" with Cue
58
+ * @author : Imad.T - itouil@cueconnect.com
59
  * @param Varien_Event_Observer $observer
60
+ */
61
+ public function ConfigUpdated(Varien_Event_Observer $observer)
62
+ {
63
+
64
+ $storeId = Mage::app()
65
+ ->getWebsite(true)
66
+ ->getDefaultGroup()
67
+ ->getDefaultStoreId();
68
+ $store = Mage::getModel('core/store')->load($storeId);
69
+
70
+ if ($store) {
71
 
72
+ $post = Mage::app()->getRequest()->getPost();
73
+ $params['showMyList'] = $post['groups']['collection']['fields']['enabled']['value'];
74
+ $params['showShareButton'] = $post['groups']['ob']['fields']['enabled']['value'];
75
+ $params['showAddToWishlist'] = $post['groups']['favorite']['fields']['enabled']['value'];
76
+ $params['showPriceAlert'] = $post['groups']['alert']['fields']['enabled']['value'];
77
+ $params['showTracking'] = $post['groups']['tracking']['fields']['enabled']['inherit'];
78
+ $params['version'] =2;
79
 
80
+ $placeApiKey = $store->getConfig('cueconnect/credentials/api_key');
81
+ $str = "v2" . Mage::helper('cueconnect')->getWebhookConfigurationChangedKey() . Mage::helper('cueconnect')->getWebhookConfigurationChangedUrl() . $placeApiKey;
82
+ $key = sha1($str) . '$' . $placeApiKey;
83
 
84
+ // Submit config changes to Cue
85
+ $result = $this->_doRequest(Mage::helper('cueconnect')->getWebhookConfigurationChangedUrl(), $key, $params);
86
+ $soap_auth = Mage::helper('cueconnect')->getRetailer($store);
87
+ $retailerId = (int)$result;
88
+ // Check if API Key is valid
89
+ if($result === "0"){
90
+ // Say API key is wrong to the admin
91
+ $message = Mage::helper('cueconnect')->__(
92
+ 'Cue Authentication Failure : Incorrect API Key. Find your API Key by visiting www.cueconnect.com > Login > Code Implementation.',
93
+ $store->getName()
94
+ );
95
+ Mage::getSingleton('adminhtml/session')->addError($message);
96
+ }
97
+ elseif(!$soap_auth){
98
+ // Say SOAP Credentials are wrong to the admin
99
+ $message = Mage::helper('cueconnect')->__(
100
+ 'Cue Authentication Failure : Incorrect email or password. You can reset your password by visiting www.cueconnect.com > Forgot password',
101
+ $store->getName()
102
+ );
103
+ Mage::getSingleton('adminhtml/session')->addError($message);
104
+ }
105
+ elseif ($retailerId) {
106
+ Mage::getModel('core/config')->saveConfig('cueconnect/credentials/retailer_id', $retailerId);
107
+ Mage::app()->getCacheInstance()->cleanType('config');
108
+ }
109
 
 
 
110
  }
111
+ }
 
 
112
 
113
  /**
114
+ * @action : Cue tools Status Sycn (Magento -> Cue)
115
+ * @description : Check if Remote Sync Needed From Cue
116
+ * @author : Imad.T - itouil@cueconnect.com
117
+ * @param $action (products or customers)
118
+ * @return bool
119
  */
120
+ public function getRemoteSyncStatus($action = "products")
121
+ {
122
+ $storeId = Mage::app()
123
+ ->getWebsite(true)
124
+ ->getDefaultGroup()
125
+ ->getDefaultStoreId();
126
+ $store = Mage::getModel('core/store')->load($storeId);
127
 
128
+ if($store){
129
+
130
+ $params['version'] =2;
131
+ $params['sync_type'] = $action;
132
+ $params['remote_sync_check'] = true;
133
+
134
+ $placeApiKey = $store->getConfig('cueconnect/credentials/api_key');
135
+ $str = "v2" . Mage::helper('cueconnect')->getWebhookConfigurationChangedKey() . Mage::helper('cueconnect')->getWebhookConfigurationChangedUrl() . $placeApiKey;
136
+ $key = sha1($str) . '$' . $placeApiKey;
137
+
138
+ // Submit config changes to Cue
139
+
140
+ $result = $this->_doRequest(Mage::helper('cueconnect')->getWebhookConfigurationChangedUrl(), $key, $params);
141
+
142
+ if($result === "enabled") return true;
143
+ return false;
144
  }
145
+
146
  }
147
 
148
 
149
+ /**########################################################################################################################
150
+ *
151
+ * List of Function for > PRODUCT / MARK Synchronization with CUE
152
+ *
153
+ * ########################################################################################################################
154
  */
 
 
 
 
 
 
 
 
155
 
156
 
157
  /**
158
+ * @action : Individual product
159
+ * @description : Checked updated product SKU Before the event
160
+ * @author : Imad.T - itouil@cueconnect.com
161
+ * @param Varien_Event_Observer $observer
162
  */
163
+ public function productSkuChanges($observer)
164
  {
165
+ $product = $observer->getEvent()->getProduct();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
166
 
167
+ if ($product->hasDataChanges()) {
168
+ try {
169
+ /* @var string $newSku */
170
+ $newSku = ($product->getData('sku')) ? $product->getData('sku') : null;
171
+ /* @var string $oldSku */
172
+ $oldSku = ($product->getOrigData('sku')) ? $product->getOrigData('sku') : null;
173
 
174
+ if ($newSku && $oldSku && ($newSku != $oldSku)) {
175
+ Mage::register('old_product_sku', $oldSku);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
176
  }
177
+ } catch (Exception $e) {
178
+ Mage::log($e->getTraceAsString(), null, 'product_changes_fault.log');
179
  }
180
  }
181
  }
182
+
183
  /**
184
+ * @action : Multiple product
185
+ * @description : Sync updated products data with CUE on bulk product's attributes update (Magento -> Cue)
186
+ * @author : Imad.T - itouil@cueconnect.com
187
+ * @param Varien_Event_Observer $observer
188
+ * @return $this
189
+ * @support enabled
190
  */
191
+ public function productMassUpdate(Varien_Event_Observer $observer)
192
  {
 
 
 
 
 
193
 
194
+ $productIds = $observer->getProductIds();
195
+ $attributesData = $observer->getAttributesData();
196
+ $this->_syncMultipleProduct($productIds, $attributesData);
 
 
 
 
197
 
 
 
 
 
 
 
 
 
 
 
 
198
  }
199
 
200
  /**
201
+ * @action : Individual product
202
+ * @description : Update product in Cue when updated in Magento
203
+ * @author : Imad.T - itouil@cueconnect.com
204
  * @param Varien_Event_Observer $observer
205
+ * @support enabled
206
  */
207
+ public function productUpdated(Varien_Event_Observer $observer)
208
+ {
209
+
210
+ // Init vars
211
  $product = $observer->getEvent()->getProduct();
212
+ $old_sku = null;
213
 
214
+ // Check if SKU changed, if Yes grab
215
  if (Mage::registry('old_product_sku')) {
216
+ $old_sku = Mage::registry('old_product_sku');
217
  Mage::unregister('old_product_sku');
218
  }
219
+
220
+ // Get Store and its API Key
221
+ $storeids = $product->getStoreIds();
222
+ $store = Mage::getModel('core/store')->load($storeids[0]);
223
+ $placeApiKey = $store->getConfig('cueconnect/credentials/api_key');
224
 
225
+ if($placeApiKey){
226
 
227
+ // Generate the Auth Key
228
+ $str = $product->getSku() . Mage::helper('cueconnect')->getWebhookProductChangedKey() . Mage::helper('cueconnect')->getWebhookProductChangedUrl() . $product->getId();
229
  $key = sha1($str) . '$' . $placeApiKey;
230
 
231
+ // Generate Image data
232
  $width = Mage::getStoreConfig('cueconnect/image/width');
233
  $height = Mage::getStoreConfig('cueconnect/image/height');
 
234
  $image = 'https://www.cueconnect.com/images/no_image.gif';
235
  if ($product->getData('small_image') && $product->getData('small_image') !== 'no_selection') {
236
  $image = (string)Mage::helper('catalog/image')->init($product, 'small_image')->resize($width, $height);
237
  }
238
 
239
+ // Format Product Data
240
  $params = array(
241
  'id' => $product->getId(),
242
  'sku' => (string)$product->getSku(),
252
  'price' => number_format(Mage::helper('core')->currency($product->getPrice(), false, false), 2),
253
  );
254
 
255
+ if($old_sku) $params['old_sku'] = $old_sku;
256
 
257
+ // Get Cue WebHook URL
258
+ $url = Mage::helper('cueconnect')->getWebhookProductChangedUrl();
259
+ // Make request
260
+ $this->_doRequest($url, $key, $params);
261
+
262
+ }else{
263
+ // Say API key is wrong to the admin
264
+ $message = Mage::helper('cueconnect')->__(
265
+ 'Cue Connect authentication issue :: Go to System > Configuration > Under Catalog select Cue Connect, and set/verify your Cue credentials ',
266
+ $store->getName()
267
+ );
268
+ Mage::getSingleton('adminhtml/session')->addError($message);
269
+
270
+ // Send support request to Cue Support team
271
+ $cueModel = Mage::getModel('cueconnect/cueconnect');
272
+ $cueModel->sendEmailToSupport(
273
+ "Observer > productUpdated()",
274
+ $store->getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB),
275
+ $store->getName(),
276
+ Mage::getStoreConfig('cueconnect/credentials/retailer_id'),
277
+ Mage::getStoreConfig('cueconnect/credentials/login', $store->getId()),
278
+ "<br/>Debug<br/>placeApiKey Not defined"
279
+ );
280
  }
 
281
 
282
 
283
+ }
284
+
285
  /**
286
+ * @action : Individual product
287
+ * @description : delete product from e-List when deleted in Magento (Magento -> Cue)
288
+ * @author : Imad.T - itouil@cueconnect.com
289
  * @param Varien_Event_Observer $observer
290
  */
291
  public function deleteProduct(Varien_Event_Observer $observer)
292
  {
293
  // Get catalog product
294
+ $product = $observer->getEvent()->getProduct();
295
 
296
  // For each related stores
297
+ $storeids = $product->getStoreIds();
298
+ // Get store
299
+ $store = Mage::getModel('core/store')->load($storeids[0]);
 
 
 
 
 
 
 
300
 
301
+ if($store->getConfig('cueconnect/enabled/enabled')){
 
 
 
 
 
 
 
 
 
 
302
 
303
+ $placeApiKey = $store->getConfig('cueconnect/credentials/api_key');
304
+ $str = $product->getSku() . Mage::helper('cueconnect')->getWebhookProductDeletedKey() . Mage::helper('cueconnect')->getWebhookProductDeletedUrl() . $product->getId();
305
+ $key = sha1($str) . '$' . $placeApiKey;
306
+
307
+ $params = array(
308
+ 'id' => $product->getId(),
309
+ 'sku' => (string)$product->getSku()
310
+ );
311
+
312
+ $url = Mage::helper('cueconnect')->getWebhookProductDeletedUrl();
313
+ $this->_doRequest($url, $key, $params);
314
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
315
  }
316
+
317
  }
318
 
319
+ /**
320
+ * @action : Multiple product
321
+ * @description : Sync imported products data with CUE (Magento -> Cue)
322
+ * @author : Imad.T - itouil@cueconnect.com
323
+ * @param Varien_Event_Observer $observer
324
+ * @support enabled
325
+ */
326
+ public function productsImportUpdate(Varien_Event_Observer $observer)
327
+ {
328
+ $adapter = $observer->getEvent()->getAdapter();
329
+ $productIds = $adapter->getAffectedEntityIds();
330
+ $this->_syncMultipleProduct($productIds);
331
+
332
+ }
333
 
334
  /**
335
+ * @action : Multiple products
336
+ * @description : Sync updated products data with CUE
337
+ * @author : Imad.T - itouil@cueconnect.com
338
+ * @support enabled
339
  */
340
+ protected function _syncMultipleProduct($productIds, $attributesData = null){
 
 
 
 
 
 
 
 
 
 
 
341
 
342
+ if (count($productIds)) {
 
343
 
344
+ $productUpdateModel = Mage::getModel('cueconnect/cueconnect');
345
+ $productCollection = $productUpdateModel->getProductsByIds($productIds);
346
 
347
+ foreach ($productCollection as $product) {
348
 
349
+ // Get Store and its API Key
350
+ $storeids = $product->getStoreIds();
351
+ $store = Mage::getModel('core/store')->load($storeids[0]);
352
+ $placeApiKey = $store->getConfig('cueconnect/credentials/api_key');
 
 
 
 
 
 
 
353
 
354
+ if($placeApiKey){
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
355
 
356
+ // Generate the Auth Key
357
+ $str = $product->getSku() . Mage::helper('cueconnect')->getWebhookProductChangedKey() . Mage::helper('cueconnect')->getWebhookProductChangedUrl() . $product->getId();
358
+ $key = sha1($str) . '$' . $placeApiKey;
359
 
360
+ // Generate Image data
361
+ $width = Mage::getStoreConfig('cueconnect/image/width');
362
+ $height = Mage::getStoreConfig('cueconnect/image/height');
363
+ $image = 'https://www.cueconnect.com/images/no_image.gif';
364
+ if ($product->getData('small_image') && $product->getData('small_image') !== 'no_selection') {
365
+ $image = (string)Mage::helper('catalog/image')->init($product, 'small_image')->resize($width, $height);
366
+ }
367
 
368
+ // Format Product Data
369
+ $params = array(
370
+ 'id' => $product->getId(),
371
+ 'sku' => (string)$product->getSku(),
372
+ 'name' => $product->getName(),
373
+ 'description' => (string)$product->getDescription(),
374
+ 'brand' => (string)$product->getAttributeText('manufacturer'),
375
+ 'upc' => uniqid(),
376
+ 'sms_name' => $product->getName(),
377
+ 'sms_desc' => (string)$product->getDescription(),
378
+ 'url' => $product->getProductUrl(),
379
+ 'taxonomy_id' => Mage::getStoreConfig('cueconnect/taxomomy_id'),
380
+ 'image' => $image,
381
+ 'price' => number_format(Mage::helper('core')->currency($product->getPrice(), false, false), 2),
382
+ );
383
 
384
+ // Append new data if exist
385
+ if($attributesData){
386
+ foreach ($attributesData as $att_key => $att_value){
387
+ $params[$att_key] = $att_value;
388
+ }
389
+ }
 
390
 
 
 
391
 
392
+ // Get Cue WebHook URL
393
+ $url = Mage::helper('cueconnect')->getWebhookProductChangedUrl();
394
 
395
+ // Make request
396
+ $this->_doRequest($url, $key, $params);
397
 
398
+ }else{
399
+ // Say API key is wrong to the admin
400
+ $message = Mage::helper('cueconnect')->__(
401
+ 'Cue Connect authentication issue :: Go to System > Configuration > Under Catalog select Cue Connect, and set/verify your Cue credentials ',
402
+ $store->getName()
403
+ );
404
+ Mage::getSingleton('adminhtml/session')->addError($message);
405
+
406
+ // Send support request to Cue Support team
407
+ $cueModel = Mage::getModel('cueconnect/cueconnect');
408
+ $cueModel->sendEmailToSupport(
409
+ "Observer > _syncMultipleProduct()",
410
+ $store->getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB),
411
+ $store->getName(),
412
+ Mage::getStoreConfig('cueconnect/credentials/retailer_id'),
413
+ Mage::getStoreConfig('cueconnect/credentials/login', $store->getId()),
414
+ "<br/>Debug<br/>placeApiKey Not defined"
415
+ );
416
+ }
417
 
 
 
 
418
  }
419
 
420
+ }
 
 
 
 
 
 
 
 
 
 
421
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
422
  }
423
 
424
 
425
+ /**########################################################################################################################
426
+ *
427
+ * List of Function for > CUSTOMER Synchronization with CUE
428
+ *
429
+ * ########################################################################################################################
430
+ */
431
 
432
  /**
433
+ *
434
+ * @action : Multiple customers
435
+ * @description : Sync all customers with CUE
436
+ * @author : Imad.T - itouil@cueconnect.com
437
+ * @support enabled
438
+ * @return bool
439
  */
440
+ public function syncAllCustomers()
441
  {
 
 
 
 
442
 
443
+ $notSyncPrev = $this->checkNotSyncedCustomer();
444
+ $storeCollection = Mage::getModel('core/store')->getCollection()->setLoadDefault(true);
 
 
 
 
 
 
 
 
 
 
445
 
446
+ foreach ($storeCollection as $store) {
447
+ $this->_currentStoreId = $store->getId();
448
+ $this->_currentStoreName = $store->getName();
449
 
450
+ // return sync status for current store
451
+ $status = $this->_getCustomerSyncStatus($store);
 
452
 
453
+ // skip if customers sync for current store complete
454
+ if ($status == self::CUSTOMER_SYNC_COMPLETE) {
455
+ continue;
 
 
 
 
 
 
456
  }
457
 
458
+ // Skip all if customer sync is processing
459
+ if ($status == self::CUSTOMER_SYNC_PROCESSING) {
460
+ return false;
461
  }
 
 
462
 
463
+ // set $status processing for current store
464
+ $this->setCustomersSyncStatus(self::CUSTOMER_SYNC_PROCESSING);
465
+ $customerCollection = Mage::getModel('customer/customer')->getCollection()
466
+ ->addFieldToFilter('store_id', $this->_currentStoreId);
467
+ // start sync of customers with Cue
468
+ foreach ($customerCollection as $customer) {
469
+ $this->_syncCustomer($customer);
470
+ }
471
 
472
+ //check the cueconnect_user_sync and find the customers with status - STATUS_ERROR (2) after sync
473
+ $notSyncUserIds = $this->checkNotSyncedCustomer();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
474
 
475
+ if (count($notSyncPrev) < count($notSyncUserIds)) {
476
+ $error_msg = '';
477
+ if (count($this->_errors)) {
478
+ $error_msg = 'Errors: ' . '<br/>';
479
+ $number = 1;
480
+ foreach ($this->_errors as $error) {
481
+ $error_msg .= $number . '. ' . $error . '<br/>';
482
+ ++$number;
483
  }
484
  }
 
485
 
486
+ // Send support request to Cue Support team
487
+ $cueModel = Mage::getModel('cueconnect/cueconnect');
488
+ $cueModel->sendEmailToSupport(
489
+ "Observer > syncAllCustomers()",
490
+ $store->getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB),
491
+ $store->getName(),
492
+ Mage::getStoreConfig('cueconnect/credentials/retailer_id'),
493
+ Mage::getStoreConfig('cueconnect/credentials/login', $store->getId()),
494
+ "<br/>Debug<br/>$error_msg"
495
+ );
 
 
496
 
 
 
 
 
 
 
 
 
 
 
497
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
498
  }
 
499
 
500
+ $notSyncPrev = $notSyncUserIds;
 
501
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
502
  }
 
503
 
 
 
 
 
 
 
 
 
 
 
 
504
  }
505
 
506
  /**
507
+ * @description : Get customer Sync status for the store.
508
+ * @author : Imad.T - itouil@cueconnect.com
509
+ * @return mixed
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
510
  */
511
+ protected function _getCustomerSyncStatus($store)
512
  {
513
+ $path = sprintf(self::XML_PATH_CUSTOMER_SYNC_STATUS, $store->getId());
514
+ $status = $store->getConfig($path);
 
515
 
516
+ return $status;
517
  }
518
 
519
  /**
 
 
 
520
  *
521
+ * @action : Single customers
522
+ * @description : flag local user as synced and create Cue user
523
+ * @author : Imad.T - itouil@cueconnect.com
524
+ * @support enabled
525
+ * @param Mage_Customer_Model_Customer $customer
526
+ * @return bool
527
  */
528
+ protected function _syncCustomer($customer)
529
  {
 
 
 
 
 
 
 
 
530
 
531
+ if ($customer) {
532
+ $this->createCueUser($customer);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
533
  }
 
 
534
  }
535
 
536
  /**
537
+ * @action : Single customers
538
+ * @description : Sync user with Cue
539
+ * @author : Imad.T - itouil@cueconnect.com
540
+ * @param Mage_Customer_Model_Customer $customer
541
  * @return bool
542
  */
543
+ protected function createCueUser($customer) {
 
 
 
 
 
 
 
 
 
 
544
 
545
+ if ($customer) {
 
 
546
 
547
+ $storeId = $customer->getStoreId();
 
 
 
 
 
 
 
 
548
 
549
+ if (!$storeId && $this->_currentStoreId ) {
550
+ $storeId = $this->_currentStoreId;
 
551
  }
552
+ if (!$storeId) {
553
+ $storeId = Mage::app()->getStore()->getStoreId();
 
554
  }
555
+ if (!$storeId) {
556
+ $storeId = Mage::app()->getDefaultStoreView()->getStoreId();
 
 
 
 
 
557
  }
558
 
559
+ $store = Mage::getModel('core/store')->load($storeId);
560
+ $placeApiKey = $store->getConfig('cueconnect/credentials/api_key');
561
 
562
+ $str = Mage::helper('cueconnect')->getWebhookSaveCustomerKey() . Mage::helper('cueconnect')->getWebhookSaveCustomerUrl() . $customer->getId() . $customer->getEmail();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
563
 
564
+ $key = sha1($str) . '$' . $placeApiKey;
 
 
 
 
 
 
 
 
 
565
 
566
+ $params = array(
567
+ 'storeId' => $storeId,
568
+ 'id' => $customer->getId(),
569
+ 'email' => $customer->getEmail(),
570
+ 'fullName' => $customer->getName(),
571
+ 'firstName' => $customer->getFirstname(),
572
+ 'lastName' => $customer->getLastname(),
573
+ 'created' => $customer->getCreatedAt(),
574
+ 'dob' => $customer->getDob(),
575
+ 'gender' => $customer->getGender(),
576
+ );
577
+
578
+ $url = Mage::helper('cueconnect')->getWebhookSaveCustomerUrl();
579
+
580
+ $response = $this->_doRequest($url, $key, $params);
581
 
582
+ return $response;
583
  }
 
584
 
585
+ return null;
586
+ }
587
 
588
  /**
589
+ * @action : Single customers
590
+ * @description : check the cueconnect_user_sync and find the customers with status - STATUS_ERROR (2)
591
+ * @author : Imad.T - itouil@cueconnect.com
592
  */
593
  public function checkNotSyncedCustomer()
594
  {
605
  }
606
 
607
  /**
608
+ * @description : Set and save customers sync status for the store
609
+ * @author : Imad.T - itouil@cueconnect.com
610
  * @param string $value
611
  */
612
  protected function setCustomersSyncStatus($value)
617
  }
618
 
619
  /**
620
+ * @description : Remove schedule customer Sync. Set flat to 0
621
+ * @author : Imad.T - itouil@cueconnect.com
622
  */
623
  public function removeScheduleCustomerSync()
624
  {
628
  }
629
 
630
  /**
631
+ * @description : Schedule customer Sync. Set flat to 1
632
+ * @author : Imad.T - itouil@cueconnect.com
 
633
  */
634
+ public function scheduleCustomerSync()
635
  {
636
+ Mage::getModel('core/config')->saveConfig(self::XML_PATH_CUSTOMER_SYNC_SCHEDULED, 1);
637
+ Mage::app()->getCacheInstance()->cleanType('config');
 
 
638
  }
639
 
640
+ /*### To be reviewed ###*/
641
  /**
642
  * Check customer sync status for the stores, return true when resync should be running.
643
+ * @todo: to remove with /Cue/Block/System/Config/Customerresync.php
644
  * @return bool
645
  */
646
  public function isCustomerReSyncNeeded()
675
  }
676
 
677
  /**
678
+ * accessing e-List - used to sync saved items to Cue if not already done
679
+ * @param Varien_Event_Observer $observer
680
  */
681
+ public function viewElist(Varien_Event_Observer $observer) {
682
+ if (Mage::getSingleton('customer/session')->isLoggedIn()) {
683
+ $event = $observer->getEvent();
684
+ $customer = $event->getCustomer();
685
+
686
+ if ($customer) {
687
+ $wishList = Mage::getModel('wishlist/wishlist')->loadByCustomer($customer);
688
+
689
+ if ($wishList) {
690
+ $wishListItemCollection = $wishList->getItemCollection();
691
+
692
+ if (count($wishListItemCollection)) {
693
+ foreach ($wishListItemCollection as $item) {
694
+ $this->_syncMark($item->getProduct(), $item->getDescription(), $customer);
695
+ }
696
+ }
697
+ }
698
+ }
699
+ }
700
+ }
701
+
702
+ /**
703
+ * Get order ids for the multishipping checkout, add it to session
704
+ * @todo: to review
705
+ * @param Varien_Event_Observer $observer
706
+ */
707
+ public function getOrderIds(Varien_Event_Observer $observer)
708
  {
709
+ $orderIds = $observer->getOrderIds();
710
+ if ($orderIds && count($orderIds)) {
711
+ Mage::getSingleton('checkout/session')->setFirstOrderId($orderIds[0]);
712
+ }
713
  }
714
 
715
  /**
716
+ * sync customer account with Cue account after login
717
+ * @param Varien_Event_Observer $observer
718
+ */
719
+ public function customerLogin(Varien_Event_Observer $observer) {
720
+ if (Mage::getSingleton('customer/session')->isLoggedIn()) {
721
+ $event = $observer->getEvent();
722
+ $customer = $event->getCustomer();
723
+
724
+ if ($customer) {
725
+ $this->_syncCustomer($customer);
726
+ }
727
+ }
728
+ }
729
+
730
+ /**
731
+ * sync magento customer profile with cue user (Magento -> Cue)
732
+ * @param Varien_Event_Observer $observer
733
+ */
734
+ public function customerSaveProfile(Varien_Event_Observer $observer) {
735
+ $event = $observer->getEvent();
736
+ $customer = $event->getCustomer();
737
+
738
+ if ($customer) {
739
+ $this->_syncCustomer($customer);
740
+ }
741
+ }
742
+
743
+ /**########################################################################################################################
744
  *
745
+ * List of Local Functions
746
+ *
747
+ * ########################################################################################################################
748
+ */
749
+
750
+
751
+ /**
752
+ * @description : Request to send data to Cue Connect
753
+ * @author : Imad.T - itouil@cueconnect.com
754
+ * @param string $url
755
+ * @param string $key
756
+ * @param array $params
757
+ * @return array
758
  */
759
+ protected function _doRequest($url, $key, $params)
760
  {
761
+ $response = null;
762
+
763
+ // do POST - use curl
764
+ if (function_exists('curl_version')) {
765
 
 
766
  try {
767
+ $ch = curl_init();
768
+ curl_setopt($ch, CURLOPT_URL, $url);
769
+ curl_setopt($ch, CURLOPT_HEADER, 0);
770
+ curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
771
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
772
+ curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
773
+ curl_setopt($ch, CURLOPT_HTTPHEADER,array('X-Cue-Mage-Auth: ' . $key));
774
+
775
+ $response = curl_exec($ch);
776
+ $httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
777
+
778
+ curl_close($ch);
779
 
 
 
 
780
  } catch (Exception $e) {
781
+ $message = $e->getMessage();
782
+ Mage::log($message);
783
+ $this->_errors[] = $message;
784
+ }
785
+ }
786
+ // do GET
787
+ else {
788
+
789
+ $params['key'] = $key;
790
+ $queryString = '?' . http_build_query($params);
791
+
792
+ try {
793
+ $response = file_get_contents($url . $queryString);
794
+ } catch (Exception $e) {
795
+ $message = $e->getMessage();
796
+ Mage::log($message);
797
+ $this->_errors[] = $message;
798
  }
799
  }
800
+
801
+ return $response;
802
  }
803
 
804
  /**
805
+ * Copy native wishlist items to e-List saves when accessing e-List for first time
806
+ * @author : Imad.T - itouil@cueconnect.com
807
+ * @param [type] $product
808
+ * @param [type] $description
809
+ * @param [type] $customer
810
+ * @todo: To review
811
  */
812
+ protected function _syncMark($product, $description, $customer)
813
  {
814
+ if ($customer && $product) {
815
+ $exception = false;
816
+ $wishlistSyncModel = Mage::getModel('cueconnect/wishlistSync');
 
 
 
 
 
 
 
 
817
 
818
+ if ($wishlistSyncModel) {
819
+ $row = $wishlistSyncModel->getCollection()
820
+ ->addFieldToFilter('product_id', $product->getId())
821
+ ->addFieldToFilter('customer_id', $customer->getId())
822
+ ->addFieldToFilter('status', $wishlistSyncModel::STATUS_DONE)
823
+ ->getFirstItem();
824
+
825
+ if (!$row->getData()) {
826
+ $wishlistSyncModel->setData(array(
827
+ 'customer_id' => $customer->getId(),
828
+ 'product_id' => $product->getId(),
829
+ 'status' => $wishlistSyncModel::STATUS_WAITING,
830
+ 'created_at' => date('Y-m-d H:i:s')
831
  ));
 
 
 
 
 
832
 
833
+ $id = $wishlistSyncModel->save()->getId();
 
 
 
 
 
834
 
835
+ // sync product/customer
836
+ $response = $this->createCueProduct($product, $description, $customer);
837
+ $exception = ($response != 1);
838
+
839
+ // update status
840
+ $row = $wishlistSyncModel->load($id);
841
+ if ($row->getData()) {
842
+ $row->addData(array(
843
+ 'status' => ($response) ? $wishlistSyncModel::STATUS_DONE : $wishlistSyncModel::STATUS_ERROR,
 
 
 
 
 
844
  ));
845
+ $row->save();
846
  }
847
  }
 
 
 
 
 
 
 
 
 
848
  }
849
+
850
+ // if unable to save local flag, then sync product/customer with Cue anyway => this means the op will be executed each time we access eList
851
+ if ($exception) {
852
+ $this->createCueProduct($product, $customer);
853
+ }
854
+ }
855
+ }
856
+
857
+ /**
858
+ * Create product
859
+ * @todo: To remove with _syncMark()
860
+ * @param $product
861
+ * @param $description
862
+ * @param $customer
863
+ *
864
+ * @return null
865
+ */
866
+ protected function createCueProduct($product, $description, $customer)
867
+ {
868
+ if ($product && $customer) {
869
+ $storeId = $customer->getStoreId();
870
+ if (!$storeId) {
871
+ $storeId = Mage::app()->getStore()->getStoreId();
872
+ }
873
+
874
+ $store = Mage::getModel('core/store')->load($storeId);
875
+ $placeApiKey = $store->getConfig('cueconnect/credentials/api_key');
876
+
877
+ $str = Mage::helper('cueconnect')->getWebhookSaveMarkKey() . Mage::helper('cueconnect')->getWebhookSaveMarkUrl() . $customer->getId() . $customer->getEmail();
878
+
879
+ $key = sha1($str) . '$' . $placeApiKey;
880
+
881
+ $width = Mage::getStoreConfig('cueconnect/image/width');
882
+ $height = Mage::getStoreConfig('cueconnect/image/height');
883
+
884
+ $image = 'https://www.cueconnect.com/images/no_image.gif';
885
+ if ($product->getData('small_image') && $product->getData('small_image') !== 'no_selection') {
886
+ $image = (string)Mage::helper('catalog/image')->init($product, 'small_image')->resize($width, $height);
887
+ }
888
+
889
+ $params = array(
890
+ // customer
891
+ 'storeId' => $storeId,
892
+ 'id' => $customer->getId(),
893
+ 'email' => $customer->getEmail(),
894
+ 'fullName' => $customer->getName(),
895
+ 'firstName' => $customer->getFirstname(),
896
+ 'lastName' => $customer->getLastname(),
897
+ 'created' => $customer->getCreatedAt(),
898
+ 'dob' => $customer->getDob(),
899
+ 'gender' => $customer->getGender(),
900
+
901
+ // product
902
+ 'sku' => (string)$product->getSku(),
903
+ 'name' => $product->getName(),
904
+ 'description' => (string)$product->getDescription(),
905
+ 'comment' => (string)$description,
906
+ 'brand' => (string)$product->getAttributeText('manufacturer'),
907
+ 'upc' => uniqid(),
908
+ 'sms_name' => $product->getName(),
909
+ 'sms_desc' => (string)$product->getDescription(),
910
+ 'url' => $product->getProductUrl(),
911
+ 'taxonomy_id' => Mage::getStoreConfig('cueconnect/taxomomy_id'),
912
+ 'image' => $image,
913
+ 'live' => '1',
914
+ 'price' => number_format(Mage::helper('core')->currency($product->getPrice(), false, false), 2),
915
+ );
916
+
917
+ $url = Mage::helper('cueconnect')->getWebhookSaveMarkUrl();
918
+ $response = $this->_doRequest($url, $key, $params);
919
+
920
+ return $response;
921
  }
922
+
923
+ return null;
924
  }
925
+
926
+
927
  }
app/code/community/CueConnect/Cue/controllers/ElistController.php CHANGED
@@ -15,10 +15,6 @@ class CueConnect_Cue_ElistController extends Mage_Core_Controller_Front_Action
15
  * View export progression and last asked exports
16
  */
17
  public function indexAction() {
18
- // if PB, redirect to home page - only CP is allowed here
19
- if (1 == Mage::helper('cueconnect')->getElistMode()) {
20
- Mage::app()->getResponse()->setRedirect(Mage::getBaseUrl());
21
- }
22
 
23
  if (!Mage::getSingleton('customer/session')->isLoggedIn()){
24
  Mage::getSingleton('customer/session')->setBeforeAuthUrl(Mage::helper('core/url')->getCurrentUrl());
15
  * View export progression and last asked exports
16
  */
17
  public function indexAction() {
 
 
 
 
18
 
19
  if (!Mage::getSingleton('customer/session')->isLoggedIn()){
20
  Mage::getSingleton('customer/session')->setBeforeAuthUrl(Mage::helper('core/url')->getCurrentUrl());
app/code/community/CueConnect/Cue/etc/config.xml CHANGED
@@ -2,7 +2,7 @@
2
  <config>
3
  <modules>
4
  <CueConnect_Cue>
5
- <version>3.0.19</version>
6
  </CueConnect_Cue>
7
  </modules>
8
  <global>
@@ -59,24 +59,6 @@
59
  </cueconnect_read>
60
  </resources>
61
  <events>
62
- <catalog_product_save_after>
63
- <observers>
64
- <cueconnect_cue_observer_update_product>
65
- <type>singleton</type>
66
- <class>CueConnect_Cue_Model_Observer</class>
67
- <method>updateProduct</method>
68
- </cueconnect_cue_observer_update_product>
69
- </observers>
70
- </catalog_product_save_after>
71
- <catalog_product_delete_before>
72
- <observers>
73
- <cueconnect_cue_observer_delete_product>
74
- <type>singleton</type>
75
- <class>CueConnect_Cue_Model_Observer</class>
76
- <method>deleteProduct</method>
77
- </cueconnect_cue_observer_delete_product>
78
- </observers>
79
- </catalog_product_delete_before>
80
  <customer_register_success>
81
  <observers>
82
  <cueconnect_cue_customer_register_success>
@@ -108,7 +90,7 @@
108
  <observers>
109
  <cueconnect_cue>
110
  <class>cueconnect/observer</class>
111
- <method>addToTopmenu</method>
112
  </cueconnect_cue>
113
  </observers>
114
  </page_block_html_topmenu_gethtml_before>
@@ -206,43 +188,46 @@
206
  <cueconnect_cue_version_change>
207
  <type>singleton</type>
208
  <class>CueConnect_Cue_Model_Observer</class>
209
- <method>adminCueConnectUpdated</method>
210
  </cueconnect_cue_version_change>
211
  </observers>
212
  </admin_system_config_changed_section_cueconnect>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
213
  <catalog_product_save_after>
214
  <observers>
215
  <cueconnect_cue_product_update>
216
  <type>singleton</type>
217
  <class>CueConnect_Cue_Model_Observer</class>
218
- <method>adminProductUpdated</method>
219
  </cueconnect_cue_product_update>
220
  </observers>
221
  </catalog_product_save_after>
222
- <catalog_product_attribute_update_after>
223
  <observers>
224
  <cueconnect_cue_product_update_attribute_after>
225
  <class>cueconnect/observer</class>
226
  <method>productMassUpdate</method>
227
  </cueconnect_cue_product_update_attribute_after>
228
  </observers>
229
- </catalog_product_attribute_update_after>
230
- <catalog_product_website_update>
231
- <observers>
232
- <cueconnect_cue_product_update_website_after>
233
- <class>cueconnect/observer</class>
234
- <method>productMassUpdate</method>
235
- </cueconnect_cue_product_update_website_after>
236
- </observers>
237
- </catalog_product_website_update>
238
- <catalog_product_stock_item_mass_change>
239
- <observers>
240
- <cueconnect_cue_product_update_stock_after>
241
- <class>cueconnect/observer</class>
242
- <method>productStockMassUpdate</method>
243
- </cueconnect_cue_product_update_stock_after>
244
- </observers>
245
- </catalog_product_stock_item_mass_change>
246
  <catalog_product_import_finish_before>
247
  <observers>
248
  <cueconnect_cue_product_import_finish_before>
@@ -251,15 +236,7 @@
251
  </cueconnect_cue_product_import_finish_before>
252
  </observers>
253
  </catalog_product_import_finish_before>
254
- <catalog_product_save_before>
255
- <observers>
256
- <cueconnect_cue_product_changes>
257
- <type>singleton</type>
258
- <class>cueconnect/observer</class>
259
- <method>detectProductSkuChanges</method>
260
- </cueconnect_cue_product_changes>
261
- </observers>
262
- </catalog_product_save_before>
263
  </events>
264
  </adminhtml>
265
  <default>
@@ -285,9 +262,9 @@
285
  <tracking>
286
  <enabled>1</enabled>
287
  </tracking>
288
- <webservice>
289
- <url>http://rapi.cueconnect.com/</url>
290
- </webservice>
291
  <taxomomy_id>fcc3465</taxomomy_id>
292
  <image>
293
  <width>480</width>
@@ -298,26 +275,30 @@
298
  </path>
299
  <webhook>
300
  <save_customer>
301
- <url>https://business.cueconnect.com/magento/saveCustomer</url>
302
  <key>026132282952ccf731a765413bf11ca32ccbc683ab92c7ad3171b2a0a71ef21d69d1334efcf79da5ecc2d496221e0e28ed025e71d210ebf16e70bfa338c4f2d3</key>
303
  </save_customer>
304
  <save_mark>
305
- <url>https://business.cueconnect.com/magento/saveMark</url>
306
  <key>bf83fc65e0e710e68e17c811bdb6e5d48ea2e805d8fc4af3ac9c8c428631fa044fa6509f128e6891b6d5e8df54508e045b53d95289d72f2f46d98499286772ca</key>
307
  </save_mark>
308
- <price_changed>
309
- <url>https://business.cueconnect.com/magento/priceChanged</url>
 
 
 
 
310
  <key>f7ba9544bdded1d3a1aead3cb43557b340bf69ce1919a94e7282bfe11f573c94ffc375bf778bc374677c8150ae3880e9fa1502bb5e4235d7628e1ed3e95a6895</key>
311
- </price_changed>
312
- <select_version>
313
- <url>https://business.cueconnect.com/magento/selectVersion</url>
314
  <key>a2645def81375a4f88475acc6b4b0639fd87bfaef715b828e1704f79bac6262ef0e85876dd7047765360678b3372812b5f1741b3abfe9159a3d50fe01e05d757</key>
315
- </select_version>
316
  </webhook>
317
  <support>
318
  <email>dev@cueconnect.com</email>
319
  <name>CUE support</name>
320
- <subject>Synchronization has failed</subject>
321
  </support>
322
  </cueconnect>
323
  </default>
2
  <config>
3
  <modules>
4
  <CueConnect_Cue>
5
+ <version>3.0.23</version>
6
  </CueConnect_Cue>
7
  </modules>
8
  <global>
59
  </cueconnect_read>
60
  </resources>
61
  <events>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
62
  <customer_register_success>
63
  <observers>
64
  <cueconnect_cue_customer_register_success>
90
  <observers>
91
  <cueconnect_cue>
92
  <class>cueconnect/observer</class>
93
+ <method>enableMyListLink</method>
94
  </cueconnect_cue>
95
  </observers>
96
  </page_block_html_topmenu_gethtml_before>
188
  <cueconnect_cue_version_change>
189
  <type>singleton</type>
190
  <class>CueConnect_Cue_Model_Observer</class>
191
+ <method>ConfigUpdated</method>
192
  </cueconnect_cue_version_change>
193
  </observers>
194
  </admin_system_config_changed_section_cueconnect>
195
+
196
+ <catalog_product_delete_before>
197
+ <observers>
198
+ <cueconnect_cue_observer_delete_product>
199
+ <type>singleton</type>
200
+ <class>CueConnect_Cue_Model_Observer</class>
201
+ <method>deleteProduct</method>
202
+ </cueconnect_cue_observer_delete_product>
203
+ </observers>
204
+ </catalog_product_delete_before>
205
+ <catalog_product_save_before>
206
+ <observers>
207
+ <cueconnect_cue_product_changes>
208
+ <type>singleton</type>
209
+ <class>cueconnect/observer</class>
210
+ <method>productSkuChanges</method>
211
+ </cueconnect_cue_product_changes>
212
+ </observers>
213
+ </catalog_product_save_before>
214
  <catalog_product_save_after>
215
  <observers>
216
  <cueconnect_cue_product_update>
217
  <type>singleton</type>
218
  <class>CueConnect_Cue_Model_Observer</class>
219
+ <method>productUpdated</method>
220
  </cueconnect_cue_product_update>
221
  </observers>
222
  </catalog_product_save_after>
223
+ <catalog_product_attribute_update_before>
224
  <observers>
225
  <cueconnect_cue_product_update_attribute_after>
226
  <class>cueconnect/observer</class>
227
  <method>productMassUpdate</method>
228
  </cueconnect_cue_product_update_attribute_after>
229
  </observers>
230
+ </catalog_product_attribute_update_before>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
231
  <catalog_product_import_finish_before>
232
  <observers>
233
  <cueconnect_cue_product_import_finish_before>
236
  </cueconnect_cue_product_import_finish_before>
237
  </observers>
238
  </catalog_product_import_finish_before>
239
+
 
 
 
 
 
 
 
 
240
  </events>
241
  </adminhtml>
242
  <default>
262
  <tracking>
263
  <enabled>1</enabled>
264
  </tracking>
265
+ <carttracking>
266
+ <url>/imi/cart_track/json</url>
267
+ </carttracking>
268
  <taxomomy_id>fcc3465</taxomomy_id>
269
  <image>
270
  <width>480</width>
275
  </path>
276
  <webhook>
277
  <save_customer>
278
+ <url>/magento/saveCustomer</url>
279
  <key>026132282952ccf731a765413bf11ca32ccbc683ab92c7ad3171b2a0a71ef21d69d1334efcf79da5ecc2d496221e0e28ed025e71d210ebf16e70bfa338c4f2d3</key>
280
  </save_customer>
281
  <save_mark>
282
+ <url>/magento/saveMark</url>
283
  <key>bf83fc65e0e710e68e17c811bdb6e5d48ea2e805d8fc4af3ac9c8c428631fa044fa6509f128e6891b6d5e8df54508e045b53d95289d72f2f46d98499286772ca</key>
284
  </save_mark>
285
+ <product_changed>
286
+ <url>/magento/productChanged</url>
287
+ <key>f7ba9544bdded1d3a1aead3cb43557b340bf69ce1919a94e7282bfe11f573c94ffc375bf778bc374677c8150ae3880e9fa1502bb5e4235d7628e1ed3e95a6895</key>
288
+ </product_changed>
289
+ <product_deleted>
290
+ <url>/magento/productDeleted</url>
291
  <key>f7ba9544bdded1d3a1aead3cb43557b340bf69ce1919a94e7282bfe11f573c94ffc375bf778bc374677c8150ae3880e9fa1502bb5e4235d7628e1ed3e95a6895</key>
292
+ </product_deleted>
293
+ <configuration_changed>
294
+ <url>/magento/configurationChanged</url>
295
  <key>a2645def81375a4f88475acc6b4b0639fd87bfaef715b828e1704f79bac6262ef0e85876dd7047765360678b3372812b5f1741b3abfe9159a3d50fe01e05d757</key>
296
+ </configuration_changed>
297
  </webhook>
298
  <support>
299
  <email>dev@cueconnect.com</email>
300
  <name>CUE support</name>
301
+ <subject>Synchronization has failed for </subject>
302
  </support>
303
  </cueconnect>
304
  </default>
app/code/community/CueConnect/Cue/etc/config.xml_backup DELETED
@@ -1,327 +0,0 @@
1
- <?xml version="1.0"?>
2
- <config>
3
- <modules>
4
- <CueConnect_Cue>
5
- <version>3.0.19</version>
6
- </CueConnect_Cue>
7
- </modules>
8
- <global>
9
- <models>
10
- <cueconnect>
11
- <class>CueConnect_Cue_Model</class>
12
- <resourceModel>cueconnect_mysql4</resourceModel>
13
- </cueconnect>
14
- <cueconnect_mysql4>
15
- <class>CueConnect_Cue_Model_Mysql4</class>
16
- <entities>
17
- <demand>
18
- <table>cueconnect_demand</table>
19
- </demand>
20
- <userSync>
21
- <table>cueconnect_user_sync</table>
22
- </userSync>
23
- <wishlistSync>
24
- <table>cueconnect_wishlist_sync</table>
25
- </wishlistSync>
26
- </entities>
27
- </cueconnect_mysql4>
28
- </models>
29
- <blocks>
30
- <cueconnect>
31
- <class>CueConnect_Cue_Block</class>
32
- </cueconnect>
33
- </blocks>
34
- <helpers>
35
- <cueconnect>
36
- <class>CueConnect_Cue_Helper</class>
37
- </cueconnect>
38
- <wishlist>
39
- <rewrite>
40
- <data>CueConnect_Cue_Helper_Wishlist_Data</data> <!-- tell magento to use your own helper instead of the default one -->
41
- </rewrite>
42
- </wishlist>
43
- </helpers>
44
- <resources>
45
- <cueconnect_setup>
46
- <setup>
47
- <module>CueConnect_Cue</module>
48
- </setup>
49
- </cueconnect_setup>
50
- <cueconnect_write>
51
- <connection>
52
- <use>core_write</use>
53
- </connection>
54
- </cueconnect_write>
55
- <cueconnect_read>
56
- <connection>
57
- <use>core_read</use>
58
- </connection>
59
- </cueconnect_read>
60
- </resources>
61
- <events>
62
- <catalog_product_save_after>
63
- <observers>
64
- <cueconnect_cue_observer_update_product>
65
- <type>singleton</type>
66
- <class>CueConnect_Cue_Model_Observer</class>
67
- <method>updateProduct</method>
68
- </cueconnect_cue_observer_update_product>
69
- </observers>
70
- </catalog_product_save_after>
71
- <catalog_product_delete_before>
72
- <observers>
73
- <cueconnect_cue_observer_delete_product>
74
- <type>singleton</type>
75
- <class>CueConnect_Cue_Model_Observer</class>
76
- <method>deleteProduct</method>
77
- </cueconnect_cue_observer_delete_product>
78
- </observers>
79
- </catalog_product_delete_before>
80
- <customer_register_success>
81
- <observers>
82
- <cueconnect_cue_customer_register_success>
83
- <type>singleton</type>
84
- <class>CueConnect_Cue_Model_Observer</class>
85
- <method>customerSaveProfile</method>
86
- </cueconnect_cue_customer_register_success>
87
- </observers>
88
- </customer_register_success>
89
- <customer_save_after>
90
- <observers>
91
- <cueconnect_cue_customer_save_after>
92
- <type>singleton</type>
93
- <class>CueConnect_Cue_Model_Observer</class>
94
- <method>customerSaveProfile</method>
95
- </cueconnect_cue_customer_save_after>
96
- </observers>
97
- </customer_save_after>
98
- <elist_view>
99
- <observers>
100
- <cueconnect_cue_elist_view>
101
- <type>singleton</type>
102
- <class>CueConnect_Cue_Model_Observer</class>
103
- <method>viewElist</method>
104
- </cueconnect_cue_elist_view>
105
- </observers>
106
- </elist_view>
107
- <page_block_html_topmenu_gethtml_before>
108
- <observers>
109
- <cueconnect_cue>
110
- <class>cueconnect/observer</class>
111
- <method>addToTopmenu</method>
112
- </cueconnect_cue>
113
- </observers>
114
- </page_block_html_topmenu_gethtml_before>
115
- <checkout_multishipping_controller_success_action>
116
- <observers>
117
- <cueconnect_cue_multishipping_get_order_ids>
118
- <class>cueconnect/observer</class>
119
- <method>getOrderIds</method>
120
- </cueconnect_cue_multishipping_get_order_ids>
121
- </observers>
122
- </checkout_multishipping_controller_success_action>
123
- </events>
124
- <rewrite>
125
- <elist_url>
126
- <from><![CDATA[#^/apps/mylist(\/)*$#]]></from>
127
- <to><![CDATA[/cueconnect/elist/index]]></to>
128
- <complete>1</complete>
129
- </elist_url>
130
- </rewrite>
131
- </global>
132
- <frontend>
133
- <layout>
134
- <updates>
135
- <cueconnect module="cueconnect">
136
- <file>cueconnect.xml</file>
137
- </cueconnect>
138
- </updates>
139
- </layout>
140
- <routers>
141
- <cueconnect>
142
- <use>standard</use>
143
- <args>
144
- <module>CueConnect_Cue</module>
145
- <frontName>elist</frontName>
146
- </args>
147
- </cueconnect>
148
- </routers>
149
- <events>
150
- <customer_login>
151
- <observers>
152
- <cueconnect_cue_customer_login>
153
- <type>model</type>
154
- <class>CueConnect_Cue_Model_Observer</class>
155
- <method>customerLogin</method>
156
- </cueconnect_cue_customer_login>
157
- </observers>
158
- </customer_login>
159
- </events>
160
- </frontend>
161
- <admin>
162
- <routers>
163
- <cueconnect>
164
- <use>admin</use>
165
- <args>
166
- <module>CueConnect_Cue</module>
167
- <frontName>cueconnect</frontName>
168
- </args>
169
- </cueconnect>
170
- </routers>
171
- </admin>
172
- <adminhtml>
173
- <acl>
174
- <resources>
175
- <all>
176
- <title>Allow Everything</title>
177
- </all>
178
- <admin>
179
- <children>
180
- <system>
181
- <children>
182
- <config>
183
- <children>
184
- <cueconnect translate="title" module="cueconnect">
185
- <title>Cue - All</title>
186
- <sort_order>100</sort_order>
187
- </cueconnect>
188
- </children>
189
- </config>
190
- </children>
191
- </system>
192
- </children>
193
- </admin>
194
- </resources>
195
- </acl>
196
- <layout>
197
- <updates>
198
- <cueconnect module="cueconnect">
199
- <file>cueconnect.xml</file>
200
- </cueconnect>
201
- </updates>
202
- </layout>
203
- <events>
204
- <admin_system_config_changed_section_cueconnect>
205
- <observers>
206
- <cueconnect_cue_version_change>
207
- <type>singleton</type>
208
- <class>CueConnect_Cue_Model_Observer</class>
209
- <method>adminCueConnectUpdated</method>
210
- </cueconnect_cue_version_change>
211
- </observers>
212
- </admin_system_config_changed_section_cueconnect>
213
- <catalog_product_save_after>
214
- <observers>
215
- <cueconnect_cue_product_update>
216
- <type>singleton</type>
217
- <class>CueConnect_Cue_Model_Observer</class>
218
- <method>adminProductUpdated</method>
219
- </cueconnect_cue_product_update>
220
- </observers>
221
- </catalog_product_save_after>
222
- <catalog_product_attribute_update_after>
223
- <observers>
224
- <cueconnect_cue_product_update_attribute_after>
225
- <class>cueconnect/observer</class>
226
- <method>productMassUpdate</method>
227
- </cueconnect_cue_product_update_attribute_after>
228
- </observers>
229
- </catalog_product_attribute_update_after>
230
- <catalog_product_website_update>
231
- <observers>
232
- <cueconnect_cue_product_update_website_after>
233
- <class>cueconnect/observer</class>
234
- <method>productMassUpdate</method>
235
- </cueconnect_cue_product_update_website_after>
236
- </observers>
237
- </catalog_product_website_update>
238
- <catalog_product_stock_item_mass_change>
239
- <observers>
240
- <cueconnect_cue_product_update_stock_after>
241
- <class>cueconnect/observer</class>
242
- <method>productStockMassUpdate</method>
243
- </cueconnect_cue_product_update_stock_after>
244
- </observers>
245
- </catalog_product_stock_item_mass_change>
246
- <catalog_product_import_finish_before>
247
- <observers>
248
- <cueconnect_cue_product_import_finish_before>
249
- <class>cueconnect/observer</class>
250
- <method>productsImportUpdate</method>
251
- </cueconnect_cue_product_import_finish_before>
252
- </observers>
253
- </catalog_product_import_finish_before>
254
- </events>
255
- </adminhtml>
256
- <default>
257
- <cueconnect>
258
- <enabled>
259
- <enabled>1</enabled>
260
- </enabled>
261
- <mode>
262
- <mode>1</mode>
263
- </mode>
264
- <collection>
265
- <enabled>1</enabled>
266
- </collection>
267
- <ob>
268
- <enabled>1</enabled>
269
- </ob>
270
- <favorite>
271
- <enabled>1</enabled>
272
- </favorite>
273
- <alert>
274
- <enabled>1</enabled>
275
- </alert>
276
- <tracking>
277
- <enabled>1</enabled>
278
- </tracking>
279
- <webservice>
280
- <url>http://qa-rapi.cueconnect.net/</url>
281
- </webservice>
282
- <taxomomy_id>fcc3465</taxomomy_id>
283
- <image>
284
- <width>480</width>
285
- <height>480</height>
286
- </image>
287
- <path>
288
- <elist>apps/mylist</elist>
289
- </path>
290
- <webhook>
291
- <save_customer>
292
- <url>https://qa-business.cueconnect.net/magento/saveCustomer</url>
293
- <key>026132282952ccf731a765413bf11ca32ccbc683ab92c7ad3171b2a0a71ef21d69d1334efcf79da5ecc2d496221e0e28ed025e71d210ebf16e70bfa338c4f2d3</key>
294
- </save_customer>
295
- <save_mark>
296
- <url>https://qa-business.cueconnect.net/magento/saveMark</url>
297
- <key>bf83fc65e0e710e68e17c811bdb6e5d48ea2e805d8fc4af3ac9c8c428631fa044fa6509f128e6891b6d5e8df54508e045b53d95289d72f2f46d98499286772ca</key>
298
- </save_mark>
299
- <price_changed>
300
- <url>https://qa-business.cueconnect.net/magento/priceChanged</url>
301
- <key>f7ba9544bdded1d3a1aead3cb43557b340bf69ce1919a94e7282bfe11f573c94ffc375bf778bc374677c8150ae3880e9fa1502bb5e4235d7628e1ed3e95a6895</key>
302
- </price_changed>
303
- <select_version>
304
- <url>https://qa-business.cueconnect.net/magento/selectVersion</url>
305
- <key>a2645def81375a4f88475acc6b4b0639fd87bfaef715b828e1704f79bac6262ef0e85876dd7047765360678b3372812b5f1741b3abfe9159a3d50fe01e05d757</key>
306
- </select_version>
307
- </webhook>
308
- <support>
309
- <email>dev@cueconnect.com</email>
310
- <name>CUE support</name>
311
- <subject>Synchronization has failed</subject>
312
- </support>
313
- </cueconnect>
314
- </default>
315
- <crontab>
316
- <jobs>
317
- <cue_sync>
318
- <schedule>
319
- <cron_expr>*/1 * * * *</cron_expr>
320
- </schedule>
321
- <run>
322
- <model>cueconnect/cueconnect::sync</model>
323
- </run>
324
- </cue_sync>
325
- </jobs>
326
- </crontab>
327
- </config>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/CueConnect/Cue/etc/system.xml CHANGED
@@ -2,7 +2,7 @@
2
  <config>
3
  <sections>
4
  <cueconnect module="cueconnect" translate="label">
5
- <label>Cue</label>
6
  <tab>catalog</tab>
7
  <frontend_type>text</frontend_type>
8
  <sort_order>300</sort_order>
@@ -29,8 +29,8 @@
29
  </fields>
30
  </environment>
31
  <credentials translate="label">
32
- <label>Cue API Credentials</label>
33
- <comment><![CDATA[<p>Get your Cue API key from your Merchant Hub account under the Code Implementation section.</p>]]></comment>
34
  <frontend_type>text</frontend_type>
35
  <sort_order>1</sort_order>
36
  <show_in_default>1</show_in_default>
@@ -38,7 +38,7 @@
38
  <show_in_store>1</show_in_store>
39
  <fields>
40
  <api_key translate="label">
41
- <label>API Credentials</label>
42
  <tooltip>Get your Cue API key from your Merchant Hub account.</tooltip>
43
  <show_in_default>1</show_in_default>
44
  <show_in_website>1</show_in_website>
@@ -106,9 +106,7 @@
106
  </enabled>
107
  </fields>
108
  </enabled>
109
-
110
-
111
- <mode translate="label">
112
  <label>My-List Version</label>
113
  <comment><![CDATA[<p>Available in two versions: a customizable widget or enterprise fully integrated that works seamlessly with your existing Customer Account and Profile.</p><p><strong>Standalone Widget:</strong> My-List technology is deployed on a standalone widget. Shoppers will opt into this service by signing up through the My-list login popup modal.</p><p><strong>Fully Integrated:</strong> works seamlessly with your existing Customer Account and Profile. Shoppers simply need to create an account with your store to have access to My-List capabilities.</p>]]></comment>
114
  <frontend_type>text</frontend_type>
@@ -127,7 +125,7 @@
127
  <show_in_store>1</show_in_store>
128
  </mode>
129
  </fields>
130
- </mode>
131
  <collection translate="label">
132
  <label>My List</label>
133
  <comment><![CDATA[<p>The &quot;My List&quot; link can be automatically added to the top links or manually inserted in any location in your theme files. <br>If you wish to manually place the &quot;My List&quot; link, set this option to &quot;No&quot; and follow the steps in the Manual Setup Instructions section below in this page.</p>]]></comment>
@@ -169,7 +167,7 @@
169
  </fields>
170
  </ob>
171
  <favorite translate="label">
172
- <label>Add to Wishlist Link</label>
173
  <comment><![CDATA[<p>The &quot;Add to Wishlist&quot; link can be automatically added or manually inserted into the product page.<br>If you wish to manually place the &quot;Add to Wishlist&quot; link, set this option to &quot;No&quot; and follow the steps in the Manual Setup Instructions section below in this page.</p>]]></comment>
174
  <frontend_type>text</frontend_type>
175
  <sort_order>6</sort_order>
@@ -228,7 +226,6 @@
228
  </enabled>
229
  </fields>
230
  </tracking>
231
-
232
  <setup translate="label">
233
  <label>Manual Setup Instructions</label>
234
  <comment><![CDATA[
@@ -238,7 +235,7 @@
238
 
239
  <p>Copy the &lt;a&gt; tag and paste it in the theme's source code where you wish the 'My List' link to appear:</p>
240
 
241
- <div class="reg_main" style="padding:0 20px;margin-bottom: 20px">
242
  <textarea readonly="readonly" style="width: 80%; height: 50px;">
243
 
244
  <a class="cue-stream"> My Wish List </a>
@@ -246,8 +243,8 @@
246
  </textarea>
247
  </div>
248
 
249
- <div style="padding:0 20px;margin-bottom: 20px; color: blue; font-size: 12px;">Tip: <br>
250
- We recommend that you place the link in your header or menu.<br>You can replace the &lt;a&gt; by any HTML tag that fits your design best.
251
  </div>
252
 
253
  <strong>Step 2. Implement the 'Share' button</strong>
@@ -263,7 +260,7 @@
263
  </div>
264
 
265
 
266
- <strong>Step 3. Implement the 'Add to Wishlist' link</strong>
267
 
268
 
269
  <p>Copy the &lt;div&gt; tag and insert it in your product's html page, where you wish the link to appear.</p>
@@ -278,7 +275,7 @@
278
  </textarea>
279
  </div>
280
 
281
- <strong>Step 4. Implement the 'Price Alert' link</strong>
282
 
283
 
284
  <p>Copy the &lt;div&gt; tag and insert it in your product's html page, where you wish the link to appear.</p>
2
  <config>
3
  <sections>
4
  <cueconnect module="cueconnect" translate="label">
5
+ <label>Cue Connect</label>
6
  <tab>catalog</tab>
7
  <frontend_type>text</frontend_type>
8
  <sort_order>300</sort_order>
29
  </fields>
30
  </environment>
31
  <credentials translate="label">
32
+ <label>Cue Credentials</label>
33
+ <comment><![CDATA[<p>Click <a href="https://business.cueconnect.com/partner/register?plan=build" target="_BLANK">HERE</a> to create your Cue account and find your API Key under the "Code Implementation" section on your Merchant Hub Panel.</p> ]]></comment>
34
  <frontend_type>text</frontend_type>
35
  <sort_order>1</sort_order>
36
  <show_in_default>1</show_in_default>
38
  <show_in_store>1</show_in_store>
39
  <fields>
40
  <api_key translate="label">
41
+ <label>API Key</label>
42
  <tooltip>Get your Cue API key from your Merchant Hub account.</tooltip>
43
  <show_in_default>1</show_in_default>
44
  <show_in_website>1</show_in_website>
106
  </enabled>
107
  </fields>
108
  </enabled>
109
+ <!--<mode translate="label">
 
 
110
  <label>My-List Version</label>
111
  <comment><![CDATA[<p>Available in two versions: a customizable widget or enterprise fully integrated that works seamlessly with your existing Customer Account and Profile.</p><p><strong>Standalone Widget:</strong> My-List technology is deployed on a standalone widget. Shoppers will opt into this service by signing up through the My-list login popup modal.</p><p><strong>Fully Integrated:</strong> works seamlessly with your existing Customer Account and Profile. Shoppers simply need to create an account with your store to have access to My-List capabilities.</p>]]></comment>
112
  <frontend_type>text</frontend_type>
125
  <show_in_store>1</show_in_store>
126
  </mode>
127
  </fields>
128
+ </mode> -->
129
  <collection translate="label">
130
  <label>My List</label>
131
  <comment><![CDATA[<p>The &quot;My List&quot; link can be automatically added to the top links or manually inserted in any location in your theme files. <br>If you wish to manually place the &quot;My List&quot; link, set this option to &quot;No&quot; and follow the steps in the Manual Setup Instructions section below in this page.</p>]]></comment>
167
  </fields>
168
  </ob>
169
  <favorite translate="label">
170
+ <label>Add to Wishlist</label>
171
  <comment><![CDATA[<p>The &quot;Add to Wishlist&quot; link can be automatically added or manually inserted into the product page.<br>If you wish to manually place the &quot;Add to Wishlist&quot; link, set this option to &quot;No&quot; and follow the steps in the Manual Setup Instructions section below in this page.</p>]]></comment>
172
  <frontend_type>text</frontend_type>
173
  <sort_order>6</sort_order>
226
  </enabled>
227
  </fields>
228
  </tracking>
 
229
  <setup translate="label">
230
  <label>Manual Setup Instructions</label>
231
  <comment><![CDATA[
235
 
236
  <p>Copy the &lt;a&gt; tag and paste it in the theme's source code where you wish the 'My List' link to appear:</p>
237
 
238
+ <div class="reg_main" style="padding:0 20px;margin-bottom: 10px">
239
  <textarea readonly="readonly" style="width: 80%; height: 50px;">
240
 
241
  <a class="cue-stream"> My Wish List </a>
243
  </textarea>
244
  </div>
245
 
246
+ <div style="padding:0 20px;margin-bottom: 20px; color: blue; font-size: 12px;">
247
+ We recommend that you place the link in your header or menu. You can replace the &lt;a&gt; by any HTML tag that fits your design best.
248
  </div>
249
 
250
  <strong>Step 2. Implement the 'Share' button</strong>
260
  </div>
261
 
262
 
263
+ <strong>Step 3. Implement the 'Add to Wishlist'</strong>
264
 
265
 
266
  <p>Copy the &lt;div&gt; tag and insert it in your product's html page, where you wish the link to appear.</p>
275
  </textarea>
276
  </div>
277
 
278
+ <strong>Step 4. Implement the 'Price Alert'</strong>
279
 
280
 
281
  <p>Copy the &lt;div&gt; tag and insert it in your product's html page, where you wish the link to appear.</p>
app/design/frontend/base/default/template/cueconnect/elist.phtml CHANGED
@@ -1,18 +1,23 @@
1
  <?php
2
  // CP
3
- if (($this->getMode() == 2) && $this->getRetailerId() && $this->isEnabled()) :
4
 
5
  $place_id = $this->getRetailerId() ? $this->getRetailerId() : 0;
6
  $origin = Mage::getBaseUrl();
7
 
8
  if ($this->getCustomerEmail()):
9
  // signed in so show my-list
 
 
 
 
 
10
  ?>
11
 
12
  <iframe
13
  id="streamIFrame"
14
  name="streamIFrame"
15
- src="https://www.cueconnect.com/poweredby/<?php echo $place_id ?>/?origin=<?php echo $origin; ?>&amp;version=embed&amp;from=stream&amp;email=<?php echo $this->getCustomerEmail() ?>"
16
  height="640px"
17
  width="100%"
18
  scrolling="no"
1
  <?php
2
  // CP
3
+ if ($this->getRetailerId() && $this->isEnabled()) :
4
 
5
  $place_id = $this->getRetailerId() ? $this->getRetailerId() : 0;
6
  $origin = Mage::getBaseUrl();
7
 
8
  if ($this->getCustomerEmail()):
9
  // signed in so show my-list
10
+ $base_url = "https://www.cueconnect.com";
11
+ if($this->getEnv() && $this->getEnv() != ''){
12
+ $base_url = "https://".$this->getEnv()."-www.cueconnect.net";
13
+ }
14
+
15
  ?>
16
 
17
  <iframe
18
  id="streamIFrame"
19
  name="streamIFrame"
20
+ src="<?php echo $base_url; ?>/poweredby/<?php echo $place_id ?>/?origin=<?php echo $origin; ?>&amp;version=embed&amp;from=stream&amp;email=<?php echo $this->getCustomerEmail() ?>"
21
  height="640px"
22
  width="100%"
23
  scrolling="no"
app/design/frontend/base/default/template/cueconnect/favorite.phtml CHANGED
@@ -1,4 +1,4 @@
1
  <?php // Todo: Rename template file name ?>
2
- <?php if ($this->isEnabled() && $this->isFavoriteEnabled() && $this->getRetailerId()): ?>
3
  <div class="cue-cueit" data-imisku="<?php echo $this->getSku(); ?>" data-cid="<?php echo $this->getCID(); ?>"></div>
4
- <?php endif; ?>
1
  <?php // Todo: Rename template file name ?>
2
+ <?php if ($this->isFavoriteEnabled() && $this->getRetailerId()): ?>
3
  <div class="cue-cueit" data-imisku="<?php echo $this->getSku(); ?>" data-cid="<?php echo $this->getCID(); ?>"></div>
4
+ <?php endif; ?>
app/design/frontend/base/default/template/cueconnect/js.phtml CHANGED
@@ -1,6 +1,11 @@
1
  <?php if ($this->isEnabled() && $this->getRetailerId()): ?>
2
-
 
 
 
 
3
  <script src="https://stream.cueconnect.com/js/cue-seed.js"></script>
 
4
  <script>
5
  function doLoad() {
6
  CUE({
1
  <?php if ($this->isEnabled() && $this->getRetailerId()): ?>
2
+ <?php
3
+ if($this->getEnv() && $this->getEnv() != ''){
4
+ ?>
5
+ <script src="https://<?php echo $this->getEnv(); ?>-stream.cueconnect.net/js/cue-seed.js"></script>
6
+ <?php }else{ ?>
7
  <script src="https://stream.cueconnect.com/js/cue-seed.js"></script>
8
+ <?php } ?>
9
  <script>
10
  function doLoad() {
11
  CUE({
package.xml CHANGED
@@ -1,18 +1,18 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Cue</name>
4
- <version>3.0.20</version>
5
  <stability>stable</stability>
6
  <license uri="http://opensource.org/licenses/osl-3.0.php">Open Software License (OSL)</license>
7
  <channel>community</channel>
8
  <extends/>
9
  <summary>Powerful onsite marketing solution that helps increase engagement and conversions.</summary>
10
  <description>Drive greater ROI using an experience and tools shoppers already engage with on your site today. Provide Cue as a free personal shopping assistant to your customers and get an inside look at the items they save and conversations they have about them. Use the data to personalize various touch points of their shopping journey and thoughtfully stimulate conversions. Receive a free 90-day trial when you sign up and grow your business risk-free.</description>
11
- <notes>- Improvements and bugfixes</notes>
12
  <authors><author><name>Cue Connect</name><user>dev</user><email>dev@cueconnect.com</email></author></authors>
13
- <date>2017-03-17</date>
14
- <time>22:48:54</time>
15
- <contents><target name="magecommunity"><dir name="CueConnect"><dir name="Cue"><dir name="Block"><dir name="Adminhtml"><dir name="Catalog"><file name="Product.php" hash="da20e73d9d6c46f8e9b8f2e0b130b69a"/></dir><file name="Index.php" hash="0c40f5f733dd6ecd2dd5a0453d1df14b"/><file name="Progress.php" hash="9767500cf8507eacd58c6b441a23d7c1"/><dir name="System"><dir name="Config"><dir name="Form"><dir name="Field"><file name="Readonly.php" hash="847f56fbe8ce7b3334b8831981aff5fb"/></dir></dir></dir></dir></dir><file name="Alert.php" hash="416cb0dba8485a32feb55306f2004664"/><file name="BaseCueBlock.php" hash="762bd5f6105ae2c82bb06888ac7e079d"/><dir name="Checkout"><dir name="Success"><file name="Share.php" hash="9d06573d7278f3d3bf72fa6b37f6a4eb"/></dir></dir><file name="Collection.php" hash="34049e05086f52a1b74bcf7046f8a4f8"/><file name="Elist.php" hash="7832410c357470a083cf3d3679ab376d"/><file name="Favorite.php" hash="dd4bd0736e3cfea4d87e366fb0e228b3"/><file name="Js.php" hash="fa423dff429d99b1969fe9b2932be095"/><file name="Meta.php" hash="c16b07f77ac3c1ccb6fdcbcfc17ea703"/><file name="Navigation.php" hash="a43d159e9629ca20461c88ba9eb2c16a"/><file name="Share.php" hash="c0a2dd7fcc9a3537718fe811d1b4d7df"/><dir name="System"><dir name="Config"><file name="Customerresync.php" hash="fdd3c3b6236bb76f291b7eff37386a25"/><file name="Productresync.php" hash="c58753a91269ec79c05d1efbf6eb637e"/></dir></dir></dir><dir name="Helper"><file name="Data.php" hash="2845147829619755bd1cd399a1046ae7"/><file name="Product.php" hash="f116d42cb6ce9aff6dec783cf7bb7bea"/><dir name="Wishlist"><file name="Data.php" hash="df7c81da4f905c5cfdc9adf18b2918f7"/></dir></dir><dir name="Model"><file name="Cueconnect.php" hash="302a39210b0807fffe6cb31c52de69a0"/><file name="Demand.php" hash="e1d627c3207a364c861faf8decbcd7cc"/><dir name="Mysql4"><dir name="Demand"><file name="Collection.php" hash="4bd64ac5500aacdd861c05161bfdea60"/></dir><file name="Demand.php" hash="6b3b0d54f7d15fb55d47773ea96690d8"/><dir name="UserSync"><file name="Collection.php" hash="2f70172ef8506195355d0f34fa963de7"/></dir><file name="UserSync.php" hash="29fbf5674f15ba2a8db2c4f79545431c"/><dir name="WishlistSync"><file name="Collection.php" hash="c7ae0dc2a51c0d6e26360cba2c82c685"/></dir><file name="WishlistSync.php" hash="18079cce3dcf1129dd412d9de5199351"/></dir><file name="Observer.php" hash="e3a8b67f59c06030ee49ad23132dfce9"/><file name="Options.php" hash="6f312d0f07fb27129c6bb8eb83fdda8c"/><file name="UserSync.php" hash="45dc5508786c1db53088f4257cd5e3bd"/><file name="WishlistSync.php" hash="4b77f0097f4ed05ea63058cc1099ce66"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="SyncController.php" hash="c9cd0b21c257205cae0f09044ba12333"/><dir name="System"><dir name="Config"><file name="CustomersyncController.php" hash="e294ed638c39e61402373927b4bd763b"/><file name="ProductsyncController.php" hash="11ad2928c8dc3ba01b0be06feba904f8"/></dir></dir></dir><file name="ElistController.php" hash="dc112c88f2ced7880379bc87ec0138a9"/></dir><dir name="etc"><file name="config.xml" hash="b73f7523a7a79d658089e4b9f702c7e1"/><file name="config.xml_backup" hash="bb24416e1f96b58ad969149e03d2f0ff"/><file name="system.xml" hash="a6207618c56ba33e5074779d2a93488c"/></dir><dir name="sql"><dir name="cueconnect_setup"><file name="mysql4-install-3.0.9.php" hash="35e874c8e139497043b0e50ea6cf2fa0"/><file name="mysql4-upgrade-3.0.8-3.0.9.php" hash="54cfba6c455bebb9e614013642fb8fdd"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="cueconnect.xml" hash="9d71f0d163c1fd881896fbea137a45f9"/></dir><dir name="template"><dir name="cueconnect"><file name="alert.phtml" hash="1b84532e255e6c4cfba9881e48013896"/><dir name="checkout"><dir name="success"><file name="share.phtml" hash="f822230a4d6fe88a923065c1d06297fc"/></dir></dir><file name="collection.phtml" hash="d41d8cd98f00b204e9800998ecf8427e"/><dir name="customer"><dir name="form"><file name="forgotpassword.phtml" hash="e77cbc35be0786aa61e08de47008595f"/><file name="login.phtml" hash="830203b7f6a8d8647a3812b51ac45721"/><file name="register.phtml" hash="b23b45199434202d0c7f582e804fb8c1"/></dir></dir><file name="elist.phtml" hash="b8c2211f819d4ae9b0faa23caee7f677"/><file name="favorite.phtml" hash="89f0bca645d6f81e2a3c3cf375c5d44e"/><file name="js.phtml" hash="65bb0542fbbb7c718a6702bb0bdc4866"/><file name="links.phtml" hash="b5567bf97bd53184fb84e23c73ab4778"/><file name="meta.phtml" hash="57bd5367b677d71d935faf8a9dfefa82"/><file name="share.phtml" hash="781d6414c1b41f3bdb2a5befc8817463"/></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="CueConnect_Cue.xml" hash="6bd6cf8a7f9e647dc5729e8b0a77cfa1"/></dir></target></contents>
16
  <compatible/>
17
  <dependencies><required><php><min>5.1.0</min><max>5.6.2</max></php></required></dependencies>
18
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Cue</name>
4
+ <version>3.0.21</version>
5
  <stability>stable</stability>
6
  <license uri="http://opensource.org/licenses/osl-3.0.php">Open Software License (OSL)</license>
7
  <channel>community</channel>
8
  <extends/>
9
  <summary>Powerful onsite marketing solution that helps increase engagement and conversions.</summary>
10
  <description>Drive greater ROI using an experience and tools shoppers already engage with on your site today. Provide Cue as a free personal shopping assistant to your customers and get an inside look at the items they save and conversations they have about them. Use the data to personalize various touch points of their shopping journey and thoughtfully stimulate conversions. Receive a free 90-day trial when you sign up and grow your business risk-free.</description>
11
+ <notes>- Improvements and bug fixes</notes>
12
  <authors><author><name>Cue Connect</name><user>dev</user><email>dev@cueconnect.com</email></author></authors>
13
+ <date>2017-06-07</date>
14
+ <time>16:42:52</time>
15
+ <contents><target name="magecommunity"><dir name="CueConnect"><dir name="Cue"><dir name="Block"><dir name="Adminhtml"><dir name="Catalog"><file name="Product.php" hash="da20e73d9d6c46f8e9b8f2e0b130b69a"/></dir><file name="Index.php" hash="0c40f5f733dd6ecd2dd5a0453d1df14b"/><file name="Progress.php" hash="9767500cf8507eacd58c6b441a23d7c1"/><dir name="System"><dir name="Config"><dir name="Form"><dir name="Field"><file name="Readonly.php" hash="847f56fbe8ce7b3334b8831981aff5fb"/></dir></dir><file name=".DS_Store" hash="194577a7e20bdcc7afbb718f502c134c"/><file name="._.DS_Store" hash="7d40ce63be1b295f209e8b80541f880d"/></dir></dir></dir><file name="Alert.php" hash="416cb0dba8485a32feb55306f2004664"/><file name="BaseCueBlock.php" hash="0b2334ff6945c2b655bc38265ae853bc"/><dir name="Checkout"><dir name="Success"><file name="Share.php" hash="c8cad566ad250505242e15fb8d429835"/></dir></dir><file name="Collection.php" hash="34049e05086f52a1b74bcf7046f8a4f8"/><file name="Elist.php" hash="7832410c357470a083cf3d3679ab376d"/><file name="Favorite.php" hash="dd4bd0736e3cfea4d87e366fb0e228b3"/><file name="Js.php" hash="fa423dff429d99b1969fe9b2932be095"/><file name="Meta.php" hash="c16b07f77ac3c1ccb6fdcbcfc17ea703"/><file name="Navigation.php" hash="6f643ad42bfcb5fb5438fc80b188f7dc"/><file name="Share.php" hash="c0a2dd7fcc9a3537718fe811d1b4d7df"/><dir name="System"><dir name="Config"><file name="Customerresync.php" hash="fdd3c3b6236bb76f291b7eff37386a25"/><file name="Productresync.php" hash="c58753a91269ec79c05d1efbf6eb637e"/></dir></dir></dir><dir name="Helper"><file name="Data.php" hash="4e19b48eaa70f7a8e7788b31a20313c8"/><file name="Product.php" hash="f116d42cb6ce9aff6dec783cf7bb7bea"/><dir name="Wishlist"><file name="Data.php" hash="df7c81da4f905c5cfdc9adf18b2918f7"/></dir></dir><dir name="Model"><file name="Cueconnect.php" hash="52299fa3b478526a5f29258302ea487c"/><file name="Demand.php" hash="e1d627c3207a364c861faf8decbcd7cc"/><dir name="Mysql4"><dir name="Demand"><file name="Collection.php" hash="4bd64ac5500aacdd861c05161bfdea60"/></dir><file name="Demand.php" hash="6b3b0d54f7d15fb55d47773ea96690d8"/><dir name="UserSync"><file name="Collection.php" hash="2f70172ef8506195355d0f34fa963de7"/></dir><file name="UserSync.php" hash="29fbf5674f15ba2a8db2c4f79545431c"/><dir name="WishlistSync"><file name="Collection.php" hash="c7ae0dc2a51c0d6e26360cba2c82c685"/></dir><file name="WishlistSync.php" hash="18079cce3dcf1129dd412d9de5199351"/></dir><file name="Observer.php" hash="3e6e8dcea6f54c4650dd0386f5373f30"/><file name="Options.php" hash="6f312d0f07fb27129c6bb8eb83fdda8c"/><file name="UserSync.php" hash="45dc5508786c1db53088f4257cd5e3bd"/><file name="WishlistSync.php" hash="4b77f0097f4ed05ea63058cc1099ce66"/><file name=".CueConnect.php.swp" hash="6563f1a641f3083c5dceca707cd9f034"/><file name=".Inmarkit.php.swp" hash="1e57142b5a69936aab17cbc6fabdd16a"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="SyncController.php" hash="c9cd0b21c257205cae0f09044ba12333"/><dir name="System"><dir name="Config"><file name="CustomersyncController.php" hash="e294ed638c39e61402373927b4bd763b"/><file name="ProductsyncController.php" hash="11ad2928c8dc3ba01b0be06feba904f8"/></dir></dir></dir><file name="ElistController.php" hash="ff33b24a3cb74adabeaa9ba16fab2b79"/></dir><dir name="etc"><file name="config.xml" hash="5354e62afe897e6a4f713411f2adf7e1"/><file name="system.xml" hash="df168398f2a7269a9b2efd6eb9bfaaf9"/></dir><dir name="sql"><dir name="cueconnect_setup"><file name="mysql4-install-3.0.9.php" hash="35e874c8e139497043b0e50ea6cf2fa0"/><file name="mysql4-upgrade-3.0.8-3.0.9.php" hash="54cfba6c455bebb9e614013642fb8fdd"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="cueconnect.xml" hash="9d71f0d163c1fd881896fbea137a45f9"/></dir><dir name="template"><dir name="cueconnect"><file name="alert.phtml" hash="1b84532e255e6c4cfba9881e48013896"/><dir name="checkout"><dir name="success"><file name="share.phtml" hash="f822230a4d6fe88a923065c1d06297fc"/></dir></dir><file name="collection.phtml" hash="d41d8cd98f00b204e9800998ecf8427e"/><dir name="customer"><dir name="form"><file name="forgotpassword.phtml" hash="e77cbc35be0786aa61e08de47008595f"/><file name="login.phtml" hash="830203b7f6a8d8647a3812b51ac45721"/><file name="register.phtml" hash="b23b45199434202d0c7f582e804fb8c1"/></dir></dir><file name="elist.phtml" hash="7f76b6c72e6a6854cd4661ccb4da87c0"/><file name="favorite.phtml" hash="38047453fd3508133452699cad87a408"/><file name="js.phtml" hash="04bbe66cfd4046dfef6fa9a2469e7009"/><file name="links.phtml" hash="b5567bf97bd53184fb84e23c73ab4778"/><file name="meta.phtml" hash="57bd5367b677d71d935faf8a9dfefa82"/><file name="share.phtml" hash="781d6414c1b41f3bdb2a5befc8817463"/></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="CueConnect_Cue.xml" hash="6bd6cf8a7f9e647dc5729e8b0a77cfa1"/></dir></target></contents>
16
  <compatible/>
17
  <dependencies><required><php><min>5.1.0</min><max>5.6.2</max></php></required></dependencies>
18
  </package>