For 45.000+ products I want to update a specific date attribute.
I use this custom attribute "new_stock", that all needs the value of "01-01-2000".
How can I easily update this attribute for all these products?
I tried this code, inside a custom .php file and run it by browser.
But that did not work
<?php
$products = Mage::getModel('catalog/product')->getCollection()
->addAttributeToFilter('entity_id', array('in' => $productIds));
foreach($products as $product)
{
$product->setNewStock('2000-01-01');
// below code use for time format
$product->setNewStockIsFormated(true);
$product->getResource()->saveAttribute($product, 'new_stock');
}?>
Best Answer
Credit to @VishwasBhatnagar for the code - I'm just clarifying what I believe the finished code should be, to do all products (the to-and-fro in the comments was getting a bit confusing I think).