0

When I save a config value, it updates the database but does not change the content in the configuration > admin section. When I get the value, its the unchanged one from the admin, not the value in the database.

Updating value with configWriterInterface updates values in the database but does not carry the value to the admin. When trying to call the value later with scopeConfigInterface it returns the value from the admin field, not the database.

What am I doing wrong?

 /**
 * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig
 */

 public function __construct(
    \Magento\Framework\App\Config\Storage\WriterInterface $configWriter
) {
    $this->_configWriter = $configWriter;
  }

  $value = 'newvalue';
  $this->_configWriter->save('carriers/testship/name', $value);

Value in the database: value updating in database

Value in the admin: admin value

If I call the value from scopeconfiginterface, I get the Admin value.

// get the Object Manager
$objectManager = $bootstrap->getObjectManager();
$scopeConfig = $objectManager->create('Magento\Framework\App\Config\ScopeConfigInterface');
$value =  $scopeConfig->getValue('carriers/testship/name',  \Magento\Store\Model\ScopeInterface::SCOPE_STORE);
echo "value: ".$value."\n";
value: oldvalue

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.