If the template you are trying to retrieve the store-config from already has a block associated with it that has scopeConfig injected then you can call the function from the block directly in your template, if not, you will need to create a block that has a function that can interact with scopeConfig like below.
You can programmatically retrieve store config by creating a helper function like so in your module .
# app/code/Vendor/Module/Helper/Data.php
<?php
namespace Vendor\Module\Helper;
use Magento\Framework\App\Helper\AbstractHelper;
class Data extends AbstractHelper
{
public function getConfig($config_path)
{
return $this->scopeConfig->getValue(
$config_path,
\Magento\Store\Model\ScopeInterface::SCOPE_STORE
);
}
}
and inject where you need it if already not injected.
# app/code/Vendor/Module/Model/<filename>/php
<?php
namespace Vendor\Module\Model;
use Vendor\Module\Helper\Data as Helper;
class SomeClass
{
protected $_helper;
public function __construct(Helper $helper)
{
$this->_helper = $helper;
}
public function getEmailAddress()
{
return $emailAddress = $this->_helper->getConfig('general/contact/email');
}
}
To find the format of the configuration data you need to retrieve, go to the core module, for which the data needed is, and look in vendor/magento/module-<name>/etc/adminhtml/system.xml
the format will be section/group/field
so you are looking for <section id="<section_name>
..., <group id="<group_name>
..., and <field id="<field_name
..., just grab the id’s and put them in order as the getConfig param i.e. $this->helper->getConfig('section/group/field');
I wrote a blog entry here to retrieve store config in your module.
http://magefoo.com/programmatically-retrieve-store-config-data/