簡體   English   中英

如何在Magento分層導航中將Manufacturer屬性添加到Filter結果

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM