How to get value from `core_config_data` table in Magento 2
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
Create a function for getting configuration values in your custom module's helper.
public function getConfig($config_path)
{
return $this->scopeConfig->getValue(
$config_path,
\Magento\Store\Model\ScopeInterface::SCOPE_STORE
);
}
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:
$this->_objectManager->create('Customvendorname\Custommodulename\Helper\Data')->getConfig('sectionid/groupid/fieldid');
I have used the following method to retrieve the variables,
if (empty($this->_data['welcome'])) {
$this->_data['welcome'] = $this->_scopeConfig->getValue(
'design/header/welcome',
\Magento\Store\Model\ScopeInterface::SCOPE_STORE
);
}
return $this->_data['welcome'];