Version Notes
generate XML-File with Orderdetails in var/export/SalesOrder_*.xml
Download this release
Release Info
Developer | Karsten Hoffmann |
Extension | Adventos_OrderExport |
Version | 1.0.2 |
Comparing to | |
See all releases |
Code changes from version 1.0.1 to 1.0.2
app/code/local/Adventos/OrderExport/Model/Observer.php
CHANGED
@@ -11,22 +11,21 @@
|
|
11 |
* 10120122 CHANGE DiscountAmount to netDiscountAmount
|
12 |
* 20120210 ADD TAGS TaxVat Umsatzsteuer ID and Currency
|
13 |
* 20120228 REMOVE netDiscount Calc
|
14 |
-
* 20120424 ADD shippingMethod + productorderid for Cache
|
15 |
*/
|
16 |
class Adventos_OrderExport_Model_Observer
|
17 |
{
|
18 |
/**
|
19 |
-
* Export
|
20 |
*
|
21 |
* @param Varien_Event_Observer $observer
|
22 |
*/
|
23 |
-
public function
|
24 |
{
|
25 |
if (Mage::getStoreConfig('catalog/orderexport/process')){
|
26 |
try
|
27 |
{
|
28 |
/*
|
29 |
-
*
|
30 |
*/
|
31 |
$order = $observer->getEvent()->getOrder();
|
32 |
// lookup for BSK Orders
|
@@ -43,8 +42,10 @@ class Adventos_OrderExport_Model_Observer
|
|
43 |
}
|
44 |
}
|
45 |
|
|
|
|
|
46 |
/**
|
47 |
-
*
|
48 |
*
|
49 |
* @param Mage_Sales_Model_Order $order
|
50 |
* @return Adventos_OrderExport_Model_Observer
|
@@ -53,12 +54,12 @@ class Adventos_OrderExport_Model_Observer
|
|
53 |
{
|
54 |
$ordArray = $this->createOrder($order);
|
55 |
$ordXml = $this->toXml($ordArray,'salesOrder');
|
56 |
-
$file
|
57 |
|
58 |
$varExport = Mage::getBaseDir('export');
|
59 |
$exportPath = $varExport.DS.$file;
|
60 |
|
61 |
-
$handle
|
62 |
fwrite($handle,$ordXml);
|
63 |
fclose($handle);
|
64 |
|
@@ -98,7 +99,7 @@ class Adventos_OrderExport_Model_Observer
|
|
98 |
}
|
99 |
|
100 |
// we want the XML to be formatted,
|
101 |
-
//
|
102 |
$doc = new DOMDocument('1.0', 'cp850');
|
103 |
$doc->preserveWhiteSpace = false;
|
104 |
$doc->loadXML( $xml->asXML() );
|
@@ -113,7 +114,7 @@ class Adventos_OrderExport_Model_Observer
|
|
113 |
|
114 |
public function createOrder($order){
|
115 |
|
116 |
-
$productArray
|
117 |
|
118 |
// Magento required models
|
119 |
$customer = Mage::getModel('customer/customer')->load($order->getCustomerId());
|
@@ -129,33 +130,32 @@ class Adventos_OrderExport_Model_Observer
|
|
129 |
"product_price" => $item->getPrice(),
|
130 |
"product_row_discount_amount" => $item->getDiscountAmount(),
|
131 |
"product_row_price" => $item->getQtyOrdered() * $item->getPrice() - $item->getDiscountAmount(),
|
132 |
-
"product_order_id" => $order->getRealOrderId(),
|
133 |
"product_order_item_id" => $item->getId(),
|
134 |
);
|
135 |
}
|
136 |
|
137 |
-
$streetBA
|
138 |
-
$streetSA
|
139 |
|
140 |
$customerGroupId = $order->getCustomerGroupId ();
|
141 |
|
142 |
$group = Mage::getModel ('customer/group')->load ($customerGroupId);
|
143 |
if ($group->getId()){
|
144 |
-
$customerGroupName
|
145 |
}
|
146 |
|
147 |
if($customer->getEmail()=="") {
|
148 |
-
$customerEmail
|
149 |
} else {
|
150 |
-
$customerEmail
|
151 |
}
|
152 |
|
153 |
-
$saleorder =
|
154 |
"id" => $order->getRealOrderId(),
|
155 |
"store_id" => $order->getStoreId(),
|
156 |
"store_name" => Mage::getModel('core/store')->load($order->getStoreID())->getName(),
|
157 |
"hofakt_lager" => Mage::getStoreConfig('catalog/orderexport/storage_id'),
|
158 |
-
"payment"
|
159 |
"shipping_amount" => $order->getShippingAmount(),
|
160 |
"discount_amount" => $order->getDiscountAmount(),
|
161 |
"discount_descr" => $order->getDiscountDescription(),
|
@@ -163,39 +163,39 @@ class Adventos_OrderExport_Model_Observer
|
|
163 |
"tax_amount" => $order->getTaxAmount(),
|
164 |
"grand_total" => $order->getGrandTotal(),
|
165 |
"currency" => $order->getOrderCurrencyCode(),
|
166 |
-
"date"
|
167 |
"customer" => array(
|
168 |
-
"customer_id"
|
169 |
-
"customer_name"
|
170 |
-
"customer_vatid"
|
171 |
-
"customer_email"
|
172 |
-
"customergroup"
|
173 |
),
|
174 |
-
"shipping_address" =>
|
175 |
-
"firstname"
|
176 |
-
"lastname"
|
177 |
-
"company"
|
178 |
"street" => $streetSA[0],
|
179 |
"street2" => (count($streetSA)==2)?$streetSA[1]:'',
|
180 |
-
"city"
|
181 |
-
"postcode"
|
182 |
-
"country"
|
183 |
-
"phone"
|
184 |
),
|
185 |
-
"billing_address" =>
|
186 |
-
"firstname"
|
187 |
-
"lastname"
|
188 |
-
"company"
|
189 |
"street" => $streetBA[0],
|
190 |
"street2" => (count($streetBA)==2)?$streetBA[1]:'',
|
191 |
-
"city"
|
192 |
-
"postcode"
|
193 |
-
"country"
|
194 |
-
"phone"
|
195 |
),
|
196 |
"lines" => $productArray,
|
197 |
);
|
198 |
|
199 |
return $saleorder;
|
200 |
}
|
201 |
-
}
|
11 |
* 10120122 CHANGE DiscountAmount to netDiscountAmount
|
12 |
* 20120210 ADD TAGS TaxVat Umsatzsteuer ID and Currency
|
13 |
* 20120228 REMOVE netDiscount Calc
|
|
|
14 |
*/
|
15 |
class Adventos_OrderExport_Model_Observer
|
16 |
{
|
17 |
/**
|
18 |
+
* Export einer Bestellung
|
19 |
*
|
20 |
* @param Varien_Event_Observer $observer
|
21 |
*/
|
22 |
+
public function salesOrderPlaceAfter($observer)
|
23 |
{
|
24 |
if (Mage::getStoreConfig('catalog/orderexport/process')){
|
25 |
try
|
26 |
{
|
27 |
/*
|
28 |
+
* Aus dem Event das Objekt mit dem Auftrag auslesen
|
29 |
*/
|
30 |
$order = $observer->getEvent()->getOrder();
|
31 |
// lookup for BSK Orders
|
42 |
}
|
43 |
}
|
44 |
|
45 |
+
|
46 |
+
|
47 |
/**
|
48 |
+
* Bestelldaten einer Order in XML schreiben
|
49 |
*
|
50 |
* @param Mage_Sales_Model_Order $order
|
51 |
* @return Adventos_OrderExport_Model_Observer
|
54 |
{
|
55 |
$ordArray = $this->createOrder($order);
|
56 |
$ordXml = $this->toXml($ordArray,'salesOrder');
|
57 |
+
$file="SalesOrder_".$order->getId().".xml";
|
58 |
|
59 |
$varExport = Mage::getBaseDir('export');
|
60 |
$exportPath = $varExport.DS.$file;
|
61 |
|
62 |
+
$handle=fopen($exportPath,"w+");
|
63 |
fwrite($handle,$ordXml);
|
64 |
fclose($handle);
|
65 |
|
99 |
}
|
100 |
|
101 |
// we want the XML to be formatted,
|
102 |
+
//20110722 add encoding CP850 for incredible stupid HOFAKT
|
103 |
$doc = new DOMDocument('1.0', 'cp850');
|
104 |
$doc->preserveWhiteSpace = false;
|
105 |
$doc->loadXML( $xml->asXML() );
|
114 |
|
115 |
public function createOrder($order){
|
116 |
|
117 |
+
$productArray=array(); // sale order line product wrapper
|
118 |
|
119 |
// Magento required models
|
120 |
$customer = Mage::getModel('customer/customer')->load($order->getCustomerId());
|
130 |
"product_price" => $item->getPrice(),
|
131 |
"product_row_discount_amount" => $item->getDiscountAmount(),
|
132 |
"product_row_price" => $item->getQtyOrdered() * $item->getPrice() - $item->getDiscountAmount(),
|
|
|
133 |
"product_order_item_id" => $item->getId(),
|
134 |
);
|
135 |
}
|
136 |
|
137 |
+
$streetBA=$order->getBillingAddress()->getStreet();
|
138 |
+
$streetSA=$order->getShippingAddress()->getStreet();
|
139 |
|
140 |
$customerGroupId = $order->getCustomerGroupId ();
|
141 |
|
142 |
$group = Mage::getModel ('customer/group')->load ($customerGroupId);
|
143 |
if ($group->getId()){
|
144 |
+
$customerGroupName=$group->getCode();
|
145 |
}
|
146 |
|
147 |
if($customer->getEmail()=="") {
|
148 |
+
$customerEmail=$order->getCustomerEmail();
|
149 |
} else {
|
150 |
+
$customerEmail=$customer->getEmail();
|
151 |
}
|
152 |
|
153 |
+
$saleorder = array(
|
154 |
"id" => $order->getRealOrderId(),
|
155 |
"store_id" => $order->getStoreId(),
|
156 |
"store_name" => Mage::getModel('core/store')->load($order->getStoreID())->getName(),
|
157 |
"hofakt_lager" => Mage::getStoreConfig('catalog/orderexport/storage_id'),
|
158 |
+
"payment"=> $order->getPayment()->getMethod(),
|
159 |
"shipping_amount" => $order->getShippingAmount(),
|
160 |
"discount_amount" => $order->getDiscountAmount(),
|
161 |
"discount_descr" => $order->getDiscountDescription(),
|
163 |
"tax_amount" => $order->getTaxAmount(),
|
164 |
"grand_total" => $order->getGrandTotal(),
|
165 |
"currency" => $order->getOrderCurrencyCode(),
|
166 |
+
"date"=> $order->getCreatedAt(),
|
167 |
"customer" => array(
|
168 |
+
"customer_id"=> $customer->getId(),
|
169 |
+
"customer_name"=> $customer->getName(),
|
170 |
+
"customer_vatid"=>$order->getCustomerTaxvat(),
|
171 |
+
"customer_email"=> $customerEmail,
|
172 |
+
"customergroup"=>$customerGroupName
|
173 |
),
|
174 |
+
"shipping_address" => array(
|
175 |
+
"firstname"=> $order->getShippingAddress()->getFirstname(),
|
176 |
+
"lastname"=> $order->getShippingAddress()->getLastname(),
|
177 |
+
"company"=> $order->getShippingAddress()->getCompany(),
|
178 |
"street" => $streetSA[0],
|
179 |
"street2" => (count($streetSA)==2)?$streetSA[1]:'',
|
180 |
+
"city"=> $order->getShippingAddress()->getCity(),
|
181 |
+
"postcode"=> $order->getShippingAddress()->getPostcode(),
|
182 |
+
"country"=> $order->getShippingAddress()->getCountry(),
|
183 |
+
"phone"=> $order->getShippingAddress()->getTelephone()
|
184 |
),
|
185 |
+
"billing_address" => array(
|
186 |
+
"firstname"=> $order->getBillingAddress()->getFirstname(),
|
187 |
+
"lastname"=> $order->getBillingAddress()->getLastname(),
|
188 |
+
"company"=> $order->getBillingAddress()->getCompany(),
|
189 |
"street" => $streetBA[0],
|
190 |
"street2" => (count($streetBA)==2)?$streetBA[1]:'',
|
191 |
+
"city"=> $order->getBillingAddress()->getCity(),
|
192 |
+
"postcode"=> $order->getBillingAddress()->getPostcode(),
|
193 |
+
"country"=> $order->getBillingAddress()->getCountry(),
|
194 |
+
"phone"=> $order->getBillingAddress()->getTelephone()
|
195 |
),
|
196 |
"lines" => $productArray,
|
197 |
);
|
198 |
|
199 |
return $saleorder;
|
200 |
}
|
201 |
+
}
|
app/code/local/Adventos/OrderExport/etc/config.xml
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
<config>
|
3 |
<modules>
|
4 |
<Adventos_OrderExport>
|
5 |
-
<version>0.
|
6 |
</Adventos_OrderExport>
|
7 |
</modules>
|
8 |
<global>
|
@@ -22,7 +22,7 @@
|
|
22 |
<orderexport>
|
23 |
<type>singleton</type>
|
24 |
<class>orderexport/observer</class>
|
25 |
-
<method>
|
26 |
</orderexport>
|
27 |
</observers>
|
28 |
</sales_order_place_after>
|
@@ -36,4 +36,4 @@
|
|
36 |
</orderexport>
|
37 |
</catalog>
|
38 |
</default>
|
39 |
-
</config>
|
2 |
<config>
|
3 |
<modules>
|
4 |
<Adventos_OrderExport>
|
5 |
+
<version>1.0.2</version>
|
6 |
</Adventos_OrderExport>
|
7 |
</modules>
|
8 |
<global>
|
22 |
<orderexport>
|
23 |
<type>singleton</type>
|
24 |
<class>orderexport/observer</class>
|
25 |
+
<method>salesOrderPlaceAfter</method>
|
26 |
</orderexport>
|
27 |
</observers>
|
28 |
</sales_order_place_after>
|
36 |
</orderexport>
|
37 |
</catalog>
|
38 |
</default>
|
39 |
+
</config>
|
package.xml
CHANGED
@@ -1,9 +1,9 @@
|
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>Adventos_OrderExport</name>
|
4 |
-
<version>1.0.
|
5 |
<stability>stable</stability>
|
6 |
-
<license>OSL</license>
|
7 |
<channel>community</channel>
|
8 |
<extends/>
|
9 |
<summary>OrderExport</summary>
|
@@ -11,8 +11,8 @@
|
|
11 |
<notes>generate XML-File with Orderdetails in var/export/SalesOrder_*.xml</notes>
|
12 |
<authors><author><name>ADVENTOS GmbH</name><user>adventos</user><email>magentomodules@adventos.de</email></author></authors>
|
13 |
<date>2012-05-11</date>
|
14 |
-
<time>
|
15 |
-
<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="afba3391027e1ebe798253cdc034d034"/></dir><file name="Api.php" hash="c41e82cf79235d51f25d248719e93f92"/></dir><dir name="Invoice"><dir name="Api"><file name="V2.php" hash="ed0e742f85e0f450c3387bb8a7738033"/></dir><file name="Api.php" hash="280512b1ae37690871384b3cba0a3a2b"/></dir><file name="Observer.php" hash="
|
16 |
<compatible/>
|
17 |
-
<dependencies><required><php><min>5.
|
18 |
</package>
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>Adventos_OrderExport</name>
|
4 |
+
<version>1.0.2</version>
|
5 |
<stability>stable</stability>
|
6 |
+
<license uri="http://opensource.org/licenses/osl-3.0.php">OSL v.3.0</license>
|
7 |
<channel>community</channel>
|
8 |
<extends/>
|
9 |
<summary>OrderExport</summary>
|
11 |
<notes>generate XML-File with Orderdetails in var/export/SalesOrder_*.xml</notes>
|
12 |
<authors><author><name>ADVENTOS GmbH</name><user>adventos</user><email>magentomodules@adventos.de</email></author></authors>
|
13 |
<date>2012-05-11</date>
|
14 |
+
<time>11:52:52</time>
|
15 |
+
<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="afba3391027e1ebe798253cdc034d034"/></dir><file name="Api.php" hash="c41e82cf79235d51f25d248719e93f92"/></dir><dir name="Invoice"><dir name="Api"><file name="V2.php" hash="ed0e742f85e0f450c3387bb8a7738033"/></dir><file name="Api.php" hash="280512b1ae37690871384b3cba0a3a2b"/></dir><file name="Observer.php" hash="ac4121a073916e9cf486855441cf06e2"/><dir name="Shipment"><dir name="Api"><file name="V2.php" hash="22acaee0fe176a65fc1071d4dab5d6f5"/></dir><file name="Api.php" hash="0b9bf452b7e36c1ee5cefbb3d6c5eb3b"/></dir></dir><dir name="etc"><file name="api.xml" hash="538bba91e396d0493fe236d6385d9049"/><file name="config.xml" hash="6354cc5a2825f63f6f8629a0dd9130ad"/><file name="system.xml" hash="5c5f13a808798403227d3fedd43c877f"/><file name="wsdl.xml" hash="b3e1086c7e06ece8e0c0e5f537b1480f"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Adventos_OrderExport.xml" hash="479b13bf3a08de9f93f5f58d77d3f9bb"/></dir></target></contents>
|
16 |
<compatible/>
|
17 |
+
<dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php><package><name>Mage_Core_Modules</name><channel>community</channel><min>1.6.0.0</min><max>1.7</max></package></required></dependencies>
|
18 |
</package>
|