Is it possible to disable or remove a module functionality from Magento2 ? Yes, its possible! This can be done easily from admin side of your store or from commandline.
I) Enable/Disable module from store admin side:
You can enable/disable module from below location:
admin-> Stores-> Configurations-> Advanced-> Advanced-> Disable Modules output
then enable/disable required module and click on ‘Save Config’ button. You need to clear corresponding cache to reflect the changes in website.
II) Enable/Disable module from commandline:
Magento provide command line utility for enable/disable module. Login to terminal and then go to your project root using below commands (assume your project name is ‘magento213’):
Xampp : cd /opt/lampp/htdocs/magento213
Ubuntu : cd /var/www/magento213
CentOS : cd /var/www/html/magento213
Windows : cd /d/xampp/htdocs/magento213
Magento allow you to enable or disable any of its module (any Magento-default module or any third-party module) that is currently available. Certain modules have dependencies on other modules, in such case Magento might not allow to enable/disable a module because it has dependencies on other modules.
Sometimes there might be conflicting so you cannot enabled both module at the same time.
You can find ‘dependencies’ declared in the ‘require’ field in modules ‘composer.json’ file.
You can find ‘conflicts’ declared in the ‘conflict’ field in modules ‘composer.json’ file.
Magento use that information to build a dependency graph. If you attempt to enable/disable a module that depends on other modules, the dependency graph displays in the error message.
Disable a module:
If you want to disable a module for example ‘Magento_AdminNotification‘ then run below command in commandline. Similarly you can disable any module by specifying its name.
php bin/magento module:disable -f Magento_AdminNotification
Enable a module:
Suppose you want to enable a module for example ‘Magento_AdminNotification‘ then run below command in commandline.
php bin/magento module:enable -f Magento_AdminNotification
Note: Before enable/disable a module through commandline, you need to give full permission to ‘var/’ folder.
Errors and solution
Deployment config file config.php is not writable.
Solution: Give full permission to file “app/etc/config.php”
Command line user does not have read and write permissions on var/generation directory.
Please address this issue before using Magento command line.
Solution: Give full permission to folder “var/generation”. If not worked then give full permission to entire “var/” folder.
No modules were changed.
Solution: This message shows in command line when you are trying to enable/disable a module that already in same status.
It comes to the end of tutorial. Now you are ready to enable or disable a module in Magento2 !
Thank you for reading this post!!!