How to get Value from Store Configuration by Scope in Magento 2?

To Fetch the System Store Configuration Values by Scope level, Store or Website, You need to use ScopeConfigInterface with getValue() method.

We can get the Core config data table value programmatically using the given way,

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

Now call in a function,

public function getConfigValue() {
    return $this->scopeConfig->getValue("sectionId/groupId/fieldId",
                \Magento\Store\Model\ScopeInterface::SCOPE_STORE,$this->storeManager->getStore()->getStoreId();
}

First Argument sectionId/groupId/fieldId is from your etc/adminhtml/system.xml file.

The second Argument will be the Scope Value.

Third Argument will be scopeCode. It may be int, string or null value.

Demo system.xml to illustrate the example,

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Config:etc/system_file.xsd">
    <system>
        <section id="test" translate="label" type="text" sortOrder="310" showInDefault="1" showInWebsite="1" showInStore="1">
            <label>Test Settings</label>
            <group id="origin" translate="label" type="text" sortOrder="1" showInDefault="1" showInWebsite="1" showInStore="0">
                <label>Main label</label>
                <field id="postcode" translate="label" type="text" sortOrder="30" showInDefault="1" showInWebsite="1" showInStore="0" canRestore="1">
                    <label>Postal Code</label>
                </field>
            </group>
        </section>
    </system>
</config>

In our case test/origin/postcode is the key value for sectionId/groupId/fieldId.

Setup upgrade Error, Invalid Document Element ‘resource’: The attribute ‘title’ is required but missing Magento 2

When we run php bin/magento setup:upgrade command through the command line, Sometimes error will throw like, Invalid Document Element ‘resource’: The attribute ‘title’ is required but missing.

This issue coming to Magento 2.2.* version when you run upgrade command.
This issue is related to acl.xml file. You missing the title attribute to <resource> tag. You must declare all the resource tag in acl.xml file with title attribute except all the resource tag which start with id=”Magento_Backend::”.

Check error code,

<?xml version="1.0" ?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:noNamespaceSchemaLocation="urn:magento:framework:Acl/etc/acl.xsd">
    <acl>
        <resources>
            <resource id="Magento_Backend::admin">
                <resource id="Rbj_CustomForm::rbj">
                    <resource id="Rbj_CustomForm::customform" title="Customform Main" sortOrder="10">
                        <resource id="Rbj_CustomForm::manage_customform" title="Manage Customform" sortOrder="10" />
                    </resource>
                </resource>
            </resource>
        </resources>
    </acl>
</config>

<resource id=”Rbj_CustomForm::rbj”> this tag with title attribute is missing, So you must set tag with title=”title name”.

Right code,

<?xml version="1.0" ?>

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:noNamespaceSchemaLocation="urn:magento:framework:Acl/etc/acl.xsd">
    <acl>
        <resources>
            <resource id="Magento_Backend::admin">
                <resource id="Rbj_CustomForm::rbj" title="Customform">
                    <resource id="Rbj_CustomForm::customform" title="Customform Slider" sortOrder="10">
                        <resource id="Rbj_CustomForm::manage_customform" title="Manage Customform" sortOrder="10" />
                    </resource>
                </resource>
            </resource>
        </resources>
    </acl>
</config>

Run   Setup upgrade command and your error will be wiped out.

php magento setup:upgrade