I have created a new attribute serial number for all the products. Now I don’t know how to set its value when order is completed. I know where to change it but I don’t have the function. Here is the code. The new attribute have the code “serial_number”.
if($status == 'complete'){
foreach ($this->getAllItems() as $item) {
// Here I want to update the value, I am sure something like the following will work.
$this->setAttribute($item, 'serial_number', '123');
}
}
Also what should be the settings for it in admin. I am changing the value when the status for the order is changed to complete.
You seem to be setting the attribute, but where is the code to save() the item to the db