I'm trying to set a default sort order to products listing in category page.

I have seen people suggest using

            <action method="setDefaultOrder">
                <argument name="sort" xsi:type="string">name</argument>
                <action method="setDefaultDirection">
                    <argument name="dir" xsi:type="string">asc</argument>

or by using

            <action method="setSortBy"><string>name</string></action>
                <action method="setDefaultDirection">
                    <argument name="dir" xsi:type="string">asc</argument>

Unfortunately none of the above method worked for me. But I just want to know what's the different between setDefaultOrder and setSortBy?

1 Answer 1


Not sure where you've got one of those snippets from



<?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">
        <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>

That's to change sort by direction

To change sort by value

Stores > Config > Catalog > Catalog > Storefront > Product Listing Sort By

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.