Jump to content

Search a product name in BO with wildcard


Recommended Posts

Hi ! when i try to search a product in BO with proper product name, it doesn't work very well.

 

Example:

 

Product name: " Kawasaki Racing Filter "

 

if i try to search " Kawasaki Racing " it's ok...the product appear in the results..

 

but if i try to search " Kawasaki Filter " the product doesn't appear... :( is there a way to correct this ? because is real hard searching a product when you have more than 30.000 articles...

 

Thanks to all

post-391630-0-38469300-1346333124_thumb.png

Link to comment
Share on other sites

I don't think prestashop can search like Google. It does not implemented in that way.

When you search "Kawasaki Racing", it will take a connected one word, not separated two words.

So it is not that easy to make that changes. I am not sure if there is any 3rd party modules to do that.

Link to comment
Share on other sites

ok, the file to edit is: AdminProductsController.php

 

 

here we go:

 

public function ajaxProcessCheckProductName()
{
 if ($this->tabAccess['view'] === '1')
 {
  $search = Tools::getValue('q'); /* Here we have the string. So, the scope is substitute the space in 2 or more words, like "Kawasaki Racing FIlter" to "Kawasaki%Racing%Filter" */
  $search = str_replace('', '%', $search);
  $id_lang = Tools::getValue('id_lang');
  $limit = Tools::getValue('limit');
  $result = Db::getInstance()->executeS('
SELECT DISTINCT pl.`name`, p.`id_product`, pl.`id_shop`
FROM `'._DB_PREFIX_.'product` p
LEFT JOIN `'._DB_PREFIX_.'product_lang` pl
 ON (pl.`id_product` = p.`id_product` AND pl.`id_lang` = '.(int)$id_lang.')
WHERE pl.`name` LIKE "%'.pSQL($search).'%"
GROUP BY pl.`id_product`
LIMIT '.(int)$limit);
  die(Tools::jsonEncode($result));
 }
}

 

but it doesn't work :( is there here some good programmers that can help me ? I'll appreciate. Thanks again dudes

Link to comment
Share on other sites

×
×
  • Create New...