Magento的:getAttributeText('制造商')不工作 [英] Magento: getAttributeText('manufacturer') doesn't work
问题描述
我非常AP preciate你的帮助。我是新来的Magento和探索它的可能性。我有这块code,它从加载类的产品及其属性:
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; ?>
我的问题是:为什么回声$ _product-> getAttributeText('制造商')是不是在这里工作?我曾尝试与不同的code无数的变种,但厂商参数只是不露面。你知道为什么吗?
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?
推荐答案
我曾尝试亚当莫斯曾建议,它的工作:
I have tried what Adam Moss has suggested and it worked:
在管理员的属性编辑器中设置为yes。然后回声$ _product-> getAttributeText('制造商')的工作没有任何问题。
'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.
这篇关于Magento的:getAttributeText('制造商')不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!