Version Notes
add product_discount_percent
Download this release
Release Info
Developer | Karsten Hoffmann |
Extension | Adventos_OrderExport |
Version | 1.3.5 |
Comparing to | |
See all releases |
Code changes from version 1.3.3 to 1.3.5
- app/code/local/Adventos/OrderExport/Model/Creditmemo/Api/V2.php +177 -177
- app/code/local/Adventos/OrderExport/Model/Invoice/Api/V2.php +136 -136
- app/code/local/Adventos/OrderExport/Model/Observer.php +75 -54
- app/code/local/Adventos/OrderExport/Model/Observer.php.def +313 -0
- app/code/local/Adventos/OrderExport/Model/Shipment/Api/V2.php +129 -129
- app/code/local/Adventos/OrderExport/etc/api.xml +10 -9
- app/code/local/Adventos/OrderExport/etc/config.xml +1 -1
- app/code/local/Adventos/OrderExport/etc/system.xml +61 -61
- app/code/local/Adventos/OrderExport/etc/wsdl.xml +120 -106
- package.xml +4 -4
app/code/local/Adventos/OrderExport/Model/Creditmemo/Api/V2.php
CHANGED
@@ -2,189 +2,189 @@
|
|
2 |
class Adventos_OrderExport_Model_Creditmemo_Api_V2 extends Adventos_OrderExport_Model_Creditmemo_Api
|
3 |
{
|
4 |
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
|
72 |
-
|
73 |
-
|
74 |
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
// refund to Store Credit
|
111 |
-
if ($refundToStoreCreditAmount) {
|
112 |
-
// check if refund to Store Credit is available
|
113 |
-
if ($order->getCustomerIsGuest()) {
|
114 |
-
$this->_fault('cannot_refund_to_storecredit');
|
115 |
-
}
|
116 |
-
$refundToStoreCreditAmount = max(
|
117 |
-
0,
|
118 |
-
min($creditmemo->getBaseCustomerBalanceReturnMax(), $refundToStoreCreditAmount)
|
119 |
-
);
|
120 |
-
if ($refundToStoreCreditAmount) {
|
121 |
-
$refundToStoreCreditAmount = $creditmemo->getStore()->roundPrice($refundToStoreCreditAmount);
|
122 |
-
$creditmemo->setBaseCustomerBalanceTotalRefunded($refundToStoreCreditAmount);
|
123 |
-
$refundToStoreCreditAmount = $creditmemo->getStore()->roundPrice(
|
124 |
-
$refundToStoreCreditAmount*$order->getStoreToOrderRate()
|
125 |
-
);
|
126 |
-
// this field can be used by customer balance observer
|
127 |
-
$creditmemo->setBsCustomerBalTotalRefunded($refundToStoreCreditAmount);
|
128 |
-
// setting flag to make actual refund to customer balance after credit memo save
|
129 |
-
$creditmemo->setCustomerBalanceRefundFlag(true);
|
130 |
-
}
|
131 |
-
}
|
132 |
-
$creditmemo->setPaymentRefundDisallowed(true)->register();
|
133 |
-
// add comment to creditmemo
|
134 |
-
if (!empty($comment)) {
|
135 |
-
$creditmemo->addComment($comment, $notifyCustomer);
|
136 |
-
}
|
137 |
-
try {
|
138 |
-
Mage::getModel('core/resource_transaction')
|
139 |
-
->addObject($creditmemo)
|
140 |
-
->addObject($order)
|
141 |
-
->save();
|
142 |
-
// send email notification
|
143 |
-
$creditmemo->sendEmail($notifyCustomer, ($includeComment ? $comment : ''));
|
144 |
-
} catch (Mage_Core_Exception $e) {
|
145 |
-
$this->_fault('data_invalid', $e->getMessage());
|
146 |
-
}
|
147 |
-
return $creditmemo->getIncrementId();
|
148 |
-
}
|
149 |
-
|
150 |
-
/**
|
151 |
-
* Prepare data
|
152 |
-
*
|
153 |
-
* @param null|object $data
|
154 |
-
* @return array
|
155 |
-
*/
|
156 |
-
protected function _prepareCreateData($data)
|
157 |
-
{
|
158 |
-
// convert data object to array, if it's null turn it into empty array
|
159 |
-
$data = (isset($data) and is_object($data)) ? get_object_vars($data) : array();
|
160 |
-
// convert qtys object to array
|
161 |
-
if (isset($data['qtys']) && count($data['qtys'])) {
|
162 |
-
$qtysArray = array();
|
163 |
-
foreach ($data['qtys'] as &$item) {
|
164 |
-
if (isset($item->order_item_id) && isset($item->qty)) {
|
165 |
-
$qtysArray[$item->order_item_id] = $item->qty;
|
166 |
-
}
|
167 |
-
}
|
168 |
-
$data['qtys'] = $qtysArray;
|
169 |
-
}
|
170 |
-
return $data;
|
171 |
-
}
|
172 |
-
|
173 |
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
189 |
}
|
190 |
?>
|
2 |
class Adventos_OrderExport_Model_Creditmemo_Api_V2 extends Adventos_OrderExport_Model_Creditmemo_Api
|
3 |
{
|
4 |
|
5 |
+
/**
|
6 |
+
* Initialize attributes' mapping
|
7 |
+
*/
|
8 |
+
public function __construct()
|
9 |
+
{
|
10 |
+
$this->_attributesMap['creditmemo'] = array(
|
11 |
+
'creditmemo_id' => 'entity_id'
|
12 |
+
);
|
13 |
+
$this->_attributesMap['creditmemo_item'] = array(
|
14 |
+
'item_id' => 'entity_id'
|
15 |
+
);
|
16 |
+
$this->_attributesMap['creditmemo_comment'] = array(
|
17 |
+
'comment_id' => 'entity_id'
|
18 |
+
);
|
19 |
+
}
|
20 |
|
21 |
+
/**
|
22 |
+
* Retrieve credit memos by filters
|
23 |
+
*
|
24 |
+
* @param array|null $filter
|
25 |
+
* @return array
|
26 |
+
*/
|
27 |
+
public function items($filter = null)
|
28 |
+
{
|
29 |
+
$filter = $this->_prepareListFilter($filter);
|
30 |
+
try {
|
31 |
+
$result = array();
|
32 |
+
/** @var $creditmemoModel Mage_Sales_Model_Order_Creditmemo */
|
33 |
+
$creditmemoModel = Mage::getModel('sales/order_creditmemo');
|
34 |
+
// map field name entity_id to creditmemo_id
|
35 |
+
foreach ($creditmemoModel->getFilteredCollectionItems($filter) as $creditmemo) {
|
36 |
+
$result[] = $this->_getAttributes($creditmemo, 'creditmemo');
|
37 |
+
}
|
38 |
+
} catch (Exception $e) {
|
39 |
+
$this->_fault('invalid_filter', $e->getMessage());
|
40 |
+
}
|
41 |
+
return $result;
|
42 |
+
}
|
43 |
|
44 |
+
/**
|
45 |
+
* Prepare filters
|
46 |
+
*
|
47 |
+
* @param null|object $filters
|
48 |
+
* @return array
|
49 |
+
*/
|
50 |
+
protected function _prepareListFilter($filters = null)
|
51 |
+
{
|
52 |
+
$preparedFilters = array();
|
53 |
+
$helper = Mage::helper('api');
|
54 |
+
if (isset($filters->filter)) {
|
55 |
+
$helper->associativeArrayUnpack($filters->filter);
|
56 |
+
$preparedFilters += $filters->filter;
|
57 |
+
}
|
58 |
+
if (isset($filters->complex_filter)) {
|
59 |
+
$helper->associativeArrayUnpack($filters->complex_filter);
|
60 |
+
foreach ($filters->complex_filter as &$filter) {
|
61 |
+
$helper->associativeArrayUnpack($filter);
|
62 |
+
}
|
63 |
+
$preparedFilters += $filters->complex_filter;
|
64 |
+
}
|
65 |
+
foreach ($preparedFilters as $field => $value) {
|
66 |
+
if (isset($this->_attributesMap['creditmemo'][$field])) {
|
67 |
+
$preparedFilters[$this->_attributesMap['creditmemo'][$field]] = $value;
|
68 |
+
unset($preparedFilters[$field]);
|
69 |
+
}
|
70 |
+
}
|
71 |
|
72 |
+
return $preparedFilters;
|
73 |
+
}
|
74 |
|
75 |
+
/**
|
76 |
+
* Create new credit memo for order
|
77 |
+
*
|
78 |
+
* @param string $orderId
|
79 |
+
* @param array $data array('qtys' => array('sku1' => qty1, ... , 'skuN' => qtyN),
|
80 |
+
* 'shipping_amount' => value, 'adjustment_positive' => value, 'adjustment_negative' => value)
|
81 |
+
* @param string $refundToStoreCreditAmount
|
82 |
+
* @param string|null $comment
|
83 |
+
* @param bool $notifyCustomer
|
84 |
+
* @param bool $includeComment
|
85 |
+
* @param string $refundToStoreCreditAmount
|
86 |
+
* @return string $creditmemoId
|
87 |
+
*/
|
88 |
+
public function create($orderId, $data = null, $creditmemoNr = null, $comment = null, $notifyCustomer = false,
|
89 |
+
$includeComment = false, $refundToStoreCreditAmount = null)
|
90 |
+
{
|
91 |
+
/** @var $order Mage_Sales_Model_Order */
|
92 |
+
$order = Mage::getModel('sales/order')->load($orderId, 'increment_id');
|
93 |
+
if (!$order->getId()) {
|
94 |
+
$this->_fault('order_not_exists');
|
95 |
+
}
|
96 |
+
if (!$order->canCreditmemo()) {
|
97 |
+
$this->_fault('cannot_create_creditmemo');
|
98 |
+
}
|
99 |
+
$data = $this->_prepareCreateData($data);
|
100 |
|
101 |
+
/** @var $service Mage_Sales_Model_Service_Order */
|
102 |
+
$service = Mage::getModel('sales/service_order', $order);
|
103 |
+
/** @var $creditmemo Mage_Sales_Model_Order_Creditmemo */
|
104 |
+
$creditmemo = $service->prepareCreditmemo($data);
|
105 |
|
106 |
+
if ($creditmemoNr !== null) {
|
107 |
+
$creditmemo->setIncrementId($creditmemoNr);
|
108 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
109 |
|
110 |
+
// refund to Store Credit
|
111 |
+
if ($refundToStoreCreditAmount) {
|
112 |
+
// check if refund to Store Credit is available
|
113 |
+
if ($order->getCustomerIsGuest()) {
|
114 |
+
$this->_fault('cannot_refund_to_storecredit');
|
115 |
+
}
|
116 |
+
$refundToStoreCreditAmount = max(
|
117 |
+
0,
|
118 |
+
min($creditmemo->getBaseCustomerBalanceReturnMax(), $refundToStoreCreditAmount)
|
119 |
+
);
|
120 |
+
if ($refundToStoreCreditAmount) {
|
121 |
+
$refundToStoreCreditAmount = $creditmemo->getStore()->roundPrice($refundToStoreCreditAmount);
|
122 |
+
$creditmemo->setBaseCustomerBalanceTotalRefunded($refundToStoreCreditAmount);
|
123 |
+
$refundToStoreCreditAmount = $creditmemo->getStore()->roundPrice(
|
124 |
+
$refundToStoreCreditAmount*$order->getStoreToOrderRate()
|
125 |
+
);
|
126 |
+
// this field can be used by customer balance observer
|
127 |
+
$creditmemo->setBsCustomerBalTotalRefunded($refundToStoreCreditAmount);
|
128 |
+
// setting flag to make actual refund to customer balance after credit memo save
|
129 |
+
$creditmemo->setCustomerBalanceRefundFlag(true);
|
130 |
+
}
|
131 |
+
}
|
132 |
+
$creditmemo->setPaymentRefundDisallowed(true)->register();
|
133 |
+
// add comment to creditmemo
|
134 |
+
if (!empty($comment)) {
|
135 |
+
$creditmemo->addComment($comment, $notifyCustomer);
|
136 |
+
}
|
137 |
+
try {
|
138 |
+
Mage::getModel('core/resource_transaction')
|
139 |
+
->addObject($creditmemo)
|
140 |
+
->addObject($order)
|
141 |
+
->save();
|
142 |
+
// send email notification
|
143 |
+
$creditmemo->sendEmail($notifyCustomer, ($includeComment ? $comment : ''));
|
144 |
+
} catch (Mage_Core_Exception $e) {
|
145 |
+
$this->_fault('data_invalid', $e->getMessage());
|
146 |
+
}
|
147 |
+
return $creditmemo->getIncrementId();
|
148 |
+
}
|
149 |
+
|
150 |
+
/**
|
151 |
+
* Prepare data
|
152 |
+
*
|
153 |
+
* @param null|object $data
|
154 |
+
* @return array
|
155 |
+
*/
|
156 |
+
protected function _prepareCreateData($data)
|
157 |
+
{
|
158 |
+
// convert data object to array, if it's null turn it into empty array
|
159 |
+
$data = (isset($data) and is_object($data)) ? get_object_vars($data) : array();
|
160 |
+
// convert qtys object to array
|
161 |
+
if (isset($data['qtys']) && count($data['qtys'])) {
|
162 |
+
$qtysArray = array();
|
163 |
+
foreach ($data['qtys'] as &$item) {
|
164 |
+
if (isset($item->order_item_id) && isset($item->qty)) {
|
165 |
+
$qtysArray[$item->order_item_id] = $item->qty;
|
166 |
+
}
|
167 |
+
}
|
168 |
+
$data['qtys'] = $qtysArray;
|
169 |
+
}
|
170 |
+
return $data;
|
171 |
+
}
|
172 |
+
|
173 |
+
|
174 |
+
/**
|
175 |
+
* Load CreditMemo by IncrementId
|
176 |
+
*
|
177 |
+
* @param mixed $incrementId
|
178 |
+
* @return Mage_Core_Model_Abstract|Mage_Sales_Model_Order_Creditmemo
|
179 |
+
*/
|
180 |
+
protected function _getCreditmemo($incrementId)
|
181 |
+
{
|
182 |
+
/** @var $creditmemo Mage_Sales_Model_Order_Creditmemo */
|
183 |
+
$creditmemo = Mage::getModel('sales/order_creditmemo')->load($incrementId, 'increment_id');
|
184 |
+
if (!$creditmemo->getId()) {
|
185 |
+
$this->_fault('not_exists');
|
186 |
+
}
|
187 |
+
return $creditmemo;
|
188 |
+
}
|
189 |
}
|
190 |
?>
|
app/code/local/Adventos/OrderExport/Model/Invoice/Api/V2.php
CHANGED
@@ -1,146 +1,146 @@
|
|
1 |
<?php
|
2 |
class Adventos_OrderExport_Model_Invoice_Api_V2 extends Adventos_OrderExport_Model_Invoice_Api
|
3 |
{
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
|
73 |
protected function _prepareItemQtyData($data)
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
/* Create new invoice for order
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
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 |
if ($invoiceNr !== null) {
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
}
|
146 |
?>
|
1 |
<?php
|
2 |
class Adventos_OrderExport_Model_Invoice_Api_V2 extends Adventos_OrderExport_Model_Invoice_Api
|
3 |
{
|
4 |
+
/**
|
5 |
+
* Retrive invoices by filters
|
6 |
+
*
|
7 |
+
* @param array $filters
|
8 |
+
* @return array
|
9 |
+
*/
|
10 |
+
public function items($filters = null)
|
11 |
+
{
|
12 |
+
//TODO: add full name logic
|
13 |
+
$collection = Mage::getModel('sales/order_invoice')->getCollection()
|
14 |
+
->addAttributeToSelect('order_id')
|
15 |
+
->addAttributeToSelect('increment_id')
|
16 |
+
->addAttributeToSelect('created_at')
|
17 |
+
->addAttributeToSelect('state')
|
18 |
+
->addAttributeToSelect('grand_total')
|
19 |
+
->addAttributeToSelect('order_currency_code')
|
20 |
+
->joinAttribute('billing_firstname', 'order_address/firstname', 'billing_address_id', null, 'left')
|
21 |
+
->joinAttribute('billing_lastname', 'order_address/lastname', 'billing_address_id', null, 'left')
|
22 |
+
->joinAttribute('order_increment_id', 'order/increment_id', 'order_id', null, 'left')
|
23 |
+
->joinAttribute('order_created_at', 'order/created_at', 'order_id', null, 'left');
|
24 |
+
|
25 |
+
$preparedFilters = array();
|
26 |
+
if (isset($filters->filter)) {
|
27 |
+
foreach ($filters->filter as $_filter) {
|
28 |
+
$preparedFilters[][$_filter->key] = $_filter->value;
|
29 |
+
}
|
30 |
+
}
|
31 |
+
if (isset($filters->complex_filter)) {
|
32 |
+
foreach ($filters->complex_filter as $_filter) {
|
33 |
+
$_value = $_filter->value;
|
34 |
+
if(is_object($_value)) {
|
35 |
+
$preparedFilters[][$_filter->key] = array(
|
36 |
+
$_value->key => $_value->value
|
37 |
+
);
|
38 |
+
} elseif(is_array($_value)) {
|
39 |
+
$preparedFilters[][$_filter->key] = array(
|
40 |
+
$_value['key'] => $_value['value']
|
41 |
+
);
|
42 |
+
} else {
|
43 |
+
$preparedFilters[][$_filter->key] = $_value;
|
44 |
+
}
|
45 |
+
}
|
46 |
+
}
|
47 |
+
|
48 |
+
if (!empty($preparedFilters)) {
|
49 |
+
try {
|
50 |
+
foreach ($preparedFilters as $preparedFilter) {
|
51 |
+
foreach ($preparedFilter as $field => $value) {
|
52 |
+
if (isset($this->_attributesMap['order'][$field])) {
|
53 |
+
$field = $this->_attributesMap['order'][$field];
|
54 |
+
}
|
55 |
+
|
56 |
+
$collection->addFieldToFilter($field, $value);
|
57 |
+
}
|
58 |
+
}
|
59 |
+
} catch (Mage_Core_Exception $e) {
|
60 |
+
$this->_fault('filters_invalid', $e->getMessage());
|
61 |
+
}
|
62 |
+
}
|
63 |
+
|
64 |
+
$result = array();
|
65 |
+
|
66 |
+
foreach ($collection as $invoice) {
|
67 |
+
$result[] = $this->_getAttributes($invoice, 'invoice');
|
68 |
+
}
|
69 |
+
|
70 |
+
return $result;
|
71 |
+
}
|
72 |
|
73 |
protected function _prepareItemQtyData($data)
|
74 |
+
{
|
75 |
+
$_data = array();
|
76 |
+
foreach ($data as $item) {
|
77 |
+
if (isset($item->order_item_id) && isset($item->qty)) {
|
78 |
+
$_data[$item->order_item_id] = $item->qty;
|
79 |
+
}
|
80 |
+
}
|
81 |
+
return $_data;
|
82 |
+
}
|
83 |
+
|
84 |
/* Create new invoice for order
|
85 |
+
*
|
86 |
+
* @param string $orderIncrementId
|
87 |
+
* @param array $itemsQty
|
88 |
+
* @param string $invoiceNr
|
89 |
+
* @param string $comment
|
90 |
+
* @param booleam $email
|
91 |
+
* @param boolean $includeComment
|
92 |
+
* @return string
|
93 |
+
* public function invoiceCreate($orderIncrementId, $invoiceNr, $itemsQty, $comment = null, $email = false, $includeComment = false)
|
94 |
+
*/
|
95 |
+
public function create($orderIncrementId, $itemsQty, $invoiceNr = null, $comment = null, $email = false, $includeComment = false)
|
96 |
+
{
|
97 |
+
$order = Mage::getModel('sales/order')->loadByIncrementId($orderIncrementId);
|
98 |
+
$itemsQty = $this->_prepareItemQtyData($itemsQty);
|
99 |
+
/* @var $order Mage_Sales_Model_Order */
|
100 |
+
/**
|
101 |
+
* Check order existing
|
102 |
+
*/
|
103 |
+
if (!$order->getId()) {
|
104 |
+
$this->_fault('order_not_exists');
|
105 |
+
}
|
106 |
+
|
107 |
+
/**
|
108 |
+
* Check invoice create availability
|
109 |
+
*/
|
110 |
+
if (!$order->canInvoice()) {
|
111 |
+
$this->_fault('data_invalid', Mage::helper('sales')->__('Cannot do invoice for order.'));
|
112 |
+
}
|
113 |
+
|
114 |
+
$invoice = $order->prepareInvoice($itemsQty);
|
115 |
+
|
116 |
+
$invoice->register();
|
117 |
+
|
118 |
+
if ($comment !== null) {
|
119 |
+
$invoice->addComment($comment, $email);
|
120 |
+
}
|
121 |
+
|
122 |
+
if ($email) {
|
123 |
+
$invoice->setEmailSent(true);
|
124 |
+
}
|
125 |
|
126 |
if ($invoiceNr !== null) {
|
127 |
+
$invoice->setIncrementId($invoiceNr);
|
128 |
+
}
|
129 |
+
|
130 |
+
$invoice->getOrder()->setIsInProcess(true);
|
131 |
+
|
132 |
+
try {
|
133 |
+
$transactionSave = Mage::getModel('core/resource_transaction')
|
134 |
+
->addObject($invoice)
|
135 |
+
->addObject($invoice->getOrder())
|
136 |
+
->save();
|
137 |
+
|
138 |
+
$invoice->sendEmail($email, ($includeComment ? $comment : ''));
|
139 |
+
} catch (Mage_Core_Exception $e) {
|
140 |
+
$this->_fault('data_invalid', $e->getMessage());
|
141 |
+
}
|
142 |
+
|
143 |
+
return $invoice->getIncrementId();
|
144 |
+
}
|
145 |
}
|
146 |
?>
|
app/code/local/Adventos/OrderExport/Model/Observer.php
CHANGED
@@ -4,6 +4,7 @@
|
|
4 |
* Export Sales Order for Import into HOFAKT ERP
|
5 |
* Output as XML in var/export directory
|
6 |
*
|
|
|
7 |
* 20110722 ADD codepage conversion to CP850 because german special characters weren't imported correct to HOFAKT
|
8 |
* 20110916 REMOVE WebSite Selector, activate SalesOrderExport for all Shops/Stores/Storeviews
|
9 |
* 20111206 ADD attribute discount_Descr to Sales_Order XML as item-text
|
@@ -33,7 +34,7 @@ class Adventos_OrderExport_Model_Observer
|
|
33 |
$webSite = Mage::getModel('core/store')->load($storeId)->getWebsiteId();
|
34 |
|
35 |
$this->_exportOrder($order);
|
36 |
-
Mage::log("ADVENTOS OrderExport Event - Store: ".$storeId);
|
37 |
}
|
38 |
catch (Exception $e)
|
39 |
{
|
@@ -60,7 +61,7 @@ class Adventos_OrderExport_Model_Observer
|
|
60 |
$file = "SalesOrder_".$order->getId().".xml";
|
61 |
|
62 |
$varExport = Mage::getBaseDir('export');
|
63 |
-
|
64 |
if (Mage::getStoreConfig('catalog/orderexport/export_path') != null){
|
65 |
if (Mage::getStoreConfig('catalog/orderexport/export_path') != ""){
|
66 |
$OrderExportPath = Mage::getStoreConfig('catalog/orderexport/export_path');
|
@@ -133,18 +134,38 @@ class Adventos_OrderExport_Model_Observer
|
|
133 |
// walk the sale order lines
|
134 |
foreach ($order->getAllVisibleItems() as $item) //getAllItems() - getItemCollection()
|
135 |
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
136 |
$productArray[] = array(
|
137 |
"product_sku" => $item->getSku(),
|
138 |
"product_magento_id" => $item->getProductId(),
|
139 |
"product_name" => $item->getName(),
|
140 |
"product_qty" => $item->getQtyOrdered(),
|
141 |
"product_price" => $item->getPrice(),
|
142 |
-
"product_discount_percent" => $
|
143 |
"product_row_discount_amount" => $item->getDiscountAmount(),
|
144 |
-
"product_row_price" => $
|
145 |
"product_order_id" => $order->getRealOrderId(),
|
146 |
"product_order_item_id" => $item->getId(),
|
147 |
-
"product_description" => "",
|
148 |
);
|
149 |
}
|
150 |
|
@@ -153,7 +174,7 @@ class Adventos_OrderExport_Model_Observer
|
|
153 |
|
154 |
$customerGroupId = $order->getCustomerGroupId();
|
155 |
$customerGroupName = "";
|
156 |
-
|
157 |
$group = Mage::getModel ('customer/group')->load ($customerGroupId);
|
158 |
if ($group->getId()){
|
159 |
$customerGroupName = $group->getCode();
|
@@ -165,16 +186,16 @@ class Adventos_OrderExport_Model_Observer
|
|
165 |
$customerEmail = $customer->getEmail();
|
166 |
}
|
167 |
|
168 |
-
$exportVatGroup = Mage::getStoreConfig('catalog/orderexport/B2B_HomeGroup');
|
169 |
-
$exportVatGroup = explode(",", $exportVatGroup);
|
170 |
-
|
171 |
-
if (in_array($customerGroupId, $exportVatGroup)) {
|
172 |
-
$order->getBillingAddress()->getvat_id() ? $billing_vat_id = $order->getBillingAddress()->getCountry().$order->getBillingAddress()->getvat_id() : $billing_vat_id = "";
|
173 |
-
$order->getShippingAddress()->getvat_id() ? $shipping_vat_id = $order->getShippingAddress()->getCountry().$order->getShippingAddress()->getvat_id() : $shipping_vat_id = "";
|
174 |
-
}else{
|
175 |
-
$billing_vat_id = "";
|
176 |
-
$shipping_vat_id = "";
|
177 |
-
}
|
178 |
|
179 |
$saleorder = array(
|
180 |
"id" => $order->getRealOrderId(),
|
@@ -209,7 +230,7 @@ class Adventos_OrderExport_Model_Observer
|
|
209 |
"country" => $order->getShippingAddress()->getCountry(),
|
210 |
"phone" => $order->getShippingAddress()->getTelephone(),
|
211 |
"addressid" => $order->getShippingAddress()->getCustomerAddressId(),
|
212 |
-
"vatid" => $shipping_vat_id
|
213 |
),
|
214 |
"billing_address" => array(
|
215 |
"firstname" => $order->getBillingAddress()->getFirstname(),
|
@@ -231,7 +252,7 @@ class Adventos_OrderExport_Model_Observer
|
|
231 |
}
|
232 |
|
233 |
public function generateCatalogInventoryFile($schedule){
|
234 |
-
Mage::log("ADVENTOS OrderExport CatalogInventoryExport - START");
|
235 |
try
|
236 |
{
|
237 |
$inventoryArray = array();
|
@@ -239,8 +260,8 @@ class Adventos_OrderExport_Model_Observer
|
|
239 |
foreach ($collection->load() as $item)
|
240 |
{
|
241 |
$inventoryArray[] = array(
|
242 |
-
|
243 |
-
|
244 |
);
|
245 |
}
|
246 |
$Xml = $this->toXml($inventoryArray,'catalogInventory');
|
@@ -248,39 +269,39 @@ class Adventos_OrderExport_Model_Observer
|
|
248 |
$varExport = Mage::getBaseDir('export');
|
249 |
}
|
250 |
catch (Exception $e)
|
251 |
-
{
|
252 |
-
Mage::logException($e);
|
253 |
-
}
|
254 |
-
|
255 |
-
$web_exported = @array();
|
256 |
-
$allStores = Mage::app()->getStores();
|
257 |
-
foreach ($allStores as $_eachStoreId => $val) {
|
258 |
-
$exportXml = $Xml;
|
259 |
-
$exportFile = $file;
|
260 |
-
$_storeId = Mage::app()->getStore($_eachStoreId)->getId();
|
261 |
-
$_webId = Mage::app()->getStore($_eachStoreId)->getWebsiteId();
|
262 |
-
$app = Mage::app()->setCurrentStore($_storeId);
|
263 |
-
if (Mage::getStoreConfig('catalog/orderexport/process')){
|
264 |
-
if (!in_array($_webId, $web_exported)){
|
265 |
-
if (Mage::getStoreConfig('catalog/orderexport/export_path') != null){
|
266 |
-
if (Mage::getStoreConfig('catalog/orderexport/export_path') != ""){
|
267 |
-
$orderExportPath = Mage::getStoreConfig('catalog/orderexport/export_path');
|
268 |
-
if(!is_dir($varExport.DS.$orderExportPath)){
|
269 |
-
mkdir($varExport.DS.$orderExportPath);
|
270 |
-
Mage::log("ADVENTOS OrderExport Event - Add MultiShop ExportPath [".$orderExportPath."]");
|
271 |
-
}
|
272 |
-
$exportFile = $orderExportPath."/".$exportFile;
|
273 |
-
}
|
274 |
-
}
|
275 |
-
$exportPath = $varExport.DS.$exportFile;
|
276 |
-
$handle = fopen($exportPath,"w+");
|
277 |
-
fwrite($handle,$exportXml);
|
278 |
-
fclose($handle);
|
279 |
-
Mage::log("ADVENTOS OrderExport CatalogInventoryExport - [".$orderExportPath."] Done");
|
280 |
-
}
|
281 |
-
array_push($web_exported, $_webId);
|
282 |
-
}
|
283 |
-
}
|
284 |
Mage::log("ADVENTOS OrderExport CatalogInventoryExport - END");
|
285 |
}
|
286 |
-
}
|
4 |
* Export Sales Order for Import into HOFAKT ERP
|
5 |
* Output as XML in var/export directory
|
6 |
*
|
7 |
+
*
|
8 |
* 20110722 ADD codepage conversion to CP850 because german special characters weren't imported correct to HOFAKT
|
9 |
* 20110916 REMOVE WebSite Selector, activate SalesOrderExport for all Shops/Stores/Storeviews
|
10 |
* 20111206 ADD attribute discount_Descr to Sales_Order XML as item-text
|
34 |
$webSite = Mage::getModel('core/store')->load($storeId)->getWebsiteId();
|
35 |
|
36 |
$this->_exportOrder($order);
|
37 |
+
Mage::log("ADVENTOS OrderExport Event - Store: ".$storeId);
|
38 |
}
|
39 |
catch (Exception $e)
|
40 |
{
|
61 |
$file = "SalesOrder_".$order->getId().".xml";
|
62 |
|
63 |
$varExport = Mage::getBaseDir('export');
|
64 |
+
|
65 |
if (Mage::getStoreConfig('catalog/orderexport/export_path') != null){
|
66 |
if (Mage::getStoreConfig('catalog/orderexport/export_path') != ""){
|
67 |
$OrderExportPath = Mage::getStoreConfig('catalog/orderexport/export_path');
|
134 |
// walk the sale order lines
|
135 |
foreach ($order->getAllVisibleItems() as $item) //getAllItems() - getItemCollection()
|
136 |
{
|
137 |
+
$tax_amount = $item->getTaxAmount();
|
138 |
+
$discount_percent = $item->getDiscountPercent();
|
139 |
+
$discountAmount = $item->getDiscountAmount();
|
140 |
+
|
141 |
+
//typo in discount_percent
|
142 |
+
if ($discount_percent > 0) {
|
143 |
+
$product_row_price = $item->getQtyOrdered() * $item->getOrginalPrice() - $item->getDiscountAmount();
|
144 |
+
}else{
|
145 |
+
$product_row_price = $item->getQtyOrdered() * $item->getPrice() - $item->getDiscountAmount();
|
146 |
+
|
147 |
+
//when fixed amount per product calc discount percent value
|
148 |
+
// rowDiscountPercent = (rowqty * rowproductprice) / rowdiscountamount
|
149 |
+
|
150 |
+
if ($discountAmount > 0) {
|
151 |
+
$discount_percent = round(100 * $discountAmount / ($item->getQtyOrdered() * $item->getPrice()),2);
|
152 |
+
}
|
153 |
+
}
|
154 |
+
|
155 |
+
//Mage::log($item);
|
156 |
+
//Mage:log(print_r($item));
|
157 |
$productArray[] = array(
|
158 |
"product_sku" => $item->getSku(),
|
159 |
"product_magento_id" => $item->getProductId(),
|
160 |
"product_name" => $item->getName(),
|
161 |
"product_qty" => $item->getQtyOrdered(),
|
162 |
"product_price" => $item->getPrice(),
|
163 |
+
"product_discount_percent" => $discount_percent,
|
164 |
"product_row_discount_amount" => $item->getDiscountAmount(),
|
165 |
+
"product_row_price" => $product_row_price,
|
166 |
"product_order_id" => $order->getRealOrderId(),
|
167 |
"product_order_item_id" => $item->getId(),
|
168 |
+
"product_description" => "", //$item->getQtyOrdered()."-".$item->getPrice()."-".$item->getOrginalPrice()."-".$item->getDiscountAmount(),
|
169 |
);
|
170 |
}
|
171 |
|
174 |
|
175 |
$customerGroupId = $order->getCustomerGroupId();
|
176 |
$customerGroupName = "";
|
177 |
+
|
178 |
$group = Mage::getModel ('customer/group')->load ($customerGroupId);
|
179 |
if ($group->getId()){
|
180 |
$customerGroupName = $group->getCode();
|
186 |
$customerEmail = $customer->getEmail();
|
187 |
}
|
188 |
|
189 |
+
$exportVatGroup = Mage::getStoreConfig('catalog/orderexport/B2B_HomeGroup');
|
190 |
+
$exportVatGroup = explode(",", $exportVatGroup);
|
191 |
+
|
192 |
+
if (in_array($customerGroupId, $exportVatGroup)) {
|
193 |
+
$order->getBillingAddress()->getvat_id() ? $billing_vat_id = $order->getBillingAddress()->getCountry().$order->getBillingAddress()->getvat_id() : $billing_vat_id = "";
|
194 |
+
$order->getShippingAddress()->getvat_id() ? $shipping_vat_id = $order->getShippingAddress()->getCountry().$order->getShippingAddress()->getvat_id() : $shipping_vat_id = "";
|
195 |
+
}else{
|
196 |
+
$billing_vat_id = "";
|
197 |
+
$shipping_vat_id = "";
|
198 |
+
}
|
199 |
|
200 |
$saleorder = array(
|
201 |
"id" => $order->getRealOrderId(),
|
230 |
"country" => $order->getShippingAddress()->getCountry(),
|
231 |
"phone" => $order->getShippingAddress()->getTelephone(),
|
232 |
"addressid" => $order->getShippingAddress()->getCustomerAddressId(),
|
233 |
+
"vatid" => $shipping_vat_id
|
234 |
),
|
235 |
"billing_address" => array(
|
236 |
"firstname" => $order->getBillingAddress()->getFirstname(),
|
252 |
}
|
253 |
|
254 |
public function generateCatalogInventoryFile($schedule){
|
255 |
+
Mage::log("ADVENTOS OrderExport CatalogInventoryExport - START");
|
256 |
try
|
257 |
{
|
258 |
$inventoryArray = array();
|
260 |
foreach ($collection->load() as $item)
|
261 |
{
|
262 |
$inventoryArray[] = array(
|
263 |
+
"sku" => $item->getSku(),
|
264 |
+
"qty" => (int)Mage::getModel('cataloginventory/stock_item')->loadByProduct($item)->getQty(),
|
265 |
);
|
266 |
}
|
267 |
$Xml = $this->toXml($inventoryArray,'catalogInventory');
|
269 |
$varExport = Mage::getBaseDir('export');
|
270 |
}
|
271 |
catch (Exception $e)
|
272 |
+
{
|
273 |
+
Mage::logException($e);
|
274 |
+
}
|
275 |
+
|
276 |
+
$web_exported = @array();
|
277 |
+
$allStores = Mage::app()->getStores();
|
278 |
+
foreach ($allStores as $_eachStoreId => $val) {
|
279 |
+
$exportXml = $Xml;
|
280 |
+
$exportFile = $file;
|
281 |
+
$_storeId = Mage::app()->getStore($_eachStoreId)->getId();
|
282 |
+
$_webId = Mage::app()->getStore($_eachStoreId)->getWebsiteId();
|
283 |
+
$app = Mage::app()->setCurrentStore($_storeId);
|
284 |
+
if (Mage::getStoreConfig('catalog/orderexport/process')){
|
285 |
+
if (!in_array($_webId, $web_exported)){
|
286 |
+
if (Mage::getStoreConfig('catalog/orderexport/export_path') != null){
|
287 |
+
if (Mage::getStoreConfig('catalog/orderexport/export_path') != ""){
|
288 |
+
$orderExportPath = Mage::getStoreConfig('catalog/orderexport/export_path');
|
289 |
+
if(!is_dir($varExport.DS.$orderExportPath)){
|
290 |
+
mkdir($varExport.DS.$orderExportPath);
|
291 |
+
Mage::log("ADVENTOS OrderExport Event - Add MultiShop ExportPath [".$orderExportPath."]");
|
292 |
+
}
|
293 |
+
$exportFile = $orderExportPath."/".$exportFile;
|
294 |
+
}
|
295 |
+
}
|
296 |
+
$exportPath = $varExport.DS.$exportFile;
|
297 |
+
$handle = fopen($exportPath,"w+");
|
298 |
+
fwrite($handle,$exportXml);
|
299 |
+
fclose($handle);
|
300 |
+
Mage::log("ADVENTOS OrderExport CatalogInventoryExport - [".$orderExportPath."] Done");
|
301 |
+
}
|
302 |
+
array_push($web_exported, $_webId);
|
303 |
+
}
|
304 |
+
}
|
305 |
Mage::log("ADVENTOS OrderExport CatalogInventoryExport - END");
|
306 |
}
|
307 |
+
}
|
app/code/local/Adventos/OrderExport/Model/Observer.php.def
ADDED
@@ -0,0 +1,313 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @author ADVENTOS GmbH, Karsten Hoffmann
|
4 |
+
* Export Sales Order for Import into HOFAKT ERP
|
5 |
+
* Output as XML in var/export directory
|
6 |
+
*
|
7 |
+
* 20110722 ADD codepage conversion to CP850 because german special characters weren't imported correct to HOFAKT
|
8 |
+
* 20110916 REMOVE WebSite Selector, activate SalesOrderExport for all Shops/Stores/Storeviews
|
9 |
+
* 20111206 ADD attribute discount_Descr to Sales_Order XML as item-text
|
10 |
+
* 20120111 CHANGE OrderId to realOrderId
|
11 |
+
* 10120122 CHANGE DiscountAmount to netDiscountAmount
|
12 |
+
* 20120210 ADD TAGS TaxVat Umsatzsteuer ID and Currency
|
13 |
+
* 20120228 REMOVE netDiscount Calc
|
14 |
+
* 20121011 ADD generateCatalogInventoryFile
|
15 |
+
*/
|
16 |
+
class Adventos_OrderExport_Model_Observer
|
17 |
+
{
|
18 |
+
/**
|
19 |
+
* Generate OrderExport
|
20 |
+
*
|
21 |
+
* @param Varien_Event_Observer $observer
|
22 |
+
*/
|
23 |
+
public function createOrderExport($observer)
|
24 |
+
{
|
25 |
+
Mage::log("ADVENTOS OrderExport Event - START");
|
26 |
+
if (Mage::getStoreConfig('catalog/orderexport/process')){
|
27 |
+
Mage::log("ADVENTOS OrderExport Event - Generate Export enable");
|
28 |
+
try
|
29 |
+
{
|
30 |
+
$order = $observer->getEvent()->getOrder();
|
31 |
+
|
32 |
+
$storeId = $order->getStoreId();
|
33 |
+
$webSite = Mage::getModel('core/store')->load($storeId)->getWebsiteId();
|
34 |
+
|
35 |
+
$this->_exportOrder($order);
|
36 |
+
Mage::log("ADVENTOS OrderExport Event - Store: ".$storeId);
|
37 |
+
}
|
38 |
+
catch (Exception $e)
|
39 |
+
{
|
40 |
+
Mage::logException($e);
|
41 |
+
}
|
42 |
+
}else{
|
43 |
+
Mage::log("ADVENTOS OrderExport Event - Generate Export disable");
|
44 |
+
}
|
45 |
+
Mage::log("ADVENTOS OrderExport Event - END");
|
46 |
+
}
|
47 |
+
|
48 |
+
|
49 |
+
|
50 |
+
/**
|
51 |
+
* write OrderDetails in XML-File
|
52 |
+
*
|
53 |
+
* @param Mage_Sales_Model_Order $order
|
54 |
+
* @return Adventos_OrderExport_Model_Observer
|
55 |
+
*/
|
56 |
+
protected function _exportOrder(Mage_Sales_Model_Order $order)
|
57 |
+
{
|
58 |
+
$ordArray = $this->createOrder($order);
|
59 |
+
$ordXml = $this->toXml($ordArray,'salesOrder');
|
60 |
+
$file = "SalesOrder_".$order->getId().".xml";
|
61 |
+
|
62 |
+
$varExport = Mage::getBaseDir('export');
|
63 |
+
|
64 |
+
if (Mage::getStoreConfig('catalog/orderexport/export_path') != null){
|
65 |
+
if (Mage::getStoreConfig('catalog/orderexport/export_path') != ""){
|
66 |
+
$OrderExportPath = Mage::getStoreConfig('catalog/orderexport/export_path');
|
67 |
+
if(!is_dir($varExport.DS.$OrderExportPath)){
|
68 |
+
Mage::log("ADVENTOS OrderExport Event - MultiShop ExportPath Folder not exist [".$OrderExportPath."]");
|
69 |
+
mkdir($varExport.DS.$OrderExportPath);
|
70 |
+
}
|
71 |
+
$file = $OrderExportPath."/".$file;
|
72 |
+
Mage::log("ADVENTOS OrderExport Event - Add MultiShop ExportPath [".$OrderExportPath."]");
|
73 |
+
}
|
74 |
+
}
|
75 |
+
|
76 |
+
$exportPath = $varExport.DS.$file;
|
77 |
+
|
78 |
+
$handle = fopen($exportPath,"w+");
|
79 |
+
fwrite($handle,$ordXml);
|
80 |
+
fclose($handle);
|
81 |
+
|
82 |
+
return $this;
|
83 |
+
}
|
84 |
+
|
85 |
+
public function toXML($data, $rootNodeName='base',$xml=null){
|
86 |
+
if ($xml == null){
|
87 |
+
/*$xml = simplexml_load_string("<?xml version='1.0' encoding='utf-8'?><$rootNodeName />");
|
88 |
+
* Change encoding from UTF-8 to CP850
|
89 |
+
*/
|
90 |
+
$xml = simplexml_load_string("<?xml version='1.0' encoding='cp850'?><$rootNodeName />");
|
91 |
+
}
|
92 |
+
|
93 |
+
// loop through the data passed in.
|
94 |
+
|
95 |
+
foreach($data as $key => $value){
|
96 |
+
// no numeric keys in our xml please!
|
97 |
+
if (is_numeric($key)){
|
98 |
+
// make item key for product array ...
|
99 |
+
$key = "item"; //.$key;
|
100 |
+
}
|
101 |
+
// replace anything not alpha numeric
|
102 |
+
$key = preg_replace('/[^a-z0-9]/i', '', $key);
|
103 |
+
// if there is another array found recrusively call this function
|
104 |
+
|
105 |
+
if (is_array($value)){
|
106 |
+
$node = $xml->addChild($key);
|
107 |
+
// recrusive call.
|
108 |
+
Adventos_OrderExport_Model_Observer::toXML($value, $rootNodeName, $node);
|
109 |
+
} else {
|
110 |
+
// add single node.
|
111 |
+
$value = str_replace('€','EUR',$value);
|
112 |
+
$xml->addChild($key,$value);
|
113 |
+
}
|
114 |
+
|
115 |
+
}
|
116 |
+
|
117 |
+
// we want the XML to be formatted,
|
118 |
+
//20110722 add encoding CP850 for incredible stupid HOFAKT
|
119 |
+
$doc = new DOMDocument('1.0', 'cp850');
|
120 |
+
$doc->preserveWhiteSpace = false;
|
121 |
+
$doc->loadXML( $xml->asXML() );
|
122 |
+
$doc->formatOutput = true;
|
123 |
+
return $doc->saveXML();
|
124 |
+
}
|
125 |
+
|
126 |
+
public function createOrder($order){
|
127 |
+
|
128 |
+
$productArray = array(); // sale order line product wrapper
|
129 |
+
|
130 |
+
// Magento required models
|
131 |
+
$customer = Mage::getModel('customer/customer')->load($order->getCustomerId());
|
132 |
+
|
133 |
+
// walk the sale order lines
|
134 |
+
foreach ($order->getAllVisibleItems() as $item) //getAllItems() - getItemCollection()
|
135 |
+
{
|
136 |
+
$tax_amount = $item->getTaxAmount();
|
137 |
+
if ($tax_amount > 0) {
|
138 |
+
$product_row_price = ($item->getQtyOrdered() * $item->getData('original_price') - $item->getDiscountAmount()) / $item->getQtyOrdered();
|
139 |
+
}else{
|
140 |
+
$product_row_price = ($item->getQtyOrdered() * $item->getPrice() - $item->getDiscountAmount()) / $item->getQtyOrdered();
|
141 |
+
}
|
142 |
+
<<<<<<< .mine
|
143 |
+
// if (!defined('OUTPUTLIKE')){
|
144 |
+
$attributes = array_keys($item->getData());
|
145 |
+
Mage::log($attributes);
|
146 |
+
Mage:log(print_r($attributes));
|
147 |
+
Mage::log($item->getQtyOrdered()."-".$item->getPrice()."-".$item->getOrginalPrice()."-".$item->getDiscountAmount()."-".$item->getData('original_price'));
|
148 |
+
//$item->getAttributes();
|
149 |
+
// foreach ($attributes as $attribute) {
|
150 |
+
// if ($attribute->getIsVisibleOnFront()) {
|
151 |
+
// $value = $attribute->getValue($item);
|
152 |
+
// Mage::log("itemarray - ".$attribute."=".$value."|");
|
153 |
+
// // do something with $value here
|
154 |
+
// }
|
155 |
+
// }
|
156 |
+
// define('OUTPUTLIKE', "FALSE");
|
157 |
+
// }
|
158 |
+
|
159 |
+
=======
|
160 |
+
//Mage::log($item);
|
161 |
+
//Mage:log(print_r($item));
|
162 |
+
>>>>>>> .r31
|
163 |
+
$productArray[] = array(
|
164 |
+
"product_sku" => $item->getSku(),
|
165 |
+
"product_magento_id" => $item->getProductId(),
|
166 |
+
"product_name" => $item->getName(),
|
167 |
+
"product_qty" => $item->getQtyOrdered(),
|
168 |
+
"product_price" => $item->getPrice(),
|
169 |
+
"product_discount_percent" => $item->getDiscountPercent(),
|
170 |
+
"product_row_discount_amount" => $item->getDiscountAmount(),
|
171 |
+
"product_row_price" => $product_row_price,
|
172 |
+
"product_order_id" => $order->getRealOrderId(),
|
173 |
+
"product_order_item_id" => $item->getId(),
|
174 |
+
"product_description" => "",
|
175 |
+
);
|
176 |
+
}
|
177 |
+
|
178 |
+
$streetBA = $order->getBillingAddress()->getStreet();
|
179 |
+
$streetSA = $order->getShippingAddress()->getStreet();
|
180 |
+
|
181 |
+
$customerGroupId = $order->getCustomerGroupId();
|
182 |
+
$customerGroupName = "";
|
183 |
+
|
184 |
+
$group = Mage::getModel ('customer/group')->load ($customerGroupId);
|
185 |
+
if ($group->getId()){
|
186 |
+
$customerGroupName = $group->getCode();
|
187 |
+
}
|
188 |
+
|
189 |
+
if($customer->getEmail() == "") {
|
190 |
+
$customerEmail = $order->getCustomerEmail();
|
191 |
+
} else {
|
192 |
+
$customerEmail = $customer->getEmail();
|
193 |
+
}
|
194 |
+
|
195 |
+
$exportVatGroup = Mage::getStoreConfig('catalog/orderexport/B2B_HomeGroup');
|
196 |
+
$exportVatGroup = explode(",", $exportVatGroup);
|
197 |
+
|
198 |
+
if (in_array($customerGroupId, $exportVatGroup)) {
|
199 |
+
$order->getBillingAddress()->getvat_id() ? $billing_vat_id = $order->getBillingAddress()->getCountry().$order->getBillingAddress()->getvat_id() : $billing_vat_id = "";
|
200 |
+
$order->getShippingAddress()->getvat_id() ? $shipping_vat_id = $order->getShippingAddress()->getCountry().$order->getShippingAddress()->getvat_id() : $shipping_vat_id = "";
|
201 |
+
}else{
|
202 |
+
$billing_vat_id = "";
|
203 |
+
$shipping_vat_id = "";
|
204 |
+
}
|
205 |
+
|
206 |
+
$saleorder = array(
|
207 |
+
"id" => $order->getRealOrderId(),
|
208 |
+
"store_id" => $order->getStoreId(),
|
209 |
+
"store_name" => Mage::getModel('core/store')->load($order->getStoreID())->getName(),
|
210 |
+
"hofakt_lager" => Mage::getStoreConfig('catalog/orderexport/storage_id'),
|
211 |
+
"hofakt_language" => Mage::getStoreConfig('catalog/orderexport/store_language'),
|
212 |
+
"payment" => $order->getPayment()->getMethod(),
|
213 |
+
"shipping_amount" => $order->getShippingAmount(),
|
214 |
+
"discount_amount" => 0,
|
215 |
+
"discount_descr" => $order->getDiscountDescription(),
|
216 |
+
"net_total" => $order->getSubtotal(),
|
217 |
+
"tax_amount" => $order->getTaxAmount(),
|
218 |
+
"grand_total" => $order->getGrandTotal(),
|
219 |
+
"currency" => $order->getOrderCurrencyCode(),
|
220 |
+
"date" => $order->getCreatedAt(),
|
221 |
+
"customer" => array(
|
222 |
+
"customer_id" => $customer->getId(),
|
223 |
+
"customer_name" => $customer->getName(),
|
224 |
+
"customer_vatid" => $order->getCustomerTaxvat(),
|
225 |
+
"customer_email" => $customerEmail,
|
226 |
+
"customergroup" => $customerGroupName
|
227 |
+
),
|
228 |
+
"shipping_address" => array(
|
229 |
+
"firstname" => $order->getShippingAddress()->getFirstname(),
|
230 |
+
"lastname" => $order->getShippingAddress()->getLastname(),
|
231 |
+
"company" => $order->getShippingAddress()->getCompany(),
|
232 |
+
"street" => $streetSA[0],
|
233 |
+
"street2" => (count($streetSA)==2)?$streetSA[1]:'',
|
234 |
+
"city" => $order->getShippingAddress()->getCity(),
|
235 |
+
"postcode" => $order->getShippingAddress()->getPostcode(),
|
236 |
+
"country" => $order->getShippingAddress()->getCountry(),
|
237 |
+
"phone" => $order->getShippingAddress()->getTelephone(),
|
238 |
+
"addressid" => $order->getShippingAddress()->getCustomerAddressId(),
|
239 |
+
"vatid" => $shipping_vat_id
|
240 |
+
),
|
241 |
+
"billing_address" => array(
|
242 |
+
"firstname" => $order->getBillingAddress()->getFirstname(),
|
243 |
+
"lastname" => $order->getBillingAddress()->getLastname(),
|
244 |
+
"company" => $order->getBillingAddress()->getCompany(),
|
245 |
+
"street" => $streetBA[0],
|
246 |
+
"street2" => (count($streetBA)==2)?$streetBA[1]:'',
|
247 |
+
"city" => $order->getBillingAddress()->getCity(),
|
248 |
+
"postcode" => $order->getBillingAddress()->getPostcode(),
|
249 |
+
"country" => $order->getBillingAddress()->getCountry(),
|
250 |
+
"phone" => $order->getBillingAddress()->getTelephone(),
|
251 |
+
"addressid" => $order->getBillingAddress()->getCustomerAddressId(),
|
252 |
+
"vatid" => $billing_vat_id
|
253 |
+
),
|
254 |
+
"lines" => $productArray,
|
255 |
+
);
|
256 |
+
|
257 |
+
return $saleorder;
|
258 |
+
}
|
259 |
+
|
260 |
+
public function generateCatalogInventoryFile($schedule){
|
261 |
+
Mage::log("ADVENTOS OrderExport CatalogInventoryExport - START");
|
262 |
+
try
|
263 |
+
{
|
264 |
+
$inventoryArray = array();
|
265 |
+
$collection = Mage::getModel('catalog/product')->getCollection();
|
266 |
+
foreach ($collection->load() as $item)
|
267 |
+
{
|
268 |
+
$inventoryArray[] = array(
|
269 |
+
"sku" => $item->getSku(),
|
270 |
+
"qty" => (int)Mage::getModel('cataloginventory/stock_item')->loadByProduct($item)->getQty(),
|
271 |
+
);
|
272 |
+
}
|
273 |
+
$Xml = $this->toXml($inventoryArray,'catalogInventory');
|
274 |
+
$file = "CatalogInventoryExport.xml";
|
275 |
+
$varExport = Mage::getBaseDir('export');
|
276 |
+
}
|
277 |
+
catch (Exception $e)
|
278 |
+
{
|
279 |
+
Mage::logException($e);
|
280 |
+
}
|
281 |
+
|
282 |
+
$web_exported = @array();
|
283 |
+
$allStores = Mage::app()->getStores();
|
284 |
+
foreach ($allStores as $_eachStoreId => $val) {
|
285 |
+
$exportXml = $Xml;
|
286 |
+
$exportFile = $file;
|
287 |
+
$_storeId = Mage::app()->getStore($_eachStoreId)->getId();
|
288 |
+
$_webId = Mage::app()->getStore($_eachStoreId)->getWebsiteId();
|
289 |
+
$app = Mage::app()->setCurrentStore($_storeId);
|
290 |
+
if (Mage::getStoreConfig('catalog/orderexport/process')){
|
291 |
+
if (!in_array($_webId, $web_exported)){
|
292 |
+
if (Mage::getStoreConfig('catalog/orderexport/export_path') != null){
|
293 |
+
if (Mage::getStoreConfig('catalog/orderexport/export_path') != ""){
|
294 |
+
$orderExportPath = Mage::getStoreConfig('catalog/orderexport/export_path');
|
295 |
+
if(!is_dir($varExport.DS.$orderExportPath)){
|
296 |
+
mkdir($varExport.DS.$orderExportPath);
|
297 |
+
Mage::log("ADVENTOS OrderExport Event - Add MultiShop ExportPath [".$orderExportPath."]");
|
298 |
+
}
|
299 |
+
$exportFile = $orderExportPath."/".$exportFile;
|
300 |
+
}
|
301 |
+
}
|
302 |
+
$exportPath = $varExport.DS.$exportFile;
|
303 |
+
$handle = fopen($exportPath,"w+");
|
304 |
+
fwrite($handle,$exportXml);
|
305 |
+
fclose($handle);
|
306 |
+
Mage::log("ADVENTOS OrderExport CatalogInventoryExport - [".$orderExportPath."] Done");
|
307 |
+
}
|
308 |
+
array_push($web_exported, $_webId);
|
309 |
+
}
|
310 |
+
}
|
311 |
+
Mage::log("ADVENTOS OrderExport CatalogInventoryExport - END");
|
312 |
+
}
|
313 |
+
}
|
app/code/local/Adventos/OrderExport/Model/Shipment/Api/V2.php
CHANGED
@@ -1,149 +1,149 @@
|
|
1 |
<?php
|
2 |
class Adventos_OrderExport_Model_Shipment_Api_V2 extends Adventos_OrderExport_Model_Shipment_Api
|
3 |
{
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
|
51 |
-
|
52 |
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
|
57 |
-
|
58 |
-
|
59 |
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
if ($shipmentNr !== null) {
|
108 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
109 |
}
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
->addObject($shipment->getOrder())
|
115 |
-
->save();
|
116 |
-
$shipment->sendEmail($email, ($includeComment ? $comment : ''));
|
117 |
-
} catch (Mage_Core_Exception $e) {
|
118 |
-
$this->_fault('data_invalid', $e->getMessage());
|
119 |
-
}
|
120 |
-
return $shipment->getIncrementId();
|
121 |
-
}
|
122 |
-
return null;
|
123 |
-
}
|
124 |
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
|
146 |
-
|
147 |
-
|
148 |
}
|
149 |
?>
|
1 |
<?php
|
2 |
class Adventos_OrderExport_Model_Shipment_Api_V2 extends Adventos_OrderExport_Model_Shipment_Api
|
3 |
{
|
4 |
+
/**
|
5 |
+
* Retrive shipments by filters
|
6 |
+
*
|
7 |
+
* @param array $filters
|
8 |
+
* @return array
|
9 |
+
*/
|
10 |
+
public function items($filters = null)
|
11 |
+
{
|
12 |
+
//TODO: add full name logic
|
13 |
+
$collection = Mage::getResourceModel('sales/order_shipment_collection')
|
14 |
+
->addAttributeToSelect('increment_id')
|
15 |
+
->addAttributeToSelect('created_at')
|
16 |
+
->addAttributeToSelect('total_qty')
|
17 |
+
->joinAttribute('shipping_firstname', 'order_address/firstname', 'shipping_address_id', null, 'left')
|
18 |
+
->joinAttribute('shipping_lastname', 'order_address/lastname', 'shipping_address_id', null, 'left')
|
19 |
+
->joinAttribute('order_increment_id', 'order/increment_id', 'order_id', null, 'left')
|
20 |
+
->joinAttribute('order_created_at', 'order/created_at', 'order_id', null, 'left');
|
21 |
|
22 |
+
$preparedFilters = array();
|
23 |
+
if (isset($filters->filter)) {
|
24 |
+
foreach ($filters->filter as $_filter) {
|
25 |
+
$preparedFilters[$_filter->key] = $_filter->value;
|
26 |
+
}
|
27 |
+
}
|
28 |
+
if (isset($filters->complex_filter)) {
|
29 |
+
foreach ($filters->complex_filter as $_filter) {
|
30 |
+
$_value = $_filter->value;
|
31 |
+
$preparedFilters[$_filter->key] = array(
|
32 |
+
$_value->key => $_value->value
|
33 |
+
);
|
34 |
+
}
|
35 |
+
}
|
36 |
|
37 |
+
if (!empty($preparedFilters)) {
|
38 |
+
try {
|
39 |
+
foreach ($preparedFilters as $field => $value) {
|
40 |
+
if (isset($this->_attributesMap['shipment'][$field])) {
|
41 |
+
$field = $this->_attributesMap['shipment'][$field];
|
42 |
+
}
|
43 |
|
44 |
+
$collection->addFieldToFilter($field, $value);
|
45 |
+
}
|
46 |
+
} catch (Mage_Core_Exception $e) {
|
47 |
+
$this->_fault('filters_invalid', $e->getMessage());
|
48 |
+
}
|
49 |
+
}
|
50 |
|
51 |
+
$result = array();
|
52 |
|
53 |
+
foreach ($collection as $shipment) {
|
54 |
+
$result[] = $this->_getAttributes($shipment, 'shipment');
|
55 |
+
}
|
56 |
|
57 |
+
return $result;
|
58 |
+
}
|
59 |
|
60 |
+
protected function _prepareItemQtyData($data)
|
61 |
+
{
|
62 |
+
$_data = array();
|
63 |
+
foreach ($data as $item) {
|
64 |
+
if (isset($item->order_item_id) && isset($item->qty)) {
|
65 |
+
$_data[$item->order_item_id] = $item->qty;
|
66 |
+
}
|
67 |
+
}
|
68 |
+
return $_data;
|
69 |
+
}
|
70 |
|
71 |
+
/**
|
72 |
+
* Create new shipment for order
|
73 |
+
*
|
74 |
+
* @param string $orderIncrementId
|
75 |
+
* @param array $itemsQty
|
76 |
+
* @param string $comment
|
77 |
+
* @param booleam $email
|
78 |
+
* @param boolean $includeComment
|
79 |
+
* @return string
|
80 |
+
*/
|
81 |
+
public function create($orderIncrementId, $itemsQty = array(), $shipmentNr = null, $comment = null, $email = false, $includeComment = false)
|
82 |
+
{
|
83 |
+
$order = Mage::getModel('sales/order')->loadByIncrementId($orderIncrementId);
|
84 |
+
$itemsQty = $this->_prepareItemQtyData($itemsQty);
|
85 |
+
/**
|
86 |
+
* Check order existing
|
87 |
+
*/
|
88 |
+
if (!$order->getId()) {
|
89 |
+
$this->_fault('order_not_exists');
|
90 |
+
}
|
91 |
|
92 |
+
/**
|
93 |
+
* Check shipment create availability
|
94 |
+
*/
|
95 |
+
if (!$order->canShip()) {
|
96 |
+
$this->_fault('data_invalid', Mage::helper('sales')->__('Cannot do shipment for order.'));
|
97 |
+
}
|
98 |
|
99 |
+
/* @var $shipment Mage_Sales_Model_Order_Shipment */
|
100 |
+
$shipment = $order->prepareShipment($itemsQty);
|
101 |
+
if ($shipment) {
|
102 |
+
$shipment->register();
|
103 |
+
$shipment->addComment($comment, $email && $includeComment);
|
104 |
+
if ($email) {
|
105 |
+
$shipment->setEmailSent(true);
|
106 |
+
}
|
107 |
if ($shipmentNr !== null) {
|
108 |
+
$shipment->setIncrementId($shipmentNr);
|
109 |
+
}
|
110 |
+
$shipment->getOrder()->setIsInProcess(true);
|
111 |
+
try {
|
112 |
+
$transactionSave = Mage::getModel('core/resource_transaction')
|
113 |
+
->addObject($shipment)
|
114 |
+
->addObject($shipment->getOrder())
|
115 |
+
->save();
|
116 |
+
$shipment->sendEmail($email, ($includeComment ? $comment : ''));
|
117 |
+
} catch (Mage_Core_Exception $e) {
|
118 |
+
$this->_fault('data_invalid', $e->getMessage());
|
119 |
}
|
120 |
+
return $shipment->getIncrementId();
|
121 |
+
}
|
122 |
+
return null;
|
123 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
124 |
|
125 |
+
/**
|
126 |
+
* Retrieve allowed shipping carriers for specified order
|
127 |
+
*
|
128 |
+
* @param string $orderIncrementId
|
129 |
+
* @return array
|
130 |
+
*/
|
131 |
+
public function getCarriers($orderIncrementId)
|
132 |
+
{
|
133 |
+
$order = Mage::getModel('sales/order')->loadByIncrementId($orderIncrementId);
|
134 |
|
135 |
+
/**
|
136 |
+
* Check order existing
|
137 |
+
*/
|
138 |
+
if (!$order->getId()) {
|
139 |
+
$this->_fault('order_not_exists');
|
140 |
+
}
|
141 |
+
$carriers = array();
|
142 |
+
foreach ($this->_getCarriers($order) as $key => $value) {
|
143 |
+
$carriers[] = array('key' => $key, 'value' => $value);
|
144 |
+
}
|
145 |
|
146 |
+
return $carriers;
|
147 |
+
}
|
148 |
}
|
149 |
?>
|
app/code/local/Adventos/OrderExport/etc/api.xml
CHANGED
@@ -24,7 +24,8 @@
|
|
24 |
</create>
|
25 |
</methods>
|
26 |
</adventos_shipment>
|
27 |
-
<adventos_creditmemo translate="title"
|
|
|
28 |
<title>Custom Credit memo functions for OrderExport</title>
|
29 |
<model>orderexport/creditmemo_api</model>
|
30 |
<acl>sales/order</acl>
|
@@ -36,17 +37,17 @@
|
|
36 |
</methods>
|
37 |
</adventos_creditmemo>
|
38 |
</resources>
|
39 |
-
|
40 |
-
|
41 |
<adventos_shipment>adventos_shipment</adventos_shipment>
|
42 |
<adventos_creditmemo>adventos_creditmemo</adventos_creditmemo>
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
<adventos_shipment>adventosShipment</adventos_shipment>
|
48 |
<adventos_creditmemo>adventosCreditmemo</adventos_creditmemo>
|
49 |
-
|
50 |
-
|
51 |
</api>
|
52 |
</config>
|
24 |
</create>
|
25 |
</methods>
|
26 |
</adventos_shipment>
|
27 |
+
<adventos_creditmemo translate="title"
|
28 |
+
module="adventos_orderexport">
|
29 |
<title>Custom Credit memo functions for OrderExport</title>
|
30 |
<model>orderexport/creditmemo_api</model>
|
31 |
<acl>sales/order</acl>
|
37 |
</methods>
|
38 |
</adventos_creditmemo>
|
39 |
</resources>
|
40 |
+
<resources_alias>
|
41 |
+
<adventos_invoice>adventos_invoice</adventos_invoice>
|
42 |
<adventos_shipment>adventos_shipment</adventos_shipment>
|
43 |
<adventos_creditmemo>adventos_creditmemo</adventos_creditmemo>
|
44 |
+
</resources_alias>
|
45 |
+
<v2>
|
46 |
+
<resources_function_prefix>
|
47 |
+
<adventos_invoice>adventosInvoice</adventos_invoice>
|
48 |
<adventos_shipment>adventosShipment</adventos_shipment>
|
49 |
<adventos_creditmemo>adventosCreditmemo</adventos_creditmemo>
|
50 |
+
</resources_function_prefix>
|
51 |
+
</v2>
|
52 |
</api>
|
53 |
</config>
|
app/code/local/Adventos/OrderExport/etc/config.xml
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
<config>
|
3 |
<modules>
|
4 |
<Adventos_OrderExport>
|
5 |
-
<version>1.3.
|
6 |
</Adventos_OrderExport>
|
7 |
</modules>
|
8 |
<global>
|
2 |
<config>
|
3 |
<modules>
|
4 |
<Adventos_OrderExport>
|
5 |
+
<version>1.3.5</version>
|
6 |
</Adventos_OrderExport>
|
7 |
</modules>
|
8 |
<global>
|
app/code/local/Adventos/OrderExport/etc/system.xml
CHANGED
@@ -1,68 +1,68 @@
|
|
1 |
<?xml version="1.0"?>
|
2 |
<config>
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
<storage_id translate="label">
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
<![CDATA[Specify MultiShop Installation Export Path
|
43 |
leave blank in Single Shop Installation]]>
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
<![CDATA[Export Vat in Shipping and Billing Address for Customer Group]]>
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
</config>
|
1 |
<?xml version="1.0"?>
|
2 |
<config>
|
3 |
+
<sections>
|
4 |
+
<catalog translate="label" module="catalog">
|
5 |
+
<groups>
|
6 |
+
<orderexport translate="label">
|
7 |
+
<label>OrderExport</label>
|
8 |
+
<frontend_type>text</frontend_type>
|
9 |
+
<sort_order>500</sort_order>
|
10 |
+
<show_in_default>1</show_in_default>
|
11 |
+
<show_in_website>1</show_in_website>
|
12 |
+
<show_in_store>1</show_in_store>
|
13 |
+
<fields>
|
14 |
+
<process translate="label">
|
15 |
+
<label>Export Orders</label>
|
16 |
+
<frontend_type>select</frontend_type>
|
17 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
18 |
+
<sort_order>1</sort_order>
|
19 |
+
<show_in_default>1</show_in_default>
|
20 |
+
<show_in_website>1</show_in_website>
|
21 |
+
<show_in_store>1</show_in_store>
|
22 |
+
</process>
|
23 |
<storage_id translate="label">
|
24 |
+
<label>LagerId</label>
|
25 |
+
<frontend_type>text</frontend_type>
|
26 |
+
<sort_order>2</sort_order>
|
27 |
+
<show_in_default>1</show_in_default>
|
28 |
+
<show_in_website>1</show_in_website>
|
29 |
+
<show_in_store>1</show_in_store>
|
30 |
+
</storage_id>
|
31 |
+
<store_language translate="label">
|
32 |
+
<label>Language</label>
|
33 |
+
<frontend_type>text</frontend_type>
|
34 |
+
<sort_order>3</sort_order>
|
35 |
+
<show_in_default>1</show_in_default>
|
36 |
+
<show_in_website>1</show_in_website>
|
37 |
+
<show_in_store>1</show_in_store>
|
38 |
+
</store_language>
|
39 |
+
<export_path translate="label">
|
40 |
+
<label>Export Path</label>
|
41 |
+
<comment>
|
42 |
<![CDATA[Specify MultiShop Installation Export Path
|
43 |
leave blank in Single Shop Installation]]>
|
44 |
+
</comment>
|
45 |
+
<frontend_type>text</frontend_type>
|
46 |
+
<sort_order>4</sort_order>
|
47 |
+
<show_in_default>1</show_in_default>
|
48 |
+
<show_in_website>1</show_in_website>
|
49 |
+
<show_in_store>1</show_in_store>
|
50 |
+
</export_path>
|
51 |
+
<B2B_HomeGroup translate="label">
|
52 |
+
<label>Vat Export Customer Group</label>
|
53 |
+
<comment>
|
54 |
<![CDATA[Export Vat in Shipping and Billing Address for Customer Group]]>
|
55 |
+
</comment>
|
56 |
+
<frontend_type>Multiselect</frontend_type>
|
57 |
+
<source_model>adminhtml/system_config_source_customer_group</source_model>
|
58 |
+
<sort_order>5</sort_order>
|
59 |
+
<show_in_default>1</show_in_default>
|
60 |
+
<show_in_website>1</show_in_website>
|
61 |
+
<show_in_store>1</show_in_store>
|
62 |
+
</B2B_HomeGroup>
|
63 |
+
</fields>
|
64 |
+
</orderexport>
|
65 |
+
</groups>
|
66 |
+
</catalog>
|
67 |
+
</sections>
|
68 |
</config>
|
app/code/local/Adventos/OrderExport/etc/wsdl.xml
CHANGED
@@ -1,120 +1,134 @@
|
|
1 |
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
-
<definitions xmlns:typens="urn:{{var wsdl.name}}" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
|
|
|
|
|
|
21 |
<complexType name="salesOrderCreditmemoData">
|
22 |
<all>
|
23 |
-
<element name="qtys" type="typens:orderItemIdQtyArray"
|
24 |
-
|
25 |
-
<element name="
|
26 |
-
|
|
|
|
|
|
|
|
|
27 |
</all>
|
28 |
</complexType>
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
<operation name="adventosCreditmemoCreate">
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
88 |
<part name="comment" type="xsd:string" />
|
89 |
<part name="notifyCustomer" type="xsd:int" />
|
90 |
<part name="includeComment" type="xsd:int" />
|
91 |
<part name="refundToStoreCreditAmount" type="xsd:string" />
|
92 |
-
|
93 |
-
|
94 |
<part name="creditmemoIncrementId" type="xsd:int" />
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
<part name="invoiceNr" type="xsd:string" />
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
<part name="invoiceIncrementId" type="xsd:int" />
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
</definitions>
|
1 |
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
+
<definitions xmlns:typens="urn:{{var wsdl.name}}" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
|
3 |
+
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
|
4 |
+
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns="http://schemas.xmlsoap.org/wsdl/"
|
5 |
+
name="{{var wsdl.name}}" targetNamespace="urn:{{var wsdl.name}}">
|
6 |
+
<types>
|
7 |
+
<schema xmlns="http://www.w3.org/2001/XMLSchema"
|
8 |
+
targetNamespace="urn:Magento">
|
9 |
+
<import namespace="http://schemas.xmlsoap.org/soap/encoding/"
|
10 |
+
schemaLocation="http://schemas.xmlsoap.org/soap/encoding/" />
|
11 |
+
<complexType name="orderItemIdQty">
|
12 |
+
<all>
|
13 |
+
<element name="order_item_id" type="xsd:int" />
|
14 |
+
<element name="qty" type="xsd:double" />
|
15 |
+
</all>
|
16 |
+
</complexType>
|
17 |
+
<complexType name="orderItemIdQtyArray">
|
18 |
+
<complexContent>
|
19 |
+
<restriction base="soapenc:Array">
|
20 |
+
<attribute ref="soapenc:arrayType" wsdl:arrayType="typens:orderItemIdQty[]" />
|
21 |
+
</restriction>
|
22 |
+
</complexContent>
|
23 |
+
</complexType>
|
24 |
<complexType name="salesOrderCreditmemoData">
|
25 |
<all>
|
26 |
+
<element name="qtys" type="typens:orderItemIdQtyArray"
|
27 |
+
minOccurs="0" />
|
28 |
+
<element name="shipping_amount" type="xsd:double"
|
29 |
+
minOccurs="0" />
|
30 |
+
<element name="adjustment_positive" type="xsd:double"
|
31 |
+
minOccurs="0" />
|
32 |
+
<element name="adjustment_negative" type="xsd:double"
|
33 |
+
minOccurs="0" />
|
34 |
</all>
|
35 |
</complexType>
|
36 |
+
</schema>
|
37 |
+
</types>
|
38 |
+
<portType name="{{var wsdl.handler}}PortType">
|
39 |
<operation name="adventosCreditmemoCreate">
|
40 |
+
<documentation>Create new Credit memo for order</documentation>
|
41 |
+
<input message="typens:adventosCreditmemoCreateRequest" />
|
42 |
+
<output message="typens:adventosCreditmemoCreateResponse" />
|
43 |
+
</operation>
|
44 |
+
<operation name="adventosInvoiceCreate">
|
45 |
+
<documentation>Create new invoice for order</documentation>
|
46 |
+
<input message="typens:adventosInvoiceCreateRequest" />
|
47 |
+
<output message="typens:adventosInvoiceCreateResponse" />
|
48 |
+
</operation>
|
49 |
+
<operation name="adventosShipmentCreate">
|
50 |
+
<documentation>Create new shipment for order</documentation>
|
51 |
+
<input message="typens:adventosShipmentCreateRequest" />
|
52 |
+
<output message="typens:adventosShipmentCreateResponse" />
|
53 |
+
</operation>
|
54 |
+
</portType>
|
55 |
+
<binding name="{{var wsdl.handler}}Binding" type="typens:{{var wsdl.handler}}PortType">
|
56 |
+
<soap:binding style="rpc"
|
57 |
+
transport="http://schemas.xmlsoap.org/soap/http" />
|
58 |
+
<operation name="adventosCreditmemoCreate">
|
59 |
+
<soap:operation soapAction="urn:{{var wsdl.handler}}Action" />
|
60 |
+
<input>
|
61 |
+
<soap:body namespace="urn:{{var wsdl.name}}" use="encoded"
|
62 |
+
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
|
63 |
+
</input>
|
64 |
+
<output>
|
65 |
+
<soap:body namespace="urn:{{var wsdl.name}}" use="encoded"
|
66 |
+
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
|
67 |
+
</output>
|
68 |
+
</operation>
|
69 |
+
<operation name="adventosInvoiceCreate">
|
70 |
+
<soap:operation soapAction="urn:{{var wsdl.handler}}Action" />
|
71 |
+
<input>
|
72 |
+
<soap:body namespace="urn:{{var wsdl.name}}" use="encoded"
|
73 |
+
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
|
74 |
+
</input>
|
75 |
+
<output>
|
76 |
+
<soap:body namespace="urn:{{var wsdl.name}}" use="encoded"
|
77 |
+
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
|
78 |
+
</output>
|
79 |
+
</operation>
|
80 |
+
<operation name="adventosShipmentCreate">
|
81 |
+
<soap:operation soapAction="urn:{{var wsdl.handler}}Action" />
|
82 |
+
<input>
|
83 |
+
<soap:body namespace="urn:{{var wsdl.name}}" use="encoded"
|
84 |
+
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
|
85 |
+
</input>
|
86 |
+
<output>
|
87 |
+
<soap:body namespace="urn:{{var wsdl.name}}" use="encoded"
|
88 |
+
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
|
89 |
+
</output>
|
90 |
+
</operation>
|
91 |
+
</binding>
|
92 |
+
<service name="{{var wsdl.name}}Service">
|
93 |
+
<port name="{{var wsdl.handler}}Port" binding="typens:{{var wsdl.handler}}Binding">
|
94 |
+
<soap:address location="{{var wsdl.url}}" />
|
95 |
+
</port>
|
96 |
+
</service>
|
97 |
+
<message name="adventosCreditmemoCreateRequest">
|
98 |
+
<part name="sessionId" type="xsd:string" />
|
99 |
+
<part name="orderId" type="xsd:string" />
|
100 |
+
<part name="creditmemoData" type="typens:salesOrderCreditmemoData" />
|
101 |
+
<part name="creditmemoNr" type="xsd:string" />
|
102 |
<part name="comment" type="xsd:string" />
|
103 |
<part name="notifyCustomer" type="xsd:int" />
|
104 |
<part name="includeComment" type="xsd:int" />
|
105 |
<part name="refundToStoreCreditAmount" type="xsd:string" />
|
106 |
+
</message>
|
107 |
+
<message name="adventosCreditmemoCreateResponse">
|
108 |
<part name="creditmemoIncrementId" type="xsd:int" />
|
109 |
+
</message>
|
110 |
+
<message name="adventosInvoiceCreateRequest">
|
111 |
+
<part name="sessionId" type="xsd:string" />
|
112 |
+
<part name="orderId" type="xsd:string" />
|
113 |
+
<part name="itemsQty" type="typens:orderItemIdQtyArray" />
|
114 |
<part name="invoiceNr" type="xsd:string" />
|
115 |
+
<part name="comment" type="xsd:string" />
|
116 |
+
<part name="email" type="xsd:string" />
|
117 |
+
<part name="includeComment" type="xsd:string" />
|
118 |
+
</message>
|
119 |
+
<message name="adventosInvoiceCreateResponse">
|
120 |
<part name="invoiceIncrementId" type="xsd:int" />
|
121 |
+
</message>
|
122 |
+
<message name="adventosShipmentCreateRequest">
|
123 |
+
<part name="sessionId" type="xsd:string" />
|
124 |
+
<part name="orderId" type="xsd:string" />
|
125 |
+
<part name="itemsQty" type="typens:orderItemIdQtyArray" />
|
126 |
+
<part name="shipmentNr" type="xsd:string" />
|
127 |
+
<part name="comment" type="xsd:string" />
|
128 |
+
<part name="email" type="xsd:int" />
|
129 |
+
<part name="includeComment" type="xsd:int" />
|
130 |
+
</message>
|
131 |
+
<message name="adventosShipmentCreateResponse">
|
132 |
+
<part name="shipmentIncrementId" type="xsd:int" />
|
133 |
+
</message>
|
134 |
</definitions>
|
package.xml
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>Adventos_OrderExport</name>
|
4 |
-
<version>1.3.
|
5 |
<stability>stable</stability>
|
6 |
<license>OSL</license>
|
7 |
<channel>community</channel>
|
@@ -11,9 +11,9 @@
|
|
11 |
<notes>add product_discount_percent
|
12 |
</notes>
|
13 |
<authors><author><name>Karsten Hoffmann</name><user>adventos</user><email>karsten@adventos.de</email></author></authors>
|
14 |
-
<date>2013-
|
15 |
-
<time>
|
16 |
-
<contents><target name="magelocal"><dir name="Adventos"><dir name="OrderExport"><dir name="Helper"><file name="Data.php" hash="f90dd7d2136cfb6349ba1d7ee939cd15"/></dir><dir name="Model"><dir name="Creditmemo"><dir name="Api"><file name="V2.php" hash="
|
17 |
<compatible/>
|
18 |
<dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php></required></dependencies>
|
19 |
</package>
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>Adventos_OrderExport</name>
|
4 |
+
<version>1.3.5</version>
|
5 |
<stability>stable</stability>
|
6 |
<license>OSL</license>
|
7 |
<channel>community</channel>
|
11 |
<notes>add product_discount_percent
|
12 |
</notes>
|
13 |
<authors><author><name>Karsten Hoffmann</name><user>adventos</user><email>karsten@adventos.de</email></author></authors>
|
14 |
+
<date>2013-07-08</date>
|
15 |
+
<time>15:15:09</time>
|
16 |
+
<contents><target name="magelocal"><dir name="Adventos"><dir name="OrderExport"><dir name="Helper"><file name="Data.php" hash="f90dd7d2136cfb6349ba1d7ee939cd15"/></dir><dir name="Model"><dir name="Creditmemo"><dir name="Api"><file name="V2.php" hash="797a58eedbbe8bf1a0c20d7c8599f8be"/></dir><file name="Api.php" hash="c41e82cf79235d51f25d248719e93f92"/></dir><dir name="Invoice"><dir name="Api"><file name="V2.php" hash="3596dc5fe58a597ba5f244b52687288e"/></dir><file name="Api.php" hash="280512b1ae37690871384b3cba0a3a2b"/></dir><file name="Observer.php" hash="844d0e79c4bba2c9f3f6021d5e53162b"/><file name="Observer.php.def" hash="8849a673153fbab13536e3f83d605c3c"/><dir name="Shipment"><dir name="Api"><file name="V2.php" hash="3d7824e13e4d5cedb755b4858398f23e"/></dir><file name="Api.php" hash="0b9bf452b7e36c1ee5cefbb3d6c5eb3b"/></dir></dir><dir name="etc"><file name="api.xml" hash="c1b2bc277e329b8191bcc5358cb96581"/><file name="config.xml" hash="7f80bbb97299bd4448c0c7400a156edb"/><file name="system.xml" hash="d7feaf247eed064d617138508dd88fe4"/><file name="wsdl.xml" hash="1538d2cb05f819c45e807f992c1b7cb3"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Adventos_OrderExport.xml" hash="479b13bf3a08de9f93f5f58d77d3f9bb"/></dir></target></contents>
|
17 |
<compatible/>
|
18 |
<dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php></required></dependencies>
|
19 |
</package>
|