Hello,
I want to do a select field to select a shop and i need to know how can i get all store's names.
But i don't know how to get all...
Regards
Solved! Go to Solution.
This works for me
public function __construct(
...,
\Magento\Store\Model\StoreManagerInterface $storeManager
) {
...
$this->_storeManager = $storeManager;
}
....
private function getStoreData(){
$storeManagerDataList = $this->_storeManager->getStores();
$options = array();
foreach ($storeManagerDataList as $key => $value) {
$options[] = ['label' => $value['name'].' - '.$value['code'], 'value' => $key];
}
return $options;
}
This works for me
public function __construct(
...,
\Magento\Store\Model\StoreManagerInterface $storeManager
) {
...
$this->_storeManager = $storeManager;
}
....
private function getStoreData(){
$storeManagerDataList = $this->_storeManager->getStores();
$options = array();
foreach ($storeManagerDataList as $key => $value) {
$options[] = ['label' => $value['name'].' - '.$value['code'], 'value' => $key];
}
return $options;
}