diff --git a/CustomerData/CountryStoreData.php b/CustomerData/CountryStoreData.php index c9df196..3d8aefc 100644 --- a/CustomerData/CountryStoreData.php +++ b/CustomerData/CountryStoreData.php @@ -14,12 +14,16 @@ use Opengento\CountryStore\Api\CountryRegistryInterface; use Opengento\CountryStore\Api\CountryStoreResolverInterface; use Opengento\CountryStore\Api\Data\CountryInterface; +use Opengento\CountryStore\Model\Resolver\DefaultCountryStore; +use Opengento\CountryStore\Model\Resolver\ResolverFactory; use Psr\Log\LoggerInterface; final class CountryStoreData implements SectionSourceInterface { private CountryRegistryInterface $countryRegistry; + private ResolverFactory $countryResolverFactory; + private CountryStoreResolverInterface $countryStoreResolver; private StoreManagerInterface $storeManager; @@ -30,12 +34,14 @@ final class CountryStoreData implements SectionSourceInterface public function __construct( CountryRegistryInterface $countryRegistry, + ResolverFactory $countryResolverFactory, CountryStoreResolverInterface $countryStoreResolver, StoreManagerInterface $storeManager, ExtensibleDataObjectConverter $dataObjectConverter, LoggerInterface $logger ) { $this->countryRegistry = $countryRegistry; + $this->countryResolverFactory = $countryResolverFactory; $this->countryStoreResolver = $countryStoreResolver; $this->storeManager = $storeManager; $this->dataObjectConverter = $dataObjectConverter; @@ -47,8 +53,8 @@ public function getSectionData(): array $country = $this->countryRegistry->get(); if ($this->isInvalidated($country)) { - $this->countryRegistry->clear(); - $country = $this->countryRegistry->get(); + $country = $this->countryResolverFactory->get(DefaultCountryStore::RESOLVER_CODE)->getCountry(); + $this->countryRegistry->set($country->getCode()); } return $this->dataObjectConverter->toFlatArray($country); diff --git a/view/frontend/web/js/view/country-store-data.js b/view/frontend/web/js/view/country-store-data.js index 60da5b0..b88eac7 100644 --- a/view/frontend/web/js/view/country-store-data.js +++ b/view/frontend/web/js/view/country-store-data.js @@ -13,7 +13,7 @@ define([ return Component.extend({ initialize() { this._super(); - var _self = this; + const _self = this; customerData.getInitCustomerData().done(function () { _self.initCountryStoreData(); }); },