How To

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.

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.

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!

Click to rate this post!
[Total: 2 Average: 5]
Dhiren Vasoya

Dhiren Vasoya is a Director and Co-founder at MageComp, Passionate 🎖️ Certified Magento Developer👨‍💻. He has more than 9 years of experience in Magento Development and completed 850+ projects to solve the most important E-commerce challenges. He is fond❤️ of coding and if he is not busy developing then you can find him at the cricket ground, hitting boundaries.🏏

Recent Posts

6 Innovative Tools Revolutionizing E-Commerce Operations

E-commerce has transformed the way consumers shop for products and services and interact with businesses.…

2 days ago

How Upcoming Cookie Changes Will Affect Your E-commerce Website?

The e-commerce world is constantly in flux. New tech and strategies emerge daily to help…

2 days ago

Magento 2: How to Add Header and Footer in Checkout

Hello Magento Friends, In today’s blog, we will discuss adding a header and footer to…

2 days ago

Understanding Flexbox Layout in React Native

Hello React Native Friends, Building a visually appealing and responsive mobile app is crucial in…

4 days ago

HYVÄ Themes Releases: 1.3.6 & 1.3.7 – What’s New

We're thrilled to announce the release of Hyvä Themes 1.3.6 and 1.3.7! These latest updates…

4 days ago

How Modern E-Commerce Platforms Leverage Docker & Kubernetes for Scalability

Your e-commerce platform is surging - orders are rolling in, traffic spikes are becoming the…

5 days ago