问题描述
我的问题是,在magento中进行高级搜索不会返回任何结果(普通搜索会返回结果).如果我转储
My problem is, that the advanced search in magento returns no results (the normal search does). If I dump
$this->getLoadedProductCollection()
在我的模板中,它返回"null".因此,我在"app/code/local/Mage/CatalogSearch/Block/Advanced/Result.php"中查看了将集合设置为高级搜索模板/视图的类,并找到了以下方法:
in my Template, it returns "null". So I looked at the class which sets the collection to the advanced search template/view in "app/code/local/Mage/CatalogSearch/Block/Advanced/Result.php" and found this method:
public function setListCollection() {
$this->getChild('search_result_list')->setCollection($this->_getProductCollection());
}
如果我转储
$this->_getProductCollection();
我获得了与我的搜索查询匹配的所有产品.但是为什么返回我的第一个方法为null?我不知道.
I get all products matching my search query. But why returns my first method null? I have no idea.
感谢您的帮助.
推荐答案
如果有产品,则可能未显示块search_result_list
.
检查布局文件catalogsearch.xml
,并查看手柄<catalogsearch_advanced_result>
的外观.它内部应该有一个名为search_result_list
的块.将其与默认主题中的一个进行比较.为了简化操作,此处显示的内容应类似于:
If the products are there maybe you are not showing the block search_result_list
.
Check your layout file catalogsearch.xml
and see how the handle <catalogsearch_advanced_result>
looks like. It should have a block inside it with the name search_result_list
. Compare it to the one in the default theme. To make it easier, here it show it should look like:
<catalogsearch_advanced_result translate="label">
<label>Advanced Search Result</label>
<update handle="page_two_columns_right" />
<!-- Mage_Catalogsearch -->
<reference name="root">
<action method="setTemplate"><template>page/2columns-right.phtml</template></action>
</reference>
<reference name="content">
<block type="catalogsearch/advanced_result" name="catalogsearch_advanced_result" template="catalogsearch/advanced/result.phtml">
<block type="catalog/product_list" name="search_result_list" template="catalog/product/list.phtml">
<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_advanced_result>
这篇关于Magento高级搜索无结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!