Is it possible to lock the design configuration in env.php?
-
14-04-2021 - |
Question
In production, the meta robots on my website is configured to be "INDEX,FOLLOW".
In staging, I run an sql query to insert or update it in the core_config_data table to be "NOINDEX,NOFOLLOW".
However, when I try to set it and lock it in the env.php file, Magento tell me that's not possible :
xxx@yyy[19/08/20 15:42:42]:~/xxx/$ php bin/magento config:set --lock-env design/search_engine_robots/default_robots "NOINDEX,NOFOLLOW"
The "design/search_engine_robots/default_robots" path doesn't exist. Verify and try again.
And magento is right : the config design/search_engine_robots/default_robots
does not exists in a system.xml file but in vendor/magento/module-theme/view/adminhtml/ui_component/design_config_form.xml
Is there any way to lock the magento design configuration values in the env.php file ?
In my opinion, it would be very convenient to set it in the file as the value is stored in core_config_data, like all the other configurations.
Pas de solution correcte
Autres conseils
I think this happens because the path you are using does not actually exist in a system.xml file. Even if it's saved in the core_config_data table as the rest of the config values, it is managed from the design management section. this section is not generated by system.xml files, but by the design_config_form.xml
ui component.
the method that validates if the config path is ok Magento\Config\Model\Config\PathValidator::validate
checks only what's generated by the system.xml files.
A quick and dirty solution would be to write a plugin for the method mentioned above and make it return true if the path matches your desired path.