Magento 2 - How to get value in "core_config_data" table
First you need to include the Magento\Store\Model\ScopeInterface
class in your constructor:
protected $_scopeConfig;
public function __construct(
...
\Magento\Store\Model\ScopeInterface $scopeInterface,
...
)
{
...
$this->_scopeConfig = $scopeInterface;
...
}
Then in your class' method you can call the following:
$this->scopeConfig->getValue('path/of/config', \Magento\Store\Model\ScopeInterface::SCOPE_STORE);
you need to inject the an instance of \Magento\Framework\App\Config\ScopeConfigInterface
in your block.
$protected $scopeConfig;
protected $storeManager;
public function __construct(
....
\Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig,
\Magento\Store\Model\StoreManagerInterface $storeManager,
....
) {
...
$this->scopeConfig = $scopeConfig;
$this->storeManager = $storeManager;
....
}
Then create the method getStoreName()
public function getStoreName()
{
return $this->scopeConfig->getValue(
'general/store_information/name',
\Magento\Store\Model\ScopeInterface::SCOPE_STORE,
$this->storeManager->getStore()->getStoreId()
);
}
and call in your template echo $this->getStoreName()