Magento:在分层导航中显示兄弟类别

pzi*_*ind 3 magento

我想将兄弟类别添加到分层导航(每当客户已经是一个层时).

换句话说:假设我有一个名为'动物'和子类别的类别,分别名为'猫''狗'和'狮子',如果客户点击'狮子',我希望他们在"按类别购物"中看到猫和狗.

有没有人知道如何做到这一点?

提前致谢.

Mag*_*Guy 7

这不应该太困难.下面的代码未经测试,但无论您将其置于前端的哪个位置,它都应该可以使用.它会做什么让你访问兄弟类别的集合,但你需要弄清楚你把模板放在哪里.

$parentId = Mage::registry('current_category')->getParentCategory()->getId();
$cats = Mage::getModel('catalog/category')->load($parentId)->getChildrenCategories();
foreach ($cats as $cat) {
  // first, skip current category.
  if ($cat->getId() == Mage::registry('current_category')->getId()) continue;
  // then do something with $cat
  echo $cat->getName().", ";
}
Run Code Online (Sandbox Code Playgroud)