Take the 2-minute tour ×
Magento Stack Exchange is a question and answer site for users of the Magento e-Commerce platform. It's 100% free, no registration required.

Is interception intended to be the preferred method when dealing with changing the behavior of an original method in Magento2 as observers was in magento1?

share|improve this question

3 Answers 3

up vote 7 down vote accepted

I don't think interception is intended to replace event observers.
There are still events dispatched in the Magento2 code.

The interceptors are just a way to process the input or output of a method.
Or the behavior of a method (using the around interceptor) but from what I understand this is a risky approach.

I think it's more of a way to avoid class rewrites as much as possible.
In Magento 1.x, if you needed to modify the result of a method you needed to override the class that contains and the method itself.
now you can simply use before, after or around interceptors to manipulate the data.

With observers you can manipulate data in certain fixed points of a method, not the full method itself.

In my opinion, using observers when possible is still the best approach for customizing even in Magento 2.

share|improve this answer

Currently there is still the option to listen to specific events and I would suggest that the interceptors is just a replacement for rewrites. I would still use the events when there is one in place for your needs.

If you look at the current release some of the modules have events.xml files that include the definitions.

<event name="cms_wysiwyg_images_static_urls_allowed">
    <observer name="catalog_wysiwyg" instance="Magento\Catalog\Model\Observer" method="catalogCheckIsUsingStaticUrlsAllowed" />
share|improve this answer

Interception is evolution of events. Its goal is to allow a developer to write his code without thinking about extension points.

With events you have to think about places where you do Mage::dispatchEvent() so that your module will be customizable.

Interception allows you not to think about this. You just write your business logic. Every method call is an event. So if you write your code in a proper object-oriented way, it will be fully customizable by design.

So yes, Interception replaces events in Magento 2. Not all events were removed because it's pretty big chunk of work that will not bring any value.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.