5

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 load. 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.

  • Thanks for the edit and Further clarification :) @TejabhagavanKollepara – Aditya Shah Sep 19 '18 at 12:33
3

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.

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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