1

I want to save store configuration programtically but I'm just getting one problem after another. Firstly I wanted to use Writer class but since it only updates core_config_data table it doesn't work with more complex models like the one I want to update. Since updating the config by path works via bin/magento config:set I started digging and found out that by using Magento\Config\Model\PreparedValueFactory I should be able to create object with correct backend model name I have to save. Now the problem is that when I create the PreparedValue object it doesn't have the information - the Magento\Config\Model\Config\Structure class that's being instantiated during the create() and is responsible for giving access to system.xml configurations doesn't have any data from said files, it's methods don't return anything.

I'm sure I'm providing correct config path to the Factory so it's not that, it just looks like Structure doesn't have any configurations collected during the run of PreparedValueFactory::create(), can I do something about it or just admit defeat? Or maybe is there an easier method for saving store configs by path from upgrade scripts?

asked Dec 6, 2018 at 15:41

1 Answer 1

0

I took couple steps back and decided to just run bin/magento config:set command from within the upgrade script and it works as intended.

Do do that you have to call ConfigSetCommand::run() and provide ArrayInput and BufferedOutput as parameters. Of course you can change them to something else that implements needed interfaces but I think that's the easiest way.

answered Dec 7, 2018 at 13:27

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.