5

In my Magento module, I want to change a config option for just one run - the change should not be saved in the database.

It is only to change it with certain conditions during runtime, so that all subsequent core calls etc use that option.

I know you can use something like Mage::getConfig()->saveConfig(...), but that actually saves the change in the database.
I'm using Magento 1.5.

Is that in any way possible?

शेखर
  • 17,412
  • 13
  • 61
  • 117
Lanbo
  • 15,118
  • 16
  • 70
  • 147
  • Can't you do it simple ? get the old value, change it, run your script, save the old value – dagfr Feb 14 '13 at 10:34
  • @dagfr No because I have to set it very early (right at App::run) and it has to span over all of magento's functionality. – Lanbo Feb 14 '13 at 10:37
  • You can also register the value you need (with Mage::register) and use this registry instead of the config everywhere you need it – dagfr Feb 14 '13 at 10:43
  • @dagfr Which would imply I have to re-write half of Magento's core libraries. The value I need to change is the `{{base_url}}`. – Lanbo Feb 14 '13 at 10:53
  • Ok, and what is the purpose of changing this value ? What are you trying to do ? – dagfr Feb 14 '13 at 16:40
  • Make magento accept a second url for the same shop - while still leaving the url untouched. But I found another workaround, I should remove this question. – Lanbo Feb 14 '13 at 20:55

2 Answers2

3

Try to this:

Mage::getConfig()->setNode($path, $value);

See http://inchoo.net/ecommerce/magento/how-to-programmatically-change-magentos-core-config-data/comment-page-1/#comment-9535

Jiří Chmiel
  • 876
  • 6
  • 20
0

Use $store->setConfig('config_path', 'value_to_set') to take in memory cache into account. Note that this is independent from the Magento config cache, but if you call Mage::getStoreConfig() twice with the same path it won't read the loaded XML structure but instead look it up in an array.

See: https://stackoverflow.com/a/23384578/664108

Community
  • 1
  • 1
Fabian Schmengler
  • 24,155
  • 9
  • 79
  • 111