Magento: getAttributeText ('manufacturer' )不起作用

标签 magento attributes

非常感谢您的帮助。我是 Magento 的新手,正在探索它的可能性。我有这段代码,它从类别及其属性加载产品:

<?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; ?>

我的问题是:为什么“echo $_product->getAttributeText('manufacturer')”在这里不起作用?我尝试了无数具有不同代码的变体,但制造商参数就是不显示。你知道为什么吗?

最佳答案

我已经尝试了 Adam Moss 的建议并且有效:

需要在管理中的属性编辑器中将“在产品列表中显示”设置为"is"。然后 echo $_product->getAttributeText('manufacturer') 工作没有任何问题。

关于Magento: getAttributeText ('manufacturer' )不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14321256/

相关文章:

PHP fatal error : Uncaught exception 'CredisException' with message 'Lost connection to Redis server

magento - 如何更新 magento 中的 XML_PATH_EMAIL_RECIPIENT 变量?

c# - 访问属性的最佳方式

javascript - 使用 jquery 或 javascript(单击)在 html 中设置工具提示的数据属性

javascript - 如何使用 JavaScript 定位 SVG 路径的属性?

Magento:从布局 xml 文件中设置ParentBlock?

php - Magento REST API 创建方法 - 资源方法未实现

php - Magento:显示子类别列表

jquery - 如何在 jquery 的输入标签中选择 'title' 属性?

c# - 如何全局应用Serialized属性?