Checking Whether a Magento Module Is Active

Checking Whether a Magento Module Is Active

If your code relies on another module, check that it is enabled first. Otherwise a disabled module can trigger fatal errors. Magento 1 offers two approaches.

Using the helper

isModuleEnabled is the simplest check:

<?php

$moduleName = 'Mage_Core';
if (Mage::helper('core')->isModuleEnabled($moduleName)) {
  echo "Module is enabled.";
} else {
  echo "Module is disabled.";
}

?>

Reading the config node

You can also inspect the module’s node in the merged configuration, which tells you whether it is active:

<?php 

$moduleName = 'Mage_Core'; 
$isActive = Mage::getConfig()->getNode('modules/' . $moduleName . '/active');
if ($isActive && in_array((string)$isActive, array('true', '1'))) {
  echo "Module is enabled.";
} else {
  echo "Module is disabled.";
}
?>

For output-only modules, also look at isModuleOutputEnabled, which respects the Advanced > Disable Modules Output setting.

Heads up: this guide applies to Magento 1, which stopped receiving official security updates in June 2020. If your store still runs it, plan a move to Magento 2 or Adobe Commerce soon. We can help with the migration.

Want this done for you? Find out more about our Magento development service.

Keep reading

Related articles

All articles

Need a hand?

Stuck on something similar?
We can fix it with you.

Send us the problem. A senior developer reads every message and replies within one working day.