Hi,
In my custom controller want to get store email addresses programmatically for email sender info. Please suggest ASAP
Hi @tippanna_pawar
Try the below stack solution.
https://magento.stackexchange.com/a/125449
I hope it will help you!
Hi Vimal,
Particularly for controller it is throwing error.. Can you suggest because i need controller code
Please find the below code to get Store Email values :
$objectManager = \Magento\Framework\App\ObjectManager::getInstance(); $scopeConfig = $objectManager->create('\Magento\Framework\App\Config\ScopeConfigInterface'); $email = $scopeConfig->getValue('trans_email/ident_support/email',\Magento\Store\Model\ScopeInterface::SCOPE_STORE);
Hi @tippanna_pawar ,
As you need to get value in Controller so please use Constructor dependency injection pattern and get the value (direct use objectManager is not recommended by Magento).
Please take some reference from below code:
protected $scopeConfig; public function __construct( ....... \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig ) { ... $this->_scopeConfig = $scopeConfig; } public function getStorename() { return $this->_scopeConfig->getValue( 'trans_email/ident_sales/name', \Magento\Store\Model\ScopeInterface::SCOPE_STORE ); } public function getStoreEmail() { return $this->_scopeConfig->getValue( 'trans_email/ident_sales/email', \Magento\Store\Model\ScopeInterface::SCOPE_STORE ); }
Now you can simply call functions getStoreEmail() and getStoreName() in order to get detiails.
Hope that help you to meet your challenge.
-----
Problem solved? Click Accept as Solution!