Megento- Get product attribute drop-down by attibute id
<select name="attribute_name">
<option value="">Color</option>
<?php
$attribute_id = 148;
$valuesCollection = Mage::getResourceModel('eav/entity_attribute_option_collection')
->setAttributeFilter($attribute_id)
->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();
?>
<option value="<?php echo $procategorydata['option_id'] ?>"><?php echo $procategorydata['value'] ?></option>
<?php
}
?>
</select>
<select name="attribute_name">
<option value="">Color</option>
<?php
$attribute_id = 148;
$valuesCollection = Mage::getResourceModel('eav/entity_attribute_option_collection')
->setAttributeFilter($attribute_id)
->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();
?>
<option value="<?php echo $procategorydata['option_id'] ?>"><?php echo $procategorydata['value'] ?></option>
<?php
}
?>
</select>
No comments:
Post a Comment