7 replaced http://magento.stackexchange.com/ with https://magento.stackexchange.com/
source | link

Suppose I have an attribute that is a collection of option (dropdown/multiselect).

I can retrieve the attribute value for a given product:

$store_id = [something];
$productId = [something];
// this is a select/multiselect
$attribute_code = [something]; 

$option_id = Mage::getResourceModel('catalog/product')->getAttributeRawValue($productId, $attribute_code, $store_id );
$option_label = ???

Now, I got the attribute option_id which is a numeric value ...

... What is the best way to load the frontend attribute label for my attribute value ? (without loading the full product)

Solution thanks MariusMarius:

// Not loading the product - just creating a simple instance
$product = Mage::getModel('catalog/product')
->setStoreId($store_id)
->setData($attribute_code,$option_id); 
$option_label = $product->getAttributeText($attribute_code);

Suppose I have an attribute that is a collection of option (dropdown/multiselect).

I can retrieve the attribute value for a given product:

$store_id = [something];
$productId = [something];
// this is a select/multiselect
$attribute_code = [something]; 

$option_id = Mage::getResourceModel('catalog/product')->getAttributeRawValue($productId, $attribute_code, $store_id );
$option_label = ???

Now, I got the attribute option_id which is a numeric value ...

... What is the best way to load the frontend attribute label for my attribute value ? (without loading the full product)

Solution thanks Marius:

// Not loading the product - just creating a simple instance
$product = Mage::getModel('catalog/product')
->setStoreId($store_id)
->setData($attribute_code,$option_id); 
$option_label = $product->getAttributeText($attribute_code);

Suppose I have an attribute that is a collection of option (dropdown/multiselect).

I can retrieve the attribute value for a given product:

$store_id = [something];
$productId = [something];
// this is a select/multiselect
$attribute_code = [something]; 

$option_id = Mage::getResourceModel('catalog/product')->getAttributeRawValue($productId, $attribute_code, $store_id );
$option_label = ???

Now, I got the attribute option_id which is a numeric value ...

... What is the best way to load the frontend attribute label for my attribute value ? (without loading the full product)

Solution thanks Marius:

// Not loading the product - just creating a simple instance
$product = Mage::getModel('catalog/product')
->setStoreId($store_id)
->setData($attribute_code,$option_id); 
$option_label = $product->getAttributeText($attribute_code);
6 fix english syntax
source | link

SupposeISuppose I have an attribute that is a collection of option (dropdown/multiselect).

I can retrieve the attribute value for a given product:

$store_id = [something];
$productId = [something];
// this is a select/multiselect
$attribute_code = [something]; 

$option_id = Mage::getResourceModel('catalog/product')->getAttributeRawValue($productId, $attribute_code, $store_id );
$option_label = ???

Now, I got the attribute option_id value but thiswhich is a numeric value ...

... What is the best way to load the frontend attribute label for my attribute value ? ( withoutwithout loading the full product  )

Solution thanks @MariusMarius:

// Not loading the product - just creating a simple instance
$product = Mage::getModel('catalog/product')
->setStoreId($store_id)
->setData($attribute_code,$option_id); 
$option_label = $product->getAttributeText($attribute_code);

SupposeI have an attribute that is a collection of option (dropdown/multiselect).

I can retrieve the attribute value for a given product:

$store_id = [something];
$productId = [something];
// this is a select/multiselect
$attribute_code = [something]; 

$option_id = Mage::getResourceModel('catalog/product')->getAttributeRawValue($productId, $attribute_code, $store_id );
$option_label = ???

Now I got the attribute option_id value but this is a numeric value ...

... What is the best way to load the frontend attribute label for my attribute value ? ( without loading the full product  )

Solution thanks @Marius:

// Not loading the product - just creating a simple instance
$product = Mage::getModel('catalog/product')
->setStoreId($store_id)
->setData($attribute_code,$option_id); 
$option_label = $product->getAttributeText($attribute_code);

Suppose I have an attribute that is a collection of option (dropdown/multiselect).

I can retrieve the attribute value for a given product:

$store_id = [something];
$productId = [something];
// this is a select/multiselect
$attribute_code = [something]; 

