Вопрос

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?

Это было полезно?

Решение

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);

Другие советы

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;
}
Лицензировано под: CC-BY-SA с атрибуция
Не связан с magento.stackexchange
scroll top