Public Member Functions | |
update ($productId, $data) |
Definition at line 34 of file V2.php.
update | ( | $ | productId, | |
$ | data | |||
) |
Reimplemented from Mage_CatalogInventory_Model_Stock_Item_Api.
Definition at line 36 of file V2.php.
00037 { 00038 $product = Mage::getModel('catalog/product'); 00039 00040 if ($newId = $product->getIdBySku($productId)) { 00041 $productId = $newId; 00042 } 00043 00044 $product->setStoreId($this->_getStoreId()) 00045 ->load($productId); 00046 00047 if (!$product->getId()) { 00048 $this->_fault('not_exists'); 00049 } 00050 00051 if (!$stockData = $product->getStockData()) { 00052 $stockData = array(); 00053 } 00054 00055 if (isset($data->qty)) { 00056 $stockData['qty'] = $data->qty; 00057 } 00058 00059 if (isset($data->is_in_stock)) { 00060 $stockData['is_in_stock'] = $data->is_in_stock; 00061 } 00062 00063 if (isset($data->manage_stock)) { 00064 $stockData['manage_stock'] = $data->manage_stock; 00065 } 00066 00067 if (isset($data->use_config_manage_stock)) { 00068 $stockData['use_config_manage_stock'] = $data->use_config_manage_stock; 00069 } 00070 00071 $product->setStockData($stockData); 00072 00073 try { 00074 $product->save(); 00075 } catch (Mage_Core_Exception $e) { 00076 $this->_fault('not_updated', $e->getMessage()); 00077 } 00078 00079 return true; 00080 }