BeezUP_Module_feed_and_tracker - Version 4.6.4

Version Notes

New features :
>Minor bugs fixing

Download this release

Release Info

Developer BeezUP
Extension BeezUP_Module_feed_and_tracker
Version 4.6.4
Comparing to
See all releases


Code changes from version 4.6.3 to 4.6.4

app/code/community/BeezUp/Block/Order.php CHANGED
@@ -30,7 +30,7 @@
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
 
@@ -247,1130 +247,1131 @@
247
  }
248
 
249
  public function getBeezupOrderId(){
250
- $oIdentifier = new BeezupOMOrderIdentifier();
251
- $oIdentifier
252
- ->setAccountId($this->account_id)
253
- ->setMarketplaceTechnicalCode($this->marketplace_code)
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
267
- $order_address = $final_order->getOrderBuyerAddressCity();
268
- $order_country = $final_order->getOrderBuyerAddressCountryName();
269
- $order_country_iso = $final_order->getOrderBuyerAddressCountryIsoCodeAlpha2();
270
- $order_address = $this->getBeezupBuyerAddress($final_order);
271
- $order_postalCode = $final_order->getOrderBuyerAddressPostalCode();
272
- $order_customer = $final_order->getOrderBuyerName();
273
- $order_customer_email = $final_order->getOrderBuyerEmail();
274
- $order_customer_phone = $final_order->getOrderBuyerPhone();
275
- $order_customer_mobile = $final_order->getOrderBuyerMobilePhone();
276
- $order_comment = $final_order->getOrderComment();
277
- $order_company = $final_order->getOrderBuyerCompanyName();
278
- $order_city = $final_order->getOrderBuyerAddressCity();
279
- $order_region = $final_order->getOrderBuyerStateOrRegion();
280
- $order_status = $final_order->getOrderStatusBeezUPOrderStatus();
281
- //shipping information
282
- $shipping_city = $final_order->getOrderShippingAddressCity();
283
- $shipping_country = $final_order->getOrderShippingAddressCountryName();
284
- $shipping_country_iso = $final_order->getOrderShippingAddressCountryIsoCodeAlpha2();
285
- $shipping_address = $this->getBeezupShippingAddress($final_order);
286
- $shipping_name = $final_order->getOrderShippingAddressName();
287
- $shipping_postalCode = $final_order->getOrderShippingAddressPostalCode();
288
- $shipping_email = $final_order->getOrderShippingEmail();
289
- $shipping_phone = $final_order->getOrderShippingPhone();
290
- $shipping_mobile = $final_order->getOrderShippingMobilePhone();
291
- $shipping_company = $final_order->getOrderShippingCompanyName();
292
- $shipping_region = $final_order->getOrderShippingAddressStateOrRegion();
293
- $order_currency_code = $final_order->getOrderCurrencyCode();
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);
320
- }
321
- elseif(!filter_var($order_customer_email, FILTER_VALIDATE_EMAIL)) {
322
- $order_customer_email = $this->generateEmail($final_order);
323
- }
324
-
325
- $mage_productIds = $this->prescanOrder($final_order);
326
- if($mage_productIds) {
327
- $order_data = array(
328
- "etag" => $etag,
329
- "account_id" => $account_id,
330
- "order_status" => $order_status,
331
- "products" => $mage_productIds['products'],
332
- "storeid" => $mage_productIds['store'],
333
- "order_currency" => $order_currency_code ,
334
- "order_address" => $order_adress,
335
- "order_country" => $order_country,
336
- "order_country_iso" => $order_country_iso ,
337
- "order_address" => $order_address ,
338
- "order_postalCode" => $order_postalCode ,
339
- "order_customer" => $order_first_name ,
340
- "order_lastname" => $order_last_name ,
341
- "order_customer_email" => $order_customer_email ,
342
- "order_customer_phone" => $this->getPhone($order_customer_phone, $order_customer_mobile) ,
343
- "order_comment" => $order_comment ,
344
- "order_company" => $order_company ,
345
- "shipping_city" => $shipping_city ,
346
- "shipping_country" => $shipping_country ,
347
- "shipping_country_iso" => $shipping_country_iso ,
348
- "shipping_address" => $shipping_address ,
349
- "shipping_name" => $shipping_first_name ,
350
- "shipping_lastname" => $shipping_last_name ,
351
- "shipping_postalCode" => $shipping_postalCode ,
352
- "shipping_region" =>$shipping_region,
353
- "shipping_email" => $shipping_email ,
354
- "shipping_phone" => $this->getPhone($shipping_phone, $shipping_mobile) ,
355
- "shipping_company" => $shipping_company ,
356
- "order_totalPrice" => $order_totalPrice ,
357
- "order_shippingPrice" => $order_shippingPrice ,
358
- "order_city" => $order_city,
359
- "order_region" => $order_region,
360
- "marketplace" => $marketplace,
361
- "discounts" => $mage_productIds['discounts'],
362
- "marketplace_business_code" => $marketplace_business_code
363
- );
364
-
365
-
366
-
367
- //check if order exists
368
- $Mageorder = $this->loadMageOrder();
369
- if ($Mageorder) {
370
- //if order exists
371
- $this->updateEtag($etag);
372
- $this->updateBilling($Mageorder, $order_data );
373
- $this->updateBeezupInfoTab($Mageorder, $final_order, $order_data);
374
- $this->debugLog("Order Already exists Mage Order ID: " .$Mageorder->getId());
375
- $status1 = $Mageorder->getStatusLabel();
376
- $status = $this->getStatus($status1);
377
- if($status !== $order_status) {
378
- //if order exits and status has changed we update order status
379
- $this->debugLog("Updating Order Status from: ".$status1." to: ".$order_status );
380
- $this->setStatus( $order_status, $Mageorder);
381
- }
382
-
383
- $id_order = $Mageorder->getId();
384
- $BeezupMageOrder = new BeezupMageOrders($id_order);
385
- $BeezupMageOrder->setData(array("shipping" =>(float) $order_data['order_shippingPrice']));
386
- $BeezupMageOrder->updateShippingInfo();
387
- } else {
388
- //if not we create order
389
-
390
-
391
- $this->debugLog("Generating Order");
392
- $this->addOrder($order_data,$final_order );
393
- //die();
394
-
395
- }
396
-
397
-
398
- } else {
399
- //order could not be imported
400
-
401
-
402
- }
403
-
404
-
405
- } else {
406
- //etag has not changed
407
- $this->debugLog("Order Etag has not changed");
408
-
409
- }
410
-
411
-
412
-
413
-
414
-
415
  }
416
 
417
 
418
 
419
  public function generateEmail(BeezupOMOrderResult $oBeezupOrder)
420
  {
421
- $sRawValue = $oBeezupOrder->getBeezupOrderUUID ();
422
- $sFakeDomain = preg_replace ( '/\W/', '', $oBeezupOrder->getMarketPlaceTechnicalCode () ) . '.com';
423
- return 'fakeemail' . md5 ( $sFakeDomain . $sRawValue ) . '@' . strtolower ( $sFakeDomain );
424
  }
425
 
426
 
427
 
428
  public function getOrderList($orderList = null) {
429
- if($orderList == null) {
430
- $data = $this->createRepository()->createOrderListRequest();
431
- $oRequest = $this->getOrderService()->getClientProxy()->getOrderList($data);
432
- $orderList = $oRequest->getResult();
433
- }
434
- $oPagination = $orderList->getPaginationResult();
435
- if(!empty($oPagination)) {
436
- $oLinksTotal = $oPagination->getLinks();
437
- } else {
438
- $configModel = Mage::getModel('core/config');
439
- $configModel->saveConfig('beezup/marketplace/sync_status',0);
440
- die("No more orders to import");
441
- }
442
-
443
- //$header = $orderList->getOrderHeaders();
444
- foreach($orderList->getOrderHeaders() as $order) {
445
- $order_status = $order->getBeezupOrderState();
446
- $orderLinks = $order->getLinks();
447
- $etag = $order->getETag();
448
- $beezup_order_id = $order->getBeezupOrderUUID();
449
- $account_id = $order->getAccountId();
450
- $orderdata = $this->getOrderService()->getClientProxy()->getOrderByLink($orderLinks[0]);
451
- $this->debugLog("Initializing Order - Link: ".$orderLinks[0]->getHref());
452
- $this->createOrder($orderdata, $oLinksTotal);
453
-
454
- }
455
-
456
- if(!empty($oLinksTotal)) {
457
- //we check if there is next link and get next orders
458
- foreach($oLinksTotal as $link) {
459
- if( $link->getRel() == "next") {
460
-
461
- $this->log->LogInfo("Initializing New Order List ->". $link->getHref());
462
- $this->log2->LogInfo("Initializing New Order List ->". $link->getHref());
463
- $oRequest = $this->getOrderService()->getClientProxy()->getOrderListByLink($link);
464
- $orderList = $oRequest->getResult();
465
- $this->getOrderList($orderList);
466
- }
467
-
468
- }
469
- }
470
-
471
  }
472
 
473
 
474
 
475
  public function updateBeezupInfoTab($order, $oLink, $data) {
476
- $beezup_last_modification_date = $oLink->getOrderLastModificationUtcDate();
477
- $beezup_last_modification_date = $beezup_last_modification_date->date;
478
- $beezup_marketplace_last_modification_date = $oLink->getOrderMarketPlaceLastModificationUtcDate();
479
- $beezup_marketplace_last_modification_date = $beezup_marketplace_last_modification_date->date;
480
- $beezup_comission = $oLink->getOrderTotalCommission()." ".$data['order_currency'];
481
- $tot_comm = $oLink->getOrderTotalCommission();
482
- if(empty($tot_comm ) || $tot_comm == 0) {
483
- $beezup_comission = 0;
484
- }
485
- $updateData = array("beezup_status" => $data['order_status'],
486
- "beezup_last_modification_date" => $beezup_last_modification_date,
487
- "beezup_marketplace_last_modification_date" => $beezup_marketplace_last_modification_date ,
488
- "beezup_total_paid" => $oLink->getOrderTotalPrice()." ".$data['order_currency'],
489
- "beezup_comission" => $beezup_comission,
490
- "beezup_marketplace_status" => $oLink->getOrderStatusMarketPlaceStatus());
491
- $orderId = $order->getId();
492
- $beezupMageOrder = new BeezupMageOrders($orderId);
493
- $beezupMageOrder->setData($updateData);
494
- $beezupMageOrder->updateBeezupInfo();
495
-
496
-
497
  }
498
 
499
  public function getPhone($phone, $phone2) {
500
- $retorno = "";
501
- if(!empty($phone) && $phone !== "") {
502
- $retorno .= $phone;
503
- }
504
- if(!empty($phone2) && $phone2 !=="") {
505
- if(empty($phone) || $phone == "") {
506
- $retorno = $phone2;
507
-
508
- } else {
509
- $retorno .= " - ".$phone2;
510
- }
511
- }
512
- return $retorno;
513
  }
514
 
515
 
516
  public function getBeezupBuyerAddress($order) {
517
- $add1=$order->getOrderBuyerAddressLine1();
518
- $add2=$order->getOrderBuyerAddressLine2();
519
- $add3=$order->getOrderBuyerAddressLine3();
520
- $retorno = "";
521
- if(!empty($add1)) {
522
- $retorno = $order->getOrderBuyerAddressLine1();
523
- }
524
- if(!empty($add2)) {
525
- if(empty($add1)) {
526
- $retorno .= $order->getOrderBuyerAddressLine2();
527
- } else {
528
- $retorno .= " - ". $order->getOrderBuyerAddressLine2();
529
- }
530
- }
531
- if(!empty($add3)){
532
- if(empty($add1) && empty($add2)) {
533
- $retorno .= $order->getOrderBuyerAddressLine3();
534
- } else {
535
- $retorno .= " - ". $order->getOrderBuyerAddressLine3();
536
- }
537
- }
538
- return $retorno;
539
  }
540
 
541
 
542
  public function getBeezupShippingAddress($order) {
543
- $add1 = $order->getOrderShippingAddressLine1();
544
- $add2 = $order->getOrderShippingAddressLine2();
545
- $add3=$order->getOrderBuyerAddressLine3();
546
- $retorno = "";
547
- if(!empty($add1 )) {
548
- $retorno = $order->getOrderShippingAddressLine1();
549
- }
550
- if(!empty($add2)) {
551
- if(empty($add1)) {
552
- $retorno .= $order->getOrderShippingAddressLine2();
553
- } else {
554
- $retorno .= " - ". $order->getOrderShippingAddressLine2();
555
- }
556
- }
557
- if(!empty($add3)){
558
- if(empty($add1) && empty($add2)) {
559
- $retorno .= $order->getOrderShippingAddressLine3();
560
- } else {
561
- $retorno .= " - ". $order->getOrderShippingAddressLine3();
562
- }
563
- }
564
- return $retorno;
565
  }
566
 
