3

I created a simple verification adding on the admin panel a select to enable or disable, but I want to add a verification to check if my module output is enabled, how can I do that?

Today I'm using this code on my module:

public function isEnable(){
    return $this->getConfig('general/enabled');
}

2 Answers 2

2

You can add this verification below.

$this->isModuleOutputEnabled()

or you can use the method below that also use the method isOutputEnabled in the same class.

$this->_moduleManager->isEnabled('Magento_Reports')
1

You can use configuration setting:

 $this->_scopeConfig->getValue(
             'advanced/modules_disable_output/' . [ModuleName],
             \Magento\Store\Model\ScopeInterface::SCOPE_STORE
 )

example:

 $this->_scopeConfig->getValue(
             'advanced/modules_disable_output/Magento_Catalog',
             \Magento\Store\Model\ScopeInterface::SCOPE_STORE
         )

if (!$this->_scopeConfig->getValue(
            'advanced/modules_disable_output/Magento_Catalog',
            \Magento\Store\Model\ScopeInterface::SCOPE_STORE
        )) {
           // output enable
 }else{
   // Disabled Output
 }
1
  • Every time 0 coming that means all the time it shows module as enabled. I have made module's output Disabled in all the stores, store-views, websites & Default but still showing 0 as output means module enabled. Any other solution?
    – KA9
    Commented Sep 5, 2017 at 6:08

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.