Check From Magento Backend
To check if a module is installed, or activated, first take a quick look from your Magento backend.
Go to System > Configuration > Advance (bottom left)
Then check your module name there. If your module’name is here. It is enabled. Even if you see the module output is set to disable.
How to check if a module is enabled programmatically in Magento 1?
Below is the code you can use to check if a module of your Magento is enabled or not.
1 2 3 4 5 6 |
// if module XXX_XXXX is enabled If (Mage::helper('core')->isModuleEnabled('XXX_XXXX')){ // module is enabled } else { // module is disabled } |
isModuleEnabled
function is implemented in Mage_Core_Helper_Abstract, which is located in app/code/core/Mage/Core/Helper/Abstract.php
Solution for older version of Magento
It might not be implemented in older versions of Magento, e.g. CE.1.4. If it is so, then you can use the following code to check whether a module is enabled.
1 2 3 4 5 6 7 8 |
// if module XXX_XXXX is enabled in an older version of Magento $moduleName = 'XXX_XXXX’; $isActive = Mage::getConfig()->getNode('modules/' . $moduleName . '/active'); if ($isActive && in_array((string)$isActive, array('true', '1'))) { // module is enabled } else { // module is disabled } |
When and why you need to check if a module is enabled
Checking if module is enabled is needed before you actually start using the module, for example if you want to load the helper of a module on a view, we can the use the code below,
Mage::helper('XXX_XXXX’);
But if you don’t check if the module is enabled or not before, you are likely to get an error when the module is disabled:
Class 'XXX_XXXX_Helper_Data' not found in xxxxxxxxx on line xxxx
Note: the code above only checks if the module is enabled or installed, if will not check if the module output is enabled or not.