diff --git a/composer.json b/composer.json index 6641058..b449e6f 100644 --- a/composer.json +++ b/composer.json @@ -10,15 +10,17 @@ "spryker/glossary": "^3.0.0", "spryker/gui": "^3.33.0", "spryker/kernel": "^3.30.0", - "spryker/key-builder": "^1.0.0", + "spryker/key-builder": "^1.1.0", "spryker/locale": "^3.0.0", "spryker/product": "^5.0.0 || ^6.0.0", "spryker/product-page-search-extension": "^1.1.0", "spryker/propel-orm": "^1.0.0", "spryker/search": "^6.0.0 || ^7.0.0 || ^8.0.0", "spryker/storage": "^3.0.0", + "spryker/store": "^1.4.0", "spryker/symfony": "^3.0.0", "spryker/touch": "^3.0.0 || ^4.0.0", + "spryker/transfer": "^3.25.0", "spryker/util-data-reader": "^1.0.0" }, "require-dev": { diff --git a/dependency.json b/dependency.json new file mode 100644 index 0000000..3665482 --- /dev/null +++ b/dependency.json @@ -0,0 +1,5 @@ +{ + "include": { + "spryker/transfer": "Provides transfer objects decimal property type functionality." + } +} diff --git a/src/Spryker/Client/ProductSearch/Dependency/Client/ProductSearchToLocaleClientBridge.php b/src/Spryker/Client/ProductSearch/Dependency/Client/ProductSearchToLocaleClientBridge.php new file mode 100644 index 0000000..6f33288 --- /dev/null +++ b/src/Spryker/Client/ProductSearch/Dependency/Client/ProductSearchToLocaleClientBridge.php @@ -0,0 +1,32 @@ +localeClient = $localeClient; + } + + /** + * @return string + */ + public function getCurrentLocale(): string + { + return $this->localeClient->getCurrentLocale(); + } +} diff --git a/src/Spryker/Client/ProductSearch/Dependency/Client/ProductSearchToLocaleClientInterface.php b/src/Spryker/Client/ProductSearch/Dependency/Client/ProductSearchToLocaleClientInterface.php new file mode 100644 index 0000000..eaca13d --- /dev/null +++ b/src/Spryker/Client/ProductSearch/Dependency/Client/ProductSearchToLocaleClientInterface.php @@ -0,0 +1,16 @@ +storeClient = $storeClient; + } + + /** + * @return \Generated\Shared\Transfer\StoreTransfer + */ + public function getCurrentStore(): StoreTransfer + { + return $this->storeClient->getCurrentStore(); + } +} diff --git a/src/Spryker/Client/ProductSearch/Dependency/Client/ProductSearchToStoreClientInterface.php b/src/Spryker/Client/ProductSearch/Dependency/Client/ProductSearchToStoreClientInterface.php new file mode 100644 index 0000000..30eafe3 --- /dev/null +++ b/src/Spryker/Client/ProductSearch/Dependency/Client/ProductSearchToStoreClientInterface.php @@ -0,0 +1,16 @@ +getCurrentLocale(); + $storeName = $this->getFactory()->getStoreClient()->getCurrentStore()->getNameOrFail(); + $key = $this ->getFactory() ->createProductSearchConfigExtensionKeyBuilder() - ->generateKey([], $currentLocale); + ->generateKey([], $currentLocale, $storeName); return $key; } @@ -55,7 +57,7 @@ protected function getCurrentLocale() { $locale = $this ->getFactory() - ->getStore() + ->getLocaleClient() ->getCurrentLocale(); return $locale; diff --git a/src/Spryker/Client/ProductSearch/ProductSearchDependencyProvider.php b/src/Spryker/Client/ProductSearch/ProductSearchDependencyProvider.php index bffe8fc..2522ca1 100644 --- a/src/Spryker/Client/ProductSearch/ProductSearchDependencyProvider.php +++ b/src/Spryker/Client/ProductSearch/ProductSearchDependencyProvider.php @@ -9,14 +9,19 @@ use Spryker\Client\Kernel\AbstractDependencyProvider; use Spryker\Client\Kernel\Container; -use Spryker\Shared\Kernel\Store; +use Spryker\Client\ProductSearch\Dependency\Client\ProductSearchToLocaleClientBridge; class ProductSearchDependencyProvider extends AbstractDependencyProvider { /** * @var string */ - public const STORE = 'store'; + public const CLIENT_LOCALE = 'CLIENT_LOCALE'; + + /** + * @var string + */ + public const CLIENT_STORE = 'CLIENT_STORE'; /** * @var string @@ -32,8 +37,9 @@ public function provideServiceLayerDependencies(Container $container) { $container = parent::provideServiceLayerDependencies($container); - $container = $this->provideStore($container); + $container = $this->addLocaleClient($container); $container = $this->addStorageClient($container); + $container = $this->addStoreClient($container); return $container; } @@ -43,10 +49,10 @@ public function provideServiceLayerDependencies(Container $container) * * @return \Spryker\Client\Kernel\Container */ - protected function provideStore(Container $container) + protected function addStorageClient(Container $container) { - $container->set(static::STORE, function () { - return Store::getInstance(); + $container->set(static::CLIENT_STORAGE, function (Container $container) { + return $container->getLocator()->storage()->client(); }); return $container; @@ -57,10 +63,26 @@ protected function provideStore(Container $container) * * @return \Spryker\Client\Kernel\Container */ - protected function addStorageClient(Container $container) + protected function addStoreClient(Container $container): Container { - $container->set(static::CLIENT_STORAGE, function (Container $container) { - return $container->getLocator()->storage()->client(); + $container->set(static::CLIENT_STORE, function (Container $container) { + return $container->getLocator()->store()->client(); + }); + + return $container; + } + + /** + * @param \Spryker\Client\Kernel\Container $container + * + * @return \Spryker\Client\Kernel\Container + */ + protected function addLocaleClient(Container $container): Container + { + $container->set(static::CLIENT_LOCALE, function (Container $container) { + return new ProductSearchToLocaleClientBridge( + $container->getLocator()->locale()->client(), + ); }); return $container; diff --git a/src/Spryker/Client/ProductSearch/ProductSearchFactory.php b/src/Spryker/Client/ProductSearch/ProductSearchFactory.php index e23de95..b269161 100644 --- a/src/Spryker/Client/ProductSearch/ProductSearchFactory.php +++ b/src/Spryker/Client/ProductSearch/ProductSearchFactory.php @@ -8,6 +8,8 @@ namespace Spryker\Client\ProductSearch; use Spryker\Client\Kernel\AbstractFactory; +use Spryker\Client\ProductSearch\Dependency\Client\ProductSearchToLocaleClientInterface; +use Spryker\Client\ProductSearch\Dependency\Client\ProductSearchToStoreClientInterface; use Spryker\Shared\ProductSearch\Code\KeyBuilder\ProductSearchConfigExtensionKeyBuilder; class ProductSearchFactory extends AbstractFactory @@ -29,10 +31,18 @@ public function getStorageClient() } /** - * @return \Spryker\Shared\Kernel\Store + * @return \Spryker\Client\ProductSearch\Dependency\Client\ProductSearchToStoreClientInterface */ - public function getStore() + public function getStoreClient(): ProductSearchToStoreClientInterface { - return $this->getProvidedDependency(ProductSearchDependencyProvider::STORE); + return $this->getProvidedDependency(ProductSearchDependencyProvider::CLIENT_STORE); + } + + /** + * @return \Spryker\Client\ProductSearch\Dependency\Client\ProductSearchToLocaleClientInterface + */ + public function getLocaleClient(): ProductSearchToLocaleClientInterface + { + return $this->getProvidedDependency(ProductSearchDependencyProvider::CLIENT_LOCALE); } } diff --git a/src/Spryker/Shared/ProductSearch/Transfer/product_search.transfer.xml b/src/Spryker/Shared/ProductSearch/Transfer/product_search.transfer.xml index 841a096..7b2773e 100644 --- a/src/Spryker/Shared/ProductSearch/Transfer/product_search.transfer.xml +++ b/src/Spryker/Shared/ProductSearch/Transfer/product_search.transfer.xml @@ -72,4 +72,8 @@ + + + +