6

To get store config data, I would use this code:

$data = Mage::getStoreConfig('my/path/whatever'); 

Now, how could I save to that node? I tried Alans suggestions from Override Magento Config, but it did not work for me.

Thanks!

Community
  • 1
  • 1
user4095519
  • 271
  • 1
  • 5
  • 12

3 Answers3

15

Try following:

$value = "100";
Mage::getModel('core/config')->saveConfig('my/path/whatever', $value);

OR

$resource = $this->getResourceModel();
$resource->saveConfig(rtrim('my/path/whatever', '/'), 1, 'default', 0);
  • Does this work for any configuration setting? I got a similar question in magento.exchange: http://magento.stackexchange.com/questions/105634/how-to-export-import-features-settings-in-magento – Jurik Mar 14 '16 at 15:28
  • first one is not working for me. which of the arguments in the second example is the value that is being saved? – Mike W Apr 27 '18 at 14:53
2

Empire Solution is right but do remember to clean cache after it. So use something like

$value = "100";
Mage::getModel('core/config')->saveConfig('my/path/whatever', $value);
Mage::getModel('core/config')->cleanCache();
zainengineer
  • 13,289
  • 6
  • 38
  • 28
0

I have a cases when i need change configuration and get changed configuration in the same runnig script. So the expresion doese not work for me:

$value = "100";
Mage::getModel('core/config')->saveConfig('my/path/whatever', $value);
Mage::getModel('core/config')->cleanCache();

I looked at the Mage class and realized that $_config property is a static property and found Mage::reset() method. So fo my case work such expression:

$value = "300";
Mage::getModel('core/config')->saveConfig('my/test/config', $value);
Mage::getModel('core/config')->cleanCache();

Mage::reset();
Mage::app();

$changed_data = Mage::getStoreConfig('my/test/config');
  • The following works pretty well: `Mage::app()->getStore()->setConfig('payment/modulename/order_status', 'pending');`. Without any additional reset/clear. My case was to set another status on order, other than that in the DB at the order creation time. The code was used in an observer. – LucianDex Jan 04 '23 at 19:59