Pages

Tuesday, September 8, 2015

Magetno 2: Get Store configuration value


Here we are giving the code to get the store configuration value In .php file (Block)

protected $_scopeConfig;


public function __construct(
\Magento\Framework\View\Element\Template\Context $context,
\Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig,
array $data = []
) {
parent::__construct($context, $data);
$this->_scopeConfig = $scopeConfig;
}

public function getTelephoneConfig(){

$showTemplateHint = $this->_scopeConfig->getValue('general/store_information/phone', \Magento\Store\Model\ScopeInterface::SCOPE_STORE);
return $showTemplateHint;
}



  In .Phtml file
<?php echo $block->getTelephoneConfig(); ?>

No comments:

Post a Comment