2

我想在 Magento 产品页面中显示产品选项值。我试过这段代码:

<?php echo $_product->getAttributeText('color'); ?> 

但选项没有出现。

4

2 回答 2

0

如果您在实际的产品视图页面上,您可以使用帮助程序来获得您想要的内容:

echo $_helper->productAttribute($_product, $_product->getColor(), 'color');

或者

echo $_helper->productAttribute($_product, $_product->getData('attribute_code'), 'attribute_code');

或者你可以试试这个:

$_product->getResource()->getAttribute('color')->getFrontend()->getValue($_product);
于 2012-09-13T12:25:21.677 回答
0

你可以这个,

<?php $attributeValue = Mage::getModel('catalog/product')->load($_product->getId())->getColor();?>
于 2012-09-13T12:41:10.987 回答