Events not firing/or observer not working in magento

↘锁芯ラ 提交于 2019-11-30 15:59:16

问题


I have a module which listens to a few events. It works fine in at least a dozen installations I have tested it on.

On on specific installation, a client which I installed it, on Magento version 1.4.1.1, It does not work. When I tested his system, and I fire the events manually, eg Mage::dispatchEvent('..') the observer does listen to them.

What should I look into ? I do not have a clue what could be the reason for this.


回答1:


There's a few reasons this could be happening

  1. The event you're trying to listen for doesn't exist in your version of Magento

  2. Someone's hacked the core file and accidentally removed the event you're listening for

  3. Someone's overridden a method

  4. Your observer is setup incorrectly, and Magento doesn't "see" it.

  5. Your observer is setup correctly, but the old configuration is cached

The steps I'd take to debug this are

  1. Make sure the merged global config has your event configuration. If it doesn't clear out your caches until it shows up

  2. Download a fresh version of the source code and diff your app/code/core/ and lib/ against the virgin version. Type man diff from a unix prompt yo learn about the diff tool if you're not already familiar with it.

  3. Grep (or ack) the core codebase for the event you're trying to listen for.

  4. Temporarily add logging code to Mage::dispatchEvent in app/Mage.php to ensure the event you're looking for is really firing.

  5. Starting with Mage::dispatchEvent, follow the execution path to the point where listeners are invoked and see why the code in Magento isn't calling your method

The first time you do this will be a time sink, so make notes along the way about where thinks happen in the core Magento system code. That way, the next time you debug a similar issue it'll go that much quicker (if you really wanted to be nice, you could share what you find here, on your blog, or in the Magento wiki)




回答2:


As I recently discovered, a module can show as enabled in Magento but actually not work if the folder name for the module begins with a lowercase letter. Perhaps this will allow someone else to retain their hair in the future.



来源:https://stackoverflow.com/questions/3924751/events-not-firing-or-observer-not-working-in-magento

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