To Check if a Module is Enabled or Not Programmatically in Magento 2

How to Add Color Picker in Magento 2 Admin Configuration
December 24, 2020
August 8, 2023

Not all modules function the way they are defined. Some modules needs to be programmatically charged for being actively working.

Many times, developers has to check if a module is enabled or disabled in a Magento 2 store.

When you are using the modules of third-party and the status of the module is multi-store, the developers need to check the compatibility of the module.

The use of isEnabled() function as shown below to check if a module is enabled or not programmatically in Magento 2.

Method to check if a module is enabled or not programmatically in Magento 2:


_moduleManager = $moduleManager;
        parent::__construct($context, $data);
    }
    /* return bool */
    public function isModuleEnable()
    {        
        if ($this->moduleManager->isEnabled('[Vendor]_[Module]')) {
            //code get for Module is enabled
            return 1;
        } else {
            //code get for Module is disabled
            return 0;
        }
    }
}


Note: The above method checks only if the module is enabled in the configuration or not. It does not support checking the status for the admin panel.

That’s it.

Thank you for reading !

Social

Related Posts