I want to set the images to 'use default value' for a list of product, and for a list of store view. I know how to do it individually for each product : setData(attributeName,false), and so i can do a loop over my list of product. Problem: it's really too slow.
$attrArray=array('thumbnail','small_image','image');
$products = array(170,171,172);
$stores = array(17,18,19);
foreach ($stores as $store_id) {
foreach ($products as $product_id) {
foreach ($attrArray as $attr) {
$product = Mage::getModel('catalog/product')
->load($product_id)->setStoreId($store_id)
->setData($attr, false)
->save();
}
}
}
So i've try to use Mage::getSingleton('catalog/product_action')->updateAttributes($products, $attrArray, $store_id); instead, which is supposed to do the same thing but over a list of products. It actually do something : all my images are now set to 'no images', but not to 'Use default value' as expected.
$attrArray = array('thumbnail'=>false,'small_image'=>false,'image'=>false);
$products = array(170,171,172);
$stores = array(17,18,19);
foreach ($stores as $store_id) {
Mage::getSingleton('catalog/product_action')
->updateAttributes($products, $attrArray, $store_id);
}
If someone around here have an idea, it could really help me to save some time ! Thanks.