567
  public function checkEtagExists($etag) {
568
- $resource = Mage::getSingleton('core/resource');
569
- $readConnection = $resource->getConnection('core_read');
570
- $table = $resource->getTableName('sales/order_grid');
571
- $query = 'SELECT increment_id FROM ' . $table . ' WHERE beezup_etag = \''
572
- . $etag . '\' LIMIT 1';
573
- $order = $readConnection->fetchOne($query);
574
- if($order && !empty($order)) {
575
- return true;
576
- }
577
- return false;
578
-
579
  }
580
 
581
 
582
  public function updateEtag($etag) {
583
- $this->debugLog("Updating Etag");
584
- $resource = Mage::getSingleton('core/resource');
585
- $writeConnection = $resource->getConnection('core_write');
586
- $table = $resource->getTableName('sales/order_grid');
587
- $query = "UPDATE {$table} SET beezup_etag = '{$etag}' where beezup_market_order_id = '{$this->orderid}' ";
588
- $writeConnection->query($query);
589
-
590
  }
591
 
592
 
593
 
594
  public function updateBilling($order, $data) {
595
-
596
-
597
- $addressData = array(
598
- 'billing_firstname' => ($data['order_customer']) ? $data['order_customer'] : "empty",
599
- 'billing_lastname' => ($data['order_lastname']) ? $data['order_lastname'] : "empty",
600
- 'billing_street' => ($data['order_address']) ? $data['order_address'] : "empty",
601
- 'billing_city' => ($data['order_city']) ? $data['order_city'] : "empty",
602
- 'billing_postcode' => ($data['order_postalCode']) ? $data['order_postalCode'] : "empty",
603
- 'billing_telephone' => ($data['order_customer_phone']) ? $data['order_customer_phone'] : "empty",
604
- 'billing_country_id' => ($data['order_country_iso']) ? $data['order_country_iso'] : "empty",
605
- 'billing_region_id' => ($data['order_region ']) ? substr($data['order_region '], 0,2) : "EM",
606
- 'shipping_firstname' => ($data['shipping_name']) ? $data['shipping_name'] : "empty",
607
- 'shipping_lastname' => ($data['shipping_lastname']) ? $data['shipping_lastname'] : "empty",
608
- 'shipping_street' => ($data['shipping_address']) ? $data['shipping_address'] : "empty",
609
- 'shipping_city' => ($data['shipping_city']) ? $data['shipping_city'] : "empty",
610
- 'shipping_postcode' => ($data['shipping_postalCode']) ? $data['shipping_postalCode'] : "empty",
611
- 'shipping_telephone' => ($data['shipping_phone']) ? $data['shipping_phone'] : "empty",
612
- 'shipping_country_id' => ($data['shipping_country_iso']) ? $data['shipping_country_iso'] : "empty",
613
- 'shipping_region_id' => ($data['shipping_region']) ? substr($data['shipping_region'], 0, 2) : "EM" // id from directory_country_region table
614
- );
615
-
616
- $shippingData = array(
617
-
618
- );
619
- // Get the id of the orders shipping address
620
- $orderId = $order->getId();
621
- $beezupMageOrder = new BeezupMageOrders($orderId);
622
- $beezupMageOrder->setData($addressData);
623
- $beezupMageOrder->updateAdresses();
624
  }
625
 
626
  public function updateAddresses($shippingData, $address) {
627
- if($shippingData['firstname'] !==$address['firstname']) {
628
- $address->setFirstname($shippingData['firstname']);
629
- }
630
- if($shippingData['lastname'] !==$address['lastname']) {
631
- $address->setLastname($shippingData['lastname']);
632
- }
633
- if($shippingData['street'] !==$address['street']) {
634
- $address->setStreet($shippingData['street']);
635
- }
636
- if($shippingData['city'] !==$address['city']) {
637
- $address->setCity($shippingData['city']);
638
- }
639
- if($shippingData['postcode'] !==$address['postcode']) {
640
- $address->setPostcode($shippingData['postcode']);
641
- }
642
- if($shippingData['telephone'] !==$address['telephone']) {
643
- $address->setTelephone($shippingData['telephone']);
644
- }
645
- $address->save();
646
-
647
-
648
  }
649
 
650
 
651
  public function loadMageOrder() {
652
- $Mageorder = Mage::getModel('sales/order')->loadByIncrementId($this->orderid);
653
- if ($Mageorder->getId()) {
654
- return $Mageorder;
655
- } else {
656
- //we get order from marketplace orderid
657
- $orderInc = $this->checkMarketOrderExists($this->orderid);
658
- if($orderInc) {
659
- // if exists
660
- $Mageorder = Mage::getModel('sales/order')->loadByIncrementId($orderInc);
661
- if ($Mageorder->getId()) {
662
- return $Mageorder;
663
- }
664
- }
665
- }
666
- return false;
667
  }
668
 
669
 
670
  private function debugLog($message) {
671
-
672
- if($this->orderid !== "") {
673
- $message = $this->orderid." | ".$message;
674
- }
675
- $this->log->LogInfo($message);
676
-
677
- $this->log2->LogInfo($message);
678
  }
679
 
