1 Nov 2013

Magento: How To Get List Of All Modules Programmatically?

One of the most great advantages of magento is it supports various of modules to install for a different type of work.Also it has default modules,So for knowing how many modules installed in magento and to check whether that is active or not please follow below details:


Get all modules :

You can find getNode() function in the class Mage_Core_Model_Config.
$modules = Mage::getConfig()->getNode('modules')->children();

From the code above, you get all the modules information like whether the module is active or not, the codePool of the module, version of the module, etc.
Get all modules name :

This code will list only the name of all the modules present in your Magento installation.


$modules = array_keys((array)Mage::getConfig()->getNode('modules')->children());

Check whether any particular module is active :

Suppose, I want to check whether Mage_Paypal module is active or not. The following code does the check.



$modules = Mage::getConfig()->getNode('modules')->children();
$modulesArray = (array)$modules;


if($modulesArray['Mage_Paypal']->is('active')) {

    echo "Paypal module is active.";
} else {

    echo "Paypal module is not active.";
}