Friday, 15 June 2012

Magento: Getting product attributes values and labels


1.$attribute = Mage::getModel('eav/config')->getAttribute('catalog_product', 'attribute_id');
2.foreach ( $attribute->getSource()->getAllOptions(true, true) as $option){
3.$attributeArray[$option['value']] = $option['label'];
4.}

---------------------------------------------------------------------------------
01.$attributes = Mage::getModel('catalogsearch/advanced')->getAttributes();02.$attributeArray=array();03.foreach($attributes as $a){04.if($a->getAttributeCode() == 'desired_attribute_code'){05.foreach($a->getSource()->getAllOptions(false) as $option){06.$attributeArray[$option['value']] = $option['label'];07.}08.}09.}
---------------------------------------------------------------------------------
1.$attributeId = Mage::getResourceModel('eav/entity_attribute')2.->getIdByCode('catalog_product','attribute_code_here');3.$attribute = Mage::getModel('catalog/resource_eav_attribute')->load($attributeId);4.$attributeOptions = $attribute ->getSource()->getAllOptions();
---------------------------------------------------------------------------------1.//Referenced from /app/code/core/Mage/Eav/Model/Config/php @ line 443
2.$_product->getResource()->getAttribute('club_type')->getFrontend()->getValue($_product)
------------------------------------------------------------------------
1.//2.$attributesInfo = Mage::getResourceModel('eav/entity_attribute_collection')3.->setEntityTypeFilter({entityType})4.->setCodeFilter($attributes)5.->addSetInfo()6.->getData();

No comments: