How to Change Default Sort Order in Magento 2?

In this tutorial, you will go through how to change default product sort order in Magento 2.

In Magento 2, the default sorting order is ascending, but what if you would like to set it to descending by default? While it would seem like this would be a simple admin configuration, you actually have to edit a .xml file to get this functionality.

Change Default Sort Order in Magento 2

First of all, You need to copy

vendor/magento/module-catalog/view/frontend/layout/catalog_category_view.xml to


Now copy below code to your new xml file.

<?xml version="1.0"?>
<page xmlns:xsi="" layout="2columns-left" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
        <referenceContainer name="content">
            <referenceBlock class="Magento\Catalog\Block\Product\ListProduct" name="category.products.list" as="product_list">
                <action method="setDefaultDirection">
                    <argument name="dir" xsi:type="string">desc</argument>
        <move element="category.view.container" destination="content" before="-"/>

That’s it !!

I hope you like this post, Please feel free to comment below, suggestion and problems!

(Visited 11 times, 1 visits today)
Chandra Kumar

Hello World, I am Chandra Kumar from New Delhi, India. I am professionally developer, programmer and blogger. I am the founder of

0 Comment

Leave a Comment

Your email address will not be published. Required fields are marked *