Skip to content

Call to a member function getValue() on null to fetch store config value in Magento 2.4.6

There is error Call to a member function getValue() on null magento 2.4.6 after upgrading from Magneto 2.3.3 to 2.4.6. It was working fine with earlier Magento 2 version.
Here is code:

public function isModuleEnable() {
    $storeScope = MagentoStoreModelScopeInterface::SCOPE_STORE;
    return $this->scopeConfig->getValue('ordergrid/general/enable', $storeScope);
}

The system.xml file is fine as it was working earlier. It’s throwing error on getValue on null.