$products = Mage::getModel('catalog/product')->getCollection();
// filter your product list
$products = $products->addFieldToFilter($attribute_code, $attribute_value)->load();
foreach($products as $product){
$stockItem = Mage::getModel('cataloginventory/stock_item')->loadByProduct($product);
$stockItem->setData('is_in_stock', 1);
$stockItem->setData('qty',1);
$stockItem->save();
}
This is my blog about Magento. I'm new to it. Had some hard time to get into it. Especially to find good documentation on the newest version of Magento Community Edition. So i decided to document my way to setup my own nice web shop to help others ;-) You'll find also some mac/os x and python related stuff here
Sunday, November 23, 2014
Bulk update products to be in/out of stock programatically
This is an example to set all (filtered) products to be in stock with quantity of 1.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment