Magento 2 Default System Values

configurationmagento-2.1

I have just installed Magento 2 and am starting to go through the configuration.
In Stores > Configuration, I notice that the fields are all greyed out (under General for example) and a checkbox is ticked next to them saying "Use System Value".

After searching for a while, I found this link:
https://magento.stackexchange.com/a/146480/1884

So I think I have found the System values for this element, however, I assume I need to know how to override these defaults, instead of editing this file?
Am I correct in thinking this?

If so, How do I override this file. Where do I copy it to?

In Magento 1, it would be app/code/local… but in Magento 2?

Best Answer

"Use system values" works as a "Restore to factory settings" feature.
Let me explain how the config section works.
The config values can come from the config.xml files of every module or from the database, core_config_data table.
If the path field from the database for a config setting matches the tag path from a config file, the database value will overwrite the value from config.xml.

For example if you have a row in the db with the path a/b/c and the value 5 and in a config.xml you have

<a>
    <b>
        <c>2</c>
    </b>
</a>

the application will use the db value 5.

What the Use system value does is to delete the row from the database for the path a/b/c making Magento use the value from config.xml if needed.

So don't be afraid to uncheck the "Use system value" checkbox and change in the UI to what you need.

But if you really want to change this value you will have to add some xml markup in one of your config.xml files of one of your modules.
For example, if you want to change the value of max_depth from the catalog module
you need to create your own module that is loaded after the catalog module (just add <sequence><Magento_Catalog /></sequence> in the module.xml file) and make your config.xml file look like this

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Store:etc/config.xsd">
    <default>
        <catalog>
            <navigation>
                <max_depth>0</max_depth>
            </navigation>
        </catalog>
    </default>
</config>