5

I want replacement of the following in magento 2

/* Name */
Mage::getStoreConfig('trans_email/ident_sales/name'); 
/* Email */
Mage::getStoreConfig('trans_email/ident_sales/email');

or similar to getting current store admin name and email.

Thanks.

16

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();
}

}

  • I got information related to customer how to get regarding sales ?? – Manish Apr 5 '16 at 8:45
  • 1
    got it replacing 'trans_email/ident_support/email' with 'trans_email/ident_general/email' – Manish Apr 5 '16 at 8:50
  • Thanks Accepted.....!! – Manish Apr 5 '16 at 9:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.