Magento 2 Developement

How to disable module in Magento 2

There are 3 ways to disable module in Magento 2. Well, actually 3rd way only disable module output, but it can be done directly from admin.
Disable module via command line
Disable module manually
Disable module output
Uninstall module completely

Disable module via command line

Magento 2 has powerful build-in command line tool to perform various tasks. To disable module in ssh console type

> php bin/magento module:disable Nwdthemes_ArraySerialized
The following modules have been disabled:
- Nwdthemes_ArraySerialized

Cache cleared successfully.
Generated classes cleared successfully. Please run the 'setup:di:compile' command to generate classes.
Info: Some modules might require static view files to be cleared. To do this, run 'module:disable' with the --clear-static-content option to clear them.

Some modules in magento depends on other modules. In this case you get a warning with a list of dependent modules

> php bin/magento module:disable Magento_Config
Unable to change status of modules because of the following constraints:
Cannot disable Magento_Config because modules depend on it:
Magento_Store: Magento_Store->Magento_Config
Magento_AdvancedPricingImportExport: Magento_AdvancedPricingImportExport->Magento_Store->Magento_Config
Magento_Directory: Magento_Directory->Magento_Config
Magento_Theme: Magento_Theme->Magento_Config
Magento_Backend: Magento_Backend->Magento_Config
Magento_Backup: Magento_Backup->Magento_Store->Magento_Config

You can still disable the module in this case with help of [-f|--force] flag. Be aware that your store might not function properly in this case!!!

> php bin/magento module:disable -f Magento_Config

Complete list of module commands commands are:

Disable module manually

You can disable module in Magento 2 manually. Open /app/etc/config.php. It could look like

return array (
  'modules' => 
  array (
    'Magento_Store' => 1,
    'Magento_AdvancedPricingImportExport' => 1,
    'Magento_Directory' => 1,
    'Magento_Theme' => 1,
    'Magento_Backend' => 1,
    'Magento_Backup' => 1,
    'Magento_Wishlist' => 1,
    'Nwdthemes_ArraySerialized' => 1,

To disable module you need to set its value to 0.
'Nwdthemes_ArraySerialized' => 1, >>> 'Nwdthemes_ArraySerialized' => 0,.
This method is not recommended to use since config.php generated automatically during setup:upgrade routine.

Disable module output

You can disable module output in magento admin. This is suitable if you pretty sure that error comes from one of module blocks and you do not have access to ssh console. However, in this case module still active and if it has any events / plugins etc they still will be executed.

Navigate to Stores > Configuration > Advanced > Disable module output. Scroll to module, select “Disable” in dropdown next to module name and click “Save Config”. Last step is to clear / flush store cache.

Uninstall module completely

If you want to uninstall module completely – check our Magento 2: How to uninstall module tutorial.

Leave a Reply

Your email address will not be published. Required fields are marked *