0

我有一个工作代码

$cModel = Mage::getModel('catalog/product');
$cModel->load($_product->getId());

echo '<p>Product name :',$cModel->getData('name'),'</p>';
echo '<p>Manufacturer id :',$cModel->getData('manufacturer'),'</p>';

$attributes = Mage::getResourceModel('eav/entity_attribute_collection')
        ->setEntityTypeFilter($_product->getResource()->getTypeId())

        ->addFieldToFilter('attribute_code', 'manufacturer');
$attribute = $attributes->getFirstItem()->setEntity($_product->getResource());

echo '<p> Manufacturer :',$attribute->getSource()->getOptionText($cModel->getData('manufacturer')),'</p>';

它正在与制造商合作。但不适用于大小和颜色属性。谢谢你。

4

3 回答 3

1

在目录 -> 属性 -> 管理属性下,您必须确保提到的属性将其值设置为“用于产品列表”选项的“是”。

于 2012-07-16T11:01:05.010 回答
1

你试过<?php echo $_product->getAttributeText("color"); ?>吗?

于 2013-08-08T12:29:11.160 回答
0

如果您对属性使用下拉菜单,请在/template/catalog/product/view.phtml文件中添加以下代码

这将显示您的第一个属性

<?php if ($_product->isSaleable() && $this->hasOptions()):?>
<?php echo $this->getChildChildHtml('container1', '', true, true) ?>
<?php endif;?>

这将显示您的第二个属性(超过 1 个自定义属性)

<?php if ($_product->isSaleable() && $this->hasOptions()):?>
<?php echo $this->getChildChildHtml('container2', '', true, true) ?>
<?php endif;?>
于 2016-02-15T11:30:12.820 回答