How to get all value of attribute in magento?

Get All Values Of a Attribute In Magento:-
To display dropdown attribute of all possible values of Attribute in Magento that you have created custom you can use the below given code for fetching the desired results.


<?php
$attributes = Mage::getResourceModel('eav/entity_attribute_collection')
->setCodeFilter('colors') ->getFirstItem();
$attrOptions = $attributes->getSource()->getAllOptions(false);
?>

<select>
<?php foreach($attrOptions as $items): ?>
<option value="<?php echo $items['value']; ?>"><?php echo $items['label']; ?></option>
<?php endforeach; ?>
</select>

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *