Merge lp:~initos.com/magentoerpconnect/magento-module-oerp6.x-stable-fix_inventory_sync_for_old_magentos into lp:magentoerpconnect/magento-module-oerp6.x-stable

Proposed by Katja Matthes on 2014-05-06
Status: Merged
Merged at revision: 41
Proposed branch: lp:~initos.com/magentoerpconnect/magento-module-oerp6.x-stable-fix_inventory_sync_for_old_magentos
Merge into: lp:magentoerpconnect/magento-module-oerp6.x-stable
Diff against target: 30 lines (+11/-2)
1 file modified
Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Oerpstock/Item/Api.php (+11/-2)
To merge this branch: bzr merge lp:~initos.com/magentoerpconnect/magento-module-oerp6.x-stable-fix_inventory_sync_for_old_magentos
Reviewer Review Type Date Requested Status
MagentoERPConnect core editors 2014-05-06 Pending
Review via email: mp+218374@code.launchpad.net

Description of the change

For older magento versions (e.g. 1.4.2.0) inventory synchronization from OpenERP to Magento didn't work, because a helper method is missing: In old magento versions there is no function 'getProduct' in the catalog-product-helper.
Add code to bypass the call to missing function and search product manualy.

To post a comment you must log in.

Thanks!

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Oerpstock/Item/Api.php'
2--- Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Oerpstock/Item/Api.php 2012-10-07 16:24:04 +0000
3+++ Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Oerpstock/Item/Api.php 2014-05-06 09:57:31 +0000
4@@ -29,7 +29,16 @@
5
6 protected function _getProduct($productId, $store = null, $identifierType = 'id')
7 {
8- $product = Mage::helper('catalog/product')->getProduct($productId, $this->_getStoreId($store), $identifierType);
9+ if(is_callable(array(Mage::helper('catalog/product'), 'getProduct'))){
10+ $product = Mage::helper('catalog/product')->getProduct($productId, $this->_getStoreId($store), $identifierType);
11+ } else {
12+ /* support for older magento versions, e.g. 1.4.2.0 */
13+ $product = Mage::getModel('catalog/product')->setStoreId(Mage::app()->getStore($store)->getId());
14+ if($identifierType == 'id'){
15+ $product->load((int) $productId);
16+ }
17+ }
18+
19 if (is_null($product->getId())) {
20 $this->_fault('product_not_exists');
21 }
22@@ -46,7 +55,7 @@
23
24 if (!$stockItemId) {
25 $stockItem->setData('product_id', $productId);
26- $stockItem->setData('stock_id', 1);
27+ $stockItem->setData('stock_id', 1);
28 } else {
29 $stock = $stockItem->getData();
30 }