【问题标题】:How to add Manufacturer attribute to Filter results in magento layered navigation如何在 magento 分层导航中将制造商属性添加到过滤结果
【发布时间】:2014-05-19 16:36:02
【问题描述】:

我正在使用 Magento 企业版,默认情况下,我在左侧导航栏中获取类别和价格范围,同时按类别显示产品列表。

但是,我需要将其他产品属性(例如制造商、传输类型...)添加到过滤结果中以进行分层导航。

我能够在该制造商属性下显示制造商列表,但使用选项“过滤无结果”,计数为 0。

每当我在管理端将制造商属性的选项更改为'Filter with results' 下的Catalogue/Attributes/Manage Attributes 时,我都无法在前端左侧导航栏中看到该属性。

即使分配了很多带有制造商的产品。我是否需要对代码进行任何更改,请帮助我,我是这个 magento 平台的新手。

谢谢

【问题讨论】:

  • 您是否尝试过索引、刷新缓存?
  • 是的,我做到了,但没有运气

标签: magento


【解决方案1】:

将此功能添加到您的: 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>

【讨论】:

  • 我试过了,但我需要根据所选产品列表按类别显示制造商列表,因此必须为每个产品列表刷新制造商列表
  • add this function in your: magento/app/code/core/Mage/Catalog/Block/Navigation.php ?修改Core是不是很糟糕??
【解决方案2】:

抱歉,这听起来是个愚蠢的问题,但您更改了看到类别配置锚定为“是”?

我会在回答后通知你

最好, 亚历杭德罗

【讨论】:

  • 谢谢!终于发现这就是缺少的东西!
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-03-23
  • 1970-01-01
相关资源
最近更新 更多