Remarkety_Mgconnector - Version 1.4.8.1

Version Notes

No comments

Download this release

Release Info

Developer Remarkety
Extension Remarkety_Mgconnector
Version 1.4.8.1
Comparing to
See all releases


Code changes from version 1.4.7.3 to 1.4.8.1

CHANGELOG.txt CHANGED
@@ -1,3 +1,11 @@
 
 
 
 
 
 
 
 
1
  1.4.7.3
2
  -------
3
  Bugfix - get configuration settings from the request parameter instead of the headers
1
+ 1.4.8.1
2
+ -------
3
+ - Bugfix - Salable products incorrect value
4
+
5
+ 1.4.8.0
6
+ -------
7
+ - Add webhooks and cron job for pushing product price updates
8
+
9
  1.4.7.3
10
  -------
11
  Bugfix - get configuration settings from the request parameter instead of the headers
app/code/community/Remarkety/Mgconnector/Model/Core.php CHANGED
@@ -22,6 +22,8 @@ class Remarkety_Mgconnector_Model_Core extends Mage_Core_Model_Abstract {
22
  const XPATH_CATEGORIES_TO_IGNORE = 'remarkety/mgconnector/categories-to-ignore';
23
  private $_categoriesToIgnore = array();
24
 
 
 
25
  private $_productCache = array();
26
  private $_categoryCache = array();
27
 
@@ -241,7 +243,7 @@ class Remarkety_Mgconnector_Model_Core extends Mage_Core_Model_Abstract {
241
  return $data;
242
  }
243
 
244
- private function _productCategories(Mage_Catalog_Model_Product $product, $getFromParent = true)
245
  {
246
  $categoryCollection = $product->getCategoryCollection()
247
  ->addAttributeToSelect('name');
@@ -538,6 +540,11 @@ class Remarkety_Mgconnector_Model_Core extends Mage_Core_Model_Abstract {
538
  $this->_debug(__FUNCTION__, REMARKETY_MGCONNECTOR_CALLED_STATUS, null, $myArgs);
539
  $ordersCollection = Mage::getModel("sales/order")
540
  ->getCollection()
 
 
 
 
 
541
  ->addOrder('updated_at', 'ASC')
542
  ->addAttributeToSelect('*');
543
 
@@ -597,6 +604,7 @@ class Remarkety_Mgconnector_Model_Core extends Mage_Core_Model_Abstract {
597
  */
598
 
599
  $productIdsToLoad = array();
 
600
  $orderIds = array();
601
 
602
  foreach ($ordersCollection as $order) {
@@ -624,6 +632,19 @@ class Remarkety_Mgconnector_Model_Core extends Mage_Core_Model_Abstract {
624
  $orderData['address'] = $address;
625
  }
626
 
 
 
 
 
 
 
 
 
 
 
 
 
 
627
  $storeUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
628
 
629
  $itemsCollection = $order->getItemsCollection();
@@ -658,6 +679,7 @@ class Remarkety_Mgconnector_Model_Core extends Mage_Core_Model_Abstract {
658
  $paymentMethods = $this->loadPaymentMethods($orderIds);
659
 
660
  // Load the products all at once and populate the items
 
661
  $this->loadProducts($mage_store_view_id, $productIdsToLoad);
662
 
663
  $ret = array();
@@ -831,7 +853,15 @@ class Remarkety_Mgconnector_Model_Core extends Mage_Core_Model_Abstract {
831
  $ret = array();
832
  $myArgs = func_get_args();
833
  $this->simpleProductsStandalone = Mage::helper('mgconnector/configuration')->getValue('configurable_standalone', false);
834
- try {
 
 
 
 
 
 
 
 
835
  $this->_debug(__FUNCTION__, REMARKETY_MGCONNECTOR_CALLED_STATUS, null, $myArgs);
836
  $productCollectionWithPrices = Mage::getModel("catalog/product")
837
  ->getCollection()
@@ -1312,8 +1342,8 @@ class Remarkety_Mgconnector_Model_Core extends Mage_Core_Model_Abstract {
1312
  $url = (string)Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK) . 'remarkety/recovery/cart/quote_id/' . $id;
1313
  return $url;
1314
  }
1315
-
1316
- private function getProductName($product, $mage_store_view_id){
1317
  $name = '';
1318
  if(!$this->simpleProductsStandalone && !in_array($product->type_id, $this->_groupedTypes)) {
1319
  $this->_debug(__FUNCTION__, null, "not config prod id ".$product->getId(), '');
@@ -1378,6 +1408,14 @@ class Remarkety_Mgconnector_Model_Core extends Mage_Core_Model_Abstract {
1378
  }
1379
  }
1380
 
 
 
 
 
 
 
 
 
1381
  private function loadProduct($productId) {
1382
  if (!isset($this->_productCache[$productId])) {
1383
  $this->_productCache[$productId] = Mage::getModel("catalog/product")->load($productId);
22
  const XPATH_CATEGORIES_TO_IGNORE = 'remarkety/mgconnector/categories-to-ignore';
23
  private $_categoriesToIgnore = array();
24
 
25
+ private $configurable_product_model = null;
26
+
27
  private $_productCache = array();
28
  private $_categoryCache = array();
29
 
243
  return $data;
244
  }
245
 
246
+ public function _productCategories(Mage_Catalog_Model_Product $product, $getFromParent = true)
247
  {
248
  $categoryCollection = $product->getCategoryCollection()
249
  ->addAttributeToSelect('name');
540
  $this->_debug(__FUNCTION__, REMARKETY_MGCONNECTOR_CALLED_STATUS, null, $myArgs);
541
  $ordersCollection = Mage::getModel("sales/order")
542
  ->getCollection()
543
+ ->join(
544
+ array('payment' => 'sales/order_payment'),
545
+ 'main_table.entity_id=payment.parent_id',
546
+ array('payment_method' => 'payment.method')
547
+ )
548
  ->addOrder('updated_at', 'ASC')
549
  ->addAttributeToSelect('*');
550
 
604
  */
605
 
606
  $productIdsToLoad = array();
607
+ $paymentMethods = array(); //hash table for payment code->name
608
  $orderIds = array();
609
 
610
  foreach ($ordersCollection as $order) {
632
  $orderData['address'] = $address;
633
  }
634
 
635
+ //convert payment method code to name
636
+ if(!empty($orderData['payment_method'])){
637
+ if(isset($paymentMethods[$orderData['payment_method']])){ //use hash table if found
638
+ $orderData['payment_method'] = $paymentMethods[$orderData['payment_method']];
639
+ } else { //get name from config
640
+ $method = Mage::getStoreConfig('payment/'.$orderData['payment_method'].'/title');
641
+ if(!empty($method)){
642
+ $paymentMethods[$orderData['payment_method']] = $method;
643
+ $orderData['payment_method'] = $method;
644
+ }
645
+ }
646
+ }
647
+
648
  $storeUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
649
 
650
  $itemsCollection = $order->getItemsCollection();
679
  $paymentMethods = $this->loadPaymentMethods($orderIds);
680
 
681
  // Load the products all at once and populate the items
682
+
683
  $this->loadProducts($mage_store_view_id, $productIdsToLoad);
684
 
685
  $ret = array();
853
  $ret = array();
854
  $myArgs = func_get_args();
855
  $this->simpleProductsStandalone = Mage::helper('mgconnector/configuration')->getValue('configurable_standalone', false);
856
+ try
857
+ {
858
+ try {
859
+ $store = Mage::app()->getStore($mage_store_id);
860
+ Mage::app()->setCurrentStore($store);
861
+ } catch (Exception $ex){
862
+ $this->_debug(__FUNCTION__, REMARKETY_MGCONNECTOR_ERROR, "Cannot set active store", $myArgs);
863
+ }
864
+
865
  $this->_debug(__FUNCTION__, REMARKETY_MGCONNECTOR_CALLED_STATUS, null, $myArgs);
866
  $productCollectionWithPrices = Mage::getModel("catalog/product")
867
  ->getCollection()
1342
  $url = (string)Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK) . 'remarkety/recovery/cart/quote_id/' . $id;
1343
  return $url;
1344
  }
1345
+
1346
+ public function getProductName($product, $mage_store_view_id){
1347
  $name = '';
1348
  if(!$this->simpleProductsStandalone && !in_array($product->type_id, $this->_groupedTypes)) {
1349
  $this->_debug(__FUNCTION__, null, "not config prod id ".$product->getId(), '');
1408
  }
1409
  }
1410
 
1411
+ private function getConfigProdModel()
1412
+ {
1413
+ if ($this->configurable_product_model == null) {
1414
+ $this->configurable_product_model = Mage::getModel('catalog/product_type_configurable');
1415
+ }
1416
+ return $this->configurable_product_model;
1417
+ }
1418
+
1419
  private function loadProduct($productId) {
1420
  if (!isset($this->_productCache[$productId])) {
1421
  $this->_productCache[$productId] = Mage::getModel("catalog/product")->load($productId);
app/code/community/Remarkety/Mgconnector/Model/Observer.php CHANGED
@@ -3,14 +3,13 @@
3
  /**
4
  * Observer model, which handle few events and send post request
5
  *
6
- * @category Remarkety
7
- * @package Remarkety_Mgconnector
8
- * @author Piotr Pierzak <piotrek.pierzak@gmail.com>
9
  */
10
 
11
- if (!defined("REMARKETY_LOG")) {
12
  define('REMARKETY_LOG', 'remarkety_mgconnector.log');
13
- }
14
 
15
  class Remarkety_Mgconnector_Model_Observer
16
  {
@@ -31,6 +30,29 @@ class Remarkety_Mgconnector_Model_Observer
31
  protected $_address = null;
32
  protected $_origAddressData = null;
33
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
34
  public function __construct()
35
  {
36
  $this->_token = Mage::getStoreConfig('remarkety/mgconnector/api_key');
@@ -42,6 +64,7 @@ class Remarkety_Mgconnector_Model_Observer
42
  }
43
 
44
 
 
45
  public function triggerCustomerAddressBeforeUpdate($observer)
46
  {
47
  $address = Mage::getSingleton('customer/session')
@@ -68,10 +91,10 @@ class Remarkety_Mgconnector_Model_Observer
68
  array(
69
  'header' => Mage::helper('salesrule')->__('Expiration date'),
70
  'index' => 'expiration_date',
71
- 'type' => 'datetime',
72
- 'default' => '-',
73
- 'align' => 'center',
74
- 'width' => '160',
75
  ),
76
  'created_at'
77
  );
@@ -121,6 +144,60 @@ class Remarkety_Mgconnector_Model_Observer
121
  return $this;
122
  }
123
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
124
  public function triggerCustomerUpdate($observer)
125
  {
126
  $this->_customer = $observer->getEvent()->getCustomer();
@@ -309,7 +386,8 @@ class Remarkety_Mgconnector_Model_Observer
309
  'curloptions' => array(
310
  // CURLOPT_FOLLOWLOCATION => true,
311
  CURLOPT_HEADER => true,
312
- CURLOPT_CONNECTTIMEOUT => self::REMARKETY_TIMEOUT
 
313
  // CURLOPT_SSL_CIPHER_LIST => "RC4-SHA"
314
  ),
315
  );
@@ -391,7 +469,7 @@ class Remarkety_Mgconnector_Model_Observer
391
  {
392
  $queueModel = Mage::getModel('mgconnector/queue');
393
 
394
- if (!empty($this->_intervals[$attempt - 1])) {
395
  $now = time();
396
  $nextAttempt = $now + (int)$this->_intervals[$attempt - 1] * 60;
397
  if ($queueId) {
@@ -410,15 +488,12 @@ class Remarkety_Mgconnector_Model_Observer
410
  )
411
  );
412
  }
413
-
414
  return $queueModel->save();
415
  } elseif ($queueId) {
416
  $queueModel->load($queueId);
417
  $queueModel->setStatus(0);
418
-
419
  return $queueModel->save();
420
  }
421
-
422
  return false;
423
  }
424
 
@@ -429,7 +504,6 @@ class Remarkety_Mgconnector_Model_Observer
429
  'timestamp' => (string)time(),
430
  'event_id' => $eventType,
431
  );
432
-
433
  return $arr;
434
  }
435
 
@@ -562,7 +636,7 @@ class Remarkety_Mgconnector_Model_Observer
562
  $arr = array(
563
  'email' => $this->_subscriber->getSubscriberEmail(),
564
  'accepts_marketing' => false,
565
- 'storeId' => $store->getStoreId(),
566
  );
567
 
568
  return $arr;
@@ -572,10 +646,21 @@ class Remarkety_Mgconnector_Model_Observer
572
  {
573
  $sent = 0;
574
  foreach ($queueItems as $_queue) {
575
- $result = $this->makeRequest($_queue->getEventType(),
576
- unserialize($_queue->getPayload()),
577
- $resetAttempts ? 1 : ($_queue->getAttempts() + 1),
578
- $_queue->getId());
 
 
 
 
 
 
 
 
 
 
 
579
  if ($result) {
580
  Mage::getModel('mgconnector/queue')
581
  ->load($_queue->getId())
@@ -600,4 +685,151 @@ class Remarkety_Mgconnector_Model_Observer
600
 
601
  return $this;
602
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
603
  }
3
  /**
4
  * Observer model, which handle few events and send post request
5
  *
6
+ * @category Remarkety
7
+ * @package Remarkety_Mgconnector
8
+ * @author Piotr Pierzak <piotrek.pierzak@gmail.com>
9
  */
10
 
11
+ if (!defined("REMARKETY_LOG"))
12
  define('REMARKETY_LOG', 'remarkety_mgconnector.log');
 
13
 
14
  class Remarkety_Mgconnector_Model_Observer
15
  {
30
  protected $_address = null;
31
  protected $_origAddressData = null;
32
 
33
+ private $response_mask = array(
34
+ 'product' => array(
35
+ 'id',
36
+ 'sku',
37
+ 'title',
38
+ 'created_at',
39
+ 'updated_at',
40
+ 'type_id',
41
+ 'base_image',
42
+ 'thumbnail_image',
43
+ 'enabled',
44
+ 'visibility',
45
+ 'categories',
46
+ 'small_image',
47
+ 'price',
48
+ 'special_price',
49
+ 'cost',
50
+ 'url',
51
+ 'is_in_stock',
52
+ 'parent_id'
53
+ )
54
+ );
55
+
56
  public function __construct()
57
  {
58
  $this->_token = Mage::getStoreConfig('remarkety/mgconnector/api_key');
64
  }
65
 
66
 
67
+
68
  public function triggerCustomerAddressBeforeUpdate($observer)
69
  {
70
  $address = Mage::getSingleton('customer/session')
91
  array(
92
  'header' => Mage::helper('salesrule')->__('Expiration date'),
93
  'index' => 'expiration_date',
94
+ 'type' => 'datetime',
95
+ 'default' => '-',
96
+ 'align' => 'center',
97
+ 'width' => '160'
98
  ),
99
  'created_at'
100
  );
144
  return $this;
145
  }
146
 
147
+ private function shouldUpdateRule($rule){
148
+ $now = new DateTime();
149
+ $currentFromDate = new DateTime($rule->getFromDate());
150
+ $currentToDate = new DateTime($rule->getToDate());
151
+ $now->setTime(0, 0, 0);
152
+ $currentFromDate->setTime(0, 0, 0);
153
+ $currentToDate->setTime(0, 0, 0);
154
+ if($currentFromDate <= $now && $currentToDate >= $now && $rule->getIsActive()){
155
+ $oldData = $rule->getOrigData();
156
+ if(!is_null($oldData) && isset($oldData['is_active']) && $oldData['is_active'] == 1){
157
+ //check if was already active so no need to update
158
+ $oldFromDate = new DateTime($oldData['from_date']);
159
+ $oldToDate = new DateTime($oldData['to_date']);
160
+ $oldFromDate->setTime(0, 0, 0);
161
+ $oldToDate->setTime(0, 0, 0);
162
+ if($rule->hasDataChanges()) {
163
+ return true;
164
+ }
165
+ if($currentFromDate <= $now && $currentToDate >= $now){
166
+ return false;
167
+ }
168
+ }
169
+ return true;
170
+ }
171
+ //check if was already active but not active now so need to update
172
+ $oldData = $rule->getOrigData();
173
+ if(!is_null($oldData) && isset($oldData['is_active']) && $oldData['is_active'] == 1){
174
+ $currentFromDate = new DateTime($oldData['from_date']);
175
+ $currentToDate = new DateTime($oldData['to_date']);
176
+ $currentFromDate->setTime(0, 0, 0);
177
+ $currentToDate->setTime(0, 0, 0);
178
+ if($currentFromDate <= $now && $currentToDate >= $now){
179
+ return true;
180
+ }
181
+ }
182
+ return false;
183
+ }
184
+ public function triggerCatalogRuleBeforeUpdate($observer)
185
+ {
186
+
187
+ $this->rule = $observer->getEvent()->getRule();
188
+ $this->rule->setUpdatedAt(date("Y-m-d H:i:s"));
189
+ if($this->shouldUpdateRule($this->rule)) {
190
+ $this->_queueRequest('catalogruleupdated', ['ruleId' => $this->rule->getId()], 1, null);
191
+ //$this->sendProductPrices($this->rule->getId());
192
+ }
193
+ }
194
+
195
+ public function triggerCatalogRuleBeforeDelete($observer){
196
+ }
197
+
198
+ public function triggerCatalogRuleAfterDelete($observer){
199
+ }
200
+
201
  public function triggerCustomerUpdate($observer)
202
  {
203
  $this->_customer = $observer->getEvent()->getCustomer();
386
  'curloptions' => array(
387
  // CURLOPT_FOLLOWLOCATION => true,
388
  CURLOPT_HEADER => true,
389
+ CURLOPT_CONNECTTIMEOUT => self::REMARKETY_TIMEOUT,
390
+ CURLOPT_SSL_VERIFYPEER => false
391
  // CURLOPT_SSL_CIPHER_LIST => "RC4-SHA"
392
  ),
393
  );
469
  {
470
  $queueModel = Mage::getModel('mgconnector/queue');
471
 
472
+ if(!empty($this->_intervals[$attempt-1])) {
473
  $now = time();
474
  $nextAttempt = $now + (int)$this->_intervals[$attempt - 1] * 60;
475
  if ($queueId) {
488
  )
489
  );
490
  }
 
491
  return $queueModel->save();
492
  } elseif ($queueId) {
493
  $queueModel->load($queueId);
494
  $queueModel->setStatus(0);
 
495
  return $queueModel->save();
496
  }
 
497
  return false;
498
  }
499
 
504
  'timestamp' => (string)time(),
505
  'event_id' => $eventType,
506
  );
 
507
  return $arr;
508
  }
509
 
636
  $arr = array(
637
  'email' => $this->_subscriber->getSubscriberEmail(),
638
  'accepts_marketing' => false,
639
+ 'storeId' => $store->getStoreId()
640
  );
641
 
642
  return $arr;
646
  {
647
  $sent = 0;
648
  foreach ($queueItems as $_queue) {
649
+ $result = false;
650
+ if($_queue->getEventType() == "catalogruleupdated"){
651
+ //create queue for price rule update
652
+ $ruleData = unserialize($_queue->getPayload());
653
+ $ruleId = isset($ruleData['ruleId']) ? $ruleData['ruleId'] : false;
654
+ if($ruleId){
655
+ $result = $this->sendProductPrices($ruleId);
656
+ }
657
+ } else {
658
+ //send event to remarkety
659
+ $result = $this->makeRequest($_queue->getEventType(),
660
+ unserialize($_queue->getPayload()),
661
+ $resetAttempts ? 1 : ($_queue->getAttempts() + 1),
662
+ $_queue->getId());
663
+ }
664
  if ($result) {
665
  Mage::getModel('mgconnector/queue')
666
  ->load($_queue->getId())
685
 
686
  return $this;
687
  }
688
+
689
+ private function _filter_output_data($data, $field_set = array())
690
+ {
691
+ if (empty($field_set)) return $data;
692
+
693
+ foreach (array_keys($data) as $key) {
694
+ if (isset($field_set[$key]) && is_array($field_set[$key])) {
695
+ $data[$key] = $this->_filter_output_data($data[$key], $field_set[$key]);
696
+ } else if (isset($field_set['*']) && is_array($field_set['*'])) {
697
+ $data[$key] = $this->_filter_output_data($data[$key], $field_set['*']);
698
+ } else {
699
+ if (!in_array($key, $field_set)) unset ($data[$key]);
700
+ }
701
+ }
702
+ return $data;
703
+ }
704
+
705
+ protected function _productsUpdate($storeId, $data, $toQueue = false)
706
+ {
707
+ if($toQueue){
708
+ $this->_queueRequest('products/update', array('storeId' => $storeId, 'products' => $data), 1, null);
709
+ } else {
710
+ $this->makeRequest('products/update', array('storeId' => $storeId, 'products' => $data));
711
+ }
712
+
713
+ return $this;
714
+ }
715
+
716
+
717
+ public function sendProductPrices($ruleId = null)
718
+ {
719
+ $yesterday_start = date('Y-m-d 00:00:00',strtotime("-1 days"));
720
+ $yesterday_end = date('Y-m-d 23:59:59',strtotime("-1 days"));
721
+ $today_start = date('Y-m-d 00:00:00');
722
+ $today_end = date('Y-m-d 23:59:59');
723
+ $data = [];
724
+
725
+ Mage::log('sendProductPrices started', null, 'remarkety-ext.log');
726
+
727
+ $collection = Mage::getModel('catalogrule/rule')->getCollection();
728
+ $collection->getSelect()
729
+ ->joinLeft(
730
+ array('catalogrule_product' => Mage::getSingleton('core/resource')->getTableName('catalogrule/rule_product')),
731
+ 'main_table.rule_id = catalogrule_product.rule_id',
732
+ array('product_id')
733
+ )
734
+ ->group(['main_table.rule_id', 'catalogrule_product.product_id']);
735
+
736
+ if(is_null($ruleId)){
737
+ $collection->getSelect()
738
+ ->where('(main_table.from_date >= ?', $today_start)->where('main_table.from_date <= ?)', $today_end)
739
+ ->orWhere('(main_table.to_date >= ? ',$yesterday_start)->where('main_table.to_date <= ?)', $yesterday_end)
740
+ ->orWhere('(main_table.updated_at >= ? ',$yesterday_start)->where('main_table.updated_at <= ?)', $yesterday_end);
741
+ } else {
742
+ $collection->getSelect()
743
+ ->where('main_table.rule_id = ?', $ruleId);
744
+ }
745
+ $useQueue = !is_null($ruleId);
746
+
747
+ // $i = 0;
748
+ $ruleProducts = [];
749
+ foreach($collection->getData() as $c) {
750
+ if (!isset($ruleProducts[$c['rule_id']]))
751
+ $ruleProducts[$c['rule_id']] = [];
752
+ $ruleProducts[$c['rule_id']][] = $c['product_id'];
753
+ }
754
+
755
+ $storeUrls = [];
756
+ foreach($ruleProducts as $ruleId => $products) {
757
+ /**
758
+ * @var Mage_CatalogRule_Model_Rule
759
+ */
760
+ $catalog_rule = Mage::getModel('catalogrule/rule')->load($ruleId);
761
+ $websiteIds = $catalog_rule->getWebsiteIds();
762
+ foreach ($websiteIds as $websiteId) {
763
+ $website = Mage::getModel('core/website')->load($websiteId);
764
+ foreach ($website->getGroups() as $group) {
765
+ $stores = $group->getStores();
766
+ foreach ($stores as $store) {
767
+ if(!isset($storeUrls[$store->getStoreId()]))
768
+ $storeUrls[$store->getStoreId()] = Mage::app()->getStore($store->getStoreId())->getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB, true);
769
+ $isRemarketyInstalled = !empty($store->getConfig(Remarkety_Mgconnector_Model_Install::XPATH_INSTALLED));
770
+ if ($isRemarketyInstalled) {
771
+ $rows = [];
772
+ $i = 0;
773
+ foreach($products as $productId){
774
+ if($i >= 10){
775
+ $this->_productsUpdate($store->getStoreId(), $rows, $useQueue);
776
+ $i = 0;
777
+ $rows = [];
778
+ }
779
+ $product = Mage::getModel('catalog/product')->load($productId);
780
+ $pWebsites = $product->getWebsiteIds();
781
+ if(in_array($websiteId, $pWebsites)) {
782
+ $rows[] = $this->_prepareProductData($product, $store->getStoreId(), $storeUrls[$store->getStoreId()]);
783
+ $i++;
784
+ }
785
+ }
786
+ if($i > 0){
787
+ $this->_productsUpdate($store->getStoreId(), $rows, $useQueue);
788
+ }
789
+ }
790
+ }
791
+ }
792
+ }
793
+ }
794
+ return true;
795
+ }
796
+
797
+ private function _prepareProductData($product,$mage_store_id,$storeUrl)
798
+ {
799
+ $product->setStoreId($mage_store_id)->setCustomerGroupId(0);
800
+
801
+ $productData = $product->toArray();
802
+ $productData['base_image'] = array('src' => Mage::getModel('mgconnector/core')->getImageUrl($product, 'image', $mage_store_id));
803
+ $productData['small_image'] = array('src' => Mage::getModel('mgconnector/core')->getImageUrl($product, 'small', $mage_store_id));
804
+ $productData['thumbnail_image'] = array('src' => Mage::getModel('mgconnector/core')->getImageUrl($product, 'thumbnail', $mage_store_id));
805
+
806
+ $cats = Mage::getModel('mgconnector/core')->_productCategories($product);
807
+ $categoriesNames = array();
808
+ foreach($cats as $catName){
809
+ $categoriesNames[] = array('name' => $catName);
810
+ }
811
+ $productData['categories'] = $categoriesNames;
812
+
813
+ $price = Mage::getModel('catalogrule/rule')->calcProductPriceRule($product,$product->getPrice());
814
+ $productData['price'] = empty($price) ? $product->getFinalPrice() : $price;
815
+ $productData['special_price'] = $product->getSpecialPrice();
816
+
817
+ $prodUrl = Mage::getModel('mgconnector/core')->getProdUrl($product, $storeUrl, $mage_store_id);
818
+ $productData['id'] = $productData['entity_id'];
819
+ $productData['url'] = $prodUrl;
820
+ $productData['title'] = Mage::getModel('mgconnector/core')->getProductName($product, $mage_store_id);
821
+ $productData['enabled'] = $product->isSalable() && $product->isVisibleInSiteVisibility();
822
+ $productData['visibility'] = $product->getVisibility();
823
+
824
+
825
+ $parent_id = Mage::getModel('mgconnector/core')->getProductParentId($product);
826
+ if($parent_id !== false){
827
+ $productData['parent_id'] = $parent_id;
828
+ }
829
+
830
+ $productData = $this->_filter_output_data($productData, $this->response_mask['product']);
831
+
832
+ return $productData;
833
+ }
834
+
835
  }
app/code/community/Remarkety/Mgconnector/etc/config.xml CHANGED
@@ -2,7 +2,7 @@
2
  <config>
3
  <modules>
4
  <Remarkety_Mgconnector>
5
- <version>1.4.7.3</version>
6
  </Remarkety_Mgconnector>
7
  </modules>
8
  <global>
@@ -45,6 +45,15 @@
45
  </mgconnector>
46
  </blocks>
47
  <events>
 
 
 
 
 
 
 
 
 
48
  <catalog_product_save_after>
49
  <observers>
50
  <remarkety_catalog_product_save_after>
@@ -172,6 +181,10 @@
172
  <schedule><cron_expr>*/1 * * * *</cron_expr></schedule>
173
  <run><model>mgconnector/observer::run</model></run>
174
  </mgconnector_cron>
 
 
 
 
175
  </jobs>
176
  </crontab>
177
  <default>
@@ -186,4 +199,4 @@
186
  </rewardpoints>
187
  </mgconnector_supported_extensions>
188
  </default>
189
- </config>
2
  <config>
3
  <modules>
4
  <Remarkety_Mgconnector>
5
+ <version>1.4.8.1</version>
6
  </Remarkety_Mgconnector>
7
  </modules>
8
  <global>
45
  </mgconnector>
46
  </blocks>
47
  <events>
48
+ <catalogrule_rule_save_before>
49
+ <observers>
50
+ <remarkety_catalogrule_rule_save_before>
51
+ <type>singleton</type>
52
+ <class>mgconnector/observer</class>
53
+ <method>triggerCatalogRuleBeforeUpdate</method>
54
+ </remarkety_catalogrule_rule_save_before>
55
+ </observers>
56
+ </catalogrule_rule_save_before>
57
  <catalog_product_save_after>
58
  <observers>
59
  <remarkety_catalog_product_save_after>
181
  <schedule><cron_expr>*/1 * * * *</cron_expr></schedule>
182
  <run><model>mgconnector/observer::run</model></run>
183
  </mgconnector_cron>
184
+ <mgconnector_prices>
185
+ <schedule><cron_expr>0 0 * * *</cron_expr></schedule>
186
+ <run><model>mgconnector/observer::sendProductPrices</model></run>
187
+ </mgconnector_prices>
188
  </jobs>
189
  </crontab>
190
  <default>
199
  </rewardpoints>
200
  </mgconnector_supported_extensions>
201
  </default>
202
+ </config>
app/code/community/Remarkety/Mgconnector/sql/mgconnector_setup/mysql4-upgrade-1.4.7.2-1.4.8.0.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Upgrade script from version 1.4.7.2 to 1.4.8.0
5
+ *
6
+ * @category Remarkety
7
+ * @package Remarkety_Mgconnector
8
+ * @author Rafał Andryanczyk <rafal.andryanczyk@gmail.com>
9
+ */
10
+ $installer = $this;
11
+ $installer->startSetup();
12
+
13
+
14
+ $installer->getConnection()
15
+ ->addColumn($installer->getTable('catalogrule/rule'),'updated_at', array(
16
+ 'type' => Varien_Db_Ddl_Table::TYPE_TIMESTAMP,
17
+ 'nullable' => true,
18
+ 'default' => null,
19
+ 'comment' => 'updated_at',
20
+ ));
21
+
22
+ $installer->endSetup();
package.xml CHANGED
@@ -1,7 +1,7 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Remarkety_Mgconnector</name>
4
- <version>1.4.7.3</version>
5
  <stability>stable</stability>
6
  <license uri="http://www.gnu.org/licenses/gpl-3.0.html">GPL v3</license>
7
  <channel>community</channel>
@@ -9,11 +9,11 @@
9
  <summary>Remarkety Magento Connector</summary>
10
  <description>Remarkety Magento Connector</description>
11
  <notes>No comments</notes>
12
- <date>2016-07-05</date>
13
- <time>9-02-33</time>
14
  <contents>
15
  <target name="magecommunity">
16
- <dir name="Remarkety"><dir name="Mgconnector"><dir name="Block"><dir name="Adminhtml"><dir name="Configuration"><dir name="Complete"><file name="Form.php" hash="dc799532128513364fc3afd17eabb78b"/></dir><file name="Complete.php" hash="b9f7b4ecbd2be587c0efbd16523b167e"/><dir name="Configuration"><file name="Form.php" hash="ffe6b6ce5b2906c916694007ca5a1b28"/></dir><file name="Configuration.php" hash="67b3b564c2c3123301f5f97b2b258a7a"/><dir name="Install"><file name="Form.php" hash="59541fe2ad9a49b9fb56a41f00e6a591"/></dir><file name="Install.php" hash="f631fcdfd86d2bc416eb1ad4422fc20c"/><dir name="Upgrade"><file name="Form.php" hash="598f83eca99d0153537e22f9ee6b1934"/></dir><file name="Upgrade.php" hash="c672741b0407f108d2266dd939590846"/></dir><file name="Configuration.php" hash="bf0c9aabe92f669694e0699c009b2a9c"/><dir name="Extension"><file name="RewardPoints.php" hash="82e320930f59dfd45e5aa73005118833"/></dir><dir name="Install"><dir name="Complete"><file name="Form.php" hash="5992149b9ff2d2a7c2b008d98098362d"/></dir><file name="Complete.php" hash="452944c613b88ede358ee4dacd562d05"/><dir name="Install"><dir name="Create"><file name="Form.php" hash="65d98f1449ce6af413a3185692e07533"/></dir><file name="Create.php" hash="0d3182923fd5542e3d0a757625a85ae4"/><dir name="Login"><file name="Form.php" hash="a58c19056e47c7851eb6a5f40517f757"/></dir><file name="Login.php" hash="3ee61a883f843c55b1b32a328af84322"/></dir><dir name="Upgrade"><file name="Form.php" hash="6f4e2ac19d30115de4e275fdb8dca5b6"/></dir><file name="Upgrade.php" hash="f16ba61a8c86007bbc0a980e8faeade1"/><dir name="Welcome"><file name="Form.php" hash="58cb26cc7555498bd0367c77a99c8d60"/><file name="Store.php" hash="9f3b5c7bbd9f4d7201189598e5a64cc4"/></dir><file name="Welcome.php" hash="86589c79b5c38ea5f25d58ac932f33cb"/></dir><dir name="Queue"><dir name="Configure"><file name="Form.php" hash="8eb691898c79cd5aed15c7857cb84b4c"/></dir><file name="Configure.php" hash="03d5ebf7644462904c439d172cde3afc"/><dir name="Grid"><dir name="Column"><dir name="Renderer"><file name="EventType.php" hash="4ac5971c368b70efa96b4c8297c85c3c"/><file name="Status.php" hash="ec57ddafc2515b952958e6ace6de22ec"/></dir></dir></dir><file name="Grid.php" hash="74d5f3b18d76cdf8219e2d39a83a2f7c"/></dir><file name="Queue.php" hash="2c905cc54a6c08d4d73a392d5b95a25c"/></dir><dir name="Tracking"><file name="Base.php" hash="5e0f245ac5ee59d2f6c6f35087059b56"/><file name="General.php" hash="9ca2796c6f2bf9233553e6b782f3722b"/><file name="Product.php" hash="3a0c1b1a5fcbd23d1dcd04714742ebe9"/></dir></dir><dir name="Helper"><file name="Configuration.php" hash="5c20237a83db488fa1fae9345bacdb15"/><file name="Data.php" hash="b27f970b943e6e989e9061275cc25c7b"/><file name="Extension.php" hash="5788a232ffaa32674b4bfc1e12e4ea98"/><file name="Links.php" hash="8bb36c918e956663113646183bd33c4c"/><file name="Urls.php" hash="ce396940c96bf8139da8ec59bb498acf"/></dir><dir name="Model"><dir name="Core"><file name="Api.php" hash="948c7965f7fe9d044b532314aaa8e0f9"/></dir><file name="Core.php" hash="381770c2746209e17a96d738051f02b1"/><dir name="Extension"><dir name="RewardPoints"><file name="AbstractIntegration.php" hash="4ac34942072ce49d2971065a82d1068c"/><file name="IntegrationInterface.php" hash="f95f9f1e243c9fd920d27b9299b90f72"/><file name="MagestoreRewardPoints.php" hash="28671b6f35cb829f2d11166f081ad816"/><dir name="Observer"><file name="AbstractObserver.php" hash="eb710b7582050de644de2a8402d759ec"/><file name="MagestoreRewardPoints.php" hash="bac2ae11f94aa923accb0437027b4bec"/></dir></dir></dir><file name="Install.php" hash="fc260ea02ba27273cd51e7051c953cce"/><file name="Observer.php" hash="58af7cc67d91ae2fcb7890eb8c1a133c"/><file name="Queue.php" hash="3a0fda4b18ec947c20e6e81cc1e995de"/><file name="Recovery.php" hash="bd856fdd5788e00bcf29a67446ad8ef1"/><file name="Request.php" hash="47e81216d7bca3f0aba93bf816298221"/><dir name="Resource"><file name="Coupon.php" hash="6079c05e422e9c1ad5327fc881cee7e3"/><dir name="Queue"><file name="Collection.php" hash="ce59b04c8a8146f5094d6622134885d3"/></dir><file name="Queue.php" hash="971a539849d0cde2e413b0642403a6ca"/><dir name="Rule"><file name="Collection.php" hash="b7cd7bbc0c4100a1a320e0f551be067a"/></dir><file name="Setup.php" hash="13253a5b7a2749f4a3bc84e32e31e27c"/></dir><file name="Webtracking.php" hash="4b2d9d73dcc8d68b40f375f6c55c4999"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="ConfigureController.php" hash="b4e51acf22ea798e2d2144a4672bc30f"/><dir name="Extension"><file name="AbstractController.php" hash="f5402dbc0e13412a52b70b5d36a14110"/><file name="RewardPointsController.php" hash="3e94e5ae4d467abf03f41e260b0421f9"/></dir><file name="InstallController.php" hash="cebbe5f80c59d6fbc18eecff20e7d432"/><file name="MgconnectorController.php" hash="a8e55464624c5fa9e9641cf97f963b3b"/><file name="QueueController.php" hash="1f2f85bd1ecf2242dd40fc64ec1aa3b0"/></dir><file name="RecoveryController.php" hash="0a53efaef9019c6b661fe494067473e3"/><file name="WebtrackingController.php" hash="fd2c5034d94161c0e6f7f4e6b5816a55"/></dir><dir name="etc"><file name="adminhtml.xml" hash="a417737a2225ef9f70b47eef77d75b7c"/><file name="api.xml" hash="9f6d5fd3330bb0640f97efc3f819e684"/><file name="config.xml" hash="639e44fb93b2fe70610ef385d60e21ac"/></dir><dir name="sql"><dir name="mgconnector_setup"><file name="mysql4-install-1.0.0.13.php" hash="d1033ffd3d6b13af28ad4082d5744c25"/><file name="mysql4-upgrade-1.0.0.13-1.0.0.14.php" hash="db871ba73f3dcc7abfb806991edc12f1"/><file name="mysql4-upgrade-1.0.0.14-1.0.0.15.php" hash="c9ced7a4a2e85c9d594e9f97320cab58"/><file name="mysql4-upgrade-1.0.0.14-1.1.0.0.php" hash="fd445e8c179cdb2718a85adec05c5343"/><file name="mysql4-upgrade-1.1.0.5-1.1.0.6.php" hash="e24831cfd077827ba545f7ea71669729"/><file name="mysql4-upgrade-1.1.2.8-1.3.0.0.php" hash="97bbb9e411bcd45f875f29fcc8c8b420"/></dir></dir></dir></dir></target>
17
  <target name="mageetc">
18
  <dir name="modules"><file name="Remarkety_Mgconnector.xml" hash="d584b234f653fbf34376e7dcb8caf117"/></dir></target>
19
  <target name="magedesign">
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Remarkety_Mgconnector</name>
4
+ <version>1.4.8.1</version>
5
  <stability>stable</stability>
6
  <license uri="http://www.gnu.org/licenses/gpl-3.0.html">GPL v3</license>
7
  <channel>community</channel>
9
  <summary>Remarkety Magento Connector</summary>
10
  <description>Remarkety Magento Connector</description>
11
  <notes>No comments</notes>
12
+ <date>2016-07-27</date>
13
+ <time>7-28-50</time>
14
  <contents>
15
  <target name="magecommunity">
16
+ <dir name="Remarkety"><dir name="Mgconnector"><dir name="Block"><dir name="Adminhtml"><dir name="Configuration"><dir name="Complete"><file name="Form.php" hash="dc799532128513364fc3afd17eabb78b"/></dir><file name="Complete.php" hash="b9f7b4ecbd2be587c0efbd16523b167e"/><dir name="Configuration"><file name="Form.php" hash="ffe6b6ce5b2906c916694007ca5a1b28"/></dir><file name="Configuration.php" hash="67b3b564c2c3123301f5f97b2b258a7a"/><dir name="Install"><file name="Form.php" hash="59541fe2ad9a49b9fb56a41f00e6a591"/></dir><file name="Install.php" hash="f631fcdfd86d2bc416eb1ad4422fc20c"/><dir name="Upgrade"><file name="Form.php" hash="598f83eca99d0153537e22f9ee6b1934"/></dir><file name="Upgrade.php" hash="c672741b0407f108d2266dd939590846"/></dir><file name="Configuration.php" hash="bf0c9aabe92f669694e0699c009b2a9c"/><dir name="Extension"><file name="RewardPoints.php" hash="82e320930f59dfd45e5aa73005118833"/></dir><dir name="Install"><dir name="Complete"><file name="Form.php" hash="5992149b9ff2d2a7c2b008d98098362d"/></dir><file name="Complete.php" hash="452944c613b88ede358ee4dacd562d05"/><dir name="Install"><dir name="Create"><file name="Form.php" hash="65d98f1449ce6af413a3185692e07533"/></dir><file name="Create.php" hash="0d3182923fd5542e3d0a757625a85ae4"/><dir name="Login"><file name="Form.php" hash="a58c19056e47c7851eb6a5f40517f757"/></dir><file name="Login.php" hash="3ee61a883f843c55b1b32a328af84322"/></dir><dir name="Upgrade"><file name="Form.php" hash="6f4e2ac19d30115de4e275fdb8dca5b6"/></dir><file name="Upgrade.php" hash="f16ba61a8c86007bbc0a980e8faeade1"/><dir name="Welcome"><file name="Form.php" hash="58cb26cc7555498bd0367c77a99c8d60"/><file name="Store.php" hash="9f3b5c7bbd9f4d7201189598e5a64cc4"/></dir><file name="Welcome.php" hash="86589c79b5c38ea5f25d58ac932f33cb"/></dir><dir name="Queue"><dir name="Configure"><file name="Form.php" hash="8eb691898c79cd5aed15c7857cb84b4c"/></dir><file name="Configure.php" hash="03d5ebf7644462904c439d172cde3afc"/><dir name="Grid"><dir name="Column"><dir name="Renderer"><file name="EventType.php" hash="4ac5971c368b70efa96b4c8297c85c3c"/><file name="Status.php" hash="ec57ddafc2515b952958e6ace6de22ec"/></dir></dir></dir><file name="Grid.php" hash="74d5f3b18d76cdf8219e2d39a83a2f7c"/></dir><file name="Queue.php" hash="2c905cc54a6c08d4d73a392d5b95a25c"/></dir><dir name="Tracking"><file name="Base.php" hash="5e0f245ac5ee59d2f6c6f35087059b56"/><file name="General.php" hash="9ca2796c6f2bf9233553e6b782f3722b"/><file name="Product.php" hash="3a0c1b1a5fcbd23d1dcd04714742ebe9"/></dir></dir><dir name="Helper"><file name="Configuration.php" hash="5c20237a83db488fa1fae9345bacdb15"/><file name="Data.php" hash="b27f970b943e6e989e9061275cc25c7b"/><file name="Extension.php" hash="5788a232ffaa32674b4bfc1e12e4ea98"/><file name="Links.php" hash="8bb36c918e956663113646183bd33c4c"/><file name="Urls.php" hash="ce396940c96bf8139da8ec59bb498acf"/></dir><dir name="Model"><dir name="Core"><file name="Api.php" hash="948c7965f7fe9d044b532314aaa8e0f9"/></dir><file name="Core.php" hash="659c8fa2de196488ff568c83e66bdc26"/><dir name="Extension"><dir name="RewardPoints"><file name="AbstractIntegration.php" hash="4ac34942072ce49d2971065a82d1068c"/><file name="IntegrationInterface.php" hash="f95f9f1e243c9fd920d27b9299b90f72"/><file name="MagestoreRewardPoints.php" hash="28671b6f35cb829f2d11166f081ad816"/><dir name="Observer"><file name="AbstractObserver.php" hash="eb710b7582050de644de2a8402d759ec"/><file name="MagestoreRewardPoints.php" hash="bac2ae11f94aa923accb0437027b4bec"/></dir></dir></dir><file name="Install.php" hash="fc260ea02ba27273cd51e7051c953cce"/><file name="Observer.php" hash="09f3c036336f6ec5fbf2503fce5533a6"/><file name="Queue.php" hash="3a0fda4b18ec947c20e6e81cc1e995de"/><file name="Recovery.php" hash="bd856fdd5788e00bcf29a67446ad8ef1"/><file name="Request.php" hash="47e81216d7bca3f0aba93bf816298221"/><dir name="Resource"><file name="Coupon.php" hash="6079c05e422e9c1ad5327fc881cee7e3"/><dir name="Queue"><file name="Collection.php" hash="ce59b04c8a8146f5094d6622134885d3"/></dir><file name="Queue.php" hash="971a539849d0cde2e413b0642403a6ca"/><dir name="Rule"><file name="Collection.php" hash="b7cd7bbc0c4100a1a320e0f551be067a"/></dir><file name="Setup.php" hash="13253a5b7a2749f4a3bc84e32e31e27c"/></dir><file name="Webtracking.php" hash="4b2d9d73dcc8d68b40f375f6c55c4999"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="ConfigureController.php" hash="b4e51acf22ea798e2d2144a4672bc30f"/><dir name="Extension"><file name="AbstractController.php" hash="f5402dbc0e13412a52b70b5d36a14110"/><file name="RewardPointsController.php" hash="3e94e5ae4d467abf03f41e260b0421f9"/></dir><file name="InstallController.php" hash="cebbe5f80c59d6fbc18eecff20e7d432"/><file name="MgconnectorController.php" hash="a8e55464624c5fa9e9641cf97f963b3b"/><file name="QueueController.php" hash="1f2f85bd1ecf2242dd40fc64ec1aa3b0"/></dir><file name="RecoveryController.php" hash="0a53efaef9019c6b661fe494067473e3"/><file name="WebtrackingController.php" hash="fd2c5034d94161c0e6f7f4e6b5816a55"/></dir><dir name="etc"><file name="adminhtml.xml" hash="a417737a2225ef9f70b47eef77d75b7c"/><file name="api.xml" hash="9f6d5fd3330bb0640f97efc3f819e684"/><file name="config.xml" hash="1af56a8f01ec6de053c6ec13fecbf025"/></dir><dir name="sql"><dir name="mgconnector_setup"><file name="mysql4-install-1.0.0.13.php" hash="d1033ffd3d6b13af28ad4082d5744c25"/><file name="mysql4-upgrade-1.0.0.13-1.0.0.14.php" hash="db871ba73f3dcc7abfb806991edc12f1"/><file name="mysql4-upgrade-1.0.0.14-1.0.0.15.php" hash="c9ced7a4a2e85c9d594e9f97320cab58"/><file name="mysql4-upgrade-1.0.0.14-1.1.0.0.php" hash="fd445e8c179cdb2718a85adec05c5343"/><file name="mysql4-upgrade-1.1.0.5-1.1.0.6.php" hash="e24831cfd077827ba545f7ea71669729"/><file name="mysql4-upgrade-1.1.2.8-1.3.0.0.php" hash="97bbb9e411bcd45f875f29fcc8c8b420"/><file name="mysql4-upgrade-1.4.7.2-1.4.8.0.php" hash="bb01ef486d9457fc7ef661a654fd1ec6"/></dir></dir></dir></dir></target>
17
  <target name="mageetc">
18
  <dir name="modules"><file name="Remarkety_Mgconnector.xml" hash="d584b234f653fbf34376e7dcb8caf117"/></dir></target>
19
  <target name="magedesign">