Magento: getAttributeText not working

I have a drop-down attribute called "Housing" (the attribute code is "housing"). I want to get the text of the selected option for the product, but the getAttributeText function returns nothing.

My code is:

$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 getHousing function returns the correct parameter identifier, but "getAttributeText" and "getHousingText" returns nothing.

Any ideas why?

+6
source share
2 answers

to try

 $prod = Mage::getModel('catalog/product')->load($productId); $housing = $prod->getResource()->getAttribute('housing')->getFrontend()->getValue($prod); echo $housing; 
+17
source

Try using the following code:

 $product_object->getData('housing') 
+1
source

Source: https://habr.com/ru/post/902094/


All Articles