Skip to content

Commit

Permalink
Merge pull request #93 from Nosto/SSP-157_v3
Browse files Browse the repository at this point in the history
SSP-157 Add fix for product tagging v3
  • Loading branch information
iganulevics authored Nov 8, 2024
2 parents 91ace44 + 3ed8255 commit 709cf50
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 @@ -187,10 +187,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 709cf50

Please sign in to comment.