分层导航和类别子菜单

时间:2014-03-20 04:52:47

标签: magento

我有一个带有顶级类别菜单的网站,当您悬停时,它会显示一个包含两列的子菜单:“按类别”和“按品牌”

目前“按类别”完美显示子类别列表,但“按品牌”有错误。当没有被任何品牌过滤时,显示品牌列表,但是当我在分层导航或子菜单中选择一个品牌(这是分层导航过滤器的链接)时,品牌就不再可见了。

如何在每个子菜单中显示品牌列表?并非所有品牌都对每个类别都有结果,这就是我使用de Layered Navigation Filter代码的原因。

这是catalog / navigation / top.phtml的代码:

<?php
$layer = Mage::getSingleton('catalog/layer');
$brands = array();
$_childCategory = Mage::getModel('catalog/category')->setStoreId($storeId)->load($categoryChildId);
$layer->setCurrentCategory($_childCategory);

$attributes = $layer->getFilterableAttributes();
foreach ($attributes as $attribute) {
    if ($attribute->getAttributeCode() == 'brand') {
        $result = Mage::app()->getLayout()
                ->createBlock('catalog/layer_filter_attribute')
                ->setLayer($layer)
                ->setAttributeModel($attribute)
                ->init();

        foreach ($result->getItems() as $option) {
            $brands[$option->getValue()] = $option->getLabel();
        }
    }
}
var_dump($brands);

0 个答案:

没有答案
相关问题