🔥 Just Launched! Werra Premium Template for HyväSee it in Action

How To Get Data From System Configuration In Magento 2

By Sanjay JethvaUpdated on May 22, 2025 1 min read

Are you a beginner in Magento 2 development? If so, I guess you are on your first tutorial on Magento 2 module development!

And hence, the below solution to get data from system configuration in Magento 2 is going to be used often. You might as well bookmark this post!

For example, you want to get the data of Magento 2 extension status, if it is enabled or disabled.

Magento 2 allows creating custom configuration fields and get config data programmatically from other modules or core Magento!

Method To Get Data From System Configuration In Magento 2:

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

protected $scopeConfig;

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


public function getConfigValue() {
    return $this->scopeConfig->getValue("sectionId/groupId/fieldId",ScopeInterface::SCOPE_STORE);
}

That’s it. To make your extensions work expectedly certain configurations are made to have particular values for that you need to set default values for Magento 2 system configuration.

Do share the post with the Magento community via social media.

Thanks.

Sanjay Jethva Full Image
Article bySanjay Jethva

Sanjay is the co-founder and CTO of Meetanshi with hands-on expertise with Magento since 2011. He specializes in complex development, integrations, extensions, and customizations. Sanjay is one the top 50 contributor to the Magento community and is recognized by Adobe. His passion for Magento 2 and Shopify solutions has made him a trusted source for businesses seeking to optimize their online stores. He loves sharing technical solutions related to Magento 2 & Shopify.