How to return store admin variables in magento2
-
12-12-2019 - |
Вопрос
how simple would it be to do as in magento1
Mage::getStoreConfig('general/store_information/name')
Решение
$this->_scopeConfig->getValue('general/store_information/name');
And the equivalent for
Mage::getStoreConfigFlag('path/goes/here')
is
$this->_scopeConfig->isSetFlag('path/goes/here');
but you have to make sure that the _scopeConfig member exists. if it doesn't inject it in the constructor. Like this:
protected $_scopeConfig;
public function __construct(
...,
\Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig,
....
){
....
$this->_scopeConfig= $scopeConfig;
....
}
As a side node...I think the answers to all 3 questions you asked regarding magento2, should give you an idea on how to inject something you need in the controller and use it later.
Не связан с magento.stackexchange