Version Notes
New features :
- Fixed bugs on Autoship carrier mapping
Download this release
Release Info
Developer | BeezUP |
Extension | BeezUP_Module_feed_and_tracker |
Version | 4.7.4 |
Comparing to | |
See all releases |
Code changes from version 4.7.3 to 4.7.4
- app/code/community/BeezUp/Block/Adminhtml/System/Config/Autoship.php +12 -4
- app/code/community/BeezUp/Block/Order_old.php +1553 -0
- app/code/community/BeezUp/Block/Order_original.php +1382 -0
- app/code/community/BeezUp/Model/Flatrate.php +91 -0
- app/code/community/BeezUp/Model/Observer.php +54 -43
- app/code/community/BeezUp/Model/System/Config/Backend/Autoship.php +5 -1
- app/code/community/BeezUp/etc/config.xml +1 -1
- app/code/community/BeezUp/etc/system.xml +3 -3
- app/code/community/BeezUp/lib/BeezupOMStatus.php +50 -36
- app/code/community/BeezUp/lib/debug.txt +0 -0
- package.xml +5 -5
app/code/community/BeezUp/Block/Adminhtml/System/Config/Autoship.php
CHANGED
@@ -36,10 +36,14 @@ class Beezup_Block_Adminhtml_System_Config_Autoship extends Mage_Adminhtml_Block
|
|
36 |
foreach($marketplaces as $key => $marketplace) {
|
37 |
$tmpval = false;
|
38 |
|
|
|
|
|
|
|
|
|
39 |
$html .= "<table class='data' style='margin-top:0px;margin-bottom:10px;'>";
|
40 |
$html .= "<tbody>
|
41 |
<tr class='headings'>
|
42 |
-
<th><span class='nobr'>".$
|
43 |
<th><span class='nobr'>Magento Carriers</span><button style='float: right;
|
44 |
margin-top: -20px;' class='scalable add 'onclick='addMarketCarrierMap(\"".$key."\")' type='button'>+</button></th>
|
45 |
</tr>
|
@@ -51,7 +55,7 @@ margin-top: -20px;' class='scalable add 'onclick='addMarketCarrierMap(\"".$key."
|
|
51 |
//$marketplace = array_unique($marketplace);
|
52 |
foreach($marketplace as $values) {
|
53 |
|
54 |
-
$html .= "<option value='".$key."|".$values['name']."|".$values['code']."'>".$values['name']."</option>";
|
55 |
}
|
56 |
$html .= "</select></td>";
|
57 |
|
@@ -68,7 +72,11 @@ top: 2px;' class='scalable add 'onclick='removeMarketTr(this.parentNode)' type='
|
|
68 |
|
69 |
|
70 |
|
71 |
-
|
|
|
|
|
|
|
|
|
72 |
|
73 |
$html .= "<tr>";
|
74 |
$html .= "<td><select name='groups[marketplace][fields][autoship_order_map][value][".$key."][beezup][]'>";
|
@@ -78,7 +86,7 @@ top: 2px;' class='scalable add 'onclick='removeMarketTr(this.parentNode)' type='
|
|
78 |
if($ship['beezup_carrierCode'] == $values['code']) {
|
79 |
$selected = "selected";
|
80 |
}
|
81 |
-
$html .= "<option ".$selected." value='".$key."|".$values['name']."|".$values['code']."'>".$values['name']."</option>";
|
82 |
}
|
83 |
$html .= "</select></td>";
|
84 |
|
36 |
foreach($marketplaces as $key => $marketplace) {
|
37 |
$tmpval = false;
|
38 |
|
39 |
+
$key = explode("-", $key);
|
40 |
+
$title = $key[1];
|
41 |
+
$key = $key[0];
|
42 |
+
|
43 |
$html .= "<table class='data' style='margin-top:0px;margin-bottom:10px;'>";
|
44 |
$html .= "<tbody>
|
45 |
<tr class='headings'>
|
46 |
+
<th><span class='nobr'>".$title." Carriers</span></th>
|
47 |
<th><span class='nobr'>Magento Carriers</span><button style='float: right;
|
48 |
margin-top: -20px;' class='scalable add 'onclick='addMarketCarrierMap(\"".$key."\")' type='button'>+</button></th>
|
49 |
</tr>
|
55 |
//$marketplace = array_unique($marketplace);
|
56 |
foreach($marketplace as $values) {
|
57 |
|
58 |
+
$html .= "<option value='".$key."|".$values['name']."|".$values['code']."|".$values['marketplace_business_code']."'>".$values['name']."</option>";
|
59 |
}
|
60 |
$html .= "</select></td>";
|
61 |
|
72 |
|
73 |
|
74 |
|
75 |
+
$localizador = $key;
|
76 |
+
if($key == "Mirakl") {
|
77 |
+
$localizador = $title;
|
78 |
+
}
|
79 |
+
foreach($autoship[$localizador] as $ship) {
|
80 |
|
81 |
$html .= "<tr>";
|
82 |
$html .= "<td><select name='groups[marketplace][fields][autoship_order_map][value][".$key."][beezup][]'>";
|
86 |
if($ship['beezup_carrierCode'] == $values['code']) {
|
87 |
$selected = "selected";
|
88 |
}
|
89 |
+
$html .= "<option ".$selected." value='".$key."|".$values['name']."|".$values['code']."|".$values['marketplace_business_code']."'>".$values['name']."</option>";
|
90 |
}
|
91 |
$html .= "</select></td>";
|
92 |
|
app/code/community/BeezUp/Block/Order_old.php
ADDED
@@ -0,0 +1,1553 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
require_once Mage::getModuleDir('', 'BeezUp') . DS . 'lib' . DS ."KLogger.php";
|
3 |
+
require_once Mage::getModuleDir('', 'BeezUp') . DS . 'lib' . DS ."bootstrap.php";
|
4 |
+
require_once Mage::getModuleDir('', 'BeezUp') . DS . 'lib' . DS ."BeezupRepository.php";
|
5 |
+
require_once Mage::getModuleDir('', 'BeezUp') . DS . 'lib' . DS ."BeezupMageOrders.php";
|
6 |
+
|
7 |
+
class Beezup_Block_Order extends Mage_core_block_text {
|
8 |
+
|
9 |
+
protected $repository = null;
|
10 |
+
protected $oOrderService;
|
11 |
+
public $log = null;
|
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 |
+
|
22 |
+
private function makeDir() {
|
23 |
+
|
24 |
+
if (file_exists(Mage::getBaseDir('base').'/beezup/tmp')) { return true;}
|
25 |
+
|
26 |
+
if (!mkdir(Mage::getBaseDir('base').'/beezup/tmp', 0777, true))
|
27 |
+
{
|
28 |
+
echo "[ERROR] : Seems we can't create 'beezup' directory inside your root directory."."<br/>"
|
29 |
+
."You can try one of these solutions :"."<br/>"
|
30 |
+
."1 - Create by yourself the beezup/tmp inside your root directory with 777 permissions"."<br/>"
|
31 |
+
."2 - Change the permissions on your root directory (777)"."<br/>"
|
32 |
+
."3 - Change the 'cache delay' option to 'None' inside beezup plugin settings"."<br/>";
|
33 |
+
return false;
|
34 |
+
}
|
35 |
+
return true;
|
36 |
+
|
37 |
+
}
|
38 |
+
public function createOrderFromLink($account_id, $marketplace_code, $beezup_order_id) {
|
39 |
+
$this->makeDir();
|
40 |
+
$logDir = Mage::getBaseDir('base').'/beezup/';
|
41 |
+
if(file_exists($logDir."log2.txt")) {
|
42 |
+
if(filesize($logDir."/log2.txt") >=3000000) {
|
43 |
+
unlink($logDir."log2.txt");
|
44 |
+
}
|
45 |
+
}
|
46 |
+
$sync_end_date = new DateTime ( 'now', new DateTimeZone ( 'UTC' ));
|
47 |
+
$helper = Mage::helper('beezup');
|
48 |
+
$sync_status = $helper->getConfig('beezup/marketplace/sync_status');
|
49 |
+
$debug_mode = $helper->getConfig('beezup/marketplace/debug_mode');
|
50 |
+
$create_customer = $helper->getConfig("beezup/marketplace/create_customers");
|
51 |
+
if($create_customer == 0) {
|
52 |
+
$this->blnCreateCustomer = true;
|
53 |
+
}
|
54 |
+
|
55 |
+
if($debug_mode==1) {
|
56 |
+
$this->debug = true;
|
57 |
+
}
|
58 |
+
if($sync_status!==1) {
|
59 |
+
$configModel = Mage::getModel('core/config');
|
60 |
+
$configModel->saveConfig('beezup/marketplace/sync_status',1);
|
61 |
+
|
62 |
+
|
63 |
+
unlink($logDir."log.txt");
|
64 |
+
$this->log = new KLogger ( $logDir."log.txt" , KLogger::DEBUG );
|
65 |
+
$this->log2 = new KLogger ( $logDir."log2.txt" , KLogger::DEBUG );
|
66 |
+
$this->debugLog("Initializing OM Importation");
|
67 |
+
$shiiping_disabled = Mage::getStoreConfig('carriers/flatrate/active');
|
68 |
+
|
69 |
+
$this->account_id = $account_id;
|
70 |
+
$this->marketplace_code = $marketplace_code;
|
71 |
+
$this->beezup_order_id = $beezup_order_id;
|
72 |
+
$orderResponse = $this->getBeezupOrder();
|
73 |
+
if($orderResponse) {
|
74 |
+
|
75 |
+
if($shiiping_disabled == 0) {
|
76 |
+
Mage::getConfig()
|
77 |
+
->saveConfig('carriers/flatrate/active', 1)
|
78 |
+
->cleanCache();
|
79 |
+
Mage::app()->reinitStores();
|
80 |
+
}
|
81 |
+
$this->createOrder($orderResponse);
|
82 |
+
//OCI sinon le shiiping flate reste actif ...
|
83 |
+
//if($shiiping_disabled == 1) {
|
84 |
+
if($shiiping_disabled == 1) {
|
85 |
+
Mage::getConfig()
|
86 |
+
->saveConfig('carriers/flatrate/active', 0)
|
87 |
+
->cleanCache();
|
88 |
+
Mage::app()->reinitStores();
|
89 |
+
}
|
90 |
+
$configModel->saveConfig('beezup/marketplace/sync_status',0);
|
91 |
+
if($this->mage_order_id) {
|
92 |
+
echo "<script>window.location='".Mage::helper('adminhtml')->getUrl("adminhtml/sales_order/view", array('order_id'=> $this->mage_order_id))."';</script>";
|
93 |
+
}
|
94 |
+
// die("Order Importation finalized");
|
95 |
+
|
96 |
+
}
|
97 |
+
|
98 |
+
}
|
99 |
+
$configModel->saveConfig('beezup/marketplace/sync_status',0);
|
100 |
+
//die("Error, Order data incorrect");
|
101 |
+
echo $this->_showLog();
|
102 |
+
}
|
103 |
+
|
104 |
+
public function _showLog() {
|
105 |
+
$logDir = Mage::getBaseDir('base').'/beezup/';
|
106 |
+
// $log1 = file_get_contents();
|
107 |
+
$ret = array();
|
108 |
+
if (file_exists($logDir."/log.txt")) {
|
109 |
+
$f = fopen($logDir."/log.txt", 'r');
|
110 |
+
|
111 |
+
if ($f) {
|
112 |
+
while (!feof($f)) {
|
113 |
+
$ret[] = fgetcsv($f, 0, '|');
|
114 |
+
}
|
115 |
+
fclose($f);
|
116 |
+
}
|
117 |
+
}
|
118 |
+
array_slice(array_reverse($ret), 1, 10);
|
119 |
+
|
120 |
+
return $this->_getTable($ret);
|
121 |
+
|
122 |
+
}
|
123 |
+
|
124 |
+
|
125 |
+
public function _getTable($data) {
|
126 |
+
$url = Mage::getBaseUrl( Mage_Core_Model_Store::URL_TYPE_WEB, true );
|
127 |
+
$html = "<td></td><td></td><tr></tr></tbody></table>
|
128 |
+
|
129 |
+
<div class='grid' style=' height: 600px;overflow-y: scroll;padding: 16px;border: 3px solid #e6e6e6;' id='marketPlaceLogBlock'>";
|
130 |
+
$html .= '<p>'. Mage::helper('beezup')->__('For full logs see here:').' <a href="'.$url .'beezup/log/load" target="_blank">'.$url .'beezup/log/load</a></p>';
|
131 |
+
$html .= "<table class='data' style='margin-top:0px;width:100%;'>";
|
132 |
+
$html .= "<tr class='headings'>";
|
133 |
+
$html .= '<th><span class="nobr">Time</span></th>';
|
134 |
+
$html .= '<th><span class="nobr">Type</span></th>';
|
135 |
+
$html .= '<th><span class="nobr">Order Id</span></th>';
|
136 |
+
$html .= '<th><span class="nobr">Message</span></th>';
|
137 |
+
$html .= "</tr>";
|
138 |
+
$html .= "<tbody>";
|
139 |
+
foreach($data as $d) {
|
140 |
+
$background = " background: rgb(240, 184, 184)";
|
141 |
+
if($d[1] == " INFO " ) {
|
142 |
+
$background = " background: rgb(210, 227, 253)";
|
143 |
+
}
|
144 |
+
$orderId = (isset($d[3])) ? $d[2] : "";
|
145 |
+
$message = (isset($d[3])) ? $d[3] : $d[2];
|
146 |
+
$html .= "<tr class='even pointer' style='".$background."'>";
|
147 |
+
$html .= "<td>".$d[0]."</td>";
|
148 |
+
$html .= "<td>".$d[1]."</td>";
|
149 |
+
$html .= "<td>".$orderId."</td>";
|
150 |
+
$html .= "<td>".$message."</td>";
|
151 |
+
$html .= "</tr>";
|
152 |
+
|
153 |
+
}
|
154 |
+
|
155 |
+
$html .= "<tbody>";
|
156 |
+
$html .= '</table>';
|
157 |
+
$html .= "</div>";
|
158 |
+
|
159 |
+
return $html;
|
160 |
+
}
|
161 |
+
|
162 |
+
|
163 |
+
|
164 |
+
public function executeCron() {
|
165 |
+
|
166 |
+
$this->makeDir();
|
167 |
+
|
168 |
+
set_time_limit(0);
|
169 |
+
$logDir = Mage::getBaseDir('base').'/beezup/';
|
170 |
+
if(file_exists($logDir."log2.txt")) {
|
171 |
+
if(filesize($logDir."/log2.txt") >=3000000) {
|
172 |
+
unlink($logDir."log2.txt");
|
173 |
+
}
|
174 |
+
}
|
175 |
+
|
176 |
+
$sync_end_date = new DateTime ( 'now', new DateTimeZone ( 'UTC' ));
|
177 |
+
$helper = Mage::helper('beezup');
|
178 |
+
$sync_status = $helper->getConfig('beezup/marketplace/sync_status');
|
179 |
+
$debug_mode = $helper->getConfig('beezup/marketplace/debug_mode');
|
180 |
+
$create_customer = $helper->getConfig("beezup/marketplace/create_customers");
|
181 |
+
if($create_customer == 0) {
|
182 |
+
$this->blnCreateCustomer = true;
|
183 |
+
}
|
184 |
+
|
185 |
+
if($debug_mode==1) {
|
186 |
+
$this->debug = true;
|
187 |
+
}
|
188 |
+
|
189 |
+
if($sync_status!==1) {
|
190 |
+
$configModel = Mage::getModel('core/config');
|
191 |
+
$configModel->saveConfig('beezup/marketplace/sync_status',1);
|
192 |
+
|
193 |
+
|
194 |
+
|
195 |
+
unlink($logDir."log.txt");
|
196 |
+
$this->log = new KLogger ( $logDir."log.txt" , KLogger::DEBUG );
|
197 |
+
$this->log2 = new KLogger ( $logDir."log2.txt" , KLogger::DEBUG );
|
198 |
+
|
199 |
+
|
200 |
+
$shiiping_disabled = Mage::getStoreConfig('carriers/flatrate/active');
|
201 |
+
$this->debugLog("## flatrate active yes or no : ".$shiiping_disabled."##");
|
202 |
+
|
203 |
+
|
204 |
+
if($shiiping_disabled == 0) {
|
205 |
+
Mage::getConfig()
|
206 |
+
->saveConfig('carriers/flatrate/active', 1)
|
207 |
+
->cleanCache();
|
208 |
+
Mage::app()->reinitStores();
|
209 |
+
|
210 |
+
}
|
211 |
+
|
212 |
+
|
213 |
+
$this->getOrderList();
|
214 |
+
|
215 |
+
//OCI shiiping_disabled 1 et pas 0...
|
216 |
+
|
217 |
+
if($shiiping_disabled == 1) {
|
218 |
+
Mage::getConfig()
|
219 |
+
->saveConfig('carriers/flatrate/active', 0)
|
220 |
+
->cleanCache();
|
221 |
+
Mage::app()->reinitStores();
|
222 |
+
|
223 |
+
}
|
224 |
+
$this->repository->updateLastSynchronizationDate( $sync_end_date);
|
225 |
+
$this->orderid = "";
|
226 |
+
$this->debugLog("OM Importation finalized succesfully");
|
227 |
+
$configModel->saveConfig('beezup/marketplace/sync_status',0);
|
228 |
+
echo "OM Importation finalized succesfully";
|
229 |
+
|
230 |
+
} else {
|
231 |
+
|
232 |
+
echo "Order Importation is already being executed";
|
233 |
+
}
|
234 |
+
|
235 |
+
}
|
236 |
+
|
237 |
+
|
238 |
+
public function getLog() {
|
239 |
+
$logDir = Mage::getBaseDir('base').'/beezup/';
|
240 |
+
$log1 = file_get_contents($logDir."/log2.txt");
|
241 |
+
|
242 |
+
echo "<pre>";
|
243 |
+
print_r($log1);
|
244 |
+
echo "</pre>";
|
245 |
+
|
246 |
+
}
|
247 |
+
public function getBeezupOrder() {
|
248 |
+
|
249 |
+
$oOrderIdentifier = $this->getBeezupOrderId();
|
250 |
+
$oBeezupOMOrderResponse = $this->getOrderService()->getOrder($oOrderIdentifier);
|
251 |
+
if ($oBeezupOMOrderResponse && $oBeezupOMOrderResponse->getResult()){
|
252 |
+
return $oBeezupOMOrderResponse;
|
253 |
+
}
|
254 |
+
|
255 |
+
|
256 |
+
return false;
|
257 |
+
}
|
258 |
+
|
259 |
+
public function getBeezupOrderId(){
|
260 |
+
$oIdentifier = new BeezupOMOrderIdentifier();
|
261 |
+
$oIdentifier
|
262 |
+
->setAccountId($this->account_id)
|
263 |
+
->setMarketplaceTechnicalCode($this->marketplace_code)
|
264 |
+
->setBeezupOrderUUID($this->beezup_order_id);
|
265 |
+
return $oIdentifier;
|
266 |
+
}
|
267 |
+
|
268 |
+
|
269 |
+
public function createOrder($oBeezupOrderResponse) {
|
270 |
+
|
271 |
+
$etag = $oBeezupOrderResponse->getETag();
|
272 |
+
$final_order = $oBeezupOrderResponse->getResult();
|
273 |
+
|
274 |
+
$orderid = $final_order->getOrderMarketPlaceOrderId();
|
275 |
+
$this->orderid = $orderid;
|
276 |
+
//customer Info
|
277 |
+
$order_address = $final_order->getOrderBuyerAddressCity();
|
278 |
+
$order_country = $final_order->getOrderBuyerAddressCountryName();
|
279 |
+
$order_country_iso = $final_order->getOrderBuyerAddressCountryIsoCodeAlpha2();
|
280 |
+
$order_address = $this->getBeezupBuyerAddress($final_order);
|
281 |
+
$order_postalCode = $final_order->getOrderBuyerAddressPostalCode();
|
282 |
+
$order_customer = $final_order->getOrderBuyerName();
|
283 |
+
$order_customer_email = $final_order->getOrderBuyerEmail();
|
284 |
+
$order_customer_phone = $final_order->getOrderBuyerPhone();
|
285 |
+
$order_customer_mobile = $final_order->getOrderBuyerMobilePhone();
|
286 |
+
$order_comment = $final_order->getOrderComment();
|
287 |
+
$order_company = $final_order->getOrderBuyerCompanyName();
|
288 |
+
$order_city = $final_order->getOrderBuyerAddressCity();
|
289 |
+
$order_region = $final_order->getOrderBuyerStateOrRegion();
|
290 |
+
$order_status = $final_order->getOrderStatusBeezUPOrderStatus();
|
291 |
+
//shipping information
|
292 |
+
$shipping_city = $final_order->getOrderShippingAddressCity();
|
293 |
+
$shipping_country = $final_order->getOrderShippingAddressCountryName();
|
294 |
+
$shipping_country_iso = $final_order->getOrderShippingAddressCountryIsoCodeAlpha2();
|
295 |
+
$shipping_address = $this->getBeezupShippingAddress($final_order);
|
296 |
+
$shipping_name = $final_order->getOrderShippingAddressName();
|
297 |
+
$shipping_postalCode = $final_order->getOrderShippingAddressPostalCode();
|
298 |
+
$shipping_email = $final_order->getOrderShippingEmail();
|
299 |
+
$shipping_phone = $final_order->getOrderShippingPhone();
|
300 |
+
$shipping_method_BEEZUP = $final_order->getOrderShippingMethod();
|
301 |
+
$shipping_mobile = $final_order->getOrderShippingMobilePhone();
|
302 |
+
$shipping_company = $final_order->getOrderShippingCompanyName();
|
303 |
+
$shipping_region = $final_order->getOrderShippingAddressStateOrRegion();
|
304 |
+
$order_currency_code = $final_order->getOrderCurrencyCode();
|
305 |
+
//order Info
|
306 |
+
$order_totalPrice = $final_order->getOrderTotalPrice();
|
307 |
+
$order_shippingPrice = $final_order->getOrderShippingPrice();
|
308 |
+
|
309 |
+
$name_parts = explode(" ", $order_customer);
|
310 |
+
$order_first_name = array_shift( $name_parts);
|
311 |
+
$order_last_name = implode(" ", $name_parts);
|
312 |
+
|
313 |
+
|
314 |
+
$name_parts = explode(" ", $shipping_name);
|
315 |
+
$shipping_first_name = array_shift( $name_parts);
|
316 |
+
$shipping_last_name = implode(" ", $name_parts);
|
317 |
+
|
318 |
+
|
319 |
+
//marketplace information
|
320 |
+
$marketplace_business_code = $final_order->getMarketPlaceBusinessCode();
|
321 |
+
$marketplace = $final_order->getMarketPlaceTechnicalCode();
|
322 |
+
|
323 |
+
//productInfo
|
324 |
+
|
325 |
+
$mage_productIds = $this->prescanOrder($final_order);
|
326 |
+
|
327 |
+
|
328 |
+
|
329 |
+
if(!$this->checkEtagExists($etag)) {
|
330 |
+
if(empty($order_customer_email)) {
|
331 |
+
$order_customer_email = $this->generateEmail($final_order);
|
332 |
+
}
|
333 |
+
elseif(!filter_var($order_customer_email, FILTER_VALIDATE_EMAIL)) {
|
334 |
+
$order_customer_email = $this->generateEmail($final_order);
|
335 |
+
}
|
336 |
+
if($order_country_iso == "FX" || $order_country_iso == "fx") {
|
337 |
+
$order_country_iso = "FR";
|
338 |
+
}
|
339 |
+
if($shipping_country_iso == "FX" || $shipping_country_iso == "fx") {
|
340 |
+
$shipping_country_iso = "FR";
|
341 |
+
}
|
342 |
+
$mage_productIds = $this->prescanOrder($final_order);
|
343 |
+
if($mage_productIds) {
|
344 |
+
|
345 |
+
if ($shipping_last_name=='') $shipping_last_name = $shipping_first_name;
|
346 |
+
|
347 |
+
$order_data = array(
|
348 |
+
"etag" => $etag,
|
349 |
+
"account_id" => $account_id,
|
350 |
+
"order_status" => $order_status,
|
351 |
+
"products" => $mage_productIds['products'],
|
352 |
+
"storeid" => $mage_productIds['store'],
|
353 |
+
"order_currency" => $order_currency_code ,
|
354 |
+
"order_address" => $order_adress,
|
355 |
+
"order_country" => $order_country,
|
356 |
+
"order_country_iso" => $order_country_iso ,
|
357 |
+
"order_address" => $order_address ,
|
358 |
+
"order_postalCode" => $order_postalCode ,
|
359 |
+
"order_customer" => $order_first_name ,
|
360 |
+
"order_lastname" => $order_last_name ,
|
361 |
+
"order_customer_email" => $order_customer_email ,
|
362 |
+
"order_customer_phone" => $this->getPhone($order_customer_phone, $order_customer_mobile) ,
|
363 |
+
"order_comment" => $order_comment ,
|
364 |
+
"order_company" => $order_company ,
|
365 |
+
"shipping_city" => $shipping_city ,
|
366 |
+
"shipping_country" => $shipping_country ,
|
367 |
+
"shipping_country_iso" => $shipping_country_iso ,
|
368 |
+
"shipping_address" => $shipping_address ,
|
369 |
+
"shipping_name" => $shipping_first_name ,
|
370 |
+
"shipping_lastname" => $shipping_last_name ,
|
371 |
+
"shipping_postalCode" => $shipping_postalCode ,
|
372 |
+
"shipping_region" =>$shipping_region,
|
373 |
+
"shipping_email" => $shipping_email ,
|
374 |
+
"shipping_phone" => $this->getPhone($shipping_phone, $shipping_mobile) ,
|
375 |
+
"shipping_company" => $shipping_company ,
|
376 |
+
"order_totalPrice" => $order_totalPrice ,
|
377 |
+
"order_shippingPrice" => $order_shippingPrice ,
|
378 |
+
"order_city" => $order_city,
|
379 |
+
"order_region" => $order_region,
|
380 |
+
"marketplace" => $marketplace,
|
381 |
+
"discounts" => $mage_productIds['discounts'],
|
382 |
+
"marketplace_business_code" => $marketplace_business_code,
|
383 |
+
//ajout OCI pour passer la methode
|
384 |
+
"shipping_method_BEEZUP" => $shipping_method_BEEZUP
|
385 |
+
);
|
386 |
+
// $this->debugLog(printf($order_data));
|
387 |
+
|
388 |
+
|
389 |
+
$this->debugLog("Order data : ");
|
390 |
+
foreach ($order_data as $key => $value){
|
391 |
+
$this->debugLog($key . " : " . $value);
|
392 |
+
}
|
393 |
+
|
394 |
+
|
395 |
+
//check if order exists
|
396 |
+
$Mageorder = $this->loadMageOrder();
|
397 |
+
if ($Mageorder) {
|
398 |
+
//if order exists
|
399 |
+
$this->updateEtag($etag);
|
400 |
+
$this->updateBilling($Mageorder, $order_data);
|
401 |
+
$this->updateBeezupInfoTab($Mageorder, $final_order, $order_data);
|
402 |
+
$this->debugLog("Order Already exists Mage Order ID: " .$Mageorder->getId());
|
403 |
+
$status1 = $Mageorder->getStatusLabel();
|
404 |
+
$status = $this->getStatus($status1);
|
405 |
+
if($status !== $order_status) {
|
406 |
+
//if order exits and status has changed we update order status
|
407 |
+
$this->debugLog("Updating Order Status from: ".$status1." to: ".$order_status );
|
408 |
+
$this->setStatus( $order_status, $Mageorder);
|
409 |
+
}
|
410 |
+
|
411 |
+
$id_order = $Mageorder->getId();
|
412 |
+
$BeezupMageOrder = new BeezupMageOrders($id_order);
|
413 |
+
$BeezupMageOrder->setData(array("shipping" =>(float) $order_data['order_shippingPrice']));
|
414 |
+
$BeezupMageOrder->updateShippingInfo();
|
415 |
+
} else {
|
416 |
+
//if not we create order
|
417 |
+
|
418 |
+
|
419 |
+
$this->debugLog("Generating Order");
|
420 |
+
$this->addOrder($order_data,$final_order);
|
421 |
+
//die();
|
422 |
+
|
423 |
+
}
|
424 |
+
|
425 |
+
|
426 |
+
} else {
|
427 |
+
//order could not be imported
|
428 |
+
|
429 |
+
|
430 |
+
}
|
431 |
+
|
432 |
+
|
433 |
+
} else {
|
434 |
+
//etag has not changed
|
435 |
+
$shiiping_disabled = Mage::getStoreConfig('carriers/flatrate/active');
|
436 |
+
// On remet le Flat à 0 !!!
|
437 |
+
if($shiiping_disabled == 1) {
|
438 |
+
Mage::getConfig()
|
439 |
+
->saveConfig('carriers/flatrate/active', 0)
|
440 |
+
->cleanCache();
|
441 |
+
Mage::app()->reinitStores();
|
442 |
+
|
443 |
+
}
|
444 |
+
|
445 |
+
$this->debugLog("Order Etag has not changed");
|
446 |
+
|
447 |
+
}
|
448 |
+
|
449 |
+
|
450 |
+
|
451 |
+
|
452 |
+
|
453 |
+
}
|
454 |
+
|
455 |
+
|
456 |
+
|
457 |
+
public function generateEmail(BeezupOMOrderResult $oBeezupOrder)
|
458 |
+
{
|
459 |
+
$sRawValue = $oBeezupOrder->getBeezupOrderUUID ();
|
460 |
+
$sFakeDomain = preg_replace ( '/\W/', '', $oBeezupOrder->getMarketPlaceTechnicalCode () ) . '.com';
|
461 |
+
return 'fakeemail' . md5 ( $sFakeDomain . $sRawValue ) . '@' . strtolower ( $sFakeDomain );
|
462 |
+
}
|
463 |
+
|
464 |
+
|
465 |
+
|
466 |
+
public function getOrderList($orderList = null) {
|
467 |
+
if($orderList == null) {
|
468 |
+
$data = $this->createRepository()->createOrderListRequest();
|
469 |
+
$oRequest = $this->getOrderService()->getClientProxy()->getOrderList($data);
|
470 |
+
$orderList = $oRequest->getResult();
|
471 |
+
}
|
472 |
+
$oPagination = $orderList->getPaginationResult();
|
473 |
+
if(!empty($oPagination)) {
|
474 |
+
$oLinksTotal = $oPagination->getLinks();
|
475 |
+
} else {
|
476 |
+
$configModel = Mage::getModel('core/config');
|
477 |
+
$configModel->saveConfig('beezup/marketplace/sync_status',0);
|
478 |
+
// Correction FRED On remet le shipping à 0 !!!
|
479 |
+
$shiiping_disabled = Mage::getStoreConfig('carriers/flatrate/active');
|
480 |
+
|
481 |
+
if($shiiping_disabled == 1) {
|
482 |
+
Mage::getConfig()
|
483 |
+
->saveConfig('carriers/flatrate/active', 0)
|
484 |
+
->cleanCache();
|
485 |
+
Mage::app()->reinitStores();
|
486 |
+
|
487 |
+
}
|
488 |
+
die("No more orders to import");
|
489 |
+
}
|
490 |
+
|
491 |
+
//$header = $orderList->getOrderHeaders();
|
492 |
+
foreach($orderList->getOrderHeaders() as $order) {
|
493 |
+
$order_status = $order->getBeezupOrderState();
|
494 |
+
$orderLinks = $order->getLinks();
|
495 |
+
$etag = $order->getETag();
|
496 |
+
$beezup_order_id = $order->getBeezupOrderUUID();
|
497 |
+
$account_id = $order->getAccountId();
|
498 |
+
$orderdata = $this->getOrderService()->getClientProxy()->getOrderByLink($orderLinks[0]);
|
499 |
+
$this->debugLog("Initializing Order - Link: ".$orderLinks[0]->getHref());
|
500 |
+
$this->createOrder($orderdata);
|
501 |
+
|
502 |
+
}
|
503 |
+
|
504 |
+
if(!empty($oLinksTotal)) {
|
505 |
+
//we check if there is next link and get next orders
|
506 |
+
foreach($oLinksTotal as $link) {
|
507 |
+
if( $link->getRel() == "next") {
|
508 |
+
|
509 |
+
$this->log->LogInfo("Initializing New Order List ->". $link->getHref());
|
510 |
+
$this->log2->LogInfo("Initializing New Order List ->". $link->getHref());
|
511 |
+
$oRequest = $this->getOrderService()->getClientProxy()->getOrderListByLink($link);
|
512 |
+
$orderList = $oRequest->getResult();
|
513 |
+
$this->getOrderList($orderList);
|
514 |
+
}
|
515 |
+
|
516 |
+
}
|
517 |
+
}
|
518 |
+
|
519 |
+
}
|
520 |
+
|
521 |
+
|
522 |
+
|
523 |
+
public function updateBeezupInfoTab($order, $oLink, $data) {
|
524 |
+
$beezup_last_modification_date = $oLink->getOrderLastModificationUtcDate();
|
525 |
+
$beezup_last_modification_date = $beezup_last_modification_date->date;
|
526 |
+
$beezup_marketplace_last_modification_date = $oLink->getOrderMarketPlaceLastModificationUtcDate();
|
527 |
+
$beezup_marketplace_last_modification_date = $beezup_marketplace_last_modification_date->date;
|
528 |
+
$beezup_comission = $oLink->getOrderTotalCommission()." ".$data['order_currency'];
|
529 |
+
$tot_comm = $oLink->getOrderTotalCommission();
|
530 |
+
if(empty($tot_comm ) || $tot_comm == 0) {
|
531 |
+
$beezup_comission = 0;
|
532 |
+
}
|
533 |
+
$updateData = array("beezup_status" => $data['order_status'],
|
534 |
+
"beezup_last_modification_date" => $beezup_last_modification_date,
|
535 |
+
"beezup_marketplace_last_modification_date" => $beezup_marketplace_last_modification_date ,
|
536 |
+
"beezup_total_paid" => $oLink->getOrderTotalPrice()." ".$data['order_currency'],
|
537 |
+
"beezup_comission" => $beezup_comission,
|
538 |
+
"beezup_marketplace_status" => $oLink->getOrderStatusMarketPlaceStatus());
|
539 |
+
$orderId = $order->getId();
|
540 |
+
$beezupMageOrder = new BeezupMageOrders($orderId);
|
541 |
+
$beezupMageOrder->setData($updateData);
|
542 |
+
$beezupMageOrder->updateBeezupInfo();
|
543 |
+
|
544 |
+
|
545 |
+
}
|
546 |
+
|
547 |
+
public function getPhone($phone, $phone2) {
|
548 |
+
$retorno = "";
|
549 |
+
if(!empty($phone) && $phone !== "") {
|
550 |
+
$retorno .= $phone;
|
551 |
+
}
|
552 |
+
if(!empty($phone2) && $phone2 !=="") {
|
553 |
+
if(empty($phone) || $phone == "") {
|
554 |
+
$retorno = $phone2;
|
555 |
+
|
556 |
+
} else {
|
557 |
+
$retorno .= " - ".$phone2;
|
558 |
+
}
|
559 |
+
}
|
560 |
+
return $retorno;
|
561 |
+
}
|
562 |
+
|
563 |
+
|
564 |
+
public function getBeezupBuyerAddress($order) {
|
565 |
+
$add1=$order->getOrderBuyerAddressLine1();
|
566 |
+
$add2=$order->getOrderBuyerAddressLine2();
|
567 |
+
$add3=$order->getOrderBuyerAddressLine3();
|
568 |
+
$retorno = "";
|
569 |
+
if(!empty($add1)) {
|
570 |
+
$retorno = $order->getOrderBuyerAddressLine1();
|
571 |
+
}
|
572 |
+
if(!empty($add2)) {
|
573 |
+
if(empty($add1)) {
|
574 |
+
$retorno .= $order->getOrderBuyerAddressLine2();
|
575 |
+
} else {
|
576 |
+
$retorno .= " - ". $order->getOrderBuyerAddressLine2();
|
577 |
+
}
|
578 |
+
}
|
579 |
+
if(!empty($add3)){
|
580 |
+
if(empty($add1) && empty($add2)) {
|
581 |
+
$retorno .= $order->getOrderBuyerAddressLine3();
|
582 |
+
} else {
|
583 |
+
$retorno .= " - ". $order->getOrderBuyerAddressLine3();
|
584 |
+
}
|
585 |
+
}
|
586 |
+
return $retorno;
|
587 |
+
}
|
588 |
+
|
589 |
+
|
590 |
+
public function getBeezupShippingAddress($order) {
|
591 |
+
$add1 = $order->getOrderShippingAddressLine1();
|
592 |
+
$add2 = $order->getOrderShippingAddressLine2();
|
593 |
+
$add3=$order->getOrderBuyerAddressLine3();
|
594 |
+
$retorno = "";
|
595 |
+
if(!empty($add1 )) {
|
596 |
+
$retorno = $order->getOrderShippingAddressLine1();
|
597 |
+
}
|
598 |
+
if(!empty($add2)) {
|
599 |
+
if(empty($add1)) {
|
600 |
+
$retorno .= $order->getOrderShippingAddressLine2();
|
601 |
+
} else {
|
602 |
+
$retorno .= " - ". $order->getOrderShippingAddressLine2();
|
603 |
+
}
|
604 |
+
}
|
605 |
+
if(!empty($add3)){
|
606 |
+
if(empty($add1) && empty($add2)) {
|
607 |
+
$retorno .= $order->getOrderShippingAddressLine3();
|
608 |
+
} else {
|
609 |
+
$retorno .= " - ". $order->getOrderShippingAddressLine3();
|
610 |
+
}
|
611 |
+
}
|
612 |
+
return $retorno;
|
613 |
+
}
|
614 |
+
|
615 |
+
public function checkEtagExists($etag) {
|
616 |
+
$resource = Mage::getSingleton('core/resource');
|
617 |
+
$readConnection = $resource->getConnection('core_read');
|
618 |
+
$table = $resource->getTableName('sales/order_grid');
|
619 |
+
$query = 'SELECT increment_id FROM ' . $table . ' WHERE beezup_etag = \''
|
620 |
+
. $etag . '\' LIMIT 1';
|
621 |
+
$order = $readConnection->fetchOne($query);
|
622 |
+
if($order && !empty($order)) {
|
623 |
+
return true;
|
624 |
+
}
|
625 |
+
return false;
|
626 |
+
|
627 |
+
}
|
628 |
+
|
629 |
+
|
630 |
+
public function updateEtag($etag) {
|
631 |
+
$this->debugLog("Updating Etag");
|
632 |
+
$resource = Mage::getSingleton('core/resource');
|
633 |
+
$writeConnection = $resource->getConnection('core_write');
|
634 |
+
$table = $resource->getTableName('sales/order_grid');
|
635 |
+
$query = "UPDATE {$table} SET beezup_etag = '{$etag}' where beezup_market_order_id = '{$this->orderid}' ";
|
636 |
+
$writeConnection->query($query);
|
637 |
+
|
638 |
+
}
|
639 |
+
|
640 |
+
|
641 |
+
|
642 |
+
public function updateBilling($order, $data) {
|
643 |
+
|
644 |
+
$addressData = array(
|
645 |
+
'billing_company' => ($data['order_company']) ? $data['order_company'] : "",
|
646 |
+
'billing_firstname' => ($data['order_customer']) ? $data['order_customer'] : "empty",
|
647 |
+
'billing_lastname' => ($data['order_lastname']) ? $data['order_lastname'] : "empty",
|
648 |
+
'billing_street' => ($data['order_address']) ? $data['order_address'] : "empty",
|
649 |
+
'billing_city' => ($data['order_city']) ? $data['order_city'] : "empty",
|
650 |
+
'billing_postcode' => ($data['order_postalCode']) ? $data['order_postalCode'] : "empty",
|
651 |
+
'billing_telephone' => ($data['order_customer_phone']) ? $data['order_customer_phone'] : "empty",
|
652 |
+
'billing_country_id' => ($data['order_country_iso']) ? $data['order_country_iso'] : "empty",
|
653 |
+
'billing_region_id' => ($data['order_region ']) ? substr($data['order_region '], 0,2) : "EM",
|
654 |
+
'shipping_firstname' => ($data['shipping_name']) ? $data['shipping_name'] : "empty",
|
655 |
+
'shipping_lastname' => ($data['shipping_lastname']) ? $data['shipping_lastname'] : $data['shipping_name'],
|
656 |
+
'shipping_street' => ($data['shipping_address']) ? $data['shipping_address'] : "empty",
|
657 |
+
'shipping_city' => ($data['shipping_city']) ? $data['shipping_city'] : "empty",
|
658 |
+
'shipping_postcode' => ($data['shipping_postalCode']) ? $data['shipping_postalCode'] : "empty",
|
659 |
+
'shipping_telephone' => ($data['shipping_phone']) ? $data['shipping_phone'] : "empty",
|
660 |
+
'shipping_country_id' => ($data['shipping_country_iso']) ? $data['shipping_country_iso'] : "empty",
|
661 |
+
'shipping_company' => ($data['shipping_company']) ? $data['shipping_company'] : "",
|
662 |
+
'shipping_region_id' => ($data['shipping_region']) ? substr($data['shipping_region'], 0, 2) : "EM" // id from directory_country_region table
|
663 |
+
);
|
664 |
+
|
665 |
+
$shippingData = array(
|
666 |
+
|
667 |
+
);
|
668 |
+
// Get the id of the orders shipping address
|
669 |
+
$orderId = $order->getId();
|
670 |
+
$beezupMageOrder = new BeezupMageOrders($orderId);
|
671 |
+
$beezupMageOrder->setData($addressData);
|
672 |
+
$beezupMageOrder->updateAdresses();
|
673 |
+
}
|
674 |
+
|
675 |
+
public function updateAddresses($shippingData, $address) {
|
676 |
+
if($shippingData['firstname'] !==$address['firstname']) {
|
677 |
+
$address->setFirstname($shippingData['firstname']);
|
678 |
+
}
|
679 |
+
if($shippingData['lastname'] !==$address['lastname']) {
|
680 |
+
$address->setLastname($shippingData['lastname']);
|
681 |
+
}
|
682 |
+
if($shippingData['street'] !==$address['street']) {
|
683 |
+
$address->setStreet($shippingData['street']);
|
684 |
+
}
|
685 |
+
if($shippingData['city'] !==$address['city']) {
|
686 |
+
$address->setCity($shippingData['city']);
|
687 |
+
}
|
688 |
+
if($shippingData['postcode'] !==$address['postcode']) {
|
689 |
+
$address->setPostcode($shippingData['postcode']);
|
690 |
+
}
|
691 |
+
if($shippingData['telephone'] !==$address['telephone']) {
|
692 |
+
$address->setTelephone($shippingData['telephone']);
|
693 |
+
}
|
694 |
+
$address->save();
|
695 |
+
|
696 |
+
|
697 |
+
}
|
698 |
+
|
699 |
+
|
700 |
+
public function loadMageOrder() {
|
701 |
+
$Mageorder = Mage::getModel('sales/order')->loadByIncrementId($this->orderid);
|
702 |
+
if ($Mageorder->getId()) {
|
703 |
+
return $Mageorder;
|
704 |
+
} else {
|
705 |
+
//we get order from marketplace orderid
|
706 |
+
$orderInc = $this->checkMarketOrderExists($this->orderid);
|
707 |
+
if($orderInc) {
|
708 |
+
// if exists
|
709 |
+
$Mageorder = Mage::getModel('sales/order')->loadByIncrementId($orderInc);
|
710 |
+
if ($Mageorder->getId()) {
|
711 |
+
return $Mageorder;
|
712 |
+
}
|
713 |
+
}
|
714 |
+
}
|
715 |
+
return false;
|
716 |
+
}
|
717 |
+
|
718 |
+
|
719 |
+
private function debugLog($message) {
|
720 |
+
|
721 |
+
if($this->orderid !== "") {
|
722 |
+
$message = $this->orderid." | ".$message;
|
723 |
+
}
|
724 |
+
$this->log->LogInfo($message);
|
725 |
+
|
726 |
+
$this->log2->LogInfo($message);
|
727 |
+
}
|
728 |
+
|
729 |
+
public function prescanOrder(BeezupOMOrderResult $order) {
|
730 |
+
$retorno = array();
|
731 |
+
$orderItems = $order->getOrderItems();
|
732 |
+
foreach ($orderItems as $item)
|
733 |
+
{
|
734 |
+
|
735 |
+
if ($item->getOrderItemOrderItemType () !== 'Product')
|
736 |
+
{
|
737 |
+
// continue;
|
738 |
+
}
|
739 |
+
$beezup_store = $item->getOrderItemBeezUPStoreId(); //beezup storeid
|
740 |
+
$mage_storeid = $this->checkOrderStore($beezup_store); //magento storeid
|
741 |
+
$marketplace_orderid = $item->getOrderItemMarketPlaceProductId();
|
742 |
+
if(!$mage_storeid) {
|
743 |
+
|
744 |
+
if(strpos($marketplace_orderid,'INTERETBCA') !== false || strpos($marketplace_orderid,'interetbca') !== false) { }
|
745 |
+
else {
|
746 |
+
$this->log->LogError($this->orderid." | No mapping for store ".$beezup_store);
|
747 |
+
$this->log2->LogError($this->orderid." | No mapping for store ".$beezup_store);
|
748 |
+
return false;
|
749 |
+
}
|
750 |
+
|
751 |
+
}
|
752 |
+
// $retorno['store'] = 1;
|
753 |
+
|
754 |
+
$product_ImportedMerchantId = $item->getOrderItemMerchantImportedProductId();
|
755 |
+
$product_MerchantId = $item->getOrderItemMerchantProductId();
|
756 |
+
|
757 |
+
$product_quantity = $item->getOrderItemQuantity();
|
758 |
+
$product_price = $item->getOrderItemItemPrice();
|
759 |
+
$product_title = $item->getOrderItemTitle();
|
760 |
+
$product_image = $item->getOrderItemImageUrl();
|
761 |
+
if(strpos($marketplace_orderid,'INTERETBCA') !== false || strpos($marketplace_orderid,'interetbca') !== false) {
|
762 |
+
$retorno['discounts']= $item->getOrderItemTotalPrice();
|
763 |
+
} else {
|
764 |
+
$retorno['store'] = $mage_storeid;
|
765 |
+
$this->debugLog("Store Matching succesful, Beezup Store: ".$beezup_store." , Magento Store Id: ".$mage_storeid);
|
766 |
+
$product = $this->getMageProduct($product_ImportedMerchantId , $product_MerchantId , $beezup_store );
|
767 |
+
if($product) {
|
768 |
+
$mage_productId = $product->getId();
|
769 |
+
$stocklevel = (int)Mage::getModel('cataloginventory/stock_item')
|
770 |
+
->loadByProduct($product)->getQty();
|
771 |
+
|
772 |
+
$retorno['products'][] = array("id" => $mage_productId, "qty" => $product_quantity, "price" => $product_price, "curr_stock" => $stocklevel);
|
773 |
+
//producto existe
|
774 |
+
} else {
|
775 |
+
//vendria if de si activada opcion de crear producto creamos
|
776 |
+
if(!$this->debug) {
|
777 |
+
return false;
|
778 |
+
}
|
779 |
+
$product_data = array(
|
780 |
+
"sku" => $product_ImportedMerchantId,
|
781 |
+
"sku2" => $product_MerchantId,
|
782 |
+
"qty" => $product_quantity,
|
783 |
+
"price" => $product_price,
|
784 |
+
"title" => $product_title,
|
785 |
+
"image" => $product_image,
|
786 |
+
"storeId" => $mage_storeid
|
787 |
+
);
|
788 |
+
$product = $this->createProduct($product_data);
|
789 |
+
if(!$product) {
|
790 |
+
return false;
|
791 |
+
}
|
792 |
+
$stocklevel = (int)Mage::getModel('cataloginventory/stock_item')
|
793 |
+
->loadByProduct($product)->getQty();
|
794 |
+
$mage_productId = $product->getId();
|
795 |
+
$retorno['products'][] = array("id" => $mage_productId, "qty" => $product_quantity, "price" => $product_price, "curr_stock" => $stocklevel);
|
796 |
+
}
|
797 |
+
}
|
798 |
+
}
|
799 |
+
|
800 |
+
return $retorno;
|
801 |
+
}
|
802 |
+
|
803 |
+
|
804 |
+
|
805 |
+
public function matchProductAttributes($importedId, $storeId) {
|
806 |
+
$product = null;
|
807 |
+
$helper = Mage::helper('beezup');
|
808 |
+
$attributes = $helper->getConfig('beezup/marketplace/attributes');
|
809 |
+
$attributes = unserialize ($attributes);
|
810 |
+
|
811 |
+
foreach($attributes['attributes'][$storeId ] as $attribute) {
|
812 |
+
$att = explode("|", $attribute);
|
813 |
+
if($storeId == $att[1]) {
|
814 |
+
|
815 |
+
$product=Mage::getModel('catalog/product')->loadByAttribute($att[0],$importedId);
|
816 |
+
if($product) {
|
817 |
+
break;
|
818 |
+
}
|
819 |
+
}
|
820 |
+
}
|
821 |
+
|
822 |
+
return $product;
|
823 |
+
}
|
824 |
+
|
825 |
+
|
826 |
+
|
827 |
+
public function getMageProduct($importedId, $merchantId, $storeId){
|
828 |
+
try {
|
829 |
+
$product=Mage::getModel('catalog/product')->load($importedId);
|
830 |
+
if (!$product->getId() || $product->getId() !== $importedId ){
|
831 |
+
$product = $this->matchProductAttributes($importedId, $storeId);
|
832 |
+
if($product == null || !is_object($product)) {
|
833 |
+
$product=Mage::getModel('catalog/product')->load($merchantId);
|
834 |
+
if(!$product->getId() || $product->getId() !== $merchantId ) {
|
835 |
+
$product = $this->matchProductAttributes($merchantId, $storeId);
|
836 |
+
|
837 |
+
}
|
838 |
+
}
|
839 |
+
}
|
840 |
+
|
841 |
+
if(is_object($product)) {
|
842 |
+
if($product->getId()) {
|
843 |
+
$this->debugLog("Product Matching succesful, Beezup Imported Id: ".$importedId." , Magento Product Id: ".$product->getId());
|
844 |
+
return $product;
|
845 |
+
}}
|
846 |
+
$this->log->LogError($this->orderid. "| No Product Matching, Product ".$importedId." could not be found");
|
847 |
+
$this->log2->LogError($this->orderid. "| No Product Matching, Product ".$importedId." could not be found");
|
848 |
+
return false;
|
849 |
+
}catch(Exception $e){
|
850 |
+
$this->log->LogError($this->orderid. "| Product ".$importedId." could not be found, error: ".$e->getMessage());
|
851 |
+
$this->log2->LogError($this->orderid. "| Product ".$importedId." could not be found, error: ".$e->getMessage());
|
852 |
+
return false;
|
853 |
+
//error no se pudo crear la orden
|
854 |
+
|
855 |
+
}
|
856 |
+
}
|
857 |
+
|
858 |
+
|
859 |
+
public function checkOrderStore($storeId ) {
|
860 |
+
$helper = Mage::helper('beezup');
|
861 |
+
$stores = $helper->getConfig('beezup/marketplace/stores');
|
862 |
+
$stores = unserialize ($stores);
|
863 |
+
foreach($stores as $store) {
|
864 |
+
if(isset($store[$storeId]) && $store[$storeId] > 0) {
|
865 |
+
return $store[$storeId];
|
866 |
+
}
|
867 |
+
}
|
868 |
+
return false;
|
869 |
+
}
|
870 |
+
|
871 |
+
|
872 |
+
|
873 |
+
/**
|
874 |
+
* @return BeezupOMOrderService
|
875 |
+
*/
|
876 |
+
public function getOrderService(){
|
877 |
+
if ($this->oOrderService === null){
|
878 |
+
$this->oOrderService = $this->createOrderService();
|
879 |
+
// enchufamos debug mode, esta activado? false true $this->oOrderService->setDebugMode(false);
|
880 |
+
}
|
881 |
+
return $this->oOrderService;
|
882 |
+
}
|
883 |
+
|
884 |
+
/**
|
885 |
+
* @return BeezupOMOrderService
|
886 |
+
*/
|
887 |
+
protected function createOrderService(){
|
888 |
+
|
889 |
+
return new BeezupOMOrderService($this->createRepository() );
|
890 |
+
}
|
891 |
+
|
892 |
+
protected function createRepository() {
|
893 |
+
if ($this->repository == null) {
|
894 |
+
$this->repository = new BeezupRepository();
|
895 |
+
}
|
896 |
+
return $this->repository;
|
897 |
+
|
898 |
+
}
|
899 |
+
|
900 |
+
|
901 |
+
|
902 |
+
|
903 |
+
private function createCustomer($customer_email , $data) {
|
904 |
+
$password = $this->orderid;
|
905 |
+
$this->debugLog("Creating new Customer");
|
906 |
+
$customer = Mage::getModel('customer/customer');
|
907 |
+
$customer->setWebsiteId(Mage::app()->getWebsite()->getId());
|
908 |
+
$customer->loadByEmail($customer_email);
|
909 |
+
if(!$customer->getId()) {
|
910 |
+
$customer->setEmail($customer_email);
|
911 |
+
$customer->setFirstname($data['firstname']);
|
912 |
+
$customer->setLastname($data['lastname']);
|
913 |
+
$customer->setPassword($password);
|
914 |
+
try {
|
915 |
+
$customer->save();
|
916 |
+
$customer->setConfirmation(null);
|
917 |
+
$customer->save();
|
918 |
+
$this->debugLog("Customer created succesfully");
|
919 |
+
return $customer;
|
920 |
+
//Make a "login" of new customer
|
921 |
+
// Mage::getSingleton('customer/session')->loginById($customer->getId());
|
922 |
+
}
|
923 |
+
|
924 |
+
catch (Exception $ex) {
|
925 |
+
//Zend_Debug::dump($ex->getMessage());
|
926 |
+
//GUARDAR ERROR CREACION USUARIO
|
927 |
+
$this->log2->LogError($this->orderid. " | Customer importation failed: ".$ex->getMessage());
|
928 |
+
return false;
|
929 |
+
}
|
930 |
+
|
931 |
+
} else {
|
932 |
+
$this->debugLog("Creating already exists, returning customer object");
|
933 |
+
return $customer;
|
934 |
+
}
|
935 |
+
}
|
936 |
+
|
937 |
+
|
938 |
+
|
939 |
+
public function addOrder($data, $oLink, $stop = false) {
|
940 |
+
|
941 |
+
|
942 |
+
try {
|
943 |
+
// BUG OCI du nom vide sur les commandes CDISOUNT... et Amazon en Disable...
|
944 |
+
$this->debugLog('status de la commande->'.$data['order_status']);
|
945 |
+
$this->debugLog('Nom vide->'.$data['shipping_lastname']);
|
946 |
+
if ($data['shipping_lastname']=='' && $data['order_status'] != 'Canceled'){
|
947 |
+
|
948 |
+
Mage::getConfig()
|
949 |
+
->saveConfig('carriers/flatrate/active', 0)
|
950 |
+
->cleanCache();
|
951 |
+
Mage::app()->reinitStores();
|
952 |
+
|
953 |
+
$configModel = Mage::getModel('core/config');
|
954 |
+
$configModel->saveConfig('beezup/marketplace/sync_status',0);
|
955 |
+
|
956 |
+
$this->debugLog('status de la commande->'.$data['order_status']);
|
957 |
+
$this->debugLog('status de la commande->'.$data['order_status']);
|
958 |
+
die("Nom Vide on attends que le nom arrive...");
|
959 |
+
|
960 |
+
}
|
961 |
+
|
962 |
+
$helper = Mage::helper('beezup');
|
963 |
+
$addStock = $helper->getConfig('beezup/marketplace/available_products');
|
964 |
+
$baseCurrencyCode = Mage::app()->getStore()->getBaseCurrencyCode();
|
965 |
+
$quote = Mage::getModel('sales/quote')
|
966 |
+
->setStoreId($data['storeid']);
|
967 |
+
|
968 |
+
$this->debugLog("## test quote storeid ##".$data['storeid']);
|
969 |
+
|
970 |
+
$quote->setCustomerEmail($data['order_customer_email']);
|
971 |
+
|
972 |
+
$this->debugLog("## test quote order_customer_email ##".$data['order_customer_email']);
|
973 |
+
|
974 |
+
|
975 |
+
$currency = Mage::getModel('directory/currency')->load($data['order_currency']);
|
976 |
+
$quote->setForcedCurrency($currency);
|
977 |
+
|
978 |
+
$this->debugLog("## test quote currency ##".$currency);
|
979 |
+
|
980 |
+
$blnCreate = true;
|
981 |
+
$total_new_price = 0;
|
982 |
+
|
983 |
+
foreach($data['products'] as $prod) {
|
984 |
+
|
985 |
+
if($prod['qty']==0) {
|
986 |
+
$blnCreate = false;
|
987 |
+
break;
|
988 |
+
}
|
989 |
+
$prod_totality_price = $prod['price']*$prod['qty'];
|
990 |
+
$total_new_price = $total_new_price + $prod_totality_price;
|
991 |
+
$product = Mage::getModel('catalog/product')->load($prod['id']);
|
992 |
+
$buyInfo = array(
|
993 |
+
'qty' => $prod['qty'],
|
994 |
+
);
|
995 |
+
|
996 |
+
$this->debugLog("Adding ".$prod['qty']." product/s with id ".$product->getId()." to order, with Beezup Price: ".$prod['price']);
|
997 |
+
//echo "Product ".$product->getId()."<br><br>";
|
998 |
+
//para no perder stock:
|
999 |
+
//Mage::getModel('cataloginventory/stock')->backItemQty($productId,$new_qty);
|
1000 |
+
|
1001 |
+
|
1002 |
+
if($addStock == 1) {
|
1003 |
+
$stock = Mage::getModel('cataloginventory/stock_item')->loadByProduct($product);
|
1004 |
+
|
1005 |
+
if ($stock->getQty() < $prod['qty'] && $product->getStockItem()->getMaxSaleQty() >= $prod['qty']) {
|
1006 |
+
$this->debugLog("Product ".$product->getId()." Stock = 0, Updating to ".$prod['qty']." to generate Order");
|
1007 |
+
// Mage::getModel('cataloginventory/stock')->backItemQty($product->getId(),$prod['qty']);
|
1008 |
+
//$this->_updateStocks(array("id_product" => $product->getId(), "qty" => $prod['qty']));
|
1009 |
+
|
1010 |
+
//BUG OCI s'emmele les pédales dans le tiers price avec la methode en dessous...->
|
1011 |
+
$stockItem = Mage::getModel('cataloginventory/stock_item')->loadByProduct($product);
|
1012 |
+
$stockItem->setData('is_in_stock', 1);
|
1013 |
+
$stockItem->setData('qty', $prod['qty']);
|
1014 |
+
$stockItem->setData('manage_stock', 1);
|
1015 |
+
$stockItem->setData('use_config_notify_stock_qty', 1);
|
1016 |
+
$stockItem->save();
|
1017 |
+
$product->save();
|
1018 |
+
|
1019 |
+
// $product->setStockData(
|
1020 |
+
// array(
|
1021 |
+
// 'is_in_stock' => 1,
|
1022 |
+
// 'qty' => $prod['qty'],
|
1023 |
+
// 'manage_stock' => 1,
|
1024 |
+
// 'use_config_notify_stock_qty' => 1
|
1025 |
+
// )
|
1026 |
+
// );
|
1027 |
+
|
1028 |
+
|
1029 |
+
//$product->save();
|
1030 |
+
|
1031 |
+
$this->debugLog("APRES TRAITEMENT 2 ->".$stock->getQty());
|
1032 |
+
$product = Mage::getModel('catalog/product')->load($product->getId());
|
1033 |
+
|
1034 |
+
}
|
1035 |
+
}
|
1036 |
+
//fin para no perder stock
|
1037 |
+
|
1038 |
+
/*
|
1039 |
+
$tax_class = $product->getTaxClassId();
|
1040 |
+
$product->setTaxClassId(0);
|
1041 |
+
$product->getResource()->saveAttribute($product, 'tax_class_id'); */
|
1042 |
+
$price = $prod['price'];
|
1043 |
+
|
1044 |
+
$quote_item = Mage::getModel('beezup/quote_item');
|
1045 |
+
$quote_item
|
1046 |
+
->setProduct($product)
|
1047 |
+
->setPrice((float) $price )
|
1048 |
+
->setCustomPrice((float)$price )
|
1049 |
+
->setOriginalCustomPrice((float) $price )
|
1050 |
+
->setQuote($quote)
|
1051 |
+
->setQty((integer) $prod['qty'])
|
1052 |
+
->setBeezupPrice((float) $price );
|
1053 |
+
|
1054 |
+
$this->debugLog("## test quote price ##".$price);
|
1055 |
+
$this->debugLog("## test quote qty ##".$prod['qty']);
|
1056 |
+
|
1057 |
+
|
1058 |
+
$quote->addItem($quote_item);
|
1059 |
+
|
1060 |
+
//$quote->addProduct($product, new Varien_Object($buyInfo))->setOriginalCustomPrice($price)->setCustomPrice($price);
|
1061 |
+
|
1062 |
+
/*
|
1063 |
+
$product->setTaxClassId($tax_class);
|
1064 |
+
|
1065 |
+
$product->getResource()->saveAttribute($product, 'tax_class_id');
|
1066 |
+
*/
|
1067 |
+
}
|
1068 |
+
|
1069 |
+
if($blnCreate) {
|
1070 |
+
$addressData = array(
|
1071 |
+
'firstname' => ($data['order_customer']) ? $data['order_customer'] : "empty",
|
1072 |
+
'lastname' => ($data['order_lastname']) ? $data['order_lastname'] : "empty",
|
1073 |
+
'street' => ($data['order_address']) ? $data['order_address'] : "empty",
|
1074 |
+
'city' => ($data['order_city']) ? $data['order_city'] : "empty",
|
1075 |
+
'postcode' => ($data['order_postalCode']) ? $data['order_postalCode'] : "empty",
|
1076 |
+
'telephone' => ($data['order_customer_phone']) ? $data['order_customer_phone'] : "empty",
|
1077 |
+
'country_id' => ($data['order_country_iso']) ? $data['order_country_iso'] : "empty",
|
1078 |
+
'company' => ($data['order_company']) ? $data['order_company'] : "",
|
1079 |
+
'region_id' => ($data['order_region ']) ? substr($data['order_region '], 0,2) : "EM"// id from directory_country_region table
|
1080 |
+
);
|
1081 |
+
|
1082 |
+
$this->debugLog("## test quote addressData : ");
|
1083 |
+
foreach ($addressData as $key => $value){
|
1084 |
+
$this->debugLog($key . " : " . $value);
|
1085 |
+
}
|
1086 |
+
|
1087 |
+
$shippingData = array(
|
1088 |
+
'firstname' => ($data['shipping_name']) ? $data['shipping_name'] : "empty",
|
1089 |
+
'lastname' => ($data['shipping_lastname']) ? $data['shipping_lastname'] : $data['shipping_name'],
|
1090 |
+
'street' => ($data['shipping_address']) ? $data['shipping_address'] : "empty",
|
1091 |
+
'city' => ($data['shipping_city']) ? $data['shipping_city'] : "empty",
|
1092 |
+
'postcode' => ($data['shipping_postalCode']) ? $data['shipping_postalCode'] : "empty",
|
1093 |
+
'telephone' => ($data['shipping_phone']) ? $data['shipping_phone'] : "empty",
|
1094 |
+
'country_id' => ($data['shipping_country_iso']) ? $data['shipping_country_iso'] : "empty",
|
1095 |
+
'shipping_company' => ($data['shipping_company']) ? $data['shipping_company'] : "",
|
1096 |
+
// il faudra penser a mettre une condtionnel seulement pour monechelle...
|
1097 |
+
//'socolissimo_relay_id' => ($data['shipping_company']) ? $data['shipping_company'] : "",
|
1098 |
+
'region_id' => ($data['shipping_region']) ? substr($data['shipping_region'], 0, 2) : "EM" // id from directory_country_region table
|
1099 |
+
);
|
1100 |
+
|
1101 |
+
$this->debugLog("## test quote shippingData : ");
|
1102 |
+
foreach ($shippingData as $key => $value){
|
1103 |
+
$this->debugLog($key . " : " . $value);
|
1104 |
+
}
|
1105 |
+
|
1106 |
+
if($this->blnCreateCustomer) {
|
1107 |
+
|
1108 |
+
$mage_customer = $this->createCustomer($data['order_customer_email'], $addressData);
|
1109 |
+
$quote->assignCustomer($mage_customer);
|
1110 |
+
$this->debugLog("## test quote order_customer_email ##".$data['order_customer_email']);
|
1111 |
+
}
|
1112 |
+
|
1113 |
+
|
1114 |
+
$payment_method = $helper->getConfig('beezup/marketplace/payment_method');
|
1115 |
+
$billingAddress = $quote->getBillingAddress()->addData($addressData);
|
1116 |
+
$shippingAddress = $quote->getShippingAddress()->addData($shippingData);
|
1117 |
+
$shipping_cost = (float) $data['order_shippingPrice'];
|
1118 |
+
if($data['order_shippingPrice'] == 0) {
|
1119 |
+
$shipping_cost = 20000;
|
1120 |
+
}
|
1121 |
+
$total_new_price = $total_new_price + $data['order_shippingPrice'] ;
|
1122 |
+
Mage::unregister('shipping_cost');
|
1123 |
+
Mage::register('shipping_cost', $shipping_cost);
|
1124 |
+
$this->debugLog("Adding Order Shipping Cost: ". $data['order_shippingPrice']);
|
1125 |
+
|
1126 |
+
$shippingAddress->setCollectShippingRates(true)->collectShippingRates()
|
1127 |
+
->setShippingMethod('flatrate_flatrate')
|
1128 |
+
->setPaymentMethod($payment_method);
|
1129 |
+
|
1130 |
+
//$shippingAddress->addTotal(array("code" => "specialfee", "title" => "Special Fee", "value" => 20));
|
1131 |
+
$quote->getPayment()->importData(array('method' => $payment_method));
|
1132 |
+
|
1133 |
+
$this->debugLog("## test quote payment_method ##".$payment_method);
|
1134 |
+
|
1135 |
+
$quote->collectTotals()->save();
|
1136 |
+
|
1137 |
+
$service = Mage::getModel('sales/service_quote', $quote);
|
1138 |
+
//$this->debugLog("## test flatrate2 ##".var_dump($quote)); // test commande qui s'importe pas -> quote mal formaté ?
|
1139 |
+
$service->submitAll();
|
1140 |
+
|
1141 |
+
$order = $service->getOrder();
|
1142 |
+
|
1143 |
+
$quoteId = $order->getQuoteId();
|
1144 |
+
//$this->setStatus($data['order_status'], $order);
|
1145 |
+
|
1146 |
+
$orderid = $order->getId();
|
1147 |
+
|
1148 |
+
$resource = Mage::getSingleton('core/resource');
|
1149 |
+
$writeConnection = $resource->getConnection('core_write');
|
1150 |
+
$table = $resource->getTableName('sales/order_grid');
|
1151 |
+
$this->debugLog("Adding Beezup Marketplace Information to Order");
|
1152 |
+
$marketplace = $data['marketplace'];
|
1153 |
+
$marketplace_business_code = ucfirst(strtolower($data['marketplace_business_code']));
|
1154 |
+
$beezup_name = $data['order_customer'];
|
1155 |
+
$market_order_id =$this->orderid;
|
1156 |
+
$beezup_order_id = $oLink->getBeezupOrderUUID();
|
1157 |
+
$beezup_status = $data['order_status'];
|
1158 |
+
$beezup_last_modification_date = $oLink->getOrderLastModificationUtcDate();
|
1159 |
+
$beezup_last_modification_date = $beezup_last_modification_date->date;
|
1160 |
+
$beezup_marketplace_status = $oLink->getOrderStatusMarketPlaceStatus();
|
1161 |
+
$beezup_purchase_date = $oLink->getOrderPurchaseUtcDate();
|
1162 |
+
$beezup_purchase_date = $beezup_purchase_date->date;
|
1163 |
+
$beezup_marketplace_last_modification_date = $oLink->getOrderMarketPlaceLastModificationUtcDate();
|
1164 |
+
$beezup_marketplace_last_modification_date = $beezup_marketplace_last_modification_date->date;
|
1165 |
+
/* $date = new DateTime($$beezup_marketplace_last_modification_date);
|
1166 |
+
$beezup_marketplace_last_modification_date = $date->format('d-m-Y H:i:s'). "(UTC Time)";
|
1167 |
+
*/
|
1168 |
+
|
1169 |
+
$beezup_total_paid = $oLink->getOrderTotalPrice()." ".$data['order_currency'];
|
1170 |
+
$beezup_account_id = $oLink->getAccountId();
|
1171 |
+
$beezup_comission = $oLink->getOrderTotalCommission()." ".$data['order_currency'];
|
1172 |
+
$tot_comm = $oLink->getOrderTotalCommission();
|
1173 |
+
if(empty($tot_comm ) || $tot_comm == 0) {
|
1174 |
+
$beezup_comission = 0;
|
1175 |
+
}
|
1176 |
+
$query = "UPDATE {$table} SET beezup_marketplace = '{$marketplace}', beezup_name = '{$beezup_account_id}', beezup_order = 1, beezup_market_order_id = '{$market_order_id}',
|
1177 |
+
beezup_order_id = '{$beezup_order_id}', beezup_status = '{$beezup_status}', beezup_last_modification_date = '{$beezup_last_modification_date}',
|
1178 |
+
beezup_marketplace_status = '{$beezup_marketplace_status}', beezup_purchase_date = '{$beezup_purchase_date}', beezup_marketplace_last_modification_date = '{$beezup_marketplace_last_modification_date}',
|
1179 |
+
beezup_total_paid = '{$beezup_total_paid}', beezup_etag = '{$data['etag']}' , beezup_comission = '{$beezup_comission}', beezup_marketplace_business_code = '{$marketplace_business_code}'
|
1180 |
+
WHERE entity_id = ". (int)$orderid;
|
1181 |
+
$writeConnection->query($query);
|
1182 |
+
$disc_price = 0;
|
1183 |
+
if(!empty($data['discounts']) && $data['discounts'] >0) {
|
1184 |
+
|
1185 |
+
|
1186 |
+
$disc_price = round($data['discounts'],2);
|
1187 |
+
$total_new_price = $total_new_price+$disc_price;
|
1188 |
+
$table_address = $resource->getTableName("sales/quote_address");
|
1189 |
+
|
1190 |
+
$query = "update {$table_address} set beezup_fee = '{$disc_price}' where quote_id = '{$quoteId}' and address_type = 'shipping'";
|
1191 |
+
$writeConnection->query($query);
|
1192 |
+
$this->debugLog("Adding CDISCOUNT products with total price: ".$disc_price);
|
1193 |
+
}
|
1194 |
+
|
1195 |
+
//if order id exists and has been created
|
1196 |
+
if ($orderid)
|
1197 |
+
{
|
1198 |
+
//we send order id to beezup
|
1199 |
+
$this->debugLog("Sending Magento Order Id to Beezup, Magento Order Id: ".$orderid);
|
1200 |
+
$oResult = new BeezupOMSetOrderIdValues ();
|
1201 |
+
$oResult->setOrderMerchantOrderId ( $orderid )->setOrderMerchantECommerceSoftwareName ( 'Magento' )->setOrderMerchantECommerceSoftwareVersion ( Mage::getVersion() );
|
1202 |
+
$sendRequest = $this->getOrderService()->getClientProxy()->setOrderMerchantIdByLink($oLink->getLinkByRel('setMerchantOrderId'), $oResult);
|
1203 |
+
}
|
1204 |
+
|
1205 |
+
$grand_total = $order->getGrandTotal();
|
1206 |
+
$beezup_price = $oLink->getOrderTotalPrice() - $disc_price;
|
1207 |
+
if($grand_total != (float) $beezup_price && $beezup_price > 0) {
|
1208 |
+
$order->setGrandTotal((float) $beezup_price);
|
1209 |
+
$order->setBaseGrandTotal((float) $beezup_price);
|
1210 |
+
$diff = (((float) $beezup_price) - $grand_total);
|
1211 |
+
|
1212 |
+
$order->setTaxAmount($order->getTaxAmount() + $diff);
|
1213 |
+
$order->save();
|
1214 |
+
}elseif($grand_total != (float)$beezup_price && $beezup_price < 1) {
|
1215 |
+
|
1216 |
+
$order->setGrandTotal((float) $total_new_price);
|
1217 |
+
$order->setBaseGrandTotal((float) $total_new_price);
|
1218 |
+
$diff = (((float) $total_new_price) - $grand_total);
|
1219 |
+
|
1220 |
+
$order->setTaxAmount($order->getTaxAmount() + $diff);
|
1221 |
+
$order->save();
|
1222 |
+
}
|
1223 |
+
|
1224 |
+
if($order->getShippingInclTax() != $data['order_shippingPrice']) {
|
1225 |
+
$shipping_cost = (float)$data['order_shippingPrice'];
|
1226 |
+
$diff_shipping = ($shipping_cost - $order->getShippingInclTax());
|
1227 |
+
//$order->setShippingAmount($order->getShippingAmount() + $diff_shipping);
|
1228 |
+
//$order->setBaseShippingAmount($order->getShippingAmount());
|
1229 |
+
$order->setShippingInclTax($shipping_cost);
|
1230 |
+
$order->setBaseShippingInclTax($order->getShippingInclTax());
|
1231 |
+
/*
|
1232 |
+
$order->setSubtotalInclTax($order->getSubtotalInclTax() + $diff_shipping);
|
1233 |
+
$order->setBaseSubtotalInclTax($order->getSubtotalInclTax());
|
1234 |
+
$order->setSubtotal($order->getSubtotal() + $diff_shipping);
|
1235 |
+
$order->setBaseSubtotal($order->getSubtotal());
|
1236 |
+
*/
|
1237 |
+
$order->save();
|
1238 |
+
}
|
1239 |
+
$products = Mage::getResourceModel('sales/order_item_collection')
|
1240 |
+
->setOrderFilter($orderid);
|
1241 |
+
foreach($products as $product) {
|
1242 |
+
$product->setBaseOriginalPrice($product->getOriginalPrice());
|
1243 |
+
$product->setBaseTaxAmount($product->getTaxAmount());
|
1244 |
+
$product->setBaseTaxInvoiced($product->getTaxAmount());
|
1245 |
+
$product->setBasePriceInclTax($product->getPriceInclTax());
|
1246 |
+
$product->setBaseRowTotalInclTax($product->getRowTotalInclTax());
|
1247 |
+
$product->save();
|
1248 |
+
}
|
1249 |
+
$order->setBaseTaxAmount($order->getTaxAmount());
|
1250 |
+
$order->setBaseTaxInvoiced($order->getTaxAmount());
|
1251 |
+
$order->setBaseTotalInvoiced($order->getTotalPaid());
|
1252 |
+
$order->setBaseTotalPaid($order->getTotalPaid());
|
1253 |
+
$order->setBaseGrandTotal($order->getTotalPaid());
|
1254 |
+
$order->setBaseSubtotalInclTax($order->getSubtotalInclTax());
|
1255 |
+
$order->save();
|
1256 |
+
|
1257 |
+
$this->setStatus($data['order_status'], $order);
|
1258 |
+
$this->mage_order_id = $orderid;
|
1259 |
+
|
1260 |
+
// update table sale flat order OCI
|
1261 |
+
|
1262 |
+
$this->debugLog("Quelle Livraison: ->".$data['shipping_method_BEEZUP']);
|
1263 |
+
if ($data['shipping_method_BEEZUP']=='Livraison Colissimo'|| $data['shipping_method_BEEZUP']=='Standard' || $data['shipping_method_BEEZUP']=='Expedited' || $data['shipping_method_BEEZUP']=='TRK' || $data['shipping_method_BEEZUP']=='STD' || $data['shipping_method_BEEZUP']=='REG' || $data['shipping_method_BEEZUP']=='Transporteur' || $data['shipping_method_BEEZUP']=='FR_Autre' || $data['shipping_method_BEEZUP']=='Colissimo Domicile' || $data['shipping_method_BEEZUP']=='A' ) {
|
1264 |
+
//update flat_order
|
1265 |
+
$table_update="sales_flat_order";
|
1266 |
+
$desc="La Poste : Colissimo - Livraison à Domicile";
|
1267 |
+
$methode="socolissimo_3";
|
1268 |
+
$query = "UPDATE {$table_update} SET shipping_description = '{$desc}', shipping_method = '{$methode}' WHERE entity_id = ". (int)$orderid;
|
1269 |
+
$writeConnection->query($query);
|
1270 |
+
|
1271 |
+
//update flat_order_address
|
1272 |
+
$table_update2="sales_flat_order_address";
|
1273 |
+
$socolissimo_method_id = '3';
|
1274 |
+
$socolissimo_method_name = 'Livraison à Domicile';
|
1275 |
+
$socolissimo_delivery_mode = 'DOM';
|
1276 |
+
$socolissimo_code = 'home_without_signature';
|
1277 |
+
$query2 = "UPDATE {$table_update2} SET socolissimo_method_id = '{$socolissimo_method_id}', socolissimo_method_name = '{$socolissimo_method_name}', socolissimo_delivery_mode = '{$socolissimo_delivery_mode}', socolissimo_code = '{$socolissimo_code}' WHERE address_type ='shipping' AND parent_id = ". (int)$orderid ;
|
1278 |
+
$writeConnection->query($query2);
|
1279 |
+
//$this->debugLog("changement methode: ".$query);
|
1280 |
+
}
|
1281 |
+
else if ($data['shipping_method_BEEZUP']=='Std ES Dom_3' || $data['shipping_method_BEEZUP']=='Exp IT Dom_1' || $data['shipping_method_BEEZUP']=='Std UK Dom_5' || $data['shipping_method_BEEZUP']=='Std IT Dom_4' || $data['shipping_method_BEEZUP']=='UK Second') {
|
1282 |
+
$table_update="sales_flat_order";
|
1283 |
+
$desc="Chronopost Livraison express partout dans le monde - Chronopost Livraison partout dans le monde";
|
1284 |
+
$methode="chronoexpress_chronoexpress";
|
1285 |
+
$query = "UPDATE {$table_update} SET shipping_description = '{$desc}', shipping_method = '{$methode}' WHERE entity_id = ". (int)$orderid;
|
1286 |
+
$writeConnection->query($query);
|
1287 |
+
}
|
1288 |
+
else if ($data['shipping_method_BEEZUP']=='Colissimo Relais') { // ajout antonin pour prise en compte pt relais manomano
|
1289 |
+
|
1290 |
+
$table_update="sales_flat_order";
|
1291 |
+
$desc="La Poste Colissimo - Livraison en Point de retrait";
|
1292 |
+
$methode="socolissimo_4";
|
1293 |
+
$query = "UPDATE {$table_update} SET shipping_description = '{$desc}', shipping_method = '{$methode}' WHERE entity_id = ". (int)$orderid;
|
1294 |
+
$writeConnection->query($query);
|
1295 |
+
|
1296 |
+
$table_update2="sales_flat_order_address";
|
1297 |
+
$socolissimo_method_id = '4';
|
1298 |
+
$socolissimo_method_name = 'Livraison en Point de retrait';
|
1299 |
+
$socolissimo_delivery_mode = 'A2P';
|
1300 |
+
$socolissimo_relay_id = substr($data['shipping_company'], 10);
|
1301 |
+
$socolissimo_code = 'pickup';
|
1302 |
+
$query2 = "UPDATE {$table_update2} SET socolissimo_method_id = '{$socolissimo_method_id}', socolissimo_method_name = '{$socolissimo_method_name}', company = '', socolissimo_relay_id = '{$socolissimo_relay_id}', socolissimo_delivery_mode = '{$socolissimo_delivery_mode}', socolissimo_code = '{$socolissimo_code}' WHERE address_type ='shipping' AND parent_id = ". (int)$orderid ;
|
1303 |
+
$writeConnection->query($query2);
|
1304 |
+
|
1305 |
+
}
|
1306 |
+
|
1307 |
+
$this->debugLog("Order imported succesfully, Magento Order Id: ".$orderid);
|
1308 |
+
|
1309 |
+
} else {
|
1310 |
+
//product stock = 0 we dont create order
|
1311 |
+
$this->log->LogError($this->orderid. "| Order ".$data['market_place_order_id']." could not be imported, error: Stock from Beezup product = 0 ");
|
1312 |
+
$this->log2->LogError($this->orderid. "| Order ".$data['market_place_order_id']." could not be imported, error: Stock from Beezup product = 0 ");
|
1313 |
+
}
|
1314 |
+
}catch(Exception $e){
|
1315 |
+
|
1316 |
+
|
1317 |
+
if($stop) {
|
1318 |
+
$this->log->LogError($this->orderid. "| Order ".$data['market_place_order_id']." could not be imported, error: ".$e->getMessage());
|
1319 |
+
$this->log2->LogError($this->orderid. "| Order ".$data['market_place_order_id']." could not be imported, error: ".$e->getMessage());
|
1320 |
+
$this->restoreStock($data);
|
1321 |
+
} else {
|
1322 |
+
$this->debugLog("Order Import failed, Trying to import Order Again ->".$e->getMessage());
|
1323 |
+
$this->addOrder($data, $oLink, true);
|
1324 |
+
|
1325 |
+
}
|
1326 |
+
//error no se pudo crear la orden
|
1327 |
+
|
1328 |
+
}
|
1329 |
+
|
1330 |
+
|
1331 |
+
|
1332 |
+
}
|
1333 |
+
|
1334 |
+
|
1335 |
+
|
1336 |
+
public function restoreStock($data) {
|
1337 |
+
|
1338 |
+
try {
|
1339 |
+
foreach($data['products'] as $prod) {
|
1340 |
+
$product = Mage::getModel('catalog/product')->load($prod['id']);
|
1341 |
+
$stock = Mage::getModel('cataloginventory/stock_item')->loadByProduct($product);
|
1342 |
+
if ($stock->getQty() != $prod['curr_stock'] ) {
|
1343 |
+
$this->debugLog("Restoring Stock from Product ".$product->getId()." to: ".$prod['curr_stock'] ." due to Order Fail");
|
1344 |
+
$stockItem = Mage::getModel('cataloginventory/stock_item')->loadByProduct($product);
|
1345 |
+
$stockItem->setData('is_in_stock', 0);
|
1346 |
+
$stockItem->setData('qty', $prod['curr_stock']);
|
1347 |
+
$stockItem->save();
|
1348 |
+
$product->save();
|
1349 |
+
}
|
1350 |
+
|
1351 |
+
}
|
1352 |
+
} catch(Exception $e){
|
1353 |
+
$this->log->LogError($this->orderid. "| Failed Restoring Product Stock: ".$e->getMessage());
|
1354 |
+
$this->log2->LogError($this->orderid. "| Failed Restoring Product Stock: ".$e->getMessage());
|
1355 |
+
}
|
1356 |
+
|
1357 |
+
}
|
1358 |
+
|
1359 |
+
|
1360 |
+
|
1361 |
+
private function createProduct($data) {
|
1362 |
+
|
1363 |
+
$sku = $data['sku'];
|
1364 |
+
if(empty($data['sku'])) {
|
1365 |
+
$sku = $data['sku2'];
|
1366 |
+
}
|
1367 |
+
|
1368 |
+
Mage::app()->setCurrentStore($data['storeId']);
|
1369 |
+
$product = Mage::getModel('catalog/product');
|
1370 |
+
// if(!$product->getIdBySku('testsku61')):
|
1371 |
+
|
1372 |
+
try{
|
1373 |
+
$product
|
1374 |
+
// ->setStoreId(1) //you can set data in store scope
|
1375 |
+
->setWebsiteIds(array($data['storeId'])) //website ID the product is assigned to, as an array
|
1376 |
+
->setAttributeSetId($product->getDefaultAttributeSetId()) //ID of a attribute set named 'default'
|
1377 |
+
->setTypeId('simple') //product type
|
1378 |
+
->setCreatedAt(strtotime('now')) //product creation time
|
1379 |
+
->setSku($sku ) //SKU
|
1380 |
+
->setWeight(0)
|
1381 |
+
->setName($data['title']) //product name
|
1382 |
+
->setStatus(1) //product status (1 - enabled, 2 - disabled)
|
1383 |
+
->setTaxClassId(4) //tax class (0 - none, 1 - default, 2 - taxable, 4 - shipping)
|
1384 |
+
->setVisibility(Mage_Catalog_Model_Product_Visibility::VISIBILITY_NOT_VISIBLE ) //catalog and search visibility
|
1385 |
+
->setPrice($data['price']) //price in form 11.22
|
1386 |
+
->setMsrpEnabled(1) //enable MAP
|
1387 |
+
->setMsrpDisplayActualPriceType(1) //display actual price (1 - on gesture, 2 - in cart, 3 - before order confirmation, 4 - use config)
|
1388 |
+
->setMsrp(0) //Manufacturer's Suggested Retail Price
|
1389 |
+
->setMetaTitle('')
|
1390 |
+
->setMetaKeyword('')
|
1391 |
+
->setMetaDescription('')
|
1392 |
+
->setDescription($data['title'])
|
1393 |
+
->setShortDescription($data['title'])
|
1394 |
+
// ->setMediaGallery (array('images'=>array (), 'values'=>array ())) //media gallery initialization
|
1395 |
+
//->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
|
1396 |
+
->setStockData(array(
|
1397 |
+
'use_config_manage_stock' => 0, //'Use config settings' checkbox
|
1398 |
+
'manage_stock'=>1, //manage stock
|
1399 |
+
'min_sale_qty'=>1, //Minimum Qty Allowed in Shopping Cart
|
1400 |
+
'max_sale_qty'=>2, //Maximum Qty Allowed in Shopping Cart
|
1401 |
+
'is_in_stock' => 1, //Stock Availability
|
1402 |
+
'qty' => 1 //qty
|
1403 |
+
)
|
1404 |
+
);
|
1405 |
+
$product->save();
|
1406 |
+
return $product;
|
1407 |
+
|
1408 |
+
}catch(Exception $e){
|
1409 |
+
//log exception
|
1410 |
+
$this->log->LogError($this->orderid."| Product ".$sku." could not be created, error: ".$e->getMessage());
|
1411 |
+
$this->log2->LogError($this->orderid."| Product ".$sku." could not be created, error: ".$e->getMessage());
|
1412 |
+
return false;
|
1413 |
+
}
|
1414 |
+
}
|
1415 |
+
|
1416 |
+
|
1417 |
+
|
1418 |
+
public function setStatus($status, $order) {
|
1419 |
+
$helper = Mage::helper('beezup');
|
1420 |
+
$retorno = "";
|
1421 |
+
$blnCancel = false;
|
1422 |
+
$blnHold = false;
|
1423 |
+
switch($status) {
|
1424 |
+
case "New" :
|
1425 |
+
$this->debugLog("Setting Order Status to New");
|
1426 |
+
$retorno = $helper->getConfig('beezup/marketplace/status_new');
|
1427 |
+
break;
|
1428 |
+
case "InProgress" :
|
1429 |
+
$this->debugLog("Setting Order Status to InProgress");
|
1430 |
+
$retorno = $helper->getConfig('beezup/marketplace/status_progress');
|
1431 |
+
$this->payOrder($order);
|
1432 |
+
break;
|
1433 |
+
case "Aborted" :
|
1434 |
+
$this->debugLog("Setting Order Status to Aborted");
|
1435 |
+
$retorno = $helper->getConfig('beezup/marketplace/status_aborted');
|
1436 |
+
$blnHold = true;
|
1437 |
+
|
1438 |
+
|
1439 |
+
break;
|
1440 |
+
case "Closed" :
|
1441 |
+
$this->debugLog("Setting Order Status to Closed");
|
1442 |
+
$blnCancel =true;
|
1443 |
+
$retorno = $helper->getConfig('beezup/marketplace/status_closed');
|
1444 |
+
$this->payOrder($order);
|
1445 |
+
break;
|
1446 |
+
case "Canceled" :
|
1447 |
+
$this->debugLog("Setting Order Status to Cancelled");
|
1448 |
+
$retorno = $helper->getConfig('beezup/marketplace/status_cancelled');
|
1449 |
+
|
1450 |
+
break;
|
1451 |
+
case "Shipped" :
|
1452 |
+
$this->debugLog("Setting Order Status to Shipped");
|
1453 |
+
$retorno = $helper->getConfig('beezup/marketplace/status_shipped');
|
1454 |
+
$this->payOrder($order);
|
1455 |
+
break;
|
1456 |
+
|
1457 |
+
}
|
1458 |
+
$order->setData('state',$retorno);
|
1459 |
+
$order->setStatus($retorno);
|
1460 |
+
$history = $order->addStatusHistoryComment('Order was set to '.$retorno.' by Beezup.', false);
|
1461 |
+
$history->setIsCustomerNotified(false);
|
1462 |
+
$order->save();
|
1463 |
+
if($blnCancel) {
|
1464 |
+
$order->cancel()->save();
|
1465 |
+
}
|
1466 |
+
if($blnHold) {
|
1467 |
+
$order->hold()->save();
|
1468 |
+
}
|
1469 |
+
|
1470 |
+
return $retorno;
|
1471 |
+
|
1472 |
+
}
|
1473 |
+
|
1474 |
+
|
1475 |
+
public function getStatus($status1) {
|
1476 |
+
$helper = Mage::helper('beezup');
|
1477 |
+
$retorno = "";
|
1478 |
+
$status = strtolower($status1);
|
1479 |
+
|
1480 |
+
if($status == strtolower($helper->getConfig('beezup/marketplace/status_new') )) {
|
1481 |
+
$retorno = "New";
|
1482 |
+
|
1483 |
+
} elseif($status == strtolower($helper->getConfig('beezup/marketplace/status_progress') ) ){
|
1484 |
+
$retorno = "InProgress";
|
1485 |
+
|
1486 |
+
|
1487 |
+
}
|
1488 |
+
elseif($status == strtolower($helper->getConfig('beezup/marketplace/status_aborted') )) {
|
1489 |
+
|
1490 |
+
$retorno = "Aborted" ;
|
1491 |
+
}
|
1492 |
+
elseif($status == strtolower($helper->getConfig('beezup/marketplace/status_closed') )) {
|
1493 |
+
$retorno = "Closed";
|
1494 |
+
|
1495 |
+
}
|
1496 |
+
elseif($status == strtolower($helper->getConfig('beezup/marketplace/status_cancelled')) ) {
|
1497 |
+
|
1498 |
+
$retorno = "Canceled";
|
1499 |
+
}
|
1500 |
+
elseif($status == strtolower($helper->getConfig('beezup/marketplace/status_shipped') )) {
|
1501 |
+
|
1502 |
+
$retorno = "Shipped";
|
1503 |
+
}
|
1504 |
+
|
1505 |
+
|
1506 |
+
return $retorno;
|
1507 |
+
|
1508 |
+
}
|
1509 |
+
|
1510 |
+
|
1511 |
+
public function checkMarketOrderExists($orderid) {
|
1512 |
+
$resource = Mage::getSingleton('core/resource');
|
1513 |
+
$readConnection = $resource->getConnection('core_read');
|
1514 |
+
$table = $resource->getTableName('sales/order_grid');
|
1515 |
+
$query = 'SELECT increment_id FROM ' . $table . ' WHERE beezup_order = 1 and beezup_market_order_id = \''
|
1516 |
+
. $orderid . '\' LIMIT 1';
|
1517 |
+
$order = $readConnection->fetchOne($query);
|
1518 |
+
if($order && !empty($order) && $this->orderId !== "") {
|
1519 |
+
return $order;
|
1520 |
+
}
|
1521 |
+
return false;
|
1522 |
+
|
1523 |
+
}
|
1524 |
+
|
1525 |
+
public function payOrder($order) {
|
1526 |
+
try {
|
1527 |
+
$this->debugLog("Generating Order Payment Invoice");
|
1528 |
+
if($order->canInvoice()) {
|
1529 |
+
$invoice = $order->prepareInvoice()
|
1530 |
+
->setTransactionId($order->getId())
|
1531 |
+
->addComment("Invoice created from Beezup.")
|
1532 |
+
->register()
|
1533 |
+
->pay();
|
1534 |
+
$transaction_save = Mage::getModel('core/resource_transaction')
|
1535 |
+
->addObject($invoice)
|
1536 |
+
->addObject($invoice->getOrder());
|
1537 |
+
$transaction_save->save();
|
1538 |
+
$this->debugLog("Order Payment Invoice Generated Succesfully");
|
1539 |
+
}
|
1540 |
+
}
|
1541 |
+
catch(Exception $e){
|
1542 |
+
//log exception
|
1543 |
+
$this->log->LogError($this->orderid."| Order Payment Invoice could not be generated, error: ".$e->getMessage());
|
1544 |
+
$this->log2->LogError($this->orderid."| Order Payment Invoice could not be generated, error: ".$e->getMessage());
|
1545 |
+
}
|
1546 |
+
}
|
1547 |
+
|
1548 |
+
|
1549 |
+
|
1550 |
+
|
1551 |
+
|
1552 |
+
|
1553 |
+
}
|
app/code/community/BeezUp/Block/Order_original.php
ADDED
@@ -0,0 +1,1382 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
require_once Mage::getModuleDir('', 'BeezUp') . DS . 'lib' . DS ."KLogger.php";
|
3 |
+
require_once Mage::getModuleDir('', 'BeezUp') . DS . 'lib' . DS ."bootstrap.php";
|
4 |
+
require_once Mage::getModuleDir('', 'BeezUp') . DS . 'lib' . DS ."BeezupRepository.php";
|
5 |
+
require_once Mage::getModuleDir('', 'BeezUp') . DS . 'lib' . DS ."BeezupMageOrders.php";
|
6 |
+
|
7 |
+
class Beezup_Block_Order extends Mage_core_block_text {
|
8 |
+
|
9 |
+
protected $repository = null;
|
10 |
+
protected $oOrderService;
|
11 |
+
public $log = null;
|
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 |
+
|
22 |
+
private function makeDir() {
|
23 |
+
|
24 |
+
if (file_exists(Mage::getBaseDir('base').'/beezup/tmp')) { return true;}
|
25 |
+
|
26 |
+
if (!mkdir(Mage::getBaseDir('base').'/beezup/tmp', 0777, true))
|
27 |
+
{
|
28 |
+
echo "[ERROR] : Seems we can't create 'beezup' directory inside your root directory."."<br/>"
|
29 |
+
."You can try one of these solutions :"."<br/>"
|
30 |
+
."1 - Create by yourself the beezup/tmp inside your root directory with 777 permissions"."<br/>"
|
31 |
+
."2 - Change the permissions on your root directory (777)"."<br/>"
|
32 |
+
."3 - Change the 'cache delay' option to 'None' inside beezup plugin settings"."<br/>";
|
33 |
+
return false;
|
34 |
+
}
|
35 |
+
return true;
|
36 |
+
|
37 |
+
}
|
38 |
+
public function createOrderFromLink($account_id, $marketplace_code, $beezup_order_id) {
|
39 |
+
$this->makeDir();
|
40 |
+
$logDir = Mage::getBaseDir('base').'/beezup/';
|
41 |
+
if(file_exists($logDir."log2.txt")) {
|
42 |
+
if(filesize($logDir."/log2.txt") >=3000000) {
|
43 |
+
unlink($logDir."log2.txt");
|
44 |
+
}
|
45 |
+
}
|
46 |
+
$sync_end_date = new DateTime ( 'now', new DateTimeZone ( 'UTC' ));
|
47 |
+
$helper = Mage::helper('beezup');
|
48 |
+
$sync_status = $helper->getConfig('beezup/marketplace/sync_status');
|
49 |
+
$debug_mode = $helper->getConfig('beezup/marketplace/debug_mode');
|
50 |
+
$create_customer = $helper->getConfig("beezup/marketplace/create_customers");
|
51 |
+
if($create_customer == 0) {
|
52 |
+
$this->blnCreateCustomer = true;
|
53 |
+
}
|
54 |
+
|
55 |
+
if($debug_mode==1) {
|
56 |
+
$this->debug = true;
|
57 |
+
}
|
58 |
+
if($sync_status!==1) {
|
59 |
+
$configModel = Mage::getModel('core/config');
|
60 |
+
$configModel->saveConfig('beezup/marketplace/sync_status',1);
|
61 |
+
|
62 |
+
|
63 |
+
|
64 |
+
unlink($logDir."log.txt");
|
65 |
+
$this->log = new KLogger ( $logDir."log.txt" , KLogger::DEBUG );
|
66 |
+
$this->log2 = new KLogger ( $logDir."log2.txt" , KLogger::DEBUG );
|
67 |
+
$this->debugLog("Initializing OM Importation");
|
68 |
+
$this->account_id = $account_id;
|
69 |
+
$this->marketplace_code = $marketplace_code;
|
70 |
+
$this->beezup_order_id = $beezup_order_id;
|
71 |
+
$orderResponse = $this->getBeezupOrder();
|
72 |
+
if($orderResponse) {
|
73 |
+
|
74 |
+
|
75 |
+
$this->createOrder($orderResponse);
|
76 |
+
|
77 |
+
$configModel->saveConfig('beezup/marketplace/sync_status',0);
|
78 |
+
if($this->mage_order_id) {
|
79 |
+
echo "<script>window.location='".Mage::helper('adminhtml')->getUrl("adminhtml/sales_order/view", array('order_id'=> $this->mage_order_id))."';</script>";
|
80 |
+
}
|
81 |
+
// die("Order Importation finalized");
|
82 |
+
|
83 |
+
}
|
84 |
+
|
85 |
+
}
|
86 |
+
$configModel->saveConfig('beezup/marketplace/sync_status',0);
|
87 |
+
//die("Error, Order data incorrect");
|
88 |
+
echo $this->_showLog();
|
89 |
+
}
|
90 |
+
|
91 |
+
public function _showLog() {
|
92 |
+
$logDir = Mage::getBaseDir('base').'/beezup/';
|
93 |
+
// $log1 = file_get_contents();
|
94 |
+
$ret = array();
|
95 |
+
if (file_exists($logDir."/log.txt")) {
|
96 |
+
$f = fopen($logDir."/log.txt", 'r');
|
97 |
+
|
98 |
+
if ($f) {
|
99 |
+
while (!feof($f)) {
|
100 |
+
$ret[] = fgetcsv($f, 0, '|');
|
101 |
+
}
|
102 |
+
fclose($f);
|
103 |
+
}
|
104 |
+
}
|
105 |
+
array_slice(array_reverse($ret), 1, 10);
|
106 |
+
|
107 |
+
return $this->_getTable($ret);
|
108 |
+
|
109 |
+
}
|
110 |
+
|
111 |
+
|
112 |
+
public function _getTable($data) {
|
113 |
+
$url = Mage::getBaseUrl( Mage_Core_Model_Store::URL_TYPE_WEB, true );
|
114 |
+
$html = "<td></td><td></td><tr></tr></tbody></table>
|
115 |
+
|
116 |
+
<div class='grid' style=' height: 600px;overflow-y: scroll;padding: 16px;border: 3px solid #e6e6e6;' id='marketPlaceLogBlock'>";
|
117 |
+
$html .= '<p>'. Mage::helper('beezup')->__('For full logs see here:').' <a href="'.$url .'beezup/log/load" target="_blank">'.$url .'beezup/log/load</a></p>';
|
118 |
+
$html .= "<table class='data' style='margin-top:0px;width:100%;'>";
|
119 |
+
$html .= "<tr class='headings'>";
|
120 |
+
$html .= '<th><span class="nobr">Time</span></th>';
|
121 |
+
$html .= '<th><span class="nobr">Type</span></th>';
|
122 |
+
$html .= '<th><span class="nobr">Order Id</span></th>';
|
123 |
+
$html .= '<th><span class="nobr">Message</span></th>';
|
124 |
+
$html .= "</tr>";
|
125 |
+
$html .= "<tbody>";
|
126 |
+
foreach($data as $d) {
|
127 |
+
$background = " background: rgb(240, 184, 184)";
|
128 |
+
if($d[1] == " INFO " ) {
|
129 |
+
$background = " background: rgb(210, 227, 253)";
|
130 |
+
}
|
131 |
+
$orderId = (isset($d[3])) ? $d[2] : "";
|
132 |
+
$message = (isset($d[3])) ? $d[3] : $d[2];
|
133 |
+
$html .= "<tr class='even pointer' style='".$background."'>";
|
134 |
+
$html .= "<td>".$d[0]."</td>";
|
135 |
+
$html .= "<td>".$d[1]."</td>";
|
136 |
+
$html .= "<td>".$orderId."</td>";
|
137 |
+
$html .= "<td>".$message."</td>";
|
138 |
+
$html .= "</tr>";
|
139 |
+
|
140 |
+
}
|
141 |
+
|
142 |
+
$html .= "<tbody>";
|
143 |
+
$html .= '</table>';
|
144 |
+
$html .= "</div>";
|
145 |
+
|
146 |
+
return $html;
|
147 |
+
}
|
148 |
+
|
149 |
+
|
150 |
+
|
151 |
+
public function executeCron() {
|
152 |
+
|
153 |
+
$this->makeDir();
|
154 |
+
|
155 |
+
set_time_limit(0);
|
156 |
+
$logDir = Mage::getBaseDir('base').'/beezup/';
|
157 |
+
if(file_exists($logDir."log2.txt")) {
|
158 |
+
if(filesize($logDir."/log2.txt") >=3000000) {
|
159 |
+
unlink($logDir."log2.txt");
|
160 |
+
}
|
161 |
+
}
|
162 |
+
|
163 |
+
$sync_end_date = new DateTime ( 'now', new DateTimeZone ( 'UTC' ));
|
164 |
+
$helper = Mage::helper('beezup');
|
165 |
+
$sync_status = $helper->getConfig('beezup/marketplace/sync_status');
|
166 |
+
$debug_mode = $helper->getConfig('beezup/marketplace/debug_mode');
|
167 |
+
$create_customer = $helper->getConfig("beezup/marketplace/create_customers");
|
168 |
+
if($create_customer == 0) {
|
169 |
+
$this->blnCreateCustomer = true;
|
170 |
+
}
|
171 |
+
|
172 |
+
if($debug_mode==1) {
|
173 |
+
$this->debug = true;
|
174 |
+
}
|
175 |
+
|
176 |
+
if($sync_status!==1) {
|
177 |
+
$configModel = Mage::getModel('core/config');
|
178 |
+
$configModel->saveConfig('beezup/marketplace/sync_status',1);
|
179 |
+
|
180 |
+
|
181 |
+
|
182 |
+
unlink($logDir."log.txt");
|
183 |
+
$this->log = new KLogger ( $logDir."log.txt" , KLogger::DEBUG );
|
184 |
+
$this->log2 = new KLogger ( $logDir."log2.txt" , KLogger::DEBUG );
|
185 |
+
$this->debugLog("Initializing OM Importation");
|
186 |
+
|
187 |
+
|
188 |
+
$this->getOrderList();
|
189 |
+
|
190 |
+
$this->repository->updateLastSynchronizationDate( $sync_end_date);
|
191 |
+
$this->orderid = "";
|
192 |
+
$this->debugLog("OM Importation finalized succesfully");
|
193 |
+
$configModel->saveConfig('beezup/marketplace/sync_status',0);
|
194 |
+
echo "OM Importation finalized succesfully";
|
195 |
+
|
196 |
+
} else {
|
197 |
+
|
198 |
+
echo "Order Importation is already being executed";
|
199 |
+
}
|
200 |
+
|
201 |
+
}
|
202 |
+
|
203 |
+
|
204 |
+
public function getLog() {
|
205 |
+
$logDir = Mage::getBaseDir('base').'/beezup/';
|
206 |
+
$log1 = file_get_contents($logDir."/log2.txt");
|
207 |
+
|
208 |
+
echo "<pre>";
|
209 |
+
print_r($log1);
|
210 |
+
echo "</pre>";
|
211 |
+
|
212 |
+
}
|
213 |
+
public function getBeezupOrder() {
|
214 |
+
|
215 |
+
$oOrderIdentifier = $this->getBeezupOrderId();
|
216 |
+
$oBeezupOMOrderResponse = $this->getOrderService()->getOrder($oOrderIdentifier);
|
217 |
+
if ($oBeezupOMOrderResponse && $oBeezupOMOrderResponse->getResult()){
|
218 |
+
return $oBeezupOMOrderResponse;
|
219 |
+
}
|
220 |
+
|
221 |
+
|
222 |
+
return false;
|
223 |
+
}
|
224 |
+
|
225 |
+
public function getBeezupOrderId(){
|
226 |
+
$oIdentifier = new BeezupOMOrderIdentifier();
|
227 |
+
$oIdentifier
|
228 |
+
->setAccountId($this->account_id)
|
229 |
+
->setMarketplaceTechnicalCode($this->marketplace_code)
|
230 |
+
->setBeezupOrderUUID($this->beezup_order_id);
|
231 |
+
return $oIdentifier;
|
232 |
+
}
|
233 |
+
|
234 |
+
|
235 |
+
public function createOrder($oBeezupOrderResponse) {
|
236 |
+
|
237 |
+
$etag = $oBeezupOrderResponse->getETag();
|
238 |
+
$final_order = $oBeezupOrderResponse->getResult();
|
239 |
+
|
240 |
+
$orderid = $final_order->getOrderMarketPlaceOrderId();
|
241 |
+
$this->orderid = $orderid;
|
242 |
+
//customer Info
|
243 |
+
$order_address = $final_order->getOrderBuyerAddressCity();
|
244 |
+
$order_country = $final_order->getOrderBuyerAddressCountryName();
|
245 |
+
$order_country_iso = $final_order->getOrderBuyerAddressCountryIsoCodeAlpha2();
|
246 |
+
$order_address = $this->getBeezupBuyerAddress($final_order);
|
247 |
+
$order_postalCode = $final_order->getOrderBuyerAddressPostalCode();
|
248 |
+
$order_customer = $final_order->getOrderBuyerName();
|
249 |
+
$order_customer_email = $final_order->getOrderBuyerEmail();
|
250 |
+
$order_customer_phone = $final_order->getOrderBuyerPhone();
|
251 |
+
$order_customer_mobile = $final_order->getOrderBuyerMobilePhone();
|
252 |
+
$order_comment = $final_order->getOrderComment();
|
253 |
+
$order_company = $final_order->getOrderBuyerCompanyName();
|
254 |
+
$order_city = $final_order->getOrderBuyerAddressCity();
|
255 |
+
$order_region = $final_order->getOrderBuyerStateOrRegion();
|
256 |
+
$order_status = $final_order->getOrderStatusBeezUPOrderStatus();
|
257 |
+
//shipping information
|
258 |
+
$shipping_city = $final_order->getOrderShippingAddressCity();
|
259 |
+
$shipping_country = $final_order->getOrderShippingAddressCountryName();
|
260 |
+
$shipping_country_iso = $final_order->getOrderShippingAddressCountryIsoCodeAlpha2();
|
261 |
+
$shipping_address = $this->getBeezupShippingAddress($final_order);
|
262 |
+
$shipping_name = $final_order->getOrderShippingAddressName();
|
263 |
+
$shipping_postalCode = $final_order->getOrderShippingAddressPostalCode();
|
264 |
+
$shipping_email = $final_order->getOrderShippingEmail();
|
265 |
+
$shipping_phone = $final_order->getOrderShippingPhone();
|
266 |
+
$shipping_mobile = $final_order->getOrderShippingMobilePhone();
|
267 |
+
$shipping_company = $final_order->getOrderShippingCompanyName();
|
268 |
+
$shipping_region = $final_order->getOrderShippingAddressStateOrRegion();
|
269 |
+
$order_currency_code = $final_order->getOrderCurrencyCode();
|
270 |
+
//order Info
|
271 |
+
$order_totalPrice = $final_order->getOrderTotalPrice();
|
272 |
+
$order_shippingPrice = $final_order->getOrderShippingPrice();
|
273 |
+
|
274 |
+
$name_parts = explode(" ", $order_customer);
|
275 |
+
$order_first_name = array_shift( $name_parts);
|
276 |
+
$order_last_name = implode(" ", $name_parts);
|
277 |
+
|
278 |
+
|
279 |
+
$name_parts = explode(" ", $shipping_name);
|
280 |
+
$shipping_first_name = array_shift( $name_parts);
|
281 |
+
$shipping_last_name = implode(" ", $name_parts);
|
282 |
+
|
283 |
+
|
284 |
+
//marketplace information
|
285 |
+
$marketplace_business_code = $final_order->getMarketPlaceBusinessCode();
|
286 |
+
$marketplace = $final_order->getMarketPlaceTechnicalCode();
|
287 |
+
|
288 |
+
//productInfo
|
289 |
+
|
290 |
+
$mage_productIds = $this->prescanOrder($final_order);
|
291 |
+
|
292 |
+
|
293 |
+
if(!$this->checkEtagExists($etag)) {
|
294 |
+
if(empty($order_customer_email)) {
|
295 |
+
$order_customer_email = $this->generateEmail($final_order);
|
296 |
+
}
|
297 |
+
elseif(!filter_var($order_customer_email, FILTER_VALIDATE_EMAIL)) {
|
298 |
+
$order_customer_email = $this->generateEmail($final_order);
|
299 |
+
}
|
300 |
+
if($order_country_iso == "FX" || $order_country_iso == "fx") {
|
301 |
+
$order_country_iso = "FR";
|
302 |
+
}
|
303 |
+
if($shipping_country_iso == "FX" || $shipping_country_iso == "fx") {
|
304 |
+
$shipping_country_iso = "FR";
|
305 |
+
}
|
306 |
+
$mage_productIds = $this->prescanOrder($final_order);
|
307 |
+
if($mage_productIds) {
|
308 |
+
$order_data = array(
|
309 |
+
"etag" => $etag,
|
310 |
+
"account_id" => $account_id,
|
311 |
+
"order_status" => $order_status,
|
312 |
+
"products" => $mage_productIds['products'],
|
313 |
+
"storeid" => $mage_productIds['store'],
|
314 |
+
"order_currency" => $order_currency_code ,
|
315 |
+
"order_address" => $order_adress,
|
316 |
+
"order_country" => $order_country,
|
317 |
+
"order_country_iso" => $order_country_iso ,
|
318 |
+
"order_address" => $order_address ,
|
319 |
+
"order_postalCode" => $order_postalCode ,
|
320 |
+
"order_customer" => $order_first_name ,
|
321 |
+
"order_lastname" => $order_last_name ,
|
322 |
+
"order_customer_email" => $order_customer_email ,
|
323 |
+
"order_customer_phone" => $this->getPhone($order_customer_phone, $order_customer_mobile) ,
|
324 |
+
"order_comment" => $order_comment ,
|
325 |
+
"order_company" => $order_company ,
|
326 |
+
"shipping_city" => $shipping_city ,
|
327 |
+
"shipping_country" => $shipping_country ,
|
328 |
+
"shipping_country_iso" => $shipping_country_iso ,
|
329 |
+
"shipping_address" => $shipping_address ,
|
330 |
+
"shipping_name" => $shipping_first_name ,
|
331 |
+
"shipping_lastname" => $shipping_last_name ,
|
332 |
+
"shipping_postalCode" => $shipping_postalCode ,
|
333 |
+
"shipping_region" =>$shipping_region,
|
334 |
+
"shipping_email" => $shipping_email ,
|
335 |
+
"shipping_phone" => $this->getPhone($shipping_phone, $shipping_mobile) ,
|
336 |
+
"shipping_company" => $shipping_company ,
|
337 |
+
"order_totalPrice" => $order_totalPrice ,
|
338 |
+
"order_shippingPrice" => $order_shippingPrice ,
|
339 |
+
"order_city" => $order_city,
|
340 |
+
"order_region" => $order_region,
|
341 |
+
"marketplace" => $marketplace,
|
342 |
+
"discounts" => $mage_productIds['discounts'],
|
343 |
+
"marketplace_business_code" => $marketplace_business_code
|
344 |
+
);
|
345 |
+
|
346 |
+
|
347 |
+
|
348 |
+
//check if order exists
|
349 |
+
$Mageorder = $this->loadMageOrder();
|
350 |
+
if ($Mageorder) {
|
351 |
+
//if order exists
|
352 |
+
$this->updateEtag($etag);
|
353 |
+
$this->updateBilling($Mageorder, $order_data );
|
354 |
+
$this->updateBeezupInfoTab($Mageorder, $final_order, $order_data);
|
355 |
+
$this->debugLog("Order Already exists Mage Order ID: " .$Mageorder->getId());
|
356 |
+
$status1 = $Mageorder->getStatusLabel();
|
357 |
+
$status = $this->getStatus($status1);
|
358 |
+
if($status !== $order_status) {
|
359 |
+
//if order exits and status has changed we update order status
|
360 |
+
$this->debugLog("Updating Order Status from: ".$status1." to: ".$order_status );
|
361 |
+
$this->setStatus( $order_status, $Mageorder);
|
362 |
+
}
|
363 |
+
|
364 |
+
$id_order = $Mageorder->getId();
|
365 |
+
$BeezupMageOrder = new BeezupMageOrders($id_order);
|
366 |
+
$BeezupMageOrder->setData(array("shipping" =>(float) $order_data['order_shippingPrice']));
|
367 |
+
$BeezupMageOrder->updateShippingInfo();
|
368 |
+
} else {
|
369 |
+
//if not we create order
|
370 |
+
|
371 |
+
|
372 |
+
$this->debugLog("Generating Order");
|
373 |
+
$this->addOrder($order_data,$final_order );
|
374 |
+
//die();
|
375 |
+
|
376 |
+
}
|
377 |
+
|
378 |
+
|
379 |
+
} else {
|
380 |
+
//order could not be imported
|
381 |
+
|
382 |
+
|
383 |
+
}
|
384 |
+
|
385 |
+
|
386 |
+
} else {
|
387 |
+
//etag has not changed
|
388 |
+
$this->debugLog("Order Etag has not changed");
|
389 |
+
|
390 |
+
}
|
391 |
+
|
392 |
+
|
393 |
+
|
394 |
+
|
395 |
+
|
396 |
+
}
|
397 |
+
|
398 |
+
|
399 |
+
|
400 |
+
public function generateEmail(BeezupOMOrderResult $oBeezupOrder)
|
401 |
+
{
|
402 |
+
$sRawValue = $oBeezupOrder->getBeezupOrderUUID ();
|
403 |
+
$sFakeDomain = preg_replace ( '/\W/', '', $oBeezupOrder->getMarketPlaceTechnicalCode () ) . '.com';
|
404 |
+
return 'fakeemail' . md5 ( $sFakeDomain . $sRawValue ) . '@' . strtolower ( $sFakeDomain );
|
405 |
+
}
|
406 |
+
|
407 |
+
|
408 |
+
|
409 |
+
public function getOrderList($orderList = null) {
|
410 |
+
if($orderList == null) {
|
411 |
+
$data = $this->createRepository()->createOrderListRequest();
|
412 |
+
$oRequest = $this->getOrderService()->getClientProxy()->getOrderList($data);
|
413 |
+
$orderList = $oRequest->getResult();
|
414 |
+
}
|
415 |
+
$oPagination = $orderList->getPaginationResult();
|
416 |
+
if(!empty($oPagination)) {
|
417 |
+
$oLinksTotal = $oPagination->getLinks();
|
418 |
+
} else {
|
419 |
+
$configModel = Mage::getModel('core/config');
|
420 |
+
$configModel->saveConfig('beezup/marketplace/sync_status',0);
|
421 |
+
die("No more orders to import");
|
422 |
+
}
|
423 |
+
|
424 |
+
//$header = $orderList->getOrderHeaders();
|
425 |
+
foreach($orderList->getOrderHeaders() as $order) {
|
426 |
+
$order_status = $order->getBeezupOrderState();
|
427 |
+
$orderLinks = $order->getLinks();
|
428 |
+
$etag = $order->getETag();
|
429 |
+
$beezup_order_id = $order->getBeezupOrderUUID();
|
430 |
+
$account_id = $order->getAccountId();
|
431 |
+
$orderdata = $this->getOrderService()->getClientProxy()->getOrderByLink($orderLinks[0]);
|
432 |
+
$this->debugLog("Initializing Order - Link: ".$orderLinks[0]->getHref());
|
433 |
+
$this->createOrder($orderdata);
|
434 |
+
|
435 |
+
}
|
436 |
+
|
437 |
+
if(!empty($oLinksTotal)) {
|
438 |
+
//we check if there is next link and get next orders
|
439 |
+
foreach($oLinksTotal as $link) {
|
440 |
+
if( $link->getRel() == "next") {
|
441 |
+
|
442 |
+
$this->log->LogInfo("Initializing New Order List ->". $link->getHref());
|
443 |
+
$this->log2->LogInfo("Initializing New Order List ->". $link->getHref());
|
444 |
+
$oRequest = $this->getOrderService()->getClientProxy()->getOrderListByLink($link);
|
445 |
+
$orderList = $oRequest->getResult();
|
446 |
+
$this->getOrderList($orderList);
|
447 |
+
}
|
448 |
+
|
449 |
+
}
|
450 |
+
}
|
451 |
+
|
452 |
+
}
|
453 |
+
|
454 |
+
|
455 |
+
|
456 |
+
public function updateBeezupInfoTab($order, $oLink, $data) {
|
457 |
+
$beezup_last_modification_date = $oLink->getOrderLastModificationUtcDate();
|
458 |
+
$beezup_last_modification_date = $beezup_last_modification_date->date;
|
459 |
+
$beezup_marketplace_last_modification_date = $oLink->getOrderMarketPlaceLastModificationUtcDate();
|
460 |
+
$beezup_marketplace_last_modification_date = $beezup_marketplace_last_modification_date->date;
|
461 |
+
$beezup_comission = $oLink->getOrderTotalCommission()." ".$data['order_currency'];
|
462 |
+
$tot_comm = $oLink->getOrderTotalCommission();
|
463 |
+
if(empty($tot_comm ) || $tot_comm == 0) {
|
464 |
+
$beezup_comission = 0;
|
465 |
+
}
|
466 |
+
$updateData = array("beezup_status" => $data['order_status'],
|
467 |
+
"beezup_last_modification_date" => $beezup_last_modification_date,
|
468 |
+
"beezup_marketplace_last_modification_date" => $beezup_marketplace_last_modification_date ,
|
469 |
+
"beezup_total_paid" => $oLink->getOrderTotalPrice()." ".$data['order_currency'],
|
470 |
+
"beezup_comission" => $beezup_comission,
|
471 |
+
"beezup_marketplace_status" => $oLink->getOrderStatusMarketPlaceStatus());
|
472 |
+
$orderId = $order->getId();
|
473 |
+
$beezupMageOrder = new BeezupMageOrders($orderId);
|
474 |
+
$beezupMageOrder->setData($updateData);
|
475 |
+
$beezupMageOrder->updateBeezupInfo();
|
476 |
+
|
477 |
+
|
478 |
+
}
|
479 |
+
|
480 |
+
public function getPhone($phone, $phone2) {
|
481 |
+
$retorno = "";
|
482 |
+
if(!empty($phone) && $phone !== "") {
|
483 |
+
$retorno .= $phone;
|
484 |
+
}
|
485 |
+
if(!empty($phone2) && $phone2 !=="") {
|
486 |
+
if(empty($phone) || $phone == "") {
|
487 |
+
$retorno = $phone2;
|
488 |
+
|
489 |
+
} else {
|
490 |
+
$retorno .= " - ".$phone2;
|
491 |
+
}
|
492 |
+
}
|
493 |
+
return $retorno;
|
494 |
+
}
|
495 |
+
|
496 |
+
|
497 |
+
public function getBeezupBuyerAddress($order) {
|
498 |
+
$add1=$order->getOrderBuyerAddressLine1();
|
499 |
+
$add2=$order->getOrderBuyerAddressLine2();
|
500 |
+
$add3=$order->getOrderBuyerAddressLine3();
|
501 |
+
$retorno = "";
|
502 |
+
if(!empty($add1)) {
|
503 |
+
$retorno = $order->getOrderBuyerAddressLine1();
|
504 |
+
}
|
505 |
+
if(!empty($add2)) {
|
506 |
+
if(empty($add1)) {
|
507 |
+
$retorno .= $order->getOrderBuyerAddressLine2();
|
508 |
+
} else {
|
509 |
+
$retorno .= " - ". $order->getOrderBuyerAddressLine2();
|
510 |
+
}
|
511 |
+
}
|
512 |
+
if(!empty($add3)){
|
513 |
+
if(empty($add1) && empty($add2)) {
|
514 |
+
$retorno .= $order->getOrderBuyerAddressLine3();
|
515 |
+
} else {
|
516 |
+
$retorno .= " - ". $order->getOrderBuyerAddressLine3();
|
517 |
+
}
|
518 |
+
}
|
519 |
+
return $retorno;
|
520 |
+
}
|
521 |
+
|
522 |
+
|
523 |
+
public function getBeezupShippingAddress($order) {
|
524 |
+
$add1 = $order->getOrderShippingAddressLine1();
|
525 |
+
$add2 = $order->getOrderShippingAddressLine2();
|
526 |
+
$add3=$order->getOrderBuyerAddressLine3();
|
527 |
+
$retorno = "";
|
528 |
+
if(!empty($add1 )) {
|
529 |
+
$retorno = $order->getOrderShippingAddressLine1();
|
530 |
+
}
|
531 |
+
if(!empty($add2)) {
|
532 |
+
if(empty($add1)) {
|
533 |
+
$retorno .= $order->getOrderShippingAddressLine2();
|
534 |
+
} else {
|
535 |
+
$retorno .= " - ". $order->getOrderShippingAddressLine2();
|
536 |
+
}
|
537 |
+
}
|
538 |
+
if(!empty($add3)){
|
539 |
+
if(empty($add1) && empty($add2)) {
|
540 |
+
$retorno .= $order->getOrderShippingAddressLine3();
|
541 |
+
} else {
|
542 |
+
$retorno .= " - ". $order->getOrderShippingAddressLine3();
|
543 |
+
}
|
544 |
+
}
|
545 |
+
return $retorno;
|
546 |
+
}
|
547 |
+
|
548 |
+
public function checkEtagExists($etag) {
|
549 |
+
$resource = Mage::getSingleton('core/resource');
|
550 |
+
$readConnection = $resource->getConnection('core_read');
|
551 |
+
$table = $resource->getTableName('sales/order_grid');
|
552 |
+
$query = 'SELECT increment_id FROM ' . $table . ' WHERE beezup_etag = \''
|
553 |
+
. $etag . '\' LIMIT 1';
|
554 |
+
$order = $readConnection->fetchOne($query);
|
555 |
+
if($order && !empty($order)) {
|
556 |
+
return true;
|
557 |
+
}
|
558 |
+
return false;
|
559 |
+
|
560 |
+
}
|
561 |
+
|
562 |
+
|
563 |
+
public function updateEtag($etag) {
|
564 |
+
$this->debugLog("Updating Etag");
|
565 |
+
$resource = Mage::getSingleton('core/resource');
|
566 |
+
$writeConnection = $resource->getConnection('core_write');
|
567 |
+
$table = $resource->getTableName('sales/order_grid');
|
568 |
+
$query = "UPDATE {$table} SET beezup_etag = '{$etag}' where beezup_market_order_id = '{$this->orderid}' ";
|
569 |
+
$writeConnection->query($query);
|
570 |
+
|
571 |
+
}
|
572 |
+
|
573 |
+
|
574 |
+
|
575 |
+
public function updateBilling($order, $data) {
|
576 |
+
|
577 |
+
|
578 |
+
$addressData = array(
|
579 |
+
'billing_company' => ($data['order_company']) ? $data['order_company'] : "",
|
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_company' => ($data['shipping_company']) ? $data['shipping_company'] : "",
|
596 |
+
'shipping_region_id' => ($data['shipping_region']) ? substr($data['shipping_region'], 0, 2) : "EM" // id from directory_country_region table
|
597 |
+
);
|
598 |
+
|
599 |
+
$shippingData = array(
|
600 |
+
|
601 |
+
);
|
602 |
+
// Get the id of the orders shipping address
|
603 |
+
$orderId = $order->getId();
|
604 |
+
$beezupMageOrder = new BeezupMageOrders($orderId);
|
605 |
+
$beezupMageOrder->setData($addressData);
|
606 |
+
$beezupMageOrder->updateAdresses();
|
607 |
+
}
|
608 |
+
|
609 |
+
public function updateAddresses($shippingData, $address) {
|
610 |
+
if($shippingData['firstname'] !==$address['firstname']) {
|
611 |
+
$address->setFirstname($shippingData['firstname']);
|
612 |
+
}
|
613 |
+
if($shippingData['lastname'] !==$address['lastname']) {
|
614 |
+
$address->setLastname($shippingData['lastname']);
|
615 |
+
}
|
616 |
+
if($shippingData['street'] !==$address['street']) {
|
617 |
+
$address->setStreet($shippingData['street']);
|
618 |
+
}
|
619 |
+
if($shippingData['city'] !==$address['city']) {
|
620 |
+
$address->setCity($shippingData['city']);
|
621 |
+
}
|
622 |
+
if($shippingData['postcode'] !==$address['postcode']) {
|
623 |
+
$address->setPostcode($shippingData['postcode']);
|
624 |
+
}
|
625 |
+
if($shippingData['telephone'] !==$address['telephone']) {
|
626 |
+
$address->setTelephone($shippingData['telephone']);
|
627 |
+
}
|
628 |
+
$address->save();
|
629 |
+
|
630 |
+
|
631 |
+
}
|
632 |
+
|
633 |
+
|
634 |
+
public function loadMageOrder() {
|
635 |
+
$Mageorder = Mage::getModel('sales/order')->loadByIncrementId($this->orderid);
|
636 |
+
if ($Mageorder->getId()) {
|
637 |
+
return $Mageorder;
|
638 |
+
} else {
|
639 |
+
//we get order from marketplace orderid
|
640 |
+
$orderInc = $this->checkMarketOrderExists($this->orderid);
|
641 |
+
if($orderInc) {
|
642 |
+
// if exists
|
643 |
+
$Mageorder = Mage::getModel('sales/order')->loadByIncrementId($orderInc);
|
644 |
+
if ($Mageorder->getId()) {
|
645 |
+
return $Mageorder;
|
646 |
+
}
|
647 |
+
}
|
648 |
+
}
|
649 |
+
return false;
|
650 |
+
}
|
651 |
+
|
652 |
+
|
653 |
+
private function debugLog($message) {
|
654 |
+
|
655 |
+
if($this->orderid !== "") {
|
656 |
+
$message = $this->orderid." | ".$message;
|
657 |
+
}
|
658 |
+
$this->log->LogInfo($message);
|
659 |
+
|
660 |
+
$this->log2->LogInfo($message);
|
661 |
+
}
|
662 |
+
|
663 |
+
public function prescanOrder(BeezupOMOrderResult $order) {
|
664 |
+
$retorno = array();
|
665 |
+
$orderItems = $order->getOrderItems();
|
666 |
+
foreach ($orderItems as $item)
|
667 |
+
{
|
668 |
+
|
669 |
+
if ($item->getOrderItemOrderItemType () !== 'Product')
|
670 |
+
{
|
671 |
+
// continue;
|
672 |
+
}
|
673 |
+
$beezup_store = $item->getOrderItemBeezUPStoreId(); //beezup storeid
|
674 |
+
$mage_storeid = $this->checkOrderStore($beezup_store); //magento storeid
|
675 |
+
$marketplace_orderid = $item->getOrderItemMarketPlaceProductId();
|
676 |
+
if(!$mage_storeid) {
|
677 |
+
|
678 |
+
if(strpos($marketplace_orderid,'INTERETBCA') !== false || strpos($marketplace_orderid,'interetbca') !== false) { }
|
679 |
+
else {
|
680 |
+
$this->log->LogError($this->orderid." | No mapping for store ".$beezup_store);
|
681 |
+
$this->log2->LogError($this->orderid." | No mapping for store ".$beezup_store);
|
682 |
+
return false;
|
683 |
+
}
|
684 |
+
|
685 |
+
}
|
686 |
+
// $retorno['store'] = 1;
|
687 |
+
|
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 |
+
$retorno['store'] = $mage_storeid;
|
699 |
+
$this->debugLog("Store Matching succesful, Beezup Store: ".$beezup_store." , Magento Store Id: ".$mage_storeid);
|
700 |
+
$product = $this->getMageProduct($product_ImportedMerchantId , $product_MerchantId , $beezup_store );
|
701 |
+
if($product) {
|
702 |
+
$mage_productId = $product->getId();
|
703 |
+
$stocklevel = (int)Mage::getModel('cataloginventory/stock_item')
|
704 |
+
->loadByProduct($product)->getQty();
|
705 |
+
|
706 |
+
$retorno['products'][] = array("id" => $mage_productId, "qty" => $product_quantity, "price" => $product_price, "curr_stock" => $stocklevel);
|
707 |
+
//producto existe
|
708 |
+
} else {
|
709 |
+
//vendria if de si activada opcion de crear producto creamos
|
710 |
+
if(!$this->debug) {
|
711 |
+
return false;
|
712 |
+
}
|
713 |
+
$product_data = array(
|
714 |
+
"sku" => $product_ImportedMerchantId,
|
715 |
+
"sku2" => $product_MerchantId,
|
716 |
+
"qty" => $product_quantity,
|
717 |
+
"price" => $product_price,
|
718 |
+
"title" => $product_title,
|
719 |
+
"image" => $product_image,
|
720 |
+
"storeId" => $mage_storeid
|
721 |
+
);
|
722 |
+
$product = $this->createProduct($product_data);
|
723 |
+
if(!$product) {
|
724 |
+
return false;
|
725 |
+
}
|
726 |
+
$stocklevel = (int)Mage::getModel('cataloginventory/stock_item')
|
727 |
+
->loadByProduct($product)->getQty();
|
728 |
+
$mage_productId = $product->getId();
|
729 |
+
$retorno['products'][] = array("id" => $mage_productId, "qty" => $product_quantity, "price" => $product_price, "curr_stock" => $stocklevel);
|
730 |
+
}
|
731 |
+
}
|
732 |
+
}
|
733 |
+
|
734 |
+
return $retorno;
|
735 |
+
}
|
736 |
+
|
737 |
+
|
738 |
+
|
739 |
+
public function matchProductAttributes($importedId, $storeId) {
|
740 |
+
$product = null;
|
741 |
+
$helper = Mage::helper('beezup');
|
742 |
+
$attributes = $helper->getConfig('beezup/marketplace/attributes');
|
743 |
+
$attributes = unserialize ($attributes);
|
744 |
+
|
745 |
+
foreach($attributes['attributes'][$storeId ] as $attribute) {
|
746 |
+
$att = explode("|", $attribute);
|
747 |
+
if($storeId == $att[1]) {
|
748 |
+
|
749 |
+
$product=Mage::getModel('catalog/product')->loadByAttribute($att[0],$importedId);
|
750 |
+
if($product) {
|
751 |
+
break;
|
752 |
+
}
|
753 |
+
}
|
754 |
+
}
|
755 |
+
|
756 |
+
return $product;
|
757 |
+
}
|
758 |
+
|
759 |
+
|
760 |
+
|
761 |
+
public function getMageProduct($importedId, $merchantId, $storeId){
|
762 |
+
try {
|
763 |
+
$product=Mage::getModel('catalog/product')->load($importedId);
|
764 |
+
if (!$product->getId() || $product->getId() !== $importedId ){
|
765 |
+
$product = $this->matchProductAttributes($importedId, $storeId);
|
766 |
+
if($product == null || !is_object($product)) {
|
767 |
+
$product=Mage::getModel('catalog/product')->load($merchantId);
|
768 |
+
if(!$product->getId() || $product->getId() !== $merchantId ) {
|
769 |
+
$product = $this->matchProductAttributes($merchantId, $storeId);
|
770 |
+
|
771 |
+
}
|
772 |
+
}
|
773 |
+
}
|
774 |
+
|
775 |
+
if(is_object($product)) {
|
776 |
+
if($product->getId()) {
|
777 |
+
$this->debugLog("Product Matching succesful, Beezup Imported Id: ".$importedId." , Magento Product Id: ".$product->getId());
|
778 |
+
return $product;
|
779 |
+
}}
|
780 |
+
$this->log->LogError($this->orderid. "| No Product Matching, Product ".$importedId." could not be found");
|
781 |
+
$this->log2->LogError($this->orderid. "| No Product Matching, Product ".$importedId." could not be found");
|
782 |
+
return false;
|
783 |
+
}catch(Exception $e){
|
784 |
+
$this->log->LogError($this->orderid. "| Product ".$importedId." could not be found, error: ".$e->getMessage());
|
785 |
+
$this->log2->LogError($this->orderid. "| Product ".$importedId." could not be found, error: ".$e->getMessage());
|
786 |
+
return false;
|
787 |
+
//error no se pudo crear la orden
|
788 |
+
|
789 |
+
}
|
790 |
+
}
|
791 |
+
|
792 |
+
|
793 |
+
public function checkOrderStore($storeId ) {
|
794 |
+
$helper = Mage::helper('beezup');
|
795 |
+
$stores = $helper->getConfig('beezup/marketplace/stores');
|
796 |
+
$stores = unserialize ($stores);
|
797 |
+
foreach($stores as $store) {
|
798 |
+
if(isset($store[$storeId]) && $store[$storeId] > 0) {
|
799 |
+
return $store[$storeId];
|
800 |
+
}
|
801 |
+
}
|
802 |
+
return false;
|
803 |
+
}
|
804 |
+
|
805 |
+
|
806 |
+
|
807 |
+
/**
|
808 |
+
* @return BeezupOMOrderService
|
809 |
+
*/
|
810 |
+
public function getOrderService(){
|
811 |
+
if ($this->oOrderService === null){
|
812 |
+
$this->oOrderService = $this->createOrderService();
|
813 |
+
// enchufamos debug mode, esta activado? false true $this->oOrderService->setDebugMode(false);
|
814 |
+
}
|
815 |
+
return $this->oOrderService;
|
816 |
+
}
|
817 |
+
|
818 |
+
/**
|
819 |
+
* @return BeezupOMOrderService
|
820 |
+
*/
|
821 |
+
protected function createOrderService(){
|
822 |
+
|
823 |
+
return new BeezupOMOrderService($this->createRepository() );
|
824 |
+
}
|
825 |
+
|
826 |
+
protected function createRepository() {
|
827 |
+
if ($this->repository == null) {
|
828 |
+
$this->repository = new BeezupRepository();
|
829 |
+
}
|
830 |
+
return $this->repository;
|
831 |
+
|
832 |
+
}
|
833 |
+
|
834 |
+
|
835 |
+
|
836 |
+
|
837 |
+
private function createCustomer($customer_email , $data) {
|
838 |
+
$password = $this->orderid;
|
839 |
+
$this->debugLog("Creating new Customer");
|
840 |
+
$customer = Mage::getModel('customer/customer');
|
841 |
+
$customer->setWebsiteId(Mage::app()->getWebsite()->getId());
|
842 |
+
$customer->loadByEmail($customer_email);
|
843 |
+
if(!$customer->getId()) {
|
844 |
+
$customer->setEmail($customer_email);
|
845 |
+
$customer->setFirstname($data['firstname']);
|
846 |
+
$customer->setLastname($data['lastname']);
|
847 |
+
$customer->setPassword($password);
|
848 |
+
try {
|
849 |
+
$customer->save();
|
850 |
+
$customer->setConfirmation(null);
|
851 |
+
$customer->save();
|
852 |
+
$this->debugLog("Customer created succesfully");
|
853 |
+
return $customer;
|
854 |
+
//Make a "login" of new customer
|
855 |
+
// Mage::getSingleton('customer/session')->loginById($customer->getId());
|
856 |
+
}
|
857 |
+
|
858 |
+
catch (Exception $ex) {
|
859 |
+
//Zend_Debug::dump($ex->getMessage());
|
860 |
+
//GUARDAR ERROR CREACION USUARIO
|
861 |
+
$this->log2->LogError($this->orderid. " | Customer importation failed: ".$ex->getMessage());
|
862 |
+
return false;
|
863 |
+
}
|
864 |
+
|
865 |
+
} else {
|
866 |
+
$this->debugLog("Creating already exists, returning customer object");
|
867 |
+
return $customer;
|
868 |
+
}
|
869 |
+
}
|
870 |
+
|
871 |
+
|
872 |
+
|
873 |
+
public function addOrder($data, $oLink, $stop = false) {
|
874 |
+
|
875 |
+
|
876 |
+
try {
|
877 |
+
$helper = Mage::helper('beezup');
|
878 |
+
$addStock = $helper->getConfig('beezup/marketplace/available_products');
|
879 |
+
$baseCurrencyCode = Mage::app()->getStore()->getBaseCurrencyCode();
|
880 |
+
$quote = Mage::getModel('sales/quote')
|
881 |
+
->setStoreId($data['storeid']);
|
882 |
+
$quote->setCustomerEmail($data['order_customer_email']);
|
883 |
+
|
884 |
+
|
885 |
+
$currency = Mage::getModel('directory/currency')->load($data['order_currency']);
|
886 |
+
$quote->setForcedCurrency($currency);
|
887 |
+
|
888 |
+
$blnCreate = true;
|
889 |
+
$total_new_price = 0;
|
890 |
+
foreach($data['products'] as $prod) {
|
891 |
+
if($prod['qty']==0) {
|
892 |
+
$blnCreate = false;
|
893 |
+
break;
|
894 |
+
}
|
895 |
+
$prod_totality_price = $prod['price']*$prod['qty'];
|
896 |
+
$total_new_price = $total_new_price + $prod_totality_price;
|
897 |
+
$product = Mage::getModel('catalog/product')->load($prod['id']);
|
898 |
+
$buyInfo = array(
|
899 |
+
'qty' => $prod['qty'],
|
900 |
+
);
|
901 |
+
$this->debugLog("Adding ".$prod['qty']." product/s with id ".$product->getId()." to order, with Beezup Price: ".$prod['price']);
|
902 |
+
//echo "Product ".$product->getId()."<br><br>";
|
903 |
+
//para no perder stock:
|
904 |
+
//Mage::getModel('cataloginventory/stock')->backItemQty($productId,$new_qty);
|
905 |
+
|
906 |
+
|
907 |
+
if($addStock == 1) {
|
908 |
+
$stock = Mage::getModel('cataloginventory/stock_item')->loadByProduct($product);
|
909 |
+
|
910 |
+
if ($stock->getQty() < $prod['qty'] && $product->getStockItem()->getMaxSaleQty() >= $prod['qty']) {
|
911 |
+
$this->debugLog("Product ".$product->getId()." Stock = 0, Updating to ".$prod['qty']." to generate Order");
|
912 |
+
// Mage::getModel('cataloginventory/stock')->backItemQty($product->getId(),$prod['qty']);
|
913 |
+
//$this->_updateStocks(array("id_product" => $product->getId(), "qty" => $prod['qty']));
|
914 |
+
$product->setStockData(
|
915 |
+
array(
|
916 |
+
'is_in_stock' => 1,
|
917 |
+
'qty' => $prod['qty'],
|
918 |
+
'manage_stock' => 1,
|
919 |
+
'use_config_notify_stock_qty' => 1
|
920 |
+
)
|
921 |
+
);
|
922 |
+
$product->save();
|
923 |
+
$product = Mage::getModel('catalog/product')->load($product->getId());
|
924 |
+
|
925 |
+
}
|
926 |
+
}
|
927 |
+
//fin para no perder stock
|
928 |
+
|
929 |
+
/*
|
930 |
+
$tax_class = $product->getTaxClassId();
|
931 |
+
$product->setTaxClassId(0);
|
932 |
+
$product->getResource()->saveAttribute($product, 'tax_class_id'); */
|
933 |
+
$price = $prod['price'];
|
934 |
+
|
935 |
+
$quote_item = Mage::getModel('beezup/quote_item');
|
936 |
+
$quote_item
|
937 |
+
->setProduct($product)
|
938 |
+
->setPrice((float) $price )
|
939 |
+
->setCustomPrice((float)$price )
|
940 |
+
->setOriginalCustomPrice((float) $price )
|
941 |
+
->setQuote($quote)
|
942 |
+
->setQty((integer) $prod['qty'])
|
943 |
+
->setBeezupPrice((float) $price );
|
944 |
+
|
945 |
+
|
946 |
+
$quote->addItem($quote_item);
|
947 |
+
|
948 |
+
//$quote->addProduct($product, new Varien_Object($buyInfo))->setOriginalCustomPrice($price)->setCustomPrice($price);
|
949 |
+
|
950 |
+
/*
|
951 |
+
$product->setTaxClassId($tax_class);
|
952 |
+
|
953 |
+
$product->getResource()->saveAttribute($product, 'tax_class_id');
|
954 |
+
*/
|
955 |
+
}
|
956 |
+
|
957 |
+
if($blnCreate) {
|
958 |
+
$addressData = array(
|
959 |
+
'firstname' => ($data['order_customer']) ? $data['order_customer'] : "empty",
|
960 |
+
'lastname' => ($data['order_lastname']) ? $data['order_lastname'] : "empty",
|
961 |
+
'street' => ($data['order_address']) ? $data['order_address'] : "empty",
|
962 |
+
'city' => ($data['order_city']) ? $data['order_city'] : "empty",
|
963 |
+
'postcode' => ($data['order_postalCode']) ? $data['order_postalCode'] : "empty",
|
964 |
+
'telephone' => ($data['order_customer_phone']) ? $data['order_customer_phone'] : "empty",
|
965 |
+
'country_id' => ($data['order_country_iso']) ? $data['order_country_iso'] : "empty",
|
966 |
+
'company' => ($data['order_company']) ? $data['order_company'] : "",
|
967 |
+
'region_id' => ($data['order_region ']) ? substr($data['order_region '], 0,2) : "EM"// id from directory_country_region table
|
968 |
+
);
|
969 |
+
|
970 |
+
$shippingData = array(
|
971 |
+
'firstname' => ($data['shipping_name']) ? $data['shipping_name'] : "empty",
|
972 |
+
'lastname' => ($data['shipping_lastname']) ? $data['shipping_lastname'] : "empty",
|
973 |
+
'street' => ($data['shipping_address']) ? $data['shipping_address'] : "empty",
|
974 |
+
'city' => ($data['shipping_city']) ? $data['shipping_city'] : "empty",
|
975 |
+
'postcode' => ($data['shipping_postalCode']) ? $data['shipping_postalCode'] : "empty",
|
976 |
+
'telephone' => ($data['shipping_phone']) ? $data['shipping_phone'] : "empty",
|
977 |
+
'country_id' => ($data['shipping_country_iso']) ? $data['shipping_country_iso'] : "empty",
|
978 |
+
'shipping_company' => ($data['shipping_company']) ? $data['shipping_company'] : "",
|
979 |
+
'region_id' => ($data['shipping_region']) ? substr($data['shipping_region'], 0, 2) : "EM" // id from directory_country_region table
|
980 |
+
);
|
981 |
+
|
982 |
+
if($this->blnCreateCustomer) {
|
983 |
+
|
984 |
+
$mage_customer = $this->createCustomer($data['order_customer_email'], $addressData);
|
985 |
+
$quote->assignCustomer($mage_customer);
|
986 |
+
}
|
987 |
+
|
988 |
+
|
989 |
+
$payment_method = $helper->getConfig('beezup/marketplace/payment_method');
|
990 |
+
$billingAddress = $quote->getBillingAddress()->addData($addressData);
|
991 |
+
$shippingAddress = $quote->getShippingAddress()->addData($shippingData);
|
992 |
+
$shipping_cost = (float) $data['order_shippingPrice'];
|
993 |
+
if($data['order_shippingPrice'] == 0) {
|
994 |
+
$shipping_cost = 20000;
|
995 |
+
}
|
996 |
+
$total_new_price = $total_new_price + $data['order_shippingPrice'] ;
|
997 |
+
Mage::unregister('shipping_cost');
|
998 |
+
Mage::register('shipping_cost', $shipping_cost);
|
999 |
+
$this->debugLog("Adding Order Shipping Cost: ". $data['order_shippingPrice']);
|
1000 |
+
|
1001 |
+
$shippingAddress->setCollectShippingRates(true)->collectShippingRates()
|
1002 |
+
->setShippingMethod('beezup_beezup')
|
1003 |
+
->setPaymentMethod($payment_method);
|
1004 |
+
|
1005 |
+
//$shippingAddress->addTotal(array("code" => "specialfee", "title" => "Special Fee", "value" => 20));
|
1006 |
+
$quote->getPayment()->importData(array('method' => $payment_method));
|
1007 |
+
|
1008 |
+
$quote->collectTotals()->save();
|
1009 |
+
|
1010 |
+
$service = Mage::getModel('sales/service_quote', $quote);
|
1011 |
+
$service->submitAll();
|
1012 |
+
$order = $service->getOrder();
|
1013 |
+
|
1014 |
+
|
1015 |
+
|
1016 |
+
$quoteId = $order->getQuoteId();
|
1017 |
+
//$this->setStatus($data['order_status'], $order);
|
1018 |
+
|
1019 |
+
$orderid = $order->getId();
|
1020 |
+
|
1021 |
+
$resource = Mage::getSingleton('core/resource');
|
1022 |
+
$writeConnection = $resource->getConnection('core_write');
|
1023 |
+
$table = $resource->getTableName('sales/order_grid');
|
1024 |
+
$this->debugLog("Adding Beezup Marketplace Information to Order");
|
1025 |
+
$marketplace = $data['marketplace'];
|
1026 |
+
$marketplace_business_code = ucfirst(strtolower($data['marketplace_business_code']));
|
1027 |
+
$beezup_name = $data['order_customer'];
|
1028 |
+
$market_order_id =$this->orderid;
|
1029 |
+
$beezup_order_id = $oLink->getBeezupOrderUUID();
|
1030 |
+
$beezup_status = $data['order_status'];
|
1031 |
+
$beezup_last_modification_date = $oLink->getOrderLastModificationUtcDate();
|
1032 |
+
$beezup_last_modification_date = $beezup_last_modification_date->date;
|
1033 |
+
$beezup_marketplace_status = $oLink->getOrderStatusMarketPlaceStatus();
|
1034 |
+
$beezup_purchase_date = $oLink->getOrderPurchaseUtcDate();
|
1035 |
+
$beezup_purchase_date = $beezup_purchase_date->date;
|
1036 |
+
$beezup_marketplace_last_modification_date = $oLink->getOrderMarketPlaceLastModificationUtcDate();
|
1037 |
+
$beezup_marketplace_last_modification_date = $beezup_marketplace_last_modification_date->date;
|
1038 |
+
/* $date = new DateTime($$beezup_marketplace_last_modification_date);
|
1039 |
+
$beezup_marketplace_last_modification_date = $date->format('d-m-Y H:i:s'). "(UTC Time)";
|
1040 |
+
*/
|
1041 |
+
|
1042 |
+
$beezup_total_paid = $oLink->getOrderTotalPrice()." ".$data['order_currency'];
|
1043 |
+
$beezup_account_id = $oLink->getAccountId();
|
1044 |
+
$beezup_comission = $oLink->getOrderTotalCommission()." ".$data['order_currency'];
|
1045 |
+
$tot_comm = $oLink->getOrderTotalCommission();
|
1046 |
+
if(empty($tot_comm ) || $tot_comm == 0) {
|
1047 |
+
$beezup_comission = 0;
|
1048 |
+
}
|
1049 |
+
$query = "UPDATE {$table} SET beezup_marketplace = '{$marketplace}', beezup_name = '{$beezup_account_id}', beezup_order = 1, beezup_market_order_id = '{$market_order_id}',
|
1050 |
+
beezup_order_id = '{$beezup_order_id}', beezup_status = '{$beezup_status}', beezup_last_modification_date = '{$beezup_last_modification_date}',
|
1051 |
+
beezup_marketplace_status = '{$beezup_marketplace_status}', beezup_purchase_date = '{$beezup_purchase_date}', beezup_marketplace_last_modification_date = '{$beezup_marketplace_last_modification_date}',
|
1052 |
+
beezup_total_paid = '{$beezup_total_paid}', beezup_etag = '{$data['etag']}' , beezup_comission = '{$beezup_comission}', beezup_marketplace_business_code = '{$marketplace_business_code}'
|
1053 |
+
WHERE entity_id = ". (int)$orderid;
|
1054 |
+
$writeConnection->query($query);
|
1055 |
+
$disc_price = 0;
|
1056 |
+
if(!empty($data['discounts']) && $data['discounts'] >0) {
|
1057 |
+
|
1058 |
+
|
1059 |
+
$disc_price = round($data['discounts'],2);
|
1060 |
+
$total_new_price = $total_new_price+$disc_price;
|
1061 |
+
$table_address = $resource->getTableName("sales/quote_address");
|
1062 |
+
|
1063 |
+
$query = "update {$table_address} set beezup_fee = '{$disc_price}' where quote_id = '{$quoteId}' and address_type = 'shipping'";
|
1064 |
+
$writeConnection->query($query);
|
1065 |
+
$this->debugLog("Adding CDISCOUNT products with total price: ".$disc_price);
|
1066 |
+
}
|
1067 |
+
|
1068 |
+
//if order id exists and has been created
|
1069 |
+
if ($orderid)
|
1070 |
+
{
|
1071 |
+
//we send order id to beezup
|
1072 |
+
$this->debugLog("Sending Magento Order Id to Beezup, Magento Order Id: ".$orderid);
|
1073 |
+
$oResult = new BeezupOMSetOrderIdValues ();
|
1074 |
+
$oResult->setOrderMerchantOrderId ( $orderid )->setOrderMerchantECommerceSoftwareName ( 'Magento' )->setOrderMerchantECommerceSoftwareVersion ( Mage::getVersion() );
|
1075 |
+
$sendRequest = $this->getOrderService()->getClientProxy()->setOrderMerchantIdByLink($oLink->getLinkByRel('setMerchantOrderId'), $oResult);
|
1076 |
+
}
|
1077 |
+
|
1078 |
+
$grand_total = $order->getGrandTotal();
|
1079 |
+
$beezup_price = $oLink->getOrderTotalPrice() - $disc_price;
|
1080 |
+
if($grand_total != (float) $beezup_price && $beezup_price > 0) {
|
1081 |
+
$order->setGrandTotal((float) $beezup_price);
|
1082 |
+
$order->setBaseGrandTotal((float) $beezup_price);
|
1083 |
+
$diff = (((float) $beezup_price) - $grand_total);
|
1084 |
+
|
1085 |
+
$order->setTaxAmount($order->getTaxAmount() + $diff);
|
1086 |
+
$order->save();
|
1087 |
+
}elseif($grand_total != (float)$beezup_price && $beezup_price < 1) {
|
1088 |
+
|
1089 |
+
$order->setGrandTotal((float) $total_new_price);
|
1090 |
+
$order->setBaseGrandTotal((float) $total_new_price);
|
1091 |
+
$diff = (((float) $total_new_price) - $grand_total);
|
1092 |
+
|
1093 |
+
$order->setTaxAmount($order->getTaxAmount() + $diff);
|
1094 |
+
$order->save();
|
1095 |
+
}
|
1096 |
+
|
1097 |
+
|
1098 |
+
if($order->getShippingInclTax() != $data['order_shippingPrice']) {
|
1099 |
+
$shipping_cost = (float)$data['order_shippingPrice'];
|
1100 |
+
$diff_shipping = ($shipping_cost - $order->getShippingInclTax());
|
1101 |
+
//$order->setShippingAmount($order->getShippingAmount() + $diff_shipping);
|
1102 |
+
//$order->setBaseShippingAmount($order->getShippingAmount());
|
1103 |
+
$order->setShippingInclTax($shipping_cost);
|
1104 |
+
$order->setBaseShippingInclTax($order->getShippingInclTax());
|
1105 |
+
/*
|
1106 |
+
$order->setSubtotalInclTax($order->getSubtotalInclTax() + $diff_shipping);
|
1107 |
+
$order->setBaseSubtotalInclTax($order->getSubtotalInclTax());
|
1108 |
+
$order->setSubtotal($order->getSubtotal() + $diff_shipping);
|
1109 |
+
$order->setBaseSubtotal($order->getSubtotal());
|
1110 |
+
*/
|
1111 |
+
$order->save();
|
1112 |
+
}
|
1113 |
+
|
1114 |
+
$products = Mage::getResourceModel('sales/order_item_collection')
|
1115 |
+
->setOrderFilter($orderid);
|
1116 |
+
foreach($products as $product) {
|
1117 |
+
$product->setBaseOriginalPrice($product->getOriginalPrice());
|
1118 |
+
$product->setBaseTaxAmount($product->getTaxAmount());
|
1119 |
+
$product->setBaseTaxInvoiced($product->getTaxAmount());
|
1120 |
+
$product->setBasePriceInclTax($product->getPriceInclTax());
|
1121 |
+
$product->setBaseRowTotalInclTax($product->getRowTotalInclTax());
|
1122 |
+
$product->save();
|
1123 |
+
}
|
1124 |
+
$order->setBaseTaxAmount($order->getTaxAmount());
|
1125 |
+
$order->setBaseTaxInvoiced($order->getTaxAmount());
|
1126 |
+
$order->setBaseTotalInvoiced($order->getTotalPaid());
|
1127 |
+
$order->setBaseTotalPaid($order->getTotalPaid());
|
1128 |
+
$order->setBaseGrandTotal($order->getTotalPaid());
|
1129 |
+
$order->setBaseSubtotalInclTax($order->getSubtotalInclTax());
|
1130 |
+
$order->save();
|
1131 |
+
|
1132 |
+
|
1133 |
+
|
1134 |
+
|
1135 |
+
$this->setStatus($data['order_status'], $order);
|
1136 |
+
$this->mage_order_id = $orderid;
|
1137 |
+
$this->debugLog("Order imported succesfully, Magento Order Id: ".$orderid);
|
1138 |
+
} else {
|
1139 |
+
//product stock = 0 we dont create order
|
1140 |
+
$this->log->LogError($this->orderid. "| Order ".$data['market_place_order_id']." could not be imported, error: Stock from Beezup product = 0 ");
|
1141 |
+
$this->log2->LogError($this->orderid. "| Order ".$data['market_place_order_id']." could not be imported, error: Stock from Beezup product = 0 ");
|
1142 |
+
}
|
1143 |
+
}catch(Exception $e){
|
1144 |
+
|
1145 |
+
|
1146 |
+
if($stop) {
|
1147 |
+
$this->log->LogError($this->orderid. "| Order ".$data['market_place_order_id']." could not be imported, error: ".$e->getMessage());
|
1148 |
+
$this->log2->LogError($this->orderid. "| Order ".$data['market_place_order_id']." could not be imported, error: ".$e->getMessage());
|
1149 |
+
$this->restoreStock($data);
|
1150 |
+
} else {
|
1151 |
+
$this->debugLog("Order Import failed, Trying to import Order Again");
|
1152 |
+
$this->addOrder($data, $oLink, true);
|
1153 |
+
|
1154 |
+
}
|
1155 |
+
//error no se pudo crear la orden
|
1156 |
+
|
1157 |
+
}
|
1158 |
+
|
1159 |
+
|
1160 |
+
|
1161 |
+
}
|
1162 |
+
|
1163 |
+
|
1164 |
+
|
1165 |
+
public function restoreStock($data) {
|
1166 |
+
|
1167 |
+
try {
|
1168 |
+
foreach($data['products'] as $prod) {
|
1169 |
+
$product = Mage::getModel('catalog/product')->load($prod['id']);
|
1170 |
+
$stock = Mage::getModel('cataloginventory/stock_item')->loadByProduct($product);
|
1171 |
+
if ($stock->getQty() != $prod['curr_stock'] ) {
|
1172 |
+
$this->debugLog("Restoring Stock from Product ".$product->getId()." to: ".$prod['curr_stock'] ." due to Order Fail");
|
1173 |
+
$stockItem = Mage::getModel('cataloginventory/stock_item')->loadByProduct($product);
|
1174 |
+
$stockItem->setData('is_in_stock', 0);
|
1175 |
+
$stockItem->setData('qty', $prod['curr_stock']);
|
1176 |
+
$stockItem->save();
|
1177 |
+
$product->save();
|
1178 |
+
}
|
1179 |
+
|
1180 |
+
}
|
1181 |
+
} catch(Exception $e){
|
1182 |
+
$this->log->LogError($this->orderid. "| Failed Restoring Product Stock: ".$e->getMessage());
|
1183 |
+
$this->log2->LogError($this->orderid. "| Failed Restoring Product Stock: ".$e->getMessage());
|
1184 |
+
}
|
1185 |
+
|
1186 |
+
}
|
1187 |
+
|
1188 |
+
|
1189 |
+
|
1190 |
+
private function createProduct($data) {
|
1191 |
+
|
1192 |
+
$sku = $data['sku'];
|
1193 |
+
if(empty($data['sku'])) {
|
1194 |
+
$sku = $data['sku2'];
|
1195 |
+
}
|
1196 |
+
|
1197 |
+
Mage::app()->setCurrentStore($data['storeId']);
|
1198 |
+
$product = Mage::getModel('catalog/product');
|
1199 |
+
// if(!$product->getIdBySku('testsku61')):
|
1200 |
+
|
1201 |
+
try{
|
1202 |
+
$product
|
1203 |
+
// ->setStoreId(1) //you can set data in store scope
|
1204 |
+
->setWebsiteIds(array($data['storeId'])) //website ID the product is assigned to, as an array
|
1205 |
+
->setAttributeSetId($product->getDefaultAttributeSetId()) //ID of a attribute set named 'default'
|
1206 |
+
->setTypeId('simple') //product type
|
1207 |
+
->setCreatedAt(strtotime('now')) //product creation time
|
1208 |
+
->setSku($sku ) //SKU
|
1209 |
+
->setWeight(0)
|
1210 |
+
->setName($data['title']) //product name
|
1211 |
+
->setStatus(1) //product status (1 - enabled, 2 - disabled)
|
1212 |
+
->setTaxClassId(4) //tax class (0 - none, 1 - default, 2 - taxable, 4 - shipping)
|
1213 |
+
->setVisibility(Mage_Catalog_Model_Product_Visibility::VISIBILITY_NOT_VISIBLE ) //catalog and search visibility
|
1214 |
+
->setPrice($data['price']) //price in form 11.22
|
1215 |
+
->setMsrpEnabled(1) //enable MAP
|
1216 |
+
->setMsrpDisplayActualPriceType(1) //display actual price (1 - on gesture, 2 - in cart, 3 - before order confirmation, 4 - use config)
|
1217 |
+
->setMsrp(0) //Manufacturer's Suggested Retail Price
|
1218 |
+
->setMetaTitle('')
|
1219 |
+
->setMetaKeyword('')
|
1220 |
+
->setMetaDescription('')
|
1221 |
+
->setDescription($data['title'])
|
1222 |
+
->setShortDescription($data['title'])
|
1223 |
+
// ->setMediaGallery (array('images'=>array (), 'values'=>array ())) //media gallery initialization
|
1224 |
+
//->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
|
1225 |
+
->setStockData(array(
|
1226 |
+
'use_config_manage_stock' => 0, //'Use config settings' checkbox
|
1227 |
+
'manage_stock'=>1, //manage stock
|
1228 |
+
'min_sale_qty'=>1, //Minimum Qty Allowed in Shopping Cart
|
1229 |
+
'max_sale_qty'=>2, //Maximum Qty Allowed in Shopping Cart
|
1230 |
+
'is_in_stock' => 1, //Stock Availability
|
1231 |
+
'qty' => 1 //qty
|
1232 |
+
)
|
1233 |
+
);
|
1234 |
+
$product->save();
|
1235 |
+
return $product;
|
1236 |
+
|
1237 |
+
}catch(Exception $e){
|
1238 |
+
//log exception
|
1239 |
+
$this->log->LogError($this->orderid."| Product ".$sku." could not be created, error: ".$e->getMessage());
|
1240 |
+
$this->log2->LogError($this->orderid."| Product ".$sku." could not be created, error: ".$e->getMessage());
|
1241 |
+
return false;
|
1242 |
+
}
|
1243 |
+
}
|
1244 |
+
|
1245 |
+
|
1246 |
+
|
1247 |
+
public function setStatus($status, $order) {
|
1248 |
+
$helper = Mage::helper('beezup');
|
1249 |
+
$retorno = "";
|
1250 |
+
$blnCancel = false;
|
1251 |
+
$blnHold = false;
|
1252 |
+
switch($status) {
|
1253 |
+
case "New" :
|
1254 |
+
$this->debugLog("Setting Order Status to New");
|
1255 |
+
$retorno = $helper->getConfig('beezup/marketplace/status_new');
|
1256 |
+
break;
|
1257 |
+
case "InProgress" :
|
1258 |
+
$this->debugLog("Setting Order Status to InProgress");
|
1259 |
+
$retorno = $helper->getConfig('beezup/marketplace/status_progress');
|
1260 |
+
$this->payOrder($order);
|
1261 |
+
break;
|
1262 |
+
case "Aborted" :
|
1263 |
+
$this->debugLog("Setting Order Status to Aborted");
|
1264 |
+
$retorno = $helper->getConfig('beezup/marketplace/status_aborted');
|
1265 |
+
$blnHold = true;
|
1266 |
+
|
1267 |
+
|
1268 |
+
break;
|
1269 |
+
case "Closed" :
|
1270 |
+
$this->debugLog("Setting Order Status to Closed");
|
1271 |
+
$blnCancel =true;
|
1272 |
+
$retorno = $helper->getConfig('beezup/marketplace/status_closed');
|
1273 |
+
$this->payOrder($order);
|
1274 |
+
break;
|
1275 |
+
case "Canceled" :
|
1276 |
+
$this->debugLog("Setting Order Status to Cancelled");
|
1277 |
+
$retorno = $helper->getConfig('beezup/marketplace/status_cancelled');
|
1278 |
+
|
1279 |
+
break;
|
1280 |
+
case "Shipped" :
|
1281 |
+
$this->debugLog("Setting Order Status to Shipped");
|
1282 |
+
$retorno = $helper->getConfig('beezup/marketplace/status_shipped');
|
1283 |
+
$this->payOrder($order);
|
1284 |
+
break;
|
1285 |
+
|
1286 |
+
}
|
1287 |
+
$order->setData('state',$retorno);
|
1288 |
+
$order->setStatus($retorno);
|
1289 |
+
$history = $order->addStatusHistoryComment('Order was set to '.$retorno.' by Beezup.', false);
|
1290 |
+
$history->setIsCustomerNotified(false);
|
1291 |
+
$order->save();
|
1292 |
+
if($blnCancel) {
|
1293 |
+
$order->cancel()->save();
|
1294 |
+
}
|
1295 |
+
if($blnHold) {
|
1296 |
+
$order->hold()->save();
|
1297 |
+
}
|
1298 |
+
|
1299 |
+
return $retorno;
|
1300 |
+
|
1301 |
+
}
|
1302 |
+
|
1303 |
+
|
1304 |
+
public function getStatus($status1) {
|
1305 |
+
$helper = Mage::helper('beezup');
|
1306 |
+
$retorno = "";
|
1307 |
+
$status = strtolower($status1);
|
1308 |
+
|
1309 |
+
if($status == strtolower($helper->getConfig('beezup/marketplace/status_new') )) {
|
1310 |
+
$retorno = "New";
|
1311 |
+
|
1312 |
+
} elseif($status == strtolower($helper->getConfig('beezup/marketplace/status_progress') ) ){
|
1313 |
+
$retorno = "InProgress";
|
1314 |
+
|
1315 |
+
|
1316 |
+
}
|
1317 |
+
elseif($status == strtolower($helper->getConfig('beezup/marketplace/status_aborted') )) {
|
1318 |
+
|
1319 |
+
$retorno = "Aborted" ;
|
1320 |
+
}
|
1321 |
+
elseif($status == strtolower($helper->getConfig('beezup/marketplace/status_closed') )) {
|
1322 |
+
$retorno = "Closed";
|
1323 |
+
|
1324 |
+
}
|
1325 |
+
elseif($status == strtolower($helper->getConfig('beezup/marketplace/status_cancelled')) ) {
|
1326 |
+
|
1327 |
+
$retorno = "Canceled";
|
1328 |
+
}
|
1329 |
+
elseif($status == strtolower($helper->getConfig('beezup/marketplace/status_shipped') )) {
|
1330 |
+
|
1331 |
+
$retorno = "Shipped";
|
1332 |
+
}
|
1333 |
+
|
1334 |
+
|
1335 |
+
return $retorno;
|
1336 |
+
|
1337 |
+
}
|
1338 |
+
|
1339 |
+
|
1340 |
+
public function checkMarketOrderExists($orderid) {
|
1341 |
+
$resource = Mage::getSingleton('core/resource');
|
1342 |
+
$readConnection = $resource->getConnection('core_read');
|
1343 |
+
$table = $resource->getTableName('sales/order_grid');
|
1344 |
+
$query = 'SELECT increment_id FROM ' . $table . ' WHERE beezup_order = 1 and beezup_market_order_id = \''
|
1345 |
+
. $orderid . '\' LIMIT 1';
|
1346 |
+
$order = $readConnection->fetchOne($query);
|
1347 |
+
if($order && !empty($order) && $this->orderId !== "") {
|
1348 |
+
return $order;
|
1349 |
+
}
|
1350 |
+
return false;
|
1351 |
+
|
1352 |
+
}
|
1353 |
+
|
1354 |
+
public function payOrder($order) {
|
1355 |
+
try {
|
1356 |
+
$this->debugLog("Generating Order Payment Invoice");
|
1357 |
+
if($order->canInvoice()) {
|
1358 |
+
$invoice = $order->prepareInvoice()
|
1359 |
+
->setTransactionId($order->getId())
|
1360 |
+
->addComment("Invoice created from Beezup.")
|
1361 |
+
->register()
|
1362 |
+
->pay();
|
1363 |
+
$transaction_save = Mage::getModel('core/resource_transaction')
|
1364 |
+
->addObject($invoice)
|
1365 |
+
->addObject($invoice->getOrder());
|
1366 |
+
$transaction_save->save();
|
1367 |
+
$this->debugLog("Order Payment Invoice Generated Succesfully");
|
1368 |
+
}
|
1369 |
+
}
|
1370 |
+
catch(Exception $e){
|
1371 |
+
//log exception
|
1372 |
+
$this->log->LogError($this->orderid."| Order Payment Invoice could not be generated, error: ".$e->getMessage());
|
1373 |
+
$this->log2->LogError($this->orderid."| Order Payment Invoice could not be generated, error: ".$e->getMessage());
|
1374 |
+
}
|
1375 |
+
}
|
1376 |
+
|
1377 |
+
|
1378 |
+
|
1379 |
+
|
1380 |
+
|
1381 |
+
|
1382 |
+
}
|
app/code/community/BeezUp/Model/Flatrate.php
ADDED
@@ -0,0 +1,91 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
|
4 |
+
class BeezUp_Model_Flatrate extends Mage_Shipping_Model_Carrier_Abstract implements Mage_Shipping_Model_Carrier_Interface
|
5 |
+
{
|
6 |
+
|
7 |
+
protected $_code = 'flatrate';
|
8 |
+
protected $_isFixed = true;
|
9 |
+
|
10 |
+
|
11 |
+
public function collectRates(Mage_Shipping_Model_Rate_Request $request)
|
12 |
+
{
|
13 |
+
if (!$this->getConfigFlag('active')) {
|
14 |
+
return false;
|
15 |
+
}
|
16 |
+
|
17 |
+
$freeBoxes = 0;
|
18 |
+
if ($request->getAllItems()) {
|
19 |
+
foreach ($request->getAllItems() as $item) {
|
20 |
+
|
21 |
+
if ($item->getProduct()->isVirtual() || $item->getParentItem()) {
|
22 |
+
continue;
|
23 |
+
}
|
24 |
+
|
25 |
+
if ($item->getHasChildren() && $item->isShipSeparately()) {
|
26 |
+
foreach ($item->getChildren() as $child) {
|
27 |
+
if ($child->getFreeShipping() && !$child->getProduct()->isVirtual()) {
|
28 |
+
$freeBoxes += $item->getQty() * $child->getQty();
|
29 |
+
}
|
30 |
+
}
|
31 |
+
} elseif ($item->getFreeShipping()) {
|
32 |
+
$freeBoxes += $item->getQty();
|
33 |
+
}
|
34 |
+
}
|
35 |
+
}
|
36 |
+
$this->setFreeBoxes($freeBoxes);
|
37 |
+
|
38 |
+
$result = Mage::getModel('shipping/rate_result');
|
39 |
+
if ($this->getConfigData('type') == 'O') { // per order
|
40 |
+
$shippingPrice = $this->getConfigData('price');
|
41 |
+
} elseif ($this->getConfigData('type') == 'I') { // per item
|
42 |
+
$shippingPrice = ($request->getPackageQty() * $this->getConfigData('price')) - ($this->getFreeBoxes() * $this->getConfigData('price'));
|
43 |
+
} else {
|
44 |
+
$shippingPrice = false;
|
45 |
+
}
|
46 |
+
|
47 |
+
$shippingPrice = $this->getFinalPriceWithHandlingFee($shippingPrice);
|
48 |
+
|
49 |
+
if ($shippingPrice !== false) {
|
50 |
+
$method = Mage::getModel('shipping/rate_result_method');
|
51 |
+
|
52 |
+
$method->setCarrier('flatrate');
|
53 |
+
$method->setCarrierTitle($this->getConfigData('title'));
|
54 |
+
|
55 |
+
$method->setMethod('flatrate');
|
56 |
+
$method->setMethodTitle($this->getConfigData('name'));
|
57 |
+
|
58 |
+
if ($request->getFreeShipping() === true || $request->getPackageQty() == $this->getFreeBoxes()) {
|
59 |
+
$shippingPrice = '0.00';
|
60 |
+
}
|
61 |
+
|
62 |
+
if(Mage::registry('shipping_cost'))
|
63 |
+
{
|
64 |
+
if(Mage::registry('shipping_cost') == 20000) {
|
65 |
+
$method->setPrice('0.00');
|
66 |
+
$method->setCost('0.00');
|
67 |
+
} else {
|
68 |
+
$method->setPrice(Mage::registry('shipping_cost'));
|
69 |
+
$method->setCost(Mage::registry('shipping_cost'));
|
70 |
+
}
|
71 |
+
} else {
|
72 |
+
$method->setPrice($shippingPrice);
|
73 |
+
$method->setCost($shippingPrice);
|
74 |
+
}
|
75 |
+
|
76 |
+
$result->append($method);
|
77 |
+
}
|
78 |
+
|
79 |
+
return $result;
|
80 |
+
}
|
81 |
+
|
82 |
+
|
83 |
+
public function getAllowedMethods()
|
84 |
+
{
|
85 |
+
|
86 |
+
return array('flatrate'=>$this->getConfigData('name'));
|
87 |
+
}
|
88 |
+
|
89 |
+
|
90 |
+
|
91 |
+
}
|
app/code/community/BeezUp/Model/Observer.php
CHANGED
@@ -32,7 +32,6 @@ class BeezUp_Model_Observer
|
|
32 |
|
33 |
public function autoShip($observer) {
|
34 |
|
35 |
-
|
36 |
$helper = Mage::helper('beezup');
|
37 |
$blnAutoship = $helper->getConfig("beezup/marketplace/autoship_order");
|
38 |
if($blnAutoship != 1) { return; }
|
@@ -51,6 +50,8 @@ class BeezUp_Model_Observer
|
|
51 |
foreach($shipment->getAllTracks() as $tracking_number){
|
52 |
$shipping_data['tracking'] = $tracking_number->getNumber();
|
53 |
$shipping_data['carrier'] = $tracking_number->getTitle();
|
|
|
|
|
54 |
break;
|
55 |
}
|
56 |
break;
|
@@ -72,6 +73,7 @@ class BeezUp_Model_Observer
|
|
72 |
//it is a beezup order
|
73 |
$marketplace_business_code = $results[0]['beezup_marketplace_business_code'];
|
74 |
$marketplace_technical_code = $results[0]['beezup_marketplace'];
|
|
|
75 |
$shipping_data['marketplace_business_code'] = $marketplace_business_code;
|
76 |
$shipping_data['marketplace_technical_code'] = $marketplace_technical_code;
|
77 |
|
@@ -87,49 +89,52 @@ class BeezUp_Model_Observer
|
|
87 |
}
|
88 |
|
89 |
|
90 |
-
private function _MarketplaceTechnicalCodeCarriers($shipping_data ) {
|
91 |
-
|
92 |
$autoship_map = $helper->getConfig("beezup/marketplace/autoship_order_map");
|
93 |
$autoship_map = unserialize($autoship_map);
|
94 |
$code = $shipping_data['marketplace_technical_code'];
|
95 |
-
$business_code = $shipping_data['marketplace_business_code'];
|
96 |
$id_carrier = $shipping_data['carrier'];
|
97 |
$retorno = "";
|
|
|
98 |
if($code =="PriceMinister") {
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
|
|
127 |
}
|
128 |
|
129 |
private function _getOMStatusCarrier($autoship_map, $carrier) {
|
130 |
foreach($autoship_map as $map) {
|
|
|
131 |
if($map['mage_carrierValue'] == $carrier) {
|
132 |
-
return $map['beezup_carrierName'];
|
133 |
}
|
134 |
}
|
135 |
return false;
|
@@ -145,29 +150,34 @@ private function _MarketplaceTechnicalCodeCarriers($shipping_data ) {
|
|
145 |
foreach($orderOptions as $key => $action) {
|
146 |
if(isset($action['action'])) {
|
147 |
if($action['action'] == "ShipOrder") {
|
148 |
-
|
149 |
$parameters = $action['parameters'];
|
150 |
|
151 |
foreach($parameters as $parameter) {
|
152 |
$post_data[$parameter->name] = "";
|
153 |
if($parameter->name == "Order_Shipping_FulfillmentDate") {
|
154 |
-
|
155 |
}
|
156 |
elseif($parameter->name == "Order_Shipping_ShipperTrackingNumber") {
|
157 |
-
|
158 |
}
|
159 |
elseif($parameter->name == "Order_Shipping_CarrierName" || $parameter->name == "Order_Shipping_CarrierCode") {
|
160 |
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
|
|
|
|
|
|
|
|
|
|
167 |
|
168 |
}
|
169 |
elseif($parameter->name == "Order_Shipping_EstimatedDeliveryDate") {
|
170 |
-
|
171 |
}
|
172 |
|
173 |
}
|
@@ -182,4 +192,5 @@ private function _MarketplaceTechnicalCodeCarriers($shipping_data ) {
|
|
182 |
|
183 |
}
|
184 |
|
|
|
185 |
}
|
32 |
|
33 |
public function autoShip($observer) {
|
34 |
|
|
|
35 |
$helper = Mage::helper('beezup');
|
36 |
$blnAutoship = $helper->getConfig("beezup/marketplace/autoship_order");
|
37 |
if($blnAutoship != 1) { return; }
|
50 |
foreach($shipment->getAllTracks() as $tracking_number){
|
51 |
$shipping_data['tracking'] = $tracking_number->getNumber();
|
52 |
$shipping_data['carrier'] = $tracking_number->getTitle();
|
53 |
+
|
54 |
+
|
55 |
break;
|
56 |
}
|
57 |
break;
|
73 |
//it is a beezup order
|
74 |
$marketplace_business_code = $results[0]['beezup_marketplace_business_code'];
|
75 |
$marketplace_technical_code = $results[0]['beezup_marketplace'];
|
76 |
+
|
77 |
$shipping_data['marketplace_business_code'] = $marketplace_business_code;
|
78 |
$shipping_data['marketplace_technical_code'] = $marketplace_technical_code;
|
79 |
|
89 |
}
|
90 |
|
91 |
|
92 |
+
private function _MarketplaceTechnicalCodeCarriers($shipping_data ) {
|
93 |
+
$helper = Mage::helper('beezup');
|
94 |
$autoship_map = $helper->getConfig("beezup/marketplace/autoship_order_map");
|
95 |
$autoship_map = unserialize($autoship_map);
|
96 |
$code = $shipping_data['marketplace_technical_code'];
|
97 |
+
$business_code = strtoupper($shipping_data['marketplace_business_code']);
|
98 |
$id_carrier = $shipping_data['carrier'];
|
99 |
$retorno = "";
|
100 |
+
|
101 |
if($code =="PriceMinister") {
|
102 |
+
//PriceMinisterCarrierName
|
103 |
+
$retorno = $this->_getOMStatusCarrier($autoship_map['PriceMinister'], $id_carrier);
|
104 |
+
} elseif($code=="Fnac") {
|
105 |
+
//FnacCarrierName
|
106 |
+
$retorno = $this->_getOMStatusCarrier( $autoship_map['Fnac'], $id_carrier);;
|
107 |
+
|
108 |
+
} elseif($code == "Mirakl") {
|
109 |
+
if($business_code == "DARTY") {
|
110 |
+
//DartyCarrierCode
|
111 |
+
$retorno = $this->_getOMStatusCarrier( $autoship_map['DARTY'], $id_carrier);;
|
112 |
+
} elseif($business_code == "BOULANGER") {
|
113 |
+
//BoulangerCarrierCode
|
114 |
+
$retorno = $this->_getOMStatusCarrier( $autoship_map['BOULANGER'], $id_carrier);;
|
115 |
+
} elseif($business_code == "LEQUIPE") {
|
116 |
+
//LEquipeCarrierCode
|
117 |
+
$retorno = $this->_getOMStatusCarrier($autoship_map['LEQUIPE'], $id_carrier);;
|
118 |
+
} elseif($business_code == "COMPTOIRSANTE") {
|
119 |
+
//ComptoirSanteCarrierCode
|
120 |
+
$retorno = $this->_getOMStatusCarrier($autoship_map['COMPTOIRSANTE'], $id_carrier);;
|
121 |
+
} elseif($business_code == "RUEDUCOMMERCE") {
|
122 |
+
//RuedDuCommerceCarrierCode
|
123 |
+
$retorno = $this->_getOMStatusCarrier($autoship_map['RUEDUCOMMERCE'], $id_carrier);;
|
124 |
+
} elseif($business_code == "OUTIZ") {
|
125 |
+
$retorno = $this->_getOMStatusCarrier($autoship_map['OUTIZ'], $id_carrier);
|
126 |
+
} else {
|
127 |
+
$retorno = $this->_getOMStatusCarrier($autoship_map[$business_code], $id_carrier);
|
128 |
+
}
|
129 |
+
}
|
130 |
+
return $retorno;
|
131 |
}
|
132 |
|
133 |
private function _getOMStatusCarrier($autoship_map, $carrier) {
|
134 |
foreach($autoship_map as $map) {
|
135 |
+
|
136 |
if($map['mage_carrierValue'] == $carrier) {
|
137 |
+
return array("name" => $map['beezup_carrierName'], "code" => $map['beezup_carrierCode']);
|
138 |
}
|
139 |
}
|
140 |
return false;
|
150 |
foreach($orderOptions as $key => $action) {
|
151 |
if(isset($action['action'])) {
|
152 |
if($action['action'] == "ShipOrder") {
|
153 |
+
$post_data['action_id'] = $action['action'];
|
154 |
$parameters = $action['parameters'];
|
155 |
|
156 |
foreach($parameters as $parameter) {
|
157 |
$post_data[$parameter->name] = "";
|
158 |
if($parameter->name == "Order_Shipping_FulfillmentDate") {
|
159 |
+
$post_data["Order_Shipping_FulfillmentDate"] = $today;
|
160 |
}
|
161 |
elseif($parameter->name == "Order_Shipping_ShipperTrackingNumber") {
|
162 |
+
$post_data['Order_Shipping_ShipperTrackingNumber'] = $shipping_data['tracking'];
|
163 |
}
|
164 |
elseif($parameter->name == "Order_Shipping_CarrierName" || $parameter->name == "Order_Shipping_CarrierCode") {
|
165 |
|
166 |
+
$carrier_name = $this->_MarketplaceTechnicalCodeCarriers($shipping_data);
|
167 |
+
|
168 |
+
if($carrier_name && $carrier_name != "") {
|
169 |
+
if($parameter->name == "Order_Shipping_CarrierName" ) {
|
170 |
+
$post_data[$parameter->name] = $carrier_name['code'];
|
171 |
+
} else {
|
172 |
+
$post_data[$parameter->name] = $carrier_name['code'];
|
173 |
+
}
|
174 |
+
} else {
|
175 |
+
$post_data[$parameter->name] = $shipping_data['carrier'];
|
176 |
+
}
|
177 |
|
178 |
}
|
179 |
elseif($parameter->name == "Order_Shipping_EstimatedDeliveryDate") {
|
180 |
+
$post_data["Order_Shipping_EstimatedDeliveryDate"] = $today;
|
181 |
}
|
182 |
|
183 |
}
|
192 |
|
193 |
}
|
194 |
|
195 |
+
|
196 |
}
|
app/code/community/BeezUp/Model/System/Config/Backend/Autoship.php
CHANGED
@@ -24,7 +24,11 @@ class Beezup_Model_System_Config_Backend_Autoship extends Mage_Core_Model_Config
|
|
24 |
foreach($dato['beezup'] as $b_key => $b) {
|
25 |
if($b_key == 0) { continue; }
|
26 |
$b = explode("|", $b);
|
27 |
-
$
|
|
|
|
|
|
|
|
|
28 |
$retorno[$key][$b_key]['beezup_carrierCode'] = $b[2];
|
29 |
$retorno[$key][$b_key]['beezup_carrierName'] = $b[1];
|
30 |
}
|
24 |
foreach($dato['beezup'] as $b_key => $b) {
|
25 |
if($b_key == 0) { continue; }
|
26 |
$b = explode("|", $b);
|
27 |
+
if($key == "Mirakl") {
|
28 |
+
$key = $b[3];
|
29 |
+
}
|
30 |
+
|
31 |
+
$retorno[$key][$b_key]['beezup_marketplace'] = $b[3];
|
32 |
$retorno[$key][$b_key]['beezup_carrierCode'] = $b[2];
|
33 |
$retorno[$key][$b_key]['beezup_carrierName'] = $b[1];
|
34 |
}
|
app/code/community/BeezUp/etc/config.xml
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
<config>
|
3 |
<modules>
|
4 |
<BeezUp>
|
5 |
-
<version>4.7.
|
6 |
</BeezUp>
|
7 |
</modules>
|
8 |
<global>
|
2 |
<config>
|
3 |
<modules>
|
4 |
<BeezUp>
|
5 |
+
<version>4.7.4</version>
|
6 |
</BeezUp>
|
7 |
</modules>
|
8 |
<global>
|
app/code/community/BeezUp/etc/system.xml
CHANGED
@@ -44,7 +44,7 @@
|
|
44 |
<tracking translate="label">
|
45 |
<label>Tracking</label>
|
46 |
<frontend_type>text</frontend_type>
|
47 |
-
<comment><![CDATA[<div style="font-size:11px;padding:3px;margin-bottom:20px;background:#FFF9E9;border:1px solid #EEE2BE">Support BeezUP : <a href="mailto:help@beezup.com">help@beezup.com</a> (Magento BeezUP v4.7.
|
48 |
<sort_order>1</sort_order>
|
49 |
<show_in_default>1</show_in_default>
|
50 |
<show_in_website>1</show_in_website>
|
@@ -108,7 +108,7 @@
|
|
108 |
<marketplace tanslate="label">
|
109 |
<label>Marketplace</label>
|
110 |
<frontend_type>text</frontend_type>
|
111 |
-
<comment><![CDATA[<div style="font-size:11px;padding:3px;margin-bottom:20px;background:#FFF9E9;border:1px solid #EEE2BE">Support BeezUP : <a href="mailto:help@beezup.com">help@beezup.com</a> (Magento BeezUP v4.7.
|
112 |
<sort_order>2</sort_order>
|
113 |
<show_in_default>1</show_in_default>
|
114 |
<show_in_website>1</show_in_website>
|
@@ -496,7 +496,7 @@
|
|
496 |
<flux translate="label">
|
497 |
<label>Catalog Flow</label>
|
498 |
<frontend_type>text</frontend_type>
|
499 |
-
<comment><![CDATA[<div style="font-size:11px;padding:3px;margin-bottom:20px;background:#FFF9E9;border:1px solid #EEE2BE">Support BeezUP : <a href="mailto:help@beezup.com">help@beezup.com</a> (Magento BeezUP v4.7.
|
500 |
<sort_order>2</sort_order>
|
501 |
<show_in_default>1</show_in_default>
|
502 |
<show_in_website>1</show_in_website>
|
44 |
<tracking translate="label">
|
45 |
<label>Tracking</label>
|
46 |
<frontend_type>text</frontend_type>
|
47 |
+
<comment><![CDATA[<div style="font-size:11px;padding:3px;margin-bottom:20px;background:#FFF9E9;border:1px solid #EEE2BE">Support BeezUP : <a href="mailto:help@beezup.com">help@beezup.com</a> (Magento BeezUP v4.7.4) - <a href="http://go.beezup.com" target="_blank">My BeezUP Account</a></div>]]></comment>
|
48 |
<sort_order>1</sort_order>
|
49 |
<show_in_default>1</show_in_default>
|
50 |
<show_in_website>1</show_in_website>
|
108 |
<marketplace tanslate="label">
|
109 |
<label>Marketplace</label>
|
110 |
<frontend_type>text</frontend_type>
|
111 |
+
<comment><![CDATA[<div style="font-size:11px;padding:3px;margin-bottom:20px;background:#FFF9E9;border:1px solid #EEE2BE">Support BeezUP : <a href="mailto:help@beezup.com">help@beezup.com</a> (Magento BeezUP v4.7.4) - <a href="http://go.beezup.com" target="_blank">My BeezUP Account</a></div>]]></comment>
|
112 |
<sort_order>2</sort_order>
|
113 |
<show_in_default>1</show_in_default>
|
114 |
<show_in_website>1</show_in_website>
|
496 |
<flux translate="label">
|
497 |
<label>Catalog Flow</label>
|
498 |
<frontend_type>text</frontend_type>
|
499 |
+
<comment><![CDATA[<div style="font-size:11px;padding:3px;margin-bottom:20px;background:#FFF9E9;border:1px solid #EEE2BE">Support BeezUP : <a href="mailto:help@beezup.com">help@beezup.com</a> (Magento BeezUP v4.7.4) - <a href="http://go.beezup.com" target="_blank">My BeezUP Account</a></div>]]></comment>
|
500 |
<sort_order>2</sort_order>
|
501 |
<show_in_default>1</show_in_default>
|
502 |
<show_in_website>1</show_in_website>
|
app/code/community/BeezUp/lib/BeezupOMStatus.php
CHANGED
@@ -217,55 +217,69 @@ $return[] = array("action"=> $fields->rel, "parameters" => $retorno);
|
|
217 |
|
218 |
|
219 |
public function getMarketplacCarriersUp() {
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
|
224 |
-
|
225 |
$market_arr = array();
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
|
|
|
|
238 |
if(in_array($code, $market_arr)) {
|
239 |
continue;
|
240 |
}
|
241 |
-
$market_arr[] = $
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
|
|
259 |
|
260 |
}
|
261 |
-
|
262 |
|
263 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
264 |
|
265 |
}
|
266 |
|
267 |
|
268 |
|
|
|
269 |
public function changeOrder($aData) {
|
270 |
|
271 |
$errmsg = "";
|
217 |
|
218 |
|
219 |
public function getMarketplacCarriersUp() {
|
220 |
+
$marketplaceResponse = $this->getOrderService()->getClientProxy()->marketplaces();
|
221 |
+
$result = $marketplaceResponse->getResult();
|
222 |
+
$marketplaces = $result->getMarketplaces();
|
223 |
|
224 |
+
$retorno = array();
|
225 |
$market_arr = array();
|
226 |
+
|
227 |
+
|
228 |
+
foreach($marketplaces as $market) {
|
229 |
+
$code = $market->getMarketplaceTechnicalCode();
|
230 |
+
$business_code = $market->getMarketplaceBusinessCode();
|
231 |
+
$tmpCode = $code."CarrierName";
|
232 |
+
if($code == "Fnac" || $code == "PriceMinister" || $code == "Mirakl") {
|
233 |
+
|
234 |
+
} else {
|
235 |
+
continue;
|
236 |
+
}
|
237 |
+
if($code == "Mirakl") {
|
238 |
+
$tmpCode = ucfirst(strtolower($business_code))."CarrierCode";
|
239 |
+
}
|
240 |
if(in_array($code, $market_arr)) {
|
241 |
continue;
|
242 |
}
|
243 |
+
$market_arr[] = $tmpCode;
|
244 |
+
$carrierResponse = $this->getOrderService()->getClientProxy()->getMarketplace($tmpCode);
|
245 |
+
|
246 |
+
$carResponse = $carrierResponse->getResult();
|
247 |
+
$tmpvars = array();
|
248 |
+
foreach($carResponse->getValues() as $car) {
|
249 |
+
$carCode = $car->getCodeIdentifier();
|
250 |
+
$carName = $car->getTranslationText();
|
251 |
+
if(!in_array($carName, $tmpvars)) {
|
252 |
+
$tmpvars[] = $carName;
|
253 |
+
$retorno[$code."-".$business_code][] = array(
|
254 |
+
'mc_idx' => md5(strtoupper($code . $carCode)),
|
255 |
+
'marketplace_technical_code' =>$code,
|
256 |
+
'marketplace_business_code' => $business_code,
|
257 |
+
'code' => $carCode,
|
258 |
+
'name' => $carName
|
259 |
+
|
260 |
+
);
|
261 |
+
}
|
262 |
|
263 |
}
|
264 |
+
}
|
265 |
|
266 |
+
foreach($retorno as $key => $ret) {
|
267 |
+
$tmpArr = array();
|
268 |
+
foreach($ret as $k => $val) {
|
269 |
+
if(!in_array($val['code'], $tmpArr)) {
|
270 |
+
$tmpArr[] = $val['code'];
|
271 |
+
} else {
|
272 |
+
unset($retorno[$key][$k]);
|
273 |
+
}
|
274 |
+
}
|
275 |
+
}
|
276 |
+
return $retorno;
|
277 |
|
278 |
}
|
279 |
|
280 |
|
281 |
|
282 |
+
|
283 |
public function changeOrder($aData) {
|
284 |
|
285 |
$errmsg = "";
|
app/code/community/BeezUp/lib/debug.txt
ADDED
File without changes
|
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.7.
|
5 |
<stability>stable</stability>
|
6 |
<license uri="http://opensource.org/licenses/osl-3.0.php">Open Software License</license>
|
7 |
<channel>community</channel>
|
@@ -42,11 +42,11 @@ After Set-up, the following files are added :</p>
|
|
42 |

|
43 |
<p>By BeezUP & Magentix</p></description>
|
44 |
<notes>New features :
|
45 |
-
- Fixed
|
46 |
<authors><author><name>BeezUP</name><user>BeezUP</user><email>charles@beezup.com</email></author></authors>
|
47 |
-
<date>
|
48 |
-
<time>
|
49 |
-
<contents><target name="magecommunity"><dir name="BeezUp"><dir name="Block"><dir name="Adminhtml"><dir name="Sales"><dir name="Order"><file name="Grid.php" hash="e18c65bc83cab8795b4ffd0d46e04c8a"/><dir name="Invoice"><file name="Totals.php" hash="ac065cd586fd2534de7e12762ab9b335"/></dir><file name="Totals.php" hash="5972281aa467d63da56a297a8df3da55"/><dir name="View"><dir name="Tab"><file name="Custom.php" hash="a60f500d604038645b826fa74e9b6619"/></dir></dir></dir><file name="Order.php" hash="c038c302f2c86f79431b49c7282c3f5c"/></dir><dir name="System"><dir name="Config"><file name="Attributes.php" hash="a504265fe4dc2df69b311d8219c88fbf"/><file name="Autoship.php" hash="29a12f9ec87f4e4a8a6d0719aab4a4f6"/><file name="Button.php" hash="476b33034b0c7d36e1bbd85f38b841db"/><file name="Childgroup.php" hash="388d3dee8f9d66a56c43c2790a44b45a"/><file name="Credentials.php" hash="b86f361800bebfd6fcf3564d9fe87c95"/><file name="Cron.php" hash="e1d47b095623593beb7f166d2ad7fecc"/><file name="Filter.php" hash="ad7ba55e18c080e25a08309dc428402a"/><file name="Log.php" hash="86221765980c0aee2381d5efd740949d"/><file name="Manualcron.php" hash="cbac01f15d256a43f0388f58449bffd0"/><file name="Orderlink.php" hash="9b9242ea9ccc4cfa746036b72aed2cc1"/><file name="Stores.php" hash="4297f4c94f136bb9778c9ddcd0cb336c"/><file name="Syncstatus.php" hash="49164eb19331aadabc0581472cd3c567"/><file name="Time.php" hash="ac5c2e4a40e9c6ff68cea1097dfa1e7b"/></dir></dir></dir><file name="Omstatus.php" hash="061d861d973e232a18acea0387a4a290"/><file name="Order.php" hash="8a65a03758ce742462782bc58f16e0fa"/><file name="Tracking.php" hash="e6dcd6b89e782b2eb6cb83abfb1b7f56"/><file name="Xml.php" hash="dbaed2a7dfb2ea57f932865a09ae9760"/></dir><dir name="Helper"><file name="Data.php" hash="867a2562b255beaf3faa047d4130304f"/></dir><dir name="Model"><file name="Carrier.php" hash="4a8f63e7cab3145ab679fbe0eff9a0bd"/><file name="Observer.php" hash="e067e82f0a86088ad5dc062074caea51"/><file name="Products.php" hash="e2ffaec55b84d4c1923547fc2aad47b6"/><dir name="Quote"><file name="Item.php" hash="13cef88e165932990fa032b57e8905a0"/></dir><dir name="Sales"><dir name="Order"><dir name="Pdf"><file name="Invoice.php" hash="9eaf28084db176b41c6007da3d529d18"/></dir></dir></dir><dir name="System"><dir name="Config"><dir name="Backend"><file name="Attributes.php" hash="174aee475c6a6a8b0b4f2e8e076c6a25"/><file name="Autoship.php" hash="7e14eb34edffeb1f42fa372874922c84"/><file name="Credentials.php" hash="09ef9fab57f64eb6415d71ba8aec2412"/><file name="Time.php" hash="a70e4d748a9b300ec7b718168fa4d5f8"/><file name="Token.php" hash="60247c8b4d5889433ae1f92e998cc889"/></dir><dir name="Source"><file name="Attributes.php" hash="8f57313a41349c7a8132b8d8e2de275e"/><file name="Autoshipcarriers.php" hash="8d630c9bff8db63b4fb30f11768ce443"/><file name="Availableproducts.php" hash="d9d4b3705f5fbd98efbae0289a1b6d6d"/><file name="Cache.php" hash="0ca6ccc2fed56e2c602d76880d062053"/><file name="Carriers.php" hash="2aa4edae4a91dfd0bbb752aa2f4c0073"/><file name="Categories.php" hash="c4e9f0a54f1d9c688543f26f02f99142"/><file name="Countries.php" hash="b6f1a9a75d5368d6365f06b42524e002"/><file name="Customercreate.php" hash="ca5d2b2d1ad4e18f9a1135af21b10bc2"/><file name="Debug.php" hash="6538ebc0cd0d61c124e5adc806e71aff"/><file name="Description.php" hash="1746e688692fc99524f02fb18e707dcf"/><file name="Images.php" hash="78fb5e2054bbfaa2e76263b1aa9197cc"/><file name="Montant.php" hash="3a46b8d564f1c2f0ed3b62354ac8964f"/><file name="Payment.php" hash="4bebe8e6ab0f980c1ada872b46e86503"/><file name="Position.php" hash="f1d6f89f5db5bfeedc506c539e76e3a8"/><file name="Price.php" hash="71707a69106cdd4990767351ab78fc04"/><file name="Shipping.php" hash="93401afc4fe0fb60824b778a26a24cdd"/><file name="Status.php" hash="d32004ad97adac6de361703a403a6a97"/><file name="Userid.php" hash="3d028bc3bfcaf7541b57676c014c94db"/><file name="Visibility.php" hash="91c69e8f967c13162eb38306c0391080"/></dir></dir></dir></dir><dir name="controllers"><file name="CacheController.php" hash="512cc26abd39d556104d5e69c0ac8a0d"/><file name="CatalogController.php" hash="0b65f6951e26283ea8c60bffa397186d"/><file name="CronController.php" hash="026ddcd6df9a51a41037687ca8d53a0b"/><file name="LogController.php" hash="5eff0d0a2c5621456e580e214d05c745"/><file name="OmstatusController.php" hash="95ae171ef21f861a7eaf74931b62a9db"/><file name="OrderController.php" hash="a2b8df2fb01fb4df8e7f04bcd7689bb3"/></dir><dir name="etc"><file name="adminhtml.xml" hash="e50ed10cb5025ff3a6dd7c90a6f7e0a4"/><file name="config.xml" hash="462a5f15bd9be24bc9d44af8da57ba2d"/><file name="system.xml" hash="6e3814eca5ef4986647ffea45a3a3faf"/></dir><dir name="img"><file name="ajax-loader.gif" hash="2a6692973429d7a74513bfa8bcb5be20"/></dir><dir name="lib"><file name="BeezupMageOrders.php" hash="6b690ddfb6ad93d98cf734925aef7121"/><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="5e3a1759aabfb0349f270ce4cfd80725"/><file name="BeezupOMStatus.php" hash="91622de51c7d8b9f53f1b9ccdafbb24c"/><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="Marketplaces"><file name="BeezupOMMarketplace.php" hash="b85f1c977258ebc70c206a4ff461cb9a"/><file name="BeezupOMMarketplacesRequest.php" hash="5d1b27434872ed04210b9af795f5e464"/><file name="BeezupOMMarketplacesResponse.php" hash="0837f9ba0a610492362d73cd54ed4123"/><file name="BeezupOMMarketplacesResult.php" hash="369a2bf6e4c4134636ddeb849c6a8945"/></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="9dba513402094fc02ec291e08583b419"/></dir><dir name="sql"><dir name="beezup_setup"><file name="mysql4-install-4.0.0.php" hash="75dacb26e3f96975a873c906eb37fbb0"/><file name="mysql4-upgrade-4.5.0-4.6.0.php" hash="34d1bc3a9b7658923a389fd6653ed4c9"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="BeezUp.xml" hash="78c53bf08b7a60920283c91fec9f18dd"/></dir></target><target name="magelocale"><dir name="fr_FR"><file name="BeezUp.csv" hash="3ae5819ffc7157b01772a15a9b16d2a2"/></dir><dir name="en_US"><file name="BeezUp.csv" hash="05b26592c14245824173936807731db4"/></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="beezup_salestab.xml" hash="784925d72538a1eeb0ca695417147a7a"/></dir><dir name="template"><dir name="beezup"><file name="custom.phtml" hash="ea83d17a2e8814c3a9ae9e056c7926a8"/></dir></dir></dir></dir></dir></target></contents>
|
50 |
<compatible/>
|
51 |
<dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php></required></dependencies>
|
52 |
</package>
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>BeezUP_Module_feed_and_tracker</name>
|
4 |
+
<version>4.7.4</version>
|
5 |
<stability>stable</stability>
|
6 |
<license uri="http://opensource.org/licenses/osl-3.0.php">Open Software License</license>
|
7 |
<channel>community</channel>
|
42 |

|
43 |
<p>By BeezUP & Magentix</p></description>
|
44 |
<notes>New features :
|
45 |
+
- Fixed bugs on Autoship carrier mapping</notes>
|
46 |
<authors><author><name>BeezUP</name><user>BeezUP</user><email>charles@beezup.com</email></author></authors>
|
47 |
+
<date>2017-03-01</date>
|
48 |
+
<time>18:42:57</time>
|
49 |
+
<contents><target name="magecommunity"><dir name="BeezUp"><dir name="Block"><dir name="Adminhtml"><dir name="Sales"><dir name="Order"><file name="Grid.php" hash="e18c65bc83cab8795b4ffd0d46e04c8a"/><dir name="Invoice"><file name="Totals.php" hash="ac065cd586fd2534de7e12762ab9b335"/></dir><file name="Totals.php" hash="5972281aa467d63da56a297a8df3da55"/><dir name="View"><dir name="Tab"><file name="Custom.php" hash="a60f500d604038645b826fa74e9b6619"/></dir></dir></dir><file name="Order.php" hash="c038c302f2c86f79431b49c7282c3f5c"/></dir><dir name="System"><dir name="Config"><file name="Attributes.php" hash="a504265fe4dc2df69b311d8219c88fbf"/><file name="Autoship.php" hash="f924df1d1ee8dff3440c43625771e2d6"/><file name="Button.php" hash="476b33034b0c7d36e1bbd85f38b841db"/><file name="Childgroup.php" hash="388d3dee8f9d66a56c43c2790a44b45a"/><file name="Credentials.php" hash="b86f361800bebfd6fcf3564d9fe87c95"/><file name="Cron.php" hash="e1d47b095623593beb7f166d2ad7fecc"/><file name="Filter.php" hash="ad7ba55e18c080e25a08309dc428402a"/><file name="Log.php" hash="86221765980c0aee2381d5efd740949d"/><file name="Manualcron.php" hash="cbac01f15d256a43f0388f58449bffd0"/><file name="Orderlink.php" hash="9b9242ea9ccc4cfa746036b72aed2cc1"/><file name="Stores.php" hash="4297f4c94f136bb9778c9ddcd0cb336c"/><file name="Syncstatus.php" hash="49164eb19331aadabc0581472cd3c567"/><file name="Time.php" hash="ac5c2e4a40e9c6ff68cea1097dfa1e7b"/></dir></dir></dir><file name="Omstatus.php" hash="061d861d973e232a18acea0387a4a290"/><file name="Order.php" hash="8a65a03758ce742462782bc58f16e0fa"/><file name="Order_old.php" hash="01cf997dfedffec513a671d9a399d3df"/><file name="Order_original.php" hash="8a65a03758ce742462782bc58f16e0fa"/><file name="Tracking.php" hash="e6dcd6b89e782b2eb6cb83abfb1b7f56"/><file name="Xml.php" hash="dbaed2a7dfb2ea57f932865a09ae9760"/></dir><dir name="Helper"><file name="Data.php" hash="867a2562b255beaf3faa047d4130304f"/></dir><dir name="Model"><file name="Carrier.php" hash="4a8f63e7cab3145ab679fbe0eff9a0bd"/><file name="Flatrate.php" hash="27d078203781d9b923605f685bfe5c25"/><file name="Observer.php" hash="d1af2bad4ecf48d3615862182b074dea"/><file name="Products.php" hash="e2ffaec55b84d4c1923547fc2aad47b6"/><dir name="Quote"><file name="Item.php" hash="13cef88e165932990fa032b57e8905a0"/></dir><dir name="Sales"><dir name="Order"><dir name="Pdf"><file name="Invoice.php" hash="9eaf28084db176b41c6007da3d529d18"/></dir></dir></dir><dir name="System"><dir name="Config"><dir name="Backend"><file name="Attributes.php" hash="174aee475c6a6a8b0b4f2e8e076c6a25"/><file name="Autoship.php" hash="7a3b906a58f488b35872d164dff9f336"/><file name="Credentials.php" hash="09ef9fab57f64eb6415d71ba8aec2412"/><file name="Time.php" hash="a70e4d748a9b300ec7b718168fa4d5f8"/><file name="Token.php" hash="60247c8b4d5889433ae1f92e998cc889"/></dir><dir name="Source"><file name="Attributes.php" hash="8f57313a41349c7a8132b8d8e2de275e"/><file name="Autoshipcarriers.php" hash="8d630c9bff8db63b4fb30f11768ce443"/><file name="Availableproducts.php" hash="d9d4b3705f5fbd98efbae0289a1b6d6d"/><file name="Cache.php" hash="0ca6ccc2fed56e2c602d76880d062053"/><file name="Carriers.php" hash="2aa4edae4a91dfd0bbb752aa2f4c0073"/><file name="Categories.php" hash="c4e9f0a54f1d9c688543f26f02f99142"/><file name="Countries.php" hash="b6f1a9a75d5368d6365f06b42524e002"/><file name="Customercreate.php" hash="ca5d2b2d1ad4e18f9a1135af21b10bc2"/><file name="Debug.php" hash="6538ebc0cd0d61c124e5adc806e71aff"/><file name="Description.php" hash="1746e688692fc99524f02fb18e707dcf"/><file name="Images.php" hash="78fb5e2054bbfaa2e76263b1aa9197cc"/><file name="Montant.php" hash="3a46b8d564f1c2f0ed3b62354ac8964f"/><file name="Payment.php" hash="4bebe8e6ab0f980c1ada872b46e86503"/><file name="Position.php" hash="f1d6f89f5db5bfeedc506c539e76e3a8"/><file name="Price.php" hash="71707a69106cdd4990767351ab78fc04"/><file name="Shipping.php" hash="93401afc4fe0fb60824b778a26a24cdd"/><file name="Status.php" hash="d32004ad97adac6de361703a403a6a97"/><file name="Userid.php" hash="3d028bc3bfcaf7541b57676c014c94db"/><file name="Visibility.php" hash="91c69e8f967c13162eb38306c0391080"/></dir></dir></dir></dir><dir name="controllers"><file name="CacheController.php" hash="512cc26abd39d556104d5e69c0ac8a0d"/><file name="CatalogController.php" hash="0b65f6951e26283ea8c60bffa397186d"/><file name="CronController.php" hash="026ddcd6df9a51a41037687ca8d53a0b"/><file name="LogController.php" hash="5eff0d0a2c5621456e580e214d05c745"/><file name="OmstatusController.php" hash="95ae171ef21f861a7eaf74931b62a9db"/><file name="OrderController.php" hash="a2b8df2fb01fb4df8e7f04bcd7689bb3"/></dir><dir name="etc"><file name="adminhtml.xml" hash="e50ed10cb5025ff3a6dd7c90a6f7e0a4"/><file name="config.xml" hash="43ea62b6372360baaafc41adc3743fb9"/><file name="system.xml" hash="8b362e20c0be60425ba0dfd6ae27e4dd"/></dir><dir name="img"><file name="ajax-loader.gif" hash="2a6692973429d7a74513bfa8bcb5be20"/></dir><dir name="lib"><file name="BeezupMageOrders.php" hash="6b690ddfb6ad93d98cf734925aef7121"/><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="5e3a1759aabfb0349f270ce4cfd80725"/><file name="BeezupOMStatus.php" hash="54c45bb77f16a81d20b5a998eaab377b"/><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="Marketplaces"><file name="BeezupOMMarketplace.php" hash="b85f1c977258ebc70c206a4ff461cb9a"/><file name="BeezupOMMarketplacesRequest.php" hash="5d1b27434872ed04210b9af795f5e464"/><file name="BeezupOMMarketplacesResponse.php" hash="0837f9ba0a610492362d73cd54ed4123"/><file name="BeezupOMMarketplacesResult.php" hash="369a2bf6e4c4134636ddeb849c6a8945"/></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="9dba513402094fc02ec291e08583b419"/><file name="debug.txt" hash="d41d8cd98f00b204e9800998ecf8427e"/></dir><dir name="sql"><dir name="beezup_setup"><file name="mysql4-install-4.0.0.php" hash="75dacb26e3f96975a873c906eb37fbb0"/><file name="mysql4-upgrade-4.5.0-4.6.0.php" hash="34d1bc3a9b7658923a389fd6653ed4c9"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="BeezUp.xml" hash="78c53bf08b7a60920283c91fec9f18dd"/></dir></target><target name="magelocale"><dir name="fr_FR"><file name="BeezUp.csv" hash="3ae5819ffc7157b01772a15a9b16d2a2"/></dir><dir name="en_US"><file name="BeezUp.csv" hash="05b26592c14245824173936807731db4"/></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="beezup_salestab.xml" hash="784925d72538a1eeb0ca695417147a7a"/></dir><dir name="template"><dir name="beezup"><file name="custom.phtml" hash="ea83d17a2e8814c3a9ae9e056c7926a8"/></dir></dir></dir></dir></dir></target></contents>
|
50 |
<compatible/>
|
51 |
<dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php></required></dependencies>
|
52 |
</package>
|