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.
There's a few reasons this could be happening
The event you're trying to listen for doesn't exist in your version of Magento
Someone's hacked the core file and accidentally removed the event you're listening for
Someone's overridden a method
Your observer is setup incorrectly, and Magento doesn't "see" it.
Your observer is setup correctly, but the old configuration is cached
The steps I'd take to debug this are
Make sure the merged global config has your event configuration. If it doesn't clear out your caches until it shows up
Download a fresh version of the source code and diff your
app/code/core/
andlib/
against the virgin version. Typeman diff
from a unix prompt yo learn about the diff tool if you're not already familiar with it.Grep (or ack) the core codebase for the event you're trying to listen for.
Temporarily add logging code to
Mage::dispatchEvent
inapp/Mage.php
to ensure the event you're looking for is really firing.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)
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