Magento 如何在一个页面中为每个类别获取所有属性
如何在一个页面中为每个类别获取所有属性 我想用这种方式显示过滤器 季节Magento 如何在一个页面中为每个类别获取所有属性,magento,Magento,如何在一个页面中为每个类别获取所有属性 我想用这种方式显示过滤器 季节 弹簧 夏季 下降 冬天 颜色 红色 绿色 蓝色 黑色 黄色的 价格 0到50 50至100 对于每个类别 请引导我。 我试图获得分层导航,但它不在我看来,你在类别页面上谈论的是分层导航。 你可以做两件事 在显示设置选项卡上,确保类别的选项值为锚定值为是 Category Name->Display Settings->Is-Anchor 在前端属性部分的分层导航选项中设置了是的自定义属性。 自定义属性名称->前端属性->在
弹簧
夏季
下降
冬天 颜色
红色 绿色 蓝色 黑色 黄色的 价格 0到50 50至100 对于每个类别 请引导我。
我试图获得分层导航,但它不在我看来,你在类别页面上谈论的是分层导航。 你可以做两件事
- 在显示设置选项卡上,确保类别的选项值为锚定值为是
Category Name->Display Settings->Is-Anchor
- 在前端属性部分的分层导航选项中设置了是的自定义属性。
自定义属性名称->前端属性->在分层导航中使用
有关详细信息,您可以查看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/>';
}
}
$layer=Mage::getModel(“目录/层”);
$category_id=$layer->getCurrentCategory();
$currentCategoryId=$category_id->getId();
$category=Mage::getModel(“目录/类别”)->load($currentCategoryId);
$layer->setCurrentCategory($category);
$attributes=$layer->getFilterableAttributes();
foreach($attributes作为$attribute)
{
echo$attribute->getAttributeCode()。
;
如果($attribute->getAttributeCode()=='price'){
$filterBlockName='catalog/layer_filter_price';
}elseif($attribute->getBackendType()=='decimal'){
$filterBlockName='catalog/layer_filter_decimal';
}否则{
$filterBlockName='catalog/layer_filter_attribute';
}
Mage::app()->getLayout()->createBlock($filterBlockName)
->setLayer($layer)->setAtributeModel($attribute)->init();
foreach($result->getItems()作为$option)
{
echo$选项->getFrontendLabel();
echo$option->getLabel()。
;
//echo$option->getValue()。
;
}
}