BeezUP_Module_feed_and_tracker - Version 4.7.0

Version Notes

New features :
- Fixed bug with disabled carrier

Download this release

Release Info

Developer BeezUP
Extension BeezUP_Module_feed_and_tracker
Version 4.7.0
Comparing to
See all releases


Code changes from version 4.6.9 to 4.7.0

app/code/community/BeezUp/Block/Order.php CHANGED
@@ -1,11 +1,11 @@
1
- <?php
2
  require_once Mage::getModuleDir('', 'BeezUp') . DS . 'lib' . DS ."KLogger.php";
3
  require_once Mage::getModuleDir('', 'BeezUp') . DS . 'lib' . DS ."bootstrap.php";
4
  require_once Mage::getModuleDir('', 'BeezUp') . DS . 'lib' . DS ."BeezupRepository.php";
5
  require_once Mage::getModuleDir('', 'BeezUp') . DS . 'lib' . DS ."BeezupMageOrders.php";
6
 
7
  class Beezup_Block_Order extends Mage_core_block_text {
8
-
9
  protected $repository = null;
10
  protected $oOrderService;
11
  public $log = null;
@@ -17,31 +17,31 @@ class Beezup_Block_Order extends Mage_core_block_text {
17
  private $marketplace_code;
18
  private $beezup_order_id;
19
  private $mage_order_id = false;
20
-
21
-
22
  private function makeDir() {
23
-
24
  if (file_exists(Mage::getBaseDir('base').'/beezup/tmp')) { return true;}
25
-
26
  if (!mkdir(Mage::getBaseDir('base').'/beezup/tmp', 0777, true))
27
  {
28
- echo "[ERROR] : Seems we can't create 'beezup' directory inside your root directory."."<br/>"
29
- ."You can try one of these solutions :"."<br/>"
30
  ."1 - Create by yourself the beezup/tmp inside your root directory with 777 permissions"."<br/>"
31
  ."2 - Change the permissions on your root directory (777)"."<br/>"
32
- ."3 - Change the 'cache delay' option to 'None' inside beezup plugin settings"."<br/>";
33
  return false;
34
  }
35
  return true;
36
-
37
- }
38
  public function createOrderFromLink($account_id, $marketplace_code, $beezup_order_id) {
39
  $this->makeDir();
40
  $logDir = Mage::getBaseDir('base').'/beezup/';
41
  if(file_exists($logDir."log2.txt")) {
42
  if(filesize($logDir."/log2.txt") >=3000000) {
43
  unlink($logDir."log2.txt");
44
- }
45
  }
46
  $sync_end_date = new DateTime ( 'now', new DateTimeZone ( 'UTC' ));
47
  $helper = Mage::helper('beezup');
@@ -51,62 +51,62 @@ class Beezup_Block_Order extends Mage_core_block_text {
51
  if($create_customer == 0) {
52
  $this->blnCreateCustomer = true;
53
  }
54
-
55
  if($debug_mode==1) {
56
  $this->debug = true;
57
  }
58
  if($sync_status!==1) {
59
  $configModel = Mage::getModel('core/config');
60
  $configModel->saveConfig('beezup/marketplace/sync_status',1);
61
-
62
-
63
-
64
  unlink($logDir."log.txt");
65
  $this->log = new KLogger ( $logDir."log.txt" , KLogger::DEBUG );
66
  $this->log2 = new KLogger ( $logDir."log2.txt" , KLogger::DEBUG );
67
  $this->debugLog("Initializing OM Importation");
68
  $shiiping_disabled = Mage::getStoreConfig('carriers/flatrate/active');
69
-
70
  $this->account_id = $account_id;
71
  $this->marketplace_code = $marketplace_code;
72
  $this->beezup_order_id = $beezup_order_id;
73
  $orderResponse = $this->getBeezupOrder();
74
  if($orderResponse) {
75
-
76
  if($shiiping_disabled == 0) {
77
  Mage::getConfig()
78
  ->saveConfig('carriers/flatrate/active', 1)
79
  ->cleanCache();
80
  Mage::app()->reinitStores();
81
- }
82
  $this->createOrder($orderResponse);
83
  if($shiiping_disabled == 0) {
84
  Mage::getConfig()
85
  ->saveConfig('carriers/flatrate/active', 0)
86
  ->cleanCache();
87
  Mage::app()->reinitStores();
88
- }
89
  $configModel->saveConfig('beezup/marketplace/sync_status',0);
90
  if($this->mage_order_id) {
91
  echo "<script>window.location='".Mage::helper('adminhtml')->getUrl("adminhtml/sales_order/view", array('order_id'=> $this->mage_order_id))."';</script>";
92
  }
93
  // die("Order Importation finalized");
94
-
95
  }
96
-
97
  }
98
  $configModel->saveConfig('beezup/marketplace/sync_status',0);
99
  //die("Error, Order data incorrect");
100
  echo $this->_showLog();
101
  }
102
-
103
  public function _showLog() {
104
  $logDir = Mage::getBaseDir('base').'/beezup/';
105
  // $log1 = file_get_contents();
106
  $ret = array();
107
  if (file_exists($logDir."/log.txt")) {
108
  $f = fopen($logDir."/log.txt", 'r');
109
-
110
  if ($f) {
111
  while (!feof($f)) {
112
  $ret[] = fgetcsv($f, 0, '|');
@@ -115,16 +115,16 @@ class Beezup_Block_Order extends Mage_core_block_text {
115
  }
116
  }
117
  array_slice(array_reverse($ret), 1, 10);
118
-
119
  return $this->_getTable($ret);
120
-
121
  }
122
-
123
-
124
  public function _getTable($data) {
125
  $url = Mage::getBaseUrl( Mage_Core_Model_Store::URL_TYPE_WEB, true );
126
  $html = "<td></td><td></td><tr></tr></tbody></table>
127
-
128
  <div class='grid' style=' height: 600px;overflow-y: scroll;padding: 16px;border: 3px solid #e6e6e6;' id='marketPlaceLogBlock'>";
129
  $html .= '<p>'. Mage::helper('beezup')->__('For full logs see here:').' <a href="'.$url .'beezup/log/load" target="_blank">'.$url .'beezup/log/load</a></p>';
130
  $html .= "<table class='data' style='margin-top:0px;width:100%;'>";
@@ -148,30 +148,30 @@ class Beezup_Block_Order extends Mage_core_block_text {
148
  $html .= "<td>".$orderId."</td>";
149
  $html .= "<td>".$message."</td>";
150
  $html .= "</tr>";
151
-
152
  }
153
-
154
  $html .= "<tbody>";
155
  $html .= '</table>';
156
  $html .= "</div>";
157
-
158
  return $html;
159
  }
160
-
161
-
162
-
163
- public function executeCron() {
164
-
165
  $this->makeDir();
166
-
167
- set_time_limit(0);
168
  $logDir = Mage::getBaseDir('base').'/beezup/';
169
  if(file_exists($logDir."log2.txt")) {
170
  if(filesize($logDir."/log2.txt") >=3000000) {
171
  unlink($logDir."log2.txt");
172
- }
173
  }
174
-
175
  $sync_end_date = new DateTime ( 'now', new DateTimeZone ( 'UTC' ));
176
  $helper = Mage::helper('beezup');
177
  $sync_status = $helper->getConfig('beezup/marketplace/sync_status');
@@ -180,72 +180,72 @@ class Beezup_Block_Order extends Mage_core_block_text {
180
  if($create_customer == 0) {
181
  $this->blnCreateCustomer = true;
182
  }
183
-
184
  if($debug_mode==1) {
185
  $this->debug = true;
186
  }
187
-
188
  if($sync_status!==1) {
189
  $configModel = Mage::getModel('core/config');
190
  $configModel->saveConfig('beezup/marketplace/sync_status',1);
191
-
192
-
193
-
194
  unlink($logDir."log.txt");
195
  $this->log = new KLogger ( $logDir."log.txt" , KLogger::DEBUG );
196
  $this->log2 = new KLogger ( $logDir."log2.txt" , KLogger::DEBUG );
197
  $this->debugLog("Initializing OM Importation");
198
- $shiiping_disabled = Mage::getStoreConfig('');
199
  if($shiiping_disabled == 0) {
200
  Mage::getConfig()
201
  ->saveConfig('carriers/flatrate/active', 1)
202
  ->cleanCache();
203
  Mage::app()->reinitStores();
204
  }
205
-
206
-
207
  $this->getOrderList();
208
  if($shiiping_disabled == 0) {
209
  Mage::getConfig()
210
  ->saveConfig('carriers/flatrate/active', 0)
211
  ->cleanCache();
212
  Mage::app()->reinitStores();
213
- }
214
  $this->repository->updateLastSynchronizationDate( $sync_end_date);
215
  $this->orderid = "";
216
  $this->debugLog("OM Importation finalized succesfully");
217
  $configModel->saveConfig('beezup/marketplace/sync_status',0);
218
  echo "OM Importation finalized succesfully";
219
-
220
  } else {
221
-
222
  echo "Order Importation is already being executed";
223
  }
224
-
225
  }
226
-
227
-
228
  public function getLog() {
229
  $logDir = Mage::getBaseDir('base').'/beezup/';
230
  $log1 = file_get_contents($logDir."/log2.txt");
231
-
232
  echo "<pre>";
233
  print_r($log1);
234
  echo "</pre>";
235
-
236
  }
237
  public function getBeezupOrder() {
238
-
239
  $oOrderIdentifier = $this->getBeezupOrderId();
240
  $oBeezupOMOrderResponse = $this->getOrderService()->getOrder($oOrderIdentifier);
241
  if ($oBeezupOMOrderResponse && $oBeezupOMOrderResponse->getResult()){
242
  return $oBeezupOMOrderResponse;
243
  }
244
-
245
-
246
  return false;
247
  }
248
-
249
  public function getBeezupOrderId(){
250
  $oIdentifier = new BeezupOMOrderIdentifier();
251
  $oIdentifier
@@ -254,13 +254,13 @@ class Beezup_Block_Order extends Mage_core_block_text {
254
  ->setBeezupOrderUUID($this->beezup_order_id);
255
  return $oIdentifier;
256
  }
257
-
258
-
259
  public function createOrder($oBeezupOrderResponse) {
260
-
261
  $etag = $oBeezupOrderResponse->getETag();
262
- $final_order = $oBeezupOrderResponse->getResult();
263
-
264
  $orderid = $final_order->getOrderMarketPlaceOrderId();
265
  $this->orderid = $orderid;
266
  //customer Info
@@ -294,26 +294,26 @@ class Beezup_Block_Order extends Mage_core_block_text {
294
  //order Info
295
  $order_totalPrice = $final_order->getOrderTotalPrice();
296
  $order_shippingPrice = $final_order->getOrderShippingPrice();
297
-
298
  $name_parts = explode(" ", $order_customer);
299
  $order_first_name = array_shift( $name_parts);
300
  $order_last_name = implode(" ", $name_parts);
301
-
302
-
303
  $name_parts = explode(" ", $shipping_name);
304
  $shipping_first_name = array_shift( $name_parts);
305
  $shipping_last_name = implode(" ", $name_parts);
306
-
307
-
308
  //marketplace information
309
  $marketplace_business_code = $final_order->getMarketPlaceBusinessCode();
310
  $marketplace = $final_order->getMarketPlaceTechnicalCode();
311
-
312
- //productInfo
313
-
314
  $mage_productIds = $this->prescanOrder($final_order);
315
-
316
-
317
  if(!$this->checkEtagExists($etag)) {
318
  if(empty($order_customer_email)) {
319
  $order_customer_email = $this->generateEmail($final_order);
@@ -329,7 +329,7 @@ class Beezup_Block_Order extends Mage_core_block_text {
329
  }
330
  $mage_productIds = $this->prescanOrder($final_order);
331
  if($mage_productIds) {
332
- $order_data = array(
333
  "etag" => $etag,
334
  "account_id" => $account_id,
335
  "order_status" => $order_status,
@@ -366,77 +366,77 @@ class Beezup_Block_Order extends Mage_core_block_text {
366
  "discounts" => $mage_productIds['discounts'],
367
  "marketplace_business_code" => $marketplace_business_code
368
  );
369
-
370
-
371
-
372
  //check if order exists
373
  $Mageorder = $this->loadMageOrder();
374
  if ($Mageorder) {
375
  //if order exists
376
- $this->updateEtag($etag);
377
  $this->updateBilling($Mageorder, $order_data );
378
  $this->updateBeezupInfoTab($Mageorder, $final_order, $order_data);
379
  $this->debugLog("Order Already exists Mage Order ID: " .$Mageorder->getId());
380
  $status1 = $Mageorder->getStatusLabel();
381
  $status = $this->getStatus($status1);
382
- if($status !== $order_status) {
383
  //if order exits and status has changed we update order status
384
  $this->debugLog("Updating Order Status from: ".$status1." to: ".$order_status );
385
  $this->setStatus( $order_status, $Mageorder);
386
  }
387
-
388
  $id_order = $Mageorder->getId();
389
  $BeezupMageOrder = new BeezupMageOrders($id_order);
390
- $BeezupMageOrder->setData(array("shipping" =>(float) $order_data['order_shippingPrice']));
391
- $BeezupMageOrder->updateShippingInfo();
392
  } else {
393
  //if not we create order
394
-
395
-
396
  $this->debugLog("Generating Order");
397
- $this->addOrder($order_data,$final_order );
398
  //die();
399
-
400
  }
401
-
402
-
403
  } else {
404
  //order could not be imported
405
-
406
-
407
- }
408
-
409
-
410
  } else {
411
  //etag has not changed
412
  $this->debugLog("Order Etag has not changed");
413
-
414
  }
415
-
416
-
417
-
418
-
419
-
420
  }
421
-
422
-
423
-
424
  public function generateEmail(BeezupOMOrderResult $oBeezupOrder)
425
  {
426
  $sRawValue = $oBeezupOrder->getBeezupOrderUUID ();
427
  $sFakeDomain = preg_replace ( '/\W/', '', $oBeezupOrder->getMarketPlaceTechnicalCode () ) . '.com';
428
  return 'fakeemail' . md5 ( $sFakeDomain . $sRawValue ) . '@' . strtolower ( $sFakeDomain );
429
  }
430
-
431
-
432
-
433
  public function getOrderList($orderList = null) {
434
  if($orderList == null) {
435
  $data = $this->createRepository()->createOrderListRequest();
436
  $oRequest = $this->getOrderService()->getClientProxy()->getOrderList($data);
437
  $orderList = $oRequest->getResult();
438
  }
439
- $oPagination = $orderList->getPaginationResult();
440
  if(!empty($oPagination)) {
441
  $oLinksTotal = $oPagination->getLinks();
442
  } else {
@@ -444,7 +444,7 @@ class Beezup_Block_Order extends Mage_core_block_text {
444
  $configModel->saveConfig('beezup/marketplace/sync_status',0);
445
  die("No more orders to import");
446
  }
447
-
448
  //$header = $orderList->getOrderHeaders();
449
  foreach($orderList->getOrderHeaders() as $order) {
450
  $order_status = $order->getBeezupOrderState();
@@ -453,35 +453,35 @@ class Beezup_Block_Order extends Mage_core_block_text {
453
  $beezup_order_id = $order->getBeezupOrderUUID();
454
  $account_id = $order->getAccountId();
455
  $orderdata = $this->getOrderService()->getClientProxy()->getOrderByLink($orderLinks[0]);
456
- $this->debugLog("Initializing Order - Link: ".$orderLinks[0]->getHref());
457
  $this->createOrder($orderdata);
458
-
459
  }
460
-
461
  if(!empty($oLinksTotal)) {
462
- //we check if there is next link and get next orders
463
  foreach($oLinksTotal as $link) {
464
  if( $link->getRel() == "next") {
465
-
466
  $this->log->LogInfo("Initializing New Order List ->". $link->getHref());
467
  $this->log2->LogInfo("Initializing New Order List ->". $link->getHref());
468
  $oRequest = $this->getOrderService()->getClientProxy()->getOrderListByLink($link);
469
  $orderList = $oRequest->getResult();
470
  $this->getOrderList($orderList);
471
- }
472
-
473
  }
474
  }
475
-
476
  }
477
-
478
-
479
-
480
  public function updateBeezupInfoTab($order, $oLink, $data) {
481
  $beezup_last_modification_date = $oLink->getOrderLastModificationUtcDate();
482
- $beezup_last_modification_date = $beezup_last_modification_date->date;
483
  $beezup_marketplace_last_modification_date = $oLink->getOrderMarketPlaceLastModificationUtcDate();
484
- $beezup_marketplace_last_modification_date = $beezup_marketplace_last_modification_date->date;
485
  $beezup_comission = $oLink->getOrderTotalCommission()." ".$data['order_currency'];
486
  $tot_comm = $oLink->getOrderTotalCommission();
487
  if(empty($tot_comm ) || $tot_comm == 0) {
@@ -497,10 +497,10 @@ class Beezup_Block_Order extends Mage_core_block_text {
497
  $beezupMageOrder = new BeezupMageOrders($orderId);
498
  $beezupMageOrder->setData($updateData);
499
  $beezupMageOrder->updateBeezupInfo();
500
-
501
-
502
  }
503
-
504
  public function getPhone($phone, $phone2) {
505
  $retorno = "";
506
  if(!empty($phone) && $phone !== "") {
@@ -509,15 +509,15 @@ class Beezup_Block_Order extends Mage_core_block_text {
509
  if(!empty($phone2) && $phone2 !=="") {
510
  if(empty($phone) || $phone == "") {
511
  $retorno = $phone2;
512
-
513
  } else {
514
  $retorno .= " - ".$phone2;
515
  }
516
  }
517
  return $retorno;
518
  }
519
-
520
-
521
  public function getBeezupBuyerAddress($order) {
522
  $add1=$order->getOrderBuyerAddressLine1();
523
  $add2=$order->getOrderBuyerAddressLine2();
@@ -525,25 +525,25 @@ class Beezup_Block_Order extends Mage_core_block_text {
525
  $retorno = "";
526
  if(!empty($add1)) {
527
  $retorno = $order->getOrderBuyerAddressLine1();
528
- }
529
  if(!empty($add2)) {
530
  if(empty($add1)) {
531
- $retorno .= $order->getOrderBuyerAddressLine2();
532
  } else {
533
  $retorno .= " - ". $order->getOrderBuyerAddressLine2();
534
  }
535
- }
536
  if(!empty($add3)){
537
  if(empty($add1) && empty($add2)) {
538
- $retorno .= $order->getOrderBuyerAddressLine3();
539
  } else {
540
  $retorno .= " - ". $order->getOrderBuyerAddressLine3();
541
  }
542
- }
543
  return $retorno;
544
  }
545
-
546
-
547
  public function getBeezupShippingAddress($order) {
548
  $add1 = $order->getOrderShippingAddressLine1();
549
  $add2 = $order->getOrderShippingAddressLine2();
@@ -551,54 +551,54 @@ class Beezup_Block_Order extends Mage_core_block_text {
551
  $retorno = "";
552
  if(!empty($add1 )) {
553
  $retorno = $order->getOrderShippingAddressLine1();
554
- }
555
  if(!empty($add2)) {
556
  if(empty($add1)) {
557
- $retorno .= $order->getOrderShippingAddressLine2();
558
  } else {
559
  $retorno .= " - ". $order->getOrderShippingAddressLine2();
560
  }
561
- }
562
  if(!empty($add3)){
563
  if(empty($add1) && empty($add2)) {
564
- $retorno .= $order->getOrderShippingAddressLine3();
565
  } else {
566
  $retorno .= " - ". $order->getOrderShippingAddressLine3();
567
  }
568
- }
569
  return $retorno;
570
  }
571
-
572
  public function checkEtagExists($etag) {
573
  $resource = Mage::getSingleton('core/resource');
574
  $readConnection = $resource->getConnection('core_read');
575
  $table = $resource->getTableName('sales/order_grid');
576
  $query = 'SELECT increment_id FROM ' . $table . ' WHERE beezup_etag = \''
577
- . $etag . '\' LIMIT 1';
578
  $order = $readConnection->fetchOne($query);
579
  if($order && !empty($order)) {
580
  return true;
581
  }
582
  return false;
583
-
584
  }
585
-
586
-
587
  public function updateEtag($etag) {
588
  $this->debugLog("Updating Etag");
589
  $resource = Mage::getSingleton('core/resource');
590
  $writeConnection = $resource->getConnection('core_write');
591
  $table = $resource->getTableName('sales/order_grid');
592
  $query = "UPDATE {$table} SET beezup_etag = '{$etag}' where beezup_market_order_id = '{$this->orderid}' ";
593
- $writeConnection->query($query);
594
-
595
  }
596
-
597
-
598
-
599
  public function updateBilling($order, $data) {
600
-
601
-
602
  $addressData = array(
603
  'billing_firstname' => ($data['order_customer']) ? $data['order_customer'] : "empty",
604
  'billing_lastname' => ($data['order_lastname']) ? $data['order_lastname'] : "empty",
@@ -617,9 +617,9 @@ class Beezup_Block_Order extends Mage_core_block_text {
617
  'shipping_country_id' => ($data['shipping_country_iso']) ? $data['shipping_country_iso'] : "empty",
618
  'shipping_region_id' => ($data['shipping_region']) ? substr($data['shipping_region'], 0, 2) : "EM" // id from directory_country_region table
619
  );
620
-
621
  $shippingData = array(
622
-
623
  );
624
  // Get the id of the orders shipping address
625
  $orderId = $order->getId();
@@ -627,7 +627,7 @@ class Beezup_Block_Order extends Mage_core_block_text {
627
  $beezupMageOrder->setData($addressData);
628
  $beezupMageOrder->updateAdresses();
629
  }
630
-
631
  public function updateAddresses($shippingData, $address) {
632
  if($shippingData['firstname'] !==$address['firstname']) {
633
  $address->setFirstname($shippingData['firstname']);
@@ -646,13 +646,13 @@ class Beezup_Block_Order extends Mage_core_block_text {
646
  }
647
  if($shippingData['telephone'] !==$address['telephone']) {
648
  $address->setTelephone($shippingData['telephone']);
649
- }
650
  $address->save();
651
-
652
-
653
  }
654
-
655
-
656
  public function loadMageOrder() {
657
  $Mageorder = Mage::getModel('sales/order')->loadByIncrementId($this->orderid);
658
  if ($Mageorder->getId()) {
@@ -670,24 +670,24 @@ class Beezup_Block_Order extends Mage_core_block_text {
670
  }
671
  return false;
672
  }
673
-
674
-
675
  private function debugLog($message) {
676
-
677
  if($this->orderid !== "") {
678
  $message = $this->orderid." | ".$message;
679
  }
680
  $this->log->LogInfo($message);
681
-
682
  $this->log2->LogInfo($message);
683
  }
684
-
685
  public function prescanOrder(BeezupOMOrderResult $order) {
686
  $retorno = array();
687
  $orderItems = $order->getOrderItems();
688
  foreach ($orderItems as $item)
689
  {
690
-
691
  if ($item->getOrderItemOrderItemType () !== 'Product')
692
  {
693
  // continue;
@@ -696,20 +696,20 @@ class Beezup_Block_Order extends Mage_core_block_text {
696
  $mage_storeid = $this->checkOrderStore($beezup_store); //magento storeid
697
  $marketplace_orderid = $item->getOrderItemMarketPlaceProductId();
698
  if(!$mage_storeid) {
699
-
700
  if(strpos($marketplace_orderid,'INTERETBCA') !== false || strpos($marketplace_orderid,'interetbca') !== false) { }
701
  else {
702
  $this->log->LogError($this->orderid." | No mapping for store ".$beezup_store);
703
  $this->log2->LogError($this->orderid." | No mapping for store ".$beezup_store);
704
  return false;
705
- }
706
-
707
  }
708
  // $retorno['store'] = 1;
709
-
710
  $product_ImportedMerchantId = $item->getOrderItemMerchantImportedProductId();
711
  $product_MerchantId = $item->getOrderItemMerchantProductId();
712
-
713
  $product_quantity = $item->getOrderItemQuantity();
714
  $product_price = $item->getOrderItemItemPrice();
715
  $product_title = $item->getOrderItemTitle();
@@ -718,13 +718,13 @@ class Beezup_Block_Order extends Mage_core_block_text {
718
  $retorno['discounts']= $item->getOrderItemTotalPrice();
719
  } else {
720
  $retorno['store'] = $mage_storeid;
721
- $this->debugLog("Store Matching succesful, Beezup Store: ".$beezup_store." , Magento Store Id: ".$mage_storeid);
722
  $product = $this->getMageProduct($product_ImportedMerchantId , $product_MerchantId , $beezup_store );
723
  if($product) {
724
  $mage_productId = $product->getId();
725
  $stocklevel = (int)Mage::getModel('cataloginventory/stock_item')
726
  ->loadByProduct($product)->getQty();
727
-
728
  $retorno['products'][] = array("id" => $mage_productId, "qty" => $product_quantity, "price" => $product_price, "curr_stock" => $stocklevel);
729
  //producto existe
730
  } else {
@@ -746,58 +746,58 @@ class Beezup_Block_Order extends Mage_core_block_text {
746
  return false;
747
  }
748
  $stocklevel = (int)Mage::getModel('cataloginventory/stock_item')
749
- ->loadByProduct($product)->getQty();
750
  $mage_productId = $product->getId();
751
  $retorno['products'][] = array("id" => $mage_productId, "qty" => $product_quantity, "price" => $product_price, "curr_stock" => $stocklevel);
752
  }
753
  }
754
  }
755
-
756
  return $retorno;
757
  }
758
-
759
-
760
-
761
  public function matchProductAttributes($importedId, $storeId) {
762
  $product = null;
763
  $helper = Mage::helper('beezup');
764
  $attributes = $helper->getConfig('beezup/marketplace/attributes');
765
  $attributes = unserialize ($attributes);
766
-
767
  foreach($attributes['attributes'][$storeId ] as $attribute) {
768
  $att = explode("|", $attribute);
769
  if($storeId == $att[1]) {
770
-
771
  $product=Mage::getModel('catalog/product')->loadByAttribute($att[0],$importedId);
772
  if($product) {
773
  break;
774
- }
775
  }
776
  }
777
-
778
  return $product;
779
  }
780
-
781
-
782
-
783
  public function getMageProduct($importedId, $merchantId, $storeId){
784
  try {
785
- $product=Mage::getModel('catalog/product')->load($importedId);
786
  if (!$product->getId() || $product->getId() !== $importedId ){
787
  $product = $this->matchProductAttributes($importedId, $storeId);
788
  if($product == null || !is_object($product)) {
789
- $product=Mage::getModel('catalog/product')->load($merchantId);
790
- if(!$product->getId() || $product->getId() !== $merchantId ) {
791
  $product = $this->matchProductAttributes($merchantId, $storeId);
792
-
793
  }
794
  }
795
  }
796
-
797
  if(is_object($product)) {
798
  if($product->getId()) {
799
  $this->debugLog("Product Matching succesful, Beezup Imported Id: ".$importedId." , Magento Product Id: ".$product->getId());
800
- return $product;
801
  }}
802
  $this->log->LogError($this->orderid. "| No Product Matching, Product ".$importedId." could not be found");
803
  $this->log2->LogError($this->orderid. "| No Product Matching, Product ".$importedId." could not be found");
@@ -807,11 +807,11 @@ class Beezup_Block_Order extends Mage_core_block_text {
807
  $this->log2->LogError($this->orderid. "| Product ".$importedId." could not be found, error: ".$e->getMessage());
808
  return false;
809
  //error no se pudo crear la orden
810
-
811
  }
812
  }
813
-
814
-
815
  public function checkOrderStore($storeId ) {
816
  $helper = Mage::helper('beezup');
817
  $stores = $helper->getConfig('beezup/marketplace/stores');
@@ -823,9 +823,9 @@ class Beezup_Block_Order extends Mage_core_block_text {
823
  }
824
  return false;
825
  }
826
-
827
-
828
-
829
  /**
830
  * @return BeezupOMOrderService
831
  */
@@ -836,26 +836,26 @@ class Beezup_Block_Order extends Mage_core_block_text {
836
  }
837
  return $this->oOrderService;
838
  }
839
-
840
  /**
841
  * @return BeezupOMOrderService
842
  */
843
  protected function createOrderService(){
844
-
845
  return new BeezupOMOrderService($this->createRepository() );
846
  }
847
-
848
  protected function createRepository() {
849
  if ($this->repository == null) {
850
  $this->repository = new BeezupRepository();
851
- }
852
  return $this->repository;
853
-
854
  }
855
-
856
-
857
-
858
-
859
  private function createCustomer($customer_email , $data) {
860
  $password = $this->orderid;
861
  $this->debugLog("Creating new Customer");
@@ -876,25 +876,25 @@ class Beezup_Block_Order extends Mage_core_block_text {
876
  //Make a "login" of new customer
877
  // Mage::getSingleton('customer/session')->loginById($customer->getId());
878
  }
879
-
880
  catch (Exception $ex) {
881
  //Zend_Debug::dump($ex->getMessage());
882
  //GUARDAR ERROR CREACION USUARIO
883
  $this->log2->LogError($this->orderid. " | Customer importation failed: ".$ex->getMessage());
884
  return false;
885
  }
886
-
887
  } else {
888
  $this->debugLog("Creating already exists, returning customer object");
889
  return $customer;
890
  }
891
  }
892
-
893
-
894
-
895
  public function addOrder($data, $oLink, $stop = false) {
896
-
897
-
898
  try {
899
  $helper = Mage::helper('beezup');
900
  $addStock = $helper->getConfig('beezup/marketplace/available_products');
@@ -902,11 +902,11 @@ class Beezup_Block_Order extends Mage_core_block_text {
902
  $quote = Mage::getModel('sales/quote')
903
  ->setStoreId($data['storeid']);
904
  $quote->setCustomerEmail($data['order_customer_email']);
905
-
906
-
907
- $currency = Mage::getModel('directory/currency')->load($data['order_currency']);
908
  $quote->setForcedCurrency($currency);
909
-
910
  $blnCreate = true;
911
  $total_new_price = 0;
912
  foreach($data['products'] as $prod) {
@@ -923,37 +923,37 @@ class Beezup_Block_Order extends Mage_core_block_text {
923
  $this->debugLog("Adding ".$prod['qty']." product/s with id ".$product->getId()." to order, with Beezup Price: ".$prod['price']);
924
  //echo "Product ".$product->getId()."<br><br>";
925
  //para no perder stock:
926
- //Mage::getModel('cataloginventory/stock')->backItemQty($productId,$new_qty);
927
-
928
-
929
  if($addStock == 1) {
930
  $stock = Mage::getModel('cataloginventory/stock_item')->loadByProduct($product);
931
-
932
  if ($stock->getQty() < $prod['qty'] && $product->getStockItem()->getMaxSaleQty() >= $prod['qty']) {
933
  $this->debugLog("Product ".$product->getId()." Stock = 0, Updating to ".$prod['qty']." to generate Order");
934
- // Mage::getModel('cataloginventory/stock')->backItemQty($product->getId(),$prod['qty']);
935
  //$this->_updateStocks(array("id_product" => $product->getId(), "qty" => $prod['qty']));
936
  $product->setStockData(
937
- array(
938
- 'is_in_stock' => 1,
939
  'qty' => $prod['qty'],
940
  'manage_stock' => 1,
941
  'use_config_notify_stock_qty' => 1
942
  )
943
- );
944
  $product->save();
945
  $product = Mage::getModel('catalog/product')->load($product->getId());
946
-
947
  }
948
  }
949
  //fin para no perder stock
950
-
951
  /*
952
  $tax_class = $product->getTaxClassId();
953
  $product->setTaxClassId(0);
954
  $product->getResource()->saveAttribute($product, 'tax_class_id'); */
955
  $price = $prod['price'];
956
-
957
  $quote_item = Mage::getModel('beezup/quote_item');
958
  $quote_item
959
  ->setProduct($product)
@@ -963,19 +963,19 @@ class Beezup_Block_Order extends Mage_core_block_text {
963
  ->setQuote($quote)
964
  ->setQty((integer) $prod['qty'])
965
  ->setBeezupPrice((float) $price );
966
-
967
-
968
- $quote->addItem($quote_item);
969
-
970
  //$quote->addProduct($product, new Varien_Object($buyInfo))->setOriginalCustomPrice($price)->setCustomPrice($price);
971
-
972
- /*
973
  $product->setTaxClassId($tax_class);
974
-
975
- $product->getResource()->saveAttribute($product, 'tax_class_id');
976
  */
977
  }
978
-
979
  if($blnCreate) {
980
  $addressData = array(
981
  'firstname' => ($data['order_customer']) ? $data['order_customer'] : "empty",
@@ -987,7 +987,7 @@ class Beezup_Block_Order extends Mage_core_block_text {
987
  'country_id' => ($data['order_country_iso']) ? $data['order_country_iso'] : "empty",
988
  'region_id' => ($data['order_region ']) ? substr($data['order_region '], 0,2) : "EM"// id from directory_country_region table
989
  );
990
-
991
  $shippingData = array(
992
  'firstname' => ($data['shipping_name']) ? $data['shipping_name'] : "empty",
993
  'lastname' => ($data['shipping_lastname']) ? $data['shipping_lastname'] : "empty",
@@ -998,14 +998,14 @@ class Beezup_Block_Order extends Mage_core_block_text {
998
  'country_id' => ($data['shipping_country_iso']) ? $data['shipping_country_iso'] : "empty",
999
  'region_id' => ($data['shipping_region']) ? substr($data['shipping_region'], 0, 2) : "EM" // id from directory_country_region table
1000
  );
1001
-
1002
  if($this->blnCreateCustomer) {
1003
-
1004
  $mage_customer = $this->createCustomer($data['order_customer_email'], $addressData);
1005
  $quote->assignCustomer($mage_customer);
1006
  }
1007
-
1008
-
1009
  $payment_method = $helper->getConfig('beezup/marketplace/payment_method');
1010
  $billingAddress = $quote->getBillingAddress()->addData($addressData);
1011
  $shippingAddress = $quote->getShippingAddress()->addData($shippingData);
@@ -1017,27 +1017,27 @@ class Beezup_Block_Order extends Mage_core_block_text {
1017
  Mage::unregister('shipping_cost');
1018
  Mage::register('shipping_cost', $shipping_cost);
1019
  $this->debugLog("Adding Order Shipping Cost: ". $data['order_shippingPrice']);
1020
-
1021
  $shippingAddress->setCollectShippingRates(true)->collectShippingRates()
1022
  ->setShippingMethod('flatrate_flatrate')
1023
  ->setPaymentMethod($payment_method);
1024
-
1025
  //$shippingAddress->addTotal(array("code" => "specialfee", "title" => "Special Fee", "value" => 20));
1026
  $quote->getPayment()->importData(array('method' => $payment_method));
1027
-
1028
  $quote->collectTotals()->save();
1029
-
1030
  $service = Mage::getModel('sales/service_quote', $quote);
1031
  $service->submitAll();
1032
  $order = $service->getOrder();
1033
-
1034
-
1035
-
1036
  $quoteId = $order->getQuoteId();
1037
  //$this->setStatus($data['order_status'], $order);
1038
-
1039
  $orderid = $order->getId();
1040
-
1041
  $resource = Mage::getSingleton('core/resource');
1042
  $writeConnection = $resource->getConnection('core_write');
1043
  $table = $resource->getTableName('sales/order_grid');
@@ -1058,7 +1058,7 @@ class Beezup_Block_Order extends Mage_core_block_text {
1058
  /* $date = new DateTime($$beezup_marketplace_last_modification_date);
1059
  $beezup_marketplace_last_modification_date = $date->format('d-m-Y H:i:s'). "(UTC Time)";
1060
  */
1061
-
1062
  $beezup_total_paid = $oLink->getOrderTotalPrice()." ".$data['order_currency'];
1063
  $beezup_account_id = $oLink->getAccountId();
1064
  $beezup_comission = $oLink->getOrderTotalCommission()." ".$data['order_currency'];
@@ -1071,20 +1071,20 @@ class Beezup_Block_Order extends Mage_core_block_text {
1071
  beezup_marketplace_status = '{$beezup_marketplace_status}', beezup_purchase_date = '{$beezup_purchase_date}', beezup_marketplace_last_modification_date = '{$beezup_marketplace_last_modification_date}',
1072
  beezup_total_paid = '{$beezup_total_paid}', beezup_etag = '{$data['etag']}' , beezup_comission = '{$beezup_comission}', beezup_marketplace_business_code = '{$marketplace_business_code}'
1073
  WHERE entity_id = ". (int)$orderid;
1074
- $writeConnection->query($query);
1075
  $disc_price = 0;
1076
  if(!empty($data['discounts']) && $data['discounts'] >0) {
1077
-
1078
-
1079
  $disc_price = round($data['discounts'],2);
1080
  $total_new_price = $total_new_price+$disc_price;
1081
  $table_address = $resource->getTableName("sales/quote_address");
1082
-
1083
  $query = "update {$table_address} set beezup_fee = '{$disc_price}' where quote_id = '{$quoteId}' and address_type = 'shipping'";
1084
- $writeConnection->query($query);
1085
  $this->debugLog("Adding CDISCOUNT products with total price: ".$disc_price);
1086
  }
1087
-
1088
  //if order id exists and has been created
1089
  if ($orderid)
1090
  {
@@ -1094,28 +1094,28 @@ class Beezup_Block_Order extends Mage_core_block_text {
1094
  $oResult->setOrderMerchantOrderId ( $orderid )->setOrderMerchantECommerceSoftwareName ( 'Magento' )->setOrderMerchantECommerceSoftwareVersion ( Mage::getVersion() );
1095
  $sendRequest = $this->getOrderService()->getClientProxy()->setOrderMerchantIdByLink($oLink->getLinkByRel('setMerchantOrderId'), $oResult);
1096
  }
1097
-
1098
  $grand_total = $order->getGrandTotal();
1099
  $beezup_price = $oLink->getOrderTotalPrice() - $disc_price;
1100
  if($grand_total != (float) $beezup_price && $beezup_price > 0) {
1101
  $order->setGrandTotal((float) $beezup_price);
1102
  $order->setBaseGrandTotal((float) $beezup_price);
1103
  $diff = (((float) $beezup_price) - $grand_total);
1104
-
1105
  $order->setTaxAmount($order->getTaxAmount() + $diff);
1106
  $order->save();
1107
  }elseif($grand_total != (float)$beezup_price && $beezup_price < 1) {
1108
-
1109
  $order->setGrandTotal((float) $total_new_price);
1110
  $order->setBaseGrandTotal((float) $total_new_price);
1111
  $diff = (((float) $total_new_price) - $grand_total);
1112
-
1113
  $order->setTaxAmount($order->getTaxAmount() + $diff);
1114
  $order->save();
1115
  }
1116
-
1117
  $products = Mage::getResourceModel('sales/order_item_collection')
1118
- ->setOrderFilter($orderid);
1119
  foreach($products as $product) {
1120
  $product->setBaseOriginalPrice($product->getOriginalPrice());
1121
  $product->setBaseTaxAmount($product->getTaxAmount());
@@ -1131,7 +1131,7 @@ class Beezup_Block_Order extends Mage_core_block_text {
1131
  $order->setBaseGrandTotal($order->getTotalPaid());
1132
  $order->setBaseSubtotalInclTax($order->getSubtotalInclTax());
1133
  $order->save();
1134
-
1135
  $this->setStatus($data['order_status'], $order);
1136
  $this->mage_order_id = $orderid;
1137
  $this->debugLog("Order imported succesfully, Magento Order Id: ".$orderid);
@@ -1141,8 +1141,8 @@ class Beezup_Block_Order extends Mage_core_block_text {
1141
  $this->log2->LogError($this->orderid. "| Order ".$data['market_place_order_id']." could not be imported, error: Stock from Beezup product = 0 ");
1142
  }
1143
  }catch(Exception $e){
1144
-
1145
-
1146
  if($stop) {
1147
  $this->log->LogError($this->orderid. "| Order ".$data['market_place_order_id']." could not be imported, error: ".$e->getMessage());
1148
  $this->log2->LogError($this->orderid. "| Order ".$data['market_place_order_id']." could not be imported, error: ".$e->getMessage());
@@ -1150,21 +1150,21 @@ class Beezup_Block_Order extends Mage_core_block_text {
1150
  } else {
1151
  $this->debugLog("Order Import failed, Trying to import Order Again");
1152
  $this->addOrder($data, $oLink, true);
1153
-
1154
  }
1155
  //error no se pudo crear la orden
1156
-
1157
  }
1158
-
1159
-
1160
-
1161
  }
1162
-
1163
-
1164
-
1165
  public function restoreStock($data) {
1166
-
1167
- try {
1168
  foreach($data['products'] as $prod) {
1169
  $product = Mage::getModel('catalog/product')->load($prod['id']);
1170
  $stock = Mage::getModel('cataloginventory/stock_item')->loadByProduct($product);
@@ -1174,30 +1174,30 @@ class Beezup_Block_Order extends Mage_core_block_text {
1174
  $stockItem->setData('is_in_stock', 0);
1175
  $stockItem->setData('qty', $prod['curr_stock']);
1176
  $stockItem->save();
1177
- $product->save();
1178
  }
1179
-
1180
  }
1181
  } catch(Exception $e){
1182
  $this->log->LogError($this->orderid. "| Failed Restoring Product Stock: ".$e->getMessage());
1183
  $this->log2->LogError($this->orderid. "| Failed Restoring Product Stock: ".$e->getMessage());
1184
  }
1185
-
1186
  }
1187
-
1188
-
1189
-
1190
  private function createProduct($data) {
1191
-
1192
  $sku = $data['sku'];
1193
  if(empty($data['sku'])) {
1194
  $sku = $data['sku2'];
1195
- }
1196
-
1197
  Mage::app()->setCurrentStore($data['storeId']);
1198
  $product = Mage::getModel('catalog/product');
1199
  // if(!$product->getIdBySku('testsku61')):
1200
-
1201
  try{
1202
  $product
1203
  // ->setStoreId(1) //you can set data in store scope
@@ -1233,7 +1233,7 @@ class Beezup_Block_Order extends Mage_core_block_text {
1233
  );
1234
  $product->save();
1235
  return $product;
1236
-
1237
  }catch(Exception $e){
1238
  //log exception
1239
  $this->log->LogError($this->orderid."| Product ".$sku." could not be created, error: ".$e->getMessage());
@@ -1241,9 +1241,9 @@ class Beezup_Block_Order extends Mage_core_block_text {
1241
  return false;
1242
  }
1243
  }
1244
-
1245
-
1246
-
1247
  public function setStatus($status, $order) {
1248
  $helper = Mage::helper('beezup');
1249
  $retorno = "";
@@ -1263,8 +1263,8 @@ class Beezup_Block_Order extends Mage_core_block_text {
1263
  $this->debugLog("Setting Order Status to Aborted");
1264
  $retorno = $helper->getConfig('beezup/marketplace/status_aborted');
1265
  $blnHold = true;
1266
-
1267
-
1268
  break;
1269
  case "Closed" :
1270
  $this->debugLog("Setting Order Status to Closed");
@@ -1275,17 +1275,17 @@ class Beezup_Block_Order extends Mage_core_block_text {
1275
  case "Canceled" :
1276
  $this->debugLog("Setting Order Status to Cancelled");
1277
  $retorno = $helper->getConfig('beezup/marketplace/status_cancelled');
1278
-
1279
  break;
1280
  case "Shipped" :
1281
  $this->debugLog("Setting Order Status to Shipped");
1282
  $retorno = $helper->getConfig('beezup/marketplace/status_shipped');
1283
  $this->payOrder($order);
1284
  break;
1285
-
1286
  }
1287
  $order->setData('state',$retorno);
1288
- $order->setStatus($retorno);
1289
  $history = $order->addStatusHistoryComment('Order was set to '.$retorno.' by Beezup.', false);
1290
  $history->setIsCustomerNotified(false);
1291
  $order->save();
@@ -1295,62 +1295,62 @@ class Beezup_Block_Order extends Mage_core_block_text {
1295
  if($blnHold) {
1296
  $order->hold()->save();
1297
  }
1298
-
1299
  return $retorno;
1300
-
1301
  }
1302
-
1303
-
1304
  public function getStatus($status1) {
1305
  $helper = Mage::helper('beezup');
1306
  $retorno = "";
1307
  $status = strtolower($status1);
1308
-
1309
  if($status == strtolower($helper->getConfig('beezup/marketplace/status_new') )) {
1310
  $retorno = "New";
1311
-
1312
  } elseif($status == strtolower($helper->getConfig('beezup/marketplace/status_progress') ) ){
1313
  $retorno = "InProgress";
1314
-
1315
-
1316
  }
1317
  elseif($status == strtolower($helper->getConfig('beezup/marketplace/status_aborted') )) {
1318
-
1319
- $retorno = "Aborted" ;
1320
  }
1321
  elseif($status == strtolower($helper->getConfig('beezup/marketplace/status_closed') )) {
1322
  $retorno = "Closed";
1323
-
1324
  }
1325
  elseif($status == strtolower($helper->getConfig('beezup/marketplace/status_cancelled')) ) {
1326
-
1327
  $retorno = "Canceled";
1328
  }
1329
  elseif($status == strtolower($helper->getConfig('beezup/marketplace/status_shipped') )) {
1330
-
1331
  $retorno = "Shipped";
1332
  }
1333
-
1334
-
1335
  return $retorno;
1336
-
1337
  }
1338
-
1339
-
1340
  public function checkMarketOrderExists($orderid) {
1341
  $resource = Mage::getSingleton('core/resource');
1342
  $readConnection = $resource->getConnection('core_read');
1343
  $table = $resource->getTableName('sales/order_grid');
1344
  $query = 'SELECT increment_id FROM ' . $table . ' WHERE beezup_order = 1 and beezup_market_order_id = \''
1345
- . $orderid . '\' LIMIT 1';
1346
  $order = $readConnection->fetchOne($query);
1347
  if($order && !empty($order) && $this->orderId !== "") {
1348
  return $order;
1349
  }
1350
  return false;
1351
-
1352
  }
1353
-
1354
  public function payOrder($order) {
1355
  try {
1356
  $this->debugLog("Generating Order Payment Invoice");
@@ -1373,10 +1373,10 @@ class Beezup_Block_Order extends Mage_core_block_text {
1373
  $this->log2->LogError($this->orderid."| Order Payment Invoice could not be generated, error: ".$e->getMessage());
1374
  }
1375
  }
1376
-
1377
-
1378
-
1379
-
1380
-
1381
-
1382
- }
1
+ <?php
2
  require_once Mage::getModuleDir('', 'BeezUp') . DS . 'lib' . DS ."KLogger.php";
3
  require_once Mage::getModuleDir('', 'BeezUp') . DS . 'lib' . DS ."bootstrap.php";
4
  require_once Mage::getModuleDir('', 'BeezUp') . DS . 'lib' . DS ."BeezupRepository.php";
5
  require_once Mage::getModuleDir('', 'BeezUp') . DS . 'lib' . DS ."BeezupMageOrders.php";
6
 
7
  class Beezup_Block_Order extends Mage_core_block_text {
8
+
9
  protected $repository = null;
10
  protected $oOrderService;
11
  public $log = null;
17
  private $marketplace_code;
18
  private $beezup_order_id;
19
  private $mage_order_id = false;
20
+
21
+
22
  private function makeDir() {
23
+
24
  if (file_exists(Mage::getBaseDir('base').'/beezup/tmp')) { return true;}
25
+
26
  if (!mkdir(Mage::getBaseDir('base').'/beezup/tmp', 0777, true))
27
  {
28
+ echo "[ERROR] : Seems we can't create 'beezup' directory inside your root directory."."<br/>"
29
+ ."You can try one of these solutions :"."<br/>"
30
  ."1 - Create by yourself the beezup/tmp inside your root directory with 777 permissions"."<br/>"
31
  ."2 - Change the permissions on your root directory (777)"."<br/>"
32
+ ."3 - Change the 'cache delay' option to 'None' inside beezup plugin settings"."<br/>";
33
  return false;
34
  }
35
  return true;
36
+
37
+ }
38
  public function createOrderFromLink($account_id, $marketplace_code, $beezup_order_id) {
39
  $this->makeDir();
40
  $logDir = Mage::getBaseDir('base').'/beezup/';
41
  if(file_exists($logDir."log2.txt")) {
42
  if(filesize($logDir."/log2.txt") >=3000000) {
43
  unlink($logDir."log2.txt");
44
+ }
45
  }
46
  $sync_end_date = new DateTime ( 'now', new DateTimeZone ( 'UTC' ));
47
  $helper = Mage::helper('beezup');
51
  if($create_customer == 0) {
52
  $this->blnCreateCustomer = true;
53
  }
54
+
55
  if($debug_mode==1) {
56
  $this->debug = true;
57
  }
58
  if($sync_status!==1) {
59
  $configModel = Mage::getModel('core/config');
60
  $configModel->saveConfig('beezup/marketplace/sync_status',1);
61
+
62
+
63
+
64
  unlink($logDir."log.txt");
65
  $this->log = new KLogger ( $logDir."log.txt" , KLogger::DEBUG );
66
  $this->log2 = new KLogger ( $logDir."log2.txt" , KLogger::DEBUG );
67
  $this->debugLog("Initializing OM Importation");
68
  $shiiping_disabled = Mage::getStoreConfig('carriers/flatrate/active');
69
+
70
  $this->account_id = $account_id;
71
  $this->marketplace_code = $marketplace_code;
72
  $this->beezup_order_id = $beezup_order_id;
73
  $orderResponse = $this->getBeezupOrder();
74
  if($orderResponse) {
75
+
76
  if($shiiping_disabled == 0) {
77
  Mage::getConfig()
78
  ->saveConfig('carriers/flatrate/active', 1)
79
  ->cleanCache();
80
  Mage::app()->reinitStores();
81
+ }
82
  $this->createOrder($orderResponse);
83
  if($shiiping_disabled == 0) {
84
  Mage::getConfig()
85
  ->saveConfig('carriers/flatrate/active', 0)
86
  ->cleanCache();
87
  Mage::app()->reinitStores();
88
+ }
89
  $configModel->saveConfig('beezup/marketplace/sync_status',0);
90
  if($this->mage_order_id) {
91
  echo "<script>window.location='".Mage::helper('adminhtml')->getUrl("adminhtml/sales_order/view", array('order_id'=> $this->mage_order_id))."';</script>";
92
  }
93
  // die("Order Importation finalized");
94
+
95
  }
96
+
97
  }
98
  $configModel->saveConfig('beezup/marketplace/sync_status',0);
99
  //die("Error, Order data incorrect");
100
  echo $this->_showLog();
101
  }
102
+
103
  public function _showLog() {
104
  $logDir = Mage::getBaseDir('base').'/beezup/';
105
  // $log1 = file_get_contents();
106
  $ret = array();
107
  if (file_exists($logDir."/log.txt")) {
108
  $f = fopen($logDir."/log.txt", 'r');
109
+
110
  if ($f) {
111
  while (!feof($f)) {
112
  $ret[] = fgetcsv($f, 0, '|');
115
  }
116
  }
117
  array_slice(array_reverse($ret), 1, 10);
118
+
119
  return $this->_getTable($ret);
120
+
121
  }
122
+
123
+
124
  public function _getTable($data) {
125
  $url = Mage::getBaseUrl( Mage_Core_Model_Store::URL_TYPE_WEB, true );
126
  $html = "<td></td><td></td><tr></tr></tbody></table>
127
+
128
  <div class='grid' style=' height: 600px;overflow-y: scroll;padding: 16px;border: 3px solid #e6e6e6;' id='marketPlaceLogBlock'>";
129
  $html .= '<p>'. Mage::helper('beezup')->__('For full logs see here:').' <a href="'.$url .'beezup/log/load" target="_blank">'.$url .'beezup/log/load</a></p>';
130
  $html .= "<table class='data' style='margin-top:0px;width:100%;'>";
148
  $html .= "<td>".$orderId."</td>";
149
  $html .= "<td>".$message."</td>";
150
  $html .= "</tr>";
151
+
152
  }
153
+
154
  $html .= "<tbody>";
155
  $html .= '</table>';
156
  $html .= "</div>";
157
+
158
  return $html;
159
  }
160
+
161
+
162
+
163
+ public function executeCron() {
164
+
165
  $this->makeDir();
166
+
167
+ set_time_limit(0);
168
  $logDir = Mage::getBaseDir('base').'/beezup/';
169
  if(file_exists($logDir."log2.txt")) {
170
  if(filesize($logDir."/log2.txt") >=3000000) {
171
  unlink($logDir."log2.txt");
172
+ }
173
  }
174
+
175
  $sync_end_date = new DateTime ( 'now', new DateTimeZone ( 'UTC' ));
176
  $helper = Mage::helper('beezup');
177
  $sync_status = $helper->getConfig('beezup/marketplace/sync_status');
180
  if($create_customer == 0) {
181
  $this->blnCreateCustomer = true;
182
  }
183
+
184
  if($debug_mode==1) {
185
  $this->debug = true;
186
  }
187
+
188
  if($sync_status!==1) {
189
  $configModel = Mage::getModel('core/config');
190
  $configModel->saveConfig('beezup/marketplace/sync_status',1);
191
+
192
+
193
+
194
  unlink($logDir."log.txt");
195
  $this->log = new KLogger ( $logDir."log.txt" , KLogger::DEBUG );
196
  $this->log2 = new KLogger ( $logDir."log2.txt" , KLogger::DEBUG );
197
  $this->debugLog("Initializing OM Importation");
198
+ $shiiping_disabled = Mage::getStoreConfig('carriers/flatrate/active');
199
  if($shiiping_disabled == 0) {
200
  Mage::getConfig()
201
  ->saveConfig('carriers/flatrate/active', 1)
202
  ->cleanCache();
203
  Mage::app()->reinitStores();
204
  }
205
+
206
+
207
  $this->getOrderList();
208
  if($shiiping_disabled == 0) {
209
  Mage::getConfig()
210
  ->saveConfig('carriers/flatrate/active', 0)
211
  ->cleanCache();
212
  Mage::app()->reinitStores();
213
+ }
214
  $this->repository->updateLastSynchronizationDate( $sync_end_date);
215
  $this->orderid = "";
216
  $this->debugLog("OM Importation finalized succesfully");
217
  $configModel->saveConfig('beezup/marketplace/sync_status',0);
218
  echo "OM Importation finalized succesfully";
219
+
220
  } else {
221
+
222
  echo "Order Importation is already being executed";
223
  }
224
+
225
  }
226
+
227
+
228
  public function getLog() {
229
  $logDir = Mage::getBaseDir('base').'/beezup/';
230
  $log1 = file_get_contents($logDir."/log2.txt");
231
+
232
  echo "<pre>";
233
  print_r($log1);
234
  echo "</pre>";
235
+
236
  }
237
  public function getBeezupOrder() {
238
+
239
  $oOrderIdentifier = $this->getBeezupOrderId();
240
  $oBeezupOMOrderResponse = $this->getOrderService()->getOrder($oOrderIdentifier);
241
  if ($oBeezupOMOrderResponse && $oBeezupOMOrderResponse->getResult()){
242
  return $oBeezupOMOrderResponse;
243
  }
244
+
245
+
246
  return false;
247
  }
248
+
249
  public function getBeezupOrderId(){
250
  $oIdentifier = new BeezupOMOrderIdentifier();
251
  $oIdentifier
254
  ->setBeezupOrderUUID($this->beezup_order_id);
255
  return $oIdentifier;
256
  }
257
+
258
+
259
  public function createOrder($oBeezupOrderResponse) {
260
+
261
  $etag = $oBeezupOrderResponse->getETag();
262
+ $final_order = $oBeezupOrderResponse->getResult();
263
+
264
  $orderid = $final_order->getOrderMarketPlaceOrderId();
265
  $this->orderid = $orderid;
266
  //customer Info
294
  //order Info
295
  $order_totalPrice = $final_order->getOrderTotalPrice();
296
  $order_shippingPrice = $final_order->getOrderShippingPrice();
297
+
298
  $name_parts = explode(" ", $order_customer);
299
  $order_first_name = array_shift( $name_parts);
300
  $order_last_name = implode(" ", $name_parts);
301
+
302
+
303
  $name_parts = explode(" ", $shipping_name);
304
  $shipping_first_name = array_shift( $name_parts);
305
  $shipping_last_name = implode(" ", $name_parts);
306
+
307
+
308
  //marketplace information
309
  $marketplace_business_code = $final_order->getMarketPlaceBusinessCode();
310
  $marketplace = $final_order->getMarketPlaceTechnicalCode();
311
+
312
+ //productInfo
313
+
314
  $mage_productIds = $this->prescanOrder($final_order);
315
+
316
+
317
  if(!$this->checkEtagExists($etag)) {
318
  if(empty($order_customer_email)) {
319
  $order_customer_email = $this->generateEmail($final_order);
329
  }
330
  $mage_productIds = $this->prescanOrder($final_order);
331
  if($mage_productIds) {
332
+ $order_data = array(
333
  "etag" => $etag,
334
  "account_id" => $account_id,
335
  "order_status" => $order_status,
366
  "discounts" => $mage_productIds['discounts'],
367
  "marketplace_business_code" => $marketplace_business_code
368
  );
369
+
370
+
371
+
372
  //check if order exists
373
  $Mageorder = $this->loadMageOrder();
374
  if ($Mageorder) {
375
  //if order exists
376
+ $this->updateEtag($etag);
377
  $this->updateBilling($Mageorder, $order_data );
378
  $this->updateBeezupInfoTab($Mageorder, $final_order, $order_data);
379
  $this->debugLog("Order Already exists Mage Order ID: " .$Mageorder->getId());
380
  $status1 = $Mageorder->getStatusLabel();
381
  $status = $this->getStatus($status1);
382
+ if($status !== $order_status) {
383
  //if order exits and status has changed we update order status
384
  $this->debugLog("Updating Order Status from: ".$status1." to: ".$order_status );
385
  $this->setStatus( $order_status, $Mageorder);
386
  }
387
+
388
  $id_order = $Mageorder->getId();
389
  $BeezupMageOrder = new BeezupMageOrders($id_order);
390
+ $BeezupMageOrder->setData(array("shipping" =>(float) $order_data['order_shippingPrice']));
391
+ $BeezupMageOrder->updateShippingInfo();
392
  } else {
393
  //if not we create order
394
+
395
+
396
  $this->debugLog("Generating Order");
397
+ $this->addOrder($order_data,$final_order );
398
  //die();
399
+
400
  }
401
+
402
+
403
  } else {
404
  //order could not be imported
405
+
406
+
407
+ }
408
+
409
+
410
  } else {
411
  //etag has not changed
412
  $this->debugLog("Order Etag has not changed");
413
+
414
  }
415
+
416
+
417
+
418
+
419
+
420
  }
421
+
422
+
423
+
424
  public function generateEmail(BeezupOMOrderResult $oBeezupOrder)
425
  {
426
  $sRawValue = $oBeezupOrder->getBeezupOrderUUID ();
427
  $sFakeDomain = preg_replace ( '/\W/', '', $oBeezupOrder->getMarketPlaceTechnicalCode () ) . '.com';
428
  return 'fakeemail' . md5 ( $sFakeDomain . $sRawValue ) . '@' . strtolower ( $sFakeDomain );
429
  }
430
+
431
+
432
+
433
  public function getOrderList($orderList = null) {
434
  if($orderList == null) {
435
  $data = $this->createRepository()->createOrderListRequest();
436
  $oRequest = $this->getOrderService()->getClientProxy()->getOrderList($data);
437
  $orderList = $oRequest->getResult();
438
  }
439
+ $oPagination = $orderList->getPaginationResult();
440
  if(!empty($oPagination)) {
441
  $oLinksTotal = $oPagination->getLinks();
442
  } else {
444
  $configModel->saveConfig('beezup/marketplace/sync_status',0);
445
  die("No more orders to import");
446
  }
447
+
448
  //$header = $orderList->getOrderHeaders();
449
  foreach($orderList->getOrderHeaders() as $order) {
450
  $order_status = $order->getBeezupOrderState();
453
  $beezup_order_id = $order->getBeezupOrderUUID();
454
  $account_id = $order->getAccountId();
455
  $orderdata = $this->getOrderService()->getClientProxy()->getOrderByLink($orderLinks[0]);
456
+ $this->debugLog("Initializing Order - Link: ".$orderLinks[0]->getHref());
457
  $this->createOrder($orderdata);
458
+
459
  }
460
+
461
  if(!empty($oLinksTotal)) {
462
+ //we check if there is next link and get next orders
463
  foreach($oLinksTotal as $link) {
464
  if( $link->getRel() == "next") {
465
+
466
  $this->log->LogInfo("Initializing New Order List ->". $link->getHref());
467
  $this->log2->LogInfo("Initializing New Order List ->". $link->getHref());
468
  $oRequest = $this->getOrderService()->getClientProxy()->getOrderListByLink($link);
469
  $orderList = $oRequest->getResult();
470
  $this->getOrderList($orderList);
471
+ }
472
+
473
  }
474
  }
475
+
476
  }
477
+
478
+
479
+
480
  public function updateBeezupInfoTab($order, $oLink, $data) {
481
  $beezup_last_modification_date = $oLink->getOrderLastModificationUtcDate();
482
+ $beezup_last_modification_date = $beezup_last_modification_date->date;
483
  $beezup_marketplace_last_modification_date = $oLink->getOrderMarketPlaceLastModificationUtcDate();
484
+ $beezup_marketplace_last_modification_date = $beezup_marketplace_last_modification_date->date;
485
  $beezup_comission = $oLink->getOrderTotalCommission()." ".$data['order_currency'];
486
  $tot_comm = $oLink->getOrderTotalCommission();
487
  if(empty($tot_comm ) || $tot_comm == 0) {
497
  $beezupMageOrder = new BeezupMageOrders($orderId);
498
  $beezupMageOrder->setData($updateData);
499
  $beezupMageOrder->updateBeezupInfo();
500
+
501
+
502
  }
503
+
504
  public function getPhone($phone, $phone2) {
505
  $retorno = "";
506
  if(!empty($phone) && $phone !== "") {
509
  if(!empty($phone2) && $phone2 !=="") {
510
  if(empty($phone) || $phone == "") {
511
  $retorno = $phone2;
512
+
513
  } else {
514
  $retorno .= " - ".$phone2;
515
  }
516
  }
517
  return $retorno;
518
  }
519
+
520
+
521
  public function getBeezupBuyerAddress($order) {
522
  $add1=$order->getOrderBuyerAddressLine1();
523
  $add2=$order->getOrderBuyerAddressLine2();
525
  $retorno = "";
526
  if(!empty($add1)) {
527
  $retorno = $order->getOrderBuyerAddressLine1();
528
+ }
529
  if(!empty($add2)) {
530
  if(empty($add1)) {
531
+ $retorno .= $order->getOrderBuyerAddressLine2();
532
  } else {
533
  $retorno .= " - ". $order->getOrderBuyerAddressLine2();
534
  }
535
+ }
536
  if(!empty($add3)){
537
  if(empty($add1) && empty($add2)) {
538
+ $retorno .= $order->getOrderBuyerAddressLine3();
539
  } else {
540
  $retorno .= " - ". $order->getOrderBuyerAddressLine3();
541
  }
542
+ }
543
  return $retorno;
544
  }
545
+
546
+
547
  public function getBeezupShippingAddress($order) {
548
  $add1 = $order->getOrderShippingAddressLine1();
549
  $add2 = $order->getOrderShippingAddressLine2();
551
  $retorno = "";
552
  if(!empty($add1 )) {
553
  $retorno = $order->getOrderShippingAddressLine1();
554
+ }
555
  if(!empty($add2)) {
556
  if(empty($add1)) {
557
+ $retorno .= $order->getOrderShippingAddressLine2();
558
  } else {
559
  $retorno .= " - ". $order->getOrderShippingAddressLine2();
560
  }
561
+ }
562
  if(!empty($add3)){
563
  if(empty($add1) && empty($add2)) {
564
+ $retorno .= $order->getOrderShippingAddressLine3();
565
  } else {
566
  $retorno .= " - ". $order->getOrderShippingAddressLine3();
567
  }
568
+ }
569
  return $retorno;
570
  }
571
+
572
  public function checkEtagExists($etag) {
573
  $resource = Mage::getSingleton('core/resource');
574
  $readConnection = $resource->getConnection('core_read');
575
  $table = $resource->getTableName('sales/order_grid');
576
  $query = 'SELECT increment_id FROM ' . $table . ' WHERE beezup_etag = \''
577
+ . $etag . '\' LIMIT 1';
578
  $order = $readConnection->fetchOne($query);
579
  if($order && !empty($order)) {
580
  return true;
581
  }
582
  return false;
583
+
584
  }
585
+
586
+
587
  public function updateEtag($etag) {
588
  $this->debugLog("Updating Etag");
589
  $resource = Mage::getSingleton('core/resource');
590
  $writeConnection = $resource->getConnection('core_write');
591
  $table = $resource->getTableName('sales/order_grid');
592
  $query = "UPDATE {$table} SET beezup_etag = '{$etag}' where beezup_market_order_id = '{$this->orderid}' ";
593
+ $writeConnection->query($query);
594
+
595
  }
596
+
597
+
598
+
599
  public function updateBilling($order, $data) {
600
+
601
+
602
  $addressData = array(
603
  'billing_firstname' => ($data['order_customer']) ? $data['order_customer'] : "empty",
604
  'billing_lastname' => ($data['order_lastname']) ? $data['order_lastname'] : "empty",
617
  'shipping_country_id' => ($data['shipping_country_iso']) ? $data['shipping_country_iso'] : "empty",
618
  'shipping_region_id' => ($data['shipping_region']) ? substr($data['shipping_region'], 0, 2) : "EM" // id from directory_country_region table
619
  );
620
+
621
  $shippingData = array(
622
+
623
  );
624
  // Get the id of the orders shipping address
625
  $orderId = $order->getId();
627
  $beezupMageOrder->setData($addressData);
628
  $beezupMageOrder->updateAdresses();
629
  }
630
+
631
  public function updateAddresses($shippingData, $address) {
632
  if($shippingData['firstname'] !==$address['firstname']) {
633
  $address->setFirstname($shippingData['firstname']);
646
  }
647
  if($shippingData['telephone'] !==$address['telephone']) {
648
  $address->setTelephone($shippingData['telephone']);
649
+ }
650
  $address->save();
651
+
652
+
653
  }
654
+
655
+
656
  public function loadMageOrder() {
657
  $Mageorder = Mage::getModel('sales/order')->loadByIncrementId($this->orderid);
658
  if ($Mageorder->getId()) {
670
  }
671
  return false;
672
  }
673
+
674
+
675
  private function debugLog($message) {
676
+
677
  if($this->orderid !== "") {
678
  $message = $this->orderid." | ".$message;
679
  }
680
  $this->log->LogInfo($message);
681
+
682
  $this->log2->LogInfo($message);
683
  }
684
+
685
  public function prescanOrder(BeezupOMOrderResult $order) {
686
  $retorno = array();
687
  $orderItems = $order->getOrderItems();
688
  foreach ($orderItems as $item)
689
  {
690
+
691
  if ($item->getOrderItemOrderItemType () !== 'Product')
692
  {
693
  // continue;
696
  $mage_storeid = $this->checkOrderStore($beezup_store); //magento storeid
697
  $marketplace_orderid = $item->getOrderItemMarketPlaceProductId();
698
  if(!$mage_storeid) {
699
+
700
  if(strpos($marketplace_orderid,'INTERETBCA') !== false || strpos($marketplace_orderid,'interetbca') !== false) { }
701
  else {
702
  $this->log->LogError($this->orderid." | No mapping for store ".$beezup_store);
703
  $this->log2->LogError($this->orderid." | No mapping for store ".$beezup_store);
704
  return false;
705
+ }
706
+
707
  }
708
  // $retorno['store'] = 1;
709
+
710
  $product_ImportedMerchantId = $item->getOrderItemMerchantImportedProductId();
711
  $product_MerchantId = $item->getOrderItemMerchantProductId();
712
+
713
  $product_quantity = $item->getOrderItemQuantity();
714
  $product_price = $item->getOrderItemItemPrice();
715
  $product_title = $item->getOrderItemTitle();
718
  $retorno['discounts']= $item->getOrderItemTotalPrice();
719
  } else {
720
  $retorno['store'] = $mage_storeid;
721
+ $this->debugLog("Store Matching succesful, Beezup Store: ".$beezup_store." , Magento Store Id: ".$mage_storeid);
722
  $product = $this->getMageProduct($product_ImportedMerchantId , $product_MerchantId , $beezup_store );
723
  if($product) {
724
  $mage_productId = $product->getId();
725
  $stocklevel = (int)Mage::getModel('cataloginventory/stock_item')
726
  ->loadByProduct($product)->getQty();
727
+
728
  $retorno['products'][] = array("id" => $mage_productId, "qty" => $product_quantity, "price" => $product_price, "curr_stock" => $stocklevel);
729
  //producto existe
730
  } else {
746
  return false;
747
  }
748
  $stocklevel = (int)Mage::getModel('cataloginventory/stock_item')
749
+ ->loadByProduct($product)->getQty();
750
  $mage_productId = $product->getId();
751
  $retorno['products'][] = array("id" => $mage_productId, "qty" => $product_quantity, "price" => $product_price, "curr_stock" => $stocklevel);
752
  }
753
  }
754
  }
755
+
756
  return $retorno;
757
  }
758
+
759
+
760
+
761
  public function matchProductAttributes($importedId, $storeId) {
762
  $product = null;
763
  $helper = Mage::helper('beezup');
764
  $attributes = $helper->getConfig('beezup/marketplace/attributes');
765
  $attributes = unserialize ($attributes);
766
+
767
  foreach($attributes['attributes'][$storeId ] as $attribute) {
768
  $att = explode("|", $attribute);
769
  if($storeId == $att[1]) {
770
+
771
  $product=Mage::getModel('catalog/product')->loadByAttribute($att[0],$importedId);
772
  if($product) {
773
  break;
774
+ }
775
  }
776
  }
777
+
778
  return $product;
779
  }
780
+
781
+
782
+
783
  public function getMageProduct($importedId, $merchantId, $storeId){
784
  try {
785
+ $product=Mage::getModel('catalog/product')->load($importedId);
786
  if (!$product->getId() || $product->getId() !== $importedId ){
787
  $product = $this->matchProductAttributes($importedId, $storeId);
788
  if($product == null || !is_object($product)) {
789
+ $product=Mage::getModel('catalog/product')->load($merchantId);
790
+ if(!$product->getId() || $product->getId() !== $merchantId ) {
791
  $product = $this->matchProductAttributes($merchantId, $storeId);
792
+
793
  }
794
  }
795
  }
796
+
797
  if(is_object($product)) {
798
  if($product->getId()) {
799
  $this->debugLog("Product Matching succesful, Beezup Imported Id: ".$importedId." , Magento Product Id: ".$product->getId());
800
+ return $product;
801
  }}
802
  $this->log->LogError($this->orderid. "| No Product Matching, Product ".$importedId." could not be found");
803
  $this->log2->LogError($this->orderid. "| No Product Matching, Product ".$importedId." could not be found");
807
  $this->log2->LogError($this->orderid. "| Product ".$importedId." could not be found, error: ".$e->getMessage());
808
  return false;
809
  //error no se pudo crear la orden
810
+
811
  }
812
  }
813
+
814
+
815
  public function checkOrderStore($storeId ) {
816
  $helper = Mage::helper('beezup');
817
  $stores = $helper->getConfig('beezup/marketplace/stores');
823
  }
824
  return false;
825
  }
826
+
827
+
828
+
829
  /**
830
  * @return BeezupOMOrderService
831
  */
836
  }
837
  return $this->oOrderService;
838
  }
839
+
840
  /**
841
  * @return BeezupOMOrderService
842
  */
843
  protected function createOrderService(){
844
+
845
  return new BeezupOMOrderService($this->createRepository() );
846
  }
847
+
848
  protected function createRepository() {
849
  if ($this->repository == null) {
850
  $this->repository = new BeezupRepository();
851
+ }
852
  return $this->repository;
853
+
854
  }
855
+
856
+
857
+
858
+
859
  private function createCustomer($customer_email , $data) {
860
  $password = $this->orderid;
861
  $this->debugLog("Creating new Customer");
876
  //Make a "login" of new customer
877
  // Mage::getSingleton('customer/session')->loginById($customer->getId());
878
  }
879
+
880
  catch (Exception $ex) {
881
  //Zend_Debug::dump($ex->getMessage());
882
  //GUARDAR ERROR CREACION USUARIO
883
  $this->log2->LogError($this->orderid. " | Customer importation failed: ".$ex->getMessage());
884
  return false;
885
  }
886
+
887
  } else {
888
  $this->debugLog("Creating already exists, returning customer object");
889
  return $customer;
890
  }
891
  }
892
+
893
+
894
+
895
  public function addOrder($data, $oLink, $stop = false) {
896
+
897
+
898
  try {
899
  $helper = Mage::helper('beezup');
900
  $addStock = $helper->getConfig('beezup/marketplace/available_products');
902
  $quote = Mage::getModel('sales/quote')
903
  ->setStoreId($data['storeid']);
904
  $quote->setCustomerEmail($data['order_customer_email']);
905
+
906
+
907
+ $currency = Mage::getModel('directory/currency')->load($data['order_currency']);
908
  $quote->setForcedCurrency($currency);
909
+
910
  $blnCreate = true;
911
  $total_new_price = 0;
912
  foreach($data['products'] as $prod) {
923
  $this->debugLog("Adding ".$prod['qty']." product/s with id ".$product->getId()." to order, with Beezup Price: ".$prod['price']);
924
  //echo "Product ".$product->getId()."<br><br>";
925
  //para no perder stock:
926
+ //Mage::getModel('cataloginventory/stock')->backItemQty($productId,$new_qty);
927
+
928
+
929
  if($addStock == 1) {
930
  $stock = Mage::getModel('cataloginventory/stock_item')->loadByProduct($product);
931
+
932
  if ($stock->getQty() < $prod['qty'] && $product->getStockItem()->getMaxSaleQty() >= $prod['qty']) {
933
  $this->debugLog("Product ".$product->getId()." Stock = 0, Updating to ".$prod['qty']." to generate Order");
934
+ // Mage::getModel('cataloginventory/stock')->backItemQty($product->getId(),$prod['qty']);
935
  //$this->_updateStocks(array("id_product" => $product->getId(), "qty" => $prod['qty']));
936
  $product->setStockData(
937
+ array(
938
+ 'is_in_stock' => 1,
939
  'qty' => $prod['qty'],
940
  'manage_stock' => 1,
941
  'use_config_notify_stock_qty' => 1
942
  )
943
+ );
944
  $product->save();
945
  $product = Mage::getModel('catalog/product')->load($product->getId());
946
+
947
  }
948
  }
949
  //fin para no perder stock
950
+
951
  /*
952
  $tax_class = $product->getTaxClassId();
953
  $product->setTaxClassId(0);
954
  $product->getResource()->saveAttribute($product, 'tax_class_id'); */
955
  $price = $prod['price'];
956
+
957
  $quote_item = Mage::getModel('beezup/quote_item');
958
  $quote_item
959
  ->setProduct($product)
963
  ->setQuote($quote)
964
  ->setQty((integer) $prod['qty'])
965
  ->setBeezupPrice((float) $price );
966
+
967
+
968
+ $quote->addItem($quote_item);
969
+
970
  //$quote->addProduct($product, new Varien_Object($buyInfo))->setOriginalCustomPrice($price)->setCustomPrice($price);
971
+
972
+ /*
973
  $product->setTaxClassId($tax_class);
974
+
975
+ $product->getResource()->saveAttribute($product, 'tax_class_id');
976
  */
977
  }
978
+
979
  if($blnCreate) {
980
  $addressData = array(
981
  'firstname' => ($data['order_customer']) ? $data['order_customer'] : "empty",
987
  'country_id' => ($data['order_country_iso']) ? $data['order_country_iso'] : "empty",
988
  'region_id' => ($data['order_region ']) ? substr($data['order_region '], 0,2) : "EM"// id from directory_country_region table
989
  );
990
+
991
  $shippingData = array(
992
  'firstname' => ($data['shipping_name']) ? $data['shipping_name'] : "empty",
993
  'lastname' => ($data['shipping_lastname']) ? $data['shipping_lastname'] : "empty",
998
  'country_id' => ($data['shipping_country_iso']) ? $data['shipping_country_iso'] : "empty",
999
  'region_id' => ($data['shipping_region']) ? substr($data['shipping_region'], 0, 2) : "EM" // id from directory_country_region table
1000
  );
1001
+
1002
  if($this->blnCreateCustomer) {
1003
+
1004
  $mage_customer = $this->createCustomer($data['order_customer_email'], $addressData);
1005
  $quote->assignCustomer($mage_customer);
1006
  }
1007
+
1008
+
1009
  $payment_method = $helper->getConfig('beezup/marketplace/payment_method');
1010
  $billingAddress = $quote->getBillingAddress()->addData($addressData);
1011
  $shippingAddress = $quote->getShippingAddress()->addData($shippingData);
1017
  Mage::unregister('shipping_cost');
1018
  Mage::register('shipping_cost', $shipping_cost);
1019
  $this->debugLog("Adding Order Shipping Cost: ". $data['order_shippingPrice']);
1020
+
1021
  $shippingAddress->setCollectShippingRates(true)->collectShippingRates()
1022
  ->setShippingMethod('flatrate_flatrate')
1023
  ->setPaymentMethod($payment_method);
1024
+
1025
  //$shippingAddress->addTotal(array("code" => "specialfee", "title" => "Special Fee", "value" => 20));
1026
  $quote->getPayment()->importData(array('method' => $payment_method));
1027
+
1028
  $quote->collectTotals()->save();
1029
+
1030
  $service = Mage::getModel('sales/service_quote', $quote);
1031
  $service->submitAll();
1032
  $order = $service->getOrder();
1033
+
1034
+
1035
+
1036
  $quoteId = $order->getQuoteId();
1037
  //$this->setStatus($data['order_status'], $order);
1038
+
1039
  $orderid = $order->getId();
1040
+
1041
  $resource = Mage::getSingleton('core/resource');
1042
  $writeConnection = $resource->getConnection('core_write');
1043
  $table = $resource->getTableName('sales/order_grid');
1058
  /* $date = new DateTime($$beezup_marketplace_last_modification_date);
1059
  $beezup_marketplace_last_modification_date = $date->format('d-m-Y H:i:s'). "(UTC Time)";
1060
  */
1061
+
1062
  $beezup_total_paid = $oLink->getOrderTotalPrice()." ".$data['order_currency'];
1063
  $beezup_account_id = $oLink->getAccountId();
1064
  $beezup_comission = $oLink->getOrderTotalCommission()." ".$data['order_currency'];
1071
  beezup_marketplace_status = '{$beezup_marketplace_status}', beezup_purchase_date = '{$beezup_purchase_date}', beezup_marketplace_last_modification_date = '{$beezup_marketplace_last_modification_date}',
1072
  beezup_total_paid = '{$beezup_total_paid}', beezup_etag = '{$data['etag']}' , beezup_comission = '{$beezup_comission}', beezup_marketplace_business_code = '{$marketplace_business_code}'
1073
  WHERE entity_id = ". (int)$orderid;
1074
+ $writeConnection->query($query);
1075
  $disc_price = 0;
1076
  if(!empty($data['discounts']) && $data['discounts'] >0) {
1077
+
1078
+
1079
  $disc_price = round($data['discounts'],2);
1080
  $total_new_price = $total_new_price+$disc_price;
1081
  $table_address = $resource->getTableName("sales/quote_address");
1082
+
1083
  $query = "update {$table_address} set beezup_fee = '{$disc_price}' where quote_id = '{$quoteId}' and address_type = 'shipping'";
1084
+ $writeConnection->query($query);
1085
  $this->debugLog("Adding CDISCOUNT products with total price: ".$disc_price);
1086
  }
1087
+
1088
  //if order id exists and has been created
1089
  if ($orderid)
1090
  {
1094
  $oResult->setOrderMerchantOrderId ( $orderid )->setOrderMerchantECommerceSoftwareName ( 'Magento' )->setOrderMerchantECommerceSoftwareVersion ( Mage::getVersion() );
1095
  $sendRequest = $this->getOrderService()->getClientProxy()->setOrderMerchantIdByLink($oLink->getLinkByRel('setMerchantOrderId'), $oResult);
1096
  }
1097
+
1098
  $grand_total = $order->getGrandTotal();
1099
  $beezup_price = $oLink->getOrderTotalPrice() - $disc_price;
1100
  if($grand_total != (float) $beezup_price && $beezup_price > 0) {
1101
  $order->setGrandTotal((float) $beezup_price);
1102
  $order->setBaseGrandTotal((float) $beezup_price);
1103
  $diff = (((float) $beezup_price) - $grand_total);
1104
+
1105
  $order->setTaxAmount($order->getTaxAmount() + $diff);
1106
  $order->save();
1107
  }elseif($grand_total != (float)$beezup_price && $beezup_price < 1) {
1108
+
1109
  $order->setGrandTotal((float) $total_new_price);
1110
  $order->setBaseGrandTotal((float) $total_new_price);
1111
  $diff = (((float) $total_new_price) - $grand_total);
1112
+
1113
  $order->setTaxAmount($order->getTaxAmount() + $diff);
1114
  $order->save();
1115
  }
1116
+
1117
  $products = Mage::getResourceModel('sales/order_item_collection')
1118
+ ->setOrderFilter($orderid);
1119
  foreach($products as $product) {
1120
  $product->setBaseOriginalPrice($product->getOriginalPrice());
1121
  $product->setBaseTaxAmount($product->getTaxAmount());
1131
  $order->setBaseGrandTotal($order->getTotalPaid());
1132
  $order->setBaseSubtotalInclTax($order->getSubtotalInclTax());
1133
  $order->save();
1134
+
1135
  $this->setStatus($data['order_status'], $order);
1136
  $this->mage_order_id = $orderid;
1137
  $this->debugLog("Order imported succesfully, Magento Order Id: ".$orderid);
1141
  $this->log2->LogError($this->orderid. "| Order ".$data['market_place_order_id']." could not be imported, error: Stock from Beezup product = 0 ");
1142
  }
1143
  }catch(Exception $e){
1144
+
1145
+
1146
  if($stop) {
1147
  $this->log->LogError($this->orderid. "| Order ".$data['market_place_order_id']." could not be imported, error: ".$e->getMessage());
1148
  $this->log2->LogError($this->orderid. "| Order ".$data['market_place_order_id']." could not be imported, error: ".$e->getMessage());
1150
  } else {
1151
  $this->debugLog("Order Import failed, Trying to import Order Again");
1152
  $this->addOrder($data, $oLink, true);
1153
+
1154
  }
1155
  //error no se pudo crear la orden
1156
+
1157
  }
1158
+
1159
+
1160
+
1161
  }
1162
+
1163
+
1164
+
1165
  public function restoreStock($data) {
1166
+
1167
+ try {
1168
  foreach($data['products'] as $prod) {
1169
  $product = Mage::getModel('catalog/product')->load($prod['id']);
1170
  $stock = Mage::getModel('cataloginventory/stock_item')->loadByProduct($product);
1174
  $stockItem->setData('is_in_stock', 0);
1175
  $stockItem->setData('qty', $prod['curr_stock']);
1176
  $stockItem->save();
1177
+ $product->save();
1178
  }
1179
+
1180
  }
1181
  } catch(Exception $e){
1182
  $this->log->LogError($this->orderid. "| Failed Restoring Product Stock: ".$e->getMessage());
1183
  $this->log2->LogError($this->orderid. "| Failed Restoring Product Stock: ".$e->getMessage());
1184
  }
1185
+
1186
  }
1187
+
1188
+
1189
+
1190
  private function createProduct($data) {
1191
+
1192
  $sku = $data['sku'];
1193
  if(empty($data['sku'])) {
1194
  $sku = $data['sku2'];
1195
+ }
1196
+
1197
  Mage::app()->setCurrentStore($data['storeId']);
1198
  $product = Mage::getModel('catalog/product');
1199
  // if(!$product->getIdBySku('testsku61')):
1200
+
1201
  try{
1202
  $product
1203
  // ->setStoreId(1) //you can set data in store scope
1233
  );
1234
  $product->save();
1235
  return $product;
1236
+
1237
  }catch(Exception $e){
1238
  //log exception
1239
  $this->log->LogError($this->orderid."| Product ".$sku." could not be created, error: ".$e->getMessage());
1241
  return false;
1242
  }
1243
  }
1244
+
1245
+
1246
+
1247
  public function setStatus($status, $order) {
1248
  $helper = Mage::helper('beezup');
1249
  $retorno = "";
1263
  $this->debugLog("Setting Order Status to Aborted");
1264
  $retorno = $helper->getConfig('beezup/marketplace/status_aborted');
1265
  $blnHold = true;
1266
+
1267
+
1268
  break;
1269
  case "Closed" :
1270
  $this->debugLog("Setting Order Status to Closed");
1275
  case "Canceled" :
1276
  $this->debugLog("Setting Order Status to Cancelled");
1277
  $retorno = $helper->getConfig('beezup/marketplace/status_cancelled');
1278
+
1279
  break;
1280
  case "Shipped" :
1281
  $this->debugLog("Setting Order Status to Shipped");
1282
  $retorno = $helper->getConfig('beezup/marketplace/status_shipped');
1283
  $this->payOrder($order);
1284
  break;
1285
+
1286
  }
1287
  $order->setData('state',$retorno);
1288
+ $order->setStatus($retorno);
1289
  $history = $order->addStatusHistoryComment('Order was set to '.$retorno.' by Beezup.', false);
1290
  $history->setIsCustomerNotified(false);
1291
  $order->save();
1295
  if($blnHold) {
1296
  $order->hold()->save();
1297
  }
1298
+
1299
  return $retorno;
1300
+
1301
  }
1302
+
1303
+
1304
  public function getStatus($status1) {
1305
  $helper = Mage::helper('beezup');
1306
  $retorno = "";
1307
  $status = strtolower($status1);
1308
+
1309
  if($status == strtolower($helper->getConfig('beezup/marketplace/status_new') )) {
1310
  $retorno = "New";
1311
+
1312
  } elseif($status == strtolower($helper->getConfig('beezup/marketplace/status_progress') ) ){
1313
  $retorno = "InProgress";
1314
+
1315
+
1316
  }
1317
  elseif($status == strtolower($helper->getConfig('beezup/marketplace/status_aborted') )) {
1318
+
1319
+ $retorno = "Aborted" ;
1320
  }
1321
  elseif($status == strtolower($helper->getConfig('beezup/marketplace/status_closed') )) {
1322
  $retorno = "Closed";
1323
+
1324
  }
1325
  elseif($status == strtolower($helper->getConfig('beezup/marketplace/status_cancelled')) ) {
1326
+
1327
  $retorno = "Canceled";
1328
  }
1329
  elseif($status == strtolower($helper->getConfig('beezup/marketplace/status_shipped') )) {
1330
+
1331
  $retorno = "Shipped";
1332
  }
1333
+
1334
+
1335
  return $retorno;
1336
+
1337
  }
1338
+
1339
+
1340
  public function checkMarketOrderExists($orderid) {
1341
  $resource = Mage::getSingleton('core/resource');
1342
  $readConnection = $resource->getConnection('core_read');
1343
  $table = $resource->getTableName('sales/order_grid');
1344
  $query = 'SELECT increment_id FROM ' . $table . ' WHERE beezup_order = 1 and beezup_market_order_id = \''
1345
+ . $orderid . '\' LIMIT 1';
1346
  $order = $readConnection->fetchOne($query);
1347
  if($order && !empty($order) && $this->orderId !== "") {
1348
  return $order;
1349
  }
1350
  return false;
1351
+
1352
  }
1353
+
1354
  public function payOrder($order) {
1355
  try {
1356
  $this->debugLog("Generating Order Payment Invoice");
1373
  $this->log2->LogError($this->orderid."| Order Payment Invoice could not be generated, error: ".$e->getMessage());
1374
  }
1375
  }
1376
+
1377
+
1378
+
1379
+
1380
+
1381
+
1382
+ }
app/code/community/BeezUp/etc/config.xml CHANGED
@@ -2,7 +2,7 @@
2
  <config>
3
  <modules>
4
  <BeezUp>
5
- <version>4.6.9</version>
6
  </BeezUp>
7
  </modules>
8
  <global>
2
  <config>
3
  <modules>
4
  <BeezUp>
5
+ <version>4.7.0</version>
6
  </BeezUp>
7
  </modules>
8
  <global>
app/code/community/BeezUp/etc/system.xml CHANGED
@@ -13,7 +13,7 @@
13
  <tracking translate="label">
14
  <label>Tracking</label>
15
  <frontend_type>text</frontend_type>
16
- <comment><![CDATA[<div style="font-size:11px;padding:3px;margin-bottom:20px;background:#FFF9E9;border:1px solid #EEE2BE">Support BeezUP : <a href="mailto:help@beezup.com">help@beezup.com</a> (Magento BeezUP v4.6.9) - <a href="http://go.beezup.com" target="_blank">My BeezUP Account</a></div>]]></comment>
17
  <sort_order>1</sort_order>
18
  <show_in_default>1</show_in_default>
19
  <show_in_website>1</show_in_website>
@@ -77,7 +77,7 @@
77
  <marketplace tanslate="label">
78
  <label>Marketplace</label>
79
  <frontend_type>text</frontend_type>
80
- <comment><![CDATA[<div style="font-size:11px;padding:3px;margin-bottom:20px;background:#FFF9E9;border:1px solid #EEE2BE">Support BeezUP : <a href="mailto:help@beezup.com">help@beezup.com</a> (Magento BeezUP v4.6.9) - <a href="http://go.beezup.com" target="_blank">My BeezUP Account</a></div>]]></comment>
81
  <sort_order>2</sort_order>
82
  <show_in_default>1</show_in_default>
83
  <show_in_website>1</show_in_website>
@@ -409,7 +409,7 @@
409
  <flux translate="label">
410
  <label>Catalog Flow</label>
411
  <frontend_type>text</frontend_type>
412
- <comment><![CDATA[<div style="font-size:11px;padding:3px;margin-bottom:20px;background:#FFF9E9;border:1px solid #EEE2BE">Support BeezUP : <a href="mailto:help@beezup.com">help@beezup.com</a> (Magento BeezUP v4.6.9) - <a href="http://go.beezup.com" target="_blank">My BeezUP Account</a></div>]]></comment>
413
  <sort_order>2</sort_order>
414
  <show_in_default>1</show_in_default>
415
  <show_in_website>1</show_in_website>
13
  <tracking translate="label">
14
  <label>Tracking</label>
15
  <frontend_type>text</frontend_type>
16
+ <comment><![CDATA[<div style="font-size:11px;padding:3px;margin-bottom:20px;background:#FFF9E9;border:1px solid #EEE2BE">Support BeezUP : <a href="mailto:help@beezup.com">help@beezup.com</a> (Magento BeezUP v4.7.0) - <a href="http://go.beezup.com" target="_blank">My BeezUP Account</a></div>]]></comment>
17
  <sort_order>1</sort_order>
18
  <show_in_default>1</show_in_default>
19
  <show_in_website>1</show_in_website>
77
  <marketplace tanslate="label">
78
  <label>Marketplace</label>
79
  <frontend_type>text</frontend_type>
80
+ <comment><![CDATA[<div style="font-size:11px;padding:3px;margin-bottom:20px;background:#FFF9E9;border:1px solid #EEE2BE">Support BeezUP : <a href="mailto:help@beezup.com">help@beezup.com</a> (Magento BeezUP v4.7.0) - <a href="http://go.beezup.com" target="_blank">My BeezUP Account</a></div>]]></comment>
81
  <sort_order>2</sort_order>
82
  <show_in_default>1</show_in_default>
83
  <show_in_website>1</show_in_website>
409
  <flux translate="label">
410
  <label>Catalog Flow</label>
411
  <frontend_type>text</frontend_type>
412
+ <comment><![CDATA[<div style="font-size:11px;padding:3px;margin-bottom:20px;background:#FFF9E9;border:1px solid #EEE2BE">Support BeezUP : <a href="mailto:help@beezup.com">help@beezup.com</a> (Magento BeezUP v4.7.0) - <a href="http://go.beezup.com" target="_blank">My BeezUP Account</a></div>]]></comment>
413
  <sort_order>2</sort_order>
414
  <show_in_default>1</show_in_default>
415
  <show_in_website>1</show_in_website>
package.xml CHANGED
@@ -1,7 +1,7 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>BeezUP_Module_feed_and_tracker</name>
4
- <version>4.6.9</version>
5
  <stability>stable</stability>
6
  <license uri="http://opensource.org/licenses/osl-3.0.php">Open Software License</license>
7
  <channel>community</channel>
@@ -42,12 +42,11 @@ After Set-up, the following files are added :&lt;/p&gt;&#xD;
42
  &#xD;
43
  &lt;p&gt;By BeezUP &amp; Magentix&lt;/p&gt;</description>
44
  <notes>New features :&#xD;
45
- - Fixed a specific cache issue with multi stores&#xD;
46
- - Fixed a bug related to carriers list</notes>
47
  <authors><author><name>BeezUP</name><user>BeezUP</user><email>charles@beezup.com</email></author></authors>
48
- <date>2016-08-01</date>
49
- <time>18:46:58</time>
50
- <contents><target name="magecommunity"><dir name="BeezUp"><dir name="Block"><dir name="Adminhtml"><dir name="Sales"><dir name="Order"><file name="Grid.php" hash="e18c65bc83cab8795b4ffd0d46e04c8a"/><dir name="Invoice"><file name="Totals.php" hash="ac065cd586fd2534de7e12762ab9b335"/></dir><file name="Totals.php" hash="5972281aa467d63da56a297a8df3da55"/><dir name="View"><dir name="Tab"><file name="Custom.php" hash="a60f500d604038645b826fa74e9b6619"/></dir></dir></dir><file name="Order.php" hash="c038c302f2c86f79431b49c7282c3f5c"/></dir><dir name="System"><dir name="Config"><file name="Attributes.php" hash="a504265fe4dc2df69b311d8219c88fbf"/><file name="Button.php" hash="476b33034b0c7d36e1bbd85f38b841db"/><file name="Childgroup.php" hash="388d3dee8f9d66a56c43c2790a44b45a"/><file name="Credentials.php" hash="b86f361800bebfd6fcf3564d9fe87c95"/><file name="Cron.php" hash="e1d47b095623593beb7f166d2ad7fecc"/><file name="Filter.php" hash="ad7ba55e18c080e25a08309dc428402a"/><file name="Log.php" hash="86221765980c0aee2381d5efd740949d"/><file name="Manualcron.php" hash="cbac01f15d256a43f0388f58449bffd0"/><file name="Orderlink.php" hash="9b9242ea9ccc4cfa746036b72aed2cc1"/><file name="Stores.php" hash="4297f4c94f136bb9778c9ddcd0cb336c"/><file name="Syncstatus.php" hash="49164eb19331aadabc0581472cd3c567"/><file name="Time.php" hash="ac5c2e4a40e9c6ff68cea1097dfa1e7b"/></dir></dir></dir><file name="Omstatus.php" hash="061d861d973e232a18acea0387a4a290"/><file name="Order.php" hash="02a8af82ffd3e7b361c3a60d7c7cc04a"/><file name="Tracking.php" hash="e6dcd6b89e782b2eb6cb83abfb1b7f56"/><file name="Xml.php" hash="dbaed2a7dfb2ea57f932865a09ae9760"/></dir><dir name="Helper"><file name="Data.php" hash="867a2562b255beaf3faa047d4130304f"/></dir><dir name="Model"><file name="Flatrate.php" hash="27d078203781d9b923605f685bfe5c25"/><file name="Observer.php" hash="3bcb925df1965ef23ef1fb08ab64de08"/><file name="Products.php" hash="e2ffaec55b84d4c1923547fc2aad47b6"/><dir name="Quote"><file name="Item.php" hash="13cef88e165932990fa032b57e8905a0"/></dir><dir name="Sales"><dir name="Order"><dir name="Pdf"><file name="Invoice.php" hash="9eaf28084db176b41c6007da3d529d18"/></dir></dir></dir><dir name="System"><dir name="Config"><dir name="Backend"><file name="Attributes.php" hash="174aee475c6a6a8b0b4f2e8e076c6a25"/><file name="Credentials.php" hash="09ef9fab57f64eb6415d71ba8aec2412"/><file name="Time.php" hash="a70e4d748a9b300ec7b718168fa4d5f8"/><file name="Token.php" hash="60247c8b4d5889433ae1f92e998cc889"/></dir><dir name="Source"><file name="Attributes.php" hash="8f57313a41349c7a8132b8d8e2de275e"/><file name="Availableproducts.php" hash="d9d4b3705f5fbd98efbae0289a1b6d6d"/><file name="Cache.php" hash="0ca6ccc2fed56e2c602d76880d062053"/><file name="Carriers.php" hash="2aa4edae4a91dfd0bbb752aa2f4c0073"/><file name="Categories.php" hash="c4e9f0a54f1d9c688543f26f02f99142"/><file name="Countries.php" hash="b6f1a9a75d5368d6365f06b42524e002"/><file name="Customercreate.php" hash="ca5d2b2d1ad4e18f9a1135af21b10bc2"/><file name="Debug.php" hash="6538ebc0cd0d61c124e5adc806e71aff"/><file name="Description.php" hash="1746e688692fc99524f02fb18e707dcf"/><file name="Images.php" hash="78fb5e2054bbfaa2e76263b1aa9197cc"/><file name="Montant.php" hash="3a46b8d564f1c2f0ed3b62354ac8964f"/><file name="Payment.php" hash="4bebe8e6ab0f980c1ada872b46e86503"/><file name="Position.php" hash="f1d6f89f5db5bfeedc506c539e76e3a8"/><file name="Price.php" hash="71707a69106cdd4990767351ab78fc04"/><file name="Shipping.php" hash="93401afc4fe0fb60824b778a26a24cdd"/><file name="Status.php" hash="d32004ad97adac6de361703a403a6a97"/><file name="Userid.php" hash="3d028bc3bfcaf7541b57676c014c94db"/><file name="Visibility.php" hash="91c69e8f967c13162eb38306c0391080"/></dir></dir></dir></dir><dir name="controllers"><file name="CacheController.php" hash="512cc26abd39d556104d5e69c0ac8a0d"/><file name="CatalogController.php" hash="0b65f6951e26283ea8c60bffa397186d"/><file name="CronController.php" hash="026ddcd6df9a51a41037687ca8d53a0b"/><file name="LogController.php" hash="5eff0d0a2c5621456e580e214d05c745"/><file name="OmstatusController.php" hash="95ae171ef21f861a7eaf74931b62a9db"/><file name="OrderController.php" hash="a2b8df2fb01fb4df8e7f04bcd7689bb3"/></dir><dir name="etc"><file name="adminhtml.xml" hash="e50ed10cb5025ff3a6dd7c90a6f7e0a4"/><file name="config.xml" hash="5f0442b98113df3f964764e750db745e"/><file name="system.xml" hash="06b7d4d0716360a8ca0742face2a6cbc"/></dir><dir name="img"><file name="ajax-loader.gif" hash="2a6692973429d7a74513bfa8bcb5be20"/></dir><dir name="lib"><file name="BeezupMageOrders.php" hash="537cfce31df19f4decda5e876ec74b5d"/><file name="BeezupOMDataHandler.php" hash="cf738987179f3125fc0f4626fd70f1a0"/><file name="BeezupOMOrderService.php" hash="47c09c14dce66f914023ff09374cd674"/><file name="BeezupOMOrderServiceInterface.php" hash="9b18485ae224c32f46ae5a2ec5966e5b"/><file name="BeezupOMRepositoryInterface.php" hash="c2a8267c01c3e5def25ed41f715fa4b4"/><file name="BeezupOMRequestData.php" hash="162196502ecc6078ac6b7dec6f068c80"/><file name="BeezupOMResponseData.php" hash="955ce5316129e837190f2ccf9962d74f"/><file name="BeezupOMServiceClientProxy.php" hash="82821826016c467657d56b568a42bd35"/><file name="BeezupOMStatus.php" hash="5ebcc05f1b763887e420c8f4f459bfdb"/><file name="BeezupRepository.php" hash="4a4eaabcd0a5d7427154e93757c3733d"/><dir name="Common"><file name="BeezupOMCredential.php" hash="7f45272d16860058af07005dda39672e"/><file name="BeezupOMErrorSummary.php" hash="418db7b85beb030b2d28aee6c8b35bf1"/><file name="BeezupOMExpectedOrderChangeMetaInfo.php" hash="be802f69a3474d6cc6a5899711c7018c"/><file name="BeezupOMInfoSummaries.php" hash="cdece780cf38e3f09ce2d5550b93a567"/><file name="BeezupOMInfoSummary.php" hash="3b0d49f22882e239c87060aa58beb643"/><file name="BeezupOMLink.php" hash="9fa99dce0b51e235e101259b2f0304f8"/><file name="BeezupOMOrderIdentifier.php" hash="334f410bf0794cb2ce02b4b1e6d3e0f4"/><file name="BeezupOMProcessingStatus.php" hash="b70c4c23a75360b5bee4d9ddec9e7915"/><file name="BeezupOMRequest.php" hash="2497b1ed30c12d179a5629479aee418d"/><file name="BeezupOMResponse.php" hash="690688115873ac9a3172bf67a0d62b50"/><file name="BeezupOMResult.php" hash="5cb890ce4ad4205114dd94cd1f28222d"/><file name="BeezupOMSuccessSummary.php" hash="791c6c186ed15ec1b872905b820cd03c"/><file name="BeezupOMSummary.php" hash="6cc3712480eff9f19b80b0ab887155f0"/><file name="BeezupOMWarningSummary.php" hash="03cfd6a98901b6b460b974b8e938a659"/></dir><dir name="Harvest"><file name="BeezupOMHarvestAbstractReporting.php" hash="3d499a69ea7b646eaeef5b80f0a919f3"/><file name="BeezupOMHarvestClientReporting.php" hash="1e40eca349352912e408718f3b218777"/><file name="BeezupOMHarvestOrderReporting.php" hash="778ba93a7673f35b2072003e3510ba6b"/></dir><file name="KLogger.php" hash="fe1d31bbfdf4d59a858ffd43453536c2"/><dir name="LOV"><file name="BeezupOMLOVRequest.php" hash="165c873b3fea4201a3b35596d24ffe36"/><file name="BeezupOMLOVResponse.php" hash="586749fb17b16d5ff9f07909e516b3c7"/><file name="BeezupOMLOVResult.php" hash="c0e3cc917a1d625ac6094917481a7b52"/><file name="BeezupOMLOVValue.php" hash="0dd13ae88e99c2537df8804f3af248b9"/></dir><dir name="Order"><file name="BeezupOMOrderItem.php" hash="a770b90ae4fcb6535563be6ff59f7528"/><file name="BeezupOMOrderRequest.php" hash="9afa0f18fc0aef344c3f71d054db23a0"/><file name="BeezupOMOrderResponse.php" hash="e8793a8754ec75a92ca6266357462307"/><file name="BeezupOMOrderResult.php" hash="b82fd5d86b578f2eb1d162a1169f3a9b"/></dir><dir name="OrderChange"><file name="BeezupOMOrderChangeMetaInfo.php" hash="abdbdfd6c3bf291fd38f9b3ddc419405"/><file name="BeezupOMOrderChangeRequest.php" hash="f43b9c0a052fe5346a1b309c6d96ae9c"/><file name="BeezupOMOrderChangeResponse.php" hash="bbb4e49e5ddb90991e763daa439a5642"/><file name="BeezupOMOrderChangeResult.php" hash="e7314addf6c2e51196577055d583f350"/></dir><dir name="OrderHistory"><file name="BeezupOMOrderChangeReporting.php" hash="fc7a7d7ee8bc53f8c5b7ed19793a911a"/><file name="BeezupOMOrderHarvestReporting.php" hash="e4cb500ef347d8e8543e0bf278d3d77c"/><file name="BeezupOMOrderHistoryRequest.php" hash="2e39c26d8d9dd4d5a92a2cde06c41353"/><file name="BeezupOMOrderHistoryResponse.php" hash="dc6a0c6dc89bf1f376d1ecfebd052a4b"/><file name="BeezupOMOrderHistoryResult.php" hash="d85d9b4ecf6c0456b5c8453cc3b9cfdd"/></dir><dir name="OrderList"><file name="BeezupOMOrderHeader.php" hash="af366bc39855f1315678f01b53859c1c"/><file name="BeezupOMOrderListRequest.php" hash="817c20c7c82fd5f05e0efb19ee19ec4b"/><file name="BeezupOMOrderListResponse.php" hash="b1b0ed33ba495f6e2c2f3a39ade2a5cd"/><file name="BeezupOMOrderListResult.php" hash="8befe82305a6c6fe3cacf113b3722585"/><file name="BeezupOMPaginationResult.php" hash="1e1ef534ddef8ac43d98839b4ed7f941"/></dir><dir name="SetOrderId"><file name="BeezupOMSetOrderIdRequest.php" hash="40b4a05023396115f582c2e907834e3b"/><file name="BeezupOMSetOrderIdResponse.php" hash="c4cb1f9013ae32dfdff8ca80e4725282"/><file name="BeezupOMSetOrderIdResult.php" hash="8b35abb55c52f6acdfd55bf20b370bf0"/><file name="BeezupOMSetOrderIdValues.php" hash="978b41465512c15bfe160463ca23d24f"/></dir><dir name="Stores"><file name="BeezupOMStore.php" hash="0882efcae2eff339d6cdcceee83135a7"/><file name="BeezupOMStoresRequest.php" hash="a6b1391e306f2ed21fd5e2fcdbcbbec5"/><file name="BeezupOMStoresResponse.php" hash="21535a8957506ef7da343a0526b57b02"/><file name="BeezupOMStoresResult.php" hash="d4ceed947e9e8086638497e75bbd20e8"/></dir><file name="bootstrap.php" hash="9e0e69bc9e9a932c7c80f8480c025bd2"/></dir><dir name="sql"><dir name="beezup_setup"><file name="mysql4-install-4.0.0.php" hash="75dacb26e3f96975a873c906eb37fbb0"/><file name="mysql4-upgrade-4.5.0-4.6.0.php" hash="34d1bc3a9b7658923a389fd6653ed4c9"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="BeezUp.xml" hash="93df32f86c55b57363b9abc62cf68474"/></dir></target><target name="magelocale"><dir name="fr_FR"><file name="BeezUp.csv" hash="3ae5819ffc7157b01772a15a9b16d2a2"/></dir><dir name="en_US"><file name="BeezUp.csv" hash="05b26592c14245824173936807731db4"/></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="beezup_salestab.xml" hash="784925d72538a1eeb0ca695417147a7a"/></dir><dir name="template"><dir name="beezup"><file name="custom.phtml" hash="ea83d17a2e8814c3a9ae9e056c7926a8"/></dir></dir></dir></dir></dir></target></contents>
51
  <compatible/>
52
  <dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php></required></dependencies>
53
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>BeezUP_Module_feed_and_tracker</name>
4
+ <version>4.7.0</version>
5
  <stability>stable</stability>
6
  <license uri="http://opensource.org/licenses/osl-3.0.php">Open Software License</license>
7
  <channel>community</channel>
42
  &#xD;
43
  &lt;p&gt;By BeezUP &amp; Magentix&lt;/p&gt;</description>
44
  <notes>New features :&#xD;
45
+ - Fixed bug with disabled carrier</notes>
 
46
  <authors><author><name>BeezUP</name><user>BeezUP</user><email>charles@beezup.com</email></author></authors>
47
+ <date>2016-09-30</date>
48
+ <time>13:19:14</time>
49
+ <contents><target name="magecommunity"><dir name="BeezUp"><dir name="Block"><dir name="Adminhtml"><dir name="Sales"><dir name="Order"><file name="Grid.php" hash="e18c65bc83cab8795b4ffd0d46e04c8a"/><dir name="Invoice"><file name="Totals.php" hash="ac065cd586fd2534de7e12762ab9b335"/></dir><file name="Totals.php" hash="5972281aa467d63da56a297a8df3da55"/><dir name="View"><dir name="Tab"><file name="Custom.php" hash="a60f500d604038645b826fa74e9b6619"/></dir></dir></dir><file name="Order.php" hash="c038c302f2c86f79431b49c7282c3f5c"/></dir><dir name="System"><dir name="Config"><file name="Attributes.php" hash="a504265fe4dc2df69b311d8219c88fbf"/><file name="Button.php" hash="476b33034b0c7d36e1bbd85f38b841db"/><file name="Childgroup.php" hash="388d3dee8f9d66a56c43c2790a44b45a"/><file name="Credentials.php" hash="b86f361800bebfd6fcf3564d9fe87c95"/><file name="Cron.php" hash="e1d47b095623593beb7f166d2ad7fecc"/><file name="Filter.php" hash="ad7ba55e18c080e25a08309dc428402a"/><file name="Log.php" hash="86221765980c0aee2381d5efd740949d"/><file name="Manualcron.php" hash="cbac01f15d256a43f0388f58449bffd0"/><file name="Orderlink.php" hash="9b9242ea9ccc4cfa746036b72aed2cc1"/><file name="Stores.php" hash="4297f4c94f136bb9778c9ddcd0cb336c"/><file name="Syncstatus.php" hash="49164eb19331aadabc0581472cd3c567"/><file name="Time.php" hash="ac5c2e4a40e9c6ff68cea1097dfa1e7b"/></dir></dir></dir><file name="Omstatus.php" hash="061d861d973e232a18acea0387a4a290"/><file name="Order.php" hash="ce1d3347e947fe4a0159e53ddb611fd3"/><file name="Tracking.php" hash="e6dcd6b89e782b2eb6cb83abfb1b7f56"/><file name="Xml.php" hash="dbaed2a7dfb2ea57f932865a09ae9760"/></dir><dir name="Helper"><file name="Data.php" hash="867a2562b255beaf3faa047d4130304f"/></dir><dir name="Model"><file name="Flatrate.php" hash="27d078203781d9b923605f685bfe5c25"/><file name="Observer.php" hash="3bcb925df1965ef23ef1fb08ab64de08"/><file name="Products.php" hash="e2ffaec55b84d4c1923547fc2aad47b6"/><dir name="Quote"><file name="Item.php" hash="13cef88e165932990fa032b57e8905a0"/></dir><dir name="Sales"><dir name="Order"><dir name="Pdf"><file name="Invoice.php" hash="9eaf28084db176b41c6007da3d529d18"/></dir></dir></dir><dir name="System"><dir name="Config"><dir name="Backend"><file name="Attributes.php" hash="174aee475c6a6a8b0b4f2e8e076c6a25"/><file name="Credentials.php" hash="09ef9fab57f64eb6415d71ba8aec2412"/><file name="Time.php" hash="a70e4d748a9b300ec7b718168fa4d5f8"/><file name="Token.php" hash="60247c8b4d5889433ae1f92e998cc889"/></dir><dir name="Source"><file name="Attributes.php" hash="8f57313a41349c7a8132b8d8e2de275e"/><file name="Availableproducts.php" hash="d9d4b3705f5fbd98efbae0289a1b6d6d"/><file name="Cache.php" hash="0ca6ccc2fed56e2c602d76880d062053"/><file name="Carriers.php" hash="2aa4edae4a91dfd0bbb752aa2f4c0073"/><file name="Categories.php" hash="c4e9f0a54f1d9c688543f26f02f99142"/><file name="Countries.php" hash="b6f1a9a75d5368d6365f06b42524e002"/><file name="Customercreate.php" hash="ca5d2b2d1ad4e18f9a1135af21b10bc2"/><file name="Debug.php" hash="6538ebc0cd0d61c124e5adc806e71aff"/><file name="Description.php" hash="1746e688692fc99524f02fb18e707dcf"/><file name="Images.php" hash="78fb5e2054bbfaa2e76263b1aa9197cc"/><file name="Montant.php" hash="3a46b8d564f1c2f0ed3b62354ac8964f"/><file name="Payment.php" hash="4bebe8e6ab0f980c1ada872b46e86503"/><file name="Position.php" hash="f1d6f89f5db5bfeedc506c539e76e3a8"/><file name="Price.php" hash="71707a69106cdd4990767351ab78fc04"/><file name="Shipping.php" hash="93401afc4fe0fb60824b778a26a24cdd"/><file name="Status.php" hash="d32004ad97adac6de361703a403a6a97"/><file name="Userid.php" hash="3d028bc3bfcaf7541b57676c014c94db"/><file name="Visibility.php" hash="91c69e8f967c13162eb38306c0391080"/></dir></dir></dir></dir><dir name="controllers"><file name="CacheController.php" hash="512cc26abd39d556104d5e69c0ac8a0d"/><file name="CatalogController.php" hash="0b65f6951e26283ea8c60bffa397186d"/><file name="CronController.php" hash="026ddcd6df9a51a41037687ca8d53a0b"/><file name="LogController.php" hash="5eff0d0a2c5621456e580e214d05c745"/><file name="OmstatusController.php" hash="95ae171ef21f861a7eaf74931b62a9db"/><file name="OrderController.php" hash="a2b8df2fb01fb4df8e7f04bcd7689bb3"/></dir><dir name="etc"><file name="adminhtml.xml" hash="e50ed10cb5025ff3a6dd7c90a6f7e0a4"/><file name="config.xml" hash="212840f8dc09cef04329fd2f460c496a"/><file name="system.xml" hash="7d801b858a000f1d0b4a1031a9d11b66"/></dir><dir name="img"><file name="ajax-loader.gif" hash="2a6692973429d7a74513bfa8bcb5be20"/></dir><dir name="lib"><file name="BeezupMageOrders.php" hash="537cfce31df19f4decda5e876ec74b5d"/><file name="BeezupOMDataHandler.php" hash="cf738987179f3125fc0f4626fd70f1a0"/><file name="BeezupOMOrderService.php" hash="47c09c14dce66f914023ff09374cd674"/><file name="BeezupOMOrderServiceInterface.php" hash="9b18485ae224c32f46ae5a2ec5966e5b"/><file name="BeezupOMRepositoryInterface.php" hash="c2a8267c01c3e5def25ed41f715fa4b4"/><file name="BeezupOMRequestData.php" hash="162196502ecc6078ac6b7dec6f068c80"/><file name="BeezupOMResponseData.php" hash="955ce5316129e837190f2ccf9962d74f"/><file name="BeezupOMServiceClientProxy.php" hash="82821826016c467657d56b568a42bd35"/><file name="BeezupOMStatus.php" hash="5ebcc05f1b763887e420c8f4f459bfdb"/><file name="BeezupRepository.php" hash="4a4eaabcd0a5d7427154e93757c3733d"/><dir name="Common"><file name="BeezupOMCredential.php" hash="7f45272d16860058af07005dda39672e"/><file name="BeezupOMErrorSummary.php" hash="418db7b85beb030b2d28aee6c8b35bf1"/><file name="BeezupOMExpectedOrderChangeMetaInfo.php" hash="be802f69a3474d6cc6a5899711c7018c"/><file name="BeezupOMInfoSummaries.php" hash="cdece780cf38e3f09ce2d5550b93a567"/><file name="BeezupOMInfoSummary.php" hash="3b0d49f22882e239c87060aa58beb643"/><file name="BeezupOMLink.php" hash="9fa99dce0b51e235e101259b2f0304f8"/><file name="BeezupOMOrderIdentifier.php" hash="334f410bf0794cb2ce02b4b1e6d3e0f4"/><file name="BeezupOMProcessingStatus.php" hash="b70c4c23a75360b5bee4d9ddec9e7915"/><file name="BeezupOMRequest.php" hash="2497b1ed30c12d179a5629479aee418d"/><file name="BeezupOMResponse.php" hash="690688115873ac9a3172bf67a0d62b50"/><file name="BeezupOMResult.php" hash="5cb890ce4ad4205114dd94cd1f28222d"/><file name="BeezupOMSuccessSummary.php" hash="791c6c186ed15ec1b872905b820cd03c"/><file name="BeezupOMSummary.php" hash="6cc3712480eff9f19b80b0ab887155f0"/><file name="BeezupOMWarningSummary.php" hash="03cfd6a98901b6b460b974b8e938a659"/></dir><dir name="Harvest"><file name="BeezupOMHarvestAbstractReporting.php" hash="3d499a69ea7b646eaeef5b80f0a919f3"/><file name="BeezupOMHarvestClientReporting.php" hash="1e40eca349352912e408718f3b218777"/><file name="BeezupOMHarvestOrderReporting.php" hash="778ba93a7673f35b2072003e3510ba6b"/></dir><file name="KLogger.php" hash="fe1d31bbfdf4d59a858ffd43453536c2"/><dir name="LOV"><file name="BeezupOMLOVRequest.php" hash="165c873b3fea4201a3b35596d24ffe36"/><file name="BeezupOMLOVResponse.php" hash="586749fb17b16d5ff9f07909e516b3c7"/><file name="BeezupOMLOVResult.php" hash="c0e3cc917a1d625ac6094917481a7b52"/><file name="BeezupOMLOVValue.php" hash="0dd13ae88e99c2537df8804f3af248b9"/></dir><dir name="Order"><file name="BeezupOMOrderItem.php" hash="a770b90ae4fcb6535563be6ff59f7528"/><file name="BeezupOMOrderRequest.php" hash="9afa0f18fc0aef344c3f71d054db23a0"/><file name="BeezupOMOrderResponse.php" hash="e8793a8754ec75a92ca6266357462307"/><file name="BeezupOMOrderResult.php" hash="b82fd5d86b578f2eb1d162a1169f3a9b"/></dir><dir name="OrderChange"><file name="BeezupOMOrderChangeMetaInfo.php" hash="abdbdfd6c3bf291fd38f9b3ddc419405"/><file name="BeezupOMOrderChangeRequest.php" hash="f43b9c0a052fe5346a1b309c6d96ae9c"/><file name="BeezupOMOrderChangeResponse.php" hash="bbb4e49e5ddb90991e763daa439a5642"/><file name="BeezupOMOrderChangeResult.php" hash="e7314addf6c2e51196577055d583f350"/></dir><dir name="OrderHistory"><file name="BeezupOMOrderChangeReporting.php" hash="fc7a7d7ee8bc53f8c5b7ed19793a911a"/><file name="BeezupOMOrderHarvestReporting.php" hash="e4cb500ef347d8e8543e0bf278d3d77c"/><file name="BeezupOMOrderHistoryRequest.php" hash="2e39c26d8d9dd4d5a92a2cde06c41353"/><file name="BeezupOMOrderHistoryResponse.php" hash="dc6a0c6dc89bf1f376d1ecfebd052a4b"/><file name="BeezupOMOrderHistoryResult.php" hash="d85d9b4ecf6c0456b5c8453cc3b9cfdd"/></dir><dir name="OrderList"><file name="BeezupOMOrderHeader.php" hash="af366bc39855f1315678f01b53859c1c"/><file name="BeezupOMOrderListRequest.php" hash="817c20c7c82fd5f05e0efb19ee19ec4b"/><file name="BeezupOMOrderListResponse.php" hash="b1b0ed33ba495f6e2c2f3a39ade2a5cd"/><file name="BeezupOMOrderListResult.php" hash="8befe82305a6c6fe3cacf113b3722585"/><file name="BeezupOMPaginationResult.php" hash="1e1ef534ddef8ac43d98839b4ed7f941"/></dir><dir name="SetOrderId"><file name="BeezupOMSetOrderIdRequest.php" hash="40b4a05023396115f582c2e907834e3b"/><file name="BeezupOMSetOrderIdResponse.php" hash="c4cb1f9013ae32dfdff8ca80e4725282"/><file name="BeezupOMSetOrderIdResult.php" hash="8b35abb55c52f6acdfd55bf20b370bf0"/><file name="BeezupOMSetOrderIdValues.php" hash="978b41465512c15bfe160463ca23d24f"/></dir><dir name="Stores"><file name="BeezupOMStore.php" hash="0882efcae2eff339d6cdcceee83135a7"/><file name="BeezupOMStoresRequest.php" hash="a6b1391e306f2ed21fd5e2fcdbcbbec5"/><file name="BeezupOMStoresResponse.php" hash="21535a8957506ef7da343a0526b57b02"/><file name="BeezupOMStoresResult.php" hash="d4ceed947e9e8086638497e75bbd20e8"/></dir><file name="bootstrap.php" hash="9e0e69bc9e9a932c7c80f8480c025bd2"/></dir><dir name="sql"><dir name="beezup_setup"><file name="mysql4-install-4.0.0.php" hash="75dacb26e3f96975a873c906eb37fbb0"/><file name="mysql4-upgrade-4.5.0-4.6.0.php" hash="34d1bc3a9b7658923a389fd6653ed4c9"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="BeezUp.xml" hash="93df32f86c55b57363b9abc62cf68474"/></dir></target><target name="magelocale"><dir name="fr_FR"><file name="BeezUp.csv" hash="3ae5819ffc7157b01772a15a9b16d2a2"/></dir><dir name="en_US"><file name="BeezUp.csv" hash="05b26592c14245824173936807731db4"/></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="beezup_salestab.xml" hash="784925d72538a1eeb0ca695417147a7a"/></dir><dir name="template"><dir name="beezup"><file name="custom.phtml" hash="ea83d17a2e8814c3a9ae9e056c7926a8"/></dir></dir></dir></dir></dir></target></contents>
50
  <compatible/>
51
  <dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php></required></dependencies>
52
  </package>