2

I want to save the order id and quote id in my custom table(collection).Give me some solution. My observer function is

public function placeOrderAfter($event) {

        try {

            $order_id = $event->getEvent()->getOrder()->getId();
            $order = Mage::getModel('sales/order')->load($order_id);
            $quote_id = $order->getQuoteId();           
           Mage::helper("comp/connection")->updatesaveorder($order_id,$order->getCustomerId());

        } catch (Exception $e) {
            Mage::log($e->getMessage());
        }

}`

after putting this code order is not placed .

1

1 Answer 1

7

Using observer event "sales_order_place_after" you can save data in your custom table.

In your module's app/code/local/Namespace/Module/etc/config.xml add code like

<events>
        <sales_order_place_after>
            <observers>
                <namespace_module_order_observer>
                    <type>singleton</type>
                    <class>module/observer</class>
                    <method>customOrderSave</method>
                </namespace_module_order_observer>
            </observers>
        </sales_order_place_after>
</events>

Create observer file app/code/local/Namespace/Module/Model/Observer.php:

public function customOrderSave($observer)
{
    $order = $observer->getOrder();
    //add your code here
}

}

1
  • may be it throws error in updatesaveorder() function. Please check error log Jul 21, 2016 at 5:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.