680
  public function prescanOrder(BeezupOMOrderResult $order) {
681
- $retorno = array();
682
- $orderItems = $order->getOrderItems();
683
- foreach ($orderItems as $item)
684
- {
685
-
686
- if ($item->getOrderItemOrderItemType () !== 'Product')
687
- {
688
- // continue;
689
- }
690
- $beezup_store = $item->getOrderItemBeezUPStoreId(); //beezup storeid
691
- $mage_storeid = $this->checkOrderStore($beezup_store); //magento storeid
692
- $marketplace_orderid = $item->getOrderItemMarketPlaceProductId();
693
- if(!$mage_storeid) {
694
-
695
- if(strpos($marketplace_orderid,'INTERETBCA') !== false || strpos($marketplace_orderid,'interetbca') !== false) { }
696
- else {
697
- $this->log->LogError($this->orderid." | No mapping for store ".$beezup_store);
698
- $this->log2->LogError($this->orderid." | No mapping for store ".$beezup_store);
699
- return false;
700
- }
701
-
702
- }
703
- // $retorno['store'] = 1;
704
- $retorno['store'] = $mage_storeid;
705
- $this->debugLog("Store Matching succesful, Beezup Store: ".$beezup_store." , Magento Store Id: ".$mage_storeid);
706
- $product_ImportedMerchantId = $item->getOrderItemMerchantImportedProductId();
707
- $product_MerchantId = $item->getOrderItemMerchantProductId();
708
-
709
- $product_quantity = $item->getOrderItemQuantity();
710
- $product_price = $item->getOrderItemItemPrice();
711
- $product_title = $item->getOrderItemTitle();
712
- $product_image = $item->getOrderItemImageUrl();
713
- if(strpos($marketplace_orderid,'INTERETBCA') !== false || strpos($marketplace_orderid,'interetbca') !== false) {
714
- $retorno['discounts']= $item->getOrderItemTotalPrice();
715
- } else {
716
- $product = $this->getMageProduct($product_ImportedMerchantId , $product_MerchantId , $beezup_store );
717
- if($product) {
718
- $mage_productId = $product->getId();
719
- $stocklevel = (int)Mage::getModel('cataloginventory/stock_item')
720
- ->loadByProduct($product)->getQty();
721
-
722
- $retorno['products'][] = array("id" => $mage_productId, "qty" => $product_quantity, "price" => $product_price, "curr_stock" => $stocklevel);
723
- //producto existe
724
- } else {
725
- //vendria if de si activada opcion de crear producto creamos
726
- if(!$this->debug) {
727
- return false;
728
- }
729
- $product_data = array(
730
- "sku" => $product_ImportedMerchantId,
731
- "sku2" => $product_MerchantId,
732
- "qty" => $product_quantity,
733
- "price" => $product_price,
734
- "title" => $product_title,
735
- "image" => $product_image,
736
- "storeId" => $mage_storeid
737
- );
738
- $product = $this->createProduct($product_data);
739
- if(!$product) {
740
- return false;
741
- }
742
- $stocklevel = (int)Mage::getModel('cataloginventory/stock_item')
743
- ->loadByProduct($product)->getQty();
744
- $mage_productId = $product->getId();
745
- $retorno['products'][] = array("id" => $mage_productId, "qty" => $product_quantity, "price" => $product_price, "curr_stock" => $stocklevel);
746
- }
747
- }
748
- }
749
-
750
- return $retorno;
751
- }
752
-
753
-
754
-
755
- public function matchProductAttributes($importedId, $storeId) {
756
- $product = null;
757
- $helper = Mage::helper('beezup');
758
- $attributes = $helper->getConfig('beezup/marketplace/attributes');
759
- $attributes = unserialize ($attributes);
760
-
761
- foreach($attributes['attributes'][$storeId ] as $attribute) {
762
- $att = explode("|", $attribute);
763
- if($storeId == $att[1]) {
764
-
765
- $product=Mage::getModel('catalog/product')->loadByAttribute($att[0],$importedId);
766
- if($product) {
767
- break;
768
- }
769
- }
770
- }
771
-
772
- return $product;
773
- }
774
-
775
-
776
-
777
- public function getMageProduct($importedId, $merchantId, $storeId){
778
- try {
779
- $product=Mage::getModel('catalog/product')->load($importedId);
780
- if (!$product->getId() || $product->getId() !== $importedId ){
781
- $product = $this->matchProductAttributes($importedId, $storeId);
782
- if($product == null || !is_object($product)) {
783
- $product=Mage::getModel('catalog/product')->load($merchantId);
784
- if(!$product->getId() || $product->getId() !== $merchantId ) {
785
- $product = $this->matchProductAttributes($merchantId, $storeId);
786
-
787
- }
788
- }
789
- }
790
-
791
- if(is_object($product)) {
792
- if($product->getId()) {
793
- $this->debugLog("Product Matching succesful, Beezup Imported Id: ".$importedId." , Magento Product Id: ".$product->getId());
794
- return $product;
795
- }}
796
- $this->log->LogError($this->orderid. "| No Product Matching, Product ".$importedId." could not be found");
797
- $this->log2->LogError($this->orderid. "| No Product Matching, Product ".$importedId." could not be found");
798
- return false;
799
- }catch(Exception $e){
800
- $this->log->LogError($this->orderid. "| Product ".$importedId." could not be found, error: ".$e->getMessage());
801
- $this->log2->LogError($this->orderid. "| Product ".$importedId." could not be found, error: ".$e->getMessage());
802
- return false;
803
- //error no se pudo crear la orden
804
-
805
- }
806
- }
807
-
808
-
809
- public function checkOrderStore($storeId ) {
810
- $helper = Mage::helper('beezup');
811
- $stores = $helper->getConfig('beezup/marketplace/stores');
812
- $stores = unserialize ($stores);
813
- foreach($stores as $store) {
814
- if(isset($store[$storeId]) && $store[$storeId] > 0) {
815
- return $store[$storeId];
816
- }
817
- }
818
- return false;
819
- }
820
-
821
-
822
-
823
- /**
824
- * @return BeezupOMOrderService
825
- */
826
- public function getOrderService(){
827
- if ($this->oOrderService === null){
828
- $this->oOrderService = $this->createOrderService();
829
- // enchufamos debug mode, esta activado? false true $this->oOrderService->setDebugMode(false);
830
- }
831
- return $this->oOrderService;
832
- }
833
-
834
- /**
835
- * @return BeezupOMOrderService
836
- */
837
- protected function createOrderService(){
838
-
839
- return new BeezupOMOrderService($this->createRepository() );
840
- }
841
-
842
- protected function createRepository() {
843
- if ($this->repository == null) {
844
- $this->repository = new BeezupRepository();
845
- }
846
- return $this->repository;
847
-
848
- }
849
-
850
-
851
-
852
-
853
- private function createCustomer($customer_email , $data) {
854
- $password = $this->orderid;
855
- $this->debugLog("Creating new Customer");
856
- $customer = Mage::getModel('customer/customer');
857
- $customer->setWebsiteId(Mage::app()->getWebsite()->getId());
858
- $customer->loadByEmail($customer_email);
859
- if(!$customer->getId()) {
860
- $customer->setEmail($customer_email);
861
- $customer->setFirstname($data['firstname']);
862
- $customer->setLastname($data['lastname']);
863
- $customer->setPassword($password);
864
- try {
865
- $customer->save();
866
- $customer->setConfirmation(null);
867
- $customer->save();
868
- $this->debugLog("Customer created succesfully");
869
- return $customer;
870
- //Make a "login" of new customer
871
- // Mage::getSingleton('customer/session')->loginById($customer->getId());
872
- }
873
-
874
- catch (Exception $ex) {
875
- //Zend_Debug::dump($ex->getMessage());
876
- //GUARDAR ERROR CREACION USUARIO
877
- $this->log2->LogError($this->orderid. " | Customer importation failed: ".$ex->getMessage());
878
- return false;
879
- }
880
-
881
- } else {
882
- $this->debugLog("Creating already exists, returning customer object");
883
- return $customer;
884
- }
885
- }
886
-
887
-
888
-
889
- public function addOrder($data, $oLink, $stop = false) {
890
-
891
-
892
- try {
893
- $helper = Mage::helper('beezup');
894
- $addStock = $helper->getConfig('beezup/marketplace/available_products');
895
- $baseCurrencyCode = Mage::app()->getStore()->getBaseCurrencyCode();
896
- $quote = Mage::getModel('sales/quote')
897
- ->setStoreId($data['storeid']);
898
- $quote->setCustomerEmail($data['order_customer_email']);
899
-
900
-
901
- $currency = Mage::getModel('directory/currency')->load($data['order_currency']);
902
- $quote->setForcedCurrency($currency);
903
-
904
- $blnCreate = true;
905
- $total_new_price = 0;
906
- foreach($data['products'] as $prod) {
907
- if($prod['qty']==0) {
908
- $blnCreate = false;
909
- break;
910
- }
911
- $prod_totality_price = $prod['price']*$prod['qty'];
912
- $total_new_price = $total_new_price + $prod_totality_price;
913
- $product = Mage::getModel('catalog/product')->load($prod['id']);
914
- $buyInfo = array(
915
- 'qty' => $prod['qty'],
916
- );
917
- $this->debugLog("Adding ".$prod['qty']." product/s with id ".$product->getId()." to order, with Beezup Price: ".$prod['price']);
918
- //echo "Product ".$product->getId()."<br><br>";
919
- //para no perder stock:
920
- //Mage::getModel('cataloginventory/stock')->backItemQty($productId,$new_qty);
921
-
922
-
923
- if($addStock == 1) {
924
- $stock = Mage::getModel('cataloginventory/stock_item')->loadByProduct($product);
925
-
926
- if ($stock->getQty() < $prod['qty'] && $product->getStockItem()->getMaxSaleQty() >= $prod['qty']) {
927
- $this->debugLog("Product ".$product->getId()." Stock = 0, Updating to ".$prod['qty']." to generate Order");
928
- // Mage::getModel('cataloginventory/stock')->backItemQty($product->getId(),$prod['qty']);
929
- //$this->_updateStocks(array("id_product" => $product->getId(), "qty" => $prod['qty']));
930
- $product->setStockData(
931
- array(
932
- 'is_in_stock' => 1,
933
- 'qty' => $prod['qty'],
934
- 'manage_stock' => 1,
935
- 'use_config_notify_stock_qty' => 1
936
- )
937
- );
938
- $product->save();
939
- $product = Mage::getModel('catalog/product')->load($product->getId());
940
-
941
- }
942
- }
943
- //fin para no perder stock
944
-
945
- /*
946
- $tax_class = $product->getTaxClassId();
947
- $product->setTaxClassId(0);
948
- $product->getResource()->saveAttribute($product, 'tax_class_id'); */
949
- $price = $prod['price'];
950
-
951
- $quote_item = Mage::getModel('beezup/quote_item');
952
- $quote_item
953
- ->setProduct($product)
954
- ->setPrice((float) $price )
955
- ->setCustomPrice((float)$price )
956
- ->setOriginalCustomPrice((float) $price )
957
- ->setQuote($quote)
958
- ->setQty((integer) $prod['qty'])
959
- ->setBeezupPrice((float) $price );
960
-
961
-
962
- $quote->addItem($quote_item);
963
-
964
- //$quote->addProduct($product, new Varien_Object($buyInfo))->setOriginalCustomPrice($price)->setCustomPrice($price);
965
-
966
- /*
967
- $product->setTaxClassId($tax_class);
968
-
969
- $product->getResource()->saveAttribute($product, 'tax_class_id');
970
- */
971
- }
972
-
973
- if($blnCreate) {
974
- $addressData = array(
975
- 'firstname' => ($data['order_customer']) ? $data['order_customer'] : "empty",
976
- 'lastname' => ($data['order_lastname']) ? $data['order_lastname'] : "empty",
977
- 'street' => ($data['order_address']) ? $data['order_address'] : "empty",
978
- 'city' => ($data['order_city']) ? $data['order_city'] : "empty",
979
- 'postcode' => ($data['order_postalCode']) ? $data['order_postalCode'] : "empty",
980
- 'telephone' => ($data['order_customer_phone']) ? $data['order_customer_phone'] : "empty",
981
- 'country_id' => ($data['order_country_iso']) ? $data['order_country_iso'] : "empty",
982
- 'region_id' => ($data['order_region ']) ? substr($data['order_region '], 0,2) : "EM"// id from directory_country_region table
983
- );
984
-
985
- $shippingData = array(
986
- 'firstname' => ($data['shipping_name']) ? $data['shipping_name'] : "empty",
987
- 'lastname' => ($data['shipping_lastname']) ? $data['shipping_lastname'] : "empty",
988
- 'street' => ($data['shipping_address']) ? $data['shipping_address'] : "empty",
989
- 'city' => ($data['shipping_city']) ? $data['shipping_city'] : "empty",
990
- 'postcode' => ($data['shipping_postalCode']) ? $data['shipping_postalCode'] : "empty",
991
- 'telephone' => ($data['shipping_phone']) ? $data['shipping_phone'] : "empty",
992
- 'country_id' => ($data['shipping_country_iso']) ? $data['shipping_country_iso'] : "empty",
993
- 'region_id' => ($data['shipping_region']) ? substr($data['shipping_region'], 0, 2) : "EM" // id from directory_country_region table
994
- );
995
-
996
- if($this->blnCreateCustomer) {
997
-
998
- $mage_customer = $this->createCustomer($data['order_customer_email'], $addressData);
999
- $quote->assignCustomer($mage_customer);
1000
- }
1001
-
1002
-
1003
- $payment_method = $helper->getConfig('beezup/marketplace/payment_method');
1004
- $billingAddress = $quote->getBillingAddress()->addData($addressData);
1005
- $shippingAddress = $quote->getShippingAddress()->addData($shippingData);
1006
- $shipping_cost = (float) $data['order_shippingPrice'];
1007
- if($data['order_shippingPrice'] == 0) {
1008
- $shipping_cost = 20000;
1009
- }
1010
- $total_new_price = $total_new_price + $data['order_shippingPrice'] ;
1011
- Mage::unregister('shipping_cost');
1012
- Mage::register('shipping_cost', $shipping_cost);
1013
- $this->debugLog("Adding Order Shipping Cost: ". $data['order_shippingPrice']);
1014
-
1015
- $shippingAddress->setCollectShippingRates(true)->collectShippingRates()
1016
- ->setShippingMethod('flatrate_flatrate')
1017
- ->setPaymentMethod($payment_method);
1018
-
1019
- //$shippingAddress->addTotal(array("code" => "specialfee", "title" => "Special Fee", "value" => 20));
1020
- $quote->getPayment()->importData(array('method' => $payment_method));
1021
-
1022
- $quote->collectTotals()->save();
1023
-
1024
- $service = Mage::getModel('sales/service_quote', $quote);
1025
- $service->submitAll();
1026
- $order = $service->getOrder();
1027
-
1028
-
1029
-
1030
- $quoteId = $order->getQuoteId();
1031
- //$this->setStatus($data['order_status'], $order);
1032
-
1033
- $orderid = $order->getId();
1034
-
1035
- $resource = Mage::getSingleton('core/resource');
1036
- $writeConnection = $resource->getConnection('core_write');
1037
- $table = $resource->getTableName('sales/order_grid');
1038
- $this->debugLog("Adding Beezup Marketplace Information to Order");
1039
- $marketplace = $data['marketplace'];
1040
- $marketplace_business_code = ucfirst(strtolower($data['marketplace_business_code']));
1041
- $beezup_name = $data['order_customer'];
1042
- $market_order_id =$this->orderid;
1043
- $beezup_order_id = $oLink->getBeezupOrderUUID();
1044
- $beezup_status = $data['order_status'];
1045
- $beezup_last_modification_date = $oLink->getOrderLastModificationUtcDate();
1046
- $beezup_last_modification_date = $beezup_last_modification_date->date;
1047
- $beezup_marketplace_status = $oLink->getOrderStatusMarketPlaceStatus();
1048
- $beezup_purchase_date = $oLink->getOrderPurchaseUtcDate();
1049
- $beezup_purchase_date = $beezup_purchase_date->date;
1050
- $beezup_marketplace_last_modification_date = $oLink->getOrderMarketPlaceLastModificationUtcDate();
1051
- $beezup_marketplace_last_modification_date = $beezup_marketplace_last_modification_date->date;
1052
- /* $date = new DateTime($$beezup_marketplace_last_modification_date);
1053
- $beezup_marketplace_last_modification_date = $date->format('d-m-Y H:i:s'). "(UTC Time)";
1054
- */
1055
-
1056
- $beezup_total_paid = $oLink->getOrderTotalPrice()." ".$data['order_currency'];
1057
- $beezup_account_id = $oLink->getAccountId();
1058
- $beezup_comission = $oLink->getOrderTotalCommission()." ".$data['order_currency'];
1059
- $tot_comm = $oLink->getOrderTotalCommission();
1060
- if(empty($tot_comm ) || $tot_comm == 0) {
1061
- $beezup_comission = 0;
1062
- }
1063
- $query = "UPDATE {$table} SET beezup_marketplace = '{$marketplace}', beezup_name = '{$beezup_account_id}', beezup_order = 1, beezup_market_order_id = '{$market_order_id}',
1064
- beezup_order_id = '{$beezup_order_id}', beezup_status = '{$beezup_status}', beezup_last_modification_date = '{$beezup_last_modification_date}',
1065
- beezup_marketplace_status = '{$beezup_marketplace_status}', beezup_purchase_date = '{$beezup_purchase_date}', beezup_marketplace_last_modification_date = '{$beezup_marketplace_last_modification_date}',
1066
- beezup_total_paid = '{$beezup_total_paid}', beezup_etag = '{$data['etag']}' , beezup_comission = '{$beezup_comission}', beezup_marketplace_business_code = '{$marketplace_business_code}'
1067
- WHERE entity_id = ". (int)$orderid;
1068
- $writeConnection->query($query);
1069
- $disc_price = 0;
1070
- if(!empty($data['discounts']) && $data['discounts'] >0) {
1071
-
1072
-
1073
- $disc_price = round($data['discounts'],2);
1074
- $total_new_price = $total_new_price+$disc_price;
1075
- $table_address = $resource->getTableName("sales/quote_address");
1076
-
1077
- $query = "update {$table_address} set beezup_fee = '{$disc_price}' where quote_id = '{$quoteId}' and address_type = 'shipping'";
1078
- $writeConnection->query($query);
1079
- $this->debugLog("Adding CDISCOUNT products with total price: ".$disc_price);
1080
- }
1081
-
1082
- //if order id exists and has been created
1083
- if ($orderid)
1084
- {
1085
- //we send order id to beezup
1086
- $this->debugLog("Sending Magento Order Id to Beezup, Magento Order Id: ".$orderid);
1087
- $oResult = new BeezupOMSetOrderIdValues ();
1088
- $oResult->setOrderMerchantOrderId ( $orderid )->setOrderMerchantECommerceSoftwareName ( 'Magento' )->setOrderMerchantECommerceSoftwareVersion ( Mage::getVersion() );
1089
- $sendRequest = $this->getOrderService()->getClientProxy()->setOrderMerchantIdByLink($oLink->getLinkByRel('setMerchantOrderId'), $oResult);
1090
- }
1091
-
1092
- $grand_total = $order->getGrandTotal();
1093
- $beezup_price = $oLink->getOrderTotalPrice() - $disc_price;
1094
- if($grand_total != (float) $beezup_price && $beezup_price > 0) {
1095
- $order->setGrandTotal((float) $beezup_price);
1096
- $order->setBaseGrandTotal((float) $beezup_price);
1097
- $diff = (((float) $beezup_price) - $grand_total);
1098
-
1099
- $order->setTaxAmount($order->getTaxAmount() + $diff);
1100
- $order->save();
1101
- }elseif($grand_total != (float)$beezup_price && $beezup_price < 1) {
1102
-
1103
- $order->setGrandTotal((float) $total_new_price);
1104
- $order->setBaseGrandTotal((float) $total_new_price);
1105
- $diff = (((float) $total_new_price) - $grand_total);
1106
-
1107
- $order->setTaxAmount($order->getTaxAmount() + $diff);
1108
- $order->save();
1109
- }
1110
-
1111
- $products = Mage::getResourceModel('sales/order_item_collection')
1112
- ->setOrderFilter($orderid);
1113
- foreach($products as $product) {
1114
- $product->setBaseOriginalPrice($product->getOriginalPrice());
1115
- $product->setBaseTaxAmount($product->getTaxAmount());
1116
- $product->setBaseTaxInvoiced($product->getTaxAmount());
1117
- $product->setBasePriceInclTax($product->getPriceInclTax());
1118
- $product->setBaseRowTotalInclTax($product->getRowTotalInclTax());
1119
- $product->save();
1120
- }
1121
- $order->setBaseTaxAmount($order->getTaxAmount());
1122
- $order->setBaseTaxInvoiced($order->getTaxAmount());
1123
- $order->setBaseTotalInvoiced($order->getTotalPaid());
1124
- $order->setBaseTotalPaid($order->getTotalPaid());
1125
- $order->setBaseGrandTotal($order->getTotalPaid());
1126
- $order->setBaseSubtotalInclTax($order->getSubtotalInclTax());
1127
- $order->save();
1128
-
1129
- $this->setStatus($data['order_status'], $order);
1130
- $this->mage_order_id = $orderid;
1131
- $this->debugLog("Order imported succesfully, Magento Order Id: ".$orderid);
1132
- } else {
1133
- //product stock = 0 we dont create order
1134
- $this->log->LogError($this->orderid. "| Order ".$data['market_place_order_id']." could not be imported, error: Stock from Beezup product = 0 ");
1135
- $this->log2->LogError($this->orderid. "| Order ".$data['market_place_order_id']." could not be imported, error: Stock from Beezup product = 0 ");
1136
- }
1137
- }catch(Exception $e){
1138
-
1139
-
1140
- if($stop) {
1141
- $this->log->LogError($this->orderid. "| Order ".$data['market_place_order_id']." could not be imported, error: ".$e->getMessage());
1142
- $this->log2->LogError($this->orderid. "| Order ".$data['market_place_order_id']." could not be imported, error: ".$e->getMessage());
1143
- $this->restoreStock($data);
1144
- } else {
1145
- $this->debugLog("Order Import failed, Trying to import Order Again");
1146
- $this->addOrder($data, $oLink, true);
1147
-
1148
- }
1149
- //error no se pudo crear la orden
1150
-
1151
- }
1152
-
1153
-
1154
-
1155
- }
1156
-
1157
-
1158
-
1159
- public function restoreStock($data) {
1160
-
1161
- try {
1162
- foreach($data['products'] as $prod) {
1163
- $product = Mage::getModel('catalog/product')->load($prod['id']);
1164
- $stock = Mage::getModel('cataloginventory/stock_item')->loadByProduct($product);
1165
- if ($stock->getQty() != $prod['curr_stock'] ) {
1166
- $this->debugLog("Restoring Stock from Product ".$product->getId()." to: ".$prod['curr_stock'] ." due to Order Fail");
1167
- $stockItem = Mage::getModel('cataloginventory/stock_item')->loadByProduct($product);
1168
- $stockItem->setData('is_in_stock', 0);
1169
- $stockItem->setData('qty', $prod['curr_stock']);
1170
- $stockItem->save();
1171
- $product->save();
1172
- }
1173
-
1174
- }
1175
- } catch(Exception $e){
1176
- $this->log->LogError($this->orderid. "| Failed Restoring Product Stock: ".$e->getMessage());
1177
- $this->log2->LogError($this->orderid. "| Failed Restoring Product Stock: ".$e->getMessage());
1178
- }
1179
-
1180
- }
1181
-
1182
-
1183
-
1184
- private function createProduct($data) {
1185
-
1186
- $sku = $data['sku'];
1187
- if(empty($data['sku'])) {
1188
- $sku = $data['sku2'];
1189
- }
1190
-
1191
- Mage::app()->setCurrentStore($data['storeId']);
1192
- $product = Mage::getModel('catalog/product');
1193
- // if(!$product->getIdBySku('testsku61')):
1194
-
1195
- try{
1196
- $product
1197
- // ->setStoreId(1) //you can set data in store scope
1198
- ->setWebsiteIds(array($data['storeId'])) //website ID the product is assigned to, as an array
1199
- ->setAttributeSetId($product->getDefaultAttributeSetId()) //ID of a attribute set named 'default'
1200
- ->setTypeId('simple') //product type
1201
- ->setCreatedAt(strtotime('now')) //product creation time
1202
- ->setSku($sku ) //SKU
1203
- ->setWeight(0)
1204
- ->setName($data['title']) //product name
1205
- ->setStatus(1) //product status (1 - enabled, 2 - disabled)
1206
- ->setTaxClassId(4) //tax class (0 - none, 1 - default, 2 - taxable, 4 - shipping)
1207
- ->setVisibility(Mage_Catalog_Model_Product_Visibility::VISIBILITY_NOT_VISIBLE ) //catalog and search visibility
1208
- ->setPrice($data['price']) //price in form 11.22
1209
- ->setMsrpEnabled(1) //enable MAP
1210
- ->setMsrpDisplayActualPriceType(1) //display actual price (1 - on gesture, 2 - in cart, 3 - before order confirmation, 4 - use config)
1211
- ->setMsrp(0) //Manufacturer's Suggested Retail Price
1212
- ->setMetaTitle('')
1213
- ->setMetaKeyword('')
1214
- ->setMetaDescription('')
1215
- ->setDescription($data['title'])
1216
- ->setShortDescription($data['title'])
1217
- // ->setMediaGallery (array('images'=>array (), 'values'=>array ())) //media gallery initialization
1218
- //->addImageToMediaGallery('media/catalog/product/1/0/10243-1.png', array('image','thumbnail','small_image'), false, false) //assigning image, thumb and small image to media gallery
1219
- ->setStockData(array(
1220
- 'use_config_manage_stock' => 0, //'Use config settings' checkbox
1221
- 'manage_stock'=>1, //manage stock
1222
- 'min_sale_qty'=>1, //Minimum Qty Allowed in Shopping Cart
1223
- 'max_sale_qty'=>2, //Maximum Qty Allowed in Shopping Cart
1224
- 'is_in_stock' => 1, //Stock Availability
1225
- 'qty' => 1 //qty
1226
- )
1227
- );
1228
- $product->save();
1229
- return $product;
1230
-
1231
- }catch(Exception $e){
1232
- //log exception
1233
- $this->log->LogError($this->orderid."| Product ".$sku." could not be created, error: ".$e->getMessage());
1234
- $this->log2->LogError($this->orderid."| Product ".$sku." could not be created, error: ".$e->getMessage());
1235
- return false;
1236
- }
1237
- }
1238
-
1239
-
1240
-
1241
- public function setStatus($status, $order) {
1242
- $helper = Mage::helper('beezup');
1243
- $retorno = "";
1244
- $blnCancel = false;
1245
- $blnHold = false;
1246
- switch($status) {
1247
- case "New" :
1248
- $this->debugLog("Setting Order Status to New");
1249
- $retorno = $helper->getConfig('beezup/marketplace/status_new');
1250
- break;
1251
- case "InProgress" :
1252
- $this->debugLog("Setting Order Status to InProgress");
1253
- $retorno = $helper->getConfig('beezup/marketplace/status_progress');
1254
- $this->payOrder($order);
1255
- break;
1256
- case "Aborted" :
1257
- $this->debugLog("Setting Order Status to Aborted");
1258
- $retorno = $helper->getConfig('beezup/marketplace/status_aborted');
1259
- $blnHold = true;
1260
-
1261
-
1262
- break;
1263
- case "Closed" :
1264
- $this->debugLog("Setting Order Status to Closed");
1265
- $blnCancel =true;
1266
- $retorno = $helper->getConfig('beezup/marketplace/status_closed');
1267
- $this->payOrder($order);
1268
- break;
1269
- case "Canceled" :
1270
- $this->debugLog("Setting Order Status to Cancelled");
1271
- $retorno = $helper->getConfig('beezup/marketplace/status_cancelled');
1272
-
1273
- break;
1274
- case "Shipped" :
1275
- $this->debugLog("Setting Order Status to Shipped");
1276
- $retorno = $helper->getConfig('beezup/marketplace/status_shipped');
1277
- $this->payOrder($order);
1278
- break;
1279
-
1280
- }
1281
- $order->setData('state',$retorno);
1282
- $order->setStatus($retorno);
1283
- $history = $order->addStatusHistoryComment('Order was set to '.$retorno.' by Beezup.', false);
1284
- $history->setIsCustomerNotified(false);
1285
- $order->save();
1286
- if($blnCancel) {
1287
- $order->cancel()->save();
1288
- }
1289
- if($blnHold) {
1290
- $order->hold()->save();
1291
- }
1292
-
1293
- return $retorno;
1294
-
1295
- }
1296
-
1297
-
1298
- public function getStatus($status1) {
1299
- $helper = Mage::helper('beezup');
1300
- $retorno = "";
1301
- $status = strtolower($status1);
1302
-
1303
- if($status == strtolower($helper->getConfig('beezup/marketplace/status_new') )) {
1304
- $retorno = "New";
1305
-
1306
- } elseif($status == strtolower($helper->getConfig('beezup/marketplace/status_progress') ) ){
1307
- $retorno = "InProgress";
1308
-
1309
-
1310
- }
1311
- elseif($status == strtolower($helper->getConfig('beezup/marketplace/status_aborted') )) {
1312
-
1313
- $retorno = "Aborted" ;
1314
- }
1315
- elseif($status == strtolower($helper->getConfig('beezup/marketplace/status_closed') )) {
1316
- $retorno = "Closed";
1317
-
1318
- }
1319
- elseif($status == strtolower($helper->getConfig('beezup/marketplace/status_cancelled')) ) {
1320
-
1321
- $retorno = "Canceled";
1322
- }
1323
- elseif($status == strtolower($helper->getConfig('beezup/marketplace/status_shipped') )) {
1324
-
1325
- $retorno = "Shipped";
1326
- }
1327
-
1328
-
1329
- return $retorno;
1330
-
1331
- }
1332
-
1333
-
1334
- public function checkMarketOrderExists($orderid) {
1335
- $resource = Mage::getSingleton('core/resource');
1336
- $readConnection = $resource->getConnection('core_read');
1337
- $table = $resource->getTableName('sales/order_grid');
1338
- $query = 'SELECT increment_id FROM ' . $table . ' WHERE beezup_order = 1 and beezup_market_order_id = \''
1339
- . $orderid . '\' LIMIT 1';
1340
- $order = $readConnection->fetchOne($query);
1341
- if($order && !empty($order) && $this->orderId !== "") {
1342
- return $order;
1343
- }
1344
- return false;
1345
-
1346
- }
1347
-
1348
- public function payOrder($order) {
1349
- try {
1350
- $this->debugLog("Generating Order Payment Invoice");
1351
- if($order->canInvoice()) {
1352
- $invoice = $order->prepareInvoice()
1353
- ->setTransactionId($order->getId())
1354
- ->addComment("Invoice created from Beezup.")
1355
- ->register()
1356
- ->pay();
1357
- $transaction_save = Mage::getModel('core/resource_transaction')
1358
- ->addObject($invoice)
1359
- ->addObject($invoice->getOrder());
1360
- $transaction_save->save();
1361
- $this->debugLog("Order Payment Invoice Generated Succesfully");
1362
- }
1363
- }
1364
- catch(Exception $e){
1365
- //log exception
1366
- $this->log->LogError($this->orderid."| Order Payment Invoice could not be generated, error: ".$e->getMessage());
1367
- $this->log2->LogError($this->orderid."| Order Payment Invoice could not be generated, error: ".$e->getMessage());
1368
- }
1369
- }
1370
-
1371
-
1372
-
1373
-
1374
-
1375
-
1376
- }
 
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
 
