Version Notes
New Features
Magento 1.7
Download this release
Release Info
Developer | Karsten Hoffmann |
Extension | Adventos_OrderExport |
Version | 1.0.3 |
Comparing to | |
See all releases |
Code changes from version 1.0.2 to 1.0.3
app/code/local/Adventos/OrderExport/Model/Observer.php
CHANGED
@@ -11,41 +11,44 @@
|
|
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 |
-
*
|
19 |
*
|
20 |
* @param Varien_Event_Observer $observer
|
21 |
*/
|
22 |
-
public function
|
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 |
-
|
32 |
$storeId = $order->getStoreId();
|
33 |
$webSite = Mage::getModel('core/store')->load($storeId)->getWebsiteId();
|
34 |
|
35 |
$this->_exportOrder($order);
|
36 |
-
Mage::log("ADVENTOS OrderExport
|
37 |
}
|
38 |
catch (Exception $e)
|
39 |
{
|
40 |
Mage::logException($e);
|
41 |
}
|
|
|
|
|
42 |
}
|
|
|
43 |
}
|
44 |
|
45 |
|
46 |
|
47 |
/**
|
48 |
-
*
|
49 |
*
|
50 |
* @param Mage_Sales_Model_Order $order
|
51 |
* @return Adventos_OrderExport_Model_Observer
|
@@ -54,12 +57,12 @@ class 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 |
|
@@ -70,7 +73,7 @@ class Adventos_OrderExport_Model_Observer
|
|
70 |
if ($xml == null){
|
71 |
/*$xml = simplexml_load_string("<?xml version='1.0' encoding='utf-8'?><$rootNodeName />");
|
72 |
* Change encoding from UTF-8 to CP850
|
73 |
-
|
74 |
$xml = simplexml_load_string("<?xml version='1.0' encoding='cp850'?><$rootNodeName />");
|
75 |
}
|
76 |
|
@@ -79,11 +82,11 @@ class Adventos_OrderExport_Model_Observer
|
|
79 |
foreach($data as $key => $value){
|
80 |
// no numeric keys in our xml please!
|
81 |
if (is_numeric($key)){
|
82 |
-
// make
|
83 |
-
$key = "
|
84 |
}
|
85 |
// replace anything not alpha numeric
|
86 |
-
$key = preg_replace('/[^a-
|
87 |
// if there is another array found recrusively call this function
|
88 |
|
89 |
if (is_array($value)){
|
@@ -105,16 +108,11 @@ class Adventos_OrderExport_Model_Observer
|
|
105 |
$doc->loadXML( $xml->asXML() );
|
106 |
$doc->formatOutput = true;
|
107 |
return $doc->saveXML();
|
108 |
-
|
109 |
-
//return $xml->asXML();
|
110 |
-
|
111 |
}
|
112 |
|
113 |
-
|
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());
|
@@ -123,79 +121,116 @@ class Adventos_OrderExport_Model_Observer
|
|
123 |
foreach ($order->getAllVisibleItems() as $item) //getAllItems() - getItemCollection()
|
124 |
{
|
125 |
$productArray[] = array(
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
|
|
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 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
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 |
+
* 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
|
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 |
$exportPath = $varExport.DS.$file;
|
64 |
|
65 |
+
$handle = fopen($exportPath,"w+");
|
66 |
fwrite($handle,$ordXml);
|
67 |
fclose($handle);
|
68 |
|
73 |
if ($xml == null){
|
74 |
/*$xml = simplexml_load_string("<?xml version='1.0' encoding='utf-8'?><$rootNodeName />");
|
75 |
* Change encoding from UTF-8 to CP850
|
76 |
+
*/
|
77 |
$xml = simplexml_load_string("<?xml version='1.0' encoding='cp850'?><$rootNodeName />");
|
78 |
}
|
79 |
|
82 |
foreach($data as $key => $value){
|
83 |
// no numeric keys in our xml please!
|
84 |
if (is_numeric($key)){
|
85 |
+
// make item key for product array ...
|
86 |
+
$key = "item"; //.$key;
|
87 |
}
|
88 |
// replace anything not alpha numeric
|
89 |
+
$key = preg_replace('/[^a-z0-9]/i', '', $key);
|
90 |
// if there is another array found recrusively call this function
|
91 |
|
92 |
if (is_array($value)){
|
108 |
$doc->loadXML( $xml->asXML() );
|
109 |
$doc->formatOutput = true;
|
110 |
return $doc->saveXML();
|
|
|
|
|
|
|
111 |
}
|
112 |
|
|
|
|
|
113 |
public function createOrder($order){
|
114 |
|
115 |
+
$productArray = array(); // sale order line product wrapper
|
116 |
|
117 |
// Magento required models
|
118 |
$customer = Mage::getModel('customer/customer')->load($order->getCustomerId());
|
121 |
foreach ($order->getAllVisibleItems() as $item) //getAllItems() - getItemCollection()
|
122 |
{
|
123 |
$productArray[] = array(
|
124 |
+
"product_sku" => $item->getSku(),
|
125 |
+
"product_magento_id" => $item->getProductId(),
|
126 |
+
"product_name" => $item->getName(),
|
127 |
+
"product_qty" => $item->getQtyOrdered(),
|
128 |
+
"product_price" => $item->getPrice(),
|
129 |
+
"product_row_discount_amount" => $item->getDiscountAmount(),
|
130 |
+
"product_row_price" => $item->getQtyOrdered() * $item->getPrice() - $item->getDiscountAmount(),
|
131 |
+
"product_order_id" => $order->getRealOrderId(),
|
132 |
+
"product_order_item_id" => $item->getId(),
|
133 |
);
|
134 |
}
|
135 |
|
136 |
+
$streetBA = $order->getBillingAddress()->getStreet();
|
137 |
+
$streetSA = $order->getShippingAddress()->getStreet();
|
138 |
|
139 |
$customerGroupId = $order->getCustomerGroupId ();
|
140 |
|
141 |
$group = Mage::getModel ('customer/group')->load ($customerGroupId);
|
142 |
if ($group->getId()){
|
143 |
+
$customerGroupName = $group->getCode();
|
144 |
}
|
145 |
|
146 |
+
if($customer->getEmail() == "") {
|
147 |
+
$customerEmail = $order->getCustomerEmail();
|
148 |
} else {
|
149 |
+
$customerEmail = $customer->getEmail();
|
150 |
}
|
151 |
|
152 |
+
$saleorder = array(
|
153 |
+
"id" => $order->getRealOrderId(),
|
154 |
+
"store_id" => $order->getStoreId(),
|
155 |
+
"store_name" => Mage::getModel('core/store')->load($order->getStoreID())->getName(),
|
156 |
+
"hofakt_lager" => Mage::getStoreConfig('catalog/orderexport/storage_id'),
|
157 |
+
"payment" => $order->getPayment()->getMethod(),
|
158 |
+
"shipping_amount" => $order->getShippingAmount(),
|
159 |
+
"discount_amount" => $order->getDiscountAmount(),
|
160 |
+
"discount_descr" => $order->getDiscountDescription(),
|
161 |
+
"net_total" => $order->getSubtotal(),
|
162 |
+
"tax_amount" => $order->getTaxAmount(),
|
163 |
+
"grand_total" => $order->getGrandTotal(),
|
164 |
+
"currency" => $order->getOrderCurrencyCode(),
|
165 |
+
"date" => $order->getCreatedAt(),
|
166 |
+
"customer" => array(
|
167 |
+
"customer_id" => $customer->getId(),
|
168 |
+
"customer_name" => $customer->getName(),
|
169 |
+
"customer_vatid" => $order->getCustomerTaxvat(),
|
170 |
+
"customer_email" => $customerEmail,
|
171 |
+
"customergroup" => $customerGroupName
|
172 |
+
),
|
173 |
+
"shipping_address" => array(
|
174 |
+
"firstname" => $order->getShippingAddress()->getFirstname(),
|
175 |
+
"lastname" => $order->getShippingAddress()->getLastname(),
|
176 |
+
"company" => $order->getShippingAddress()->getCompany(),
|
177 |
+
"street" => $streetSA[0],
|
178 |
+
"street2" => (count($streetSA)==2)?$streetSA[1]:'',
|
179 |
+
"city" => $order->getShippingAddress()->getCity(),
|
180 |
+
"postcode" => $order->getShippingAddress()->getPostcode(),
|
181 |
+
"country" => $order->getShippingAddress()->getCountry(),
|
182 |
+
"phone" => $order->getShippingAddress()->getTelephone()
|
183 |
+
),
|
184 |
+
"billing_address" => array(
|
185 |
+
"firstname" => $order->getBillingAddress()->getFirstname(),
|
186 |
+
"lastname" => $order->getBillingAddress()->getLastname(),
|
187 |
+
"company" => $order->getBillingAddress()->getCompany(),
|
188 |
+
"street" => $streetBA[0],
|
189 |
+
"street2" => (count($streetBA)==2)?$streetBA[1]:'',
|
190 |
+
"city" => $order->getBillingAddress()->getCity(),
|
191 |
+
"postcode" => $order->getBillingAddress()->getPostcode(),
|
192 |
+
"country" => $order->getBillingAddress()->getCountry(),
|
193 |
+
"phone" => $order->getBillingAddress()->getTelephone()
|
194 |
+
),
|
195 |
+
"lines" => $productArray,
|
196 |
);
|
197 |
|
198 |
return $saleorder;
|
199 |
}
|
200 |
+
|
201 |
+
public function generateCatalogInventoryFile($schedule){
|
202 |
+
Mage::log("ADVENTOS OrderExport CatalogInventoryExport - START");
|
203 |
+
try
|
204 |
+
{
|
205 |
+
$inventoryArray = array();
|
206 |
+
$collection = Mage::getModel('catalog/product')->getCollection();
|
207 |
+
// ->addAttributeToSelect('*') // select all attributes
|
208 |
+
// ->setPageSize(10) // limit number of results returned
|
209 |
+
// ->setCurPage(4); // set the offset (useful for pagination)
|
210 |
+
|
211 |
+
foreach ($collection->load() as $item)
|
212 |
+
{
|
213 |
+
$inventoryArray[] = array(
|
214 |
+
"sku" => $item->getSku(),
|
215 |
+
"qty" => (int)Mage::getModel('cataloginventory/stock_item')->loadByProduct($item)->getQty(),
|
216 |
+
);
|
217 |
+
}
|
218 |
+
|
219 |
+
$Xml = $this->toXml($inventoryArray,'catalogInventory');
|
220 |
+
$file = "CatalogInventoryExport.xml";
|
221 |
+
|
222 |
+
$varExport = Mage::getBaseDir('export');
|
223 |
+
$exportPath = $varExport.DS.$file;
|
224 |
+
|
225 |
+
$handle = fopen($exportPath,"w+");
|
226 |
+
fwrite($handle,$Xml);
|
227 |
+
fclose($handle);
|
228 |
+
Mage::log("ADVENTOS OrderExport CatalogInventoryExport - DONE");
|
229 |
+
}
|
230 |
+
catch (Exception $e)
|
231 |
+
{
|
232 |
+
Mage::logException($e);
|
233 |
+
}
|
234 |
+
Mage::log("ADVENTOS OrderExport CatalogInventoryExport - END");
|
235 |
+
}
|
236 |
+
}
|
app/code/local/Adventos/OrderExport/etc/api.xml
CHANGED
@@ -27,11 +27,11 @@
|
|
27 |
<adventos_creditmemo translate="title" module="adventos_orderexport">
|
28 |
<title>Custom Credit memo functions for OrderExport</title>
|
29 |
<model>orderexport/creditmemo_api</model>
|
30 |
-
<acl>sales/order
|
31 |
<methods>
|
32 |
<create translate="title" module="adventos_orderexport">
|
33 |
<title>Create new Credit memo for order</title>
|
34 |
-
<acl>sales/order
|
35 |
</create>
|
36 |
</methods>
|
37 |
</adventos_creditmemo>
|
27 |
<adventos_creditmemo translate="title" module="adventos_orderexport">
|
28 |
<title>Custom Credit memo functions for OrderExport</title>
|
29 |
<model>orderexport/creditmemo_api</model>
|
30 |
+
<acl>sales/order</acl>
|
31 |
<methods>
|
32 |
<create translate="title" module="adventos_orderexport">
|
33 |
<title>Create new Credit memo for order</title>
|
34 |
+
<acl>sales/order</acl>
|
35 |
</create>
|
36 |
</methods>
|
37 |
</adventos_creditmemo>
|
app/code/local/Adventos/OrderExport/etc/config.xml
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
<config>
|
3 |
<modules>
|
4 |
<Adventos_OrderExport>
|
5 |
-
<version>1.0
|
6 |
</Adventos_OrderExport>
|
7 |
</modules>
|
8 |
<global>
|
@@ -22,12 +22,24 @@
|
|
22 |
<orderexport>
|
23 |
<type>singleton</type>
|
24 |
<class>orderexport/observer</class>
|
25 |
-
<method>
|
26 |
</orderexport>
|
27 |
</observers>
|
28 |
</sales_order_place_after>
|
29 |
</events>
|
30 |
</global>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
31 |
<default>
|
32 |
<catalog>
|
33 |
<orderexport>
|
@@ -36,4 +48,4 @@
|
|
36 |
</orderexport>
|
37 |
</catalog>
|
38 |
</default>
|
39 |
-
</config>
|
2 |
<config>
|
3 |
<modules>
|
4 |
<Adventos_OrderExport>
|
5 |
+
<version>1.2.0</version>
|
6 |
</Adventos_OrderExport>
|
7 |
</modules>
|
8 |
<global>
|
22 |
<orderexport>
|
23 |
<type>singleton</type>
|
24 |
<class>orderexport/observer</class>
|
25 |
+
<method>createOrderExport</method>
|
26 |
</orderexport>
|
27 |
</observers>
|
28 |
</sales_order_place_after>
|
29 |
</events>
|
30 |
</global>
|
31 |
+
<crontab>
|
32 |
+
<jobs>
|
33 |
+
<orderexport>
|
34 |
+
<schedule>
|
35 |
+
<cron_expr>0 22 * * *</cron_expr>
|
36 |
+
</schedule>
|
37 |
+
<run>
|
38 |
+
<model>orderexport/observer::generateCatalogInventoryFile</model>
|
39 |
+
</run>
|
40 |
+
</orderexport>
|
41 |
+
</jobs>
|
42 |
+
</crontab>
|
43 |
<default>
|
44 |
<catalog>
|
45 |
<orderexport>
|
48 |
</orderexport>
|
49 |
</catalog>
|
50 |
</default>
|
51 |
+
</config>
|
package.xml
CHANGED
@@ -1,18 +1,20 @@
|
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>Adventos_OrderExport</name>
|
4 |
-
<version>1.0.
|
5 |
<stability>stable</stability>
|
6 |
-
<license
|
7 |
<channel>community</channel>
|
8 |
<extends/>
|
9 |
-
<summary>
|
10 |
-
<description>
|
11 |
-
|
12 |
-
<
|
13 |
-
|
14 |
-
<
|
15 |
-
<
|
|
|
|
|
16 |
<compatible/>
|
17 |
-
<dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php
|
18 |
</package>
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>Adventos_OrderExport</name>
|
4 |
+
<version>1.0.3</version>
|
5 |
<stability>stable</stability>
|
6 |
+
<license>OSL v3.0</license>
|
7 |
<channel>community</channel>
|
8 |
<extends/>
|
9 |
+
<summary>HOFAKT Order and Fullfillment Extension</summary>
|
10 |
+
<description>Export Orders and Customers to HOFAKT
|
11 |
+
Update Order status</description>
|
12 |
+
<notes>New Features
|
13 |
+
Magento 1.7</notes>
|
14 |
+
<authors><author><name>Karsten Hoffmann</name><user>adventos</user><email>info@adventos.de</email></author></authors>
|
15 |
+
<date>2012-11-06</date>
|
16 |
+
<time>12:23:35</time>
|
17 |
+
<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="ad9fc9a19bb966ac2800bd7db9804ecf"/><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="8126b41684e8ee21ed6c8916e29f67d3"/><file name="config.xml" hash="44f24ba32bd7dc728c15227402870c3c"/><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>
|
18 |
<compatible/>
|
19 |
+
<dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php></required></dependencies>
|
20 |
</package>
|