3

Suppose I want to go back to the code state where only M2 core modules are active.

question: How do I disable all non-core modules in Magento 2? (in 1 step)

2 Answers 2

3

it will find & disable all modules except which one start with Magento_

$ php bin/magento module:status | grep -v Magento | grep -v List | grep -v None | grep -v -e '^$'| xargs php bin/magento module:disable

To disable all module for particular vendor, you could use something like this

$ php bin/magento module:status | grep VendorName_ | grep -v List | grep -v None | grep -v -e '^$'| xargs php bin/magento module:disable

The differences is one with grep -v Magento and the other is grep VendorName_

check this and let me know if any issue

1
  • grep -v List will skip any module that has "List" in its name. So, it's better to use grep -v -e "^List\s.*$" instead. This will only skip the line which has "List" followed by a space, e.g. "List of disabled modules", "List of enabled modules". Commented Feb 29 at 19:27
0

One option is to execute

php bin/magento module:disable $(php bin/magento module:status | grep -vE '^Magento|List of enabled modules:|List of disabled modules:|None|^$')

It will grep all none core modules and pass them as a list to the disable command

https://www.michiel-gerritsen.com/disabling-non-magento-modules-magento-2/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.