My goal is to disable the module programmatically (for example, during some observer event). The earliest watcher I found is controller_front_init_before .
So, my module listens for it, and then does the following:
Mage::getConfig()->getModuleConfig('IG_LightBox')->active=(string)'false';
But the selected module is still active on every page.
I also tried this approach (the same, but in a different way):
Mage::getConfig()->getNode('modules/IG_LightBox')->active=(string)'false';
Also, I tried reinstalling the config in the end and loading the Modules again, but both will not help.
Mage::getConfig()->loadModules();
Is it possible to programmatically disable the module?
Update 1 . This solution is great for working with sources. active = false really disables the module, but I also need it for the interface. Therefore, I continue to search.
Update 2 There are two methods in the /Mage.php application: init and initSpecified, which allows you to run Magento with only a selected number of modules. But these methods are not called in the thread by default.
Update 3 There is an observer event that we can use to activate or deactivate payment modules on the fly. It is called payment_method_is_active. In this code example, the check transfer payment method is not active:
public function payment_method_is_active(Varien_Event_Observer $observer) { if($observer->getMethodInstance()->getCode()=='checkmo') { $observer->getResult()->isAvailable=false; } }