Mage Check Facebook iconFacebook MAGE CHECK Mage Check Linkedin iconLinkedin MAGE CHECK

Magento How to create an Observer

$ An Observer, also called 'listener', will listen to your program to detect events. When there is an event taking place, it will perform an action defined by you.

Step 1: Install Module\Extension

Install the module from initial page

Step 2: Declare Observer

Magento 1 (2007 - 2014)

File path: app/code/local/MageCheck/Tutorial/etc/config.xml


        
    

Magento 2 Open Source (2014 -)

File path: app/code/MageCheck/Tutorial/etc/events.xml


        
    

Step 3: Create Observer Class

Magento 1 (2007 - 2014)

File path: app/code/local/MageCheck/Tutorial/Model/Observer.php


        
    

Magento 2 Open Source (2014 -)

File path: app/code/MageCheck/Tutorial/Controller/Index/Test.php


        
    
Notice
Do not forget to clean Magento Cache.
Custom
This is the sample way to create an Observer in Magento!
Quote