我想从主菜单中的每个类别下拉列表中添加品牌列表。我相信这将被视为一个'超级菜单'。Magento在类别下拉菜单中添加品牌列表
例如 - 如果我将鼠标悬停在主类别上,它不仅会在下拉菜单中显示子类别,还会显示此类别中的所有不同品牌。
的品牌建立在两个方面:
所有产品都具有的属性“品牌”。因此,我们可以尝试获取该类别中的所有产品,并显示与此类别中的产品相关的所有品牌的列表。这将需要合并分层导航,以便当选择该菜单项时,它将显示来自该类别和该品牌属性的项目的过滤器。
我认为这种方法会更容易 - 每个品牌都已经创建了自己的类别,并且每个产品都属于主类别以及相关品牌类别。这是最初完成的,所以我们可以展示所有品牌的大名单。导航循环中的Magento中是否有函数来获取“其他选择的类别”?例如。如果项目位于类别A中,则下拉列表将显示所有子类别,但也会显示在产品上选择的任何其他相关顶级类别。
我已经试过这涉及修改Navigation.php(Magento的1.6)的各种解决方案,但我只能把它显示在店铺所有的品牌,而不仅仅是品牌的特定类别内。请参见下面的代码:
// Navigation.php code
// render children
$htmlChildren = '';
$j = 0;
foreach ($activeChildren as $child) {
$htmlChildren .= $this->_renderCategoryMenuItemHtml(
$child,
($level + 1),
($j == $activeChildrenCount - 1),
($j == 0),
false,
$outermostItemClass,
$childrenWrapClass,
$noEventAttributes
);
$j++;
}
if (!empty($htmlChildren)) {
if ($childrenWrapClass) {
$html[] = '<div class="' . $childrenWrapClass . '">';
}
$html[] = '<ul class="level' . $level . '">';
$html[] = $htmlChildren;
// My modifications start here
$product = Mage::getModel('catalog/product');
$attributes = Mage::getResourceModel('eav/entity_attribute_collection')
->setEntityTypeFilter($product->getResource()->getTypeId())
->addFieldToFilter('attribute_code', 'brands');
$attribute = $attributes->getFirstItem()->setEntity($product->getResource());
$manufacturers = $attribute->getSource()->getAllOptions(false);
$html[] = '<ol id="nav-drop-brands">';
foreach ($manufacturers as $manufacturer) {
$html[] = '<li><a href="http://www.domain.com/catalogsearch/advanced/result?manufacturer[]=';
$html[] = $manufacturer['value'];
$html[] = '">';
$html[] = $manufacturer['label'];
$html[] = '</a></li>';
}
$html[] = '</ol>';
// end of my modifications
$html[] = '</ul>';
if ($childrenWrapClass) {
$html[] = '</div>';
}
}
$html[] = '</li>';
$html = implode("\n", $html);
return $html;
}
嗨尼希尔 - 非常感谢您的回答。目前,品牌已经建立在两个方面(我已经更新了我的问题以上给你更多的信息)。我认为我们不能将它们全部设置好,并且将它们作为子分类来使用,因为商店已经有超过1000个商品。 – ronnz
这是一个不好的解决方案!您应该使用制造商属性并使用它来创建菜单。 看到这个:http://www.magentocommerce.com/wiki/5_-_modules_and_development/navigation/add_dropdown_list_of_manufactures_or_another_attribute – karantan
@karantan添加菜单后,下一步将是什么..? –