How to Get Store Config Value by Scope in Magento 2

How to Get Store Config Value by Scope in Magento 2

Scope in Magento 2 allows setting the configuration based on a specific website, store or view. A bigger business leads to having multiple stores, websites and store views. Sometimes, it’s required to get values from the various scope and use it somewhere while creating an extension. This requires to get store config value by scope in Magento 2.

All the adminhtml settings are saved in core_config table of your Magento 2 database. You just need to call getConfig() method and add a second param with the scope to get the stored value for website, store or the store view.

Method to get store config value by scope in Magento 2:

 

Using the above code, you can easily get store config value by scope in Magento 2. Remove the code with the scope as per your requirement. Do comment your doubts, suggestions, feedback, and queries. I would really appreciate your inputs and help you as soon as possible.

Don’t forget to hit the 5 stars below to reward my write-ups. 🙂

Get Weekly Updates

Never miss Magento tips, tricks, tutorials, and news.

Thank you for subscribing.

Something went wrong.

4.2
(based on 17 Reviews)

Sanjay is a co-founder at Meetanshi. He is a Certified Magento Developer who loves creating Magento E-commerce solutions. Owing to his contributions in Magento Forums and posting solutions, he is among the top 50 contributors of the Magento community in 2019. When he is not engrossed with anything related to Magento, he loves to play cricket.

Leave a reply:

Your email address will not be published.