How I should ‘Setup/update System/store Configuration values through setup script’? Trying with Setup/Patch/Data script using something like
//app/code/Namespace/Module/Setup/Patch/Data/SetupConfigData.php
namespace NamespaceModuleSetupPatchData;
use MagentoFrameworkSetupModuleDataSetupInterface;
use MagentoFrameworkSetupPatchDataPatchInterface;
use MagentoFrameworkAppConfigMutableScopeConfigInterface;
class SetupConfigData implements DataPatchInterface
{
const XML_PATH_STORE_NAME = 'general/store_information/name';
const XML_PATH_STORE_PHONE = 'general/store_information/phone';
const XML_PATH_ADMIN_ACCOUNT_SHARING = 'admin/security/admin_account_sharing';
const XML_PATH_ADMIN_URL_SECRET_KEY = 'admin/security/use_form_key';
const SCOPE_STORE = 'store';
/**
* @var MagentoFrameworkAppConfigMutableScopeConfigInterface
*/
private $mutableScopeConfig;
/**
* @var ModuleDataSetupInterface
*/
private $moduleDataSetup;
public function __construct(
ModuleDataSetupInterface $moduleDataSetup,
MutableScopeConfigInterface $mutableScopeConfig
)
{
$this->moduleDataSetup = $moduleDataSetup;
$this->mutableScopeConfig = $mutableScopeConfig;
}
public function apply()
{
$this->moduleDataSetup->startSetup();
$this->mutableScopeConfig->setValue(self::XML_PATH_STORE_NAME, "Title", self::SCOPE_STORE);
$this->mutableScopeConfig->setValue(self::XML_PATH_STORE_PHONE, "Default contact", self::SCOPE_STORE);
$this->mutableScopeConfig->setValue(self::XML_PATH_ADMIN_ACCOUNT_SHARING, 0, self::SCOPE_STORE);
$this->mutableScopeConfig->setValue(self::XML_PATH_ADMIN_URL_SECRET_KEY, 0, self::SCOPE_STORE);
$this->moduleDataSetup->endSetup();
}
public function getAliases()
{
return [];
}
public static function getDependencies()
{
return [];
}
}
Environment: Magento 2.3.3
and nothing changed after running setup:upgrade
, am not sure what am I missing.