我相信失蹤的「鑰匙」有以下兩個項目:在任何情況下
<action method="setDefaultDirection"><string>desc</string></action>
<action method="setDefaultOrder"><string>relevance</string></action>
你應該能夠acomplish這幾種不同的方法......你需要做的本地副本所述文件。
1)如果你不已經有一個,加上「catalogsearch.xml」的本地副本
注: 由於Magento的佈局作品「級聯」這是一個好主意,先檢查任何「其他」Magento佈局目錄(除了「基礎」)。例如,在我的例子中,我們使用EE,所以我們在查看'base'目錄之前先檢查'enterprise'佈局目錄以複製文件。
/應用程序/設計/前端/基/默認/佈局/ catalogsearch: 'catalogsearch.xml' 的
常見位置。xml(作爲最後的手段) /app/design/frontend/enterprise/default/layout/catalogsearch.xml(針對EE) 注意:可能與PE有不同的位置......我不是100%。
2)添加以下在 'catalogsearch.xml' 的 'catalogsearch_result_index' 部分內:
<action method="setDefaultDirection"><string>desc</string></action>
<action method="setDefaultOrder"><string>relevance</string></action>
例如:
引用 'search_result_list' 句柄(即企業佈局):
<reference name="search_result_list">
<action method="setDefaultDirection"><string>desc</string></action>
<action method="setDefaultOrder"><string>relevance</string></action>
</reference>
因此,這將最終看起來類似於:
<catalogsearch_result_index>
...other code
<reference name="search_result_list">
<action method="setDefaultDirection"><string>desc</string></action>
<action method="setDefaultOrder"><string>relevance</string></action>
</reference>
...other code
</catalogsearch_result_index>
或者你也可以直接在 'search_result_list' 塊內放置(即基地佈局):
<catalogsearch_result_index translate="label">
<label>Quick Search Form</label>
<reference name="root">
<action method="setTemplate"><template>page/3columns.phtml</template></action>
</reference>
<reference name="left">
<block type="catalogsearch/layer" name="catalogsearch.leftnav" after="currency" template="catalog/layer/view.phtml"/>
</reference>
<reference name="content">
<block type="catalogsearch/result" name="search.result" template="catalogsearch/result.phtml">
<block type="catalog/product_list" name="search_result_list" template="catalog/product/list.phtml">
<action method="setDefaultDirection"><string>desc</string></action>
<action method="setDefaultOrder"><string>relevance</string></action>
<block type="catalog/product_list_toolbar" name="product_list_toolbar" template="catalog/product/list/toolbar.phtml">
<block type="page/html_pager" name="product_list_toolbar_pager"/>
</block>
<action method="addColumnCountLayoutDepend"><layout>empty</layout><count>6</count></action>
<action method="addColumnCountLayoutDepend"><layout>one_column</layout><count>5</count></action>
<action method="addColumnCountLayoutDepend"><layout>two_columns_left</layout><count>4</count></action>
<action method="addColumnCountLayoutDepend"><layout>two_columns_right</layout><count>4</count></action>
<action method="addColumnCountLayoutDepend"><layout>three_columns</layout><count>3</count></action>
<action method="setToolbarBlockName"><name>product_list_toolbar</name></action>
</block>
<action method="setListOrders"/>
<action method="setListModes"/>
<action method="setListCollection"/>
</block>
</reference>
</catalogsearch_result_index>
3)確保轉儲Magento的緩存/存儲和REINDEX。
另一個選項將是將它們作爲「隱藏」在「form.mini.phtml」
1)將在「form.mini.phtml」的形式內的以下形式的元素:
現在
<input type="hidden" name="order" value="relevance">
<input type="hidden" name="dir" value="desc">
,在「form.mini.phtml」形式的開頭將類似於:
<form id="search_mini_form" action="<?php echo $this->helper('catalogsearch')->getResultUrl() ?>" method="get">
<input type="hidden" name="order" value="relevance">
<input type="hidden" name="dir" value="desc">
...other code
2)「默認」內將路徑更改爲「form.mini.phtml」模板部分('頭'參考手le)在'catalogsearch.xml'中:
<default>
<reference name="header">
<block type="core/template" name="top.search" as="topSearch" template="custom_template/catalogsearch/form.mini.phtml"/>
</reference>
... other code
3)確保轉儲Magento緩存/存儲和重新索引。
最後的筆記... 下面是我們設置爲「自定義模板」的路徑結構。位於「企業」目錄中,因此我的定製文件將位於: /app/design/frontend/enterprise/custom_template/layout/catalogsearch.xml /app/design/frontend/enterprise/custom_template/template/catalogsearch/form .mini.phtml
希望這是有道理的,並幫助。
我看到了這個問題:http://stackoverflow.com/questions/1953715/magento-search-not-returning-expected-results但我不確定這是真的,Magento顯示最不相關的第一?! – WOBenji