- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Get store email addresses programmatically
Hi,
In my custom controller want to get store email addresses programmatically for email sender info. Please suggest ASAP
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Re: Get store email addresses programmatically
Hi @tippanna_pawar
Try the below stack solution.
https://magento.stackexchange.com/a/125449
I hope it will help you!
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Re: Get store email addresses programmatically
Hi Vimal,
Particularly for controller it is throwing error.. Can you suggest because i need controller code
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Re: Get store email addresses programmatically
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);

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Re: Get store email addresses programmatically
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!