简体   繁体   English

如何从magento检索自定义属性产品信息?

[英]How do I retrieve custom attribute product info from magento?

Im having some issues retrieving the firmness attribute for my magento product. 我在检索magento产品的硬度属性时遇到一些问题。

Im adding an additional box underneath the magento product image, where we can display the firmness of the mattress. 我在magento产品图片下方添加了一个额外的框,我们可以在其中显示床垫的坚固性。

在此处输入图片说明

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, 将此代码添加到模板目录中的addto.phtml文件中后,它会工作,并且回显197,这是我想要的,但是当我将其添加到模板目录中的media.phtml时,它不显示197,我不确定为什么,我认为它在从产品中提取信息时遇到问题,但是为什么它不能在addto.phtml中工作,而不能在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. 由于$ _product对象可以在media.phtml中启动,因此您也可以在media.phtml中使用以上代码。 Please check it out. 请检查一下。 Hope u are missing something. 希望你错过了一些东西。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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