Reputation: 5042
What is getConfigData? and diff between getConfigData and getStoreConfigData in Magento.
$this->getConfigData('shippingspecificcountry', $store_id);
I tried with my current store id and 0, both gives empty array.
Can anyone explain about the above method.
Upvotes: 0
Views: 2337
Reputation: 166106
Your question could use a little more context -- lacking that.
The Mage::getStoreConfig
method is a static method on the global Mage
class, and provides access to configuration values stored in Magento's Configuration tree. Magento's configuration tree is created by
app/etc/*.xml
config.xml
files from the active modulescore_config_data
(via System -> Configuration
in the admin)Because Magento's configuration is so big, many module developers add methods like getConfigData
or getConfig
to make fetching specific configuration values easy. For example, consider this oversimplified example
Mage::getStoreConfig('foo/baz/bar')
vs.
$this->getConfig('bar');
....
public function getConfigData($key)
{
return Mage::getStoreConfig('foo/baz/' . $bar);
}
The second allows a client programmer more concise code.
You can see an example of this in the base class for Magento's various shipping carriers
public function getConfigData($field)
{
if (empty($this->_code)) {
return false;
}
$path = 'carriers/'.$this->_code.'/'.$field;
return Mage::getStoreConfig($path, $this->getStore());
}
Here the getConfigData
method will automatically look for the configuration key in the carriers
node -- using the carrier's _code
as a sub-node, and checking the instantiated carrier object for a store code.
The getConfigData
method will behave differently depending on which class/object you're using, but hopefully that's enough to get you pointed in the right direction.
Upvotes: 5