10

I am using pipeline deployment. As suggested in Magento 2.2 documentation, to use pipeline deployment process use below code:

app:config:dump

and add config.php to source control. But when i execute app:config:dump it locks everything in system configuration. Even not able to update store email addresses.

Is there any way to dump only required settings that will be used to generate static content on build system?

I am confused whether to use pipeline deployment or not. I am using Magento 2.2 CE Open Source version.

Any one has implemented pipeline deployment and any suggestion for me.

Thanks in advance.

5 Answers 5

6

You need to delete all data from app > etc > config.php except modules array.

After run below command
setup:upgrade
setup:di:compile
setup:static-content:deploy -f
cache:flush.

All your system configuration are unlocked and you can change the value of it.

2
  • Thanks a lot @himanshu!!It works like a charm! Commented Dec 7, 2018 at 5:16
  • 1
    It is enough to just call setup:upgrade
    – Black
    Commented Jan 28, 2020 at 21:23
4

I also do not think that dumping all settings is a good idea, so I created this PR to be able to skip dumping the whole core_config_data:

As I mention on the PR, the right way to manage core_config_data settings into config.php should be manually and not using any dump system. That is because those settings should be not more than a few and developers know which ones are needed. The dump still makes sense for scopes and themes as in that case we need all settings for those scopes inside config.php

That said, until the PR gets accepted, if it ever does... We accomplish the same by adding the following in our projects:

module.xml

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Module/etc/module.xsd">
    <module name="VendorName_ModuleName" setup_version="0.0.1" >
        <sequence>
            <module name="Magento_Config"/>
        </sequence>
    </module>
</config> 

di.xml

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
    <virtualType name="skipDumpSystemSource" type="Magento\Config\App\Config\Source\DumpConfigSourceAggregated">
        <arguments>
            <argument name="sources" xsi:type="array">
            </argument>
            <argument name="rules" xsi:type="array">
            </argument>
        </arguments>
    </virtualType>
    <type name="Magento\Deploy\Console\Command\App\ApplicationDumpCommand">
        <arguments>
            <argument name="sources" xsi:type="array">
                <item name="system" xsi:type="array">
                    <item name="source" xsi:type="object">skipDumpSystemSource</item>
                    <item name="namespace" xsi:type="string">skipSystem</item>
                    <item name="comment" xsi:type="string"></item>
                </item>
                <item name="system_env" xsi:type="array">
                    <item name="source" xsi:type="object">skipDumpSystemSource</item>
                    <item name="namespace" xsi:type="string">skipSystem</item>
                </item>
            </argument>
        </arguments>
    </type>
</config>

These configuration will skip the dump for all core_config_data settings while keeping any system configuration already existing in config.php and env.php

Another option: If that does not work for you and you still want to specify which core_config_data should be dumped automatically, you can check this gist code:

That code allows you to specify which config settings to dump into config.php like that:

<!-- any di.xml -->    
<type name="VendorName\ModuleName\Model\Config\Type\TypeConfigPool">
    <arguments>
        <argument name="includeInConfigPhp" xsi:type="array">
            <item name="dev/js/merge_files" xsi:type="string">1</item>
            <item name="dev/css/merge_css_files" xsi:type="string">1</item>
            <item name="dev/static/sign" xsi:type="string">1</item>
        </argument>
     </arguments>
</type>
1
  • All this can be done now in Magento 2.3, using the cli. Commented Jan 6, 2019 at 20:47
3

This is by design. Any configuration contained in config files will be locked in the Admin Panel. The recommendation is to make all needed configuration updates on your system before using the app:config:dump command as documented in the recommended pipeline deployment workflow. Unfortunately there's not a way to generate only the config needed by static content deploy for now (though you could create your own).

You have two options to edit configuration values after you dump the config:

  • remove the needed configuration line from the config file (and then run config:import). This will make it editable in Admin Panel again.
  • change the needed config value with the help of config:set --lock CLI command
3
  • Magento cloud have such command magento-cloud:scd-dump on devdocs.magento.com/guides/v2.2/cloud/live/… and it is Recommended. So there should be similar one in Magento CE. May be they will include it in future. Commented Oct 16, 2017 at 8:13
  • 1
    @gulshanmaurya hopefully it gets included in the future. I created a PR long time ago but it has not been accepted yet. github.com/magento/magento2/pull/12410 In the meantime, I use the solution described in my answer below. It's working really well so far.
    – Jalogut
    Commented Mar 3, 2018 at 13:33
  • This makes no sense. What if you need to change something in the config? Then you will have to change it in app/etc/config.php ??? Try to explain this to someone who is not a developer. Magento gives me headache ...
    – Black
    Commented Sep 3, 2020 at 16:02
