Magento - Show Custom Attributes in Grouped Product table.

Posted by greencoconut on Stack Overflow See other posts from Stack Overflow or by greencoconut
Published on 2009-06-17T06:23:28Z Indexed on 2010/03/11 21:09 UTC
Read the original article Hit count: 388

Filed under:
|
|
|

I need to find a way to show the value of a custom attribute in place of the "Product Name" shown in the image below.

Grouped products table

I'm working with /app/design/frontend/default/defaultx/template/catalog/product/view/type/grouped.php

The code below doesn't work(the custom attribute is yearmade):

<?php if (count($_associatedProducts)): ?>  
<?php foreach ($_associatedProducts as $_item): ?>  
    <tr>  
        <td><?php echo $this->htmlEscape($_item->getYearmade()) ?></td>

Any help would be appreciated.

EDIT: So the answer turned out to be quite simple. You see what I failed to mention above was that there was indeed output... but that it was just a number (eg: 52). Turns out this was the ID for that custom attribute value (It was a Dropdown type of custom attribute).

So in summary
This works for custom attributes of type text:

echo $this->htmlEscape($_item->getYearmade())

But for all other types of custom attribute (I think), the following should be used:

echo $this->htmlEscape($_item->getAttributeText('yearmade'))

I would not have discovered this without the most excellent answer provided by Alan Storm, below. Thank you sir.

© Stack Overflow or respective owner

Related posts about magento

Related posts about custom-attributes