247
  }
248
 
249
  public function getBeezupOrderId(){
250
+ $oIdentifier = new BeezupOMOrderIdentifier();
251
+ $oIdentifier
252
+ ->setAccountId($this->account_id)
253
+ ->setMarketplaceTechnicalCode($this->marketplace_code)
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
267
+ $order_address = $final_order->getOrderBuyerAddressCity();
268
+ $order_country = $final_order->getOrderBuyerAddressCountryName();
269
+ $order_country_iso = $final_order->getOrderBuyerAddressCountryIsoCodeAlpha2();
270
+ $order_address = $this->getBeezupBuyerAddress($final_order);
271
+ $order_postalCode = $final_order->getOrderBuyerAddressPostalCode();
272
+ $order_customer = $final_order->getOrderBuyerName();
273
+ $order_customer_email = $final_order->getOrderBuyerEmail();
274
+ $order_customer_phone = $final_order->getOrderBuyerPhone();
275
+ $order_customer_mobile = $final_order->getOrderBuyerMobilePhone();
276
+ $order_comment = $final_order->getOrderComment();
277
+ $order_company = $final_order->getOrderBuyerCompanyName();
278
+ $order_city = $final_order->getOrderBuyerAddressCity();
279
+ $order_region = $final_order->getOrderBuyerStateOrRegion();
280
+ $order_status = $final_order->getOrderStatusBeezUPOrderStatus();
281
+ //shipping information
282
+ $shipping_city = $final_order->getOrderShippingAddressCity();
283
+ $shipping_country = $final_order->getOrderShippingAddressCountryName();
284
+ $shipping_country_iso = $final_order->getOrderShippingAddressCountryIsoCodeAlpha2();
285
+ $shipping_address = $this->getBeezupShippingAddress($final_order);
286
+ $shipping_name = $final_order->getOrderShippingAddressName();
287
+ $shipping_postalCode = $final_order->getOrderShippingAddressPostalCode();
288
+ $shipping_email = $final_order->getOrderShippingEmail();
289
+ $shipping_phone = $final_order->getOrderShippingPhone();
290
+ $shipping_mobile = $final_order->getOrderShippingMobilePhone();
291
+ $shipping_company = $final_order->getOrderShippingCompanyName();
292
+ $shipping_region = $final_order->getOrderShippingAddressStateOrRegion();
293
+ $order_currency_code = $final_order->getOrderCurrencyCode();
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);
320
+ }
321
+ elseif(!filter_var($order_customer_email, FILTER_VALIDATE_EMAIL)) {
322
+ $order_customer_email = $this->generateEmail($final_order);
323
+ }
324
+
325
+ $mage_productIds = $this->prescanOrder($final_order);
326
+ if($mage_productIds) {
327
+ $order_data = array(
328
+ "etag" => $etag,
329
+ "account_id" => $account_id,
330
+ "order_status" => $order_status,
331
+ "products" => $mage_productIds['products'],
332
+ "storeid" => $mage_productIds['store'],
333
+ "order_currency" => $order_currency_code ,
334
+ "order_address" => $order_adress,
335
+ "order_country" => $order_country,
336
+ "order_country_iso" => $order_country_iso ,
337
+ "order_address" => $order_address ,
338
+ "order_postalCode" => $order_postalCode ,
339
+ "order_customer" => $order_first_name ,
340
+ "order_lastname" => $order_last_name ,
341
+ "order_customer_email" => $order_customer_email ,
342
+ "order_customer_phone" => $this->getPhone($order_customer_phone, $order_customer_mobile) ,
343
+ "order_comment" => $order_comment ,
344
+ "order_company" => $order_company ,
345
+ "shipping_city" => $shipping_city ,
346
+ "shipping_country" => $shipping_country ,
347
+ "shipping_country_iso" => $shipping_country_iso ,
348
+ "shipping_address" => $shipping_address ,
349
+ "shipping_name" => $shipping_first_name ,
350
+ "shipping_lastname" => $shipping_last_name ,
351
+ "shipping_postalCode" => $shipping_postalCode ,
352
+ "shipping_region" =>$shipping_region,
353
+ "shipping_email" => $shipping_email ,
354
+ "shipping_phone" => $this->getPhone($shipping_phone, $shipping_mobile) ,
355
+ "shipping_company" => $shipping_company ,
356
+ "order_totalPrice" => $order_totalPrice ,
357
+ "order_shippingPrice" => $order_shippingPrice ,
358
+ "order_city" => $order_city,
359
+ "order_region" => $order_region,
360
+ "marketplace" => $marketplace,
361
+ "discounts" => $mage_productIds['discounts'],
362
+ "marketplace_business_code" => $marketplace_business_code
363
+ );
364
+
365
+
366
+
367
+ //check if order exists
368
+ $Mageorder = $this->loadMageOrder();
369
+ if ($Mageorder) {
370
+ //if order exists
371
+ $this->updateEtag($etag);
372
+ $this->updateBilling($Mageorder, $order_data );
373
+ $this->updateBeezupInfoTab($Mageorder, $final_order, $order_data);
374
+ $this->debugLog("Order Already exists Mage Order ID: " .$Mageorder->getId());
375
+ $status1 = $Mageorder->getStatusLabel();
376
+ $status = $this->getStatus($status1);
377
+ if($status !== $order_status) {
378
+ //if order exits and status has changed we update order status
379
+ $this->debugLog("Updating Order Status from: ".$status1." to: ".$order_status );
380
+ $this->setStatus( $order_status, $Mageorder);
381
+ }
382
+
383
+ $id_order = $Mageorder->getId();
384
+ $BeezupMageOrder = new BeezupMageOrders($id_order);
385
+ $BeezupMageOrder->setData(array("shipping" =>(float) $order_data['order_shippingPrice']));
386
+ $BeezupMageOrder->updateShippingInfo();
387
+ } else {
388
+ //if not we create order
389
+
390
+
391
+ $this->debugLog("Generating Order");
392
+ $this->addOrder($order_data,$final_order );
393
+ //die();
394
+
395
+ }
396
+
397
+
398
+ } else {
399
+ //order could not be imported
400
+
401
+
402
+ }
403
+
404
+
405
+ } else {
406
+ //etag has not changed
407
+ $this->debugLog("Order Etag has not changed");
408
+
409
+ }
410
+
411
+
412
+
413
+
414
+
415
  }
