我有一个制造商id,我想获得制造商名称。我怎样才能得到它呢?
如何从制造商id获取制造商名称?
$brandid=$_REQUEST['brand-id'];
$collection = Mage::getModel('catalog/product')->getCollection();
$collection->addAttributeToSelect('*');
代码
$brandid=$_REQUEST['brand-id'];
$attribute_code= //manufaute attribute code
Mage::getSingleton("eav/config")->getAttribute("catalog_product", $attribute_code);
$options = $attribute_details->getSource()->getAllOptions(false);
foreach($options as $option){
// print_r($option) and find all the elements
echo $option["value"]; echo $option["label"];
if($brandid==$option["value"]):
echo $option["label"];
endif;
}
如果这是从设置为下拉菜单的属性中检索的,并且您的属性是brand-id
,您将使用如下内容:
$collection->getAttributeText('brand-id')
来检索与下拉框id相关联的属性文本,否则在查询属性值时通常会返回。