How to Disable an Event Observer

It would be possible that the action of an event implemented by default in Magento or by a 3rd party module is not needed for you. Let's see the options you have to disable an event and which is the best one.

The first option will be to override the observer method but is not recommended. The second and the best practice to disable an event is by using the property disabled of the observer xml element and set it to true. When you declare an event in the event.xml file, the observer xml element has some properties, like name, instance, disabled and shared.

In the example below you can see how you can disable the observer reports for the sendfriend_product event of the default Magento's reports module.

Create the above file in your custom module under etc/frontend/events.xml

Feel free to share this post and ask your questions in the comments below.

Till next time!

DigitalOcean Referral Badge