Jump to content

Filter by discount in sort by


laqmarc

Recommended Posts

Hello, I would like to know if there is any way to filter by discount in the facets module.

I have tried adding a case in private function addSearchFilters($selectedFilters) but it doesn't quite work for me.

 case 'offer':
        if ($orderDirection === 'desc') {
            $this->query->addOrderBy('(price - reduced_price) / price', 'DESC');
        } else {
            $this->query->addOrderBy('(price - reduced_price) / price', 'ASC');
        }
        break;

But it doesn't work for me, I've been looking at the documentation but I'm quite lost.

Any ideas?

Greetings

Link to comment
Share on other sites

Hello,

Thank you for reaching out to us.

If you're looking to filter products by discount in the faceted search module in PrestaShop, you may need to create a custom module or override the existing one. Look for suitable hooks like actionProductSearchComplete or actionProductSearchAfter to modify search results and consider adjusting the SQL query to include discounts in the sorting process.

If you encounter difficulties, check the PrestaShop support for assistance.

I wish you a good day.

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