Magento-1.9 – Difference Between Mage::getStoreConfig() and getConfigData()

magento-1.9

Please explain me what is the difference of

$this->getConfigData('xyz') and Mage::getStoreConfig('abc/xyz/hfc').

What is the difference of both function.

Best Answer

When you use Mage::getStoreConfig('abc/xyz/hfc') then you need to pass section name, tab name & field Name. so It will fetch value for that field.

But If Suppose you have payment module and you have more then 100 Fields so each time you can not give whole path. In your Module you can create one method like as below. so you need to just pass the key and it will create path using function.

public function getConfigData($key)
{
    return Mage::getStoreConfig("catalog/custom_options/$key");
}

It it's very easy for you to identify.

In Magento Release Notes They also mention this Line Made fetching payment methods sort order properly: via getConfigData() rather getStoreConfig() (optimization for 3rd-party customizations).

Related Topic