I have a dropdown attribute called "Housing" (attribute code "housing"). I want to get the text of the selected option for a product but the "getAttributeText" function returns nothing.
My code:
$product_object = Mage::getModel('catalog/product')->load($productId);
$housing = $product_object->getHousing();
echo $housing;
echo "<br>";
$housing = $product_object->getAttributeText('housing');
echo $housing;
echo "<br>";
$housing = $product_object->getHousingText();
echo $housing;
echo "<br>";
The function getHousing returns the correct option id but "getAttributeText" and "getHousingText" doesn't return anything.
Any ideas why?
try,
$prod = Mage::getModel('catalog/product')->load($productId);
$housing = $prod->getResource()->getAttribute('housing')->getFrontend()->getValue($prod);
echo $housing;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With