我有来自Mukesh Chapagain的代码:链接到这里
$_product = Mage::getModel('catalog/product')->load(PRODUCT_ID);
$manufacturerName = $_product->getAttributeText('manufacturer');
$manufacturerId = $_product->getManufacturer();
Run Code Online (Sandbox Code Playgroud)
这似乎并没有让制造商接受,即使我把它们作为属性.是因为制造商领域是下拉列表吗?
任何获得制造商属性的帮助将不胜感激
$attribute = Mage::getModel('eav/config')->getAttribute('catalog_product', 'manufacturer');
foreach ( $attribute->getSource()->getAllOptions(true, true) as $option){
$attributeArray[$option['value']] = $option['label'];
}
foreach($attributeArray as $key=>$val){
echo $val;
}
Run Code Online (Sandbox Code Playgroud)
$collection = Mage::getModel('catalog/product')->getCollection();
$collection->addAttributeToSelect('manufacturer');
$collection->addFieldToFilter(array(
array('attribute' => 'manufacturer', 'eq' =>$designer_id),
));
Run Code Online (Sandbox Code Playgroud)
$_productCollection=$this->getLoadedProductCollection();
foreach ($_productCollection as $_product):
echo $_product->getAttributeText('manufacturer');
endforeach;
Run Code Online (Sandbox Code Playgroud)