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
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 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.
Revision history for this message
Guewen Baconnier @ Camptocamp (gbaconnier-c2c) wrote :

Thanks!

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Oerpstock/Item/Api.php'
--- Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Oerpstock/Item/Api.php 2012-10-07 16:24:04 +0000
+++ Openlabs_OpenERPConnector-1.1.0/Openlabs/OpenERPConnector/Model/Oerpstock/Item/Api.php 2014-05-06 09:57:31 +0000
@@ -29,7 +29,16 @@
2929
30 protected function _getProduct($productId, $store = null, $identifierType = 'id')30 protected function _getProduct($productId, $store = null, $identifierType = 'id')
31 {31 {
32 $product = Mage::helper('catalog/product')->getProduct($productId, $this->_getStoreId($store), $identifierType);32 if(is_callable(array(Mage::helper('catalog/product'), 'getProduct'))){
33 $product = Mage::helper('catalog/product')->getProduct($productId, $this->_getStoreId($store), $identifierType);
34 } else {
35 /* support for older magento versions, e.g. 1.4.2.0 */
36 $product = Mage::getModel('catalog/product')->setStoreId(Mage::app()->getStore($store)->getId());
37 if($identifierType == 'id'){
38 $product->load((int) $productId);
39 }
40 }
41
33 if (is_null($product->getId())) {42 if (is_null($product->getId())) {
34 $this->_fault('product_not_exists');43 $this->_fault('product_not_exists');
35 }44 }
@@ -46,7 +55,7 @@
4655
47 if (!$stockItemId) {56 if (!$stockItemId) {
48 $stockItem->setData('product_id', $productId);57 $stockItem->setData('product_id', $productId);
49 $stockItem->setData('stock_id', 1); 58 $stockItem->setData('stock_id', 1);
50 } else {59 } else {
51 $stock = $stockItem->getData();60 $stock = $stockItem->getData();
52 }61 }