416
 
417
 
418
 
419
  public function generateEmail(BeezupOMOrderResult $oBeezupOrder)
420
  {
421
+ $sRawValue = $oBeezupOrder->getBeezupOrderUUID ();
422
+ $sFakeDomain = preg_replace ( '/\W/', '', $oBeezupOrder->getMarketPlaceTechnicalCode () ) . '.com';
423
+ return 'fakeemail' . md5 ( $sFakeDomain . $sRawValue ) . '@' . strtolower ( $sFakeDomain );
424
  }
425
 
426
 
427
 
428
  public function getOrderList($orderList = null) {
429
+ if($orderList == null) {
430
+ $data = $this->createRepository()->createOrderListRequest();
431
+ $oRequest = $this->getOrderService()->getClientProxy()->getOrderList($data);
432
+ $orderList = $oRequest->getResult();
433
+ }
434
+ $oPagination = $orderList->getPaginationResult();
435
+ if(!empty($oPagination)) {
436
+ $oLinksTotal = $oPagination->getLinks();
437
+ } else {
438
+ $configModel = Mage::getModel('core/config');
439
+ $configModel->saveConfig('beezup/marketplace/sync_status',0);
440
+ die("No more orders to import");
441
+ }
442
+
443
+ //$header = $orderList->getOrderHeaders();
444
+ foreach($orderList->getOrderHeaders() as $order) {
445
+ $order_status = $order->getBeezupOrderState();
446
+ $orderLinks = $order->getLinks();
447
+ $etag = $order->getETag();
448
+ $beezup_order_id = $order->getBeezupOrderUUID();
449
+ $account_id = $order->getAccountId();
450
+ $orderdata = $this->getOrderService()->getClientProxy()->getOrderByLink($orderLinks[0]);
451
+ $this->debugLog("Initializing Order - Link: ".$orderLinks[0]->getHref());
452
+ $this->createOrder($orderdata);
453
+
454
+ }
455
+
456
+ if(!empty($oLinksTotal)) {
457
+ //we check if there is next link and get next orders
458
+ foreach($oLinksTotal as $link) {
459
+ if( $link->getRel() == "next") {
460
+
461
+ $this->log->LogInfo("Initializing New Order List ->". $link->getHref());
462
+ $this->log2->LogInfo("Initializing New Order List ->". $link->getHref());
463
+ $oRequest = $this->getOrderService()->getClientProxy()->getOrderListByLink($link);
464
+ $orderList = $oRequest->getResult();
465
+ $this->getOrderList($orderList);
466
+ }
467
+
468
+ }
469
+ }
470
+
471
  }
472
 
473
 
474
 
475
  public function updateBeezupInfoTab($order, $oLink, $data) {
476
+ $beezup_last_modification_date = $oLink->getOrderLastModificationUtcDate();
477
+ $beezup_last_modification_date = $beezup_last_modification_date->date;
478
+ $beezup_marketplace_last_modification_date = $oLink->getOrderMarketPlaceLastModificationUtcDate();
479
+ $beezup_marketplace_last_modification_date = $beezup_marketplace_last_modification_date->date;
480
+ $beezup_comission = $oLink->getOrderTotalCommission()." ".$data['order_currency'];
481
+ $tot_comm = $oLink->getOrderTotalCommission();
482
+ if(empty($tot_comm ) || $tot_comm == 0) {
483
+ $beezup_comission = 0;
484
+ }
485
+ $updateData = array("beezup_status" => $data['order_status'],
486
+ "beezup_last_modification_date" => $beezup_last_modification_date,
487
+ "beezup_marketplace_last_modification_date" => $beezup_marketplace_last_modification_date ,
488
+ "beezup_total_paid" => $oLink->getOrderTotalPrice()." ".$data['order_currency'],
489
+ "beezup_comission" => $beezup_comission,
490
+ "beezup_marketplace_status" => $oLink->getOrderStatusMarketPlaceStatus());
491
+ $orderId = $order->getId();
492
+ $beezupMageOrder = new BeezupMageOrders($orderId);
493
+ $beezupMageOrder->setData($updateData);
494
+ $beezupMageOrder->updateBeezupInfo();
495
+
496
+
497
  }
498
 
499
  public function getPhone($phone, $phone2) {
500
+ $retorno = "";
501
+ if(!empty($phone) && $phone !== "") {
502
+ $retorno .= $phone;
503
+ }
504
+ if(!empty($phone2) && $phone2 !=="") {
505
+ if(empty($phone) || $phone == "") {
506
+ $retorno = $phone2;
507
+
508
+ } else {
509
+ $retorno .= " - ".$phone2;
510
+ }
511
+ }
512
+ return $retorno;
513
  }
514
 
515
 
516
  public function getBeezupBuyerAddress($order) {
517
+ $add1=$order->getOrderBuyerAddressLine1();
518
+ $add2=$order->getOrderBuyerAddressLine2();
519
+ $add3=$order->getOrderBuyerAddressLine3();
520
+ $retorno = "";
521
+ if(!empty($add1)) {
522
+ $retorno = $order->getOrderBuyerAddressLine1();
523
+ }
524
+ if(!empty($add2)) {
525
+ if(empty($add1)) {
526
+ $retorno .= $order->getOrderBuyerAddressLine2();
527
+ } else {
528
+ $retorno .= " - ". $order->getOrderBuyerAddressLine2();
529
+ }
530
+ }
531
+ if(!empty($add3)){
532
+ if(empty($add1) && empty($add2)) {
533
+ $retorno .= $order->getOrderBuyerAddressLine3();
534
+ } else {
535
+ $retorno .= " - ". $order->getOrderBuyerAddressLine3();
536
+ }
537
+ }
538
+ return $retorno;
539
  }
540
 
541
 
542
  public function getBeezupShippingAddress($order) {
543
+ $add1 = $order->getOrderShippingAddressLine1();
544
+ $add2 = $order->getOrderShippingAddressLine2();
545
+ $add3=$order->getOrderBuyerAddressLine3();
546
+ $retorno = "";
547
+ if(!empty($add1 )) {
548
+ $retorno = $order->getOrderShippingAddressLine1();
549
+ }
550
+ if(!empty($add2)) {
551
+ if(empty($add1)) {
552
+ $retorno .= $order->getOrderShippingAddressLine2();
553
+ } else {
554
+ $retorno .= " - ". $order->getOrderShippingAddressLine2();
555
+ }
556
+ }
557
+ if(!empty($add3)){
558
+ if(empty($add1) && empty($add2)) {
559
+ $retorno .= $order->getOrderShippingAddressLine3();
560
+ } else {
561
+ $retorno .= " - ". $order->getOrderShippingAddressLine3();
562
+ }
563
+ }
564
+ return $retorno;
565
  }
566
 
567
  public function checkEtagExists($etag) {
568
+ $resource = Mage::getSingleton('core/resource');
569
+ $readConnection = $resource->getConnection('core_read');
570
+ $table = $resource->getTableName('sales/order_grid');
571
+ $query = 'SELECT increment_id FROM ' . $table . ' WHERE beezup_etag = \''
572
+ . $etag . '\' LIMIT 1';
573
+ $order = $readConnection->fetchOne($query);
574
+ if($order && !empty($order)) {
575
+ return true;
576
+ }
577
+ return false;
578
+
579
  }
580
 
581
 
582
  public function updateEtag($etag) {
583
+ $this->debugLog("Updating Etag");
584
+ $resource = Mage::getSingleton('core/resource');
585
+ $writeConnection = $resource->getConnection('core_write');
586
+ $table = $resource->getTableName('sales/order_grid');
587
+ $query = "UPDATE {$table} SET beezup_etag = '{$etag}' where beezup_market_order_id = '{$this->orderid}' ";
588
+ $writeConnection->query($query);
589
+
590
  }
591
 
592
 
593
 
594
  public function updateBilling($order, $data) {
595
+
596
+
597
+ $addressData = array(
598
+ 'billing_firstname' => ($data['order_customer']) ? $data['order_customer'] : "empty",
599
+ 'billing_lastname' => ($data['order_lastname']) ? $data['order_lastname'] : "empty",
600
+ 'billing_street' => ($data['order_address']) ? $data['order_address'] : "empty",
601
+ 'billing_city' => ($data['order_city']) ? $data['order_city'] : "empty",
602
+ 'billing_postcode' => ($data['order_postalCode']) ? $data['order_postalCode'] : "empty",
603
+ 'billing_telephone' => ($data['order_customer_phone']) ? $data['order_customer_phone'] : "empty",
604
+ 'billing_country_id' => ($data['order_country_iso']) ? $data['order_country_iso'] : "empty",
605
+ 'billing_region_id' => ($data['order_region ']) ? substr($data['order_region '], 0,2) : "EM",
606
+ 'shipping_firstname' => ($data['shipping_name']) ? $data['shipping_name'] : "empty",
607
+ 'shipping_lastname' => ($data['shipping_lastname']) ? $data['shipping_lastname'] : "empty",
608
+ 'shipping_street' => ($data['shipping_address']) ? $data['shipping_address'] : "empty",
609
+ 'shipping_city' => ($data['shipping_city']) ? $data['shipping_city'] : "empty",
610
+ 'shipping_postcode' => ($data['shipping_postalCode']) ? $data['shipping_postalCode'] : "empty",
611
+ 'shipping_telephone' => ($data['shipping_phone']) ? $data['shipping_phone'] : "empty",
612
+ 'shipping_country_id' => ($data['shipping_country_iso']) ? $data['shipping_country_iso'] : "empty",
613
+ 'shipping_region_id' => ($data['shipping_region']) ? substr($data['shipping_region'], 0, 2) : "EM" // id from directory_country_region table
614
+ );
615
+
616
+ $shippingData = array(
617
+
618
+ );
619
+ // Get the id of the orders shipping address
620
+ $orderId = $order->getId();
621
+ $beezupMageOrder = new BeezupMageOrders($orderId);
622
+ $beezupMageOrder->setData($addressData);
623
+ $beezupMageOrder->updateAdresses();
624
  }
