Magento 1.x use Mage::getStoreConfig('sections/groups/fields') get data on core_config_data table.

How to Magento2 get value from core_config_data table ?


We need to call the default method available.

Just Use \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, In your constructor argument and set the class property: $this->scopeConfig = $scopeConfig;

Now to Get the configuration value just use

$this->scopeConfig->getValue('dev/debug/template_hints', \Magento\Store\Model\ScopeInterface::SCOPE_STORE);

I have get the answer from this link and refer this

  • 3
    good one Meenakshi! keep it up – anshuman Jan 11 '17 at 16:34
  • How do you obtain them from a separate script, not from within the magento filesystem or a module? If you make a class in your script and instantiate it, what should the class inherit from, and how do you ensure it loads all the proper files? – ahnbizcad Jan 18 '18 at 22:19
  • Which scope does this get the configuration from? The currently viewed storeview by the customer? – Erfan Jan 24 '18 at 8:11
  • yes, it'll take current storeview of the customer – MeenakshiSundaram R Jan 24 '18 at 8:13
  • @MeenakshiSundaramR I am asking apart from this post, how to give free shipping for selected products using sku.Help me at magento.stackexchange.com/q/215022/57334 – zus Feb 28 '18 at 7:00

Create a function for getting configuration values in your custom module's helper.

public function getConfig($config_path)
    return $this->scopeConfig->getValue(

and call anywhere you want for example in test.phtml

$moduleStatus = $this->helper('Customvendorname\Custommodulename\Helper\Data')->getConfig('sectionid/groupid/fieldid');

In block and helper call like this:

  • 7
    It's recommended in M2 to prefer the DI approch. Thus, using $this->_objectManager->create(...) should be avoided. – Anna Völkl Jun 22 '16 at 12:27
  • Thanks @AnnaVölkl, then what is the replacement of that please can you post a similar answer here ? – Manish Jun 22 '16 at 13:12
  • See the upvoted answer above. – Anna Völkl Jun 22 '16 at 13:22

I have used the following method to retrieve the variables,

if (empty($this->_data['welcome'])) {
    $this->_data['welcome'] = $this->_scopeConfig->getValue(

return $this->_data['welcome'];

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.