{"id":832,"date":"2020-02-21T03:58:16","date_gmt":"2020-02-21T03:58:16","guid":{"rendered":"https:\/\/meetanshi.com\/blog\/2020\/02\/21\/get-data-from-system-configuration-in-magento-2\/"},"modified":"2025-05-22T14:56:54","modified_gmt":"2025-05-22T09:26:54","slug":"get-data-from-system-configuration-in-magento-2","status":"publish","type":"post","link":"https:\/\/meetanshi.com\/blog\/get-data-from-system-configuration-in-magento-2\/","title":{"rendered":"How To Get Data From System Configuration In Magento 2"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Are you a beginner in Magento 2 development? If so, I guess you are on your first <a href=\"https:\/\/meetanshi.com\/blog\/magento-2-module-development\/\" target=\"_blank\" rel=\"noreferrer noopener\">tutorial on Magento 2 module development<\/a>!<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">And hence, the below solution to <strong>get data from system configuration in Magento 2<\/strong> is going to be used often. You might as well bookmark this post!<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">For example, you want to get the data of <a href=\"https:\/\/meetanshi.com\/magento-2-extensions.html\" target=\"_blank\" rel=\"noreferrer noopener\">Magento 2 extension<\/a> status, if it is enabled or disabled.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Magento 2 allows creating custom configuration fields and get config data programmatically from other modules or core Magento!<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Method To Get Data From System Configuration In Magento 2:<\/h2>\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=\"\">use Magento\\Framework\\App\\Config\\ScopeConfigInterface;\nuse Magento\\Store\\Model\\ScopeInterface;\n\nprotected $scopeConfig;\n\npublic function __construct(\n    ScopeConfigInterface $scopeConfig\n) {\n    $this->scopeConfig = $scopeConfig;\n}\n\n\npublic function getConfigValue() {\n    return $this->scopeConfig->getValue(\"sectionId\/groupId\/fieldId\",ScopeInterface::SCOPE_STORE);\n}<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">That&#8217;s it. To make your extensions work expectedly certain configurations are made to have particular values for that you need to <a href=\"https:\/\/meetanshi.com\/blog\/set-default-values-for-magento-2-system-configuration\/\">set default values for Magento 2 system configuration<\/a>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Do share the post with the Magento community via social media.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Thanks.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Are you a beginner in Magento 2 development? If so, I guess you are on your first tutorial on Magento 2 module development! And hence,&#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-832","post","type-post","status-publish","format-standard","hentry","category-magento"],"acf":[],"_links":{"self":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts\/832","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=832"}],"version-history":[{"count":3,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts\/832\/revisions"}],"predecessor-version":[{"id":15075,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts\/832\/revisions\/15075"}],"wp:attachment":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/media?parent=832"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/categories?post=832"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/tags?post=832"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}