2

When I do any search we can see a list of products with the field "Sort by", but I need get rid of the option "Relevance": enter image description here

If I go to a category from menu I don't have this sorter.

Any idea?

2

To remove relevance sort order in searching you can rewrite below class

app/code/core/Mage/CatalogSearch/Block/Result.php

Mage_CatalogSearch_Block_Result in your custom module

and rewrite this method in this class setListOrders

and comment below code

 $availableOrders = array_merge(array(
        'relevance' => $this->__('Relevance')
    ), $availableOrders);
| improve this answer | |
1

Sort options are set in Mage_CatalogSearch_Block_Result::setListOrders()

To override this you can add something like this to your local.xml

<catalogsearch_result_index>
    <reference name="search_result_list">
        <action method="setAvailableOrders">
            <sort>
                <name>Name</name>
                <price>Price</price>
            </sort>
         </action>
    </reference>
</catalogsearch_result_index>

This would give you 2 sorting options (Name and Price). You can also use a helper method to make it more flexible ...


Edit: bit more flexible ... you dont have to care about other sort options, it just removes relevance:

<catalogsearch_result_index>
    <reference name="search_result_list">
        <action method="setAvailableOrders">
            <sort helper="[your_helper]/removeRelevanceFromSortOptions" />
        </action>
    </reference>
</catalogsearch_result_index>

For you helper you can use this:

public function removeRelevanceFromSortOptions()
{
    $availableOrders = Mage::getSingleton('catalog/layer')
        ->getCurrentCategory()
        ->getAvailableSortByOptions();

    unset($availableOrders['position']);
    # no need to to this ... see setListOrders()
    # unset($availableOrders['relevance']);

    return $availableOrders;
}
| improve this answer | |
  • 1
    Bro I think Op ask for search , not for category – Murtuza Zabuawala Jun 28 '18 at 10:10
  • You always welcome bro :) , but how we can remove one sorting with this, because , Relevance is hard coded in PHP code over there – Murtuza Zabuawala Jun 28 '18 at 10:55
  • but +1 for this answer as I am not aware of it – Murtuza Zabuawala Jun 28 '18 at 10:58
  • @MurtuzaZabuawala You do not remove one particular item, you (re-)set all sort options. – sv3n Jun 28 '18 at 10:58
  • @sv3n Yes, But I only need remove one sorting. – str_lml Jun 28 '18 at 12:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.