>How to disable Magento 2 Extension

How to disable Magento 2 Extension

There are various ways to disable a Magento 2 Extension (module).

Here are 3 common ways to disable a Magento 2 module (or disable the module output). They are already sorted from mostly recommended. 


1. Disable a module using command line.

Magento already provides command line utility to disable a module. 

php bin/magento module:disable Bss_PreOrder
sundayz$ php bin/magento module:disable Bss_PreOrder

The following modules have been disabled:
- Bss_PreOrder
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.

If the module depends on other modules, using the basic command line will not disable it correctly which will have errors like this:

sundayz$ php bin/magento module:disable Magento_Checkout

Unable to change status of modules because of the following constraints:
Cannot disable Magento_Checkout because modules depend on it:
Magento_Store: Magento_Store->Magento_Catalog->Magento_Checkout
Magento_Directory: Magento_Directory->Magento_Backend->Magento_Customer->Magento_Checkout
Magento_Theme: Magento_Theme->Magento_Customer->Magento_Checkout
Magento_AdvancedPricingImportExport: Magento_AdvancedPricingImportExport->Magento_Customer->Magento_Checkout
Magento_Backend: Magento_Backend->Magento_Customer->Magento_Checkout
Magento_Eav: Magento_Eav->Magento_Catalog->Magento_Checkout
Magento_Customer: Magento_Customer->Magento_Checkout
Magento_Backup: Magento_Backup->Magento_Backend->Magento_Customer->Magento_Checkout
Magento_AdminNotification: Magento_AdminNotification->Magento_Backend->Magento_Customer->Magento_Checkout
Magento_Indexer: Magento_Indexer->Magento_Backend->Magento_Customer->Magento_Checkout
Magento_BundleImportExport: Magento_BundleImportExport->Magento_Catalog->Magento_Checkout
Magento_Search: Magento_Search->Magento_Backend->Magento_Customer->Magento_Checkout
Magento_CacheInvalidate: Magento_CacheInvalidate->Magento_PageCache->Magento_Backend->Magento_Customer->Magento_Checkout
Magento_Cms: Magento_Cms->Magento_Catalog->Magento_Checkout
Magento_Widget: Magento_Widget->Magento_Catalog->Magento_Checkout
Magento_CatalogImportExport: Magento_CatalogImportExport->Magento_Customer->Magento_Checkout
Magento_Catalog: Magento_Catalog->Magento_Checkout

To solve this, we need to use [-f] (force) flag in the command line.

sundayz$ php bin/magento -f -c module:disable Magento_Checkout

The following modules have been disabled:
- Magento_Checkout
Cache cleared successfully.
Generated classes cleared successfully. Please run the 'setup:di:compile' command to generate classes.
Generated static view files cleared successfully.
Alert: You used the --force option. As a result, modules might not function properly.


Another problem occurs when you don’t clear static view content. This may bring issues such as there are various files with a similar name and you don’t clear all of them.

In the other hand, due to static file fallback rules, assume that you don’t clear static files and have more than one file with the same name, but different content and  fallback rules will make the static view display incorrectly. To  everything work well, make sure that [-c] or [–clear-static-content] is added to the command line.

php bin/magento --force --clear-static-content module:disable Magento_Checkout


Remember to read carefully the warning:

Alert: You used the –force option. As a result, modules might not function properly.

You can also check status of all modules:

php bin/magento module:status


2. Disable a module manually

To disable a module manually, some changes have to be done at app/etc/config.php.

However, this way is not recommended because config.php was created automatically after command:

php bin/magento setup:upgrade

It means that the next time you “upgrade” your Magento, config.php will be renewed and changed that you did will be no longer there.

Magento stores the flag value 0 or 1 of each module with the meaning of enable or disable:

1 means that the module is enable.

0 means that the module is disable.

So if you want to disable any module, you need to change its value to 0.

Then you need to save it, flush cache to complete disabling the module.


Assume that this is your config.php file:

return array (
  'modules' => 
  array (
    'Magento_Store' => 1,
    'Magento_AdvancedPricingImportExport' => 1,
    'Magento_Directory' => 1,
    'Magento_Theme' => 1,
    'Magento_Backend' => 1,
    'Magento_Backup' => 1,
    'Magento_Eav' => 1,
    'Magento_Customer' => 1,
    'Magento_BundleImportExport' => 1,
    'Magento_AdminNotification' => 1,
    'Magento_CacheInvalidate' => 1,
    'Magento_Indexer' => 1,
    'Magento_Cms' => 1,
    'Magento_CatalogImportExport' => 1,
    'Magento_Catalog' => 1,
    'Magento_Rule' => 1,
    'Magento_Msrp' => 1,

In order to disable the module Magento_Cms, you just need to change ‘Magento_Cms’ => 1, to ‘Magento_Cms’ => 0, save it, and flush the cache.


3. Disable modules output using back-end configuration

This is the easiest solution to “disable” a module and this seems convenient for non-developer users.

However, this way does not actually disable your extension but rather disabled the display block output defined or outputted by the module.

If there’s no blocks used by the module, this option is useless. Let’s take an example: “if your module called directly from template, you disable module output, the module still works.”

By navigating in the Magento Backend to Stores => Configuration => Advanced => Disable module output



Find the module that you want to disable then choose “Disable”. After that, click “Save Config”, flush your cache and the module is “disabled”.







< Previous Post
Next Post >