Merge lp:magentoerpconnect/magento-module-oerp6.x-stable into lp:magentoerpconnect
- module-magento-trunk
- Merge into 7.0
Status: | Rejected |
---|---|
Rejected by: | Guewen Baconnier @ Camptocamp |
Proposed branch: | lp:magentoerpconnect/magento-module-oerp6.x-stable |
Merge into: | lp:magentoerpconnect |
Diff against target: |
3969 lines (+3801/-0) 27 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/Oerpcatalog/Category/Api.php (+91/-0) Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Oerpstock/Item/Api.php (+75/-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/Link.php (+277/-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 (+325/-0) Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcore/Groups.php (+167/-0) Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcore/Storeviews.php (+167/-0) Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcore/Website.php (+195/-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 (+182/-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 (+187/-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 (+630/-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:magentoerpconnect/magento-module-oerp6.x-stable |
Related bugs: | |
Related blueprints: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
MagentoERPConnect core editors | Pending | ||
Review via email: mp+177738@code.launchpad.net |
Commit message
Description of the change
Guewen Baconnier @ Camptocamp (gbaconnier-c2c) wrote : | # |
Unmerged revisions
- 42. By Guewen Baconnier @ Camptocamp
-
Merge from magento-
module- catalog- manager Add better methods for attributes (update option, addOption returns the id of
the option, ...). - 41. By Katja Matthes
-
Add missing code for older magento versions. Needed for inventory synchonization.
- 40. By Guewen Baconnier @ Camptocamp
-
Fix previous commit: event declared at the wrong place (last commit and this one are courtesy of Alexandre Khayrullin)
- 39. By Guewen Baconnier @ Camptocamp
-
add bundle informations in ol_catalog_
product. info - 38. By Guewen Baconnier @ Camptocamp
-
[ADD] search method on product categories
- 37. By Guewen Baconnier @ Camptocamp
-
[ADD] ol_storeviews.
search and ol_groups.search: returns list of ids, including admin ones with ids '0' - 36. By Guewen Baconnier @ Camptocamp
-
[ADD] ol_website.search: must be used because ol_website.info and list do not return the website '0'
- 35. By Sébastien BEAU - http://www.akretion.com
-
[IMP] add two new webservice oerp_catalog_
category (move) and oerp_catalog_ inventory (update, massive_update) - 34. By Sébastien BEAU - http://www.akretion.com
-
[CLEAN] clean syntax code, removing useless space and replacing tab per 4 spaces
- 33. By Sébastien BEAU - http://www.akretion.com
-
[IMP] adding method to retrieve invoice and shipment ids from the order
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 2013-07-31 04:42:30 +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 2013-07-31 04:42:30 +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 2013-07-31 04:42:30 +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/Oerpcatalog' |
137 | === added directory 'Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Oerpcatalog/Category' |
138 | === added file 'Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Oerpcatalog/Category/Api.php' |
139 | --- Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Oerpcatalog/Category/Api.php 1970-01-01 00:00:00 +0000 |
140 | +++ Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Oerpcatalog/Category/Api.php 2013-07-31 04:42:30 +0000 |
141 | @@ -0,0 +1,91 @@ |
142 | +<?php |
143 | + |
144 | +# -*- encoding: utf-8 -*- |
145 | +############################################################################### |
146 | +# |
147 | +# Webservice extension for Magento |
148 | +# Copyright (C) 2012-TODAY Akretion <http://www.akretion.com>. All Rights Reserved |
149 | +# @author Sébastien BEAU <sebastien.beau@akretion.com> |
150 | +# This program is free software: you can redistribute it and/or modify |
151 | +# it under the terms of the GNU Affero General Public License as |
152 | +# published by the Free Software Foundation, either version 3 of the |
153 | +# License, or (at your option) any later version. |
154 | +# |
155 | +# This program is distributed in the hope that it will be useful, |
156 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
157 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
158 | +# GNU Affero General Public License for more details. |
159 | +# |
160 | +# You should have received a copy of the GNU Affero General Public License |
161 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
162 | +# |
163 | +############################################################################### |
164 | + |
165 | +class Openlabs_OpenERPConnector_Model_Oerpcatalog_category_api extends Mage_Catalog_Model_Category_Api |
166 | +{ |
167 | + |
168 | + /** |
169 | + * Return the list of products category ids |
170 | + * |
171 | + * @param array $filters |
172 | + * @param string|int $store |
173 | + * @return array |
174 | + */ |
175 | + public function search($filters = null, $store = null) |
176 | + { |
177 | + $collection = Mage::getModel('catalog/category')->getCollection() |
178 | + ->setStoreId($this->_getStoreId($store)) |
179 | + ->addAttributeToSelect('name'); |
180 | + |
181 | + if (is_array($filters)) { |
182 | + try { |
183 | + foreach ($filters as $field => $value) { |
184 | + if (isset($this->_filtersMap[$field])) { |
185 | + $field = $this->_filtersMap[$field]; |
186 | + } |
187 | + |
188 | + $collection->addFieldToFilter($field, $value); |
189 | + } |
190 | + } catch (Mage_Core_Exception $e) { |
191 | + $this->_fault('filters_invalid', $e->getMessage()); |
192 | + } |
193 | + } |
194 | + |
195 | + $result = array(); |
196 | + |
197 | + foreach ($collection as $product) { |
198 | + $result[] = $product->getId(); |
199 | + } |
200 | + |
201 | + return $result; |
202 | + } |
203 | + |
204 | + public function move($categoryId, $parentId, $afterId = null) |
205 | + { |
206 | + $category = $this->_initCategory($categoryId); |
207 | + $parent_category = $this->_initCategory($parentId); |
208 | + |
209 | + $parentChildren = $parent_category->getChildren(); |
210 | + $child = explode(',', $parentChildren); |
211 | + // TODO Improve speed when using $afterId |
212 | + if (!in_array($categoryId, $child) || $afterId != null) { |
213 | + // if $afterId is null - move category to the down |
214 | + if ($afterId === null && $parent_category->hasChildren()) { |
215 | + |
216 | + $afterId = array_pop($child); |
217 | + } |
218 | + |
219 | + if( strpos($parent_category->getPath(), $category->getPath()) === 0) { |
220 | + $this->_fault('not_moved', "Operation do not allow to move a parent category to any of children category"); |
221 | + } |
222 | + |
223 | + try { |
224 | + $category->move($parentId, $afterId); |
225 | + } catch (Mage_Core_Exception $e) { |
226 | + $this->_fault('not_moved', $e->getMessage()); |
227 | + } |
228 | + } |
229 | + return true; |
230 | + } |
231 | + |
232 | +} |
233 | |
234 | === added directory 'Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Oerpstock' |
235 | === added directory 'Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Oerpstock/Item' |
236 | === added file 'Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Oerpstock/Item/Api.php' |
237 | --- Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Oerpstock/Item/Api.php 1970-01-01 00:00:00 +0000 |
238 | +++ Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Oerpstock/Item/Api.php 2013-07-31 04:42:30 +0000 |
239 | @@ -0,0 +1,75 @@ |
240 | +<?php |
241 | + |
242 | +# -*- encoding: utf-8 -*- |
243 | +############################################################################### |
244 | +# |
245 | +# Webservice extension for Magento |
246 | +# Copyright (C) 2012-TODAY Akretion <http://www.akretion.com>. All Rights Reserved |
247 | +# @author Sébastien BEAU <sebastien.beau@akretion.com> |
248 | +# This program is free software: you can redistribute it and/or modify |
249 | +# it under the terms of the GNU Affero General Public License as |
250 | +# published by the Free Software Foundation, either version 3 of the |
251 | +# License, or (at your option) any later version. |
252 | +# |
253 | +# This program is distributed in the hope that it will be useful, |
254 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
255 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
256 | +# GNU Affero General Public License for more details. |
257 | +# |
258 | +# You should have received a copy of the GNU Affero General Public License |
259 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
260 | +# |
261 | +############################################################################### |
262 | + |
263 | +/* Inspired from http://www.sonassi.com/knowledge-base/magento-kb/mass-update-stock-levels-in-magento-fast/ |
264 | +*/ |
265 | + |
266 | +class Openlabs_OpenERPConnector_Model_Oerpstock_item_api extends Mage_CatalogInventory_Model_Stock_Item_Api |
267 | +{ |
268 | + |
269 | + protected function _getProduct($productId, $store = null, $identifierType = 'id') |
270 | + { |
271 | + $product = Mage::helper('catalog/product')->getProduct($productId, $this->_getStoreId($store), $identifierType); |
272 | + if (is_null($product->getId())) { |
273 | + $this->_fault('product_not_exists'); |
274 | + } |
275 | + return $product; |
276 | + } |
277 | + |
278 | + protected function _updateStock($productId, $data) |
279 | + { |
280 | + // test if product exist |
281 | + $product = $this->_getProduct($productId); |
282 | + |
283 | + $stockItem = Mage::getModel('cataloginventory/stock_item')->loadByProduct($productId); |
284 | + $stockItemId = $stockItem->getId(); |
285 | + |
286 | + if (!$stockItemId) { |
287 | + $stockItem->setData('product_id', $productId); |
288 | + $stockItem->setData('stock_id', 1); |
289 | + } else { |
290 | + $stock = $stockItem->getData(); |
291 | + } |
292 | + |
293 | + foreach($data as $field=>$value) { |
294 | + $stockItem->setData($field, $value?$value:0); |
295 | + } |
296 | + |
297 | + $stockItem->save(); |
298 | + return true; |
299 | + } |
300 | + |
301 | + public function update($productId, $data) |
302 | + { |
303 | + return $this->_updateStock($productId, $data); |
304 | + } |
305 | + |
306 | + public function massive_update($datas) |
307 | + { |
308 | + foreach($datas as $productId=>$data) { |
309 | + $this->_updateStock($productId, $data); |
310 | + } |
311 | + return true; |
312 | + } |
313 | + |
314 | +} // Class Mage_CatalogInventory_Model_Stock_Item_Api End |
315 | |
316 | === added directory 'Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcatalog' |
317 | === added file 'Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcatalog/Categories.php' |
318 | --- Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcatalog/Categories.php 1970-01-01 00:00:00 +0000 |
319 | +++ Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcatalog/Categories.php 2013-07-31 04:42:30 +0000 |
320 | @@ -0,0 +1,111 @@ |
321 | +<?php |
322 | + |
323 | + |
324 | +/** |
325 | + * @author Sharoon Thomas |
326 | + * Inspired from Dieter's Magento Extender |
327 | + * @copyright 2009 |
328 | + */ |
329 | + |
330 | +class Openlabs_OpenERPConnector_Model_Olcatalog_Categories extends Mage_Catalog_Model_Api_Resource |
331 | +{ |
332 | + public function items($filters = null) { |
333 | + try { |
334 | + $collection = Mage :: getModel('catalog/category/attribute')->getCollection()->addAttributeToSelect('image'); |
335 | + } catch (Mage_Core_Exception $e) { |
336 | + $this->_fault('category_not_exists'); |
337 | + } |
338 | + if (is_array($filters)) { |
339 | + try { |
340 | + foreach ($filters as $field => $value) { |
341 | + $collection->addFieldToFilter($field, $value); |
342 | + } |
343 | + } catch (Mage_Core_Exception $e) { |
344 | + $this->_fault('filters_invalid', $e->getMessage()); |
345 | + // If we are adding filter on non-existent attribute |
346 | + } |
347 | + } |
348 | + $result = array (); |
349 | + foreach ($collection as $category) { |
350 | + //$result[] = $customer->toArray(); |
351 | + $result[] = array ( |
352 | + 'category_id' => $category->getId(), |
353 | + 'image' => $category->getImage(), |
354 | + ); |
355 | + } |
356 | + return $result; |
357 | + } |
358 | + |
359 | + public function info($categoryId = null) { |
360 | + if (is_numeric($categoryId)) { |
361 | + try { |
362 | + $collection = Mage :: getModel('catalog/category/attribute')->load($categoryId)->getCollection()->addAttributeToSelect('image'); |
363 | + $result = array (); |
364 | + foreach ($collection as $category) { |
365 | + //$result[] = $customer->toArray(); |
366 | + if ($category->getId() == $categoryId) { |
367 | + $image = $category->getImage(); |
368 | + if ($image) { |
369 | + $path = Mage :: getBaseDir('media') . DS . 'catalog' . DS . 'category' . DS; |
370 | + $fullpath = $path . $image; |
371 | + try { |
372 | + $fp = fopen($fullpath, "rb"); |
373 | + $imagebin = fread($fp, filesize($fullpath)); |
374 | + $img_data = base64_encode($imagebin); |
375 | + fclose($fp); |
376 | + } catch (Exception $e) { |
377 | + $this->_fault('not_media'); |
378 | + } |
379 | + } |
380 | + $result[] = array ( |
381 | + 'category_id' => $category->getId(), |
382 | + 'image' => $category->getImage(), |
383 | + 'image_data' => $img_data |
384 | + ); |
385 | + } |
386 | + } |
387 | + |
388 | + return $result; |
389 | + |
390 | + } catch (Mage_Core_Exception $e) { |
391 | + $this->_fault('group_not_exists'); |
392 | + } |
393 | + |
394 | + } |
395 | + |
396 | + } |
397 | + |
398 | +public function create($filename,$imgdata) { |
399 | + if ($filename) |
400 | + { |
401 | + $path = Mage :: getBaseDir('media') . DS . 'catalog' . DS . 'category' . DS; |
402 | + $fullpath = $path . $filename; |
403 | + try |
404 | + { |
405 | + $fp = fopen($fullpath, "w"); |
406 | + if ($fp==false) |
407 | + { |
408 | + return "Error in file creation"; |
409 | + } |
410 | + $img_data = base64_decode($imgdata); |
411 | + $imagebin = fwrite($fp,$img_data); |
412 | + fclose($fp); |
413 | + return $imagebin; |
414 | + } |
415 | + catch (Exception $e) |
416 | + { |
417 | + $this->_fault('not_created'); |
418 | + } |
419 | + return False; |
420 | + } |
421 | +} |
422 | +public function update($something=null) |
423 | +{ |
424 | + return "Not implemented yet"; |
425 | +} |
426 | +public function remove($something=null) |
427 | +{ |
428 | + return "Not implemented yet"; |
429 | +} |
430 | +} |
431 | +?> |
432 | |
433 | === added directory 'Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcatalog/Product' |
434 | === added file 'Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcatalog/Product/Attribute.php' |
435 | --- Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcatalog/Product/Attribute.php 1970-01-01 00:00:00 +0000 |
436 | +++ Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcatalog/Product/Attribute.php 2013-07-31 04:42:30 +0000 |
437 | @@ -0,0 +1,109 @@ |
438 | +<?php |
439 | + |
440 | + |
441 | +/** |
442 | + * @author Sharoon Thomas |
443 | + * Inspired from Dieter's Magento Extender |
444 | + * @copyright 2009 |
445 | + */ |
446 | + |
447 | +class Openlabs_OpenERPConnector_Model_Olcatalog_Product_Attribute extends Mage_Catalog_Model_Api_Resource { |
448 | + public function __construct() { |
449 | + $this->_storeIdSessionField = 'product_store_id'; |
450 | + $this->_ignoredAttributeCodes[] = 'type_id'; |
451 | + $this->_ignoredAttributeTypes[] = 'gallery'; |
452 | + $this->_ignoredAttributeTypes[] = 'media_image'; |
453 | + } |
454 | + |
455 | + /** |
456 | + * Retrieve attributes from specified attribute set |
457 | + * |
458 | + * @param int $setId |
459 | + * @return array |
460 | + */ |
461 | + public function relations($setId){ |
462 | + $attributes = Mage :: getModel('catalog/product')->getResource()->loadAllAttributes()->getSortedAttributes($setId); |
463 | + $result = array (); |
464 | + foreach ($attributes as $attribute){ |
465 | + $result[] = Array( |
466 | + 'attribute_id' => $attribute->getId() |
467 | + ); |
468 | + } |
469 | + return $result; |
470 | + |
471 | + } |
472 | + public function items($setId) { |
473 | + $attributes = Mage :: getModel('catalog/product')->getResource()->loadAllAttributes()->getSortedAttributes($setId); |
474 | + $result = array (); |
475 | + |
476 | + foreach ($attributes as $attribute) { |
477 | + /* @var $attribute Mage_Catalog_Model_Resource_Eav_Attribute */ |
478 | + if ((!$attribute->getId() || $attribute->isInSet($setId)) && $this->_isAllowedAttribute($attribute)) { |
479 | + |
480 | + if (!$attribute->getId() || $attribute->isScopeGlobal()) { |
481 | + $scope = 'global'; |
482 | + } |
483 | + elseif ($attribute->isScopeWebsite()) { |
484 | + $scope = 'website'; |
485 | + } else { |
486 | + $scope = 'store'; |
487 | + } |
488 | + |
489 | + /*$result[] = array ( |
490 | + 'attribute_id' => $attribute->getId(), |
491 | + 'code' => $attribute->getAttributeCode(), |
492 | + 'type' => $attribute->getFrontendInput(), |
493 | + 'required' => $attribute->getIsRequired(), |
494 | + 'attributeset' => $attribute->getattribute_set_info(), |
495 | + 'scope' => $scope |
496 | + );*/ |
497 | + //Override hooray |
498 | + $attribute['scope'] = $scope; |
499 | + $result[]=$attribute->toArray(); |
500 | + } |
501 | + } |
502 | + |
503 | + return $result; |
504 | + } |
505 | + |
506 | + public function info($attributeId) { |
507 | + try { |
508 | + return 'hello'; |
509 | + $attribute = Mage :: getModel('catalog/product')->getResource()->getAttribute($attributeId); |
510 | + return $attribute->toArray(); |
511 | + } catch (Exception $e) { |
512 | + $this->_fault('not_exists'); |
513 | + } |
514 | + } |
515 | + /** |
516 | + * Retrieve attribute options |
517 | + * |
518 | + * @param int $attributeId |
519 | + * @param string|int $store |
520 | + * @return array |
521 | + */ |
522 | + public function options($attributeId, $store = null) { |
523 | + $storeId = $this->_getStoreId($store); |
524 | + $attribute = Mage :: getModel('catalog/product')->setStoreId($storeId)->getResource()->getAttribute($attributeId)->setStoreId($storeId); |
525 | + |
526 | + /* @var $attribute Mage_Catalog_Model_Entity_Attribute */ |
527 | + if (!$attribute) { |
528 | + $this->_fault('not_exists'); |
529 | + } |
530 | + |
531 | + $options = array (); |
532 | + foreach ($attribute->getSource()->getAllOptions() as $optionId => $optionValue) { |
533 | + if (is_array($optionValue)) { |
534 | + $options[] = $optionValue; |
535 | + } |
536 | + else { |
537 | + $options[] = array ( |
538 | + 'value' => $optionId, |
539 | + 'label' => $optionValue |
540 | + ); |
541 | + } |
542 | + } |
543 | + return $options; |
544 | + } |
545 | +} |
546 | +?> |
547 | |
548 | === added file 'Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcatalog/Product/Attributegroup.php' |
549 | --- Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcatalog/Product/Attributegroup.php 1970-01-01 00:00:00 +0000 |
550 | +++ Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcatalog/Product/Attributegroup.php 2013-07-31 04:42:30 +0000 |
551 | @@ -0,0 +1,167 @@ |
552 | +<?php |
553 | + |
554 | + |
555 | +/** |
556 | + * @author Sharoon Thomas |
557 | + * Inspired from Dieter's Magento Extender |
558 | + * @copyright 2009 |
559 | + */ |
560 | + |
561 | +class Openlabs_OpenERPConnector_Model_Olcatalog_Product_Attributegroup extends Mage_Catalog_Model_Api_Resource { |
562 | + public function olditems($setId = null) { |
563 | + $groups = Mage :: getModel('eav/entity_attribute_group')->getResourceCollection(); |
564 | + |
565 | + if (!is_null($setId) && !empty ($setId) && is_numeric($setId)) { |
566 | + $groups->setAttributeSetFilter($setId); |
567 | + } |
568 | + |
569 | + $groups->load(); |
570 | + |
571 | + $arrGroups = array (); |
572 | + |
573 | + foreach ($groups as $group) { |
574 | + $arrGroups[] = array ( |
575 | + 'attribute_group_id' => $group->getAttributeGroupId(), |
576 | + 'attribute_set_id' => $group->getAttributeSetId(), |
577 | + 'attribute_group_name' => $group->getAttributeGroupName(), |
578 | + 'sort_order' => $group->getSortOrder(), |
579 | + 'default_id' => $group->getDefaultId() |
580 | + ); |
581 | + } |
582 | + |
583 | + return $arrGroups; |
584 | + } |
585 | + |
586 | + public function items($filters = null) { |
587 | + try { |
588 | + $collection = Mage :: getModel('eav/entity_attribute_group')->getCollection(); |
589 | + } catch (Mage_Core_Exception $e) { |
590 | + $this->_fault('group_not_exists'); |
591 | + } |
592 | + |
593 | + if (is_array($filters)) { |
594 | + try { |
595 | + foreach ($filters as $field => $value) { |
596 | + $collection->addFieldToFilter($field, $value); |
597 | + } |
598 | + } catch (Mage_Core_Exception $e) { |
599 | + $this->_fault('filters_invalid', $e->getMessage()); |
600 | + // If we are adding filter on non-existent attribute |
601 | + } |
602 | + } |
603 | + |
604 | + $result = array (); |
605 | + foreach ($collection as $collection_item) { |
606 | + $result[] = $collection_item->toArray(); |
607 | + } |
608 | + |
609 | + return $result; |
610 | + |
611 | + } |
612 | + /* |
613 | + <param><value><string>cl19t0dqhmheafqc0ccdeejc76</string></value></param> |
614 | + <param><value><string>catalog_product_attribute_group.create</string></value></param> |
615 | + <param> |
616 | + <value> |
617 | + <array> |
618 | + <data> |
619 | + <value><i4>26</i4></value> |
620 | + <value><string>Leonelle</string></value> |
621 | + </data> |
622 | + </array> |
623 | + </value> |
624 | + </param> |
625 | + */ |
626 | + public function create($setId, array $data) { |
627 | + try { |
628 | + // $attrOption = Mage_Eav_Model_Entity_Attribute_Group |
629 | + $attrOption = Mage :: getModel("eav/entity_attribute_group"); |
630 | + |
631 | + $attrOption->addData($data); |
632 | + |
633 | + // check if there already exists a group with the give groupname |
634 | + if ($attrOption->itemExists()) { |
635 | + $this->_fault("group_already_exists"); |
636 | + } |
637 | + |
638 | + $attrOption->save(); |
639 | + |
640 | + return (int) $attrOption->getAttributeGroupId(); |
641 | + } catch (Exception $ex) { |
642 | + return false; |
643 | + } |
644 | + } |
645 | + /* |
646 | + <param><value><string>cl19t0dqhmheafqc0ccdeejc76</string></value></param> |
647 | + <param><value><string>catalog_product_attribute_group.update</string></value></param> |
648 | + <param> |
649 | + <value> |
650 | + <array> |
651 | + <data> |
652 | + <value><i4>85</i4></value> |
653 | + <value><string>Leonelle2</string></value> |
654 | + <value><i4>85</i4></value> |
655 | + <value><i4>85</i4></value> |
656 | + </data> |
657 | + </array> |
658 | + </value> |
659 | + </param> |
660 | + */ |
661 | + public function update(array $data) { |
662 | + try { |
663 | + // $attrOption = Mage_Eav_Model_Entity_Attribute_Group |
664 | + $attrOption = Mage :: getModel("eav/entity_attribute_group"); |
665 | + |
666 | + $attrOption->load($data["attribute_group_id"]); |
667 | + |
668 | + // check if the requested group exists... |
669 | + if (!$attrOption->getAttributeGroupId()) { |
670 | + $this->_fault("group_not_exists"); |
671 | + } |
672 | + |
673 | + $attrOption->addData($data); |
674 | + |
675 | + $attrOption->save(); |
676 | + |
677 | + return true; |
678 | + } catch (Exception $ex) { |
679 | + return false; |
680 | + } |
681 | + } |
682 | + |
683 | + /* |
684 | + <param><value><string>cl19t0dqhmheafqc0ccdeejc76</string></value></param> |
685 | + <param><value><string>catalog_product_attribute_group.delete</string></value></param> |
686 | + <param> |
687 | + <value> |
688 | + <array> |
689 | + <data> |
690 | + <value><i4>85</i4></value> |
691 | + </data> |
692 | + </array> |
693 | + </value> |
694 | + </param> |
695 | + */ |
696 | + public function delete($groupId) { |
697 | + try { |
698 | + // $attrOption = Mage_Eav_Model_Entity_Attribute_Group |
699 | + $attrOption = Mage :: getModel("eav/entity_attribute_group"); |
700 | + |
701 | + $attrOption->load($groupId); |
702 | + |
703 | + // check if the requested group exists... |
704 | + if (!$attrOption->getAttributeGroupId()) { |
705 | + $this->_fault("group_not_exists"); |
706 | + } |
707 | + |
708 | + // save data |
709 | + $attrOption->delete(); |
710 | + |
711 | + return true; |
712 | + } catch (Exception $ex) { |
713 | + return false; |
714 | + } |
715 | + } |
716 | + |
717 | +} |
718 | +?> |
719 | |
720 | === added file 'Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcatalog/Product/Attributeset.php' |
721 | --- Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcatalog/Product/Attributeset.php 1970-01-01 00:00:00 +0000 |
722 | +++ Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcatalog/Product/Attributeset.php 2013-07-31 04:42:30 +0000 |
723 | @@ -0,0 +1,58 @@ |
724 | +<?php |
725 | +/** |
726 | + * Magento |
727 | + * |
728 | + * NOTICE OF LICENSE |
729 | + * |
730 | + * This source file is subject to the Open Software License (OSL 3.0) |
731 | + * that is bundled with this package in the file LICENSE.txt. |
732 | + * It is also available through the world-wide-web at this URL: |
733 | + * http://opensource.org/licenses/osl-3.0.php |
734 | + * If you did not receive a copy of the license and are unable to |
735 | + * obtain it through the world-wide-web, please send an email |
736 | + * to license@magentocommerce.com so we can send you a copy immediately. |
737 | + * |
738 | + * DISCLAIMER |
739 | + * |
740 | + * Do not edit or add to this file if you wish to upgrade Magento to newer |
741 | + * versions in the future. If you wish to customize Magento for your |
742 | + * needs please refer to http://www.magentocommerce.com for more information. |
743 | + * |
744 | + * @category Mage |
745 | + * @package Mage_Catalog |
746 | + * @copyright Copyright (c) 2008 Irubin Consulting Inc. DBA Varien (http://www.varien.com) |
747 | + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) |
748 | + */ |
749 | + |
750 | +/** |
751 | + * Catalog product attribute set api |
752 | + * |
753 | + * @category Mage |
754 | + * @package Mage_Catalog |
755 | + * @author Magento Core Team <core@magentocommerce.com> |
756 | + */ |
757 | +class Openlabs_OpenERPConnector_Model_Olcatalog_Product_Attributeset extends Mage_Api_Model_Resource_Abstract |
758 | +{ |
759 | + /** |
760 | + * Retrieve attribute set list |
761 | + * |
762 | + * @return array |
763 | + */ |
764 | + public function items() |
765 | + { |
766 | + $entityType = Mage::getModel('catalog/product')->getResource()->getEntityType(); |
767 | + $collection = Mage::getResourceModel('eav/entity_attribute_set_collection') |
768 | + ->setEntityTypeFilter($entityType->getId()); |
769 | + |
770 | + $result = array(); |
771 | + foreach ($collection as $attributeSet) { |
772 | + $result[] = array( |
773 | + 'attribute_set_id' => $attributeSet->getId(), |
774 | + 'attribute_set_name' => $attributeSet->getAttributeSetName() |
775 | + ); |
776 | + |
777 | + } |
778 | + |
779 | + return $result; |
780 | + } |
781 | +} // Class Mage_Catalog_Model_Product_Attribute_Set_Api End |
782 | \ No newline at end of file |
783 | |
784 | === added file 'Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcatalog/Product/Link.php' |
785 | --- Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcatalog/Product/Link.php 1970-01-01 00:00:00 +0000 |
786 | +++ Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcatalog/Product/Link.php 2013-07-31 04:42:30 +0000 |
787 | @@ -0,0 +1,277 @@ |
788 | +<?php |
789 | + |
790 | +/** |
791 | + * @author Raimon Esteve |
792 | + * Inspired from Dieter's Magento Extender |
793 | + * @copyright 2009 |
794 | + */ |
795 | + |
796 | +class Openlabs_OpenERPConnector_Model_Olcatalog_Product_Link extends Mage_Catalog_Model_Product_Link_Api //Mage_Core_Model_Abstract |
797 | +{ |
798 | + |
799 | + /** |
800 | + * get list product_super_link |
801 | + * |
802 | + * @param int $productId |
803 | + * @return array |
804 | + */ |
805 | + public function items($productId) |
806 | + { |
807 | + $product = $this->_initProduct($productId); |
808 | + |
809 | + $childProducts=array(); |
810 | + |
811 | + //$configurableAttributes = $product->getTypeInstance()->getConfigurableAttributesAsArray(); |
812 | + |
813 | + //print_r($configurableAttributes); |
814 | + $collection = $product->getTypeInstance()->getUsedProducts();//getUsedProductCollection(); |
815 | + |
816 | + foreach($collection as $simpleProduct) |
817 | + { |
818 | + $row = $simpleProduct->toArray(); |
819 | + |
820 | + // naming convention |
821 | + $row["product_id"] = $row["entity_id"]; |
822 | + $row["type"] = $row["type_id"]; |
823 | + $row["set"] = $row["attribute_set_id"]; |
824 | + $childProducts[] = $row;// $simpleProduct->toArray(); |
825 | + } |
826 | + |
827 | + return $childProducts; |
828 | + |
829 | + return array(); |
830 | + } |
831 | + |
832 | + /** |
833 | + * set product_super_link |
834 | + * |
835 | + * @param int $productId |
836 | + * @param array $linkedProductIds |
837 | + * @param array $data |
838 | + * @return array |
839 | + */ |
840 | + public function assign($productId, $linkedProductIds, $data = array()) |
841 | + { |
842 | + $product = $this->_initProduct($productId); |
843 | + $tmpProductIds = $product->getTypeInstance()->getUsedProductIds(); |
844 | + $productIds = array(); |
845 | + |
846 | + foreach($tmpProductIds as $key => $prodId) |
847 | + { |
848 | + $productIds[$prodId] = $prodId; |
849 | + } |
850 | + |
851 | + if(is_array($linkedProductIds)) { |
852 | + foreach($linkedProductIds as $prodId) |
853 | + { |
854 | + if(!key_exists($prodId,$productIds)) {$productIds[$prodId] = $prodId;} |
855 | + } |
856 | + } elseif(is_numeric($linkedProductIds)) { |
857 | + if(!key_exists($linkedProductIds,$productIds)) {$productIds[$linkedProductIds] = $linkedProductIds;} |
858 | + } else { |
859 | + return false; |
860 | + } |
861 | + |
862 | + $product->setConfigurableProductsData($productIds); |
863 | + $product->save(); |
864 | + |
865 | + return true; |
866 | + } |
867 | + |
868 | + /** |
869 | + * remove product_super_link |
870 | + * |
871 | + * @param int $productId |
872 | + * @param array $linkedProductIds |
873 | + * @return array |
874 | + */ |
875 | + public function remove($productId, $linkedProductIds) |
876 | + { |
877 | + $product = $this->_initProduct($productId); |
878 | + $tmpProductIds = $product->getTypeInstance()->getUsedProductIds(); |
879 | + $productIds = array(); |
880 | + |
881 | + foreach($tmpProductIds as $key => $prodId) |
882 | + { |
883 | + if(is_array($linkedProductIds)) |
884 | + { |
885 | + if(!in_array($prodId, $linkedProductIds)) |
886 | + { |
887 | + |
888 | + $productIds[$prodId] = $prodId; |
889 | + } |
890 | + } |
891 | + elseif(is_numeric($linkedProductIds)) |
892 | + { |
893 | + if($prodId!=$linkedProductIds) |
894 | + { |
895 | + $productIds[$prodId] = $prodId;; |
896 | + } |
897 | + } |
898 | + } |
899 | + |
900 | + $product->setConfigurableProductsData($productIds); |
901 | + $product->save(); |
902 | + |
903 | + return true; |
904 | + } |
905 | + |
906 | + private function _getStores() |
907 | + { |
908 | + $stores = Mage::getModel('core/store') |
909 | + ->getResourceCollection() |
910 | + ->setLoadDefault(true) |
911 | + ->load(); |
912 | + return $stores; |
913 | + } |
914 | + |
915 | + /** |
916 | + * List Configurables Atributes |
917 | + * |
918 | + * @param int $productId |
919 | + * @return array |
920 | + */ |
921 | + public function listSuperAttributes($productIdOrSku) |
922 | + { |
923 | + try |
924 | + { |
925 | + // check if product Exists |
926 | + $product = $this->_initProduct($productIdOrSku); |
927 | + |
928 | + if($product->getTypeId()!="configurable") $this->_fault("not a configurable product"); |
929 | + |
930 | + $productId = $product->getEntityId(); |
931 | + |
932 | + $stores = $this->_getStores(); |
933 | + |
934 | + $superAttributes=array(); |
935 | + |
936 | + foreach($stores as $store) |
937 | + { |
938 | + $product = $product = Mage::getModel('catalog/product')->setStoreId($store->getStoreId()); |
939 | + $product->load($productId); |
940 | + $attrs = $product->getTypeInstance()->getConfigurableAttributesAsArray(); |
941 | + |
942 | + foreach($attrs as $key=>$attr) |
943 | + { |
944 | + if(!isset($superAttributes[$attr["id"]])) |
945 | + { |
946 | + $superAttributes["".$attr["id"].""] = $attr; |
947 | + $superAttributes["".$attr["id"].""]["product_id"] = $product->getEntityId(); |
948 | + $superAttributes["".$attr["id"].""]["product_super_attribute_id"] = $attr["id"]; |
949 | + unset($superAttributes["".$attr["id"].""]["id"]); |
950 | + } |
951 | + |
952 | + unset($superAttributes["".$attr["id"].""]["label"]); |
953 | + |
954 | + $superAttributes["".$attr["id"].""]["labels"][$store->getStoreId()] = $attr["label"]; |
955 | + } |
956 | + } |
957 | + //print_r($superAttributes); |
958 | + |
959 | + return array_values($superAttributes); |
960 | + } |
961 | + catch (Exception $ex) |
962 | + { |
963 | + echo $ex; |
964 | + } |
965 | + |
966 | + } |
967 | + |
968 | + /** |
969 | + * Create Configurables Atributes |
970 | + * |
971 | + * @param int $productId |
972 | + * @param int $attributeID |
973 | + * @param int position |
974 | + * @param array labels |
975 | + * @param array prices |
976 | + * @return ID |
977 | + */ |
978 | + public function createSuperAttribute($productIDorSku, $attributeID, $position, array $labels, array $prices = null) |
979 | + { |
980 | + $product = $this->_initProduct($productIDorSku); |
981 | + //$confAttributes = $product->getTypeInstance()->getUsedProductIds(); |
982 | + |
983 | + $superAttr = Mage::getModel("catalog/product_type_configurable_attribute"); |
984 | + |
985 | + $superAttr->setProductId($product->getId()); |
986 | + $superAttr->setAttributeId($attributeID); |
987 | + $superAttr->setPosition($position); |
988 | + |
989 | + if(is_string($labels)) |
990 | + { |
991 | + $superAttr->setStoreId(0); |
992 | + $superAttr->setLabel($labels); |
993 | + $superAttr->save(); |
994 | + } |
995 | + elseif(is_array($labels)) |
996 | + { |
997 | + foreach($labels as $storeID => $label) |
998 | + { |
999 | + $superAttr->setStoreId($storeID); |
1000 | + $superAttr->setLabel($label); |
1001 | + $superAttr->save(); |
1002 | + } |
1003 | + } |
1004 | + |
1005 | + if(is_array($prices)) |
1006 | + { |
1007 | + $superAttr->setValues($prices); |
1008 | + $superAttr->save(); |
1009 | + } |
1010 | + |
1011 | + return (int)$superAttr->getId(); |
1012 | + } |
1013 | + |
1014 | + /** |
1015 | + * Set Configurables Atributes |
1016 | + * |
1017 | + * @param int $product |
1018 | + * @param int $attribute |
1019 | + * @return True |
1020 | + */ |
1021 | + public function setSuperAttributeValues($product, $attribute) |
1022 | + { |
1023 | + #get if product exists |
1024 | + $product = Mage::getModel('catalog/product')->load($product)->getID(); |
1025 | + if(!$product){ |
1026 | + return False; |
1027 | + } |
1028 | + #get if attribute exists |
1029 | + $attribute = Mage::getModel('eav/config')->getAttribute('catalog_product', 'attribute_id')->load($attribute)->getID(); |
1030 | + if(!$attribute){ |
1031 | + return False; |
1032 | + } |
1033 | + |
1034 | + #try add catalog_product_super_attribute |
1035 | + try { |
1036 | + $resource = Mage::getSingleton('core/resource'); |
1037 | + $writeConnection = $resource->getConnection('core_write'); |
1038 | + $query = 'INSERT INTO '.$resource->getTableName('catalog_product_super_attribute').' (product_id, attribute_id) VALUES ('.$product.', '.$attribute.');'; |
1039 | + $writeConnection->query($query); |
1040 | + return True; |
1041 | + } catch (Exception $e) { |
1042 | + return False; |
1043 | + } |
1044 | + } |
1045 | + |
1046 | + /** |
1047 | + * Remove Configurables Atributes |
1048 | + * |
1049 | + * @param int $superAttributeID |
1050 | + * @return ID |
1051 | + */ |
1052 | + public function removeSuperAttribute($superAttributeID) |
1053 | + { |
1054 | + $superAttr = Mage::getModel("catalog/product_type_configurable_attribute"); |
1055 | + $superAttr->load($superAttributeID); |
1056 | + |
1057 | + $superAttr->delete(); |
1058 | + //$superAttr->setValues($prices); |
1059 | + //$superAttr->save(); |
1060 | + return true; |
1061 | + } |
1062 | +} |
1063 | + |
1064 | +?> |
1065 | |
1066 | === added file 'Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcatalog/Product/Tierprice.php' |
1067 | --- Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcatalog/Product/Tierprice.php 1970-01-01 00:00:00 +0000 |
1068 | +++ Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcatalog/Product/Tierprice.php 2013-07-31 04:42:30 +0000 |
1069 | @@ -0,0 +1,71 @@ |
1070 | +<?php |
1071 | + |
1072 | +/** |
1073 | + * Magento |
1074 | + * |
1075 | + * NOTICE OF LICENSE |
1076 | + * |
1077 | + * This source file is subject to the Open Software License (OSL 3.0) |
1078 | + * that is bundled with this package in the file LICENSE.txt. |
1079 | + * It is also available through the world-wide-web at this URL: |
1080 | + * http://opensource.org/licenses/osl-3.0.php |
1081 | + * If you did not receive a copy of the license and are unable to |
1082 | + * obtain it through the world-wide-web, please send an email |
1083 | + * to license@magentocommerce.com so we can send you a copy immediately. |
1084 | + * |
1085 | + * DISCLAIMER |
1086 | + * |
1087 | + * Do not edit or add to this file if you wish to upgrade Magento to newer |
1088 | + * versions in the future. If you wish to customize Magento for your |
1089 | + * needs please refer to http://www.magentocommerce.com for more information. |
1090 | + * |
1091 | + * @category Mage |
1092 | + * @package Mage_Catalog |
1093 | + * @copyright Copyright (c) 2008 Irubin Consulting Inc. DBA Varien (http://www.varien.com) |
1094 | + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) |
1095 | + */ |
1096 | + |
1097 | +/** |
1098 | + * Catalog Product tier price api |
1099 | + * |
1100 | + * @category Mage |
1101 | + * @package Mage_Catalog |
1102 | + * @author Magento Core Team <core@magentocommerce.com> |
1103 | + */ |
1104 | +class Openlabs_OpenERPConnector_Model_Olcatalog_Product_Tierprice extends Mage_Catalog_Model_Api_Resource { |
1105 | + const ATTRIBUTE_CODE = 'tier_price'; |
1106 | + |
1107 | + |
1108 | + public function items($productIds=null) { |
1109 | + if (is_array($productIds)) { |
1110 | + $result = array (); |
1111 | + foreach ($productIds as $productId) { |
1112 | + $product = Mage :: getModel('catalog/product')->load($productId); |
1113 | + if (!$product->getId()) { |
1114 | + $this->_fault('product_not_exists'); |
1115 | + } |
1116 | + $tierPrices = $product->getData(self :: ATTRIBUTE_CODE); |
1117 | + $result[$productId] = $tierPrices; |
1118 | + } |
1119 | + } |
1120 | + return $result; |
1121 | + |
1122 | + } |
1123 | + |
1124 | + public function items2($productIds=null) { |
1125 | + $product = Mage :: getModel('catalog/product_attribute_backend_tierprice')->_get_set_go(); |
1126 | + if (!$product->getId()) { |
1127 | + $this->_fault('product_not_exists'); |
1128 | + } |
1129 | + |
1130 | + $tierPrices = $product->getPriceModel()->getTierPriceCount(); |
1131 | + return 'hello'; |
1132 | + $result[$productIds] = $tierPrices; |
1133 | + |
1134 | + |
1135 | + return $result; |
1136 | + |
1137 | + |
1138 | + } |
1139 | + |
1140 | +} |
1141 | \ No newline at end of file |
1142 | |
1143 | === added file 'Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcatalog/Products.php' |
1144 | --- Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcatalog/Products.php 1970-01-01 00:00:00 +0000 |
1145 | +++ Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcatalog/Products.php 2013-07-31 04:42:30 +0000 |
1146 | @@ -0,0 +1,325 @@ |
1147 | +<?php |
1148 | + |
1149 | +class Openlabs_OpenERPConnector_Model_Olcatalog_Products extends Mage_Catalog_Model_Api_Resource |
1150 | +{ |
1151 | + protected $_filtersMap = array( |
1152 | + 'product_id' => 'entity_id', |
1153 | + 'set' => 'attribute_set_id', |
1154 | + 'type' => 'type_id' |
1155 | + ); |
1156 | + |
1157 | + public function __construct() |
1158 | + { |
1159 | + $this->_storeIdSessionField = 'product_store_id'; |
1160 | + $this->_ignoredAttributeTypes[] = 'gallery'; |
1161 | + $this->_ignoredAttributeTypes[] = 'media_image'; |
1162 | + } |
1163 | + |
1164 | + /** |
1165 | + * Return the list of products ids |
1166 | + * |
1167 | + * @param array $filters |
1168 | + * @param string|int $store |
1169 | + * @return array |
1170 | + */ |
1171 | + public function search($filters = null, $store = null) |
1172 | + { |
1173 | + $collection = Mage::getModel('catalog/product')->getCollection() |
1174 | + ->setStoreId($this->_getStoreId($store)) |
1175 | + ->addAttributeToSelect('name'); |
1176 | + |
1177 | + if (is_array($filters)) { |
1178 | + try { |
1179 | + foreach ($filters as $field => $value) { |
1180 | + if (isset($this->_filtersMap[$field])) { |
1181 | + $field = $this->_filtersMap[$field]; |
1182 | + } |
1183 | + |
1184 | + $collection->addFieldToFilter($field, $value); |
1185 | + } |
1186 | + } catch (Mage_Core_Exception $e) { |
1187 | + $this->_fault('filters_invalid', $e->getMessage()); |
1188 | + } |
1189 | + } |
1190 | + |
1191 | + $result = array(); |
1192 | + |
1193 | + foreach ($collection as $product) { |
1194 | + $result[] = $product->getId(); |
1195 | + } |
1196 | + |
1197 | + return $result; |
1198 | + } |
1199 | + |
1200 | + /** |
1201 | + * Retrieve list of products with basic info (id, sku, type, set, name) |
1202 | + * |
1203 | + * @param array $filters |
1204 | + * @param string|int $store |
1205 | + * @return array |
1206 | + */ |
1207 | + public function items($filters = null, $store = null) |
1208 | + { |
1209 | + $collection = Mage::getModel('catalog/product')->getCollection() |
1210 | + ->setStoreId($this->_getStoreId($store)) |
1211 | + ->addAttributeToSelect('name'); |
1212 | + |
1213 | + if (is_array($filters)) { |
1214 | + try { |
1215 | + foreach ($filters as $field => $value) { |
1216 | + if (isset($this->_filtersMap[$field])) { |
1217 | + $field = $this->_filtersMap[$field]; |
1218 | + } |
1219 | + |
1220 | + $collection->addFieldToFilter($field, $value); |
1221 | + } |
1222 | + } catch (Mage_Core_Exception $e) { |
1223 | + $this->_fault('filters_invalid', $e->getMessage()); |
1224 | + } |
1225 | + } |
1226 | + |
1227 | + $result = array(); |
1228 | + |
1229 | + foreach ($collection as $product) { |
1230 | +// $result[] = $product->getData(); |
1231 | + $result[] = array( // Basic product data |
1232 | + 'product_id' => $product->getId(), |
1233 | + 'sku' => $product->getSku(), |
1234 | + 'name' => $product->getName(), |
1235 | + 'set' => $product->getAttributeSetId(), |
1236 | + 'type' => $product->getTypeId(), |
1237 | + 'category_ids' => $product->getCategoryIds() |
1238 | + ); |
1239 | + } |
1240 | + |
1241 | + return $result; |
1242 | + } |
1243 | + |
1244 | + /** |
1245 | + * Retrieve product info |
1246 | + * |
1247 | + * @param int|string $productId |
1248 | + * @param string|int $store |
1249 | + * @param array $attributes |
1250 | + * @return array |
1251 | + */ |
1252 | + public function biglist($productId, $store = null, $filters = null) |
1253 | + { |
1254 | + $collection = Mage::getModel('catalog/product')->getCollection() |
1255 | + ->setStoreId($this->_getStoreId($store)) |
1256 | + ->addAttributeToSelect('name'); |
1257 | + |
1258 | + if (is_array($filters)) { |
1259 | + try { |
1260 | + foreach ($filters as $field => $value) { |
1261 | + if (isset($this->_filtersMap[$field])) { |
1262 | + $field = $this->_filtersMap[$field]; |
1263 | + } |
1264 | + |
1265 | + $collection->addFieldToFilter($field, $value); |
1266 | + } |
1267 | + } catch (Mage_Core_Exception $e) { |
1268 | + $this->_fault('filters_invalid', $e->getMessage()); |
1269 | + } |
1270 | + } |
1271 | + foreach ($collection as $product) { |
1272 | + $data = array(); |
1273 | + $data = array( // Basic product data |
1274 | + 'product_id' => $product->getId(), |
1275 | + 'sku' => $product->getSku(), |
1276 | + 'set' => $product->getAttributeSetId(), |
1277 | + 'type' => $product->getTypeId(), |
1278 | + 'categories' => $product->getCategoryIds(), |
1279 | + 'websites' => $product->getWebsiteIds() |
1280 | + ); |
1281 | + |
1282 | + foreach ($product->getTypeInstance(true)->getEditableAttributes($product) as $attribute) { |
1283 | + $data[$attribute->getAttributeCode()] = $product->getData($attribute->getAttributeCode()); |
1284 | + } |
1285 | + $result[]=$data; |
1286 | + } |
1287 | + return $result; |
1288 | + } |
1289 | + |
1290 | + /** |
1291 | + * Create new product. |
1292 | + * |
1293 | + * @param string $type |
1294 | + * @param int $set |
1295 | + * @param array $productData |
1296 | + * @return int |
1297 | + */ |
1298 | + public function create($type, $set, $sku, $productData) |
1299 | + { |
1300 | + if (!$type || !$set || !$sku) { |
1301 | + $this->_fault('data_invalid'); |
1302 | + } |
1303 | + |
1304 | + $product = Mage::getModel('catalog/product'); |
1305 | + /* @var $product Mage_Catalog_Model_Product */ |
1306 | + $product->setStoreId($this->_getStoreId($store)) |
1307 | + ->setAttributeSetId($set) |
1308 | + ->setTypeId($type) |
1309 | + ->setSku($sku); |
1310 | + |
1311 | + if (isset($productData['website_ids']) && is_array($productData['website_ids'])) { |
1312 | + $product->setWebsiteIds($productData['website_ids']); |
1313 | + } |
1314 | + |
1315 | + foreach ($product->getTypeInstance(true)->getEditableAttributes($product) as $attribute) { |
1316 | + if ($this->_isAllowedAttribute($attribute) |
1317 | + && isset($productData[$attribute->getAttributeCode()])) { |
1318 | + $product->setData( |
1319 | + $attribute->getAttributeCode(), |
1320 | + $productData[$attribute->getAttributeCode()] |
1321 | + ); |
1322 | + } |
1323 | + } |
1324 | + |
1325 | + $this->_prepareDataForSave($product, $productData); |
1326 | + |
1327 | + if (is_array($errors = $product->validate())) { |
1328 | + $this->_fault('data_invalid', implode("\n", $errors)); |
1329 | + } |
1330 | + |
1331 | + try { |
1332 | + $product->save(); |
1333 | + } catch (Mage_Core_Exception $e) { |
1334 | + $this->_fault('data_invalid', $e->getMessage()); |
1335 | + } |
1336 | + |
1337 | + return $product->getId(); |
1338 | + } |
1339 | + |
1340 | + /** |
1341 | + * Update product data |
1342 | + * |
1343 | + * @param int|string $productId |
1344 | + * @param array $productData |
1345 | + * @param string|int $store |
1346 | + * @return boolean |
1347 | + */ |
1348 | + public function update($productId, $productData = array(), $store = null) |
1349 | + { |
1350 | + $product = $this->_getProduct($productId, $store); |
1351 | + |
1352 | + if (!$product->getId()) { |
1353 | + $this->_fault('not_exists'); |
1354 | + } |
1355 | + |
1356 | + if (isset($productData['website_ids']) && is_array($productData['website_ids'])) { |
1357 | + $product->setWebsiteIds($productData['website_ids']); |
1358 | + } |
1359 | + |
1360 | + foreach ($product->getTypeInstance(true)->getEditableAttributes($product) as $attribute) { |
1361 | + if ($this->_isAllowedAttribute($attribute) |
1362 | + && isset($productData[$attribute->getAttributeCode()])) { |
1363 | + $product->setData( |
1364 | + $attribute->getAttributeCode(), |
1365 | + $productData[$attribute->getAttributeCode()] |
1366 | + ); |
1367 | + } |
1368 | + } |
1369 | + |
1370 | + $this->_prepareDataForSave($product, $productData); |
1371 | + |
1372 | + try { |
1373 | + if (is_array($errors = $product->validate())) { |
1374 | + $this->_fault('data_invalid', implode("\n", $errors)); |
1375 | + } |
1376 | + } catch (Mage_Core_Exception $e) { |
1377 | + $this->_fault('data_invalid', $e->getMessage()); |
1378 | + } |
1379 | + |
1380 | + try { |
1381 | + $product->save(); |
1382 | + } catch (Mage_Core_Exception $e) { |
1383 | + $this->_fault('data_invalid', $e->getMessage()); |
1384 | + } |
1385 | + |
1386 | + return true; |
1387 | + } |
1388 | + |
1389 | + /** |
1390 | + * Set additional data before product saved |
1391 | + * |
1392 | + * @param Mage_Catalog_Model_Product $product |
1393 | + * @param array $productData |
1394 | + * @return object |
1395 | + */ |
1396 | + protected function _prepareDataForSave ($product, $productData) |
1397 | + { |
1398 | + if (isset($productData['categories']) && is_array($productData['categories'])) { |
1399 | + $product->setCategoryIds($productData['categories']); |
1400 | + } |
1401 | + |
1402 | + if (isset($productData['websites']) && is_array($productData['websites'])) { |
1403 | + foreach ($productData['websites'] as &$website) { |
1404 | + if (is_string($website)) { |
1405 | + try { |
1406 | + $website = Mage::app()->getWebsite($website)->getId(); |
1407 | + } catch (Exception $e) { } |
1408 | + } |
1409 | + } |
1410 | + $product->setWebsiteIds($productData['websites']); |
1411 | + } |
1412 | + |
1413 | + if (isset($productData['stock_data']) && is_array($productData['stock_data'])) { |
1414 | + $product->setStockData($productData['stock_data']); |
1415 | + } |
1416 | + } |
1417 | + |
1418 | + /** |
1419 | + * Update product special price |
1420 | + * |
1421 | + * @param int|string $productId |
1422 | + * @param float $specialPrice |
1423 | + * @param string $fromDate |
1424 | + * @param string $toDate |
1425 | + * @param string|int $store |
1426 | + * @return boolean |
1427 | + */ |
1428 | + public function setSpecialPrice($productId, $specialPrice = null, $fromDate = null, $toDate = null, $store = null) |
1429 | + { |
1430 | + return $this->update($productId, array( |
1431 | + 'special_price' => $specialPrice, |
1432 | + 'special_from_date' => $fromDate, |
1433 | + 'special_to_date' => $toDate |
1434 | + ), $store); |
1435 | + } |
1436 | + |
1437 | + /** |
1438 | + * Retrieve product special price |
1439 | + * |
1440 | + * @param int|string $productId |
1441 | + * @param string|int $store |
1442 | + * @return array |
1443 | + */ |
1444 | + public function getSpecialPrice($productId, $store = null) |
1445 | + { |
1446 | + return $this->info($productId, $store, array('special_price', 'special_from_date', 'special_to_date')); |
1447 | + } |
1448 | + |
1449 | + /** |
1450 | + * Delete product |
1451 | + * |
1452 | + * @param int|string $productId |
1453 | + * @return boolean |
1454 | + */ |
1455 | + public function delete($productId) |
1456 | + { |
1457 | + $product = $this->_getProduct($productId); |
1458 | + |
1459 | + if (!$product->getId()) { |
1460 | + $this->_fault('not_exists'); |
1461 | + } |
1462 | + |
1463 | + try { |
1464 | + $product->delete(); |
1465 | + } catch (Mage_Core_Exception $e) { |
1466 | + $this->_fault('not_deleted', $e->getMessage()); |
1467 | + } |
1468 | + |
1469 | + return true; |
1470 | + } |
1471 | +} // Class Mage_Catalog_Model_Product_Api End |
1472 | \ No newline at end of file |
1473 | |
1474 | === added directory 'Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcore' |
1475 | === added file 'Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcore/Groups.php' |
1476 | --- Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcore/Groups.php 1970-01-01 00:00:00 +0000 |
1477 | +++ Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcore/Groups.php 2013-07-31 04:42:30 +0000 |
1478 | @@ -0,0 +1,167 @@ |
1479 | +<?php |
1480 | + |
1481 | +/** |
1482 | + * @author Sharoon Thomas |
1483 | + * Inspired from Dieter's Magento Extender |
1484 | + * @copyright 2009 |
1485 | + */ |
1486 | + |
1487 | +class Openlabs_OpenERPConnector_Model_Olcore_Groups extends Mage_Catalog_Model_Api_Resource |
1488 | +{ |
1489 | + |
1490 | + /** |
1491 | + * Return the list of partner ids which match the filters |
1492 | + * |
1493 | + * @param array $filters |
1494 | + * @return array |
1495 | + */ |
1496 | + public function search($filters) |
1497 | + { |
1498 | + |
1499 | + $collection = Mage::getModel('core/store_group')->getCollection(); |
1500 | + |
1501 | + if (is_array($filters)) { |
1502 | + try { |
1503 | + foreach ($filters as $field => $value) { |
1504 | + $collection->addFieldToFilter($field, $value); |
1505 | + } |
1506 | + } catch (Mage_Core_Exception $e) { |
1507 | + $this->_fault('filters_invalid', $e->getMessage()); |
1508 | + } |
1509 | + } |
1510 | + |
1511 | + return $collection->getAllIds(); |
1512 | + } |
1513 | + |
1514 | + public function items($filters=null) |
1515 | + { |
1516 | + try |
1517 | + { |
1518 | + $collection = Mage::getModel('core/store_group')->getCollection();//->addAttributeToSelect('*'); |
1519 | + } |
1520 | + catch (Mage_Core_Exception $e) |
1521 | + { |
1522 | + $this->_fault('group_not_exists'); |
1523 | + } |
1524 | + |
1525 | + if (is_array($filters)) { |
1526 | + try { |
1527 | + foreach ($filters as $field => $value) { |
1528 | + $collection->addFieldToFilter($field, $value); |
1529 | + } |
1530 | + } catch (Mage_Core_Exception $e) { |
1531 | + $this->_fault('filters_invalid', $e->getMessage()); |
1532 | + // If we are adding filter on non-existent attribute |
1533 | + } |
1534 | + } |
1535 | + |
1536 | + $result = array(); |
1537 | + foreach ($collection as $customer) { |
1538 | + $result[] = $customer->toArray(); |
1539 | + } |
1540 | + |
1541 | + return $result; |
1542 | + } |
1543 | + |
1544 | + public function info($groupIds = null) |
1545 | + { |
1546 | + $groups = array(); |
1547 | + |
1548 | + if(is_array($groupIds)) |
1549 | + { |
1550 | + foreach($groupIds as $groupId) |
1551 | + { |
1552 | + try |
1553 | + { |
1554 | + $groups[] = Mage::getModel('core/store_group')->load($groupId)->toArray(); |
1555 | + } |
1556 | + catch (Mage_Core_Exception $e) |
1557 | + { |
1558 | + $this->_fault('group_not_exists'); |
1559 | + } |
1560 | + } |
1561 | + return $groups; |
1562 | + } |
1563 | + elseif(is_numeric($groupIds)) |
1564 | + { |
1565 | + try |
1566 | + { |
1567 | + return Mage::getModel('core/store_group')->load($groupIds)->toArray(); |
1568 | + } |
1569 | + catch (Mage_Core_Exception $e) |
1570 | + { |
1571 | + $this->_fault('group_not_exists'); |
1572 | + } |
1573 | + |
1574 | + } |
1575 | + |
1576 | + } |
1577 | + |
1578 | + public function create($groupdata) |
1579 | + { |
1580 | + try |
1581 | + { |
1582 | + $group = Mage::getModel('core/store_group') |
1583 | + ->setData($groupdata) |
1584 | + ->save(); |
1585 | + |
1586 | + } |
1587 | + catch (Magento_Core_Exception $e) |
1588 | + { |
1589 | + $this->_fault('data_invalid',$e->getMessage()); |
1590 | + } |
1591 | + catch (Exception $e) |
1592 | + { |
1593 | + $this->_fault('data_invalid',$e->getMessage()); |
1594 | + } |
1595 | + return $group->getId(); |
1596 | + } |
1597 | + |
1598 | + public function update($groupid,$groupdata) |
1599 | + { |
1600 | + try |
1601 | + { |
1602 | + $group = Mage::getModel('core/store_group') |
1603 | + ->load($groupid); |
1604 | + if (!$group->getId()) |
1605 | + { |
1606 | + $this->_fault('group_not_exists'); |
1607 | + } |
1608 | + $group->addData($groupdata)->save(); |
1609 | + } |
1610 | + catch (Magento_Core_Exception $e) |
1611 | + { |
1612 | + $this->_fault('data_invalid',$e->getMessage()); |
1613 | + } |
1614 | + catch (Exception $e) |
1615 | + { |
1616 | + $this->_fault('data_invalid',$e->getMessage()); |
1617 | + } |
1618 | + return true; |
1619 | + } |
1620 | + |
1621 | + public function delete($groupid) |
1622 | + { |
1623 | + try |
1624 | + { |
1625 | + $group = Mage::getModel('core/store_group') |
1626 | + ->load($groupid); |
1627 | + if (!$group->getId()) |
1628 | + { |
1629 | + $this->_fault('group_not_exists'); |
1630 | + } |
1631 | + $group->delete(); |
1632 | + |
1633 | + } |
1634 | + catch (Magento_Core_Exception $e) |
1635 | + { |
1636 | + $this->_fault('data_invalid',$e->getMessage()); |
1637 | + } |
1638 | + catch (Exception $e) |
1639 | + { |
1640 | + $this->_fault('data_invalid',$e->getMessage()); |
1641 | + } |
1642 | + return true; |
1643 | + } |
1644 | +} |
1645 | +?> |
1646 | |
1647 | === added file 'Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcore/Storeviews.php' |
1648 | --- Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcore/Storeviews.php 1970-01-01 00:00:00 +0000 |
1649 | +++ Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcore/Storeviews.php 2013-07-31 04:42:30 +0000 |
1650 | @@ -0,0 +1,167 @@ |
1651 | +<?php |
1652 | + |
1653 | +/** |
1654 | + * @author Sharoon Thomas |
1655 | + * Inspired from Dieter's Magento Extender |
1656 | + * @copyright 2009 |
1657 | + */ |
1658 | + |
1659 | +class Openlabs_OpenERPConnector_Model_Olcore_Storeviews extends Mage_Catalog_Model_Api_Resource |
1660 | +{ |
1661 | + |
1662 | + /** |
1663 | + * Return the list of storeviews ids which match the filters |
1664 | + * |
1665 | + * @param array $filters |
1666 | + * @return array |
1667 | + */ |
1668 | + public function search($filters) |
1669 | + { |
1670 | + |
1671 | + $collection = Mage::getModel('core/store')->getCollection(); |
1672 | + |
1673 | + if (is_array($filters)) { |
1674 | + try { |
1675 | + foreach ($filters as $field => $value) { |
1676 | + $collection->addFieldToFilter($field, $value); |
1677 | + } |
1678 | + } catch (Mage_Core_Exception $e) { |
1679 | + $this->_fault('filters_invalid', $e->getMessage()); |
1680 | + } |
1681 | + } |
1682 | + |
1683 | + return $collection->getAllIds(); |
1684 | + } |
1685 | + |
1686 | + public function items($filters=null) |
1687 | + { |
1688 | + try |
1689 | + { |
1690 | + $collection = Mage::getModel('core/store')->getCollection();//->addAttributeToSelect('*'); |
1691 | + } |
1692 | + catch (Mage_Core_Exception $e) |
1693 | + { |
1694 | + $this->_fault('store_not_exists'); |
1695 | + } |
1696 | + |
1697 | + if (is_array($filters)) { |
1698 | + try { |
1699 | + foreach ($filters as $field => $value) { |
1700 | + $collection->addFieldToFilter($field, $value); |
1701 | + } |
1702 | + } catch (Mage_Core_Exception $e) { |
1703 | + $this->_fault('filters_invalid', $e->getMessage()); |
1704 | + // If we are adding filter on non-existent attribute |
1705 | + } |
1706 | + } |
1707 | + |
1708 | + $result = array(); |
1709 | + foreach ($collection as $customer) { |
1710 | + $result[] = $customer->toArray(); |
1711 | + } |
1712 | + |
1713 | + return $result; |
1714 | + } |
1715 | + |
1716 | + public function info($storeIds = null) |
1717 | + { |
1718 | + $stores = array(); |
1719 | + |
1720 | + if(is_array($storeIds)) |
1721 | + { |
1722 | + foreach($storeIds as $storeId) |
1723 | + { |
1724 | + try |
1725 | + { |
1726 | + $stores[] = Mage::getModel('core/store')->load($storeId)->toArray(); |
1727 | + } |
1728 | + catch (Mage_Core_Exception $e) |
1729 | + { |
1730 | + $this->_fault('store_not_exists'); |
1731 | + } |
1732 | + } |
1733 | + return $stores; |
1734 | + } |
1735 | + elseif(is_numeric($storeIds)) |
1736 | + { |
1737 | + try |
1738 | + { |
1739 | + return Mage::getModel('core/store')->load($storeIds)->toArray(); |
1740 | + } |
1741 | + catch (Mage_Core_Exception $e) |
1742 | + { |
1743 | + $this->_fault('store_not_exists'); |
1744 | + } |
1745 | + |
1746 | + } |
1747 | + |
1748 | + } |
1749 | + |
1750 | + public function create($storedata) |
1751 | + { |
1752 | + try |
1753 | + { |
1754 | + $store = Mage::getModel('core/store') |
1755 | + ->setData($storedata) |
1756 | + ->save(); |
1757 | + |
1758 | + } |
1759 | + catch (Magento_Core_Exception $e) |
1760 | + { |
1761 | + $this->_fault('data_invalid',$e->getMessage()); |
1762 | + } |
1763 | + catch (Exception $e) |
1764 | + { |
1765 | + $this->_fault('data_invalid',$e->getMessage()); |
1766 | + } |
1767 | + return $store->getId(); |
1768 | + } |
1769 | + |
1770 | + public function update($storeid,$storedata) |
1771 | + { |
1772 | + try |
1773 | + { |
1774 | + $store = Mage::getModel('core/store') |
1775 | + ->load($storeid); |
1776 | + if (!$store->getId()) |
1777 | + { |
1778 | + $this->_fault('store_not_exists'); |
1779 | + } |
1780 | + $store->addData($storedata)->save(); |
1781 | + } |
1782 | + catch (Magento_Core_Exception $e) |
1783 | + { |
1784 | + $this->_fault('data_invalid',$e->getMessage()); |
1785 | + } |
1786 | + catch (Exception $e) |
1787 | + { |
1788 | + $this->_fault('data_invalid',$e->getMessage()); |
1789 | + } |
1790 | + return true; |
1791 | + } |
1792 | + |
1793 | + public function delete($storeid) |
1794 | + { |
1795 | + try |
1796 | + { |
1797 | + $store = Mage::getModel('core/store') |
1798 | + ->load($storeid); |
1799 | + if (!$store->getId()) |
1800 | + { |
1801 | + $this->_fault('store_not_exists'); |
1802 | + } |
1803 | + $store->delete(); |
1804 | + |
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 | +?> |
1818 | |
1819 | === added file 'Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcore/Website.php' |
1820 | --- Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcore/Website.php 1970-01-01 00:00:00 +0000 |
1821 | +++ Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcore/Website.php 2013-07-31 04:42:30 +0000 |
1822 | @@ -0,0 +1,195 @@ |
1823 | +<?php |
1824 | + |
1825 | +/** |
1826 | + * @author Sharoon Thomas |
1827 | + * Inspired from Dieter's Magento Extender |
1828 | + * @copyright 2009 |
1829 | + */ |
1830 | + |
1831 | +class Openlabs_OpenERPConnector_Model_Olcore_Website extends Mage_Catalog_Model_Api_Resource |
1832 | +{ |
1833 | + |
1834 | + /** |
1835 | + * Return the list of website ids which match the filters |
1836 | + * |
1837 | + * @param array $filters |
1838 | + * @return array |
1839 | + */ |
1840 | + public function search($filters) |
1841 | + { |
1842 | + |
1843 | + $collection = Mage::getModel('core/website')->getCollection(); |
1844 | + |
1845 | + if (is_array($filters)) { |
1846 | + try { |
1847 | + foreach ($filters as $field => $value) { |
1848 | + $collection->addFieldToFilter($field, $value); |
1849 | + } |
1850 | + } catch (Mage_Core_Exception $e) { |
1851 | + $this->_fault('filters_invalid', $e->getMessage()); |
1852 | + } |
1853 | + } |
1854 | + |
1855 | + return $collection->getAllIds(); |
1856 | + } |
1857 | + |
1858 | + public function items($filters=null) |
1859 | + { |
1860 | + try |
1861 | + { |
1862 | + $collection = Mage::getModel('core/website')->getCollection();//->addAttributeToSelect('*'); |
1863 | + } |
1864 | + catch (Mage_Core_Exception $e) |
1865 | + { |
1866 | + $this->_fault('store_not_exists'); |
1867 | + } |
1868 | + |
1869 | + if (is_array($filters)) { |
1870 | + try { |
1871 | + foreach ($filters as $field => $value) { |
1872 | + $collection->addFieldToFilter($field, $value); |
1873 | + } |
1874 | + } catch (Mage_Core_Exception $e) { |
1875 | + $this->_fault('filters_invalid', $e->getMessage()); |
1876 | + // If we are adding filter on non-existent attribute |
1877 | + } |
1878 | + } |
1879 | + |
1880 | + $result = array(); |
1881 | + foreach ($collection as $customer) { |
1882 | + $result[] = $customer->toArray(); |
1883 | + } |
1884 | + |
1885 | + return $result; |
1886 | + } |
1887 | + |
1888 | + public function info($storeIds = null) |
1889 | + { |
1890 | + $stores = array(); |
1891 | + |
1892 | + if(is_array($storeIds)) |
1893 | + { |
1894 | + foreach($storeIds as $storeId) |
1895 | + { |
1896 | + try |
1897 | + { |
1898 | + $stores[] = Mage::getModel('core/website')->load($storeId)->toArray(); |
1899 | + } |
1900 | + catch (Mage_Core_Exception $e) |
1901 | + { |
1902 | + $this->_fault('store_not_exists'); |
1903 | + } |
1904 | + } |
1905 | + return $stores; |
1906 | + } |
1907 | + elseif(is_numeric($storeIds)) |
1908 | + { |
1909 | + try |
1910 | + { |
1911 | + return Mage::getModel('core/website')->load($storeIds)->toArray(); |
1912 | + } |
1913 | + catch (Mage_Core_Exception $e) |
1914 | + { |
1915 | + $this->_fault('store_not_exists'); |
1916 | + } |
1917 | + |
1918 | + } |
1919 | + |
1920 | + } |
1921 | + //This is a protected function used by items & info for fetching website information |
1922 | + |
1923 | + public function create($websitedata) |
1924 | + { |
1925 | + try |
1926 | + { |
1927 | + $website = Mage::getModel('core/website') |
1928 | + ->setData($websitedata) |
1929 | + ->save(); |
1930 | + |
1931 | + } |
1932 | + catch (Magento_Core_Exception $e) |
1933 | + { |
1934 | + $this->_fault('data_invalid',$e->getMessage()); |
1935 | + } |
1936 | + catch (Exception $e) |
1937 | + { |
1938 | + $this->_fault('data_invalid',$e->getMessage()); |
1939 | + } |
1940 | + return $website->getId(); |
1941 | + } |
1942 | + |
1943 | + public function update($websiteid,$websitedata) |
1944 | + { |
1945 | + try |
1946 | + { |
1947 | + $website = Mage::getModel('core/website') |
1948 | + ->load($websiteid); |
1949 | + if (!$website->getId()) |
1950 | + { |
1951 | + $this->_fault('website_not_exists'); |
1952 | + } |
1953 | + $website->addData($websitedata)->save(); |
1954 | + } |
1955 | + catch (Magento_Core_Exception $e) |
1956 | + { |
1957 | + $this->_fault('data_invalid',$e->getMessage()); |
1958 | + } |
1959 | + catch (Exception $e) |
1960 | + { |
1961 | + $this->_fault('data_invalid',$e->getMessage()); |
1962 | + } |
1963 | + return true; |
1964 | + } |
1965 | + |
1966 | + public function delete($websiteid) |
1967 | + { |
1968 | + try |
1969 | + { |
1970 | + $website = Mage::getModel('core/website') |
1971 | + ->load($websiteid); |
1972 | + if (!$website->getId()) |
1973 | + { |
1974 | + $this->_fault('website_not_exists'); |
1975 | + } |
1976 | + $website->delete(); |
1977 | + |
1978 | + } |
1979 | + catch (Magento_Core_Exception $e) |
1980 | + { |
1981 | + $this->_fault('data_invalid',$e->getMessage()); |
1982 | + } |
1983 | + catch (Exception $e) |
1984 | + { |
1985 | + $this->_fault('data_invalid',$e->getMessage()); |
1986 | + } |
1987 | + return true; |
1988 | + } |
1989 | + |
1990 | + public function tree() |
1991 | + { |
1992 | + $tree = array(); |
1993 | + |
1994 | + $websites = $this->websites(); |
1995 | + |
1996 | + foreach($websites as $website) |
1997 | + { |
1998 | + $groups = $this->groups($website['group_ids']); |
1999 | + $tree[$website['code']] = $website; |
2000 | + foreach($groups as $group) |
2001 | + { |
2002 | + $stores = $this->stores($group["store_ids"]); |
2003 | + |
2004 | + $tree[$website['code']]['groups']['group_'.$group['group_id']] = $group; |
2005 | + |
2006 | + foreach($stores as $store) |
2007 | + { |
2008 | + $tree[$website['code']]['groups']['group_'.$group['group_id']]['stores'][$store['code']] = $store; |
2009 | + } |
2010 | + } |
2011 | + } |
2012 | + |
2013 | + return $tree; |
2014 | + } |
2015 | + |
2016 | +} |
2017 | +?> |
2018 | |
2019 | === added directory 'Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcustomer' |
2020 | === added file 'Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcustomer/Address.php' |
2021 | --- Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcustomer/Address.php 1970-01-01 00:00:00 +0000 |
2022 | +++ Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcustomer/Address.php 2013-07-31 04:42:30 +0000 |
2023 | @@ -0,0 +1,241 @@ |
2024 | +<?php |
2025 | +/** |
2026 | + * Magento |
2027 | + * |
2028 | + * NOTICE OF LICENSE |
2029 | + * |
2030 | + * This source file is subject to the Open Software License (OSL 3.0) |
2031 | + * that is bundled with this package in the file LICENSE.txt. |
2032 | + * It is also available through the world-wide-web at this URL: |
2033 | + * http://opensource.org/licenses/osl-3.0.php |
2034 | + * If you did not receive a copy of the license and are unable to |
2035 | + * obtain it through the world-wide-web, please send an email |
2036 | + * to license@magentocommerce.com so we can send you a copy immediately. |
2037 | + * |
2038 | + * DISCLAIMER |
2039 | + * |
2040 | + * Do not edit or add to this file if you wish to upgrade Magento to newer |
2041 | + * versions in the future. If you wish to customize Magento for your |
2042 | + * needs please refer to http://www.magentocommerce.com for more information. |
2043 | + * |
2044 | + * @category Mage |
2045 | + * @package Mage_Customer |
2046 | + * @copyright Copyright (c) 2008 Irubin Consulting Inc. DBA Varien (http://www.varien.com) |
2047 | + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) |
2048 | + */ |
2049 | + |
2050 | +/** |
2051 | + * Customer address api |
2052 | + * |
2053 | + * @category Mage |
2054 | + * @package Mage_Customer |
2055 | + * @author Magento Core Team <core@magentocommerce.com> |
2056 | + */ |
2057 | +class Openlabs_OpenERPConnector_Model_Olcustomer_Address extends Mage_Customer_Model_Api_Resource |
2058 | +{ |
2059 | + protected $_mapAttributes = array( |
2060 | + 'customer_id' => 'entity_id' |
2061 | + ); |
2062 | + |
2063 | + public function __construct() |
2064 | + { |
2065 | + $this->_ignoredAttributeCodes[] = 'parent_id'; |
2066 | + } |
2067 | + |
2068 | + /** |
2069 | + * Retrive customer addresses list |
2070 | + * |
2071 | + * @param int $customerId |
2072 | + * @return array |
2073 | + */ |
2074 | + public function items($customerId) |
2075 | + { |
2076 | + $customer = Mage::getModel('customer/customer') |
2077 | + ->load($customerId); |
2078 | + /* @var $customer Mage_Customer_Model_Customer */ |
2079 | + |
2080 | + if (!$customer->getId()) { |
2081 | + $this->_fault('customer_not_exists'); |
2082 | + } |
2083 | + |
2084 | + $result = array(); |
2085 | + foreach ($customer->getAddresses() as $address) { |
2086 | + $data = $address->toArray(); |
2087 | + $data['default_billing'] = $customer->getDefaultBilling() == $address->getId(); |
2088 | + $data['default_shipping'] = $customer->getDefaultShipping() == $address->getId(); |
2089 | + $result[] = $data; |
2090 | + /*$data = $address->toArray(); |
2091 | + $row = array(); |
2092 | + |
2093 | + foreach ($this->_mapAttributes as $attributeAlias => $attributeCode) { |
2094 | + $row[$attributeAlias] = isset($data[$attributeCode]) ? $data[$attributeCode] : null; |
2095 | + } |
2096 | + |
2097 | + foreach ($this->getAllowedAttributes($address) as $attributeCode => $attribute) { |
2098 | + if (isset($data[$attributeCode])) { |
2099 | + $row[$attributeCode] = $data[$attributeCode]; |
2100 | + } |
2101 | + } |
2102 | + |
2103 | + $row['is_default_billing'] = $customer->getDefaultBillingAddress() == $address->getId(); |
2104 | + $row['is_default_shipping'] = $customer->getDefaultShippingAddress() == $address->getId(); |
2105 | + |
2106 | + $result[] = $row;*/ |
2107 | + |
2108 | + } |
2109 | + |
2110 | + return $result; |
2111 | + } |
2112 | + |
2113 | + /** |
2114 | + * Create new address for customer |
2115 | + * |
2116 | + * @param int $customerId |
2117 | + * @param array $addressData |
2118 | + * @return int |
2119 | + */ |
2120 | + public function create($customerId, $addressData) |
2121 | + { |
2122 | + $customer = Mage::getModel('customer/customer') |
2123 | + ->load($customerId); |
2124 | + /* @var $customer Mage_Customer_Model_Customer */ |
2125 | + |
2126 | + if (!$customer->getId()) { |
2127 | + $this->_fault('customer_not_exists'); |
2128 | + } |
2129 | + |
2130 | + $address = Mage::getModel('customer/address'); |
2131 | + |
2132 | + foreach ($this->getAllowedAttributes($address) as $attributeCode=>$attribute) { |
2133 | + if (isset($addressData[$attributeCode])) { |
2134 | + $address->setData($attributeCode, $addressData[$attributeCode]); |
2135 | + } |
2136 | + } |
2137 | + |
2138 | + if (isset($addressData['is_default_billing'])) { |
2139 | + $address->setIsDefaultBilling($addressData['is_default_billing']); |
2140 | + } |
2141 | + |
2142 | + if (isset($addressData['is_default_shipping'])) { |
2143 | + $address->setIsDefaultShipping($addressData['is_default_shipping']); |
2144 | + } |
2145 | + |
2146 | + $address->setCustomerId($customer->getId()); |
2147 | + |
2148 | + $valid = $address->validate(); |
2149 | + |
2150 | + if (is_array($valid)) { |
2151 | + $this->_fault('data_invalid', implode("\n", $valid)); |
2152 | + } |
2153 | + |
2154 | + try { |
2155 | + $address->save(); |
2156 | + } catch (Mage_Core_Exception $e) { |
2157 | + $this->_fault('data_invalid', $e->getMessage()); |
2158 | + } |
2159 | + |
2160 | + return $address->getId(); |
2161 | + } |
2162 | + |
2163 | + /** |
2164 | + * Retrieve address data |
2165 | + * |
2166 | + * @param int $addressId |
2167 | + * @return array |
2168 | + */ |
2169 | + public function info($addressId) |
2170 | + { |
2171 | + $address = Mage::getModel('customer/address') |
2172 | + ->load($addressId); |
2173 | + |
2174 | + if (!$address->getId()) { |
2175 | + $this->_fault('not_exists'); |
2176 | + } |
2177 | + |
2178 | + $result = array(); |
2179 | + |
2180 | + foreach ($this->_mapAttributes as $attributeAlias => $attributeCode) { |
2181 | + $result[$attributeAlias] = $address->getData($attributeCode); |
2182 | + } |
2183 | + |
2184 | + foreach ($this->getAllowedAttributes($address) as $attributeCode => $attribute) { |
2185 | + $result[$attributeCode] = $address->getData($attributeCode); |
2186 | + } |
2187 | + |
2188 | + |
2189 | + if ($customer = $address->getCustomer()) { |
2190 | + $result['is_default_billing'] = $customer->getDefaultBillingAddress() == $address->getId(); |
2191 | + $result['is_default_shipping'] = $customer->getDefaultShippingAddress() == $address->getId(); |
2192 | + } |
2193 | + |
2194 | + return $result; |
2195 | + } |
2196 | + |
2197 | + /** |
2198 | + * Update address data |
2199 | + * |
2200 | + * @param int $addressId |
2201 | + * @param array $addressData |
2202 | + * @return boolean |
2203 | + */ |
2204 | + public function update($addressId, $addressData) |
2205 | + { |
2206 | + $address = Mage::getModel('customer/address') |
2207 | + ->load($addressId); |
2208 | + |
2209 | + if (!$address->getId()) { |
2210 | + $this->_fault('not_exists'); |
2211 | + } |
2212 | + |
2213 | + foreach ($this->getAllowedAttributes($address) as $attributeCode=>$attribute) { |
2214 | + if (isset($addressData[$attributeCode])) { |
2215 | + $address->setData($attributeCode, $addressData[$attributeCode]); |
2216 | + } |
2217 | + } |
2218 | + |
2219 | + if (isset($addressData['is_default_billing'])) { |
2220 | + $address->setIsDefaultBilling($addressData['is_default_billing']); |
2221 | + } |
2222 | + |
2223 | + if (isset($addressData['is_default_shipping'])) { |
2224 | + $address->setIsDefaultShipping($addressData['is_default_shipping']); |
2225 | + } |
2226 | + |
2227 | + $valid = $address->validate(); |
2228 | + if (is_array($valid)) { |
2229 | + $this->_fault('data_invalid', implode("\n", $valid)); |
2230 | + } |
2231 | + |
2232 | + try { |
2233 | + $address->save(); |
2234 | + } catch (Mage_Core_Exception $e) { |
2235 | + $this->_fault('data_invalid', $e->getMessage()); |
2236 | + } |
2237 | + |
2238 | + return true; |
2239 | + } |
2240 | + |
2241 | + /** |
2242 | + * Delete address |
2243 | + * |
2244 | + * @param int $addressId |
2245 | + * @return boolean |
2246 | + */ |
2247 | + public function delete($addressId) |
2248 | + { |
2249 | + $address = Mage::getModel('customer/address') |
2250 | + ->load($addressId); |
2251 | + |
2252 | + if (!$address->getId()) { |
2253 | + $this->_fault('not_exists'); |
2254 | + } |
2255 | + |
2256 | + try { |
2257 | + $address->delete(); |
2258 | + } catch (Mage_Core_Exception $e) { |
2259 | + $this->_fault('not_deleted', $e->getMessage()); |
2260 | + } |
2261 | + |
2262 | + return true; |
2263 | + } |
2264 | +} // Class Mage_Customer_Model_Address_Api End |
2265 | \ No newline at end of file |
2266 | |
2267 | === added file 'Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcustomer/Customer.php' |
2268 | --- Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcustomer/Customer.php 1970-01-01 00:00:00 +0000 |
2269 | +++ Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcustomer/Customer.php 2013-07-31 04:42:30 +0000 |
2270 | @@ -0,0 +1,182 @@ |
2271 | +<?php |
2272 | + |
2273 | +/** |
2274 | + * @author Sharoon Thomas |
2275 | + * Inspired from Dieter's Magento Extender |
2276 | + * @copyright 2009 |
2277 | + */ |
2278 | + |
2279 | +class Openlabs_OpenERPConnector_Model_Olcustomer_Customer extends Mage_Catalog_Model_Api_Resource |
2280 | +{ |
2281 | + |
2282 | + protected $_mapFilters = array( |
2283 | + 'customer_id' => 'entity_id' |
2284 | + ); |
2285 | + |
2286 | + /** |
2287 | + * Return the list of partner ids which match the filters |
2288 | + * |
2289 | + * @param array $filters |
2290 | + * @return array |
2291 | + */ |
2292 | + public function search($filters) |
2293 | + { |
2294 | + |
2295 | + $collection = Mage::getModel('customer/customer')->getCollection() |
2296 | + ->addAttributeToSelect('*'); |
2297 | + |
2298 | + if (is_array($filters)) { |
2299 | + try { |
2300 | + foreach ($filters as $field => $value) { |
2301 | + if (isset($this->_mapFilters[$field])) { |
2302 | + $field = $this->_mapFilters[$field]; |
2303 | + } |
2304 | + |
2305 | + $collection->addFieldToFilter($field, $value); |
2306 | + } |
2307 | + } catch (Mage_Core_Exception $e) { |
2308 | + $this->_fault('filters_invalid', $e->getMessage()); |
2309 | + } |
2310 | + } |
2311 | + |
2312 | + $result = array(); |
2313 | + |
2314 | + foreach ($collection as $product) { |
2315 | + $result[] = $product->getId(); |
2316 | + } |
2317 | + |
2318 | + return $result; |
2319 | + } |
2320 | + |
2321 | + public function items($filters=null) |
2322 | + { |
2323 | + try |
2324 | + { |
2325 | + $collection = Mage::getModel('customer/customer')->getCollection();//->addAttributeToSelect('*'); |
2326 | + } |
2327 | + catch (Mage_Core_Exception $e) |
2328 | + { |
2329 | + $this->_fault('customer_not_exists'); |
2330 | + } |
2331 | + |
2332 | + if (is_array($filters)) { |
2333 | + try { |
2334 | + foreach ($filters as $field => $value) { |
2335 | + $collection->addFieldToFilter($field, $value); |
2336 | + } |
2337 | + } catch (Mage_Core_Exception $e) { |
2338 | + $this->_fault('filters_invalid', $e->getMessage()); |
2339 | + // If we are adding filter on non-existent attribute |
2340 | + } |
2341 | + } |
2342 | + |
2343 | + $result = array(); |
2344 | + foreach ($collection as $customer) { |
2345 | + $result[] = $customer->toArray(); |
2346 | + } |
2347 | + |
2348 | + return $result; |
2349 | + } |
2350 | + |
2351 | + public function info($groupIds = null) |
2352 | + { |
2353 | + $groups = array(); |
2354 | + |
2355 | + if(is_array($groupIds)) |
2356 | + { |
2357 | + foreach($groupIds as $groupId) |
2358 | + { |
2359 | + try |
2360 | + { |
2361 | + $groups[] = Mage::getModel('customer')->load($groupId)->toArray(); |
2362 | + } |
2363 | + catch (Mage_Core_Exception $e) |
2364 | + { |
2365 | + $this->_fault('customer_not_exists'); |
2366 | + } |
2367 | + } |
2368 | + return $groups; |
2369 | + } |
2370 | + elseif(is_numeric($groupIds)) |
2371 | + { |
2372 | + try |
2373 | + { |
2374 | + return Mage::getModel('customer')->load($groupIds)->toArray(); |
2375 | + } |
2376 | + catch (Mage_Core_Exception $e) |
2377 | + { |
2378 | + $this->_fault('customer_not_exists'); |
2379 | + } |
2380 | + |
2381 | + } |
2382 | + |
2383 | + } |
2384 | + |
2385 | + public function create($groupdata) |
2386 | + { |
2387 | + try |
2388 | + { |
2389 | + $group = Mage::getModel('customer') |
2390 | + ->setData($groupdata) |
2391 | + ->save(); |
2392 | + |
2393 | + } |
2394 | + catch (Magento_Core_Exception $e) |
2395 | + { |
2396 | + $this->_fault('data_invalid',$e->getMessage()); |
2397 | + } |
2398 | + catch (Exception $e) |
2399 | + { |
2400 | + $this->_fault('data_invalid',$e->getMessage()); |
2401 | + } |
2402 | + return $group->getId(); |
2403 | + } |
2404 | + |
2405 | + public function update($groupid,$groupdata) |
2406 | + { |
2407 | + try |
2408 | + { |
2409 | + $group = Mage::getModel('customer') |
2410 | + ->load($groupid); |
2411 | + if (!$group->getId()) |
2412 | + { |
2413 | + $this->_fault('customer_not_exists'); |
2414 | + } |
2415 | + $group->addData($groupdata)->save(); |
2416 | + } |
2417 | + catch (Magento_Core_Exception $e) |
2418 | + { |
2419 | + $this->_fault('data_invalid',$e->getMessage()); |
2420 | + } |
2421 | + catch (Exception $e) |
2422 | + { |
2423 | + $this->_fault('data_invalid',$e->getMessage()); |
2424 | + } |
2425 | + return true; |
2426 | + } |
2427 | + |
2428 | + public function delete($groupid) |
2429 | + { |
2430 | + try |
2431 | + { |
2432 | + $group = Mage::getModel('customer') |
2433 | + ->load($groupid); |
2434 | + if (!$group->getId()) |
2435 | + { |
2436 | + $this->_fault('customer_not_exists'); |
2437 | + } |
2438 | + $group->delete(); |
2439 | + |
2440 | + } |
2441 | + catch (Magento_Core_Exception $e) |
2442 | + { |
2443 | + $this->_fault('data_invalid',$e->getMessage()); |
2444 | + } |
2445 | + catch (Exception $e) |
2446 | + { |
2447 | + $this->_fault('data_invalid',$e->getMessage()); |
2448 | + } |
2449 | + return true; |
2450 | + } |
2451 | +} |
2452 | +?> |
2453 | |
2454 | === added file 'Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcustomer/Group.php' |
2455 | --- Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcustomer/Group.php 1970-01-01 00:00:00 +0000 |
2456 | +++ Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcustomer/Group.php 2013-07-31 04:42:30 +0000 |
2457 | @@ -0,0 +1,142 @@ |
2458 | +<?php |
2459 | + |
2460 | +/** |
2461 | + * @author Sharoon Thomas |
2462 | + * Inspired from Dieter's Magento Extender |
2463 | + * @copyright 2009 |
2464 | + */ |
2465 | + |
2466 | +class Openlabs_OpenERPConnector_Model_Olcustomer_Group extends Mage_Catalog_Model_Api_Resource |
2467 | +{ |
2468 | + public function items($filters=null) |
2469 | + { |
2470 | + try |
2471 | + { |
2472 | + $collection = Mage::getModel('customer/group')->getCollection();//->addAttributeToSelect('*'); |
2473 | + } |
2474 | + catch (Mage_Core_Exception $e) |
2475 | + { |
2476 | + $this->_fault('group_not_exists'); |
2477 | + } |
2478 | + |
2479 | + if (is_array($filters)) { |
2480 | + try { |
2481 | + foreach ($filters as $field => $value) { |
2482 | + $collection->addFieldToFilter($field, $value); |
2483 | + } |
2484 | + } catch (Mage_Core_Exception $e) { |
2485 | + $this->_fault('filters_invalid', $e->getMessage()); |
2486 | + // If we are adding filter on non-existent attribute |
2487 | + } |
2488 | + } |
2489 | + |
2490 | + $result = array(); |
2491 | + foreach ($collection as $customer) { |
2492 | + $result[] = $customer->toArray(); |
2493 | + } |
2494 | + |
2495 | + return $result; |
2496 | + } |
2497 | + |
2498 | + public function info($groupIds = null) |
2499 | + { |
2500 | + $groups = array(); |
2501 | + |
2502 | + if(is_array($groupIds)) |
2503 | + { |
2504 | + foreach($groupIds as $groupId) |
2505 | + { |
2506 | + try |
2507 | + { |
2508 | + $groups[] = Mage::getModel('customer/group')->load($groupId)->toArray(); |
2509 | + } |
2510 | + catch (Mage_Core_Exception $e) |
2511 | + { |
2512 | + $this->_fault('group_not_exists'); |
2513 | + } |
2514 | + } |
2515 | + return $groups; |
2516 | + } |
2517 | + elseif(is_numeric($groupIds)) |
2518 | + { |
2519 | + try |
2520 | + { |
2521 | + return Mage::getModel('customer/group')->load($groupIds)->toArray(); |
2522 | + } |
2523 | + catch (Mage_Core_Exception $e) |
2524 | + { |
2525 | + $this->_fault('group_not_exists'); |
2526 | + } |
2527 | + |
2528 | + } |
2529 | + |
2530 | + } |
2531 | + |
2532 | + public function create($groupdata) |
2533 | + { |
2534 | + try |
2535 | + { |
2536 | + $group = Mage::getModel('customer/group') |
2537 | + ->setData($groupdata) |
2538 | + ->save(); |
2539 | + |
2540 | + } |
2541 | + catch (Magento_Core_Exception $e) |
2542 | + { |
2543 | + $this->_fault('data_invalid',$e->getMessage()); |
2544 | + } |
2545 | + catch (Exception $e) |
2546 | + { |
2547 | + $this->_fault('data_invalid',$e->getMessage()); |
2548 | + } |
2549 | + return $group->getId(); |
2550 | + } |
2551 | + |
2552 | + public function update($groupid,$groupdata) |
2553 | + { |
2554 | + try |
2555 | + { |
2556 | + $group = Mage::getModel('customer/group') |
2557 | + ->load($groupid); |
2558 | + if (!$group->getId()) |
2559 | + { |
2560 | + $this->_fault('group_not_exists'); |
2561 | + } |
2562 | + $group->addData($groupdata)->save(); |
2563 | + } |
2564 | + catch (Magento_Core_Exception $e) |
2565 | + { |
2566 | + $this->_fault('data_invalid',$e->getMessage()); |
2567 | + } |
2568 | + catch (Exception $e) |
2569 | + { |
2570 | + $this->_fault('data_invalid',$e->getMessage()); |
2571 | + } |
2572 | + return true; |
2573 | + } |
2574 | + |
2575 | + public function delete($groupid) |
2576 | + { |
2577 | + try |
2578 | + { |
2579 | + $group = Mage::getModel('customer/group') |
2580 | + ->load($groupid); |
2581 | + if (!$group->getId()) |
2582 | + { |
2583 | + $this->_fault('group_not_exists'); |
2584 | + } |
2585 | + $group->delete(); |
2586 | + |
2587 | + } |
2588 | + catch (Magento_Core_Exception $e) |
2589 | + { |
2590 | + $this->_fault('data_invalid',$e->getMessage()); |
2591 | + } |
2592 | + catch (Exception $e) |
2593 | + { |
2594 | + $this->_fault('data_invalid',$e->getMessage()); |
2595 | + } |
2596 | + return true; |
2597 | + } |
2598 | +} |
2599 | +?> |
2600 | |
2601 | === added file 'Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcustomer/Subscriber.php' |
2602 | --- Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcustomer/Subscriber.php 1970-01-01 00:00:00 +0000 |
2603 | +++ Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Olcustomer/Subscriber.php 2013-07-31 04:42:30 +0000 |
2604 | @@ -0,0 +1,163 @@ |
2605 | +<?php |
2606 | +/** |
2607 | + * Magento |
2608 | + * |
2609 | + * NOTICE OF LICENSE |
2610 | + * |
2611 | + * This source file is subject to the Open Software License (OSL 3.0) |
2612 | + * that is bundled with this package in the file LICENSE.txt. |
2613 | + * It is also available through the world-wide-web at this URL: |
2614 | + * http://opensource.org/licenses/osl-3.0.php |
2615 | + * If you did not receive a copy of the license and are unable to |
2616 | + * obtain it through the world-wide-web, please send an email |
2617 | + * to license@magentocommerce.com so we can send you a copy immediately. |
2618 | + * |
2619 | + * DISCLAIMER |
2620 | + * |
2621 | + * Do not edit or add to this file if you wish to upgrade Magento to newer |
2622 | + * versions in the future. If you wish to customize Magento for your |
2623 | + * needs please refer to http://www.magentocommerce.com for more information. |
2624 | + * |
2625 | + * @category Mage |
2626 | + * @package Mage_Customer |
2627 | + * @copyright Copyright (c) 2008 Irubin Consulting Inc. DBA Varien (http://www.varien.com) |
2628 | + * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) |
2629 | + */ |
2630 | + |
2631 | +/** |
2632 | + * Customer address api |
2633 | + * |
2634 | + * @category Mage |
2635 | + * @package Mage_Customer |
2636 | + * @author Magento Core Team <core@magentocommerce.com> |
2637 | + */ |
2638 | +class Openlabs_OpenERPConnector_Model_Olcustomer_Subscriber extends Mage_Customer_Model_Api_Resource |
2639 | +{ |
2640 | + protected $_mapAttributes = array( |
2641 | + 'customer_id' => 'entity_id' |
2642 | + ); |
2643 | + |
2644 | + public function __construct() |
2645 | + { |
2646 | + $this->_ignoredAttributeCodes[] = 'parent_id'; |
2647 | + } |
2648 | + |
2649 | + /** |
2650 | + * Retrive subscriber list |
2651 | + * |
2652 | + * @param int $filters |
2653 | + * @return array |
2654 | + */ |
2655 | + public function items($filters=null) |
2656 | + { |
2657 | + $collection = Mage::getModel('customer/customer')->getCollection() |
2658 | + ->addAttributeToSelect('*'); |
2659 | + |
2660 | + |
2661 | + if (is_array($filters)) { |
2662 | + try { |
2663 | + foreach ($filters as $field => $value) { |
2664 | + $collection->addFieldToFilter($field, $value); |
2665 | + } |
2666 | + } catch (Mage_Core_Exception $e) { |
2667 | + $this->_fault('filters_invalid', $e->getMessage()); |
2668 | + // If we are adding filter on non-existent attribute |
2669 | + } |
2670 | + } |
2671 | + |
2672 | + $result = array(); |
2673 | + |
2674 | + foreach ($collection as $customer) { |
2675 | + $subscriber = Mage::getModel('newsletter/subscriber')->loadByEmail($customer['email']); |
2676 | + if($subscriber->getId()) |
2677 | + $result[] = $subscriber->getId(); |
2678 | + } |
2679 | + |
2680 | + return $result; |
2681 | + } |
2682 | + |
2683 | + /** |
2684 | + * Create new address for customer |
2685 | + * |
2686 | + * @param int $customerId |
2687 | + * @param array $email |
2688 | + * @return int |
2689 | + */ |
2690 | + public function create($customerId,$email) |
2691 | + { |
2692 | + if($customerId && $email): |
2693 | + $customer = Mage::getModel("newsletter/subscriber"); |
2694 | + |
2695 | + $customer->setCustomerId($customerId); |
2696 | + $customer->setEmail($email); |
2697 | + $customer->subscriber_status = "1"; |
2698 | + |
2699 | + $customer->save(); |
2700 | + |
2701 | + return $customer->getId(); |
2702 | + else: |
2703 | + return False; |
2704 | + endif; |
2705 | + } |
2706 | + |
2707 | + /** |
2708 | + * Retrieve subscriber data |
2709 | + * |
2710 | + * @param int $subscriberId |
2711 | + * @return array |
2712 | + */ |
2713 | + public function info($subscriberId) |
2714 | + { |
2715 | + $subscriber = Mage::getModel('newsletter/subscriber')->load($subscriberId); |
2716 | + |
2717 | + if($subscriber->getId()): |
2718 | + $result[] = $subscriber->toArray(); |
2719 | + endif; |
2720 | + |
2721 | + return $result; |
2722 | + } |
2723 | + |
2724 | + /** |
2725 | + * Update subscriber data (subscriber) |
2726 | + * |
2727 | + * @param $email |
2728 | + * @return boolean |
2729 | + */ |
2730 | + public function update($email) |
2731 | + { |
2732 | + if($email): |
2733 | + $subscriber = Mage::getModel('newsletter/subscriber')->loadByEmail($email); |
2734 | + |
2735 | + if($subscriber->getId()): |
2736 | + $customer = Mage::getModel("newsletter/subscriber")->load($subscriber->getId()); |
2737 | + $customer->subscriber_status = "1"; |
2738 | + $customer->save(); |
2739 | + endif; |
2740 | + |
2741 | + return $subscriber->getId(); |
2742 | + else: |
2743 | + return False; |
2744 | + endif; |
2745 | + } |
2746 | + |
2747 | + /** |
2748 | + * Delete subscriber (unsubscriber) |
2749 | + * |
2750 | + * @param $email |
2751 | + * @return boolean |
2752 | + */ |
2753 | + public function delete($email) |
2754 | + { |
2755 | + if($email): |
2756 | + $subscriber = Mage::getModel('newsletter/subscriber')->loadByEmail($email); |
2757 | + |
2758 | + if($subscriber->getId()): |
2759 | + Mage::getModel('newsletter/subscriber')->load($subscriber->getId())->unsubscribe(); |
2760 | + endif; |
2761 | + |
2762 | + return $subscriber->getId(); |
2763 | + else: |
2764 | + return False; |
2765 | + endif; |
2766 | + } |
2767 | +} // Class Mage_Customer_Model_Address_Api End |
2768 | |
2769 | === added directory 'Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Sales' |
2770 | === added directory 'Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Sales/Order' |
2771 | === added file 'Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Sales/Order/Api.php' |
2772 | --- Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Sales/Order/Api.php 1970-01-01 00:00:00 +0000 |
2773 | +++ Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Sales/Order/Api.php 2013-07-31 04:42:30 +0000 |
2774 | @@ -0,0 +1,187 @@ |
2775 | +<?php |
2776 | + |
2777 | +/** |
2778 | + * |
2779 | + * @author Mohammed NAHHAS |
2780 | + * @package Openlabs_OpenERPConnector |
2781 | + * |
2782 | + */ |
2783 | + |
2784 | +class Openlabs_OpenERPConnector_Model_Sales_Order_Api extends Mage_Sales_Model_Order_Api { |
2785 | + |
2786 | + /** |
2787 | + * Return the list of products ids that match with the filter |
2788 | + * The filter imported is required |
2789 | + * @param array |
2790 | + * @return array |
2791 | + */ |
2792 | + public function search($data) { |
2793 | + |
2794 | + $result = array(); |
2795 | + if(isset($data['imported'])) { |
2796 | + |
2797 | + $collection = Mage::getModel("sales/order")->getCollection() |
2798 | + ->addAttributeToSelect('increment_id') |
2799 | + ->addAttributeToFilter('imported', array('eq' => $data['imported'])); |
2800 | + |
2801 | + if(isset($data['limit'])) { |
2802 | + $collection->setPageSize($data['limit']); |
2803 | + $collection->setOrder('entity_id', 'ASC'); |
2804 | + } |
2805 | + |
2806 | + if(isset($data['filters']) && is_array($data['filters'])) { |
2807 | + $filters = $data['filters']; |
2808 | + foreach($filters as $field => $value) { |
2809 | + $collection->addAttributeToFilter($field, $value); |
2810 | + } |
2811 | + } |
2812 | + |
2813 | + foreach ($collection as $order) { |
2814 | + $result[] = $order['increment_id']; |
2815 | + } |
2816 | + |
2817 | + return $result; |
2818 | + }else{ |
2819 | + $this->_fault('data_invalid', "Error, the attribut 'imported' need to be specified"); |
2820 | + } |
2821 | + } |
2822 | + |
2823 | + |
2824 | + /** |
2825 | + * |
2826 | + * Retrieve orders data based on the value of the flag 'imported' |
2827 | + * @param array |
2828 | + * @return array |
2829 | + */ |
2830 | + public function retrieveOrders($data) { |
2831 | + |
2832 | + $result = array(); |
2833 | + if(isset($data['imported'])) { |
2834 | + |
2835 | + $collection = Mage::getModel("sales/order")->getCollection() |
2836 | + ->addAttributeToSelect('*') |
2837 | + ->addAttributeToFilter('imported', array('eq' => $data['imported'])); |
2838 | + |
2839 | + /* addAddressFields() is called only if version >= 1400 */ |
2840 | + if(str_replace('.','',Mage::getVersion()) >= 1400) { |
2841 | + $collection->addAddressFields(); |
2842 | + } |
2843 | + |
2844 | + if(isset($data['limit'])) { |
2845 | + $collection->setPageSize($data['limit']); |
2846 | + $collection->setOrder('entity_id', 'ASC'); |
2847 | + } |
2848 | + |
2849 | + if(isset($data['filters']) && is_array($data['filters'])) { |
2850 | + $filters = $data['filters']; |
2851 | + foreach($filters as $field => $value) { |
2852 | + $collection->addAttributeToFilter($field, $value); |
2853 | + } |
2854 | + } |
2855 | + |
2856 | + foreach ($collection as $order) { |
2857 | + $tmp = $this->_getAttributes($order, 'order'); |
2858 | + |
2859 | + /* if version < 1400, billing and shipping information are added manually to order data */ |
2860 | + if(str_replace('.','',Mage::getVersion()) < 1400) { |
2861 | + $address_data = $this->_getAttributes($order->getShippingAddress(), 'order_address'); |
2862 | + if(!empty($address_data)) { |
2863 | + $tmp['shipping_firstname'] = $address_data['firstname']; |
2864 | + $tmp['shipping_lastname'] = $address_data['lastname']; |
2865 | + } |
2866 | + |
2867 | + $address_data = $this->_getAttributes($order->getBillingAddress(), 'order_address'); |
2868 | + if(!empty($address_data)) { |
2869 | + $tmp['billing_firstname'] = $address_data['firstname']; |
2870 | + $tmp['billing_lastname'] = $address_data['lastname']; |
2871 | + } |
2872 | + } |
2873 | + |
2874 | + $result[] = $tmp; |
2875 | + } |
2876 | + return $result; |
2877 | + }else{ |
2878 | + $this->_fault('data_invalid', "Error, the attribut 'imported' need to be specified"); |
2879 | + } |
2880 | + } |
2881 | + |
2882 | + public function setFlagForOrder($incrementId) { |
2883 | + $_order = $this->_initOrder($incrementId); |
2884 | + $_order->setImported(1); |
2885 | + try { |
2886 | + $_order->save(); |
2887 | + return true; |
2888 | + } catch (Mage_Core_Exception $e) { |
2889 | + $this->_fault('data_invalid', $e->getMessage()); |
2890 | + } |
2891 | + } |
2892 | + |
2893 | + /* Retrieve increment_id of the child order */ |
2894 | + public function getOrderChild($incrementId) { |
2895 | + |
2896 | + $order = Mage::getModel('sales/order')->loadByIncrementId($incrementId); |
2897 | + /** |
2898 | + * Check order existing |
2899 | + */ |
2900 | + if (!$order->getId()) { |
2901 | + $this->_fault('order_not_exists'); |
2902 | + } |
2903 | + |
2904 | + if($order->getRelationChildId()) { |
2905 | + return $order->getRelationChildRealId(); |
2906 | + }else{ |
2907 | + return false; |
2908 | + } |
2909 | + } |
2910 | + |
2911 | + /* Retrieve increment_id of the parent order */ |
2912 | + public function getOrderParent($incrementId) { |
2913 | + |
2914 | + $order = Mage::getModel('sales/order')->loadByIncrementId($incrementId); |
2915 | + /** |
2916 | + * Check order existing |
2917 | + */ |
2918 | + if (!$order->getId()) { |
2919 | + $this->_fault('order_not_exists'); |
2920 | + } |
2921 | + |
2922 | + if($order->getRelationParentId()) { |
2923 | + return $order->getRelationParentRealId(); |
2924 | + }else{ |
2925 | + return false; |
2926 | + } |
2927 | + } |
2928 | + |
2929 | + /* Retrieve invoices increment ids of the order */ |
2930 | + public function getInvoiceIds($incrementId) { |
2931 | + $order = Mage::getModel('sales/order')->loadByIncrementId($incrementId); |
2932 | + /** |
2933 | + * Check order existing |
2934 | + */ |
2935 | + if (!$order->getId()) { |
2936 | + $this->_fault('order_not_exists'); |
2937 | + } |
2938 | + $res = array(); |
2939 | + foreach($order->getInvoiceCollection() as $invoice){ |
2940 | + array_push($res, $invoice->getIncrementId()); |
2941 | + }; |
2942 | + return $res; |
2943 | + } |
2944 | + |
2945 | + /* Retrieve shipment increment ids of the order */ |
2946 | + public function getShipmentIds($incrementId) { |
2947 | + $order = Mage::getModel('sales/order')->loadByIncrementId($incrementId); |
2948 | + /** |
2949 | + * Check order existing |
2950 | + */ |
2951 | + if (!$order->getId()) { |
2952 | + $this->_fault('order_not_exists'); |
2953 | + } |
2954 | + $res = array(); |
2955 | + foreach($order->getShipmentsCollection() as $shipping){ |
2956 | + array_push($res, $shipping->getIncrementId()); |
2957 | + }; |
2958 | + return $res; |
2959 | + } |
2960 | + |
2961 | +} |
2962 | |
2963 | === added directory 'Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/controllers' |
2964 | === added directory 'Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/controllers/Adminhtml' |
2965 | === added file 'Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/controllers/Adminhtml/InitController.php' |
2966 | --- Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/controllers/Adminhtml/InitController.php 1970-01-01 00:00:00 +0000 |
2967 | +++ Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/controllers/Adminhtml/InitController.php 2013-07-31 04:42:30 +0000 |
2968 | @@ -0,0 +1,61 @@ |
2969 | +<?php |
2970 | + |
2971 | +/** |
2972 | + * |
2973 | + * @author Mohammed NAHHAS |
2974 | + * @package Openlabs_OpenERPConnector |
2975 | + * |
2976 | + */ |
2977 | + |
2978 | +class Openlabs_OpenERPConnector_Adminhtml_InitController extends Mage_Adminhtml_Controller_Action |
2979 | +{ |
2980 | + protected $_imported = 'imported'; |
2981 | + |
2982 | + /* Initialize the Attribute 'Imported' for orders placed before installing Openlabs_OpenERPConnector Extension */ |
2983 | + public function ordersAction() { |
2984 | + /* 'imported' value will be initialized if magento version is < 1.4.0.0 */ |
2985 | + if(str_replace('.','',Mage::getVersion()) < 1400) { |
2986 | + $orders = array(); |
2987 | + |
2988 | + /* 'imported' attribute values are stored in sales_order_int */ |
2989 | + $imported_attribute_table_name = 'sales_order_int'; |
2990 | + |
2991 | + /* retrieve entity_type_id for order */ |
2992 | + $entity_type = Mage::getModel('eav/entity_type')->loadByCode('order'); |
2993 | + |
2994 | + /* Load 'imported' attribute to get its attribute_id */ |
2995 | + $attributeInfo = Mage::getResourceModel('eav/entity_attribute_collection') |
2996 | + ->setCodeFilter($this->_imported) |
2997 | + ->setEntityTypeFilter($entity_type->getEntityTypeId()) |
2998 | + ->getFirstItem(); |
2999 | + |
3000 | + /* load order collection */ |
3001 | + $collection = Mage::getResourceModel('sales/order_collection') |
3002 | + ->addAttributeToSelect($this->_imported); |
3003 | + |
3004 | + if(count($collection->getItems()) > 0) { |
3005 | + foreach($collection as $order) { |
3006 | + try{ |
3007 | + $test = $order->getResource()->getAttribute($this->_imported); |
3008 | + $orders[] = $order->getIncrementId(); |
3009 | + $order->setImported(0)->save(); |
3010 | + $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)"; |
3011 | + $write = Mage::getSingleton('core/resource')->getConnection('core_write'); |
3012 | + $query = $write->query($request); |
3013 | + }catch (Exception $e) { |
3014 | + echo 'Error : '.$e->getMessage(); |
3015 | + } |
3016 | + } |
3017 | + |
3018 | + echo 'Number of Orders Initialized : '.count($collection->getItems()) .'<br />'; |
3019 | + echo 'Orders List : '.'<br />'; |
3020 | + echo '<pre>'; |
3021 | + print_r($orders); |
3022 | + echo '</pre>'; |
3023 | + } |
3024 | + }else{ |
3025 | + echo 'Magento Version : '.Mage::getVersion().'<br />'; |
3026 | + echo 'There is no need to initialize orders'; |
3027 | + } |
3028 | + } |
3029 | +} |
3030 | \ No newline at end of file |
3031 | |
3032 | === added file 'Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/controllers/OpenerpconnectorController.php' |
3033 | --- Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/controllers/OpenerpconnectorController.php 1970-01-01 00:00:00 +0000 |
3034 | +++ Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/controllers/OpenerpconnectorController.php 2013-07-31 04:42:30 +0000 |
3035 | @@ -0,0 +1,5 @@ |
3036 | +<?php |
3037 | +class Openlabs_OpenERPConnector_OpenerpconnectorController extends Mage_Core_Controller_Front_Action |
3038 | +{ |
3039 | + |
3040 | +} |
3041 | |
3042 | === added directory 'Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/etc' |
3043 | === added file 'Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/etc/api.xml' |
3044 | --- Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/etc/api.xml 1970-01-01 00:00:00 +0000 |
3045 | +++ Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/etc/api.xml 2013-07-31 04:42:30 +0000 |
3046 | @@ -0,0 +1,630 @@ |
3047 | + |
3048 | +<config> |
3049 | + <api> |
3050 | + <resources> |
3051 | + <ol_websites translate="title" module="core"> |
3052 | + <title>Website Management</title> |
3053 | + <model>openerpconnector/olcore_website</model> |
3054 | + <acl>core/store</acl> |
3055 | + <methods> |
3056 | + <search translate="title" module="core"> |
3057 | + <title>Return the list of website ids that match with the filter</title> |
3058 | + <method>search</method> |
3059 | + </search> |
3060 | + <list translate="title" module="core"> |
3061 | + <title>Enumerate websites</title> |
3062 | + <method>items</method> |
3063 | + </list> |
3064 | + <create translate="title" module="core"> |
3065 | + <title>Create Websites</title> |
3066 | + <!--Parameters are code,name,is_default,sort_order,default_group_id,group_ids--> |
3067 | + <method>create</method> |
3068 | + </create> |
3069 | + <info translate="title" module="core"> |
3070 | + <title>Fetch detail of websites</title> |
3071 | + <method>info</method> |
3072 | + </info> |
3073 | + <update translate="title" module="core"> |
3074 | + <title>Update websites info</title> |
3075 | + <method>update</method> |
3076 | + </update> |
3077 | + <delete translate="title" module="core"> |
3078 | + <title>Delete websites</title> |
3079 | + <method>delete</method> |
3080 | + </delete> |
3081 | + </methods> |
3082 | + <faults module="core"> |
3083 | + <website_not_exists> |
3084 | + <code>101</code> |
3085 | + <message>Requested website not found.</message> |
3086 | + </website_not_exists> |
3087 | + <data_invalid> |
3088 | + <code>102</code> |
3089 | + <message>Website creation failed due to invalid data.</message> |
3090 | + </data_invalid> |
3091 | + </faults> |
3092 | + </ol_websites> |
3093 | + <ol_groups translate="title" module="core"> |
3094 | + <title>Groups Management</title> |
3095 | + <model>openerpconnector/olcore_groups</model> |
3096 | + <acl>core/store</acl> |
3097 | + <methods> |
3098 | + <search translate="title" module="core"> |
3099 | + <title>Return the list of groups ids that match with the filter</title> |
3100 | + <method>search</method> |
3101 | + </search> |
3102 | + <list translate="title" module="core"> |
3103 | + <title>Enumerate groups</title> |
3104 | + <method>items</method> |
3105 | + </list> |
3106 | + <create translate="title" module="core"> |
3107 | + <title>Create groups</title> |
3108 | + <!--Parameters are code,name,is_default,sort_order,default_group_id,group_ids--> |
3109 | + <method>create</method> |
3110 | + </create> |
3111 | + <info translate="title" module="core"> |
3112 | + <title>Fetch detail of groups</title> |
3113 | + <method>info</method> |
3114 | + </info> |
3115 | + <update translate="title" module="core"> |
3116 | + <title>Update groups info</title> |
3117 | + <method>update</method> |
3118 | + </update> |
3119 | + <delete translate="title" module="core"> |
3120 | + <title>Delete groups</title> |
3121 | + <method>delete</method> |
3122 | + </delete> |
3123 | + </methods> |
3124 | + <faults module="core"> |
3125 | + <group_not_exists> |
3126 | + <code>101</code> |
3127 | + <message>Requested group not found.</message> |
3128 | + </group_not_exists> |
3129 | + <data_invalid> |
3130 | + <code>102</code> |
3131 | + <message>group creation failed due to invalid data.</message> |
3132 | + </data_invalid> |
3133 | + <filters_invalid> |
3134 | + <code>103</code> |
3135 | + <message>Invalid data fetch filter.</message> |
3136 | + </filters_invalid> |
3137 | + </faults> |
3138 | + </ol_groups> |
3139 | + <ol_storeviews translate="title" module="core"> |
3140 | + <title>Stores Management</title> |
3141 | + <model>openerpconnector/olcore_storeviews</model> |
3142 | + <acl>core/store</acl> |
3143 | + <methods> |
3144 | + <search translate="title" module="core"> |
3145 | + <title>Return the list of storeviews ids that match with the filter</title> |
3146 | + <method>search</method> |
3147 | + </search> |
3148 | + <list translate="title" module="core"> |
3149 | + <title>Enumerate stores</title> |
3150 | + <method>items</method> |
3151 | + </list> |
3152 | + <create translate="title" module="core"> |
3153 | + <title>Create stores</title> |
3154 | + <!--Parameters are code,name,is_default,sort_order,default_group_id,group_ids--> |
3155 | + <method>create</method> |
3156 | + </create> |
3157 | + <info translate="title" module="core"> |
3158 | + <title>Fetch detail of stores</title> |
3159 | + <method>info</method> |
3160 | + </info> |
3161 | + <update translate="title" module="core"> |
3162 | + <title>Update stores info</title> |
3163 | + <method>update</method> |
3164 | + </update> |
3165 | + <delete translate="title" module="core"> |
3166 | + <title>Delete stores</title> |
3167 | + <method>delete</method> |
3168 | + </delete> |
3169 | + </methods> |
3170 | + <faults module="core"> |
3171 | + <store_not_exists> |
3172 | + <code>101</code> |
3173 | + <message>Requested store not found.</message> |
3174 | + </store_not_exists> |
3175 | + <data_invalid> |
3176 | + <code>102</code> |
3177 | + <message>Store creation failed due to invalid data.</message> |
3178 | + </data_invalid> |
3179 | + <filters_invalid> |
3180 | + <code>103</code> |
3181 | + <message>Invalid data fetch filter.</message> |
3182 | + </filters_invalid> |
3183 | + </faults> |
3184 | + </ol_storeviews> |
3185 | + <ol_catalog_category_media translate="title" module="catalog"> |
3186 | + <title>Product Images API</title> |
3187 | + <model>openerpconnector/olcatalog_categories</model> |
3188 | + <acl>catalog/category</acl> |
3189 | + <methods> |
3190 | + <list translate="title" module="catalog"> |
3191 | + <title>Retrieve product image list</title> |
3192 | + <method>items</method> |
3193 | + </list> |
3194 | + <info translate="title" module="catalog"> |
3195 | + <title>Retrieve product category image</title> |
3196 | + </info> |
3197 | + <types translate="title" module="catalog"> |
3198 | + <title>Retrieve product category image types</title> |
3199 | + </types> |
3200 | + <create translate="title" module="catalog"> |
3201 | + <title>Upload new product category image </title> |
3202 | + <acl>catalog/product/media/create</acl> |
3203 | + </create> |
3204 | + <update translate="title" module="catalog"> |
3205 | + <title>Update product category image</title> |
3206 | + <acl>catalog/product/media/update</acl> |
3207 | + </update> |
3208 | + <remove translate="title" module="catalog"> |
3209 | + <title>Remove product category image</title> |
3210 | + <acl>catalog/product/media/remove</acl> |
3211 | + </remove> |
3212 | + </methods> |
3213 | + <faults module="catalog"> |
3214 | + <create_failure> |
3215 | + <code>100</code> |
3216 | + <message>Could not create file, check permissions.</message> |
3217 | + </create_failure> |
3218 | + <category_not_exists> |
3219 | + <code>101</code> |
3220 | + <message>Product not exists.</message> |
3221 | + </category_not_exists> |
3222 | + <data_invalid> |
3223 | + <code>102</code> |
3224 | + <message>Invalid data given. Details in error message.</message> |
3225 | + </data_invalid> |
3226 | + <not_exists> |
3227 | + <code>103</code> |
3228 | + <message>Requested image not exists in product images' gallery.</message> |
3229 | + </not_exists> |
3230 | + <not_created> |
3231 | + <code>104</code> |
3232 | + <message>Image creation failed. Details in error message.</message> |
3233 | + </not_created> |
3234 | + <not_updated> |
3235 | + <code>105</code> |
3236 | + <message>Image not updated. Details in error message.</message> |
3237 | + </not_updated> |
3238 | + <not_removed> |
3239 | + <code>106</code> |
3240 | + <message>Image not removed. Details in error message.</message> |
3241 | + </not_removed> |
3242 | + <not_media> |
3243 | + <code>107</code> |
3244 | + <message>Error in opening image file</message> |
3245 | + </not_media> |
3246 | + <filters_invalid> |
3247 | + <code>108</code> |
3248 | + <message>Invalid data fetch filter.</message> |
3249 | + </filters_invalid> |
3250 | + </faults> |
3251 | + </ol_catalog_category_media> |
3252 | + <ol_catalog_product_attribute translate="title" module="catalog"> |
3253 | + <title>Product Images API</title> |
3254 | + <model>openerpconnector/olcatalog_product_attribute</model> |
3255 | + <acl>catalog/category</acl> |
3256 | + <methods> |
3257 | + <list translate="title" module="catalog"> |
3258 | + <title>Retrieve attribute list</title> |
3259 | + <method>items</method> |
3260 | + </list> |
3261 | + <relations translate="title" module="catalog"> |
3262 | + <title>Retrieve attribute sets attribute ids</title> |
3263 | + <method>relations</method> |
3264 | + </relations> |
3265 | + <info translate="title" module="catalog"> |
3266 | + <title>Retrieve full attribute details</title> |
3267 | + <method>info</method> |
3268 | + </info> |
3269 | + <options translate="title" module="catalog"> |
3270 | + <title>Retrieve options of attributes</title> |
3271 | + <method>options</method> |
3272 | + </options> |
3273 | + </methods> |
3274 | + <faults> |
3275 | + </faults> |
3276 | + </ol_catalog_product_attribute> |
3277 | + <ol_catalog_product_attribute_group translate="title" module="catalog"> |
3278 | + <title>Product Images API</title> |
3279 | + <model>openerpconnector/olcatalog_product_attributegroup</model> |
3280 | + <acl>catalog/category</acl> |
3281 | + <methods> |
3282 | + <list translate="title" module="catalog"> |
3283 | + <title>Retrieve attribute group list</title> |
3284 | + <method>items</method> |
3285 | + </list> |
3286 | + <info translate="title" module="catalog"> |
3287 | + <title>Retrieve full attribute details</title> |
3288 | + <method>info</method> |
3289 | + </info> |
3290 | + </methods> |
3291 | + <faults> |
3292 | + </faults> |
3293 | + </ol_catalog_product_attribute_group> |
3294 | + <ol_customer_groups translate="title" module="core"> |
3295 | + <title>Groups Management</title> |
3296 | + <model>openerpconnector/olcustomer_group</model> |
3297 | + <acl>customer/group</acl> |
3298 | + <methods> |
3299 | + <list translate="title" module="core"> |
3300 | + <title>Enumerate groups</title> |
3301 | + <method>items</method> |
3302 | + </list> |
3303 | + <create translate="title" module="core"> |
3304 | + <title>Create groups</title> |
3305 | + <method>create</method> |
3306 | + </create> |
3307 | + <info translate="title" module="core"> |
3308 | + <title>Fetch detail of groups</title> |
3309 | + <method>info</method> |
3310 | + </info> |
3311 | + <update translate="title" module="core"> |
3312 | + <title>Update groups info</title> |
3313 | + <method>update</method> |
3314 | + </update> |
3315 | + <delete translate="title" module="core"> |
3316 | + <title>Delete groups</title> |
3317 | + <method>delete</method> |
3318 | + </delete> |
3319 | + </methods> |
3320 | + <faults module="core"> |
3321 | + <group_not_exists> |
3322 | + <code>101</code> |
3323 | + <message>Requested group not found.</message> |
3324 | + </group_not_exists> |
3325 | + <data_invalid> |
3326 | + <code>102</code> |
3327 | + <message>group creation failed due to invalid data.</message> |
3328 | + </data_invalid> |
3329 | + <filters_invalid> |
3330 | + <code>103</code> |
3331 | + <message>Invalid data fetch filter.</message> |
3332 | + </filters_invalid> |
3333 | + </faults> |
3334 | + </ol_customer_groups> |
3335 | + <ol_customer_address translate="title" module="core"> |
3336 | + <title>Address Management</title> |
3337 | + <model>openerpconnector/olcustomer_address</model> |
3338 | + <acl>customer/group</acl> |
3339 | + <methods> |
3340 | + <list translate="title" module="core"> |
3341 | + <title>Enumerate groups</title> |
3342 | + <method>items</method> |
3343 | + </list> |
3344 | + <create translate="title" module="core"> |
3345 | + <title>Create groups</title> |
3346 | + <method>create</method> |
3347 | + </create> |
3348 | + <info translate="title" module="core"> |
3349 | + <title>Fetch detail of groups</title> |
3350 | + <method>info</method> |
3351 | + </info> |
3352 | + <update translate="title" module="core"> |
3353 | + <title>Update groups info</title> |
3354 | + <method>update</method> |
3355 | + </update> |
3356 | + <delete translate="title" module="core"> |
3357 | + <title>Delete groups</title> |
3358 | + <method>delete</method> |
3359 | + </delete> |
3360 | + </methods> |
3361 | + <faults module="core"> |
3362 | + <customer_not_exists> |
3363 | + <code>101</code> |
3364 | + <message>Requested Customer not found.</message> |
3365 | + </customer_not_exists> |
3366 | + <data_invalid> |
3367 | + <code>102</code> |
3368 | + <message>group creation failed due to invalid data.</message> |
3369 | + </data_invalid> |
3370 | + <filters_invalid> |
3371 | + <code>103</code> |
3372 | + <message>Invalid data fetch filter.</message> |
3373 | + </filters_invalid> |
3374 | + </faults> |
3375 | + </ol_customer_address> |
3376 | + <ol_customer_subscriber translate="title" module="core"> |
3377 | + <title>Subscriber Management</title> |
3378 | + <model>openerpconnector/olcustomer_subscriber</model> |
3379 | + <acl>customer/group</acl> |
3380 | + <methods> |
3381 | + <list translate="title" module="core"> |
3382 | + <title>Enumerate subscriber</title> |
3383 | + <method>items</method> |
3384 | + </list> |
3385 | + <create translate="title" module="core"> |
3386 | + <title>Create subscriber</title> |
3387 | + <method>create</method> |
3388 | + </create> |
3389 | + <info translate="title" module="core"> |
3390 | + <title>Fetch detail of subscriber</title> |
3391 | + <method>info</method> |
3392 | + </info> |
3393 | + <update translate="title" module="core"> |
3394 | + <title>Update subscriber info</title> |
3395 | + <method>update</method> |
3396 | + </update> |
3397 | + <delete translate="title" module="core"> |
3398 | + <title>Delete subscriber</title> |
3399 | + <method>delete</method> |
3400 | + </delete> |
3401 | + </methods> |
3402 | + <faults module="core"> |
3403 | + <customer_not_exists> |
3404 | + <code>101</code> |
3405 | + <message>Requested Customer not found.</message> |
3406 | + </customer_not_exists> |
3407 | + <data_invalid> |
3408 | + <code>102</code> |
3409 | + <message>group creation failed due to invalid data.</message> |
3410 | + </data_invalid> |
3411 | + <filters_invalid> |
3412 | + <code>103</code> |
3413 | + <message>Invalid data fetch filter.</message> |
3414 | + </filters_invalid> |
3415 | + </faults> |
3416 | + </ol_customer_subscriber> |
3417 | + <ol_customer translate="title" module="core"> |
3418 | + <title>Customers Management</title> |
3419 | + <model>openerpconnector/olcustomer_customer</model> |
3420 | + <acl>customer/group</acl> |
3421 | + <methods> |
3422 | + <search translate="title" module="core"> |
3423 | + <title>Return the list of customer ids that match with the filter</title> |
3424 | + <method>search</method> |
3425 | + </search> |
3426 | + <list translate="title" module="core"> |
3427 | + <title>Enumerate Customers</title> |
3428 | + <method>items</method> |
3429 | + </list> |
3430 | + <create translate="title" module="core"> |
3431 | + <title>Create Customers</title> |
3432 | + <method>create</method> |
3433 | + </create> |
3434 | + <info translate="title" module="core"> |
3435 | + <title>Fetch detail of customers</title> |
3436 | + <method>info</method> |
3437 | + </info> |
3438 | + <update translate="title" module="core"> |
3439 | + <title>Update customers info</title> |
3440 | + <method>update</method> |
3441 | + </update> |
3442 | + <delete translate="title" module="core"> |
3443 | + <title>Delete customers</title> |
3444 | + <method>delete</method> |
3445 | + </delete> |
3446 | + </methods> |
3447 | + <faults module="core"> |
3448 | + <customer_not_exists> |
3449 | + <code>101</code> |
3450 | + <message>Requested customer not found.</message> |
3451 | + </customer_not_exists> |
3452 | + <data_invalid> |
3453 | + <code>102</code> |
3454 | + <message>Customer creation failed due to invalid data.</message> |
3455 | + </data_invalid> |
3456 | + <filters_invalid> |
3457 | + <code>103</code> |
3458 | + <message>Invalid data fetch filter.</message> |
3459 | + </filters_invalid> |
3460 | + </faults> |
3461 | + </ol_customer> |
3462 | + <ol_catalog_product_tierprice translate="title" module="catalog"> |
3463 | + <title>Product Tier Price API</title> |
3464 | + <model>openerpconnector/olcatalog_product_tierprice</model> |
3465 | + <acl>catalog/category</acl> |
3466 | + <methods> |
3467 | + <list translate="title" module="catalog"> |
3468 | + <title>Retrieve attribute list</title> |
3469 | + <method>items</method> |
3470 | + </list> |
3471 | + <items2 translate="title" module="catalog"> |
3472 | + <title>Retrieve attribute list</title> |
3473 | + <method>items2</method> |
3474 | + </items2> |
3475 | + </methods> |
3476 | + <faults> |
3477 | + <product_not_exists> |
3478 | + <code>101</code> |
3479 | + <message>Requested product not found.</message> |
3480 | + </product_not_exists> |
3481 | + <filters_invalid> |
3482 | + <code>103</code> |
3483 | + <message>Invalid data fetch filter.</message> |
3484 | + </filters_invalid> |
3485 | + </faults> |
3486 | + </ol_catalog_product_tierprice> |
3487 | + <ol_catalog_product translate="title" module="core"> |
3488 | + <title>Address Management</title> |
3489 | + <model>openerpconnector/olcatalog_products</model> |
3490 | + <acl>catalog/product</acl> |
3491 | + <methods> |
3492 | + <search translate="title" module="core"> |
3493 | + <title>Return the list of products ids that match with the filter</title> |
3494 | + <method>search</method> |
3495 | + </search> |
3496 | + <list translate="title" module="core"> |
3497 | + <title>Enumerate Products</title> |
3498 | + <method>items</method> |
3499 | + </list> |
3500 | + <create translate="title" module="core"> |
3501 | + <title>Create Products</title> |
3502 | + <method>create</method> |
3503 | + </create> |
3504 | + <biglist translate="title" module="core"> |
3505 | + <title>Fetch detail of products</title> |
3506 | + <method>biglist</method> |
3507 | + </biglist> |
3508 | + <update translate="title" module="core"> |
3509 | + <title>Update groups info</title> |
3510 | + <method>update</method> |
3511 | + </update> |
3512 | + <delete translate="title" module="core"> |
3513 | + <title>Delete groups</title> |
3514 | + <method>delete</method> |
3515 | + </delete> |
3516 | + </methods> |
3517 | + <faults module="core"> |
3518 | + <customer_not_exists> |
3519 | + <code>101</code> |
3520 | + <message>Requested Customer not found.</message> |
3521 | + </customer_not_exists> |
3522 | + <data_invalid> |
3523 | + <code>102</code> |
3524 | + <message>group creation failed due to invalid data.</message> |
3525 | + </data_invalid> |
3526 | + <filters_invalid> |
3527 | + <code>103</code> |
3528 | + <message>Invalid data fetch filter.</message> |
3529 | + </filters_invalid> |
3530 | + </faults> |
3531 | + </ol_catalog_product> |
3532 | + <ol_catalog_product_attributeset translate="title" module="core"> |
3533 | + <title>Attribute Set Management</title> |
3534 | + <model>openerpconnector/olcatalog_product_attributeset</model> |
3535 | + <acl>catalog/product</acl> |
3536 | + <methods> |
3537 | + <list translate="title" module="core"> |
3538 | + <title>Enumerate Attribute sets</title> |
3539 | + <method>items</method> |
3540 | + </list> |
3541 | + </methods> |
3542 | + <faults module="core"> |
3543 | + <customer_not_exists> |
3544 | + <code>101</code> |
3545 | + <message>Requested Customer not found.</message> |
3546 | + </customer_not_exists> |
3547 | + <data_invalid> |
3548 | + <code>102</code> |
3549 | + <message>group creation failed due to invalid data.</message> |
3550 | + </data_invalid> |
3551 | + <filters_invalid> |
3552 | + <code>103</code> |
3553 | + <message>Invalid data fetch filter.</message> |
3554 | + </filters_invalid> |
3555 | + </faults> |
3556 | + </ol_catalog_product_attributeset> |
3557 | + <ol_catalog_product_link> |
3558 | + <title>Product Link</title> |
3559 | + <model>openerpconnector/olcatalog_product_link</model> |
3560 | + <acl>catalog/product</acl> |
3561 | + <methods> |
3562 | + <list translate="title" module="core"> |
3563 | + <title>Enumerate configurable Products</title> |
3564 | + <method>items</method> |
3565 | + </list> |
3566 | + <assign translate="title" module="catalog"> |
3567 | + <title>Assign simple product in configurable product</title> |
3568 | + </assign> |
3569 | + <remove translate="title" module="catalog"> |
3570 | + <title>Remove simple products in configurable product</title> |
3571 | + </remove> |
3572 | + <listSuperAttributes translate="title" module="catalog"> |
3573 | + <title>Get configurable attribute values for a configurable product</title> |
3574 | + </listSuperAttributes> |
3575 | + <createSuperAttribute translate="title" module="catalog"> |
3576 | + <title>Create configurable attribute for a configurable product</title> |
3577 | + </createSuperAttribute> |
3578 | + <removeSuperAttribute translate="title" module="catalog"> |
3579 | + <title>Remove super attribute</title> |
3580 | + </removeSuperAttribute> |
3581 | + <setSuperAttributeValues translate="title" module="catalog"> |
3582 | + <title>Set configurable attribute values for super attribute</title> |
3583 | + </setSuperAttributeValues> |
3584 | + </methods> |
3585 | + </ol_catalog_product_link> |
3586 | + <sales_order translate="title" module="Openlabs_OpenERPConnector"> |
3587 | + <model>sales/order_api</model> |
3588 | + <title>Custom Sales Orders API</title> |
3589 | + <methods> |
3590 | + <search translate="title" module="Openlabs_OpenERPConnector"> |
3591 | + <title>Return the list of products ids that match with the filter</title> |
3592 | + <method>search</method> |
3593 | + </search> |
3594 | + <retrieve translate="title" module="Openlabs_OpenERPConnector"> |
3595 | + <title>Retrieve list of orders by filters, nb max, etc...</title> |
3596 | + <method>retrieveOrders</method> |
3597 | + </retrieve> |
3598 | + <done translate="title" module="Openlabs_OpenERPConnector"> |
3599 | + <title>Set Flag to TRUE for imported orders</title> |
3600 | + <method>setFlagForOrder</method> |
3601 | + </done> |
3602 | + <get_child translate="title" module="Openlabs_OpenERPConnector"> |
3603 | + <title>get The Child of The Order Edited</title> |
3604 | + <method>getOrderChild</method> |
3605 | + </get_child> |
3606 | + <get_parent translate="title" module="Openlabs_OpenERPConnector"> |
3607 | + <title>get The Parent of the order annulated</title> |
3608 | + <method>getOrderParent</method> |
3609 | + </get_parent> |
3610 | + <get_invoice_ids translate="title" module="Openlabs_OpenERPConnector"> |
3611 | + <title>get The Invoices Increment ids of the order</title> |
3612 | + <method>getInvoiceIds</method> |
3613 | + </get_invoice_ids> |
3614 | + <get_shipment_ids translate="title" module="Openlabs_OpenERPConnector"> |
3615 | + <title>get The Shipment Increment ids of the order</title> |
3616 | + <method>getShipmentIds</method> |
3617 | + </get_shipment_ids> |
3618 | + </methods> |
3619 | + </sales_order> |
3620 | + <catalog_product translate="title" module="catalog"> |
3621 | + <title>Product API</title> |
3622 | + <model>catalog/product_api</model> |
3623 | + <acl>catalog/product</acl> |
3624 | + <methods> |
3625 | + <create_bundle translate="title" module="Openlabs_OpenERPConnector"> |
3626 | + <title>Create Bundle Products with Custom Options and Bundle Items</title> |
3627 | + <method>createBundleProducts</method> |
3628 | + </create_bundle> |
3629 | + </methods> |
3630 | + </catalog_product> |
3631 | + <oerp_catalog_category translate="title" module="Openlabs_OpenERPConnector"> |
3632 | + <title>Product Category API</title> |
3633 | + <model>openerpconnector/oerpcatalog_category_api</model> |
3634 | + <acl>catalog/category/move</acl> |
3635 | + <methods> |
3636 | + <search translate="title" module="core"> |
3637 | + <title>Return the list of product category ids that match with the filter</title> |
3638 | + <method>search</method> |
3639 | + </search> |
3640 | + <move translate="title" module="Openlabs_OpenERPConnector"> |
3641 | + <title>Move category in tree</title> |
3642 | + <method>move</method> |
3643 | + </move> |
3644 | + </methods> |
3645 | + </oerp_catalog_category> |
3646 | + |
3647 | + <oerp_cataloginventory_stock_item translate="title" module="Openlabs_OpenERPConnector"> |
3648 | + <model>openerpconnector/oerpstock_item_api</model> |
3649 | + <title>Inventory API</title> |
3650 | + <acl>cataloginventory</acl> |
3651 | + <methods> |
3652 | + <update translate="title" module="Openlabs_OpenERPConnector"> |
3653 | + <title>Update product stock data</title> |
3654 | + <acl>cataloginventory/update</acl> |
3655 | + <method>update</method> |
3656 | + </update> |
3657 | + <massive_update translate="title" module="Openlabs_OpenERPConnector"> |
3658 | + <title>Massive Update product stock data</title> |
3659 | + <acl>cataloginventory/update</acl> |
3660 | + <method>massive_update</method> |
3661 | + </massive_update> |
3662 | + </methods> |
3663 | + <faults module="cataloginventory"> |
3664 | + <product_not_exists> |
3665 | + <code>101</code> |
3666 | + <message>Product not exists.</message> |
3667 | + </product_not_exists> |
3668 | + <not_updated> |
3669 | + <code>102</code> |
3670 | + <message>Product inventory not updated. Details in error message.</message> |
3671 | + </not_updated> |
3672 | + </faults> |
3673 | + </oerp_cataloginventory_stock_item> |
3674 | + </resources> |
3675 | + </api> |
3676 | +</config> |
3677 | |
3678 | === added file 'Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/etc/config.xml' |
3679 | --- Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/etc/config.xml 1970-01-01 00:00:00 +0000 |
3680 | +++ Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/etc/config.xml 2013-07-31 04:42:30 +0000 |
3681 | @@ -0,0 +1,88 @@ |
3682 | +<?xml version="1.0"?> |
3683 | +<config> |
3684 | + <modules> |
3685 | + <Openlabs_OpenERPConnector> |
3686 | + <version>0.0.1</version> |
3687 | + </Openlabs_OpenERPConnector> |
3688 | + </modules> |
3689 | + <frontend> |
3690 | + <routers> |
3691 | + <openerpconnector> |
3692 | + <use>standard</use> |
3693 | + <args> |
3694 | + <module>Openlabs_OpenERPConnector</module> |
3695 | + <frontName>openerpconnector</frontName> |
3696 | + </args> |
3697 | + </openerpconnector> |
3698 | + </routers> |
3699 | + </frontend> |
3700 | + <global> |
3701 | + <models> |
3702 | + <openerpconnector> |
3703 | + <class>Openlabs_OpenERPConnector_Model</class> |
3704 | + </openerpconnector> |
3705 | + <sales> |
3706 | + <rewrite> |
3707 | + <order_api>Openlabs_OpenERPConnector_Model_Sales_Order_Api</order_api> |
3708 | + </rewrite> |
3709 | + </sales> |
3710 | + <catalog> |
3711 | + <rewrite> |
3712 | + <product_api>Openlabs_OpenERPConnector_Model_Catalog_Product_Api</product_api> |
3713 | + </rewrite> |
3714 | + </catalog> |
3715 | + </models> |
3716 | + <resources> |
3717 | + <openerpconnector_setup> |
3718 | + <setup> |
3719 | + <module>Openlabs_OpenERPConnector</module> |
3720 | + </setup> |
3721 | + <connection> |
3722 | + <use>core_setup</use> |
3723 | + </connection> |
3724 | + </openerpconnector_setup> |
3725 | + <openerpconnector_write> |
3726 | + <connection> |
3727 | + <use>core_write</use> |
3728 | + </connection> |
3729 | + </openerpconnector_write> |
3730 | + <openerpconnector_read> |
3731 | + <connection> |
3732 | + <use>core_read</use> |
3733 | + </connection> |
3734 | + </openerpconnector_read> |
3735 | + </resources> |
3736 | + <blocks> |
3737 | + <openerpconnector> |
3738 | + <class>Openlabs_OpenERPConnector_Block</class> |
3739 | + </openerpconnector> |
3740 | + </blocks> |
3741 | + <helpers> |
3742 | + <openerpconnector> |
3743 | + <class>Openlabs_OpenERPConnector_Helper</class> |
3744 | + </openerpconnector> |
3745 | + </helpers> |
3746 | + <events> |
3747 | + <sales_order_place_after> |
3748 | + <observers> |
3749 | + <init_imported_after_place_order> |
3750 | + <type>singleton</type> |
3751 | + <class>openerpconnector/observer</class> |
3752 | + <method>initImported</method> |
3753 | + </init_imported_after_place_order> |
3754 | + </observers> |
3755 | + </sales_order_place_after> |
3756 | + </events> |
3757 | + </global> |
3758 | + <admin> |
3759 | + <routers> |
3760 | + <openerpconnector> |
3761 | + <use>admin</use> |
3762 | + <args> |
3763 | + <module>Openlabs_OpenERPConnector</module> |
3764 | + <frontName>connector</frontName> |
3765 | + </args> |
3766 | + </openerpconnector> |
3767 | + </routers> |
3768 | + </admin> |
3769 | +</config> |
3770 | \ No newline at end of file |
3771 | |
3772 | === added directory 'Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/sql' |
3773 | === added directory 'Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/sql/openerpconnector_setup' |
3774 | === added file 'Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/sql/openerpconnector_setup/mysql4-install-0.0.1.php' |
3775 | --- Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/sql/openerpconnector_setup/mysql4-install-0.0.1.php 1970-01-01 00:00:00 +0000 |
3776 | +++ Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/sql/openerpconnector_setup/mysql4-install-0.0.1.php 2013-07-31 04:42:30 +0000 |
3777 | @@ -0,0 +1,54 @@ |
3778 | +<?php |
3779 | +/** |
3780 | + * |
3781 | + * @author Mohammed NAHHAS |
3782 | + * @package Openlabs_OpenERPConnector |
3783 | + * |
3784 | + */ |
3785 | + |
3786 | +/* Retrieve the version of Magento */ |
3787 | +$version = Mage::getVersion(); |
3788 | + |
3789 | +/* Need to add a sales_order attribute if the version < 1.4.x.x - sales_order is an EAV Model */ |
3790 | +/* Else add a simple column to sales_flat_order Table */ |
3791 | +$version = str_replace('.','',$version); |
3792 | +if($version >= 1400) { |
3793 | + $installer = $this; |
3794 | + $installer->startSetup(); |
3795 | + $tableName='sales_flat_order'; |
3796 | + $db = $installer->getConnection(); |
3797 | + |
3798 | + /* Delete the column if it exists before re-create it */ |
3799 | + if($db->tableColumnExists($this->getTable($tableName), 'imported')) { |
3800 | + $installer->run("ALTER TABLE {$this->getTable($tableName)} drop column imported"); |
3801 | + } |
3802 | + |
3803 | + /* re-create 'imported' column */ |
3804 | + if(!$db->tableColumnExists($this->getTable($tableName), 'imported')) { |
3805 | + $installer->run(" |
3806 | + ALTER TABLE {$this->getTable($tableName)} ADD imported tinyint(1) unsigned NOT NULL default '0'; |
3807 | + "); |
3808 | + } |
3809 | +}else{ |
3810 | + $installer = new Mage_Eav_Model_Entity_Setup('core_setup'); |
3811 | + $installer->startSetup(); |
3812 | + |
3813 | + /* Attribute Data */ |
3814 | + $attribute_data = array( |
3815 | + 'type' => 'int', |
3816 | + 'default' => 0, |
3817 | + 'visible' => false, |
3818 | + 'required' => false, |
3819 | + 'user_defined' => false, |
3820 | + 'searchable' => false, |
3821 | + 'filterable' => false, |
3822 | + 'comparable' => false |
3823 | + ); |
3824 | + /* Add a sales_order attribute named 'imported' */ |
3825 | + $installer->addAttribute('order', 'imported', $attribute_data); |
3826 | + |
3827 | +} |
3828 | + |
3829 | + |
3830 | +/* End */ |
3831 | +$installer->endSetup(); |
3832 | |
3833 | === added directory 'Openlabs_OpenERPConnector-1.1.0/app' |
3834 | === added directory 'Openlabs_OpenERPConnector-1.1.0/app/etc' |
3835 | === added directory 'Openlabs_OpenERPConnector-1.1.0/app/etc/modules' |
3836 | === added file 'Openlabs_OpenERPConnector-1.1.0/app/etc/modules/Openlabs_OpenERPConnector.xml' |
3837 | --- Openlabs_OpenERPConnector-1.1.0/app/etc/modules/Openlabs_OpenERPConnector.xml 1970-01-01 00:00:00 +0000 |
3838 | +++ Openlabs_OpenERPConnector-1.1.0/app/etc/modules/Openlabs_OpenERPConnector.xml 2013-07-31 04:42:30 +0000 |
3839 | @@ -0,0 +1,41 @@ |
3840 | +<?xml version="1.0"?> |
3841 | + |
3842 | +<!-- |
3843 | +############################################################################## |
3844 | +# |
3845 | +# OpenERP, Open Source Management Solution |
3846 | +# Copyright (C) 2004-2008 Tiny SPRL (<http://tiny.be>). All Rights Reserved |
3847 | +# Sharoon Thomas |
3848 | +# |
3849 | +# This program is free software: you can redistribute it and/or modify |
3850 | +# it under the terms of the GNU General Public License as published by |
3851 | +# the Free Software Foundation, either version 3 of the License, or |
3852 | +# (at your option) any later version. |
3853 | +# |
3854 | +# This program is distributed in the hope that it will be useful, |
3855 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
3856 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3857 | +# GNU General Public License for more details. |
3858 | +# |
3859 | +# You should have received a copy of the GNU General Public License |
3860 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
3861 | +# |
3862 | +############################################################################## |
3863 | +# * @category Community |
3864 | +# * @package |
3865 | +# * @copyright Copyright (c) 2009 Sharoon Thomas, openlabs.co.in |
3866 | +# * @license GPL-3 |
3867 | +# */ |
3868 | +--> |
3869 | +<config> |
3870 | + <modules> |
3871 | + <Openlabs_OpenERPConnector> |
3872 | + <codePool>community</codePool> |
3873 | + <active>true</active> |
3874 | + <depends> |
3875 | + <Mage_Api /> |
3876 | + <Mage_Catalog /> |
3877 | + </depends> |
3878 | + </Openlabs_OpenERPConnector> |
3879 | + </modules> |
3880 | +</config> |
3881 | |
3882 | === added file 'package.xml' |
3883 | --- package.xml 1970-01-01 00:00:00 +0000 |
3884 | +++ package.xml 2013-07-31 04:42:30 +0000 |
3885 | @@ -0,0 +1,84 @@ |
3886 | +<?xml version="1.0" encoding="UTF-8"?> |
3887 | +<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 |
3888 | + http://pear.php.net/dtd/tasks-1.0.xsd |
3889 | + http://pear.php.net/dtd/package-2.0 |
3890 | + http://pear.php.net/dtd/package-2.0.xsd"> |
3891 | + <name>Openlabs_OpenERPConnector</name> |
3892 | + <channel>connect.magentocommerce.com/community</channel> |
3893 | + <summary>Magento extension for multiwebsite Open ERP connector by Open Labs</summary> |
3894 | + <description>This magento extension provides additional API methods for use by the Multi website, Multi Store, Multi Product category synchronization connector. |
3895 | + |
3896 | +Contents: |
3897 | + |
3898 | +Magento Websites API |
3899 | +Magento Stores(groups) API |
3900 | +Magento Store Views API |
3901 | +Magento Category Images API (Partial : list, info, create) |
3902 | + |
3903 | +Contact sharoon.thomas@openlabs.co.in for further details</description> |
3904 | + <lead> |
3905 | + <name>Sharoon Thomas</name> |
3906 | + <user>sharoonthomas</user> |
3907 | + <email>sharoonthomas@teagarden.in</email> |
3908 | + <active>yes</active> |
3909 | + </lead> |
3910 | + <date>2009-08-27</date> |
3911 | + <time>15:23:56</time> |
3912 | + <version> |
3913 | + <release>1.1.0</release> |
3914 | + <api>2.0</api> |
3915 | + </version> |
3916 | + <stability> |
3917 | + <release>beta</release> |
3918 | + <api>beta</api> |
3919 | + </stability> |
3920 | + <license>GPL</license> |
3921 | + <notes>Magento Websites API |
3922 | +Magento Stores(groups) API |
3923 | +Magento Store Views API |
3924 | +Magento Category Images API</notes> |
3925 | + <contents> |
3926 | + <dir name="/"> |
3927 | + <dir name="app"> |
3928 | + <dir name="etc"> |
3929 | + <dir name="modules"> |
3930 | + <file md5sum="fc14d089cce44cc1e2ac08fa6c6c20a6" name="Openlabs_OpenERPConnector.xml" role="mage" /> |
3931 | + </dir> <!-- /app/etc/modules --> |
3932 | + </dir> <!-- /app/etc --> |
3933 | + </dir> <!-- /app --> |
3934 | + <dir name="Openlabs"> |
3935 | + <dir name="OpenERPConnector"> |
3936 | + <dir name="etc"> |
3937 | + <file md5sum="12668c63dc2e626940c5651510acdd95" name="api.xml" role="magecommunity" /> |
3938 | + <file md5sum="c9ab22309066dc8d181061a0f158dc6f" name="config.xml" role="magecommunity" /> |
3939 | + </dir> <!-- /Openlabs/OpenERPConnector/etc --> |
3940 | + <dir name="Helper"> |
3941 | + <file md5sum="a2ea05cfc56bcd06be442f75844e3fc1" name="Data.php" role="magecommunity" /> |
3942 | + </dir> <!-- /Openlabs/OpenERPConnector/Helper --> |
3943 | + <dir name="Model"> |
3944 | + <dir name="Olcatalog"> |
3945 | + <file md5sum="43c11c180f0f1ccfc576bb0d8b238015" name="Categories.php" role="magecommunity" /> |
3946 | + </dir> <!-- /Openlabs/OpenERPConnector/Model/Olcatalog --> |
3947 | + <dir name="Olcore"> |
3948 | + <file md5sum="568a59414cd61bb14dd9899bd3d74edc" name="Groups.php" role="magecommunity" /> |
3949 | + <file md5sum="03e476e465b5794d8deee99fd027d35c" name="Storeviews.php" role="magecommunity" /> |
3950 | + <file md5sum="5abd4c8db3b68b4dfd5bdd7ebbb7ec93" name="Website.php" role="magecommunity" /> |
3951 | + </dir> <!-- /Openlabs/OpenERPConnector/Model/Olcore --> |
3952 | + </dir> <!-- /Openlabs/OpenERPConnector/Model --> |
3953 | + </dir> <!-- /Openlabs/OpenERPConnector --> |
3954 | + </dir> <!-- /Openlabs --> |
3955 | + </dir> <!-- / --> |
3956 | + </contents> |
3957 | + <dependencies> |
3958 | + <required> |
3959 | + <php> |
3960 | + <min>5.2.0</min> |
3961 | + <max>6.0.0</max> |
3962 | + </php> |
3963 | + <pearinstaller> |
3964 | + <min>1.6.2</min> |
3965 | + </pearinstaller> |
3966 | + </required> |
3967 | + </dependencies> |
3968 | + <phprelease /> |
3969 | +</package> |
This is likely a manipulation mistake, so I put this MP as "rejected".