I have one configuration field with scope as store view in my module.

System config path: vendor/module/title

I have multiple websites with multiple store views and I want to get values of my field for each store view as an array. I can use looping for website and store views to get value for my field for each store view with below code.

$this->scopeConfig->getValue('vendor/module/title', ScopeInterface::SCOPE_STORE, $scopeCode);

and then store it in an array with store_code or store_id as the key.

Is there any other way I can achieve this? May be without loop?

2 Answers 2


You may inject the given file path \Magento\Store\Model\StoresConfig in your dependencies and use the function getStoresConfigByPath($path).

This function will return all the store values for a given path.

I hope this function meets your requirement.


add this in your constructor

\Magento\Store\Model\StoreRepository $storeRepo

$stores = $this->storeRepo->getList();
$storeList = array();
foreach ($stores as $store) {
  $storeId = $store["store_id"];
  $storeName = $store["name"];
  $storeList[$storeId] = $storeName;
return $storeList;
  • Thanks Vishnunath for the answer but I am looking to get values of my config field, not list of available stores. Sep 10, 2018 at 12:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.