diff --git a/src/Model/Nosto/Entity/Helper/ProductHelper.php b/src/Model/Nosto/Entity/Helper/ProductHelper.php index fcce8b8c..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 @@ -61,8 +60,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 +190,15 @@ 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(