views:

45

answers:

1

Hello,

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  A: 

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)

Alan Storm
The cause cannot be 1 or 2 since a manual dispatch did nothing.
clockworkgeek
Thanks for the answer Alan. Big fan of yours.I do not have full access to the magento source since its at a remote client. I can however change files on my module's directory (limited access). I did suspect of reason number 2 or 3.a cache refresh is a wise option. I didn't think of that.will post updates later on.
oshafran
@oshafran - I misread the question!
clockworkgeek
Some of this are almost certainly not the case here, but this is my standard set of "an event listener isn't working" debugging tips.
Alan Storm