Mage_CatalogInventory_Model_Stock_Item_Api_V2 Class Reference

Inheritance diagram for Mage_CatalogInventory_Model_Stock_Item_Api_V2:

Mage_CatalogInventory_Model_Stock_Item_Api Mage_Catalog_Model_Api_Resource Mage_Api_Model_Resource_Abstract

List of all members.

Public Member Functions

 update ($productId, $data)


Detailed Description

Definition at line 34 of file V2.php.


Member Function Documentation

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     }


The documentation for this class was generated from the following file:

Generated on Sat Jul 4 17:23:48 2009 for Magento by  doxygen 1.5.8