How to get all stores collection include the store id 0 in magento 2
-
22-03-2021 - |
Pregunta
Solución
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:
Licenciado bajo: CC-BY-SA con atribución
No afiliado a magento.stackexchange