Cannot update Stock Item Quantity for a Product in Magento 1.6.2

前端 未结 4 397
感动是毒
感动是毒 2020-12-16 06:25

I am trying to update the stock quantities of products in Magento from within a script.

I load the product, set the stock quantity, and save - but the quantity remai

4条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-16 07:06

    In my case I got the same problem with products that I've imported programmatically. I just realized that I forgot to add stock_data in the array...

    'name' => $productName,
    'stock_data' => array(
                            'use_config_manage_stock' => 0,
                            'manage_stock' => 0,
                            'qty' => 0,
                            'stock_id' => 1,
                            'min_qty' => 0,
                        )
    

    Without stock data information, Magento generates an exception(at \Mage_CatalogInventory_Model_Stock_Item) when adding product to cart.

    With this node, it works. =)

提交回复
热议问题