Magento 2 : get all store list by sort order
-
25-02-2021 - |
Вопрос
I want to get store list sort by sort order. How to get it?
I just use this code. Which code i need to add ?
$stores = $this->storeManager->getStores();
Решение
$stores = $this->storeManager->getStores();
uasort(
$stores,
function (\Magento\Store\Model\Store $storeA, \Magento\Store\Model\Store $storeB) {
return $storeA->getSortOrder() <=> $storeB->getSortOrder();
}
);
Now the variable $stores
should contain all your stores sorted by sort_order
.
Не связан с magento.stackexchange