Studyon Minte9.com
Magento




Observers



Like any good object-oriented system, Magento implements an Event/Observer pattern for end users to hook into. 
As certain actions happen during a Page request (a Model is saved, a user logs in, etc.), Magento will issue an 
event signal.

When creating your own Modules, you can "listen" for these events. 
Say you wanted to get an email every time a certain customer logged into the store. 
You could listen for the "customer_login" event (setup in config.xml)

	<events>
	    <customer_login>
		<observers>
		    <unique_name>
			<type>singleton</type>
			<class>mymodule/observer</class>
			<method>iSpyWithMyLittleEye</method>
		    </unique_name>
		</observers>
	    </customer_login>
	</events> 

And then write some code that would run whenever a user logged in:

	class Packagename_Mymodule_Model_Observer {
	    public function iSpyWithMyLittleEye($observer)
	    {
		$data = $observer->getData();
		//code to check observer data for out user,
		//and take some action goes here
	    }
	}


http://www.magentocommerce.com/knowledge-base/entry/magento-for-dev-part-1-introduction-to-magento#8