3

If you absolutely MUST unlock all configuration as I had to do, there is a way but it's quite tedious and time consuming.

As this can be dangerous it goes without saying you should backup your database before undertaking this process.

  1. Dump all current config php bin/magento app:config:dump and make a backup of this file - you'll need it later
  2. Remove all config from app/etc/config.php, but leave some stuff in, like in this example: https://pastebin.com/XKxM08q1

  3. Go to your database and run SELECT flag_data FROM flag WHERE flag_code = 'system_config_snapshot'; This will return a long JSON. Try validating it using an online tool.

  4. It's likely that validation will fail since the column's flag_data type is TEXT (as per 2.2.3) which can only take 65k characters and the value might be trimmed. In my case the JSON ended like ... {"email":"[email protected]"},"ident_sales":{"email":"[email protected]"},"ident_suppor which is obviosusly invalid so I changed it to ... {"email":"[email protected]"},"ident_support":{}}}}}.

  5. Change the column type to MEDIUMTEXT or LONGTEXT

  6. Try fixing the likely invalid JSON and replace the value of system_config_snapshot

  7. Run php bin/magento app:config:import and pray it'll "import" (in this case unlock) all configuration

  8. If all goes well your configuration should be unlocked and empty/default. This is why we dumped the config in step 1
  9. Create a custom script that will parse the dumped config.php file. You can get the code here https://pastebin.com/rhYGxeiL
  10. Run the script in your browser. It will only output a list of commands that you can later put in a .sh script.
  11. Adjust the script to your needs. This was sufficient for my scenario but you might need to tweak it a bit.

Script output should be something like this:

