user3548132 user3548132 - 2 months ago 13
PHP Question

Search algorithm to find symbols with and without "-" sign

On my

prestashop
1.6 store I've got problem with search algorithm. Every product has got compatibility in description, and it looks like: "DCP-9015". I want search algorithm to find it when user is looking by word: "DCP9015".
I don't have any idea how to make it works.

Answer

You can use the Search Alias tool. In your Backoffice go to Preferences > Search and at the top click on Add new Alias.

Here you can provide an Alias for DCP-9015. In the Alias field type "DCP9015" and in the Result field type "DCP-9015".

Save and repeat this operation for every alias you need to create.

If you got a lot of aliases you can do it programmatically. If you really want you can also override indexation() method in /classes/Search.php, but that will needs more work.

Comments