Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Sort order in dispatchEvent
 
tzyganu
Mentor
 
Avatar
Total Posts:  2205
Joined:  2009-11-18
Bucharest, Romania
 

Hello guys and girls.
My question in a nut shell is ‘How can I set the order of the events dispatched with dispatchEvent(’some_event_here’)?’

Now the details of my problem.
I’m using Magento EE 1.9.1.1.
I have full page cache enabled (I said it before but I will say it again -it is worth it’s weight in gold).
My problem is that the full page cache module dispatches the event ‘controller_action_predispatch’

In a custom module I’m hooking on the same event ‘controller_action_predispatch’ and I set some cookies, check some urls and other stuff (the content of my module is not actually important).
The main idea is that I want this to be executed before the method from the full page cache module.

Any ideas and pointers are valuable.

Marius.

 
Magento Community Magento Community
Magento Community
Magento Community
 
tzyganu
Mentor
 
Avatar
Total Posts:  2205
Joined:  2009-11-18
Bucharest, Romania
 

Update.

I found how to sort the events. (sort of).
I just make the full page cache depend on my module. this is not actually safe if I will disable my custom module later. But no big problem. If I disable it my application will crash and tell me that the full page cache module is depending on a disabled module.

Does anyone have an idea why my method is not called in the dispatchEvent() with full page cache enabled?

 
Magento Community Magento Community
Magento Community
Magento Community
 
brobie
Sr. Member
 
Avatar
Total Posts:  139
Joined:  2008-07-28
 

If a page is fully cached, then the request never makes it into the PHP code, so the event will never be dispatched.

 
Magento Community Magento Community
Magento Community
Magento Community
 
tzyganu
Mentor
 
Avatar
Total Posts:  2205
Joined:  2009-11-18
Bucharest, Romania
 

After a few hours of hitting my head on the table (don’t do that - it doesn’t help. You will only get a headache) I found out what the same thing that brobie said.
The way it actually works is that Magneto only loads a part of the config (just the xml files in app/etc folder) and everything is routed through the full page cache module.
I finally ended up with a ‘workaround’ (or a solution if you want to sound professional). Since my code was fast and didn’t do much (no output - just one query and set some cookies that I don’t need in the first page the customer visits) I placed an AJAX call in the footer to a custom controller that does this. It seams to work like a charm.

If anyone sees any downside of this approach please let me know.

Marius.

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top