View Single Post
  #1  
Old 07-10-2018, 09:03 AM
 
xgarb xgarb is online now
 

eXpert
  
Join Date: Jul 2004
Location: UK
Posts: 263
 

Default Extending Tags Module without Breaking Search

I've created a module that extends the Tags module. Basically it does site-wide filtering on grouped tags.

The problem is the code below is breaking the search - I guess as I'm decorating a class that search uses. How can I use my querybuilder code below without breaking search?




PHP Code:
<?php

class Product extends \XLite\Model\Repo\Product implements \XLite\Base\IDecorator
{

    protected function 
prepareCndSubstring(\Doctrine\ORM\QueryBuilder $queryBuilder$value)
    {
        
        
$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");
        }
            
}
__________________
Core version: 5.5.xx
Reply With Quote