Magento 2: Before & After Method Observer using Plugin

Magento 2 provides a new feature called Plugin or Interceptor that is used to run some code before/after/around any function call of any public class. Hence, with the help of Plugins, we can change the behavior of class method without making any changes in the code of the class itself. This also avoids conflicts with … Read more

Magento 2: Event Observer

This article shows how you can create event observer in a custom module in Magento 2. In Magento 2, there is a separate xml file where you can define your event observer. For frontend events, you need to write your code in app/code/YourCompany/YourModule/etc/frontend/events.xml and for admin events, you need to write event observer code in … Read more

Magento: Event Observer with Save before and Save after

Magento has this cool functionality of Event Observer. Magento follows the Observer Design Pattern for its event hooking system. With this Event Observer Hook, additional functionality can be added without modifying the core code. The full list of Magento Event Observer Hooks is present over here:- Magento Event/Observer Hooks Cheat Sheet Magento has been programmed … Read more