Merge lp:~mohammed-nahhas/magentoerpconnect/magento-module-dev into lp:magentoerpconnect/oerp6.1-oldstable
- magento-module-dev
- Merge into trunk_version
Status: | Rejected |
---|---|
Rejected by: | Guewen Baconnier @ Camptocamp |
Proposed branch: | lp:~mohammed-nahhas/magentoerpconnect/magento-module-dev |
Merge into: | lp:magentoerpconnect/oerp6.1-oldstable |
Diff against target: |
3185 lines (+3033/-0) 24 files modified
Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Helper/Data.php (+6/-0) 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/Olcatalog/Categories.php (+111/-0) Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcatalog/Product/Attribute.php (+109/-0) Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcatalog/Product/Attributegroup.php (+167/-0) Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcatalog/Product/Attributeset.php (+58/-0) Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcatalog/Product/Tierprice.php (+71/-0) Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcatalog/Products.php (+289/-0) Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcore/Groups.php (+142/-0) Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcore/Storeviews.php (+142/-0) Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcore/Website.php (+171/-0) Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcustomer/Address.php (+241/-0) Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcustomer/Customer.php (+142/-0) Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcustomer/Group.php (+142/-0) Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcustomer/Subscriber.php (+163/-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 (+526/-0) Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/etc/config.xml (+88/-0) Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/sql/openerpconnector_setup/mysql4-install-0.0.1.php (+54/-0) Openlabs_OpenERPConnector-1.1.0/app/etc/modules/Openlabs_OpenERPConnector.xml (+41/-0) package.xml (+84/-0) |
To merge this branch: | bzr merge lp:~mohammed-nahhas/magentoerpconnect/magento-module-dev |
Related bugs: | |
Related blueprints: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Guewen Baconnier @ Camptocamp | Disapprove | ||
Review via email: mp+80985@code.launchpad.net |
Commit message
Description of the change
- 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/
Guewen Baconnier @ Camptocamp (gbaconnier-c2c) wrote : | # |
Thierry (tboulogne) wrote : | # |
Hello Guewen,
Does your message related to
https:/
too ?
> Guewen Baconnier @ Camptocamp <mailto:<email address hidden>>
> 21 novembre 2011 14:18
> Review: Disapprove
>
> Hello,
>
> This merge proposal is invalid as this branch must be merged into
> lp:magentoerpconnect/magento-module (Magento module) and not into
> lp:magentoerpconnect (OpenERP module).
>
> Also, the reviewer of lp:magentoerpconnect/magento-module is Sharoon
> Thomas and not the "MagentoERPConnect core Editors" Team.
>
> A merge proposal is currently pending on this branch on the behalf of
> Mohammed Nahhas as requestor and of Sharoon Thomas as reviewer :
> https:/
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
- 24. By Raimon Esteve (www.zikzakmedia.com)
-
[IMP] Newsletter Subscribers. WebServices (part 2)
- 23. By Raimon Esteve (www.zikzakmedia.com)
-
[IMP] Newsletter Subscribers. WebServices:
- list
- info
- create
- update
- delete (unsubscriber)
note: magento core not avaible webservice for Newsletter Subscribers - 22. By Raphaël Valyi - http://www.akretion.com
-
[IMP] send attribute scope as we would eventually use it, especially to find out which attributes are translatable (scope=='store'), though that might be overkill
- 21. By Sharoon Thomas http://openlabs.co.in
-
[FIX]The attributes.list method now gives the details
- 20. By Sharoon Thomas http://openlabs.co.in
-
[ADD]Attribute set fixed
- 19. By Sharoon Thomas http://openlabs.co.in
-
[ADD]Api for tier price & customer
Preview Diff
1 | === added directory 'Openlabs_OpenERPConnector-1.1.0' |
2 | === added directory 'Openlabs_OpenERPConnector-1.1.0/Openlabs' |
3 | === added directory 'Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector' |
4 | === added directory 'Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Helper' |
5 | === added file 'Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Helper/Data.php' |
6 | --- Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Helper/Data.php 1970-01-01 00:00:00 +0000 |
7 | +++ Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Helper/Data.php 2011-11-09 09:54:26 +0000 |
8 | @@ -0,0 +1,6 @@ |
9 | +<?php |
10 | +class Openlabs_OpenERPConnector_Helper_Data extends Mage_Core_Helper_Abstract |
11 | +{ |
12 | + //Linux4ever_MagentoXtender_Model_Api |
13 | +} |
14 | +?> |
15 | \ No newline at end of file |
16 | |
17 | === added directory 'Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model' |
18 | === added directory 'Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Catalog' |
19 | === added directory 'Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Catalog/Product' |
20 | === added file 'Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Catalog/Product/Api.php' |
21 | --- Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Catalog/Product/Api.php 1970-01-01 00:00:00 +0000 |
22 | +++ Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Catalog/Product/Api.php 2011-11-09 09:54:26 +0000 |
23 | @@ -0,0 +1,80 @@ |
24 | +<?php |
25 | + |
26 | +/** |
27 | + * @author Mohammed NAHHAS |
28 | + * @package Openlabs_OpenERPConnector |
29 | + */ |
30 | + |
31 | +class Openlabs_OpenERPConnector_Model_Catalog_Product_Api extends Mage_Catalog_Model_Product_Api |
32 | +{ |
33 | + /** |
34 | + * Set additional data before product saved |
35 | + * |
36 | + * @param Mage_Catalog_Model_Product $product |
37 | + * @param array $productData |
38 | + * @return object |
39 | + */ |
40 | + protected function _prepareDataForSave ($product, $productData) |
41 | + { |
42 | + if (isset($productData['categories']) && is_array($productData['categories'])) { |
43 | + $product->setCategoryIds($productData['categories']); |
44 | + } |
45 | + |
46 | + if (isset($productData['websites']) && is_array($productData['websites'])) { |
47 | + foreach ($productData['websites'] as &$website) { |
48 | + if (is_string($website)) { |
49 | + try { |
50 | + $website = Mage::app()->getWebsite($website)->getId(); |
51 | + } catch (Exception $e) { } |
52 | + } |
53 | + } |
54 | + $product->setWebsiteIds($productData['websites']); |
55 | + } |
56 | + |
57 | + if (Mage::app()->isSingleStoreMode()) { |
58 | + $product->setWebsiteIds(array(Mage::app()->getStore(true)->getWebsite()->getId())); |
59 | + } |
60 | + |
61 | + if (isset($productData['stock_data']) && is_array($productData['stock_data'])) { |
62 | + $product->setStockData($productData['stock_data']); |
63 | + } else { |
64 | + $product->setStockData(array('use_config_manage_stock' => 0)); |
65 | + } |
66 | + |
67 | + if (isset($productData['tier_price']) && is_array($productData['tier_price'])) { |
68 | + $tierPrices = Mage::getModel('catalog/product_attribute_tierprice_api')->prepareTierPrices($product, $productData['tier_price']); |
69 | + $product->setData(Mage_Catalog_Model_Product_Attribute_Tierprice_Api::ATTRIBUTE_CODE, $tierPrices); |
70 | + } |
71 | + |
72 | + /* |
73 | + * Check if configurable product data array passed |
74 | + */ |
75 | + if(isset($productData['configurable_products_data']) && is_array($productData['configurable_products_data'])) { |
76 | + $product->setConfigurableProductsData($productData['configurable_products_data']); |
77 | + } |
78 | + |
79 | + if(isset($productData['configurable_attributes_data']) && is_array($productData['configurable_attributes_data'])) { |
80 | + foreach($productData['configurable_attributes_data'] as $key => $data) { |
81 | + |
82 | + //Check to see if these values exist, otherwise try and populate from existing values |
83 | + $data['label'] = (!empty($data['label'])) ? $data['label'] : $product->getResource()->getAttribute($data['attribute_code'])->getStoreLabel(); |
84 | + $data['frontend_label'] = (!empty($data['frontend_label'])) ? $data['frontend_label'] : $product->getResource()->getAttribute($data['attribute_code'])->getFrontendLabel(); |
85 | + $productData['configurable_attributes_data'][$key] = $data; |
86 | + } |
87 | + $product->setConfigurableAttributesData($productData['configurable_attributes_data']); |
88 | + $product->setCanSaveConfigurableAttributes(true); |
89 | + } |
90 | + |
91 | + /* |
92 | + * Check if bundle product data, options and bundle items arrays passed |
93 | + */ |
94 | + if(isset($productData['bundle_items_data']) && isset($productData['options_data']) && is_array($productData['bundle_items_data']) && is_array($productData['options_data'])) { |
95 | + |
96 | + $product->setBundleOptionsData($productData['options_data']); |
97 | + $product->setBundleSelectionsData($productData['bundle_items_data']); |
98 | + $product->setCanSaveBundleSelections(true); |
99 | + $product->setAffectBundleProductSelections(true); |
100 | + Mage::register('product', $product); // product must be registred in order to get the store_id, see _beforeSave() in Mage/Bundle/Model/Selection.php |
101 | + } |
102 | + } |
103 | +} |
104 | \ No newline at end of file |
105 | |
106 | === added file 'Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Observer.php' |
107 | --- Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Observer.php 1970-01-01 00:00:00 +0000 |
108 | +++ Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Observer.php 2011-11-09 09:54:26 +0000 |
109 | @@ -0,0 +1,24 @@ |
110 | +<?php |
111 | +/** |
112 | + * |
113 | + * @author Mohammed NAHHAS |
114 | + * @package Openlabs_OpenERPConnector |
115 | + * |
116 | + */ |
117 | + |
118 | +class Openlabs_OpenERPConnector_Model_Observer extends Mage_Core_Model_Abstract { |
119 | + |
120 | + /* Initialize attribtue 'imported' if version < 1.4.0.0 */ |
121 | + public function initImported($observer) { |
122 | + if(str_replace('.','',Mage::getVersion()) < 1400) { |
123 | + $order = $observer->getOrder(); |
124 | + try { |
125 | + $order->setImported(0)->save(); |
126 | + }catch (Exception $e) { |
127 | + /* If logs are enabled (backend : system->configuration->developer->logSettings), it creates a file named OpenErp_Connector.log in /var/log/ which contains the errors */ |
128 | + Mage::log('Error, order increment_id = '.$order->getIncrementId().', attribute "imported" was not initialized - error : '.$e->getMessage(), null, 'OpenErp_Connector.log'); |
129 | + } |
130 | + $order->setImported(0)->save(); |
131 | + } |
132 | + } |
133 | +} |
134 | \ No newline at end of file |
135 | |
136 | === added directory 'Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcatalog' |
137 | === added file 'Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcatalog/Categories.php' |
138 | --- Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcatalog/Categories.php 1970-01-01 00:00:00 +0000 |
139 | +++ Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcatalog/Categories.php 2011-11-09 09:54:26 +0000 |
140 | @@ -0,0 +1,111 @@ |
141 | +<?php |
142 | + |
143 | + |
144 | +/** |
145 | + * @author Sharoon Thomas |
146 | + * Inspired from Dieter's Magento Extender |
147 | + * @copyright 2009 |
148 | + */ |
149 | + |
150 | +class Openlabs_OpenERPConnector_Model_Olcatalog_Categories extends Mage_Catalog_Model_Api_Resource |
151 | +{ |
152 | + public function items($filters = null) { |
153 | + try { |
154 | + $collection = Mage :: getModel('catalog/category/attribute')->getCollection()->addAttributeToSelect('image'); |
155 | + } catch (Mage_Core_Exception $e) { |
156 | + $this->_fault('category_not_exists'); |
157 | + } |
158 | + if (is_array($filters)) { |
159 | + try { |
160 | + foreach ($filters as $field => $value) { |
161 | + $collection->addFieldToFilter($field, $value); |
162 | + } |
163 | + } catch (Mage_Core_Exception $e) { |
164 | + $this->_fault('filters_invalid', $e->getMessage()); |
165 | + // If we are adding filter on non-existent attribute |
166 | + } |
167 | + } |
168 | + $result = array (); |
169 | + foreach ($collection as $category) { |
170 | + //$result[] = $customer->toArray(); |
171 | + $result[] = array ( |
172 | + 'category_id' => $category->getId(), |
173 | + 'image' => $category->getImage(), |
174 | + ); |
175 | + } |
176 | + return $result; |
177 | + } |
178 | + |
179 | + public function info($categoryId = null) { |
180 | + if (is_numeric($categoryId)) { |
181 | + try { |
182 | + $collection = Mage :: getModel('catalog/category/attribute')->load($categoryId)->getCollection()->addAttributeToSelect('image'); |
183 | + $result = array (); |
184 | + foreach ($collection as $category) { |
185 | + //$result[] = $customer->toArray(); |
186 | + if ($category->getId() == $categoryId) { |
187 | + $image = $category->getImage(); |
188 | + if ($image) { |
189 | + $path = Mage :: getBaseDir('media') . DS . 'catalog' . DS . 'category' . DS; |
190 | + $fullpath = $path . $image; |
191 | + try { |
192 | + $fp = fopen($fullpath, "rb"); |
193 | + $imagebin = fread($fp, filesize($fullpath)); |
194 | + $img_data = base64_encode($imagebin); |
195 | + fclose($fp); |
196 | + } catch (Exception $e) { |
197 | + $this->_fault('not_media'); |
198 | + } |
199 | + } |
200 | + $result[] = array ( |
201 | + 'category_id' => $category->getId(), |
202 | + 'image' => $category->getImage(), |
203 | + 'image_data' => $img_data |
204 | + ); |
205 | + } |
206 | + } |
207 | + |
208 | + return $result; |
209 | + |
210 | + } catch (Mage_Core_Exception $e) { |
211 | + $this->_fault('group_not_exists'); |
212 | + } |
213 | + |
214 | + } |
215 | + |
216 | + } |
217 | + |
218 | +public function create($filename,$imgdata) { |
219 | + if ($filename) |
220 | + { |
221 | + $path = Mage :: getBaseDir('media') . DS . 'catalog' . DS . 'category' . DS; |
222 | + $fullpath = $path . $filename; |
223 | + try |
224 | + { |
225 | + $fp = fopen($fullpath, "w"); |
226 | + if ($fp==false) |
227 | + { |
228 | + return "Error in file creation"; |
229 | + } |
230 | + $img_data = base64_decode($imgdata); |
231 | + $imagebin = fwrite($fp,$img_data); |
232 | + fclose($fp); |
233 | + return $imagebin; |
234 | + } |
235 | + catch (Exception $e) |
236 | + { |
237 | + $this->_fault('not_created'); |
238 | + } |
239 | + return False; |
240 | + } |
241 | +} |
242 | +public function update($something=null) |
243 | +{ |
244 | + return "Not implemented yet"; |
245 | +} |
246 | +public function remove($something=null) |
247 | +{ |
248 | + return "Not implemented yet"; |
249 | +} |
250 | +} |
251 | +?> |
252 | |
253 | === added directory 'Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcatalog/Product' |
254 | === added file 'Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcatalog/Product/Attribute.php' |
255 | --- Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcatalog/Product/Attribute.php 1970-01-01 00:00:00 +0000 |
256 | +++ Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcatalog/Product/Attribute.php 2011-11-09 09:54:26 +0000 |
257 | @@ -0,0 +1,109 @@ |
258 | +<?php |
259 | + |
260 | + |
261 | +/** |
262 | + * @author Sharoon Thomas |
263 | + * Inspired from Dieter's Magento Extender |
264 | + * @copyright 2009 |
265 | + */ |
266 | + |
267 | +class Openlabs_OpenERPConnector_Model_Olcatalog_Product_Attribute extends Mage_Catalog_Model_Api_Resource { |
268 | + public function __construct() { |
269 | + $this->_storeIdSessionField = 'product_store_id'; |
270 | + $this->_ignoredAttributeCodes[] = 'type_id'; |
271 | + $this->_ignoredAttributeTypes[] = 'gallery'; |
272 | + $this->_ignoredAttributeTypes[] = 'media_image'; |
273 | + } |
274 | + |
275 | + /** |
276 | + * Retrieve attributes from specified attribute set |
277 | + * |
278 | + * @param int $setId |
279 | + * @return array |
280 | + */ |
281 | + public function relations($setId){ |
282 | + $attributes = Mage :: getModel('catalog/product')->getResource()->loadAllAttributes()->getSortedAttributes($setId); |
283 | + $result = array (); |
284 | + foreach ($attributes as $attribute){ |
285 | + $result[] = Array( |
286 | + 'attribute_id' => $attribute->getId() |
287 | + ); |
288 | + } |
289 | + return $result; |
290 | + |
291 | + } |
292 | + public function items($setId) { |
293 | + $attributes = Mage :: getModel('catalog/product')->getResource()->loadAllAttributes()->getSortedAttributes($setId); |
294 | + $result = array (); |
295 | + |
296 | + foreach ($attributes as $attribute) { |
297 | + /* @var $attribute Mage_Catalog_Model_Resource_Eav_Attribute */ |
298 | + if ((!$attribute->getId() || $attribute->isInSet($setId)) && $this->_isAllowedAttribute($attribute)) { |
299 | + |
300 | + if (!$attribute->getId() || $attribute->isScopeGlobal()) { |
301 | + $scope = 'global'; |
302 | + } |
303 | + elseif ($attribute->isScopeWebsite()) { |
304 | + $scope = 'website'; |
305 | + } else { |
306 | + $scope = 'store'; |
307 | + } |
308 | + |
309 | + /*$result[] = array ( |
310 | + 'attribute_id' => $attribute->getId(), |
311 | + 'code' => $attribute->getAttributeCode(), |
312 | + 'type' => $attribute->getFrontendInput(), |
313 | + 'required' => $attribute->getIsRequired(), |
314 | + 'attributeset' => $attribute->getattribute_set_info(), |
315 | + 'scope' => $scope |
316 | + );*/ |
317 | + //Override hooray |
318 | + $attribute['scope'] = $scope; |
319 | + $result[]=$attribute->toArray(); |
320 | + } |
321 | + } |
322 | + |
323 | + return $result; |
324 | + } |
325 | + |
326 | + public function info($attributeId) { |
327 | + try { |
328 | + return 'hello'; |
329 | + $attribute = Mage :: getModel('catalog/product')->getResource()->getAttribute($attributeId); |
330 | + return $attribute->toArray(); |
331 | + } catch (Exception $e) { |
332 | + $this->_fault('not_exists'); |
333 | + } |
334 | + } |
335 | + /** |
336 | + * Retrieve attribute options |
337 | + * |
338 | + * @param int $attributeId |
339 | + * @param string|int $store |
340 | + * @return array |
341 | + */ |
342 | + public function options($attributeId, $store = null) { |
343 | + $storeId = $this->_getStoreId($store); |
344 | + $attribute = Mage :: getModel('catalog/product')->setStoreId($storeId)->getResource()->getAttribute($attributeId)->setStoreId($storeId); |
345 | + |
346 | + /* @var $attribute Mage_Catalog_Model_Entity_Attribute */ |
347 | + if (!$attribute) { |
348 | + $this->_fault('not_exists'); |
349 | + } |
350 | + |
351 | + $options = array (); |
352 | + foreach ($attribute->getSource()->getAllOptions() as $optionId => $optionValue) { |
353 | + if (is_array($optionValue)) { |
354 | + $options[] = $optionValue; |
355 | + } |
356 | + else { |
357 | + $options[] = array ( |
358 | + 'value' => $optionId, |
359 | + 'label' => $optionValue |
360 | + ); |
361 | + } |
362 | + } |
363 | + return $options; |
364 | + } |
365 | +} |
366 | +?> |
367 | |
368 | === added file 'Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcatalog/Product/Attributegroup.php' |
369 | --- Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcatalog/Product/Attributegroup.php 1970-01-01 00:00:00 +0000 |
370 | +++ Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcatalog/Product/Attributegroup.php 2011-11-09 09:54:26 +0000 |
371 | @@ -0,0 +1,167 @@ |
372 | +<?php |
373 | + |
374 | + |
375 | +/** |
376 | + * @author Sharoon Thomas |
377 | + * Inspired from Dieter's Magento Extender |
378 | + * @copyright 2009 |
379 | + */ |
380 | + |
381 | +class Openlabs_OpenERPConnector_Model_Olcatalog_Product_Attributegroup extends Mage_Catalog_Model_Api_Resource { |
382 | + public function olditems($setId = null) { |
383 | + $groups = Mage :: getModel('eav/entity_attribute_group')->getResourceCollection(); |
384 | + |
385 | + if (!is_null($setId) && !empty ($setId) && is_numeric($setId)) { |
386 | + $groups->setAttributeSetFilter($setId); |
387 | + } |
388 | + |
389 | + $groups->load(); |
390 | + |
391 | + $arrGroups = array (); |
392 | + |
393 | + foreach ($groups as $group) { |
394 | + $arrGroups[] = array ( |
395 | + 'attribute_group_id' => $group->getAttributeGroupId(), |
396 | + 'attribute_set_id' => $group->getAttributeSetId(), |
397 | + 'attribute_group_name' => $group->getAttributeGroupName(), |
398 | + 'sort_order' => $group->getSortOrder(), |
399 | + 'default_id' => $group->getDefaultId() |
400 | + ); |
401 | + } |
402 | + |
403 | + return $arrGroups; |
404 | + } |
405 | + |
406 | + public function items($filters = null) { |
407 | + try { |
408 | + $collection = Mage :: getModel('eav/entity_attribute_group')->getCollection(); |
409 | + } catch (Mage_Core_Exception $e) { |
410 | + $this->_fault('group_not_exists'); |
411 | + } |
412 | + |
413 | + if (is_array($filters)) { |
414 | + try { |
415 | + foreach ($filters as $field => $value) { |
416 | + $collection->addFieldToFilter($field, $value); |
417 | + } |
418 | + } catch (Mage_Core_Exception $e) { |
419 | + $this->_fault('filters_invalid', $e->getMessage()); |
420 | + // If we are adding filter on non-existent attribute |
421 | + } |
422 | + } |
423 | + |
424 | + $result = array (); |
425 | + foreach ($collection as $collection_item) { |
426 | + $result[] = $collection_item->toArray(); |
427 | + } |
428 | + |
429 | + return $result; |
430 | + |
431 | + } |
432 | + /* |
433 | + <param><value><string>cl19t0dqhmheafqc0ccdeejc76</string></value></param> |
434 | + <param><value><string>catalog_product_attribute_group.create</string></value></param> |
435 | + <param> |
436 | + <value> |
437 | + <array> |
438 | + <data> |
439 | + <value><i4>26</i4></value> |
440 | + <value><string>Leonelle</string></value> |
441 | + </data> |
442 | + </array> |
443 | + </value> |
444 | + </param> |
445 | + */ |
446 | + public function create($setId, array $data) { |
447 | + try { |
448 | + // $attrOption = Mage_Eav_Model_Entity_Attribute_Group |
449 | + $attrOption = Mage :: getModel("eav/entity_attribute_group"); |
450 | + |
451 | + $attrOption->addData($data); |
452 | + |
453 | + // check if there already exists a group with the give groupname |
454 | + if ($attrOption->itemExists()) { |
455 | + $this->_fault("group_already_exists"); |
456 | + } |
457 | + |
458 | + $attrOption->save(); |
459 | + |
460 | + return (int) $attrOption->getAttributeGroupId(); |
461 | + } catch (Exception $ex) { |
462 | + return false; |
463 | + } |
464 | + } |
465 | + /* |
466 | + <param><value><string>cl19t0dqhmheafqc0ccdeejc76</string></value></param> |
467 | + <param><value><string>catalog_product_attribute_group.update</string></value></param> |
468 | + <param> |
469 | + <value> |
470 | + <array> |
471 | + <data> |
472 | + <value><i4>85</i4></value> |
473 | + <value><string>Leonelle2</string></value> |
474 | + <value><i4>85</i4></value> |
475 | + <value><i4>85</i4></value> |
476 | + </data> |
477 | + </array> |
478 | + </value> |
479 | + </param> |
480 | + */ |
481 | + public function update(array $data) { |
482 | + try { |
483 | + // $attrOption = Mage_Eav_Model_Entity_Attribute_Group |
484 | + $attrOption = Mage :: getModel("eav/entity_attribute_group"); |
485 | + |
486 | + $attrOption->load($data["attribute_group_id"]); |
487 | + |
488 | + // check if the requested group exists... |
489 | + if (!$attrOption->getAttributeGroupId()) { |
490 | + $this->_fault("group_not_exists"); |
491 | + } |
492 | + |
493 | + $attrOption->addData($data); |
494 | + |
495 | + $attrOption->save(); |
496 | + |
497 | + return true; |
498 | + } catch (Exception $ex) { |
499 | + return false; |
500 | + } |
501 | + } |
502 | + |
503 | + /* |
504 | + <param><value><string>cl19t0dqhmheafqc0ccdeejc76</string></value></param> |
505 | + <param><value><string>catalog_product_attribute_group.delete</string></value></param> |
506 | + <param> |
507 | + <value> |
508 | + <array> |
509 | + <data> |
510 | + <value><i4>85</i4></value> |
511 | + </data> |
512 | + </array> |
513 | + </value> |
514 | + </param> |
515 | + */ |
516 | + public function delete($groupId) { |
517 | + try { |
518 | + // $attrOption = Mage_Eav_Model_Entity_Attribute_Group |
519 | + $attrOption = Mage :: getModel("eav/entity_attribute_group"); |
520 | + |
521 | + $attrOption->load($groupId); |
522 | + |
523 | + // check if the requested group exists... |
524 | + if (!$attrOption->getAttributeGroupId()) { |
525 | + $this->_fault("group_not_exists"); |
526 | + } |
527 | + |
528 | + // save data |
529 | + $attrOption->delete(); |
530 | + |
531 | + return true; |
532 | + } catch (Exception $ex) { |
533 | + return false; |
534 | + } |
535 | + } |
536 | + |
537 | +} |
538 | +?> |
539 | |
540 | === added file 'Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcatalog/Product/Attributeset.php' |
541 | --- Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcatalog/Product/Attributeset.php 1970-01-01 00:00:00 +0000 |
542 | +++ Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcatalog/Product/Attributeset.php 2011-11-09 09:54:26 +0000 |
543 | @@ -0,0 +1,58 @@ |
544 | +<?php |
545 | +/** |
546 | + * Magento |
547 | + * |
548 | + * NOTICE OF LICENSE |
549 | + * |
550 | + * This source file is subject to the Open Software License (OSL 3.0) |
551 | + * that is bundled with this package in the file LICENSE.txt. |
552 | + * It is also available through the world-wide-web at this URL: |
553 | + * http://opensource.org/licenses/osl-3.0.php |
554 | + * If you did not receive a copy of the license and are unable to |
555 | + * obtain it through the world-wide-web, please send an email |
556 | + * to license@magentocommerce.com so we can send you a copy immediately. |
557 | + * |
558 | + * DISCLAIMER |
559 | + * |
560 | + * Do not edit or add to this file if you wish to upgrade Magento to newer |
561 | + * versions in the future. If you wish to customize Magento for your |
562 | + * needs please refer to http://www.magentocommerce.com for more information. |
563 | + * |
564 | + * @category Mage |
565 | + * @package Mage_Catalog |
566 | + * @copyright Copyright (c) 2008 Irubin Consulting Inc. DBA Varien (http://www.varien.com) |
567 | + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) |
568 | + */ |
569 | + |
570 | +/** |
571 | + * Catalog product attribute set api |
572 | + * |
573 | + * @category Mage |
574 | + * @package Mage_Catalog |
575 | + * @author Magento Core Team <core@magentocommerce.com> |
576 | + */ |
577 | +class Openlabs_OpenERPConnector_Model_Olcatalog_Product_Attributeset extends Mage_Api_Model_Resource_Abstract |
578 | +{ |
579 | + /** |
580 | + * Retrieve attribute set list |
581 | + * |
582 | + * @return array |
583 | + */ |
584 | + public function items() |
585 | + { |
586 | + $entityType = Mage::getModel('catalog/product')->getResource()->getEntityType(); |
587 | + $collection = Mage::getResourceModel('eav/entity_attribute_set_collection') |
588 | + ->setEntityTypeFilter($entityType->getId()); |
589 | + |
590 | + $result = array(); |
591 | + foreach ($collection as $attributeSet) { |
592 | + $result[] = array( |
593 | + 'attribute_set_id' => $attributeSet->getId(), |
594 | + 'attribute_set_name' => $attributeSet->getAttributeSetName() |
595 | + ); |
596 | + |
597 | + } |
598 | + |
599 | + return $result; |
600 | + } |
601 | +} // Class Mage_Catalog_Model_Product_Attribute_Set_Api End |
602 | \ No newline at end of file |
603 | |
604 | === added file 'Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcatalog/Product/Tierprice.php' |
605 | --- Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcatalog/Product/Tierprice.php 1970-01-01 00:00:00 +0000 |
606 | +++ Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcatalog/Product/Tierprice.php 2011-11-09 09:54:26 +0000 |
607 | @@ -0,0 +1,71 @@ |
608 | +<?php |
609 | + |
610 | +/** |
611 | + * Magento |
612 | + * |
613 | + * NOTICE OF LICENSE |
614 | + * |
615 | + * This source file is subject to the Open Software License (OSL 3.0) |
616 | + * that is bundled with this package in the file LICENSE.txt. |
617 | + * It is also available through the world-wide-web at this URL: |
618 | + * http://opensource.org/licenses/osl-3.0.php |
619 | + * If you did not receive a copy of the license and are unable to |
620 | + * obtain it through the world-wide-web, please send an email |
621 | + * to license@magentocommerce.com so we can send you a copy immediately. |
622 | + * |
623 | + * DISCLAIMER |
624 | + * |
625 | + * Do not edit or add to this file if you wish to upgrade Magento to newer |
626 | + * versions in the future. If you wish to customize Magento for your |
627 | + * needs please refer to http://www.magentocommerce.com for more information. |
628 | + * |
629 | + * @category Mage |
630 | + * @package Mage_Catalog |
631 | + * @copyright Copyright (c) 2008 Irubin Consulting Inc. DBA Varien (http://www.varien.com) |
632 | + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) |
633 | + */ |
634 | + |
635 | +/** |
636 | + * Catalog Product tier price api |
637 | + * |
638 | + * @category Mage |
639 | + * @package Mage_Catalog |
640 | + * @author Magento Core Team <core@magentocommerce.com> |
641 | + */ |
642 | +class Openlabs_OpenERPConnector_Model_Olcatalog_Product_Tierprice extends Mage_Catalog_Model_Api_Resource { |
643 | + const ATTRIBUTE_CODE = 'tier_price'; |
644 | + |
645 | + |
646 | + public function items($productIds=null) { |
647 | + if (is_array($productIds)) { |
648 | + $result = array (); |
649 | + foreach ($productIds as $productId) { |
650 | + $product = Mage :: getModel('catalog/product')->load($productId); |
651 | + if (!$product->getId()) { |
652 | + $this->_fault('product_not_exists'); |
653 | + } |
654 | + $tierPrices = $product->getData(self :: ATTRIBUTE_CODE); |
655 | + $result[$productId] = $tierPrices; |
656 | + } |
657 | + } |
658 | + return $result; |
659 | + |
660 | + } |
661 | + |
662 | + public function items2($productIds=null) { |
663 | + $product = Mage :: getModel('catalog/product_attribute_backend_tierprice')->_get_set_go(); |
664 | + if (!$product->getId()) { |
665 | + $this->_fault('product_not_exists'); |
666 | + } |
667 | + |
668 | + $tierPrices = $product->getPriceModel()->getTierPriceCount(); |
669 | + return 'hello'; |
670 | + $result[$productIds] = $tierPrices; |
671 | + |
672 | + |
673 | + return $result; |
674 | + |
675 | + |
676 | + } |
677 | + |
678 | +} |
679 | \ No newline at end of file |
680 | |
681 | === added file 'Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcatalog/Products.php' |
682 | --- Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcatalog/Products.php 1970-01-01 00:00:00 +0000 |
683 | +++ Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcatalog/Products.php 2011-11-09 09:54:26 +0000 |
684 | @@ -0,0 +1,289 @@ |
685 | +<?php |
686 | + |
687 | +class Openlabs_OpenERPConnector_Model_Olcatalog_Products extends Mage_Catalog_Model_Api_Resource |
688 | +{ |
689 | + protected $_filtersMap = array( |
690 | + 'product_id' => 'entity_id', |
691 | + 'set' => 'attribute_set_id', |
692 | + 'type' => 'type_id' |
693 | + ); |
694 | + |
695 | + public function __construct() |
696 | + { |
697 | + $this->_storeIdSessionField = 'product_store_id'; |
698 | + $this->_ignoredAttributeTypes[] = 'gallery'; |
699 | + $this->_ignoredAttributeTypes[] = 'media_image'; |
700 | + } |
701 | + |
702 | + /** |
703 | + * Retrieve list of products with basic info (id, sku, type, set, name) |
704 | + * |
705 | + * @param array $filters |
706 | + * @param string|int $store |
707 | + * @return array |
708 | + */ |
709 | + public function items($filters = null, $store = null) |
710 | + { |
711 | + $collection = Mage::getModel('catalog/product')->getCollection() |
712 | + ->setStoreId($this->_getStoreId($store)) |
713 | + ->addAttributeToSelect('name'); |
714 | + |
715 | + if (is_array($filters)) { |
716 | + try { |
717 | + foreach ($filters as $field => $value) { |
718 | + if (isset($this->_filtersMap[$field])) { |
719 | + $field = $this->_filtersMap[$field]; |
720 | + } |
721 | + |
722 | + $collection->addFieldToFilter($field, $value); |
723 | + } |
724 | + } catch (Mage_Core_Exception $e) { |
725 | + $this->_fault('filters_invalid', $e->getMessage()); |
726 | + } |
727 | + } |
728 | + |
729 | + $result = array(); |
730 | + |
731 | + foreach ($collection as $product) { |
732 | +// $result[] = $product->getData(); |
733 | + $result[] = array( // Basic product data |
734 | + 'product_id' => $product->getId(), |
735 | + 'sku' => $product->getSku(), |
736 | + 'name' => $product->getName(), |
737 | + 'set' => $product->getAttributeSetId(), |
738 | + 'type' => $product->getTypeId(), |
739 | + 'category_ids' => $product->getCategoryIds() |
740 | + ); |
741 | + } |
742 | + |
743 | + return $result; |
744 | + } |
745 | + |
746 | + /** |
747 | + * Retrieve product info |
748 | + * |
749 | + * @param int|string $productId |
750 | + * @param string|int $store |
751 | + * @param array $attributes |
752 | + * @return array |
753 | + */ |
754 | + public function biglist($productId, $store = null, $filters = null) |
755 | + { |
756 | + $collection = Mage::getModel('catalog/product')->getCollection() |
757 | + ->setStoreId($this->_getStoreId($store)) |
758 | + ->addAttributeToSelect('name'); |
759 | + |
760 | + if (is_array($filters)) { |
761 | + try { |
762 | + foreach ($filters as $field => $value) { |
763 | + if (isset($this->_filtersMap[$field])) { |
764 | + $field = $this->_filtersMap[$field]; |
765 | + } |
766 | + |
767 | + $collection->addFieldToFilter($field, $value); |
768 | + } |
769 | + } catch (Mage_Core_Exception $e) { |
770 | + $this->_fault('filters_invalid', $e->getMessage()); |
771 | + } |
772 | + } |
773 | + foreach ($collection as $product) { |
774 | + $data = array(); |
775 | + $data = array( // Basic product data |
776 | + 'product_id' => $product->getId(), |
777 | + 'sku' => $product->getSku(), |
778 | + 'set' => $product->getAttributeSetId(), |
779 | + 'type' => $product->getTypeId(), |
780 | + 'categories' => $product->getCategoryIds(), |
781 | + 'websites' => $product->getWebsiteIds() |
782 | + ); |
783 | + |
784 | + foreach ($product->getTypeInstance(true)->getEditableAttributes($product) as $attribute) { |
785 | + $data[$attribute->getAttributeCode()] = $product->getData($attribute->getAttributeCode()); |
786 | + } |
787 | + $result[]=$data; |
788 | + } |
789 | + return $result; |
790 | + } |
791 | + |
792 | + /** |
793 | + * Create new product. |
794 | + * |
795 | + * @param string $type |
796 | + * @param int $set |
797 | + * @param array $productData |
798 | + * @return int |
799 | + */ |
800 | + public function create($type, $set, $sku, $productData) |
801 | + { |
802 | + if (!$type || !$set || !$sku) { |
803 | + $this->_fault('data_invalid'); |
804 | + } |
805 | + |
806 | + $product = Mage::getModel('catalog/product'); |
807 | + /* @var $product Mage_Catalog_Model_Product */ |
808 | + $product->setStoreId($this->_getStoreId($store)) |
809 | + ->setAttributeSetId($set) |
810 | + ->setTypeId($type) |
811 | + ->setSku($sku); |
812 | + |
813 | + if (isset($productData['website_ids']) && is_array($productData['website_ids'])) { |
814 | + $product->setWebsiteIds($productData['website_ids']); |
815 | + } |
816 | + |
817 | + foreach ($product->getTypeInstance(true)->getEditableAttributes($product) as $attribute) { |
818 | + if ($this->_isAllowedAttribute($attribute) |
819 | + && isset($productData[$attribute->getAttributeCode()])) { |
820 | + $product->setData( |
821 | + $attribute->getAttributeCode(), |
822 | + $productData[$attribute->getAttributeCode()] |
823 | + ); |
824 | + } |
825 | + } |
826 | + |
827 | + $this->_prepareDataForSave($product, $productData); |
828 | + |
829 | + if (is_array($errors = $product->validate())) { |
830 | + $this->_fault('data_invalid', implode("\n", $errors)); |
831 | + } |
832 | + |
833 | + try { |
834 | + $product->save(); |
835 | + } catch (Mage_Core_Exception $e) { |
836 | + $this->_fault('data_invalid', $e->getMessage()); |
837 | + } |
838 | + |
839 | + return $product->getId(); |
840 | + } |
841 | + |
842 | + /** |
843 | + * Update product data |
844 | + * |
845 | + * @param int|string $productId |
846 | + * @param array $productData |
847 | + * @param string|int $store |
848 | + * @return boolean |
849 | + */ |
850 | + public function update($productId, $productData = array(), $store = null) |
851 | + { |
852 | + $product = $this->_getProduct($productId, $store); |
853 | + |
854 | + if (!$product->getId()) { |
855 | + $this->_fault('not_exists'); |
856 | + } |
857 | + |
858 | + if (isset($productData['website_ids']) && is_array($productData['website_ids'])) { |
859 | + $product->setWebsiteIds($productData['website_ids']); |
860 | + } |
861 | + |
862 | + foreach ($product->getTypeInstance(true)->getEditableAttributes($product) as $attribute) { |
863 | + if ($this->_isAllowedAttribute($attribute) |
864 | + && isset($productData[$attribute->getAttributeCode()])) { |
865 | + $product->setData( |
866 | + $attribute->getAttributeCode(), |
867 | + $productData[$attribute->getAttributeCode()] |
868 | + ); |
869 | + } |
870 | + } |
871 | + |
872 | + $this->_prepareDataForSave($product, $productData); |
873 | + |
874 | + try { |
875 | + if (is_array($errors = $product->validate())) { |
876 | + $this->_fault('data_invalid', implode("\n", $errors)); |
877 | + } |
878 | + } catch (Mage_Core_Exception $e) { |
879 | + $this->_fault('data_invalid', $e->getMessage()); |
880 | + } |
881 | + |
882 | + try { |
883 | + $product->save(); |
884 | + } catch (Mage_Core_Exception $e) { |
885 | + $this->_fault('data_invalid', $e->getMessage()); |
886 | + } |
887 | + |
888 | + return true; |
889 | + } |
890 | + |
891 | + /** |
892 | + * Set additional data before product saved |
893 | + * |
894 | + * @param Mage_Catalog_Model_Product $product |
895 | + * @param array $productData |
896 | + * @return object |
897 | + */ |
898 | + protected function _prepareDataForSave ($product, $productData) |
899 | + { |
900 | + if (isset($productData['categories']) && is_array($productData['categories'])) { |
901 | + $product->setCategoryIds($productData['categories']); |
902 | + } |
903 | + |
904 | + if (isset($productData['websites']) && is_array($productData['websites'])) { |
905 | + foreach ($productData['websites'] as &$website) { |
906 | + if (is_string($website)) { |
907 | + try { |
908 | + $website = Mage::app()->getWebsite($website)->getId(); |
909 | + } catch (Exception $e) { } |
910 | + } |
911 | + } |
912 | + $product->setWebsiteIds($productData['websites']); |
913 | + } |
914 | + |
915 | + if (isset($productData['stock_data']) && is_array($productData['stock_data'])) { |
916 | + $product->setStockData($productData['stock_data']); |
917 | + } |
918 | + } |
919 | + |
920 | + /** |
921 | + * Update product special price |
922 | + * |
923 | + * @param int|string $productId |
924 | + * @param float $specialPrice |
925 | + * @param string $fromDate |
926 | + * @param string $toDate |
927 | + * @param string|int $store |
928 | + * @return boolean |
929 | + */ |
930 | + public function setSpecialPrice($productId, $specialPrice = null, $fromDate = null, $toDate = null, $store = null) |
931 | + { |
932 | + return $this->update($productId, array( |
933 | + 'special_price' => $specialPrice, |
934 | + 'special_from_date' => $fromDate, |
935 | + 'special_to_date' => $toDate |
936 | + ), $store); |
937 | + } |
938 | + |
939 | + /** |
940 | + * Retrieve product special price |
941 | + * |
942 | + * @param int|string $productId |
943 | + * @param string|int $store |
944 | + * @return array |
945 | + */ |
946 | + public function getSpecialPrice($productId, $store = null) |
947 | + { |
948 | + return $this->info($productId, $store, array('special_price', 'special_from_date', 'special_to_date')); |
949 | + } |
950 | + |
951 | + /** |
952 | + * Delete product |
953 | + * |
954 | + * @param int|string $productId |
955 | + * @return boolean |
956 | + */ |
957 | + public function delete($productId) |
958 | + { |
959 | + $product = $this->_getProduct($productId); |
960 | + |
961 | + if (!$product->getId()) { |
962 | + $this->_fault('not_exists'); |
963 | + } |
964 | + |
965 | + try { |
966 | + $product->delete(); |
967 | + } catch (Mage_Core_Exception $e) { |
968 | + $this->_fault('not_deleted', $e->getMessage()); |
969 | + } |
970 | + |
971 | + return true; |
972 | + } |
973 | +} // Class Mage_Catalog_Model_Product_Api End |
974 | \ No newline at end of file |
975 | |
976 | === added directory 'Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcore' |
977 | === added file 'Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcore/Groups.php' |
978 | --- Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcore/Groups.php 1970-01-01 00:00:00 +0000 |
979 | +++ Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcore/Groups.php 2011-11-09 09:54:26 +0000 |
980 | @@ -0,0 +1,142 @@ |
981 | +<?php |
982 | + |
983 | +/** |
984 | + * @author Sharoon Thomas |
985 | + * Inspired from Dieter's Magento Extender |
986 | + * @copyright 2009 |
987 | + */ |
988 | + |
989 | +class Openlabs_OpenERPConnector_Model_Olcore_Groups extends Mage_Catalog_Model_Api_Resource |
990 | +{ |
991 | + public function items($filters=null) |
992 | + { |
993 | + try |
994 | + { |
995 | + $collection = Mage::getModel('core/store_group')->getCollection();//->addAttributeToSelect('*'); |
996 | + } |
997 | + catch (Mage_Core_Exception $e) |
998 | + { |
999 | + $this->_fault('group_not_exists'); |
1000 | + } |
1001 | + |
1002 | + if (is_array($filters)) { |
1003 | + try { |
1004 | + foreach ($filters as $field => $value) { |
1005 | + $collection->addFieldToFilter($field, $value); |
1006 | + } |
1007 | + } catch (Mage_Core_Exception $e) { |
1008 | + $this->_fault('filters_invalid', $e->getMessage()); |
1009 | + // If we are adding filter on non-existent attribute |
1010 | + } |
1011 | + } |
1012 | + |
1013 | + $result = array(); |
1014 | + foreach ($collection as $customer) { |
1015 | + $result[] = $customer->toArray(); |
1016 | + } |
1017 | + |
1018 | + return $result; |
1019 | + } |
1020 | + |
1021 | + public function info($groupIds = null) |
1022 | + { |
1023 | + $groups = array(); |
1024 | + |
1025 | + if(is_array($groupIds)) |
1026 | + { |
1027 | + foreach($groupIds as $groupId) |
1028 | + { |
1029 | + try |
1030 | + { |
1031 | + $groups[] = Mage::getModel('core/store_group')->load($groupId)->toArray(); |
1032 | + } |
1033 | + catch (Mage_Core_Exception $e) |
1034 | + { |
1035 | + $this->_fault('group_not_exists'); |
1036 | + } |
1037 | + } |
1038 | + return $groups; |
1039 | + } |
1040 | + elseif(is_numeric($groupIds)) |
1041 | + { |
1042 | + try |
1043 | + { |
1044 | + return Mage::getModel('core/store_group')->load($groupIds)->toArray(); |
1045 | + } |
1046 | + catch (Mage_Core_Exception $e) |
1047 | + { |
1048 | + $this->_fault('group_not_exists'); |
1049 | + } |
1050 | + |
1051 | + } |
1052 | + |
1053 | + } |
1054 | + |
1055 | + public function create($groupdata) |
1056 | + { |
1057 | + try |
1058 | + { |
1059 | + $group = Mage::getModel('core/store_group') |
1060 | + ->setData($groupdata) |
1061 | + ->save(); |
1062 | + |
1063 | + } |
1064 | + catch (Magento_Core_Exception $e) |
1065 | + { |
1066 | + $this->_fault('data_invalid',$e->getMessage()); |
1067 | + } |
1068 | + catch (Exception $e) |
1069 | + { |
1070 | + $this->_fault('data_invalid',$e->getMessage()); |
1071 | + } |
1072 | + return $group->getId(); |
1073 | + } |
1074 | + |
1075 | + public function update($groupid,$groupdata) |
1076 | + { |
1077 | + try |
1078 | + { |
1079 | + $group = Mage::getModel('core/store_group') |
1080 | + ->load($groupid); |
1081 | + if (!$group->getId()) |
1082 | + { |
1083 | + $this->_fault('group_not_exists'); |
1084 | + } |
1085 | + $group->addData($groupdata)->save(); |
1086 | + } |
1087 | + catch (Magento_Core_Exception $e) |
1088 | + { |
1089 | + $this->_fault('data_invalid',$e->getMessage()); |
1090 | + } |
1091 | + catch (Exception $e) |
1092 | + { |
1093 | + $this->_fault('data_invalid',$e->getMessage()); |
1094 | + } |
1095 | + return true; |
1096 | + } |
1097 | + |
1098 | + public function delete($groupid) |
1099 | + { |
1100 | + try |
1101 | + { |
1102 | + $group = Mage::getModel('core/store_group') |
1103 | + ->load($groupid); |
1104 | + if (!$group->getId()) |
1105 | + { |
1106 | + $this->_fault('group_not_exists'); |
1107 | + } |
1108 | + $group->delete(); |
1109 | + |
1110 | + } |
1111 | + catch (Magento_Core_Exception $e) |
1112 | + { |
1113 | + $this->_fault('data_invalid',$e->getMessage()); |
1114 | + } |
1115 | + catch (Exception $e) |
1116 | + { |
1117 | + $this->_fault('data_invalid',$e->getMessage()); |
1118 | + } |
1119 | + return true; |
1120 | + } |
1121 | +} |
1122 | +?> |
1123 | |
1124 | === added file 'Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcore/Storeviews.php' |
1125 | --- Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcore/Storeviews.php 1970-01-01 00:00:00 +0000 |
1126 | +++ Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcore/Storeviews.php 2011-11-09 09:54:26 +0000 |
1127 | @@ -0,0 +1,142 @@ |
1128 | +<?php |
1129 | + |
1130 | +/** |
1131 | + * @author Sharoon Thomas |
1132 | + * Inspired from Dieter's Magento Extender |
1133 | + * @copyright 2009 |
1134 | + */ |
1135 | + |
1136 | +class Openlabs_OpenERPConnector_Model_Olcore_Storeviews extends Mage_Catalog_Model_Api_Resource |
1137 | +{ |
1138 | + public function items($filters=null) |
1139 | + { |
1140 | + try |
1141 | + { |
1142 | + $collection = Mage::getModel('core/store')->getCollection();//->addAttributeToSelect('*'); |
1143 | + } |
1144 | + catch (Mage_Core_Exception $e) |
1145 | + { |
1146 | + $this->_fault('store_not_exists'); |
1147 | + } |
1148 | + |
1149 | + if (is_array($filters)) { |
1150 | + try { |
1151 | + foreach ($filters as $field => $value) { |
1152 | + $collection->addFieldToFilter($field, $value); |
1153 | + } |
1154 | + } catch (Mage_Core_Exception $e) { |
1155 | + $this->_fault('filters_invalid', $e->getMessage()); |
1156 | + // If we are adding filter on non-existent attribute |
1157 | + } |
1158 | + } |
1159 | + |
1160 | + $result = array(); |
1161 | + foreach ($collection as $customer) { |
1162 | + $result[] = $customer->toArray(); |
1163 | + } |
1164 | + |
1165 | + return $result; |
1166 | + } |
1167 | + |
1168 | + public function info($storeIds = null) |
1169 | + { |
1170 | + $stores = array(); |
1171 | + |
1172 | + if(is_array($storeIds)) |
1173 | + { |
1174 | + foreach($storeIds as $storeId) |
1175 | + { |
1176 | + try |
1177 | + { |
1178 | + $stores[] = Mage::getModel('core/store')->load($storeId)->toArray(); |
1179 | + } |
1180 | + catch (Mage_Core_Exception $e) |
1181 | + { |
1182 | + $this->_fault('store_not_exists'); |
1183 | + } |
1184 | + } |
1185 | + return $stores; |
1186 | + } |
1187 | + elseif(is_numeric($storeIds)) |
1188 | + { |
1189 | + try |
1190 | + { |
1191 | + return Mage::getModel('core/store')->load($storeIds)->toArray(); |
1192 | + } |
1193 | + catch (Mage_Core_Exception $e) |
1194 | + { |
1195 | + $this->_fault('store_not_exists'); |
1196 | + } |
1197 | + |
1198 | + } |
1199 | + |
1200 | + } |
1201 | + |
1202 | + public function create($storedata) |
1203 | + { |
1204 | + try |
1205 | + { |
1206 | + $store = Mage::getModel('core/store') |
1207 | + ->setData($storedata) |
1208 | + ->save(); |
1209 | + |
1210 | + } |
1211 | + catch (Magento_Core_Exception $e) |
1212 | + { |
1213 | + $this->_fault('data_invalid',$e->getMessage()); |
1214 | + } |
1215 | + catch (Exception $e) |
1216 | + { |
1217 | + $this->_fault('data_invalid',$e->getMessage()); |
1218 | + } |
1219 | + return $store->getId(); |
1220 | + } |
1221 | + |
1222 | + public function update($storeid,$storedata) |
1223 | + { |
1224 | + try |
1225 | + { |
1226 | + $store = Mage::getModel('core/store') |
1227 | + ->load($storeid); |
1228 | + if (!$store->getId()) |
1229 | + { |
1230 | + $this->_fault('store_not_exists'); |
1231 | + } |
1232 | + $store->addData($storedata)->save(); |
1233 | + } |
1234 | + catch (Magento_Core_Exception $e) |
1235 | + { |
1236 | + $this->_fault('data_invalid',$e->getMessage()); |
1237 | + } |
1238 | + catch (Exception $e) |
1239 | + { |
1240 | + $this->_fault('data_invalid',$e->getMessage()); |
1241 | + } |
1242 | + return true; |
1243 | + } |
1244 | + |
1245 | + public function delete($storeid) |
1246 | + { |
1247 | + try |
1248 | + { |
1249 | + $store = Mage::getModel('core/store') |
1250 | + ->load($storeid); |
1251 | + if (!$store->getId()) |
1252 | + { |
1253 | + $this->_fault('store_not_exists'); |
1254 | + } |
1255 | + $store->delete(); |
1256 | + |
1257 | + } |
1258 | + catch (Magento_Core_Exception $e) |
1259 | + { |
1260 | + $this->_fault('data_invalid',$e->getMessage()); |
1261 | + } |
1262 | + catch (Exception $e) |
1263 | + { |
1264 | + $this->_fault('data_invalid',$e->getMessage()); |
1265 | + } |
1266 | + return true; |
1267 | + } |
1268 | +} |
1269 | +?> |
1270 | |
1271 | === added file 'Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcore/Website.php' |
1272 | --- Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcore/Website.php 1970-01-01 00:00:00 +0000 |
1273 | +++ Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcore/Website.php 2011-11-09 09:54:26 +0000 |
1274 | @@ -0,0 +1,171 @@ |
1275 | +<?php |
1276 | + |
1277 | +/** |
1278 | + * @author Sharoon Thomas |
1279 | + * Inspired from Dieter's Magento Extender |
1280 | + * @copyright 2009 |
1281 | + */ |
1282 | + |
1283 | +class Openlabs_OpenERPConnector_Model_Olcore_Website extends Mage_Catalog_Model_Api_Resource |
1284 | +{ |
1285 | + |
1286 | + public function items($filters=null) |
1287 | + { |
1288 | + try |
1289 | + { |
1290 | + $collection = Mage::getModel('core/website')->getCollection();//->addAttributeToSelect('*'); |
1291 | + } |
1292 | + catch (Mage_Core_Exception $e) |
1293 | + { |
1294 | + $this->_fault('store_not_exists'); |
1295 | + } |
1296 | + |
1297 | + if (is_array($filters)) { |
1298 | + try { |
1299 | + foreach ($filters as $field => $value) { |
1300 | + $collection->addFieldToFilter($field, $value); |
1301 | + } |
1302 | + } catch (Mage_Core_Exception $e) { |
1303 | + $this->_fault('filters_invalid', $e->getMessage()); |
1304 | + // If we are adding filter on non-existent attribute |
1305 | + } |
1306 | + } |
1307 | + |
1308 | + $result = array(); |
1309 | + foreach ($collection as $customer) { |
1310 | + $result[] = $customer->toArray(); |
1311 | + } |
1312 | + |
1313 | + return $result; |
1314 | + } |
1315 | + |
1316 | + public function info($storeIds = null) |
1317 | + { |
1318 | + $stores = array(); |
1319 | + |
1320 | + if(is_array($storeIds)) |
1321 | + { |
1322 | + foreach($storeIds as $storeId) |
1323 | + { |
1324 | + try |
1325 | + { |
1326 | + $stores[] = Mage::getModel('core/website')->load($storeId)->toArray(); |
1327 | + } |
1328 | + catch (Mage_Core_Exception $e) |
1329 | + { |
1330 | + $this->_fault('store_not_exists'); |
1331 | + } |
1332 | + } |
1333 | + return $stores; |
1334 | + } |
1335 | + elseif(is_numeric($storeIds)) |
1336 | + { |
1337 | + try |
1338 | + { |
1339 | + return Mage::getModel('core/website')->load($storeIds)->toArray(); |
1340 | + } |
1341 | + catch (Mage_Core_Exception $e) |
1342 | + { |
1343 | + $this->_fault('store_not_exists'); |
1344 | + } |
1345 | + |
1346 | + } |
1347 | + |
1348 | + } |
1349 | + //This is a protected function used by items & info for fetching website information |
1350 | + |
1351 | + public function create($websitedata) |
1352 | + { |
1353 | + try |
1354 | + { |
1355 | + $website = Mage::getModel('core/website') |
1356 | + ->setData($websitedata) |
1357 | + ->save(); |
1358 | + |
1359 | + } |
1360 | + catch (Magento_Core_Exception $e) |
1361 | + { |
1362 | + $this->_fault('data_invalid',$e->getMessage()); |
1363 | + } |
1364 | + catch (Exception $e) |
1365 | + { |
1366 | + $this->_fault('data_invalid',$e->getMessage()); |
1367 | + } |
1368 | + return $website->getId(); |
1369 | + } |
1370 | + |
1371 | + public function update($websiteid,$websitedata) |
1372 | + { |
1373 | + try |
1374 | + { |
1375 | + $website = Mage::getModel('core/website') |
1376 | + ->load($websiteid); |
1377 | + if (!$website->getId()) |
1378 | + { |
1379 | + $this->_fault('website_not_exists'); |
1380 | + } |
1381 | + $website->addData($websitedata)->save(); |
1382 | + } |
1383 | + catch (Magento_Core_Exception $e) |
1384 | + { |
1385 | + $this->_fault('data_invalid',$e->getMessage()); |
1386 | + } |
1387 | + catch (Exception $e) |
1388 | + { |
1389 | + $this->_fault('data_invalid',$e->getMessage()); |
1390 | + } |
1391 | + return true; |
1392 | + } |
1393 | + |
1394 | + public function delete($websiteid) |
1395 | + { |
1396 | + try |
1397 | + { |
1398 | + $website = Mage::getModel('core/website') |
1399 | + ->load($websiteid); |
1400 | + if (!$website->getId()) |
1401 | + { |
1402 | + $this->_fault('website_not_exists'); |
1403 | + } |
1404 | + $website->delete(); |
1405 | + |
1406 | + } |
1407 | + catch (Magento_Core_Exception $e) |
1408 | + { |
1409 | + $this->_fault('data_invalid',$e->getMessage()); |
1410 | + } |
1411 | + catch (Exception $e) |
1412 | + { |
1413 | + $this->_fault('data_invalid',$e->getMessage()); |
1414 | + } |
1415 | + return true; |
1416 | + } |
1417 | + |
1418 | + public function tree() |
1419 | + { |
1420 | + $tree = array(); |
1421 | + |
1422 | + $websites = $this->websites(); |
1423 | + |
1424 | + foreach($websites as $website) |
1425 | + { |
1426 | + $groups = $this->groups($website['group_ids']); |
1427 | + $tree[$website['code']] = $website; |
1428 | + foreach($groups as $group) |
1429 | + { |
1430 | + $stores = $this->stores($group["store_ids"]); |
1431 | + |
1432 | + $tree[$website['code']]['groups']['group_'.$group['group_id']] = $group; |
1433 | + |
1434 | + foreach($stores as $store) |
1435 | + { |
1436 | + $tree[$website['code']]['groups']['group_'.$group['group_id']]['stores'][$store['code']] = $store; |
1437 | + } |
1438 | + } |
1439 | + } |
1440 | + |
1441 | + return $tree; |
1442 | + } |
1443 | + |
1444 | +} |
1445 | +?> |
1446 | \ No newline at end of file |
1447 | |
1448 | === added directory 'Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcustomer' |
1449 | === added file 'Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcustomer/Address.php' |
1450 | --- Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcustomer/Address.php 1970-01-01 00:00:00 +0000 |
1451 | +++ Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcustomer/Address.php 2011-11-09 09:54:26 +0000 |
1452 | @@ -0,0 +1,241 @@ |
1453 | +<?php |
1454 | +/** |
1455 | + * Magento |
1456 | + * |
1457 | + * NOTICE OF LICENSE |
1458 | + * |
1459 | + * This source file is subject to the Open Software License (OSL 3.0) |
1460 | + * that is bundled with this package in the file LICENSE.txt. |
1461 | + * It is also available through the world-wide-web at this URL: |
1462 | + * http://opensource.org/licenses/osl-3.0.php |
1463 | + * If you did not receive a copy of the license and are unable to |
1464 | + * obtain it through the world-wide-web, please send an email |
1465 | + * to license@magentocommerce.com so we can send you a copy immediately. |
1466 | + * |
1467 | + * DISCLAIMER |
1468 | + * |
1469 | + * Do not edit or add to this file if you wish to upgrade Magento to newer |
1470 | + * versions in the future. If you wish to customize Magento for your |
1471 | + * needs please refer to http://www.magentocommerce.com for more information. |
1472 | + * |
1473 | + * @category Mage |
1474 | + * @package Mage_Customer |
1475 | + * @copyright Copyright (c) 2008 Irubin Consulting Inc. DBA Varien (http://www.varien.com) |
1476 | + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) |
1477 | + */ |
1478 | + |
1479 | +/** |
1480 | + * Customer address api |
1481 | + * |
1482 | + * @category Mage |
1483 | + * @package Mage_Customer |
1484 | + * @author Magento Core Team <core@magentocommerce.com> |
1485 | + */ |
1486 | +class Openlabs_OpenERPConnector_Model_Olcustomer_Address extends Mage_Customer_Model_Api_Resource |
1487 | +{ |
1488 | + protected $_mapAttributes = array( |
1489 | + 'customer_id' => 'entity_id' |
1490 | + ); |
1491 | + |
1492 | + public function __construct() |
1493 | + { |
1494 | + $this->_ignoredAttributeCodes[] = 'parent_id'; |
1495 | + } |
1496 | + |
1497 | + /** |
1498 | + * Retrive customer addresses list |
1499 | + * |
1500 | + * @param int $customerId |
1501 | + * @return array |
1502 | + */ |
1503 | + public function items($customerId) |
1504 | + { |
1505 | + $customer = Mage::getModel('customer/customer') |
1506 | + ->load($customerId); |
1507 | + /* @var $customer Mage_Customer_Model_Customer */ |
1508 | + |
1509 | + if (!$customer->getId()) { |
1510 | + $this->_fault('customer_not_exists'); |
1511 | + } |
1512 | + |
1513 | + $result = array(); |
1514 | + foreach ($customer->getAddresses() as $address) { |
1515 | + $data = $address->toArray(); |
1516 | + $data['default_billing'] = $customer->getDefaultBilling() == $address->getId(); |
1517 | + $data['default_shipping'] = $customer->getDefaultShipping() == $address->getId(); |
1518 | + $result[] = $data; |
1519 | + /*$data = $address->toArray(); |
1520 | + $row = array(); |
1521 | + |
1522 | + foreach ($this->_mapAttributes as $attributeAlias => $attributeCode) { |
1523 | + $row[$attributeAlias] = isset($data[$attributeCode]) ? $data[$attributeCode] : null; |
1524 | + } |
1525 | + |
1526 | + foreach ($this->getAllowedAttributes($address) as $attributeCode => $attribute) { |
1527 | + if (isset($data[$attributeCode])) { |
1528 | + $row[$attributeCode] = $data[$attributeCode]; |
1529 | + } |
1530 | + } |
1531 | + |
1532 | + $row['is_default_billing'] = $customer->getDefaultBillingAddress() == $address->getId(); |
1533 | + $row['is_default_shipping'] = $customer->getDefaultShippingAddress() == $address->getId(); |
1534 | + |
1535 | + $result[] = $row;*/ |
1536 | + |
1537 | + } |
1538 | + |
1539 | + return $result; |
1540 | + } |
1541 | + |
1542 | + /** |
1543 | + * Create new address for customer |
1544 | + * |
1545 | + * @param int $customerId |
1546 | + * @param array $addressData |
1547 | + * @return int |
1548 | + */ |
1549 | + public function create($customerId, $addressData) |
1550 | + { |
1551 | + $customer = Mage::getModel('customer/customer') |
1552 | + ->load($customerId); |
1553 | + /* @var $customer Mage_Customer_Model_Customer */ |
1554 | + |
1555 | + if (!$customer->getId()) { |
1556 | + $this->_fault('customer_not_exists'); |
1557 | + } |
1558 | + |
1559 | + $address = Mage::getModel('customer/address'); |
1560 | + |
1561 | + foreach ($this->getAllowedAttributes($address) as $attributeCode=>$attribute) { |
1562 | + if (isset($addressData[$attributeCode])) { |
1563 | + $address->setData($attributeCode, $addressData[$attributeCode]); |
1564 | + } |
1565 | + } |
1566 | + |
1567 | + if (isset($addressData['is_default_billing'])) { |
1568 | + $address->setIsDefaultBilling($addressData['is_default_billing']); |
1569 | + } |
1570 | + |
1571 | + if (isset($addressData['is_default_shipping'])) { |
1572 | + $address->setIsDefaultShipping($addressData['is_default_shipping']); |
1573 | + } |
1574 | + |
1575 | + $address->setCustomerId($customer->getId()); |
1576 | + |
1577 | + $valid = $address->validate(); |
1578 | + |
1579 | + if (is_array($valid)) { |
1580 | + $this->_fault('data_invalid', implode("\n", $valid)); |
1581 | + } |
1582 | + |
1583 | + try { |
1584 | + $address->save(); |
1585 | + } catch (Mage_Core_Exception $e) { |
1586 | + $this->_fault('data_invalid', $e->getMessage()); |
1587 | + } |
1588 | + |
1589 | + return $address->getId(); |
1590 | + } |
1591 | + |
1592 | + /** |
1593 | + * Retrieve address data |
1594 | + * |
1595 | + * @param int $addressId |
1596 | + * @return array |
1597 | + */ |
1598 | + public function info($addressId) |
1599 | + { |
1600 | + $address = Mage::getModel('customer/address') |
1601 | + ->load($addressId); |
1602 | + |
1603 | + if (!$address->getId()) { |
1604 | + $this->_fault('not_exists'); |
1605 | + } |
1606 | + |
1607 | + $result = array(); |
1608 | + |
1609 | + foreach ($this->_mapAttributes as $attributeAlias => $attributeCode) { |
1610 | + $result[$attributeAlias] = $address->getData($attributeCode); |
1611 | + } |
1612 | + |
1613 | + foreach ($this->getAllowedAttributes($address) as $attributeCode => $attribute) { |
1614 | + $result[$attributeCode] = $address->getData($attributeCode); |
1615 | + } |
1616 | + |
1617 | + |
1618 | + if ($customer = $address->getCustomer()) { |
1619 | + $result['is_default_billing'] = $customer->getDefaultBillingAddress() == $address->getId(); |
1620 | + $result['is_default_shipping'] = $customer->getDefaultShippingAddress() == $address->getId(); |
1621 | + } |
1622 | + |
1623 | + return $result; |
1624 | + } |
1625 | + |
1626 | + /** |
1627 | + * Update address data |
1628 | + * |
1629 | + * @param int $addressId |
1630 | + * @param array $addressData |
1631 | + * @return boolean |
1632 | + */ |
1633 | + public function update($addressId, $addressData) |
1634 | + { |
1635 | + $address = Mage::getModel('customer/address') |
1636 | + ->load($addressId); |
1637 | + |
1638 | + if (!$address->getId()) { |
1639 | + $this->_fault('not_exists'); |
1640 | + } |
1641 | + |
1642 | + foreach ($this->getAllowedAttributes($address) as $attributeCode=>$attribute) { |
1643 | + if (isset($addressData[$attributeCode])) { |
1644 | + $address->setData($attributeCode, $addressData[$attributeCode]); |
1645 | + } |
1646 | + } |
1647 | + |
1648 | + if (isset($addressData['is_default_billing'])) { |
1649 | + $address->setIsDefaultBilling($addressData['is_default_billing']); |
1650 | + } |
1651 | + |
1652 | + if (isset($addressData['is_default_shipping'])) { |
1653 | + $address->setIsDefaultShipping($addressData['is_default_shipping']); |
1654 | + } |
1655 | + |
1656 | + $valid = $address->validate(); |
1657 | + if (is_array($valid)) { |
1658 | + $this->_fault('data_invalid', implode("\n", $valid)); |
1659 | + } |
1660 | + |
1661 | + try { |
1662 | + $address->save(); |
1663 | + } catch (Mage_Core_Exception $e) { |
1664 | + $this->_fault('data_invalid', $e->getMessage()); |
1665 | + } |
1666 | + |
1667 | + return true; |
1668 | + } |
1669 | + |
1670 | + /** |
1671 | + * Delete address |
1672 | + * |
1673 | + * @param int $addressId |
1674 | + * @return boolean |
1675 | + */ |
1676 | + public function delete($addressId) |
1677 | + { |
1678 | + $address = Mage::getModel('customer/address') |
1679 | + ->load($addressId); |
1680 | + |
1681 | + if (!$address->getId()) { |
1682 | + $this->_fault('not_exists'); |
1683 | + } |
1684 | + |
1685 | + try { |
1686 | + $address->delete(); |
1687 | + } catch (Mage_Core_Exception $e) { |
1688 | + $this->_fault('not_deleted', $e->getMessage()); |
1689 | + } |
1690 | + |
1691 | + return true; |
1692 | + } |
1693 | +} // Class Mage_Customer_Model_Address_Api End |
1694 | \ No newline at end of file |
1695 | |
1696 | === added file 'Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcustomer/Customer.php' |
1697 | --- Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcustomer/Customer.php 1970-01-01 00:00:00 +0000 |
1698 | +++ Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcustomer/Customer.php 2011-11-09 09:54:26 +0000 |
1699 | @@ -0,0 +1,142 @@ |
1700 | +<?php |
1701 | + |
1702 | +/** |
1703 | + * @author Sharoon Thomas |
1704 | + * Inspired from Dieter's Magento Extender |
1705 | + * @copyright 2009 |
1706 | + */ |
1707 | + |
1708 | +class Openlabs_OpenERPConnector_Model_Olcustomer_Customer extends Mage_Catalog_Model_Api_Resource |
1709 | +{ |
1710 | + public function items($filters=null) |
1711 | + { |
1712 | + try |
1713 | + { |
1714 | + $collection = Mage::getModel('customer')->getCollection();//->addAttributeToSelect('*'); |
1715 | + } |
1716 | + catch (Mage_Core_Exception $e) |
1717 | + { |
1718 | + $this->_fault('customer_not_exists'); |
1719 | + } |
1720 | + |
1721 | + if (is_array($filters)) { |
1722 | + try { |
1723 | + foreach ($filters as $field => $value) { |
1724 | + $collection->addFieldToFilter($field, $value); |
1725 | + } |
1726 | + } catch (Mage_Core_Exception $e) { |
1727 | + $this->_fault('filters_invalid', $e->getMessage()); |
1728 | + // If we are adding filter on non-existent attribute |
1729 | + } |
1730 | + } |
1731 | + |
1732 | + $result = array(); |
1733 | + foreach ($collection as $customer) { |
1734 | + $result[] = $customer->toArray(); |
1735 | + } |
1736 | + |
1737 | + return $result; |
1738 | + } |
1739 | + |
1740 | + public function info($groupIds = null) |
1741 | + { |
1742 | + $groups = array(); |
1743 | + |
1744 | + if(is_array($groupIds)) |
1745 | + { |
1746 | + foreach($groupIds as $groupId) |
1747 | + { |
1748 | + try |
1749 | + { |
1750 | + $groups[] = Mage::getModel('customer')->load($groupId)->toArray(); |
1751 | + } |
1752 | + catch (Mage_Core_Exception $e) |
1753 | + { |
1754 | + $this->_fault('customer_not_exists'); |
1755 | + } |
1756 | + } |
1757 | + return $groups; |
1758 | + } |
1759 | + elseif(is_numeric($groupIds)) |
1760 | + { |
1761 | + try |
1762 | + { |
1763 | + return Mage::getModel('customer')->load($groupIds)->toArray(); |
1764 | + } |
1765 | + catch (Mage_Core_Exception $e) |
1766 | + { |
1767 | + $this->_fault('customer_not_exists'); |
1768 | + } |
1769 | + |
1770 | + } |
1771 | + |
1772 | + } |
1773 | + |
1774 | + public function create($groupdata) |
1775 | + { |
1776 | + try |
1777 | + { |
1778 | + $group = Mage::getModel('customer') |
1779 | + ->setData($groupdata) |
1780 | + ->save(); |
1781 | + |
1782 | + } |
1783 | + catch (Magento_Core_Exception $e) |
1784 | + { |
1785 | + $this->_fault('data_invalid',$e->getMessage()); |
1786 | + } |
1787 | + catch (Exception $e) |
1788 | + { |
1789 | + $this->_fault('data_invalid',$e->getMessage()); |
1790 | + } |
1791 | + return $group->getId(); |
1792 | + } |
1793 | + |
1794 | + public function update($groupid,$groupdata) |
1795 | + { |
1796 | + try |
1797 | + { |
1798 | + $group = Mage::getModel('customer') |
1799 | + ->load($groupid); |
1800 | + if (!$group->getId()) |
1801 | + { |
1802 | + $this->_fault('customer_not_exists'); |
1803 | + } |
1804 | + $group->addData($groupdata)->save(); |
1805 | + } |
1806 | + catch (Magento_Core_Exception $e) |
1807 | + { |
1808 | + $this->_fault('data_invalid',$e->getMessage()); |
1809 | + } |
1810 | + catch (Exception $e) |
1811 | + { |
1812 | + $this->_fault('data_invalid',$e->getMessage()); |
1813 | + } |
1814 | + return true; |
1815 | + } |
1816 | + |
1817 | + public function delete($groupid) |
1818 | + { |
1819 | + try |
1820 | + { |
1821 | + $group = Mage::getModel('customer') |
1822 | + ->load($groupid); |
1823 | + if (!$group->getId()) |
1824 | + { |
1825 | + $this->_fault('customer_not_exists'); |
1826 | + } |
1827 | + $group->delete(); |
1828 | + |
1829 | + } |
1830 | + catch (Magento_Core_Exception $e) |
1831 | + { |
1832 | + $this->_fault('data_invalid',$e->getMessage()); |
1833 | + } |
1834 | + catch (Exception $e) |
1835 | + { |
1836 | + $this->_fault('data_invalid',$e->getMessage()); |
1837 | + } |
1838 | + return true; |
1839 | + } |
1840 | +} |
1841 | +?> |
1842 | |
1843 | === added file 'Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcustomer/Group.php' |
1844 | --- Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcustomer/Group.php 1970-01-01 00:00:00 +0000 |
1845 | +++ Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcustomer/Group.php 2011-11-09 09:54:26 +0000 |
1846 | @@ -0,0 +1,142 @@ |
1847 | +<?php |
1848 | + |
1849 | +/** |
1850 | + * @author Sharoon Thomas |
1851 | + * Inspired from Dieter's Magento Extender |
1852 | + * @copyright 2009 |
1853 | + */ |
1854 | + |
1855 | +class Openlabs_OpenERPConnector_Model_Olcustomer_Group extends Mage_Catalog_Model_Api_Resource |
1856 | +{ |
1857 | + public function items($filters=null) |
1858 | + { |
1859 | + try |
1860 | + { |
1861 | + $collection = Mage::getModel('customer/group')->getCollection();//->addAttributeToSelect('*'); |
1862 | + } |
1863 | + catch (Mage_Core_Exception $e) |
1864 | + { |
1865 | + $this->_fault('group_not_exists'); |
1866 | + } |
1867 | + |
1868 | + if (is_array($filters)) { |
1869 | + try { |
1870 | + foreach ($filters as $field => $value) { |
1871 | + $collection->addFieldToFilter($field, $value); |
1872 | + } |
1873 | + } catch (Mage_Core_Exception $e) { |
1874 | + $this->_fault('filters_invalid', $e->getMessage()); |
1875 | + // If we are adding filter on non-existent attribute |
1876 | + } |
1877 | + } |
1878 | + |
1879 | + $result = array(); |
1880 | + foreach ($collection as $customer) { |
1881 | + $result[] = $customer->toArray(); |
1882 | + } |
1883 | + |
1884 | + return $result; |
1885 | + } |
1886 | + |
1887 | + public function info($groupIds = null) |
1888 | + { |
1889 | + $groups = array(); |
1890 | + |
1891 | + if(is_array($groupIds)) |
1892 | + { |
1893 | + foreach($groupIds as $groupId) |
1894 | + { |
1895 | + try |
1896 | + { |
1897 | + $groups[] = Mage::getModel('customer/group')->load($groupId)->toArray(); |
1898 | + } |
1899 | + catch (Mage_Core_Exception $e) |
1900 | + { |
1901 | + $this->_fault('group_not_exists'); |
1902 | + } |
1903 | + } |
1904 | + return $groups; |
1905 | + } |
1906 | + elseif(is_numeric($groupIds)) |
1907 | + { |
1908 | + try |
1909 | + { |
1910 | + return Mage::getModel('customer/group')->load($groupIds)->toArray(); |
1911 | + } |
1912 | + catch (Mage_Core_Exception $e) |
1913 | + { |
1914 | + $this->_fault('group_not_exists'); |
1915 | + } |
1916 | + |
1917 | + } |
1918 | + |
1919 | + } |
1920 | + |
1921 | + public function create($groupdata) |
1922 | + { |
1923 | + try |
1924 | + { |
1925 | + $group = Mage::getModel('customer/group') |
1926 | + ->setData($groupdata) |
1927 | + ->save(); |
1928 | + |
1929 | + } |
1930 | + catch (Magento_Core_Exception $e) |
1931 | + { |
1932 | + $this->_fault('data_invalid',$e->getMessage()); |
1933 | + } |
1934 | + catch (Exception $e) |
1935 | + { |
1936 | + $this->_fault('data_invalid',$e->getMessage()); |
1937 | + } |
1938 | + return $group->getId(); |
1939 | + } |
1940 | + |
1941 | + public function update($groupid,$groupdata) |
1942 | + { |
1943 | + try |
1944 | + { |
1945 | + $group = Mage::getModel('customer/group') |
1946 | + ->load($groupid); |
1947 | + if (!$group->getId()) |
1948 | + { |
1949 | + $this->_fault('group_not_exists'); |
1950 | + } |
1951 | + $group->addData($groupdata)->save(); |
1952 | + } |
1953 | + catch (Magento_Core_Exception $e) |
1954 | + { |
1955 | + $this->_fault('data_invalid',$e->getMessage()); |
1956 | + } |
1957 | + catch (Exception $e) |
1958 | + { |
1959 | + $this->_fault('data_invalid',$e->getMessage()); |
1960 | + } |
1961 | + return true; |
1962 | + } |
1963 | + |
1964 | + public function delete($groupid) |
1965 | + { |
1966 | + try |
1967 | + { |
1968 | + $group = Mage::getModel('customer/group') |
1969 | + ->load($groupid); |
1970 | + if (!$group->getId()) |
1971 | + { |
1972 | + $this->_fault('group_not_exists'); |
1973 | + } |
1974 | + $group->delete(); |
1975 | + |
1976 | + } |
1977 | + catch (Magento_Core_Exception $e) |
1978 | + { |
1979 | + $this->_fault('data_invalid',$e->getMessage()); |
1980 | + } |
1981 | + catch (Exception $e) |
1982 | + { |
1983 | + $this->_fault('data_invalid',$e->getMessage()); |
1984 | + } |
1985 | + return true; |
1986 | + } |
1987 | +} |
1988 | +?> |
1989 | |
1990 | === added file 'Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcustomer/Subscriber.php' |
1991 | --- Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcustomer/Subscriber.php 1970-01-01 00:00:00 +0000 |
1992 | +++ Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcustomer/Subscriber.php 2011-11-09 09:54:26 +0000 |
1993 | @@ -0,0 +1,163 @@ |
1994 | +<?php |
1995 | +/** |
1996 | + * Magento |
1997 | + * |
1998 | + * NOTICE OF LICENSE |
1999 | + * |
2000 | + * This source file is subject to the Open Software License (OSL 3.0) |
2001 | + * that is bundled with this package in the file LICENSE.txt. |
2002 | + * It is also available through the world-wide-web at this URL: |
2003 | + * http://opensource.org/licenses/osl-3.0.php |
2004 | + * If you did not receive a copy of the license and are unable to |
2005 | + * obtain it through the world-wide-web, please send an email |
2006 | + * to license@magentocommerce.com so we can send you a copy immediately. |
2007 | + * |
2008 | + * DISCLAIMER |
2009 | + * |
2010 | + * Do not edit or add to this file if you wish to upgrade Magento to newer |
2011 | + * versions in the future. If you wish to customize Magento for your |
2012 | + * needs please refer to http://www.magentocommerce.com for more information. |
2013 | + * |
2014 | + * @category Mage |
2015 | + * @package Mage_Customer |
2016 | + * @copyright Copyright (c) 2008 Irubin Consulting Inc. DBA Varien (http://www.varien.com) |
2017 | + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) |
2018 | + */ |
2019 | + |
2020 | +/** |
2021 | + * Customer address api |
2022 | + * |
2023 | + * @category Mage |
2024 | + * @package Mage_Customer |
2025 | + * @author Magento Core Team <core@magentocommerce.com> |
2026 | + */ |
2027 | +class Openlabs_OpenERPConnector_Model_Olcustomer_Subscriber extends Mage_Customer_Model_Api_Resource |
2028 | +{ |
2029 | + protected $_mapAttributes = array( |
2030 | + 'customer_id' => 'entity_id' |
2031 | + ); |
2032 | + |
2033 | + public function __construct() |
2034 | + { |
2035 | + $this->_ignoredAttributeCodes[] = 'parent_id'; |
2036 | + } |
2037 | + |
2038 | + /** |
2039 | + * Retrive subscriber list |
2040 | + * |
2041 | + * @param int $filters |
2042 | + * @return array |
2043 | + */ |
2044 | + public function items($filters=null) |
2045 | + { |
2046 | + $collection = Mage::getModel('customer/customer')->getCollection() |
2047 | + ->addAttributeToSelect('*'); |
2048 | + |
2049 | + |
2050 | + if (is_array($filters)) { |
2051 | + try { |
2052 | + foreach ($filters as $field => $value) { |
2053 | + $collection->addFieldToFilter($field, $value); |
2054 | + } |
2055 | + } catch (Mage_Core_Exception $e) { |
2056 | + $this->_fault('filters_invalid', $e->getMessage()); |
2057 | + // If we are adding filter on non-existent attribute |
2058 | + } |
2059 | + } |
2060 | + |
2061 | + $result = array(); |
2062 | + |
2063 | + foreach ($collection as $customer) { |
2064 | + $subscriber = Mage::getModel('newsletter/subscriber')->loadByEmail($customer['email']); |
2065 | + if($subscriber->getId()) |
2066 | + $result[] = $subscriber->getId(); |
2067 | + } |
2068 | + |
2069 | + return $result; |
2070 | + } |
2071 | + |
2072 | + /** |
2073 | + * Create new address for customer |
2074 | + * |
2075 | + * @param int $customerId |
2076 | + * @param array $email |
2077 | + * @return int |
2078 | + */ |
2079 | + public function create($customerId,$email) |
2080 | + { |
2081 | + if($customerId && $email): |
2082 | + $customer = Mage::getModel("newsletter/subscriber"); |
2083 | + |
2084 | + $customer->setCustomerId($customerId); |
2085 | + $customer->setEmail($email); |
2086 | + $customer->subscriber_status = "1"; |
2087 | + |
2088 | + $customer->save(); |
2089 | + |
2090 | + return $customer->getId(); |
2091 | + else: |
2092 | + return False; |
2093 | + endif; |
2094 | + } |
2095 | + |
2096 | + /** |
2097 | + * Retrieve subscriber data |
2098 | + * |
2099 | + * @param int $subscriberId |
2100 | + * @return array |
2101 | + */ |
2102 | + public function info($subscriberId) |
2103 | + { |
2104 | + $subscriber = Mage::getModel('newsletter/subscriber')->load($subscriberId); |
2105 | + |
2106 | + if($subscriber->getId()): |
2107 | + $result[] = $subscriber->toArray(); |
2108 | + endif; |
2109 | + |
2110 | + return $result; |
2111 | + } |
2112 | + |
2113 | + /** |
2114 | + * Update subscriber data (subscriber) |
2115 | + * |
2116 | + * @param $email |
2117 | + * @return boolean |
2118 | + */ |
2119 | + public function update($email) |
2120 | + { |
2121 | + if($email): |
2122 | + $subscriber = Mage::getModel('newsletter/subscriber')->loadByEmail($email); |
2123 | + |
2124 | + if($subscriber->getId()): |
2125 | + $customer = Mage::getModel("newsletter/subscriber")->load($subscriber->getId()); |
2126 | + $customer->subscriber_status = "1"; |
2127 | + $customer->save(); |
2128 | + endif; |
2129 | + |
2130 | + return $subscriber->getId(); |
2131 | + else: |
2132 | + return False; |
2133 | + endif; |
2134 | + } |
2135 | + |
2136 | + /** |
2137 | + * Delete subscriber (unsubscriber) |
2138 | + * |
2139 | + * @param $email |
2140 | + * @return boolean |
2141 | + */ |
2142 | + public function delete($email) |
2143 | + { |
2144 | + if($email): |
2145 | + $subscriber = Mage::getModel('newsletter/subscriber')->loadByEmail($email); |
2146 | + |
2147 | + if($subscriber->getId()): |
2148 | + Mage::getModel('newsletter/subscriber')->load($subscriber->getId())->unsubscribe(); |
2149 | + endif; |
2150 | + |
2151 | + return $subscriber->getId(); |
2152 | + else: |
2153 | + return False; |
2154 | + endif; |
2155 | + } |
2156 | +} // Class Mage_Customer_Model_Address_Api End |
2157 | |
2158 | === added directory 'Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Sales' |
2159 | === added directory 'Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Sales/Order' |
2160 | === added file 'Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Sales/Order/Api.php' |
2161 | --- Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Sales/Order/Api.php 1970-01-01 00:00:00 +0000 |
2162 | +++ Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Sales/Order/Api.php 2011-11-09 09:54:26 +0000 |
2163 | @@ -0,0 +1,116 @@ |
2164 | +<?php |
2165 | + |
2166 | +/** |
2167 | + * |
2168 | + * @author Mohammed NAHHAS |
2169 | + * @package Openlabs_OpenERPConnector |
2170 | + * |
2171 | + */ |
2172 | + |
2173 | +class Openlabs_OpenERPConnector_Model_Sales_Order_Api extends Mage_Sales_Model_Order_Api { |
2174 | + |
2175 | + /** |
2176 | + * |
2177 | + * Retrieve orders data based on the value of the flag 'imported' |
2178 | + * @param array |
2179 | + * @return array |
2180 | + */ |
2181 | + public function retrieveOrders($data) { |
2182 | + |
2183 | + $result = array(); |
2184 | + if(isset($data['imported'])) { |
2185 | + |
2186 | + $collection = Mage::getModel("sales/order")->getCollection() |
2187 | + ->addAttributeToSelect('*') |
2188 | + ->addAttributeToFilter('imported', array('eq' => $data['imported'])); |
2189 | + |
2190 | + /* addAddressFields() is called only if version >= 1400 */ |
2191 | + if(str_replace('.','',Mage::getVersion()) >= 1400) { |
2192 | + $collection->addAddressFields(); |
2193 | + } |
2194 | + |
2195 | + if(isset($data['limit'])) { |
2196 | + $collection->setPageSize($data['limit']); |
2197 | + $collection->setOrder('entity_id', 'ASC'); |
2198 | + } |
2199 | + |
2200 | + if(isset($data['filters']) && is_array($data['filters'])) { |
2201 | + $filters = $data['filters']; |
2202 | + foreach($filters as $field => $value) { |
2203 | + $collection->addAttributeToFilter($field, $value); |
2204 | + } |
2205 | + } |
2206 | + |
2207 | + foreach ($collection as $order) { |
2208 | + $tmp = $this->_getAttributes($order, 'order'); |
2209 | + |
2210 | + /* if version < 1400, billing and shipping information are added manually to order data */ |
2211 | + if(str_replace('.','',Mage::getVersion()) < 1400) { |
2212 | + $address_data = $this->_getAttributes($order->getShippingAddress(), 'order_address'); |
2213 | + if(!empty($address_data)) { |
2214 | + $tmp['shipping_firstname'] = $address_data['firstname']; |
2215 | + $tmp['shipping_lastname'] = $address_data['lastname']; |
2216 | + } |
2217 | + |
2218 | + $address_data = $this->_getAttributes($order->getBillingAddress(), 'order_address'); |
2219 | + if(!empty($address_data)) { |
2220 | + $tmp['billing_firstname'] = $address_data['firstname']; |
2221 | + $tmp['billing_lastname'] = $address_data['lastname']; |
2222 | + } |
2223 | + } |
2224 | + |
2225 | + $result[] = $tmp; |
2226 | + } |
2227 | + return $result; |
2228 | + }else{ |
2229 | + $this->_fault('data_invalid', "Error, the attribut 'imported' need to be specified"); |
2230 | + } |
2231 | + } |
2232 | + |
2233 | + public function setFlagForOrder($incrementId) { |
2234 | + $_order = $this->_initOrder($incrementId); |
2235 | + $_order->setImported(1); |
2236 | + try { |
2237 | + $_order->save(); |
2238 | + return true; |
2239 | + } catch (Mage_Core_Exception $e) { |
2240 | + $this->_fault('data_invalid', $e->getMessage()); |
2241 | + } |
2242 | + } |
2243 | + |
2244 | + /* Retrieve increment_id of the child order */ |
2245 | + public function getOrderChild($incrementId) { |
2246 | + |
2247 | + $order = Mage::getModel('sales/order')->loadByIncrementId($incrementId); |
2248 | + /** |
2249 | + * Check order existing |
2250 | + */ |
2251 | + if (!$order->getId()) { |
2252 | + $this->_fault('order_not_exists'); |
2253 | + } |
2254 | + |
2255 | + if($order->getRelationChildId()) { |
2256 | + return $order->getRelationChildRealId(); |
2257 | + }else{ |
2258 | + return false; |
2259 | + } |
2260 | + } |
2261 | + |
2262 | + /* Retrieve increment_id of the parent order */ |
2263 | + public function getOrderParent($incrementId) { |
2264 | + |
2265 | + $order = Mage::getModel('sales/order')->loadByIncrementId($incrementId); |
2266 | + /** |
2267 | + * Check order existing |
2268 | + */ |
2269 | + if (!$order->getId()) { |
2270 | + $this->_fault('order_not_exists'); |
2271 | + } |
2272 | + |
2273 | + if($order->getRelationParentId()) { |
2274 | + return $order->getRelationParentRealId(); |
2275 | + }else{ |
2276 | + return false; |
2277 | + } |
2278 | + } |
2279 | +} |
2280 | \ No newline at end of file |
2281 | |
2282 | === added directory 'Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/controllers' |
2283 | === added directory 'Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/controllers/Adminhtml' |
2284 | === added file 'Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/controllers/Adminhtml/InitController.php' |
2285 | --- Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/controllers/Adminhtml/InitController.php 1970-01-01 00:00:00 +0000 |
2286 | +++ Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/controllers/Adminhtml/InitController.php 2011-11-09 09:54:26 +0000 |
2287 | @@ -0,0 +1,61 @@ |
2288 | +<?php |
2289 | + |
2290 | +/** |
2291 | + * |
2292 | + * @author Mohammed NAHHAS |
2293 | + * @package Openlabs_OpenERPConnector |
2294 | + * |
2295 | + */ |
2296 | + |
2297 | +class Openlabs_OpenERPConnector_Adminhtml_InitController extends Mage_Adminhtml_Controller_Action |
2298 | +{ |
2299 | + protected $_imported = 'imported'; |
2300 | + |
2301 | + /* Initialize the Attribute 'Imported' for orders placed before installing Openlabs_OpenERPConnector Extension */ |
2302 | + public function ordersAction() { |
2303 | + /* 'imported' value will be initialized if magento version is < 1.4.0.0 */ |
2304 | + if(str_replace('.','',Mage::getVersion()) < 1400) { |
2305 | + $orders = array(); |
2306 | + |
2307 | + /* 'imported' attribute values are stored in sales_order_int */ |
2308 | + $imported_attribute_table_name = 'sales_order_int'; |
2309 | + |
2310 | + /* retrieve entity_type_id for order */ |
2311 | + $entity_type = Mage::getModel('eav/entity_type')->loadByCode('order'); |
2312 | + |
2313 | + /* Load 'imported' attribute to get its attribute_id */ |
2314 | + $attributeInfo = Mage::getResourceModel('eav/entity_attribute_collection') |
2315 | + ->setCodeFilter($this->_imported) |
2316 | + ->setEntityTypeFilter($entity_type->getEntityTypeId()) |
2317 | + ->getFirstItem(); |
2318 | + |
2319 | + /* load order collection */ |
2320 | + $collection = Mage::getResourceModel('sales/order_collection') |
2321 | + ->addAttributeToSelect($this->_imported); |
2322 | + |
2323 | + if(count($collection->getItems()) > 0) { |
2324 | + foreach($collection as $order) { |
2325 | + try{ |
2326 | + $test = $order->getResource()->getAttribute($this->_imported); |
2327 | + $orders[] = $order->getIncrementId(); |
2328 | + $order->setImported(0)->save(); |
2329 | + $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)"; |
2330 | + $write = Mage::getSingleton('core/resource')->getConnection('core_write'); |
2331 | + $query = $write->query($request); |
2332 | + }catch (Exception $e) { |
2333 | + echo 'Error : '.$e->getMessage(); |
2334 | + } |
2335 | + } |
2336 | + |
2337 | + echo 'Number of Orders Initialized : '.count($collection->getItems()) .'<br />'; |
2338 | + echo 'Orders List : '.'<br />'; |
2339 | + echo '<pre>'; |
2340 | + print_r($orders); |
2341 | + echo '</pre>'; |
2342 | + } |
2343 | + }else{ |
2344 | + echo 'Magento Version : '.Mage::getVersion().'<br />'; |
2345 | + echo 'There is no need to initialize orders'; |
2346 | + } |
2347 | + } |
2348 | +} |
2349 | \ No newline at end of file |
2350 | |
2351 | === added file 'Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/controllers/OpenerpconnectorController.php' |
2352 | --- Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/controllers/OpenerpconnectorController.php 1970-01-01 00:00:00 +0000 |
2353 | +++ Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/controllers/OpenerpconnectorController.php 2011-11-09 09:54:26 +0000 |
2354 | @@ -0,0 +1,5 @@ |
2355 | +<?php |
2356 | +class Openlabs_OpenERPConnector_OpenerpconnectorController extends Mage_Core_Controller_Front_Action |
2357 | +{ |
2358 | + |
2359 | +} |
2360 | |
2361 | === added directory 'Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/etc' |
2362 | === added file 'Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/etc/api.xml' |
2363 | --- Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/etc/api.xml 1970-01-01 00:00:00 +0000 |
2364 | +++ Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/etc/api.xml 2011-11-09 09:54:26 +0000 |
2365 | @@ -0,0 +1,526 @@ |
2366 | + |
2367 | +<config> |
2368 | + <api> |
2369 | + <resources> |
2370 | + <ol_websites translate="title" module="core"> |
2371 | + <title>Website Management</title> |
2372 | + <model>openerpconnector/olcore_website</model> |
2373 | + <acl>core/store</acl> |
2374 | + <methods> |
2375 | + <list translate="title" module="core"> |
2376 | + <title>Enumerate websites</title> |
2377 | + <method>items</method> |
2378 | + </list> |
2379 | + <create translate="title" module="core"> |
2380 | + <title>Create Websites</title> |
2381 | + <!--Parameters are code,name,is_default,sort_order,default_group_id,group_ids--> |
2382 | + <method>create</method> |
2383 | + </create> |
2384 | + <info translate="title" module="core"> |
2385 | + <title>Fetch detail of websites</title> |
2386 | + <method>info</method> |
2387 | + </info> |
2388 | + <update translate="title" module="core"> |
2389 | + <title>Update websites info</title> |
2390 | + <method>update</method> |
2391 | + </update> |
2392 | + <delete translate="title" module="core"> |
2393 | + <title>Delete websites</title> |
2394 | + <method>delete</method> |
2395 | + </delete> |
2396 | + </methods> |
2397 | + <faults module="core"> |
2398 | + <website_not_exists> |
2399 | + <code>101</code> |
2400 | + <message>Requested website not found.</message> |
2401 | + </website_not_exists> |
2402 | + <data_invalid> |
2403 | + <code>102</code> |
2404 | + <message>Website creation failed due to invalid data.</message> |
2405 | + </data_invalid> |
2406 | + </faults> |
2407 | + </ol_websites> |
2408 | + <ol_groups translate="title" module="core"> |
2409 | + <title>Groups Management</title> |
2410 | + <model>openerpconnector/olcore_groups</model> |
2411 | + <acl>core/store</acl> |
2412 | + <methods> |
2413 | + <list translate="title" module="core"> |
2414 | + <title>Enumerate groups</title> |
2415 | + <method>items</method> |
2416 | + </list> |
2417 | + <create translate="title" module="core"> |
2418 | + <title>Create groups</title> |
2419 | + <!--Parameters are code,name,is_default,sort_order,default_group_id,group_ids--> |
2420 | + <method>create</method> |
2421 | + </create> |
2422 | + <info translate="title" module="core"> |
2423 | + <title>Fetch detail of groups</title> |
2424 | + <method>info</method> |
2425 | + </info> |
2426 | + <update translate="title" module="core"> |
2427 | + <title>Update groups info</title> |
2428 | + <method>update</method> |
2429 | + </update> |
2430 | + <delete translate="title" module="core"> |
2431 | + <title>Delete groups</title> |
2432 | + <method>delete</method> |
2433 | + </delete> |
2434 | + </methods> |
2435 | + <faults module="core"> |
2436 | + <group_not_exists> |
2437 | + <code>101</code> |
2438 | + <message>Requested group not found.</message> |
2439 | + </group_not_exists> |
2440 | + <data_invalid> |
2441 | + <code>102</code> |
2442 | + <message>group creation failed due to invalid data.</message> |
2443 | + </data_invalid> |
2444 | + <filters_invalid> |
2445 | + <code>103</code> |
2446 | + <message>Invalid data fetch filter.</message> |
2447 | + </filters_invalid> |
2448 | + </faults> |
2449 | + </ol_groups> |
2450 | + <ol_storeviews translate="title" module="core"> |
2451 | + <title>Stores Management</title> |
2452 | + <model>openerpconnector/olcore_storeviews</model> |
2453 | + <acl>core/store</acl> |
2454 | + <methods> |
2455 | + <list translate="title" module="core"> |
2456 | + <title>Enumerate stores</title> |
2457 | + <method>items</method> |
2458 | + </list> |
2459 | + <create translate="title" module="core"> |
2460 | + <title>Create stores</title> |
2461 | + <!--Parameters are code,name,is_default,sort_order,default_group_id,group_ids--> |
2462 | + <method>create</method> |
2463 | + </create> |
2464 | + <info translate="title" module="core"> |
2465 | + <title>Fetch detail of stores</title> |
2466 | + <method>info</method> |
2467 | + </info> |
2468 | + <update translate="title" module="core"> |
2469 | + <title>Update stores info</title> |
2470 | + <method>update</method> |
2471 | + </update> |
2472 | + <delete translate="title" module="core"> |
2473 | + <title>Delete stores</title> |
2474 | + <method>delete</method> |
2475 | + </delete> |
2476 | + </methods> |
2477 | + <faults module="core"> |
2478 | + <store_not_exists> |
2479 | + <code>101</code> |
2480 | + <message>Requested store not found.</message> |
2481 | + </store_not_exists> |
2482 | + <data_invalid> |
2483 | + <code>102</code> |
2484 | + <message>Store creation failed due to invalid data.</message> |
2485 | + </data_invalid> |
2486 | + <filters_invalid> |
2487 | + <code>103</code> |
2488 | + <message>Invalid data fetch filter.</message> |
2489 | + </filters_invalid> |
2490 | + </faults> |
2491 | + </ol_storeviews> |
2492 | + <ol_catalog_category_media translate="title" module="catalog"> |
2493 | + <title>Product Images API</title> |
2494 | + <model>openerpconnector/olcatalog_categories</model> |
2495 | + <acl>catalog/category</acl> |
2496 | + <methods> |
2497 | + <list translate="title" module="catalog"> |
2498 | + <title>Retrieve product image list</title> |
2499 | + <method>items</method> |
2500 | + </list> |
2501 | + <info translate="title" module="catalog"> |
2502 | + <title>Retrieve product category image</title> |
2503 | + </info> |
2504 | + <types translate="title" module="catalog"> |
2505 | + <title>Retrieve product category image types</title> |
2506 | + </types> |
2507 | + <create translate="title" module="catalog"> |
2508 | + <title>Upload new product category image </title> |
2509 | + <acl>catalog/product/media/create</acl> |
2510 | + </create> |
2511 | + <update translate="title" module="catalog"> |
2512 | + <title>Update product category image</title> |
2513 | + <acl>catalog/product/media/update</acl> |
2514 | + </update> |
2515 | + <remove translate="title" module="catalog"> |
2516 | + <title>Remove product category image</title> |
2517 | + <acl>catalog/product/media/remove</acl> |
2518 | + </remove> |
2519 | + </methods> |
2520 | + <faults module="catalog"> |
2521 | + <create_failure> |
2522 | + <code>100</code> |
2523 | + <message>Could not create file, check permissions.</message> |
2524 | + </create_failure> |
2525 | + <category_not_exists> |
2526 | + <code>101</code> |
2527 | + <message>Product not exists.</message> |
2528 | + </category_not_exists> |
2529 | + <data_invalid> |
2530 | + <code>102</code> |
2531 | + <message>Invalid data given. Details in error message.</message> |
2532 | + </data_invalid> |
2533 | + <not_exists> |
2534 | + <code>103</code> |
2535 | + <message>Requested image not exists in product images' gallery.</message> |
2536 | + </not_exists> |
2537 | + <not_created> |
2538 | + <code>104</code> |
2539 | + <message>Image creation failed. Details in error message.</message> |
2540 | + </not_created> |
2541 | + <not_updated> |
2542 | + <code>105</code> |
2543 | + <message>Image not updated. Details in error message.</message> |
2544 | + </not_updated> |
2545 | + <not_removed> |
2546 | + <code>106</code> |
2547 | + <message>Image not removed. Details in error message.</message> |
2548 | + </not_removed> |
2549 | + <not_media> |
2550 | + <code>107</code> |
2551 | + <message>Error in opening image file</message> |
2552 | + </not_media> |
2553 | + <filters_invalid> |
2554 | + <code>108</code> |
2555 | + <message>Invalid data fetch filter.</message> |
2556 | + </filters_invalid> |
2557 | + </faults> |
2558 | + </ol_catalog_category_media> |
2559 | + <ol_catalog_product_attribute translate="title" module="catalog"> |
2560 | + <title>Product Images API</title> |
2561 | + <model>openerpconnector/olcatalog_product_attribute</model> |
2562 | + <acl>catalog/category</acl> |
2563 | + <methods> |
2564 | + <list translate="title" module="catalog"> |
2565 | + <title>Retrieve attribute list</title> |
2566 | + <method>items</method> |
2567 | + </list> |
2568 | + <relations translate="title" module="catalog"> |
2569 | + <title>Retrieve attribute sets attribute ids</title> |
2570 | + <method>relations</method> |
2571 | + </relations> |
2572 | + <info translate="title" module="catalog"> |
2573 | + <title>Retrieve full attribute details</title> |
2574 | + <method>info</method> |
2575 | + </info> |
2576 | + <options translate="title" module="catalog"> |
2577 | + <title>Retrieve options of attributes</title> |
2578 | + <method>options</method> |
2579 | + </options> |
2580 | + </methods> |
2581 | + <faults> |
2582 | + </faults> |
2583 | + </ol_catalog_product_attribute> |
2584 | + <ol_catalog_product_attribute_group translate="title" module="catalog"> |
2585 | + <title>Product Images API</title> |
2586 | + <model>openerpconnector/olcatalog_product_attributegroup</model> |
2587 | + <acl>catalog/category</acl> |
2588 | + <methods> |
2589 | + <list translate="title" module="catalog"> |
2590 | + <title>Retrieve attribute group list</title> |
2591 | + <method>items</method> |
2592 | + </list> |
2593 | + <info translate="title" module="catalog"> |
2594 | + <title>Retrieve full attribute details</title> |
2595 | + <method>info</method> |
2596 | + </info> |
2597 | + </methods> |
2598 | + <faults> |
2599 | + </faults> |
2600 | + </ol_catalog_product_attribute_group> |
2601 | + <ol_customer_groups translate="title" module="core"> |
2602 | + <title>Groups Management</title> |
2603 | + <model>openerpconnector/olcustomer_group</model> |
2604 | + <acl>customer/group</acl> |
2605 | + <methods> |
2606 | + <list translate="title" module="core"> |
2607 | + <title>Enumerate groups</title> |
2608 | + <method>items</method> |
2609 | + </list> |
2610 | + <create translate="title" module="core"> |
2611 | + <title>Create groups</title> |
2612 | + <method>create</method> |
2613 | + </create> |
2614 | + <info translate="title" module="core"> |
2615 | + <title>Fetch detail of groups</title> |
2616 | + <method>info</method> |
2617 | + </info> |
2618 | + <update translate="title" module="core"> |
2619 | + <title>Update groups info</title> |
2620 | + <method>update</method> |
2621 | + </update> |
2622 | + <delete translate="title" module="core"> |
2623 | + <title>Delete groups</title> |
2624 | + <method>delete</method> |
2625 | + </delete> |
2626 | + </methods> |
2627 | + <faults module="core"> |
2628 | + <group_not_exists> |
2629 | + <code>101</code> |
2630 | + <message>Requested group not found.</message> |
2631 | + </group_not_exists> |
2632 | + <data_invalid> |
2633 | + <code>102</code> |
2634 | + <message>group creation failed due to invalid data.</message> |
2635 | + </data_invalid> |
2636 | + <filters_invalid> |
2637 | + <code>103</code> |
2638 | + <message>Invalid data fetch filter.</message> |
2639 | + </filters_invalid> |
2640 | + </faults> |
2641 | + </ol_customer_groups> |
2642 | + <ol_customer_address translate="title" module="core"> |
2643 | + <title>Address Management</title> |
2644 | + <model>openerpconnector/olcustomer_address</model> |
2645 | + <acl>customer/group</acl> |
2646 | + <methods> |
2647 | + <list translate="title" module="core"> |
2648 | + <title>Enumerate groups</title> |
2649 | + <method>items</method> |
2650 | + </list> |
2651 | + <create translate="title" module="core"> |
2652 | + <title>Create groups</title> |
2653 | + <method>create</method> |
2654 | + </create> |
2655 | + <info translate="title" module="core"> |
2656 | + <title>Fetch detail of groups</title> |
2657 | + <method>info</method> |
2658 | + </info> |
2659 | + <update translate="title" module="core"> |
2660 | + <title>Update groups info</title> |
2661 | + <method>update</method> |
2662 | + </update> |
2663 | + <delete translate="title" module="core"> |
2664 | + <title>Delete groups</title> |
2665 | + <method>delete</method> |
2666 | + </delete> |
2667 | + </methods> |
2668 | + <faults module="core"> |
2669 | + <customer_not_exists> |
2670 | + <code>101</code> |
2671 | + <message>Requested Customer not found.</message> |
2672 | + </customer_not_exists> |
2673 | + <data_invalid> |
2674 | + <code>102</code> |
2675 | + <message>group creation failed due to invalid data.</message> |
2676 | + </data_invalid> |
2677 | + <filters_invalid> |
2678 | + <code>103</code> |
2679 | + <message>Invalid data fetch filter.</message> |
2680 | + </filters_invalid> |
2681 | + </faults> |
2682 | + </ol_customer_address> |
2683 | + <ol_customer_subscriber translate="title" module="core"> |
2684 | + <title>Subscriber Management</title> |
2685 | + <model>openerpconnector/olcustomer_subscriber</model> |
2686 | + <acl>customer/group</acl> |
2687 | + <methods> |
2688 | + <list translate="title" module="core"> |
2689 | + <title>Enumerate subscriber</title> |
2690 | + <method>items</method> |
2691 | + </list> |
2692 | + <create translate="title" module="core"> |
2693 | + <title>Create subscriber</title> |
2694 | + <method>create</method> |
2695 | + </create> |
2696 | + <info translate="title" module="core"> |
2697 | + <title>Fetch detail of subscriber</title> |
2698 | + <method>info</method> |
2699 | + </info> |
2700 | + <update translate="title" module="core"> |
2701 | + <title>Update subscriber info</title> |
2702 | + <method>update</method> |
2703 | + </update> |
2704 | + <delete translate="title" module="core"> |
2705 | + <title>Delete subscriber</title> |
2706 | + <method>delete</method> |
2707 | + </delete> |
2708 | + </methods> |
2709 | + <faults module="core"> |
2710 | + <customer_not_exists> |
2711 | + <code>101</code> |
2712 | + <message>Requested Customer not found.</message> |
2713 | + </customer_not_exists> |
2714 | + <data_invalid> |
2715 | + <code>102</code> |
2716 | + <message>group creation failed due to invalid data.</message> |
2717 | + </data_invalid> |
2718 | + <filters_invalid> |
2719 | + <code>103</code> |
2720 | + <message>Invalid data fetch filter.</message> |
2721 | + </filters_invalid> |
2722 | + </faults> |
2723 | + </ol_customer_subscriber> |
2724 | + <ol_customer translate="title" module="core"> |
2725 | + <title>Customers Management</title> |
2726 | + <model>openerpconnector/olcustomer_customer</model> |
2727 | + <acl>customer/group</acl> |
2728 | + <methods> |
2729 | + <list translate="title" module="core"> |
2730 | + <title>Enumerate Customers</title> |
2731 | + <method>items</method> |
2732 | + </list> |
2733 | + <create translate="title" module="core"> |
2734 | + <title>Create Customers</title> |
2735 | + <method>create</method> |
2736 | + </create> |
2737 | + <info translate="title" module="core"> |
2738 | + <title>Fetch detail of customers</title> |
2739 | + <method>info</method> |
2740 | + </info> |
2741 | + <update translate="title" module="core"> |
2742 | + <title>Update customers info</title> |
2743 | + <method>update</method> |
2744 | + </update> |
2745 | + <delete translate="title" module="core"> |
2746 | + <title>Delete customers</title> |
2747 | + <method>delete</method> |
2748 | + </delete> |
2749 | + </methods> |
2750 | + <faults module="core"> |
2751 | + <customer_not_exists> |
2752 | + <code>101</code> |
2753 | + <message>Requested customer not found.</message> |
2754 | + </customer_not_exists> |
2755 | + <data_invalid> |
2756 | + <code>102</code> |
2757 | + <message>Customer creation failed due to invalid data.</message> |
2758 | + </data_invalid> |
2759 | + <filters_invalid> |
2760 | + <code>103</code> |
2761 | + <message>Invalid data fetch filter.</message> |
2762 | + </filters_invalid> |
2763 | + </faults> |
2764 | + </ol_customer> |
2765 | + <ol_catalog_product_tierprice translate="title" module="catalog"> |
2766 | + <title>Product Tier Price API</title> |
2767 | + <model>openerpconnector/olcatalog_product_tierprice</model> |
2768 | + <acl>catalog/category</acl> |
2769 | + <methods> |
2770 | + <list translate="title" module="catalog"> |
2771 | + <title>Retrieve attribute list</title> |
2772 | + <method>items</method> |
2773 | + </list> |
2774 | + <items2 translate="title" module="catalog"> |
2775 | + <title>Retrieve attribute list</title> |
2776 | + <method>items2</method> |
2777 | + </items2> |
2778 | + </methods> |
2779 | + <faults> |
2780 | + <product_not_exists> |
2781 | + <code>101</code> |
2782 | + <message>Requested product not found.</message> |
2783 | + </product_not_exists> |
2784 | + <filters_invalid> |
2785 | + <code>103</code> |
2786 | + <message>Invalid data fetch filter.</message> |
2787 | + </filters_invalid> |
2788 | + </faults> |
2789 | + </ol_catalog_product_tierprice> |
2790 | + <ol_catalog_product translate="title" module="core"> |
2791 | + <title>Address Management</title> |
2792 | + <model>openerpconnector/olcatalog_products</model> |
2793 | + <acl>catalog/product</acl> |
2794 | + <methods> |
2795 | + <list translate="title" module="core"> |
2796 | + <title>Enumerate Products</title> |
2797 | + <method>items</method> |
2798 | + </list> |
2799 | + <create translate="title" module="core"> |
2800 | + <title>Create Products</title> |
2801 | + <method>create</method> |
2802 | + </create> |
2803 | + <biglist translate="title" module="core"> |
2804 | + <title>Fetch detail of products</title> |
2805 | + <method>biglist</method> |
2806 | + </biglist> |
2807 | + <update translate="title" module="core"> |
2808 | + <title>Update groups info</title> |
2809 | + <method>update</method> |
2810 | + </update> |
2811 | + <delete translate="title" module="core"> |
2812 | + <title>Delete groups</title> |
2813 | + <method>delete</method> |
2814 | + </delete> |
2815 | + </methods> |
2816 | + <faults module="core"> |
2817 | + <customer_not_exists> |
2818 | + <code>101</code> |
2819 | + <message>Requested Customer not found.</message> |
2820 | + </customer_not_exists> |
2821 | + <data_invalid> |
2822 | + <code>102</code> |
2823 | + <message>group creation failed due to invalid data.</message> |
2824 | + </data_invalid> |
2825 | + <filters_invalid> |
2826 | + <code>103</code> |
2827 | + <message>Invalid data fetch filter.</message> |
2828 | + </filters_invalid> |
2829 | + </faults> |
2830 | + </ol_catalog_product> |
2831 | + <ol_catalog_product_attributeset translate="title" module="core"> |
2832 | + <title>Attribute Set Management</title> |
2833 | + <model>openerpconnector/olcatalog_product_attributeset</model> |
2834 | + <acl>catalog/product</acl> |
2835 | + <methods> |
2836 | + <list translate="title" module="core"> |
2837 | + <title>Enumerate Attribute sets</title> |
2838 | + <method>items</method> |
2839 | + </list> |
2840 | + </methods> |
2841 | + <faults module="core"> |
2842 | + <customer_not_exists> |
2843 | + <code>101</code> |
2844 | + <message>Requested Customer not found.</message> |
2845 | + </customer_not_exists> |
2846 | + <data_invalid> |
2847 | + <code>102</code> |
2848 | + <message>group creation failed due to invalid data.</message> |
2849 | + </data_invalid> |
2850 | + <filters_invalid> |
2851 | + <code>103</code> |
2852 | + <message>Invalid data fetch filter.</message> |
2853 | + </filters_invalid> |
2854 | + </faults> |
2855 | + </ol_catalog_product_attributeset> |
2856 | + <sales_order translate="title" module="Openlabs_OpenERPConnector"> |
2857 | + <model>sales/order_api</model> |
2858 | + <title>Custom Sales Orders API</title> |
2859 | + <methods> |
2860 | + <retrieve translate="title" module="Openlabs_OpenERPConnector"> |
2861 | + <title>Retrieve list of orders by filters, nb max, etc...</title> |
2862 | + <method>retrieveOrders</method> |
2863 | + </retrieve> |
2864 | + <done translate="title" module="Openlabs_OpenERPConnector"> |
2865 | + <title>Set Flag to TRUE for imported orders</title> |
2866 | + <method>setFlagForOrder</method> |
2867 | + </done> |
2868 | + <get_child translate="title" module="Openlabs_OpenERPConnector"> |
2869 | + <title>get The Child of The Order Edited</title> |
2870 | + <method>getOrderChild</method> |
2871 | + </get_child> |
2872 | + <get_parent translate="title" module="Openlabs_OpenERPConnector"> |
2873 | + <title>get The Parent of the order annulated</title> |
2874 | + <method>getOrderParent</method> |
2875 | + </get_parent> |
2876 | + </methods> |
2877 | + </sales_order> |
2878 | + <catalog_product translate="title" module="catalog"> |
2879 | + <title>Product API</title> |
2880 | + <model>catalog/product_api</model> |
2881 | + <acl>catalog/product</acl> |
2882 | + <methods> |
2883 | + <create_bundle translate="title" module="Openlabs_OpenERPConnector"> |
2884 | + <title>Create Bundle Products with Custom Options and Bundle Items</title> |
2885 | + <method>createBundleProducts</method> |
2886 | + </create_bundle> |
2887 | + </methods> |
2888 | + </catalog_product> |
2889 | + </resources> |
2890 | + </api> |
2891 | +</config> |
2892 | |
2893 | === added file 'Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/etc/config.xml' |
2894 | --- Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/etc/config.xml 1970-01-01 00:00:00 +0000 |
2895 | +++ Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/etc/config.xml 2011-11-09 09:54:26 +0000 |
2896 | @@ -0,0 +1,88 @@ |
2897 | +<?xml version="1.0"?> |
2898 | +<config> |
2899 | + <modules> |
2900 | + <Openlabs_OpenERPConnector> |
2901 | + <version>0.0.1</version> |
2902 | + </Openlabs_OpenERPConnector> |
2903 | + </modules> |
2904 | + <frontend> |
2905 | + <routers> |
2906 | + <openerpconnector> |
2907 | + <use>standard</use> |
2908 | + <args> |
2909 | + <module>Openlabs_OpenERPConnector</module> |
2910 | + <frontName>openerpconnector</frontName> |
2911 | + </args> |
2912 | + </openerpconnector> |
2913 | + </routers> |
2914 | + </frontend> |
2915 | + <global> |
2916 | + <models> |
2917 | + <openerpconnector> |
2918 | + <class>Openlabs_OpenERPConnector_Model</class> |
2919 | + </openerpconnector> |
2920 | + <sales> |
2921 | + <rewrite> |
2922 | + <order_api>Openlabs_OpenERPConnector_Model_Sales_Order_Api</order_api> |
2923 | + </rewrite> |
2924 | + </sales> |
2925 | + <catalog> |
2926 | + <rewrite> |
2927 | + <product_api>Openlabs_OpenERPConnector_Model_Catalog_Product_Api</product_api> |
2928 | + </rewrite> |
2929 | + </catalog> |
2930 | + </models> |
2931 | + <resources> |
2932 | + <openerpconnector_setup> |
2933 | + <setup> |
2934 | + <module>Openlabs_OpenERPConnector</module> |
2935 | + </setup> |
2936 | + <connection> |
2937 | + <use>core_setup</use> |
2938 | + </connection> |
2939 | + </openerpconnector_setup> |
2940 | + <openerpconnector_write> |
2941 | + <connection> |
2942 | + <use>core_write</use> |
2943 | + </connection> |
2944 | + </openerpconnector_write> |
2945 | + <openerpconnector_read> |
2946 | + <connection> |
2947 | + <use>core_read</use> |
2948 | + </connection> |
2949 | + </openerpconnector_read> |
2950 | + </resources> |
2951 | + <blocks> |
2952 | + <openerpconnector> |
2953 | + <class>Openlabs_OpenERPConnector_Block</class> |
2954 | + </openerpconnector> |
2955 | + </blocks> |
2956 | + <helpers> |
2957 | + <openerpconnector> |
2958 | + <class>Openlabs_OpenERPConnector_Helper</class> |
2959 | + </openerpconnector> |
2960 | + </helpers> |
2961 | + <events> |
2962 | + <sales_order_place_after> |
2963 | + <observers> |
2964 | + <init_imported_after_place_order> |
2965 | + <type>singleton</type> |
2966 | + <class>openerpconnector/observer</class> |
2967 | + <method>initImported</method> |
2968 | + </init_imported_after_place_order> |
2969 | + </observers> |
2970 | + </sales_order_place_after> |
2971 | + </events> |
2972 | + </global> |
2973 | + <admin> |
2974 | + <routers> |
2975 | + <openerpconnector> |
2976 | + <use>admin</use> |
2977 | + <args> |
2978 | + <module>Openlabs_OpenERPConnector</module> |
2979 | + <frontName>connector</frontName> |
2980 | + </args> |
2981 | + </openerpconnector> |
2982 | + </routers> |
2983 | + </admin> |
2984 | +</config> |
2985 | \ No newline at end of file |
2986 | |
2987 | === added directory 'Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/sql' |
2988 | === added directory 'Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/sql/openerpconnector_setup' |
2989 | === added file 'Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/sql/openerpconnector_setup/mysql4-install-0.0.1.php' |
2990 | --- Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/sql/openerpconnector_setup/mysql4-install-0.0.1.php 1970-01-01 00:00:00 +0000 |
2991 | +++ Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/sql/openerpconnector_setup/mysql4-install-0.0.1.php 2011-11-09 09:54:26 +0000 |
2992 | @@ -0,0 +1,54 @@ |
2993 | +<?php |
2994 | +/** |
2995 | + * |
2996 | + * @author Mohammed NAHHAS |
2997 | + * @package Openlabs_OpenERPConnector |
2998 | + * |
2999 | + */ |
3000 | + |
3001 | +/* Retrieve the version of Magento */ |
3002 | +$version = Mage::getVersion(); |
3003 | + |
3004 | +/* Need to add a sales_order attribute if the version < 1.4.x.x - sales_order is an EAV Model */ |
3005 | +/* Else add a simple column to sales_flat_order Table */ |
3006 | +$version = str_replace('.','',$version); |
3007 | +if($version >= 1400) { |
3008 | + $installer = $this; |
3009 | + $installer->startSetup(); |
3010 | + $tableName='sales_flat_order'; |
3011 | + $db = $installer->getConnection(); |
3012 | + |
3013 | + /* Delete the column if it exists before re-create it */ |
3014 | + if($db->tableColumnExists($this->getTable($tableName), 'imported')) { |
3015 | + $installer->run("ALTER TABLE {$this->getTable($tableName)} drop column imported"); |
3016 | + } |
3017 | + |
3018 | + /* re-create 'imported' column */ |
3019 | + if(!$db->tableColumnExists($this->getTable($tableName), 'imported')) { |
3020 | + $installer->run(" |
3021 | + ALTER TABLE {$this->getTable($tableName)} ADD imported tinyint(1) unsigned NOT NULL default '0'; |
3022 | + "); |
3023 | + } |
3024 | +}else{ |
3025 | + $installer = new Mage_Eav_Model_Entity_Setup('core_setup'); |
3026 | + $installer->startSetup(); |
3027 | + |
3028 | + /* Attribute Data */ |
3029 | + $attribute_data = array( |
3030 | + 'type' => 'int', |
3031 | + 'default' => 0, |
3032 | + 'visible' => false, |
3033 | + 'required' => false, |
3034 | + 'user_defined' => false, |
3035 | + 'searchable' => false, |
3036 | + 'filterable' => false, |
3037 | + 'comparable' => false |
3038 | + ); |
3039 | + /* Add a sales_order attribute named 'imported' */ |
3040 | + $installer->addAttribute('order', 'imported', $attribute_data); |
3041 | + |
3042 | +} |
3043 | + |
3044 | + |
3045 | +/* End */ |
3046 | +$installer->endSetup(); |
3047 | \ No newline at end of file |
3048 | |
3049 | === added directory 'Openlabs_OpenERPConnector-1.1.0/app' |
3050 | === added directory 'Openlabs_OpenERPConnector-1.1.0/app/etc' |
3051 | === added directory 'Openlabs_OpenERPConnector-1.1.0/app/etc/modules' |
3052 | === added file 'Openlabs_OpenERPConnector-1.1.0/app/etc/modules/Openlabs_OpenERPConnector.xml' |
3053 | --- Openlabs_OpenERPConnector-1.1.0/app/etc/modules/Openlabs_OpenERPConnector.xml 1970-01-01 00:00:00 +0000 |
3054 | +++ Openlabs_OpenERPConnector-1.1.0/app/etc/modules/Openlabs_OpenERPConnector.xml 2011-11-09 09:54:26 +0000 |
3055 | @@ -0,0 +1,41 @@ |
3056 | +<?xml version="1.0"?> |
3057 | + |
3058 | +<!-- |
3059 | +############################################################################## |
3060 | +# |
3061 | +# OpenERP, Open Source Management Solution |
3062 | +# Copyright (C) 2004-2008 Tiny SPRL (<http://tiny.be>). All Rights Reserved |
3063 | +# Sharoon Thomas |
3064 | +# |
3065 | +# This program is free software: you can redistribute it and/or modify |
3066 | +# it under the terms of the GNU General Public License as published by |
3067 | +# the Free Software Foundation, either version 3 of the License, or |
3068 | +# (at your option) any later version. |
3069 | +# |
3070 | +# This program is distributed in the hope that it will be useful, |
3071 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
3072 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3073 | +# GNU General Public License for more details. |
3074 | +# |
3075 | +# You should have received a copy of the GNU General Public License |
3076 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
3077 | +# |
3078 | +############################################################################## |
3079 | +# * @category Community |
3080 | +# * @package |
3081 | +# * @copyright Copyright (c) 2009 Sharoon Thomas, openlabs.co.in |
3082 | +# * @license GPL-3 |
3083 | +# */ |
3084 | +--> |
3085 | +<config> |
3086 | + <modules> |
3087 | + <Openlabs_OpenERPConnector> |
3088 | + <codePool>community</codePool> |
3089 | + <active>true</active> |
3090 | + <depends> |
3091 | + <Mage_Api /> |
3092 | + <Mage_Catalog /> |
3093 | + </depends> |
3094 | + </Openlabs_OpenERPConnector> |
3095 | + </modules> |
3096 | +</config> |
3097 | |
3098 | === added file 'package.xml' |
3099 | --- package.xml 1970-01-01 00:00:00 +0000 |
3100 | +++ package.xml 2011-11-09 09:54:26 +0000 |
3101 | @@ -0,0 +1,84 @@ |
3102 | +<?xml version="1.0" encoding="UTF-8"?> |
3103 | +<package packagerversion="1.7.1" version="2.0" xmlns="http://pear.php.net/dtd/package-2.0" xmlns:tasks="http://pear.php.net/dtd/tasks-1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://pear.php.net/dtd/tasks-1.0 |
3104 | + http://pear.php.net/dtd/tasks-1.0.xsd |
3105 | + http://pear.php.net/dtd/package-2.0 |
3106 | + http://pear.php.net/dtd/package-2.0.xsd"> |
3107 | + <name>Openlabs_OpenERPConnector</name> |
3108 | + <channel>connect.magentocommerce.com/community</channel> |
3109 | + <summary>Magento extension for multiwebsite Open ERP connector by Open Labs</summary> |
3110 | + <description>This magento extension provides additional API methods for use by the Multi website, Multi Store, Multi Product category synchronization connector. |
3111 | + |
3112 | +Contents: |
3113 | + |
3114 | +Magento Websites API |
3115 | +Magento Stores(groups) API |
3116 | +Magento Store Views API |
3117 | +Magento Category Images API (Partial : list, info, create) |
3118 | + |
3119 | +Contact sharoon.thomas@openlabs.co.in for further details</description> |
3120 | + <lead> |
3121 | + <name>Sharoon Thomas</name> |
3122 | + <user>sharoonthomas</user> |
3123 | + <email>sharoonthomas@teagarden.in</email> |
3124 | + <active>yes</active> |
3125 | + </lead> |
3126 | + <date>2009-08-27</date> |
3127 | + <time>15:23:56</time> |
3128 | + <version> |
3129 | + <release>1.1.0</release> |
3130 | + <api>2.0</api> |
3131 | + </version> |
3132 | + <stability> |
3133 | + <release>beta</release> |
3134 | + <api>beta</api> |
3135 | + </stability> |
3136 | + <license>GPL</license> |
3137 | + <notes>Magento Websites API |
3138 | +Magento Stores(groups) API |
3139 | +Magento Store Views API |
3140 | +Magento Category Images API</notes> |
3141 | + <contents> |
3142 | + <dir name="/"> |
3143 | + <dir name="app"> |
3144 | + <dir name="etc"> |
3145 | + <dir name="modules"> |
3146 | + <file md5sum="fc14d089cce44cc1e2ac08fa6c6c20a6" name="Openlabs_OpenERPConnector.xml" role="mage" /> |
3147 | + </dir> <!-- /app/etc/modules --> |
3148 | + </dir> <!-- /app/etc --> |
3149 | + </dir> <!-- /app --> |
3150 | + <dir name="Openlabs"> |
3151 | + <dir name="OpenERPConnector"> |
3152 | + <dir name="etc"> |
3153 | + <file md5sum="12668c63dc2e626940c5651510acdd95" name="api.xml" role="magecommunity" /> |
3154 | + <file md5sum="c9ab22309066dc8d181061a0f158dc6f" name="config.xml" role="magecommunity" /> |
3155 | + </dir> <!-- /Openlabs/OpenERPConnector/etc --> |
3156 | + <dir name="Helper"> |
3157 | + <file md5sum="a2ea05cfc56bcd06be442f75844e3fc1" name="Data.php" role="magecommunity" /> |
3158 | + </dir> <!-- /Openlabs/OpenERPConnector/Helper --> |
3159 | + <dir name="Model"> |
3160 | + <dir name="Olcatalog"> |
3161 | + <file md5sum="43c11c180f0f1ccfc576bb0d8b238015" name="Categories.php" role="magecommunity" /> |
3162 | + </dir> <!-- /Openlabs/OpenERPConnector/Model/Olcatalog --> |
3163 | + <dir name="Olcore"> |
3164 | + <file md5sum="568a59414cd61bb14dd9899bd3d74edc" name="Groups.php" role="magecommunity" /> |
3165 | + <file md5sum="03e476e465b5794d8deee99fd027d35c" name="Storeviews.php" role="magecommunity" /> |
3166 | + <file md5sum="5abd4c8db3b68b4dfd5bdd7ebbb7ec93" name="Website.php" role="magecommunity" /> |
3167 | + </dir> <!-- /Openlabs/OpenERPConnector/Model/Olcore --> |
3168 | + </dir> <!-- /Openlabs/OpenERPConnector/Model --> |
3169 | + </dir> <!-- /Openlabs/OpenERPConnector --> |
3170 | + </dir> <!-- /Openlabs --> |
3171 | + </dir> <!-- / --> |
3172 | + </contents> |
3173 | + <dependencies> |
3174 | + <required> |
3175 | + <php> |
3176 | + <min>5.2.0</min> |
3177 | + <max>6.0.0</max> |
3178 | + </php> |
3179 | + <pearinstaller> |
3180 | + <min>1.6.2</min> |
3181 | + </pearinstaller> |
3182 | + </required> |
3183 | + </dependencies> |
3184 | + <phprelease /> |
3185 | +</package> |
Hello,
This merge proposal is invalid as this branch must be merged into lp:magentoerpconnect/magento-module (Magento module) and not into lp:magentoerpconnect (OpenERP module).
Also, the reviewer of lp:magentoerpconnect/magento-module is Sharoon Thomas and not the "MagentoERPConnect core Editors" Team.
A merge proposal is currently pending on this branch on the behalf of Mohammed Nahhas as requestor and of Sharoon Thomas as reviewer : https:/ /code.launchpad .net/~mohammed- nahhas/ magentoerpconne ct/magento- module- dev/+merge/ 63859