How to get store admin email address and name in Magento 2?
Try the below code -
<?php
namespace Custom\Module\Controller\Index;
use Magento\Framework\App\Config\ScopeConfigInterface;
use Magento\Store\Model\ScopeInterface;
class Index extends \Magento\Framework\App\Action\Action
{
protected $request;
protected $scopeConfig;
public function __construct(
\Magento\Framework\App\Action\Context $context,
\Magento\Framework\App\Request\Http $request,
ScopeConfigInterface $scopeConfig
){
parent::__construct($context);
$this->scopeConfig = $scopeConfig;
$this->request = $request;
}
public function execute()
{
$email = $this->scopeConfig->getValue('trans_email/ident_support/email',ScopeInterface::SCOPE_STORE);
$name = $this->scopeConfig->getValue('trans_email/ident_support/name',ScopeInterface::SCOPE_STORE);
echo $email;echo "<br/>";
echo $name;echo "<br/>";
$this->_view->loadLayout();
$this->_view->renderLayout();
}
}