0

Seeing we are installing, upgrading, removing a new M2 (2.3.1) install we wouldlike a fast way to enable or disable modules from vendors in 1 go. Either by the Vendor name or for a Subset of modules belonging to the same extension.

When extensions are acquired we see the following. One acquires 1 extension call it Foo_Coolstuff but it can then be packaged either as

  • Foo_Core
  • Foo_Coolstuff

Or as

  • Foo_Core
  • Foo_Coolsub1
  • Foo_Coolsub2
  • Foo_Coolstuff

To us as a user this is 1 extension. I mean this is how it is offered and how it is acquired.

Question: So how can we easily enable or disable for example (only)

  • all modules from Vendor Foo_*
  • or all modules from Extension Foo_Cool*

2 Answers 2

0

One can use magento module:status to create lists of extensions. By wrapping this into $() it is executed first. It filters out the extensions that we want by using grep and adds a negative grep to be certain we dont match unwanted stuff.

How to enable all modules from Vendor Foo_

The base command to enable all modules from Foo_ is like this

php bin/magento module:enable $(php bin/magento module:status | grep '^Foo_' | grep -v '^List|^None|^Magento|^$')

This will enable all Modules that start with the label Foo_.

Changing you filter

You can replace Foo with the Vendor name of your choice if the Modules label start with this string. Or you can remove the caret ^ and it will match anywhere in the string. Like this grep 'Foo' will match any extension that hass the string Foo in the label. Be carefull with this. A good way to test it is to first execute php bin/magento module:status | grep '^Foo_' | grep -v '^List|^None|^Magento|^$' and see the list that it returns: is this what you want?

How to disable all modules from Vendor Foo_

The same can be made to disable all modules from Foo_

php bin/magento module:disable $(php bin/magento module:status | grep '^Foo_' | grep -v '^List|^None|^Magento|^$')

How to disable all modules from 1 certain extension called Foo_Coolstuff

The same can be made to disable all modules and submodules from Foo_Coolstuff

php bin/magento module:disable $(php bin/magento module:status | grep '^Foo_Cool' | grep -v '^List|^None|^Magento|^$')

The above will enable all modules where the label starts with ^Foo_Cool. Another option can be to add ^Foo_Core then the command will become grep '^Foo_Cool|^Foo_Core'

0

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
  • use enable instead of disable for enabling module
    – mohith
    Commented Apr 26, 2019 at 12:44

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.