Menu Close
    Hire Us Request Quote Reading List Switch to Dark Mode

    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.

    Back to Top
    css.php
    Hire Us!
    Brief us about your requirements and we'll get back to you.
    Woo! Hooy!
    We have just recieved your project brief and our expert will contact you shortly.
    Send Again
    Close