$attribute = Mage::getModel('eav/entity_attribute')->load($attr);
$type=$attribute->getFrontendInput();
$attrLabel=$attribute->getFrontendLabel();
$attrName=$attribute->getAttributeCode();
//echo $attribute->getData($attrName);die;
if($type=='multiselect'){
$html.='<div class="field"><label for='.$attrName.'" class="required">'.$attrLabel.': </label><div class="input-box"><select multiple id="'.$attrName.'" name="product['.$attrName.'][]" >';
//$values=$attribute->getSource()->getAllOptions(true, true);
$values=$attribute->getAttributeText($attrName);
$attributeId = Mage::getResourceModel('eav/entity_attribute')->getIdByCode('catalog_product',$attrName);
$collection =Mage::getResourceModel('eav/entity_attribute_option_collection')
->setPositionOrder('asc')
->setAttributeFilter($attributeId)
->setStoreFilter(Mage::app()->getStore()->getId())
->load();
foreach($collection->toOptionArray() as $option){
$html.='<option value="'.$option['value'].'">'.$option['label'].'</option>';
}
$html.='</select></div></br>';
}
if($type=='select'){
$html.='<label for='.$attrName.'" class="required">'.$attrLabel.': </label><div class="input-box"><select id="'.$attrName.'" name="product['.$attrName.']" >';
$values=$attribute->getSource()->getAllOptions(true, true);
foreach($values as $option){
$html.='<option value="'.$option['value'].'">'.$option['label'].'</option>';
}
$html.='</select></div></br>';
}
if($type=='text') {
$html.='<label for='.$attrName.'" class="required">'.$attrLabel.'</label>: <div class="input-box"> <input id="'.$attrName.'" required type="'.$type.'" name="product['.$attrName.']" /></div></br>';
}
Comments
Post a Comment