Skip to content

Instantly share code, notes, and snippets.

@timneutkens
Forked from wsakaren/gist:3a26a61347cbe485677f
Last active March 24, 2019 17:45
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save timneutkens/17185b139e8476ec7296c92142d03028 to your computer and use it in GitHub Desktop.
Save timneutkens/17185b139e8476ec7296c92142d03028 to your computer and use it in GitHub Desktop.
Mage::getStoreConfig in Magento 2 compared to Magento 1

Magento 1.x:

Mage::getStoreConfig('carriers/shipper/active')

Magento 2.x (using constructor injection):

protected $scopeConfig;

public function __construct(\Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig) {
 $this->scopeConfig = $scopeConfig;
}

Then you can do

$this->scopeConfig->getValue('path/to/config', \Magento\Store\Model\ScopeInterface::SCOPE_STORE);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment