2

If I want to add a custom configuration node in my modules config.xml, how would I go about this and how to retrieve the values?

I do not want store configuration, just a node in my modules configuration file where I can put some variables that my module needs.

Also is there any best practices for doing this?

1 Answer 1

5

There is no need to add a system.xml to have a node in the configuration.

You can take the configuration wherever you want it. If you want an easy way to retrieve it and it doesn't feel wrong, just put it in:

<config>
    <default>
        <your_module_identifier>
            <your_identifiert>
                <your_config_setting>SETTING</your_config_setting>
            </your_identifiert>
        </your_module_identifier>
    </default>
</config>

Then you can retrieve this setting with:

Mage::getStoreConfig('your_module_identifier/your_identifiert/your_config_setting');

The alternative is to put it wherever you want it, like the fieldsets in the Mage_Sales config.xml:

<config>
    <global>
        <fieldsets>
            ...
        </fieldsets>
    </global>
</config>

Then you need to use:

Mage::getConfig()->getNode('global/fieldsets/whatever/path/you/have/in/your/xml');
2
  • Quick and easy solution that I didn't know, thanks!
    – Kenny
    Sep 2, 2013 at 13:15
  • I like "and it doesn't feel wrong" - thats programmer's intuition right there
    – Deus777
    Jun 16, 2017 at 8:21

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.