Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Magento - Checking if a module is installed?

Tags:

magento

I have a small piece of code in a template file that I ONLY want to run if a certain module is installed. I found the below code, which you can use to find if a module is active, but I want to know if a module is installed.

$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.";
}

I'm thinking I could maybe get a list of names of all the modules that are installed, and then use

if (stristr($modulelist, 'Name_Extension'))

to show my code only if the referenced extension is installed.

Anyone any ideas how to do that? Or any better solutions?

like image 317
Marlon Creative Avatar asked Nov 29 '10 19:11

Marlon Creative


People also ask

How do I know what extensions are installed in Magento?

check them out under System > Configuration > Advanced > Advanced. And you can find out what's installed from app/etc/modules/. Magento "extensions" add code to the configuration based MVC system.

How do I know if Magento is installed?

1. Check Magento version via Admin Panel. In order to check the Magento version, you need to log into your Magento Admin Panel. Once you scroll down the page, you will see the Magento version in the bottom (footer) right corner.


2 Answers

There's a core helper for that:

Mage::helper('core')->isModuleEnabled('MyCompany_MyModule');

It's in Mage_Core_Helper_Abstract.

There's also a isModuleOutputEnabled() method to check if output of module is disabled in System -> Configuration -> Advanced -> Disable Modules Output.

like image 167
baoutch Avatar answered Oct 02 '22 09:10

baoutch


Try this:

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

if(isset($modulesArray['Mage_Paypal'])) {
    echo "Paypal module exists.";
} else {
    echo "Paypal module doesn't exist.";
}   
like image 41
Joe Mastey Avatar answered Oct 02 '22 09:10

Joe Mastey