我正在尝试在特定类别中禁用分层导航中的特定属性过滤器。在这种情况下,我希望禁用的属性过滤器是制造商。

我正在为所讨论的类别中的“自定义设计布局”尝试以下内容: -

<block type="catalog/layer_view" name="catalog.leftnav" after="currency" template="catalog/layer/view.phtml">
    <action method="unsetChild"><alias>manufacturer_filter</alias></action>
</block>

这是一半的工作,它隐藏了制造商的过滤器中的层次导航,但也隐藏了以下所有其他所有内容 catalog.leftnav.

是否知道上述如何修改以防止这种情况发生?

为了解释我的意思,这里是屏幕截图。

在XML更新之前

enter image description here

XML更新后

enter image description here

有帮助吗?

解决方案

如果您重写 Mage_Catalog_Model_Layer::getFilterableAttributes 方法。
对于特定类别,您可以添加新的过滤器。

这样的东西(未测试)

public function getFilterableAttributes()
{
    $setIds = $this->_getSetIds();
    if (!$setIds) {
        return array();
    }
    $collection = Mage::getResourceModel('catalog/product_attribute_collection');
    $collection
        ->setItemObjectClass('catalog/resource_eav_attribute')
        ->setAttributeSetFilter($setIds)
        ->addStoreLabel(Mage::app()->getStore()->getId())
        ->setOrder('position', 'ASC');
    if ($this->getCurrentCategory()->getId() == 7) {
         //if in that specific category...You can even make this a category setting or a config setting so you won't hard code it.  
         $collection->addFieldToFilter('attribute_code', array('neq'=>'manufacturer'));
    }

    $collection = $this->_prepareAttributeCollection($collection);
    $collection->load();

    return $collection;
}
许可以下: CC-BY-SA归因
scroll top