Magento – set product attribute without loading full product

attributesproduct

Mage::getResourceModel('catalog/product')->getAttributeRawValue($id, 'attribute', Mage::app()->getStore());

This can be used to fetch the product attribute by ID. How can one set this value as well?

Best Answer

For that you'll want the Mage_Catalog_Model_Product_Action model.

Mage::getSingleton('catalog/product_action')->updateAttributes(
    array(100, 200, 300),               // Product IDs to update
    array('my_attribute'=>'new value'), // Key/value pairs of attributes and their values
    1                                   // Store ID
);