繁体   English   中英

如何通过cron启用或禁用magento中的模块?

[英]How I can enable, or disable modules in magento by cron?

我在magento中使用维护页面模块,并且想由cron启用和禁用。 我如何使用cron作业做到这一点?

您好,您可以使用cron服务禁用该模块

我正在为此创建一个自定义扩展,请给我们

    Please create config.xml under app/code/local/Amit/CustomDisable    
    <?xml version="1.0"?>
        <config>
          <modules>
            <Amit_CustomDisable>
              <version>0.1.0</version>
            </Amit_CustomDisable>
          </modules>
            <global>
                <models>
                    <customdisable>
                        <class>Amit_CustomDisable_Model</class>
                    </customdisable>
                </models>
            <helpers>
              <customdisable>
                <class>Amit_CustomDisable_Helper</class>
              </customdisable>
            </helpers>
          </global>
                <crontab>
                    <jobs>
                        <customdisable_setting>
                        <schedule><cron_expr>*/15 * * * *</cron_expr></schedule>
                        <run><model>customdisable/observer::setupforcustom</model></run>
                    </customdisable_setting>
                    </jobs>
                </crontab>

        </config> 



          create Observer.php under app/code/local/Amit/CustomDisable/Model/
public function setupforcustom(){
  // Disable the module itself
        $moduleName='Mage_Wishlist';//like an example 
                $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);
                }
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM