0

I am trying to disable a Magento programatically.For just trying I added the following code to myadmin header.phtml.

    // Disable the module itself
$moduleName="Thycart_Customcheckout"
        $nodePath = "modules/$moduleName/active";
        if (Mage::helper('core/data')->isModuleEnabled($moduleName)) {
            Mage::getConfig()->setNode($nodePath, 'false', true);
            echo Mage::getConfig()->getNode('modules/Thycart_Customcheckout')->active;            
        }

        // 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);
         }

On echoing

Mage::getConfig()->getNode('modules/Thycart_Customcheckout')->active;

is returning me its false but actualy the module is not getting disabled from xml.

Also tried

Mage::getConfig()->saveConfig();

returned a

Front controller reached 100 router match iterations

Error.

Can someone please help to make the node active to false in config file . Thanks.

2
  • From app/etc/Namespace_Modulename.xml you can do it. Open the file and set active to false. Or just rename the file to something like Namespace_Modulename.xml_bak. Commented Apr 25, 2017 at 12:42
  • Please read the qn.I need to make this happen programatically.
    – Melvin
    Commented Apr 25, 2017 at 12:44

1 Answer 1

0

I already had a controller, so I added the following protected function:

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');

In phtml, use below code.

    // Disable the module itself
    $nodePath = "modules/$moduleName/active";
    if (Mage::helper('core/data')->isModuleEnabled('Namespace_Modulename')) {
        Mage::getConfig()->setNode($nodePath, 'false', true);
    }

    // Disable its output as well (which was already loaded)
    $outputPath = "advanced/modules_disable_output/Namespace_Modulename";
    if (!Mage::getStoreConfig($outputPath)) {
        Mage::app()->getStore()->setConfig($outputPath, true);
    }
3
  • I added it in phtml so no need of action required i gues
    – Melvin
    Commented Apr 25, 2017 at 12:48
  • Okay. I updated answer for it. Please check. Commented Apr 25, 2017 at 12:50
  • This is exactly I have tried and did not work
    – Melvin
    Commented Apr 25, 2017 at 12:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.