2

I have created a menu in the configuration menu.

system.xml:

I have an observer and I want to get the values of those two fields.

How can I do that?

Thanks for any help!

silberfuchz
  • 905
  • 1
  • 16
  • 48
  • Check that link you will get answer of your question by help of this . https://magento.stackexchange.com/questions/87789/magento2-how-to-get-data-from-system-configuration – Ansar Husain Jul 27 '18 at 09:33

1 Answers1

1

Try to use this below code in your observer :

protected $scopeConfig;

const XML_PATH_CREDIT_CARD = 'uv_email/general/uv_email_kredit';
const XML_PATH_SALES_TEAM = 'uv_email/general/uv_email_vertrieb';

public function __construct(
    ......
    \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig,
    ......
) {
    ......
    $this->scopeConfig = $scopeConfig;
    ......
}

public function execute(\Magento\Framework\Event\Observer $observer)
{
    $storeScope = \Magento\Store\Model\ScopeInterface::SCOPE_STORE;
    $credit_card_value = $this->scopeConfig->getValue(self::XML_PATH_CREDIT_CARD, $storeScope);
    $sales_team_value = $this->scopeConfig->getValue(self::XML_PATH_SALES_TEAM, $storeScope);
}