0

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

1 Answer 1

3

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
0

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.