How To Update Magento 2 Store Config Value Programmatically

How can I update Magento 2 store config values programmatically

You can use same method as add Magento 2 store core config.

$configData = [
    'section' => 'YOUR_SECTION',
    'website' => null,
    'store'   => null,
    'groups'  => [
        'YOUR_GROUP' => [
            'fields' => [
                'YOUR_FIELD' => [
                    'value' => $yourValue,
                ],
            ],
        ],
    ],
];

$configFactory = \Magento\Framework\App\ObjectManager::getInstance()->get('Magento\Config\Model\Config\Factory');
$configModel = $configFactory->create(['data' => $configData]);
$configModel->save();

Magento 2: Programmatically Add A Store Config Value

0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments