[英]How to add Manufacturer attribute to Filter results in magento layered navigation
我正在使用Magento企业版,默认情况下,在按类别显示产品列表时,在左侧导航栏中会获得类别和价格范围。
但是,我需要将其他产品属性(例如制造商,转移类型...)添加到分层导航的过滤结果中。
我可以在“制造商属性”下显示该制造商列表,但带有“无结果过滤”选项,且计数为0。
每当我在Catalogue/Attributes/Manage Attributes
下将'Filter with results'
制造商属性'Filter with results'
管理”中的选项更改为“制造商属性'Filter with results'
无法在前端左侧导航栏中看到该属性。
即使为制造商分配了很多产品。 我是否需要对Code进行任何更改,请帮助我,我是这个magento平台的新手。
谢谢
抱歉,如果您听到的是一个愚蠢的问题,但是您更改了,将类别配置固定为是?
回答之后,我会及时通知你
最好,亚历杭德罗
在您的以下位置添加此功能:magento / app / code / core / Mage / Catalog / Block / Navigation.php
public function getAllManu()
{
$product = Mage::getModel('catalog/product');
$attributes = Mage::getResourceModel('eav/entity_attribute_collection')
->setEntityTypeFilter($product->getResource()->getTypeId())
->addFieldToFilter('attribute_code', 'manufacturer'); //can be changed to any attribute
$attribute = $attributes->getFirstItem()->setEntity($product->getResource());
$manufacturers = $attribute->getSource()->getAllOptions(false);
return $manufacturers;
}
现在在以下位置添加phtml文件:magento / app / design / frontend / mytheme / default / template / catalog / navigation / left_nav.phtml
<?php foreach ($this->getAllManu() as $manufacturer): ?>
<li>
<a href="catalogsearch/advanced/result/?manufacturer[]=<?php echo $manufacturer['value'] ?>"><?php echo $manufacturer['label'] ?></a>
</li>
<?php endforeach;?>
然后只需调用block:magento / app / design / frontend / mytheme / default / layout / catalog.xml
<reference name="left">
<block type="catalog/navigation" name="catalog.leftnavigation" template="catalog/navigation/left_nav.phtml"/>
</reference>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.