Magento: getAttributeText('manufacturer') doesn't work
11,192
I have tried what Adam Moss has suggested and it worked:
'Show in Product Listing' needed to be set to yes in the attribute editor in admin. Then echo $_product->getAttributeText('manufacturer') worked without any problems.
Related videos on Youtube
Author by
Swip
Updated on June 05, 2022Comments
-
Swip almost 2 years
I would very much appreciate your help. I am new to Magento and exploring it's possibilities. I have this piece of code, which loads products from category and their attributes:
<?php $_productCollection=$this->getLoadedProductCollection(); $_helper = $this->helper('catalog/output'); ?> <?php if(!$_productCollection->count()): ?> <p class="note-msg"><?php echo $this->__('There are no products matching the selection.') ?></p> <?php else: ?> <div class="category-products"> <?php // Grid Mode ?> <?php $_collectionSize = $_productCollection->count() ?> <?php $_columnCount = $this->getColumnCount(); ?> <?php $_iterator = 0; ?> <ul class="products-grid"> <?php $i=0; foreach ($_productCollection as $_product): ?> <li class="item"> <a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" class="product-image"><img src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize(252); ?>" width="252" height="252" alt="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" /></a> <h3 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></h3> <h4 class="product-name"><?php echo $_product->getAttributeText('manufacturer') ?></h4> <?php echo $this->getPriceHtml($_product, true) ?> </li> <?php endforeach ?> </ul> <script type="text/javascript">decorateGeneric($$('ul.products-grid'), ['odd','even','first','last'])</script> </div> <?php endif; ?>
My question is: why "echo $_product->getAttributeText('manufacturer')" is not working here? I have tried countless variants with different code, but the manufacturer parameter just doesn't show up. Do you know why?
-
Adam Moss over 11 yearsAlso ensure that 'Show in Product Listing' is set to yes in the attribute editor.
-
-
ahnbizcad almost 7 yearsI set "used in product listing" to "yes", and it doesn't seem to pull
-
Shawn Northrop over 6 yearsI could not get this to work either, however, if I use $_product->getData('manufacturer') it seems to work