Jump to content

Prestashop 1.7.5.1 Sort by popularity


Recommended Posts

Hello everyone,

I try to edit the "sort by" select in my site and I want to obtain theese 4 options:

1) From relevance (and it's ok, I modify the position in Catalog-Products)

2) from the most recent to the oldest 

3) from the oldest to the most recent

4) by popularity

I found the file Ps_FacetedsearchProductSearchProvider.php  in modules\ps_facetedsearch\src\Ps_FacetedsearchProductSearchProvider.php
and I obtained the first 3 of 4 options that i need. I modify the code at line 117 and there is the result:

private function getAvailableSortOrders()
{
    return [
        (new SortOrder('product', 'position', 'asc'))->setLabel(
            $this->module->getTranslator()->trans('Relevance', array(), 'Modules.Facetedsearch.Shop')
        ),
        (new SortOrder('product', 'date_add', 'desc'))->setLabel(
            $this->module->getTranslator()->trans('Da più recente a meno recente', array(), 'Shop.Theme.Catalog')
        ),
        (new SortOrder('product', 'date_add', 'asc'))->setLabel(
            $this->module->getTranslator()->trans('Da meno recente a più recente', array(), 'Shop.Theme.Catalog')
        ),
    ];
}

I don't know what to write for the last option = BY POPULARITY

Anyone can help me? Thanks!

 

P.S: Sorry for my bad english, I'm an italian guy :D

 

 

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

  • 4 weeks 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...