Merge lp:~mohammed-nahhas/magentoerpconnect/magento-module-dev into lp:magentoerpconnect/magento-module-oerp5.0-stable

Proposed by Mohammed NAHHAS
Status: Needs review
Proposed branch: lp:~mohammed-nahhas/magentoerpconnect/magento-module-dev
Merge into: lp:magentoerpconnect/magento-module-oerp5.0-stable
Diff against target: 510 lines (+418/-2)
8 files modified
Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Catalog/Product/Api.php (+80/-0)
Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Observer.php (+24/-0)
Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Sales/Order/Api.php (+116/-0)
Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/controllers/Adminhtml/InitController.php (+61/-0)
Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/controllers/OpenerpconnectorController.php (+5/-0)
Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/etc/api.xml (+33/-0)
Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/etc/config.xml (+45/-2)
Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/sql/openerpconnector_setup/mysql4-install-0.0.1.php (+54/-0)
To merge this branch: bzr merge lp:~mohammed-nahhas/magentoerpconnect/magento-module-dev
Reviewer Review Type Date Requested Status
Guewen Baconnier @ Camptocamp (community) Needs Resubmitting
Sharoon Thomas http://openlabs.co.in Pending
Review via email: mp+63859@code.launchpad.net
To post a comment you must log in.
26. By Mohammed <email address hidden>

[ADD] Missing files for previous revision (25th)

Revision history for this message
Sharoon Thomas http://openlabs.co.in (sharoonthomas) wrote :

Hi,

Can you rewrite the comments in english. I think that would help more people to contribute and stick to the rest of the codebase.

Thanks,

Sharoon

Revision history for this message
Guewen Baconnier @ Camptocamp (gbaconnier-c2c) wrote :

Hi Mohammed,

Just a quick note : the address stuffs in the retrieveOrders function is not needed I think you can remove it to clarify the code (lines 14-43).

Thanks
Guewen

27. By monahhas <monahhas@midgard>

[ADD] create Configurable and Bundle product

Revision history for this message
Guewen Baconnier @ Camptocamp (gbaconnier-c2c) wrote :

Hi,

Thanks for the corrections and the bundle product API.
It seems that the API for the configurable is missing, can you check please ?
Thanks !!
Guewen

Revision history for this message
Guewen Baconnier @ Camptocamp (gbaconnier-c2c) wrote :

I was wrong, configurable API is here. Thanks

28. By monahhas <monahhas@midgard>

[ADD] Compatibility with magento 1.3.x.x added, if version of magento is 1.3.x.x the module will :

- add an order attribute called 'imported' instead of column for magento 1.4.x.x and higher.
- add an observer for the event 'sales_order_place_after' which initialize the value of 'imported' to 0 every time an order is placed, if there any problem during the initialization, a log called OpenErp_Connector.log will be created in [yourmagento]/var/log/, this log contains information about the problem, increment_id, error message,...
- function retreive() compatibility with 1.3.x.x fixed
- allow you to initialize the value of the attribute 'imported' to 0 for all orders placed before installing the module, so they can be imported in OpenErp, this script can be called via this Url : http://[base_url]/index.php/connector/adminhtml_init/orders/

Revision history for this message
Guewen Baconnier @ Camptocamp (gbaconnier-c2c) wrote :

Seems that Mohammed fixed the problems but not updated the merge proposal.

review: Needs Resubmitting

Unmerged revisions

28. By monahhas <monahhas@midgard>

[ADD] Compatibility with magento 1.3.x.x added, if version of magento is 1.3.x.x the module will :

- add an order attribute called 'imported' instead of column for magento 1.4.x.x and higher.
- add an observer for the event 'sales_order_place_after' which initialize the value of 'imported' to 0 every time an order is placed, if there any problem during the initialization, a log called OpenErp_Connector.log will be created in [yourmagento]/var/log/, this log contains information about the problem, increment_id, error message,...
- function retreive() compatibility with 1.3.x.x fixed
- allow you to initialize the value of the attribute 'imported' to 0 for all orders placed before installing the module, so they can be imported in OpenErp, this script can be called via this Url : http://[base_url]/index.php/connector/adminhtml_init/orders/

27. By monahhas <monahhas@midgard>

