In ProductRepository inside method createByTaxonPaginator tree root condition is missing. Because of this, products which are not assigned to the given taxon will still be fetched from db.
I believe this method should be:
public function createByTaxonPaginator(TaxonInterface $taxon, array $criteria = [])
{
$queryBuilder = $this->createQueryBuilder('o');
$queryBuilder
->innerJoin('o.taxons', 'taxon')
->andWhere($queryBuilder->expr()->orX(
'taxon = :taxon',
':left < taxon.left AND taxon.right < :right'
))
->andWhere('taxon.root = :tree_root')
->setParameter('tree_root', $taxon->isRoot() ? $taxon->getId() : $taxon->getRoot()->getId())
->setParameter('taxon', $taxon)
->setParameter('left', $taxon->getLeft())
->setParameter('right', $taxon->getRight())
;
$this->applyCriteria($queryBuilder, $criteria);
return $this->getPaginator($queryBuilder);
}
Tell me If I got this wrong, but as far as I can see tree_left and tree_right condition will match taxons even they are not into the given taxon tree.
Thanks!
Are you open for PR?
Most helpful comment
Are you open for PR?