简体   繁体   中英

How do I retrieve custom attribute product info from magento?

Im having some issues retrieving the firmness attribute for my magento product.

Im adding an additional box underneath the magento product image, where we can display the firmness of the mattress.

在此处输入图片说明

I'm using this code:

<div class="image_box">
<?php 
    $firmness = $_product->getFirmness(); 
    echo $firmness; 

?>
</div>

This code works as I have added this to my addto.phtml file in my template directory, and it echos 197 which is what I wanted, but when I add it to media.phtml in my template directory, it doesn't display 197, and Im not sure why, I believe its having issues pulling the information from the product but why would it work in addto.phtml and not in media.phtml,

I've tried adding:

$_product = $this->getProduct();
$_helper = $this->helper('catalog/output');
$athleteHelper = Mage::helper('athlete');

but no look, any advice on what I need to add to help it pull the info ?

<?php 
$firmness = $_product->getFirmness(); 
echo $firmness; 
?>

Since, $_product object can be initiated within the media.phtml, You can use the above code in media.phtml also. Please check it out. Hope u are missing something.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM