Magento: getAttributeText ("producer") does not work

I am very grateful for your help. I am new to Magento and am exploring its possibilities. I have this piece of code that loads products from a 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 does "echo $ _product-> getAttributeText (" manufacturer ") not work here? I tried countless options with different code, but the manufacturer parameter just does not appear. Do you know why?

+4
source share
2 answers

I tried what Adam Moss suggested and it worked:

"Show in product list" must be set in the "Yes" field in the attribute editor in admin. Then echo $ _product-> getAttributeText ("producer") worked without problems.

+5
source

so I got this with the @Shawn_Northrop offer;

 <?php echo $_product->getData('my_custom_attribute'); ?> 

Good coding ...

0
source

Source: https://habr.com/ru/post/902095/


All Articles