I want to sort products by popularity and discount(high to low).

How can I achieve?


You can use native table for select popularity and discount:

report_viewed_product_index - products popularity (SUM(index_id) GROUP BY product_id)

catalog_product_index_price - discount = final_price - price

Also you can use comprehensive solution, like https://mirasvit.com/magento-2-improved-sorting.html which allows sort products by more 10 different factors and apply sorting by few factors in same time (set importance for each factor)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.