Event & observer is one of the most powerful features which we can use in any custom module. Generally, Magento uses a different kind of events which are fired/dispatched by Magento throughout its code base. Each event has class objects (data array) attached as function parameters & the observer class receive this class object when the certain event is fired. In a simple way, Observer is act like a listener which is used to detect the event. Observer always waits for an event so that it can execute the event whenever the event is fired.
Magneto uses Mage::dispatchEvent function to fire an event, you can find this inside the core files ofMagentoo.
2. Now, Create Observer.php file to execute the event observer is located in the Model directory of your module and extends the Varien_Event_Observer class Path: /app/code/local/Namespace/Modulename/Model/ folder and create a file Observer.php:
class Namespace_Modulename_Model_Observer extends Varien_Event_Observer
public function saveOrderAfter($observer)
$order = $observer->getOrder();
$quote = $observer->getQuote();