From 40bed2851027550b10bb1fda7fb061f218fcdd87 Mon Sep 17 00:00:00 2001 From: Bojan Date: Fri, 30 Aug 2024 12:32:06 +0200 Subject: [PATCH 01/10] Adapt sales channel logic for language id --- src/Export/Services/SalesChannelService.php | 7 +++++-- src/Struct/Config.php | 5 ++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/Export/Services/SalesChannelService.php b/src/Export/Services/SalesChannelService.php index e3cca712..70e02daf 100644 --- a/src/Export/Services/SalesChannelService.php +++ b/src/Export/Services/SalesChannelService.php @@ -40,10 +40,12 @@ public function getSalesChannelContext( $currentContext->getContext() ); + $salesChannelContext = null; + /** @var FinSearchConfigEntity $systemConfigEntity */ foreach ($systemConfigEntities as $systemConfigEntity) { if ($systemConfigEntity->getConfigurationValue() === $shopkey) { - return $this->salesChannelContextFactory->create( + $salesChannelContext = $this->salesChannelContextFactory->create( $currentContext->getToken(), $systemConfigEntity->getSalesChannelId(), [ @@ -51,10 +53,11 @@ public function getSalesChannelContext( SalesChannelContextService::CUSTOMER_ID => $customerId ] ); + $salesChannelContext->getSalesChannel()->setLanguageId($salesChannelContext->getLanguageId()); } } - return null; + return $salesChannelContext; } /** diff --git a/src/Struct/Config.php b/src/Struct/Config.php index d263e9c9..2d20c096 100644 --- a/src/Struct/Config.php +++ b/src/Struct/Config.php @@ -152,9 +152,8 @@ public function useXmlVariants(): bool */ public function initializeBySalesChannel(SalesChannelContext $salesChannelContext): void { - $salesChannel = $salesChannelContext->getSalesChannel(); - $salesChannelId = $salesChannel->getId(); - $languageId = $salesChannel->getLanguageId(); + $salesChannelId = $salesChannelContext->getSalesChannel()->getId(); + $languageId = $salesChannelContext->getLanguageId(); $this->active = $this->getConfig($salesChannelId, $languageId, 'FinSearch.config.active', false); $this->shopkey = $this->getConfig($salesChannelId, $languageId, 'FinSearch.config.shopkey'); From 6bbe462b2e2eb88062f3334e6dd1a298da1ba8f4 Mon Sep 17 00:00:00 2001 From: Bojan Date: Mon, 2 Sep 2024 08:16:17 +0200 Subject: [PATCH 02/10] Dump for testing --- .../Product/SalesChannel/Listing/ProductListingRouteTest.php | 1 + .../Content/Product/SalesChannel/Listing/ProductRouteBase.php | 1 + 2 files changed, 2 insertions(+) diff --git a/tests/Core/Content/Product/SalesChannel/Listing/ProductListingRouteTest.php b/tests/Core/Content/Product/SalesChannel/Listing/ProductListingRouteTest.php index df368443..0544eea7 100644 --- a/tests/Core/Content/Product/SalesChannel/Listing/ProductListingRouteTest.php +++ b/tests/Core/Content/Product/SalesChannel/Listing/ProductListingRouteTest.php @@ -129,6 +129,7 @@ public function testCategoryWithDynamicProductGroupAddsStreamIdAndFilters(): voi $categoryId = Uuid::randomHex(); $streamId = Uuid::randomHex(); + var_dump($categoryId, $streamId); $salesChannelContextMock = $this->getMockedSalesChannelContext(true, '1'); $request = Request::create('http://your-shop.de/some-category'); diff --git a/tests/Core/Content/Product/SalesChannel/Listing/ProductRouteBase.php b/tests/Core/Content/Product/SalesChannel/Listing/ProductRouteBase.php index 352d5999..8dfa3f8e 100644 --- a/tests/Core/Content/Product/SalesChannel/Listing/ProductRouteBase.php +++ b/tests/Core/Content/Product/SalesChannel/Listing/ProductRouteBase.php @@ -183,6 +183,7 @@ protected function setCategoryMock( $category = $this->createTestCategory([ 'id' => $categoryId ?? Uuid::randomHex() ]); + var_dump($category . "setCategoryMock"); $supportsProductStreams = defined( '\Shopware\Core\Content\Category\CategoryDefinition::PRODUCT_ASSIGNMENT_TYPE_PRODUCT_STREAM' From 7f6df29fe8d4425782f115db0e0bd7054def0416 Mon Sep 17 00:00:00 2001 From: Bojan Date: Mon, 2 Sep 2024 08:28:56 +0200 Subject: [PATCH 03/10] Add more dumps --- .../Product/SalesChannel/Listing/ProductListingRouteTest.php | 1 - .../Content/Product/SalesChannel/Listing/ProductRouteBase.php | 3 +-- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/tests/Core/Content/Product/SalesChannel/Listing/ProductListingRouteTest.php b/tests/Core/Content/Product/SalesChannel/Listing/ProductListingRouteTest.php index 0544eea7..df368443 100644 --- a/tests/Core/Content/Product/SalesChannel/Listing/ProductListingRouteTest.php +++ b/tests/Core/Content/Product/SalesChannel/Listing/ProductListingRouteTest.php @@ -129,7 +129,6 @@ public function testCategoryWithDynamicProductGroupAddsStreamIdAndFilters(): voi $categoryId = Uuid::randomHex(); $streamId = Uuid::randomHex(); - var_dump($categoryId, $streamId); $salesChannelContextMock = $this->getMockedSalesChannelContext(true, '1'); $request = Request::create('http://your-shop.de/some-category'); diff --git a/tests/Core/Content/Product/SalesChannel/Listing/ProductRouteBase.php b/tests/Core/Content/Product/SalesChannel/Listing/ProductRouteBase.php index 8dfa3f8e..f8514b69 100644 --- a/tests/Core/Content/Product/SalesChannel/Listing/ProductRouteBase.php +++ b/tests/Core/Content/Product/SalesChannel/Listing/ProductRouteBase.php @@ -183,8 +183,7 @@ protected function setCategoryMock( $category = $this->createTestCategory([ 'id' => $categoryId ?? Uuid::randomHex() ]); - var_dump($category . "setCategoryMock"); - + var_dump($categoryId, Uuid::randomHex()); $supportsProductStreams = defined( '\Shopware\Core\Content\Category\CategoryDefinition::PRODUCT_ASSIGNMENT_TYPE_PRODUCT_STREAM' ); From caa808c91990b143b24f20f051c899eb1899dc81 Mon Sep 17 00:00:00 2001 From: Bojan Date: Mon, 2 Sep 2024 08:38:19 +0200 Subject: [PATCH 04/10] Revoke changes from Config class --- src/Struct/Config.php | 5 +++-- .../Product/SalesChannel/Listing/ProductRouteBase.php | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/Struct/Config.php b/src/Struct/Config.php index 2d20c096..d263e9c9 100644 --- a/src/Struct/Config.php +++ b/src/Struct/Config.php @@ -152,8 +152,9 @@ public function useXmlVariants(): bool */ public function initializeBySalesChannel(SalesChannelContext $salesChannelContext): void { - $salesChannelId = $salesChannelContext->getSalesChannel()->getId(); - $languageId = $salesChannelContext->getLanguageId(); + $salesChannel = $salesChannelContext->getSalesChannel(); + $salesChannelId = $salesChannel->getId(); + $languageId = $salesChannel->getLanguageId(); $this->active = $this->getConfig($salesChannelId, $languageId, 'FinSearch.config.active', false); $this->shopkey = $this->getConfig($salesChannelId, $languageId, 'FinSearch.config.shopkey'); diff --git a/tests/Core/Content/Product/SalesChannel/Listing/ProductRouteBase.php b/tests/Core/Content/Product/SalesChannel/Listing/ProductRouteBase.php index f8514b69..352d5999 100644 --- a/tests/Core/Content/Product/SalesChannel/Listing/ProductRouteBase.php +++ b/tests/Core/Content/Product/SalesChannel/Listing/ProductRouteBase.php @@ -183,7 +183,7 @@ protected function setCategoryMock( $category = $this->createTestCategory([ 'id' => $categoryId ?? Uuid::randomHex() ]); - var_dump($categoryId, Uuid::randomHex()); + $supportsProductStreams = defined( '\Shopware\Core\Content\Category\CategoryDefinition::PRODUCT_ASSIGNMENT_TYPE_PRODUCT_STREAM' ); From fa072afcfbbfb6a09f256c71377ae43da2dd3d00 Mon Sep 17 00:00:00 2001 From: Bojan Date: Mon, 2 Sep 2024 08:46:35 +0200 Subject: [PATCH 05/10] Refactor Config method --- src/Struct/Config.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Struct/Config.php b/src/Struct/Config.php index d263e9c9..4c6d1150 100644 --- a/src/Struct/Config.php +++ b/src/Struct/Config.php @@ -154,7 +154,7 @@ public function initializeBySalesChannel(SalesChannelContext $salesChannelContex { $salesChannel = $salesChannelContext->getSalesChannel(); $salesChannelId = $salesChannel->getId(); - $languageId = $salesChannel->getLanguageId(); + $languageId = $salesChannelContext->getLanguageId(); $this->active = $this->getConfig($salesChannelId, $languageId, 'FinSearch.config.active', false); $this->shopkey = $this->getConfig($salesChannelId, $languageId, 'FinSearch.config.shopkey'); From eece751831ce0e5ff839ebd432347d8ea42d67a2 Mon Sep 17 00:00:00 2001 From: Bojan Date: Mon, 2 Sep 2024 08:54:26 +0200 Subject: [PATCH 06/10] Refactor Config method --- src/Struct/Config.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Struct/Config.php b/src/Struct/Config.php index 4c6d1150..1bb6ef00 100644 --- a/src/Struct/Config.php +++ b/src/Struct/Config.php @@ -156,6 +156,8 @@ public function initializeBySalesChannel(SalesChannelContext $salesChannelContex $salesChannelId = $salesChannel->getId(); $languageId = $salesChannelContext->getLanguageId(); + var_dump($languageId , $salesChannel->getLanguageId() ); + $this->active = $this->getConfig($salesChannelId, $languageId, 'FinSearch.config.active', false); $this->shopkey = $this->getConfig($salesChannelId, $languageId, 'FinSearch.config.shopkey'); $this->activeOnCategoryPages = $this->getConfig( From c99d244d196fbc441f82c203da1ffd63c398c336 Mon Sep 17 00:00:00 2001 From: Bojan Date: Mon, 2 Sep 2024 08:54:58 +0200 Subject: [PATCH 07/10] Refactor Config method --- src/Struct/Config.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Struct/Config.php b/src/Struct/Config.php index 1bb6ef00..4c3aae0f 100644 --- a/src/Struct/Config.php +++ b/src/Struct/Config.php @@ -156,7 +156,7 @@ public function initializeBySalesChannel(SalesChannelContext $salesChannelContex $salesChannelId = $salesChannel->getId(); $languageId = $salesChannelContext->getLanguageId(); - var_dump($languageId , $salesChannel->getLanguageId() ); + var_dump($languageId , $salesChannel->getLanguageId()); $this->active = $this->getConfig($salesChannelId, $languageId, 'FinSearch.config.active', false); $this->shopkey = $this->getConfig($salesChannelId, $languageId, 'FinSearch.config.shopkey'); From 4bf55139dd112345df67b71b95261337e88443e4 Mon Sep 17 00:00:00 2001 From: Bojan Date: Wed, 11 Sep 2024 14:07:04 +0200 Subject: [PATCH 08/10] Remove var dump --- src/Struct/Config.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Struct/Config.php b/src/Struct/Config.php index 4c3aae0f..4c6d1150 100644 --- a/src/Struct/Config.php +++ b/src/Struct/Config.php @@ -156,8 +156,6 @@ public function initializeBySalesChannel(SalesChannelContext $salesChannelContex $salesChannelId = $salesChannel->getId(); $languageId = $salesChannelContext->getLanguageId(); - var_dump($languageId , $salesChannel->getLanguageId()); - $this->active = $this->getConfig($salesChannelId, $languageId, 'FinSearch.config.active', false); $this->shopkey = $this->getConfig($salesChannelId, $languageId, 'FinSearch.config.shopkey'); $this->activeOnCategoryPages = $this->getConfig( From 81049bf5cd27076f86273248043f36f0cedbceb3 Mon Sep 17 00:00:00 2001 From: Radomir Butacevic Date: Wed, 18 Sep 2024 11:55:17 +0200 Subject: [PATCH 09/10] Test commit --- src/Struct/Config.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Struct/Config.php b/src/Struct/Config.php index 4c6d1150..d263e9c9 100644 --- a/src/Struct/Config.php +++ b/src/Struct/Config.php @@ -154,7 +154,7 @@ public function initializeBySalesChannel(SalesChannelContext $salesChannelContex { $salesChannel = $salesChannelContext->getSalesChannel(); $salesChannelId = $salesChannel->getId(); - $languageId = $salesChannelContext->getLanguageId(); + $languageId = $salesChannel->getLanguageId(); $this->active = $this->getConfig($salesChannelId, $languageId, 'FinSearch.config.active', false); $this->shopkey = $this->getConfig($salesChannelId, $languageId, 'FinSearch.config.shopkey'); From 9d4f8a65f4f675bb23a876f12930f2ad8830c50d Mon Sep 17 00:00:00 2001 From: Radomir Butacevic Date: Wed, 18 Sep 2024 12:18:45 +0200 Subject: [PATCH 10/10] Correct the changes --- src/Struct/Config.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Struct/Config.php b/src/Struct/Config.php index d263e9c9..ce94ec26 100644 --- a/src/Struct/Config.php +++ b/src/Struct/Config.php @@ -154,7 +154,9 @@ public function initializeBySalesChannel(SalesChannelContext $salesChannelContex { $salesChannel = $salesChannelContext->getSalesChannel(); $salesChannelId = $salesChannel->getId(); - $languageId = $salesChannel->getLanguageId(); + if (!$languageId = $salesChannelContext->getLanguageId()) { + $languageId = $salesChannel->getId(); + } $this->active = $this->getConfig($salesChannelId, $languageId, 'FinSearch.config.active', false); $this->shopkey = $this->getConfig($salesChannelId, $languageId, 'FinSearch.config.shopkey');