{"id":1042,"date":"2020-06-05T11:32:31","date_gmt":"2020-06-05T11:32:31","guid":{"rendered":"https:\/\/meetanshi.com\/blog\/2020\/06\/05\/check-if-module-is-enabled-or-not-programmatically-in-magento-2\/"},"modified":"2025-05-22T12:53:03","modified_gmt":"2025-05-22T07:23:03","slug":"check-if-module-is-enabled-or-not-programmatically-in-magento-2","status":"publish","type":"post","link":"https:\/\/meetanshi.com\/blog\/check-if-module-is-enabled-or-not-programmatically-in-magento-2\/","title":{"rendered":"How to Check if a Module is Enabled or Not Programmatically in Magento 2"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Many times, developers would come across a requirement to check if a module is enabled or disabled in a Magento 2 store.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">It happens when one needs to check about the module\u2019s status is a multi-store or when you are using third-party modules.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Use the isEnabled() function as shown below to&nbsp;<em><strong>check if a module is enabled or not programmatically in Magento 2<\/strong><\/em>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Method to check if a module is enabled or not programmatically in Magento 2:<\/h2>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">&lt;?php\n\nnamespace [Vendor]\\[Module]\\Helper;\n\nuse Magento\\Framework\\App\\Helper\\AbstractHelper;\nuse Magento\\Framework\\App\\Helper\\Context;\nuse Magento\\Framework\\Module\\Manager;\n\nclass Data extends AbstractHelper\n{\n    protected $moduleManager;\n\n    public function __construct(\n        Context $context,\n        Manager $moduleManager\n    )\n    {\n        $this->moduleManager = $moduleManager;\n        parent::__construct($context);\n    }\n    \n    public function isEnable()\n    {\n        if ($this->moduleManager->isEnabled('[Vendor]_[Module]')) {\n            \/\/code for Module is enabled\n            return 1;\n        } else {\n            \/\/code for Module is disabled\n            return 0;\n        }\n    }\n}<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">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.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">That\u2019s it.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Also, please share the solution with the Magento community via social media.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Thank you.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Many times, developers would come across a requirement to check if a module is enabled or disabled in a Magento 2 store. It happens when&#8230;<\/p>\n","protected":false},"author":14,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[34],"tags":[],"class_list":["post-1042","post","type-post","status-publish","format-standard","hentry","category-magento"],"acf":[],"_links":{"self":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts\/1042","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/users\/14"}],"replies":[{"embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/comments?post=1042"}],"version-history":[{"count":3,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts\/1042\/revisions"}],"predecessor-version":[{"id":14876,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts\/1042\/revisions\/14876"}],"wp:attachment":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/media?parent=1042"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/categories?post=1042"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/tags?post=1042"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}