2017-04-25 56 views
0

我試圖以編程方式禁用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

回答

0

這是一個不好的代碼實踐。你不應該像這樣禁用模塊。當你的phtml文件(header.php)執行時,大部分模塊已經被調用,它們在內存中有它們的對象。

如果要禁用模塊,那麼你可以通過 系統 - >配置 - >高級 - >禁用模塊輸出禁用它們也可以通過

禁用它們設置在其模塊\應用.xml文件錯誤\ etc \ modules \ Mynamespace_Mymodulename.xml。