This feature is nice, but it doesn't help in two situations:
- when you want to deactivate community modules also. In this case, you can use something as described in this blog post.
- when you want to disable all the modules but then re-enable a few of them.
The script consists of two files: a bash script, and a PHP script, used to get the modules that should be deactivated.
This is the bash script:
| #!/bin/sh |
| MODULES_DEACTIVATOR_FILE=app/etc/modules/zzzzz_DisableModules.xml |
| SCRIPT_FOLDER="`dirname ${BASH_SOURCE[0]}`" |
| PHP_BIN=php |
| echo "<?xml version=\"1.0\"?>" > $MODULES_DEACTIVATOR_FILE |
| echo "<config>" >> $MODULES_DEACTIVATOR_FILE |
| echo " <modules>" >> $MODULES_DEACTIVATOR_FILE |
| for m in $($PHP_BIN $SCRIPT_FOLDER/active_non_core_modules.php) |
| do |
| echo " <$m>" >> $MODULES_DEACTIVATOR_FILE |
| echo " <active>false</active>" >> $MODULES_DEACTIVATOR_FILE |
| echo " </$m>" >> $MODULES_DEACTIVATOR_FILE |
| done |
| echo " </modules>" >> $MODULES_DEACTIVATOR_FILE |
| echo "</config>" >> $MODULES_DEACTIVATOR_FILE |
And this is the PHP script:
| <?php |
| require_once('app/Mage.php'); |
| $modules = Mage::app()->getConfig()->getNode('modules')->asCanonicalArray(); |
| $modules = array_filter($modules, function ($module) { |
| return $module['codePool'] != 'core' && $module['active'] === 'true'; |
| }); |
| echo(implode(PHP_EOL, array_keys($modules))); |
To use them, just save the two scripts in the same folder (the PHP script must be named active_non_core_modules.php), and then run the bash script, from the Magento root folder.