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?

6
  • Can't you do it simple ? get the old value, change it, run your script, save the old value Commented Feb 14, 2013 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. Commented Feb 14, 2013 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 Commented Feb 14, 2013 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}}. Commented Feb 14, 2013 at 10:53
  • Ok, and what is the purpose of changing this value ? What are you trying to do ? Commented Feb 14, 2013 at 16:40

2 Answers 2

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

Sign up to request clarification or add additional context in comments.

Comments

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

Comments

Your Answer

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.