Skip to content

Commit

Permalink
Merge pull request #92 from Nosto/SSP-157_v4
Browse files Browse the repository at this point in the history
SSP-157 Add fix for product tagging v4
  • Loading branch information
iganulevics authored Nov 8, 2024
2 parents 2920e0e + fcf9b8b commit 03269a7
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/Model/Nosto/Entity/Helper/ProductHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit 03269a7

Please sign in to comment.