1

In product list page I need to change the sorting order. I have a current order like:

  • Description A-Z
  • Price High To Low
  • Price Low to High
  • Description Z-A

I need to change it to.

  • Description A-Z
  • Description Z-A
  • Price High To Low
  • Price Low to High

I tried using this JS.

window.onload = () => {
        const fontMenu = document.querySelector("#sorter");
        const options = Array.from(fontMenu.querySelectorAll("option"));
        // options.reverse();
             options.forEach((item,o) => {
                 options.splice(0,3);
                console.log(options,'op')
                options.unshift(item);
                fontMenu.appendChild(item);

             });
        }

1 Answer 1

3

Well, I think there are two ways.

  1. Create your own sort option in a module using a plugin. Something like this: Magento 2 How to add custom sort by option. Look at Luca S's answer. I think this person has a general idea of how to do it.
  2. Use Position option but modified: http://magento2x.com/magento-sort-newest-products-solution/.

Hopefully this will Help You.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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