1

Hi guys so I've opened my list.phtml file and located the code that displays the name attribute for the products displayed in my catalog.

Could someone possible show me how they would add an extra attribute to this?

I have an attribute named Manufacturer, I'm just wondering how I can call this attribute so I don't just have the name of the product I have the manufacturer.

Any help would be great, here's an example of my code:

<div class="details-area">
                        <h2 class="product-name"><a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->stripTags($_product->getName(), null, true) ?>"><?php echo $_helper->productAttribute($_product, $_product->getName(), 'name') ?></a></h2>
                        <?php if($_product->getRatingSummary()): ?>
                        <?php echo $this->getReviewsSummaryHtml($_product, 'short') ?>
                        <?php else: ?>
                            <div class="ratings">
                                <div class="rating-box">
                                    <div class="rating" style="width:0"></div>
                                </div>
                            </div>
                        <?php endif; ?>
                        <?php
                            if ($this->getChild('name.after')) {
                                $_nameAfterChildren = $this->getChild('name.after')->getSortedChildren();
                                foreach ($_nameAfterChildren as $_nameAfterChildName) {
                                    $_nameAfterChild = $this->getChild('name.after')->getChild($_nameAfterChildName);   $_nameAfterChild->setProduct($_product);
                                    echo $_nameAfterChild->toHtml();
                                }
                            }
                        ?>

1 Answer 1

2

First, make sure that the manufacturer attribute is set to "Used in Product Listing". Then, you can simply use something like this (I just added the third row):

<div class="details-area">
    <h2 class="product-name"><a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->stripTags($_product->getName(), null, true) ?>"><?php echo $_helper->productAttribute($_product, $_product->getName(), 'name') ?></a></h2>
    <div class="manufacturer"><?php echo $this->escapeHtml($_product->getAttributeText('manufacturer')); ?></div>
    <?php if($_product->getRatingSummary()): ?>
    <?php echo $this->getReviewsSummaryHtml($_product, 'short') ?>
    <?php else: ?>
        <div class="ratings">
            <div class="rating-box">
                <div class="rating" style="width:0"></div>
            </div>
        </div>
    <?php endif; ?>
    <?php
        if ($this->getChild('name.after')) {
            $_nameAfterChildren = $this->getChild('name.after')->getSortedChildren();
            foreach ($_nameAfterChildren as $_nameAfterChildName) {
                $_nameAfterChild = $this->getChild('name.after')->getChild($_nameAfterChildName);   $_nameAfterChild->setProduct($_product);
                echo $_nameAfterChild->toHtml();
            }
        }
    ?>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.