2011-06-10 115 views
5

如何將排序順序更改爲Magento搜索結果頁中的名稱?Magento - 更改排序順序到搜索結果中的名稱

感謝您的幫助。

+0

你沒有在那裏分選方法中,選擇工具欄? – 2011-06-10 09:26:40

+0

我掩蓋了它,我的廚師不想展示它。任何解決方案按產品名稱進行默​​認排序 – Bizboss 2011-06-10 15:09:21

回答

7

&order=name添加到您的查詢字符串中。爲了做到這一點去/app/design/frontend/{your-interface}/{your-theme}/template/catalogsearch/advanced/form.phtml和剛剛閉幕</form>標記前新增

<input type="hidden" name="order" value="name"/> 

+0

非常感謝,你救了我的命! 我只將它添加到form.mini.phtml – Bizboss 2011-06-10 15:50:22

+0

您是否也知道如何訂購Autocomplete搜索表單中的建議? – Bizboss 2011-06-10 15:51:23

+0

這將會複雜得多。我建議提出另一個問題。 – 2011-06-10 17:21:24

21

在你的主題(例如/app/design/frontend/{your-interface}/{your-theme}/layout/)創建一個文件local.xml具有以下內容:

<?xml version="1.0" encoding="UTF-8"?> 
<layout> 
    <catalogsearch_result_index> 
     <reference name="search_result_list"> 
      <action method="setDefaultDirection"><param>asc</param></action> 
      <action method="setSortBy"><param>name</param></action> 
     </reference> 
    </catalogsearch_result_index> 
    <catalogsearch_advanced_result> 
     <reference name="search_result_list"> 
      <action method="setDefaultDirection"><param>asc</param></action> 
      <action method="setSortBy"><param>name</param></action> 
     </reference> 
    </catalogsearch_advanced_result> 
</layout> 
+2

在Magento'1.7.0.2'上,我必須將這個文件放在'/ app/design/frontend/default/{theme}/layout/local.xml'中。除此之外,完美的工作。 – Maurice 2013-01-20 16:41:58

+1

這個方法的+1,因爲簡單地添加查詢字符串來設置排序是有問題的。 – pspahn 2013-01-22 18:38:19

+0

這個真的很整潔!完成了這項工作。 – anshuman 2013-07-19 13:56:02