I want to perform some action when my custom module gets disable. Is there any observer event or plugin event that being fired when i disable my module?

Any help would be appreciated.

Thank you,

  • in my opinion you can't use observers or plugins because magento core doesn't load. The "setup" part works with own logic without support of interceptors.
    – sergei.sss
    Commented Feb 28, 2019 at 11:33
  • I think we can use plugin because controller's execute method is public. So i think we can implement with controller but not sure how to implement when we disable mymodule. Commented Feb 28, 2019 at 11:51
  • What controller do you mean? Your extension may be disabled from CLI. You can try add plugin to Magento\Setup\Console\Command\ModuleDisableCommand::run() but it useless...
    – sergei.sss
    Commented Feb 28, 2019 at 12:00
  • Looking for the something. Any help will be great..
    – Sangeetha
    Commented Jan 24, 2020 at 6:25
  • Can you please add the answer if you get solution of this thing ? Commented Mar 14, 2022 at 11:40

1 Answer 1


For that purpose you can create the Recurring script and use Magento\Framework\Module\Manager to check your module.

All recurring scripts executing are during each launch of the setup:upgrade command. Or you can use any other event to make changes.

Code will be something like this:

// Initialize module manager
public function __construct(
    \Magento\Framework\Module\Manager $moduleManager,
) {
    $this->moduleManager = $moduleManager;

And then check if modules enabled:

if ($this->moduleManager->isEnabled('Vendor_Module')) {
    //the module is enabled
} else {
    //the module is disabled
  • where do i put that code? i know how to check module is enable or not. I need even. when you disable or enable from command line it fire specific action. Commented Mar 5, 2019 at 17:38

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.