我正在尝试列出属性catalog/category/view.phtml文件
如何实现此功能?
首先获取当前图层集合的get list属性
$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();
}
}
希望我能工作
视图.php
public 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;
}
查看.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>