How to check module is enable or not in model in Magento 2 - Magento Source24

 

How to check module is enable or not in model in Magento 2


Hello Magento friends todays im share with you to check Module enables or not in magento 

in mageno2 to check Module enables or not from a system configuration setting follow Bellow Steps Carefully.

Every Professional third party Module in magento contains the Is Active or Enable feature for a module from 

➤ System -> Configuration settings.

➤  To Check module is Active/Deative or enable/disable or not in magento, 

In here I have just created a Model file


app/code/Deep/Mageget/Model/ConfigData.php file 

 


<?php
declare(strict_types=1);
/**
 * @author  Deepak Mageget
 * @package Deep_Mageget
 */

namespace Deep\Mageget\Model;

use Magento\Store\Model\ScopeInterface;
use Magento\Framework\App\Config\ScopeConfigInterface;

class ConfigData
{
    const XML_PATH_CHECK_MODULE_ENABLE = 'section_name/group_name/field_name';

    private $scopeConfig;

    public function __construct(
        ScopeConfigInterface $scopeConfig
    ) {
        $this->scopeConfig = $scopeConfig;
    }

    public function isModuleEnable(): bool
    {
        return (bool)$this->scopeConfig->getValue(
            self::XML_PATH_CHECK_MODULE_ENABLE,
            ScopeInterface::SCOPE_STORE
        );
    }
}




Deepak Kumar Bind

Success is peace of mind, which is a direct result of self-satisfaction in knowing you made the effort to become the best of which you are capable.

Post a Comment

If you liked this post please do not forget to leave a comment. Thanks

Previous Post Next Post