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.

  • 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. – Kingshuk Deb Apr 25 '17 at 12:42
  • Please read the qn.I need to make this happen programatically. – Melvin Apr 25 '17 at 12:44
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);
    }
  • I added it in phtml so no need of action required i gues – Melvin Apr 25 '17 at 12:48
  • Okay. I updated answer for it. Please check. – Kishan Patadia Apr 25 '17 at 12:50
  • This is exactly I have tried and did not work – Melvin Apr 25 '17 at 12:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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