Magento, implement an event/observer pattern like any good Object Oriented System for the end user. In Magento Some of the action happen during any page request ( any model serve, any user logs in etc..) , for such magento issued an event signal. So when you create your own module, you can listen for the same events.
So lets clear it with example:
let’s assume that you wanted to get an email notification every time when any user logged into your store, in that case you could listen for the “user_login” event in the config.xml
Config.xml
[xml]
<events>
<user_login>
<observers>
<observer_name>
<type> Singleton </type>
<class> myModule/Observer </class>
<method>loginNotification </method>
</observer_name>
</observer>
</user_login>
</events>
[/xml]
and then write below code inside “app/code/vendorName/myModule/Model/Observer.php”
Observer.php
[code]
<?php
class Gs_Searchtap_Model_Observer extends Varien_Event_Observer
{
public function loginNotification($observer)
{
$data= $observer->getData();
// Now your stuff here to check user data;
}
}
[/code]
Happy Coding 🙂
Praveen Maurya work in e-commerce domain having knowledge of Plugin development in Magento 1.x/2.x, Drupal, Woo-Commerce, PrestaShop, Opencart and other e-commerce solution. When he is not engrossed with anything related to these, he loves to explore new things.