Skip to content

Commit

Permalink
FRW-9023 updated store locale expander to have the same structure as …
Browse files Browse the repository at this point in the history
…in DMS OFF mode (#11141)

FRW-9023 Fixed locale store expander in order to have same structure in both Dynamic Multistore ON and OFF modes.
  • Loading branch information
gechetspr authored Oct 14, 2024
1 parent 15409f1 commit 59e5dfd
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion src/Spryker/Zed/Locale/Business/Expander/StoreExpander.php
Original file line number Diff line number Diff line change
@@ -38,15 +38,34 @@ public function expandStoreTransfersWithLocales(array $storeTransfers): array
}

$localeNamesGroupedByIdStore = $this->localeRepository->getLocaleNamesGroupedByIdStore($storeIds);
$indexedLocaleNamesGroupedByIdStore = $this->indexLocaleNamesByShortName($localeNamesGroupedByIdStore);

$defaultLocaleNamesIndexedByIdStore = $this->localeRepository->getDefaultLocaleNamesIndexedByIdStore($storeIds);

foreach ($storeTransfers as $storeTransfer) {
$storeTransfer
->setDefaultLocaleIsoCode($defaultLocaleNamesIndexedByIdStore[$storeTransfer->getIdStoreOrFail()])
->setAvailableLocaleIsoCodes($localeNamesGroupedByIdStore[$storeTransfer->getIdStoreOrFail()] ?? []);
->setAvailableLocaleIsoCodes($indexedLocaleNamesGroupedByIdStore[$storeTransfer->getIdStoreOrFail()] ?? []);
}

return $storeTransfers;
}

/**
* @param array<int, array<int, string>> $localeNamesGroupedByIdStore
*
* @return array<int, array<string, string>>
*/
protected function indexLocaleNamesByShortName(array $localeNamesGroupedByIdStore): array
{
$indexedLocaleNamesGroupedByIdStore = [];
foreach ($localeNamesGroupedByIdStore as $idStore => $localeNames) {
foreach ($localeNames as $localeName) {
[$locale, $region] = explode('_', $localeName);
$indexedLocaleNamesGroupedByIdStore[$idStore][$locale] = $localeName;
}
}

return $indexedLocaleNamesGroupedByIdStore;
}
}

0 comments on commit 59e5dfd

Please sign in to comment.