Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Programmatically setting a custom customer attribute

Is it possible to programmatically set the value of a custom customer attribute? I have scoured the internet for an answer to this, but to no avail :(.

I know that you can access one using this method:

$customer = Mage::getSingleton('customer/session')->getCustomer();
$measurements_taken = $customer->getResource()->getAttribute('measurements_taken')->getFrontend()->getValue($customer);

but I'm not too sure on how to set the value of this attribute. I tried the following:

$customer = Mage::getSingleton('customer/session')->getCustomer();
$customer->setMeasurementsTaken('TO_CHECK');
$customer->saveAttribute($customer,'measurements_taken');

but it throws an error saying something about an invalid method.

like image 542
NateTheGreatt Avatar asked Jun 24 '26 07:06

NateTheGreatt


1 Answers

After making your updates,

$customer->save();

or

$customer->setMeasurementsTaken('TO_CHECK')->save();
like image 60
benmarks Avatar answered Jun 26 '26 20:06

benmarks



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!