Wednesday, August 13, 2014

How to change core configuration data in magento programmatically

$coreConfig = Mage::getModel('core/config');
$coreConfig ->saveConfig($path, $value, $scope = ‘default’, $scopeId = 0);

For it magento use core_config_data table and
core_config_data table contain two important fields scope and scope_id.
There are three scope types
    default
    websites
    stores
If scope is set to default then scope_id is always 0.
If scope is set to websites then scope_id is website_id.
If scope is set to stores then scope_id is store_id(store view).
Imagine that we need to get some config value.
How Magento will get the it for current store view?
Search value by priority:
    scope == stores and scope_id == store_id(store view)
    scope == websites and scope_id == website_id (to which belongs current store view)
    scope == default
    default section of config.xml