Jump to content

Search result order is reversed


robinbrorsson

Recommended Posts

I have a problem with my prestashop version 1.7.2.2. 

When I search for a reference. for example: TB-BOX-IP44 I get many results, most of them seem to react on the "BOX" part. Since there is many other products that have box in reference or description. however there is one product that has an exact match. But the exact match product almost allways comes last in the results. Seems there relevance order is reversed somehow. any ideas?

 

/Robin

Link to comment
Share on other sites

  • 5 weeks later...
  • 1 month later...

Hi guys,

after strugling with this issue for quite some time I finally found a solution.

This fix involves changes in "Src" folder, so it isn't "elegant".

My version of Presta is 1.7.2.4.

Here goes:

1)  in file "./src/Core/Product/Search/SortOrderFactory.php" change line 44

from:

           (new SortOrder('product', 'position', 'asc'))->setLabel(

to:

           (new SortOrder('product', 'position', 'desc'))->setLabel(

2) in file "./controllers/front/listing/SearchController.php" change line 67

from:

           ->setSortOrder(new SortOrder('product', Tools::getProductsOrder('by'), Tools::getProductsOrder('way')))

to

           ->setSortOrder(new SortOrder('product', Tools::getProductsOrder('by'), 'desc'))

 

  • Like 2
Link to comment
Share on other sites

  • 1 year later...
On 2/8/2018 at 1:47 PM, bTk said:

Hi guys,

after strugling with this issue for quite some time I finally found a solution.

This fix involves changes in "Src" folder, so it isn't "elegant".

My version of Presta is 1.7.2.4.

Here goes:

1)  in file "./src/Core/Product/Search/SortOrderFactory.php" change line 44

from:


           (new SortOrder('product', 'position', 'asc'))->setLabel(

to:


           (new SortOrder('product', 'position', 'desc'))->setLabel(

2) in file "./controllers/front/listing/SearchController.php" change line 67

from:


           ->setSortOrder(new SortOrder('product', Tools::getProductsOrder('by'), Tools::getProductsOrder('way')))

to


           ->setSortOrder(new SortOrder('product', Tools::getProductsOrder('by'), 'desc'))

 

this absolute work! Thanks

Link to comment
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...