Tag: observers

Plugins vs Observers in Magento 2

In short, plugins are everywhere since it is possible to modify/replace behavior of any public method in the system.

On the other hand, observers is legacy extension mechanism inherited from Magento 1, it is very limited. so, it is better to avoid them.

For plugins, Customization should be done using plugins for public methods/classes marked with @api annotation whenever possible. Otherwise, you don’t take any guarantees that customization will stay functional after new Magento releases. In addition to before/afterplugins mentioned in the question, it is possible to create around plugins to substitute original behavior.

The conclusion is use plugins whenever possible, then observers, this will allow you to avoid conflicts with other extensions(3rd party modules.)