If attribute ID = 161, below is the simple code to get option ids and values for the attribute ID.
$valuesCollection = Mage::getResourceModel('eav/entity_attribute_option_collection')
->setAttributeFilter(161)
->load();
foreach ($valuesCollection as $item) {
$attr = Mage::getModel('eav/entity_attribute_option')
->getCollection()->setStoreFilter()
->join('attribute','attribute.attribute_id=main_table.attribute_id', 'attribute_code')
->addFieldToFilter('main_table.option_id',array('eq'=>$item->getId()))->getFirstItem();
$procategorydata= $attr->getData();
echo 'Option ID: ';
echo $procategorydata['option_id'];
echo 'Value:';
echo $procategorydata['value'];
echo '======';
}
No comments:
Post a Comment