[ADD] create Configurable and Bundle product

26. By Mohammed <email address hidden>

[ADD] Missing files for previous revision (25th)

25. By Mohammed <email address hidden>

[ADD] Flag for imported orders

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Helper/Data.php' (properties changed: +x to -x)
2=== added directory 'Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Catalog'
3=== added directory 'Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Catalog/Product'
4=== added file 'Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Catalog/Product/Api.php'
5--- Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Catalog/Product/Api.php 1970-01-01 00:00:00 +0000
6+++ Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Catalog/Product/Api.php 2011-11-09 09:54:26 +0000
7@@ -0,0 +1,80 @@
8+<?php
9+
10+/**
11+ * @author Mohammed NAHHAS
12+ * @package Openlabs_OpenERPConnector
13+ */
14+
15+class Openlabs_OpenERPConnector_Model_Catalog_Product_Api extends Mage_Catalog_Model_Product_Api
16+{
17+ /**
18+ * Set additional data before product saved
19+ *
20+ * @param Mage_Catalog_Model_Product $product
21+ * @param array $productData
22+ * @return object
23+ */
24+ protected function _prepareDataForSave ($product, $productData)
25+ {
26+ if (isset($productData['categories']) && is_array($productData['categories'])) {
27+ $product->setCategoryIds($productData['categories']);
28+ }
29+
30+ if (isset($productData['websites']) && is_array($productData['websites'])) {
31+ foreach ($productData['websites'] as &$website) {
32+ if (is_string($website)) {
33+ try {
34+ $website = Mage::app()->getWebsite($website)->getId();
35+ } catch (Exception $e) { }
36+ }
37+ }
38+ $product->setWebsiteIds($productData['websites']);
39+ }
40+
41+ if (Mage::app()->isSingleStoreMode()) {
42+ $product->setWebsiteIds(array(Mage::app()->getStore(true)->getWebsite()->getId()));
43+ }
44+
45+ if (isset($productData['stock_data']) && is_array($productData['stock_data'])) {
46+ $product->setStockData($productData['stock_data']);
47+ } else {
48+ $product->setStockData(array('use_config_manage_stock' => 0));
49+ }
50+
51+ if (isset($productData['tier_price']) && is_array($productData['tier_price'])) {
52+ $tierPrices = Mage::getModel('catalog/product_attribute_tierprice_api')->prepareTierPrices($product, $productData['tier_price']);
53+ $product->setData(Mage_Catalog_Model_Product_Attribute_Tierprice_Api::ATTRIBUTE_CODE, $tierPrices);
54+ }
55+
56+ /*
57+ * Check if configurable product data array passed
58+ */
59+ if(isset($productData['configurable_products_data']) && is_array($productData['configurable_products_data'])) {
60+ $product->setConfigurableProductsData($productData['configurable_products_data']);
61+ }
62+
63+ if(isset($productData['configurable_attributes_data']) && is_array($productData['configurable_attributes_data'])) {
64+ foreach($productData['configurable_attributes_data'] as $key => $data) {
65+
66+ //Check to see if these values exist, otherwise try and populate from existing values
67+ $data['label'] = (!empty($data['label'])) ? $data['label'] : $product->getResource()->getAttribute($data['attribute_code'])->getStoreLabel();
68+ $data['frontend_label'] = (!empty($data['frontend_label'])) ? $data['frontend_label'] : $product->getResource()->getAttribute($data['attribute_code'])->getFrontendLabel();
69+ $productData['configurable_attributes_data'][$key] = $data;
70+ }
71+ $product->setConfigurableAttributesData($productData['configurable_attributes_data']);
72+ $product->setCanSaveConfigurableAttributes(true);
73+ }
74+
75+ /*
76+ * Check if bundle product data, options and bundle items arrays passed
77+ */
78+ if(isset($productData['bundle_items_data']) && isset($productData['options_data']) && is_array($productData['bundle_items_data']) && is_array($productData['options_data'])) {
79+
80+ $product->setBundleOptionsData($productData['options_data']);
81+ $product->setBundleSelectionsData($productData['bundle_items_data']);
82+ $product->setCanSaveBundleSelections(true);
83+ $product->setAffectBundleProductSelections(true);
84+ Mage::register('product', $product); // product must be registred in order to get the store_id, see _beforeSave() in Mage/Bundle/Model/Selection.php
85+ }
86+ }
87+}
88\ No newline at end of file
89
90=== added file 'Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Observer.php'
91--- Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Observer.php 1970-01-01 00:00:00 +0000
92+++ Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Observer.php 2011-11-09 09:54:26 +0000
93@@ -0,0 +1,24 @@
94+<?php
95+/**
96+ *
97+ * @author Mohammed NAHHAS
98+ * @package Openlabs_OpenERPConnector
99+ *
100+ */
101+
102+class Openlabs_OpenERPConnector_Model_Observer extends Mage_Core_Model_Abstract {
103+
104+ /* Initialize attribtue 'imported' if version < 1.4.0.0 */
105+ public function initImported($observer) {
106+ if(str_replace('.','',Mage::getVersion()) < 1400) {
107+ $order = $observer->getOrder();
108+ try {
109+ $order->setImported(0)->save();
110+ }catch (Exception $e) {
111+ /* If logs are enabled (backend : system->configuration->developer->logSettings), it creates a file named OpenErp_Connector.log in /var/log/ which contains the errors */
112+ Mage::log('Error, order increment_id = '.$order->getIncrementId().', attribute "imported" was not initialized - error : '.$e->getMessage(), null, 'OpenErp_Connector.log');
113+ }
114+ $order->setImported(0)->save();
115+ }
116+ }
117+}
118\ No newline at end of file
119
120=== modified file 'Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcatalog/Categories.php' (properties changed: +x to -x)
121=== modified file 'Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcatalog/Product/Attribute.php' (properties changed: +x to -x)
122=== modified file 'Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcatalog/Product/Attributegroup.php' (properties changed: +x to -x)
123=== modified file 'Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcatalog/Product/Attributeset.php' (properties changed: +x to -x)
124=== modified file 'Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcatalog/Product/Tierprice.php' (properties changed: +x to -x)
125=== modified file 'Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcatalog/Products.php' (properties changed: +x to -x)
126=== modified file 'Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcore/Groups.php' (properties changed: +x to -x)
127=== modified file 'Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcore/Storeviews.php' (properties changed: +x to -x)
128=== modified file 'Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcore/Website.php' (properties changed: +x to -x)
129=== modified file 'Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcustomer/Customer.php' (properties changed: +x to -x)
130=== modified file 'Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcustomer/Group.php' (properties changed: +x to -x)
131=== added directory 'Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Sales'
132=== added directory 'Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Sales/Order'
133=== added file 'Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Sales/Order/Api.php'
134--- Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Sales/Order/Api.php 1970-01-01 00:00:00 +0000
135+++ Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Sales/Order/Api.php 2011-11-09 09:54:26 +0000
136@@ -0,0 +1,116 @@
137+<?php
138+
139+/**
140+ *
141+ * @author Mohammed NAHHAS
142+ * @package Openlabs_OpenERPConnector
143+ *
144+ */
145+
146+class Openlabs_OpenERPConnector_Model_Sales_Order_Api extends Mage_Sales_Model_Order_Api {
147+
148+ /**
149+ *
150+ * Retrieve orders data based on the value of the flag 'imported'
151+ * @param array
152+ * @return array
153+ */
154+ public function retrieveOrders($data) {
155+
156+ $result = array();
157+ if(isset($data['imported'])) {
158+
159+ $collection = Mage::getModel("sales/order")->getCollection()
160+ ->addAttributeToSelect('*')
161+ ->addAttributeToFilter('imported', array('eq' => $data['imported']));
162+
163+ /* addAddressFields() is called only if version >= 1400 */
164+ if(str_replace('.','',Mage::getVersion()) >= 1400) {
165+ $collection->addAddressFields();
166+ }
167+
168+ if(isset($data['limit'])) {
169+ $collection->setPageSize($data['limit']);
170+ $collection->setOrder('entity_id', 'ASC');
171+ }
172+
173+ if(isset($data['filters']) && is_array($data['filters'])) {
174+ $filters = $data['filters'];
175+ foreach($filters as $field => $value) {
176+ $collection->addAttributeToFilter($field, $value);
177+ }
178+ }
179+
180+ foreach ($collection as $order) {
181+ $tmp = $this->_getAttributes($order, 'order');
182+
183+ /* if version < 1400, billing and shipping information are added manually to order data */
184+ if(str_replace('.','',Mage::getVersion()) < 1400) {
185+ $address_data = $this->_getAttributes($order->getShippingAddress(), 'order_address');
186+ if(!empty($address_data)) {
187+ $tmp['shipping_firstname'] = $address_data['firstname'];
188+ $tmp['shipping_lastname'] = $address_data['lastname'];
189+ }
190+
191+ $address_data = $this->_getAttributes($order->getBillingAddress(), 'order_address');
192+ if(!empty($address_data)) {
193+ $tmp['billing_firstname'] = $address_data['firstname'];
194+ $tmp['billing_lastname'] = $address_data['lastname'];
195+ }
196+ }
197+
198+ $result[] = $tmp;
199+ }
200+ return $result;
201+ }else{
202+ $this->_fault('data_invalid', "Error, the attribut 'imported' need to be specified");
203+ }
204+ }
205+
206+ public function setFlagForOrder($incrementId) {
207+ $_order = $this->_initOrder($incrementId);
208+ $_order->setImported(1);
209+ try {
210+ $_order->save();
211+ return true;
212+ } catch (Mage_Core_Exception $e) {
213+ $this->_fault('data_invalid', $e->getMessage());
214+ }
215+ }
216+
217+ /* Retrieve increment_id of the child order */
218+ public function getOrderChild($incrementId) {
219+
220+ $order = Mage::getModel('sales/order')->loadByIncrementId($incrementId);
221+ /**
222+ * Check order existing
223+ */
224+ if (!$order->getId()) {
225+ $this->_fault('order_not_exists');
226+ }
227+
228+ if($order->getRelationChildId()) {
229+ return $order->getRelationChildRealId();
230+ }else{
231+ return false;
232+ }
233+ }
234+
235+ /* Retrieve increment_id of the parent order */
236+ public function getOrderParent($incrementId) {
237+
238+ $order = Mage::getModel('sales/order')->loadByIncrementId($incrementId);
239+ /**
240+ * Check order existing
241+ */
242+ if (!$order->getId()) {
243+ $this->_fault('order_not_exists');
244+ }
245+
246+ if($order->getRelationParentId()) {
247+ return $order->getRelationParentRealId();
248+ }else{
249+ return false;
250+ }
251+ }
252+}
253\ No newline at end of file
254
255=== added directory 'Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/controllers'
256=== added directory 'Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/controllers/Adminhtml'
257=== added file 'Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/controllers/Adminhtml/InitController.php'
258--- Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/controllers/Adminhtml/InitController.php 1970-01-01 00:00:00 +0000
259+++ Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/controllers/Adminhtml/InitController.php 2011-11-09 09:54:26 +0000
260@@ -0,0 +1,61 @@
261+<?php
262+
263+/**
264+ *
265+ * @author Mohammed NAHHAS
266+ * @package Openlabs_OpenERPConnector
267+ *
268+ */
269+
270+class Openlabs_OpenERPConnector_Adminhtml_InitController extends Mage_Adminhtml_Controller_Action
271+{
272+ protected $_imported = 'imported';
273+
274+ /* Initialize the Attribute 'Imported' for orders placed before installing Openlabs_OpenERPConnector Extension */
275+ public function ordersAction() {
276+ /* 'imported' value will be initialized if magento version is < 1.4.0.0 */
277+ if(str_replace('.','',Mage::getVersion()) < 1400) {
278+ $orders = array();
279+
280+ /* 'imported' attribute values are stored in sales_order_int */
281+ $imported_attribute_table_name = 'sales_order_int';
282+
283+ /* retrieve entity_type_id for order */
284+ $entity_type = Mage::getModel('eav/entity_type')->loadByCode('order');
285+
286+ /* Load 'imported' attribute to get its attribute_id */
287+ $attributeInfo = Mage::getResourceModel('eav/entity_attribute_collection')
288+ ->setCodeFilter($this->_imported)
289+ ->setEntityTypeFilter($entity_type->getEntityTypeId())
290+ ->getFirstItem();
291+
292+ /* load order collection */
293+ $collection = Mage::getResourceModel('sales/order_collection')
294+ ->addAttributeToSelect($this->_imported);
295+
296+ if(count($collection->getItems()) > 0) {
297+ foreach($collection as $order) {
298+ try{
299+ $test = $order->getResource()->getAttribute($this->_imported);
300+ $orders[] = $order->getIncrementId();
301+ $order->setImported(0)->save();
302+ $request = "INSERT IGNORE INTO ".$imported_attribute_table_name." (entity_type_id, attribute_id, entity_id, value) VALUES (".$entity_type->getEntityTypeId().", ".$attributeInfo->getAttributeId().", ".$order->getEntityId().", 0)";
303+ $write = Mage::getSingleton('core/resource')->getConnection('core_write');
304+ $query = $write->query($request);
305+ }catch (Exception $e) {
306+ echo 'Error : '.$e->getMessage();
307+ }
308+ }
309+
310+ echo 'Number of Orders Initialized : '.count($collection->getItems()) .'<br />';
311+ echo 'Orders List : '.'<br />';
312+ echo '<pre>';
313+ print_r($orders);
314+ echo '</pre>';
315+ }
316+ }else{
317+ echo 'Magento Version : '.Mage::getVersion().'<br />';
318+ echo 'There is no need to initialize orders';
319+ }
320+ }
321+}
322\ No newline at end of file
323
324=== added file 'Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/controllers/OpenerpconnectorController.php'
325--- Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/controllers/OpenerpconnectorController.php 1970-01-01 00:00:00 +0000
326+++ Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/controllers/OpenerpconnectorController.php 2011-11-09 09:54:26 +0000
327@@ -0,0 +1,5 @@
328+<?php
329+class Openlabs_OpenERPConnector_OpenerpconnectorController extends Mage_Core_Controller_Front_Action
330+{
331+
332+}
333
334=== modified file 'Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/etc/api.xml'
335--- Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/etc/api.xml 2010-08-19 15:06:19 +0000
336+++ Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/etc/api.xml 2011-11-09 09:54:26 +0000
337@@ -488,6 +488,39 @@
338 </filters_invalid>
339 </faults>
340 </ol_catalog_product_attributeset>
341+ <sales_order translate="title" module="Openlabs_OpenERPConnector">
342+ <model>sales/order_api</model>
343+ <title>Custom Sales Orders API</title>
344+ <methods>
345+ <retrieve translate="title" module="Openlabs_OpenERPConnector">
346+ <title>Retrieve list of orders by filters, nb max, etc...</title>
347+ <method>retrieveOrders</method>
348+ </retrieve>
349+ <done translate="title" module="Openlabs_OpenERPConnector">
350+ <title>Set Flag to TRUE for imported orders</title>
351+ <method>setFlagForOrder</method>
352+ </done>
353+ <get_child translate="title" module="Openlabs_OpenERPConnector">
354+ <title>get The Child of The Order Edited</title>
355+ <method>getOrderChild</method>
356+ </get_child>
357+ <get_parent translate="title" module="Openlabs_OpenERPConnector">
358+ <title>get The Parent of the order annulated</title>
359+ <method>getOrderParent</method>
360+ </get_parent>
361+ </methods>
362+ </sales_order>
363+ <catalog_product translate="title" module="catalog">
364+ <title>Product API</title>
365+ <model>catalog/product_api</model>
366+ <acl>catalog/product</acl>
367+ <methods>
368+ <create_bundle translate="title" module="Openlabs_OpenERPConnector">
369+ <title>Create Bundle Products with Custom Options and Bundle Items</title>
370+ <method>createBundleProducts</method>
371+ </create_bundle>
372+ </methods>
373+ </catalog_product>
374 </resources>
375 </api>
376 </config>
377
378=== modified file 'Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/etc/config.xml'
379--- Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/etc/config.xml 2010-08-19 15:06:19 +0000
380+++ Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/etc/config.xml 2011-11-09 09:54:26 +0000
381@@ -1,15 +1,36 @@
382 <?xml version="1.0"?>
383 <config>
384- <!--<modules>
385+ <modules>
386 <Openlabs_OpenERPConnector>
387 <version>0.0.1</version>
388 </Openlabs_OpenERPConnector>
389- </modules>-->
390+ </modules>
391+ <frontend>
392+ <routers>
393+ <openerpconnector>
394+ <use>standard</use>
395+ <args>
396+ <module>Openlabs_OpenERPConnector</module>
397+ <frontName>openerpconnector</frontName>
398+ </args>
399+ </openerpconnector>
400+ </routers>
401+ </frontend>
402 <global>
403 <models>
404 <openerpconnector>
405 <class>Openlabs_OpenERPConnector_Model</class>
406 </openerpconnector>
407+ <sales>
408+ <rewrite>
409+ <order_api>Openlabs_OpenERPConnector_Model_Sales_Order_Api</order_api>
410+ </rewrite>
411+ </sales>
412+ <catalog>
413+ <rewrite>
414+ <product_api>Openlabs_OpenERPConnector_Model_Catalog_Product_Api</product_api>
415+ </rewrite>
416+ </catalog>
417 </models>
418 <resources>
419 <openerpconnector_setup>
420@@ -41,5 +62,27 @@
421 <class>Openlabs_OpenERPConnector_Helper</class>
422 </openerpconnector>
423 </helpers>
424+ <events>
425+ <sales_order_place_after>
426+ <observers>
427+ <init_imported_after_place_order>
428+ <type>singleton</type>
429+ <class>openerpconnector/observer</class>
430+ <method>initImported</method>
431+ </init_imported_after_place_order>
432+ </observers>
433+ </sales_order_place_after>
434+ </events>
435 </global>
436+ <admin>
437+ <routers>
438+ <openerpconnector>
439+ <use>admin</use>
440+ <args>
441+ <module>Openlabs_OpenERPConnector</module>
442+ <frontName>connector</frontName>
443+ </args>
444+ </openerpconnector>
445+ </routers>
446+ </admin>
447 </config>
448\ No newline at end of file
449
450=== added directory 'Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/sql'
451=== added directory 'Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/sql/openerpconnector_setup'
452=== added file 'Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/sql/openerpconnector_setup/mysql4-install-0.0.1.php'
453--- Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/sql/openerpconnector_setup/mysql4-install-0.0.1.php 1970-01-01 00:00:00 +0000
454+++ Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/sql/openerpconnector_setup/mysql4-install-0.0.1.php 2011-11-09 09:54:26 +0000
455@@ -0,0 +1,54 @@
456+<?php
457+/**
458+ *
459+ * @author Mohammed NAHHAS
460+ * @package Openlabs_OpenERPConnector
461+ *
462+ */
463+
464+/* Retrieve the version of Magento */
465+$version = Mage::getVersion();
466+
467+/* Need to add a sales_order attribute if the version < 1.4.x.x - sales_order is an EAV Model */
468+/* Else add a simple column to sales_flat_order Table */
469+$version = str_replace('.','',$version);
470+if($version >= 1400) {
471+ $installer = $this;
472+ $installer->startSetup();
473+ $tableName='sales_flat_order';
474+ $db = $installer->getConnection();
475+
476+ /* Delete the column if it exists before re-create it */
477+ if($db->tableColumnExists($this->getTable($tableName), 'imported')) {
478+ $installer->run("ALTER TABLE {$this->getTable($tableName)} drop column imported");
479+ }
480+
481+ /* re-create 'imported' column */
482+ if(!$db->tableColumnExists($this->getTable($tableName), 'imported')) {
483+ $installer->run("
484+ ALTER TABLE {$this->getTable($tableName)} ADD imported tinyint(1) unsigned NOT NULL default '0';
485+ ");
486+ }
487+}else{
488+ $installer = new Mage_Eav_Model_Entity_Setup('core_setup');
489+ $installer->startSetup();
490+
491+ /* Attribute Data */
492+ $attribute_data = array(
493+ 'type' => 'int',
494+ 'default' => 0,
495+ 'visible' => false,
496+ 'required' => false,
497+ 'user_defined' => false,
498+ 'searchable' => false,
499+ 'filterable' => false,
500+ 'comparable' => false
501+ );
502+ /* Add a sales_order attribute named 'imported' */
503+ $installer->addAttribute('order', 'imported', $attribute_data);
504+
505+}
506+
507+
508+/* End */
509+$installer->endSetup();
510\ No newline at end of file