完全禁用模块 - Magento 1.9

问题描述:

我试图以编程方式禁用Magento模块。为了尝试,我将以下代码添加到myadmin header.phtml完全禁用模块 - Magento 1.9

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

在呼应

法师:: getConfig() - > getNode( '模块/ Thycart_Customcheckout') - >活性;

将返回给我它的虚假但实际上该模块没有从xml禁用。

还试图

法师:: getConfig() - > saveconfig的();

返回

前端控制器达到100路由器匹配迭代错误。

有人可以请帮助使配置文件中的节点活动为false。谢谢。

+0

试试这个https://magento.stackexchange.com/a/48840/46038 –

+0

@BachchaSingh不是程式化的 – Melvin

这是一个不好的代码实践。你不应该像这样禁用模块。当你的phtml文件(header.php)执行时,大部分模块已经被调用,它们在内存中有它们的对象。

如果要禁用模块,那么你可以通过 系统 - >配置 - >高级 - >禁用模块输出禁用它们也可以通过

禁用它们设置在其模块\应用.xml文件错误\ etc \ modules \ Mynamespace_Mymodulename.xml。