/** * @param \Magento\Framework\StoreManagerInterface $storage * @param string $scopeCode * @return null|string */ protected function _getStoreByGroup(\Magento\Framework\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(); }