3

I'm rather new to Magento and read in this article that it is possible to configure the base_url values in app/etc/local.xml. Would be nice to have this functionality for running multiple environments, for which Magento doesn't seem to offer a lot of possibilities out of the box (correct me if I'm wrong here, though).

Am I assuming correctly that the values for base_url in local.xml will take precedence over the config values in the database?

What other database config values would you be able to override this way? Not finding a lot of documentation on this...

<config>
    <global>
    <!-- ... -->
    </global>
    <stores>
        <default>
            <web>
                <unsecure>
                    <base_url>http://beispiel.tld/shop/</base_url>
                </unsecure>
        </default>
        <admin>
            <web>
                <unsecure>
                    <base_url>https://beispiel.tld/shop/</base_url>
                </unsecure>
        </admin>
    </stores>
</config>
  • Your XML is invalid. Don't forget to close the </web> Elements! – Matthias Kleine Jul 6 '17 at 10:02
4

the order the config files are loaded is this (see Mage_Core_Model_Config::init):

  • every xml file from app/etc/
  • every xml file from app/etc/modules
  • every config.xml of the enabled modules
  • database.

Every lower lever overrides values from upper levels.
this means that what's in the database overrides anything else (if applicable). so the xml you provided works as long as you don't have in the db in the table core_config_data an entry with the path = 'web/unsecure/base_url' and scope = 'stores' and scope_id the id of the store view with the code default.

To summarize and answer your question...

Am I assuming correctly that the values for base_url in local.xml will take precedence over the config values in the database?

Your assumption is incorrect. Database overrides files configuration, but you can still have base urls in xml config files as long as you don't save a value for the same path in the db.

  • Valuable info, tnx! With "as long as you don't save a value for the same path in the db" you mean a row in the database for the path or a value other than NULL / empty string? – Maarten Troonbeeckx Feb 12 '16 at 8:12
  • an empty string or null in the database for a specific path will still override the value in the xml. – Marius Feb 12 '16 at 8:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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