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!

1

1 Answer 1

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);
}
4
  • Use this updated answer. Commented Jul 27, 2018 at 9:46
  • Fatal error: Uncaught TypeError: Argument 1 passed to UO\CheckCartSpecialProducts\Observer\AfterPurchaseObserver::__construct() must implement interface Magento\Framework\App\Config\ScopeConfigInterface, none given, Commented Jul 27, 2018 at 10:09
  • Remove var/generation or generated/ folder after add this code. Commented Jul 27, 2018 at 10:12
  • Go to core_config_data table in database. Then, search "uv_email/general/uv_email_kredit" in path column and check value is available or not. Commented Jul 27, 2018 at 10:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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