How can I set per-website defaults in config.xml?

All we need is an easy explanation of the problem, so here it is.

With custom modules I prefer to put system config settings in config.xml (the default settings part). This makes it easier when I push code from my local machine to a dev/staging/live environment as I don’t need to go into admin and re-enter settings. There are other benefits too – it can be quicker to do things in a text editor and you can always have a sensible default if there is something in the config.xml for that.

I would like to do this for a multi-website Magento store that has different shipping prices for different websites (and store views). At the moment my stores are called ‘euro’, ‘usd’ and ‘gbp’. The ‘euro’ view takes the admin defaults with no over-ride at the website level whereas ‘gbp’ and ‘usd’ views are with the over-ride at website level.

    ...
    <default>
    <carriers>
        <my_courier>
            <stuff_goes_here_such_as_price/>
            <price>15.00</price>
            ...
        </my_courier>
    </carriers>
</default>

How to solve :

I know you bored from this bug, So we are here to help you! Take a deep breath and look at the explanation of your problem. We have many solutions to this problem, But we recommend you to use the first method because it is tested & true method that will 100% work for you.

Method 1

You can add this using the <stores> node in your config.xml as follows.

<stores>
    <store_code>

You can also do this on website level with the <websites> node in your config.xml as follows.

<websites>
    <website_code>

The only examples of this in the core code is in the admin side because these are the only websites or stores that are guaranteed to be in the system. Check out app/code/core/Mage/Adminhtml/etc/config.xml for an example.

<websites>
    <admin>
        <web>
            <routers>
                <frontend>
                    <disabled>true</disabled>
                </frontend>
            </routers>
            <default>
                <no_route>admin/index/noRoute</no_route>
            </default>
        </web>
    </admin>
</websites>

Note: Use and implement method 1 because this method fully tested our system.
Thank you 🙂

All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply