Jump to content

Search products by multiple tags


SkyHiRider

Recommended Posts

I'm using Prestashop 1.4 and I really need to be able to search for products by using more then one tag.

I'd like to be able for this url /search?tag=colop&tag=circle to work and show all the products that are tagged by colop and circle.

 

Currently it only takes the last tag into account - I've actually found the code that I probably need to change in controllers/SearchController.php :

 elseif ($tag = urldecode(Tools::getValue('tag')) AND !is_array($tag))
                {
                        $nbProducts = (int)(Search::searchTag((int)(self::$cookie->id_lang), $tag, true));
                        $this->pagination($nbProducts);
                        $result = Search::searchTag((int)(self::$cookie->id_lang), $tag, false, $this->p, $this->n, $this->orderBy, $this->orderWay);
                        Module::hookExec('search', array('expr' => $tag, 'total' => sizeof($result)));
                        self::$smarty->assign(array(
                        'search_tag' => $tag,
                        'products' => $result, // DEPRECATED (since to 1.4), not use this: conflict with block_cart module
                        'search_products' => $result,
                        'nbProducts' => $nbProducts,
                        'homeSize' => Image::getSize('home')));
                }

How must I modify the code for Prestashop to accept multiple tags? Did I even find the right code?

Edited by SkyHiRider (see edit history)
Link to comment
Share on other sites

  • 1 month later...
  • 8 months later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...