From 8de7a6fd21a62b7f9412cd781fa38d511b9abb9c Mon Sep 17 00:00:00 2001 From: Radomir Butacevic Date: Tue, 22 Oct 2024 11:41:54 +0200 Subject: [PATCH 1/3] Add fix for product tagging --- src/Model/Nosto/Entity/Helper/ProductHelper.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/Model/Nosto/Entity/Helper/ProductHelper.php b/src/Model/Nosto/Entity/Helper/ProductHelper.php index fcce8b8c..bcbc785e 100644 --- a/src/Model/Nosto/Entity/Helper/ProductHelper.php +++ b/src/Model/Nosto/Entity/Helper/ProductHelper.php @@ -61,8 +61,9 @@ public function reloadProduct(string $productId, SalesChannelContext $context): $criteria = $this->getCommonCriteria(); $criteria->addFilter(new EqualsFilter('id', $productId)); $this->eventDispatcher->dispatch(new ProductReloadCriteriaEvent($criteria, $context)); + $shopwareProduct = $this->getShopwareProducts([$productId], $context, true); - return $this->productRoute->load($productId, new Request(), $context, $criteria)->getProduct(); + return $shopwareProduct->get($productId) ?? null; } private function getCommonCriteria(): Criteria @@ -190,10 +191,12 @@ public function createRepositoryIterator(Criteria $criteria, Context $context): return new RepositoryIterator($this->productRepository, $context, $criteria); } - public function getShopwareProducts(array $productIds, SalesChannelContext $context): SalesChannelProductCollection + public function getShopwareProducts(array $productIds, SalesChannelContext $context, bool $isProductTagging = false): SalesChannelProductCollection { $criteria = $this->getCommonCriteria(); - $this->getCommonCriteriaChildren($criteria); + if (!$isProductTagging) { + $this->getCommonCriteriaChildren($criteria); + } $criteria->setIds($productIds); return $this->salesChannelProductRepository->search( From 580693c248fc55e44d3ece322afa31ccc286d616 Mon Sep 17 00:00:00 2001 From: Radomir Butacevic Date: Tue, 22 Oct 2024 11:44:49 +0200 Subject: [PATCH 2/3] Adapt lint test --- src/Model/Nosto/Entity/Helper/ProductHelper.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/Model/Nosto/Entity/Helper/ProductHelper.php b/src/Model/Nosto/Entity/Helper/ProductHelper.php index bcbc785e..fb4eab9a 100644 --- a/src/Model/Nosto/Entity/Helper/ProductHelper.php +++ b/src/Model/Nosto/Entity/Helper/ProductHelper.php @@ -191,8 +191,11 @@ public function createRepositoryIterator(Criteria $criteria, Context $context): return new RepositoryIterator($this->productRepository, $context, $criteria); } - public function getShopwareProducts(array $productIds, SalesChannelContext $context, bool $isProductTagging = false): SalesChannelProductCollection - { + public function getShopwareProducts( + array $productIds, + SalesChannelContext $context, + bool $isProductTagging = false, + ): SalesChannelProductCollection { $criteria = $this->getCommonCriteria(); if (!$isProductTagging) { $this->getCommonCriteriaChildren($criteria); From fcf9b8b633cede276bb05418e298d805e2065057 Mon Sep 17 00:00:00 2001 From: Radomir Butacevic Date: Tue, 22 Oct 2024 11:46:59 +0200 Subject: [PATCH 3/3] Adapt lint test --- src/Model/Nosto/Entity/Helper/ProductHelper.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Model/Nosto/Entity/Helper/ProductHelper.php b/src/Model/Nosto/Entity/Helper/ProductHelper.php index fb4eab9a..cbd0e4f4 100644 --- a/src/Model/Nosto/Entity/Helper/ProductHelper.php +++ b/src/Model/Nosto/Entity/Helper/ProductHelper.php @@ -25,7 +25,6 @@ use Shopware\Core\Framework\DataAbstractionLayer\Search\Filter\NotFilter; use Shopware\Core\System\SalesChannel\Entity\SalesChannelRepository; use Shopware\Core\System\SalesChannel\SalesChannelContext; -use Symfony\Component\HttpFoundation\Request; use Symfony\Contracts\EventDispatcher\EventDispatcherInterface; class ProductHelper