Bobcares

Magento 2 disable module programmatically

by | Mar 23, 2023

Want to know more about disabling modules programmatically in Magento 2? Our Magento Support team is here to help you with your questions and concerns.

How to Disable Module Programmatically in Magento 2?

Did you know we can disable a module programmatically in Magento 2 with the ModuleManager object? Our experts have put together the following steps to help you with this process:

How to Disable Module Programmatically in Magento 2?

  1. To begin with, we have to inject the ModuleManager object in the constructor of our class as seen below:

    How to Disable Module Programmatically in Magento 2

  2. Then, we will call the disable method of the ModuleManager object and then pass the name of the module that we want to disable:

    How to Disable Module Programmatically in Magento 2

    In the above example, the Vendor_Module is disabled.

  3. Additionally, if we prefer to disable a module only for a particular area, like the frontend or backend, we can pass the area as the second argument as seen below:

    How to Disable Module Programmatically in Magento 2

  4. Once we are done disabling the module, we can clear the Magento cache to make that the changes take effect:

    How to Disable Module Programmatically in Magento 2

Our experts do not recommend disabling modules programmatically unless absolutely necessary. Since this may lead to compatibility issues or unexpected behavior, it is better to disable modules via the Magento admin interface. Alternatively, we can also edit the “app/etc/config.php” file directly to disable the module.

Let us know in the comments if you need further help disabling a module in Magento 2.

[Need assistance with a different issue? Our team is available 24/7.]

Conclusion

To sum up, our Support Techs demonstrated how to disable a module programmatically in Magento 2.

PREVENT YOUR SERVER FROM CRASHING!

Never again lose customers to poor server speed! Let us help you.

Our server experts will monitor & maintain your server 24/7 so that it remains lightning fast and secure.

GET STARTED

0 Comments

Submit a Comment

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

Never again lose customers to poor
server speed! Let us help you.