Here’s a bit of code I used while developing a custom module for a client’s shop. The module allows a Flash application to launch popups of any given product. There was a module the client definitely wanted to keep but that was interfering with my ability to close the popup when the client clicked the ‘Add to Cart’ button – and we didn’t need that module working within the popup iframe. I googled for a while but there was no documentation on how to do this.
So here’s what I did to disable that module and its output. It might not be the best solution but it worked nicely and I didn’t have to manually remove each item in my module’s layout file:
- I already had a controller, so I added the following protected function:
01020304050607080910111213
protected
function
_disableModule(
$moduleName
) {
// Disable the module itself
$nodePath
=
"modules/$moduleName/active"
;
if
(Mage::helper(
'core/data'
)->isModuleEnabled(
$moduleName
)) {
Mage::getConfig()->setNode(
$nodePath
,
'false'
, true);
}
// Disable its output as well (which was already loaded)
$outputPath
=
"advanced/modules_disable_output/$moduleName"
;
if
(!Mage::getStoreConfig(
$outputPath
)) {
Mage::app()->getStore()->setConfig(
$outputPath
, true);
}
}
- and called it in my action before loading the layout:
$this->_disableModule('Namespace_Modulename');
A better solution might be to hook at an earlier moment, preferably before module layouts are loaded, but I didn’t have enough time to research on that possibility.