1

I need to get all the fields and values from

Stores -> Configuration -> General

1 Answer 1

3

Try to use this:

$this->scopeConfig->getValue('general');

where the $this->scopeConfig instance of \Magento\Framework\App\Config\ScopeConfigInterface

Here the complete example class:

class SystemValuesManager
{
    /**
     * @var \Magento\Framework\App\Config\ScopeConfigInterface 
     */
    private $scopeConfig;

    /**
     * SystemValuesManager constructor.
     *
     * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig
     */
    public function __construct(
        \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig
    ) {
        $this->scopeConfig = $scopeConfig;
    }

    /**
     * @param string $scope
     * @param null $scopeCode
     * @return array
     */
    public function getGeneralTabValues(
        $scope = \Magento\Store\Model\ScopeInterface::SCOPE_WEBSITE,
        $scopeCode = null
    ) {
        return $this->scopeConfig->getValue(
            'general',
            $scope,
            $scopeCode
        );
    }
}

As a result you will see an array with all values from corresponding tab:

result

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.