Magento获取当前产品的属性

时间:2015-09-18 08:01:24

标签: php magento

我对magento开发很新。在我的产品详细信息页面上,我添加了一个自定义选项卡以及其他信息,其中显示了特定属性(video_embed_code)的值。

我想在该标签中显示该属性的值。但是当我尝试在tabs.phtml文件中获取属性值时,它会给我带来致命的错误。

Fatal error: Call to a member function getAttributeText() on a non-object in ..

以下是我用来显示属性值的内容:

$video_code=$this->getProduct()->getAttributeText('video_embed_code');

我也试过

$video_code=$product->getAttributeText('video_embed_code');

但它给出了同样的致命错误。这里似乎有什么问题?

艾哈迈尔A。

2 个答案:

答案 0 :(得分:2)

你有没有尝试过?

response.write(ScriptEngine & "<br />")
response.write(ScriptEngineBuildVersion & "<br />")
response.write(ScriptEngineMajorVersion & "<br />")
response.write(ScriptEngineMinorVersion)

注意:在magento admin中编辑属性(video_embed_code)&amp;标记“是” 在“前端产品视图页面上可见”

答案 1 :(得分:2)

试试这个。

$video_code = Mage::registry('current_product')->getData('video_embed_code');
相关问题