I'm trying to update the stock quantity in magento manually. I know it's possible but I don't know how to proceed...

I want to update the stock from a web service, and I'm searching how to list all my articles. Then, get the id of the article, send it to the web service, get the stock provides by the web service and to finish, update the stock in the database of Magento.

I'm a new user of Magento and your help will be really appreciate :)

Thank you so much guys!

有帮助吗?

解决方案

3 tables are mainly used to manage the stock : cataloginventory_stock, cataloginventory_stock_item and cataloginventory_stock_status

If you need to update a product's stock quantity you will need to find the relevant line in the cataloginventory_stock_item table and edit the qty field:

Example (set qty to 100 for product ID 33) :

UPDATE cataloginventory_stock_item set qty=100 where product_id=33

其他提示

Exist following solution

$stockItem = Mage::getModel('cataloginventory/stock_item');
Mage::getResourceModel('cataloginventory/stock_item')->loadByProductId($stockItem, $allProductsIDs[$sku]);

$dataStock['sku'] = $sku;
$dataStock['qty'] = $qty;
$dataStock['is_in_stock'] = $isInStock;
$dataStock['manage_stock'] = $stockData['manage_stock'];
$dataStock['use_config_manage_stock'] = $stockData['use_config_manage_stock'];

foreach($dataStock as $key1=>$value1) {
$stockItem->setData($key1, $value1);
}

$stockItem->save();
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top