1

I have an attribute with the name "staerke" and a few option fields like 1mm, 2mm, 3mm and so on.

I know the attribute id of the attribute and i have the id of the option value. In my case the attribute "staerke" has the attribut-id 267 and the value for "5mm" has the id 239.

How can i get the value text of 5mm in my code when i have the id 239.

This is my code to get the id 239 ($thicknessId)

$newProduct = Mage::getModel('catalog/product')->load($newProductId);
$thicknessId = $newProduct->getData('staerke');

My last problem is to get the value "5mm" back from this id.

3 Answers 3

0

You can get the value directly with :

$_staerke = Mage::helper('catalog/output')->productAttribute($newProduct, $newProduct->getAttributeText('staerke'), 'staerke');
0
0

Try this:

1. $attributeText = $product->getAttributeText('staerke');

2. $attributeText = $product->getResource()->getAttribute('staerke')->getFrontend()->getValue($product);

3. $attributeText = $product->getResource()->getAttribute('staerke')->getFrontend()->getAttribute()->getFrontendLabel();
0

Since you've loaded your product already, you can use $thicknessId = $newProduct->getAttributeText('staerke') to get the label of the value.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.