Tôi đã nhận được tất cả các giá trị thuộc tính thả xuống theo cách này
<select class=" required-entry required-entry select" name="product[age]" id="age">
<?php
$attributeId = Mage::getResourceModel('eav/entity_attribute')->getIdByCode('catalog_product','age');
$attribute = Mage::getModel('catalog/resource_eav_attribute')->load($attributeId);
$attributeOptions = $attribute->getSource()->getAllOptions();
foreach($attributeOptions as $each){?>
<option value="<?php echo $each[value]?>"><?php echo $each["label"]?></option><?php
}
}?>
</select>
Ở đây thuộc tính Id = tuổi. Bây giờ tôi đã lưu trữ một số giá trị trong cơ sở dữ liệu nên được chọn
Xin hãy giúp tôi cho điều này Cảm ơn trước
Ngoài ra tôi đã sử dụng trong mã này
<select class=" required-entry required-entry select" name="product[age]" id="age">
<?php $productId = $this->getProduct()->getId();
$product = Mage::getModel('catalog/product')->setStoreId(Mage::app()->getStore()->getId())->load($productId);
$selectedvalue = $product->getAttributeText('age');
$atributeCode = 'age';
$attribute = Mage::getModel('eav/config')->getAttribute('catalog_product',$atributeCode);
$options = $attribute->getSource()->getAllOptions();
foreach($options as $key => $value){
if(in_array($selectedvalue,$value)){
?>
<option>
<?php echo $value['label'] ; ?>
</option><?php
continue;
}
?>
<option>
<?php echo $value['label']; ?>
</option><?php
}?>
</option>
</select>
nó cũng hiển thị tất cả giá trị thuộc tính không được tô sáng giá trị được chọn

