如何通过cron启用或禁用magento中的模块?
我在magento中使用维护页面模块,我希望通过cron启用和禁用。我怎样才能用cron作业做到这一点 您好,您可以使用cron服务禁用该模块 我正在为此创建一个自定义扩展,请与我们联系如何通过cron启用或禁用magento中的模块?,magento,module,cron,magento-1.7,crontab,Magento,Module,Cron,Magento 1.7,Crontab,我在magento中使用维护页面模块,我希望通过cron启用和禁用。我怎样才能用cron作业做到这一点 您好,您可以使用cron服务禁用该模块 我正在为此创建一个自定义扩展,请与我们联系 Please create config.xml under app/code/local/Amit/CustomDisable <?xml version="1.0"?> <config> <modules>
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);
}
}
请在app/code/local/Amit/CustomDisable下创建config.xml
0.1.0
Amit_自定义禁用_模型
Amit\u自定义禁用\u帮助程序
*/15 * * * *
customdisable/observer::setupforcustom
在app/code/local/Amit/CustomDisable/Model下创建Observer.php/
公共函数setupforcustom(){
//禁用模块本身
$moduleName='Mage_Wishlist';//如示例所示
$nodePath=“modules/$moduleName/active”;
if(Mage::helper('core/data')->isModuleEnabled($moduleName)){
Mage::getConfig()->setNode($nodePath,'false',true);
}
//同时禁用其输出(已加载)
$outputPath=“高级/模块\禁用\输出/$moduleName”;
如果(!Mage::getStoreConfig($outputPath)){
Mage::app()->getStore()->setConfig($outputPath,true);
}
}
谢谢您的回复!代码看起来很棒!你能告诉我如何使用它的完整解决方案吗?