Magento – Bulk update configurable products

product

I recently migrated from Volusion to Magento using Cart2Cart. Most of my products are configurable and are showing "Out of Stock" and quantities set to zero. I have 5,000 products (including variations). My question is, is there a way to do a either do a bulk update, or at least have access to a page where I can see all products at once with the option of setting stock values from that page?

Best Answer

You can do it programatically via a script or an extension. What you need is to load magento object, load product collection

    //load Magento
    $mageFilename = 'app/Mage.php';
    require_once $mageFilename;
    umask(0);
    Mage::app('admin');

    //load products collection        
    $productsCollection = Mage::getModel('catalog/product')->getCollection();
    foreach($productsCollection as $item) {

    //load product object
    $product = Mage::getModel('catalog/product')->load($item->getId());
    //set Is in stock to Yes 
    $stockItem = Mage::getModel('cataloginventory/stock_item')->loadByProduct($product);
    $stockItem->setData('is_in_stock', 1);
    $stockItem->save();
    $product->save();
}

For more information check this thread (perhaps you need to set Manage Stock=Yes, Qty etc.)

After @Marius brilliant answer I decided to update my answer by providing few alternatives in case you don't need the same QTY for ALL products.

1) What you can do is to use Magento Dataflow - Import/Export Profile. You need to export your products, change Qty field and if you enabled the stock control in the administration area I believe this would solve the problem. 2) Also you could check Magmi Mass Importer as it allows to update products 3) And here you can check MASS UPDATE STOCK LEVELS IN MAGENTO – FAST by @Sonassi

Related Topic