1

I want to modify a setting, which I know how to find and change in the Magento Admin, - but I want to modify it in the config.php file. Which way can i find out the configuration path / syntax within the config.php file for that specific setting?

Example I want to set the cookie restriction mode to Yes via config.php. http://docs.magento.com/m2/ee/user_guide/stores/compliance-cookie-restriction-mode.html describes how to change the setting in the Magento Admin.

It seems to be possible to get the path from /src/vendor/magento/module-cookie/etc/config.xml:

<?xml version="1.0"?>
<!--
/**
 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Store:etc/config.xsd">
 <default>
    <web>
        <cookie>
            <cookie_lifetime>3600</cookie_lifetime>
            <cookie_httponly>1</cookie_httponly>
            <cookie_restriction>0</cookie_restriction>
            <cookie_restriction_lifetime>31536000</cookie_restriction_lifetime>
        </cookie>
    </web>
 </default>
</config>

... which could translate into ...

'system' => 
  array (
    'default' => 
      array ( 
        'web' =>
           array (
             'cookie' =>
                array (
                  'cookie_lifetime' => '3600',
                  'cookie_restriction' => '1'

... but that seems a bit complicated to me for everyday usage (1. find the right module, 2. investigate source code, 3. translate xml to config.php format). Is there an easier way?

  • Have you checked this with config:dump command? – Ramkishan Suthar Sep 26 '18 at 4:58
  • I'm a bit worried about destroying my config with that one, @Ramkishan... – hey Oct 5 '18 at 1:44
  • It actually was a great hint! - I took a backup of env.php and config.php first, then run bin/magento app:config:dump. The script updated env.php and config.php for me; I stored the two updated files in a safe place and restored the backup, so that the environment would run the same way as before. I then was able to find and copy the configurations I needed in the stored config.php file. Thank you, @Ramkishan! – hey Oct 5 '18 at 2:37
  • your most welcome man – Ramkishan Suthar Oct 5 '18 at 3:43
  • @Ramkishan, do you want to add it as an answer, so that I can mark it as "correct"? – hey Oct 23 '18 at 20:09
1

You can do this using app:config:dump command. This will generate system specific, configuration specific, sensitive configuration settings in config.php and env.php files. Then using app:config:import command you can update your configuration once you update these files.

I hope it'll work for you.

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.