如何在每个类别的一个页面中将所有属性组合在一起

时间:2015-02-23 13:40:45

标签: magento

如何在每个类别

的一个页面中将所有属性组合在一起

我想以这种方式显示过滤器!


 春天
 夏天
 下跌
 冬

颜色
 红色  绿色  蓝色  黑色  黄

价格  0到50  50到100

每个类别

请指导我。 我试图获得图层导航,但它不是

2 个答案:

答案 0 :(得分:0)

在我看来,你在谈论类别页面上的分层导航。 你可以做两件事

  • 在显示设置标签上确保类别的选项值 Is Anchor Category Name -> Display Settings -> Is Anchor
  • 并为前端属性部分中的在分层导航中使用选项设置自定义属性。
    custom attribute name -> Frontend Properties -> Use In Layered Navigation

有关详情,请查看this link

答案 1 :(得分:0)

Thanx,但我需要通过程序化来实现它 我使用自定义编码来获取图层导航中的所有属性

$layer = Mage::getModel("catalog/layer");
$category_id = $layer->getCurrentCategory();
$currentCategoryId= $category_id->getId();
$category = Mage::getModel("catalog/category")->load($currentCategoryId);
$layer->setCurrentCategory($category);
$attributes = $layer->getFilterableAttributes();
foreach ($attributes as $attribute)
{
    echo $attribute->getAttributeCode().'<br />';

  if ($attribute->getAttributeCode() == 'price') {
     $filterBlockName = 'catalog/layer_filter_price';
  } elseif ($attribute->getBackendType() == 'decimal') {
     $filterBlockName = 'catalog/layer_filter_decimal';
  } else {
     $filterBlockName = 'catalog/layer_filter_attribute';
  }
  Mage::app()->getLayout()->createBlock($filterBlockName)
  ->setLayer($layer)->setAtributeModel($attribute)->init();
    foreach($result->getItems() as $option) 
 {          
        echo $option->getFrontendLabel();
        echo $option->getLabel().'<br/>';
        //echo $option->getValue().'<br/>';
    }
}