How to Enable or Disable Modules in Magento 2

Magento 2 Enabling and Disabling module is the popular action when you run third-party modules on your Magento 2 store. The third-party modules are often the plugins you want to enable with the main purpose to improve the status of your online business. However, due to any reason that sometimes causes the conflict when you activate all modules at the same time, it is necessary to disable the module that is not temporarily important.

So as to enable or disable, you can go into the configuration of that module, but on the topic today, Mageplaza will recommend you how to enable or disable Magento 2 module manually? That maybe will be great for the developers.

4 Step to enabling/ disabling Magento 2 module

Step 1: Login to Magento File System

Firstly, it is required to login to Magento File System as an owner who has rights to write and edit the file system in Magento. In a case you use the bash shell, running the following command will help you access Magento File System as the owner

su <Magento file system owner> -s /bin/bash -c

If Magento File System does not accept any external login, please use the command below:

sudo -u <Magento file system owner>

Step 2: Run Magento commands

To run Magento commands from any directory, add <your Magento install dir>/bin to your system PATH.

Please inject <your Magento install dir>/bin to your system PATH or follow this intructions:

  • cd <your Magento install dir>/bin and run them as ./magento <command name>

  • php <your Magento install dir>/bin/magento <command name>

<your Magento install dir> is a subdirectory of your web server’s docroot.

Step 3: Enable/ Disable Magento 2 module

Next, you can start to enable or disable the modules in Magento 2 as the following:

Run the commands

magento module:enable [-c|--clear-static-content] [-f|--force] [--all] <module-list> 
magento module:disable [-c|--clear-static-content] [-f|--force] [--all] <module-list> 

With these commands, you need to understand:

  • <module-list> is the modules list that you want to enable or disable. If including the special characters, that module’s name will be put in either single or double quotes.

  • --all mentions you can simultaneously enable or disable all modules.

  • -f or --force means you obligate to enable or disable the modules regardless the dependencies.

  • -c or --clear-static-content means clear any published static view files. However, if there are many files having the same name, you will not eliminate all of them. That means there is more than one file named logo.gif and that will cause the mistake to display the file.

Show the list of the enabled and disabled modules with the command:

magento module:status

For example, you call Wee module that is disabled, need to run

magento module:disable Magento_Weee

Step 4: Update the database of Magento 2 enabled module

After enabling one or more modules, should declare the following command to request the update of the database:

magento setup:upgrade

Notes of enabling and disabling Magento 2 module

Here are some notes for you when you enable or disable the module which has the dependencies on another module.

  • If Module A depends on Module B:
    • It is required to disable Module A before disabling Module B.
    • It is required to enable Module B before enabling Module A if both are unavailable.
  • If Module A conflicts with Module B, you can disable both of them or do that individually, but especially, you cannot enable both at the same time.

The dependencies are announced in the require field in the Magento’s composer.json file of each module while the conflicts are announced in the conflict field. If there are dependencies among the modules, and you still try to enable and disable without the rule, the error message will be shown and inform of you the dependency graph.

  • A->B means Module A depends on Module B.
  • A->B->C means Module A depends Module B while Module B depends on Module C.

Wrap up

You’ll need to disable a module run a module in Magento 2 because there are modules that conflict with each other. You can easily do it with this tutorial. If you find it helpful, don’t forget to share it with your friends. Thanks for reading!

Related Topics

Image Description
With over a decade of experience crafting innovative tech solutions for ecommerce businesses built on Magento, Jacker is the mastermind behind our secure and well-functioned extensions. With his expertise in building user-friendly interfaces and robust back-end systems, Mageplaza was able to deliver exceptional Magento solutions and services for over 122K+ customers around the world.

People also searched for

  • Magento 2 disable module
  • magento 2 enable disable module
  • magento 2 disable module from database
  • magento 2 disable module from code
  • magento 2 disable module for store
  • magento 2 disable module from admin
  • magento 2 disable module in database
  • magento 2 disable module in xml
  • magento 2 disable module in admin
  • magento 2 disable module manually
  • magento 2 disable module mysql
  • magento 2 disable module output
  • magento 2 disable modules output not working
  • magento 2 disable module programmatically
  • magento 2 disable module per store
  • magento 2 disable modules performance
  • magento 2 disable module via database
  • magento 2 disable module xml
  • 2.3.x, 2.4.x
x