$option_id = Mage::getResourceModel('catalog/product')->getAttributeRawValue($productId, $attribute_code, $store_id );
$option_label = ???

Now, I got the attribute option_id which is a numeric value ...

... What is the best way to load the frontend attribute label for my attribute value ? (without loading the full product)

Solution thanks Marius:

// Not loading the product - just creating a simple instance
$product = Mage::getModel('catalog/product')
->setStoreId($store_id)
->setData($attribute_code,$option_id); 
$option_label = $product->getAttributeText($attribute_code);
5 deleted 261 characters in body; edited title
source | link

How can Ito get attribute 'option label',"option label/attribute text" having attribute value"attribute value" (option_id)?

SupposeSupposeI have an attribute that is a collection of option (dropdown/multiselect).

I load mycan retrieve the attribute value in this wayfor a given product:

$store_id = 1[something];
$productId ;= [something];
$brand_value// this is a select/multiselect
$attribute_code = [something]; 

$option_id = Mage::getResourceModel('catalog/product')->getAttributeRawValue($product->getId()$productId, 'brand'$attribute_code, $store_id );
brand_label$option_label = $brand_value ???

Now I got numeric value $brand_value for the given attribute and sooption_id value but this is a numeric value ...  

... What is the best way to load the frontend attribute label for my attribute value ? ( without loading the full product )

Solution thanks @Marius:

// Not loading the product - just creating a simple instance
$product = Mage::getModel('catalog/product')
->setStoreId($store_id)
->setBrand($brand_value); 
$brandLabel = $product->getAttributeText('brand');

So if you already got a product object

$brand_value_id = Mage::getResourceModel('catalog/product')->getAttributeRawValue($product->getId>setData(), 'brand'$attribute_code, $store_id$option_id);

// not loading the product - just creating a simple instance
    $brandLabel$option_label = $product
        ->setStoreId($store_id)
        ->setBrand($brand_value_id)
        ->getAttributeText('brand'$attribute_code);

    echo $product->getId() . ':' . $brand_value_id . ':' . $brandLabel . '<br>';

How can I get attribute 'option label', having attribute value?

Suppose I load my attribute value in this way:

$store_id = 1 ;
$brand_value = Mage::getResourceModel('catalog/product')->getAttributeRawValue($product->getId(), 'brand', $store_id );
brand_label = $brand_value ???

Now I got numeric value $brand_value for the given attribute and so ...  

... What is the best way to load the frontend attribute label for my attribute value ? ( without loading the full product )

Solution thanks @Marius:

// Not loading the product - just creating a simple instance
$product = Mage::getModel('catalog/product')
->setStoreId($store_id)
->setBrand($brand_value); 
$brandLabel = $product->getAttributeText('brand');

So if you already got a product object

$brand_value_id = Mage::getResourceModel('catalog/product')->getAttributeRawValue($product->getId(), 'brand', $store_id);

// not loading the product - just creating a simple instance
    $brandLabel = $product
        ->setStoreId($store_id)
        ->setBrand($brand_value_id)
        ->getAttributeText('brand');

    echo $product->getId() . ':' . $brand_value_id . ':' . $brandLabel . '<br>';

How to get attribute "option label/attribute text" having "attribute value" (option_id)?

SupposeI have an attribute that is a collection of option (dropdown/multiselect).

I can retrieve the attribute value for a given product:

$store_id = [something];
$productId = [something];
// this is a select/multiselect
$attribute_code = [something]; 

$option_id = Mage::getResourceModel('catalog/product')->getAttributeRawValue($productId, $attribute_code, $store_id );
$option_label = ???

Now I got the attribute option_id value but this is a numeric value ...

... What is the best way to load the frontend attribute label for my attribute value ? ( without loading the full product )

Solution thanks @Marius:

// Not loading the product - just creating a simple instance
$product = Mage::getModel('catalog/product')
->setStoreId($store_id)
->setData($attribute_code,$option_id); 
$option_label = $product->getAttributeText($attribute_code);
4 edited title
| link
    Tweeted twitter.com/#!/StackMagento/status/384926202089447424
3 added 484 characters in body
source | link
2 added 267 characters in body
source | link
1
source | link