Home » Php » php – Observer doesn't save order

php – Observer doesn't save order

Posted by: admin July 12, 2020 Leave a comment


I’ve build an observer which listens on the sales_convert_quote_to_order event. The event is triggered and I just want to add a value to an attribute of the order. The attribute is set – as printed in the log – but magento doesn’t save the order. What I’m doing wrong?


public function addLangToOrder($observer){
        Mage::log('catching convert_quote_to_order_after');
        $order = $observer->getEvent()->getOrder();



I’ve added the attribute customer_language through an install script

$customer_lang = 'customer_language';
$installer->addAttribute('order', $customer_lang, array('type'=>'varchar'));

The customer_language column is present in my sales_flat_order table. But it doesn’t get saved.

I’m using Magento

How to&Answers:

You need to add your attribute to both – quote and sales model – to make this work.

As Magento will copy a defined <fieldset>* from quote to order, you need to extend the config.xml of your overriding class accordingly, too:

    <!-- : -->
    <!-- : -->

*see the config.xml of Mages_Sales


is there a transaction occurring before this? its been my experience that trying to save a model when a transaction is still in progress doesn’t work. I had to move the observer to another event after the transaction like “sales_model_service_quote_submit_after” instead.