Create a event observer after order submit Magento 1x

Create a event observer after order submit. Bellow code is need to add in your module path/etc/config.xml if you have already adminhtml tag then just ignore adminhtml tag. in bellow code Trenza_Prescription is the module name. and class is the class name of which trigger it do when observer event run. Method is which class function run for this observer event.


Now add this class on your magento module model create a file name Observer.php

Class Trenza_Prescription_Model_Observer
    public function updatePrescription($observer) {
        #echo 'hi';
        #print_r(Mage::app()->getRequest()->getParams()) ;
        #$order_id = $observer->getReservedOrderId();
        $order = $observer->getEvent()->getOrder();
        $order_id = $order->getId();
        $session = Mage::getSingleton('core/session', array ('name' => 'backend'));
        #echo Mage::getSingleton('core/session')->setOrdersession2('hello');
        $prescription_id = Mage::getSingleton('core/session')->getOrdersession();
        $data = array('orderid'=>$order_id);
        $model = Mage::getModel('prescription/prescription')->load($prescription_id)->addData($data);
        try {
                #echo "Data updated successfully.";
            } catch (Exception $e){
                echo $e->getMessage(); 

Leave a Reply