We can get system configuration values using
Mage::getStoreConfig($xmlPath);
But how can we set such configuration field programatically? I would expect some method like
Mage::setStoreConfig($xmlPath, $val);
But the closest thing I'm seeing is
Mage::app()
 ->getStore()
 ->setConfig($xmlPath, $val);
 ->save();
But this is not updating the config value. Thanks for your time and help.
 asked Sep 19, 2019 at 21:04
 
 
 
 Nick Rolando 
 
 1,2125 gold badges17 silver badges36 bronze badges
 
 1 Answer 1
This should work
/*
*turns notice on
*/
Mage::getConfig()->saveConfig('design/head/demonotice', '1', 'default', 0);
/*
*turns notice off
*/
Mage::getConfig()->saveConfig('design/head/demonotice', '0', 'default', 0);
class Mage_Core_Model_Config
{
 /**
 * Save config value to DB
 *
 * @param string $path
 * @param string $value
 * @param string $scope
 * @param int $scopeId
 * @return Mage_Core_Store_Config
 */
 public function saveConfig($path, $value, $scope = 'default', $scopeId = 0)
 {
 $resource = $this->getResourceModel();
 $resource->saveConfig(rtrim($path, '/'), $value, $scope, $scopeId);
 return $this;
 }
}
 
 answered Sep 19, 2019 at 22:02
 
 
 
 Dominic Pixie 
 
 7,7134 gold badges21 silver badges64 bronze badges
 
 Explore related questions
See similar questions with these tags.
default