BeezUP_Module_feed_and_tracker - Version 4.6.0

Version Notes

New features :
> Advanced shipping prices
> Description HTML Support
> New products filtering options
> Possibility to retrieve one specific order
> Shipment details prefilling
> Customer creation option

Download this release

Release Info

Developer BeezUP
Extension BeezUP_Module_feed_and_tracker
Version 4.6.0
Comparing to
See all releases


Code changes from version 4.5.0 to 4.6.0

Files changed (28) hide show
  1. app/code/community/BeezUp/Block/Adminhtml/Sales/Order/Grid.php +2 -2
  2. app/code/community/BeezUp/Block/Adminhtml/Sales/Order/View/Tab/Custom.php +100 -94
  3. app/code/community/BeezUp/Block/Adminhtml/System/Config/Log.php +8 -1
  4. app/code/community/BeezUp/Block/Adminhtml/System/Config/Orderlink.php +86 -0
  5. app/code/community/BeezUp/Block/Omstatus.php +512 -512
  6. app/code/community/BeezUp/Block/Order.php +1145 -925
  7. app/code/community/BeezUp/Block/Xml.php +277 -166
  8. app/code/community/BeezUp/Helper/Data.php +93 -60
  9. app/code/community/BeezUp/Model/Products.php +416 -277
  10. app/code/community/BeezUp/Model/System/Config/Source/Attributes.php +2 -2
  11. app/code/community/BeezUp/Model/System/Config/Source/Carriers.php +35 -0
  12. app/code/community/BeezUp/Model/System/Config/Source/Countries.php +17 -0
  13. app/code/community/BeezUp/Model/System/Config/Source/Customercreate.php +14 -0
  14. app/code/community/BeezUp/Model/System/Config/Source/Description.php +2 -0
  15. app/code/community/BeezUp/Model/System/Config/Source/Visibility.php +19 -0
  16. app/code/community/BeezUp/controllers/CatalogController.php +6 -4
  17. app/code/community/BeezUp/controllers/CronController.php +74 -21
  18. app/code/community/BeezUp/etc/config.xml +5 -6
  19. app/code/community/BeezUp/etc/system.xml +476 -416
  20. app/code/community/BeezUp/lib/BeezupOMOrderService.php +362 -361
  21. app/code/community/BeezUp/lib/Order/BeezupOMOrderResult.php +20 -0
  22. app/code/community/BeezUp/log/log.txt +16 -0
  23. app/code/community/BeezUp/log/log2.txt +293 -0
  24. app/code/community/BeezUp/sql/beezup_setup/mysql4-upgrade-4.5.0-4.6.0.php +11 -0
  25. app/design/adminhtml/default/default/template/beezup/custom.phtml +340 -325
  26. app/locale/en_US/BeezUp.csv +15 -0
  27. app/locale/fr_FR/BeezUp.csv +21 -4
  28. package.xml +10 -5
app/code/community/BeezUp/Block/Adminhtml/Sales/Order/Grid.php CHANGED
@@ -74,9 +74,9 @@ class BeezUp_Block_Adminhtml_Sales_Order_Grid extends Mage_Adminhtml_Block_Widg
74
  'header' => Mage::helper('sales')->__('Ship to Name'),
75
  'index' => 'shipping_name',
76
  ));
77
- $this->addColumn('beezup_marketplace', array(
78
  'header' =>Mage::helper('beezup')->__('Marketplace'),
79
- 'index' => 'beezup_marketplace',
80
  ));
81
 
82
 
74
  'header' => Mage::helper('sales')->__('Ship to Name'),
75
  'index' => 'shipping_name',
76
  ));
77
+ $this->addColumn('beezup_marketplace_business_code', array(
78
  'header' =>Mage::helper('beezup')->__('Marketplace'),
79
+ 'index' => 'beezup_marketplace_business_code',
80
  ));
81
 
82
 
app/code/community/BeezUp/Block/Adminhtml/Sales/Order/View/Tab/Custom.php CHANGED
@@ -1,99 +1,105 @@
1
  <?php
2
 
3
- require_once dirname ( __FILE__ ) . "/../../../../../../lib/BeezupOMStatus.php";
4
-
5
- class BeezUp_Block_Adminhtml_Sales_Order_View_Tab_Custom
6
  extends Mage_Adminhtml_Block_Template
7
  implements Mage_Adminhtml_Block_Widget_Tab_Interface
8
- {
9
- protected $_chat = null;
10
-
11
- protected function _construct()
12
- {
13
- parent::_construct();
14
- $this->setTemplate('beezup/custom.phtml');
15
- }
16
-
17
- public function getTabLabel() {
18
- return $this->__('BeezUP Info');
19
- }
20
-
21
- public function getTabTitle() {
22
- return $this->__('BeezUP Info');
23
- }
24
-
25
- public function canShowTab() {
26
- return true;
27
- }
28
-
29
- public function isHidden() {
30
- return false;
31
- }
32
-
33
- public function getOrder(){
34
- return Mage::registry('current_order');
35
- }
36
-
37
- public function getBeezupInfo($id_order) {
38
- $omStatus = new BeezupOmStatus();
39
- $data = $omStatus->getInfo($id_order);
40
-
41
- return $data;
42
- }
43
-
44
- public function generateInput($values) {
45
- $retorno = "<table class='table' style='width:100%'>";
46
- foreach($values as $data) {
47
-
48
- $required = false;
49
- $txtLabel = "";
50
- $inputReq = "";
51
- if($data->isMandatory==1) {
52
- $required = true;
53
- $txtLabel = " <span style='color:red;'>*</span>";
54
- $inputReq = "required";
55
- }
56
- $action_name = $data->name;
57
- $label = str_replace("Order_Shipping_", "", $data->name);
58
- $label = preg_replace('/(?<!\ )[A-Z]/', ' $0', $label);
59
- $label = str_replace("_", " ", $label);
60
- // $label = implode(" ", $label);
61
- $retorno .= "<tr><td style='text-align:right;'><label>".$label." ".$txtLabel."</label></td>";
62
-
63
- if($data->islovRequired ==1) {
64
- $retorno .= '<td><select '.$inputReq.' onclick="updateOrder(this.value)" name='.$data->name.' >';
65
- foreach($data->$action_name->values as $value) {
66
- $texto = $value->TranslationText;
67
- if(empty($texto) || trim($texto) == "") {
68
- $texto = ucfirst(str_replace("_", " ", $value->CodeIdentifier));
69
- }
70
- $retorno .= '<option value="'.$value->CodeIdentifier.'" >'.$texto.'</option>';
71
- }
72
- $retorno .= '</select></td></tr>';
73
-
74
- } elseif($data->cSharpType == "System.DateTime") {
75
- $retorno .= '<td><input type="text" style="width:169px;" id="'.$data->name."_".$action_name.'" name="'.$data->name.'" />
76
- <script>// <![CDATA[
77
- Calendar.setup({
78
- inputField : \''.$data->name."_".$action_name.'\',
79
- ifFormat : \'%m/%e/%y\',
80
- button : \'date_from_trig\',
81
- align : \'Bl\',
82
- singleClick : true
83
- });
84
- // ]]
85
- </script>
86
- </td></tr>';
87
- } else {
88
- $retorno .= '<td><input type="text" name="'.$data->name.'" /></td></tr>';
89
- }
90
 
91
- }
92
- $retorno .= "</table>";
93
- return $retorno;
94
-
95
- }
96
-
97
-
98
-
99
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  <?php
2
 
3
+ require_once dirname ( __FILE__ ) . "/../../../../../../lib/BeezupOMStatus.php";
4
+
5
+ class BeezUp_Block_Adminhtml_Sales_Order_View_Tab_Custom
6
  extends Mage_Adminhtml_Block_Template
7
  implements Mage_Adminhtml_Block_Widget_Tab_Interface
8
+ {
9
+ protected $_chat = null;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10
 
11
+ protected function _construct()
12
+ {
13
+ parent::_construct();
14
+ $this->setTemplate('beezup/custom.phtml');
15
+ }
16
+
17
+ public function getTabLabel() {
18
+ return $this->__('BeezUP Info');
19
+ }
20
+
21
+ public function getTabTitle() {
22
+ return $this->__('BeezUP Info');
23
+ }
24
+
25
+ public function canShowTab() {
26
+ return true;
27
+ }
28
+
29
+ public function isHidden() {
30
+ return false;
31
+ }
32
+
33
+ public function getOrder(){
34
+ return Mage::registry('current_order');
35
+ }
36
+
37
+ public function getBeezupInfo($id_order) {
38
+ $omStatus = new BeezupOmStatus();
39
+ $data = $omStatus->getInfo($id_order);
40
+ return $data;
41
+ }
42
+
43
+ public function generateInput($values, $shipping_data) {
44
+ $retorno = "<table class='table' style='width:100%'>";
45
+ foreach($values as $data) {
46
+ $valor_input = "";
47
+ if (strpos(strtolower($data->name), 'track') !== false) {
48
+ $valor_input = $shipping_data['tracking'];
49
+ } elseif (strpos(strtolower($data->name), 'carrier') !== false) {
50
+ $valor_input = $shipping_data['carrier'];
51
+ }
52
+
53
+ $required = false;
54
+ $txtLabel = "";
55
+ $inputReq = "";
56
+ if($data->isMandatory==1) {
57
+ $required = true;
58
+ $txtLabel = " <span style='color:red;'>*</span>";
59
+ $inputReq = "required";
60
+ }
61
+ $action_name = $data->name;
62
+ $label = str_replace("Order_Shipping_", "", $data->name);
63
+ $label = preg_replace('/(?<!\ )[A-Z]/', ' $0', $label);
64
+ $label = str_replace("_", " ", $label);
65
+ // $label = implode(" ", $label);
66
+ $retorno .= "<tr><td style='text-align:right;'><label>".$label." ".$txtLabel."</label></td>";
67
+
68
+ if($data->islovRequired ==1) {
69
+ $retorno .= '<td><select '.$inputReq.' onclick="updateOrder(this.value)" name='.$data->name.' >';
70
+ foreach($data->$action_name->values as $value) {
71
+ $texto = $value->TranslationText;
72
+ if(empty($texto) || trim($texto) == "") {
73
+ $texto = ucfirst(str_replace("_", " ", $value->CodeIdentifier));
74
+ }
75
+ $retorno .= '<option value="'.$value->CodeIdentifier.'" >'.$texto.'</option>';
76
+ }
77
+ $retorno .= '</select></td></tr>';
78
+
79
+ } elseif($data->cSharpType == "System.DateTime") {
80
+ $today_date = date('m/d/y');
81
+ $retorno .= '<td><input type="text" style="width:169px;" id="'.$data->name."_".$action_name.'" name="'.$data->name.'" value="'.$today_date.'" />
82
+ <script>// <![CDATA[
83
+ Calendar.setup({
84
+ inputField : \''.$data->name."_".$action_name.'\',
85
+ ifFormat : \'%m/%e/%y\',
86
+ button : \'date_from_trig\',
87
+ align : \'Bl\',
88
+ singleClick : true
89
+ });
90
+ // ]]
91
+ </script>
92
+ </td></tr>';
93
+ } else {
94
+ $retorno .= '<td><input type="text" name="'.$data->name.'" value="'.$valor_input.'" /></td></tr>';
95
+ }
96
+
97
+ }
98
+ $retorno .= "</table>";
99
+ return $retorno;
100
+
101
+ }
102
+
103
+
104
+
105
+ }
app/code/community/BeezUp/Block/Adminhtml/System/Config/Log.php CHANGED
@@ -28,7 +28,14 @@ class Beezup_Block_Adminhtml_System_Config_Log extends Mage_Adminhtml_Block_Syst
28
 
29
  public function _getTable($data) {
30
  $url = Mage::getBaseUrl( Mage_Core_Model_Store::URL_TYPE_WEB, true );
31
- $html = "<td></td><td></td><tr></tr></tbody></table>
 
 
 
 
 
 
 
32
 
33
  <div class='grid' style=' height: 400px;overflow-y: scroll;padding: 16px;border: 3px solid #e6e6e6;' id='marketPlaceLogBlock'>";
34
  $html .= '<p>'. Mage::helper('beezup')->__('For full logs see here:').' <a href="'.$url .'beezup/log/load" target="_blank">'.$url .'beezup/log/load</a></p>';
28
 
29
  public function _getTable($data) {
30
  $url = Mage::getBaseUrl( Mage_Core_Model_Store::URL_TYPE_WEB, true );
31
+ $html = "
32
+ <style>
33
+ #beezup_flux_description {
34
+ height: 110px;
35
+
36
+ }
37
+ </style>
38
+ <td></td><td></td><tr></tr></tbody></table>
39
 
40
  <div class='grid' style=' height: 400px;overflow-y: scroll;padding: 16px;border: 3px solid #e6e6e6;' id='marketPlaceLogBlock'>";
41
  $html .= '<p>'. Mage::helper('beezup')->__('For full logs see here:').' <a href="'.$url .'beezup/log/load" target="_blank">'.$url .'beezup/log/load</a></p>';
app/code/community/BeezUp/Block/Adminhtml/System/Config/Orderlink.php ADDED
@@ -0,0 +1,86 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Beezup_Block_Adminhtml_System_Config_Orderlink extends Mage_Adminhtml_Block_System_Config_Form_Field
4
+ {
5
+
6
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
7
+ {
8
+
9
+ $url_link = Mage::getStoreConfig(Mage_Core_Model_Url::XML_PATH_SECURE_URL) . 'beezup/cron/orderlink';
10
+ $url_order = Mage::getStoreConfig(Mage_Core_Model_Url::XML_PATH_SECURE_URL) . 'beezup/cron/order';
11
+
12
+ $retorno = "<input type='radio' name='order-link' onclick='openOrderLink(1);' /> ".$this->__('Separated data')." &nbsp;&nbsp;&nbsp;<input type='radio' name='order-link' onclick='openOrderLink(2);' /> ".$this->__('go.beezup.com order link')." ";
13
+
14
+ $retorno .= "
15
+ <div id='info-order-link' style='display:none;margin-top:50px;'>
16
+ <table class='table'>
17
+ <tr>
18
+ <td>".$this->__('Account ID').":</td>
19
+ <td><input type='text' class='input-text' id='info-order-account' /></td>
20
+ </tr>
21
+ <tr>
22
+ <td>".$this->__('Marketplace ID').":</td>
23
+ <td><input type='text' class='input-text' id='info-order-marketplace' /></td>
24
+ </tr>
25
+ <tr>
26
+ <td>".$this->__('Order ID').":</td>
27
+ <td><input type='text' class='input-text' id='info-order-orderid' /></td>
28
+ </tr>
29
+ <tr>
30
+ <td></td>
31
+ <td><a class='form-button' style='float: right;' onclick='sendOrderInfo();'>".$this->__('Get Order')."</a></td>
32
+ </tr>
33
+ </table>
34
+ </div>
35
+
36
+ <div id='order-order-link' style='display:none;margin-top:50px;'>
37
+ <table class='table'>
38
+ <tr>
39
+ <td>".$this->__('go.beezup.com order link').":</td>
40
+ <td><input type='text' class='input-text' id='order-link-enlace' /></td>
41
+ </tr>
42
+ <tr>
43
+ <td></td>
44
+ <td><a class='form-button' style='float: right;' onclick='sendOrderLink();'>".$this->__('Get Order')."</a></td>
45
+ </tr>
46
+ </table>
47
+ </div>
48
+ ";
49
+
50
+ $retorno .= "
51
+ <script>
52
+ function openOrderLink(valor) {
53
+ if(valor == 1) {
54
+ document.getElementById('order-order-link').style.display = 'none';
55
+ document.getElementById('info-order-link').style.display = 'block';
56
+ } else {
57
+ document.getElementById('order-order-link').style.display = 'block';
58
+ document.getElementById('info-order-link').style.display = 'none';
59
+ }
60
+ }
61
+
62
+
63
+ function sendOrderInfo() {
64
+ var account = document.getElementById('info-order-account').value;
65
+ var marketplace = document.getElementById('info-order-marketplace').value;
66
+ var orderid = document.getElementById('info-order-orderid').value;
67
+ var orderlink = '".$url_order."?acount_id=' + account + '&marketplace=' + marketplace + '&order_id=' + orderid;
68
+ window.open(orderlink,'_blank');
69
+ }
70
+
71
+ function sendOrderLink() {
72
+ var link = document.getElementById('order-link-enlace').value;
73
+ var link = encodeURIComponent(link);
74
+ var orderlink = '".$url_link."?url=' + link;
75
+ window.open(orderlink,'_blank');
76
+ }
77
+
78
+ </script>
79
+ ";
80
+
81
+ return $retorno;
82
+ }
83
+
84
+
85
+
86
+ }
app/code/community/BeezUp/Block/Omstatus.php CHANGED
@@ -1,139 +1,139 @@
1
  <?php
2
- require_once dirname ( __FILE__ ) . "/../lib/KLogger.php";
3
- require_once dirname ( __FILE__ ) . "/../lib/bootstrap.php";
4
- require_once dirname ( __FILE__ ) . "/../lib/BeezupRepository.php";
5
- require_once dirname ( __FILE__ ) . "/../lib/BeezupMageOrders.php";
6
-
7
- class Beezup_Block_Omstatus extends Mage_core_block_text {
8
- protected $repository = null;
9
- protected $oOrderService;
10
- public $log = null;
11
- public $log2 = null;
12
- public $orderid = "";
13
- public $debug = false;
14
- private $account_id;
15
- private $marketplace_code;
16
- private $beezup_order_id;
17
-
18
-
19
- public function getLoader() {
20
- $dir = Mage::getModuleDir("etc", "BeezUp");
21
- $dir = str_replace("etc", "img", $dir);
22
- header('Content-Type: image/jpeg');
23
- readfile($dir."/ajax-loader.gif");
24
-
25
- }
26
-
27
-
28
- public function getBeezupBuyerAddress($order) {
29
  $add1=$order->getOrderBuyerAddressLine1();
30
  $add2=$order->getOrderBuyerAddressLine2();
31
  $add3=$order->getOrderBuyerAddressLine3();
32
  $retorno = "";
33
- if(!empty($add1)) {
34
- $retorno = $order->getOrderBuyerAddressLine1();
35
- }
36
- if(!empty($add2)) {
37
- if(empty($add1)) {
38
- $retorno .= $order->getOrderBuyerAddressLine2();
39
- } else {
40
- $retorno .= " - ". $order->getOrderBuyerAddressLine2();
41
- }
42
- }
43
  if(!empty($add3)){
44
- if(empty($add1) && empty($add2)) {
45
- $retorno .= $order->getOrderBuyerAddressLine3();
46
- } else {
47
- $retorno .= " - ". $order->getOrderBuyerAddressLine3();
48
- }
49
- }
50
- return $retorno;
51
- }
52
-
53
-
54
  public function getBeezupShippingAddress($order) {
55
  $add1 = $order->getOrderShippingAddressLine1();
56
  $add2 = $order->getOrderShippingAddressLine2();
57
  $add3=$order->getOrderBuyerAddressLine3();
58
- $retorno = "";
59
- if(!empty($add1 )) {
60
- $retorno = $order->getOrderShippingAddressLine1();
61
- }
62
- if(!empty($add2)) {
63
- if(empty($add1)) {
64
- $retorno .= $order->getOrderShippingAddressLine2();
65
- } else {
66
- $retorno .= " - ". $order->getOrderShippingAddressLine2();
67
- }
68
- }
69
  if(!empty($add3)){
70
  if(empty($add1) && empty($add2)) {
71
  $retorno .= $order->getOrderShippingAddressLine3();
72
- } else {
73
- $retorno .= " - ". $order->getOrderShippingAddressLine3();
74
- }
75
- }
76
- return $retorno;
77
- }
78
-
79
-
80
- public function checkEtagExists($etag) {
81
- $resource = Mage::getSingleton('core/resource');
82
- $readConnection = $resource->getConnection('core_read');
83
- $table = $resource->getTableName('sales/order_grid');
84
- $query = 'SELECT increment_id FROM ' . $table . ' WHERE beezup_etag = \''
85
- . $etag . '\' LIMIT 1';
86
- $order = $readConnection->fetchOne($query);
87
- if($order && !empty($order)) {
88
- return true;
89
  }
90
- return false;
91
-
92
- }
93
-
94
- public function loadMageOrder() {
95
- $Mageorder = Mage::getModel('sales/order')->load($this->orderid);
96
- if ($Mageorder->getId()) {
97
- return $Mageorder;
98
- } else {
99
- //we get order from marketplace orderid
100
- $orderInc = $this->checkMarketOrderExists($this->orderid);
101
- if($orderInc) {
102
- // if exists
103
- $Mageorder = Mage::getModel('sales/order')->loadByIncrementId($orderInc);
104
- if ($Mageorder->getId()) {
105
- return $Mageorder;
106
- }
107
- }
108
- }
109
-
110
-
111
- return false;
112
- }
113
-
114
-
115
- public function checkMarketOrderExists($orderid) {
116
- $resource = Mage::getSingleton('core/resource');
117
- $readConnection = $resource->getConnection('core_read');
118
- $table = $resource->getTableName('sales/order_grid');
119
- $query = 'SELECT increment_id FROM ' . $table . ' WHERE beezup_order = 1 and beezup_market_order_id = \''
120
- . $orderid . '\' LIMIT 1';
121
- $order = $readConnection->fetchOne($query);
122
-
123
- if($order && !empty($order) && $this->orderId !== "") {
124
- return $order;
125
  }
126
- return false;
127
-
128
- }
129
-
130
- public function resynOrder($orderId) {
131
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
132
  $this->orderid = $orderId;
133
  $oBeezupOrderResponse= $this->getBeezupOrderFromMage();
134
-
135
  $etag = $oBeezupOrderResponse->getETag();
136
-
137
  $final_order = $oBeezupOrderResponse->getResult();
138
  $order_status = $final_order->getOrderStatusBeezUPOrderStatus();
139
  $isPending = $final_order->getIsPendingSynchronization();
@@ -171,262 +171,262 @@ public function resynOrder($orderId) {
171
  $name_parts = explode(" ", $shipping_name);
172
  $shipping_first_name = array_shift( $name_parts);
173
  $shipping_last_name = implode(" ", $name_parts);
174
-
175
  $etag_exists = $this->checkEtagExists($etag);
176
-
177
- if(!$isPending && !$etag_exists ) {
178
- $order_data = array(
179
- "etag" => $etag,
180
- "order_status" => $order_status,
181
- "order_address" => $order_adress,
182
- "order_country" => $order_country,
183
- "order_country_iso" => $order_country_iso ,
184
- "order_address" => $order_address ,
185
- "order_postalCode" => $order_postalCode ,
186
- "order_customer" => $order_first_name ,
187
- "order_lastname" => $order_last_name ,
188
- "order_customer_email" => $order_customer_email ,
189
- "order_customer_phone" => $this->getPhone($order_customer_phone, $order_customer_mobile) ,
190
- "shipping_city" => $shipping_city ,
191
- "shipping_country" => $shipping_country ,
192
- "shipping_country_iso" => $shipping_country_iso ,
193
- "shipping_address" => $shipping_address ,
194
- "shipping_name" => $shipping_first_name ,
195
- "shipping_lastname" => $shipping_last_name ,
196
- "shipping_postalCode" => $shipping_postalCode ,
197
- "shipping_region" =>$shipping_region,
198
- "shipping_email" => $shipping_email ,
199
- "shipping_phone" => $this->getPhone($shipping_phone, $shipping_mobile) ,
200
- "shipping_company" => $shipping_company ,
201
- "order_totalPrice" => $order_totalPrice ,
202
- "order_shippingPrice" => $order_shippingPrice ,
203
- "order_city" => $order_city,
204
- "order_region" => $order_region,
205
  );
206
 
207
-
208
- $Mageorder = $this->loadMageOrder();
209
- if ($Mageorder) {
210
- //if order exists
211
- $this->updateEtag($etag);
212
- $this->updateBilling($Mageorder, $order_data );
213
- $this->updateBeezupInfoTab($Mageorder, $final_order, $order_data);
214
- $status1 = $Mageorder->getStatusLabel();
215
- $status = $this->getStatus($status1);
216
- if($status !== $order_status) {
217
- //if order exits and status has changed we update order status
218
- $this->setStatus( $order_status, $Mageorder);
219
- }
220
-
221
- $id_order = $Mageorder->getId();
222
- $BeezupMageOrder = new BeezupMageOrders($id_order);
223
- $BeezupMageOrder->setData(array("shipping" =>(float) $order_data['order_shippingPrice']));
224
- $BeezupMageOrder->updateShippingInfo();
225
-
226
- echo 1;
227
- } else {
228
-
229
- echo 2;
230
- }
231
-
232
-
233
- }
234
- else {
235
- if($isPending) {
236
- echo 3;
237
- } else {
238
- echo 2;
239
-
240
- }
241
- }
242
-
243
- }
244
-
245
-
246
-
247
  public function getStatus($status1) {
248
  $helper = Mage::helper('beezup');
249
- $retorno = "";
250
- $status = strtolower($status1);
251
-
252
- if($status == strtolower($helper->getConfig('beezup/marketplace/status_new') )) {
253
- $retorno = "New";
254
 
255
- } elseif($status == strtolower($helper->getConfig('beezup/marketplace/status_progress') ) ){
 
 
 
256
  $retorno = "InProgress";
257
-
258
-
259
- }
260
- elseif($status == strtolower($helper->getConfig('beezup/marketplace/status_aborted') )) {
261
-
262
  $retorno = "Aborted" ;
263
- }
264
- elseif($status == strtolower($helper->getConfig('beezup/marketplace/status_closed') )) {
265
- $retorno = "Closed";
266
-
267
- }
268
- elseif($status == strtolower($helper->getConfig('beezup/marketplace/status_cancelled')) ) {
269
-
270
- $retorno = "Canceled";
271
- }
272
- elseif($status == strtolower($helper->getConfig('beezup/marketplace/status_shipped') )) {
273
-
274
  $retorno = "Shipped";
275
- }
276
-
277
-
278
- return $retorno;
279
-
280
- }
281
-
282
- public function setStatus($status, $order) {
283
- $helper = Mage::helper('beezup');
284
- $retorno = "";
285
- $blnCancel = false;
286
- $blnHold = false;
287
- switch($status) {
288
- case "New" :
289
- $retorno = $helper->getConfig('beezup/marketplace/status_new');
290
- break;
291
- case "InProgress" :
292
- $retorno = $helper->getConfig('beezup/marketplace/status_progress');
293
  $this->payOrder($order);
294
- break;
295
- case "Aborted" :
296
- $retorno = $helper->getConfig('beezup/marketplace/status_aborted');
297
- $blnHold = true;
298
-
299
-
300
- break;
301
- case "Closed" :
302
- $blnCancel =true;
303
- $retorno = $helper->getConfig('beezup/marketplace/status_closed');
304
  $this->payOrder($order);
305
- break;
306
- case "Canceled" :
307
- $retorno = $helper->getConfig('beezup/marketplace/status_cancelled');
308
-
309
- break;
310
- case "Shipped" :
311
- $retorno = $helper->getConfig('beezup/marketplace/status_shipped');
312
  $this->payOrder($order);
313
- break;
314
-
315
- }
316
- $order->setData('state',$retorno);
317
- $order->setStatus($retorno);
318
- $history = $order->addStatusHistoryComment('Order was set to '.$retorno.' by Beezup.', false);
319
- $history->setIsCustomerNotified(false);
320
- $order->save();
321
- if($blnCancel) {
322
- $order->cancel()->save();
323
- }
324
- if($blnHold) {
325
- $order->hold()->save();
326
- }
327
 
328
- return $retorno;
329
-
330
- }
331
- public function getPhone($phone, $phone2) {
332
- $retorno = "";
333
- if(!empty($phone) && $phone !== "") {
334
- $retorno .= $phone;
 
 
 
 
 
 
 
 
335
  }
336
- if(!empty($phone2) && $phone2 !=="") {
337
- if(empty($phone) || $phone == "") {
338
- $retorno = $phone2;
339
-
340
- } else {
341
- $retorno .= " - ".$phone2;
 
 
 
 
 
 
342
  }
 
343
  }
344
- return $retorno;
345
- }
346
-
347
  public function payOrder($order) {
348
- try {
349
-
350
- if($order->canInvoice()) {
351
- $invoice = $order->prepareInvoice()
352
- ->setTransactionId($order->getId())
353
- ->addComment("Invoice created from Beezup.")
354
- ->register()
355
- ->pay();
356
- $transaction_save = Mage::getModel('core/resource_transaction')
357
- ->addObject($invoice)
358
- ->addObject($invoice->getOrder());
359
- $transaction_save->save();
360
-
 
 
 
 
 
361
  }
362
- }
363
- catch(Exception $e){
364
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
365
  }
366
- }
367
-
368
-
369
- public function updateBeezupInfoTab($order, $oLink, $data) {
370
- $beezup_last_modification_date = $oLink->getOrderLastModificationUtcDate();
371
- $beezup_last_modification_date = $beezup_last_modification_date->date;
372
- $beezup_marketplace_last_modification_date = $oLink->getOrderMarketPlaceLastModificationUtcDate();
373
- $beezup_marketplace_last_modification_date = $beezup_marketplace_last_modification_date->date;
374
- $beezup_comission = $oLink->getOrderTotalCommission()." ".$data['order_currency'];
375
- $tot_comm = $oLink->getOrderTotalCommission();
376
- if(empty($tot_comm ) || $tot_comm == 0) {
377
- $beezup_comission = 0;
378
- }
379
- $updateData = array("beezup_status" => $data['order_status'],
380
- "beezup_last_modification_date" => $beezup_last_modification_date,
381
- "beezup_marketplace_last_modification_date" => $beezup_marketplace_last_modification_date ,
382
- "beezup_total_paid" => $oLink->getOrderTotalPrice()." ".$data['order_currency'],
383
- "beezup_comission" => $beezup_comission,
384
- "beezup_marketplace_status" => $oLink->getOrderStatusMarketPlaceStatus());
385
- $orderId = $order->getId();
386
- $beezupMageOrder = new BeezupMageOrders($orderId);
387
- $beezupMageOrder->setData($updateData);
388
- $beezupMageOrder->updateBeezupInfo();
389
-
390
 
391
- }
392
-
393
-
394
-
395
- public function updateBilling($order, $data) {
396
-
397
-
398
- $addressData = array(
399
- 'billing_firstname' => ($data['order_customer']) ? $data['order_customer'] : "empty",
400
- 'billing_lastname' => ($data['order_lastname']) ? $data['order_lastname'] : "empty",
401
- 'billing_street' => ($data['order_address']) ? $data['order_address'] : "empty",
402
- 'billing_city' => ($data['order_city']) ? $data['order_city'] : "empty",
403
- 'billing_postcode' => ($data['order_postalCode']) ? $data['order_postalCode'] : "empty",
404
- 'billing_telephone' => ($data['order_customer_phone']) ? $data['order_customer_phone'] : "empty",
405
- 'billing_country_id' => ($data['order_country_iso']) ? $data['order_country_iso'] : "empty",
406
- 'billing_region_id' => ($data['order_region ']) ? substr($data['order_region '], 0,2) : "EM",
407
  'shipping_firstname' => ($data['shipping_name']) ? $data['shipping_name'] : "empty",
408
- 'shipping_lastname' => ($data['shipping_lastname']) ? $data['shipping_lastname'] : "empty",
409
- 'shipping_street' => ($data['shipping_address']) ? $data['shipping_address'] : "empty",
410
- 'shipping_city' => ($data['shipping_city']) ? $data['shipping_city'] : "empty",
411
- 'shipping_postcode' => ($data['shipping_postalCode']) ? $data['shipping_postalCode'] : "empty",
412
- 'shipping_telephone' => ($data['shipping_phone']) ? $data['shipping_phone'] : "empty",
413
- 'shipping_country_id' => ($data['shipping_country_iso']) ? $data['shipping_country_iso'] : "empty",
414
- 'shipping_region_id' => ($data['shipping_region']) ? substr($data['shipping_region'], 0, 2) : "EM" // id from directory_country_region table
415
- );
416
-
417
- $shippingData = array(
418
-
419
- );
420
- // Get the id of the orders shipping address
421
- $orderId = $order->getId();
422
- $beezupMageOrder = new BeezupMageOrders($orderId);
423
- $beezupMageOrder->setData($addressData);
424
- $beezupMageOrder->updateAdresses();
425
- }
426
-
427
-
428
-
429
-
430
  public function updateEtag($etag) {
431
  $resource = Mage::getSingleton('core/resource');
432
  $writeConnection = $resource->getConnection('core_write');
@@ -435,19 +435,19 @@ $addressData = array(
435
  $writeConnection->query($query);
436
 
437
  }
438
-
439
-
440
- public function changeOrder($aData) {
441
-
442
- $errmsg = "";
443
- $this->orderid = $aData['order_id'];
444
- $aResult = array('errors' => array(), 'warnings' => array(), 'infos' => array(),'successes' => array());
445
-
446
  if (!isset($aData['order_id']) || !is_numeric($aData['order_id'])){
447
  $errmsg .= "ERROR: ".Mage::helper('beezup')->__('Invalid order id')."<br>";
448
  echo $errmsg;
449
  }
450
-
451
  $oBeezupOrderResponse= $this->getBeezupOrderFromMage();
452
  $oBeezupOrder = $oBeezupOrderResponse->getResult();
453
 
@@ -456,47 +456,47 @@ public function changeOrder($aData) {
456
 
457
  echo $errmsg;
458
  }
459
-
460
  if (!isset($aData['action_id'])){
461
  $errmsg .= "ERROR: ".Mage::helper('beezup')->__('No action id')."<br>";
462
-
463
- echo $errmsg;
464
  }
465
-
466
  $oLink = $oBeezupOrder->getTransitionLinkByRel($aData['action_id']);
467
-
468
  if (!$oLink){
469
-
470
  $errmsg .= "ERROR: ".Mage::helper('beezup')->__('Invalid action')."<br>";
471
  }
472
  $aParams = array(
473
- 'TestMode' => $this->isTestModeActivated() ? 1 : 0,
474
- 'userName' => $aData['adminUser']
475
  );
476
-
477
  if ($oLink){
478
-
479
 
480
  list($bResult, $oResult) = $this->getOrderService()->changeOrder($oLink, $aParams, $aData);
481
-
482
  if ($bResult){
483
  $errmsg .= "SUCCESS: ". Mage::helper('beezup')->__('Order update well executed and is currently resyncing')."<br>";
484
  $aResult['aResult'] = true;
485
  $oCachedOrder = $this->getBeezupOrderFromMage();
486
 
487
  /**
488
- * @var BeezupOMOrderResult
489
- */
490
  $oBeezupOrderResult = $oCachedOrder->getResult();
491
-
492
  $oBeezupOrderResult->setIsPendingSynchronization(true);
493
-
494
- } else {
495
  // how to know what happened?
496
 
497
 
498
  if ($oResult && $oResult->getInfo()){
499
-
500
 
501
  foreach ($oResult->getInfo()->getErrors() as $oError){
502
  // ie we have 404 because of bad query params, we don't need to display those 404
@@ -505,196 +505,196 @@ public function changeOrder($aData) {
505
  }
506
  $errmsg .= "ERROR: ".$oError->getCode() .' : ' . $oError->getMessage()."<br>";
507
  }
508
- } else {
509
  $errmsg .= "ERROR: ". Mage::helper('beezup')->__('Unable to update')."<br>";
510
  }
511
  }
512
  }
513
 
514
-
515
 
516
- echo $errmsg;
517
-
518
-
519
- }
520
-
521
- public function isTestModeActivated() {
522
- return false;
523
- }
524
-
525
- //function to get beezup info list
526
- public function getInfo($order_id) {
527
- $this->orderid = $order_id;
528
- try {
529
- $order = $this->getBeezupOrderFromMage();
530
- if ($order && $order->getResult()) {
531
- $order_result = $order->getResult();
532
- $beezup_infos = $order? $order->getInfo()->getInformations() : array();
533
- $order_actions = $this->getOrderActions($order_result );
534
- /*
535
- echo "<pre>";
536
- print_r($order_actions);
537
-
538
- echo "</pre>";
539
- */
540
- echo "<label>Status</label><br>";
541
- echo "<select id='status_value'>";
542
- foreach($order_actions as $action) {
543
-
544
- echo "<option value='".$action['id']."'>".$action['translated_name']."</option>";
545
- echo "<input type='hidden' id='lovs_".$action['id']."' value='".$action['lovs']."' />";
546
- }
547
-
548
- echo "</select>";
549
- echo "<button class='button' onclick='changeStatus();'>Change Status</button>";
550
-
551
- echo ' <div id="closed"></div>
552
 
553
- <div class="popup-wrapper" id="popup">
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
554
  <div class="popup-container"><!-- Popup Contents, just modify with your own -->
555
-
556
- <h2>Update Order Status</h2>
557
- <hr>
558
- <div class="input-group"><div id="contenido-form"></div>';
559
-
560
-
561
- echo '<br><button class="button">Update</button>
562
- </div>
563
-
564
- <a class="popup-close" href="#closed">X</a>
565
  </div>
566
- </div>
567
- ';
568
-
569
-
 
 
 
 
 
 
570
  }
571
- } catch (Exception $ex ) {
572
- die($ex->getMessage());
573
  }
574
 
575
 
576
- }
577
-
578
-
579
 
580
-
581
-
582
- public function updateOrder($order_id) {
583
- $this->orderid = $order_id;
584
 
585
- }
586
-
587
-
588
- public function getBeezupOrderFromMage() {
589
- $order = $this->getMageOrder();
590
- if($order) {
 
 
 
 
591
  $oOrderIdentifier = $this->getBeezupOrderId();
592
  $oBeezupOMOrderResponse = $this->getOrderService()->getOrder($oOrderIdentifier);
593
  if ($oBeezupOMOrderResponse && $oBeezupOMOrderResponse->getResult()){
594
  return $oBeezupOMOrderResponse;
595
  }
596
-
 
 
597
  }
598
- return false;
599
- }
600
-
601
-
602
- public function getMageOrder() {
603
- $resource = Mage::getSingleton('core/resource');
604
- $readConnection = $resource->getConnection('core_read');
605
- $table = $resource->getTableName('sales/order_grid');
606
- $query = 'SELECT * FROM ' . $table . ' WHERE entity_id = \''
607
- . $this->orderid . '\' ';
608
- $order = $readConnection->fetchAll($query);
609
- if(!empty($order)) {
610
- $order = $order[0];
611
- $this->account_id= $order['beezup_name'];
612
- $this->marketplace_code = $order['beezup_marketplace'];
613
- $this->beezup_order_id = $order['beezup_order_id'];
614
- return $order;
615
  }
616
- return false;
617
- }
618
-
619
-
620
  public function getBeezupOrderId(){
621
  $oIdentifier = new BeezupOMOrderIdentifier();
622
  $oIdentifier
623
- ->setAccountId($this->account_id)
624
- ->setMarketplaceTechnicalCode($this->marketplace_code)
625
- ->setBeezupOrderUUID($this->beezup_order_id);
626
  return $oIdentifier;
627
  }
628
-
629
-
630
  /**
631
- * @return BeezupOMOrderService
632
- */
633
  public function getOrderService(){
634
  if ($this->oOrderService === null){
635
  $this->oOrderService = $this->createOrderService();
636
- // enchufamos debug mode, esta activado? false true $this->oOrderService->setDebugMode(false);
637
  }
638
  return $this->oOrderService;
639
  }
640
-
641
  /**
642
- * @return BeezupOMOrderService
643
- */
644
  protected function createOrderService(){
645
-
646
  return new BeezupOMOrderService($this->createRepository() );
647
  }
648
 
649
  protected function createRepository() {
650
  if ($this->repository == null) {
651
- $this->repository = new BeezupRepository();
652
  }
653
- return $this->repository;
654
 
655
  }
656
 
657
 
658
- /**
659
- * Returns disponible order actions
660
- * @param unknown_type $oBeezupOrder
661
- * @param unknown_type $oPsOrder
662
- * @return multitype:|multitype:multitype:string NULL unknown
663
- */
664
  public function getOrderActions($oBeezupOrder = null, $oPsOrder = null){
665
  $aResult = array();
666
  if (!$oBeezupOrder || !($oBeezupOrder instanceof BeezupOMOrderResult)) {
667
  return $aResult;
668
  }
669
-
670
- // $aLovValues = $this->getOrderService()->getLovValues('OrderChangeBusinessOperationType', Context::getContext()->language->iso_code);
671
 
672
  foreach ($oBeezupOrder->getTransitionLinks() as $oLink){
673
-
674
  $aResult[] = array(
675
- 'link' => $oLink,
676
- 'href' => $oLink->getHref(),
677
- 'id' => $oLink->getRel(),
678
- 'name' => $oLink->getRel(),
679
- 'translated_name' => $oLink->getRel(),
680
- 'fields' => json_encode($oLink->toArray()),
681
- 'lovs' => json_encode($this->getOrderService()->getLOVValuesForParams($oLink))
682
- /*,
683
  'values' => json_encode($this->getFieldsValues($oLink, $oPsOrder)),
684
- 'info' => json_encode($this->getTransitionLinkInfo($oLink))*/
685
  );
686
- /*
687
- echo "<pre>";
688
- print_r(json_decode($aResult[0]['lovs']));
689
- echo "</pre>";
690
-
691
- echo "<pre>";
692
- print_r(json_decode($aResult[0]['fields']));
693
- echo "</pre>";
694
- */
695
  }
696
 
697
  return $aResult;
698
  }
699
-
700
- }
1
  <?php
2
+ require_once dirname ( __FILE__ ) . "/../lib/KLogger.php";
3
+ require_once dirname ( __FILE__ ) . "/../lib/bootstrap.php";
4
+ require_once dirname ( __FILE__ ) . "/../lib/BeezupRepository.php";
5
+ require_once dirname ( __FILE__ ) . "/../lib/BeezupMageOrders.php";
6
+
7
+ class Beezup_Block_Omstatus extends Mage_core_block_text {
8
+ protected $repository = null;
9
+ protected $oOrderService;
10
+ public $log = null;
11
+ public $log2 = null;
12
+ public $orderid = "";
13
+ public $debug = false;
14
+ private $account_id;
15
+ private $marketplace_code;
16
+ private $beezup_order_id;
17
+
18
+
19
+ public function getLoader() {
20
+ $dir = Mage::getModuleDir("etc", "BeezUp");
21
+ $dir = str_replace("etc", "img", $dir);
22
+ header('Content-Type: image/jpeg');
23
+ readfile($dir."/ajax-loader.gif");
24
+
25
+ }
26
+
27
+
28
+ public function getBeezupBuyerAddress($order) {
29
  $add1=$order->getOrderBuyerAddressLine1();
30
  $add2=$order->getOrderBuyerAddressLine2();
31
  $add3=$order->getOrderBuyerAddressLine3();
32
  $retorno = "";
33
+ if(!empty($add1)) {
34
+ $retorno = $order->getOrderBuyerAddressLine1();
35
+ }
36
+ if(!empty($add2)) {
37
+ if(empty($add1)) {
38
+ $retorno .= $order->getOrderBuyerAddressLine2();
39
+ } else {
40
+ $retorno .= " - ". $order->getOrderBuyerAddressLine2();
41
+ }
42
+ }
43
  if(!empty($add3)){
44
+ if(empty($add1) && empty($add2)) {
45
+ $retorno .= $order->getOrderBuyerAddressLine3();
46
+ } else {
47
+ $retorno .= " - ". $order->getOrderBuyerAddressLine3();
48
+ }
49
+ }
50
+ return $retorno;
51
+ }
52
+
53
+
54
  public function getBeezupShippingAddress($order) {
55
  $add1 = $order->getOrderShippingAddressLine1();
56
  $add2 = $order->getOrderShippingAddressLine2();
57
  $add3=$order->getOrderBuyerAddressLine3();
58
+ $retorno = "";
59
+ if(!empty($add1 )) {
60
+ $retorno = $order->getOrderShippingAddressLine1();
61
+ }
62
+ if(!empty($add2)) {
63
+ if(empty($add1)) {
64
+ $retorno .= $order->getOrderShippingAddressLine2();
65
+ } else {
66
+ $retorno .= " - ". $order->getOrderShippingAddressLine2();
67
+ }
68
+ }
69
  if(!empty($add3)){
70
  if(empty($add1) && empty($add2)) {
71
  $retorno .= $order->getOrderShippingAddressLine3();
72
+ } else {
73
+ $retorno .= " - ". $order->getOrderShippingAddressLine3();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
74
  }
75
+ }
76
+ return $retorno;
77
+ }
78
+
79
+
80
+ public function checkEtagExists($etag) {
81
+ $resource = Mage::getSingleton('core/resource');
82
+ $readConnection = $resource->getConnection('core_read');
83
+ $table = $resource->getTableName('sales/order_grid');
84
+ $query = 'SELECT increment_id FROM ' . $table . ' WHERE beezup_etag = \''
85
+ . $etag . '\' LIMIT 1';
86
+ $order = $readConnection->fetchOne($query);
87
+ if($order && !empty($order)) {
88
+ return true;
89
+ }
90
+ return false;
91
+
92
+ }
93
+
94
+ public function loadMageOrder() {
95
+ $Mageorder = Mage::getModel('sales/order')->load($this->orderid);
96
+ if ($Mageorder->getId()) {
97
+ return $Mageorder;
98
+ } else {
99
+ //we get order from marketplace orderid
100
+ $orderInc = $this->checkMarketOrderExists($this->orderid);
101
+ if($orderInc) {
102
+ // if exists
103
+ $Mageorder = Mage::getModel('sales/order')->loadByIncrementId($orderInc);
104
+ if ($Mageorder->getId()) {
105
+ return $Mageorder;
106
+ }
 
 
 
107
  }
108
+ }
109
+
110
+
111
+ return false;
112
+ }
113
+
114
+
115
+ public function checkMarketOrderExists($orderid) {
116
+ $resource = Mage::getSingleton('core/resource');
117
+ $readConnection = $resource->getConnection('core_read');
118
+ $table = $resource->getTableName('sales/order_grid');
119
+ $query = 'SELECT increment_id FROM ' . $table . ' WHERE beezup_order = 1 and beezup_market_order_id = \''
120
+ . $orderid . '\' LIMIT 1';
121
+ $order = $readConnection->fetchOne($query);
122
+
123
+ if($order && !empty($order) && $this->orderId !== "") {
124
+ return $order;
125
+ }
126
+ return false;
127
+
128
+ }
129
+
130
+ public function resynOrder($orderId) {
131
+
132
  $this->orderid = $orderId;
133
  $oBeezupOrderResponse= $this->getBeezupOrderFromMage();
134
+
135
  $etag = $oBeezupOrderResponse->getETag();
136
+
137
  $final_order = $oBeezupOrderResponse->getResult();
138
  $order_status = $final_order->getOrderStatusBeezUPOrderStatus();
139
  $isPending = $final_order->getIsPendingSynchronization();
171
  $name_parts = explode(" ", $shipping_name);
172
  $shipping_first_name = array_shift( $name_parts);
173
  $shipping_last_name = implode(" ", $name_parts);
174
+
175
  $etag_exists = $this->checkEtagExists($etag);
176
+
177
+ if(!$isPending && !$etag_exists ) {
178
+ $order_data = array(
179
+ "etag" => $etag,
180
+ "order_status" => $order_status,
181
+ "order_address" => $order_adress,
182
+ "order_country" => $order_country,
183
+ "order_country_iso" => $order_country_iso ,
184
+ "order_address" => $order_address ,
185
+ "order_postalCode" => $order_postalCode ,
186
+ "order_customer" => $order_first_name ,
187
+ "order_lastname" => $order_last_name ,
188
+ "order_customer_email" => $order_customer_email ,
189
+ "order_customer_phone" => $this->getPhone($order_customer_phone, $order_customer_mobile) ,
190
+ "shipping_city" => $shipping_city ,
191
+ "shipping_country" => $shipping_country ,
192
+ "shipping_country_iso" => $shipping_country_iso ,
193
+ "shipping_address" => $shipping_address ,
194
+ "shipping_name" => $shipping_first_name ,
195
+ "shipping_lastname" => $shipping_last_name ,
196
+ "shipping_postalCode" => $shipping_postalCode ,
197
+ "shipping_region" =>$shipping_region,
198
+ "shipping_email" => $shipping_email ,
199
+ "shipping_phone" => $this->getPhone($shipping_phone, $shipping_mobile) ,
200
+ "shipping_company" => $shipping_company ,
201
+ "order_totalPrice" => $order_totalPrice ,
202
+ "order_shippingPrice" => $order_shippingPrice ,
203
+ "order_city" => $order_city,
204
+ "order_region" => $order_region,
205
  );
206
 
207
+
208
+ $Mageorder = $this->loadMageOrder();
209
+ if ($Mageorder) {
210
+ //if order exists
211
+ $this->updateEtag($etag);
212
+ $this->updateBilling($Mageorder, $order_data );
213
+ $this->updateBeezupInfoTab($Mageorder, $final_order, $order_data);
214
+ $status1 = $Mageorder->getStatusLabel();
215
+ $status = $this->getStatus($status1);
216
+ if($status !== $order_status) {
217
+ //if order exits and status has changed we update order status
218
+ $this->setStatus( $order_status, $Mageorder);
219
+ }
220
+
221
+ $id_order = $Mageorder->getId();
222
+ $BeezupMageOrder = new BeezupMageOrders($id_order);
223
+ $BeezupMageOrder->setData(array("shipping" =>(float) $order_data['order_shippingPrice']));
224
+ $BeezupMageOrder->updateShippingInfo();
225
+
226
+ echo 1;
227
+ } else {
228
+
229
+ echo 2;
230
+ }
231
+
232
+
233
+ }
234
+ else {
235
+ if($isPending) {
236
+ echo 3;
237
+ } else {
238
+ echo 2;
239
+
240
+ }
241
+ }
242
+
243
+ }
244
+
245
+
246
+
247
  public function getStatus($status1) {
248
  $helper = Mage::helper('beezup');
249
+ $retorno = "";
250
+ $status = strtolower($status1);
 
 
 
251
 
252
+ if($status == strtolower($helper->getConfig('beezup/marketplace/status_new') )) {
253
+ $retorno = "New";
254
+
255
+ } elseif($status == strtolower($helper->getConfig('beezup/marketplace/status_progress') ) ){
256
  $retorno = "InProgress";
257
+
258
+
259
+ }
260
+ elseif($status == strtolower($helper->getConfig('beezup/marketplace/status_aborted') )) {
261
+
262
  $retorno = "Aborted" ;
263
+ }
264
+ elseif($status == strtolower($helper->getConfig('beezup/marketplace/status_closed') )) {
265
+ $retorno = "Closed";
266
+
267
+ }
268
+ elseif($status == strtolower($helper->getConfig('beezup/marketplace/status_cancelled')) ) {
269
+
270
+ $retorno = "Canceled";
271
+ }
272
+ elseif($status == strtolower($helper->getConfig('beezup/marketplace/status_shipped') )) {
273
+
274
  $retorno = "Shipped";
275
+ }
276
+
277
+
278
+ return $retorno;
279
+
280
+ }
281
+
282
+ public function setStatus($status, $order) {
283
+ $helper = Mage::helper('beezup');
284
+ $retorno = "";
285
+ $blnCancel = false;
286
+ $blnHold = false;
287
+ switch($status) {
288
+ case "New" :
289
+ $retorno = $helper->getConfig('beezup/marketplace/status_new');
290
+ break;
291
+ case "InProgress" :
292
+ $retorno = $helper->getConfig('beezup/marketplace/status_progress');
293
  $this->payOrder($order);
294
+ break;
295
+ case "Aborted" :
296
+ $retorno = $helper->getConfig('beezup/marketplace/status_aborted');
297
+ $blnHold = true;
298
+
299
+
300
+ break;
301
+ case "Closed" :
302
+ $blnCancel =true;
303
+ $retorno = $helper->getConfig('beezup/marketplace/status_closed');
304
  $this->payOrder($order);
305
+ break;
306
+ case "Canceled" :
307
+ $retorno = $helper->getConfig('beezup/marketplace/status_cancelled');
308
+
309
+ break;
310
+ case "Shipped" :
311
+ $retorno = $helper->getConfig('beezup/marketplace/status_shipped');
312
  $this->payOrder($order);
313
+ break;
 
 
 
 
 
 
 
 
 
 
 
 
 
314
 
315
+ }
316
+ $order->setData('state',$retorno);
317
+ $order->setStatus($retorno);
318
+ $history = $order->addStatusHistoryComment('Order was set to '.$retorno.' by Beezup.', false);
319
+ $history->setIsCustomerNotified(false);
320
+ $order->save();
321
+ if($blnCancel) {
322
+ $order->cancel()->save();
323
+ }
324
+ if($blnHold) {
325
+ $order->hold()->save();
326
+ }
327
+
328
+ return $retorno;
329
+
330
  }
331
+ public function getPhone($phone, $phone2) {
332
+ $retorno = "";
333
+ if(!empty($phone) && $phone !== "") {
334
+ $retorno .= $phone;
335
+ }
336
+ if(!empty($phone2) && $phone2 !=="") {
337
+ if(empty($phone) || $phone == "") {
338
+ $retorno = $phone2;
339
+
340
+ } else {
341
+ $retorno .= " - ".$phone2;
342
+ }
343
  }
344
+ return $retorno;
345
  }
346
+
 
 
347
  public function payOrder($order) {
348
+ try {
349
+
350
+ if($order->canInvoice()) {
351
+ $invoice = $order->prepareInvoice()
352
+ ->setTransactionId($order->getId())
353
+ ->addComment("Invoice created from Beezup.")
354
+ ->register()
355
+ ->pay();
356
+ $transaction_save = Mage::getModel('core/resource_transaction')
357
+ ->addObject($invoice)
358
+ ->addObject($invoice->getOrder());
359
+ $transaction_save->save();
360
+
361
+ }
362
+ }
363
+ catch(Exception $e){
364
+
365
+ }
366
  }
367
+
368
+
369
+ public function updateBeezupInfoTab($order, $oLink, $data) {
370
+ $beezup_last_modification_date = $oLink->getOrderLastModificationUtcDate();
371
+ $beezup_last_modification_date = $beezup_last_modification_date->date;
372
+ $beezup_marketplace_last_modification_date = $oLink->getOrderMarketPlaceLastModificationUtcDate();
373
+ $beezup_marketplace_last_modification_date = $beezup_marketplace_last_modification_date->date;
374
+ $beezup_comission = $oLink->getOrderTotalCommission()." ".$data['order_currency'];
375
+ $tot_comm = $oLink->getOrderTotalCommission();
376
+ if(empty($tot_comm ) || $tot_comm == 0) {
377
+ $beezup_comission = 0;
378
+ }
379
+ $updateData = array("beezup_status" => $data['order_status'],
380
+ "beezup_last_modification_date" => $beezup_last_modification_date,
381
+ "beezup_marketplace_last_modification_date" => $beezup_marketplace_last_modification_date ,
382
+ "beezup_total_paid" => $oLink->getOrderTotalPrice()." ".$data['order_currency'],
383
+ "beezup_comission" => $beezup_comission,
384
+ "beezup_marketplace_status" => $oLink->getOrderStatusMarketPlaceStatus());
385
+ $orderId = $order->getId();
386
+ $beezupMageOrder = new BeezupMageOrders($orderId);
387
+ $beezupMageOrder->setData($updateData);
388
+ $beezupMageOrder->updateBeezupInfo();
389
+
390
+
391
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
392
 
393
+
394
+
395
+ public function updateBilling($order, $data) {
396
+
397
+
398
+ $addressData = array(
399
+ 'billing_firstname' => ($data['order_customer']) ? $data['order_customer'] : "empty",
400
+ 'billing_lastname' => ($data['order_lastname']) ? $data['order_lastname'] : "empty",
401
+ 'billing_street' => ($data['order_address']) ? $data['order_address'] : "empty",
402
+ 'billing_city' => ($data['order_city']) ? $data['order_city'] : "empty",
403
+ 'billing_postcode' => ($data['order_postalCode']) ? $data['order_postalCode'] : "empty",
404
+ 'billing_telephone' => ($data['order_customer_phone']) ? $data['order_customer_phone'] : "empty",
405
+ 'billing_country_id' => ($data['order_country_iso']) ? $data['order_country_iso'] : "empty",
406
+ 'billing_region_id' => ($data['order_region ']) ? substr($data['order_region '], 0,2) : "EM",
 
 
407
  'shipping_firstname' => ($data['shipping_name']) ? $data['shipping_name'] : "empty",
408
+ 'shipping_lastname' => ($data['shipping_lastname']) ? $data['shipping_lastname'] : "empty",
409
+ 'shipping_street' => ($data['shipping_address']) ? $data['shipping_address'] : "empty",
410
+ 'shipping_city' => ($data['shipping_city']) ? $data['shipping_city'] : "empty",
411
+ 'shipping_postcode' => ($data['shipping_postalCode']) ? $data['shipping_postalCode'] : "empty",
412
+ 'shipping_telephone' => ($data['shipping_phone']) ? $data['shipping_phone'] : "empty",
413
+ 'shipping_country_id' => ($data['shipping_country_iso']) ? $data['shipping_country_iso'] : "empty",
414
+ 'shipping_region_id' => ($data['shipping_region']) ? substr($data['shipping_region'], 0, 2) : "EM" // id from directory_country_region table
415
+ );
416
+
417
+ $shippingData = array(
418
+
419
+ );
420
+ // Get the id of the orders shipping address
421
+ $orderId = $order->getId();
422
+ $beezupMageOrder = new BeezupMageOrders($orderId);
423
+ $beezupMageOrder->setData($addressData);
424
+ $beezupMageOrder->updateAdresses();
425
+ }
426
+
427
+
428
+
429
+
430
  public function updateEtag($etag) {
431
  $resource = Mage::getSingleton('core/resource');
432
  $writeConnection = $resource->getConnection('core_write');
435
  $writeConnection->query($query);
436
 
437
  }
438
+
439
+
440
+ public function changeOrder($aData) {
441
+
442
+ $errmsg = "";
443
+ $this->orderid = $aData['order_id'];
444
+ $aResult = array('errors' => array(), 'warnings' => array(), 'infos' => array(),'successes' => array());
445
+
446
  if (!isset($aData['order_id']) || !is_numeric($aData['order_id'])){
447
  $errmsg .= "ERROR: ".Mage::helper('beezup')->__('Invalid order id')."<br>";
448
  echo $errmsg;
449
  }
450
+
451
  $oBeezupOrderResponse= $this->getBeezupOrderFromMage();
452
  $oBeezupOrder = $oBeezupOrderResponse->getResult();
453
 
456
 
457
  echo $errmsg;
458
  }
459
+
460
  if (!isset($aData['action_id'])){
461
  $errmsg .= "ERROR: ".Mage::helper('beezup')->__('No action id')."<br>";
462
+
463
+ echo $errmsg;
464
  }
465
+
466
  $oLink = $oBeezupOrder->getTransitionLinkByRel($aData['action_id']);
467
+
468
  if (!$oLink){
469
+
470
  $errmsg .= "ERROR: ".Mage::helper('beezup')->__('Invalid action')."<br>";
471
  }
472
  $aParams = array(
473
+ 'TestMode' => $this->isTestModeActivated() ? 1 : 0,
474
+ 'userName' => $aData['adminUser']
475
  );
476
+
477
  if ($oLink){
478
+
479
 
480
  list($bResult, $oResult) = $this->getOrderService()->changeOrder($oLink, $aParams, $aData);
481
+
482
  if ($bResult){
483
  $errmsg .= "SUCCESS: ". Mage::helper('beezup')->__('Order update well executed and is currently resyncing')."<br>";
484
  $aResult['aResult'] = true;
485
  $oCachedOrder = $this->getBeezupOrderFromMage();
486
 
487
  /**
488
+ * @var BeezupOMOrderResult
489
+ */
490
  $oBeezupOrderResult = $oCachedOrder->getResult();
491
+
492
  $oBeezupOrderResult->setIsPendingSynchronization(true);
493
+
494
+ } else {
495
  // how to know what happened?
496
 
497
 
498
  if ($oResult && $oResult->getInfo()){
499
+
500
 
501
  foreach ($oResult->getInfo()->getErrors() as $oError){
502
  // ie we have 404 because of bad query params, we don't need to display those 404
505
  }
506
  $errmsg .= "ERROR: ".$oError->getCode() .' : ' . $oError->getMessage()."<br>";
507
  }
508
+ } else {
509
  $errmsg .= "ERROR: ". Mage::helper('beezup')->__('Unable to update')."<br>";
510
  }
511
  }
512
  }
513
 
 
514
 
515
+
516
+ echo $errmsg;
517
+
518
+
519
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
520
 
521
+ public function isTestModeActivated() {
522
+ return false;
523
+ }
524
+
525
+ //function to get beezup info list
526
+ public function getInfo($order_id) {
527
+ $this->orderid = $order_id;
528
+ try {
529
+ $order = $this->getBeezupOrderFromMage();
530
+ if ($order && $order->getResult()) {
531
+ $order_result = $order->getResult();
532
+ $beezup_infos = $order? $order->getInfo()->getInformations() : array();
533
+ $order_actions = $this->getOrderActions($order_result );
534
+ /*
535
+ echo "<pre>";
536
+ print_r($order_actions);
537
+
538
+ echo "</pre>";
539
+ */
540
+ echo "<label>Status</label><br>";
541
+ echo "<select id='status_value'>";
542
+ foreach($order_actions as $action) {
543
+
544
+ echo "<option value='".$action['id']."'>".$action['translated_name']."</option>";
545
+ echo "<input type='hidden' id='lovs_".$action['id']."' value='".$action['lovs']."' />";
546
+ }
547
+
548
+ echo "</select>";
549
+ echo "<button class='button' onclick='changeStatus();'>Change Status</button>";
550
+
551
+ echo ' <div id="closed"></div>
552
+
553
+ <div class="popup-wrapper" id="popup">
554
  <div class="popup-container"><!-- Popup Contents, just modify with your own -->
555
+
556
+ <h2>Update Order Status</h2>
557
+ <hr>
558
+ <div class="input-group"><div id="contenido-form"></div>';
559
+
560
+
561
+ echo '<br><button class="button">Update</button>
 
 
 
562
  </div>
563
+
564
+ <a class="popup-close" href="#closed">X</a>
565
+ </div>
566
+ </div>
567
+ ';
568
+
569
+
570
+ }
571
+ } catch (Exception $ex ) {
572
+ die($ex->getMessage());
573
  }
574
+
575
+
576
  }
577
 
578
 
 
 
 
579
 
 
 
 
 
580
 
581
+
582
+ public function updateOrder($order_id) {
583
+ $this->orderid = $order_id;
584
+
585
+ }
586
+
587
+
588
+ public function getBeezupOrderFromMage() {
589
+ $order = $this->getMageOrder();
590
+ if($order) {
591
  $oOrderIdentifier = $this->getBeezupOrderId();
592
  $oBeezupOMOrderResponse = $this->getOrderService()->getOrder($oOrderIdentifier);
593
  if ($oBeezupOMOrderResponse && $oBeezupOMOrderResponse->getResult()){
594
  return $oBeezupOMOrderResponse;
595
  }
596
+
597
+ }
598
+ return false;
599
  }
600
+
601
+
602
+ public function getMageOrder() {
603
+ $resource = Mage::getSingleton('core/resource');
604
+ $readConnection = $resource->getConnection('core_read');
605
+ $table = $resource->getTableName('sales/order_grid');
606
+ $query = 'SELECT * FROM ' . $table . ' WHERE entity_id = \''
607
+ . $this->orderid . '\' ';
608
+ $order = $readConnection->fetchAll($query);
609
+ if(!empty($order)) {
610
+ $order = $order[0];
611
+ $this->account_id= $order['beezup_name'];
612
+ $this->marketplace_code = $order['beezup_marketplace'];
613
+ $this->beezup_order_id = $order['beezup_order_id'];
614
+ return $order;
615
+ }
616
+ return false;
617
  }
618
+
619
+
 
 
620
  public function getBeezupOrderId(){
621
  $oIdentifier = new BeezupOMOrderIdentifier();
622
  $oIdentifier
623
+ ->setAccountId($this->account_id)
624
+ ->setMarketplaceTechnicalCode($this->marketplace_code)
625
+ ->setBeezupOrderUUID($this->beezup_order_id);
626
  return $oIdentifier;
627
  }
628
+
629
+
630
  /**
631
+ * @return BeezupOMOrderService
632
+ */
633
  public function getOrderService(){
634
  if ($this->oOrderService === null){
635
  $this->oOrderService = $this->createOrderService();
636
+ // enchufamos debug mode, esta activado? false true $this->oOrderService->setDebugMode(false);
637
  }
638
  return $this->oOrderService;
639
  }
640
+
641
  /**
642
+ * @return BeezupOMOrderService
643
+ */
644
  protected function createOrderService(){
645
+
646
  return new BeezupOMOrderService($this->createRepository() );
647
  }
648
 
649
  protected function createRepository() {
650
  if ($this->repository == null) {
651
+ $this->repository = new BeezupRepository();
652
  }
653
+ return $this->repository;
654
 
655
  }
656
 
657
 
658
+ /**
659
+ * Returns disponible order actions
660
+ * @param unknown_type $oBeezupOrder
661
+ * @param unknown_type $oPsOrder
662
+ * @return multitype:|multitype:multitype:string NULL unknown
663
+ */
664
  public function getOrderActions($oBeezupOrder = null, $oPsOrder = null){
665
  $aResult = array();
666
  if (!$oBeezupOrder || !($oBeezupOrder instanceof BeezupOMOrderResult)) {
667
  return $aResult;
668
  }
669
+
670
+ // $aLovValues = $this->getOrderService()->getLovValues('OrderChangeBusinessOperationType', Context::getContext()->language->iso_code);
671
 
672
  foreach ($oBeezupOrder->getTransitionLinks() as $oLink){
673
+
674
  $aResult[] = array(
675
+ 'link' => $oLink,
676
+ 'href' => $oLink->getHref(),
677
+ 'id' => $oLink->getRel(),
678
+ 'name' => $oLink->getRel(),
679
+ 'translated_name' => $oLink->getRel(),
680
+ 'fields' => json_encode($oLink->toArray()),
681
+ 'lovs' => json_encode($this->getOrderService()->getLOVValuesForParams($oLink))
682
+ /*,
683
  'values' => json_encode($this->getFieldsValues($oLink, $oPsOrder)),
684
+ 'info' => json_encode($this->getTransitionLinkInfo($oLink))*/
685
  );
686
+ /*
687
+ echo "<pre>";
688
+ print_r(json_decode($aResult[0]['lovs']));
689
+ echo "</pre>";
690
+
691
+ echo "<pre>";
692
+ print_r(json_decode($aResult[0]['fields']));
693
+ echo "</pre>";
694
+ */
695
  }
696
 
697
  return $aResult;
698
  }
699
+
700
+ }
app/code/community/BeezUp/Block/Order.php CHANGED
@@ -1,125 +1,249 @@
1
  <?php
2
- require_once dirname ( __FILE__ ) . "/../lib/KLogger.php";
3
- require_once dirname ( __FILE__ ) . "/../lib/bootstrap.php";
4
- require_once dirname ( __FILE__ ) . "/../lib/BeezupRepository.php";
5
- require_once dirname ( __FILE__ ) . "/../lib/BeezupMageOrders.php";
6
-
7
- class Beezup_Block_Order extends Mage_core_block_text {
8
 
9
- protected $repository = null;
10
- protected $oOrderService;
11
- public $log = null;
12
- public $log2 = null;
13
- public $orderid = "";
14
- public $debug = false;
15
- public function executeCron() {
16
-
17
-
18
-
19
- set_time_limit(0);
20
- $logDir = Mage::getModuleDir('', 'BeezUp')."/log/";
21
- if(file_exists($logDir."log2.txt")) {
 
 
 
 
22
  if(filesize($logDir."/log2.txt") >=3000000) {
23
- unlink($logDir."log2.txt");
24
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
25
  }
26
 
27
- $sync_end_date = new DateTime ( 'now', new DateTimeZone ( 'UTC' ));
28
- $helper = Mage::helper('beezup');
29
- $sync_status = $helper->getConfig('beezup/marketplace/sync_status');
30
- $debug_mode = $helper->getConfig('beezup/marketplace/debug_mode');
31
- if($debug_mode==1) {
32
- $this->debug = true;
 
 
 
 
 
 
 
 
 
 
 
 
33
  }
34
 
35
- if($sync_status!==1) {
36
- $configModel = Mage::getModel('core/config');
37
- $configModel->saveConfig('beezup/marketplace/sync_status',1);
38
-
39
 
40
-
41
- unlink($logDir."log.txt");
42
- $this->log = new KLogger ( $logDir."log.txt" , KLogger::DEBUG );
43
- $this->log2 = new KLogger ( $logDir."log2.txt" , KLogger::DEBUG );
44
- $this->debugLog("Initializing OM Importation");
45
- $shiiping_disabled = Mage::getStoreConfig('');
46
- if($shiiping_disabled == 0) {
47
- Mage::getConfig()
48
- ->saveConfig('carriers/flatrate/active', 1)
49
- ->cleanCache();
50
- Mage::app()->reinitStores();
51
- }
52
- $this->getOrderList();
53
- if($shiiping_disabled == 0) {
54
- Mage::getConfig()
55
- ->saveConfig('carriers/flatrate/active', 0)
56
- ->cleanCache();
57
- Mage::app()->reinitStores();
58
- }
59
- $this->repository->updateLastSynchronizationDate( $sync_end_date);
60
- $this->orderid = "";
61
- $this->debugLog("OM Importation finalized succesfully");
62
- $configModel->saveConfig('beezup/marketplace/sync_status',0);
63
- echo "OM Importation finalized succesfully";
64
 
65
-
66
-
67
-
68
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
69
 
70
 
71
 
72
- } else {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
73
 
74
- echo "Order Importation is already being executed";
75
  }
76
-
77
- }
78
-
79
-
80
- public function getLog() {
81
- $logDir = Mage::getModuleDir('', 'BeezUp')."/log/";
82
- $log1 = file_get_contents($logDir."/log2.txt");
83
-
84
- echo "<pre>";
85
- print_r($log1);
86
- echo "</pre>";
87
 
88
- }
89
-
90
- public function getOrderList($orderList = null) {
91
- if($orderList == null) {
92
- $data = $this->createRepository()->createOrderListRequest();
93
- $oRequest = $this->getOrderService()->getClientProxy()->getOrderList($data);
94
- $orderList = $oRequest->getResult();
 
 
 
 
 
 
 
 
 
95
  }
96
- $oPagination = $orderList->getPaginationResult();
97
- if(!empty($oPagination)) {
98
- $oLinksTotal = $oPagination->getLinks();
99
- } else {
100
- $configModel = Mage::getModel('core/config');
101
- $configModel->saveConfig('beezup/marketplace/sync_status',0);
102
- die("No more orders to import");
103
- }
104
-
105
- //$header = $orderList->getOrderHeaders();
106
- foreach($orderList->getOrderHeaders() as $order) {
107
-
108
-
109
- $order_status = $order->getBeezupOrderState();
110
- $orderLinks = $order->getLinks();
111
- $etag = $order->getETag();
112
- $beezup_order_id = $order->getBeezupOrderUUID();
113
- // print_r($order);
114
- // print_r($orderLinks[0]);
115
- $account_id = $order->getAccountId();
116
- $orderdata = $this->getOrderService()->getClientProxy()->getOrderByLink($orderLinks[0]);
117
- $final_order = $orderdata->getResult();
118
- // $order_items = $final_order->getOrderItems();
119
- $marketplace_mod_date = $order->getMarketPlaceLastModificationUtcDate();
120
- $purchase_date = $order->getPurchaseUtcDate();
121
- $last_mod_date = $order->getLastModificationUtcDate();
122
- $orderid = $final_order->getOrderMarketPlaceOrderId();
123
  $this->orderid = $orderid;
124
  //customer Info
125
  $order_address = $final_order->getOrderBuyerAddressCity();
@@ -135,7 +259,7 @@ if(!empty($oPagination)) {
135
  $order_company = $final_order->getOrderBuyerCompanyName();
136
  $order_city = $final_order->getOrderBuyerAddressCity();
137
  $order_region = $final_order->getOrderBuyerStateOrRegion();
138
-
139
  //shipping information
140
  $shipping_city = $final_order->getOrderShippingAddressCity();
141
  $shipping_country = $final_order->getOrderShippingAddressCountryName();
@@ -164,232 +288,279 @@ if(!empty($oPagination)) {
164
 
165
 
166
  //marketplace information
167
- $marketplace_order_id = $order->getMarketPlaceOrderId();
168
  $marketplace = $final_order->getMarketPlaceTechnicalCode();
169
- $this->debugLog("Initializing Order - Link: ".$orderLinks[0]->getHref());
170
  //productInfo
171
- if(!$this->checkEtagExists($etag)) {
172
 
173
  $mage_productIds = $this->prescanOrder($final_order);
174
- if($mage_productIds) {
175
- $order_data = array(
176
- "etag" => $etag,
177
- "account_id" => $account_id,
178
- "marketplace_mod_date" => $marketplace_mod_date,
179
- "purchase_date" => $purchase_date ,
180
- "last_mod_date" => $last_mod_date ,
181
- "beezup_order_id" => $beezup_order_id,
182
- "order_status" => $order_status,
183
- "products" => $mage_productIds['products'],
184
- "storeid" => $mage_productIds['store'],
185
- "order_currency" => $order_currency_code ,
186
- "order_address" => $order_adress,
187
- "order_country" => $order_country,
188
- "order_country_iso" => $order_country_iso ,
189
- "order_address" => $order_address ,
190
- "order_postalCode" => $order_postalCode ,
191
- "order_customer" => $order_first_name ,
192
- "order_lastname" => $order_last_name ,
193
- "order_customer_email" => $order_customer_email ,
194
- "order_customer_phone" => $this->getPhone($order_customer_phone, $order_customer_mobile) ,
195
- "order_comment" => $order_comment ,
196
- "order_company" => $order_company ,
197
- "shipping_city" => $shipping_city ,
198
- "shipping_country" => $shipping_country ,
199
- "shipping_country_iso" => $shipping_country_iso ,
200
- "shipping_address" => $shipping_address ,
201
- "shipping_name" => $shipping_first_name ,
202
- "shipping_lastname" => $shipping_last_name ,
203
- "shipping_postalCode" => $shipping_postalCode ,
204
- "shipping_region" =>$shipping_region,
205
- "shipping_email" => $shipping_email ,
206
- "shipping_phone" => $this->getPhone($shipping_phone, $shipping_mobile) ,
207
- "shipping_company" => $shipping_company ,
208
- "order_totalPrice" => $order_totalPrice ,
209
- "order_shippingPrice" => $order_shippingPrice ,
210
- "order_city" => $order_city,
211
- "order_region" => $order_region,
212
- "marketplace_order_id" => $marketplace_order_id,
213
- "marketplace" => $marketplace,
214
- "discounts" => $mage_productIds['discounts']
215
- );
216
-
217
-
218
 
219
- //check if order exists
220
- $Mageorder = $this->loadMageOrder();
221
- if ($Mageorder) {
222
- //if order exists
223
- $this->updateEtag($etag);
224
- $this->updateBilling($Mageorder, $order_data );
225
- $this->updateBeezupInfoTab($Mageorder, $final_order, $order_data);
226
- $this->debugLog("Order Already exists Mage Order ID: " .$Mageorder->getId());
227
- $status1 = $Mageorder->getStatusLabel();
228
- $status = $this->getStatus($status1);
229
- if($status !== $order_status) {
230
- //if order exits and status has changed we update order status
231
- $this->debugLog("Updating Order Status from: ".$status1." to: ".$order_status );
232
- $this->setStatus( $order_status, $Mageorder);
233
- }
234
-
235
- $id_order = $Mageorder->getId();
236
- $BeezupMageOrder = new BeezupMageOrders($id_order);
237
- $BeezupMageOrder->setData(array("shipping" =>(float) $order_data['order_shippingPrice']));
238
- $BeezupMageOrder->updateShippingInfo();
239
- } else {
240
- //if not we create order
241
-
242
-
243
- $this->debugLog("Generating Order");
244
- $this->addOrder($order_data,$final_order );
245
-
246
-
247
- }
248
-
249
-
250
- } else {
251
- //order could not be imported
252
-
253
 
254
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
255
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
256
 
 
 
 
 
257
  } else {
258
- //etag has not changed
259
- $this->debugLog("Order Etag has not changed");
260
-
261
- }
262
-
263
- }
264
-
265
- if(!empty($oLinksTotal)) {
266
- //we check if there is next link and get next orders
267
- foreach($oLinksTotal as $link) {
268
- if( $link->getRel() == "next") {
269
-
270
- $this->log->LogInfo("Initializing New Order List ->". $link->getHref());
271
- $this->log2->LogInfo("Initializing New Order List ->". $link->getHref());
272
- $oRequest = $this->getOrderService()->getClientProxy()->getOrderListByLink($link);
273
- $orderList = $oRequest->getResult();
274
- $this->getOrderList($orderList);
275
- }
276
 
277
  }
278
-
279
 
280
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
281
  }
 
 
 
282
 
283
 
284
- }
285
-
286
- public function updateBeezupInfoTab($order, $oLink, $data) {
287
- $beezup_last_modification_date = $oLink->getOrderLastModificationUtcDate();
288
- $beezup_last_modification_date = $beezup_last_modification_date->date;
289
- $beezup_marketplace_last_modification_date = $oLink->getOrderMarketPlaceLastModificationUtcDate();
290
- $beezup_marketplace_last_modification_date = $beezup_marketplace_last_modification_date->date;
291
- $beezup_comission = $oLink->getOrderTotalCommission()." ".$data['order_currency'];
292
- $tot_comm = $oLink->getOrderTotalCommission();
293
- if(empty($tot_comm ) || $tot_comm == 0) {
294
- $beezup_comission = 0;
295
- }
296
- $updateData = array("beezup_status" => $data['order_status'],
297
- "beezup_last_modification_date" => $beezup_last_modification_date,
298
- "beezup_marketplace_last_modification_date" => $beezup_marketplace_last_modification_date ,
299
- "beezup_total_paid" => $oLink->getOrderTotalPrice()." ".$data['order_currency'],
300
- "beezup_comission" => $beezup_comission,
301
- "beezup_marketplace_status" => $oLink->getOrderStatusMarketPlaceStatus());
302
- $orderId = $order->getId();
303
- $beezupMageOrder = new BeezupMageOrders($orderId);
304
- $beezupMageOrder->setData($updateData);
305
- $beezupMageOrder->updateBeezupInfo();
306
-
307
 
308
- }
309
-
310
- public function getPhone($phone, $phone2) {
311
- $retorno = "";
312
- if(!empty($phone) && $phone !== "") {
313
- $retorno .= $phone;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
314
  }
315
- if(!empty($phone2) && $phone2 !=="") {
316
- if(empty($phone) || $phone == "") {
317
- $retorno = $phone2;
318
-
319
- } else {
320
- $retorno .= " - ".$phone2;
321
  }
 
 
 
 
 
 
 
 
 
322
  }
323
- return $retorno;
324
- }
325
-
326
-
327
- public function getBeezupBuyerAddress($order) {
328
  $add1=$order->getOrderBuyerAddressLine1();
329
  $add2=$order->getOrderBuyerAddressLine2();
330
  $add3=$order->getOrderBuyerAddressLine3();
331
  $retorno = "";
332
- if(!empty($add1)) {
333
- $retorno = $order->getOrderBuyerAddressLine1();
334
- }
335
- if(!empty($add2)) {
336
- if(empty($add1)) {
337
- $retorno .= $order->getOrderBuyerAddressLine2();
338
- } else {
339
- $retorno .= " - ". $order->getOrderBuyerAddressLine2();
340
- }
341
- }
342
  if(!empty($add3)){
343
- if(empty($add1) && empty($add2)) {
344
- $retorno .= $order->getOrderBuyerAddressLine3();
345
- } else {
346
- $retorno .= " - ". $order->getOrderBuyerAddressLine3();
347
- }
348
- }
349
- return $retorno;
350
- }
351
-
352
-
353
  public function getBeezupShippingAddress($order) {
354
  $add1 = $order->getOrderShippingAddressLine1();
355
  $add2 = $order->getOrderShippingAddressLine2();
356
  $add3=$order->getOrderBuyerAddressLine3();
357
- $retorno = "";
358
- if(!empty($add1 )) {
359
- $retorno = $order->getOrderShippingAddressLine1();
360
- }
361
- if(!empty($add2)) {
362
- if(empty($add1)) {
363
- $retorno .= $order->getOrderShippingAddressLine2();
364
- } else {
365
- $retorno .= " - ". $order->getOrderShippingAddressLine2();
366
- }
367
- }
368
  if(!empty($add3)){
369
  if(empty($add1) && empty($add2)) {
370
  $retorno .= $order->getOrderShippingAddressLine3();
371
- } else {
372
- $retorno .= " - ". $order->getOrderShippingAddressLine3();
373
  }
374
- }
375
- return $retorno;
376
- }
377
-
378
  public function checkEtagExists($etag) {
379
- $resource = Mage::getSingleton('core/resource');
380
- $readConnection = $resource->getConnection('core_read');
381
- $table = $resource->getTableName('sales/order_grid');
382
- $query = 'SELECT increment_id FROM ' . $table . ' WHERE beezup_etag = \''
383
- . $etag . '\' LIMIT 1';
384
- $order = $readConnection->fetchOne($query);
385
- if($order && !empty($order)) {
386
- return true;
387
- }
388
- return false;
389
-
390
- }
 
391
 
392
-
393
  public function updateEtag($etag) {
394
  $this->debugLog("Updating Etag");
395
  $resource = Mage::getSingleton('core/resource');
@@ -401,143 +572,143 @@ if(!empty($oPagination)) {
401
  }
402
 
403
 
404
-
405
- public function updateBilling($order, $data) {
406
-
407
-
408
- $addressData = array(
409
- 'billing_firstname' => ($data['order_customer']) ? $data['order_customer'] : "empty",
410
- 'billing_lastname' => ($data['order_lastname']) ? $data['order_lastname'] : "empty",
411
- 'billing_street' => ($data['order_address']) ? $data['order_address'] : "empty",
412
- 'billing_city' => ($data['order_city']) ? $data['order_city'] : "empty",
413
- 'billing_postcode' => ($data['order_postalCode']) ? $data['order_postalCode'] : "empty",
414
- 'billing_telephone' => ($data['order_customer_phone']) ? $data['order_customer_phone'] : "empty",
415
- 'billing_country_id' => ($data['order_country_iso']) ? $data['order_country_iso'] : "empty",
416
- 'billing_region_id' => ($data['order_region ']) ? substr($data['order_region '], 0,2) : "EM",
417
  'shipping_firstname' => ($data['shipping_name']) ? $data['shipping_name'] : "empty",
418
- 'shipping_lastname' => ($data['shipping_lastname']) ? $data['shipping_lastname'] : "empty",
419
- 'shipping_street' => ($data['shipping_address']) ? $data['shipping_address'] : "empty",
420
- 'shipping_city' => ($data['shipping_city']) ? $data['shipping_city'] : "empty",
421
- 'shipping_postcode' => ($data['shipping_postalCode']) ? $data['shipping_postalCode'] : "empty",
422
- 'shipping_telephone' => ($data['shipping_phone']) ? $data['shipping_phone'] : "empty",
423
- 'shipping_country_id' => ($data['shipping_country_iso']) ? $data['shipping_country_iso'] : "empty",
424
- 'shipping_region_id' => ($data['shipping_region']) ? substr($data['shipping_region'], 0, 2) : "EM" // id from directory_country_region table
425
- );
426
-
427
- $shippingData = array(
428
-
429
- );
430
- // Get the id of the orders shipping address
431
- $orderId = $order->getId();
432
- $beezupMageOrder = new BeezupMageOrders($orderId);
433
- $beezupMageOrder->setData($addressData);
434
- $beezupMageOrder->updateAdresses();
435
- }
436
-
437
- public function updateAddresses($shippingData, $address) {
438
- if($shippingData['firstname'] !==$address['firstname']) {
439
- $address->setFirstname($shippingData['firstname']);
440
- }
441
- if($shippingData['lastname'] !==$address['lastname']) {
442
- $address->setLastname($shippingData['lastname']);
443
- }
444
- if($shippingData['street'] !==$address['street']) {
445
- $address->setStreet($shippingData['street']);
446
- }
447
- if($shippingData['city'] !==$address['city']) {
448
- $address->setCity($shippingData['city']);
449
- }
450
- if($shippingData['postcode'] !==$address['postcode']) {
451
- $address->setPostcode($shippingData['postcode']);
452
- }
453
- if($shippingData['telephone'] !==$address['telephone']) {
454
- $address->setTelephone($shippingData['telephone']);
455
- }
456
- $address->save();
457
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
458
 
459
- }
460
-
461
-
462
- public function loadMageOrder() {
463
- $Mageorder = Mage::getModel('sales/order')->loadByIncrementId($this->orderid);
464
- if ($Mageorder->getId()) {
465
- return $Mageorder;
466
- } else {
467
- //we get order from marketplace orderid
468
- $orderInc = $this->checkMarketOrderExists($this->orderid);
469
- if($orderInc) {
470
- // if exists
471
- $Mageorder = Mage::getModel('sales/order')->loadByIncrementId($orderInc);
472
- if ($Mageorder->getId()) {
473
- return $Mageorder;
474
- }
475
- }
476
- }
477
- return false;
478
- }
479
-
480
-
481
- private function debugLog($message) {
482
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
483
  if($this->orderid !== "") {
484
  $message = $this->orderid." | ".$message;
485
  }
486
  $this->log->LogInfo($message);
 
 
 
487
 
488
- $this->log2->LogInfo($message);
489
- }
490
-
491
- public function prescanOrder(BeezupOMOrderResult $order) {
492
- $retorno = array();
493
- $orderItems = $order->getOrderItems();
494
- foreach ($orderItems as $item)
495
- {
496
-
497
- if ($item->getOrderItemOrderItemType () !== 'Product')
498
  {
499
- // continue;
500
- }
501
- $beezup_store = $item->getOrderItemBeezUPStoreId(); //beezup storeid
502
- $mage_storeid = $this->checkOrderStore($beezup_store); //magento storeid
503
- $marketplace_orderid = $item->getOrderItemMarketPlaceProductId();
504
- if(!$mage_storeid) {
505
-
506
- if(strpos($marketplace_orderid,'INTERETBCA') !== false || strpos($marketplace_orderid,'interetbca') !== false) { }
507
- else {
508
- $this->log->LogError($this->orderid." | No mapping for store ".$beezup_store);
509
- $this->log2->LogError($this->orderid." | No mapping for store ".$beezup_store);
510
- return false;
511
- }
512
-
513
- }
514
- // $retorno['store'] = 1;
515
- $retorno['store'] = $mage_storeid;
516
- $this->debugLog("Store Matching succesful, Beezup Store: ".$beezup_store." , Magento Store Id: ".$mage_storeid);
517
- $product_ImportedMerchantId = $item->getOrderItemMerchantImportedProductId();
518
- $product_MerchantId = $item->getOrderItemMerchantProductId();
519
-
520
- $product_quantity = $item->getOrderItemQuantity();
521
- $product_price = $item->getOrderItemItemPrice();
522
- $product_title = $item->getOrderItemTitle();
523
- $product_image = $item->getOrderItemImageUrl();
524
- if(strpos($marketplace_orderid,'INTERETBCA') !== false || strpos($marketplace_orderid,'interetbca') !== false) {
525
- $retorno['discounts']= $item->getOrderItemTotalPrice();
526
- } else {
527
- $product = $this->getMageProduct($product_ImportedMerchantId , $product_MerchantId , $beezup_store );
528
- if($product) {
529
- $mage_productId = $product->getId();
530
- $stocklevel = (int)Mage::getModel('cataloginventory/stock_item')
531
- ->loadByProduct($product)->getQty();
532
 
533
- $retorno['products'][] = array("id" => $mage_productId, "qty" => $product_quantity, "price" => $product_price, "curr_stock" => $stocklevel);
534
- //producto existe
535
- } else {
536
- //vendria if de si activada opcion de crear producto creamos
537
- if(!$this->debug) {
538
- return false;
539
  }
540
- $product_data = array(
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
541
  "sku" => $product_ImportedMerchantId,
542
  "sku2" => $product_MerchantId,
543
  "qty" => $product_quantity,
@@ -545,594 +716,643 @@ $addressData = array(
545
  "title" => $product_title,
546
  "image" => $product_image,
547
  "storeId" => $mage_storeid
548
- );
549
- $product = $this->createProduct($product_data);
550
- if(!$product) {
551
- return false;
 
 
 
 
 
552
  }
553
- $stocklevel = (int)Mage::getModel('cataloginventory/stock_item')
554
- ->loadByProduct($product)->getQty();
555
- $mage_productId = $product->getId();
556
- $retorno['products'][] = array("id" => $mage_productId, "qty" => $product_quantity, "price" => $product_price, "curr_stock" => $stocklevel);
557
  }
 
 
558
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
559
  }
560
 
561
- return $retorno;
562
- }
563
-
564
-
565
-
566
- public function matchProductAttributes($importedId, $storeId) {
567
- $product = null;
568
- $helper = Mage::helper('beezup');
569
- $attributes = $helper->getConfig('beezup/marketplace/attributes');
570
- $attributes = unserialize ($attributes);
571
-
572
- foreach($attributes['attributes'][$storeId ] as $attribute) {
573
- $att = explode("|", $attribute);
574
- if($storeId == $att[1]) {
575
-
576
- $product=Mage::getModel('catalog/product')->loadByAttribute($att[0],$importedId);
577
- if($product) {
578
- break;
579
- }
580
  }
581
  }
582
-
583
- return $product;
584
- }
585
-
586
-
587
-
588
- public function getMageProduct($importedId, $merchantId, $storeId){
589
- try {
590
- $product=Mage::getModel('catalog/product')->load($importedId);
591
- if (!$product->getId() || $product->getId() !== $importedId ){
592
- $product = $this->matchProductAttributes($importedId, $storeId);
593
- if($product == null || !is_object($product)) {
594
- $product=Mage::getModel('catalog/product')->load($merchantId);
595
- if(!$product->getId() || $product->getId() !== $merchantId ) {
596
- $product = $this->matchProductAttributes($merchantId, $storeId);
597
-
598
  }
599
  }
600
- }
601
-
602
- if(is_object($product)) {
603
- if($product->getId()) {
604
- $this->debugLog("Product Matching succesful, Beezup Imported Id: ".$importedId." , Magento Product Id: ".$product->getId());
605
- return $product;
606
- }}
607
- $this->log->LogError($this->orderid. "| No Product Matching, Product ".$importedId." could not be found");
608
- $this->log2->LogError($this->orderid. "| No Product Matching, Product ".$importedId." could not be found");
609
- return false;
610
- }catch(Exception $e){
611
- $this->log->LogError($this->orderid. "| Product ".$importedId." could not be found, error: ".$e->getMessage());
612
- $this->log2->LogError($this->orderid. "| Product ".$importedId." could not be found, error: ".$e->getMessage());
613
- return false;
614
- //error no se pudo crear la orden
615
-
616
- }
617
- }
618
-
619
-
620
- public function checkOrderStore($storeId ) {
621
- $helper = Mage::helper('beezup');
622
- $stores = $helper->getConfig('beezup/marketplace/stores');
623
- $stores = unserialize ($stores);
624
- foreach($stores as $store) {
625
- if(isset($store[$storeId]) && $store[$storeId] > 0) {
626
- return $store[$storeId];
627
  }
628
- }
629
  return false;
630
  }
631
-
632
-
633
-
634
  /**
635
- * @return BeezupOMOrderService
636
- */
637
  public function getOrderService(){
638
  if ($this->oOrderService === null){
639
  $this->oOrderService = $this->createOrderService();
640
- // enchufamos debug mode, esta activado? false true $this->oOrderService->setDebugMode(false);
641
  }
642
  return $this->oOrderService;
643
  }
644
-
645
  /**
646
- * @return BeezupOMOrderService
647
- */
648
  protected function createOrderService(){
649
-
650
  return new BeezupOMOrderService($this->createRepository() );
651
  }
652
 
653
  protected function createRepository() {
654
  if ($this->repository == null) {
655
- $this->repository = new BeezupRepository();
656
  }
657
- return $this->repository;
658
 
659
  }
660
-
661
-
662
-
663
- public function addOrder($data, $oLink, $stop = false) {
664
-
665
 
666
- try {
667
- $helper = Mage::helper('beezup');
668
- $addStock = $helper->getConfig('beezup/marketplace/available_products');
669
- $baseCurrencyCode = Mage::app()->getStore()->getBaseCurrencyCode();
670
- $quote = Mage::getModel('sales/quote')
671
- ->setStoreId($data['storeid']);
672
- $quote->setCustomerEmail($data['order_customer_email']);
673
-
674
-
675
- $currency = Mage::getModel('directory/currency')->load($data['order_currency']);
676
- $quote->setForcedCurrency($currency);
677
-
678
- $blnCreate = true;
679
- $total_new_price = 0;
680
- foreach($data['products'] as $prod) {
681
- if($prod['qty']==0) {
682
- $blnCreate = false;
683
- break;
684
- }
685
- $prod_totality_price = $prod['price']*$prod['qty'];
686
- $total_new_price = $total_new_price + $prod_totality_price;
687
- $product = Mage::getModel('catalog/product')->load($prod['id']);
688
- $buyInfo = array(
689
- 'qty' => $prod['qty'],
690
- );
691
- $this->debugLog("Adding ".$prod['qty']." product/s with id ".$product->getId()." to order, with Beezup Price: ".$prod['price']);
692
- //echo "Product ".$product->getId()."<br><br>";
693
- //para no perder stock:
694
- //Mage::getModel('cataloginventory/stock')->backItemQty($productId,$new_qty);
695
-
696
-
697
- if($addStock == 1) {
698
- $stock = Mage::getModel('cataloginventory/stock_item')->loadByProduct($product);
699
-
700
- if ($stock->getQty() < $prod['qty'] && $product->getStockItem()->getMaxSaleQty() >= $prod['qty']) {
701
- $this->debugLog("Product ".$product->getId()." Stock = 0, Updating to ".$prod['qty']." to generate Order");
702
- // Mage::getModel('cataloginventory/stock')->backItemQty($product->getId(),$prod['qty']);
703
- //$this->_updateStocks(array("id_product" => $product->getId(), "qty" => $prod['qty']));
704
- $product->setStockData(
705
- array(
706
- 'is_in_stock' => 1,
707
- 'qty' => $prod['qty'],
708
- 'manage_stock' => 1,
709
- 'use_config_notify_stock_qty' => 1
710
- )
711
- );
712
- $product->save();
713
- $product = Mage::getModel('catalog/product')->load($product->getId());
714
-
715
- }
716
- }
717
- //fin para no perder stock
718
-
719
- /*
720
- $tax_class = $product->getTaxClassId();
721
- $product->setTaxClassId(0);
722
- $product->getResource()->saveAttribute($product, 'tax_class_id'); */
723
- $price = $prod['price'];
724
-
725
- $quote_item = Mage::getModel('beezup/quote_item');
726
- $quote_item
727
- ->setProduct($product)
728
- ->setPrice((float) $price )
729
- ->setCustomPrice((float)$price )
730
- ->setOriginalCustomPrice((float) $price )
731
- ->setQuote($quote)
732
- ->setQty((integer) $prod['qty'])
733
- ->setBeezupPrice((float) $price );
734
-
735
-
736
- $quote->addItem($quote_item);
737
-
738
- //$quote->addProduct($product, new Varien_Object($buyInfo))->setOriginalCustomPrice($price)->setCustomPrice($price);
739
 
740
- /*
741
- $product->setTaxClassId($tax_class);
742
-
743
- $product->getResource()->saveAttribute($product, 'tax_class_id');
744
- */
745
- }
746
-
747
- if($blnCreate) {
748
- $addressData = array(
749
- 'firstname' => ($data['order_customer']) ? $data['order_customer'] : "empty",
750
- 'lastname' => ($data['order_lastname']) ? $data['order_lastname'] : "empty",
751
- 'street' => ($data['order_address']) ? $data['order_address'] : "empty",
752
- 'city' => ($data['order_city']) ? $data['order_city'] : "empty",
753
- 'postcode' => ($data['order_postalCode']) ? $data['order_postalCode'] : "empty",
754
- 'telephone' => ($data['order_customer_phone']) ? $data['order_customer_phone'] : "empty",
755
- 'country_id' => ($data['order_country_iso']) ? $data['order_country_iso'] : "empty",
756
- 'region_id' => ($data['order_region ']) ? substr($data['order_region '], 0,2) : "EM"// id from directory_country_region table
757
- );
758
-
759
- $shippingData = array(
760
- 'firstname' => ($data['shipping_name']) ? $data['shipping_name'] : "empty",
761
- 'lastname' => ($data['shipping_lastname']) ? $data['shipping_lastname'] : "empty",
762
- 'street' => ($data['shipping_address']) ? $data['shipping_address'] : "empty",
763
- 'city' => ($data['shipping_city']) ? $data['shipping_city'] : "empty",
764
- 'postcode' => ($data['shipping_postalCode']) ? $data['shipping_postalCode'] : "empty",
765
- 'telephone' => ($data['shipping_phone']) ? $data['shipping_phone'] : "empty",
766
- 'country_id' => ($data['shipping_country_iso']) ? $data['shipping_country_iso'] : "empty",
767
- 'region_id' => ($data['shipping_region']) ? substr($data['shipping_region'], 0, 2) : "EM" // id from directory_country_region table
768
- );
769
-
770
-
771
- $payment_method = $helper->getConfig('beezup/marketplace/payment_method');
772
- $billingAddress = $quote->getBillingAddress()->addData($addressData);
773
- $shippingAddress = $quote->getShippingAddress()->addData($shippingData);
774
- $shipping_cost = (float) $data['order_shippingPrice'];
775
- if($data['order_shippingPrice'] == 0) {
776
- $shipping_cost = 20000;
777
- }
778
- $total_new_price = $total_new_price + $data['order_shippingPrice'] ;
779
- Mage::unregister('shipping_cost');
780
- Mage::register('shipping_cost', $shipping_cost);
781
- $this->debugLog("Adding Order Shipping Cost: ". $data['order_shippingPrice']);
782
-
783
- $shippingAddress->setCollectShippingRates(true)->collectShippingRates()
784
- ->setShippingMethod('flatrate_flatrate')
785
- ->setPaymentMethod($payment_method);
786
-
787
- //$shippingAddress->addTotal(array("code" => "specialfee", "title" => "Special Fee", "value" => 20));
788
- $quote->getPayment()->importData(array('method' => $payment_method));
789
-
790
- $quote->collectTotals()->save();
791
-
792
- $service = Mage::getModel('sales/service_quote', $quote);
793
- $service->submitAll();
794
- $order = $service->getOrder();
795
-
796
-
797
-
798
- $quoteId = $order->getQuoteId();
799
- //$this->setStatus($data['order_status'], $order);
800
-
801
- $orderid = $order->getId();
802
-
803
- $resource = Mage::getSingleton('core/resource');
804
- $writeConnection = $resource->getConnection('core_write');
805
- $table = $resource->getTableName('sales/order_grid');
806
- $this->debugLog("Adding Beezup Marketplace Information to Order");
807
- $marketplace = $data['marketplace'];
808
- $beezup_name = $data['order_customer'];
809
- $market_order_id =$this->orderid;
810
- $beezup_order_id = $oLink->getBeezupOrderUUID();
811
- $beezup_status = $data['order_status'];
812
- $beezup_last_modification_date = $oLink->getOrderLastModificationUtcDate();
813
- $beezup_last_modification_date = $beezup_last_modification_date->date;
814
- $beezup_marketplace_status = $oLink->getOrderStatusMarketPlaceStatus();
815
- $beezup_purchase_date = $oLink->getOrderPurchaseUtcDate();
816
- $beezup_purchase_date = $beezup_purchase_date->date;
817
- $beezup_marketplace_last_modification_date = $oLink->getOrderMarketPlaceLastModificationUtcDate();
818
- $beezup_marketplace_last_modification_date = $beezup_marketplace_last_modification_date->date;
819
- /* $date = new DateTime($$beezup_marketplace_last_modification_date);
820
- $beezup_marketplace_last_modification_date = $date->format('d-m-Y H:i:s'). "(UTC Time)";
821
- */
822
-
823
- $beezup_total_paid = $oLink->getOrderTotalPrice()." ".$data['order_currency'];
824
- $beezup_account_id = $oLink->getAccountId();
825
- $beezup_comission = $oLink->getOrderTotalCommission()." ".$data['order_currency'];
826
- $tot_comm = $oLink->getOrderTotalCommission();
827
- if(empty($tot_comm ) || $tot_comm == 0) {
828
- $beezup_comission = 0;
829
- }
830
- $query = "UPDATE {$table} SET beezup_marketplace = '{$marketplace}', beezup_name = '{$beezup_account_id}', beezup_order = 1, beezup_market_order_id = '{$market_order_id}',
831
- beezup_order_id = '{$beezup_order_id}', beezup_status = '{$beezup_status}', beezup_last_modification_date = '{$beezup_last_modification_date}',
832
- beezup_marketplace_status = '{$beezup_marketplace_status}', beezup_purchase_date = '{$beezup_purchase_date}', beezup_marketplace_last_modification_date = '{$beezup_marketplace_last_modification_date}',
833
- beezup_total_paid = '{$beezup_total_paid}', beezup_etag = '{$data['etag']}' , beezup_comission = '{$beezup_comission}'
834
- WHERE entity_id = ". (int)$orderid;
835
- $writeConnection->query($query);
836
- $disc_price = 0;
837
- if(!empty($data['discounts']) && $data['discounts'] >0) {
838
 
839
-
840
- $disc_price = round($data['discounts'],2);
841
- $total_new_price = $total_new_price+$disc_price;
842
- $table_address = $resource->getTableName("sales/quote_address");
843
-
844
- $query = "update {$table_address} set beezup_fee = '{$disc_price}' where quote_id = '{$quoteId}' and address_type = 'shipping'";
845
- $writeConnection->query($query);
846
- $this->debugLog("Adding CDISCOUNT products with total price: ".$disc_price);
847
- }
848
-
849
- //if order id exists and has been created
850
- if ($orderid)
851
- {
852
- //we send order id to beezup
853
- $this->debugLog("Sending Magento Order Id to Beezup, Magento Order Id: ".$orderid);
854
- $oResult = new BeezupOMSetOrderIdValues ();
855
- $oResult->setOrderMerchantOrderId ( $orderid )->setOrderMerchantECommerceSoftwareName ( 'Magento' )->setOrderMerchantECommerceSoftwareVersion ( Mage::getVersion() );
856
- $sendRequest = $this->getOrderService()->getClientProxy()->setOrderMerchantIdByLink($oLink->getLinkByRel('setMerchantOrderId'), $oResult);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
857
  }
858
-
859
- $grand_total = $order->getGrandTotal();
860
- $beezup_price = $oLink->getOrderTotalPrice() - $disc_price;
861
- if($grand_total != (float) $beezup_price && $beezup_price > 0) {
862
- $order->setGrandTotal((float) $beezup_price);
863
- $order->setBaseGrandTotal((float) $beezup_price);
864
- $diff = (((float) $beezup_price) - $grand_total);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
865
 
866
- $order->setTaxAmount($order->getTaxAmount() + $diff);
867
- $order->save();
868
- }elseif($grand_total != (float)$beezup_price && $beezup_price < 1) {
869
 
870
- $order->setGrandTotal((float) $total_new_price);
871
- $order->setBaseGrandTotal((float) $total_new_price);
872
- $diff = (((float) $total_new_price) - $grand_total);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
873
 
874
- $order->setTaxAmount($order->getTaxAmount() + $diff);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
875
  $order->save();
 
 
 
 
 
 
 
 
876
  }
877
-
878
- $products = Mage::getResourceModel('sales/order_item_collection')
879
- ->setOrderFilter($orderid);
880
- foreach($products as $product) {
881
- $product->setBaseOriginalPrice($product->getOriginalPrice());
882
- $product->setBaseTaxAmount($product->getTaxAmount());
883
- $product->setBaseTaxInvoiced($product->getTaxAmount());
884
- $product->setBasePriceInclTax($product->getPriceInclTax());
885
- $product->setBaseRowTotalInclTax($product->getRowTotalInclTax());
886
- $product->save();
887
- }
888
- $order->setBaseTaxAmount($order->getTaxAmount());
889
- $order->setBaseTaxInvoiced($order->getTaxAmount());
890
- $order->setBaseTotalInvoiced($order->getTotalPaid());
891
- $order->setBaseTotalPaid($order->getTotalPaid());
892
- $order->setBaseGrandTotal($order->getTotalPaid());
893
- $order->setBaseSubtotalInclTax($order->getSubtotalInclTax());
894
- $order->save();
895
-
896
- $this->setStatus($data['order_status'], $order);
897
-
898
- $this->debugLog("Order imported succesfully, Magento Order Id: ".$orderid);
899
- } else {
900
- //product stock = 0 we dont create order
901
- $this->log->LogError($this->orderid. "| Order ".$data['market_place_order_id']." could not be imported, error: Stock from Beezup product = 0 ");
902
- $this->log2->LogError($this->orderid. "| Order ".$data['market_place_order_id']." could not be imported, error: Stock from Beezup product = 0 ");
903
- }
904
- }catch(Exception $e){
905
-
906
-
907
- if($stop) {
908
- $this->log->LogError($this->orderid. "| Order ".$data['market_place_order_id']." could not be imported, error: ".$e->getMessage());
909
- $this->log2->LogError($this->orderid. "| Order ".$data['market_place_order_id']." could not be imported, error: ".$e->getMessage());
910
- $this->restoreStock($data);
911
- } else {
912
- $this->debugLog("Order Import failed, Trying to import Order Again");
913
- $this->addOrder($data, $oLink, true);
914
-
915
- }
916
- //error no se pudo crear la orden
917
-
918
- }
919
 
920
-
921
-
922
- }
923
-
924
-
925
 
926
  public function restoreStock($data) {
927
-
928
  try {
929
- foreach($data['products'] as $prod) {
930
- $product = Mage::getModel('catalog/product')->load($prod['id']);
931
- $stock = Mage::getModel('cataloginventory/stock_item')->loadByProduct($product);
932
- if ($stock->getQty() != $prod['curr_stock'] ) {
933
- $this->debugLog("Restoring Stock from Product ".$product->getId()." to: ".$prod['curr_stock'] ." due to Order Fail");
934
- $stockItem = Mage::getModel('cataloginventory/stock_item')->loadByProduct($product);
935
- $stockItem->setData('is_in_stock', 0);
936
- $stockItem->setData('qty', $prod['curr_stock']);
937
- $stockItem->save();
938
- $product->save();
939
- }
940
-
941
- }
942
  } catch(Exception $e){
943
- $this->log->LogError($this->orderid. "| Failed Restoring Product Stock: ".$e->getMessage());
944
- $this->log2->LogError($this->orderid. "| Failed Restoring Product Stock: ".$e->getMessage());
 
 
945
  }
946
-
947
- }
948
 
949
 
950
 
951
  private function createProduct($data) {
952
-
953
  $sku = $data['sku'];
954
- if(empty($data['sku'])) {
955
  $sku = $data['sku2'];
956
- }
957
-
958
- Mage::app()->setCurrentStore($data['storeId']);
959
- $product = Mage::getModel('catalog/product');
960
- // if(!$product->getIdBySku('testsku61')):
961
-
962
- try{
963
- $product
964
- // ->setStoreId(1) //you can set data in store scope
965
- ->setWebsiteIds(array($data['storeId'])) //website ID the product is assigned to, as an array
966
- ->setAttributeSetId($product->getDefaultAttributeSetId()) //ID of a attribute set named 'default'
967
- ->setTypeId('simple') //product type
968
- ->setCreatedAt(strtotime('now')) //product creation time
969
- ->setSku($sku ) //SKU
970
  ->setWeight(0)
971
- ->setName($data['title']) //product name
972
- ->setStatus(1) //product status (1 - enabled, 2 - disabled)
973
- ->setTaxClassId(4) //tax class (0 - none, 1 - default, 2 - taxable, 4 - shipping)
974
- ->setVisibility(Mage_Catalog_Model_Product_Visibility::VISIBILITY_NOT_VISIBLE ) //catalog and search visibility
975
- ->setPrice($data['price']) //price in form 11.22
976
- ->setMsrpEnabled(1) //enable MAP
977
- ->setMsrpDisplayActualPriceType(1) //display actual price (1 - on gesture, 2 - in cart, 3 - before order confirmation, 4 - use config)
978
- ->setMsrp(0) //Manufacturer's Suggested Retail Price
979
- ->setMetaTitle('')
980
- ->setMetaKeyword('')
981
- ->setMetaDescription('')
982
- ->setDescription($data['title'])
983
- ->setShortDescription($data['title'])
984
- // ->setMediaGallery (array('images'=>array (), 'values'=>array ())) //media gallery initialization
985
- //->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
986
- ->setStockData(array(
987
- 'use_config_manage_stock' => 0, //'Use config settings' checkbox
988
- 'manage_stock'=>1, //manage stock
989
- 'min_sale_qty'=>1, //Minimum Qty Allowed in Shopping Cart
990
- 'max_sale_qty'=>2, //Maximum Qty Allowed in Shopping Cart
991
- 'is_in_stock' => 1, //Stock Availability
992
- 'qty' => 1 //qty
993
- )
994
- );
995
- $product->save();
996
  return $product;
997
-
998
- }catch(Exception $e){
999
- //log exception
1000
- $this->log->LogError($this->orderid."| Product ".$sku." could not be created, error: ".$e->getMessage());
1001
- $this->log2->LogError($this->orderid."| Product ".$sku." could not be created, error: ".$e->getMessage());
1002
  return false;
1003
- }
1004
  }
1005
 
1006
 
1007
 
1008
  public function setStatus($status, $order) {
1009
- $helper = Mage::helper('beezup');
1010
- $retorno = "";
1011
- $blnCancel = false;
1012
- $blnHold = false;
1013
- switch($status) {
1014
- case "New" :
1015
- $this->debugLog("Setting Order Status to New");
1016
- $retorno = $helper->getConfig('beezup/marketplace/status_new');
1017
- break;
1018
- case "InProgress" :
1019
- $this->debugLog("Setting Order Status to InProgress");
1020
- $retorno = $helper->getConfig('beezup/marketplace/status_progress');
1021
- $this->payOrder($order);
1022
- break;
1023
- case "Aborted" :
1024
- $this->debugLog("Setting Order Status to Aborted");
1025
- $retorno = $helper->getConfig('beezup/marketplace/status_aborted');
1026
- $blnHold = true;
1027
-
1028
-
1029
- break;
1030
- case "Closed" :
1031
- $this->debugLog("Setting Order Status to Closed");
1032
- $blnCancel =true;
1033
- $retorno = $helper->getConfig('beezup/marketplace/status_closed');
1034
- $this->payOrder($order);
1035
- break;
1036
- case "Canceled" :
1037
- $this->debugLog("Setting Order Status to Cancelled");
1038
- $retorno = $helper->getConfig('beezup/marketplace/status_cancelled');
1039
-
1040
- break;
1041
- case "Shipped" :
1042
- $this->debugLog("Setting Order Status to Shipped");
1043
- $retorno = $helper->getConfig('beezup/marketplace/status_shipped');
1044
- $this->payOrder($order);
1045
- break;
1046
-
1047
- }
1048
- $order->setData('state',$retorno);
1049
- $order->setStatus($retorno);
1050
- $history = $order->addStatusHistoryComment('Order was set to '.$retorno.' by Beezup.', false);
1051
- $history->setIsCustomerNotified(false);
1052
- $order->save();
1053
  if($blnCancel) {
1054
- $order->cancel()->save();
1055
  }
1056
  if($blnHold) {
1057
- $order->hold()->save();
1058
  }
1059
-
1060
- return $retorno;
1061
-
1062
  }
1063
 
1064
 
1065
- public function getStatus($status1) {
1066
- $helper = Mage::helper('beezup');
1067
- $retorno = "";
1068
- $status = strtolower($status1);
1069
-
1070
  if($status == strtolower($helper->getConfig('beezup/marketplace/status_new') )) {
1071
- $retorno = "New";
1072
-
1073
  } elseif($status == strtolower($helper->getConfig('beezup/marketplace/status_progress') ) ){
1074
- $retorno = "InProgress";
 
1075
 
1076
-
1077
  }
1078
  elseif($status == strtolower($helper->getConfig('beezup/marketplace/status_aborted') )) {
1079
-
1080
- $retorno = "Aborted" ;
1081
  }
1082
  elseif($status == strtolower($helper->getConfig('beezup/marketplace/status_closed') )) {
1083
- $retorno = "Closed";
1084
-
1085
  }
1086
  elseif($status == strtolower($helper->getConfig('beezup/marketplace/status_cancelled')) ) {
1087
-
1088
- $retorno = "Canceled";
1089
  }
1090
  elseif($status == strtolower($helper->getConfig('beezup/marketplace/status_shipped') )) {
1091
-
1092
- $retorno = "Shipped";
1093
  }
1094
-
1095
-
1096
- return $retorno;
1097
-
1098
  }
1099
 
1100
 
1101
  public function checkMarketOrderExists($orderid) {
1102
- $resource = Mage::getSingleton('core/resource');
1103
- $readConnection = $resource->getConnection('core_read');
1104
- $table = $resource->getTableName('sales/order_grid');
1105
- $query = 'SELECT increment_id FROM ' . $table . ' WHERE beezup_order = 1 and beezup_market_order_id = \''
1106
- . $orderid . '\' LIMIT 1';
1107
- $order = $readConnection->fetchOne($query);
1108
- if($order && !empty($order) && $this->orderId !== "") {
1109
- return $order;
1110
- }
1111
- return false;
1112
-
1113
  }
1114
 
1115
  public function payOrder($order) {
1116
- try {
1117
- $this->debugLog("Generating Order Payment Invoice");
1118
- if($order->canInvoice()) {
1119
- $invoice = $order->prepareInvoice()
1120
- ->setTransactionId($order->getId())
1121
- ->addComment("Invoice created from Beezup.")
1122
- ->register()
1123
- ->pay();
1124
- $transaction_save = Mage::getModel('core/resource_transaction')
1125
- ->addObject($invoice)
1126
- ->addObject($invoice->getOrder());
1127
- $transaction_save->save();
1128
- $this->debugLog("Order Payment Invoice Generated Succesfully");
1129
- }
1130
  }
1131
  catch(Exception $e){
1132
- //log exception
1133
- $this->log->LogError($this->orderid."| Order Payment Invoice could not be generated, error: ".$e->getMessage());
1134
  $this->log2->LogError($this->orderid."| Order Payment Invoice could not be generated, error: ".$e->getMessage());
1135
- }
1136
  }
 
 
 
 
 
 
1137
 
1138
- }
1
  <?php
2
+ require_once dirname ( __FILE__ ) . "/../lib/KLogger.php";
3
+ require_once dirname ( __FILE__ ) . "/../lib/bootstrap.php";
4
+ require_once dirname ( __FILE__ ) . "/../lib/BeezupRepository.php";
5
+ require_once dirname ( __FILE__ ) . "/../lib/BeezupMageOrders.php";
 
 
6
 
7
+ class Beezup_Block_Order extends Mage_core_block_text {
8
+
9
+ protected $repository = null;
10
+ protected $oOrderService;
11
+ public $log = null;
12
+ public $log2 = null;
13
+ public $orderid = "";
14
+ public $debug = false;
15
+ public $blnCreateCustomer = false;
16
+ private $account_id;
17
+ private $marketplace_code;
18
+ private $beezup_order_id;
19
+ private $mage_order_id = false;
20
+
21
+ public function createOrderFromLink($account_id, $marketplace_code, $beezup_order_id) {
22
+ $logDir = Mage::getModuleDir('', 'BeezUp')."/log/";
23
+ if(file_exists($logDir."log2.txt")) {
24
  if(filesize($logDir."/log2.txt") >=3000000) {
25
+ unlink($logDir."log2.txt");
26
  }
27
+ }
28
+ $sync_end_date = new DateTime ( 'now', new DateTimeZone ( 'UTC' ));
29
+ $helper = Mage::helper('beezup');
30
+ $sync_status = $helper->getConfig('beezup/marketplace/sync_status');
31
+ $debug_mode = $helper->getConfig('beezup/marketplace/debug_mode');
32
+ $create_customer = $helper->getConfig("beezup/marketplace/create_customers");
33
+ if($create_customer == 0) {
34
+ $this->blnCreateCustomer = true;
35
+ }
36
+
37
+ if($debug_mode==1) {
38
+ $this->debug = true;
39
+ }
40
+ if($sync_status!==1) {
41
+ $configModel = Mage::getModel('core/config');
42
+ $configModel->saveConfig('beezup/marketplace/sync_status',1);
43
+
44
+
45
+
46
+ unlink($logDir."log.txt");
47
+ $this->log = new KLogger ( $logDir."log.txt" , KLogger::DEBUG );
48
+ $this->log2 = new KLogger ( $logDir."log2.txt" , KLogger::DEBUG );
49
+ $this->debugLog("Initializing OM Importation");
50
+ $shiiping_disabled = Mage::getStoreConfig('carriers/flatrate/active');
51
+
52
+ $this->account_id = $account_id;
53
+ $this->marketplace_code = $marketplace_code;
54
+ $this->beezup_order_id = $beezup_order_id;
55
+ $orderResponse = $this->getBeezupOrder();
56
+ if($orderResponse) {
57
+
58
+ if($shiiping_disabled == 0) {
59
+ Mage::getConfig()
60
+ ->saveConfig('carriers/flatrate/active', 1)
61
+ ->cleanCache();
62
+ Mage::app()->reinitStores();
63
+ }
64
+ $this->createOrder($orderResponse);
65
+ if($shiiping_disabled == 0) {
66
+ Mage::getConfig()
67
+ ->saveConfig('carriers/flatrate/active', 0)
68
+ ->cleanCache();
69
+ Mage::app()->reinitStores();
70
+ }
71
+ $configModel->saveConfig('beezup/marketplace/sync_status',0);
72
+ if($this->mage_order_id) {
73
+ echo "<script>window.location='".Mage::helper('adminhtml')->getUrl("adminhtml/sales_order/view", array('order_id'=> $this->mage_order_id))."';</script>";
74
+ }
75
+ // die("Order Importation finalized");
76
+
77
+ }
78
+
79
+ }
80
+ $configModel->saveConfig('beezup/marketplace/sync_status',0);
81
+ //die("Error, Order data incorrect");
82
+ echo $this->_showLog();
83
  }
84
 
85
+ public function _showLog() {
86
+ $logDir = Mage::getModuleDir('', 'BeezUp')."/log/";
87
+ // $log1 = file_get_contents();
88
+ $ret = array();
89
+ if (file_exists($logDir."/log.txt")) {
90
+ $f = fopen($logDir."/log.txt", 'r');
91
+
92
+ if ($f) {
93
+ while (!feof($f)) {
94
+ $ret[] = fgetcsv($f, 0, '|');
95
+ }
96
+ fclose($f);
97
+ }
98
+ }
99
+ array_slice(array_reverse($ret), 1, 10);
100
+
101
+ return $this->_getTable($ret);
102
+
103
  }
104
 
 
 
 
 
105
 
106
+ public function _getTable($data) {
107
+ $url = Mage::getBaseUrl( Mage_Core_Model_Store::URL_TYPE_WEB, true );
108
+ $html = "<td></td><td></td><tr></tr></tbody></table>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
109
 
110
+ <div class='grid' style=' height: 600px;overflow-y: scroll;padding: 16px;border: 3px solid #e6e6e6;' id='marketPlaceLogBlock'>";
111
+ $html .= '<p>'. Mage::helper('beezup')->__('For full logs see here:').' <a href="'.$url .'beezup/log/load" target="_blank">'.$url .'beezup/log/load</a></p>';
112
+ $html .= "<table class='data' style='margin-top:0px;width:100%;'>";
113
+ $html .= "<tr class='headings'>";
114
+ $html .= '<th><span class="nobr">Time</span></th>';
115
+ $html .= '<th><span class="nobr">Type</span></th>';
116
+ $html .= '<th><span class="nobr">Order Id</span></th>';
117
+ $html .= '<th><span class="nobr">Message</span></th>';
118
+ $html .= "</tr>";
119
+ $html .= "<tbody>";
120
+ foreach($data as $d) {
121
+ $background = " background: rgb(240, 184, 184)";
122
+ if($d[1] == " INFO " ) {
123
+ $background = " background: rgb(210, 227, 253)";
124
+ }
125
+ $orderId = (isset($d[3])) ? $d[2] : "";
126
+ $message = (isset($d[3])) ? $d[3] : $d[2];
127
+ $html .= "<tr class='even pointer' style='".$background."'>";
128
+ $html .= "<td>".$d[0]."</td>";
129
+ $html .= "<td>".$d[1]."</td>";
130
+ $html .= "<td>".$orderId."</td>";
131
+ $html .= "<td>".$message."</td>";
132
+ $html .= "</tr>";
133
+
134
+ }
135
+
136
+ $html .= "<tbody>";
137
+ $html .= '</table>';
138
+ $html .= "</div>";
139
+
140
+ return $html;
141
+ }
142
 
143
 
144
 
145
+ public function executeCron() {
146
+
147
+
148
+
149
+ set_time_limit(0);
150
+ $logDir = Mage::getModuleDir('', 'BeezUp')."/log/";
151
+ if(file_exists($logDir."log2.txt")) {
152
+ if(filesize($logDir."/log2.txt") >=3000000) {
153
+ unlink($logDir."log2.txt");
154
+ }
155
+ }
156
+
157
+ $sync_end_date = new DateTime ( 'now', new DateTimeZone ( 'UTC' ));
158
+ $helper = Mage::helper('beezup');
159
+ $sync_status = $helper->getConfig('beezup/marketplace/sync_status');
160
+ $debug_mode = $helper->getConfig('beezup/marketplace/debug_mode');
161
+ $create_customer = $helper->getConfig("beezup/marketplace/create_customers");
162
+ if($create_customer == 0) {
163
+ $this->blnCreateCustomer = true;
164
+ }
165
+
166
+ if($debug_mode==1) {
167
+ $this->debug = true;
168
+ }
169
+
170
+ if($sync_status!==1) {
171
+ $configModel = Mage::getModel('core/config');
172
+ $configModel->saveConfig('beezup/marketplace/sync_status',1);
173
+
174
+
175
+
176
+ unlink($logDir."log.txt");
177
+ $this->log = new KLogger ( $logDir."log.txt" , KLogger::DEBUG );
178
+ $this->log2 = new KLogger ( $logDir."log2.txt" , KLogger::DEBUG );
179
+ $this->debugLog("Initializing OM Importation");
180
+ $shiiping_disabled = Mage::getStoreConfig('');
181
+ if($shiiping_disabled == 0) {
182
+ Mage::getConfig()
183
+ ->saveConfig('carriers/flatrate/active', 1)
184
+ ->cleanCache();
185
+ Mage::app()->reinitStores();
186
+ }
187
+
188
+
189
+ $this->getOrderList();
190
+ if($shiiping_disabled == 0) {
191
+ Mage::getConfig()
192
+ ->saveConfig('carriers/flatrate/active', 0)
193
+ ->cleanCache();
194
+ Mage::app()->reinitStores();
195
+ }
196
+ $this->repository->updateLastSynchronizationDate( $sync_end_date);
197
+ $this->orderid = "";
198
+ $this->debugLog("OM Importation finalized succesfully");
199
+ $configModel->saveConfig('beezup/marketplace/sync_status',0);
200
+ echo "OM Importation finalized succesfully";
201
+
202
+ } else {
203
+
204
+ echo "Order Importation is already being executed";
205
+ }
206
 
 
207
  }
 
 
 
 
 
 
 
 
 
 
 
208
 
209
+
210
+ public function getLog() {
211
+ $logDir = Mage::getModuleDir('', 'BeezUp')."/log/";
212
+ $log1 = file_get_contents($logDir."/log2.txt");
213
+
214
+ echo "<pre>";
215
+ print_r($log1);
216
+ echo "</pre>";
217
+
218
+ }
219
+ public function getBeezupOrder() {
220
+
221
+ $oOrderIdentifier = $this->getBeezupOrderId();
222
+ $oBeezupOMOrderResponse = $this->getOrderService()->getOrder($oOrderIdentifier);
223
+ if ($oBeezupOMOrderResponse && $oBeezupOMOrderResponse->getResult()){
224
+ return $oBeezupOMOrderResponse;
225
  }
226
+
227
+
228
+ return false;
229
+ }
230
+
231
+ public function getBeezupOrderId(){
232
+ $oIdentifier = new BeezupOMOrderIdentifier();
233
+ $oIdentifier
234
+ ->setAccountId($this->account_id)
235
+ ->setMarketplaceTechnicalCode($this->marketplace_code)
236
+ ->setBeezupOrderUUID($this->beezup_order_id);
237
+ return $oIdentifier;
238
+ }
239
+
240
+
241
+ public function createOrder($oBeezupOrderResponse) {
242
+
243
+ $etag = $oBeezupOrderResponse->getETag();
244
+ $final_order = $oBeezupOrderResponse->getResult();
245
+
246
+ $orderid = $final_order->getOrderMarketPlaceOrderId();
 
 
 
 
 
 
247
  $this->orderid = $orderid;
248
  //customer Info
249
  $order_address = $final_order->getOrderBuyerAddressCity();
259
  $order_company = $final_order->getOrderBuyerCompanyName();
260
  $order_city = $final_order->getOrderBuyerAddressCity();
261
  $order_region = $final_order->getOrderBuyerStateOrRegion();
262
+ $order_status = $final_order->getOrderStatusBeezUPOrderStatus();
263
  //shipping information
264
  $shipping_city = $final_order->getOrderShippingAddressCity();
265
  $shipping_country = $final_order->getOrderShippingAddressCountryName();
288
 
289
 
290
  //marketplace information
291
+ $marketplace_business_code = $final_order->getMarketPlaceBusinessCode();
292
  $marketplace = $final_order->getMarketPlaceTechnicalCode();
293
+
294
  //productInfo
 
295
 
296
  $mage_productIds = $this->prescanOrder($final_order);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
297
 
298
+
299
+ if(!$this->checkEtagExists($etag)) {
300
+ if(empty($order_customer_email)) {
301
+ $order_customer_email = $this->generateEmail($final_order);
302
+ }
303
+ elseif(!filter_var($order_customer_email, FILTER_VALIDATE_EMAIL)) {
304
+ $order_customer_email = $this->generateEmail($final_order);
305
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
306
 
307
+ $mage_productIds = $this->prescanOrder($final_order);
308
+ if($mage_productIds) {
309
+ $order_data = array(
310
+ "etag" => $etag,
311
+ "account_id" => $account_id,
312
+ "order_status" => $order_status,
313
+ "products" => $mage_productIds['products'],
314
+ "storeid" => $mage_productIds['store'],
315
+ "order_currency" => $order_currency_code ,
316
+ "order_address" => $order_adress,
317
+ "order_country" => $order_country,
318
+ "order_country_iso" => $order_country_iso ,
319
+ "order_address" => $order_address ,
320
+ "order_postalCode" => $order_postalCode ,
321
+ "order_customer" => $order_first_name ,
322
+ "order_lastname" => $order_last_name ,
323
+ "order_customer_email" => $order_customer_email ,
324
+ "order_customer_phone" => $this->getPhone($order_customer_phone, $order_customer_mobile) ,
325
+ "order_comment" => $order_comment ,
326
+ "order_company" => $order_company ,
327
+ "shipping_city" => $shipping_city ,
328
+ "shipping_country" => $shipping_country ,
329
+ "shipping_country_iso" => $shipping_country_iso ,
330
+ "shipping_address" => $shipping_address ,
331
+ "shipping_name" => $shipping_first_name ,
332
+ "shipping_lastname" => $shipping_last_name ,
333
+ "shipping_postalCode" => $shipping_postalCode ,
334
+ "shipping_region" =>$shipping_region,
335
+ "shipping_email" => $shipping_email ,
336
+ "shipping_phone" => $this->getPhone($shipping_phone, $shipping_mobile) ,
337
+ "shipping_company" => $shipping_company ,
338
+ "order_totalPrice" => $order_totalPrice ,
339
+ "order_shippingPrice" => $order_shippingPrice ,
340
+ "order_city" => $order_city,
341
+ "order_region" => $order_region,
342
+ "marketplace" => $marketplace,
343
+ "discounts" => $mage_productIds['discounts'],
344
+ "marketplace_business_code" => $marketplace_business_code
345
+ );
346
+
347
 
348
+
349
+ //check if order exists
350
+ $Mageorder = $this->loadMageOrder();
351
+ if ($Mageorder) {
352
+ //if order exists
353
+ $this->updateEtag($etag);
354
+ $this->updateBilling($Mageorder, $order_data );
355
+ $this->updateBeezupInfoTab($Mageorder, $final_order, $order_data);
356
+ $this->debugLog("Order Already exists Mage Order ID: " .$Mageorder->getId());
357
+ $status1 = $Mageorder->getStatusLabel();
358
+ $status = $this->getStatus($status1);
359
+ if($status !== $order_status) {
360
+ //if order exits and status has changed we update order status
361
+ $this->debugLog("Updating Order Status from: ".$status1." to: ".$order_status );
362
+ $this->setStatus( $order_status, $Mageorder);
363
+ }
364
 
365
+ $id_order = $Mageorder->getId();
366
+ $BeezupMageOrder = new BeezupMageOrders($id_order);
367
+ $BeezupMageOrder->setData(array("shipping" =>(float) $order_data['order_shippingPrice']));
368
+ $BeezupMageOrder->updateShippingInfo();
369
  } else {
370
+ //if not we create order
371
+
372
+
373
+ $this->debugLog("Generating Order");
374
+ $this->addOrder($order_data,$final_order );
375
+ //die();
 
 
 
 
 
 
 
 
 
 
 
 
376
 
377
  }
 
378
 
379
+
380
+ } else {
381
+ //order could not be imported
382
+
383
+
384
+ }
385
+
386
+
387
+ } else {
388
+ //etag has not changed
389
+ $this->debugLog("Order Etag has not changed");
390
+
391
+ }
392
+
393
+
394
+
395
+
396
+
397
+ }
398
+
399
+
400
+
401
+ public function generateEmail(BeezupOMOrderResult $oBeezupOrder)
402
+ {
403
+ $sRawValue = $oBeezupOrder->getBeezupOrderUUID ();
404
+ $sFakeDomain = preg_replace ( '/\W/', '', $oBeezupOrder->getMarketPlaceTechnicalCode () ) . '.com';
405
+ return 'fakeemail' . md5 ( $sFakeDomain . $sRawValue ) . '@' . strtolower ( $sFakeDomain );
406
+ }
407
+
408
+
409
+
410
+ public function getOrderList($orderList = null) {
411
+ if($orderList == null) {
412
+ $data = $this->createRepository()->createOrderListRequest();
413
+ $oRequest = $this->getOrderService()->getClientProxy()->getOrderList($data);
414
+ $orderList = $oRequest->getResult();
415
+ }
416
+ $oPagination = $orderList->getPaginationResult();
417
+ if(!empty($oPagination)) {
418
+ $oLinksTotal = $oPagination->getLinks();
419
+ } else {
420
+ $configModel = Mage::getModel('core/config');
421
+ $configModel->saveConfig('beezup/marketplace/sync_status',0);
422
+ die("No more orders to import");
423
+ }
424
+
425
+ //$header = $orderList->getOrderHeaders();
426
+ foreach($orderList->getOrderHeaders() as $order) {
427
+ $order_status = $order->getBeezupOrderState();
428
+ $orderLinks = $order->getLinks();
429
+ $etag = $order->getETag();
430
+ $beezup_order_id = $order->getBeezupOrderUUID();
431
+ $account_id = $order->getAccountId();
432
+ $orderdata = $this->getOrderService()->getClientProxy()->getOrderByLink($orderLinks[0]);
433
+ $this->debugLog("Initializing Order - Link: ".$orderLinks[0]->getHref());
434
+ $this->createOrder($orderdata, $oLinksTotal);
435
+
436
+ }
437
+
438
+ if(!empty($oLinksTotal)) {
439
+ //we check if there is next link and get next orders
440
+ foreach($oLinksTotal as $link) {
441
+ if( $link->getRel() == "next") {
442
+
443
+ $this->log->LogInfo("Initializing New Order List ->". $link->getHref());
444
+ $this->log2->LogInfo("Initializing New Order List ->". $link->getHref());
445
+ $oRequest = $this->getOrderService()->getClientProxy()->getOrderListByLink($link);
446
+ $orderList = $oRequest->getResult();
447
+ $this->getOrderList($orderList);
448
+ }
449
+
450
  }
451
+ }
452
+
453
+ }
454
 
455
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
456
 
457
+ public function updateBeezupInfoTab($order, $oLink, $data) {
458
+ $beezup_last_modification_date = $oLink->getOrderLastModificationUtcDate();
459
+ $beezup_last_modification_date = $beezup_last_modification_date->date;
460
+ $beezup_marketplace_last_modification_date = $oLink->getOrderMarketPlaceLastModificationUtcDate();
461
+ $beezup_marketplace_last_modification_date = $beezup_marketplace_last_modification_date->date;
462
+ $beezup_comission = $oLink->getOrderTotalCommission()." ".$data['order_currency'];
463
+ $tot_comm = $oLink->getOrderTotalCommission();
464
+ if(empty($tot_comm ) || $tot_comm == 0) {
465
+ $beezup_comission = 0;
466
+ }
467
+ $updateData = array("beezup_status" => $data['order_status'],
468
+ "beezup_last_modification_date" => $beezup_last_modification_date,
469
+ "beezup_marketplace_last_modification_date" => $beezup_marketplace_last_modification_date ,
470
+ "beezup_total_paid" => $oLink->getOrderTotalPrice()." ".$data['order_currency'],
471
+ "beezup_comission" => $beezup_comission,
472
+ "beezup_marketplace_status" => $oLink->getOrderStatusMarketPlaceStatus());
473
+ $orderId = $order->getId();
474
+ $beezupMageOrder = new BeezupMageOrders($orderId);
475
+ $beezupMageOrder->setData($updateData);
476
+ $beezupMageOrder->updateBeezupInfo();
477
+
478
+
479
  }
480
+
481
+ public function getPhone($phone, $phone2) {
482
+ $retorno = "";
483
+ if(!empty($phone) && $phone !== "") {
484
+ $retorno .= $phone;
 
485
  }
486
+ if(!empty($phone2) && $phone2 !=="") {
487
+ if(empty($phone) || $phone == "") {
488
+ $retorno = $phone2;
489
+
490
+ } else {
491
+ $retorno .= " - ".$phone2;
492
+ }
493
+ }
494
+ return $retorno;
495
  }
496
+
497
+
498
+ public function getBeezupBuyerAddress($order) {
 
 
499
  $add1=$order->getOrderBuyerAddressLine1();
500
  $add2=$order->getOrderBuyerAddressLine2();
501
  $add3=$order->getOrderBuyerAddressLine3();
502
  $retorno = "";
503
+ if(!empty($add1)) {
504
+ $retorno = $order->getOrderBuyerAddressLine1();
505
+ }
506
+ if(!empty($add2)) {
507
+ if(empty($add1)) {
508
+ $retorno .= $order->getOrderBuyerAddressLine2();
509
+ } else {
510
+ $retorno .= " - ". $order->getOrderBuyerAddressLine2();
511
+ }
512
+ }
513
  if(!empty($add3)){
514
+ if(empty($add1) && empty($add2)) {
515
+ $retorno .= $order->getOrderBuyerAddressLine3();
516
+ } else {
517
+ $retorno .= " - ". $order->getOrderBuyerAddressLine3();
518
+ }
519
+ }
520
+ return $retorno;
521
+ }
522
+
523
+
524
  public function getBeezupShippingAddress($order) {
525
  $add1 = $order->getOrderShippingAddressLine1();
526
  $add2 = $order->getOrderShippingAddressLine2();
527
  $add3=$order->getOrderBuyerAddressLine3();
528
+ $retorno = "";
529
+ if(!empty($add1 )) {
530
+ $retorno = $order->getOrderShippingAddressLine1();
531
+ }
532
+ if(!empty($add2)) {
533
+ if(empty($add1)) {
534
+ $retorno .= $order->getOrderShippingAddressLine2();
535
+ } else {
536
+ $retorno .= " - ". $order->getOrderShippingAddressLine2();
537
+ }
538
+ }
539
  if(!empty($add3)){
540
  if(empty($add1) && empty($add2)) {
541
  $retorno .= $order->getOrderShippingAddressLine3();
542
+ } else {
543
+ $retorno .= " - ". $order->getOrderShippingAddressLine3();
544
  }
545
+ }
546
+ return $retorno;
547
+ }
548
+
549
  public function checkEtagExists($etag) {
550
+ $resource = Mage::getSingleton('core/resource');
551
+ $readConnection = $resource->getConnection('core_read');
552
+ $table = $resource->getTableName('sales/order_grid');
553
+ $query = 'SELECT increment_id FROM ' . $table . ' WHERE beezup_etag = \''
554
+ . $etag . '\' LIMIT 1';
555
+ $order = $readConnection->fetchOne($query);
556
+ if($order && !empty($order)) {
557
+ return true;
558
+ }
559
+ return false;
560
+
561
+ }
562
+
563
 
 
564
  public function updateEtag($etag) {
565
  $this->debugLog("Updating Etag");
566
  $resource = Mage::getSingleton('core/resource');
572
  }
573
 
574
 
575
+
576
+ public function updateBilling($order, $data) {
577
+
578
+
579
+ $addressData = array(
580
+ 'billing_firstname' => ($data['order_customer']) ? $data['order_customer'] : "empty",
581
+ 'billing_lastname' => ($data['order_lastname']) ? $data['order_lastname'] : "empty",
582
+ 'billing_street' => ($data['order_address']) ? $data['order_address'] : "empty",
583
+ 'billing_city' => ($data['order_city']) ? $data['order_city'] : "empty",
584
+ 'billing_postcode' => ($data['order_postalCode']) ? $data['order_postalCode'] : "empty",
585
+ 'billing_telephone' => ($data['order_customer_phone']) ? $data['order_customer_phone'] : "empty",
586
+ 'billing_country_id' => ($data['order_country_iso']) ? $data['order_country_iso'] : "empty",
587
+ 'billing_region_id' => ($data['order_region ']) ? substr($data['order_region '], 0,2) : "EM",
588
  'shipping_firstname' => ($data['shipping_name']) ? $data['shipping_name'] : "empty",
589
+ 'shipping_lastname' => ($data['shipping_lastname']) ? $data['shipping_lastname'] : "empty",
590
+ 'shipping_street' => ($data['shipping_address']) ? $data['shipping_address'] : "empty",
591
+ 'shipping_city' => ($data['shipping_city']) ? $data['shipping_city'] : "empty",
592
+ 'shipping_postcode' => ($data['shipping_postalCode']) ? $data['shipping_postalCode'] : "empty",
593
+ 'shipping_telephone' => ($data['shipping_phone']) ? $data['shipping_phone'] : "empty",
594
+ 'shipping_country_id' => ($data['shipping_country_iso']) ? $data['shipping_country_iso'] : "empty",
595
+ 'shipping_region_id' => ($data['shipping_region']) ? substr($data['shipping_region'], 0, 2) : "EM" // id from directory_country_region table
596
+ );
597
+
598
+ $shippingData = array(
599
+
600
+ );
601
+ // Get the id of the orders shipping address
602
+ $orderId = $order->getId();
603
+ $beezupMageOrder = new BeezupMageOrders($orderId);
604
+ $beezupMageOrder->setData($addressData);
605
+ $beezupMageOrder->updateAdresses();
606
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
607
 
608
+ public function updateAddresses($shippingData, $address) {
609
+ if($shippingData['firstname'] !==$address['firstname']) {
610
+ $address->setFirstname($shippingData['firstname']);
611
+ }
612
+ if($shippingData['lastname'] !==$address['lastname']) {
613
+ $address->setLastname($shippingData['lastname']);
614
+ }
615
+ if($shippingData['street'] !==$address['street']) {
616
+ $address->setStreet($shippingData['street']);
617
+ }
618
+ if($shippingData['city'] !==$address['city']) {
619
+ $address->setCity($shippingData['city']);
620
+ }
621
+ if($shippingData['postcode'] !==$address['postcode']) {
622
+ $address->setPostcode($shippingData['postcode']);
623
+ }
624
+ if($shippingData['telephone'] !==$address['telephone']) {
625
+ $address->setTelephone($shippingData['telephone']);
626
+ }
627
+ $address->save();
628
+
629
+
630
+ }
631
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
632
 
633
+ public function loadMageOrder() {
634
+ $Mageorder = Mage::getModel('sales/order')->loadByIncrementId($this->orderid);
635
+ if ($Mageorder->getId()) {
636
+ return $Mageorder;
637
+ } else {
638
+ //we get order from marketplace orderid
639
+ $orderInc = $this->checkMarketOrderExists($this->orderid);
640
+ if($orderInc) {
641
+ // if exists
642
+ $Mageorder = Mage::getModel('sales/order')->loadByIncrementId($orderInc);
643
+ if ($Mageorder->getId()) {
644
+ return $Mageorder;
645
+ }
646
+ }
647
+ }
648
+ return false;
649
+ }
650
+
651
+
652
+ private function debugLog($message) {
653
+
654
  if($this->orderid !== "") {
655
  $message = $this->orderid." | ".$message;
656
  }
657
  $this->log->LogInfo($message);
658
+
659
+ $this->log2->LogInfo($message);
660
+ }
661
 
662
+ public function prescanOrder(BeezupOMOrderResult $order) {
663
+ $retorno = array();
664
+ $orderItems = $order->getOrderItems();
665
+ foreach ($orderItems as $item)
 
 
 
 
 
 
666
  {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
667
 
668
+ if ($item->getOrderItemOrderItemType () !== 'Product')
669
+ {
670
+ // continue;
 
 
 
671
  }
672
+ $beezup_store = $item->getOrderItemBeezUPStoreId(); //beezup storeid
673
+ $mage_storeid = $this->checkOrderStore($beezup_store); //magento storeid
674
+ $marketplace_orderid = $item->getOrderItemMarketPlaceProductId();
675
+ if(!$mage_storeid) {
676
+
677
+ if(strpos($marketplace_orderid,'INTERETBCA') !== false || strpos($marketplace_orderid,'interetbca') !== false) { }
678
+ else {
679
+ $this->log->LogError($this->orderid." | No mapping for store ".$beezup_store);
680
+ $this->log2->LogError($this->orderid." | No mapping for store ".$beezup_store);
681
+ return false;
682
+ }
683
+
684
+ }
685
+ // $retorno['store'] = 1;
686
+ $retorno['store'] = $mage_storeid;
687
+ $this->debugLog("Store Matching succesful, Beezup Store: ".$beezup_store." , Magento Store Id: ".$mage_storeid);
688
+ $product_ImportedMerchantId = $item->getOrderItemMerchantImportedProductId();
689
+ $product_MerchantId = $item->getOrderItemMerchantProductId();
690
+
691
+ $product_quantity = $item->getOrderItemQuantity();
692
+ $product_price = $item->getOrderItemItemPrice();
693
+ $product_title = $item->getOrderItemTitle();
694
+ $product_image = $item->getOrderItemImageUrl();
695
+ if(strpos($marketplace_orderid,'INTERETBCA') !== false || strpos($marketplace_orderid,'interetbca') !== false) {
696
+ $retorno['discounts']= $item->getOrderItemTotalPrice();
697
+ } else {
698
+ $product = $this->getMageProduct($product_ImportedMerchantId , $product_MerchantId , $beezup_store );
699
+ if($product) {
700
+ $mage_productId = $product->getId();
701
+ $stocklevel = (int)Mage::getModel('cataloginventory/stock_item')
702
+ ->loadByProduct($product)->getQty();
703
+
704
+ $retorno['products'][] = array("id" => $mage_productId, "qty" => $product_quantity, "price" => $product_price, "curr_stock" => $stocklevel);
705
+ //producto existe
706
+ } else {
707
+ //vendria if de si activada opcion de crear producto creamos
708
+ if(!$this->debug) {
709
+ return false;
710
+ }
711
+ $product_data = array(
712
  "sku" => $product_ImportedMerchantId,
713
  "sku2" => $product_MerchantId,
714
  "qty" => $product_quantity,
716
  "title" => $product_title,
717
  "image" => $product_image,
718
  "storeId" => $mage_storeid
719
+ );
720
+ $product = $this->createProduct($product_data);
721
+ if(!$product) {
722
+ return false;
723
+ }
724
+ $stocklevel = (int)Mage::getModel('cataloginventory/stock_item')
725
+ ->loadByProduct($product)->getQty();
726
+ $mage_productId = $product->getId();
727
+ $retorno['products'][] = array("id" => $mage_productId, "qty" => $product_quantity, "price" => $product_price, "curr_stock" => $stocklevel);
728
  }
729
+ }
 
 
 
730
  }
731
+
732
+ return $retorno;
733
  }
734
+
735
+
736
+
737
+ public function matchProductAttributes($importedId, $storeId) {
738
+ $product = null;
739
+ $helper = Mage::helper('beezup');
740
+ $attributes = $helper->getConfig('beezup/marketplace/attributes');
741
+ $attributes = unserialize ($attributes);
742
+
743
+ foreach($attributes['attributes'][$storeId ] as $attribute) {
744
+ $att = explode("|", $attribute);
745
+ if($storeId == $att[1]) {
746
+
747
+ $product=Mage::getModel('catalog/product')->loadByAttribute($att[0],$importedId);
748
+ if($product) {
749
+ break;
750
+ }
751
+ }
752
+ }
753
+
754
+ return $product;
755
  }
756
 
757
+
758
+
759
+ public function getMageProduct($importedId, $merchantId, $storeId){
760
+ try {
761
+ $product=Mage::getModel('catalog/product')->load($importedId);
762
+ if (!$product->getId() || $product->getId() !== $importedId ){
763
+ $product = $this->matchProductAttributes($importedId, $storeId);
764
+ if($product == null || !is_object($product)) {
765
+ $product=Mage::getModel('catalog/product')->load($merchantId);
766
+ if(!$product->getId() || $product->getId() !== $merchantId ) {
767
+ $product = $this->matchProductAttributes($merchantId, $storeId);
768
+
 
 
 
 
 
 
 
769
  }
770
  }
771
+ }
772
+
773
+ if(is_object($product)) {
774
+ if($product->getId()) {
775
+ $this->debugLog("Product Matching succesful, Beezup Imported Id: ".$importedId." , Magento Product Id: ".$product->getId());
776
+ return $product;
777
+ }}
778
+ $this->log->LogError($this->orderid. "| No Product Matching, Product ".$importedId." could not be found");
779
+ $this->log2->LogError($this->orderid. "| No Product Matching, Product ".$importedId." could not be found");
780
+ return false;
781
+ }catch(Exception $e){
782
+ $this->log->LogError($this->orderid. "| Product ".$importedId." could not be found, error: ".$e->getMessage());
783
+ $this->log2->LogError($this->orderid. "| Product ".$importedId." could not be found, error: ".$e->getMessage());
784
+ return false;
785
+ //error no se pudo crear la orden
786
+
787
  }
788
  }
789
+
790
+
791
+ public function checkOrderStore($storeId ) {
792
+ $helper = Mage::helper('beezup');
793
+ $stores = $helper->getConfig('beezup/marketplace/stores');
794
+ $stores = unserialize ($stores);
795
+ foreach($stores as $store) {
796
+ if(isset($store[$storeId]) && $store[$storeId] > 0) {
797
+ return $store[$storeId];
798
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
799
  }
 
800
  return false;
801
  }
802
+
803
+
804
+
805
  /**
806
+ * @return BeezupOMOrderService
807
+ */
808
  public function getOrderService(){
809
  if ($this->oOrderService === null){
810
  $this->oOrderService = $this->createOrderService();
811
+ // enchufamos debug mode, esta activado? false true $this->oOrderService->setDebugMode(false);
812
  }
813
  return $this->oOrderService;
814
  }
815
+
816
  /**
817
+ * @return BeezupOMOrderService
818
+ */
819
  protected function createOrderService(){
820
+
821
  return new BeezupOMOrderService($this->createRepository() );
822
  }
823
 
824
  protected function createRepository() {
825
  if ($this->repository == null) {
826
+ $this->repository = new BeezupRepository();
827
  }
828
+ return $this->repository;
829
 
830
  }
 
 
 
 
 
831
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
832
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
833
 
834
+
835
+ private function createCustomer($customer_email , $data) {
836
+ $password = $this->orderid;
837
+ $this->debugLog("Creating new Customer");
838
+ $customer = Mage::getModel('customer/customer');
839
+ $customer->setWebsiteId(Mage::app()->getWebsite()->getId());
840
+ $customer->loadByEmail($customer_email);
841
+ if(!$customer->getId()) {
842
+ $customer->setEmail($customer_email);
843
+ $customer->setFirstname($data['firstname']);
844
+ $customer->setLastname($data['lastname']);
845
+ $customer->setPassword($password);
846
+ try {
847
+ $customer->save();
848
+ $customer->setConfirmation(null);
849
+ $customer->save();
850
+ $this->debugLog("Customer created succesfully");
851
+ return $customer;
852
+ //Make a "login" of new customer
853
+ // Mage::getSingleton('customer/session')->loginById($customer->getId());
854
+ }
855
+
856
+ catch (Exception $ex) {
857
+ //Zend_Debug::dump($ex->getMessage());
858
+ //GUARDAR ERROR CREACION USUARIO
859
+ $this->log2->LogError($this->orderid. " | Customer importation failed: ".$ex->getMessage());
860
+ return false;
861
+ }
862
+
863
+ } else {
864
+ $this->debugLog("Creating already exists, returning customer object");
865
+ return $customer;
866
+ }
867
  }
868
+
869
+
870
+
871
+ public function addOrder($data, $oLink, $stop = false) {
872
+
873
+
874
+ try {
875
+ $helper = Mage::helper('beezup');
876
+ $addStock = $helper->getConfig('beezup/marketplace/available_products');
877
+ $baseCurrencyCode = Mage::app()->getStore()->getBaseCurrencyCode();
878
+ $quote = Mage::getModel('sales/quote')
879
+ ->setStoreId($data['storeid']);
880
+ $quote->setCustomerEmail($data['order_customer_email']);
881
+
882
+
883
+ $currency = Mage::getModel('directory/currency')->load($data['order_currency']);
884
+ $quote->setForcedCurrency($currency);
885
+
886
+ $blnCreate = true;
887
+ $total_new_price = 0;
888
+ foreach($data['products'] as $prod) {
889
+ if($prod['qty']==0) {
890
+ $blnCreate = false;
891
+ break;
892
+ }
893
+ $prod_totality_price = $prod['price']*$prod['qty'];
894
+ $total_new_price = $total_new_price + $prod_totality_price;
895
+ $product = Mage::getModel('catalog/product')->load($prod['id']);
896
+ $buyInfo = array(
897
+ 'qty' => $prod['qty'],
898
+ );
899
+ $this->debugLog("Adding ".$prod['qty']." product/s with id ".$product->getId()." to order, with Beezup Price: ".$prod['price']);
900
+ //echo "Product ".$product->getId()."<br><br>";
901
+ //para no perder stock:
902
+ //Mage::getModel('cataloginventory/stock')->backItemQty($productId,$new_qty);
903
 
 
 
 
904
 
905
+ if($addStock == 1) {
906
+ $stock = Mage::getModel('cataloginventory/stock_item')->loadByProduct($product);
907
+
908
+ if ($stock->getQty() < $prod['qty'] && $product->getStockItem()->getMaxSaleQty() >= $prod['qty']) {
909
+ $this->debugLog("Product ".$product->getId()." Stock = 0, Updating to ".$prod['qty']." to generate Order");
910
+ // Mage::getModel('cataloginventory/stock')->backItemQty($product->getId(),$prod['qty']);
911
+ //$this->_updateStocks(array("id_product" => $product->getId(), "qty" => $prod['qty']));
912
+ $product->setStockData(
913
+ array(
914
+ 'is_in_stock' => 1,
915
+ 'qty' => $prod['qty'],
916
+ 'manage_stock' => 1,
917
+ 'use_config_notify_stock_qty' => 1
918
+ )
919
+ );
920
+ $product->save();
921
+ $product = Mage::getModel('catalog/product')->load($product->getId());
922
+
923
+ }
924
+ }
925
+ //fin para no perder stock
926
+
927
+ /*
928
+ $tax_class = $product->getTaxClassId();
929
+ $product->setTaxClassId(0);
930
+ $product->getResource()->saveAttribute($product, 'tax_class_id'); */
931
+ $price = $prod['price'];
932
+
933
+ $quote_item = Mage::getModel('beezup/quote_item');
934
+ $quote_item
935
+ ->setProduct($product)
936
+ ->setPrice((float) $price )
937
+ ->setCustomPrice((float)$price )
938
+ ->setOriginalCustomPrice((float) $price )
939
+ ->setQuote($quote)
940
+ ->setQty((integer) $prod['qty'])
941
+ ->setBeezupPrice((float) $price );
942
+
943
+
944
+ $quote->addItem($quote_item);
945
+
946
+ //$quote->addProduct($product, new Varien_Object($buyInfo))->setOriginalCustomPrice($price)->setCustomPrice($price);
947
 
948
+ /*
949
+ $product->setTaxClassId($tax_class);
950
+
951
+ $product->getResource()->saveAttribute($product, 'tax_class_id');
952
+ */
953
+ }
954
+
955
+ if($blnCreate) {
956
+ $addressData = array(
957
+ 'firstname' => ($data['order_customer']) ? $data['order_customer'] : "empty",
958
+ 'lastname' => ($data['order_lastname']) ? $data['order_lastname'] : "empty",
959
+ 'street' => ($data['order_address']) ? $data['order_address'] : "empty",
960
+ 'city' => ($data['order_city']) ? $data['order_city'] : "empty",
961
+ 'postcode' => ($data['order_postalCode']) ? $data['order_postalCode'] : "empty",
962
+ 'telephone' => ($data['order_customer_phone']) ? $data['order_customer_phone'] : "empty",
963
+ 'country_id' => ($data['order_country_iso']) ? $data['order_country_iso'] : "empty",
964
+ 'region_id' => ($data['order_region ']) ? substr($data['order_region '], 0,2) : "EM"// id from directory_country_region table
965
+ );
966
+
967
+ $shippingData = array(
968
+ 'firstname' => ($data['shipping_name']) ? $data['shipping_name'] : "empty",
969
+ 'lastname' => ($data['shipping_lastname']) ? $data['shipping_lastname'] : "empty",
970
+ 'street' => ($data['shipping_address']) ? $data['shipping_address'] : "empty",
971
+ 'city' => ($data['shipping_city']) ? $data['shipping_city'] : "empty",
972
+ 'postcode' => ($data['shipping_postalCode']) ? $data['shipping_postalCode'] : "empty",
973
+ 'telephone' => ($data['shipping_phone']) ? $data['shipping_phone'] : "empty",
974
+ 'country_id' => ($data['shipping_country_iso']) ? $data['shipping_country_iso'] : "empty",
975
+ 'region_id' => ($data['shipping_region']) ? substr($data['shipping_region'], 0, 2) : "EM" // id from directory_country_region table
976
+ );
977
+
978
+ if($this->blnCreateCustomer) {
979
+
980
+ $mage_customer = $this->createCustomer($data['order_customer_email'], $addressData);
981
+ $quote->assignCustomer($mage_customer);
982
+ }
983
+
984
+
985
+ $payment_method = $helper->getConfig('beezup/marketplace/payment_method');
986
+ $billingAddress = $quote->getBillingAddress()->addData($addressData);
987
+ $shippingAddress = $quote->getShippingAddress()->addData($shippingData);
988
+ $shipping_cost = (float) $data['order_shippingPrice'];
989
+ if($data['order_shippingPrice'] == 0) {
990
+ $shipping_cost = 20000;
991
+ }
992
+ $total_new_price = $total_new_price + $data['order_shippingPrice'] ;
993
+ Mage::unregister('shipping_cost');
994
+ Mage::register('shipping_cost', $shipping_cost);
995
+ $this->debugLog("Adding Order Shipping Cost: ". $data['order_shippingPrice']);
996
+
997
+ $shippingAddress->setCollectShippingRates(true)->collectShippingRates()
998
+ ->setShippingMethod('flatrate_flatrate')
999
+ ->setPaymentMethod($payment_method);
1000
+
1001
+ //$shippingAddress->addTotal(array("code" => "specialfee", "title" => "Special Fee", "value" => 20));
1002
+ $quote->getPayment()->importData(array('method' => $payment_method));
1003
+
1004
+ $quote->collectTotals()->save();
1005
+
1006
+ $service = Mage::getModel('sales/service_quote', $quote);
1007
+ $service->submitAll();
1008
+ $order = $service->getOrder();
1009
+
1010
+
1011
+
1012
+ $quoteId = $order->getQuoteId();
1013
+ //$this->setStatus($data['order_status'], $order);
1014
+
1015
+ $orderid = $order->getId();
1016
+
1017
+ $resource = Mage::getSingleton('core/resource');
1018
+ $writeConnection = $resource->getConnection('core_write');
1019
+ $table = $resource->getTableName('sales/order_grid');
1020
+ $this->debugLog("Adding Beezup Marketplace Information to Order");
1021
+ $marketplace = $data['marketplace'];
1022
+ $marketplace_business_code = ucfirst(strtolower($data['marketplace_business_code']));
1023
+ $beezup_name = $data['order_customer'];
1024
+ $market_order_id =$this->orderid;
1025
+ $beezup_order_id = $oLink->getBeezupOrderUUID();
1026
+ $beezup_status = $data['order_status'];
1027
+ $beezup_last_modification_date = $oLink->getOrderLastModificationUtcDate();
1028
+ $beezup_last_modification_date = $beezup_last_modification_date->date;
1029
+ $beezup_marketplace_status = $oLink->getOrderStatusMarketPlaceStatus();
1030
+ $beezup_purchase_date = $oLink->getOrderPurchaseUtcDate();
1031
+ $beezup_purchase_date = $beezup_purchase_date->date;
1032
+ $beezup_marketplace_last_modification_date = $oLink->getOrderMarketPlaceLastModificationUtcDate();
1033
+ $beezup_marketplace_last_modification_date = $beezup_marketplace_last_modification_date->date;
1034
+ /* $date = new DateTime($$beezup_marketplace_last_modification_date);
1035
+ $beezup_marketplace_last_modification_date = $date->format('d-m-Y H:i:s'). "(UTC Time)";
1036
+ */
1037
+
1038
+ $beezup_total_paid = $oLink->getOrderTotalPrice()." ".$data['order_currency'];
1039
+ $beezup_account_id = $oLink->getAccountId();
1040
+ $beezup_comission = $oLink->getOrderTotalCommission()." ".$data['order_currency'];
1041
+ $tot_comm = $oLink->getOrderTotalCommission();
1042
+ if(empty($tot_comm ) || $tot_comm == 0) {
1043
+ $beezup_comission = 0;
1044
+ }
1045
+ $query = "UPDATE {$table} SET beezup_marketplace = '{$marketplace}', beezup_name = '{$beezup_account_id}', beezup_order = 1, beezup_market_order_id = '{$market_order_id}',
1046
+ beezup_order_id = '{$beezup_order_id}', beezup_status = '{$beezup_status}', beezup_last_modification_date = '{$beezup_last_modification_date}',
1047
+ beezup_marketplace_status = '{$beezup_marketplace_status}', beezup_purchase_date = '{$beezup_purchase_date}', beezup_marketplace_last_modification_date = '{$beezup_marketplace_last_modification_date}',
1048
+ beezup_total_paid = '{$beezup_total_paid}', beezup_etag = '{$data['etag']}' , beezup_comission = '{$beezup_comission}', beezup_marketplace_business_code = '{$marketplace_business_code}'
1049
+ WHERE entity_id = ". (int)$orderid;
1050
+ $writeConnection->query($query);
1051
+ $disc_price = 0;
1052
+ if(!empty($data['discounts']) && $data['discounts'] >0) {
1053
+
1054
+
1055
+ $disc_price = round($data['discounts'],2);
1056
+ $total_new_price = $total_new_price+$disc_price;
1057
+ $table_address = $resource->getTableName("sales/quote_address");
1058
+
1059
+ $query = "update {$table_address} set beezup_fee = '{$disc_price}' where quote_id = '{$quoteId}' and address_type = 'shipping'";
1060
+ $writeConnection->query($query);
1061
+ $this->debugLog("Adding CDISCOUNT products with total price: ".$disc_price);
1062
+ }
1063
+
1064
+ //if order id exists and has been created
1065
+ if ($orderid)
1066
+ {
1067
+ //we send order id to beezup
1068
+ $this->debugLog("Sending Magento Order Id to Beezup, Magento Order Id: ".$orderid);
1069
+ $oResult = new BeezupOMSetOrderIdValues ();
1070
+ $oResult->setOrderMerchantOrderId ( $orderid )->setOrderMerchantECommerceSoftwareName ( 'Magento' )->setOrderMerchantECommerceSoftwareVersion ( Mage::getVersion() );
1071
+ $sendRequest = $this->getOrderService()->getClientProxy()->setOrderMerchantIdByLink($oLink->getLinkByRel('setMerchantOrderId'), $oResult);
1072
+ }
1073
+
1074
+ $grand_total = $order->getGrandTotal();
1075
+ $beezup_price = $oLink->getOrderTotalPrice() - $disc_price;
1076
+ if($grand_total != (float) $beezup_price && $beezup_price > 0) {
1077
+ $order->setGrandTotal((float) $beezup_price);
1078
+ $order->setBaseGrandTotal((float) $beezup_price);
1079
+ $diff = (((float) $beezup_price) - $grand_total);
1080
+
1081
+ $order->setTaxAmount($order->getTaxAmount() + $diff);
1082
+ $order->save();
1083
+ }elseif($grand_total != (float)$beezup_price && $beezup_price < 1) {
1084
+
1085
+ $order->setGrandTotal((float) $total_new_price);
1086
+ $order->setBaseGrandTotal((float) $total_new_price);
1087
+ $diff = (((float) $total_new_price) - $grand_total);
1088
+
1089
+ $order->setTaxAmount($order->getTaxAmount() + $diff);
1090
+ $order->save();
1091
+ }
1092
+
1093
+ $products = Mage::getResourceModel('sales/order_item_collection')
1094
+ ->setOrderFilter($orderid);
1095
+ foreach($products as $product) {
1096
+ $product->setBaseOriginalPrice($product->getOriginalPrice());
1097
+ $product->setBaseTaxAmount($product->getTaxAmount());
1098
+ $product->setBaseTaxInvoiced($product->getTaxAmount());
1099
+ $product->setBasePriceInclTax($product->getPriceInclTax());
1100
+ $product->setBaseRowTotalInclTax($product->getRowTotalInclTax());
1101
+ $product->save();
1102
+ }
1103
+ $order->setBaseTaxAmount($order->getTaxAmount());
1104
+ $order->setBaseTaxInvoiced($order->getTaxAmount());
1105
+ $order->setBaseTotalInvoiced($order->getTotalPaid());
1106
+ $order->setBaseTotalPaid($order->getTotalPaid());
1107
+ $order->setBaseGrandTotal($order->getTotalPaid());
1108
+ $order->setBaseSubtotalInclTax($order->getSubtotalInclTax());
1109
  $order->save();
1110
+
1111
+ $this->setStatus($data['order_status'], $order);
1112
+ $this->mage_order_id = $orderid;
1113
+ $this->debugLog("Order imported succesfully, Magento Order Id: ".$orderid);
1114
+ } else {
1115
+ //product stock = 0 we dont create order
1116
+ $this->log->LogError($this->orderid. "| Order ".$data['market_place_order_id']." could not be imported, error: Stock from Beezup product = 0 ");
1117
+ $this->log2->LogError($this->orderid. "| Order ".$data['market_place_order_id']." could not be imported, error: Stock from Beezup product = 0 ");
1118
  }
1119
+ }catch(Exception $e){
1120
+
1121
+
1122
+ if($stop) {
1123
+ $this->log->LogError($this->orderid. "| Order ".$data['market_place_order_id']." could not be imported, error: ".$e->getMessage());
1124
+ $this->log2->LogError($this->orderid. "| Order ".$data['market_place_order_id']." could not be imported, error: ".$e->getMessage());
1125
+ $this->restoreStock($data);
1126
+ } else {
1127
+ $this->debugLog("Order Import failed, Trying to import Order Again");
1128
+ $this->addOrder($data, $oLink, true);
1129
+
1130
+ }
1131
+ //error no se pudo crear la orden
1132
+
1133
+ }
1134
+
1135
+
1136
+
1137
+ }
1138
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1139
 
 
 
 
 
 
1140
 
1141
  public function restoreStock($data) {
1142
+
1143
  try {
1144
+ foreach($data['products'] as $prod) {
1145
+ $product = Mage::getModel('catalog/product')->load($prod['id']);
1146
+ $stock = Mage::getModel('cataloginventory/stock_item')->loadByProduct($product);
1147
+ if ($stock->getQty() != $prod['curr_stock'] ) {
1148
+ $this->debugLog("Restoring Stock from Product ".$product->getId()." to: ".$prod['curr_stock'] ." due to Order Fail");
1149
+ $stockItem = Mage::getModel('cataloginventory/stock_item')->loadByProduct($product);
1150
+ $stockItem->setData('is_in_stock', 0);
1151
+ $stockItem->setData('qty', $prod['curr_stock']);
1152
+ $stockItem->save();
1153
+ $product->save();
1154
+ }
1155
+
1156
+ }
1157
  } catch(Exception $e){
1158
+ $this->log->LogError($this->orderid. "| Failed Restoring Product Stock: ".$e->getMessage());
1159
+ $this->log2->LogError($this->orderid. "| Failed Restoring Product Stock: ".$e->getMessage());
1160
+ }
1161
+
1162
  }
 
 
1163
 
1164
 
1165
 
1166
  private function createProduct($data) {
1167
+
1168
  $sku = $data['sku'];
1169
+ if(empty($data['sku'])) {
1170
  $sku = $data['sku2'];
1171
+ }
1172
+
1173
+ Mage::app()->setCurrentStore($data['storeId']);
1174
+ $product = Mage::getModel('catalog/product');
1175
+ // if(!$product->getIdBySku('testsku61')):
1176
+
1177
+ try{
1178
+ $product
1179
+ // ->setStoreId(1) //you can set data in store scope
1180
+ ->setWebsiteIds(array($data['storeId'])) //website ID the product is assigned to, as an array
1181
+ ->setAttributeSetId($product->getDefaultAttributeSetId()) //ID of a attribute set named 'default'
1182
+ ->setTypeId('simple') //product type
1183
+ ->setCreatedAt(strtotime('now')) //product creation time
1184
+ ->setSku($sku ) //SKU
1185
  ->setWeight(0)
1186
+ ->setName($data['title']) //product name
1187
+ ->setStatus(1) //product status (1 - enabled, 2 - disabled)
1188
+ ->setTaxClassId(4) //tax class (0 - none, 1 - default, 2 - taxable, 4 - shipping)
1189
+ ->setVisibility(Mage_Catalog_Model_Product_Visibility::VISIBILITY_NOT_VISIBLE ) //catalog and search visibility
1190
+ ->setPrice($data['price']) //price in form 11.22
1191
+ ->setMsrpEnabled(1) //enable MAP
1192
+ ->setMsrpDisplayActualPriceType(1) //display actual price (1 - on gesture, 2 - in cart, 3 - before order confirmation, 4 - use config)
1193
+ ->setMsrp(0) //Manufacturer's Suggested Retail Price
1194
+ ->setMetaTitle('')
1195
+ ->setMetaKeyword('')
1196
+ ->setMetaDescription('')
1197
+ ->setDescription($data['title'])
1198
+ ->setShortDescription($data['title'])
1199
+ // ->setMediaGallery (array('images'=>array (), 'values'=>array ())) //media gallery initialization
1200
+ //->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
1201
+ ->setStockData(array(
1202
+ 'use_config_manage_stock' => 0, //'Use config settings' checkbox
1203
+ 'manage_stock'=>1, //manage stock
1204
+ 'min_sale_qty'=>1, //Minimum Qty Allowed in Shopping Cart
1205
+ 'max_sale_qty'=>2, //Maximum Qty Allowed in Shopping Cart
1206
+ 'is_in_stock' => 1, //Stock Availability
1207
+ 'qty' => 1 //qty
1208
+ )
1209
+ );
1210
+ $product->save();
1211
  return $product;
1212
+
1213
+ }catch(Exception $e){
1214
+ //log exception
1215
+ $this->log->LogError($this->orderid."| Product ".$sku." could not be created, error: ".$e->getMessage());
1216
+ $this->log2->LogError($this->orderid."| Product ".$sku." could not be created, error: ".$e->getMessage());
1217
  return false;
1218
+ }
1219
  }
1220
 
1221
 
1222
 
1223
  public function setStatus($status, $order) {
1224
+ $helper = Mage::helper('beezup');
1225
+ $retorno = "";
1226
+ $blnCancel = false;
1227
+ $blnHold = false;
1228
+ switch($status) {
1229
+ case "New" :
1230
+ $this->debugLog("Setting Order Status to New");
1231
+ $retorno = $helper->getConfig('beezup/marketplace/status_new');
1232
+ break;
1233
+ case "InProgress" :
1234
+ $this->debugLog("Setting Order Status to InProgress");
1235
+ $retorno = $helper->getConfig('beezup/marketplace/status_progress');
1236
+ $this->payOrder($order);
1237
+ break;
1238
+ case "Aborted" :
1239
+ $this->debugLog("Setting Order Status to Aborted");
1240
+ $retorno = $helper->getConfig('beezup/marketplace/status_aborted');
1241
+ $blnHold = true;
1242
+
1243
+
1244
+ break;
1245
+ case "Closed" :
1246
+ $this->debugLog("Setting Order Status to Closed");
1247
+ $blnCancel =true;
1248
+ $retorno = $helper->getConfig('beezup/marketplace/status_closed');
1249
+ $this->payOrder($order);
1250
+ break;
1251
+ case "Canceled" :
1252
+ $this->debugLog("Setting Order Status to Cancelled");
1253
+ $retorno = $helper->getConfig('beezup/marketplace/status_cancelled');
1254
+
1255
+ break;
1256
+ case "Shipped" :
1257
+ $this->debugLog("Setting Order Status to Shipped");
1258
+ $retorno = $helper->getConfig('beezup/marketplace/status_shipped');
1259
+ $this->payOrder($order);
1260
+ break;
1261
+
1262
+ }
1263
+ $order->setData('state',$retorno);
1264
+ $order->setStatus($retorno);
1265
+ $history = $order->addStatusHistoryComment('Order was set to '.$retorno.' by Beezup.', false);
1266
+ $history->setIsCustomerNotified(false);
1267
+ $order->save();
1268
  if($blnCancel) {
1269
+ $order->cancel()->save();
1270
  }
1271
  if($blnHold) {
1272
+ $order->hold()->save();
1273
  }
1274
+
1275
+ return $retorno;
1276
+
1277
  }
1278
 
1279
 
1280
+ public function getStatus($status1) {
1281
+ $helper = Mage::helper('beezup');
1282
+ $retorno = "";
1283
+ $status = strtolower($status1);
1284
+
1285
  if($status == strtolower($helper->getConfig('beezup/marketplace/status_new') )) {
1286
+ $retorno = "New";
1287
+
1288
  } elseif($status == strtolower($helper->getConfig('beezup/marketplace/status_progress') ) ){
1289
+ $retorno = "InProgress";
1290
+
1291
 
 
1292
  }
1293
  elseif($status == strtolower($helper->getConfig('beezup/marketplace/status_aborted') )) {
1294
+
1295
+ $retorno = "Aborted" ;
1296
  }
1297
  elseif($status == strtolower($helper->getConfig('beezup/marketplace/status_closed') )) {
1298
+ $retorno = "Closed";
1299
+
1300
  }
1301
  elseif($status == strtolower($helper->getConfig('beezup/marketplace/status_cancelled')) ) {
1302
+
1303
+ $retorno = "Canceled";
1304
  }
1305
  elseif($status == strtolower($helper->getConfig('beezup/marketplace/status_shipped') )) {
1306
+
1307
+ $retorno = "Shipped";
1308
  }
1309
+
1310
+
1311
+ return $retorno;
1312
+
1313
  }
1314
 
1315
 
1316
  public function checkMarketOrderExists($orderid) {
1317
+ $resource = Mage::getSingleton('core/resource');
1318
+ $readConnection = $resource->getConnection('core_read');
1319
+ $table = $resource->getTableName('sales/order_grid');
1320
+ $query = 'SELECT increment_id FROM ' . $table . ' WHERE beezup_order = 1 and beezup_market_order_id = \''
1321
+ . $orderid . '\' LIMIT 1';
1322
+ $order = $readConnection->fetchOne($query);
1323
+ if($order && !empty($order) && $this->orderId !== "") {
1324
+ return $order;
1325
+ }
1326
+ return false;
1327
+
1328
  }
1329
 
1330
  public function payOrder($order) {
1331
+ try {
1332
+ $this->debugLog("Generating Order Payment Invoice");
1333
+ if($order->canInvoice()) {
1334
+ $invoice = $order->prepareInvoice()
1335
+ ->setTransactionId($order->getId())
1336
+ ->addComment("Invoice created from Beezup.")
1337
+ ->register()
1338
+ ->pay();
1339
+ $transaction_save = Mage::getModel('core/resource_transaction')
1340
+ ->addObject($invoice)
1341
+ ->addObject($invoice->getOrder());
1342
+ $transaction_save->save();
1343
+ $this->debugLog("Order Payment Invoice Generated Succesfully");
1344
+ }
1345
  }
1346
  catch(Exception $e){
1347
+ //log exception
1348
+ $this->log->LogError($this->orderid."| Order Payment Invoice could not be generated, error: ".$e->getMessage());
1349
  $this->log2->LogError($this->orderid."| Order Payment Invoice could not be generated, error: ".$e->getMessage());
 
1350
  }
1351
+ }
1352
+
1353
+
1354
+
1355
+
1356
+
1357
 
1358
+ }
app/code/community/BeezUp/Block/Xml.php CHANGED
@@ -1,5 +1,6 @@
1
  <?php
2
  ini_set('memory_limit','1024M');
 
3
  class BeezUp_Block_Xml extends Mage_Core_Block_Text
4
  {
5
  /**
@@ -13,10 +14,20 @@
13
  $helper = Mage::helper('beezup');
14
  $category_logic = $helper->getConfig('beezup/flux/category_logic');
15
  /* Initially load the useful elements */
 
 
 
 
 
 
 
 
16
  $many_images = $helper->getConfig('beezup/flux/images');
17
  $_ht = $helper->getConfig('beezup/flux/ht');
18
  $_description = $helper->getConfig('beezup/flux/description');
19
- $_tablerates = $helper->getConfig('beezup/flux/tablerates_weight_destination') ? $beezup->getTablerates() : 0;
 
 
20
  $cat_logic = false;
21
  if($category_logic == 1) {
22
  $_categories = $beezup->getCategoriesAsArray(Mage::helper('catalog/category')->getStoreCategories());
@@ -32,10 +43,9 @@
32
 
33
  $_attributes = $helper->getConfig('beezup/flux/attributes') ? explode(',', $helper->getConfig('beezup/flux/attributes')) : array();
34
  $_vat = ($_ht && is_numeric($helper->getConfig('beezup/flux/vat'))) ? (preg_replace('(\,+)', '.', $helper->getConfig('beezup/flux/vat')) / 100) + 1 : 1;
35
- $_catalog_rules = $helper->getConfig('beezup/flux/catalog_rules');
36
-
37
  /* Build file */
38
- $xml = $helper->getConfig('beezup/flux/bom') ? "\xEF\xBB\xBF" : '';
39
  $xml .= '<?xml version="1.0" encoding="utf-8"?>' . PHP_EOL . '<catalog>' . PHP_EOL;
40
 
41
  $products = $beezup->getProducts();
@@ -43,9 +53,9 @@
43
  $backendModel = $products->getResource()->getAttribute('media_gallery')->getBackend();
44
  }
45
 
46
-
47
  foreach ($products as $p) {
48
- if($category_logic == 1) {
49
  $categories = $beezup->getProductsCategories($p, $_categories);
50
  } else {
51
 
@@ -62,14 +72,34 @@
62
  $image = $p->getSmallImage();
63
 
64
 
 
65
 
66
 
67
  $xml .= '<product>';
 
68
  $xml .= $helper->tag($this->__('b_unique_id'), $p->getId());
69
  $xml .= $helper->tag($this->__('b_sku'), trim($p->getSku()), 1);
70
  $xml .= $helper->tag($this->__('b_title'), trim($p->getName()), 1);
71
- $xml .= $helper->tag($this->__('b_description'), preg_replace("/(\r\n|\n|\r)/", ' ', strip_tags($p->getData($_description))), 1);
 
 
 
 
 
 
 
 
 
72
  $xml .= $helper->tag($this->__('b_product_url'), $p->getProductUrl(), 1);
 
 
 
 
 
 
 
 
 
73
 
74
 
75
 
@@ -91,28 +121,22 @@
91
 
92
  }
93
 
94
- /*
95
- //we get all category id's from product
96
- $currentCatIds = $product->getCategoryIds();
97
- //we get a collection of the categories from the ids
98
- $categoryCollection = Mage::getResourceModel('catalog/category_collection')
99
- ->addAttributeToSelect('name')
100
- ->addAttributeToSelect('url')
101
- ->addAttributeToFilter('entity_id', $currentCatIds)
102
- ->addIsActiveFilter();
103
- $inc_cat = 0;
104
- //loop through category collection to add to xml categories
105
- foreach($categoryCollection as $cat){
106
- $inc_cat++;
107
- $xml .= $helper->tag($this->__('b_product_category_'.$inc_cat), $cat->getUrl(), 1);
108
- } */
109
-
110
-
111
- // $xml .= $helper->tag($this->__('b_product_image'), $helper->getImageDir() . $image, 1);
112
  $xml .= $helper->tag($this->__('b_availability'), $stock, 1);
113
  $xml .= $helper->tag($this->__('b_qty'), $qty);
114
  $xml .= $helper->tag($this->__('b_delivery'), $shipping, 1);
115
- $xml .= $helper->tag($this->__('b_shipping'), $helper->currency($beezup->getShippingAmount($p->getWeight(), $_tablerates)));
 
 
 
 
 
 
 
 
 
 
 
116
  $xml .= $helper->tag($this->__('b_weight'), $helper->currency($p->getWeight()));
117
  $xml .= $helper->tag($this->__('b_price'), $helper->currency($final_price*$_vat));
118
  if ($price != $final_price) $xml .= $helper->tag($this->__('b_regular_price'), $helper->currency($price*$_vat));
@@ -145,10 +169,18 @@
145
  $helper = Mage::helper('beezup');
146
  $category_logic = $helper->getConfig('beezup/flux/category_logic');
147
  /* Initially load the useful elements */
 
 
 
 
 
 
148
  $many_images = $helper->getConfig('beezup/flux/images');
149
  $_ht = $helper->getConfig('beezup/flux/ht');
150
- $_description = $helper->getConfig('beezup/flux/description');
151
- $_tablerates = $helper->getConfig('beezup/flux/tablerates_weight_destination') ? $beezup->getTablerates() : 0;
 
 
152
  $cat_logic = false;
153
  if($category_logic == 1) {
154
  $_categories = $beezup->getCategoriesAsArray(Mage::helper('catalog/category')->getStoreCategories());
@@ -163,10 +195,10 @@
163
  }
164
  $_attributes = $helper->getConfig('beezup/flux/attributes') ? explode(',', $helper->getConfig('beezup/flux/attributes')) : array();
165
  $_vat = ($_ht && is_numeric($helper->getConfig('beezup/flux/vat'))) ? (preg_replace('(\,+)', '.', $helper->getConfig('beezup/flux/vat')) / 100) + 1 : 1;
166
- $_catalog_rules = $helper->getConfig('beezup/flux/catalog_rules');
167
 
168
  /* Build file */
169
- $xml = $helper->getConfig('beezup/flux/bom') ? "\xEF\xBB\xBF" : '';
170
  $xml .= '<?xml version="1.0" encoding="utf-8"?>' . PHP_EOL . '<catalog>' . PHP_EOL;
171
 
172
  //r�cup�re tous les produits
@@ -174,10 +206,10 @@
174
  $childs = $beezup->getConfigurableProducts(true);
175
  $backendModel = $products->getResource()->getAttribute('media_gallery')->getBackend();
176
  $products->addAttributeToFilter('type_id', Mage_Catalog_Model_Product_Type::TYPE_CONFIGURABLE);
177
-
178
  //parcours les produits
179
  foreach ($products as $p) {
180
-
181
  if($many_images == 1) {
182
  $backendModel->afterLoad($p); //adding media gallery to the product object
183
  $datos = $p->getData();
@@ -189,9 +221,9 @@
189
 
190
  $categories = $beezup->getProductsCategories2($p, $_categories);
191
  }
192
- // $varationTheme = $beezup->getOptions($p);
193
  //we get product object from catalog/product reason(beezup/products gets products from catalog/product_collection, didn't find the way to get image collection from there *will check)
194
-
195
  if (count($categories)) {
196
  //si l'�l�ment est un p�re, on va traiter ces enfants
197
  if(isset($childs[$p->getId()])) {
@@ -205,83 +237,101 @@
205
  $final_price = $c->getFinalPrice();
206
  $image = $this->fillImageUrl($p, $c);
207
 
208
- //DBG
209
- if (0)
210
- {
211
- echo "----------------------------" ."<br/>";
212
- echo "Name : " .$c->getName() ."<br/>";
213
- echo "Id : " .$c->getId() ."<br/>";
214
- echo "Parent Id : " .$p->getId() ."<br/>";
215
- echo "Url : " .$p->getProductUrl() ."<br/>";
216
- echo "Image : " .$helper->getImageDir().$image ."<br/>";
 
 
 
 
 
 
 
 
 
 
217
 
218
 
219
- echo "SKU : " .$c->getSku() ."<br/>";
220
- echo "Quantity : " .$qty ."<br/>";
221
- echo "Stock : " .$stock ."<br/>";
222
- echo "Shipping : " .$shipping ."<br/>";
223
- echo "price : " .$price ."<br/>";
224
- // echo "finalprice : ".$final_price ."<br/>";
225
- echo "specialprice : ".$c->getSpecialPrice() ."<br/>";
226
- }
227
-
228
-
229
- $xml .= '<product>';
230
- $xml .= $helper->tag($this->__('b_unique_id'), $c->getId());
231
- $xml .= $helper->tag($this->__('b_sku'), trim($c->getSku()), 1);
232
-
233
- $xml .= $helper->tag($this->__('parent_or_child'), 'child', 1);
234
- $xml .= $helper->tag($this->__('parent_id'), $p->getId());
235
- //$xml .= $helper->tag($this->__('variation-theme'), $varationTheme, 1);
236
-
237
- $xml .= $helper->tag($this->__('b_title'), trim($p->getName()), 1);
238
- $xml .= $helper->tag($this->__('b_description'), preg_replace("/(\r\n|\n|\r)/", ' ', strip_tags($p->getData($_description))), 1);
239
- $xml .= $helper->tag($this->__('b_product_url'), $p->getProductUrl(), 1);
240
-
241
- $xml .= $helper->tag($this->__('url_image'), $helper->getImageDir() . $image, 1);
242
- if($many_images==1) {
243
 
244
- $product = Mage::getModel('catalog/product')->load( $c->getId());
245
- $inc = 1;
246
- foreach ($product->getMediaGalleryImages() as $img) {
247
- if( $helper->getImageDir() . $image !== $img->getUrl()) {
248
- $inc++;
249
- $xml .= $helper->tag($this->__('url_image')."_".$inc, $img->getUrl(), 1);
 
 
 
 
 
250
  }
251
-
252
  }
253
 
254
- if($inc==1 && ($c->getImage() == "no_selection" || $c->getImage()=="" || $c->getSmallImage() == "no_selection" || $c->getSmallImage() == "")) { //if there are no child pictures
 
 
 
255
 
256
- $product = Mage::getModel('catalog/product')->load( $p->getId());
257
  $inc = 1;
258
  foreach ($product->getMediaGalleryImages() as $img) {
259
  if( $helper->getImageDir() . $image !== $img->getUrl()) {
260
  $inc++;
261
  $xml .= $helper->tag($this->__('url_image')."_".$inc, $img->getUrl(), 1);
262
  }
 
263
  }
264
 
265
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
266
  }
267
- }
268
- $xml .= $helper->tag($this->__('b_availability'), $stock, 1);
269
- $xml .= $helper->tag($this->__('b_qty'), $qty);
270
- $xml .= $helper->tag($this->__('b_delivery'), $shipping, 1);
271
- $xml .= $helper->tag($this->__('b_shipping'), $helper->currency($beezup->getShippingAmount($c->getWeight(), $_tablerates)));
272
- $xml .= $helper->tag($this->__('b_weight'), $helper->currency($c->getWeight()));
273
- $xml .= $helper->tag($this->__('b_price'), $helper->currency($final_price*$_vat));
274
- if ($price != $final_price) $xml .= $helper->tag($this->__('b_regular_price'), $helper->currency($price*$_vat));
275
- $i = 1;
276
-
277
-
278
- foreach ($categories as $v) $xml .= $helper->tag($this->__('b_category_%s', $i++), $v, 1);
279
- foreach ($_attributes as $a) {
280
- $value = $c->getResource()->getAttribute($a)->getFrontend()->getValue($c);
281
- $xml .= $helper->tag($a, is_float($value) ? $helper->currency($value) : $value, is_float($value) ? 0 : 1);
282
- }
283
- $xml .= '</product>' . PHP_EOL;
284
-
285
  }
286
 
287
  $qty = $beezup->getQty($p->getId());
@@ -300,10 +350,17 @@
300
 
301
  $xml .= $helper->tag($this->__('parent_or_child'), 'parent', 1);
302
  $xml .= $helper->tag($this->__('parent_id'), '');
303
- // $xml .= $helper->tag($this->__('variation-theme'), $varationTheme, 1);
304
 
305
  $xml .= $helper->tag($this->__('b_title'), trim($p->getName()), 1);
306
- $xml .= $helper->tag($this->__('b_description'), preg_replace("/(\r\n|\n|\r)/", ' ', strip_tags($p->getData($_description))), 1);
 
 
 
 
 
 
 
307
  $xml .= $helper->tag($this->__('b_product_url'), $p->getProductUrl(), 1);
308
  $xml .= $helper->tag($this->__('url_image'), $helper->getImageDir() . $image, 1);
309
  if($many_images == 1) {
@@ -325,7 +382,17 @@
325
  $xml .= $helper->tag($this->__('b_availability'), $stock, 1);
326
  $xml .= $helper->tag($this->__('b_qty'), $qty);
327
  $xml .= $helper->tag($this->__('b_delivery'), $shipping, 1);
328
- $xml .= $helper->tag($this->__('b_shipping'), $helper->currency($beezup->getShippingAmount($p->getWeight(), $_tablerates)));
 
 
 
 
 
 
 
 
 
 
329
  $xml .= $helper->tag($this->__('b_weight'), $helper->currency($p->getWeight()));
330
  $xml .= $helper->tag($this->__('b_price'), $helper->currency($final_price*$_vat));
331
  if ($price != $final_price) $xml .= $helper->tag($this->__('b_regular_price'), $helper->currency($price*$_vat));
@@ -339,7 +406,7 @@
339
  $xml .= '</product>' . PHP_EOL;
340
  }
341
  }
342
- }
343
 
344
  $product_simple = $beezup->getProductsSimple();
345
  $backendModelSimple = $product_simple->getResource()->getAttribute('media_gallery')->getBackend();
@@ -373,7 +440,14 @@
373
  $xml .= $helper->tag($this->__('variation-theme'), '', 1);
374
 
375
  $xml .= $helper->tag($this->__('b_title'), trim($p->getName()), 1);
376
- $xml .= $helper->tag($this->__('b_description'), preg_replace("/(\r\n|\n|\r)/", ' ', strip_tags($p->getData($_description))), 1);
 
 
 
 
 
 
 
377
  $xml .= $helper->tag($this->__('b_product_url'), $p->getProductUrl(), 1);
378
  $xml .= $helper->tag($this->__('url_image'), $helper->getImageDir() . $image, 1);
379
  if($many_images == 1) {
@@ -396,7 +470,15 @@
396
  $xml .= $helper->tag($this->__('b_availability'), $stock, 1);
397
  $xml .= $helper->tag($this->__('b_qty'), $qty);
398
  $xml .= $helper->tag($this->__('b_delivery'), $shipping, 1);
399
- $xml .= $helper->tag($this->__('b_shipping'), $helper->currency($beezup->getShippingAmount($p->getWeight(), $_tablerates)));
 
 
 
 
 
 
 
 
400
  $xml .= $helper->tag($this->__('b_weight'), $helper->currency($p->getWeight()));
401
  $xml .= $helper->tag($this->__('b_price'), $helper->currency($final_price*$_vat));
402
  if ($price != $final_price) $xml .= $helper->tag($this->__('b_regular_price'), $helper->currency($price*$_vat));
@@ -428,10 +510,18 @@
428
  $helper = Mage::helper('beezup');
429
  $category_logic = $helper->getConfig('beezup/flux/category_logic');
430
  /* Initially load the useful elements */
 
 
 
 
 
 
431
  $many_images = $helper->getConfig('beezup/flux/images');
432
  $_ht = $helper->getConfig('beezup/flux/ht');
433
  $_description = $helper->getConfig('beezup/flux/description');
434
- $_tablerates = $helper->getConfig('beezup/flux/tablerates_weight_destination') ? $beezup->getTablerates() : 0;
 
 
435
  $cat_logic = false;
436
  if($category_logic == 1) {
437
  $_categories = $beezup->getCategoriesAsArray(Mage::helper('catalog/category')->getStoreCategories());
@@ -446,10 +536,10 @@
446
  }
447
  $_attributes = $helper->getConfig('beezup/flux/attributes') ? explode(',', $helper->getConfig('beezup/flux/attributes')) : array();
448
  $_vat = ($_ht && is_numeric($helper->getConfig('beezup/flux/vat'))) ? (preg_replace('(\,+)', '.', $helper->getConfig('beezup/flux/vat')) / 100) + 1 : 1;
449
- $_catalog_rules = $helper->getConfig('beezup/flux/catalog_rules');
450
 
451
  /* Build file */
452
- $xml = $helper->getConfig('beezup/flux/bom') ? "\xEF\xBB\xBF" : '';
453
  $xml .= '<?xml version="1.0" encoding="utf-8"?>' . PHP_EOL . '<catalog>' . PHP_EOL;
454
 
455
  $childs = $beezup->getConfigurableProducts(false);
@@ -462,14 +552,16 @@
462
  $productParent = Mage::getModel('catalog/product')->load($productParentId);
463
  $image=$productParent->getImage();
464
  if($category_logic == 1) {
465
- $categories = $beezup->getProductsCategories($p, $_categories);
466
- } else {
467
-
468
- $categories = $beezup->getProductsCategories2($p, $_categories);
469
- }
470
  $url = $productParent->getProductUrl();
471
  $name = $productParent->getName();
472
- $description = $productParent->getData($_description);
 
 
473
  }
474
 
475
  if(count($categories)){
@@ -488,20 +580,12 @@
488
  $xml .= $helper->tag($this->__('parent_id'), $c->getParentId());
489
 
490
  $xml .= $helper->tag($this->__('b_title'), trim($name), 1);
491
- $xml .= $helper->tag($this->__('b_description'), preg_replace("/(\r\n|\n|\r)/", ' ', strip_tags($description)), 1);
 
 
492
  $xml .= $helper->tag($this->__('b_product_url'), $url, 1);
493
 
494
- /*$inc = 0;
495
- $product = Mage::getModel('catalog/product')->load( $c->getId());
496
-
497
- foreach ($product->getMediaGalleryImages() as $image) {
498
- $inc++;
499
- if($inc==1) {
500
- $xml .= $helper->tag($this->__('url_image'), $image->getUrl(), 1);
501
- } else {
502
- $xml .= $helper->tag($this->__('url_image')."_".$inc, $image->getUrl(), 1);
503
- }
504
- }*/
505
  $xml .= $helper->tag($this->__('url_image'), $helper->getImageDir() . $image, 1); //r�cup�re l'image sur le p�re
506
 
507
  if($many_images == 1) {
@@ -521,7 +605,16 @@
521
  $xml .= $helper->tag($this->__('b_availability'), $stock, 1);
522
  $xml .= $helper->tag($this->__('b_qty'), $qty);
523
  $xml .= $helper->tag($this->__('b_delivery'), $shipping, 1);
524
- $xml .= $helper->tag($this->__('b_shipping'), $helper->currency($beezup->getShippingAmount($c->getWeight(), $_tablerates)));
 
 
 
 
 
 
 
 
 
525
  $xml .= $helper->tag($this->__('b_weight'), $helper->currency($c->getWeight()));
526
  $xml .= $helper->tag($this->__('b_price'), $helper->currency($final_price*$_vat));
527
  if ($price != $final_price) $xml .= $helper->tag($this->__('b_regular_price'), $helper->currency($price*$_vat));
@@ -553,22 +646,31 @@
553
  $helper = Mage::helper('beezup');
554
  $category_logic = $helper->getConfig('beezup/flux/category_logic');
555
  /* Initially load the useful elements */
 
 
 
 
 
 
 
556
  $many_images = $helper->getConfig('beezup/flux/images');
557
  $_ht = $helper->getConfig('beezup/flux/ht');
558
- $_description = $helper->getConfig('beezup/flux/description');
559
- $_tablerates = $helper->getConfig('beezup/flux/tablerates_weight_destination') ? $beezup->getTablerates() : 0;
 
 
560
  $cat_logic = false;
561
-
562
- $_categories = $beezup->getCategoriesAsArray(Mage::helper('catalog/category')->getStoreCategories());
563
-
564
-
565
  $_vat = ($_ht && is_numeric($helper->getConfig('beezup/flux/vat'))) ? (preg_replace('(\,+)', '.', $helper->getConfig('beezup/flux/vat')) / 100) + 1 : 1;
566
  $_attributes = $helper->getConfig('beezup/flux/attributes') ? explode(',', $helper->getConfig('beezup/flux/attributes')) : array();
567
- $_catalog_rules = $helper->getConfig('beezup/flux/catalog_rules');
568
 
569
  $products = $beezup->getGroupedProduct();
570
 
571
- $buf = $helper->getConfig('beezup/flux/bom') ? "\xEF\xBB\xBF" : '';
572
  foreach ($products as $product) {
573
  $associatedProducts = $product->getTypeInstance(true)->getAssociatedProducts($product);
574
 
@@ -598,23 +700,23 @@
598
  echo "----------------------------" ."<br/>";
599
  echo "Name : " .$g->getName() ."<br/>";
600
  echo "Description : ".$parentDesc ."<br/>";
601
- echo "Id : " .$g->getId() ."<br/>";
602
- echo "Parent Id : " .$parentId ."<br/>";
603
- echo "Url : " .$parentUrl ."<br/>";
604
- echo "Image : " .$helper->getImageDir().$image ."<br/>";
605
-
606
-
607
- echo "SKU : " .$g->getSku() ."<br/>";
608
- echo "Quantity : " .$qty ."<br/>";
609
- echo "Stock : " .$stock ."<br/>";
610
- echo "Shipping : " .$shipping ."<br/>";
611
- echo "price : " .$price ."<br/>";
612
- echo "finalprice : ".$final_price ."<br/>";
613
- echo "weight : " .$g->getWeight() ."<br/>";
614
-
615
- $i = 1;
616
- foreach ($parentCategories as $v)
617
- echo "Cat�gorie ".$i." : ".$v."<br/>";
618
  }
619
 
620
 
@@ -622,36 +724,45 @@
622
  $buf .= $helper->tag($this->__('b_unique_id'), $g->getId());
623
  $buf .= $helper->tag($this->__('b_sku'), trim($g->getSku()), 1);
624
  if ($configurable){
625
- $buf .= $helper->tag($this->__('parent_or_child'), 'grouped_child', 1);
626
- $buf .= $helper->tag($this->__('parent_id'), $parentId);
627
  }
628
  $buf .= $helper->tag($this->__('b_title'), $g->getName()/*trim($name)*/, 1);
629
  $buf .= $helper->tag($this->__('b_description'), preg_replace("/(\r\n|\n|\r)/", ' ', strip_tags($parentDesc)), 1);
630
  $buf .= $helper->tag($this->__('b_product_url'), $parentUrl, 1);
631
 
632
  /*
633
- if($many_images==1) {
634
-
635
- $gprod = Mage::getModel('catalog/product')->load( $g->getId());
636
- $inc = 0;
637
- foreach ($gprod->getMediaGalleryImages() as $image) {
638
- $inc++;
639
- if($inc==1) {
640
- $buf .= $helper->tag($this->__('url_image'), $image->getUrl(), 1);
641
- } else {
642
- $buf .= $helper->tag($this->__('url_image')."_".$inc, $image->getUrl(), 1);
643
- }
644
- }
645
- } else {
646
-
647
- $buf .= $helper->tag($this->__('url_image'), $helper->getImageDir() . $image, 1);
648
  }*/
649
 
650
  $buf .= $helper->tag($this->__('b_product_image'), $helper->getImageDir() . $image, 1); //r�cup�re l'image sur le p�re
651
  $buf .= $helper->tag($this->__('b_availability'), $stock, 1);
652
  $buf .= $helper->tag($this->__('b_qty'), $qty);
653
  $buf .= $helper->tag($this->__('b_delivery'), $shipping, 1);
654
- $buf .= $helper->tag($this->__('b_shipping'), $helper->currency($beezup->getShippingAmount($g->getWeight(), $_tablerates)));
 
 
 
 
 
 
 
 
 
655
  $buf .= $helper->tag($this->__('b_weight'), $helper->currency($g->getWeight()));
656
  $buf .= $helper->tag($this->__('b_price'), $helper->currency($final_price * $_vat));
657
  if ($price != $final_price) $buf .= $helper->tag($this->__('b_regular_price'), $helper->currency($price*$_vat));
1
  <?php
2
  ini_set('memory_limit','1024M');
3
+
4
  class BeezUp_Block_Xml extends Mage_Core_Block_Text
5
  {
6
  /**
14
  $helper = Mage::helper('beezup');
15
  $category_logic = $helper->getConfig('beezup/flux/category_logic');
16
  /* Initially load the useful elements */
17
+
18
+ $shipping_logic = $helper->getConfig('beezup/flux/carrier_method');
19
+ if($shipping_logic == 1) {
20
+ $shipping_carrier = $helper->getConfig('beezup/flux/shipping_carrier');
21
+ $default_country = $helper->getConfig('beezup/flux/default_country');
22
+ }
23
+
24
+ $default_shipping_cost = (int)$helper->getConfig('beezup/flux/default_shipping_cost');
25
  $many_images = $helper->getConfig('beezup/flux/images');
26
  $_ht = $helper->getConfig('beezup/flux/ht');
27
  $_description = $helper->getConfig('beezup/flux/description');
28
+ $_description = explode(",", $_description);
29
+ $enable_html = $helper->getConfig('beezup/flux/description_html');
30
+ $_tablerates =0;
31
  $cat_logic = false;
32
  if($category_logic == 1) {
33
  $_categories = $beezup->getCategoriesAsArray(Mage::helper('catalog/category')->getStoreCategories());
43
 
44
  $_attributes = $helper->getConfig('beezup/flux/attributes') ? explode(',', $helper->getConfig('beezup/flux/attributes')) : array();
45
  $_vat = ($_ht && is_numeric($helper->getConfig('beezup/flux/vat'))) ? (preg_replace('(\,+)', '.', $helper->getConfig('beezup/flux/vat')) / 100) + 1 : 1;
46
+ // $_catalog_rules = $helper->getConfig('beezup/flux/catalog_rules');
 
47
  /* Build file */
48
+ $xml = "\xEF\xBB\xBF";
49
  $xml .= '<?xml version="1.0" encoding="utf-8"?>' . PHP_EOL . '<catalog>' . PHP_EOL;
50
 
51
  $products = $beezup->getProducts();
53
  $backendModel = $products->getResource()->getAttribute('media_gallery')->getBackend();
54
  }
55
 
56
+ //$productModel = Mage::getModel('catalog/product');
57
  foreach ($products as $p) {
58
+ if($category_logic == 1) {
59
  $categories = $beezup->getProductsCategories($p, $_categories);
60
  } else {
61
 
72
  $image = $p->getSmallImage();
73
 
74
 
75
+ //$precio = Mage::getModel('catalogrule/rule')->calcProductPriceRule($p,$p->getPrice());
76
 
77
 
78
  $xml .= '<product>';
79
+ // $productModel->load($p->getId());
80
  $xml .= $helper->tag($this->__('b_unique_id'), $p->getId());
81
  $xml .= $helper->tag($this->__('b_sku'), trim($p->getSku()), 1);
82
  $xml .= $helper->tag($this->__('b_title'), trim($p->getName()), 1);
83
+ // $xml .= $helper->tag($this->__('b_description'), preg_replace("/(\r\n|\n|\r)/", ' ', strip_tags($p->getData($_description))), 1);
84
+
85
+ foreach($_description as $desc) {
86
+ if($enable_html == 1) {
87
+ $xml .= $helper->tag($this->__('b_'.$desc), $p->getData($desc), 1);
88
+ } else {
89
+ $xml .= $helper->tag($this->__('b_'.$desc), preg_replace("/(\r\n|\n|\r)/", ' ', strip_tags($p->getData($desc))), 1);
90
+ }
91
+ }
92
+
93
  $xml .= $helper->tag($this->__('b_product_url'), $p->getProductUrl(), 1);
94
+ $special_price = $p->getSpecialPrice();
95
+ if(!empty($special_price) && $special_price > 0) {
96
+ $special_date = $p->getSpecialToDate();
97
+ if (strtotime($special_date) >= time() || empty($special_date)) {
98
+ $final_price = $p->getSpecialPrice();
99
+ //$xml .= $helper->tag($this->__('precio'), $p->getSpecialPrice(), 1);
100
+ }
101
+ }
102
+
103
 
104
 
105
 
121
 
122
  }
123
 
124
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
125
  $xml .= $helper->tag($this->__('b_availability'), $stock, 1);
126
  $xml .= $helper->tag($this->__('b_qty'), $qty);
127
  $xml .= $helper->tag($this->__('b_delivery'), $shipping, 1);
128
+
129
+ if($shipping_logic == 1) {
130
+ $shipping_rate = $beezup->_getShippingPrice($p, $shipping_carrier, $default_country);
131
+ if($shipping_rate == 0 && $default_shipping_cost > 0) {
132
+ $shipping_rate = $default_shipping_cost;
133
+ }
134
+ $xml .= $helper->tag($this->__('b_shipping'), $helper->currency($shipping_rate));
135
+ } else {
136
+ $xml .= $helper->tag($this->__('b_shipping'), $helper->currency($beezup->getShippingAmount($p->getWeight(), $_tablerates)));
137
+ }
138
+
139
+
140
  $xml .= $helper->tag($this->__('b_weight'), $helper->currency($p->getWeight()));
141
  $xml .= $helper->tag($this->__('b_price'), $helper->currency($final_price*$_vat));
142
  if ($price != $final_price) $xml .= $helper->tag($this->__('b_regular_price'), $helper->currency($price*$_vat));
169
  $helper = Mage::helper('beezup');
170
  $category_logic = $helper->getConfig('beezup/flux/category_logic');
171
  /* Initially load the useful elements */
172
+ $shipping_logic = $helper->getConfig('beezup/flux/carrier_method');
173
+ if($shipping_logic == 1) {
174
+ $shipping_carrier = $helper->getConfig('beezup/flux/shipping_carrier');
175
+ $default_country = $helper->getConfig('beezup/flux/default_country');
176
+ }
177
+ $default_shipping_cost = (int)$helper->getConfig('beezup/flux/default_shipping_cost');
178
  $many_images = $helper->getConfig('beezup/flux/images');
179
  $_ht = $helper->getConfig('beezup/flux/ht');
180
+ $_description = $helper->getConfig('beezup/flux/description');
181
+ $_description = explode(",", $_description);
182
+ $enable_html = $helper->getConfig('beezup/flux/description_html');
183
+ $_tablerates = 0;
184
  $cat_logic = false;
185
  if($category_logic == 1) {
186
  $_categories = $beezup->getCategoriesAsArray(Mage::helper('catalog/category')->getStoreCategories());
195
  }
196
  $_attributes = $helper->getConfig('beezup/flux/attributes') ? explode(',', $helper->getConfig('beezup/flux/attributes')) : array();
197
  $_vat = ($_ht && is_numeric($helper->getConfig('beezup/flux/vat'))) ? (preg_replace('(\,+)', '.', $helper->getConfig('beezup/flux/vat')) / 100) + 1 : 1;
198
+ // $_catalog_rules = $helper->getConfig('beezup/flux/catalog_rules');
199
 
200
  /* Build file */
201
+ $xml = "\xEF\xBB\xBF";
202
  $xml .= '<?xml version="1.0" encoding="utf-8"?>' . PHP_EOL . '<catalog>' . PHP_EOL;
203
 
204
  //r�cup�re tous les produits
206
  $childs = $beezup->getConfigurableProducts(true);
207
  $backendModel = $products->getResource()->getAttribute('media_gallery')->getBackend();
208
  $products->addAttributeToFilter('type_id', Mage_Catalog_Model_Product_Type::TYPE_CONFIGURABLE);
209
+
210
  //parcours les produits
211
  foreach ($products as $p) {
212
+
213
  if($many_images == 1) {
214
  $backendModel->afterLoad($p); //adding media gallery to the product object
215
  $datos = $p->getData();
221
 
222
  $categories = $beezup->getProductsCategories2($p, $_categories);
223
  }
224
+ // $varationTheme = $beezup->getOptions($p);
225
  //we get product object from catalog/product reason(beezup/products gets products from catalog/product_collection, didn't find the way to get image collection from there *will check)
226
+
227
  if (count($categories)) {
228
  //si l'�l�ment est un p�re, on va traiter ces enfants
229
  if(isset($childs[$p->getId()])) {
237
  $final_price = $c->getFinalPrice();
238
  $image = $this->fillImageUrl($p, $c);
239
 
240
+ //DBG
241
+ if (0)
242
+ {
243
+ echo "----------------------------" ."<br/>";
244
+ echo "Name : " .$c->getName() ."<br/>";
245
+ echo "Id : " .$c->getId() ."<br/>";
246
+ echo "Parent Id : " .$p->getId() ."<br/>";
247
+ echo "Url : " .$p->getProductUrl() ."<br/>";
248
+ echo "Image : " .$helper->getImageDir().$image ."<br/>";
249
+
250
+
251
+ echo "SKU : " .$c->getSku() ."<br/>";
252
+ echo "Quantity : " .$qty ."<br/>";
253
+ echo "Stock : " .$stock ."<br/>";
254
+ echo "Shipping : " .$shipping ."<br/>";
255
+ echo "price : " .$price ."<br/>";
256
+ // echo "finalprice : ".$final_price ."<br/>";
257
+ echo "specialprice : ".$c->getSpecialPrice() ."<br/>";
258
+ }
259
 
260
 
261
+ $xml .= '<product>';
262
+ $xml .= $helper->tag($this->__('b_unique_id'), $c->getId());
263
+ $xml .= $helper->tag($this->__('b_sku'), trim($c->getSku()), 1);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
264
 
265
+ $xml .= $helper->tag($this->__('parent_or_child'), 'child', 1);
266
+ $xml .= $helper->tag($this->__('parent_id'), $p->getId());
267
+ //$xml .= $helper->tag($this->__('variation-theme'), $varationTheme, 1);
268
+
269
+ $xml .= $helper->tag($this->__('b_title'), trim($p->getName()), 1);
270
+ //$xml .= $helper->tag($this->__('b_description'), preg_replace("/(\r\n|\n|\r)/", ' ', strip_tags($p->getData($_description))), 1);
271
+ foreach($_description as $desc) {
272
+ if($enable_html == 1) {
273
+ $xml .= $helper->tag($this->__('b_'.$desc), $p->getData($desc), 1);
274
+ } else {
275
+ $xml .= $helper->tag($this->__('b_'.$desc), preg_replace("/(\r\n|\n|\r)/", ' ', strip_tags($p->getData($desc))), 1);
276
  }
 
277
  }
278
 
279
+ $xml .= $helper->tag($this->__('b_product_url'), $p->getProductUrl(), 1);
280
+
281
+ $xml .= $helper->tag($this->__('url_image'), $helper->getImageDir() . $image, 1);
282
+ if($many_images==1) {
283
 
284
+ $product = Mage::getModel('catalog/product')->load( $c->getId());
285
  $inc = 1;
286
  foreach ($product->getMediaGalleryImages() as $img) {
287
  if( $helper->getImageDir() . $image !== $img->getUrl()) {
288
  $inc++;
289
  $xml .= $helper->tag($this->__('url_image')."_".$inc, $img->getUrl(), 1);
290
  }
291
+
292
  }
293
 
294
+ if($inc==1 && ($c->getImage() == "no_selection" || $c->getImage()=="" || $c->getSmallImage() == "no_selection" || $c->getSmallImage() == "")) { //if there are no child pictures
295
+
296
+ $product = Mage::getModel('catalog/product')->load( $p->getId());
297
+ $inc = 1;
298
+ foreach ($product->getMediaGalleryImages() as $img) {
299
+ if( $helper->getImageDir() . $image !== $img->getUrl()) {
300
+ $inc++;
301
+ $xml .= $helper->tag($this->__('url_image')."_".$inc, $img->getUrl(), 1);
302
+ }
303
+ }
304
+
305
+
306
+ }
307
+ }
308
+ $xml .= $helper->tag($this->__('b_availability'), $stock, 1);
309
+ $xml .= $helper->tag($this->__('b_qty'), $qty);
310
+ $xml .= $helper->tag($this->__('b_delivery'), $shipping, 1);
311
+
312
+ if($shipping_logic == 1) {
313
+ $shipping_rate = $beezup->_getShippingPrice($c, $shipping_carrier, $default_country);
314
+ if($shipping_rate == 0 && $default_shipping_cost > 0) {
315
+ $shipping_rate = $default_shipping_cost;
316
+ }
317
+ $xml .= $helper->tag($this->__('b_shipping'), $helper->currency($shipping_rate));
318
+ } else {
319
+ $xml .= $helper->tag($this->__('b_shipping'), $helper->currency($beezup->getShippingAmount($c->getWeight(), $_tablerates)));
320
+ }
321
+
322
+ $xml .= $helper->tag($this->__('b_weight'), $helper->currency($c->getWeight()));
323
+ $xml .= $helper->tag($this->__('b_price'), $helper->currency($final_price*$_vat));
324
+ if ($price != $final_price) $xml .= $helper->tag($this->__('b_regular_price'), $helper->currency($price*$_vat));
325
+ $i = 1;
326
+
327
+
328
+ foreach ($categories as $v) $xml .= $helper->tag($this->__('b_category_%s', $i++), $v, 1);
329
+ foreach ($_attributes as $a) {
330
+ $value = $c->getResource()->getAttribute($a)->getFrontend()->getValue($c);
331
+ $xml .= $helper->tag($a, is_float($value) ? $helper->currency($value) : $value, is_float($value) ? 0 : 1);
332
  }
333
+ $xml .= '</product>' . PHP_EOL;
334
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
335
  }
336
 
337
  $qty = $beezup->getQty($p->getId());
350
 
351
  $xml .= $helper->tag($this->__('parent_or_child'), 'parent', 1);
352
  $xml .= $helper->tag($this->__('parent_id'), '');
353
+ // $xml .= $helper->tag($this->__('variation-theme'), $varationTheme, 1);
354
 
355
  $xml .= $helper->tag($this->__('b_title'), trim($p->getName()), 1);
356
+ //$xml .= $helper->tag($this->__('b_description'), preg_replace("/(\r\n|\n|\r)/", ' ', strip_tags($p->getData($_description))), 1);
357
+ foreach($_description as $desc) {
358
+ if($enable_html == 1) {
359
+ $xml .= $helper->tag($this->__('b_'.$desc), $p->getData($desc), 1);
360
+ } else {
361
+ $xml .= $helper->tag($this->__('b_'.$desc), preg_replace("/(\r\n|\n|\r)/", ' ', strip_tags($p->getData($desc))), 1);
362
+ }
363
+ }
364
  $xml .= $helper->tag($this->__('b_product_url'), $p->getProductUrl(), 1);
365
  $xml .= $helper->tag($this->__('url_image'), $helper->getImageDir() . $image, 1);
366
  if($many_images == 1) {
382
  $xml .= $helper->tag($this->__('b_availability'), $stock, 1);
383
  $xml .= $helper->tag($this->__('b_qty'), $qty);
384
  $xml .= $helper->tag($this->__('b_delivery'), $shipping, 1);
385
+
386
+ if($shipping_logic == 1) {
387
+ $shipping_rate = $beezup->_getShippingPrice($p, $shipping_carrier, $default_country);
388
+ if($shipping_rate == 0 && $default_shipping_cost > 0) {
389
+ $shipping_rate = $default_shipping_cost;
390
+ }
391
+ $xml .= $helper->tag($this->__('b_shipping'), $helper->currency($shipping_rate));
392
+ } else {
393
+ $xml .= $helper->tag($this->__('b_shipping'), $helper->currency($beezup->getShippingAmount($p->getWeight(), $_tablerates)));
394
+ }
395
+
396
  $xml .= $helper->tag($this->__('b_weight'), $helper->currency($p->getWeight()));
397
  $xml .= $helper->tag($this->__('b_price'), $helper->currency($final_price*$_vat));
398
  if ($price != $final_price) $xml .= $helper->tag($this->__('b_regular_price'), $helper->currency($price*$_vat));
406
  $xml .= '</product>' . PHP_EOL;
407
  }
408
  }
409
+ }
410
 
411
  $product_simple = $beezup->getProductsSimple();
412
  $backendModelSimple = $product_simple->getResource()->getAttribute('media_gallery')->getBackend();
440
  $xml .= $helper->tag($this->__('variation-theme'), '', 1);
441
 
442
  $xml .= $helper->tag($this->__('b_title'), trim($p->getName()), 1);
443
+ //$xml .= $helper->tag($this->__('b_description'), preg_replace("/(\r\n|\n|\r)/", ' ', strip_tags($p->getData($_description))), 1);
444
+ foreach($_description as $desc) {
445
+ if($enable_html == 1) {
446
+ $xml .= $helper->tag($this->__('b_'.$desc), $p->getData($desc), 1);
447
+ } else {
448
+ $xml .= $helper->tag($this->__('b_'.$desc), preg_replace("/(\r\n|\n|\r)/", ' ', strip_tags($p->getData($desc))), 1);
449
+ }
450
+ }
451
  $xml .= $helper->tag($this->__('b_product_url'), $p->getProductUrl(), 1);
452
  $xml .= $helper->tag($this->__('url_image'), $helper->getImageDir() . $image, 1);
453
  if($many_images == 1) {
470
  $xml .= $helper->tag($this->__('b_availability'), $stock, 1);
471
  $xml .= $helper->tag($this->__('b_qty'), $qty);
472
  $xml .= $helper->tag($this->__('b_delivery'), $shipping, 1);
473
+ if($shipping_logic == 1) {
474
+ $shipping_rate = $beezup->_getShippingPrice($p, $shipping_carrier, $default_country);
475
+ if($shipping_rate == 0 && $default_shipping_cost > 0) {
476
+ $shipping_rate = $default_shipping_cost;
477
+ }
478
+ $xml .= $helper->tag($this->__('b_shipping'), $helper->currency($shipping_rate));
479
+ } else {
480
+ $xml .= $helper->tag($this->__('b_shipping'), $helper->currency($beezup->getShippingAmount($p->getWeight(), $_tablerates)));
481
+ }
482
  $xml .= $helper->tag($this->__('b_weight'), $helper->currency($p->getWeight()));
483
  $xml .= $helper->tag($this->__('b_price'), $helper->currency($final_price*$_vat));
484
  if ($price != $final_price) $xml .= $helper->tag($this->__('b_regular_price'), $helper->currency($price*$_vat));
510
  $helper = Mage::helper('beezup');
511
  $category_logic = $helper->getConfig('beezup/flux/category_logic');
512
  /* Initially load the useful elements */
513
+ $shipping_logic = $helper->getConfig('beezup/flux/carrier_method');
514
+ if($shipping_logic == 1) {
515
+ $shipping_carrier = $helper->getConfig('beezup/flux/shipping_carrier');
516
+ $default_country = $helper->getConfig('beezup/flux/default_country');
517
+ }
518
+ $default_shipping_cost = (int)$helper->getConfig('beezup/flux/default_shipping_cost');
519
  $many_images = $helper->getConfig('beezup/flux/images');
520
  $_ht = $helper->getConfig('beezup/flux/ht');
521
  $_description = $helper->getConfig('beezup/flux/description');
522
+ $_description = explode(",", $_description);
523
+ $enable_html = $helper->getConfig('beezup/flux/description_html');
524
+ $_tablerates = 0;
525
  $cat_logic = false;
526
  if($category_logic == 1) {
527
  $_categories = $beezup->getCategoriesAsArray(Mage::helper('catalog/category')->getStoreCategories());
536
  }
537
  $_attributes = $helper->getConfig('beezup/flux/attributes') ? explode(',', $helper->getConfig('beezup/flux/attributes')) : array();
538
  $_vat = ($_ht && is_numeric($helper->getConfig('beezup/flux/vat'))) ? (preg_replace('(\,+)', '.', $helper->getConfig('beezup/flux/vat')) / 100) + 1 : 1;
539
+ // $_catalog_rules = $helper->getConfig('beezup/flux/catalog_rules');
540
 
541
  /* Build file */
542
+ $xml = "\xEF\xBB\xBF";
543
  $xml .= '<?xml version="1.0" encoding="utf-8"?>' . PHP_EOL . '<catalog>' . PHP_EOL;
544
 
545
  $childs = $beezup->getConfigurableProducts(false);
552
  $productParent = Mage::getModel('catalog/product')->load($productParentId);
553
  $image=$productParent->getImage();
554
  if($category_logic == 1) {
555
+ $categories = $beezup->getProductsCategories($p, $_categories);
556
+ } else {
557
+
558
+ $categories = $beezup->getProductsCategories2($p, $_categories);
559
+ }
560
  $url = $productParent->getProductUrl();
561
  $name = $productParent->getName();
562
+ $description_short = $productParent->getData("short_description");
563
+ $description = $productParent->getData("description");
564
+
565
  }
566
 
567
  if(count($categories)){
580
  $xml .= $helper->tag($this->__('parent_id'), $c->getParentId());
581
 
582
  $xml .= $helper->tag($this->__('b_title'), trim($name), 1);
583
+ //$xml .= $helper->tag($this->__('b_description'), preg_replace("/(\r\n|\n|\r)/", ' ', strip_tags($description)), 1);
584
+ $xml .= $helper->tag($this->__('b_description_short'), $description_short, 1);
585
+ $xml .= $helper->tag($this->__('b_description'), $description, 1);
586
  $xml .= $helper->tag($this->__('b_product_url'), $url, 1);
587
 
588
+
 
 
 
 
 
 
 
 
 
 
589
  $xml .= $helper->tag($this->__('url_image'), $helper->getImageDir() . $image, 1); //r�cup�re l'image sur le p�re
590
 
591
  if($many_images == 1) {
605
  $xml .= $helper->tag($this->__('b_availability'), $stock, 1);
606
  $xml .= $helper->tag($this->__('b_qty'), $qty);
607
  $xml .= $helper->tag($this->__('b_delivery'), $shipping, 1);
608
+ if($shipping_logic == 1) {
609
+ $shipping_rate = $beezup->_getShippingPrice($c, $shipping_carrier, $default_country);
610
+ if($shipping_rate == 0 && $default_shipping_cost > 0) {
611
+ $shipping_rate = $default_shipping_cost;
612
+ }
613
+ $xml .= $helper->tag($this->__('b_shipping'), $helper->currency($shipping_rate));
614
+ } else {
615
+ $xml .= $helper->tag($this->__('b_shipping'), $helper->currency($beezup->getShippingAmount($c->getWeight(), $_tablerates)));
616
+ }
617
+
618
  $xml .= $helper->tag($this->__('b_weight'), $helper->currency($c->getWeight()));
619
  $xml .= $helper->tag($this->__('b_price'), $helper->currency($final_price*$_vat));
620
  if ($price != $final_price) $xml .= $helper->tag($this->__('b_regular_price'), $helper->currency($price*$_vat));
646
  $helper = Mage::helper('beezup');
647
  $category_logic = $helper->getConfig('beezup/flux/category_logic');
648
  /* Initially load the useful elements */
649
+ $shipping_logic = $helper->getConfig('beezup/flux/carrier_method');
650
+ if($shipping_logic == 1) {
651
+ $shipping_carrier = $helper->getConfig('beezup/flux/shipping_carrier');
652
+ $default_country = $helper->getConfig('beezup/flux/default_country');
653
+ }
654
+
655
+ $default_shipping_cost = (int)$helper->getConfig('beezup/flux/default_shipping_cost');
656
  $many_images = $helper->getConfig('beezup/flux/images');
657
  $_ht = $helper->getConfig('beezup/flux/ht');
658
+ $_description = $helper->getConfig('beezup/flux/description');
659
+ $_description = explode(",", $_description);
660
+ $enable_html = $helper->getConfig('beezup/flux/description_html');
661
+ $_tablerates = 0;
662
  $cat_logic = false;
663
+
664
+ $_categories = $beezup->getCategoriesAsArray(Mage::helper('catalog/category')->getStoreCategories());
665
+
666
+
667
  $_vat = ($_ht && is_numeric($helper->getConfig('beezup/flux/vat'))) ? (preg_replace('(\,+)', '.', $helper->getConfig('beezup/flux/vat')) / 100) + 1 : 1;
668
  $_attributes = $helper->getConfig('beezup/flux/attributes') ? explode(',', $helper->getConfig('beezup/flux/attributes')) : array();
669
+ // $_catalog_rules = $helper->getConfig('beezup/flux/catalog_rules');
670
 
671
  $products = $beezup->getGroupedProduct();
672
 
673
+ $buf = "\xEF\xBB\xBF";
674
  foreach ($products as $product) {
675
  $associatedProducts = $product->getTypeInstance(true)->getAssociatedProducts($product);
676
 
700
  echo "----------------------------" ."<br/>";
701
  echo "Name : " .$g->getName() ."<br/>";
702
  echo "Description : ".$parentDesc ."<br/>";
703
+ echo "Id : " .$g->getId() ."<br/>";
704
+ echo "Parent Id : " .$parentId ."<br/>";
705
+ echo "Url : " .$parentUrl ."<br/>";
706
+ echo "Image : " .$helper->getImageDir().$image ."<br/>";
707
+
708
+
709
+ echo "SKU : " .$g->getSku() ."<br/>";
710
+ echo "Quantity : " .$qty ."<br/>";
711
+ echo "Stock : " .$stock ."<br/>";
712
+ echo "Shipping : " .$shipping ."<br/>";
713
+ echo "price : " .$price ."<br/>";
714
+ echo "finalprice : ".$final_price ."<br/>";
715
+ echo "weight : " .$g->getWeight() ."<br/>";
716
+
717
+ $i = 1;
718
+ foreach ($parentCategories as $v)
719
+ echo "Cat�gorie ".$i." : ".$v."<br/>";
720
  }
721
 
722
 
724
  $buf .= $helper->tag($this->__('b_unique_id'), $g->getId());
725
  $buf .= $helper->tag($this->__('b_sku'), trim($g->getSku()), 1);
726
  if ($configurable){
727
+ $buf .= $helper->tag($this->__('parent_or_child'), 'grouped_child', 1);
728
+ $buf .= $helper->tag($this->__('parent_id'), $parentId);
729
  }
730
  $buf .= $helper->tag($this->__('b_title'), $g->getName()/*trim($name)*/, 1);
731
  $buf .= $helper->tag($this->__('b_description'), preg_replace("/(\r\n|\n|\r)/", ' ', strip_tags($parentDesc)), 1);
732
  $buf .= $helper->tag($this->__('b_product_url'), $parentUrl, 1);
733
 
734
  /*
735
+ if($many_images==1) {
736
+
737
+ $gprod = Mage::getModel('catalog/product')->load( $g->getId());
738
+ $inc = 0;
739
+ foreach ($gprod->getMediaGalleryImages() as $image) {
740
+ $inc++;
741
+ if($inc==1) {
742
+ $buf .= $helper->tag($this->__('url_image'), $image->getUrl(), 1);
743
+ } else {
744
+ $buf .= $helper->tag($this->__('url_image')."_".$inc, $image->getUrl(), 1);
745
+ }
746
+ }
747
+ } else {
748
+
749
+ $buf .= $helper->tag($this->__('url_image'), $helper->getImageDir() . $image, 1);
750
  }*/
751
 
752
  $buf .= $helper->tag($this->__('b_product_image'), $helper->getImageDir() . $image, 1); //r�cup�re l'image sur le p�re
753
  $buf .= $helper->tag($this->__('b_availability'), $stock, 1);
754
  $buf .= $helper->tag($this->__('b_qty'), $qty);
755
  $buf .= $helper->tag($this->__('b_delivery'), $shipping, 1);
756
+ if($shipping_logic == 1) {
757
+ if($shipping_rate == 0 && $default_shipping_cost > 0) {
758
+ $shipping_rate = $default_shipping_cost;
759
+ }
760
+ $shipping_rate = $beezup->_getShippingPrice($g, $shipping_carrier, $default_country);
761
+ $xml .= $helper->tag($this->__('b_shipping'), $helper->currency($shipping_rate));
762
+ } else {
763
+ $xml .= $helper->tag($this->__('b_shipping'), $helper->currency($beezup->getShippingAmount($g->getWeight(), $_tablerates)));
764
+ }
765
+
766
  $buf .= $helper->tag($this->__('b_weight'), $helper->currency($g->getWeight()));
767
  $buf .= $helper->tag($this->__('b_price'), $helper->currency($final_price * $_vat));
768
  if ($price != $final_price) $buf .= $helper->tag($this->__('b_regular_price'), $helper->currency($price*$_vat));
app/code/community/BeezUp/Helper/Data.php CHANGED
@@ -1,68 +1,101 @@
1
  <?php
2
-
3
- class BeezUp_Helper_Data extends Mage_Core_Helper_Abstract
4
- {
5
-
6
- /*
7
- * Retrieve product image directory
8
- *
9
- * @return string
10
- */
11
- public function getImageDir()
12
- {
13
- return Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA) . 'catalog/product';
14
- }
15
-
16
- /*
17
- * Retrieve config path value
18
- *
19
- * @return string
20
- */
21
- public function getConfig($path = '')
22
- {
23
- if($path) {
24
- return Mage::getStoreConfig($path);
25
- }
26
- return '';
27
- }
28
-
29
- /*
30
- * Retrieve Remote Address
31
- *
32
- * @return string
33
- */
34
- public function getRemoteAddr()
35
- {
36
- return $_SERVER['REMOTE_ADDR'];
37
- }
38
-
39
- /*
40
- * Retrieve tag
41
- *
42
- * @param string $tagName
43
- * @param string $content
44
- * @param bool $cdata
45
- * @return string
46
- */
47
- public function tag($tagName, $content, $cdata = 0)
48
- {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
49
  $result = '<' . $tagName . '>';
50
  if ($cdata) $result .= '<![CDATA[';
51
  $result .= preg_replace('(^' . $this->__('No') . '$)', '', trim($content));
52
  if ($cdata) $result .= ']]>';
53
  $result .= '</' . $tagName . '>';
54
  return $result;
55
- }
56
-
57
- /*
58
- * Format currency
59
- *
60
- * @param float $v
61
- * @return string
62
- */
63
- public function currency($v)
64
- {
65
  return number_format($v, 2, '.', '');
66
- }
67
-
68
- }
1
  <?php
2
+
3
+ class BeezUp_Helper_Data extends Mage_Core_Helper_Abstract
4
+ {
5
+
6
+ public function _getProductPrice($objProduct){
7
+
8
+ $price = '';
9
+ $classId = $objProduct->getTaxClassId();
10
+
11
+ $catalogRulePrice = "";
12
+ $taxprice = Mage::helper('tax')->getPrice($objProduct, $objProduct->getFinalPrice());
13
+ $catalogRulePrice = Mage::getModel('catalogrule/rule')->calcProductPriceRule($objProduct, $taxprice);
14
+ $price = $taxprice;
15
+ // Added logc to consider speacial price in feed if it is available
16
+ if ($objProduct->getSpecialPrice()) {
17
+ $today = mktime(0, 0, 0, date('m'), date('d'), date('y'));
18
+ $todaytimestamp = strtotime(date('Y-m-d 00:00:00', $today));
19
+ $spcl_pri_time = strtotime($objProduct->getSpecialToDate());
20
+ if ($spcl_pri_time <= $todaytimestamp) {
21
+ $_price = number_format($objProduct->getSpecialPrice(), 2, ".", "");
22
+ } else {
23
+ $_price = number_format($objProduct->getPrice(), 2, ".", "");
24
+ }
25
+
26
+
27
+ } else if ($catalogRulePrice) {
28
+ $price = number_format($catalogRulePrice, 2, ".", "");
29
+ } else {
30
+ $_price = number_format($objProduct->getPrice(), 2, ".", "");
31
+
32
+ }
33
+
34
+ return $price;
35
+
36
+ }
37
+
38
+
39
+ /*
40
+ * Retrieve product image directory
41
+ *
42
+ * @return string
43
+ */
44
+ public function getImageDir()
45
+ {
46
+ return Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA) . 'catalog/product';
47
+ }
48
+
49
+ /*
50
+ * Retrieve config path value
51
+ *
52
+ * @return string
53
+ */
54
+ public function getConfig($path = '')
55
+ {
56
+ if($path) {
57
+ return Mage::getStoreConfig($path);
58
+ }
59
+ return '';
60
+ }
61
+
62
+ /*
63
+ * Retrieve Remote Address
64
+ *
65
+ * @return string
66
+ */
67
+ public function getRemoteAddr()
68
+ {
69
+ return $_SERVER['REMOTE_ADDR'];
70
+ }
71
+
72
+ /*
73
+ * Retrieve tag
74
+ *
75
+ * @param string $tagName
76
+ * @param string $content
77
+ * @param bool $cdata
78
+ * @return string
79
+ */
80
+ public function tag($tagName, $content, $cdata = 0)
81
+ {
82
  $result = '<' . $tagName . '>';
83
  if ($cdata) $result .= '<![CDATA[';
84
  $result .= preg_replace('(^' . $this->__('No') . '$)', '', trim($content));
85
  if ($cdata) $result .= ']]>';
86
  $result .= '</' . $tagName . '>';
87
  return $result;
88
+ }
89
+
90
+ /*
91
+ * Format currency
92
+ *
93
+ * @param float $v
94
+ * @return string
95
+ */
96
+ public function currency($v)
97
+ {
98
  return number_format($v, 2, '.', '');
99
+ }
100
+
101
+ }
app/code/community/BeezUp/Model/Products.php CHANGED
@@ -9,38 +9,66 @@
9
  * @param bool $configurable
10
  * @return Mage_Catalog_Model_Resource_Product_Collection?
11
  */
12
- public function getProducts($configurable = false)
13
- {
14
- $products = Mage::getResourceModel('catalog/product_collection')
15
  ->addAttributeToFilter('status', 1)
16
- ->addAttributeToFilter('visibility', array('in' => array(Mage_Catalog_Model_Product_Visibility::VISIBILITY_IN_CATALOG, Mage_Catalog_Model_Product_Visibility::VISIBILITY_BOTH)))
17
  ->addAttributeToFilter('price', array('neq' => 0))
18
  ->addAttributeToSelect('name')
19
  ->addAttributeToSelect('weight')
20
  ->addAttributeToSelect('sku')
21
  ->addAttributeToSelect('special_price')
22
- ->addAttributeToSelect('special_from_date')
23
  ->addAttributeToSelect('special_to_date')
24
  ->addAttributeToSelect('small_image')
25
  ->addAttributeToSelect('image')
26
- ->addAttributeToSelect(Mage::getStoreConfig('beezup/flux/description'))
27
- ->addStoreFilter();
28
-
29
- if($configurable) $products->addAttributeToFilter('type_id', Mage_Catalog_Model_Product_Type::TYPE_CONFIGURABLE);
30
-
31
- if(Mage::getStoreConfig('beezup/flux/stock')){
32
- $products= $products->joinField('inventory_in_stock', 'cataloginventory_stock_item', 'is_in_stock', 'product_id=entity_id','is_in_stock>=0', 'left')
33
- ->addAttributeToFilter('inventory_in_stock', array('neq' => 0));
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
34
  }
35
 
36
- $attributes = explode(',', Mage::getStoreConfig('beezup/flux/attributes'));
37
- foreach ($attributes as $a) $products->addAttributeToSelect($a);
38
-
39
- if (Mage::getStoreConfig('beezup/flux/debug_flux')) $products->setPageSize(10);
40
-
41
- return $products;
42
- }
43
-
44
  public function getGroupedProduct()
45
  {
46
  $products = Mage::getModel('catalog/product')
@@ -55,19 +83,48 @@
55
  public function getProductsSimple()
56
  {
57
  $products = Mage::getResourceModel('catalog/product_collection')
58
- ->addAttributeToFilter('status', 1)
59
- ->addAttributeToFilter('visibility', array('in' => array(Mage_Catalog_Model_Product_Visibility::VISIBILITY_IN_CATALOG, Mage_Catalog_Model_Product_Visibility::VISIBILITY_BOTH)))
60
- ->addAttributeToFilter('price', array('neq' => 0))
61
- ->addAttributeToSelect('name')
62
- ->addAttributeToSelect('weight')
63
- ->addAttributeToSelect('sku')
64
- ->addAttributeToSelect('special_price')
65
  ->addAttributeToSelect('special_from_date')
66
- ->addAttributeToSelect('special_to_date')
67
- ->addAttributeToSelect('small_image')
68
- ->addAttributeToSelect('image')
69
- ->addAttributeToSelect(Mage::getStoreConfig('beezup/flux/description'))
70
- ->addStoreFilter();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
71
 
72
  $products->addAttributeToFilter('type_id', Mage_Catalog_Model_Product_Type::TYPE_SIMPLE);
73
 
@@ -89,285 +146,367 @@
89
  *
90
  * @return Mage_Catalog_Model_Resource_Product_Collection?
91
  */
92
- public function getConfigurableProducts($config = true) {
93
- $products = Mage::getResourceModel('catalog/product_type_configurable_product_collection')
94
- ->addAttributeToFilter('status', 1)
95
- ->addAttributeToFilter('price', array('neq' => 0))
96
- ->addAttributeToSelect('name')
97
- ->addAttributeToSelect('weight')
98
- ->addAttributeToSelect('sku')
99
  ->addAttributeToSelect('special_from_date')
100
- ->addAttributeToSelect('special_to_date')
101
- ->addAttributeToSelect('special_price')
102
- ->addAttributeToSelect('small_image')
103
- ->addAttributeToSelect('image')
104
- ->addAttributeToSelect(Mage::getStoreConfig('beezup/flux/description'))
105
- ->addStoreFilter();
 
 
 
 
 
106
 
107
- if(Mage::getStoreConfig('beezup/flux/stock')){
108
- $products= $products->joinField('inventory_in_stock', 'cataloginventory_stock_item', 'is_in_stock', 'product_id=entity_id','is_in_stock>=0', 'left')
109
- ->addAttributeToFilter('inventory_in_stock', array('neq' => 0));
110
- }
111
-
112
- $attributes = explode(',', Mage::getStoreConfig('beezup/flux/attributes'));
113
- foreach ($attributes as $a) $products->addAttributeToSelect($a);
114
-
115
- $productsArray = $products;
116
-
117
- //si on est dans le cas o� on veut les p�res et les fils
118
- if($config){
119
- $productsArray = array();
120
-
121
- foreach($products as $p) {
122
- $productsArray[$p->getParentId()][] = $p;
123
  }
124
- }
125
-
126
- return $productsArray;
127
- }
128
-
129
-
130
- /*
131
- * Collect options applicable to the configurable product for Varation Theme
132
- *
133
- * @param Mage_Catalog_Model_Product $product
134
- * @return String
135
- */
136
-
137
- public function getOptions($product) {
138
- $childs = $this->getConfigurableProducts();
139
 
140
- //si c'est un parent
141
- if(isset($childs[$product->getId()])) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
142
  $productAttributeOptions = $product->getTypeInstance(true)->getConfigurableAttributesAsArray($product);
143
 
144
  $attributeOptions = array();
145
 
146
  foreach ($productAttributeOptions as $productAttribute) {
147
- $attributeOptions[] = ucfirst($productAttribute['attribute_code']);
148
  }
149
 
150
  return implode('',$attributeOptions);
151
- }
152
- }
153
-
154
- /*
155
- * Retrieve products stock
156
- *
157
- * @param int $id
158
- * @param int $qty
159
- * @return int
160
- */
161
- public function getQty($productId, $qty = 0)
162
- {
163
- $stockItem = Mage::getModel('cataloginventory/stock_item')->loadByProduct($productId);
164
- if ($stockItem->getManageStock()) {
165
  if ($stockItem->getIsInStock()) {
166
- $qty = intval($stockItem->getQty());
167
- $qty = ($qty <= 0) ? 0 : $qty;
168
  }
169
  } else {
170
  $qty = 100;
171
- }
172
- return $qty;
173
- }
174
-
175
- /*
176
- * Retrieve product shipping amount
177
- *
178
- * @param float $weight
179
- * @param Mage_Shipping_Model_Mysql4_Carrier_Tablerate_Collection $tablerates
180
- * @return float
181
- */
182
- public function getShippingAmount($weight, $tablerates)
183
- {
184
- $shipping_amount = 0;
185
-
186
- if ($tablerates && $tablerates instanceof Mage_Shipping_Model_Mysql4_Carrier_Tablerate_Collection) {
187
  foreach ($tablerates as $t) {
188
- if ($weight <= $t->getConditionValue()) $shipping_amount = $t->getPrice();
189
  }
190
  } else {
191
  $shipping_amount = preg_replace('(\,+)', '.', trim(Mage::getStoreConfig('beezup/flux/ship')));
192
  if (!is_numeric($shipping_amount)) $shipping_amount = 0;
193
- }
194
- return $shipping_amount;
195
- }
196
-
197
- /*
198
- * Retrieve Tablerates
199
- *
200
- * @return Mage_Shipping_Model_Mysql4_Carrier_Tablerate_Collection
201
- */
202
- public function getTablerates()
203
- {
204
- return Mage::getResourceModel('shipping/carrier_tablerate_collection')->setOrder('condition_value', 'desc');
205
- }
206
-
207
- /*
208
- * Retrieve product is in stock
209
- *
210
- * @param float $qty
211
- * @return string
212
- */
213
- public function getIsInStock($qty)
214
- {
215
- return ($qty > 0) ? Mage::helper('beezup')->__('In Stock') : Mage::helper('beezup')->__('Out of Stock');
216
- }
217
-
218
- /*
219
- * Retrieve product delivery
220
- *
221
- * @param float $qty
222
- * @return string
223
- */
224
- public function getDelivery($qty)
225
- {
226
- return ($qty > 0) ? Mage::getStoreConfig('beezup/flux/days_in') : Mage::getStoreConfig('beezup/flux/days_out');
227
- }
228
-
229
- /*
230
- * Retrieve store categories as array (recursive)
231
- *
232
- * @param Varien_Data_Tree_Node_Collection $categories
233
- * @param string $parent
234
- * @param array $cats
235
- * @return string
236
- */
237
- public function getCategoriesAsArray($categories, $logic = false, $parent = '', &$cats = array())
238
- {
239
- if($logic) {
240
  $parent = 0;
241
  $i = 0;
242
  $tl_name = '';
243
  $_categories = $categories;
244
  foreach($_categories as $_category){
245
-
246
- if($i==0 ) {
247
- $par_cat = Mage::getModel('catalog/category')->load($_category->getId())->getParentCategory();
248
-
249
- $cats[$par_cat->getId()] = array("name" => $tl_name.$par_cat->getName(), "id" => $par_cat->getId(), "parent" => $par_cat->getParentId());
250
- }
251
-
252
-
253
- //$_category = Mage::getModel('catalog/category')->load($_category->getId());
254
- $cats[$_category->getId()] = array("name" => $tl_name.$_category->getName(), "id" => $_category->getId(), "parent" => $_category->getParentId() ); //Toplevel auslesen
255
- $i++;
256
- $_category = Mage::getModel('catalog/category')->load($_category->getId());
257
- $subcats = $this->getChildCategories($_category);
258
-
259
- foreach($subcats as $c) {
260
-
261
- $cats[$c['id']] = array("name" => $tl_name.$c['name'], "id" => $c['id'] , "parent" => $c['parent']);
262
- }
263
- }
264
- return $cats;
265
-
266
  } else {
267
  foreach ($categories as $c) {
268
- $cats[$c['entity_id']] = $parent . $c['name'];
269
-
270
- if (!Mage::helper('catalog/category_flat')->isEnabled()) {
271
- if ($childs = $c->getChildren()) {
272
- $this->getCategoriesAsArray($childs, $logic, $parent . $c['name'] . '||', $cats);
273
- }
274
- } else {
275
- if (isset($c['children_nodes'])) {
276
- $this->getCategoriesAsArray($c['children_nodes'], $logic, $parent . $c['name'] . '||', $cats);
277
- }
278
- }
279
  }
280
- }
281
- return $cats;
282
- }
283
-
284
-
285
- public $_catIds = array();
286
- public function getChildCategories($categoryObject){
287
- $categories = $categoryObject->getChildrenCategories();
288
- foreach ($categories as $catgory){
 
 
 
 
 
 
289
  if($catgory->hasChildren()){
290
- $this->getChildCategories($catgory);
291
  }
292
  $this->_catIds[] = array("id" => $catgory->getId(), "name" => $catgory->getName(), "parent" => $catgory->getParentId());
293
- }
294
- return $this->_catIds;
295
- }
296
-
297
- /*
298
- * Retrieve product categories
299
- *
300
- * @param Mage_Catalog_Model_Product $product
301
- * @param array $categories
302
- * @return array
303
- */
304
- public function getProductsCategories($product,$categories)
305
- {
306
-
307
-
308
  $_categories = $product->getCategoryIds();
309
 
310
  sort($_categories);
311
  $result = array();
312
  if(count($_categories)) {
313
- $_count = 0;
314
- foreach($_categories as $c) {
315
- if(isset($categories[$c])) {
316
- if(count(explode('||',$categories[$c])) > $_count) $result = explode('||',$categories[$c]);
317
- $_count = count($result);
318
- }
319
- }
320
  }
321
-
322
- return $result;
323
- }
324
-
325
-
326
- /*
327
- * Retrieve product categories
328
- *
329
- * @param Mage_Catalog_Model_Product $product
330
- * @param array $categories
331
- * @return array
332
- */
333
- public function getProductsCategories2($product,$categories)
334
- {
335
- $result = array();
336
- $_categories = $product->getCategoryIds();
337
- $parent_id = 0;
338
- $parent_id = 0;
339
- $i = 0;
340
- sort($_categories);
341
-
342
- if(count($_categories)) {
343
- $_count = 0;
344
- foreach($_categories as $c) {
345
- if(isset($categories[$c])) {
346
- if( $parent_id == $categories[$c]['parent'] || $i <= 1) {
347
- $result[] = $categories[$c]['name'];
348
-
349
-
350
- $parent_id = $categories[$c]['id'];
351
-
352
- }
353
- $i++;
354
- // if(count(explode('||',$categories[$c])) > $_count) $result = explode('||',$categories[$c]);
355
- $_count = count($result);
356
- }
357
- }
358
- }
359
- return $result;
360
- }
361
-
362
-
363
- /*
364
- * Retrieve current store
365
- *
366
- * @return Mage_Core_Model_Store
367
- */
368
- public function getStore()
369
- {
370
- return Mage::app()->getStore();
371
- }
372
-
373
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9
  * @param bool $configurable
10
  * @return Mage_Catalog_Model_Resource_Product_Collection?
11
  */
12
+ public function getProducts($configurable = false)
13
+ {
14
+ $products = Mage::getResourceModel('catalog/product_collection')
15
  ->addAttributeToFilter('status', 1)
 
16
  ->addAttributeToFilter('price', array('neq' => 0))
17
  ->addAttributeToSelect('name')
18
  ->addAttributeToSelect('weight')
19
  ->addAttributeToSelect('sku')
20
  ->addAttributeToSelect('special_price')
21
+ ->addAttributeToSelect('special_from_date')
22
  ->addAttributeToSelect('special_to_date')
23
  ->addAttributeToSelect('small_image')
24
  ->addAttributeToSelect('image')
25
+ //->addAttributeToSelect(Mage::getStoreConfig('beezup/flux/description'))
26
+ ->addAttributeToSelect("description")
27
+ ->addAttributeToSelect("short_description")
28
+ ->addAttributeToSelect("meta_description")
29
+ ->addAttributeToSelect("meta_title")
30
+ ->addAttributeToSelect("meta_keyword")
31
+ ->addStoreFilter();
32
+
33
+ $visibility = Mage::getStoreConfig('beezup/flux/visibility');
34
+ switch($visibility) {
35
+ case 1:
36
+ $products->addAttributeToFilter('visibility', array('in' => array(Mage_Catalog_Model_Product_Visibility::VISIBILITY_IN_CATALOG)));
37
+ break;
38
+ case 2:
39
+ $products->addAttributeToFilter('visibility', array('in' => array(Mage_Catalog_Model_Product_Visibility::VISIBILITY_IN_SEARCH)));
40
+ break;
41
+ case 3:
42
+ $products->addAttributeToFilter('visibility', array('in' => array(Mage_Catalog_Model_Product_Visibility::VISIBILITY_BOTH)));
43
+ break;
44
+ case 4:
45
+ $products->addAttributeToFilter('visibility', array('in' => array(Mage_Catalog_Model_Product_Visibility::VISIBILITY_IN_CATALOG, Mage_Catalog_Model_Product_Visibility::VISIBILITY_IN_SEARCH, Mage_Catalog_Model_Product_Visibility::VISIBILITY_BOTH)));
46
+ break;
47
+ case 5:
48
+ $products->addAttributeToFilter('visibility', array('in' => array(Mage_Catalog_Model_Product_Visibility::VISIBILITY_NOT_VISIBLE)));
49
+ break;
50
+ case 6:
51
+ breaK;
52
+ case 7:
53
+ $products->addAttributeToFilter('visibility', array('in' => array(Mage_Catalog_Model_Product_Visibility::VISIBILITY_IN_CATALOG, Mage_Catalog_Model_Product_Visibility::VISIBILITY_BOTH)));
54
+ break;
55
+ }
56
+
57
+ if($configurable) $products->addAttributeToFilter('type_id', Mage_Catalog_Model_Product_Type::TYPE_CONFIGURABLE);
58
+
59
+ if(Mage::getStoreConfig('beezup/flux/stock')){
60
+ $products= $products->joinField('inventory_in_stock', 'cataloginventory_stock_item', 'is_in_stock', 'product_id=entity_id','is_in_stock>=0', 'left')
61
+ ->addAttributeToFilter('inventory_in_stock', array('neq' => 0));
62
+ }
63
+
64
+ $attributes = explode(',', Mage::getStoreConfig('beezup/flux/attributes'));
65
+ foreach ($attributes as $a) $products->addAttributeToSelect($a);
66
+
67
+ if (Mage::getStoreConfig('beezup/flux/debug_flux')) $products->setPageSize(10);
68
+
69
+ return $products;
70
  }
71
 
 
 
 
 
 
 
 
 
72
  public function getGroupedProduct()
73
  {
74
  $products = Mage::getModel('catalog/product')
83
  public function getProductsSimple()
84
  {
85
  $products = Mage::getResourceModel('catalog/product_collection')
86
+ ->addAttributeToFilter('status', 1)
87
+ ->addAttributeToFilter('price', array('neq' => 0))
88
+ ->addAttributeToSelect('name')
89
+ ->addAttributeToSelect('weight')
90
+ ->addAttributeToSelect('sku')
91
+ ->addAttributeToSelect('special_price')
 
92
  ->addAttributeToSelect('special_from_date')
93
+ ->addAttributeToSelect('special_to_date')
94
+ ->addAttributeToSelect('small_image')
95
+ ->addAttributeToSelect('image')
96
+ // ->addAttributeToSelect(Mage::getStoreConfig('beezup/flux/description'))
97
+ ->addAttributeToSelect("description")
98
+ ->addAttributeToSelect("short_description")
99
+ ->addAttributeToSelect("meta_description")
100
+ ->addAttributeToSelect("meta_title")
101
+ ->addAttributeToSelect("meta_keyword")
102
+ ->addStoreFilter();
103
+
104
+ $visibility = Mage::getStoreConfig('beezup/flux/visibility');
105
+ switch($visibility) {
106
+ case 1:
107
+ $products->addAttributeToFilter('visibility', array('in' => array(Mage_Catalog_Model_Product_Visibility::VISIBILITY_IN_CATALOG)));
108
+ break;
109
+ case 2:
110
+ $products->addAttributeToFilter('visibility', array('in' => array(Mage_Catalog_Model_Product_Visibility::VISIBILITY_IN_SEARCH)));
111
+ break;
112
+ case 3:
113
+ $products->addAttributeToFilter('visibility', array('in' => array(Mage_Catalog_Model_Product_Visibility::VISIBILITY_BOTH)));
114
+ break;
115
+ case 4:
116
+ $products->addAttributeToFilter('visibility', array('in' => array(Mage_Catalog_Model_Product_Visibility::VISIBILITY_IN_CATALOG, Mage_Catalog_Model_Product_Visibility::VISIBILITY_IN_SEARCH, Mage_Catalog_Model_Product_Visibility::VISIBILITY_BOTH)));
117
+ break;
118
+ case 5:
119
+ $products->addAttributeToFilter('visibility', array('in' => array(Mage_Catalog_Model_Product_Visibility::VISIBILITY_NOT_VISIBLE)));
120
+ break;
121
+ case 6:
122
+ breaK;
123
+ case 7:
124
+ $products->addAttributeToFilter('visibility', array('in' => array(Mage_Catalog_Model_Product_Visibility::VISIBILITY_IN_CATALOG, Mage_Catalog_Model_Product_Visibility::VISIBILITY_BOTH)));
125
+ break;
126
+ }
127
+
128
 
129
  $products->addAttributeToFilter('type_id', Mage_Catalog_Model_Product_Type::TYPE_SIMPLE);
130
 
146
  *
147
  * @return Mage_Catalog_Model_Resource_Product_Collection?
148
  */
149
+ public function getConfigurableProducts($config = true) {
150
+ $products = Mage::getResourceModel('catalog/product_type_configurable_product_collection')
151
+ ->addAttributeToFilter('status', 1)
152
+ ->addAttributeToFilter('price', array('neq' => 0))
153
+ ->addAttributeToSelect('name')
154
+ ->addAttributeToSelect('weight')
155
+ ->addAttributeToSelect('sku')
156
  ->addAttributeToSelect('special_from_date')
157
+ ->addAttributeToSelect('special_to_date')
158
+ ->addAttributeToSelect('special_price')
159
+ ->addAttributeToSelect('small_image')
160
+ ->addAttributeToSelect('image')
161
+ //->addAttributeToSelect(Mage::getStoreConfig('beezup/flux/description'))
162
+ ->addAttributeToSelect("description")
163
+ ->addAttributeToSelect("short_description")
164
+ ->addAttributeToSelect("meta_description")
165
+ ->addAttributeToSelect("meta_title")
166
+ ->addAttributeToSelect("meta_keyword")
167
+ ->addStoreFilter();
168
 
169
+ if(Mage::getStoreConfig('beezup/flux/stock')){
170
+ $products= $products->joinField('inventory_in_stock', 'cataloginventory_stock_item', 'is_in_stock', 'product_id=entity_id','is_in_stock>=0', 'left')
171
+ ->addAttributeToFilter('inventory_in_stock', array('neq' => 0));
 
 
 
 
 
 
 
 
 
 
 
 
 
172
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
173
 
174
+ $attributes = explode(',', Mage::getStoreConfig('beezup/flux/attributes'));
175
+ foreach ($attributes as $a) $products->addAttributeToSelect($a);
176
+
177
+ $productsArray = $products;
178
+
179
+ //si on est dans le cas o� on veut les p�res et les fils
180
+ if($config){
181
+ $productsArray = array();
182
+
183
+ foreach($products as $p) {
184
+ $productsArray[$p->getParentId()][] = $p;
185
+ }
186
+ }
187
+
188
+ return $productsArray;
189
+ }
190
+
191
+
192
+ /*
193
+ * Collect options applicable to the configurable product for Varation Theme
194
+ *
195
+ * @param Mage_Catalog_Model_Product $product
196
+ * @return String
197
+ */
198
+
199
+ public function getOptions($product) {
200
+ $childs = $this->getConfigurableProducts();
201
+
202
+ //si c'est un parent
203
+ if(isset($childs[$product->getId()])) {
204
  $productAttributeOptions = $product->getTypeInstance(true)->getConfigurableAttributesAsArray($product);
205
 
206
  $attributeOptions = array();
207
 
208
  foreach ($productAttributeOptions as $productAttribute) {
209
+ $attributeOptions[] = ucfirst($productAttribute['attribute_code']);
210
  }
211
 
212
  return implode('',$attributeOptions);
213
+ }
214
+ }
215
+
216
+ /*
217
+ * Retrieve products stock
218
+ *
219
+ * @param int $id
220
+ * @param int $qty
221
+ * @return int
222
+ */
223
+ public function getQty($productId, $qty = 0)
224
+ {
225
+ $stockItem = Mage::getModel('cataloginventory/stock_item')->loadByProduct($productId);
226
+ if ($stockItem->getManageStock()) {
227
  if ($stockItem->getIsInStock()) {
228
+ $qty = intval($stockItem->getQty());
229
+ $qty = ($qty <= 0) ? 0 : $qty;
230
  }
231
  } else {
232
  $qty = 100;
233
+ }
234
+ return $qty;
235
+ }
236
+
237
+ /*
238
+ * Retrieve product shipping amount
239
+ *
240
+ * @param float $weight
241
+ * @param Mage_Shipping_Model_Mysql4_Carrier_Tablerate_Collection $tablerates
242
+ * @return float
243
+ */
244
+ public function getShippingAmount($weight, $tablerates)
245
+ {
246
+ $shipping_amount = 0;
247
+
248
+ if ($tablerates && $tablerates instanceof Mage_Shipping_Model_Mysql4_Carrier_Tablerate_Collection) {
249
  foreach ($tablerates as $t) {
250
+ if ($weight <= $t->getConditionValue()) $shipping_amount = $t->getPrice();
251
  }
252
  } else {
253
  $shipping_amount = preg_replace('(\,+)', '.', trim(Mage::getStoreConfig('beezup/flux/ship')));
254
  if (!is_numeric($shipping_amount)) $shipping_amount = 0;
255
+ }
256
+ return $shipping_amount;
257
+ }
258
+
259
+ /*
260
+ * Retrieve Tablerates
261
+ *
262
+ * @return Mage_Shipping_Model_Mysql4_Carrier_Tablerate_Collection
263
+ */
264
+ public function getTablerates()
265
+ {
266
+ return Mage::getResourceModel('shipping/carrier_tablerate_collection')->setOrder('condition_value', 'desc');
267
+ }
268
+
269
+ /*
270
+ * Retrieve product is in stock
271
+ *
272
+ * @param float $qty
273
+ * @return string
274
+ */
275
+ public function getIsInStock($qty)
276
+ {
277
+ return ($qty > 0) ? Mage::helper('beezup')->__('In Stock') : Mage::helper('beezup')->__('Out of Stock');
278
+ }
279
+
280
+ /*
281
+ * Retrieve product delivery
282
+ *
283
+ * @param float $qty
284
+ * @return string
285
+ */
286
+ public function getDelivery($qty)
287
+ {
288
+ return ($qty > 0) ? Mage::getStoreConfig('beezup/flux/days_in') : Mage::getStoreConfig('beezup/flux/days_out');
289
+ }
290
+
291
+ /*
292
+ * Retrieve store categories as array (recursive)
293
+ *
294
+ * @param Varien_Data_Tree_Node_Collection $categories
295
+ * @param string $parent
296
+ * @param array $cats
297
+ * @return string
298
+ */
299
+ public function getCategoriesAsArray($categories, $logic = false, $parent = '', &$cats = array())
300
+ {
301
+ if($logic) {
302
  $parent = 0;
303
  $i = 0;
304
  $tl_name = '';
305
  $_categories = $categories;
306
  foreach($_categories as $_category){
307
+
308
+ if($i==0 ) {
309
+ $par_cat = Mage::getModel('catalog/category')->load($_category->getId())->getParentCategory();
310
+
311
+ $cats[$par_cat->getId()] = array("name" => $tl_name.$par_cat->getName(), "id" => $par_cat->getId(), "parent" => $par_cat->getParentId());
312
+ }
313
+
314
+
315
+ //$_category = Mage::getModel('catalog/category')->load($_category->getId());
316
+ $cats[$_category->getId()] = array("name" => $tl_name.$_category->getName(), "id" => $_category->getId(), "parent" => $_category->getParentId() ); //Toplevel auslesen
317
+ $i++;
318
+ $_category = Mage::getModel('catalog/category')->load($_category->getId());
319
+ $subcats = $this->getChildCategories($_category);
320
+
321
+ foreach($subcats as $c) {
322
+
323
+ $cats[$c['id']] = array("name" => $tl_name.$c['name'], "id" => $c['id'] , "parent" => $c['parent']);
324
+ }
325
+ }
326
+ return $cats;
327
+
328
  } else {
329
  foreach ($categories as $c) {
330
+ $cats[$c['entity_id']] = $parent . $c['name'];
331
+
332
+ if (!Mage::helper('catalog/category_flat')->isEnabled()) {
333
+ if ($childs = $c->getChildren()) {
334
+ $this->getCategoriesAsArray($childs, $logic, $parent . $c['name'] . '||', $cats);
 
 
 
 
 
 
335
  }
336
+ } else {
337
+ if (isset($c['children_nodes'])) {
338
+ $this->getCategoriesAsArray($c['children_nodes'], $logic, $parent . $c['name'] . '||', $cats);
339
+ }
340
+ }
341
+ }
342
+ }
343
+ return $cats;
344
+ }
345
+
346
+
347
+ public $_catIds = array();
348
+ public function getChildCategories($categoryObject){
349
+ $categories = $categoryObject->getChildrenCategories();
350
+ foreach ($categories as $catgory){
351
  if($catgory->hasChildren()){
352
+ $this->getChildCategories($catgory);
353
  }
354
  $this->_catIds[] = array("id" => $catgory->getId(), "name" => $catgory->getName(), "parent" => $catgory->getParentId());
355
+ }
356
+ return $this->_catIds;
357
+ }
358
+
359
+ /*
360
+ * Retrieve product categories
361
+ *
362
+ * @param Mage_Catalog_Model_Product $product
363
+ * @param array $categories
364
+ * @return array
365
+ */
366
+ public function getProductsCategories($product,$categories)
367
+ {
368
+
369
+
370
  $_categories = $product->getCategoryIds();
371
 
372
  sort($_categories);
373
  $result = array();
374
  if(count($_categories)) {
375
+ $_count = 0;
376
+ foreach($_categories as $c) {
377
+ if(isset($categories[$c])) {
378
+ if(count(explode('||',$categories[$c])) > $_count) $result = explode('||',$categories[$c]);
379
+ $_count = count($result);
 
 
380
  }
381
+ }
382
+ }
383
+
384
+ return $result;
385
+ }
386
+
387
+
388
+ /*
389
+ * Retrieve product categories
390
+ *
391
+ * @param Mage_Catalog_Model_Product $product
392
+ * @param array $categories
393
+ * @return array
394
+ */
395
+ public function getProductsCategories2($product,$categories)
396
+ {
397
+ $result = array();
398
+ $_categories = $product->getCategoryIds();
399
+ $parent_id = 0;
400
+ $parent_id = 0;
401
+ $i = 0;
402
+ sort($_categories);
403
+
404
+ if(count($_categories)) {
405
+ $_count = 0;
406
+ foreach($_categories as $c) {
407
+ if(isset($categories[$c])) {
408
+ if( $parent_id == $categories[$c]['parent'] || $i <= 1) {
409
+ $result[] = $categories[$c]['name'];
410
+
411
+
412
+ $parent_id = $categories[$c]['id'];
413
+
414
+ }
415
+ $i++;
416
+ // if(count(explode('||',$categories[$c])) > $_count) $result = explode('||',$categories[$c]);
417
+ $_count = count($result);
418
+ }
419
+ }
420
+ }
421
+ return $result;
422
+ }
423
+
424
+
425
+ /*
426
+ * Retrieve current store
427
+ *
428
+ * @return Mage_Core_Model_Store
429
+ */
430
+ public function getStore()
431
+ {
432
+ return Mage::app()->getStore();
433
+ }
434
+
435
+
436
+
437
+
438
+
439
+ /**
440
+ * Get shipping price
441
+ *
442
+ * @param Mage_Catalog_Model_Product $product_instance
443
+ * @param string $carrierValue
444
+ * @param string $countryCode
445
+ *
446
+ * @return mixed
447
+ */
448
+ public function _getShippingPrice($product_instance, $carrierValue, $countryCode = 'FR')
449
+ {
450
+ $carrierTab = explode('_', $carrierValue);
451
+ list($carrierCode, $methodCode) = $carrierTab;
452
+ $shipping = Mage::getModel('shipping/shipping');
453
+ $methodModel = $shipping->getCarrierByCode($carrierCode);
454
+ if($methodModel) {
455
+ $result = $methodModel->collectRates($this->_getShippingRateRequest($product_instance, $countryCode));
456
+ if($result != NULL) {
457
+ if($result->getError()) {
458
+ return 0;
459
+ } else {
460
+ foreach($result->getAllRates() as $rate) {
461
+ return $rate->getPrice();
462
+ }
463
+ }
464
+ } else {
465
+ return 0;
466
+ }
467
+ }
468
+ return 0;
469
+ }
470
+
471
+ /**
472
+ * Get Shipping rate request
473
+ *
474
+ * @param Mage_Catalog_Model_Product $product_instance
475
+ * @param string $countryCode
476
+ *
477
+ * @return Mage_Shipping_Model_Rate_Request
478
+ */
479
+ protected function _getShippingRateRequest($product_instance, $countryCode = 'FR')
480
+ {
481
+ /** @var $request Mage_Shipping_Model_Rate_Request */
482
+ $request = Mage::getModel('shipping/rate_request');
483
+ $storeId = $request->getStoreId();
484
+ if (!$request->getOrig()) {
485
+ $request->setCountryId($countryCode)
486
+ ->setRegionId('')
487
+ ->setCity('')
488
+ ->setPostcode('');
489
+ }
490
+ $item = Mage::getModel('sales/quote_item');
491
+ $item->setStoreId($storeId);
492
+ $item->setOptions($product_instance->getCustomOptions())
493
+ ->setProduct($product_instance);
494
+ $request->setAllItems(array($item));
495
+ $request->setDestCountryId($countryCode);
496
+ $request->setDestRegionId('');
497
+ $request->setDestRegionCode('');
498
+ $request->setDestPostcode('');
499
+ $request->setPackageValue($product_instance->getPrice());
500
+ $request->setPackageValueWithDiscount($product_instance->getFinalPrice());
501
+ $request->setPackageWeight($product_instance->getWeight());
502
+ $request->setFreeMethodWeight(0);
503
+ $request->setPackageQty(1);
504
+ $request->setStoreId(Mage::app()->getStore()->getId());
505
+ $request->setWebsiteId(Mage::app()->getStore()->getWebsiteId());
506
+ $request->setBaseCurrency(Mage::app()->getStore()->getBaseCurrency());
507
+ $request->setPackageCurrency(Mage::app()->getStore()->getCurrentCurrency());
508
+ return $request;
509
+ }
510
+
511
+
512
+ }
app/code/community/BeezUp/Model/System/Config/Source/Attributes.php CHANGED
@@ -10,9 +10,9 @@ class BeezUp_Model_System_Config_Source_Attributes
10
  $attributeArray = array();
11
 
12
  foreach ($attribute as $option) {
13
- if ($option->getIsUserDefined() && $option->getFrontendLabel()) {
14
  $attributeArray[] = array('value' => $option->getAttributeCode(), 'label' => $option->getAttributeCode());
15
- }
16
  }
17
 
18
  return $attributeArray;
10
  $attributeArray = array();
11
 
12
  foreach ($attribute as $option) {
13
+ // if ($option->getIsUserDefined() && $option->getFrontendLabel()) {
14
  $attributeArray[] = array('value' => $option->getAttributeCode(), 'label' => $option->getAttributeCode());
15
+ // }
16
  }
17
 
18
  return $attributeArray;
app/code/community/BeezUp/Model/System/Config/Source/Carriers.php ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class BeezUp_Model_System_Config_Source_Carriers
4
+ {
5
+
6
+ public function toOptionArray()
7
+ {
8
+
9
+ $methods = Mage::getSingleton('shipping/config')->getActiveCarriers();
10
+
11
+ $options = array();
12
+
13
+ foreach($methods as $_ccode => $_carrier)
14
+ {
15
+ $_methodOptions = array();
16
+ if($_methods = $_carrier->getAllowedMethods())
17
+ {
18
+ foreach($_methods as $_mcode => $_method)
19
+ {
20
+ $_code = $_ccode . '_' . $_mcode;
21
+ $_methodOptions[] = array('value' => $_code, 'label' => $_method);
22
+ }
23
+
24
+ if(!$_title = Mage::getStoreConfig("carriers/$_ccode/title"))
25
+ $_title = $_ccode;
26
+
27
+ $options[] = array('value' => $_methodOptions, 'label' => $_title);
28
+ }
29
+ }
30
+
31
+ return $options;
32
+
33
+ }
34
+
35
+ }
app/code/community/BeezUp/Model/System/Config/Source/Countries.php ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class BeezUp_Model_System_Config_Source_Countries
4
+ {
5
+
6
+ public function toOptionArray()
7
+ {
8
+
9
+ $countryList = Mage::getResourceModel('directory/country_collection')
10
+ ->loadData()
11
+ ->toOptionArray(false);
12
+ return $countryList;
13
+
14
+
15
+ }
16
+
17
+ }
app/code/community/BeezUp/Model/System/Config/Source/Customercreate.php ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class BeezUp_Model_System_Config_Source_Customercreate
4
+ {
5
+
6
+ public function toOptionArray()
7
+ {
8
+ return array(
9
+ array('value' => 0, 'label' => Mage::helper('beezup')->__('Enable')),
10
+ array('value' => 1, 'label' => Mage::helper('beezup')->__('Disable')),
11
+ );
12
+ }
13
+
14
+ }
app/code/community/BeezUp/Model/System/Config/Source/Description.php CHANGED
@@ -9,6 +9,8 @@ class BeezUp_Model_System_Config_Source_Description
9
  array('value' => 'short_description', 'label' => Mage::helper('beezup')->__('Short Description')),
10
  array('value' => 'description', 'label' => Mage::helper('beezup')->__('Description')),
11
  array('value' => 'meta_description', 'label' => Mage::helper('beezup')->__('Meta Description')),
 
 
12
  );
13
  }
14
 
9
  array('value' => 'short_description', 'label' => Mage::helper('beezup')->__('Short Description')),
10
  array('value' => 'description', 'label' => Mage::helper('beezup')->__('Description')),
11
  array('value' => 'meta_description', 'label' => Mage::helper('beezup')->__('Meta Description')),
12
+ array('value' => 'meta_title', 'label' => Mage::helper('beezup')->__('Meta Title')),
13
+ array('value' => 'meta_keyword', 'label' => Mage::helper('beezup')->__('Meta Keywords')),
14
  );
15
  }
16
 
app/code/community/BeezUp/Model/System/Config/Source/Visibility.php ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class BeezUp_Model_System_Config_Source_Visibility
4
+ {
5
+
6
+ public function toOptionArray()
7
+ {
8
+ return array(
9
+ array('value' => 1, 'label' => Mage::helper('beezup')->__('Catalog')),
10
+ array('value' => 2, 'label' => Mage::helper('beezup')->__('Search')),
11
+ array('value' => 3, 'label' => Mage::helper('beezup')->__('Both')),
12
+ array('value' => 7, 'label' => Mage::helper('beezup')->__('Catalog and Both')),
13
+ array('value' => 4, 'label' => Mage::helper('beezup')->__('Catalog, Search and Both')),
14
+ array('value' => 5, 'label' => Mage::helper('beezup')->__('Not Visible')),
15
+ array('value' => 6, 'label' => Mage::helper('beezup')->__('Not Apply Filter')),
16
+ );
17
+ }
18
+
19
+ }
app/code/community/BeezUp/controllers/CatalogController.php CHANGED
@@ -5,10 +5,11 @@ class BeezUp_CatalogController extends Mage_Core_Controller_Front_Action
5
 
6
  public function preDispatch()
7
  {
 
8
  parent::preDispatch();
9
 
10
  $helper = Mage::helper('beezup');
11
-
12
  $_active = $helper->getConfig('beezup/flux/active');
13
  $_ip = $helper->getConfig('beezup/flux/ip');
14
  $_key = $helper->getConfig('beezup/flux/key');
@@ -20,17 +21,18 @@ class BeezUp_CatalogController extends Mage_Core_Controller_Front_Action
20
 
21
  public function xmlAction()
22
  {
23
- $this->getResponse()->setBody($this->getLayout()->createBlock('beezup/xml')->setConfigurable(false)->setChildXML(false)->toHtml());
 
24
  }
25
 
26
  public function configurableAction()
27
  {
28
- $this->getResponse()->setBody($this->getLayout()->createBlock('beezup/xml')->setConfigurable(true)->setChildXML(false)->toHtml());
29
  }
30
 
31
  public function childAction()
32
  {
33
- $this->getResponse()->setBody($this->getLayout()->createBlock('beezup/xml')->setConfigurable(false)->setChildXML(true)->toHtml());
34
  }
35
 
36
  }
5
 
6
  public function preDispatch()
7
  {
8
+ Mage::app()->loadAreaPart(Mage_Core_Model_App_Area::AREA_FRONTEND,Mage_Core_Model_App_Area::PART_EVENTS);
9
  parent::preDispatch();
10
 
11
  $helper = Mage::helper('beezup');
12
+
13
  $_active = $helper->getConfig('beezup/flux/active');
14
  $_ip = $helper->getConfig('beezup/flux/ip');
15
  $_key = $helper->getConfig('beezup/flux/key');
21
 
22
  public function xmlAction()
23
  {
24
+
25
+ $this->getResponse()->setHeader('Content-Type', 'text/xml')->setBody($this->getLayout()->createBlock('beezup/xml')->setConfigurable(false)->setChildXML(false)->toHtml());
26
  }
27
 
28
  public function configurableAction()
29
  {
30
+ $this->getResponse()->setHeader('Content-Type', 'text/xml')->setBody($this->getLayout()->createBlock('beezup/xml')->setConfigurable(true)->setChildXML(false)->toHtml());
31
  }
32
 
33
  public function childAction()
34
  {
35
+ $this->getResponse()->setHeader('Content-Type', 'text/xml')->setBody($this->getLayout()->createBlock('beezup/xml')->setConfigurable(false)->setChildXML(true)->toHtml());
36
  }
37
 
38
  }
app/code/community/BeezUp/controllers/CronController.php CHANGED
@@ -1,23 +1,76 @@
1
  <?php
2
- require_once dirname ( __FILE__ ) . "/../lib/bootstrap.php";
3
- require_once dirname ( __FILE__ ) . "/../lib/BeezupRepository.php";
4
- class BeezUp_CronController extends Mage_Core_Controller_Front_Action
5
- {
6
-
7
- public function preDispatch()
8
- {
9
- parent::preDispatch();
10
-
11
- $repository = new BeezupRepository();
12
  if(!$repository->isConnectionOk()) {
13
- $this->norouteAction();
14
- }
15
- }
16
-
17
- public function executeAction()
18
- {
19
- $this->getResponse()->setBody($this->getLayout()->createBlock('beezup/order')->executeCron());
20
- }
21
-
22
-
23
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  <?php
2
+ require_once dirname ( __FILE__ ) . "/../lib/bootstrap.php";
3
+ require_once dirname ( __FILE__ ) . "/../lib/BeezupRepository.php";
4
+ class BeezUp_CronController extends Mage_Core_Controller_Front_Action
5
+ {
6
+
7
+ public function preDispatch()
8
+ {
9
+ parent::preDispatch();
10
+
11
+ $repository = new BeezupRepository();
12
  if(!$repository->isConnectionOk()) {
13
+ $this->norouteAction();
14
+ }
15
+ }
16
+
17
+ public function executeAction()
18
+ {
19
+ $this->getResponse()->setBody($this->getLayout()->createBlock('beezup/order')->executeCron());
20
+ }
21
+
22
+
23
+ public function orderlinkAction()
24
+ {
25
+ $url = $_GET['url'];
26
+ $url = urldecode($url);
27
+ if($this->_stringContains($url, "go.beezup.com/OrderManagement/Informations?")) {
28
+ $data = substr($url, strpos($url, "go.beezup.com/OrderManagement/Informations?") + 1);
29
+ if($this->_stringContains($data, "BeezUPOrderUUId=") && $this->_stringContains($data, "AccountId=")) {
30
+ $order_id = $this->_getStringbetween($data, "BeezUPOrderUUId=", "&");
31
+ $account_id = substr($url, strpos($url, "AccountId=") + 1);
32
+ $account_id = str_replace("ccountId=", "", $account_id);
33
+ $marketplace = false;
34
+ if($this->_stringContains($data, "MarketplaceTechnicalCode=") ) {
35
+ $marketplace = $this->_getStringbetween($data, "MarketplaceTechnicalCode=", "&");
36
+ }
37
+ elseif( $this->_stringContains($data, "MarketPlaceBusinessCode=") ) {
38
+ $marketplace = $this->_getStringbetween($data, "MarketPlaceBusinessCode=", "&");
39
+ }
40
+ if($marketplace) {
41
+ $this->getResponse()->setBody($this->getLayout()->createBlock('beezup/order')->createOrderFromLink($account_id, $marketplace, $order_id));
42
+ }
43
+ }
44
+
45
+ }
46
+ }
47
+
48
+
49
+ private function _getStringbetween($string, $start, $end){
50
+ $string = ' ' . $string;
51
+ $ini = strpos($string, $start);
52
+ if ($ini == 0) return '';
53
+ $ini += strlen($start);
54
+ $len = strpos($string, $end, $ini) - $ini;
55
+ return substr($string, $ini, $len);
56
+ }
57
+
58
+ private function _stringContains($string, $value) {
59
+ if (strpos($string, $value) !== false) {
60
+ return true;
61
+ }
62
+ die("Error, data incorrect");
63
+ }
64
+
65
+
66
+ public function orderAction() {
67
+ $account_id = $_GET['acount_id'];
68
+ $order_id = $_GET['order_id'];
69
+ $marketplace =$_GET['marketplace'];
70
+ if(!is_numeric($account_id) ) {
71
+ die("Error, Order data incorrect");
72
+ }
73
+ $this->getResponse()->setBody($this->getLayout()->createBlock('beezup/order')->createOrderFromLink($account_id, $marketplace, $order_id));
74
+ }
75
+
76
+ }
app/code/community/BeezUp/etc/config.xml CHANGED
@@ -2,7 +2,7 @@
2
  <config>
3
  <modules>
4
  <BeezUp>
5
- <version>4.5.0</version>
6
  </BeezUp>
7
  </modules>
8
  <global>
@@ -164,14 +164,13 @@
164
  <active>0</active>
165
  <debug_flux>1</debug_flux>
166
  <ht>1</ht>
167
- <vat>19.6</vat>
168
- <tablerates_weight_destination>0</tablerates_weight_destination>
169
  <days_in>1-2</days_in>
170
  <days_out>6-8</days_out>
171
- <description>short_description</description>
172
- <catalog_rules>0</catalog_rules>
173
- <bom>1</bom>
174
  <cachedelay>2</cachedelay>
 
 
175
  <ship></ship>
176
  <key></key>
177
  <ip></ip>
2
  <config>
3
  <modules>
4
  <BeezUp>
5
+ <version>4.6.0</version>
6
  </BeezUp>
7
  </modules>
8
  <global>
164
  <active>0</active>
165
  <debug_flux>1</debug_flux>
166
  <ht>1</ht>
167
+ <vat>20</vat>
 
168
  <days_in>1-2</days_in>
169
  <days_out>6-8</days_out>
170
+ <description>description</description>
 
 
171
  <cachedelay>2</cachedelay>
172
+ <visiblity>7</visiblity>
173
+ <category_logic>1</category_logic>
174
  <ship></ship>
175
  <key></key>
176
  <ip></ip>
app/code/community/BeezUp/etc/system.xml CHANGED
@@ -1,7 +1,7 @@
1
  <config>
2
  <sections>
3
-
4
-
5
  <beezup translate="label" module="beezup">
6
  <label>BeezUP</label>
7
  <tab>catalog</tab>
@@ -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.5.0) - <a href="http://go.beezup.com" target="_blank">My BeezUP Account</a></div>]]></comment>
17
  <sort_order>1</sort_order>
18
  <show_in_default>1</show_in_default>
19
  <show_in_website>1</show_in_website>
@@ -27,7 +27,7 @@
27
  <show_in_default>1</show_in_default>
28
  <show_in_website>1</show_in_website>
29
  <show_in_store>1</show_in_store>
30
- </active>
31
  <storeid translate="label">
32
  <label>Store ID</label>
33
  <frontend_type>text</frontend_type>
@@ -36,7 +36,7 @@
36
  <show_in_default>1</show_in_default>
37
  <show_in_website>1</show_in_website>
38
  <show_in_store>1</show_in_store>
39
- </storeid>
40
  <marge translate="label">
41
  <label>Calculate product margin</label>
42
  <frontend_type>select</frontend_type>
@@ -46,7 +46,7 @@
46
  <show_in_default>1</show_in_default>
47
  <show_in_website>1</show_in_website>
48
  <show_in_store>1</show_in_store>
49
- </marge>
50
  <montant translate="label">
51
  <label>Total orders amount</label>
52
  <frontend_type>select</frontend_type>
@@ -55,7 +55,7 @@
55
  <show_in_default>1</show_in_default>
56
  <show_in_website>1</show_in_website>
57
  <show_in_store>1</show_in_store>
58
- </montant>
59
  <debug translate="label">
60
  <label>Logs</label>
61
  <frontend_type>select</frontend_type>
@@ -65,523 +65,583 @@
65
  <show_in_default>1</show_in_default>
66
  <show_in_website>1</show_in_website>
67
  <show_in_store>1</show_in_store>
68
- </debug>
69
- </fields>
70
- </tracking>
71
- </groups>
72
 
73
 
74
 
75
 
76
  <groups>
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.5.0) - <a href="http://go.beezup.com" target="_blank">My BeezUP Account</a></div>]]></comment>
81
  <sort_order>2</sort_order>
82
  <show_in_default>1</show_in_default>
83
  <show_in_website>1</show_in_website>
84
  <show_in_store>1</show_in_store>
85
- <fields>
86
-
87
- <api_credentials translate="comment">
88
- <label>BeezUP API Credentials:</label>
89
- <frontend_model>beezup/adminhtml_system_config_childgroup</frontend_model>
90
- <sort_order>0</sort_order>
91
  <show_in_default>1</show_in_default>
92
  <show_in_website>1</show_in_website>
93
  <show_in_store>1</show_in_store>
94
- </api_credentials>
95
-
96
- <connection_status translate="label">
97
  <label>API BeezUP Connection status:</label>
98
- <frontend_type>text</frontend_type>
99
- <frontend_model>beezup/adminhtml_system_config_credentials</frontend_model>
100
- <backend_model>beezup/system_config_backend_credentials</backend_model>
101
  <sort_order>1</sort_order>
102
  <show_in_default>1</show_in_default>
103
  <show_in_website>1</show_in_website>
104
  <show_in_store>1</show_in_store>
105
- </connection_status>
106
 
107
- <sync_status translate="label">
108
  <label>Sync Status:</label>
109
- <frontend_type>text</frontend_type>
110
- <frontend_model>beezup/adminhtml_system_config_syncstatus</frontend_model>
111
  <sort_order>2</sort_order>
112
  <show_in_default>1</show_in_default>
113
  <show_in_website>1</show_in_website>
114
  <show_in_store>1</show_in_store>
115
- </sync_status>
116
 
117
-
118
- <syncro_time translate="label">
119
  <label>Last synchronization time :</label>
120
- <frontend_type>text</frontend_type>
121
- <frontend_model>beezup/adminhtml_system_config_time</frontend_model>
122
- <backend_model>beezup/system_config_backend_time</backend_model>
123
  <sort_order>3</sort_order>
124
  <show_in_default>1</show_in_default>
125
  <show_in_website>1</show_in_website>
126
  <show_in_store>1</show_in_store>
127
- </syncro_time>
128
-
129
-
130
- <cron_url translate="label">
131
  <label>Manual orders retrieval link:</label>
132
- <frontend_type>text</frontend_type>
133
- <frontend_model>beezup/adminhtml_system_config_manualcron</frontend_model>
134
-
135
  <sort_order>4</sort_order>
136
  <show_in_default>1</show_in_default>
137
  <show_in_website>1</show_in_website>
138
  <show_in_store>1</show_in_store>
139
  <depends><connection_status>1</connection_status></depends>
140
- </cron_url>
141
-
142
- <cron_call translate="label">
143
  <label>Cron Call</label>
144
- <frontend_type>text</frontend_type>
145
- <frontend_model>beezup/adminhtml_system_config_cron</frontend_model>
146
-
147
  <sort_order>5</sort_order>
148
  <show_in_default>1</show_in_default>
149
  <show_in_website>1</show_in_website>
150
  <show_in_store>1</show_in_store>
151
  <depends><connection_status>1</connection_status></depends>
152
- </cron_call>
153
-
154
-
155
- <userid translate="label">
156
  <label>User Id</label>
157
- <frontend_type>text</frontend_type>
158
- <comment><![CDATA[<a href='https://go.beezup.com/Account/MyAccount' target='_blank'>My Account</a>]]></comment>
159
  <sort_order>6</sort_order>
160
  <show_in_default>1</show_in_default>
161
  <show_in_website>1</show_in_website>
162
  <show_in_store>1</show_in_store>
163
- </userid>
164
- <usertoken translate="label">
165
  <label>User Token</label>
166
- <frontend_type>text</frontend_type>
167
- <comment><![CDATA[<a href='https://go.beezup.com/Account/MyAccount' target='_blank'>My Account</a>]]></comment>
168
  <sort_order>7</sort_order>
169
  <show_in_default>1</show_in_default>
170
  <show_in_website>1</show_in_website>
171
  <show_in_store>1</show_in_store>
172
- </usertoken>
173
-
174
 
175
-
176
-
177
-
178
-
179
- <status_mapping translate="comment">
180
- <label>BeezUP API Status mapping :</label>
181
- <frontend_model>beezup/adminhtml_system_config_childgroup</frontend_model>
182
- <sort_order>16</sort_order>
 
 
 
 
 
 
 
 
 
 
 
 
183
  <show_in_default>1</show_in_default>
184
  <show_in_website>1</show_in_website>
185
  <show_in_store>1</show_in_store>
186
- </status_mapping>
187
-
188
-
189
- <status_new translate="comment">
190
  <label>New (New) </label>
191
  <frontend_type>select</frontend_type>
192
  <source_model>beezup/system_config_source_status</source_model>
193
  <sort_order>17</sort_order>
194
- <show_in_default>1</show_in_default>
195
- <show_in_website>1</show_in_website>
196
- <show_in_store>1</show_in_store>
197
- <comment></comment>
 
 
198
 
199
- </status_new>
200
-
201
-
202
- <status_progress translate="comment">
203
- <label>In progress (InProgress)</label>
204
- <frontend_type>select</frontend_type>
205
- <source_model>beezup/system_config_source_status</source_model>
206
- <sort_order>18</sort_order>
207
- <show_in_default>1</show_in_default>
208
- <show_in_website>1</show_in_website>
209
- <show_in_store>1</show_in_store>
210
- <comment></comment>
211
 
212
- </status_progress>
213
-
214
-
215
- <status_cancelled translate="comment">
216
- <label>Cancelled (Canceled)</label>
217
  <frontend_type>select</frontend_type>
218
- <source_model>beezup/system_config_source_status</source_model>
219
- <sort_order>19</sort_order>
220
- <show_in_default>1</show_in_default>
221
- <show_in_website>1</show_in_website>
222
- <show_in_store>1</show_in_store>
223
- <comment></comment>
 
 
224
 
225
- </status_cancelled>
226
 
227
- <status_shipped translate="comment">
228
- <label>Shipped (Shipped)</label>
229
  <frontend_type>select</frontend_type>
230
- <source_model>beezup/system_config_source_status</source_model>
231
- <sort_order>19</sort_order>
232
- <show_in_default>1</show_in_default>
233
- <show_in_website>1</show_in_website>
234
- <show_in_store>1</show_in_store>
235
- <comment></comment>
 
 
236
 
237
- </status_shipped>
238
-
239
- <status_closed translate="comment">
240
- <label>Closed (Closed)</label>
241
  <frontend_type>select</frontend_type>
242
- <source_model>beezup/system_config_source_status</source_model>
243
- <sort_order>19</sort_order>
244
- <show_in_default>1</show_in_default>
245
- <show_in_website>1</show_in_website>
246
- <show_in_store>1</show_in_store>
247
- <comment></comment>
 
 
248
 
249
- </status_closed>
 
 
 
 
 
 
 
 
 
 
250
 
251
 
252
  <status_aborted translate="comment">
253
- <label>(Aborted)</label>
254
  <frontend_type>select</frontend_type>
255
- <source_model>beezup/system_config_source_status</source_model>
256
- <sort_order>19</sort_order>
257
- <show_in_default>1</show_in_default>
258
- <show_in_website>1</show_in_website>
259
- <show_in_store>1</show_in_store>
260
- <comment></comment>
 
 
261
 
262
- </status_aborted>
263
-
264
-
265
-
266
-
267
- <stores_mapping translate="comment">
268
- <label>BeezUP Stores mapping :</label>
269
- <frontend_model>beezup/adminhtml_system_config_childgroup</frontend_model>
270
- <sort_order>26</sort_order>
271
  <show_in_default>1</show_in_default>
272
- <show_in_website>1</show_in_website>
273
- <show_in_store>1</show_in_store>
274
- </stores_mapping>
275
-
276
-
277
- <stores translate="comment">
278
- <label>BeezUP Stores mapping :</label>
279
- <frontend_model>beezup/adminhtml_system_config_stores</frontend_model>
280
- <backend_model>adminhtml/system_config_backend_serialized_array</backend_model>
281
- <sort_order>27</sort_order>
282
- <show_in_default>1</show_in_default>
283
- <show_in_website>1</show_in_website>
284
- <show_in_store>1</show_in_store>
285
- <comment></comment>
286
-
287
- </stores>
288
-
289
 
290
- <field_mapping translate="comment">
291
- <label>BeezUP id field mapping :</label>
292
- <frontend_model>beezup/adminhtml_system_config_childgroup</frontend_model>
293
- <sort_order>28</sort_order>
 
 
294
  <show_in_default>1</show_in_default>
295
- <show_in_website>1</show_in_website>
296
- <show_in_store>1</show_in_store>
297
- </field_mapping>
298
-
299
- <attributes translate="comment">
300
- <label>BeezUP id field mapping</label>
301
- <frontend_model>beezup/adminhtml_system_config_attributes</frontend_model>
302
- <backend_model>beezup/system_config_backend_attributes</backend_model>
303
- <sort_order>29</sort_order>
304
- <show_in_default>1</show_in_default>
305
- <show_in_website>1</show_in_website>
306
- <show_in_store>1</show_in_store>
307
- <comment></comment>
308
-
309
- </attributes>
310
-
311
 
312
-
313
- <main_config_block translate="comment">
314
- <label>BeezUP Config:</label>
315
- <frontend_model>beezup/adminhtml_system_config_childgroup</frontend_model>
316
- <sort_order>30</sort_order>
317
  <show_in_default>1</show_in_default>
318
- <show_in_website>1</show_in_website>
319
- <show_in_store>1</show_in_store>
320
- </main_config_block>
321
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
322
 
323
-
324
  <payment_method translate="label">
325
- <label>Default payment </label>
326
  <frontend_type>select</frontend_type>
327
- <source_model>beezup/system_config_source_payment</source_model>
328
- <sort_order>32</sort_order>
329
- <show_in_default>1</show_in_default>
330
- <show_in_website>1</show_in_website>
331
- <show_in_store>1</show_in_store>
332
- </payment_method>
333
 
334
-
335
 
336
- <available_products translate="label">
337
- <label>Allow creating orders with non available products (Beta Version)</label>
 
338
  <frontend_type>select</frontend_type>
339
- <source_model>beezup/system_config_source_availableproducts</source_model>
340
- <sort_order>33</sort_order>
341
- <show_in_default>1</show_in_default>
342
- <show_in_website>1</show_in_website>
343
- <show_in_store>1</show_in_store>
344
- </available_products>
 
 
 
 
 
 
 
 
 
 
 
 
345
 
346
 
347
- <debug_mode translate="label">
348
- <label>Debug Mode</label>
 
349
  <frontend_type>select</frontend_type>
350
  <comment>Set enabled to display error repporting (should be desabled in production shop)</comment>
351
- <source_model>beezup/system_config_source_debug</source_model>
352
- <comment><![CDATA[Create products if not matched - should always be disabled in production shop]]></comment>
353
- <sort_order>34</sort_order>
354
- <show_in_default>1</show_in_default>
355
- <show_in_website>1</show_in_website>
356
- <show_in_store>1</show_in_store>
357
- </debug_mode>
358
 
359
 
360
- <log_block translate="comment">
361
- <label>Last execution Logs:</label>
362
- <frontend_model>beezup/adminhtml_system_config_childgroup</frontend_model>
363
- <sort_order>35</sort_order>
364
  <show_in_default>1</show_in_default>
365
- <show_in_website>1</show_in_website>
366
- <show_in_store>1</show_in_store>
367
- </log_block>
 
368
 
369
-
370
  <log translate="comment">
371
- <label></label>
372
- <frontend_model>beezup/adminhtml_system_config_log</frontend_model>
373
- <sort_order>36</sort_order>
374
  <show_in_default>1</show_in_default>
375
- <show_in_website>1</show_in_website>
376
- <show_in_store>1</show_in_store>
377
- </log>
378
 
379
- </fields>
380
- </marketplace>
381
  </groups>
382
 
383
 
384
-
385
-
386
-
387
-
388
-
389
-
390
-
391
-
392
-
393
-
394
-
395
-
396
-
397
-
398
-
399
- <groups>
400
- <flux translate="label">
401
- <label>Catalog Flow</label>
402
- <frontend_type>text</frontend_type>
403
- <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.5.0) - <a href="http://go.beezup.com" target="_blank">My BeezUP Account</a></div>]]></comment>
404
- <sort_order>2</sort_order>
405
- <show_in_default>1</show_in_default>
406
- <show_in_website>1</show_in_website>
407
- <show_in_store>1</show_in_store>
408
- <fields>
409
- <active translate="label">
410
- <label>Enabled</label>
411
- <comment><![CDATA[www.yoursite.com/beezup/catalog/xml<br />www.yoursite.com/beezup/catalog/configurable <br /> www.yoursite.com/beezup/catalog/child]]></comment>
412
- <frontend_type>select</frontend_type>
413
- <source_model>adminhtml/system_config_source_yesno</source_model>
414
- <sort_order>1</sort_order>
415
- <show_in_default>1</show_in_default>
416
- <show_in_website>1</show_in_website>
417
- <show_in_store>1</show_in_store>
418
- </active>
419
- <debug_flux translate="label">
420
- <label>Debug Mode</label>
421
- <comment><![CDATA[Limit the number of products]]></comment>
422
- <frontend_type>select</frontend_type>
423
- <source_model>adminhtml/system_config_source_yesno</source_model>
424
- <sort_order>2</sort_order>
425
- <show_in_default>1</show_in_default>
426
- <show_in_website>1</show_in_website>
427
- <show_in_store>1</show_in_store>
428
- </debug_flux>
429
  <stock translate="label">
430
- <label>Filter out of stock products</label>
431
- <frontend_type>select</frontend_type>
432
- <source_model>adminhtml/system_config_source_yesno</source_model>
433
- <sort_order>3</sort_order>
434
- <show_in_default>1</show_in_default>
435
- <show_in_website>1</show_in_website>
436
- <show_in_store>1</show_in_store>
437
- </stock>
438
- <ship translate="label">
439
- <label>Shipping (Incl. Tax)</label>
440
- <frontend_type>text</frontend_type>
441
- <sort_order>4</sort_order>
442
- <show_in_default>1</show_in_default>
443
- <show_in_website>1</show_in_website>
444
- <show_in_store>1</show_in_store>
445
- </ship>
446
- <tablerates_weight_destination translate="label">
447
- <label>Table Rates</label>
448
- <comment><![CDATA[Use Table Rates (only Weight vs. Destination)]]></comment>
449
- <frontend_type>select</frontend_type>
450
- <source_model>adminhtml/system_config_source_yesno</source_model>
451
- <sort_order>5</sort_order>
452
- <show_in_default>1</show_in_default>
453
- <show_in_website>1</show_in_website>
454
- <show_in_store>1</show_in_store>
455
- </tablerates_weight_destination>
456
- <ht translate="label">
457
- <label>Catalog Price</label>
458
- <frontend_type>select</frontend_type>
459
- <source_model>beezup/system_config_source_price</source_model>
460
- <comment><![CDATA[Product Price Excl. Tax or Incl. Tax in catalog]]></comment>
461
- <sort_order>6</sort_order>
462
- <show_in_default>1</show_in_default>
463
- <show_in_website>1</show_in_website>
464
- <show_in_store>1</show_in_store>
465
- </ht>
466
- <vat translate="label">
467
- <label>VAT Rates</label>
468
- <frontend_type>text</frontend_type>
469
- <sort_order>7</sort_order>
470
- <show_in_default>1</show_in_default>
471
- <show_in_website>1</show_in_website>
472
- <show_in_store>1</show_in_store>
473
- </vat>
474
- <catalog_rules translate="label">
475
- <label>Use Catalog Price Rules</label>
476
- <comment><![CDATA[Let off if Catalog Price Rules are not used]]></comment>
477
- <frontend_type>select</frontend_type>
478
- <source_model>adminhtml/system_config_source_yesno</source_model>
479
- <sort_order>8</sort_order>
480
- <show_in_default>1</show_in_default>
481
- <show_in_website>1</show_in_website>
482
- <show_in_store>1</show_in_store>
483
- </catalog_rules>
484
- <days_in translate="label">
485
- <label>Delivery Time if Product in Stock</label>
486
- <frontend_type>text</frontend_type>
487
- <comment><![CDATA[Enter eg 1-2 for 1 to 2 days]]></comment>
488
- <sort_order>9</sort_order>
489
- <show_in_default>1</show_in_default>
490
- <show_in_website>1</show_in_website>
491
- <show_in_store>1</show_in_store>
492
- </days_in>
493
- <days_out translate="label">
494
- <label>Delivery Time if Product out of Stock</label>
495
- <frontend_type>text</frontend_type>
496
- <comment><![CDATA[Enter eg 6-8 for 6 to 8 days]]></comment>
497
- <sort_order>10</sort_order>
498
- <show_in_default>1</show_in_default>
499
- <show_in_website>1</show_in_website>
500
- <show_in_store>1</show_in_store>
501
- </days_out>
502
- <description translate="label">
503
- <label>Product description</label>
504
- <frontend_type>select</frontend_type>
505
- <source_model>beezup/system_config_source_description</source_model>
506
- <sort_order>11</sort_order>
507
- <show_in_default>1</show_in_default>
508
- <show_in_website>1</show_in_website>
509
- <show_in_store>1</show_in_store>
510
- </description>
511
- <attributes translate="label">
512
- <label>Specific Attributes</label>
513
- <frontend_type>multiselect</frontend_type>
514
- <source_model>beezup/system_config_source_attributes</source_model>
515
- <sort_order>12</sort_order>
516
- <show_in_default>1</show_in_default>
517
- <show_in_website>1</show_in_website>
518
- <show_in_store>1</show_in_store>
519
- </attributes>
520
- <ip translate="label">
521
- <label>BeezUP Server IP address</label>
522
- <comment><![CDATA[Only this IP address will be able to read the flow (leave empty to disable the restriction)]]></comment>
523
- <frontend_type>text</frontend_type>
524
- <sort_order>13</sort_order>
525
- <show_in_default>1</show_in_default>
526
- <show_in_website>1</show_in_website>
527
- <show_in_store>1</show_in_store>
528
- </ip>
529
- <key translate="label">
530
- <label>Key</label>
531
- <frontend_type>text</frontend_type>
532
- <comment><![CDATA[Protects the flow by a unique key (Eg: 85ds6f7): www.yoursite.com/beezup/catalog/xml/key/85ds6f7/]]></comment>
533
- <sort_order>14</sort_order>
534
- <show_in_default>1</show_in_default>
535
- <show_in_website>1</show_in_website>
536
- <show_in_store>1</show_in_store>
537
- </key>
538
- <bom translate="label">
539
- <label>Bom</label>
540
- <frontend_type>select</frontend_type>
541
- <source_model>adminhtml/system_config_source_yesno</source_model>
542
- <comment><![CDATA[Add Byte Order Mark (BOM)]]></comment>
543
- <sort_order>15</sort_order>
544
- <show_in_default>1</show_in_default>
545
- <show_in_website>1</show_in_website>
546
- <show_in_store>1</show_in_store>
547
- </bom>
548
- <cachedelay translate="label">
549
- <label>Cache delay</label>
550
  <frontend_type>select</frontend_type>
551
- <source_model>beezup/system_config_source_cache</source_model>
552
- <comment><![CDATA[Refresh time of the cache export file in hours]]></comment>
553
- <sort_order>16</sort_order>
554
- <show_in_default>1</show_in_default>
555
- <show_in_website>1</show_in_website>
556
- <show_in_store>1</show_in_store>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
557
  </cachedelay>
558
  <images translate="label">
559
- <label>Export all available pictures</label>
560
- <frontend_type>select</frontend_type>
561
- <source_model>beezup/system_config_source_images</source_model>
562
- <comment><![CDATA[Export all available pictures]]></comment>
563
- <sort_order>17</sort_order>
564
- <show_in_default>1</show_in_default>
565
- <show_in_website>1</show_in_website>
566
- <show_in_store>1</show_in_store>
567
  </images>
568
 
569
  <category_logic translate="label">
570
- <label>Category Logic</label>
571
- <frontend_type>select</frontend_type>
572
- <source_model>beezup/system_config_source_categories</source_model>
573
- <comment><![CDATA[Choose option 1 if don't know what this is]]></comment>
574
- <sort_order>18</sort_order>
575
- <show_in_default>1</show_in_default>
576
- <show_in_website>1</show_in_website>
577
- <show_in_store>1</show_in_store>
578
  </category_logic>
579
 
580
 
 
 
 
 
 
 
 
 
 
 
 
 
581
 
582
- </fields>
583
- </flux>
584
- </groups>
585
- </beezup>
586
- </sections>
587
- </config>
1
  <config>
2
  <sections>
3
+
4
+
5
  <beezup translate="label" module="beezup">
6
  <label>BeezUP</label>
7
  <tab>catalog</tab>
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.0) - <a href="http://go.beezup.com" target="_blank">My BeezUP Account</a></div>]]></comment>
17
  <sort_order>1</sort_order>
18
  <show_in_default>1</show_in_default>
19
  <show_in_website>1</show_in_website>
27
  <show_in_default>1</show_in_default>
28
  <show_in_website>1</show_in_website>
29
  <show_in_store>1</show_in_store>
30
+ </active>
31
  <storeid translate="label">
32
  <label>Store ID</label>
33
  <frontend_type>text</frontend_type>
36
  <show_in_default>1</show_in_default>
37
  <show_in_website>1</show_in_website>
38
  <show_in_store>1</show_in_store>
39
+ </storeid>
40
  <marge translate="label">
41
  <label>Calculate product margin</label>
42
  <frontend_type>select</frontend_type>
46
  <show_in_default>1</show_in_default>
47
  <show_in_website>1</show_in_website>
48
  <show_in_store>1</show_in_store>
49
+ </marge>
50
  <montant translate="label">
51
  <label>Total orders amount</label>
52
  <frontend_type>select</frontend_type>
55
  <show_in_default>1</show_in_default>
56
  <show_in_website>1</show_in_website>
57
  <show_in_store>1</show_in_store>
58
+ </montant>
59
  <debug translate="label">
60
  <label>Logs</label>
61
  <frontend_type>select</frontend_type>
65
  <show_in_default>1</show_in_default>
66
  <show_in_website>1</show_in_website>
67
  <show_in_store>1</show_in_store>
68
+ </debug>
69
+ </fields>
70
+ </tracking>
71
+ </groups>
72
 
73
 
74
 
75
 
76
  <groups>
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.0) - <a href="http://go.beezup.com" target="_blank">My BeezUP Account</a></div>]]></comment>
81
  <sort_order>2</sort_order>
82
  <show_in_default>1</show_in_default>
83
  <show_in_website>1</show_in_website>
84
  <show_in_store>1</show_in_store>
85
+ <fields>
86
+
87
+ <api_credentials translate="comment">
88
+ <label>BeezUP API Credentials:</label>
89
+ <frontend_model>beezup/adminhtml_system_config_childgroup</frontend_model>
90
+ <sort_order>0</sort_order>
91
  <show_in_default>1</show_in_default>
92
  <show_in_website>1</show_in_website>
93
  <show_in_store>1</show_in_store>
94
+ </api_credentials>
95
+
96
+ <connection_status translate="label">
97
  <label>API BeezUP Connection status:</label>
98
+ <frontend_type>text</frontend_type>
99
+ <frontend_model>beezup/adminhtml_system_config_credentials</frontend_model>
100
+ <backend_model>beezup/system_config_backend_credentials</backend_model>
101
  <sort_order>1</sort_order>
102
  <show_in_default>1</show_in_default>
103
  <show_in_website>1</show_in_website>
104
  <show_in_store>1</show_in_store>
105
+ </connection_status>
106
 
107
+ <sync_status translate="label">
108
  <label>Sync Status:</label>
109
+ <frontend_type>text</frontend_type>
110
+ <frontend_model>beezup/adminhtml_system_config_syncstatus</frontend_model>
111
  <sort_order>2</sort_order>
112
  <show_in_default>1</show_in_default>
113
  <show_in_website>1</show_in_website>
114
  <show_in_store>1</show_in_store>
115
+ </sync_status>
116
 
117
+
118
+ <syncro_time translate="label">
119
  <label>Last synchronization time :</label>
120
+ <frontend_type>text</frontend_type>
121
+ <frontend_model>beezup/adminhtml_system_config_time</frontend_model>
122
+ <backend_model>beezup/system_config_backend_time</backend_model>
123
  <sort_order>3</sort_order>
124
  <show_in_default>1</show_in_default>
125
  <show_in_website>1</show_in_website>
126
  <show_in_store>1</show_in_store>
127
+ </syncro_time>
128
+
129
+
130
+ <cron_url translate="label">
131
  <label>Manual orders retrieval link:</label>
132
+ <frontend_type>text</frontend_type>
133
+ <frontend_model>beezup/adminhtml_system_config_manualcron</frontend_model>
134
+
135
  <sort_order>4</sort_order>
136
  <show_in_default>1</show_in_default>
137
  <show_in_website>1</show_in_website>
138
  <show_in_store>1</show_in_store>
139
  <depends><connection_status>1</connection_status></depends>
140
+ </cron_url>
141
+
142
+ <cron_call translate="label">
143
  <label>Cron Call</label>
144
+ <frontend_type>text</frontend_type>
145
+ <frontend_model>beezup/adminhtml_system_config_cron</frontend_model>
146
+
147
  <sort_order>5</sort_order>
148
  <show_in_default>1</show_in_default>
149
  <show_in_website>1</show_in_website>
150
  <show_in_store>1</show_in_store>
151
  <depends><connection_status>1</connection_status></depends>
152
+ </cron_call>
153
+
154
+
155
+ <userid translate="label">
156
  <label>User Id</label>
157
+ <frontend_type>text</frontend_type>
158
+ <comment><![CDATA[<a href='https://go.beezup.com/Account/MyAccount' target='_blank'>My Account</a>]]></comment>
159
  <sort_order>6</sort_order>
160
  <show_in_default>1</show_in_default>
161
  <show_in_website>1</show_in_website>
162
  <show_in_store>1</show_in_store>
163
+ </userid>
164
+ <usertoken translate="label">
165
  <label>User Token</label>
166
+ <frontend_type>text</frontend_type>
167
+ <comment><![CDATA[<a href='https://go.beezup.com/Account/MyAccount' target='_blank'>My Account</a>]]></comment>
168
  <sort_order>7</sort_order>
169
  <show_in_default>1</show_in_default>
170
  <show_in_website>1</show_in_website>
171
  <show_in_store>1</show_in_store>
172
+ </usertoken>
 
173
 
174
+ <order_link translate="label">
175
+ <label>Synchronize a specific order</label>
176
+ <frontend_type>text</frontend_type>
177
+ <frontend_model>beezup/adminhtml_system_config_orderlink</frontend_model>
178
+
179
+ <sort_order>8</sort_order>
180
+ <show_in_default>1</show_in_default>
181
+ <show_in_website>1</show_in_website>
182
+ <show_in_store>1</show_in_store>
183
+ <depends><connection_status>1</connection_status></depends>
184
+ </order_link>
185
+
186
+
187
+
188
+
189
+
190
+ <status_mapping translate="comment">
191
+ <label>BeezUP API Status mapping :</label>
192
+ <frontend_model>beezup/adminhtml_system_config_childgroup</frontend_model>
193
+ <sort_order>16</sort_order>
194
  <show_in_default>1</show_in_default>
195
  <show_in_website>1</show_in_website>
196
  <show_in_store>1</show_in_store>
197
+ </status_mapping>
198
+
199
+
200
+ <status_new translate="comment">
201
  <label>New (New) </label>
202
  <frontend_type>select</frontend_type>
203
  <source_model>beezup/system_config_source_status</source_model>
204
  <sort_order>17</sort_order>
205
+ <show_in_default>1</show_in_default>
206
+ <show_in_website>1</show_in_website>
207
+ <show_in_store>1</show_in_store>
208
+ <comment></comment>
209
+
210
+ </status_new>
211
 
 
 
 
 
 
 
 
 
 
 
 
 
212
 
213
+ <status_progress translate="comment">
214
+ <label>In progress (InProgress)</label>
 
 
 
215
  <frontend_type>select</frontend_type>
216
+ <source_model>beezup/system_config_source_status</source_model>
217
+ <sort_order>18</sort_order>
218
+ <show_in_default>1</show_in_default>
219
+ <show_in_website>1</show_in_website>
220
+ <show_in_store>1</show_in_store>
221
+ <comment></comment>
222
+
223
+ </status_progress>
224
 
 
225
 
226
+ <status_cancelled translate="comment">
227
+ <label>Cancelled (Canceled)</label>
228
  <frontend_type>select</frontend_type>
229
+ <source_model>beezup/system_config_source_status</source_model>
230
+ <sort_order>19</sort_order>
231
+ <show_in_default>1</show_in_default>
232
+ <show_in_website>1</show_in_website>
233
+ <show_in_store>1</show_in_store>
234
+ <comment></comment>
235
+
236
+ </status_cancelled>
237
 
238
+ <status_shipped translate="comment">
239
+ <label>Shipped (Shipped)</label>
 
 
240
  <frontend_type>select</frontend_type>
241
+ <source_model>beezup/system_config_source_status</source_model>
242
+ <sort_order>19</sort_order>
243
+ <show_in_default>1</show_in_default>
244
+ <show_in_website>1</show_in_website>
245
+ <show_in_store>1</show_in_store>
246
+ <comment></comment>
247
+
248
+ </status_shipped>
249
 
250
+ <status_closed translate="comment">
251
+ <label>Closed (Closed)</label>
252
+ <frontend_type>select</frontend_type>
253
+ <source_model>beezup/system_config_source_status</source_model>
254
+ <sort_order>19</sort_order>
255
+ <show_in_default>1</show_in_default>
256
+ <show_in_website>1</show_in_website>
257
+ <show_in_store>1</show_in_store>
258
+ <comment></comment>
259
+
260
+ </status_closed>
261
 
262
 
263
  <status_aborted translate="comment">
264
+ <label>(Aborted)</label>
265
  <frontend_type>select</frontend_type>
266
+ <source_model>beezup/system_config_source_status</source_model>
267
+ <sort_order>19</sort_order>
268
+ <show_in_default>1</show_in_default>
269
+ <show_in_website>1</show_in_website>
270
+ <show_in_store>1</show_in_store>
271
+ <comment></comment>
272
+
273
+ </status_aborted>
274
 
275
+
276
+
277
+
278
+ <stores_mapping translate="comment">
279
+ <label>BeezUP Stores mapping :</label>
280
+ <frontend_model>beezup/adminhtml_system_config_childgroup</frontend_model>
281
+ <sort_order>26</sort_order>
 
 
282
  <show_in_default>1</show_in_default>
283
+ <show_in_website>1</show_in_website>
284
+ <show_in_store>1</show_in_store>
285
+ </stores_mapping>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
286
 
287
+
288
+ <stores translate="comment">
289
+ <label>BeezUP Stores mapping :</label>
290
+ <frontend_model>beezup/adminhtml_system_config_stores</frontend_model>
291
+ <backend_model>adminhtml/system_config_backend_serialized_array</backend_model>
292
+ <sort_order>27</sort_order>
293
  <show_in_default>1</show_in_default>
294
+ <show_in_website>1</show_in_website>
295
+ <show_in_store>1</show_in_store>
296
+ <comment></comment>
297
+
298
+ </stores>
 
 
 
 
 
 
 
 
 
 
 
299
 
300
+
301
+ <field_mapping translate="comment">
302
+ <label>BeezUP id field mapping :</label>
303
+ <frontend_model>beezup/adminhtml_system_config_childgroup</frontend_model>
304
+ <sort_order>28</sort_order>
305
  <show_in_default>1</show_in_default>
306
+ <show_in_website>1</show_in_website>
307
+ <show_in_store>1</show_in_store>
308
+ </field_mapping>
309
+
310
+ <attributes translate="comment">
311
+ <label>BeezUP id field mapping</label>
312
+ <frontend_model>beezup/adminhtml_system_config_attributes</frontend_model>
313
+ <backend_model>beezup/system_config_backend_attributes</backend_model>
314
+ <sort_order>29</sort_order>
315
+ <show_in_default>1</show_in_default>
316
+ <show_in_website>1</show_in_website>
317
+ <show_in_store>1</show_in_store>
318
+ <comment></comment>
319
+
320
+ </attributes>
321
+
322
+
323
+
324
+ <main_config_block translate="comment">
325
+ <label>BeezUP Config:</label>
326
+ <frontend_model>beezup/adminhtml_system_config_childgroup</frontend_model>
327
+ <sort_order>30</sort_order>
328
+ <show_in_default>1</show_in_default>
329
+ <show_in_website>1</show_in_website>
330
+ <show_in_store>1</show_in_store>
331
+ </main_config_block>
332
+
333
+
334
 
 
335
  <payment_method translate="label">
336
+ <label>Default payment </label>
337
  <frontend_type>select</frontend_type>
338
+ <source_model>beezup/system_config_source_payment</source_model>
339
+ <sort_order>32</sort_order>
340
+ <show_in_default>1</show_in_default>
341
+ <show_in_website>1</show_in_website>
342
+ <show_in_store>1</show_in_store>
343
+ </payment_method>
344
 
 
345
 
346
+
347
+ <available_products translate="label">
348
+ <label>Allow creating orders with non available products (Beta Version)</label>
349
  <frontend_type>select</frontend_type>
350
+ <source_model>beezup/system_config_source_availableproducts</source_model>
351
+ <sort_order>33</sort_order>
352
+ <show_in_default>1</show_in_default>
353
+ <show_in_website>1</show_in_website>
354
+ <show_in_store>1</show_in_store>
355
+ </available_products>
356
+
357
+ <create_customers translate="label">
358
+ <label>Create customer for each order</label>
359
+ <frontend_type>select</frontend_type>
360
+ <source_model>beezup/system_config_source_customercreate</source_model>
361
+ <comment><![CDATA[If you enable this option customers will be created in Magento for each marketplace imported order]]></comment>
362
+ <sort_order>34</sort_order>
363
+ <show_in_default>1</show_in_default>
364
+ <show_in_website>1</show_in_website>
365
+ <show_in_store>1</show_in_store>
366
+ </create_customers>
367
+
368
 
369
 
370
+
371
+ <debug_mode translate="label">
372
+ <label>Debug Mode</label>
373
  <frontend_type>select</frontend_type>
374
  <comment>Set enabled to display error repporting (should be desabled in production shop)</comment>
375
+ <source_model>beezup/system_config_source_debug</source_model>
376
+ <comment><![CDATA[Create products if not matched - should always be disabled in production shop]]></comment>
377
+ <sort_order>35</sort_order>
378
+ <show_in_default>1</show_in_default>
379
+ <show_in_website>1</show_in_website>
380
+ <show_in_store>1</show_in_store>
381
+ </debug_mode>
382
 
383
 
384
+ <log_block translate="comment">
385
+ <label>Last execution Logs:</label>
386
+ <frontend_model>beezup/adminhtml_system_config_childgroup</frontend_model>
387
+ <sort_order>36</sort_order>
388
  <show_in_default>1</show_in_default>
389
+ <show_in_website>1</show_in_website>
390
+ <show_in_store>1</show_in_store>
391
+ </log_block>
392
+
393
 
 
394
  <log translate="comment">
395
+ <label></label>
396
+ <frontend_model>beezup/adminhtml_system_config_log</frontend_model>
397
+ <sort_order>37</sort_order>
398
  <show_in_default>1</show_in_default>
399
+ <show_in_website>1</show_in_website>
400
+ <show_in_store>1</show_in_store>
401
+ </log>
402
 
403
+ </fields>
404
+ </marketplace>
405
  </groups>
406
 
407
 
408
+ <groups>
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.0) - <a href="http://go.beezup.com" target="_blank">My BeezUP Account</a></div>]]></comment>
413
+ <sort_order>2</sort_order>
414
+ <show_in_default>1</show_in_default>
415
+ <show_in_website>1</show_in_website>
416
+ <show_in_store>1</show_in_store>
417
+ <fields>
418
+ <active translate="label">
419
+ <label>Enabled</label>
420
+ <comment><![CDATA[www.yoursite.com/beezup/catalog/xml<br />www.yoursite.com/beezup/catalog/configurable <br /> www.yoursite.com/beezup/catalog/child]]></comment>
421
+ <frontend_type>select</frontend_type>
422
+ <source_model>adminhtml/system_config_source_yesno</source_model>
423
+ <sort_order>1</sort_order>
424
+ <show_in_default>1</show_in_default>
425
+ <show_in_website>1</show_in_website>
426
+ <show_in_store>1</show_in_store>
427
+ </active>
428
+ <debug_flux translate="label">
429
+ <label>Debug Mode</label>
430
+ <comment><![CDATA[Limit the number of products]]></comment>
431
+ <frontend_type>select</frontend_type>
432
+ <source_model>adminhtml/system_config_source_yesno</source_model>
433
+ <sort_order>2</sort_order>
434
+ <show_in_default>1</show_in_default>
435
+ <show_in_website>1</show_in_website>
436
+ <show_in_store>1</show_in_store>
437
+ </debug_flux>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
438
  <stock translate="label">
439
+ <label>Filter out of stock products</label>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
440
  <frontend_type>select</frontend_type>
441
+ <source_model>adminhtml/system_config_source_yesno</source_model>
442
+ <sort_order>3</sort_order>
443
+ <show_in_default>1</show_in_default>
444
+ <show_in_website>1</show_in_website>
445
+ <show_in_store>1</show_in_store>
446
+ </stock>
447
+
448
+
449
+ <ht translate="label">
450
+ <label>Catalog Price</label>
451
+ <frontend_type>select</frontend_type>
452
+ <source_model>beezup/system_config_source_price</source_model>
453
+ <comment><![CDATA[Product Price Excl. Tax or Incl. Tax in catalog]]></comment>
454
+ <sort_order>6</sort_order>
455
+ <show_in_default>1</show_in_default>
456
+ <show_in_website>1</show_in_website>
457
+ <show_in_store>1</show_in_store>
458
+ </ht>
459
+ <vat translate="label">
460
+ <label>VAT Rates</label>
461
+ <frontend_type>text</frontend_type>
462
+ <sort_order>7</sort_order>
463
+ <show_in_default>1</show_in_default>
464
+ <show_in_website>1</show_in_website>
465
+ <show_in_store>1</show_in_store>
466
+ </vat>
467
+
468
+ <days_in translate="label">
469
+ <label>Delivery Time if Product in Stock</label>
470
+ <frontend_type>text</frontend_type>
471
+ <comment><![CDATA[Enter eg 1-2 for 1 to 2 days]]></comment>
472
+ <sort_order>9</sort_order>
473
+ <show_in_default>1</show_in_default>
474
+ <show_in_website>1</show_in_website>
475
+ <show_in_store>1</show_in_store>
476
+ </days_in>
477
+ <days_out translate="label">
478
+ <label>Delivery Time if Product out of Stock</label>
479
+ <frontend_type>text</frontend_type>
480
+ <comment><![CDATA[Enter eg 6-8 for 6 to 8 days]]></comment>
481
+ <sort_order>10</sort_order>
482
+ <show_in_default>1</show_in_default>
483
+ <show_in_website>1</show_in_website>
484
+ <show_in_store>1</show_in_store>
485
+ </days_out>
486
+
487
+
488
+ <carrier_method translate="label">
489
+ <label>Shipping cost - Carrier</label>
490
+ <frontend_type>select</frontend_type>
491
+ <source_model>beezup/system_config_source_images</source_model>
492
+ <comment><![CDATA[Beware this option might make your feed take longer to load]]></comment>
493
+ <sort_order>11</sort_order>
494
+ <show_in_default>1</show_in_default>
495
+ <show_in_website>1</show_in_website>
496
+ <show_in_store>1</show_in_store>
497
+ </carrier_method>
498
+
499
+
500
+ <shipping_carrier translate="label">
501
+ <label>Default Shipping Carrier</label>
502
+ <frontend_type>select</frontend_type>
503
+ <source_model>beezup/system_config_source_carriers</source_model>
504
+ <comment><![CDATA[Used if option "Shipping cost - Carrier" is enabled]]></comment>
505
+ <sort_order>12</sort_order>
506
+ <show_in_default>1</show_in_default>
507
+ <show_in_website>1</show_in_website>
508
+ <show_in_store>1</show_in_store>
509
+ <depends><carrier_method>1</carrier_method></depends>
510
+ </shipping_carrier>
511
+
512
+ <ship translate="label">
513
+ <label>Default Shipping Cost (with tax)</label>
514
+ <frontend_type>text</frontend_type>
515
+ <sort_order>13</sort_order>
516
+ <show_in_default>1</show_in_default>
517
+ <show_in_website>1</show_in_website>
518
+ <show_in_store>1</show_in_store>
519
+ <depends><carrier_method>0</carrier_method></depends>
520
+ </ship>
521
+
522
+
523
+ <default_country translate="label">
524
+ <label>Default Country</label>
525
+ <frontend_type>select</frontend_type>
526
+ <source_model>beezup/system_config_source_countries</source_model>
527
+ <comment><![CDATA[Used if option "Shipping cost - Carrier" is enabled]]></comment>
528
+ <sort_order>14</sort_order>
529
+ <show_in_default>1</show_in_default>
530
+ <show_in_website>1</show_in_website>
531
+ <show_in_store>1</show_in_store>
532
+ <depends><carrier_method>1</carrier_method></depends>
533
+ </default_country>
534
+
535
+ <default_shipping_cost translate="label">
536
+ <label>Shipping Cost (if no value found)</label>
537
+ <frontend_type>text</frontend_type>
538
+ <comment><![CDATA[Used if option "Shipping cost - Carrier" is enabled]]></comment>
539
+ <sort_order>15</sort_order>
540
+ <show_in_default>1</show_in_default>
541
+ <show_in_website>1</show_in_website>
542
+ <show_in_store>1</show_in_store>
543
+ <depends><carrier_method>1</carrier_method></depends>
544
+ </default_shipping_cost>
545
+
546
+
547
+
548
+
549
+ <description translate="label">
550
+ <label>Product description</label>
551
+ <frontend_type>multiselect</frontend_type>
552
+ <source_model>beezup/system_config_source_description</source_model>
553
+ <sort_order>17</sort_order>
554
+ <show_in_default>1</show_in_default>
555
+ <show_in_website>1</show_in_website>
556
+ <show_in_store>1</show_in_store>
557
+ </description>
558
+ <description_html translate="label">
559
+ <label>Enable Html in descriptions</label>
560
+ <frontend_type>select</frontend_type>
561
+ <source_model>adminhtml/system_config_source_yesno</source_model>
562
+ <sort_order>16</sort_order>
563
+ <show_in_default>1</show_in_default>
564
+ <show_in_website>1</show_in_website>
565
+ <show_in_store>1</show_in_store>
566
+ </description_html>
567
+
568
+
569
+ <attributes translate="label">
570
+ <label>Specific Attributes</label>
571
+ <frontend_type>multiselect</frontend_type>
572
+ <source_model>beezup/system_config_source_attributes</source_model>
573
+ <sort_order>18</sort_order>
574
+ <show_in_default>1</show_in_default>
575
+ <show_in_website>1</show_in_website>
576
+ <show_in_store>1</show_in_store>
577
+ </attributes>
578
+ <ip translate="label">
579
+ <label>BeezUP Server IP address</label>
580
+ <comment><![CDATA[Only this IP address will be able to read the flow (leave empty to disable the restriction)]]></comment>
581
+ <frontend_type>text</frontend_type>
582
+ <sort_order>19</sort_order>
583
+ <show_in_default>1</show_in_default>
584
+ <show_in_website>1</show_in_website>
585
+ <show_in_store>1</show_in_store>
586
+ </ip>
587
+ <key translate="label">
588
+ <label>Key</label>
589
+ <frontend_type>text</frontend_type>
590
+ <comment><![CDATA[Protects the flow by a unique key (Eg: 85ds6f7): www.yoursite.com/beezup/catalog/xml/key/85ds6f7/]]></comment>
591
+ <sort_order>20</sort_order>
592
+ <show_in_default>1</show_in_default>
593
+ <show_in_website>1</show_in_website>
594
+ <show_in_store>1</show_in_store>
595
+ </key>
596
+
597
+ <cachedelay translate="label">
598
+ <label>Cache delay</label>
599
+ <frontend_type>select</frontend_type>
600
+ <source_model>beezup/system_config_source_cache</source_model>
601
+ <comment><![CDATA[Refresh time of the cache export file in hours]]></comment>
602
+ <sort_order>22</sort_order>
603
+ <show_in_default>1</show_in_default>
604
+ <show_in_website>1</show_in_website>
605
+ <show_in_store>1</show_in_store>
606
  </cachedelay>
607
  <images translate="label">
608
+ <label>Export all available pictures</label>
609
+ <frontend_type>select</frontend_type>
610
+ <source_model>beezup/system_config_source_images</source_model>
611
+ <sort_order>21</sort_order>
612
+ <show_in_default>1</show_in_default>
613
+ <show_in_website>1</show_in_website>
614
+ <show_in_store>1</show_in_store>
 
615
  </images>
616
 
617
  <category_logic translate="label">
618
+ <label>Category Logic</label>
619
+ <frontend_type>select</frontend_type>
620
+ <source_model>beezup/system_config_source_categories</source_model>
621
+ <comment><![CDATA[Choose option 1 if don't know what this is]]></comment>
622
+ <sort_order>23</sort_order>
623
+ <show_in_default>1</show_in_default>
624
+ <show_in_website>1</show_in_website>
625
+ <show_in_store>1</show_in_store>
626
  </category_logic>
627
 
628
 
629
+
630
+
631
+ <visibility translate="label">
632
+ <label>Choice of exported products</label>
633
+ <frontend_type>select</frontend_type>
634
+ <source_model>beezup/system_config_source_visibility</source_model>
635
+ <sort_order>24</sort_order>
636
+ <show_in_default>1</show_in_default>
637
+ <show_in_website>1</show_in_website>
638
+ <show_in_store>1</show_in_store>
639
+ </visibility>
640
+
641
 
642
+ </fields>
643
+ </flux>
644
+ </groups>
645
+ </beezup>
646
+ </sections>
647
+ </config>
app/code/community/BeezUp/lib/BeezupOMOrderService.php CHANGED
@@ -1,134 +1,134 @@
1
  <?php
2
-
3
  /**
4
- * Service class
5
- */
6
  class BeezupOMOrderService {
7
-
8
  /**
9
- * @var BeezupOMRepository
10
- */
11
  protected $oRepository = null;
12
-
13
  /**
14
- * @var BeezupOMServiceClientProxy
15
- */
16
  protected $oClientProxy = null;
17
 
18
  protected $bDebugMode = false;
19
 
20
  protected $aCache = array();
21
-
22
- # MAGIC METHODS
23
-
24
  /**
25
- * @param BeezupOMRepositoryInterface $oRepository
26
- * @param BeezupOMServiceClientProxy $oProxy
27
- */
28
  public function __construct(BeezupOMRepositoryInterface $oRepository){
29
  $this
30
- ->setRepository($oRepository)
31
- ->setClientProxy(new BeezupOMServiceClientProxy($oRepository->getCredential()));
32
  }
33
-
34
- # GETTERS AND SETTERS
35
-
36
  public function setDebugMode($bDebugMode = true){
37
  $this->bDebugMode = (bool)$bDebugMode;
38
  $this->getClientProxy()->setDebugMode($this->isDebugModeActivated());
39
  $this->getRepository()->setDebugMode($this->isDebugModeActivated());
40
-
41
  return $this;
42
  }
43
 
44
  /**
45
- *
46
- * @return boolean True if debug is activated
47
- */
48
  public function isDebugModeActivated(){
49
  return $this->bDebugMode;
50
  }
51
 
52
  /**
53
- * @return BeezupOMRepository
54
- */
55
  public function getRepository(){
56
  return $this->oRepository;
57
  }
58
-
59
  /**
60
- * @param BeezupOMRepositoryInterface $oRepository
61
- * @return BeezupOMOrderService
62
- */
63
  public function setRepository(BeezupOMRepositoryInterface $oRepository){
64
  $this->oRepository = $oRepository;
65
  return $this;
66
  }
67
-
68
  /**
69
- * @return BeezupOMServiceClientProxy
70
- */
71
  public function getClientProxy(){
72
  return $this->oClientProxy;
73
  }
74
-
75
  /**
76
- * @param BeezupOMServiceClientProxy $oClientProxy
77
- * @return BeezupOMOrderService
78
- */
79
  public function setClientProxy(BeezupOMServiceClientProxy $oClientProxy){
80
  $this->oClientProxy = $oClientProxy;
81
  return $this;
82
  }
83
-
84
- # PUBLIC API
85
-
86
  public function purgeSync(){
87
-
88
  $this->getRepository()->purgeSync();
89
-
90
  }
91
-
92
  /**
93
- * Tests if credential is valid
94
- * @return boolean
95
- */
96
  public function isCredentialValid(){
97
  $oResult = $this->getClientProxy()->validate();
98
  return $oResult && $oResult->getHttpStatus() === 204;
99
  }
100
-
101
  /**
102
- *
103
- * @param BeezupOMLink $oLink
104
- * @param unknown_type $aParams
105
- * @param unknown_type $aData
106
- * @return boolean
107
- */
108
  public function changeOrder(BeezupOMLink $oLink, $aParams, $aData){
109
-
110
  if (!$this->getRepository()->isConfigurationOk() || !$this->isCredentialValid()){
111
  return array(false, null);
112
  }
113
-
114
  $aPostData = $this->processData($oLink, $aData);
115
-
116
  $oResponse = $this->getClientProxy()->changeOrderByLink($oLink, $aParams, $aPostData);
117
-
118
  return array(($oResponse && (int)$oResponse->getHttpStatus() === 200) , $oResponse);
119
  }
120
-
121
  /**
122
- *
123
- * @param BeezupOMOrderListRequest $oRequest
124
- * @return boolean
125
- */
126
  public function synchronizeOrders(BeezupOMOrderListRequest $oRequest = null){
127
-
128
  if ($oRequest === null){
129
  $oRequest = $this->createOrderListRequest();
130
  }
131
-
132
  if (!$this->isOrderListRequestValid($oRequest)){
133
  throw new Exception('BeezUP OM : Invalid request');
134
  }
@@ -141,26 +141,26 @@
141
  if ($this->isSynchronizationAlreadyInProgress()){
142
  throw new Exception('BeezUP OM : Synchronization in progress already');
143
  }
144
-
145
-
146
  $oLink = null;
147
  $bHasErrors = false;
148
  $nOrders = 0;
149
-
150
  $oHarvestClientReporting = $this->createHarvestClientReporting($this->getRepository()->getCredential(), $oRequest->getBeginPeriodUtcDate(), $oRequest->getEndPeriodUtcDate());
151
  try {
152
  do {
153
  if ($oLink){
154
  $oResponse = $this->getClientProxy()->getOrderListByLink($oLink);
155
- } else {
156
  $oResponse = $this->getClientProxy()->getOrderList($oRequest);
157
  }
158
-
159
  if ($oResponse && $oResponse->getExecutionId()){
160
  $this->getRepository()->saveHarvestClientReporting($oHarvestClientReporting, $oResponse->getExecutionId());
161
  $oHarvestClientReporting->setExecutionId($oResponse->getExecutionId());
162
  }
163
-
164
  if ($oResponse && $oResponse->getResult() ){
165
  if ($this->pushErrors($oResponse, $oHarvestClientReporting)){
166
  break;
@@ -175,29 +175,29 @@
175
  // on first request only
176
  if ($oLink === null){
177
  $oHarvestClientReporting
178
- ->setEntriesPerPage($oResponse->getRequest()->getEntriesPerPage())
179
- ->setRemainingPageCount($oPagination->getTotalNumberOfPages())
180
- ->getTotalOrderCount($oPagination->getTotalNumberOfEntries());
181
- }
182
  // on every request
183
  $oHarvestClientReporting
184
- ->setLastUpdateUtcDate(new DateTime('now', new DateTimeZone('UTC')))
185
- ->setRemainingPageCount($oHarvestClientReporting->getRemainingPageCount() - 1);
186
  // update reporting
187
  $this->getRepository()->saveHarvestClientReporting($oHarvestClientReporting, $oResponse->getExecutionId());
188
  }
189
  // synchronizing page
190
 
191
  $this->synchronizeOrderListPage($oOrderList, $oHarvestClientReporting);
192
-
193
  // link to next page or null
194
  $oLink = $oOrderList->getPaginationResult()->getLinkByRel('next');
195
- } else {
196
  $oLink = null;
197
  }
198
  } while($oLink);
199
-
200
- } catch (Exception $oException){
201
  $bHasErrors = true;
202
  if ($oHarvestClientReporting){
203
  $oHarvestClientReporting->setErrorMessage($oException->getMessage());
@@ -206,9 +206,9 @@
206
  if ($oHarvestClientReporting){
207
  // update & save reporting
208
  $oHarvestClientReporting
209
- ->setLastUpdateUtcDate(new DateTime('now', new DateTimeZone('UTC')))
210
- ->setProcessingStatus($oHarvestClientReporting->getRemainingPageCount() == 0 ? BeezupOMProcessingStatus::SUCCEED : BeezupOMProcessingStatus::ABORTED);
211
-
212
  $this->getRepository()->saveHarvestClientReporting($oHarvestClientReporting);
213
  }
214
  // update synchro date if we fetched at list one page so any error is not global (ie. no connexion errors ... )
@@ -217,11 +217,11 @@
217
  }
218
  return true;
219
  }
220
-
221
  /**
222
- *
223
- * @param unknown_type $oBeezupOrderLinkOrId
224
- */
225
  public function synchronizeOrder($oBeezupOrderLinkOrId){
226
  $bResult = false;
227
  $sOperation = '';
@@ -231,92 +231,93 @@
231
  try {
232
  $oBeezupOMOrderResponse = $this->getOrder($oBeezupOrderLinkOrId);
233
  if ($oBeezupOMOrderResponse && $oBeezupOMOrderResponse->getResult()){
234
- $oBeezupOrder = $oBeezupOMOrderResponse->getResult();
235
- $oHarvestOrderReporting
236
- ->setBeezupOrderUUID($oBeezupOrder->getBeezupOrderUUID())
237
- ->setOrderDetailJson(json_encode($oBeezupOrder->toArray()));
238
- $this->getRepository()->saveHarvestOrderReporting($oHarvestOrderReporting, $oBeezupOMOrderResponse->getExecutionId());
239
- $oHarvestOrderReporting->setExecutionId($oBeezupOMOrderResponse->getExecutionId());
240
-
241
- $oImportedOrderIdentifier = $this->getImportedOrderIdentifier($oBeezupOrder);
242
- $oCurrentOrderIdentifier = BeezupOMOrderIdentifier::fromBeezupOrder($oBeezupOrder);
243
- $bWasIdentifierImported = $this->wasIdentifierImported($oCurrentOrderIdentifier);
244
-
245
- if (!$oImportedOrderIdentifier && !$bWasIdentifierImported){
246
- // no order associated
247
- $mResult = $this->getRepository()->createOrder($oBeezupOMOrderResponse);
248
- if ($mResult){
249
- try {
250
- if ($mResult instanceof BeezupOMSetOrderIdValues && $oBeezupOrder->getLinkByRel('setMerchantOrderId')){
251
- $oSetOrderIdResponse = $this->getClientProxy()
252
- ->setOrderMerchantIdByLink($oBeezupOrder->getLinkByRel('setMerchantOrderId'), $mResult);
253
- $this->pushErrors($oSetOrderIdResponse, $oHarvestOrderReporting);
254
- $bResult = true;
255
- $sOperation = 'create';
256
- } // if
257
  } catch (Exception $oException){
258
- $oHarvestOrderReporting->setErrorMessage($oException->getMessage());
259
- }
260
 
261
- }
262
  } else if (($oImportedOrderIdentifier && $this->isSameIdentifier($oCurrentOrderIdentifier, $oImportedOrderIdentifier) )|| $bWasIdentifierImported){
263
- $mResult = $this->getRepository()->updateOrder($oBeezupOMOrderResponse);
264
- if ($mResult){
265
- try {
266
- if ($mResult instanceof BeezupOMSetOrderIdValues && $oBeezupOrder->getLinkByRel('setMerchantOrderId')){
267
- $oSetOrderIdResponse = $this->getClientProxy()
268
- ->setOrderMerchantIdByLink($oBeezupOrder->getLinkByRel('setMerchantOrderId'), $mResult);
269
- $this->pushErrors($oSetOrderIdResponse, $oHarvestOrderReporting);
270
- $bResult = true;
271
- $sOperation = 'update';
272
- } // if
273
  } catch (Exception $oException){
274
- $oHarvestOrderReporting->setErrorMessage($oException->getMessage());
275
- }
276
- $bResult = true;
277
- }
278
-
279
  } else {
280
- $oHarvestOrderReporting->setErrorMessage(sprintf('Order id mismatch %s', $oCurrentOrderIdentifier));
281
-
282
- }
283
- $oHarvestOrderReporting->setProcessingStatus($bResult ? BeezupOMProcessingStatus::SUCCEED : BeezupOMProcessingStatus::FAILED);
284
- $this->getRepository()->saveHarvestOrderReporting($oHarvestOrderReporting);
285
  } else{
286
- $oHarvestOrderReporting->setProcessingStatus(BeezupOMProcessingStatus::FAILED);
287
- $oHarvestOrderReporting->setErrorMessage('Unable to fetch order ' . $oBeezupOrderLinkOrId);
288
- $this->getRepository()->saveHarvestOrderReporting($oHarvestOrderReporting);
289
- }
290
- } catch (Exception $oException) {
291
  $oHarvestOrderReporting->setErrorMessage($oException->getMessage());
292
  $oHarvestOrderReporting->setProcessingStatus(BeezupOMProcessingStatus::FAILED);
293
  } // try
294
  $this->getRepository()->saveHarvestOrderReporting($oHarvestOrderReporting);
295
  return array($bResult, $sOperation);
296
  }
297
-
298
  /**
299
- *
300
- * @param BeezupOMLink|BeezupOMOrderIdentifier $oOrderLinkOrId
301
- * @return NULL|Ambigous <NULL, BeezupOMOrderResponse, BeezupOMResponse>
302
- */
303
  public function getOrder($oOrderLinkOrId){
304
  if ($oOrderLinkOrId instanceof BeezupOMOrderIdentifier){
305
  $oOrderIdentifier = $oOrderLinkOrId;
306
  $oOrderRequest = new BeezupOMOrderRequest();
307
  $oOrderRequest
308
- ->setOrderIdentifier($oOrderIdentifier);
309
-
310
  $oCachedOrderResponse = $this->getRepository()->getCachedBeezupOrderResponse($oOrderIdentifier);
311
  if ($oCachedOrderResponse && $oCachedOrderResponse->getEtag()){
312
  $oOrderRequest->setETagIfNoneMatch($oCachedOrderResponse->getEtag());
313
  }
314
  $oResponse = $this->getClientProxy()->getOrder($oOrderRequest);
315
- } else if ($oOrderLinkOrId instanceof BeezupOMLink){
 
316
  $oResponse = $this->getClientProxy()->getOrderByLink($oOrderLinkOrId);
317
  $oCachedOrderResponse = null;
318
  $oOrderIdentifier = null;
319
- } else {
320
  return null;
321
  }
322
  if ($oResponse && $oResponse->getHttpStatus() === 304){
@@ -330,14 +331,14 @@
330
  }
331
 
332
  public function getOrderDirect(BeezupOMOrderIdentifier $oOrderIdentifier){
333
- $oOrderIdentifier = $oOrderLinkOrId;
334
- $oOrderRequest = new BeezupOMOrderRequest();
335
- $oOrderRequest
336
- ->setOrderIdentifier($oOrderIdentifier);
337
- $oResponse = $this->getClientProxy()->getOrder($oOrderRequest);
338
  return ($oResponse && count($oResponse->getInfo()->getErrors()) == 0 && $oResponse->getResult()) ? $oResponse : null;
339
  }
340
-
341
  public function getStores(){
342
  $aResult = array();
343
  $oResponse = $this->getClientProxy()->stores();
@@ -349,267 +350,267 @@
349
  return $aResult;
350
  }
351
 
352
-
353
  /**
354
- * @param string $sLOVListName
355
- * @param string $sCultureName
356
- * @return array
357
- */
358
  public function getLovValues($sLOVListName, $sCultureName = 'en') {
359
- $aResult = array();
360
- $oResult = $this->getLov($sLOVListName, $sCultureName);
361
- if ($oResult){
362
- foreach($oResult->getValues() as $oLovValue){
363
- $aResult[$oLovValue->getCodeIdentifier()] = $oLovValue;
364
- }
365
- }
366
- return $aResult;
367
  }
368
 
369
  public function getLOVValuesForParams(BeezupOMLink $oLink, $bRequired = true){
370
- $aResult = array();
371
- foreach ($oLink->getParameters() as $oParam){
372
- if ($oParam->getLovLink() && (!$bRequired || $oParam->isLovRequired())) {
373
- $oLovResult = $this->getLOVByLink($oParam->getLovLink());
374
- $aResult[$oParam->getName()] = $oLovResult ? $oLovResult->toArray() : array();
375
- } // if
376
- } // foreach
377
- return $aResult;
378
  }
379
 
380
- # PAGE SYNC
381
-
382
  protected function synchronizeOrderListPage($oOrderList, $oHarvestClientReporting){
383
 
384
- foreach ($oOrderList->getOrderHeaders() as $oOrderHeader){
385
- $oOrderLink = $oOrderHeader->getLinkByRel('self');
386
- if ($oOrderLink){
387
- try {
388
- $this->synchronizeOrder($oOrderLink);
389
- } catch (Exception $oException){
390
- if ($oHarvestClientReporting){
391
- $oHarvestClientReporting->setErrorMessage($oException->getMessage());
392
- }
393
-
394
- }
395
- } // if
396
- }// foreach
397
 
398
  }
 
 
399
 
400
- # LOV helper
 
 
401
 
402
  protected function getLovByLink(BeezupOMLink $oLink) {
403
- $aAtoms = explode('cultureName=', $oLink->getHref(), 2);
404
- $sCultureName = isset($aAtoms[1]) ? $aAtoms[1] : '';
405
- $sCacheKey = sprintf('%s-%s', $oLink->getRel(), $sCultureName);
406
- if (!isset($this->aCache[$sCacheKey])){
407
- $oLovResponse = $this->getClientProxy()->getLOVByLink($oLink);
408
- if ($oLovResponse && $oLovResponse->getResult()){
409
- $this->aCache[$sCacheKey] = $oLovResponse->getResult();
410
- }
411
- }
412
- return $this->aCache[$sCacheKey];
413
  }
414
-
 
 
 
415
  /**
416
- * @param string $sLOVListName
417
- * @param string $sCultureName
418
- * @return multitype:
419
- */
420
  protected function getLov($sLOVListName, $sCultureName = 'en'){
421
- $sCacheKey = sprintf('LOV_%s-%s', $sLOVListName, $sCultureName);
422
- if (!isset($this->aCache[$sCacheKey])){
423
- $aResult = array();
424
- $oLovRequest = new BeezupOMLOVRequest();
425
- $oLovRequest
426
- ->setListName($sLOVListName)
427
- ->setCultureName($sCultureName);
428
- $oLovResponse = $this->getClientProxy()->getLOV($oLovRequest);
429
- if ($oLovResponse && $oLovResponse->getResult()){
430
- $this->aCache[$sCacheKey] = $oLovResponse->getResult();
431
- }
432
- }
433
- return $this->aCache[$sCacheKey];
434
  }
435
-
436
- # VALIDATION FOR CHANGE ORDER
437
-
 
 
 
438
  protected function processData(BeezupOMLink $oLink, array $aData = array()){
439
- $aResult = array();
440
- if ($oLink){
441
- foreach ($oLink->getParameters() as $oParam){
442
- $sName = $oParam->getName();
443
- if ((!isset($aData[$sName]) || empty($aData[$sName]) && $oParam->isMandatory())){
444
- die(sprintf('Param %s cannot be empty',$sName));
445
- }
446
- if (!$this->validateParam($oParam, $aData[$sName])){
447
- die(sprintf('Param %s cannot be empty has invalid value %s', $sName, strval($aData[$sName])));
448
- }
449
- if ($oParam->getCSharpType() === 'System.DateTime'){
450
- $formatDate = date("Y-m-d", strtotime($aData[$sName]));
451
- $aResult[$sName] = substr($formatDate,0,10) . 'T' . gmdate('H:i:s', time()-300) . '.000Z';
452
- // echo $aResult[$sName]."<br>";
453
- } else {
454
- $aResult[$sName] = $aData[$sName];
455
- }
456
- }
457
- }
458
- return $aResult;
459
  }
460
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
461
  protected function validateLOVRequired(BeezupOMExpectedOrderChangeMetaInfo $oParam, $mValue){
462
-
463
- if ($oParam->isLovRequired()){
464
- $aValues = $this->getLOVCodes($oParam);
465
- if (empty($aValues) || !in_array($mValue, $aValues)){
466
- return false;
467
- }
468
- // @todo smart mapping / exchange as in lengow
469
- }
470
- return true;
471
-
472
  }
473
-
 
 
 
 
 
474
  protected function validateParam(BeezupOMExpectedOrderChangeMetaInfo $oParam, $mValue){
475
- return $this->validateParamType($oParam, $mValue) && $this->validateLOVRequired($oParam, $mValue);
476
  }
477
-
478
  protected function validateParamType(BeezupOMExpectedOrderChangeMetaInfo $oParam, $mValue){
479
- switch ($oParam->getCSharpType()){
480
- default:
481
- case 'System.String':
482
- if (!is_string($mValue)){
483
- return false;
484
- }
485
- break;
486
- case 'System.Int32':
487
- if (preg_match('/^[0-9]+$/', $mValue) !== 1){
488
- return false;
489
- }
490
- break;
491
- case 'System.Decimal':
492
- case 'System.Money':
493
- if (preg_match('/^[0-9]+(,[0-9]{0,3})?$/', $mValue) !== 1){
494
- return false;
495
- }
496
- break;
497
- case 'System.DateTime':
498
- if (!strtotime($mValue)){
499
- return false;
500
- }
501
- break;
502
- }
503
- return true;
504
  }
505
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
506
  protected function createOrderListRequest(){
507
- $oResult = new BeezupOMOrderListRequest();
508
- $oResult
509
- ->setBeginPeriodUtcDate($this->getRepository()->getLastSynchronizationDate());
510
- return $oResult;
511
  }
512
-
513
  protected function getLOVCodes(BeezupOMExpectedOrderChangeMetaInfo $oParam){
514
- if ($oParam->isLovRequired()){
515
- $oLovResponse = $this->getClientProxy()->getLOVByLink($oParam->getLovLink());
516
- if ($oLovResponse && $oLovResponse->getResult()){
517
- return $oLovResponse->getResult()->getCodeIdentifiers();
518
- }
519
- }
520
- return array();
521
  }
522
-
 
 
 
523
  protected function pushErrors(BeezupOMResponse $oResponse, BeezupOMHarvestAbstractReporting $oReporting){
524
- if ($oResponse->getInfo()->getErrors()) {
525
- foreach($oResponse->getInfo()->getErrors() as $oError){
526
- // @todo add error
527
- $oReporting->setErrorMessage($oError->getCode() . ' ' . $oError->getMessage());
528
- }
529
- return true;
530
- }
531
- return false;
532
-
533
  }
534
-
535
- # REPORTING HELPERS
536
-
 
 
 
 
 
537
  /**
538
- * @return BeezupOMHarvestClientReporting
539
- */
540
  protected function createHarvestClientReporting(BeezupOMCredential $oCredential, DateTime $oBeginPeriodUtcDate, DateTime $oEndPeriodUtcDate, $sExecutionId = null){
541
- $oResult = $this->initReportingObject(new BeezupOMHarvestClientReporting(), $sExecutionId);
542
- $oResult
543
- ->setBeginPeriodUtcDate($oBeginPeriodUtcDate)
544
- ->setEndPeriodUtcDate($oBeginPeriodUtcDate)
545
- ->setBeezUPApiToken($oCredential->getBeezupApiToken())
546
- ->setBeezUPUserId($oCredential->getBeezupUserId());
547
- $this->getRepository()->saveHarvestClientReporting($oResult);
548
-
549
- return $oResult;
550
  }
551
-
552
  /**
553
- * @return BeezupOMHarvestOrderReporting
554
- */
555
  protected function createHarvestOrderReporting($sExecutionId = null){
556
- $oResult = $this->initReportingObject(new BeezupOMHarvestOrderReporting(), $sExecutionId);
557
- $this->getRepository()->saveHarvestOrderReporting($oResult);
558
- return $oResult;
559
  }
560
-
561
  /**
562
- *
563
- * @param BeezupOMHarvestAbstractReporting $oHarvestObject
564
- * @param string $sProcessingStatus
565
- */
566
  protected function initReportingObject(BeezupOMHarvestAbstractReporting $oHarvestObject, $sExecutionId = null){
567
- if ($sExecutionId === null){
568
- $sExecutionId = md5(microtime(true) . spl_object_hash($oHarvestObject) . uniqid('bom'));
569
- }
570
- return $oHarvestObject
571
- ->setExecutionId($sExecutionId)
572
- ->setCreationUtcDate(new DateTime('now', new DateTimeZone('UTC')))
573
- ->setProcessingStatus(BeezupOMProcessingStatus::IN_PROGRESS);
574
  }
575
-
576
- # CHECKS
577
-
 
 
 
 
 
578
  protected function isOrderListRequestValid(BeezupOMOrderListRequest $oRequest){
579
- return $oRequest->getBeginPeriodUtcDate() && $oRequest->getBeginPeriodUtcDate()->getTimestamp();
580
  }
581
-
582
  protected function isConfigurationOk(){
583
- return $this->getRepository()->isConfigurationOk();
584
  }
585
-
586
  protected function isSynchronizationAlreadyInProgress(){
587
- return $this->getRepository()->getCurrentHarvestSynchronization() !== null;
588
  }
589
-
590
  /**
591
- *
592
- * @param BeezupOMOrderResult $oBeezupOrder
593
- */
594
  protected function getImportedOrderIdentifier(BeezupOMOrderResult $oBeezupOrder){
595
- return $this->getRepository()->getImportedOrderIdentifier((int)$oBeezupOrder->getOrderMerchantOrderId()) ;
596
  }
597
-
598
  /**
599
- * Compares two identifiers
600
- * @todo BeezupOMOrderIdentifier::compare ?
601
- * @param BeezupOMOrderIdentifier $oOrderIdentifier1
602
- * @param BeezupOMOrderIdentifier $oOrderIdentifier2
603
- * @return boolean True if both identifiers are same
604
- */
605
  protected function isSameIdentifier(BeezupOMOrderIdentifier $oOrderIdentifier1, BeezupOMOrderIdentifier $oOrderIdentifier2){
606
- return ($oOrderIdentifier1->getAccountId() === $oOrderIdentifier2->getAccountId() &&
607
- $oOrderIdentifier1->getMarketplaceTechnicalCode() === $oOrderIdentifier2->getMarketplaceTechnicalCode() &&
608
- $oOrderIdentifier1->getBeezupOrderUUID() === $oOrderIdentifier2->getBeezupOrderUUID());
609
  }
610
-
611
  protected function wasIdentifierImported(BeezupOMOrderIdentifier $oOrderIdentifier){
612
- return $this->getRepository()->wasIdentifierImported($oOrderIdentifier) ;
613
  }
614
 
615
- }
1
  <?php
2
+
3
  /**
4
+ * Service class
5
+ */
6
  class BeezupOMOrderService {
7
+
8
  /**
9
+ * @var BeezupOMRepository
10
+ */
11
  protected $oRepository = null;
12
+
13
  /**
14
+ * @var BeezupOMServiceClientProxy
15
+ */
16
  protected $oClientProxy = null;
17
 
18
  protected $bDebugMode = false;
19
 
20
  protected $aCache = array();
21
+
22
+ # MAGIC METHODS
23
+
24
  /**
25
+ * @param BeezupOMRepositoryInterface $oRepository
26
+ * @param BeezupOMServiceClientProxy $oProxy
27
+ */
28
  public function __construct(BeezupOMRepositoryInterface $oRepository){
29
  $this
30
+ ->setRepository($oRepository)
31
+ ->setClientProxy(new BeezupOMServiceClientProxy($oRepository->getCredential()));
32
  }
33
+
34
+ # GETTERS AND SETTERS
35
+
36
  public function setDebugMode($bDebugMode = true){
37
  $this->bDebugMode = (bool)$bDebugMode;
38
  $this->getClientProxy()->setDebugMode($this->isDebugModeActivated());
39
  $this->getRepository()->setDebugMode($this->isDebugModeActivated());
40
+
41
  return $this;
42
  }
43
 
44
  /**
45
+ *
46
+ * @return boolean True if debug is activated
47
+ */
48
  public function isDebugModeActivated(){
49
  return $this->bDebugMode;
50
  }
51
 
52
  /**
53
+ * @return BeezupOMRepository
54
+ */
55
  public function getRepository(){
56
  return $this->oRepository;
57
  }
58
+
59
  /**
60
+ * @param BeezupOMRepositoryInterface $oRepository
61
+ * @return BeezupOMOrderService
62
+ */
63
  public function setRepository(BeezupOMRepositoryInterface $oRepository){
64
  $this->oRepository = $oRepository;
65
  return $this;
66
  }
67
+
68
  /**
69
+ * @return BeezupOMServiceClientProxy
70
+ */
71
  public function getClientProxy(){
72
  return $this->oClientProxy;
73
  }
74
+
75
  /**
76
+ * @param BeezupOMServiceClientProxy $oClientProxy
77
+ * @return BeezupOMOrderService
78
+ */
79
  public function setClientProxy(BeezupOMServiceClientProxy $oClientProxy){
80
  $this->oClientProxy = $oClientProxy;
81
  return $this;
82
  }
83
+
84
+ # PUBLIC API
85
+
86
  public function purgeSync(){
87
+
88
  $this->getRepository()->purgeSync();
89
+
90
  }
91
+
92
  /**
93
+ * Tests if credential is valid
94
+ * @return boolean
95
+ */
96
  public function isCredentialValid(){
97
  $oResult = $this->getClientProxy()->validate();
98
  return $oResult && $oResult->getHttpStatus() === 204;
99
  }
100
+
101
  /**
102
+ *
103
+ * @param BeezupOMLink $oLink
104
+ * @param unknown_type $aParams
105
+ * @param unknown_type $aData
106
+ * @return boolean
107
+ */
108
  public function changeOrder(BeezupOMLink $oLink, $aParams, $aData){
109
+
110
  if (!$this->getRepository()->isConfigurationOk() || !$this->isCredentialValid()){
111
  return array(false, null);
112
  }
113
+
114
  $aPostData = $this->processData($oLink, $aData);
115
+
116
  $oResponse = $this->getClientProxy()->changeOrderByLink($oLink, $aParams, $aPostData);
117
+
118
  return array(($oResponse && (int)$oResponse->getHttpStatus() === 200) , $oResponse);
119
  }
120
+
121
  /**
122
+ *
123
+ * @param BeezupOMOrderListRequest $oRequest
124
+ * @return boolean
125
+ */
126
  public function synchronizeOrders(BeezupOMOrderListRequest $oRequest = null){
127
+
128
  if ($oRequest === null){
129
  $oRequest = $this->createOrderListRequest();
130
  }
131
+
132
  if (!$this->isOrderListRequestValid($oRequest)){
133
  throw new Exception('BeezUP OM : Invalid request');
134
  }
141
  if ($this->isSynchronizationAlreadyInProgress()){
142
  throw new Exception('BeezUP OM : Synchronization in progress already');
143
  }
144
+
145
+
146
  $oLink = null;
147
  $bHasErrors = false;
148
  $nOrders = 0;
149
+
150
  $oHarvestClientReporting = $this->createHarvestClientReporting($this->getRepository()->getCredential(), $oRequest->getBeginPeriodUtcDate(), $oRequest->getEndPeriodUtcDate());
151
  try {
152
  do {
153
  if ($oLink){
154
  $oResponse = $this->getClientProxy()->getOrderListByLink($oLink);
155
+ } else {
156
  $oResponse = $this->getClientProxy()->getOrderList($oRequest);
157
  }
158
+
159
  if ($oResponse && $oResponse->getExecutionId()){
160
  $this->getRepository()->saveHarvestClientReporting($oHarvestClientReporting, $oResponse->getExecutionId());
161
  $oHarvestClientReporting->setExecutionId($oResponse->getExecutionId());
162
  }
163
+
164
  if ($oResponse && $oResponse->getResult() ){
165
  if ($this->pushErrors($oResponse, $oHarvestClientReporting)){
166
  break;
175
  // on first request only
176
  if ($oLink === null){
177
  $oHarvestClientReporting
178
+ ->setEntriesPerPage($oResponse->getRequest()->getEntriesPerPage())
179
+ ->setRemainingPageCount($oPagination->getTotalNumberOfPages())
180
+ ->getTotalOrderCount($oPagination->getTotalNumberOfEntries());
181
+ }
182
  // on every request
183
  $oHarvestClientReporting
184
+ ->setLastUpdateUtcDate(new DateTime('now', new DateTimeZone('UTC')))
185
+ ->setRemainingPageCount($oHarvestClientReporting->getRemainingPageCount() - 1);
186
  // update reporting
187
  $this->getRepository()->saveHarvestClientReporting($oHarvestClientReporting, $oResponse->getExecutionId());
188
  }
189
  // synchronizing page
190
 
191
  $this->synchronizeOrderListPage($oOrderList, $oHarvestClientReporting);
192
+
193
  // link to next page or null
194
  $oLink = $oOrderList->getPaginationResult()->getLinkByRel('next');
195
+ } else {
196
  $oLink = null;
197
  }
198
  } while($oLink);
199
+
200
+ } catch (Exception $oException){
201
  $bHasErrors = true;
202
  if ($oHarvestClientReporting){
203
  $oHarvestClientReporting->setErrorMessage($oException->getMessage());
206
  if ($oHarvestClientReporting){
207
  // update & save reporting
208
  $oHarvestClientReporting
209
+ ->setLastUpdateUtcDate(new DateTime('now', new DateTimeZone('UTC')))
210
+ ->setProcessingStatus($oHarvestClientReporting->getRemainingPageCount() == 0 ? BeezupOMProcessingStatus::SUCCEED : BeezupOMProcessingStatus::ABORTED);
211
+
212
  $this->getRepository()->saveHarvestClientReporting($oHarvestClientReporting);
213
  }
214
  // update synchro date if we fetched at list one page so any error is not global (ie. no connexion errors ... )
217
  }
218
  return true;
219
  }
220
+
221
  /**
222
+ *
223
+ * @param unknown_type $oBeezupOrderLinkOrId
224
+ */
225
  public function synchronizeOrder($oBeezupOrderLinkOrId){
226
  $bResult = false;
227
  $sOperation = '';
231
  try {
232
  $oBeezupOMOrderResponse = $this->getOrder($oBeezupOrderLinkOrId);
233
  if ($oBeezupOMOrderResponse && $oBeezupOMOrderResponse->getResult()){
234
+ $oBeezupOrder = $oBeezupOMOrderResponse->getResult();
235
+ $oHarvestOrderReporting
236
+ ->setBeezupOrderUUID($oBeezupOrder->getBeezupOrderUUID())
237
+ ->setOrderDetailJson(json_encode($oBeezupOrder->toArray()));
238
+ $this->getRepository()->saveHarvestOrderReporting($oHarvestOrderReporting, $oBeezupOMOrderResponse->getExecutionId());
239
+ $oHarvestOrderReporting->setExecutionId($oBeezupOMOrderResponse->getExecutionId());
240
+
241
+ $oImportedOrderIdentifier = $this->getImportedOrderIdentifier($oBeezupOrder);
242
+ $oCurrentOrderIdentifier = BeezupOMOrderIdentifier::fromBeezupOrder($oBeezupOrder);
243
+ $bWasIdentifierImported = $this->wasIdentifierImported($oCurrentOrderIdentifier);
244
+
245
+ if (!$oImportedOrderIdentifier && !$bWasIdentifierImported){
246
+ // no order associated
247
+ $mResult = $this->getRepository()->createOrder($oBeezupOMOrderResponse);
248
+ if ($mResult){
249
+ try {
250
+ if ($mResult instanceof BeezupOMSetOrderIdValues && $oBeezupOrder->getLinkByRel('setMerchantOrderId')){
251
+ $oSetOrderIdResponse = $this->getClientProxy()
252
+ ->setOrderMerchantIdByLink($oBeezupOrder->getLinkByRel('setMerchantOrderId'), $mResult);
253
+ $this->pushErrors($oSetOrderIdResponse, $oHarvestOrderReporting);
254
+ $bResult = true;
255
+ $sOperation = 'create';
256
+ } // if
257
  } catch (Exception $oException){
258
+ $oHarvestOrderReporting->setErrorMessage($oException->getMessage());
259
+ }
260
 
261
+ }
262
  } else if (($oImportedOrderIdentifier && $this->isSameIdentifier($oCurrentOrderIdentifier, $oImportedOrderIdentifier) )|| $bWasIdentifierImported){
263
+ $mResult = $this->getRepository()->updateOrder($oBeezupOMOrderResponse);
264
+ if ($mResult){
265
+ try {
266
+ if ($mResult instanceof BeezupOMSetOrderIdValues && $oBeezupOrder->getLinkByRel('setMerchantOrderId')){
267
+ $oSetOrderIdResponse = $this->getClientProxy()
268
+ ->setOrderMerchantIdByLink($oBeezupOrder->getLinkByRel('setMerchantOrderId'), $mResult);
269
+ $this->pushErrors($oSetOrderIdResponse, $oHarvestOrderReporting);
270
+ $bResult = true;
271
+ $sOperation = 'update';
272
+ } // if
273
  } catch (Exception $oException){
274
+ $oHarvestOrderReporting->setErrorMessage($oException->getMessage());
275
+ }
276
+ $bResult = true;
277
+ }
278
+
279
  } else {
280
+ $oHarvestOrderReporting->setErrorMessage(sprintf('Order id mismatch %s', $oCurrentOrderIdentifier));
281
+
282
+ }
283
+ $oHarvestOrderReporting->setProcessingStatus($bResult ? BeezupOMProcessingStatus::SUCCEED : BeezupOMProcessingStatus::FAILED);
284
+ $this->getRepository()->saveHarvestOrderReporting($oHarvestOrderReporting);
285
  } else{
286
+ $oHarvestOrderReporting->setProcessingStatus(BeezupOMProcessingStatus::FAILED);
287
+ $oHarvestOrderReporting->setErrorMessage('Unable to fetch order ' . $oBeezupOrderLinkOrId);
288
+ $this->getRepository()->saveHarvestOrderReporting($oHarvestOrderReporting);
289
+ }
290
+ } catch (Exception $oException) {
291
  $oHarvestOrderReporting->setErrorMessage($oException->getMessage());
292
  $oHarvestOrderReporting->setProcessingStatus(BeezupOMProcessingStatus::FAILED);
293
  } // try
294
  $this->getRepository()->saveHarvestOrderReporting($oHarvestOrderReporting);
295
  return array($bResult, $sOperation);
296
  }
297
+
298
  /**
299
+ *
300
+ * @param BeezupOMLink|BeezupOMOrderIdentifier $oOrderLinkOrId
301
+ * @return NULL|Ambigous <NULL, BeezupOMOrderResponse, BeezupOMResponse>
302
+ */
303
  public function getOrder($oOrderLinkOrId){
304
  if ($oOrderLinkOrId instanceof BeezupOMOrderIdentifier){
305
  $oOrderIdentifier = $oOrderLinkOrId;
306
  $oOrderRequest = new BeezupOMOrderRequest();
307
  $oOrderRequest
308
+ ->setOrderIdentifier($oOrderIdentifier);
309
+
310
  $oCachedOrderResponse = $this->getRepository()->getCachedBeezupOrderResponse($oOrderIdentifier);
311
  if ($oCachedOrderResponse && $oCachedOrderResponse->getEtag()){
312
  $oOrderRequest->setETagIfNoneMatch($oCachedOrderResponse->getEtag());
313
  }
314
  $oResponse = $this->getClientProxy()->getOrder($oOrderRequest);
315
+
316
+ } else if ($oOrderLinkOrId instanceof BeezupOMLink){
317
  $oResponse = $this->getClientProxy()->getOrderByLink($oOrderLinkOrId);
318
  $oCachedOrderResponse = null;
319
  $oOrderIdentifier = null;
320
+ } else {
321
  return null;
322
  }
323
  if ($oResponse && $oResponse->getHttpStatus() === 304){
331
  }
332
 
333
  public function getOrderDirect(BeezupOMOrderIdentifier $oOrderIdentifier){
334
+ $oOrderIdentifier = $oOrderLinkOrId;
335
+ $oOrderRequest = new BeezupOMOrderRequest();
336
+ $oOrderRequest
337
+ ->setOrderIdentifier($oOrderIdentifier);
338
+ $oResponse = $this->getClientProxy()->getOrder($oOrderRequest);
339
  return ($oResponse && count($oResponse->getInfo()->getErrors()) == 0 && $oResponse->getResult()) ? $oResponse : null;
340
  }
341
+
342
  public function getStores(){
343
  $aResult = array();
344
  $oResponse = $this->getClientProxy()->stores();
350
  return $aResult;
351
  }
352
 
353
+
354
  /**
355
+ * @param string $sLOVListName
356
+ * @param string $sCultureName
357
+ * @return array
358
+ */
359
  public function getLovValues($sLOVListName, $sCultureName = 'en') {
360
+ $aResult = array();
361
+ $oResult = $this->getLov($sLOVListName, $sCultureName);
362
+ if ($oResult){
363
+ foreach($oResult->getValues() as $oLovValue){
364
+ $aResult[$oLovValue->getCodeIdentifier()] = $oLovValue;
365
+ }
366
+ }
367
+ return $aResult;
368
  }
369
 
370
  public function getLOVValuesForParams(BeezupOMLink $oLink, $bRequired = true){
371
+ $aResult = array();
372
+ foreach ($oLink->getParameters() as $oParam){
373
+ if ($oParam->getLovLink() && (!$bRequired || $oParam->isLovRequired())) {
374
+ $oLovResult = $this->getLOVByLink($oParam->getLovLink());
375
+ $aResult[$oParam->getName()] = $oLovResult ? $oLovResult->toArray() : array();
376
+ } // if
377
+ } // foreach
378
+ return $aResult;
379
  }
380
 
381
+ # PAGE SYNC
382
+
383
  protected function synchronizeOrderListPage($oOrderList, $oHarvestClientReporting){
384
 
385
+ foreach ($oOrderList->getOrderHeaders() as $oOrderHeader){
386
+ $oOrderLink = $oOrderHeader->getLinkByRel('self');
387
+ if ($oOrderLink){
388
+ try {
389
+ $this->synchronizeOrder($oOrderLink);
390
+ } catch (Exception $oException){
391
+ if ($oHarvestClientReporting){
392
+ $oHarvestClientReporting->setErrorMessage($oException->getMessage());
393
+ }
 
 
 
 
394
 
395
  }
396
+ } // if
397
+ }// foreach
398
 
399
+ }
400
+
401
+ # LOV helper
402
 
403
  protected function getLovByLink(BeezupOMLink $oLink) {
404
+ $aAtoms = explode('cultureName=', $oLink->getHref(), 2);
405
+ $sCultureName = isset($aAtoms[1]) ? $aAtoms[1] : '';
406
+ $sCacheKey = sprintf('%s-%s', $oLink->getRel(), $sCultureName);
407
+ if (!isset($this->aCache[$sCacheKey])){
408
+ $oLovResponse = $this->getClientProxy()->getLOVByLink($oLink);
409
+ if ($oLovResponse && $oLovResponse->getResult()){
410
+ $this->aCache[$sCacheKey] = $oLovResponse->getResult();
 
 
 
411
  }
412
+ }
413
+ return $this->aCache[$sCacheKey];
414
+ }
415
+
416
  /**
417
+ * @param string $sLOVListName
418
+ * @param string $sCultureName
419
+ * @return multitype:
420
+ */
421
  protected function getLov($sLOVListName, $sCultureName = 'en'){
422
+ $sCacheKey = sprintf('LOV_%s-%s', $sLOVListName, $sCultureName);
423
+ if (!isset($this->aCache[$sCacheKey])){
424
+ $aResult = array();
425
+ $oLovRequest = new BeezupOMLOVRequest();
426
+ $oLovRequest
427
+ ->setListName($sLOVListName)
428
+ ->setCultureName($sCultureName);
429
+ $oLovResponse = $this->getClientProxy()->getLOV($oLovRequest);
430
+ if ($oLovResponse && $oLovResponse->getResult()){
431
+ $this->aCache[$sCacheKey] = $oLovResponse->getResult();
 
 
 
432
  }
433
+ }
434
+ return $this->aCache[$sCacheKey];
435
+ }
436
+
437
+ # VALIDATION FOR CHANGE ORDER
438
+
439
  protected function processData(BeezupOMLink $oLink, array $aData = array()){
440
+ $aResult = array();
441
+ if ($oLink){
442
+ foreach ($oLink->getParameters() as $oParam){
443
+ $sName = $oParam->getName();
444
+ if ((!isset($aData[$sName]) || empty($aData[$sName]) && $oParam->isMandatory())){
445
+ die(sprintf('Param %s cannot be empty',$sName));
 
 
 
 
 
 
 
 
 
 
 
 
 
 
446
  }
447
+ if (!$this->validateParam($oParam, $aData[$sName])){
448
+ die(sprintf('Param %s cannot be empty has invalid value %s', $sName, strval($aData[$sName])));
449
+ }
450
+ if ($oParam->getCSharpType() === 'System.DateTime'){
451
+ $formatDate = date("Y-m-d", strtotime($aData[$sName]));
452
+ $aResult[$sName] = substr($formatDate,0,10) . 'T' . gmdate('H:i:s', time()-300) . '.000Z';
453
+ // echo $aResult[$sName]."<br>";
454
+ } else {
455
+ $aResult[$sName] = $aData[$sName];
456
+ }
457
+ }
458
+ }
459
+ return $aResult;
460
+ }
461
+
462
  protected function validateLOVRequired(BeezupOMExpectedOrderChangeMetaInfo $oParam, $mValue){
463
+
464
+ if ($oParam->isLovRequired()){
465
+ $aValues = $this->getLOVCodes($oParam);
466
+ if (empty($aValues) || !in_array($mValue, $aValues)){
467
+ return false;
 
 
 
 
 
468
  }
469
+ // @todo smart mapping / exchange as in lengow
470
+ }
471
+ return true;
472
+
473
+ }
474
+
475
  protected function validateParam(BeezupOMExpectedOrderChangeMetaInfo $oParam, $mValue){
476
+ return $this->validateParamType($oParam, $mValue) && $this->validateLOVRequired($oParam, $mValue);
477
  }
478
+
479
  protected function validateParamType(BeezupOMExpectedOrderChangeMetaInfo $oParam, $mValue){
480
+ switch ($oParam->getCSharpType()){
481
+ default:
482
+ case 'System.String':
483
+ if (!is_string($mValue)){
484
+ return false;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
485
  }
486
+ break;
487
+ case 'System.Int32':
488
+ if (preg_match('/^[0-9]+$/', $mValue) !== 1){
489
+ return false;
490
+ }
491
+ break;
492
+ case 'System.Decimal':
493
+ case 'System.Money':
494
+ if (preg_match('/^[0-9]+(,[0-9]{0,3})?$/', $mValue) !== 1){
495
+ return false;
496
+ }
497
+ break;
498
+ case 'System.DateTime':
499
+ if (!strtotime($mValue)){
500
+ return false;
501
+ }
502
+ break;
503
+ }
504
+ return true;
505
+ }
506
+
507
  protected function createOrderListRequest(){
508
+ $oResult = new BeezupOMOrderListRequest();
509
+ $oResult
510
+ ->setBeginPeriodUtcDate($this->getRepository()->getLastSynchronizationDate());
511
+ return $oResult;
512
  }
513
+
514
  protected function getLOVCodes(BeezupOMExpectedOrderChangeMetaInfo $oParam){
515
+ if ($oParam->isLovRequired()){
516
+ $oLovResponse = $this->getClientProxy()->getLOVByLink($oParam->getLovLink());
517
+ if ($oLovResponse && $oLovResponse->getResult()){
518
+ return $oLovResponse->getResult()->getCodeIdentifiers();
 
 
 
519
  }
520
+ }
521
+ return array();
522
+ }
523
+
524
  protected function pushErrors(BeezupOMResponse $oResponse, BeezupOMHarvestAbstractReporting $oReporting){
525
+ if ($oResponse->getInfo()->getErrors()) {
526
+ foreach($oResponse->getInfo()->getErrors() as $oError){
527
+ // @todo add error
528
+ $oReporting->setErrorMessage($oError->getCode() . ' ' . $oError->getMessage());
 
 
 
 
 
529
  }
530
+ return true;
531
+ }
532
+ return false;
533
+
534
+ }
535
+
536
+ # REPORTING HELPERS
537
+
538
  /**
539
+ * @return BeezupOMHarvestClientReporting
540
+ */
541
  protected function createHarvestClientReporting(BeezupOMCredential $oCredential, DateTime $oBeginPeriodUtcDate, DateTime $oEndPeriodUtcDate, $sExecutionId = null){
542
+ $oResult = $this->initReportingObject(new BeezupOMHarvestClientReporting(), $sExecutionId);
543
+ $oResult
544
+ ->setBeginPeriodUtcDate($oBeginPeriodUtcDate)
545
+ ->setEndPeriodUtcDate($oBeginPeriodUtcDate)
546
+ ->setBeezUPApiToken($oCredential->getBeezupApiToken())
547
+ ->setBeezUPUserId($oCredential->getBeezupUserId());
548
+ $this->getRepository()->saveHarvestClientReporting($oResult);
549
+
550
+ return $oResult;
551
  }
552
+
553
  /**
554
+ * @return BeezupOMHarvestOrderReporting
555
+ */
556
  protected function createHarvestOrderReporting($sExecutionId = null){
557
+ $oResult = $this->initReportingObject(new BeezupOMHarvestOrderReporting(), $sExecutionId);
558
+ $this->getRepository()->saveHarvestOrderReporting($oResult);
559
+ return $oResult;
560
  }
561
+
562
  /**
563
+ *
564
+ * @param BeezupOMHarvestAbstractReporting $oHarvestObject
565
+ * @param string $sProcessingStatus
566
+ */
567
  protected function initReportingObject(BeezupOMHarvestAbstractReporting $oHarvestObject, $sExecutionId = null){
568
+ if ($sExecutionId === null){
569
+ $sExecutionId = md5(microtime(true) . spl_object_hash($oHarvestObject) . uniqid('bom'));
 
 
 
 
 
570
  }
571
+ return $oHarvestObject
572
+ ->setExecutionId($sExecutionId)
573
+ ->setCreationUtcDate(new DateTime('now', new DateTimeZone('UTC')))
574
+ ->setProcessingStatus(BeezupOMProcessingStatus::IN_PROGRESS);
575
+ }
576
+
577
+ # CHECKS
578
+
579
  protected function isOrderListRequestValid(BeezupOMOrderListRequest $oRequest){
580
+ return $oRequest->getBeginPeriodUtcDate() && $oRequest->getBeginPeriodUtcDate()->getTimestamp();
581
  }
582
+
583
  protected function isConfigurationOk(){
584
+ return $this->getRepository()->isConfigurationOk();
585
  }
586
+
587
  protected function isSynchronizationAlreadyInProgress(){
588
+ return $this->getRepository()->getCurrentHarvestSynchronization() !== null;
589
  }
590
+
591
  /**
592
+ *
593
+ * @param BeezupOMOrderResult $oBeezupOrder
594
+ */
595
  protected function getImportedOrderIdentifier(BeezupOMOrderResult $oBeezupOrder){
596
+ return $this->getRepository()->getImportedOrderIdentifier((int)$oBeezupOrder->getOrderMerchantOrderId()) ;
597
  }
598
+
599
  /**
600
+ * Compares two identifiers
601
+ * @todo BeezupOMOrderIdentifier::compare ?
602
+ * @param BeezupOMOrderIdentifier $oOrderIdentifier1
603
+ * @param BeezupOMOrderIdentifier $oOrderIdentifier2
604
+ * @return boolean True if both identifiers are same
605
+ */
606
  protected function isSameIdentifier(BeezupOMOrderIdentifier $oOrderIdentifier1, BeezupOMOrderIdentifier $oOrderIdentifier2){
607
+ return ($oOrderIdentifier1->getAccountId() === $oOrderIdentifier2->getAccountId() &&
608
+ $oOrderIdentifier1->getMarketplaceTechnicalCode() === $oOrderIdentifier2->getMarketplaceTechnicalCode() &&
609
+ $oOrderIdentifier1->getBeezupOrderUUID() === $oOrderIdentifier2->getBeezupOrderUUID());
610
  }
611
+
612
  protected function wasIdentifierImported(BeezupOMOrderIdentifier $oOrderIdentifier){
613
+ return $this->getRepository()->wasIdentifierImported($oOrderIdentifier) ;
614
  }
615
 
616
+ }
app/code/community/BeezUp/lib/Order/BeezupOMOrderResult.php CHANGED
@@ -7,6 +7,7 @@ class BeezupOMOrderResult extends BeezupOMResult {
7
  protected $aLinks = array();
8
  protected $aTransitionLinks = array();
9
  protected $sMarketPlaceTechnicalCode = null;
 
10
  protected $aOrderItems = array();
11
  protected $sOrderBuyerAddressCity = null;
12
  protected $sOrderBuyerAddressCountryIsoCodeAlpha2 = null;
@@ -196,6 +197,7 @@ class BeezupOMOrderResult extends BeezupOMResult {
196
  $this->aTransitionLinks[] = $oLink;
197
  return $this;
198
  }
 
199
  /**
200
  * @return the $sMarketPlaceTechnicalCode
201
  */
@@ -214,6 +216,24 @@ class BeezupOMOrderResult extends BeezupOMResult {
214
 
215
  }
216
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
217
  /**
218
  * @return the $aOrderItems
219
  */
7
  protected $aLinks = array();
8
  protected $aTransitionLinks = array();
9
  protected $sMarketPlaceTechnicalCode = null;
10
+ protected $sMarketPlaceBusinessCode = null;
11
  protected $aOrderItems = array();
12
  protected $sOrderBuyerAddressCity = null;
13
  protected $sOrderBuyerAddressCountryIsoCodeAlpha2 = null;
197
  $this->aTransitionLinks[] = $oLink;
198
  return $this;
199
  }
200
+
201
  /**
202
  * @return the $sMarketPlaceTechnicalCode
203
  */
216
 
217
  }
218
 
219
+ /**
220
+ * @return the $sMarketPlaceBusinessCode
221
+ */
222
+ public function getMarketPlaceBusinessCode()
223
+ {
224
+ return $this->sMarketPlaceBusinessCode;
225
+ }
226
+
227
+ /**
228
+ * @param NULL sMarketPlaceBusinessCode
229
+ */
230
+ public function setMarketPlaceBusinessCode($sMarketPlaceBusinessCode)
231
+ {
232
+ $this->sMarketPlaceBusinessCode = $sMarketPlaceBusinessCode;
233
+ return $this;
234
+
235
+ }
236
+
237
  /**
238
  * @return the $aOrderItems
239
  */
app/code/community/BeezUp/log/log.txt ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ 2016-03-18 16:15:55 | INFO | Initializing OM Importation
2
+ 2016-03-18 16:15:56 | INFO | 404-3346486-8692320 | Store Matching succesful, Beezup Store: bdd7b7cf-558c-48a1-984b-00303aecdc34 , Magento Store Id: 1
3
+ 2016-03-18 16:15:56 | ERROR | 404-3346486-8692320| No Product Matching, Product 14328 could not be found
4
+ 2016-03-18 16:15:57 | INFO | 404-3346486-8692320 | Store Matching succesful, Beezup Store: bdd7b7cf-558c-48a1-984b-00303aecdc34 , Magento Store Id: 1
5
+ 2016-03-18 16:15:57 | INFO | 404-3346486-8692320 | Product Matching succesful, Beezup Imported Id: 14328 , Magento Product Id: 1019
6
+ 2016-03-18 16:15:57 | INFO | 404-3346486-8692320 | Generating Order
7
+ 2016-03-18 16:15:57 | INFO | 404-3346486-8692320 | Adding 1 product/s with id 1019 to order, with Beezup Price: 10
8
+ 2016-03-18 16:15:57 | INFO | 404-3346486-8692320 | Creating new Customer
9
+ 2016-03-18 16:15:58 | INFO | 404-3346486-8692320 | Customer created succesfully
10
+ 2016-03-18 16:15:58 | INFO | 404-3346486-8692320 | Adding Order Shipping Cost: 3
11
+ 2016-03-18 16:16:00 | INFO | 404-3346486-8692320 | Adding Beezup Marketplace Information to Order
12
+ 2016-03-18 16:16:00 | INFO | 404-3346486-8692320 | Sending Magento Order Id to Beezup, Magento Order Id: 241
13
+ 2016-03-18 16:16:02 | INFO | 404-3346486-8692320 | Setting Order Status to InProgress
14
+ 2016-03-18 16:16:02 | INFO | 404-3346486-8692320 | Generating Order Payment Invoice
15
+ 2016-03-18 16:16:03 | INFO | 404-3346486-8692320 | Order Payment Invoice Generated Succesfully
16
+ 2016-03-18 16:16:03 | INFO | 404-3346486-8692320 | Order imported succesfully, Magento Order Id: 241
app/code/community/BeezUp/log/log2.txt ADDED
@@ -0,0 +1,293 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ 2016-02-14 11:21:20 | INFO | Initializing OM Importation
2
+ 2016-02-14 11:21:24 | INFO | 238381552 | Initializing Order - Link: /orders/v1/7fa50176-b2e9-4570-9cce-20b2ff7bd6d0/PriceMinister/1426/8D32AC4F06A92E81db86394d9904b83a949d134c2258e00
3
+ 2016-02-14 11:21:24 | INFO | 238381552 | Store Matching succesful, Beezup Store: c466247e-aadf-443c-b8ed-dedce8b281b7 , Magento Store Id: 1
4
+ 2016-02-14 11:21:25 | ERROR | 238381552| No Product Matching, Product 4800000 could not be found
5
+ 2016-02-14 11:21:30 | INFO | 238381552 | Generating Order
6
+ 2016-02-14 11:21:30 | INFO | 238381552 | Adding 1 product/s with id 1008 to order, with Beezup Price: 50.4
7
+ 2016-02-14 11:21:31 | INFO | 238381552 | Creating new Customer
8
+ 2016-02-14 11:21:31 | ERROR | 238381552 | Customer importation failed: Customer email is required
9
+ 2016-02-14 11:29:12 | INFO | Initializing OM Importation
10
+ 2016-02-14 11:29:15 | INFO | 238381552 | Initializing Order - Link: /orders/v1/7fa50176-b2e9-4570-9cce-20b2ff7bd6d0/PriceMinister/1426/8D32AC4F06A92E81db86394d9904b83a949d134c2258e00
11
+ 2016-02-14 11:29:15 | INFO | 238381552 | Store Matching succesful, Beezup Store: c466247e-aadf-443c-b8ed-dedce8b281b7 , Magento Store Id: 1
12
+ 2016-02-14 11:29:15 | INFO | 238381552 | Product Matching succesful, Beezup Imported Id: 4800000 , Magento Product Id: 1008
13
+ 2016-02-14 11:29:15 | INFO | 238381552 | Generating Order
14
+ 2016-02-14 11:29:15 | INFO | 238381552 | Adding 1 product/s with id 1008 to order, with Beezup Price: 50.4
15
+ 2016-02-14 11:30:06 | INFO | Initializing OM Importation
16
+ 2016-02-14 11:30:09 | INFO | 238381552 | Initializing Order - Link: /orders/v1/7fa50176-b2e9-4570-9cce-20b2ff7bd6d0/PriceMinister/1426/8D32AC4F06A92E81db86394d9904b83a949d134c2258e00
17
+ 2016-02-14 11:30:09 | INFO | 238381552 | Store Matching succesful, Beezup Store: c466247e-aadf-443c-b8ed-dedce8b281b7 , Magento Store Id: 1
18
+ 2016-02-14 11:30:10 | INFO | 238381552 | Product Matching succesful, Beezup Imported Id: 4800000 , Magento Product Id: 1008
19
+ 2016-02-14 11:30:11 | INFO | 238381552 | Generating Order
20
+ 2016-02-14 11:30:11 | INFO | 238381552 | Adding 1 product/s with id 1008 to order, with Beezup Price: 50.4
21
+ 2016-02-14 11:30:54 | INFO | Initializing OM Importation
22
+ 2016-02-14 11:30:57 | INFO | 238381552 | Initializing Order - Link: /orders/v1/7fa50176-b2e9-4570-9cce-20b2ff7bd6d0/PriceMinister/1426/8D32AC4F06A92E81db86394d9904b83a949d134c2258e00
23
+ 2016-02-14 11:30:57 | INFO | 238381552 | Store Matching succesful, Beezup Store: c466247e-aadf-443c-b8ed-dedce8b281b7 , Magento Store Id: 1
24
+ 2016-02-14 11:30:57 | INFO | 238381552 | Product Matching succesful, Beezup Imported Id: 4800000 , Magento Product Id: 1008
25
+ 2016-02-14 11:30:57 | INFO | 238381552 | Generating Order
26
+ 2016-02-14 11:30:57 | INFO | 238381552 | Adding 1 product/s with id 1008 to order, with Beezup Price: 50.4
27
+ 2016-02-14 11:42:23 | INFO | Initializing OM Importation
28
+ 2016-02-14 11:42:27 | INFO | 238381552 | Initializing Order - Link: /orders/v1/7fa50176-b2e9-4570-9cce-20b2ff7bd6d0/PriceMinister/1426/8D32AC4F06A92E81db86394d9904b83a949d134c2258e00
29
+ 2016-02-14 11:42:27 | INFO | 238381552 | Store Matching succesful, Beezup Store: c466247e-aadf-443c-b8ed-dedce8b281b7 , Magento Store Id: 1
30
+ 2016-02-14 11:42:27 | INFO | 238381552 | Product Matching succesful, Beezup Imported Id: 4800000 , Magento Product Id: 1008
31
+ 2016-02-14 11:42:27 | INFO | 238381552 | Generating Order
32
+ 2016-02-14 11:42:27 | INFO | 238381552 | Adding 1 product/s with id 1008 to order, with Beezup Price: 50.4
33
+ 2016-02-14 11:47:45 | INFO | Initializing OM Importation
34
+ 2016-02-14 11:47:48 | INFO | 238381552 | Initializing Order - Link: /orders/v1/7fa50176-b2e9-4570-9cce-20b2ff7bd6d0/PriceMinister/1426/8D32AC4F06A92E81db86394d9904b83a949d134c2258e00
35
+ 2016-02-14 11:47:48 | INFO | 238381552 | Store Matching succesful, Beezup Store: c466247e-aadf-443c-b8ed-dedce8b281b7 , Magento Store Id: 1
36
+ 2016-02-14 11:47:48 | INFO | 238381552 | Product Matching succesful, Beezup Imported Id: 4800000 , Magento Product Id: 1008
37
+ 2016-02-14 11:47:48 | INFO | 238381552 | Generating Order
38
+ 2016-02-14 11:47:48 | INFO | 238381552 | Adding 1 product/s with id 1008 to order, with Beezup Price: 50.4
39
+ 2016-02-14 11:47:48 | INFO | 238381552 | Creating new Customer
40
+ 2016-02-14 11:47:49 | INFO | 238381552 | Creating created succesfully
41
+ 2016-02-14 11:47:49 | INFO | 238381552 | Adding Order Shipping Cost: 8.05
42
+ 2016-02-14 11:47:51 | INFO | 238381552 | Adding Beezup Marketplace Information to Order
43
+ 2016-02-14 11:47:51 | INFO | 238381552 | Sending Magento Order Id to Beezup, Magento Order Id: 230
44
+ 2016-02-14 11:47:53 | INFO | 238381552 | Setting Order Status to Shipped
45
+ 2016-02-14 11:47:53 | INFO | 238381552 | Generating Order Payment Invoice
46
+ 2016-02-14 11:47:53 | INFO | 238381552 | Order Payment Invoice Generated Succesfully
47
+ 2016-02-14 11:47:53 | INFO | 238381552 | Order imported succesfully, Magento Order Id: 230
48
+ 2016-02-14 12:02:53 | INFO | Initializing OM Importation
49
+ 2016-02-14 12:04:22 | INFO | Initializing OM Importation
50
+ 2016-02-15 17:33:20 | INFO | Initializing OM Importation
51
+ 2016-02-15 17:34:48 | INFO | Initializing OM Importation
52
+ 2016-02-15 17:35:27 | INFO | Initializing OM Importation
53
+ 2016-02-15 17:36:53 | INFO | Initializing OM Importation
54
+ 2016-02-15 17:36:56 | INFO | Initializing Order - Link: /orders/v1/7fa50176-b2e9-4570-9cce-20b2ff7bd6d0/PriceMinister/1426/8D32AC4F06A92E81db86394d9904b83a949d134c2258e00
55
+ 2016-02-15 17:36:56 | INFO | 238381552 | Store Matching succesful, Beezup Store: c466247e-aadf-443c-b8ed-dedce8b281b7 , Magento Store Id: 1
56
+ 2016-02-15 17:36:56 | INFO | 238381552 | Product Matching succesful, Beezup Imported Id: 4800000 , Magento Product Id: 1008
57
+ 2016-02-15 17:36:56 | INFO | 238381552 | Updating Etag
58
+ 2016-02-15 17:36:56 | INFO | 238381552 | Order Already exists Mage Order ID: 230
59
+ 2016-02-15 17:36:57 | INFO | 238381552 | Updating Order Status from: Complete to:
60
+ 2016-02-15 17:36:59 | INFO | 238381552 | Initializing Order - Link: /orders/v1/7fa50176-b2e9-4570-9cce-20b2ff7bd6d0/Amazon/827/8D335F739A64E5586803046162340789f3fe9543f1c6c9d
61
+ 2016-02-15 17:36:59 | INFO | 404-4178672-2473153 | Store Matching succesful, Beezup Store: c466247e-aadf-443c-b8ed-dedce8b281b7 , Magento Store Id: 1
62
+ 2016-02-15 17:36:59 | ERROR | 404-4178672-2473153| No Product Matching, Product 180800000 could not be found
63
+ 2016-02-15 17:37:00 | INFO | 404-4178672-2473153 | Generating Order
64
+ 2016-02-15 17:37:00 | INFO | 404-4178672-2473153 | Adding 1 product/s with id 1009 to order, with Beezup Price: 166.8
65
+ 2016-02-15 17:37:01 | INFO | 404-4178672-2473153 | Creating new Customer
66
+ 2016-02-15 17:37:01 | INFO | 404-4178672-2473153 | Customer created succesfully
67
+ 2016-02-15 17:37:01 | INFO | 404-4178672-2473153 | Adding Order Shipping Cost: 2.01
68
+ 2016-02-15 17:37:03 | INFO | 404-4178672-2473153 | Adding Beezup Marketplace Information to Order
69
+ 2016-02-15 17:37:03 | INFO | 404-4178672-2473153 | Sending Magento Order Id to Beezup, Magento Order Id: 231
70
+ 2016-02-15 17:37:04 | INFO | 404-4178672-2473153 | Order imported succesfully, Magento Order Id: 231
71
+ 2016-02-15 18:08:34 | INFO | Initializing OM Importation
72
+ 2016-02-15 18:08:41 | ERROR | 403-3063642-5478711 | No mapping for store bdd7b7cf-558c-48a1-984b-00303aecdc34
73
+ 2016-02-15 18:09:57 | INFO | Initializing OM Importation
74
+ 2016-02-15 18:10:04 | INFO | 403-3063642-5478711 | Store Matching succesful, Beezup Store: bdd7b7cf-558c-48a1-984b-00303aecdc34 , Magento Store Id: 1
75
+ 2016-02-15 18:10:04 | ERROR | 403-3063642-5478711| No Product Matching, Product 16711 could not be found
76
+ 2016-02-15 18:10:05 | INFO | 403-3063642-5478711 | Generating Order
77
+ 2016-02-15 18:10:05 | INFO | 403-3063642-5478711 | Adding 1 product/s with id 1010 to order, with Beezup Price: 26
78
+ 2016-02-15 18:10:05 | INFO | 403-3063642-5478711 | Creating new Customer
79
+ 2016-02-15 18:10:05 | INFO | 403-3063642-5478711 | Customer created succesfully
80
+ 2016-02-15 18:10:05 | INFO | 403-3063642-5478711 | Adding Order Shipping Cost: 3
81
+ 2016-02-15 18:10:06 | INFO | 403-3063642-5478711 | Adding Beezup Marketplace Information to Order
82
+ 2016-02-15 18:10:06 | INFO | 403-3063642-5478711 | Sending Magento Order Id to Beezup, Magento Order Id: 232
83
+ 2016-02-15 18:10:07 | INFO | 403-3063642-5478711 | Order imported succesfully, Magento Order Id: 232
84
+ 2016-02-15 18:15:50 | INFO | Initializing OM Importation
85
+ 2016-02-15 18:15:57 | INFO | 403-3063642-5478711 | Order Etag has not changed
86
+ 2016-02-15 18:16:47 | INFO | Initializing OM Importation
87
+ 2016-02-15 18:16:53 | INFO | 403-3063642-5478711 | Store Matching succesful, Beezup Store: bdd7b7cf-558c-48a1-984b-00303aecdc34 , Magento Store Id: 1
88
+ 2016-02-15 18:16:53 | INFO | 403-3063642-5478711 | Product Matching succesful, Beezup Imported Id: 16711 , Magento Product Id: 1010
89
+ 2016-02-15 18:16:53 | INFO | 403-3063642-5478711 | Updating Etag
90
+ 2016-02-15 18:16:53 | INFO | 403-3063642-5478711 | Order Already exists Mage Order ID: 232
91
+ 2016-02-15 18:16:53 | INFO | 403-3063642-5478711 | Updating Order Status from: to: InProgress
92
+ 2016-02-15 18:16:53 | INFO | 403-3063642-5478711 | Setting Order Status to InProgress
93
+ 2016-02-15 18:16:53 | INFO | 403-3063642-5478711 | Generating Order Payment Invoice
94
+ 2016-02-15 18:16:54 | INFO | 403-3063642-5478711 | Order Payment Invoice Generated Succesfully
95
+ 2016-02-16 18:11:48 | INFO | Initializing OM Importation
96
+ 2016-02-16 18:11:53 | INFO | 403-3063642-5478711 | Store Matching succesful, Beezup Store: bdd7b7cf-558c-48a1-984b-00303aecdc34 , Magento Store Id: 1
97
+ 2016-02-16 18:11:53 | INFO | 403-3063642-5478711 | Product Matching succesful, Beezup Imported Id: 16711 , Magento Product Id: 1010
98
+ 2016-02-16 18:11:53 | INFO | 403-3063642-5478711 | Updating Etag
99
+ 2016-02-16 18:11:53 | INFO | 403-3063642-5478711 | Order Already exists Mage Order ID: 232
100
+ 2016-02-16 18:11:53 | INFO | 403-3063642-5478711 | Updating Order Status from: Processing to: Shipped
101
+ 2016-02-16 18:11:53 | INFO | 403-3063642-5478711 | Setting Order Status to Shipped
102
+ 2016-02-16 18:11:53 | INFO | 403-3063642-5478711 | Generating Order Payment Invoice
103
+ 2016-02-17 17:04:01 | INFO | Initializing OM Importation
104
+ 2016-02-17 17:04:06 | INFO | 402-4016744-7374764 | Store Matching succesful, Beezup Store: bdd7b7cf-558c-48a1-984b-00303aecdc34 , Magento Store Id: 1
105
+ 2016-02-17 17:04:06 | ERROR | 402-4016744-7374764| No Product Matching, Product 15777 could not be found
106
+ 2016-02-17 17:04:10 | INFO | 402-4016744-7374764 | Generating Order
107
+ 2016-02-17 17:04:10 | INFO | 402-4016744-7374764 | Adding 1 product/s with id 1011 to order, with Beezup Price: 9
108
+ 2016-02-17 17:04:11 | INFO | 402-4016744-7374764 | Creating new Customer
109
+ 2016-02-17 17:04:11 | INFO | 402-4016744-7374764 | Customer created succesfully
110
+ 2016-02-17 17:04:11 | INFO | 402-4016744-7374764 | Adding Order Shipping Cost: 3
111
+ 2016-02-17 17:04:14 | INFO | 402-4016744-7374764 | Adding Beezup Marketplace Information to Order
112
+ 2016-02-17 17:04:14 | INFO | 402-4016744-7374764 | Sending Magento Order Id to Beezup, Magento Order Id: 233
113
+ 2016-02-17 17:04:15 | INFO | 402-4016744-7374764 | Setting Order Status to Shipped
114
+ 2016-02-17 17:04:15 | INFO | 402-4016744-7374764 | Generating Order Payment Invoice
115
+ 2016-02-17 17:04:16 | INFO | 402-4016744-7374764 | Order Payment Invoice Generated Succesfully
116
+ 2016-02-17 17:04:16 | INFO | 402-4016744-7374764 | Order imported succesfully, Magento Order Id: 233
117
+ 2016-02-17 17:29:06 | INFO | Initializing OM Importation
118
+ 2016-02-17 17:29:12 | INFO | 403-9673370-4170700 | Store Matching succesful, Beezup Store: bdd7b7cf-558c-48a1-984b-00303aecdc34 , Magento Store Id: 1
119
+ 2016-02-17 17:29:12 | ERROR | 403-9673370-4170700| No Product Matching, Product 15460 could not be found
120
+ 2016-02-17 17:29:13 | INFO | 403-9673370-4170700 | Generating Order
121
+ 2016-02-17 17:29:13 | INFO | 403-9673370-4170700 | Adding 1 product/s with id 1012 to order, with Beezup Price: 15
122
+ 2016-02-17 17:29:13 | INFO | 403-9673370-4170700 | Creating new Customer
123
+ 2016-02-17 17:29:13 | INFO | 403-9673370-4170700 | Customer created succesfully
124
+ 2016-02-17 17:29:13 | INFO | 403-9673370-4170700 | Adding Order Shipping Cost: 3
125
+ 2016-02-17 17:29:14 | INFO | 403-9673370-4170700 | Adding Beezup Marketplace Information to Order
126
+ 2016-02-17 17:29:14 | INFO | 403-9673370-4170700 | Sending Magento Order Id to Beezup, Magento Order Id: 234
127
+ 2016-02-17 17:29:15 | INFO | 403-9673370-4170700 | Setting Order Status to InProgress
128
+ 2016-02-17 17:29:15 | INFO | 403-9673370-4170700 | Generating Order Payment Invoice
129
+ 2016-02-17 17:29:15 | INFO | 403-9673370-4170700 | Order Payment Invoice Generated Succesfully
130
+ 2016-02-17 17:29:16 | INFO | 403-9673370-4170700 | Order imported succesfully, Magento Order Id: 234
131
+ 2016-03-04 15:01:38 | INFO | Initializing OM Importation
132
+ 2016-03-04 15:01:44 | INFO | 402-8076668-0666712 | Store Matching succesful, Beezup Store: bdd7b7cf-558c-48a1-984b-00303aecdc34 , Magento Store Id: 1
133
+ 2016-03-04 15:01:44 | ERROR | 402-8076668-0666712| No Product Matching, Product 14452 could not be found
134
+ 2016-03-04 15:01:45 | INFO | 402-8076668-0666712 | Generating Order
135
+ 2016-03-04 15:01:45 | INFO | 402-8076668-0666712 | Adding 1 product/s with id 1013 to order, with Beezup Price: 18
136
+ 2016-03-04 15:01:45 | INFO | 402-8076668-0666712 | Creating new Customer
137
+ 2016-03-04 15:01:45 | INFO | 402-8076668-0666712 | Customer created succesfully
138
+ 2016-03-04 15:01:45 | INFO | 402-8076668-0666712 | Adding Order Shipping Cost: 3
139
+ 2016-03-04 15:01:48 | INFO | 402-8076668-0666712 | Adding Beezup Marketplace Information to Order
140
+ 2016-03-04 15:01:48 | INFO | 402-8076668-0666712 | Sending Magento Order Id to Beezup, Magento Order Id: 235
141
+ 2016-03-04 15:01:49 | INFO | 402-8076668-0666712 | Setting Order Status to InProgress
142
+ 2016-03-04 15:01:49 | INFO | 402-8076668-0666712 | Generating Order Payment Invoice
143
+ 2016-03-04 15:01:50 | INFO | 402-8076668-0666712 | Order Payment Invoice Generated Succesfully
144
+ 2016-03-04 15:01:50 | INFO | 402-8076668-0666712 | Order imported succesfully, Magento Order Id: 235
145
+ 2016-03-04 15:20:50 | INFO | Initializing OM Importation
146
+ 2016-03-04 15:20:51 | INFO | MOR-8AD5BM23790272 | Store Matching succesful, Beezup Store: bdd7b7cf-558c-48a1-984b-00303aecdc34 , Magento Store Id: 1
147
+ 2016-03-04 15:20:51 | ERROR | MOR-8AD5BM23790272| No Product Matching, Product 15668 could not be found
148
+ 2016-03-04 15:20:52 | INFO | MOR-8AD5BM23790272 | Generating Order
149
+ 2016-03-04 15:20:52 | INFO | MOR-8AD5BM23790272 | Adding 3 product/s with id 1014 to order, with Beezup Price: 11
150
+ 2016-03-04 15:20:52 | INFO | MOR-8AD5BM23790272 | Creating new Customer
151
+ 2016-03-04 15:20:53 | INFO | MOR-8AD5BM23790272 | Customer created succesfully
152
+ 2016-03-04 15:20:53 | INFO | MOR-8AD5BM23790272 | Adding Order Shipping Cost: 0
153
+ 2016-03-04 15:20:53 | INFO | MOR-8AD5BM23790272 | Order Import failed, Trying to import Order Again
154
+ 2016-03-04 15:20:53 | INFO | MOR-8AD5BM23790272 | Adding 3 product/s with id 1014 to order, with Beezup Price: 11
155
+ 2016-03-04 15:20:53 | INFO | MOR-8AD5BM23790272 | Creating new Customer
156
+ 2016-03-04 15:20:53 | INFO | MOR-8AD5BM23790272 | Creating already exists, returning customer object
157
+ 2016-03-04 15:20:53 | INFO | MOR-8AD5BM23790272 | Adding Order Shipping Cost: 0
158
+ 2016-03-04 15:20:54 | ERROR | MOR-8AD5BM23790272| Order could not be imported, error: Not all products are available in the requested quantity
159
+ 2016-03-04 15:23:44 | INFO | Initializing OM Importation
160
+ 2016-03-04 15:23:46 | INFO | MOR-8AD5BM23790272 | Store Matching succesful, Beezup Store: bdd7b7cf-558c-48a1-984b-00303aecdc34 , Magento Store Id: 1
161
+ 2016-03-04 15:23:46 | INFO | MOR-8AD5BM23790272 | Product Matching succesful, Beezup Imported Id: 15668 , Magento Product Id: 1014
162
+ 2016-03-04 15:23:46 | INFO | MOR-8AD5BM23790272 | Generating Order
163
+ 2016-03-04 15:23:46 | INFO | MOR-8AD5BM23790272 | Adding 3 product/s with id 1014 to order, with Beezup Price: 11
164
+ 2016-03-04 15:23:47 | INFO | MOR-8AD5BM23790272 | Creating new Customer
165
+ 2016-03-04 15:23:47 | INFO | MOR-8AD5BM23790272 | Creating already exists, returning customer object
166
+ 2016-03-04 15:23:47 | INFO | MOR-8AD5BM23790272 | Adding Order Shipping Cost: 0
167
+ 2016-03-04 15:23:47 | INFO | MOR-8AD5BM23790272 | Order Import failed, Trying to import Order Again
168
+ 2016-03-04 15:23:47 | INFO | MOR-8AD5BM23790272 | Adding 3 product/s with id 1014 to order, with Beezup Price: 11
169
+ 2016-03-04 15:23:47 | INFO | MOR-8AD5BM23790272 | Creating new Customer
170
+ 2016-03-04 15:23:47 | INFO | MOR-8AD5BM23790272 | Creating already exists, returning customer object
171
+ 2016-03-04 15:23:47 | INFO | MOR-8AD5BM23790272 | Adding Order Shipping Cost: 0
172
+ 2016-03-04 15:23:48 | ERROR | MOR-8AD5BM23790272| Order could not be imported, error: Not all products are available in the requested quantity
173
+ 2016-03-04 15:25:56 | INFO | Initializing OM Importation
174
+ 2016-03-04 15:25:58 | INFO | MOR-8AD5BM23790272 | Store Matching succesful, Beezup Store: bdd7b7cf-558c-48a1-984b-00303aecdc34 , Magento Store Id: 1
175
+ 2016-03-04 15:25:58 | INFO | MOR-8AD5BM23790272 | Product Matching succesful, Beezup Imported Id: 15668 , Magento Product Id: 1014
176
+ 2016-03-04 15:25:58 | INFO | MOR-8AD5BM23790272 | Generating Order
177
+ 2016-03-04 15:25:58 | INFO | MOR-8AD5BM23790272 | Adding 3 product/s with id 1014 to order, with Beezup Price: 11
178
+ 2016-03-04 15:25:58 | INFO | MOR-8AD5BM23790272 | Creating new Customer
179
+ 2016-03-04 15:25:58 | INFO | MOR-8AD5BM23790272 | Creating already exists, returning customer object
180
+ 2016-03-04 15:25:58 | INFO | MOR-8AD5BM23790272 | Adding Order Shipping Cost: 0
181
+ 2016-03-04 15:26:00 | INFO | MOR-8AD5BM23790272 | Adding Beezup Marketplace Information to Order
182
+ 2016-03-04 15:26:00 | INFO | MOR-8AD5BM23790272 | Sending Magento Order Id to Beezup, Magento Order Id: 236
183
+ 2016-03-04 15:26:02 | INFO | MOR-8AD5BM23790272 | Setting Order Status to Shipped
184
+ 2016-03-04 15:26:02 | INFO | MOR-8AD5BM23790272 | Generating Order Payment Invoice
185
+ 2016-03-04 15:26:02 | INFO | MOR-8AD5BM23790272 | Order Payment Invoice Generated Succesfully
186
+ 2016-03-04 15:26:03 | INFO | MOR-8AD5BM23790272 | Order imported succesfully, Magento Order Id: 236
187
+ 2016-03-04 15:27:50 | INFO | Initializing OM Importation
188
+ 2016-03-04 15:29:16 | INFO | Initializing OM Importation
189
+ 2016-03-04 15:29:18 | INFO | MOR-8AD5BM23790272 | Store Matching succesful, Beezup Store: bdd7b7cf-558c-48a1-984b-00303aecdc34 , Magento Store Id: 1
190
+ 2016-03-04 15:29:18 | INFO | MOR-8AD5BM23790272 | Product Matching succesful, Beezup Imported Id: 15668 , Magento Product Id: 1014
191
+ 2016-03-04 15:29:38 | INFO | Initializing OM Importation
192
+ 2016-03-04 15:29:39 | INFO | MOR-8AD5BM23790272 | Store Matching succesful, Beezup Store: bdd7b7cf-558c-48a1-984b-00303aecdc34 , Magento Store Id: 1
193
+ 2016-03-04 15:29:39 | INFO | MOR-8AD5BM23790272 | Product Matching succesful, Beezup Imported Id: 15668 , Magento Product Id: 1014
194
+ 2016-03-07 10:53:11 | INFO | Initializing OM Importation
195
+ 2016-03-07 10:54:06 | INFO | Initializing OM Importation
196
+ 2016-03-07 10:54:54 | INFO | Initializing OM Importation
197
+ 2016-03-16 15:38:39 | INFO | Initializing OM Importation
198
+ 2016-03-16 15:38:40 | INFO | 403-6750959-2690726 | Store Matching succesful, Beezup Store: bdd7b7cf-558c-48a1-984b-00303aecdc34 , Magento Store Id: 1
199
+ 2016-03-16 15:38:40 | ERROR | 403-6750959-2690726| No Product Matching, Product 14272 could not be found
200
+ 2016-03-16 15:38:41 | INFO | 403-6750959-2690726 | Store Matching succesful, Beezup Store: bdd7b7cf-558c-48a1-984b-00303aecdc34 , Magento Store Id: 1
201
+ 2016-03-16 15:38:41 | ERROR | 403-6750959-2690726| No Product Matching, Product 14330 could not be found
202
+ 2016-03-16 15:38:42 | INFO | 403-6750959-2690726 | Store Matching succesful, Beezup Store: bdd7b7cf-558c-48a1-984b-00303aecdc34 , Magento Store Id: 1
203
+ 2016-03-16 15:38:42 | INFO | 403-6750959-2690726 | Product Matching succesful, Beezup Imported Id: 14272 , Magento Product Id: 1015
204
+ 2016-03-16 15:38:42 | INFO | 403-6750959-2690726 | Store Matching succesful, Beezup Store: bdd7b7cf-558c-48a1-984b-00303aecdc34 , Magento Store Id: 1
205
+ 2016-03-16 15:38:42 | INFO | 403-6750959-2690726 | Product Matching succesful, Beezup Imported Id: 14330 , Magento Product Id: 1016
206
+ 2016-03-16 15:38:42 | INFO | 403-6750959-2690726 | Generating Order
207
+ 2016-03-16 15:38:42 | INFO | 403-6750959-2690726 | Adding 1 product/s with id 1015 to order, with Beezup Price: 9
208
+ 2016-03-16 15:38:42 | INFO | 403-6750959-2690726 | Adding 1 product/s with id 1016 to order, with Beezup Price: 13
209
+ 2016-03-16 15:38:42 | INFO | 403-6750959-2690726 | Creating new Customer
210
+ 2016-03-16 15:38:42 | INFO | 403-6750959-2690726 | Customer created succesfully
211
+ 2016-03-16 15:38:42 | INFO | 403-6750959-2690726 | Adding Order Shipping Cost: 3
212
+ 2016-03-16 15:38:45 | INFO | 403-6750959-2690726 | Adding Beezup Marketplace Information to Order
213
+ 2016-03-16 15:38:45 | INFO | 403-6750959-2690726 | Sending Magento Order Id to Beezup, Magento Order Id: 237
214
+ 2016-03-16 15:38:46 | INFO | 403-6750959-2690726 | Setting Order Status to InProgress
215
+ 2016-03-16 15:38:46 | INFO | 403-6750959-2690726 | Generating Order Payment Invoice
216
+ 2016-03-16 15:38:47 | INFO | 403-6750959-2690726 | Order Payment Invoice Generated Succesfully
217
+ 2016-03-16 15:38:47 | INFO | 403-6750959-2690726 | Order imported succesfully, Magento Order Id: 237
218
+ 2016-03-16 15:41:18 | INFO | Initializing OM Importation
219
+ 2016-03-16 15:41:19 | INFO | 403-6750959-2690726 | Store Matching succesful, Beezup Store: bdd7b7cf-558c-48a1-984b-00303aecdc34 , Magento Store Id: 1
220
+ 2016-03-16 15:41:19 | INFO | 403-6750959-2690726 | Product Matching succesful, Beezup Imported Id: 14272 , Magento Product Id: 1015
221
+ 2016-03-16 15:41:19 | INFO | 403-6750959-2690726 | Store Matching succesful, Beezup Store: bdd7b7cf-558c-48a1-984b-00303aecdc34 , Magento Store Id: 1
222
+ 2016-03-16 15:41:19 | INFO | 403-6750959-2690726 | Product Matching succesful, Beezup Imported Id: 14330 , Magento Product Id: 1016
223
+ 2016-03-16 15:41:19 | INFO | 403-6750959-2690726 | Order Etag has not changed
224
+ 2016-03-16 15:42:52 | INFO | Initializing OM Importation
225
+ 2016-03-16 15:42:53 | INFO | 171-5103575-0375518 | Store Matching succesful, Beezup Store: bdd7b7cf-558c-48a1-984b-00303aecdc34 , Magento Store Id: 1
226
+ 2016-03-16 15:42:53 | INFO | 171-5103575-0375518 | Product Matching succesful, Beezup Imported Id: 15622 , Magento Product Id: 832
227
+ 2016-03-16 15:42:53 | INFO | 171-5103575-0375518 | Store Matching succesful, Beezup Store: bdd7b7cf-558c-48a1-984b-00303aecdc34 , Magento Store Id: 1
228
+ 2016-03-16 15:42:53 | INFO | 171-5103575-0375518 | Product Matching succesful, Beezup Imported Id: 15622 , Magento Product Id: 832
229
+ 2016-03-16 15:42:53 | INFO | 171-5103575-0375518 | Generating Order
230
+ 2016-03-16 15:42:53 | INFO | 171-5103575-0375518 | Adding 1 product/s with id 832 to order, with Beezup Price: 16
231
+ 2016-03-16 15:42:53 | INFO | 171-5103575-0375518 | Product 832 Stock = 0, Updating to 1 to generate Order
232
+ 2016-03-16 15:42:54 | INFO | 171-5103575-0375518 | Creating new Customer
233
+ 2016-03-16 15:42:54 | INFO | 171-5103575-0375518 | Customer created succesfully
234
+ 2016-03-16 15:42:54 | INFO | 171-5103575-0375518 | Adding Order Shipping Cost: 3
235
+ 2016-03-16 15:42:55 | INFO | 171-5103575-0375518 | Adding Beezup Marketplace Information to Order
236
+ 2016-03-16 15:42:55 | INFO | 171-5103575-0375518 | Sending Magento Order Id to Beezup, Magento Order Id: 238
237
+ 2016-03-16 15:42:57 | INFO | 171-5103575-0375518 | Setting Order Status to InProgress
238
+ 2016-03-16 15:42:57 | INFO | 171-5103575-0375518 | Generating Order Payment Invoice
239
+ 2016-03-16 15:42:57 | INFO | 171-5103575-0375518 | Order Payment Invoice Generated Succesfully
240
+ 2016-03-16 15:42:58 | INFO | 171-5103575-0375518 | Order imported succesfully, Magento Order Id: 238
241
+ 2016-03-16 15:43:31 | INFO | Initializing OM Importation
242
+ 2016-03-17 15:22:28 | INFO | Initializing OM Importation
243
+ 2016-03-17 15:22:29 | INFO | 402-0432037-5045910 | Store Matching succesful, Beezup Store: bdd7b7cf-558c-48a1-984b-00303aecdc34 , Magento Store Id: 1
244
+ 2016-03-17 15:22:29 | ERROR | 402-0432037-5045910| No Product Matching, Product 16336 could not be found
245
+ 2016-03-17 15:22:32 | INFO | 402-0432037-5045910 | Store Matching succesful, Beezup Store: bdd7b7cf-558c-48a1-984b-00303aecdc34 , Magento Store Id: 1
246
+ 2016-03-17 15:22:32 | INFO | 402-0432037-5045910 | Product Matching succesful, Beezup Imported Id: 16336 , Magento Product Id: 1017
247
+ 2016-03-17 15:22:32 | INFO | 402-0432037-5045910 | Generating Order
248
+ 2016-03-17 15:22:32 | INFO | 402-0432037-5045910 | Adding 1 product/s with id 1017 to order, with Beezup Price: 12
249
+ 2016-03-17 15:22:32 | INFO | 402-0432037-5045910 | Creating new Customer
250
+ 2016-03-17 15:22:32 | INFO | 402-0432037-5045910 | Customer created succesfully
251
+ 2016-03-17 15:22:32 | INFO | 402-0432037-5045910 | Adding Order Shipping Cost: 3
252
+ 2016-03-17 15:22:34 | INFO | 402-0432037-5045910 | Adding Beezup Marketplace Information to Order
253
+ 2016-03-17 15:22:34 | INFO | 402-0432037-5045910 | Sending Magento Order Id to Beezup, Magento Order Id: 239
254
+ 2016-03-17 15:22:37 | INFO | 402-0432037-5045910 | Setting Order Status to Shipped
255
+ 2016-03-17 15:22:37 | INFO | 402-0432037-5045910 | Generating Order Payment Invoice
256
+ 2016-03-17 15:22:38 | INFO | 402-0432037-5045910 | Order Payment Invoice Generated Succesfully
257
+ 2016-03-17 15:22:38 | INFO | 402-0432037-5045910 | Order imported succesfully, Magento Order Id: 239
258
+ 2016-03-17 16:43:03 | INFO | Initializing OM Importation
259
+ 2016-03-17 16:43:03 | INFO | 1603162336S0T4A | Store Matching succesful, Beezup Store: bdd7b7cf-558c-48a1-984b-00303aecdc34 , Magento Store Id: 1
260
+ 2016-03-17 16:43:04 | ERROR | 1603162336S0T4A| No Product Matching, Product 15434 could not be found
261
+ 2016-03-17 16:43:04 | INFO | 1603162336S0T4A | Store Matching succesful, Beezup Store: bdd7b7cf-558c-48a1-984b-00303aecdc34 , Magento Store Id: 1
262
+ 2016-03-17 16:43:04 | INFO | 1603162336S0T4A | Product Matching succesful, Beezup Imported Id: 15434 , Magento Product Id: 1018
263
+ 2016-03-17 16:43:04 | INFO | 1603162336S0T4A | Generating Order
264
+ 2016-03-17 16:43:04 | INFO | 1603162336S0T4A | Adding 1 product/s with id 1018 to order, with Beezup Price: 57
265
+ 2016-03-17 16:43:04 | INFO | 1603162336S0T4A | Creating new Customer
266
+ 2016-03-17 16:43:04 | INFO | 1603162336S0T4A | Customer created succesfully
267
+ 2016-03-17 16:43:05 | INFO | 1603162336S0T4A | Adding Order Shipping Cost: 0
268
+ 2016-03-17 16:43:06 | INFO | 1603162336S0T4A | Adding Beezup Marketplace Information to Order
269
+ 2016-03-17 16:43:06 | INFO | 1603162336S0T4A | Sending Magento Order Id to Beezup, Magento Order Id: 240
270
+ 2016-03-17 16:43:08 | INFO | 1603162336S0T4A | Setting Order Status to Shipped
271
+ 2016-03-17 16:43:08 | INFO | 1603162336S0T4A | Generating Order Payment Invoice
272
+ 2016-03-17 16:43:08 | INFO | 1603162336S0T4A | Order Payment Invoice Generated Succesfully
273
+ 2016-03-17 16:43:09 | INFO | 1603162336S0T4A | Order imported succesfully, Magento Order Id: 240
274
+ 2016-03-17 19:33:39 | INFO | Initializing OM Importation
275
+ 2016-03-17 19:33:40 | INFO | 402-0432037-5045910 | Store Matching succesful, Beezup Store: bdd7b7cf-558c-48a1-984b-00303aecdc34 , Magento Store Id: 1
276
+ 2016-03-17 19:33:40 | INFO | 402-0432037-5045910 | Product Matching succesful, Beezup Imported Id: 16336 , Magento Product Id: 1017
277
+ 2016-03-17 19:33:40 | INFO | 402-0432037-5045910 | Order Etag has not changed
278
+ 2016-03-18 16:15:55 | INFO | Initializing OM Importation
279
+ 2016-03-18 16:15:56 | INFO | 404-3346486-8692320 | Store Matching succesful, Beezup Store: bdd7b7cf-558c-48a1-984b-00303aecdc34 , Magento Store Id: 1
280
+ 2016-03-18 16:15:56 | ERROR | 404-3346486-8692320| No Product Matching, Product 14328 could not be found
281
+ 2016-03-18 16:15:57 | INFO | 404-3346486-8692320 | Store Matching succesful, Beezup Store: bdd7b7cf-558c-48a1-984b-00303aecdc34 , Magento Store Id: 1
282
+ 2016-03-18 16:15:57 | INFO | 404-3346486-8692320 | Product Matching succesful, Beezup Imported Id: 14328 , Magento Product Id: 1019
283
+ 2016-03-18 16:15:57 | INFO | 404-3346486-8692320 | Generating Order
284
+ 2016-03-18 16:15:57 | INFO | 404-3346486-8692320 | Adding 1 product/s with id 1019 to order, with Beezup Price: 10
285
+ 2016-03-18 16:15:57 | INFO | 404-3346486-8692320 | Creating new Customer
286
+ 2016-03-18 16:15:58 | INFO | 404-3346486-8692320 | Customer created succesfully
287
+ 2016-03-18 16:15:58 | INFO | 404-3346486-8692320 | Adding Order Shipping Cost: 3
288
+ 2016-03-18 16:16:00 | INFO | 404-3346486-8692320 | Adding Beezup Marketplace Information to Order
289
+ 2016-03-18 16:16:00 | INFO | 404-3346486-8692320 | Sending Magento Order Id to Beezup, Magento Order Id: 241
290
+ 2016-03-18 16:16:02 | INFO | 404-3346486-8692320 | Setting Order Status to InProgress
291
+ 2016-03-18 16:16:02 | INFO | 404-3346486-8692320 | Generating Order Payment Invoice
292
+ 2016-03-18 16:16:03 | INFO | 404-3346486-8692320 | Order Payment Invoice Generated Succesfully
293
+ 2016-03-18 16:16:03 | INFO | 404-3346486-8692320 | Order imported succesfully, Magento Order Id: 241
app/code/community/BeezUp/sql/beezup_setup/mysql4-upgrade-4.5.0-4.6.0.php ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ $installer = $this;
4
+ $installer->startSetup();
5
+ $this->getConnection()->addColumn(
6
+ $this->getTable('sales/order_grid'),
7
+ 'beezup_marketplace_business_code',
8
+ 'varchar(255) DEFAULT NULL'
9
+
10
+ );
11
+ $installer->endSetup();
app/design/adminhtml/default/default/template/beezup/custom.phtml CHANGED
@@ -1,340 +1,355 @@
1
  <div class="entry-edit">
2
  <div class="entry-edit-head">
3
  <h4><?php echo $this->__('BeezUP Info'); ?></h4>
4
- </div>
5
  <div class="fieldset fieldset-wide">
6
-
7
- <?php
8
- $order = $this->getOrder();
9
- $blnBeezup = false;
10
- $base_url = $url = Mage::getBaseUrl( Mage_Core_Model_Store::URL_TYPE_WEB, true );
11
-
12
- $resource = Mage::getSingleton('core/resource');
13
- $readConnection = $resource->getConnection('core_read');
14
- $table = $resource->getTableName('sales/order_grid');
15
- $query = 'SELECT * FROM ' . $table . ' WHERE beezup_order = 1 and entity_id = \''
16
- . $order->getId() . '\' LIMIT 1';
17
- $results = $readConnection->fetchAll($query);
18
- //var_dump($results);
19
- if($results[0]['beezup_order'] == 1) {
20
- $blnBeezup = true;
21
-
22
- $date = new DateTime($results[0]['beezup_marketplace_last_modification_date']);
23
- $beezup_marketplace_last_modification_date = $date->format('d-m-Y H:i:s'). " (UTC Time)";
24
-
25
- $date2 = new DateTime($results[0]['beezup_purchase_date']);
26
- $beezup_purchase_date = $date2->format('d-m-Y H:i:s'). " (UTC Time)";
27
-
28
- $date3 = new DateTime($results[0]['beezup_last_modification_date']);
29
- $beezup_last_modification_date = $date3->format('d-m-Y H:i:s'). " (UTC Time)";
30
-
31
- echo "<strong>".Mage::helper('beezup')->__('BeezUP Order Id:')." </strong> ".$results[0]['beezup_order_id']."<br>";
32
- echo "<strong>".Mage::helper('beezup')->__('BeezUP Status:')." </strong> ".$results[0]['beezup_status']."<br>";
33
- echo "<strong>".Mage::helper('beezup')->__('BeezUP Last Modification Date:')." </strong> ".$beezup_last_modification_date."<br>";
34
- echo "<strong>".Mage::helper('beezup')->__('Marketplace:')." </strong> ".$results[0]['beezup_marketplace']."<br>";
35
- echo "<strong>".Mage::helper('beezup')->__('Marketplace Order Id:')." </strong> ".$results[0]['beezup_market_order_id']."<br>";
36
- echo "<strong>".Mage::helper('beezup')->__('Marketplace Status:')." </strong> ".$results[0]['beezup_marketplace_status']."<br>";
37
- echo "<strong>".Mage::helper('beezup')->__('BeezUP Purchase Date: ')."</strong> ".$beezup_purchase_date ."<br>";
38
- echo "<strong>".Mage::helper('beezup')->__('Marketplace Last Modification Date:')." </strong> ".$beezup_marketplace_last_modification_date."<br>";
39
- echo "<strong>".Mage::helper('beezup')->__('BeezUP Total Paid: ')."</strong> ".$results[0]['beezup_total_paid']."<br>";
40
- if((int)$results[0]['beezup_comission'] > 0) {
41
- echo "<strong>".Mage::helper('beezup')->__('BeezUP Total Commission:')." </strong> ".$results[0]['beezup_comission']."<br>";
42
- }
43
- echo "<strong>".Mage::helper('beezup')->__('BeezUP Order Link:')." </strong> <a href='https://go.beezup.com/OrderManagement/Informations?BeezUPOrderUUId=".$results[0]['beezup_order_id']."&MarketplaceTechnicalCode=".$results[0]['beezup_marketplace']."&AccountId=".$results[0]['beezup_name']."' target='_blank'>https://go.beezup.com/OrderManagement/Informations?BeezUPOrderUUId=".$results[0]['beezup_order_id']."&MarketplaceTechnicalCode=".$results[0]['beezup_marketplace']."&AccountId=".$results[0]['beezup_name']."</a><br>";
44
- } else {
45
-
46
- echo Mage::helper('beezup')->__('No data here, since it\'s not an order coming from BeezUP');
47
- }
48
-
49
- ?>
50
-
51
- </div>
52
- </div>
53
- <?php if($blnBeezup) {
54
- $firstname = Mage::getSingleton('admin/session')->getUser()->getFirstname();
55
- $lastname = Mage::getSingleton('admin/session')->getUser()->getLastname();
56
- $username = $firstname." ".$lastname;
57
-
58
- $helper = Mage::helper('beezup');
59
- $userid = $helper->getConfig('beezup/marketplace/userid');
60
- $usertoken = $helper->getConfig('beezup/marketplace/usertoken');
61
-
62
- $order_actions = $this->getBeezupInfo($order->getId());
63
- ?>
64
-
65
-
66
- <style>
67
- #acciones {
68
-
69
- width: 80%;
70
- float: left;
71
-
72
- }
73
- .calendar {
74
- left: 40% !important;
75
- position:fixed !Important;
76
- top: 31% !Important;
77
- z-index: 999999999 !Important;
78
-
79
- }
80
- .beezup-modal-dialog {
81
- visibility:hidden;
82
- position: fixed;
83
- left: 0px;
84
- top: 20%;
85
- width: 30%;
86
-
87
- text-align: center;
88
- z-index: 1000;
89
- border: 2px solid gray;
90
- background: blue;
91
- z-index: 999999;
92
- margin: 0 auto;
93
- left: 0;
94
- right: 0;
95
- height: auto;
96
- padding-bottom:20px;
97
- background: white;
98
- z-index: 999999;
99
- }
100
- .popup-close {
101
- position:absolute;
102
- right:0;
103
- cursor: pointer;
104
- width: 30px;
105
- border: 1px solid #808080;
106
- height: 30px;
107
- line-height: 28px;
108
- font-size: 18px;
109
- background: gray;
110
- color: white;
111
- z-index: 999999999;
112
- }
113
- #fondo {
114
- visibility:hidden;
115
- position: fixed;
116
- height: 100%;
117
- width: 100%;
118
- background: #000 none repeat scroll 0% 0%;
119
- opacity: 0.5;
120
- top: 0;
121
- left: 0;
122
- z-index: 9999;
123
-
124
- }
125
- </style>
126
-
127
- <div id="fondo"></div>
128
- <div class="entry-edit">
129
- <div class="entry-edit-head">
130
- <h4><?php echo $this->__('BeezUP Order Status'); ?></h4>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
131
  </div>
132
- <div class="fieldset fieldset-wide">
133
- <div class="alert" id="msgAlert" style="display:none;padding: 10px;background-color: lightgrey; color:white;margin-bottom: 10px;"></div>
134
- <div id="acciones">
135
- <?php
136
- if($order_actions['is_pending'] == false) {
137
- foreach($order_actions as $key => $action) {
138
- if(isset($action['action'])) {
139
- $label = preg_replace('/(?<!\ )[A-Z]/', ' $0', $action['action']);
140
- ?>
141
-
142
- <button class="button" style="background:gray;border-color:gray;" onclick="overlay('<?php echo $action['action'];?>');"><?php echo $label;?></button>
143
-
144
-
145
  <div id="overlay_<?php echo $action['action'];?>" class="beezup-modal-dialog">
146
- <div>
147
- <span class="popup-close" onclick="overlay('<?php echo $action['action'];?>');">X</span>
148
- <h3 style="position: relative;top: 5px;color:gray;"><?php echo Mage::helper('beezup')->__('Update Order Status');?></h3>
149
- <hr style="margin-top: 9px;color: gray; background: gray;">
150
- <form id="Updateform_<?php echo $action['action'];?>">
151
- <div style="margin-top:10px;padding:10px;">
152
- <?php $inputs = $this->generateInput($action['parameters']);
153
- echo $inputs;
154
- ?>
155
-
156
- </div>
157
- <div id="submitBtn-<?php echo $action['action'];?>" style=" float: right;margin-right: 25px;"><button type="button" onclick="updateOrder('<?php echo $action['action'];?>');" class="button" name="submit" ><?php echo Mage::helper('beezup')->__('Update');?></button></div>
158
- </form>
159
- </div>
160
  </div>
161
-
162
- <?php }
163
- } } else {?>
164
-
165
- <div style="padding: 10px;background-color: lightgrey; margin-bottom: 10px;"><?php echo Mage::helper('beezup')->__('Order is syncronizing, please resync within a few mins to get updated info');?></div>
166
-
167
- <?php } ?>
168
- </div>
169
-
170
- <button class="button" style="float:right;" onclick="resync();"><?php echo Mage::helper('beezup')->__('Resync Order');?></button>
171
- <div id="ajax-loader" style="display:none;float:right;"><img src="<?php echo $base_url."/beezup/omstatus/loader";?>" /></div>
172
- <br>
173
- <div id="statusLoad" style="margin-top:15px;">
174
- </div>
175
-
176
-
177
-
178
- </div>
179
-
180
- </div>
181
-
182
-
183
- <script>
184
- var ajax = {};
185
- ajax.x = function() {
186
- if (typeof XMLHttpRequest !== 'undefined') {
187
- return new XMLHttpRequest();
188
- }
189
- var versions = [
190
- "MSXML2.XmlHttp.6.0",
191
- "MSXML2.XmlHttp.5.0",
192
- "MSXML2.XmlHttp.4.0",
193
- "MSXML2.XmlHttp.3.0",
194
- "MSXML2.XmlHttp.2.0",
195
- "Microsoft.XmlHttp"
196
- ];
197
-
198
- var xhr;
199
- for(var i = 0; i < versions.length; i++) {
200
- try {
201
- xhr = new ActiveXObject(versions[i]);
202
- break;
203
- } catch (e) {
204
- }
205
- }
206
- return xhr;
207
- };
208
-
209
- ajax.send = function(url, callback, method, data, sync) {
210
- var x = ajax.x();
211
- x.open(method, url, sync);
212
- x.onreadystatechange = function() {
213
- if (x.readyState == 4) {
214
- callback(x.responseText)
215
- }
216
- };
217
- if (method == 'POST') {
218
- x.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
219
- }
220
- x.send(data)
221
- };
222
-
223
- ajax.get = function(url, data, callback, sync) {
224
- var query = [];
225
- for (var key in data) {
226
- query.push(encodeURIComponent(key) + '=' + encodeURIComponent(data[key]));
227
- }
228
- ajax.send(url + (query.length ? '?' + query.join('&') : ''), callback, 'GET', null, sync)
229
- };
230
-
231
- ajax.post = function(url, data, callback, sync) {
232
- var query = [];
233
- for (var key in data) {
234
- query.push(encodeURIComponent(key) + '=' + encodeURIComponent(data[key]));
235
- }
236
- ajax.send(url, callback, 'POST', query.join('&'), sync)
237
- };
238
-
239
-
240
-
241
- function resync() {
 
 
 
 
242
  document.getElementById("ajax-loader").style.display="block";
243
 
244
- setTimeout(function () {
245
- ajax.get('<?php echo $base_url."beezup/omstatus/resync";?>', {order_id : <?php echo $order->getId();?>, uid : '<?php echo $userid;?>', token : '<?php echo $usertoken;?>'}, function(response) {
246
- document.getElementById("msgAlert").innerHTML = '';
247
- document.getElementById("msgAlert").style.display = "block";
248
-
249
  document.getElementById("ajax-loader").style.display="none";
250
- if(response == 1) {
251
  document.getElementById("msgAlert").innerHTML = '<?php echo Mage::helper('beezup')->__("Updated Order Ok page will refresh in 2 secc");?>';
252
- document.getElementById("msgAlert").style.backgroundColor = "green";
253
-
254
  setTimeout(function () { window.location='window.location.href'; } , 2000);
255
- } else if(response == 2) {
256
- document.getElementById("msgAlert").innerHTML = '<?php echo Mage::helper('beezup')->__('Order has been refreshed with no change');?>';
257
- document.getElementById("msgAlert").style.backgroundColor = "orange";
258
-
259
- } else {
260
- document.getElementById("msgAlert").innerHTML = '<?php echo Mage::helper('beezup')->__("Order is syncronizing, please resync within a few mins to get updated info");?>';
261
- document.getElementById("msgAlert").style.backgroundColor = "orange";
262
-
263
-
264
- }
265
-
266
- });
267
-
268
-
269
- }, 1000);
270
- }
271
- function overlay(action) {
272
- var el = document.getElementById("overlay_"+action);
273
- el.style.visibility = (el.style.visibility == "visible") ? "hidden" : "visible";
274
- var fondo = document.getElementById("fondo");
275
- fondo.style.visibility = (fondo.style.visibility == "visible") ? "hidden" : "visible";
276
- }
277
-
278
-
279
- function updateOrder(action) {
280
- var form = document.getElementById('Updateform_'+action);
281
- var data = serialize(form);
282
- var btnSubmit = document.getElementById("submitBtn-"+action);
283
- var alert = document.getElementById("msgAlert");
284
- var el = document.getElementById("overlay_"+action);
285
- var fondo = document.getElementById("fondo");
286
- var acciones = document.getElementById("acciones");
287
- btnSubmit.innerHTML = "<img src='<?php echo $base_url."/beezup/omstatus/loader";?>' />";
288
- ajax.get('<?php echo $base_url."beezup/omstatus/update?"?>'+data+"&adminUser=<?php echo $username;?>&order_id=<?php echo $order->getId();?>&uid=<?php echo $userid;?>&token=<?php echo $usertoken;?>&action_id="+action, {}, function(response) {
289
-
290
- if (response.indexOf("SUCCESS") !=-1) {
291
- alert.style.backgroundColor = "green";
292
-
293
- } else {
294
- alert.style.backgroundColor = "red";
295
-
296
-
297
- }
298
-
299
  alert.innerHTML = response;
300
  alert.style.display="block";
301
  btnSubmit.innerHTML = "";
302
- fondo.style.visibility = (fondo.style.visibility == "visible") ? "hidden" : "visible";
303
- el.style.visibility = (el.style.visibility == "visible") ? "hidden" : "visible";
304
- acciones.innerHTML = "";
305
- setTimeout(function () {
306
- resync();
307
- }, 2000);
308
- });
309
-
310
-
311
- console.log(data);
312
- }
313
-
314
-
315
-
316
-
317
- function serialize(form) {
318
- var field, s = [];
319
- if (typeof form == 'object' && form.nodeName == "FORM") {
320
- var len = form.elements.length;
321
- for (i=0; i<len; i++) {
322
- field = form.elements[i];
323
- if (field.name && !field.disabled && field.type != 'file' && field.type != 'reset' && field.type != 'submit' && field.type != 'button') {
324
- if (field.type == 'select-multiple') {
325
- for (j=form.elements[i].options.length-1; j>=0; j--) {
326
- if(field.options[j].selected)
327
- s[s.length] = encodeURIComponent(field.name) + "=" + encodeURIComponent(field.options[j].value);
328
- }
329
- } else if ((field.type != 'checkbox' && field.type != 'radio') || field.checked) {
330
- s[s.length] = encodeURIComponent(field.name) + "=" + encodeURIComponent(field.value);
331
- }
332
- }
333
- }
334
- }
335
- return s.join('&').replace(/%20/g, '+');
336
- }
337
- </script>
338
-
339
- <?php
340
- } ?>
1
  <div class="entry-edit">
2
  <div class="entry-edit-head">
3
  <h4><?php echo $this->__('BeezUP Info'); ?></h4>
4
+ </div>
5
  <div class="fieldset fieldset-wide">
6
+
7
+ <?php
8
+ $order = $this->getOrder();
9
+
10
+ $shipment_collection = Mage::getResourceModel('sales/order_shipment_collection')
11
+ ->setOrderFilter($order)
12
+ ->load();
13
+ $shipping_data = array();
14
+ $shipping_data['tracking'] = "";
15
+ $shipping_data['carrier'] = "";
16
+ foreach($shipment_collection as $shipment){
17
+ foreach($shipment->getAllTracks() as $tracking_number){
18
+ $shipping_data['tracking'] = $tracking_number->getNumber();
19
+ $shipping_data['carrier'] = $tracking_number->getTitle();
20
+ break;
21
+ }
22
+ break;
23
+ }
24
+
25
+ $blnBeezup = false;
26
+ $base_url = $url = Mage::getBaseUrl( Mage_Core_Model_Store::URL_TYPE_WEB, true );
27
+
28
+ $resource = Mage::getSingleton('core/resource');
29
+ $readConnection = $resource->getConnection('core_read');
30
+ $table = $resource->getTableName('sales/order_grid');
31
+ $query = 'SELECT * FROM ' . $table . ' WHERE beezup_order = 1 and entity_id = \''
32
+ . $order->getId() . '\' LIMIT 1';
33
+ $results = $readConnection->fetchAll($query);
34
+ //var_dump($results);
35
+ if($results[0]['beezup_order'] == 1) {
36
+ $blnBeezup = true;
37
+
38
+ $date = new DateTime($results[0]['beezup_marketplace_last_modification_date']);
39
+ $beezup_marketplace_last_modification_date = $date->format('d-m-Y H:i:s'). " (UTC Time)";
40
+
41
+ $date2 = new DateTime($results[0]['beezup_purchase_date']);
42
+ $beezup_purchase_date = $date2->format('d-m-Y H:i:s'). " (UTC Time)";
43
+
44
+ $date3 = new DateTime($results[0]['beezup_last_modification_date']);
45
+ $beezup_last_modification_date = $date3->format('d-m-Y H:i:s'). " (UTC Time)";
46
+
47
+ echo "<strong>".Mage::helper('beezup')->__('BeezUP Order Id:')." </strong> ".$results[0]['beezup_order_id']."<br>";
48
+ echo "<strong>".Mage::helper('beezup')->__('BeezUP Status:')." </strong> ".$results[0]['beezup_status']."<br>";
49
+ echo "<strong>".Mage::helper('beezup')->__('BeezUP Last Modification Date:')." </strong> ".$beezup_last_modification_date."<br>";
50
+ echo "<strong>".Mage::helper('beezup')->__('Marketplace:')." </strong> ".ucfirst(strtolower($results[0]['beezup_marketplace_business_code']))."<br>";
51
+ echo "<strong>".Mage::helper('beezup')->__('Marketplace Order Id:')." </strong> ".$results[0]['beezup_market_order_id']."<br>";
52
+ echo "<strong>".Mage::helper('beezup')->__('Marketplace Status:')." </strong> ".$results[0]['beezup_marketplace_status']."<br>";
53
+ echo "<strong>".Mage::helper('beezup')->__('BeezUP Purchase Date: ')."</strong> ".$beezup_purchase_date ."<br>";
54
+ echo "<strong>".Mage::helper('beezup')->__('Marketplace Last Modification Date:')." </strong> ".$beezup_marketplace_last_modification_date."<br>";
55
+ echo "<strong>".Mage::helper('beezup')->__('BeezUP Total Paid: ')."</strong> ".$results[0]['beezup_total_paid']."<br>";
56
+ if((int)$results[0]['beezup_comission'] > 0) {
57
+ echo "<strong>".Mage::helper('beezup')->__('BeezUP Total Commission:')." </strong> ".$results[0]['beezup_comission']."<br>";
58
+ }
59
+ echo "<strong>".Mage::helper('beezup')->__('BeezUP Order Link:')." </strong> <a href='https://go.beezup.com/OrderManagement/Informations?BeezUPOrderUUId=".$results[0]['beezup_order_id']."&MarketplaceTechnicalCode=".$results[0]['beezup_marketplace']."&AccountId=".$results[0]['beezup_name']."' target='_blank'>https://go.beezup.com/OrderManagement/Informations?BeezUPOrderUUId=".$results[0]['beezup_order_id']."&MarketplaceTechnicalCode=".$results[0]['beezup_marketplace']."&AccountId=".$results[0]['beezup_name']."</a><br>";
60
+ } else {
61
+
62
+ echo Mage::helper('beezup')->__('No data here, since it\'s not an order coming from BeezUP');
63
+ }
64
+
65
+ ?>
66
+
67
+ </div>
68
+ </div>
69
+ <?php if($blnBeezup) {
70
+ $firstname = Mage::getSingleton('admin/session')->getUser()->getFirstname();
71
+ $lastname = Mage::getSingleton('admin/session')->getUser()->getLastname();
72
+ $username = $firstname." ".$lastname;
73
+
74
+ $helper = Mage::helper('beezup');
75
+ $userid = $helper->getConfig('beezup/marketplace/userid');
76
+ $usertoken = $helper->getConfig('beezup/marketplace/usertoken');
77
+ $order_actions = $this->getBeezupInfo($order->getId());
78
+ ?>
79
+
80
+
81
+ <style>
82
+ #acciones {
83
+
84
+ width: 80%;
85
+ float: left;
86
+
87
+ }
88
+ .calendar {
89
+ left: 40% !important;
90
+ position:fixed !Important;
91
+ top: 31% !Important;
92
+ z-index: 999999999 !Important;
93
+
94
+ }
95
+ .beezup-modal-dialog {
96
+ visibility:hidden;
97
+ position: fixed;
98
+ left: 0px;
99
+ top: 20%;
100
+ width: 30%;
101
+
102
+ text-align: center;
103
+ z-index: 1000;
104
+ border: 2px solid gray;
105
+ background: blue;
106
+ z-index: 999999;
107
+ margin: 0 auto;
108
+ left: 0;
109
+ right: 0;
110
+ height: auto;
111
+ padding-bottom:20px;
112
+ background: white;
113
+ z-index: 999999;
114
+ }
115
+ .popup-close {
116
+ position:absolute;
117
+ right:0;
118
+ cursor: pointer;
119
+ width: 30px;
120
+ border: 1px solid #808080;
121
+ height: 30px;
122
+ line-height: 28px;
123
+ font-size: 18px;
124
+ background: gray;
125
+ color: white;
126
+ z-index: 999999999;
127
+ }
128
+ #fondo {
129
+ visibility:hidden;
130
+ position: fixed;
131
+ height: 100%;
132
+ width: 100%;
133
+ background: #000 none repeat scroll 0% 0%;
134
+ opacity: 0.5;
135
+ top: 0;
136
+ left: 0;
137
+ z-index: 9999;
138
+
139
+ }
140
+ </style>
141
+
142
+ <div id="fondo"></div>
143
+ <div class="entry-edit">
144
+ <div class="entry-edit-head">
145
+ <h4><?php echo $this->__('BeezUP Order Status'); ?></h4>
146
  </div>
147
+ <div class="fieldset fieldset-wide">
148
+ <div class="alert" id="msgAlert" style="display:none;padding: 10px;background-color: lightgrey; color:white;margin-bottom: 10px;"></div>
149
+ <div id="acciones">
150
+ <?php
151
+ if($order_actions['is_pending'] == false) {
152
+ foreach($order_actions as $key => $action) {
153
+ if(isset($action['action'])) {
154
+ $label = preg_replace('/(?<!\ )[A-Z]/', ' $0', $action['action']);
155
+ ?>
156
+
157
+ <button class="button" style="background:gray;border-color:gray;" onclick="overlay('<?php echo $action['action'];?>');"><?php echo $label;?></button>
158
+
159
+
160
  <div id="overlay_<?php echo $action['action'];?>" class="beezup-modal-dialog">
161
+ <div>
162
+ <span class="popup-close" onclick="overlay('<?php echo $action['action'];?>');">X</span>
163
+ <h3 style="position: relative;top: 5px;color:gray;"><?php echo Mage::helper('beezup')->__('Update Order Status');?></h3>
164
+ <hr style="margin-top: 9px;color: gray; background: gray;">
165
+ <form id="Updateform_<?php echo $action['action'];?>">
166
+ <div style="margin-top:10px;padding:10px;">
167
+ <?php $inputs = $this->generateInput($action['parameters'], $shipping_data);
168
+ echo $inputs;
169
+ ?>
170
+
 
 
 
 
171
  </div>
172
+ <div id="submitBtn-<?php echo $action['action'];?>" style=" float: right;margin-right: 25px;"><button type="button" onclick="updateOrder('<?php echo $action['action'];?>');" class="button" name="submit" ><?php echo Mage::helper('beezup')->__('Update');?></button></div>
173
+ </form>
174
+ </div>
175
+ </div>
176
+
177
+ <?php }
178
+ } } else {?>
179
+
180
+ <div style="padding: 10px;background-color: lightgrey; margin-bottom: 10px;"><?php echo Mage::helper('beezup')->__('Order is syncronizing, please resync within a few mins to get updated info');?></div>
181
+
182
+ <?php } ?>
183
+ </div>
184
+
185
+ <button class="button" style="float:right;" onclick="resync();"><?php echo Mage::helper('beezup')->__('Resync Order');?></button>
186
+ <div id="ajax-loader" style="display:none;float:right;"><img src="<?php echo $base_url."/beezup/omstatus/loader";?>" /></div>
187
+ <br>
188
+ <div id="statusLoad" style="margin-top:15px;">
189
+ </div>
190
+
191
+
192
+
193
+ </div>
194
+
195
+ </div>
196
+
197
+
198
+ <script>
199
+ var ajax = {};
200
+ ajax.x = function() {
201
+ if (typeof XMLHttpRequest !== 'undefined') {
202
+ return new XMLHttpRequest();
203
+ }
204
+ var versions = [
205
+ "MSXML2.XmlHttp.6.0",
206
+ "MSXML2.XmlHttp.5.0",
207
+ "MSXML2.XmlHttp.4.0",
208
+ "MSXML2.XmlHttp.3.0",
209
+ "MSXML2.XmlHttp.2.0",
210
+ "Microsoft.XmlHttp"
211
+ ];
212
+
213
+ var xhr;
214
+ for(var i = 0; i < versions.length; i++) {
215
+ try {
216
+ xhr = new ActiveXObject(versions[i]);
217
+ break;
218
+ } catch (e) {
219
+ }
220
+ }
221
+ return xhr;
222
+ };
223
+
224
+ ajax.send = function(url, callback, method, data, sync) {
225
+ var x = ajax.x();
226
+ x.open(method, url, sync);
227
+ x.onreadystatechange = function() {
228
+ if (x.readyState == 4) {
229
+ callback(x.responseText)
230
+ }
231
+ };
232
+ if (method == 'POST') {
233
+ x.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
234
+ }
235
+ x.send(data)
236
+ };
237
+
238
+ ajax.get = function(url, data, callback, sync) {
239
+ var query = [];
240
+ for (var key in data) {
241
+ query.push(encodeURIComponent(key) + '=' + encodeURIComponent(data[key]));
242
+ }
243
+ ajax.send(url + (query.length ? '?' + query.join('&') : ''), callback, 'GET', null, sync)
244
+ };
245
+
246
+ ajax.post = function(url, data, callback, sync) {
247
+ var query = [];
248
+ for (var key in data) {
249
+ query.push(encodeURIComponent(key) + '=' + encodeURIComponent(data[key]));
250
+ }
251
+ ajax.send(url, callback, 'POST', query.join('&'), sync)
252
+ };
253
+
254
+
255
+
256
+ function resync() {
257
  document.getElementById("ajax-loader").style.display="block";
258
 
259
+ setTimeout(function () {
260
+ ajax.get('<?php echo $base_url."beezup/omstatus/resync";?>', {order_id : <?php echo $order->getId();?>, uid : '<?php echo $userid;?>', token : '<?php echo $usertoken;?>'}, function(response) {
261
+ document.getElementById("msgAlert").innerHTML = '';
262
+ document.getElementById("msgAlert").style.display = "block";
263
+
264
  document.getElementById("ajax-loader").style.display="none";
265
+ if(response == 1) {
266
  document.getElementById("msgAlert").innerHTML = '<?php echo Mage::helper('beezup')->__("Updated Order Ok page will refresh in 2 secc");?>';
267
+ document.getElementById("msgAlert").style.backgroundColor = "green";
268
+
269
  setTimeout(function () { window.location='window.location.href'; } , 2000);
270
+ } else if(response == 2) {
271
+ document.getElementById("msgAlert").innerHTML = '<?php echo Mage::helper('beezup')->__('Order has been refreshed with no change');?>';
272
+ document.getElementById("msgAlert").style.backgroundColor = "orange";
273
+
274
+ } else {
275
+ document.getElementById("msgAlert").innerHTML = '<?php echo Mage::helper('beezup')->__("Order is syncronizing, please resync within a few mins to get updated info");?>';
276
+ document.getElementById("msgAlert").style.backgroundColor = "orange";
277
+
278
+
279
+ }
280
+
281
+ });
282
+
283
+
284
+ }, 1000);
285
+ }
286
+ function overlay(action) {
287
+ var el = document.getElementById("overlay_"+action);
288
+ el.style.visibility = (el.style.visibility == "visible") ? "hidden" : "visible";
289
+ var fondo = document.getElementById("fondo");
290
+ fondo.style.visibility = (fondo.style.visibility == "visible") ? "hidden" : "visible";
291
+ }
292
+
293
+
294
+ function updateOrder(action) {
295
+ var form = document.getElementById('Updateform_'+action);
296
+ var data = serialize(form);
297
+ var btnSubmit = document.getElementById("submitBtn-"+action);
298
+ var alert = document.getElementById("msgAlert");
299
+ var el = document.getElementById("overlay_"+action);
300
+ var fondo = document.getElementById("fondo");
301
+ var acciones = document.getElementById("acciones");
302
+ btnSubmit.innerHTML = "<img src='<?php echo $base_url."/beezup/omstatus/loader";?>' />";
303
+ ajax.get('<?php echo $base_url."beezup/omstatus/update?"?>'+data+"&adminUser=<?php echo $username;?>&order_id=<?php echo $order->getId();?>&uid=<?php echo $userid;?>&token=<?php echo $usertoken;?>&action_id="+action, {}, function(response) {
304
+
305
+ if (response.indexOf("SUCCESS") !=-1) {
306
+ alert.style.backgroundColor = "green";
307
+
308
+ } else {
309
+ alert.style.backgroundColor = "red";
310
+
311
+
312
+ }
313
+
314
  alert.innerHTML = response;
315
  alert.style.display="block";
316
  btnSubmit.innerHTML = "";
317
+ fondo.style.visibility = (fondo.style.visibility == "visible") ? "hidden" : "visible";
318
+ el.style.visibility = (el.style.visibility == "visible") ? "hidden" : "visible";
319
+ acciones.innerHTML = "";
320
+ setTimeout(function () {
321
+ resync();
322
+ }, 2000);
323
+ });
324
+
325
+
326
+ console.log(data);
327
+ }
328
+
329
+
330
+
331
+
332
+ function serialize(form) {
333
+ var field, s = [];
334
+ if (typeof form == 'object' && form.nodeName == "FORM") {
335
+ var len = form.elements.length;
336
+ for (i=0; i<len; i++) {
337
+ field = form.elements[i];
338
+ if (field.name && !field.disabled && field.type != 'file' && field.type != 'reset' && field.type != 'submit' && field.type != 'button') {
339
+ if (field.type == 'select-multiple') {
340
+ for (j=form.elements[i].options.length-1; j>=0; j--) {
341
+ if(field.options[j].selected)
342
+ s[s.length] = encodeURIComponent(field.name) + "=" + encodeURIComponent(field.options[j].value);
343
+ }
344
+ } else if ((field.type != 'checkbox' && field.type != 'radio') || field.checked) {
345
+ s[s.length] = encodeURIComponent(field.name) + "=" + encodeURIComponent(field.value);
346
+ }
347
+ }
348
+ }
349
+ }
350
+ return s.join('&').replace(/%20/g, '+');
351
+ }
352
+ </script>
353
+
354
+ <?php
355
+ } ?>
app/locale/en_US/BeezUp.csv CHANGED
@@ -107,3 +107,18 @@ parent_id,parent_id
107
  parent_or_child,parent_or_child
108
  url_image,url_image
109
  variation-theme,variation-theme
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
107
  parent_or_child,parent_or_child
108
  url_image,url_image
109
  variation-theme,variation-theme
110
+ Shipping cost - Carrier,Shipping cost - Carrier
111
+ Beware this option might make your feed take longer to load,Beware this option might make your feed take longer to load
112
+ Default Shipping Carrier,Default Shipping Carrier
113
+ Used if option 'Shipping cost - Carrier' is enabled, Used if option 'Shipping cost - Carrier' is enabled
114
+ Default Country,Default Country
115
+ Enable Html in descriptions,Enable Html in descriptions
116
+ Create customer for each order,Create customer for each order
117
+ Synchronize a specific order,Synchronize a specific order
118
+ Separated data,Separated data
119
+ go.beezup.com order link,go.beezup.com order link
120
+ Account ID,Account ID
121
+ Marketplace ID,Marketplace ID
122
+ Order ID,Order ID
123
+ Get Order,Get Order
124
+ If you enable this option, customers will be created in Magento for each marketplace imported order,If you enable this option, customers will be created in Magento for each marketplace imported order
app/locale/fr_FR/BeezUp.csv CHANGED
@@ -103,7 +103,7 @@ Product Price Excl. Tax or Incl. Tax in catalog,Prix produits saisis en HT ou TT
103
  Protects the flow by a unique key (Eg: 85ds6f7): www.yoursite.com/beezup/catalog/xml/key/85ds6f7/,"Prot&eacute;ge le flux par une cl&eacute; unique (Ex : 85ds6f7) : www.votresite.com/beezup/catalog/xml/key/85ds6f7/"
104
  Sales,Ventes
105
  Select Value...,"S&eacute;lectionner une valeur..."
106
- Shipping (Incl. Tax),Frais de port (TTC)
107
  Short Description,Description courte
108
  Special Fee,Co�ts de gestion
109
  Specific Attributes,"Attributs sp&eacute;cifiques"
@@ -144,6 +144,23 @@ Resync Order, Resynchroniser cette commande
144
  Updated Order Ok - page will refresh in 2 sec,Commande mise &agrave; jour avec succ�s - rafraichissement de la page sous 2 sec
145
  Order has been refreshed with no change,Commande mise &agrave; jour sans changement
146
  Order is syncronizing, please resync within a few mins to get updated info,Commande en cours de synchro - merci d'attendre et de resynchroniser manuellement d'ici quelques minutes.
147
- Refresh time of the cache export file in hours,Dur&egrave;e de vie du cache en heures
148
- Category Logic,Logique de cat&egrave;gories
149
- Choose option 1 if don't know what this is,Choisissez l'option 1, si vous ne savez pas ce dont il s'agit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
103
  Protects the flow by a unique key (Eg: 85ds6f7): www.yoursite.com/beezup/catalog/xml/key/85ds6f7/,"Prot&eacute;ge le flux par une cl&eacute; unique (Ex : 85ds6f7) : www.votresite.com/beezup/catalog/xml/key/85ds6f7/"
104
  Sales,Ventes
105
  Select Value...,"S&eacute;lectionner une valeur..."
106
+ Default Shipping Cost (with tax),Frais de port par d&eacute;faut (TTC)
107
  Short Description,Description courte
108
  Special Fee,Co�ts de gestion
109
  Specific Attributes,"Attributs sp&eacute;cifiques"
144
  Updated Order Ok - page will refresh in 2 sec,Commande mise &agrave; jour avec succ�s - rafraichissement de la page sous 2 sec
145
  Order has been refreshed with no change,Commande mise &agrave; jour sans changement
146
  Order is syncronizing, please resync within a few mins to get updated info,Commande en cours de synchro - merci d'attendre et de resynchroniser manuellement d'ici quelques minutes.
147
+ Refresh time of the cache export file in hours,Dur&eacute;e de vie du cache en heures
148
+ Category Logic,Logique de cat&eacute;gories
149
+ Choose option 1 if don't know what this is,Choisissez l'option 1, si vous ne savez pas ce dont il s'agit
150
+ Shipping cost - Carrier,Frais de port - Transporteur
151
+ Beware this option might make your feed take longer to load,Attention cette option peut rendre votre flux plus long &agrave; charger
152
+ Default Shipping Carrier,Transporteur par d&eacute;faut
153
+ Used if option "Shipping cost - Carrier" is enabled, Utilis&eacute; si option &quot;Frais de port - Transporteur&quot; actif
154
+ Default Country,Pays par d&eacute;faut
155
+ Enable Html in descriptions,Activer l'HTML dans les descriptions
156
+ Create customer for each order,Cr&eacute;ation du client &agrave; chaque commande
157
+ Synchronize a specific order,Synchroniser une commande pr&eacute;cise
158
+ Separated data,Infos s&eacute;par&eacute;es
159
+ go.beezup.com order link,Lien commande go.beezup.com
160
+ Account ID,Id compte
161
+ Marketplace ID,Id Place de march&eacute;
162
+ Order ID,Id de la commande
163
+ Get Order,R&eacute;cup&eacute;rer commande
164
+ If you enable this option customers will be created in Magento for each marketplace imported order,Si cette option est active les clients sont cr&eacute;&eacute;s dans Magento pour chaque commande place de march&eacute; import&eacute;e
165
+ Shipping Cost (if no value found), Frais de port (si aucune valeur trouv&eacute;e)
166
+ Choice of exported products,Choix des produits export&eacute;s
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.5.0</version>
5
  <stability>stable</stability>
6
  <license uri="http://opensource.org/licenses/osl-3.0.php">Open Software License</license>
7
  <channel>community</channel>
@@ -42,11 +42,16 @@ 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; Performance improvements on "Configurable" feed</notes>
 
 
 
 
 
46
  <authors><author><name>BeezUP</name><user>BeezUP</user><email>charles@beezup.com</email></author></authors>
47
- <date>2015-08-18</date>
48
- <time>08:38:10</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="7cc12a09107b07ee7a66bcd9678283b5"/><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="0e77729f1865d123eda43b77101e63fc"/></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="56f4877f21e94d046f9d3eac3ae1b254"/><file name="Manualcron.php" hash="cbac01f15d256a43f0388f58449bffd0"/><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="da6422d294cb047dd81982ebb65f5aa8"/><file name="Order.php" hash="cf2b26596073c5e959939ce5a869e386"/><file name="Tracking.php" hash="e6dcd6b89e782b2eb6cb83abfb1b7f56"/><file name="Xml.php" hash="586c74c8d0137ef386842fc6a3519422"/></dir><dir name="Helper"><file name="Data.php" hash="1cbbd163fea65ae82224a11c95d90e03"/></dir><dir name="Model"><file name="Flatrate.php" hash="27d078203781d9b923605f685bfe5c25"/><file name="Observer.php" hash="3bcb925df1965ef23ef1fb08ab64de08"/><file name="Products.php" hash="0bf2dd5752a720983bca0770a044cac7"/><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="5c5ca91b68bebe3a0354a9b22f5f44f3"/><file name="Time.php" hash="a70e4d748a9b300ec7b718168fa4d5f8"/><file name="Token.php" hash="60247c8b4d5889433ae1f92e998cc889"/></dir><dir name="Source"><file name="Attributes.php" hash="878b6ed9c50afee368f2688a1ff56f5e"/><file name="Availableproducts.php" hash="d9d4b3705f5fbd98efbae0289a1b6d6d"/><file name="Cache.php" hash="0ca6ccc2fed56e2c602d76880d062053"/><file name="Categories.php" hash="c4e9f0a54f1d9c688543f26f02f99142"/><file name="Debug.php" hash="6538ebc0cd0d61c124e5adc806e71aff"/><file name="Description.php" hash="e4f80883f8a2deab48af9625582edfb6"/><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"/></dir></dir></dir></dir><dir name="controllers"><file name="CacheController.php" hash="512cc26abd39d556104d5e69c0ac8a0d"/><file name="CatalogController.php" hash="b1b170b6dcb9dc3f95dc46dec24a37a7"/><file name="CronController.php" hash="5cc9e5e5eca471d644ef7dee991ce6b9"/><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="9bf057475afdb711abb40abaf1c298e5"/><file name="system.xml" hash="6792ec35e5f32ebbd4baa3df714f0966"/></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="88dc1c91a4ccc1bb94d7ecb8e40531be"/><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="87ae70f6b82e49e45bc12a8155dec629"/></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="e035e76fe92b063d6cecc9fa2872cfab"/></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="9fcbe224014a0fb34a0e6120010f8d47"/></dir><dir name="en_US"><file name="BeezUp.csv" hash="27b63e33bbdf8b1edfd0ec63c55b18cb"/></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="9f30419a17d2aac252f5c49d8e9b7c46"/></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.0</version>
5
  <stability>stable</stability>
6
  <license uri="http://opensource.org/licenses/osl-3.0.php">Open Software License</license>
7
  <channel>community</channel>
42
  &#xD;
43
  &lt;p&gt;By BeezUP &amp; Magentix&lt;/p&gt;</description>
44
  <notes>New features :&#xD;
45
+ &gt; Advanced shipping prices&#xD;
46
+ &gt; Description HTML Support&#xD;
47
+ &gt; New products filtering options&#xD;
48
+ &gt; Possibility to retrieve one specific order&#xD;
49
+ &gt; Shipment details prefilling&#xD;
50
+ &gt; Customer creation option</notes>
51
  <authors><author><name>BeezUP</name><user>BeezUP</user><email>charles@beezup.com</email></author></authors>
52
+ <date>2016-03-18</date>
53
+ <time>16:33:46</time>
54
+ <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="3f8e84a9035853447b79d25a6c263dd1"/><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="a12f1faa15da11fcc5a1abaa0bbd0480"/><file name="Order.php" hash="af2c931132c5b37c97f83713e566d2bf"/><file name="Tracking.php" hash="e6dcd6b89e782b2eb6cb83abfb1b7f56"/><file name="Xml.php" hash="43d6ac203df42e682d2e75cd5f9c82aa"/></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="862b463a3cff9ee3d74423637f4d8c45"/><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="5c5ca91b68bebe3a0354a9b22f5f44f3"/><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="f07f18bf6b072c4ebc54f40dfd1594f6"/><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="d4cc8ed53f42d01fbfec1b3710e1b16c"/><file name="system.xml" hash="ecc0c1e3ec8d4b2d967f9d998e1f53da"/></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="log"><file name="log.txt" hash="b395b6e8e6369519056494878753123c"/><file name="log2.txt" hash="9d32514109ef640516489220c1aada45"/></dir><dir name="sql"><dir name="beezup_setup"><file name="mysql4-install-4.0.0.php" hash="e035e76fe92b063d6cecc9fa2872cfab"/><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>
55
  <compatible/>
56
  <dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php></required></dependencies>
57
  </package>