We use cookies to make your experience better. To comply with the new e-Privacy directive, we need to ask for your consent to set the cookies. Learn more.
How to Set Store Configuration using Data Patch

On previously posts we had the chance to see how we can create a block or a CMS page programmatically using a data patch. Let's see together now how you can set store configuration via a data patch!
We have only to create a data patch class as the one below. The apply() function is the one that includes the code which is executed by running the CLI command, bin/magento setup:upgrade. In this function we set as default timezone in our shop to be 'Europe/Berlin'.
As you can see above, our class implements the DataPatchInterface. The DataPatchInterface is the standard one for a data patch class, requests to have in our class the functions apply(), getDependencies() and getAliases().
So now if you execute the command bin/magento setup:upgrade, our data patch will be executed and store configuration will be set.
The full example as extension can be found here.
Feel free to share this post and ask your questions in the comments below.
Till next time!