Get Product attribute’s select option Id or Lable or Value in Magento
Suppose, you have an product attribute called “
manufacture” in Magento. You
have the label (e.g.
Acer), and you want to find it’s value. The below
code will help you get the value for it.
$_product = Mage::getModel('catalog/product');
$attr = $_product->getResource()->getAttribute("manufacture");
if ($attr->usesSource()) {
echo $manufacture = $attr->getSource()->getOptionId("acer");
}
it can be display select box option id of attribute's (value). it will display attributes value of select box.
$_product = Mage::getModel('catalog/product');
$attr = $_product->getResource()->getAttribute("
manufacture
");
if ($attr->usesSource()) {
echo $color_label = $attr->getSource()->getOptionText("28");
}
it can be display select box option label of attribute's (label). it will display attributes label of select box.
also you can count product in option value and option id.
you just add code of product count using option id.
No comments:
Post a Comment
Thank You For Comment