How to get value from “core_config_data” table in Magento 2?

First you need to create object of Scope Config Interface , You can create it by constructor or by Object Manager.
Using Constructor
Inject the an instance of \Magento\Framework\App\Config\ScopeConfigInterface in your block.

protected $scopeConfig;

public function __construct()
....
\Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig,
....
) {
...
$this->scopeConfig = $scopeConfig;
....
}
Then create the method:
getStoreName()
public function getStoreName()
{
return $this->scopeConfig->getValue(
'section/group/field',
\Magento\Store\Model\ScopeInterface::SCOPE_STORE
);
}
 And call in your template:
echo $this->getStoreName()

Using ObjectManager
If you are having object of ObjectManager then you can get config as below

$this->_objectManager->get('Magento\Framework\App\Config\ScopeConfigInterface')->getValue('section/group/field');

Do you need support to implement Magento 2 codes?

Contact Now

Leave a Reply