2012-03-19 54 views
1

我正在使用Magento 1.6.2进行开发。Magento - 获取顶级导航中类别的可用过滤器

我想在我的顶部导航栏中显示包含过滤器(颜色,大小等)的下拉列表。

到目前为止(在/app/design/fontend/package/theme/template/catalog/navigation/top.phtml)我有:

<ul>  
<?php foreach ($this->getStoreCategories() as $_category): ?> 
<li><a href="<?php echo $this->getCategoryUrl($_category); ?>" title="<?php echo $this->htmlEscape($_category->getName()); ?>"><?php echo $this->htmlEscape($_category->getName()); ?></a> 
    <?php $_filters = $this->getFilters() ?> 
    <div> 
      <?php foreach ($_filters as $_filter): ?> 
      <dl> 
      <?php if($_filter->getItemsCount()): ?> 
       <dt><?php echo $this->__($_filter->getName()) ?></dt> 
       <dd><?php echo $_filter->getHtml() ?></dd> 
      <?php endif; ?> 
      </dl> 
      <?php endforeach; ?>   
    </div>   
</li> 
<?php endforeach ?> 
</ul> 

$这个 - > getFilters()不返回任何东西。 如何获取类别内容中的过滤器?

+1

是否将类别设置为锚点=是? – seanbreeden 2012-03-19 19:29:39

+0

它不是你想的那么难以置信!考虑一下,你访问了一个cms页面,下拉菜单中可以看到但没有内容。原因是,cms页面中没有类别集合。导航部分的相同方面。导航部分没有产品集合,因此产品属性不会以下拉菜单显示。 – 2012-03-19 20:51:18

+0

锚点确实设置为yes – mononym 2012-03-21 18:46:27

回答

1

catalog/navigation/top.phtml使用Mage_Catalog_Block_Navigation,除非你已经添加这样它没有实现方法getFilter() ...此块负责显示顶部导航菜单/

我认为你正在寻找Layered Navigation所使用在类别视图工具栏中,并负责分类过滤器。