【问题标题】:Magento - getting the available filters for a category in top navigationMagento - 在顶部导航中获取类别的可用过滤器
【发布时间】:2012-03-19 17:52:02
【问题描述】:

我正在使用 Magento 1.6.2 进行开发。

我想在顶部导航栏中显示一个包含我的类别中的过滤器(颜色、大小等)的下拉菜单。

到目前为止(在 /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>

$this->getFilters() 没有返回任何内容。 如何获取分类内容中的过滤器?

【问题讨论】:

  • 类别是否设置为 Anchor = Yes?
  • 这不是你想象的不可能!想想看,你访问了一个 cms 页面,那里的下拉菜单也可见,但没有内容。原因是,cms 页面中没有分类集合。导航部分的相同方面。导航部分没有产品集合,因此产品属性不会显示在下拉列表中。
  • 锚确实设置为yes

标签: php magento


【解决方案1】:

catalog/navigation/top.phtml 使用Mage_Catalog_Block_Navigation 并且它不实现方法getFilter() 除非你添加了这样的......这个块负责显示顶部导航菜单/

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多