Magento,如何在主题文件中调用产品属性?

I have been searching for a an answer to this for a roughly 2 days and I am just not finding much on this, hopefully some one here may be able to assist.

Basically I am looking to call a product attribute in a theme file eg: 2columns-right.phtml

While I realize this is not possible by default as attributes are available in front end: product, category & search pages, I am hoping some one may have done this before and could point me in the right direction.

The goal is the following:

I have a that contains a banner image on the product detail, what I would like to do is use a small script that checks against the "attribute" manufacturer, and display a banner that is related to the manufacturer name, so brand-x gets banner x, brand-y gets banner-x.

If there is no, image or the manufacturer is not set then it will use a default banner.

Quite a simple concept, but proving to be troublesome since I am unable to call the function outside of view.phtml

I am currently trying to use: $_product->getAttributeName(); works great on view.pthml, not so great outside the page.

As a last resort I thought to create a simple hack where I would just have the above mentioned div empty while retaining its size selectors and then use and image with an absolute position that is called from view.phtml and lives in the desired location.

This would easily handle what I aiming to achieve but I would prefer if I could find the proper method to get the desired result and with out changing core Mage files.

Thank you in advance!

查看全部
douhe4336
douhe4336
2011/05/02 16:01
  • php
  • mysql
  • magento
  • 点赞
  • 收藏
  • 回答
    私信
满意答案
查看全部

1个回复