625
 
626
  public function updateAddresses($shippingData, $address) {
627
+ if($shippingData['firstname'] !==$address['firstname']) {
628
+ $address->setFirstname($shippingData['firstname']);
629
+ }
630
+ if($shippingData['lastname'] !==$address['lastname']) {
631
+ $address->setLastname($shippingData['lastname']);
632
+ }
633
+ if($shippingData['street'] !==$address['street']) {
634
+ $address->setStreet($shippingData['street']);
635
+ }
636
+ if($shippingData['city'] !==$address['city']) {
637
+ $address->setCity($shippingData['city']);
638
+ }
639
+ if($shippingData['postcode'] !==$address['postcode']) {
640
+ $address->setPostcode($shippingData['postcode']);
641
+ }
642
+ if($shippingData['telephone'] !==$address['telephone']) {
643
+ $address->setTelephone($shippingData['telephone']);
644
+ }
645
+ $address->save();
646
+
647
+
648
  }
649
 
650
 
651
  public function loadMageOrder() {
652
+ $Mageorder = Mage::getModel('sales/order')->loadByIncrementId($this->orderid);
653
+ if ($Mageorder->getId()) {
654
+ return $Mageorder;
655
+ } else {
656
+ //we get order from marketplace orderid
657
+ $orderInc = $this->checkMarketOrderExists($this->orderid);
658
+ if($orderInc) {
659
+ // if exists
660
+ $Mageorder = Mage::getModel('sales/order')->loadByIncrementId($orderInc);
661
+ if ($Mageorder->getId()) {
662
+ return $Mageorder;
663
+ }
664
+ }
665
+ }
666
+ return false;
667
  }
668
 
669
 
670
  private function debugLog($message) {
671
+
672
+ if($this->orderid !== "") {
673
+ $message = $this->orderid." | ".$message;
674
+ }
675
+ $this->log->LogInfo($message);
676
+
677
+ $this->log2->LogInfo($message);
678
  }
679
 
