Recent Posts


New loadModulesConfiguration Location


Frustrated by Magento? Then you’ll love Commerce Bug, the must have debugging extension for anyone using Magento. Whether you’re just starting out or you’re a seasoned pro, Commerce Bug will save you and your team hours everyday. Grab a copy and start working with Magento instead of against it.

Updated for Magento 2! No Frills Magento Layout is the only Magento front end book you'll ever need. Get your copy today!

Over Magento 2’s long gestation period, there’s been a lot of back and forth on its backwards compatibility. At this point, there would need to be a major engineering effort for out of the box API compatibility with Magento 1. Extension developers will need to resign themselves to some refactoring to get their extensions working. While certainly a pain in the behind, one positive effect of this will be a flushing out of certain fly-by-night extension vendors who aren’t in it for the long haul.

The first major change I’ve found is Magento 2 has removed the loadModulesConfiguration method from the Mage_Core_Model_Config object. Instead, if you need to read and merge every module’s xml configuration file, there’s a new configuration reader object. You can invoke it like this

$loaded_config = Mage::getSingleton('Mage_Core_Model_Config_Modules_Reader')

Here’s another difference: In Magento 1.0 this method returns a Mage_Core_Model_Config_Element object, which inherits from Varien_Simplexml_Element, which inherits from the base PHP SimpleXMLElement.

In Magento 2 this method returns a Mage_Core_Model_Config_Base object, which inherits from Varien_Simplexml_Config, which inherits from nothing. This means the configuration objects you fetch from loadModulesConfiguration no longer have API compatibility with PHP’s simplexml object. Behind the scenes Magento is still using a simple xml extended Varien_Simplexml_Element to handle things. You can fetch the Varien_Simplexml_Element object from a Mage_Core_Model_Config_Element with the getNode method and you’ll have access to all the simple xml methods.

$simple_xml_compat = $loaded_config->getNode();

Be careful though — I’ve noticed some differences when using the xpath method on this returned node when making method calls like this


and I haven’t had time to untangle why the behavior is different.

If you’re interested in this sort of thing, you may be interested in the Magento 1 article series In Depth Magento Dispatch.

Copyright © Alan Storm 1975 – 2022 All Rights Reserved

Originally Posted: 21st August 2013