Home

Wednesday, August 3, 2016

How to get value of Attribute Option in magento ?

<?php
require_once '../app/Mage.php';
umask(0) ;
Mage::app();

function getAttributeOptionValue($arg_attribute, $arg_value)
{
$attribute_model = Mage::getModel('eav/entity_attribute');
$attribute_options_model= Mage::getModel('eav/entity_attribute_source_table');  
$attribute_code = $attribute_model->getIdByCode('catalog_product', $arg_attribute);
$attribute = $attribute_model->load($attribute_code);
$attribute_table = $attribute_options_model->setAttribute($attribute);
$options = $attribute_options_model->getAllOptions(false);  
foreach($options as $option)
{
if ($option['label'] == $arg_value)
{
return $option['value'];
}
}  
return false;
}
echo $optionValue = getAttributeOptionValue("diamond_symmetry", "Very Good");
?>

No comments:

Post a Comment

rathoddhirendra.blogspot.com-Google pagerank and Worth