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
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
<?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>
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!
In this guide, we'll explore how to integrate ChatGPT, an AI-powered chatbot, with a Laravel…
In the world of business, understanding financial metrics is crucial for making informed decisions and…
Welcome to the MageComp Monthly Digest, where we bring you the latest updates, releases, and…
In this era, businesses are always on the lookout for ways to engage with their…
Managing a Shopify store efficiently involves keeping your product catalog organized. This includes removing outdated…
E-commerce has transformed the way consumers shop for products and services and interact with businesses.…
View Comments
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