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

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

appcodeVendorExtensionetc

<?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="MagentoCatalogModelConfig">
        <plugin name="RemovePriceOption" type="VendorExtensionPluginModelConfig"/>
    </type>
 
</config>

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

VendorExtensionPluginModel

And then add the code as follows

<?php
 
namespace VendorExtensionPluginModel;
 
class Config
{
    public function afterGetAttributeUsedForSortByArray(MagentoCatalogModelConfig $catalogConfig, $options)
    {
        unset($options['price']);
        return $options;
    }
}

Leave a comment

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