echo "#0 - Setting : design/pagination/list_allow_all";
bin/magento config:set design/pagination/list_allow_all "1";
echo "#1 - Setting : design/pagination/pagination_frame";
bin/magento config:set design/pagination/pagination_frame "5";
echo "#2 - Setting : design/head/default_title";
bin/magento config:set design/head/default_title "Site title";
echo "#3 - Setting : design/head/default_media_type";
bin/magento config:set design/head/default_media_type "text/html";
echo "#4 - Setting : design/head/default_charset";
bin/magento config:set design/head/default_charset "utf-8";
echo "#5 - Setting : design/head/demonotice";
bin/magento config:set design/head/demonotice "0";
echo "#6 - Setting : design/head/shortcut_icon";
bin/magento config:set design/head/shortcut_icon "default/favicon.ico";
echo "#7 - Setting : design/search_engine_robots/default_robots";
bin/magento config:set design/search_engine_robots/default_robots "INDEX,FOLLOW";
echo "#8 - Setting : design/search_engine_robots/default_custom_instructions";
bin/magento config:set design/search_engine_robots/default_custom_instructions "
User-agent: *
Disallow: /index.php/
Disallow: /*?
Disallow: /checkout/
Disallow: /app/
Disallow: /lib/
Disallow: /*.php$
Disallow: /pkginfo/
Disallow: /report/
Disallow: /var/
Disallow: /catalog/
Disallow: /customer/
Disallow: /sendfriend/
Disallow: /review/
Disallow: /*SID=
            ";

echo #[n] - Setting [path] is there just so you can see what's going on later in the console. Note the multiline value for design/search_engine_robots/default_custom_instructions -> this is fine.

Once you confirm everything is OK you can put the entire output inside a .sh file, e.g. config_import.sh on your server and run it sh config_import.sh and watch the configuration import. It can (will) take some time so be patient.


Bottom line: if you aren't absolutely sure you'll use the pipeline deployment as per documentation, do not lock the configuration :)

Good luck

4
  • For those facing the same issue, an even simplier way to solve the problem of the JSON in 'system_config_snapshot ' is to delete it entierly and replace the content with an empty JSON object: {}. Magento will then repopulate the field for you on your next setup:upgrade. In any case, updating the field to LONGTEXT is a good idea...
    – grll
    Commented Apr 1, 2020 at 22:07
  • @grll Does not work, I get Invalid configuration file: 'app/etc/config.php' if I replace the content with just {}
    – Black
    Commented Sep 3, 2020 at 16:04
  • @Black you didn't read the comment correctly. They said to replace the content in system_config_snapshot not in the config.php
    – Zankar
    Commented Sep 7, 2020 at 7:43
  • @Zankar, Where do I find system_config_snapshot?
    – Black
    Commented Sep 7, 2020 at 9:24
1

Here is a slightly modified version of the php script by Zankar above that dumps the config commands to the console instead of in an HTML page.

I create a file called: config-php-to-config-cli.php

<?php

$skip = [
    'customer/address_templates/html',
    // add any config paths you might want to avoid importing
];

$config = include './mag_configs/dev.config.php';  // this is the dumped config backup
$i = 0;

echo 'cd $mroot';    
echo "\n";
echo "set -v\n"; //so that you can see the commands being executed

foreach ($config['system'] as $l0 => $l0items) {
    if ($l0 == 'default') {
        foreach ($l0items as $l1 => $l1items) {
            foreach ($l1items as $l2 => $l2items) {
                if (!is_array($l2items)) { continue; }
                foreach ($l2items as $key => $value) {
                    if (in_array("$l1/$l2/$key", $skip)) {
                        continue;
                    }
                    $buffer = "bin/magento config:set $l1/$l2/$key";
                    if (is_string($value)) {
                        $buffer .= ' "' . str_replace('"', '\"', $value) . '";';
                        //echo '\n\n echo "#'.$i++.' - Setting : ' . $l1.'/'.$l2.'/'.$key.'";\n\n';
                        echo "$buffer\n";
                    } else {
                        continue;
                    }
                }
            }
        }
    } else {
        foreach ($l0items as $scope => $items) {
            if (in_array($scope, ['admin', 'default'])) {
                continue;
            }
            foreach ($items as $l1 => $l1items) {
                foreach ($l1items as $l2 => $l2items) {
                    if (!is_array($l2items)) { continue; }
                    foreach ($l2items as $key => $value) {
                        if (in_array("$l1/$l2/$key", $skip)) {
                            continue;
                        }
                        $buffer = "bin/magento config:set $l1/$l2/$key --scope website --scope-code $scope";
                        if (is_string($value)) {
                            $buffer .= ' "' . str_replace('"', '\"', $value) . '";';
                            //echo '\n\necho "#'.$i++.' - Setting : ' . $l1.'/'.$l2.'/'.$key.' for website ' . $scope .'";\n\n';
                            echo "$buffer\n";
                        } else {
                            continue;
                        }
                    }
                }
            }
        }
    }
}


echo "bin/magento setup:upgrade\n";
echo "bin/magento setup:di:compile\n";
echo "bin/magento setup:static-content:deploy -f\n";
echo "bin/magento cache:flush config\n";
echo "set +v\n"; //so that you can see the commands being executed

?>

and then I create a bash script with these contents:

php config-php-to-config-cli.php > cli-config-dev.sh
echo Generated ./cli-config-dev.sh

Oh and here is the config.php file you can use to go back to an unlocked config:

<?php
return [
    'modules' => [
        'Magento_Store' => 1,
        'Magento_Directory' => 1,
        'Magento_Theme' => 1,
        'Magento_Backend' => 1,
        'Magento_Variable' => 1,
        'Magento_Eav' => 1,
        'Magento_AdminNotification' => 1,
        'MSP_ReCaptcha' => 1,
        'Magento_Config' => 1,
        'Magento_Indexer' => 1,
        'Magento_AdvancedPricingImportExport' => 1,
        'Magento_Search' => 1,
        'Magento_Amqp' => 1,
        'Magento_Security' => 1,
        'Magento_User' => 1,
        'Magento_Authorization' => 1,
        'Magento_Customer' => 1,
        'Magento_Rule' => 1,
        'Magento_Backup' => 1,
        'Magento_Cms' => 1,
        'Magento_Catalog' => 1,
        'Magento_GraphQl' => 1,
        'Magento_BundleImportExport' => 1,
        'Magento_CatalogRule' => 1,
        'Magento_CacheInvalidate' => 1,
        'Magento_Quote' => 1,
        'Magento_SalesSequence' => 1,
        'Magento_Integration' => 1,
        'Magento_EavGraphQl' => 1,
        'Magento_CatalogImportExport' => 1,
        'Magento_Payment' => 1,
        'Magento_CatalogInventory' => 1,
        'Magento_Cron' => 1,
        'Magento_Msrp' => 1,
        'Magento_CatalogSearch' => 1,
        'Magento_Sales' => 1,
        'Magento_Checkout' => 1,
        'Magento_CatalogUrlRewrite' => 1,
        'Magento_CatalogUrlRewriteGraphQl' => 1,
        'Magento_Widget' => 1,
        'Magento_Vault' => 1,
        'Magento_CheckoutAgreements' => 1,
        'Magento_Paypal' => 1,
        'Magento_CmsGraphQl' => 1,
        'Magento_Downloadable' => 1,
        'Magento_CmsUrlRewrite' => 1,
        'Magento_CmsUrlRewriteGraphQl' => 1,
        'MSP_TwoFactorAuth' => 1,
        'Magento_ConfigurableImportExport' => 1,
        'Magento_UrlRewrite' => 1,
        'Magento_StoreGraphQl' => 1,
        'Magento_ConfigurableProduct' => 1,
        'Magento_GroupedProduct' => 1,
        'Magento_Contact' => 1,
        'Magento_Cookie' => 1,
        'Magento_Email' => 1,
        'Magento_CurrencySymbol' => 1,
        'Klarna_Core' => 1,
        'Magento_Analytics' => 1,
        'Magento_CustomerGraphQl' => 1,
        'Magento_CustomerImportExport' => 1,
        'Magento_SampleData' => 1,
        'Magento_Deploy' => 1,
        'Magento_Developer' => 1,
        'Magento_Dhl' => 1,
        'Amazon_Core' => 1,
        'Magento_Tax' => 1,
        'Magento_CatalogGraphQl' => 1,
        'Magento_ImportExport' => 1,
        'Magento_Weee' => 1,
        'Magento_Authorizenet' => 1,
        'Magento_BundleGraphQl' => 1,
        'Magento_AdvancedSearch' => 1,
        'Magento_Newsletter' => 1,
        'Magento_EncryptionKey' => 1,
        'Magento_Fedex' => 1,
        'Magento_GiftMessage' => 1,
        'Magento_GoogleAdwords' => 1,
        'Magento_GoogleAnalytics' => 1,
        'Magento_Ui' => 1,
        'Magento_ConfigurableProductGraphQl' => 1,
        'Magento_GroupedImportExport' => 1,
        'Magento_CatalogRuleConfigurable' => 1,
        'Magento_GroupedProductGraphQl' => 1,
        'Magento_CatalogSampleData' => 1,
        'Magento_DownloadableImportExport' => 1,
        'Magento_Braintree' => 1,
        'Magento_InstantPurchase' => 1,
        'Magento_CatalogAnalytics' => 1,
        'Magento_Inventory' => 1,
        'Magento_InventoryAdminUi' => 1,
        'Magento_InventoryApi' => 1,
        'Magento_InventoryBundleProduct' => 1,
        'Magento_InventoryBundleProductAdminUi' => 1,
        'Magento_InventoryCatalog' => 1,
        'Magento_InventorySales' => 1,
        'Magento_InventoryCatalogAdminUi' => 1,
        'Magento_InventoryCatalogApi' => 1,
        'Magento_InventoryCatalogSearch' => 1,
        'Magento_InventoryConfigurableProduct' => 1,
        'Magento_InventoryConfigurableProductAdminUi' => 1,
        'Magento_InventoryConfigurableProductIndexer' => 1,
        'Magento_InventoryConfiguration' => 1,
        'Magento_InventoryConfigurationApi' => 1,
        'Magento_InventoryDistanceBasedSourceSelection' => 1,
        'Magento_InventoryDistanceBasedSourceSelectionAdminUi' => 1,
        'Magento_InventoryDistanceBasedSourceSelectionApi' => 1,
        'Magento_InventoryElasticsearch' => 1,
        'Magento_InventoryGroupedProduct' => 1,
        'Magento_InventoryGroupedProductAdminUi' => 1,
        'Magento_InventoryGroupedProductIndexer' => 1,
        'Magento_InventoryImportExport' => 1,
        'Magento_InventoryIndexer' => 1,
        'Magento_InventoryLowQuantityNotification' => 1,
        'Magento_InventoryLowQuantityNotificationAdminUi' => 1,
        'Magento_InventoryLowQuantityNotificationApi' => 1,
        'Magento_InventoryMultiDimensionalIndexerApi' => 1,
        'Magento_InventoryProductAlert' => 1,
        'Magento_InventoryReservations' => 1,
        'Magento_InventoryReservationsApi' => 1,
        'Magento_InventoryCache' => 1,
        'Magento_InventorySalesAdminUi' => 1,
        'Magento_InventorySalesApi' => 1,
        'Magento_InventorySalesFrontendUi' => 1,
        'Magento_InventorySetupFixtureGenerator' => 0,
        'Magento_InventoryShipping' => 1,
        'Magento_Shipping' => 1,
        'Magento_InventorySourceDeductionApi' => 1,
        'Magento_InventorySourceSelection' => 1,
        'Magento_InventorySourceSelectionApi' => 1,
        'Magento_LayeredNavigation' => 1,
        'Magento_Marketplace' => 1,
        'Magento_MediaStorage' => 1,
        'Magento_MessageQueue' => 1,
        'Magento_GroupedProductSampleData' => 1,
        'Magento_MsrpSampleData' => 1,
        'Magento_Multishipping' => 1,
        'Magento_MysqlMq' => 1,
        'Magento_NewRelicReporting' => 1,
        'Magento_ProductAlert' => 1,
        'Magento_OfflinePayments' => 1,
        'Magento_SalesRule' => 1,
        'Magento_OfflineShipping' => 1,
        'Magento_PageCache' => 1,
        'Magento_Captcha' => 1,
        'Klarna_Ordermanagement' => 1,
        'Magento_Persistent' => 1,
        'Magento_Reports' => 1,
        'Magento_Bundle' => 1,
        'Magento_ProductVideo' => 1,
        'Amazon_Login' => 1,
        'Magento_QuoteAnalytics' => 1,
        'Magento_QuoteGraphQl' => 1,
        'Magento_ReleaseNotification' => 1,
        'Magento_Review' => 1,
        'Magento_RequireJs' => 1,
        'Magento_SendFriend' => 1,
        'Magento_ReviewAnalytics' => 1,
        'Magento_BundleSampleData' => 1,
        'Magento_Robots' => 1,
        'Magento_Rss' => 1,
        'Magento_ThemeSampleData' => 1,
        'Amazon_Payment' => 1,
        'Magento_SalesAnalytics' => 1,
        'Magento_SalesInventory' => 1,
        'Magento_OfflineShippingSampleData' => 1,
        'Magento_DownloadableSampleData' => 1,
        'Magento_TaxSampleData' => 1,
        'Magento_ConfigurableSampleData' => 1,
        'Magento_ProductLinksSampleData' => 1,
        'Magento_Elasticsearch' => 1,
        'Magento_CustomerAnalytics' => 1,
        'Magento_Wishlist' => 1,
        'Magento_InventoryShippingAdminUi' => 1,
        'Magento_Signifyd' => 1,
        'Magento_Sitemap' => 1,
        'Magento_CatalogInventoryGraphQl' => 1,
        'Magento_DownloadableGraphQl' => 1,
        'Magento_Webapi' => 1,
        'Magento_SwaggerWebapi' => 1,
        'Magento_SwaggerWebapiAsync' => 1,
        'Magento_Swatches' => 1,
        'Magento_SwatchesGraphQl' => 1,
        'Magento_SwatchesLayeredNavigation' => 1,
        'Magento_SwatchesSampleData' => 1,
        'Magento_ReviewSampleData' => 1,
        'Magento_TaxGraphQl' => 1,
        'Magento_TaxImportExport' => 1,
        'Magento_CustomerSampleData' => 1,
        'Magento_TestModuleAsyncAmqp' => 1,
        'Magento_TestModuleDirectoryZipCodes' => 1,
        'Magento_TestModuleExtensionAttributes' => 1,
        'Magento_TestModuleFakePaymentMethod' => 1,
        'Magento_TestModuleMessageQueueConfigOverride' => 1,
        'Magento_TestModuleMessageQueueConfiguration' => 1,
        'Magento_TestModuleSample' => 1,
        'Magento_TestModuleSynchronousAmqp' => 1,
        'Magento_TestModuleWysiwygConfig' => 1,
        'Magento_ConfigurableProductSales' => 1,
        'Magento_CmsSampleData' => 1,
        'Magento_Tinymce3' => 1,
        'Magento_Translation' => 1,
        'Magento_GoogleOptimizer' => 1,
        'Magento_Ups' => 1,
        'Magento_SalesSampleData' => 1,
        'Magento_UrlRewriteGraphQl' => 1,
        'Magento_AsynchronousOperations' => 1,
        'Magento_Usps' => 1,
        'Magento_CatalogRuleSampleData' => 1,
        'Klarna_Kp' => 1,
        'Magento_Version' => 1,
        'Magento_Swagger' => 1,
        'Magento_WebapiAsync' => 1,
        'Magento_WebapiSecurity' => 1,
        'Magento_SalesRuleSampleData' => 1,
        'Magento_WeeeGraphQl' => 1,
        'Magento_CatalogWidget' => 1,
        'Magento_WidgetSampleData' => 1,
        'Dotdigitalgroup_Email' => 1,
        'Magento_WishlistAnalytics' => 1,
        'Magento_WishlistSampleData' => 1,
        'Temando_Shipping' => 1,
        'Vertex_Tax' => 1
    ]
];

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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