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
=== modified file 'Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Helper/Data.php' (properties changed: +x to -x)
=== added directory 'Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Catalog'
=== added directory 'Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Catalog/Product'
=== added file 'Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Catalog/Product/Api.php'
--- Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Catalog/Product/Api.php 1970-01-01 00:00:00 +0000
+++ Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Catalog/Product/Api.php 2011-11-09 09:54:26 +0000
@@ -0,0 +1,80 @@
1<?php
2
3/**
4 * @author Mohammed NAHHAS
5 * @package Openlabs_OpenERPConnector
6 */
7
8class Openlabs_OpenERPConnector_Model_Catalog_Product_Api extends Mage_Catalog_Model_Product_Api
9{
10 /**
11 * Set additional data before product saved
12 *
13 * @param Mage_Catalog_Model_Product $product
14 * @param array $productData
15 * @return object
16 */
17 protected function _prepareDataForSave ($product, $productData)
18 {
19 if (isset($productData['categories']) && is_array($productData['categories'])) {
20 $product->setCategoryIds($productData['categories']);
21 }
22
23 if (isset($productData['websites']) && is_array($productData['websites'])) {
24 foreach ($productData['websites'] as &$website) {
25 if (is_string($website)) {
26 try {
27 $website = Mage::app()->getWebsite($website)->getId();
28 } catch (Exception $e) { }
29 }
30 }
31 $product->setWebsiteIds($productData['websites']);
32 }
33
34 if (Mage::app()->isSingleStoreMode()) {
35 $product->setWebsiteIds(array(Mage::app()->getStore(true)->getWebsite()->getId()));
36 }
37
38 if (isset($productData['stock_data']) && is_array($productData['stock_data'])) {
39 $product->setStockData($productData['stock_data']);
40 } else {
41 $product->setStockData(array('use_config_manage_stock' => 0));
42 }
43
44 if (isset($productData['tier_price']) && is_array($productData['tier_price'])) {
45 $tierPrices = Mage::getModel('catalog/product_attribute_tierprice_api')->prepareTierPrices($product, $productData['tier_price']);
46 $product->setData(Mage_Catalog_Model_Product_Attribute_Tierprice_Api::ATTRIBUTE_CODE, $tierPrices);
47 }
48
49 /*
50 * Check if configurable product data array passed
51 */
52 if(isset($productData['configurable_products_data']) && is_array($productData['configurable_products_data'])) {
53 $product->setConfigurableProductsData($productData['configurable_products_data']);
54 }
55
56 if(isset($productData['configurable_attributes_data']) && is_array($productData['configurable_attributes_data'])) {
57 foreach($productData['configurable_attributes_data'] as $key => $data) {
58
59 //Check to see if these values exist, otherwise try and populate from existing values
60 $data['label'] = (!empty($data['label'])) ? $data['label'] : $product->getResource()->getAttribute($data['attribute_code'])->getStoreLabel();
61 $data['frontend_label'] = (!empty($data['frontend_label'])) ? $data['frontend_label'] : $product->getResource()->getAttribute($data['attribute_code'])->getFrontendLabel();
62 $productData['configurable_attributes_data'][$key] = $data;
63 }
64 $product->setConfigurableAttributesData($productData['configurable_attributes_data']);
65 $product->setCanSaveConfigurableAttributes(true);
66 }
67
68 /*
69 * Check if bundle product data, options and bundle items arrays passed
70 */
71 if(isset($productData['bundle_items_data']) && isset($productData['options_data']) && is_array($productData['bundle_items_data']) && is_array($productData['options_data'])) {
72
73 $product->setBundleOptionsData($productData['options_data']);
74 $product->setBundleSelectionsData($productData['bundle_items_data']);
75 $product->setCanSaveBundleSelections(true);
76 $product->setAffectBundleProductSelections(true);
77 Mage::register('product', $product); // product must be registred in order to get the store_id, see _beforeSave() in Mage/Bundle/Model/Selection.php
78 }
79 }
80}
0\ No newline at end of file81\ No newline at end of file
182
=== added file 'Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Observer.php'
--- Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Observer.php 1970-01-01 00:00:00 +0000
+++ Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Observer.php 2011-11-09 09:54:26 +0000
@@ -0,0 +1,24 @@
1<?php
2/**
3 *
4 * @author Mohammed NAHHAS
5 * @package Openlabs_OpenERPConnector
6 *
7 */
8
9class Openlabs_OpenERPConnector_Model_Observer extends Mage_Core_Model_Abstract {
10
11 /* Initialize attribtue 'imported' if version < 1.4.0.0 */
12 public function initImported($observer) {
13 if(str_replace('.','',Mage::getVersion()) < 1400) {
14 $order = $observer->getOrder();
15 try {
16 $order->setImported(0)->save();
17 }catch (Exception $e) {
18 /* If logs are enabled (backend : system->configuration->developer->logSettings), it creates a file named OpenErp_Connector.log in /var/log/ which contains the errors */
19 Mage::log('Error, order increment_id = '.$order->getIncrementId().', attribute "imported" was not initialized - error : '.$e->getMessage(), null, 'OpenErp_Connector.log');
20 }
21 $order->setImported(0)->save();
22 }
23 }
24}
0\ No newline at end of file25\ No newline at end of file
126
=== modified file 'Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcatalog/Categories.php' (properties changed: +x to -x)
=== modified file 'Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcatalog/Product/Attribute.php' (properties changed: +x to -x)
=== modified file 'Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcatalog/Product/Attributegroup.php' (properties changed: +x to -x)
=== modified file 'Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcatalog/Product/Attributeset.php' (properties changed: +x to -x)
=== modified file 'Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcatalog/Product/Tierprice.php' (properties changed: +x to -x)
=== modified file 'Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcatalog/Products.php' (properties changed: +x to -x)
=== modified file 'Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcore/Groups.php' (properties changed: +x to -x)
=== modified file 'Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcore/Storeviews.php' (properties changed: +x to -x)
=== modified file 'Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcore/Website.php' (properties changed: +x to -x)
=== modified file 'Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcustomer/Customer.php' (properties changed: +x to -x)
=== modified file 'Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcustomer/Group.php' (properties changed: +x to -x)
=== added directory 'Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Sales'
=== added directory 'Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Sales/Order'
=== added file 'Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Sales/Order/Api.php'
--- Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Sales/Order/Api.php 1970-01-01 00:00:00 +0000
+++ Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Sales/Order/Api.php 2011-11-09 09:54:26 +0000
@@ -0,0 +1,116 @@
1<?php
2
3/**
4 *
5 * @author Mohammed NAHHAS
6 * @package Openlabs_OpenERPConnector
7 *
8 */
9
10class Openlabs_OpenERPConnector_Model_Sales_Order_Api extends Mage_Sales_Model_Order_Api {
11
12 /**
13 *
14 * Retrieve orders data based on the value of the flag 'imported'
15 * @param array
16 * @return array
17 */
18 public function retrieveOrders($data) {
19
20 $result = array();
21 if(isset($data['imported'])) {
22
23 $collection = Mage::getModel("sales/order")->getCollection()
24 ->addAttributeToSelect('*')
25 ->addAttributeToFilter('imported', array('eq' => $data['imported']));
26
27 /* addAddressFields() is called only if version >= 1400 */
28 if(str_replace('.','',Mage::getVersion()) >= 1400) {
29 $collection->addAddressFields();
30 }
31
32 if(isset($data['limit'])) {
33 $collection->setPageSize($data['limit']);
34 $collection->setOrder('entity_id', 'ASC');
35 }
36
37 if(isset($data['filters']) && is_array($data['filters'])) {
38 $filters = $data['filters'];
39 foreach($filters as $field => $value) {
40 $collection->addAttributeToFilter($field, $value);
41 }
42 }
43
44 foreach ($collection as $order) {
45 $tmp = $this->_getAttributes($order, 'order');
46
47 /* if version < 1400, billing and shipping information are added manually to order data */
48 if(str_replace('.','',Mage::getVersion()) < 1400) {
49 $address_data = $this->_getAttributes($order->getShippingAddress(), 'order_address');
50 if(!empty($address_data)) {
51 $tmp['shipping_firstname'] = $address_data['firstname'];
52 $tmp['shipping_lastname'] = $address_data['lastname'];
53 }
54
55 $address_data = $this->_getAttributes($order->getBillingAddress(), 'order_address');
56 if(!empty($address_data)) {
57 $tmp['billing_firstname'] = $address_data['firstname'];
58 $tmp['billing_lastname'] = $address_data['lastname'];
59 }
60 }
61
62 $result[] = $tmp;
63 }
64 return $result;
65 }else{
66 $this->_fault('data_invalid', "Error, the attribut 'imported' need to be specified");
67 }
68 }
69
70 public function setFlagForOrder($incrementId) {
71 $_order = $this->_initOrder($incrementId);
72 $_order->setImported(1);
73 try {
74 $_order->save();
75 return true;
76 } catch (Mage_Core_Exception $e) {
77 $this->_fault('data_invalid', $e->getMessage());
78 }
79 }
80
81 /* Retrieve increment_id of the child order */
82 public function getOrderChild($incrementId) {
83
84 $order = Mage::getModel('sales/order')->loadByIncrementId($incrementId);
85 /**
86 * Check order existing
87 */
88 if (!$order->getId()) {
89 $this->_fault('order_not_exists');
90 }
91
92 if($order->getRelationChildId()) {
93 return $order->getRelationChildRealId();
94 }else{
95 return false;
96 }
97 }
98
99 /* Retrieve increment_id of the parent order */
100 public function getOrderParent($incrementId) {
101
102 $order = Mage::getModel('sales/order')->loadByIncrementId($incrementId);
103 /**
104 * Check order existing
105 */
106 if (!$order->getId()) {
107 $this->_fault('order_not_exists');
108 }
109
110 if($order->getRelationParentId()) {
111 return $order->getRelationParentRealId();
112 }else{
113 return false;
114 }
115 }
116}
0\ No newline at end of file117\ No newline at end of file
1118
=== added directory 'Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/controllers'
=== added directory 'Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/controllers/Adminhtml'
=== added file 'Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/controllers/Adminhtml/InitController.php'
--- Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/controllers/Adminhtml/InitController.php 1970-01-01 00:00:00 +0000
+++ Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/controllers/Adminhtml/InitController.php 2011-11-09 09:54:26 +0000
@@ -0,0 +1,61 @@
1<?php
2
3/**
4 *
5 * @author Mohammed NAHHAS
6 * @package Openlabs_OpenERPConnector
7 *
8 */
9
10class Openlabs_OpenERPConnector_Adminhtml_InitController extends Mage_Adminhtml_Controller_Action
11{
12 protected $_imported = 'imported';
13
14 /* Initialize the Attribute 'Imported' for orders placed before installing Openlabs_OpenERPConnector Extension */
15 public function ordersAction() {
16 /* 'imported' value will be initialized if magento version is < 1.4.0.0 */
17 if(str_replace('.','',Mage::getVersion()) < 1400) {
18 $orders = array();
19
20 /* 'imported' attribute values are stored in sales_order_int */
21 $imported_attribute_table_name = 'sales_order_int';
22
23 /* retrieve entity_type_id for order */
24 $entity_type = Mage::getModel('eav/entity_type')->loadByCode('order');
25
26 /* Load 'imported' attribute to get its attribute_id */
27 $attributeInfo = Mage::getResourceModel('eav/entity_attribute_collection')
28 ->setCodeFilter($this->_imported)
29 ->setEntityTypeFilter($entity_type->getEntityTypeId())
30 ->getFirstItem();
31
32 /* load order collection */
33 $collection = Mage::getResourceModel('sales/order_collection')
34 ->addAttributeToSelect($this->_imported);
35
36 if(count($collection->getItems()) > 0) {
37 foreach($collection as $order) {
38 try{
39 $test = $order->getResource()->getAttribute($this->_imported);
40 $orders[] = $order->getIncrementId();
41 $order->setImported(0)->save();
42 $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)";
43 $write = Mage::getSingleton('core/resource')->getConnection('core_write');
44 $query = $write->query($request);
45 }catch (Exception $e) {
46 echo 'Error : '.$e->getMessage();
47 }
48 }
49
50 echo 'Number of Orders Initialized : '.count($collection->getItems()) .'<br />';
51 echo 'Orders List : '.'<br />';
52 echo '<pre>';
53 print_r($orders);
54 echo '</pre>';
55 }
56 }else{
57 echo 'Magento Version : '.Mage::getVersion().'<br />';
58 echo 'There is no need to initialize orders';
59 }
60 }
61}
0\ No newline at end of file62\ No newline at end of file
163
=== added file 'Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/controllers/OpenerpconnectorController.php'
--- Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/controllers/OpenerpconnectorController.php 1970-01-01 00:00:00 +0000
+++ Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/controllers/OpenerpconnectorController.php 2011-11-09 09:54:26 +0000
@@ -0,0 +1,5 @@
1<?php
2class Openlabs_OpenERPConnector_OpenerpconnectorController extends Mage_Core_Controller_Front_Action
3{
4
5}
06
=== modified file 'Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/etc/api.xml'
--- Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/etc/api.xml 2010-08-19 15:06:19 +0000
+++ Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/etc/api.xml 2011-11-09 09:54:26 +0000
@@ -488,6 +488,39 @@
488 </filters_invalid>488 </filters_invalid>
489 </faults>489 </faults>
490 </ol_catalog_product_attributeset>490 </ol_catalog_product_attributeset>
491 <sales_order translate="title" module="Openlabs_OpenERPConnector">
492 <model>sales/order_api</model>
493 <title>Custom Sales Orders API</title>
494 <methods>
495 <retrieve translate="title" module="Openlabs_OpenERPConnector">
496 <title>Retrieve list of orders by filters, nb max, etc...</title>
497 <method>retrieveOrders</method>
498 </retrieve>
499 <done translate="title" module="Openlabs_OpenERPConnector">
500 <title>Set Flag to TRUE for imported orders</title>
501 <method>setFlagForOrder</method>
502 </done>
503 <get_child translate="title" module="Openlabs_OpenERPConnector">
504 <title>get The Child of The Order Edited</title>
505 <method>getOrderChild</method>
506 </get_child>
507 <get_parent translate="title" module="Openlabs_OpenERPConnector">
508 <title>get The Parent of the order annulated</title>
509 <method>getOrderParent</method>
510 </get_parent>
511 </methods>
512 </sales_order>
513 <catalog_product translate="title" module="catalog">
514 <title>Product API</title>
515 <model>catalog/product_api</model>
516 <acl>catalog/product</acl>
517 <methods>
518 <create_bundle translate="title" module="Openlabs_OpenERPConnector">
519 <title>Create Bundle Products with Custom Options and Bundle Items</title>
520 <method>createBundleProducts</method>
521 </create_bundle>
522 </methods>
523 </catalog_product>
491 </resources>524 </resources>
492 </api>525 </api>
493</config>526</config>
494527
=== modified file 'Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/etc/config.xml'
--- Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/etc/config.xml 2010-08-19 15:06:19 +0000
+++ Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/etc/config.xml 2011-11-09 09:54:26 +0000
@@ -1,15 +1,36 @@
1<?xml version="1.0"?>1<?xml version="1.0"?>
2<config>2<config>
3 <!--<modules>3 <modules>
4 <Openlabs_OpenERPConnector>4 <Openlabs_OpenERPConnector>
5 <version>0.0.1</version>5 <version>0.0.1</version>
6 </Openlabs_OpenERPConnector>6 </Openlabs_OpenERPConnector>
7 </modules>-->7 </modules>
8 <frontend>
9 <routers>
10 <openerpconnector>
11 <use>standard</use>
12 <args>
13 <module>Openlabs_OpenERPConnector</module>
14 <frontName>openerpconnector</frontName>
15 </args>
16 </openerpconnector>
17 </routers>
18 </frontend>
8 <global>19 <global>
9 <models>20 <models>
10 <openerpconnector>21 <openerpconnector>
11 <class>Openlabs_OpenERPConnector_Model</class>22 <class>Openlabs_OpenERPConnector_Model</class>
12 </openerpconnector>23 </openerpconnector>
24 <sales>
25 <rewrite>
26 <order_api>Openlabs_OpenERPConnector_Model_Sales_Order_Api</order_api>
27 </rewrite>
28 </sales>
29 <catalog>
30 <rewrite>
31 <product_api>Openlabs_OpenERPConnector_Model_Catalog_Product_Api</product_api>
32 </rewrite>
33 </catalog>
13 </models>34 </models>
14 <resources>35 <resources>
15 <openerpconnector_setup>36 <openerpconnector_setup>
@@ -41,5 +62,27 @@
41 <class>Openlabs_OpenERPConnector_Helper</class>62 <class>Openlabs_OpenERPConnector_Helper</class>
42 </openerpconnector>63 </openerpconnector>
43 </helpers>64 </helpers>
65 <events>
66 <sales_order_place_after>
67 <observers>
68 <init_imported_after_place_order>
69 <type>singleton</type>
70 <class>openerpconnector/observer</class>
71 <method>initImported</method>
72 </init_imported_after_place_order>
73 </observers>
74 </sales_order_place_after>
75 </events>
44 </global>76 </global>
77 <admin>
78 <routers>
79 <openerpconnector>
80 <use>admin</use>
81 <args>
82 <module>Openlabs_OpenERPConnector</module>
83 <frontName>connector</frontName>
84 </args>
85 </openerpconnector>
86 </routers>
87 </admin>
45</config>88</config>
46\ No newline at end of file89\ No newline at end of file
4790
=== added directory 'Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/sql'
=== added directory 'Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/sql/openerpconnector_setup'
=== added file 'Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/sql/openerpconnector_setup/mysql4-install-0.0.1.php'
--- Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/sql/openerpconnector_setup/mysql4-install-0.0.1.php 1970-01-01 00:00:00 +0000
+++ Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/sql/openerpconnector_setup/mysql4-install-0.0.1.php 2011-11-09 09:54:26 +0000
@@ -0,0 +1,54 @@
1<?php
2/**
3 *
4 * @author Mohammed NAHHAS
5 * @package Openlabs_OpenERPConnector
6 *
7 */
8
9/* Retrieve the version of Magento */
10$version = Mage::getVersion();
11
12/* Need to add a sales_order attribute if the version < 1.4.x.x - sales_order is an EAV Model */
13/* Else add a simple column to sales_flat_order Table */
14$version = str_replace('.','',$version);
15if($version >= 1400) {
16 $installer = $this;
17 $installer->startSetup();
18 $tableName='sales_flat_order';
19 $db = $installer->getConnection();
20
21 /* Delete the column if it exists before re-create it */
22 if($db->tableColumnExists($this->getTable($tableName), 'imported')) {
23 $installer->run("ALTER TABLE {$this->getTable($tableName)} drop column imported");
24 }
25
26 /* re-create 'imported' column */
27 if(!$db->tableColumnExists($this->getTable($tableName), 'imported')) {
28 $installer->run("
29 ALTER TABLE {$this->getTable($tableName)} ADD imported tinyint(1) unsigned NOT NULL default '0';
30 ");
31 }
32}else{
33 $installer = new Mage_Eav_Model_Entity_Setup('core_setup');
34 $installer->startSetup();
35
36 /* Attribute Data */
37 $attribute_data = array(
38 'type' => 'int',
39 'default' => 0,
40 'visible' => false,
41 'required' => false,
42 'user_defined' => false,
43 'searchable' => false,
44 'filterable' => false,
45 'comparable' => false
46 );
47 /* Add a sales_order attribute named 'imported' */
48 $installer->addAttribute('order', 'imported', $attribute_data);
49
50}
51
52
53/* End */
54$installer->endSetup();
0\ No newline at end of file55\ No newline at end of file