How to call a method before the method of the requested controller is executed: magento

I want to call a method before executing each and every controller method. I do not want to go and call a method in each method. I just want to call it from one place and it will be called before any method of any controller in purple.

And I’m sure that we can do this, but I don’t know how to do it.

Please submit your suggestions.

Hope we can solve this problem or maybe some expert guys have already solved it.

Thank.

+3
source share
2 answers

Observer, controller_action_predispatch. Magento. wiki, .

+5

, preDispatch . .

- :

public function preDispatch()
    {
        parent::preDispatch();

        //my code here
    }
0

Source: https://habr.com/ru/post/1771058/


All Articles