$attributes = Mage::getModel('catalogsearch/advanced')->getAttributes();
$attributeArray=array();
foreach($attributes as $a){
if($a->getAttributeCode() == 'desired_attribute_code'){
foreach($a->getSource()->getAllOptions(false) as $option){
$attributeArray[$option['value']] = $option['label'];
}
}
}
$attribute = Mage::getModel('eav/config')->getAttribute('catalog_product', 'attribute_id');foreach ( $attribute->getSource()->getAllOptions(true, true) as $option){$attributeArray[$option['value']] = $option['label'];}
获取multi-select的属性值:
$attributeId = Mage::getResourceModel('eav/entity_attribute')
->getIdByCode('catalog_product','attribute_code_here');
$attribute = Mage::getModel('catalog/resource_eav_attribute')->load($attributeId);
$attributeOptions = $attribute ->getSource()->getAllOptions();
获取某产品的属性的值:
$_product->getResource()->getAttribute('club_type')->getFrontend()->getValue($_product)
根据attribute code获取attribute属性对象:
Mage::getModel('eav/entity_attribute')->loadByCode(Mage_Catalog_Model_Product::ENTITY, 'price');
获取某个dropdown的所有属性值
$collection = Mage::getResourceModel('eav/entity_attribute_option_collection')
->setPositionOrder('asc')
->setAttributeFilter($attributeId)
->setStoreFilter(null);
或者:
$attributesInfo = Mage::getResourceModel('eav/entity_attribute_collection')
->setEntityTypeFilter({entityType})
->setCodeFilter($attributes)
->addSetInfo()
->getData();
参考: http://www.sharpdotinc.com/mdost/2009/04/06/magento-getting-product-attributes-values-and-labels/