【发布时间】:2014-02-08 10:39:36
【问题描述】:
在 Magento 中,我设置了一个名为“供应商”(文本字段类型)的产品属性。 我想获得所有供应商值的唯一集合。
【问题讨论】:
在 Magento 中,我设置了一个名为“供应商”(文本字段类型)的产品属性。 我想获得所有供应商值的唯一集合。
【问题讨论】:
$attribute_value = $product->getVendor(); //对于供应商属性(类型文本字段)
独特属性
// specify the attribute code
$attributeCode = 'vendor';
// build and filter the product collection
$products = Mage::getResourceModel('catalog/product_collection')
->addAttributeToFilter($attributeCode, array('notnull' => true))
->addAttributeToFilter($attributeCode, array('neq' => ''))
->addAttributeToSelect($attributeCode);
// get all distinct attribute values
$usedAttributeValues = array_unique($products->getColumnValues($attributeCode));
【讨论】:
请试试这个...........
$Collection=Mage::getModel('catalog/product')->getCollection() ->addAttributeToSelect('vendor')->groupByAttribute('vendor');
foreach($Collection as $each)
{
echo "<br/>".$each['vendor'];
}
【讨论】: