Simple example using magento event observer

Magento’s Event observer concept is about raising events in key areas in an application flow. An Event is an action that takes place during normal program execution. Eg: Product saved,order placed,etc.

Observer is the event handler. Customizing Magento using Event observer allows us to add our own logic in addition to the core logic without changing any core code.

The Sample Module illustrated here will trigger an event whenever a new product is added to the shopping cart. Here we will write our own observer (event handler) to handle this event. Our observer
will display the currently triggered event name and product name along with the success message.

Step 1: Create the below folders in app/code/local/Mydons/Eventdemo/etc,app/code/local/Mydons/Eventdemo/Model. In this example Mydons is the companyname and Eventdemo is the module name.You can use your own companyname and modulename.

Step 2: Lets create the module activation file Mydons_Eventdemo.xml and place it in app/etc/modules/ directory

<?xml version="1.0"?> <config> <modules> <Mydons_Eventdemo> <active>true</active> <codePool>local</codePool> </Mydons_Eventdemo> </modules> </config>

Step 3: Next step is to create our config.xml file and place it in app/code/local/Mydons/Eventdemo/etc folder

Step 4: Finally we are going to create our Model class file observer.php. Save the Model file in app/code/local/Mydons/Eventdemo/Model/ folder.

Step 5: Thats it we finished our module. Now go to frontend and add any product to the shopping cart. Our observer will be called.
In addition to the default success message our custom modules message will be added.
If you need the list of magento events as of 1.4.2 Please visit the below site
Magento 1.4.2.0 Events Cheatsheet

Requirement :- Magento
Download :-http://mydons.com/download/75b5411e5c83ea7e9a8f9f80d0746f21/magentoeventobserver.zip
License :- License Free