Disabling a Magento Observer in config.xml

In some rare cases there is functionality that clients need me to develop that requires disabling some built-in observers due to them conflicting with the desired custom behavior. There are also some that aren’t needed by everyone that you can gain a performance boost from by disabling. I have previously disabled a few observers by rewriting the observer model and returning NULL inside the observer method. Brought to light by Colin M. on the Magento Developer Group, it turns out there is a better technique and method of disabling observers that is both less intrusive and only requires a small bit of configuration XML in your custom modules config.xml file.

I┬ádecided to test it myself and find out if it worked and then determine if it was merely a side effect of something not being handled in the code or if the event dispatcher was intentionally coded to skip calling observers that have the type set to ‘disabled’. The one I chose for my test case was the customer_login event, which is called by an observer in the Mage_Catalog module; I added a call to Mage::log in my sandbox to easily see when it was being called.


In a typical observer declaration you would have a type of model or object, but if you specify a type of disabled Magento will specifically skip calling the observer per the code found in Mage_Core_Model_App::dispatchEvent, which means not only is this less intrusive and only requiring a bit of XML to disable any observer, it is also does not rely on side-effects of being an invalid observer type.

switch ($obs['type']) {

    case 'disabled':
    case 'object': case 'model':