简体   繁体   中英

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

I using maintenance page module in magento and I want to enabled and disabled by cron. How I can do it that with cron jobs?

Hello you can disabled the module using cron service

I am creating a custom extension for that ,please us this

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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