我在magento中使用维护页面模块,我希望由cron启用和禁用。我怎么能用cron工作做到这一点?
答案 0 :(得分:0)
您好,您可以使用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);
}
}