display attribute values on category page in magento
I have a Brand
attribute (dropdown) that I created for products. The dropdown for this attribute displays 5 to 6 brands.
What I want is to display the attribute value of brand
in the category page, and the value should be related only to those products which are currently displayed in 开发者_运维知识库the category page. So, if six products are displayed, then six brands should be displayed, selected by the admin.
In the template catalog/product/list.phtml
, near the top, there is a line like this:
<?php $_productCollection=$this->getLoadedProductCollection() ?>
This collection contains all the product objects that will be displayed on the page. If you want to echo those onto the page, do something like this:
<?php foreach($_productCollection as $_product) {
print $_product->getBrand();
} ?>
You will want to make sure that your brand attribute has been configured to set "Used in Product Listing" to "Yes". That will make sure that the attribute is loaded.
Hope that helps!
Thanks, Joe
精彩评论