OK.. I've done it like this....
PHP Code:
<?php
class Product extends \XLite\Model\Repo\Product implements \XLite\Base\IDecorator
{
protected function prepareCndSubstring(\Doctrine\ORM\QueryBuilder $queryBuilder, $value)
{
if ($_GET['target'] != 'search'){
$tagsGroupsArray = // not important but is something like array('animal' => 'cat-dog','colour' => 'red-blue-green','size' => 'small')
$queryBuilder->linkLeft('p.tags', 't');
$queryBuilder->linkLeft('t.tag_groups', 'tg');
$this->addTranslationJoins($queryBuilder, 't', 'tt', $this->getTranslationCode());
$queryBuilder->addGroupBy('p.id');
foreach ($tagsGroupsArray as $key => $val) {
$inString = str_replace("-", "','", $val);
$queryBuilder->andHaving("SUM(CASE WHEN tt.name IN ('".$inString."') AND tg.group_name = '".$key."' THEN 1 ELSE 0 END ) > 0");
}
}
if ($_GET['target'] == 'search'){
parent::prepareCndSubstring($queryBuilder, $value);
}
}
The problem now is that getItemsCount() is counting all the products in the store while the page (the Itemlist) shows the correct result.
I don't know why getData() finds the products based on the tags correctly but it doesn't count the number of results.