在Magento产品页面中显示颜色和大小属性

在Magento产品页面中显示颜色和大小属性,magento,Magento,我有一个工作代码 $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>

我有一个工作代码

$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>';
$cModel=Mage::getModel('catalog/product');
$cModel->load($\u product->getId());
echo“产品名称:”,$cModel->getData('name'),“

”; echo“制造商id:”,$cModel->getData('Manufacturer'),“

”; $attributes=Mage::getResourceModel('eav/entity\u attribute\u collection') ->setEntityTypeFilter($\u product->getResource()->getTypeId()) ->addFieldToFilter(“属性代码”、“制造商”); $attribute=$attributes->getFirstItem()->setEntity($\u product->getResource()); 回显“Manufacturer:”,$attribute->getSource()->getOptionText($cModel->getData('Manufacturer'),“

”;

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

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

您是否尝试过

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

这将显示您的第一个属性

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

这将显示第二个属性(多于1个自定义属性)



我已经将产品清单中的Used设置为“Yes”。两个问题:它们是什么类型的产品属性?(文本、下拉列表等)此外,您是否可以发布代码,尝试获取尺寸和颜色属性的值?
<?php if ($_product->isSaleable() && $this->hasOptions()):?>
<?php echo $this->getChildChildHtml('container2', '', true, true) ?>
<?php endif;?>