680
  public function prescanOrder(BeezupOMOrderResult $order) {
681
+ $retorno = array();
682
+ $orderItems = $order->getOrderItems();
683
+ foreach ($orderItems as $item)
684
+ {
685
+
686
+ if ($item->getOrderItemOrderItemType () !== 'Product')
687
+ {
688
+ // continue;
689
+ }
690
+ $beezup_store = $item->getOrderItemBeezUPStoreId(); //beezup storeid
691
+ $mage_storeid = $this->checkOrderStore($beezup_store); //magento storeid
692
+ $marketplace_orderid = $item->getOrderItemMarketPlaceProductId();
693
+ if(!$mage_storeid) {
694
+
695
+ if(strpos($marketplace_orderid,'INTERETBCA') !== false || strpos($marketplace_orderid,'interetbca') !== false) { }
696
+ else {
697
+ $this->log->LogError($this->orderid." | No mapping for store ".$beezup_store);
698
+ $this->log2->LogError($this->orderid." | No mapping for store ".$beezup_store);
699
+ return false;
700
+ }
701
+
702
+ }
703
+ // $retorno['store'] = 1;
704
+
705
+ $product_ImportedMerchantId = $item->getOrderItemMerchantImportedProductId();
706
+ $product_MerchantId = $item->getOrderItemMerchantProductId();
707
+
708
+ $product_quantity = $item->getOrderItemQuantity();
709
+ $product_price = $item->getOrderItemItemPrice();
710
+ $product_title = $item->getOrderItemTitle();
711
+ $product_image = $item->getOrderItemImageUrl();
712
+ if(strpos($marketplace_orderid,'INTERETBCA') !== false || strpos($marketplace_orderid,'interetbca') !== false) {
713
+ $retorno['discounts']= $item->getOrderItemTotalPrice();
714
+ } else {
715
+ $retorno['store'] = $mage_storeid;
716
+ $this->debugLog("Store Matching succesful, Beezup Store: ".$beezup_store." , Magento Store Id: ".$mage_storeid);
717
+ $product = $this->getMageProduct($product_ImportedMerchantId , $product_MerchantId , $beezup_store );
718
+ if($product) {
719
+ $mage_productId = $product->getId();
720
+ $stocklevel = (int)Mage::getModel('cataloginventory/stock_item')
721
+ ->loadByProduct($product)->getQty();
722
+
723
+ $retorno['products'][] = array("id" => $mage_productId, "qty" => $product_quantity, "price" => $product_price, "curr_stock" => $stocklevel);
724
+ //producto existe
725
+ } else {
726
+ //vendria if de si activada opcion de crear producto creamos
727
+ if(!$this->debug) {
728
+ return false;
729
+ }
730
+ $product_data = array(
731
+ "sku" => $product_ImportedMerchantId,
732
+ "sku2" => $product_MerchantId,
733
+ "qty" => $product_quantity,
734
+ "price" => $product_price,
735
+ "title" => $product_title,
736
+ "image" => $product_image,
737
+ "storeId" => $mage_storeid
738
+ );
739
+ $product = $this->createProduct($product_data);
740
+ if(!$product) {
741
+ return false;
742
+ }
743
+ $stocklevel = (int)Mage::getModel('cataloginventory/stock_item')
744
+ ->loadByProduct($product)->getQty();
745
+ $mage_productId = $product->getId();
746
+ $retorno['products'][] = array("id" => $mage_productId, "qty" => $product_quantity, "price" => $product_price, "curr_stock" => $stocklevel);
747
+ }
748
+ }
749
+ }
750
+
751
+ return $retorno;
752
+ }
753
+
754
+
755
+
756
+ public function matchProductAttributes($importedId, $storeId) {
757
+ $product = null;
758
+ $helper = Mage::helper('beezup');
759
+ $attributes = $helper->getConfig('beezup/marketplace/attributes');
760
+ $attributes = unserialize ($attributes);
761
+
762
+ foreach($attributes['attributes'][$storeId ] as $attribute) {
763
+ $att = explode("|", $attribute);
764
+ if($storeId == $att[1]) {
765
+
766
+ $product=Mage::getModel('catalog/product')->loadByAttribute($att[0],$importedId);
767
+ if($product) {
768
+ break;
769
+ }
770
+ }
771
+ }
772
+
773
+ return $product;
774
+ }
775
+
776
+
777
+
778
+ public function getMageProduct($importedId, $merchantId, $storeId){
779
+ try {
780
+ $product=Mage::getModel('catalog/product')->load($importedId);
781
+ if (!$product->getId() || $product->getId() !== $importedId ){
782
+ $product = $this->matchProductAttributes($importedId, $storeId);
783
+ if($product == null || !is_object($product)) {
784
+ $product=Mage::getModel('catalog/product')->load($merchantId);
785
+ if(!$product->getId() || $product->getId() !== $merchantId ) {
786
+ $product = $this->matchProductAttributes($merchantId, $storeId);
787
+
788
+ }
789
+ }
790
+ }
791
+
792
+ if(is_object($product)) {
793
+ if($product->getId()) {
794
+ $this->debugLog("Product Matching succesful, Beezup Imported Id: ".$importedId." , Magento Product Id: ".$product->getId());
795
+ return $product;
796
+ }}
797
+ $this->log->LogError($this->orderid. "| No Product Matching, Product ".$importedId." could not be found");
798
+ $this->log2->LogError($this->orderid. "| No Product Matching, Product ".$importedId." could not be found");
799
+ return false;
800
+ }catch(Exception $e){
801
+ $this->log->LogError($this->orderid. "| Product ".$importedId." could not be found, error: ".$e->getMessage());
802
+ $this->log2->LogError($this->orderid. "| Product ".$importedId." could not be found, error: ".$e->getMessage());
803
+ return false;
804
+ //error no se pudo crear la orden
805
+
806
+ }
807
+ }
808
+
809
+
810
+ public function checkOrderStore($storeId ) {
811
+ $helper = Mage::helper('beezup');
812
+ $stores = $helper->getConfig('beezup/marketplace/stores');
813
+ $stores = unserialize ($stores);
814
+ foreach($stores as $store) {
815
+ if(isset($store[$storeId]) && $store[$storeId] > 0) {
816
+ return $store[$storeId];
817
+ }
818
+ }
819
+ return false;
820
+ }
821
+
822
+
823
+
824
+ /**
825
+ * @return BeezupOMOrderService
826
+ */
827
+ public function getOrderService(){
828
+ if ($this->oOrderService === null){
829
+ $this->oOrderService = $this->createOrderService();
830
+ // enchufamos debug mode, esta activado? false true $this->oOrderService->setDebugMode(false);
831
+ }
832
+ return $this->oOrderService;
833
+ }
834
+
835
+ /**
836
+ * @return BeezupOMOrderService
837
+ */
838
+ protected function createOrderService(){
839
+
840
+ return new BeezupOMOrderService($this->createRepository() );
841
+ }
842
+
843
+ protected function createRepository() {
844
+ if ($this->repository == null) {
845
+ $this->repository = new BeezupRepository();
846
+ }
847
+ return $this->repository;
848
+
849
+ }
850
+
851
+
852
+
853
+
854
+ private function createCustomer($customer_email , $data) {
855
+ $password = $this->orderid;
856
+ $this->debugLog("Creating new Customer");
857
+ $customer = Mage::getModel('customer/customer');
858
+ $customer->setWebsiteId(Mage::app()->getWebsite()->getId());
859
+ $customer->loadByEmail($customer_email);
860
+ if(!$customer->getId()) {
861
+ $customer->setEmail($customer_email);
862
+ $customer->setFirstname($data['firstname']);
863
+ $customer->setLastname($data['lastname']);
864
+ $customer->setPassword($password);
865
+ try {
866
+ $customer->save();
867
+ $customer->setConfirmation(null);
868
+ $customer->save();
869
+ $this->debugLog("Customer created succesfully");
870
+ return $customer;
871
+ //Make a "login" of new customer
872
+ // Mage::getSingleton('customer/session')->loginById($customer->getId());
873
+ }
874
+
875
+ catch (Exception $ex) {
876
+ //Zend_Debug::dump($ex->getMessage());
877
+ //GUARDAR ERROR CREACION USUARIO
878
+ $this->log2->LogError($this->orderid. " | Customer importation failed: ".$ex->getMessage());
879
+ return false;
880
+ }
881
+
882
+ } else {
883
+ $this->debugLog("Creating already exists, returning customer object");
884
+ return $customer;
885
+ }
886
+ }
887
+
888
+
889
+
890
+ public function addOrder($data, $oLink, $stop = false) {
891
+
892
+
893
+ try {
894
+ $helper = Mage::helper('beezup');
895
+ $addStock = $helper->getConfig('beezup/marketplace/available_products');
896
+ $baseCurrencyCode = Mage::app()->getStore()->getBaseCurrencyCode();
897
+ $quote = Mage::getModel('sales/quote')
898
+ ->setStoreId($data['storeid']);
899
+ $quote->setCustomerEmail($data['order_customer_email']);
900
+
901
+
902
+ $currency = Mage::getModel('directory/currency')->load($data['order_currency']);
903
+ $quote->setForcedCurrency($currency);
904
+
905
+ $blnCreate = true;
906
+ $total_new_price = 0;
907
+ foreach($data['products'] as $prod) {
908
+ if($prod['qty']==0) {
909
+ $blnCreate = false;
910
+ break;
911
+ }
912
+ $prod_totality_price = $prod['price']*$prod['qty'];
913
+ $total_new_price = $total_new_price + $prod_totality_price;
914
+ $product = Mage::getModel('catalog/product')->load($prod['id']);
915
+ $buyInfo = array(
916
+ 'qty' => $prod['qty'],
917
+ );
918
+ $this->debugLog("Adding ".$prod['qty']." product/s with id ".$product->getId()." to order, with Beezup Price: ".$prod['price']);
919
+ //echo "Product ".$product->getId()."<br><br>";
920
+ //para no perder stock:
921
+ //Mage::getModel('cataloginventory/stock')->backItemQty($productId,$new_qty);
922
+
923
+
924
+ if($addStock == 1) {
925
+ $stock = Mage::getModel('cataloginventory/stock_item')->loadByProduct($product);
926
+
927
+ if ($stock->getQty() < $prod['qty'] && $product->getStockItem()->getMaxSaleQty() >= $prod['qty']) {
928
+ $this->debugLog("Product ".$product->getId()." Stock = 0, Updating to ".$prod['qty']." to generate Order");
929
+ // Mage::getModel('cataloginventory/stock')->backItemQty($product->getId(),$prod['qty']);
930
+ //$this->_updateStocks(array("id_product" => $product->getId(), "qty" => $prod['qty']));
931
+ $product->setStockData(
932
+ array(
933
+ 'is_in_stock' => 1,
934
+ 'qty' => $prod['qty'],
935
+ 'manage_stock' => 1,
936
+ 'use_config_notify_stock_qty' => 1
937
+ )
938
+ );
939
+ $product->save();
940
+ $product = Mage::getModel('catalog/product')->load($product->getId());
941
+
942
+ }
943
+ }
944
+ //fin para no perder stock
945
+
946
+ /*
947
+ $tax_class = $product->getTaxClassId();
948
+ $product->setTaxClassId(0);
949
+ $product->getResource()->saveAttribute($product, 'tax_class_id'); */
950
+ $price = $prod['price'];
951
+
952
+ $quote_item = Mage::getModel('beezup/quote_item');
953
+ $quote_item
954
+ ->setProduct($product)
955
+ ->setPrice((float) $price )
956
+ ->setCustomPrice((float)$price )
957
+ ->setOriginalCustomPrice((float) $price )
958
+ ->setQuote($quote)
959
+ ->setQty((integer) $prod['qty'])
960
+ ->setBeezupPrice((float) $price );
961
+
962
+
963
+ $quote->addItem($quote_item);
964
+
965
+ //$quote->addProduct($product, new Varien_Object($buyInfo))->setOriginalCustomPrice($price)->setCustomPrice($price);
966
+
967
+ /*
968
+ $product->setTaxClassId($tax_class);
969
+
970
+ $product->getResource()->saveAttribute($product, 'tax_class_id');
971
+ */
972
+ }
973
+
974
+ if($blnCreate) {
975
+ $addressData = array(
976
+ 'firstname' => ($data['order_customer']) ? $data['order_customer'] : "empty",
977
+ 'lastname' => ($data['order_lastname']) ? $data['order_lastname'] : "empty",
978
+ 'street' => ($data['order_address']) ? $data['order_address'] : "empty",
979
+ 'city' => ($data['order_city']) ? $data['order_city'] : "empty",
980
+ 'postcode' => ($data['order_postalCode']) ? $data['order_postalCode'] : "empty",
981
+ 'telephone' => ($data['order_customer_phone']) ? $data['order_customer_phone'] : "empty",
982
+ 'country_id' => ($data['order_country_iso']) ? $data['order_country_iso'] : "empty",
983
+ 'region_id' => ($data['order_region ']) ? substr($data['order_region '], 0,2) : "EM"// id from directory_country_region table
984
+ );
985
+
986
+ $shippingData = array(
987
+ 'firstname' => ($data['shipping_name']) ? $data['shipping_name'] : "empty",
988
+ 'lastname' => ($data['shipping_lastname']) ? $data['shipping_lastname'] : "empty",
989
+ 'street' => ($data['shipping_address']) ? $data['shipping_address'] : "empty",
990
+ 'city' => ($data['shipping_city']) ? $data['shipping_city'] : "empty",
991
+ 'postcode' => ($data['shipping_postalCode']) ? $data['shipping_postalCode'] : "empty",
992
+ 'telephone' => ($data['shipping_phone']) ? $data['shipping_phone'] : "empty",
993
+ 'country_id' => ($data['shipping_country_iso']) ? $data['shipping_country_iso'] : "empty",
994
+ 'region_id' => ($data['shipping_region']) ? substr($data['shipping_region'], 0, 2) : "EM" // id from directory_country_region table
995
+ );
996
+
997
+ if($this->blnCreateCustomer) {
998
+
999
+ $mage_customer = $this->createCustomer($data['order_customer_email'], $addressData);
1000
+ $quote->assignCustomer($mage_customer);
1001
+ }
1002
+
1003
+
1004
+ $payment_method = $helper->getConfig('beezup/marketplace/payment_method');
1005
+ $billingAddress = $quote->getBillingAddress()->addData($addressData);
1006
+ $shippingAddress = $quote->getShippingAddress()->addData($shippingData);
1007
+ $shipping_cost = (float) $data['order_shippingPrice'];
1008
+ if($data['order_shippingPrice'] == 0) {
1009
+ $shipping_cost = 20000;
1010
+ }
1011
+ $total_new_price = $total_new_price + $data['order_shippingPrice'] ;
1012
+ Mage::unregister('shipping_cost');
1013
+ Mage::register('shipping_cost', $shipping_cost);
1014
+ $this->debugLog("Adding Order Shipping Cost: ". $data['order_shippingPrice']);
1015
+
1016
+ $shippingAddress->setCollectShippingRates(true)->collectShippingRates()
1017
+ ->setShippingMethod('flatrate_flatrate')
1018
+ ->setPaymentMethod($payment_method);
1019
+
1020
+ //$shippingAddress->addTotal(array("code" => "specialfee", "title" => "Special Fee", "value" => 20));
1021
+ $quote->getPayment()->importData(array('method' => $payment_method));
1022
+
1023
+ $quote->collectTotals()->save();
1024
+
1025
+ $service = Mage::getModel('sales/service_quote', $quote);
1026
+ $service->submitAll();
1027
+ $order = $service->getOrder();
1028
+
1029
+
1030
+
1031
+ $quoteId = $order->getQuoteId();
1032
+ //$this->setStatus($data['order_status'], $order);
1033
+
1034
+ $orderid = $order->getId();
1035
+
1036
+ $resource = Mage::getSingleton('core/resource');
1037
+ $writeConnection = $resource->getConnection('core_write');
1038
+ $table = $resource->getTableName('sales/order_grid');
1039
+ $this->debugLog("Adding Beezup Marketplace Information to Order");
1040
+ $marketplace = $data['marketplace'];
1041
+ $marketplace_business_code = ucfirst(strtolower($data['marketplace_business_code']));
1042
+ $beezup_name = $data['order_customer'];
1043
+ $market_order_id =$this->orderid;
1044
+ $beezup_order_id = $oLink->getBeezupOrderUUID();
1045
+ $beezup_status = $data['order_status'];
1046
+ $beezup_last_modification_date = $oLink->getOrderLastModificationUtcDate();
1047
+ $beezup_last_modification_date = $beezup_last_modification_date->date;
1048
+ $beezup_marketplace_status = $oLink->getOrderStatusMarketPlaceStatus();
1049
+ $beezup_purchase_date = $oLink->getOrderPurchaseUtcDate();
1050
+ $beezup_purchase_date = $beezup_purchase_date->date;
1051
+ $beezup_marketplace_last_modification_date = $oLink->getOrderMarketPlaceLastModificationUtcDate();
1052
+ $beezup_marketplace_last_modification_date = $beezup_marketplace_last_modification_date->date;
1053
+ /* $date = new DateTime($$beezup_marketplace_last_modification_date);
1054
+ $beezup_marketplace_last_modification_date = $date->format('d-m-Y H:i:s'). "(UTC Time)";
1055
+ */
1056
+
1057
+ $beezup_total_paid = $oLink->getOrderTotalPrice()." ".$data['order_currency'];
1058
+ $beezup_account_id = $oLink->getAccountId();
1059
+ $beezup_comission = $oLink->getOrderTotalCommission()." ".$data['order_currency'];
1060
+ $tot_comm = $oLink->getOrderTotalCommission();
1061
+ if(empty($tot_comm ) || $tot_comm == 0) {
1062
+ $beezup_comission = 0;
1063
+ }
1064
+ $query = "UPDATE {$table} SET beezup_marketplace = '{$marketplace}', beezup_name = '{$beezup_account_id}', beezup_order = 1, beezup_market_order_id = '{$market_order_id}',
1065
+ beezup_order_id = '{$beezup_order_id}', beezup_status = '{$beezup_status}', beezup_last_modification_date = '{$beezup_last_modification_date}',
1066
+ beezup_marketplace_status = '{$beezup_marketplace_status}', beezup_purchase_date = '{$beezup_purchase_date}', beezup_marketplace_last_modification_date = '{$beezup_marketplace_last_modification_date}',
1067
+ beezup_total_paid = '{$beezup_total_paid}', beezup_etag = '{$data['etag']}' , beezup_comission = '{$beezup_comission}', beezup_marketplace_business_code = '{$marketplace_business_code}'
1068
+ WHERE entity_id = ". (int)$orderid;
1069
+ $writeConnection->query($query);
1070
+ $disc_price = 0;
1071
+ if(!empty($data['discounts']) && $data['discounts'] >0) {
1072
+
1073
+
1074
+ $disc_price = round($data['discounts'],2);
1075
+ $total_new_price = $total_new_price+$disc_price;
1076
+ $table_address = $resource->getTableName("sales/quote_address");
1077
+
1078
+ $query = "update {$table_address} set beezup_fee = '{$disc_price}' where quote_id = '{$quoteId}' and address_type = 'shipping'";
1079
+ $writeConnection->query($query);
1080
+ $this->debugLog("Adding CDISCOUNT products with total price: ".$disc_price);
1081
+ }
1082
+
1083
+ //if order id exists and has been created
1084
+ if ($orderid)
1085
+ {
1086
+ //we send order id to beezup
1087
+ $this->debugLog("Sending Magento Order Id to Beezup, Magento Order Id: ".$orderid);
1088
+ $oResult = new BeezupOMSetOrderIdValues ();
1089
+ $oResult->setOrderMerchantOrderId ( $orderid )->setOrderMerchantECommerceSoftwareName ( 'Magento' )->setOrderMerchantECommerceSoftwareVersion ( Mage::getVersion() );
1090
+ $sendRequest = $this->getOrderService()->getClientProxy()->setOrderMerchantIdByLink($oLink->getLinkByRel('setMerchantOrderId'), $oResult);
1091
+ }
1092
+
1093
+ $grand_total = $order->getGrandTotal();
1094
+ $beezup_price = $oLink->getOrderTotalPrice() - $disc_price;
1095
+ if($grand_total != (float) $beezup_price && $beezup_price > 0) {
1096
+ $order->setGrandTotal((float) $beezup_price);
1097
+ $order->setBaseGrandTotal((float) $beezup_price);
1098
+ $diff = (((float) $beezup_price) - $grand_total);
1099
+
1100
+ $order->setTaxAmount($order->getTaxAmount() + $diff);
1101
+ $order->save();
1102
+ }elseif($grand_total != (float)$beezup_price && $beezup_price < 1) {
1103
+
1104
+ $order->setGrandTotal((float) $total_new_price);
1105
+ $order->setBaseGrandTotal((float) $total_new_price);
1106
+ $diff = (((float) $total_new_price) - $grand_total);
1107
+
1108
+ $order->setTaxAmount($order->getTaxAmount() + $diff);
1109
+ $order->save();
1110
+ }
1111
+
1112
+ $products = Mage::getResourceModel('sales/order_item_collection')
1113
+ ->setOrderFilter($orderid);
1114
+ foreach($products as $product) {
1115
+ $product->setBaseOriginalPrice($product->getOriginalPrice());
1116
+ $product->setBaseTaxAmount($product->getTaxAmount());
1117
+ $product->setBaseTaxInvoiced($product->getTaxAmount());
1118
+ $product->setBasePriceInclTax($product->getPriceInclTax());
1119
+ $product->setBaseRowTotalInclTax($product->getRowTotalInclTax());
1120
+ $product->save();
1121
+ }
1122
+ $order->setBaseTaxAmount($order->getTaxAmount());
1123
+ $order->setBaseTaxInvoiced($order->getTaxAmount());
1124
+ $order->setBaseTotalInvoiced($order->getTotalPaid());
1125
+ $order->setBaseTotalPaid($order->getTotalPaid());
1126
+ $order->setBaseGrandTotal($order->getTotalPaid());
1127
+ $order->setBaseSubtotalInclTax($order->getSubtotalInclTax());
1128
+ $order->save();
1129
+
1130
+ $this->setStatus($data['order_status'], $order);
1131
+ $this->mage_order_id = $orderid;
1132
+ $this->debugLog("Order imported succesfully, Magento Order Id: ".$orderid);
1133
+ } else {
1134
+ //product stock = 0 we dont create order
1135
+ $this->log->LogError($this->orderid. "| Order ".$data['market_place_order_id']." could not be imported, error: Stock from Beezup product = 0 ");
1136
+ $this->log2->LogError($this->orderid. "| Order ".$data['market_place_order_id']." could not be imported, error: Stock from Beezup product = 0 ");
1137
+ }
1138
+ }catch(Exception $e){
1139
+
1140
+
1141
+ if($stop) {
1142
+ $this->log->LogError($this->orderid. "| Order ".$data['market_place_order_id']." could not be imported, error: ".$e->getMessage());
1143
+ $this->log2->LogError($this->orderid. "| Order ".$data['market_place_order_id']." could not be imported, error: ".$e->getMessage());
1144
+ $this->restoreStock($data);
1145
+ } else {
1146
+ $this->debugLog("Order Import failed, Trying to import Order Again");
1147
+ $this->addOrder($data, $oLink, true);
1148
+
1149
+ }
1150
+ //error no se pudo crear la orden
1151
+
1152
+ }
1153
+
1154
+
1155
+
1156
+ }
1157
+
1158
+
1159
+
1160
+ public function restoreStock($data) {
1161
+
1162
+ try {
1163
+ foreach($data['products'] as $prod) {
1164
+ $product = Mage::getModel('catalog/product')->load($prod['id']);
1165
+ $stock = Mage::getModel('cataloginventory/stock_item')->loadByProduct($product);
1166
+ if ($stock->getQty() != $prod['curr_stock'] ) {
1167
+ $this->debugLog("Restoring Stock from Product ".$product->getId()." to: ".$prod['curr_stock'] ." due to Order Fail");
1168
+ $stockItem = Mage::getModel('cataloginventory/stock_item')->loadByProduct($product);
1169
+ $stockItem->setData('is_in_stock', 0);
1170
+ $stockItem->setData('qty', $prod['curr_stock']);
1171
+ $stockItem->save();
1172
+ $product->save();
1173
+ }
1174
+
1175
+ }
1176
+ } catch(Exception $e){
1177
+ $this->log->LogError($this->orderid. "| Failed Restoring Product Stock: ".$e->getMessage());
1178
+ $this->log2->LogError($this->orderid. "| Failed Restoring Product Stock: ".$e->getMessage());
1179
+ }
1180
+
1181
+ }
1182
+
1183
+
1184
+
1185
+ private function createProduct($data) {
1186
+
1187
+ $sku = $data['sku'];
1188
+ if(empty($data['sku'])) {
1189
+ $sku = $data['sku2'];
1190
+ }
1191
+
1192
+ Mage::app()->setCurrentStore($data['storeId']);
1193
+ $product = Mage::getModel('catalog/product');
1194
+ // if(!$product->getIdBySku('testsku61')):
1195
+
1196
+ try{
1197
+ $product
1198
+ // ->setStoreId(1) //you can set data in store scope
1199
+ ->setWebsiteIds(array($data['storeId'])) //website ID the product is assigned to, as an array
1200
+ ->setAttributeSetId($product->getDefaultAttributeSetId()) //ID of a attribute set named 'default'
1201
+ ->setTypeId('simple') //product type
1202
+ ->setCreatedAt(strtotime('now')) //product creation time
1203
+ ->setSku($sku ) //SKU
1204
+ ->setWeight(0)
1205
+ ->setName($data['title']) //product name
1206
+ ->setStatus(1) //product status (1 - enabled, 2 - disabled)
1207
+ ->setTaxClassId(4) //tax class (0 - none, 1 - default, 2 - taxable, 4 - shipping)
1208
+ ->setVisibility(Mage_Catalog_Model_Product_Visibility::VISIBILITY_NOT_VISIBLE ) //catalog and search visibility
1209
+ ->setPrice($data['price']) //price in form 11.22
1210
+ ->setMsrpEnabled(1) //enable MAP
1211
+ ->setMsrpDisplayActualPriceType(1) //display actual price (1 - on gesture, 2 - in cart, 3 - before order confirmation, 4 - use config)
1212
+ ->setMsrp(0) //Manufacturer's Suggested Retail Price
1213
+ ->setMetaTitle('')
1214
+ ->setMetaKeyword('')
1215
+ ->setMetaDescription('')
1216
+ ->setDescription($data['title'])
1217
+ ->setShortDescription($data['title'])
1218
+ // ->setMediaGallery (array('images'=>array (), 'values'=>array ())) //media gallery initialization
1219
+ //->addImageToMediaGallery('media/catalog/product/1/0/10243-1.png', array('image','thumbnail','small_image'), false, false) //assigning image, thumb and small image to media gallery
1220
+ ->setStockData(array(
1221
+ 'use_config_manage_stock' => 0, //'Use config settings' checkbox
1222
+ 'manage_stock'=>1, //manage stock
1223
+ 'min_sale_qty'=>1, //Minimum Qty Allowed in Shopping Cart
1224
+ 'max_sale_qty'=>2, //Maximum Qty Allowed in Shopping Cart
1225
+ 'is_in_stock' => 1, //Stock Availability
1226
+ 'qty' => 1 //qty
1227
+ )
1228
+ );
1229
+ $product->save();
1230
+ return $product;
1231
+
1232
+ }catch(Exception $e){
1233
+ //log exception
1234
+ $this->log->LogError($this->orderid."| Product ".$sku." could not be created, error: ".$e->getMessage());
1235
+ $this->log2->LogError($this->orderid."| Product ".$sku." could not be created, error: ".$e->getMessage());
1236
+ return false;
1237
+ }
1238
+ }
1239
+
1240
+
1241
+
1242
+ public function setStatus($status, $order) {
1243
+ $helper = Mage::helper('beezup');
1244
+ $retorno = "";
1245
+ $blnCancel = false;
1246
+ $blnHold = false;
1247
+ switch($status) {
1248
+ case "New" :
1249
+ $this->debugLog("Setting Order Status to New");
1250
+ $retorno = $helper->getConfig('beezup/marketplace/status_new');
1251
+ break;
1252
+ case "InProgress" :
1253
+ $this->debugLog("Setting Order Status to InProgress");
1254
+ $retorno = $helper->getConfig('beezup/marketplace/status_progress');
1255
+ $this->payOrder($order);
1256
+ break;
1257
+ case "Aborted" :
1258
+ $this->debugLog("Setting Order Status to Aborted");
1259
+ $retorno = $helper->getConfig('beezup/marketplace/status_aborted');
1260
+ $blnHold = true;
1261
+
1262
+
1263
+ break;
1264
+ case "Closed" :
1265
+ $this->debugLog("Setting Order Status to Closed");
1266
+ $blnCancel =true;
1267
+ $retorno = $helper->getConfig('beezup/marketplace/status_closed');
1268
+ $this->payOrder($order);
1269
+ break;
1270
+ case "Canceled" :
1271
+ $this->debugLog("Setting Order Status to Cancelled");
1272
+ $retorno = $helper->getConfig('beezup/marketplace/status_cancelled');
1273
+
1274
+ break;
1275
+ case "Shipped" :
1276
+ $this->debugLog("Setting Order Status to Shipped");
1277
+ $retorno = $helper->getConfig('beezup/marketplace/status_shipped');
1278
+ $this->payOrder($order);
1279
+ break;
1280
+
1281
+ }
1282
+ $order->setData('state',$retorno);
1283
+ $order->setStatus($retorno);
1284
+ $history = $order->addStatusHistoryComment('Order was set to '.$retorno.' by Beezup.', false);
1285
+ $history->setIsCustomerNotified(false);
1286
+ $order->save();
1287
+ if($blnCancel) {
1288
+ $order->cancel()->save();
1289
+ }
1290
+ if($blnHold) {
1291
+ $order->hold()->save();
1292
+ }
1293
+
1294
+ return $retorno;
1295
+
1296
+ }
1297
+
1298
+
1299
+ public function getStatus($status1) {
1300
+ $helper = Mage::helper('beezup');
1301
+ $retorno = "";
1302
+ $status = strtolower($status1);
1303
+
1304
+ if($status == strtolower($helper->getConfig('beezup/marketplace/status_new') )) {
1305
+ $retorno = "New";
1306
+
1307
+ } elseif($status == strtolower($helper->getConfig('beezup/marketplace/status_progress') ) ){
1308
+ $retorno = "InProgress";
1309
+
1310
+
1311
+ }
1312
+ elseif($status == strtolower($helper->getConfig('beezup/marketplace/status_aborted') )) {
1313
+
1314
+ $retorno = "Aborted" ;
1315
+ }
1316
+ elseif($status == strtolower($helper->getConfig('beezup/marketplace/status_closed') )) {
1317
+ $retorno = "Closed";
1318
+
1319
+ }
1320
+ elseif($status == strtolower($helper->getConfig('beezup/marketplace/status_cancelled')) ) {
1321
+
1322
+ $retorno = "Canceled";
1323
+ }
1324
+ elseif($status == strtolower($helper->getConfig('beezup/marketplace/status_shipped') )) {
1325
+
1326
+ $retorno = "Shipped";
1327
+ }
1328
+
1329
+
1330
+ return $retorno;
1331
+
1332
+ }
1333
+
1334
+
1335
+ public function checkMarketOrderExists($orderid) {
1336
+ $resource = Mage::getSingleton('core/resource');
1337
+ $readConnection = $resource->getConnection('core_read');
1338
+ $table = $resource->getTableName('sales/order_grid');
1339
+ $query = 'SELECT increment_id FROM ' . $table . ' WHERE beezup_order = 1 and beezup_market_order_id = \''
1340
+ . $orderid . '\' LIMIT 1';
1341
+ $order = $readConnection->fetchOne($query);
1342
+ if($order && !empty($order) && $this->orderId !== "") {
1343
+ return $order;
1344
+ }
1345
+ return false;
1346
+
1347
+ }
1348
+
1349
+ public function payOrder($order) {
1350
+ try {
1351
+ $this->debugLog("Generating Order Payment Invoice");
1352
+ if($order->canInvoice()) {
1353
+ $invoice = $order->prepareInvoice()
1354
+ ->setTransactionId($order->getId())
1355
+ ->addComment("Invoice created from Beezup.")
1356
+ ->register()
1357
+ ->pay();
1358
+ $transaction_save = Mage::getModel('core/resource_transaction')
1359
+ ->addObject($invoice)
1360
+ ->addObject($invoice->getOrder());
1361
+ $transaction_save->save();
1362
+ $this->debugLog("Order Payment Invoice Generated Succesfully");
1363
+ }
1364
+ }
1365
+ catch(Exception $e){
1366
+ //log exception
1367
+ $this->log->LogError($this->orderid."| Order Payment Invoice could not be generated, error: ".$e->getMessage());
1368
+ $this->log2->LogError($this->orderid."| Order Payment Invoice could not be generated, error: ".$e->getMessage());
1369
+ }
1370
+ }
1371
+
1372
+
1373
+
1374
+
1375
+
1376
+
1377
+ }
app/code/community/BeezUp/etc/config.xml CHANGED
@@ -2,7 +2,7 @@
2
  <config>
