/** * @param \Magento\Store\Model\StoreManagerInterface $storage * @param string $scopeCode * @return null|string */ protected function _getStoreByGroup(\Magento\Store\Model\StoreManagerInterface $storage, $scopeCode) { $groups = $storage->getGroups(true); $stores = $storage->getStores(true); if (!isset($groups[$scopeCode])) { return null; } if (!$groups[$scopeCode]->getDefaultStoreId() || !isset($stores[$groups[$scopeCode]->getDefaultStoreId()])) { return null; } return $stores[$groups[$scopeCode]->getDefaultStoreId()]->getCode(); }
/** * Retrieve a list of available groups * * @return \Magento\Store\Model\Group[] */ public function getScopes() { return $this->storeManager->getGroups(); }