Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Events not firing/or observer not working in magento

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.

like image 566
user145100 Avatar asked Dec 02 '22 04:12

user145100


1 Answers

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)

like image 51
Alan Storm Avatar answered Dec 05 '22 01:12

Alan Storm