Adventos_OrderExport - Version 1.4.0

Version Notes

Supporting Bundle Products

Export orders that have the "Processing" status by default.

Download this release

Release Info

Developer Karsten Hoffmann
Extension Adventos_OrderExport
Version 1.4.0
Comparing to
See all releases


Code changes from version 1.3.9 to 1.4.0

app/code/local/Adventos/OrderExport/Model/Observer.php CHANGED
@@ -13,8 +13,8 @@
13
  * 20120210 ADD TAGS TaxVat Umsatzsteuer ID and Currency
14
  * 20120228 REMOVE netDiscount Calc
15
  * 20121011 ADD generateCatalogInventoryFile
16
- * TODO Add new Tag <fee> for Shell payment fee invoice 10 Bucks
17
- * TODO Handle Bundle Product > Split into Simple
18
  */
19
  class Adventos_OrderExport_Model_Observer {
20
  /**
@@ -134,6 +134,7 @@ class Adventos_OrderExport_Model_Observer {
134
  return $doc->saveXML ();
135
  }
136
  public function createOrder($order) {
 
137
  $productArray = array (); // sale order line product wrapper
138
 
139
  // Magento required models
@@ -142,12 +143,30 @@ class Adventos_OrderExport_Model_Observer {
142
  // walk the sale order lines
143
  foreach ( $order->getAllItems () as $item ) // getAllVisibleItems() - getAllItems() - getItemCollection()
144
  {
145
- // Check if Item is Bundled
146
- if ($item->getHasChildren () && $item->getData ( 'product_type' ) != Mage_Catalog_Model_Product_Type::TYPE_CONFIGURABLE) {
147
- //if ($item->getData ( 'product_type' ) == Mage_Catalog_Model_Product_Type::TYPE_BUNDLE && $item->getHasChildren ()) {
148
  Mage::log ( "ADVENTOS Skip Item Type with children = " . $item->getData ('product_type'));
149
  } else {
150
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
151
  $tax_amount = $item->getTaxAmount ();
152
  $discount_percent = $item->getDiscountPercent ();
153
  $discountAmount = $item->getDiscountAmount ();
@@ -168,21 +187,22 @@ class Adventos_OrderExport_Model_Observer {
168
  }
169
  }
170
  }
 
171
 
172
- // Mage:log(print_r($item));
173
  $productArray [] = array (
174
- "product_sku" => $item->getSku (),
175
- "product_magento_id" => $item->getProductId (),
176
- "product_name" => $item->getName (),
177
- "product_qty" => $item->getQtyOrdered (),
178
- "product_price" => $item->getPrice (),
179
- "product_discount_percent" => $item->getDiscountPercent (),
180
- "product_row_discount_amount" => $item->getDiscountAmount (),
181
- "product_row_price" => $product_row_price,
182
- "product_order_id" => $order->getRealOrderId (),
183
- "product_order_item_id" => $item->getId (),
184
- "product_description" => ""
185
- );
 
186
  }
187
  }
188
 
@@ -214,7 +234,6 @@ class Adventos_OrderExport_Model_Observer {
214
  $shipping_vat_id = "";
215
  }
216
 
217
- // Check if SalesOrder Fee is set
218
 
219
  // Check if SalesOrder Fee is set
220
  if ($order->getFeeAmount () != null) {
@@ -419,4 +438,21 @@ class Adventos_OrderExport_Model_Observer {
419
  }
420
 
421
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
422
  }
13
  * 20120210 ADD TAGS TaxVat Umsatzsteuer ID and Currency
14
  * 20120228 REMOVE netDiscount Calc
15
  * 20121011 ADD generateCatalogInventoryFile
16
+ * 20140820 CHANGE dispatchEvent to change Order_Status PENDING -> PROCESSING
17
+ * 20140929 ADD support for bundle products, removing duplicated configurable products
18
  */
19
  class Adventos_OrderExport_Model_Observer {
20
  /**
134
  return $doc->saveXML ();
135
  }
136
  public function createOrder($order) {
137
+ $isPreviousProductConfigurable = false;
138
  $productArray = array (); // sale order line product wrapper
139
 
140
  // Magento required models
143
  // walk the sale order lines
144
  foreach ( $order->getAllItems () as $item ) // getAllVisibleItems() - getAllItems() - getItemCollection()
145
  {
146
+ // Check if Item is Bundled
147
+ if ($item->getHasChildren () && $item->getData ('product_type') == Mage_Catalog_Model_Product_Type::TYPE_BUNDLE) {
 
148
  Mage::log ( "ADVENTOS Skip Item Type with children = " . $item->getData ('product_type'));
149
  } else {
150
 
151
+ // check if simple product has a configurable product. If yes, skip the product
152
+ if ($isPreviousProductConfigurable) {
153
+ if ($item->getData ('product_type') == Mage_Catalog_Model_Product_Type::TYPE_SIMPLE) {
154
+ $parentIds = Mage::getResourceSingleton('catalog/product_type_configurable')->getParentIdsByChild($item->getData('product_id'));
155
+ if (is_array($parentIds))
156
+ if (isset($parentIds[0])) {
157
+ $_product = Mage::getModel('catalog/product')->load($parentIds[0]);
158
+ if ($_product->getTypeId() == Mage_Catalog_Model_Product_Type::TYPE_CONFIGURABLE) {
159
+ continue;
160
+ }
161
+ }
162
+ }
163
+ }
164
+
165
+ if ($item->getData ('product_type') == Mage_Catalog_Model_Product_Type::TYPE_CONFIGURABLE)
166
+ $isPreviousProductConfigurable = true;
167
+ else
168
+ $isPreviousProductConfigurable = false;
169
+
170
  $tax_amount = $item->getTaxAmount ();
171
  $discount_percent = $item->getDiscountPercent ();
172
  $discountAmount = $item->getDiscountAmount ();
187
  }
188
  }
189
  }
190
+
191
 
 
192
  $productArray [] = array (
193
+ "product_sku" => $item->getSku (),
194
+ "product_magento_id" => $item->getProductId (),
195
+ "product_name" => $item->getName (),
196
+ "product_qty" => $item->getQtyOrdered (),
197
+ "product_price" => $item->getPrice (),
198
+ "product_discount_percent" => $item->getDiscountPercent (),
199
+ "product_row_discount_amount" => $item->getDiscountAmount (),
200
+ "product_row_price" => $product_row_price,
201
+ "product_order_id" => $order->getRealOrderId (),
202
+ "product_order_item_id" => $item->getId (),
203
+ "product_description" => ""
204
+ );
205
+
206
  }
207
  }
208
 
234
  $shipping_vat_id = "";
235
  }
236
 
 
237
 
238
  // Check if SalesOrder Fee is set
239
  if ($order->getFeeAmount () != null) {
438
  }
439
 
440
  }
441
+
442
+ /**
443
+ * Exports the order when a new order has been received and its status is "processing"
444
+ *
445
+ * @param object $observer
446
+ */
447
+ public function exportNewProcessingOrder($observer) {
448
+ $order = $observer->getEvent()->getOrder();
449
+ Mage::log("an order has been received. Order status is: ".$order->getStatus());
450
+ if ($order->getStatus() == Mage_Sales_Model_Order::STATE_PROCESSING) {
451
+ Mage::dispatchEvent('adventos_orderexport_export_single_order' , array('order' => $order));
452
+ Mage::Log("==== Export Event Fired ===");
453
+ }
454
+
455
+ }
456
+
457
+
458
  }
app/code/local/Adventos/OrderExport/etc/config.xml CHANGED
@@ -2,7 +2,7 @@
2
  <config>
3
  <modules>
4
  <Adventos_OrderExport>
5
- <version>1.3.9</version>
6
  </Adventos_OrderExport>
7
  </modules>
8
  <admin>
@@ -28,15 +28,6 @@
28
  </orderexport>
29
  </helpers>
30
  <events>
31
- <!--sales_order_place_after>
32
- <observers>
33
- <orderexport>
34
- <type>singleton</type>
35
- <class>orderexport/observer</class>
36
- <method>createOrderExport</method>
37
- </orderexport>
38
- </observers>
39
- </sales_order_place_after-->
40
  <core_block_abstract_to_html_before>
41
  <observers>
42
  <exportmassaction>
@@ -64,6 +55,15 @@
64
  </ordersaved>
65
  </observers>
66
  </sales_order_save_commit_after>
 
 
 
 
 
 
 
 
 
67
  </events>
68
  </global>
69
  <crontab>
@@ -89,4 +89,4 @@
89
  </orderexport>
90
  </catalog>
91
  </default>
92
- </config>
2
  <config>
3
  <modules>
4
  <Adventos_OrderExport>
5
+ <version>1.4.0</version>
6
  </Adventos_OrderExport>
7
  </modules>
8
  <admin>
28
  </orderexport>
29
  </helpers>
30
  <events>
 
 
 
 
 
 
 
 
 
31
  <core_block_abstract_to_html_before>
32
  <observers>
33
  <exportmassaction>
55
  </ordersaved>
56
  </observers>
57
  </sales_order_save_commit_after>
58
+ <sales_order_place_after>
59
+ <observers>
60
+ <orderplaced>
61
+ <type>singleton</type>
62
+ <class>orderexport/observer</class>
63
+ <method>exportNewProcessingOrder</method>
64
+ </orderplaced>
65
+ </observers>
66
+ </sales_order_place_after>
67
  </events>
68
  </global>
69
  <crontab>
89
  </orderexport>
90
  </catalog>
91
  </default>
92
+ </config>
package.xml CHANGED
@@ -1,18 +1,20 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Adventos_OrderExport</name>
4
- <version>1.3.9</version>
5
  <stability>stable</stability>
6
- <license>OSL</license>
7
  <channel>community</channel>
8
  <extends/>
9
  <summary>Magento integration for HeadOffice</summary>
10
  <description>Create Order XML file to integrate Magento with HeadOffice and synchronize stock, order status, invoice, shipments and credit memos.</description>
11
- <notes>Add Handling Fee NL</notes>
 
 
12
  <authors><author><name>Karsten Hoffmann</name><user>adventos</user><email>karsten@adventos.de</email></author></authors>
13
- <date>2014-08-21</date>
14
- <time>08:02:50</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="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="2a4b8e9b630b15a107093b24506d9a85"/><dir name="Shipment"><dir name="Api"><file name="V2.php" hash="3d7824e13e4d5cedb755b4858398f23e"/></dir><file name="Api.php" hash="0b9bf452b7e36c1ee5cefbb3d6c5eb3b"/></dir></dir><dir name="controllers"><dir name="Adminhtml"><file name="IndexController.php" hash="b9e0e5a0baabed9482061f5c7c12a5ff"/></dir></dir><dir name="etc"><file name="api.xml" hash="c1b2bc277e329b8191bcc5358cb96581"/><file name="config.xml" hash="7ffaa5d955b3bd7bcd31d559752be89a"/><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>
16
  <compatible/>
17
- <dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php></required></dependencies>
18
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Adventos_OrderExport</name>
4
+ <version>1.4.0</version>
5
  <stability>stable</stability>
6
+ <license uri="http://opensource.org/licenses/osl-3.0.php">OSL</license>
7
  <channel>community</channel>
8
  <extends/>
9
  <summary>Magento integration for HeadOffice</summary>
10
  <description>Create Order XML file to integrate Magento with HeadOffice and synchronize stock, order status, invoice, shipments and credit memos.</description>
11
+ <notes>Supporting Bundle Products&#xD;
12
+ &#xD;
13
+ Export orders that have the "Processing" status by default.</notes>
14
  <authors><author><name>Karsten Hoffmann</name><user>adventos</user><email>karsten@adventos.de</email></author></authors>
15
+ <date>2014-10-02</date>
16
+ <time>09:16:04</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="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="c20bd44e89be59a4163a69250d3a018f"/><dir name="Shipment"><dir name="Api"><file name="V2.php" hash="3d7824e13e4d5cedb755b4858398f23e"/></dir><file name="Api.php" hash="0b9bf452b7e36c1ee5cefbb3d6c5eb3b"/></dir></dir><dir name="controllers"><dir name="Adminhtml"><file name="IndexController.php" hash="b9e0e5a0baabed9482061f5c7c12a5ff"/></dir></dir><dir name="etc"><file name="api.xml" hash="c1b2bc277e329b8191bcc5358cb96581"/><file name="config.xml" hash="c3d5d3fede16b669c6c48e28c569b2c0"/><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>
18
  <compatible/>
19
+ <dependencies><required><php><min>5.0.0</min><max>6.0.0</max></php></required></dependencies>
20
  </package>