Hello Magento Friends,
In today’s blog, we will learn about How to Change Default Sort Order from Ascending to Descending in Magento 2.
In Magento 2, the default product listing in the category page shows the default filter option in ascending to descending order. But if you want to set the sort order from descending to ascending, you can use the below steps.
Contents
Steps to Change Default Sort Order from Ascending to Descending in Magento 2:
Step 1: Create app\design\frontend\Themes\Yourtheme\Magento_Catalog\layout\catalog_category_view.xml or you can override the catalog_category_view.xml file in your custom extension at the below location
app\code\Vendor\Extension\view\frontend\layout\catalog_category_view.xml
Now add the code as below
1 2 3 4 5 6 7 8 9 10 11 12 13 |
<?xml version="1.0"?> <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="2columns-left" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd"> <body> <referenceContainer name="content"> <referenceBlock class="Magento\Catalog\Block\Product\ListProduct" name="category.products.list"> <action method="setDefaultDirection"> <argument name="dir" xsi:type="string">desc</argument> </action> </referenceBlock> </referenceContainer> </body> </page> |
Conclusion:
Hence, with the help of the above method, you can easily change the order of product listing in the category page from ascending to descending in Magento 2. To configure product listings in Magento 2 – Click Here!
Share your doubts with me through the comment section, and stay with us for more Magento solutions.
Happy Coding!
this method no longer works in magento 2.4x do you have a alternative
For your custom requirement you can contact on support@magecomp.com