Skip to content

Commit

Permalink
FRW-8812 Fixed non infrastructural places with different behaviour fo…
Browse files Browse the repository at this point in the history
…r Dynamic Multistore ON/OFF mode. (#11042)

FRW-8812 Fixed non infrastructural places with different behaviour for DS ON and DS OFF.
  • Loading branch information
dimitriyTsemma authored Aug 29, 2024
1 parent 806f85e commit 8bfdf37
Showing 1 changed file with 14 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public function __construct(
/**
* @param int|null $idCustomerAddress
*
* @return array
* @return array<string, mixed>
*/
public function getData($idCustomerAddress = null)
{
Expand Down Expand Up @@ -76,33 +76,27 @@ public function getOptions()
*/
protected function getCountryChoices(): array
{
$result = [];
$countries = $this->countryFacade->getAvailableCountries()
->getCountries()
->getIterator()
->getArrayCopy();

foreach ($this->getContries() as $countryTransfer) {
$result[$countryTransfer->getIdCountry()] = $countryTransfer->getName();
}

return $result;
return $this->getCountryNamesIndexedByCountryId($countries);
}

/**
* @return array<\Generated\Shared\Transfer\CountryTransfer>
* @param array<\Generated\Shared\Transfer\CountryTransfer> $countries
*
* @return array<int|string, string|null>
*/
protected function getContries(): array
protected function getCountryNamesIndexedByCountryId(array $countries): array
{
if ($this->storeFacade->isDynamicStoreEnabled()) {
return $this->countryFacade->getAvailableCountries()
->getCountries()
->getIterator()
->getArrayCopy();
}

$countryTransfers = [];
$result = [];

foreach ($this->storeFacade->getCurrentStore()->getCountries() as $iso2Code) {
$countryTransfers[] = $this->countryFacade->getCountryByIso2Code($iso2Code);
foreach ($countries as $countryTransfer) {
$result[$countryTransfer->getIdCountry()] = $countryTransfer->getName();
}

return $countryTransfers;
return $result;
}
}

0 comments on commit 8bfdf37

Please sign in to comment.