3
  <modules>
4
  <BeezUp>
5
- <version>4.6.3</version>
6
  </BeezUp>
7
  </modules>
8
  <global>
2
  <config>
3
  <modules>
4
  <BeezUp>
5
+ <version>4.6.4</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.3) - <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.3) - <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.3) - <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.6.4) - <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.6.4) - <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.6.4) - <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.3</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,11 +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
- &gt;Configurable feed load speed enhancement</notes>
46
  <authors><author><name>BeezUP</name><user>BeezUP</user><email>charles@beezup.com</email></author></authors>
47
- <date>2016-04-12</date>
48
- <time>14:59:38</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="a40f2918627077264132594cfe028290"/><file name="Order.php" hash="9952ed2a24816b211fcc1dbcf7488678"/><file name="Tracking.php" hash="e6dcd6b89e782b2eb6cb83abfb1b7f56"/><file name="Xml.php" hash="ae72affa5895c8191b12724554c3bfb3"/></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="6d471745eddabe2bf75bdea600d239bf"/><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="8d6a9940891902a0a8d5a99c366432ce"/><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="3b38e6a923d98f2739b70c9960958dd6"/><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="9d899f939d341c75c9996e1fd4bd1d82"/><file name="system.xml" hash="e42049583fd3653c6c155b2c9a38a969"/></dir><dir name="img"><file name="ajax-loader.gif" hash="2a6692973429d7a74513bfa8bcb5be20"/></dir><dir name="lib"><file name="BeezupMageOrders.php" hash="cb62e5d5322912447cf829599013c17f"/><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>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>BeezUP_Module_feed_and_tracker</name>
4
+ <version>4.6.4</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
+ &gt;Minor bugs fixing</notes>
46
  <authors><author><name>BeezUP</name><user>BeezUP</user><email>charles@beezup.com</email></author></authors>
47
+ <date>2016-05-16</date>
48
+ <time>16:44:21</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="a40f2918627077264132594cfe028290"/><file name="Order.php" hash="f911b2962639f9f96018237eb51b8892"/><file name="Tracking.php" hash="e6dcd6b89e782b2eb6cb83abfb1b7f56"/><file name="Xml.php" hash="ae72affa5895c8191b12724554c3bfb3"/></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="6d471745eddabe2bf75bdea600d239bf"/><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="8d6a9940891902a0a8d5a99c366432ce"/><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="3b38e6a923d98f2739b70c9960958dd6"/><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="b6e08cb67381277e63fec3a99e9562e2"/><file name="system.xml" hash="4682c8d1d3beda0355db6f40aabf4cfb"/></dir><dir name="img"><file name="ajax-loader.gif" hash="2a6692973429d7a74513bfa8bcb5be20"/></dir><dir name="lib"><file name="BeezupMageOrders.php" hash="cb62e5d5322912447cf829599013c17f"/><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>