顯示的顏色和大小的屬性,我有一個工作代碼在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>';
$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>';
它正在與製造商。但不適用於大小和顏色屬性。謝謝。
有兩個問題:它們是什麼類型的產品屬性? (文本,下拉等)另外,你可以發佈代碼,你試圖獲取大小和顏色屬性的值嗎? – Jason 2013-08-08 16:12:11