6

How to call pre dispatch event before all the front-side pages and it's action.

Let's say Before front side index page or product detail page is loaded, i want a event before all the front-end action.

Even before Index page load. How to achieve that ?

Note:

I want to call my dispatch event before all the front end actions, whenever any front action calls - it should call my dispatch event first.

Eg- Before Index page, CMS pages, every single front-end pages.

1
  • Thanks for the edit and Further clarification :) @TejabhagavanKollepara Commented Sep 19, 2018 at 12:33

1 Answer 1

4

You have to use this for all page on front end.

<event name="controller_action_predispatch">
        <observer name="<observername>" instance="<observerpath>" />
</event>

You can see in this file :

vendor/magento/module-persistent/etc/frontend/events.xml

It's same which you asked. It's call every time to checked customer session.

7
  • But can't we achieve it without changing in all front-end files ? Commented Sep 19, 2018 at 12:20
  • Not understand. Commented Sep 19, 2018 at 12:21
  • so should i override Magento\Persistent ? Commented Sep 19, 2018 at 12:39
  • Not sure but might be you can achieve using this. Commented Sep 19, 2018 at 12:40
  • 1
    Welcome bro anytime!!!!! Commented Sep 19, 2018 at 13:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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