Reputation: 902
Retrieving the value is easy enough:
$itemIsConsolidated = $productResource->getAttributeRawValue($productId, 'my_attr_code', Mage_Core_Model_App::ADMIN_STORE_ID);
How can I change (update) the value without loading the product model (catalog/product
) and calling setData()
?
Upvotes: 0
Views: 1291
Reputation: 15206
You can do this by simulating what the 'Update attributes' action from the product grid does:
Mage::getModel('catalog/product_action')->updateAttributes(array($productId), array('my_attr_code'=>'Some value here'), 0);
Here is how it works.
The first parameter is an array of product ids that you want to update. In your case it's an array with one id.
The second parameter is an array with the attributes your want changed and their values. You can change multiple attributes at the same time if your array looks like this
array(
'some_attr'=>'Some value',
'some_other_attr'=>'Some other value'
)
The third parameter is the store view for which you change the value. 0 means 'default values'.
Upvotes: 8