Magento Get attribute options by attribute code without load by product


Hi Friends,

Get attribute option label by attribute code without product load

Here is code:

$store_id = 1;
$attribute_code = 'brand';
$attribute = Mage::getModel('eav/config')->getAttribute('catalog_product', $attribute_code);

foreach ( $attribute->getSource()->getAllOptions(true, true) as $option )
{
    $product = Mage::getModel('catalog/product')
        ->setStoreId($store_id)
        ->setData($attribute_code,$option['value']);
    $option_label = $product->getAttributeText($attribute_code);

    echo "Option Is is ".$option['value']." And Option Label is ".$option_label."<br>";
}


I hope this helpful to you :)

1 comment:

  1. Wonderful bloggers like yourself who would positively reply encouraged me to be more open and engaging in commenting.So know it's helpful.

    Hadoop Training in Chennai

    ReplyDelete