How to Remove SORT BY “Price” Option in Magento 2?

How to Remove SORT BY Price Option in Magento 2

Hello Magento Friends,

Today in this tutorial, I will explain How to Remove SORT BY “Price” Option in Magento 2.

Sort by options is a vital tool for eCommerce websites to increase user convenience in searching the products. It provides a smoother user experience and improves sales conversion rates with improved navigation. Using the sort-by options, users can find their desired product quickly, thereby increasing customer satisfaction and loyalty.

The sort-by options include price, discount, relevance, newest, popularity, and more. In Magento 2, Position, Product Name, and Price are default sort by options. You can easily Add Sort by Price Options in Magento 2.

Sort by Price - Before

Due to several reasons, you may not require the sort by price option in Magento 2. 

  • While selling services, the price may vary. So you want users to ask for price instead of displaying the fixed price.
  • For some products, you want the customer’s attention on other crucial features as compared to price.
  • If the target audience values other factors more than the price.

Let’s see How to Remove SORT BY “Price” option in Magento 2.

Steps to Remove SORT BY “Price” Option in Magento 2:

Step 1: Create a di.xml file at the below path

app\code\Vendor\Extension\etc\

And add the following code

<?xml version="1.0"?>

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">

    <type name="Magento\Catalog\Model\Config">
        <plugin name="RemovePriceOption" type="Vendor\Extension\Plugin\Model\Config"/>
    </type>

</config>

Step 2: After that, create Config.php in the following path

Vendor\Extension\Plugin\Model\

And then add the code as follows

<?php

namespace Vendor\Extension\Plugin\Model;

class Config
{
    public function afterGetAttributeUsedForSortByArray(\Magento\Catalog\Model\Config $catalogConfig, $options)
    {
        unset($options['price']);
        return $options;
    }
}

Ta-da! The SORT BY “Price” option has been successfully removed from your Magento 2 front-end product listing pages.

Sort by Price - After

Conclusion:

This way, you can remove the sort by price option in Magento 2. If you need help removing the sort by price option in Magento 2, you can connect with me through the comment section, and I will quickly provide you with the solution.

Share the tutorial with your other Magento friends to help them customize the sort by options in Magento 2. Stay updated with us for more Magento 2 customization solutions.

Happy Coding!

Previous Article

How to Uninstall Any App in Shopify Store?

Next Article

How to Add a Blog Post to Your Shopify Store?

Write a Comment

Leave a Comment

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

Get Connect With Us

Subscribe to our email newsletter to get the latest posts delivered right to your email.
Pure inspiration, zero spam ✨