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?
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
);
catalog_product_after_save
event, only catalog_product_attribute_update_before
and catalog_product_attribute_update_after
which might not reindex things or clear caches as you might expect, so use it carefully.
You can use the saveAttribute
method of Mage_Eav_Model_Entity_Abstract
which Mage_Catalog_Model_Resource_Abstract
extends:
$id = 905;
$attributeCode = 'name';
$product = Mage::getModel('catalog/product');
$product->setStoreId(0);
$product->setId($id);
$product->setName('8GB Memory Card');
$product->getResource()->saveAttribute($product, $attributeCode);
Note that this will not work with attributes that have a static backend type like sku. Sku is actually a field in catalog_product_entity
table.