Request Quote

System configuration data for different store or website in Magento 2

In this blog I’ll explain how you can get the system configuration data for different store or website.

In the below example we are getting system config value for a website and a store. The getValue method of scopeConfig requires only one parameter which is the relevant path of the configuration that you are trying to get. The second parameter is optional which tells that what is the scope type. It is “default” by default but we can pass values like “website“, “store“. The third parameter represents website or store based on the scope type.

So we want system configuration data for a website then we set the scope type to “website” and pass the website as the third argument.

$this->scopeConfig->getValue(
        'general/country/default', 
        \Magento\Store\Model\ScopeInterface::SCOPE_WEBSITE, 
        $website
    );

So we want system configuration data for a website then we set the scope type to “store” and pass the store as the third argument.

$this->scopeConfig->getValue(
        'general/country/default', 
        \Magento\Store\Model\ScopeInterface::SCOPE_STORE, 
        $store
    );

Please let me know in the comments if you have any queries.

. . .

Comment

Add Your Comment

Be the first to comment.

css.php