Magento: save model object attribute value

Save a single attribute value of a customer, using the saveAttribute function. This is more efficient than save for saving only one attribute value.
[code language=”php”]
$customer = Mage::getSingleton(‘customer/customer’)->load(12345);
$customer->setEmail(‘dummy@dummy.com’);
$customer->getResource()->saveAttribute($customer,’email’);
[/code]

Save multiple attributes of a customer, using the setData() to set the values, and then call save()
[code language=”php”]
$customer = Mage::getSingleton(‘customer/customer’)->load(12345);
$data = array(’email’=>’dummy@dummy.com’,’firstname’=>’dummy’); // email and firstname are the attribute_code of the the customer object
$customer->setData($data);
$customer->save();
[/code]

Search within Codexpedia

Custom Search

Search the entire web

Custom Search