{"id":11887,"date":"2020-11-13T14:56:55","date_gmt":"2020-11-13T09:26:55","guid":{"rendered":"https:\/\/www.hiddentechies.com\/blog\/?p=11887"},"modified":"2020-12-07T18:24:34","modified_gmt":"2020-12-07T12:54:34","slug":"get-system-configuration-value-phtml-file","status":"publish","type":"post","link":"https:\/\/www.hiddentechies.com\/blog\/magento-2\/get-system-configuration-value-phtml-file\/","title":{"rendered":"Magento 2 &#8211; How To Get System Configuration Value in phtml File"},"content":{"rendered":"<p>In this post I am going to explain how to get system configuration value in phtml file in Magento 2.<\/p>\n<p>You can get system configuration field value programatically as below.<\/p>\n<p>Add below code snippet in Block class.<\/p>\n<pre class=\"lang:default decode:true \">protected $scopeConfig;\r\n    \r\npublic function __construct(\r\n    \\Magento\\Framework\\View\\Element\\Template\\Context $context,\r\n    \\Magento\\Framework\\App\\Config\\ScopeConfigInterface $scopeConfig,\r\n    array $data = []\r\n) {\r\n    $this-&gt;scopeConfig = $scopeConfig;\r\n    parent::__construct($context, $data);\r\n}\r\n\r\npublic function getConfigValue($value = '') \r\n{\r\n    return $this-&gt;scopeConfig-&gt;getValue($value, \\Magento\\Store\\Model\\ScopeInterface::SCOPE_STORE);\r\n}<\/pre>\n<p>&nbsp;<\/p>\n<p>Add below code snippet in template file.<\/p>\n<pre class=\"lang:default decode:true \">\/\/ call block function and get value of system config field as below.\r\n\r\n$configValue = $block-&gt;getConfigValue('sectionId\/groupId\/fieldId');\r\n\r\necho $configValue;<\/pre>\n<p>&nbsp;<\/p>\n<p>Thats it. Enjoy Magento 2!!<\/p>\n<div class=\"angwp_12010 _ning_cont _ning_hidden _ning_outer _align_center responsive\" data-size=\"custom\" data-bid=\"12010\" data-aid=\"0\" style=\"max-width:800px; width:100%;height:inherit;\"><div class=\"_ning_label _left\" style=\"\"><\/div><div class=\"_ning_inner\" style=\"\"><a href=\"https:\/\/www.hiddentechies.com\/blog?_dnlink=12010&t=1776466253\" class=\"strack_cli _ning_link\" target=\"_blank\">&nbsp;<\/a><div class=\"_ning_elmt\"><img decoding=\"async\" src=\"https:\/\/www.hiddentechies.com\/blog\/wp-content\/uploads\/angwp\/items\/12010\/Banner-2.png\" \/><\/div><\/div><\/div><div class=\"clear\"><\/div>","protected":false},"excerpt":{"rendered":"<p>In this post I am going to explain how to get system configuration value in phtml file in Magento 2. You can get system configuration field value programatically as below. Add below code snippet in Block class. protected $scopeConfig; public function __construct( \\Magento\\Framework\\View\\Element\\Template\\Context $context, \\Magento\\Framework\\App\\Config\\ScopeConfigInterface $scopeConfig, array $data = [] ) { $this-&gt;scopeConfig = $scopeConfig;&#8230; <\/p>\n<div class=\"actions\"><a href=\"https:\/\/www.hiddentechies.com\/blog\/magento-2\/get-system-configuration-value-phtml-file\/\">Continue Reading<\/a><\/div>\n","protected":false},"author":1,"featured_media":12110,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[181,59,2138],"tags":[729,9,2153],"_links":{"self":[{"href":"https:\/\/www.hiddentechies.com\/blog\/wp-json\/wp\/v2\/posts\/11887"}],"collection":[{"href":"https:\/\/www.hiddentechies.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.hiddentechies.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.hiddentechies.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hiddentechies.com\/blog\/wp-json\/wp\/v2\/comments?post=11887"}],"version-history":[{"count":2,"href":"https:\/\/www.hiddentechies.com\/blog\/wp-json\/wp\/v2\/posts\/11887\/revisions"}],"predecessor-version":[{"id":12086,"href":"https:\/\/www.hiddentechies.com\/blog\/wp-json\/wp\/v2\/posts\/11887\/revisions\/12086"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.hiddentechies.com\/blog\/wp-json\/wp\/v2\/media\/12110"}],"wp:attachment":[{"href":"https:\/\/www.hiddentechies.com\/blog\/wp-json\/wp\/v2\/media?parent=11887"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hiddentechies.com\/blog\/wp-json\/wp\/v2\/categories?post=11887"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hiddentechies.com\/blog\/wp-json\/wp\/v2\/tags?post=11887"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}