Magento event observer not working on some machines

自闭症网瘾萝莉.ら 提交于 2019-12-08 01:54:57

问题


I cannot seem to figure out why my event observer works from my machine (and another coworkers) but not from other machines in the office.

For example, I have an observer that listens for the event:

controller_action_postdispatch_adminhtml_process_reindexProcess

My code detects the event and runs some code. When I run the re-index process, my code executes. When certain other machines here in the office run the re-index, either the event is not fired, or my observer isn't detecting it.

Why would the computer or the user clicking on the re-index button in the admin panel change anything for how events are fired or observed?

I have researched this problem as best I could and found this post.

Events not firing/or observer not working in magento

But that seemed to pertain to different installations. In my problem, it works on a given installation on certain computers and not from others so I felt that this article was not directly relevant.

This problem is driving me crazy. Any help would be greatly appreciated.


回答1:


There's a whole lot of voodoo you could try, but what you'll end up having to in the end is start here

#File: app/Mage.php

public static function dispatchEvent($name, array $data = array())
{
    Varien_Profiler::start('DISPATCH EVENT:'.$name);
    $result = self::app()->dispatchEvent($name, $data);
    #$result = self::registry('events')->dispatch($name, $data);
    Varien_Profiler::stop('DISPATCH EVENT:'.$name);
    return $result;
}

and debug/log the execution of your event to determine why it isn't firing in certain situations.

Specific Answer From Comments

Thanks! I was able to see that re-indexing from the check marks calls a different event than simply clicking on the re-index process text. A painfully long error to debug but a simple solution. Thanks again! –




回答2:


Are you sure you have the same file state on both computer? Maybe you forget to transfer/check-in the MyFirm_MyModule.xml and your module is not active?

Are the computers using different operating systems? If you are on Windows and your colleagues are on Linux it might be a problem with uppercase/lowercase of module names.



来源:https://stackoverflow.com/questions/8409085/magento-event-observer-not-working-on-some-machines

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!