{"id":862,"date":"2020-03-05T07:48:44","date_gmt":"2020-03-05T07:48:44","guid":{"rendered":"https:\/\/meetanshi.com\/blog\/2020\/03\/05\/set-store-configuration-value-in-installschema-in-magento-2\/"},"modified":"2025-05-22T14:50:28","modified_gmt":"2025-05-22T09:20:28","slug":"set-store-configuration-value-in-installschema-in-magento-2","status":"publish","type":"post","link":"https:\/\/meetanshi.com\/blog\/set-store-configuration-value-in-installschema-in-magento-2\/","title":{"rendered":"How To Set Store Configuration Value In InstallSchema In Magento 2"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">The post gives the solution to programmatically&nbsp;<em><strong>set store configuration value in InstallSchema in Magento 2<\/strong><\/em>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">For example, you are using a&nbsp;<a href=\"https:\/\/meetanshi.com\/magento-2-extensions.html\" target=\"_blank\" rel=\"noreferrer noopener\">Magento 2 extension<\/a>&nbsp;in your store and want to change the default Magento 2 field values while extension installation. The below code is the solution for the same.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Changing the default field values in Magento 2 while extension installation becomes easy with this method. You can also implement this manually from the admin panel by logging in and navigate to&nbsp;<strong>Stores &gt; Configuration<\/strong>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Method to Set Store Configuration Value In InstallSchema in Magento 2:<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Place the below code in&nbsp;<em><strong>app\/code\/Vendor\/Extension\/InstallSchema.php<\/strong><\/em>:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">&lt;?php\n\nnamespace Vendor\\Extension\\Setup;\n\nuse Magento\\Framework\\Setup\\UpgradeSchemaInterface;\nuse Magento\\Framework\\Setup\\SchemaSetupInterface;\nuse Magento\\Framework\\Setup\\ModuleContextInterface;\nuse Magento\\Framework\\App\\Config\\ConfigResource\\ConfigInterface;\nuse Magento\\Framework\\App\\Config\\ScopeConfigInterface;\nuse Magento\\Store\\Model\\Store;\n\nclass UpgradeSchema implements UpgradeSchemaInterface\n{\n    protected $resourceConfig;\n\n    public function __construct(\n        ConfigInterface $resourceConfig)\n    {\n        $this->resourceConfig = $resourceConfig;\n    }\n\n    public function upgrade(SchemaSetupInterface $setup, ModuleContextInterface $context)\n    {\n        $setup->startSetup();\n\n        $this->resourceConfig->saveConfig(\n            'checkout\/cart\/delete_quote_after',\n            '3000',\n            ScopeConfigInterface::SCOPE_TYPE_DEFAULT,\n            Store::DEFAULT_STORE_ID\n        );\n\n\n        $setup->endSetup();\n    }\n}<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">That\u2019s it.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Do share the post with fellow Magento developers via social media.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Thank you.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The post gives the solution to programmatically&nbsp;set store configuration value in InstallSchema in Magento 2. For example, you are using a&nbsp;Magento 2 extension&nbsp;in your store&#8230;<\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[34],"tags":[],"class_list":["post-862","post","type-post","status-publish","format-standard","hentry","category-magento"],"acf":[],"_links":{"self":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts\/862","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/comments?post=862"}],"version-history":[{"count":3,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts\/862\/revisions"}],"predecessor-version":[{"id":15050,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts\/862\/revisions\/15050"}],"wp:attachment":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/media?parent=862"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/categories?post=862"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/tags?post=862"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}