How to get store config values by scope in Magento 2

Written by Mahesh Makwana

Apr 20, 2021

How to get store config values by scope in Magento 2

We used to store configuration to store some value which affects our store and provides functionality from the configuration. All Magento store settings are saved and stored in core_config table in Magento 2.

The below code show how to get store config values:


namespace Dolphin\GetStoreVal\Helper;

use Magento\Framework\App\Helper\AbstractHelper;
use Magento\Store\Model\ScopeInterface;

class Data extends AbstractHelper
    protected $scopeConfig;
    XML_PATH_KEY = 'section_name/group_name/field_name';// add your path here

    public function __construct(
        \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig
    ) {
        $this->scopeConfig = $scopeConfig;

    public function getConfigValue($field, $storeId = null)
        return $this->scopeConfig->getValue($field, ScopeInterface::SCOPE_STORE, $storeId);

    public function getFieldVal($storeId = null)
        return $this->getConfigValue(self::XML_PATH_KEY, $storeId);


You can change the SCOPE_STORE to following:

SCOPE_STORES    For  Stores
SCOPE_GROUPS    For  Groups
SCOPE_GROUP     For  Group
SCOPE_WEBSITE   For  Website

I hope this helps you. For any doubts regarding this topic, please write your doubts in the comments section.

Mahesh Makwana


We can help you with

  • Dedicated Team
  • Setup Extended Team
  • Product Development
  • Custom App Development

Schedule a Developer Interview And Get 7 Days Risk-Free Trial

Fill out This Form and one of Our Technical Experts will Contact you Within 12 Hours.

    Copyright © 2023 DOLPHIN WEB SOLUTION. All rights reserved.

    TO TOP