Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Magento: fetch value of "disable module output"

The Magento backend allows you to disable module output per site. I've done some Google searches but can't figure out how to grab this value through my code. Basically when my module's output is disabled that works just fine. But I've discovered (the hard way) that Magento doesn't prevent the module from loading per-site.

Because I'm extending some core classes, some constructors are still being executed. My thought is to check if the module output is disabled. If so, have my constructor call the parent's constructor. If the module output is enabled, proceed with my custom code.

I just can't figure out how to grab this value for the current site (I am multi-sited, BTW). Ideally it would be something like this:

$isThisEnabled = Mage::app()->getCurrentStore()->isOutputEnabled('myModule');

Basically have a single line that fetches the current site's value (or the default, if not specified for the current site).

Any help would be greatly appreciated!

EDIT: I found the table core_config_data, which appears to store this information. I could manually query it if I had to, but I feel like Magento would have something built-in to return the current store's value, falling back to the default value.

like image 353
Colin O'Dell Avatar asked Dec 12 '22 19:12

Colin O'Dell


2 Answers

It is a standard config setting, so accessing it should be no different than accessing any other config setting. You just need to know what is the path to this value. Analysing the DB I believe this should do the trick:

Mage::getStoreConfig('advanced/modules_disable_output/Namespace_Module');
like image 162
silvo Avatar answered Dec 23 '22 20:12

silvo


The other option is that the Mage_Core_Helper_Abstract has an isModuleEnabled($moduleName = null) method, which means that you should be able to call:

Mage::helper('core/data')->isModuleEnabled('Namespace_Module')

There is also a isModuleOutputEnabled() method. Looking at the code, these don't seem to be filtered by store/view, whereas @silvo's method is.

like image 26
Jonathan Day Avatar answered Dec 23 '22 20:12

Jonathan Day