我需要在 Magento 高级搜索结果页面上显示分层导航过滤器,就像在目录搜索结果页面上一样。
我已经根据需要将 XML block 移至 Catalogsearch_advanced_result:
<reference name="left">
<block type="catalogsearch/layer" name="catalogsearch.leftnav" template="catalog/layer/view.phtml"/>
</reference>
该 block 被调用,但没有显示任何内容。我追踪了核心文件,发现在 Catalog/Block/Layer/View.php 中该函数不返回任何属性(第 161 行):
protected function _getFilterableAttributes()
{
$attributes = $this->getData('_filterable_attributes');
if (is_null($attributes)) {
$attributes = $this->getLayer()->getFilterableAttributes();
$this->setData('_filterable_attributes', $attributes);
}
return $attributes;
}
我将 getFilterableAttributes() 跟踪到 Catalog/Model/Layer.php 文件中,但从这一点开始,很难弄清楚目录搜索和高级搜索之间的区别在哪里。
我基本上只是想让它以任何可能的方式工作。任何帮助或指导将不胜感激!
编辑:
我的产品属性设置正确如下:
最佳答案
嘿,我已经成功地在高级搜索页面中引入了分层导航。
执行以下步骤:
第 1 步:在 catalogsearch.xml
中更新如下
`
<label>Advanced Search Result</label>
<update handle="page_two_columns_right" />
<!-- Mage_Catalogsearch -->
<reference name="root">
<action method="setTemplate"><template>page/3columns.phtml</template></action>
</reference>
<reference name="left">
<block type="catalog/layer_view" name="catalog.leftnav" after="currency" template="catalog/layer/view.phtml"/>
</reference>`
第 2 步:清除缓存,然后就可以开始了。
现在为了使过滤器正常工作,您需要对请求网址进行一些修改
例如在高级搜索中,价格过滤器类似于 price[from]=1&price[to]=100
而不是 price=1,100
关于Magento:高级搜索结果的分层导航,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13248461/