Magento – custom config for module – not store config

modulexml

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?

Best Answer

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');
Related Topic