Skip to content

Custom Sort By Option – Magneto 2.4.4 p-4

I have made a custom module to try and add a “bestseller” option to the sort by options on my magento 2.4.4 p-4 category pages. I can not seem to add the option bestseller though. I don’t want to overide the current options but rather just add to them. I have created a file catalog_category_view.xml which is below

<layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Element/UiComponent/etc/ui_configuration.xsd">
    <referenceBlock name="sorter.sorter-options">
        <arguments>
            <argument name="options" xsi:type="array">
                <item name="bestseller" xsi:type="array">
                    <item name="label" xsi:type="string" translate="true">Bestseller</item>
                    <item name="value" xsi:type="string">bestseller</item>
                </item>
            </argument>
        </arguments>
    </referenceBlock>
</layout>

Any advice on how to add this would be greatly appreciated