How to get all stores collection include the store id 0 in magento 2
-
22-03-2021 - |
Lösung
You can use a default Magento store repository \Magento\Store\Api\StoreRepositoryInterface
. Add it as dependency and call the getList
method.
/** @var \Magento\Store\Api\StoreRepositoryInterface $repository */
$stores = $repository->getList();
foreach ($stores as $store) {
echo 'Store: ' . $store->getId();
echo ' --- ';
}
will output all ids:
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit magento.stackexchange