我正在尝试列出属性目录/ category / view.phtml文件
我该怎么做这个功能?
答案 0 :(得分:1)
首先获取当前图层集合的获取列表属性
$CurrentLayer=Mage::getSingleton('catalog/layer');
$attributes = $CurrentLayer->getFilterableAttributes();
foreach ($attributes as $attribute) {
if ($attribute->getAttributeCode() == 'price') {
$filterBlockName = 'catalog/layer_filter_price';
} elseif ($attribute->getBackendType() == 'decimal') {
$filterBlockName = 'catalog/layer_filter_decimal';
} else {
$filterBlockName = 'catalog/layer_filter_attribute';
}
$result = $this->getLayout()->createBlock($filterBlockName)->setLayer($layer)->setAttributeModel($attribute)->init();
foreach($result->getItems() as $option) {
echo $option->getLabel().'<br/>';
echo $option->getValue();
}
}
希望我会工作
答案 1 :(得分:0)
@Amit Bera
抱歉,我的英语非常糟糕。
我解决了这个问题 view.phppublic function getAllManu()
{
$product = Mage::getModel('catalog/product');
$attributes = Mage::getResourceModel('eav/entity_attribute_collection')
->setEntityTypeFilter($product->getResource()->getTypeId())
->addFieldToFilter('attribute_code', 'product_properties');
$attribute = $attributes->getFirstItem()->setEntity($product->getResource());
$product_properties = $attribute->getSource()->getAllOptions(false);
return $product_properties;
}
view.phtml
<select class="form-control" onchange="if (this.value) window.location.href=this.value">
<option>Select</option>
<?php foreach ($this->getAllManu() as $product_properties): ?>
<option value="<?php Mage::getURL() ?>catalogsearch/advanced/result/?product_properties[]=<?php echo $product_properties['value'] ?>"><?php echo $product_properties['label'] ?></option>
<?php endforeach; ?>
</select>
感谢您的帮助