Jump to content

Search with or without spaces


Recommended Posts


I have a problem with my prestashop store. My store is: http://recambioprofesionalbarato.com

I have loaded about a thousand products, with reference codes to vehicles which account for each exchange.

But my problem comes here: I want these codes are found in the search, even if placed with or without spaces.

For example, when I do the search:

0 986 013 850

The search engine will find it perfectly.

However, if we look no spaces:


The search finds nothing.

Is there an automatic way? Can you help me?

Looking forward for your answer.

Share this post

Link to post
Share on other sites


as far as I know, the only 'simple' way to do it is adding 'aliases' one by one, so that the spaceless version returns the spaced version in preferences->search. 


The problem is, you have to add them all manually :(

Share this post

Link to post
Share on other sites

You could autogenerate aliases by doing something like this:

$sql = 'SELECT `reference`
         FROM `'._DB_PREFIX_.'product`';

$refs = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($q);

foreach($refs as $ref){
  $alias = new Alias();
  $alias->search = preg_replace('/\s+/', '', $ref['reference']);
  $alias->alias = $ref['reference'];

I have not tested this, use at your own risk.

Share this post

Link to post
Share on other sites

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...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More