How to Get Store Configuration value in Magento 2?

How to Get Store Configuration value in Magento 2?

Hello Devs, In this tutorial we are going to see how to get store configuration value or store config value in Magento 2.

Magento stores all the configuration values in the core_config_data table based on a specific scope website, store, or view.

We can utilize the Magento\Store\Model\ScopeInterface class in our helper file as below.

Method 1 :

Now, you can inject the helper class anywhere and use the getConfig() function to get the config value.

Method 2 :

You can also manually specify the Store ID in the getConfig() param and get store-specific configuration values like below.

Method 3 :

We can also get configuration values using Object Manager like below.

Using the above code, you can easily get store config value by scope in Magento 2.

You may also like :

How to get value from env.php in Magento 2?

How to create a root script in Magento 2?

That’s it for this tutorial, See you in the next blog. Thank you!!

Leave a Reply

Your email address will not be published. Required fields are marked *