please try this.....................
$Collection=Mage::getModel('catalog/product')->getCollection() ->addAttributeToSelect('vendor')->groupByAttribute('vendor');
foreach($Collection as $each)
{
echo "<br/>".$each['vendor'];
}
Pergunta
In Magento I setup a product attribute called "Vendor"(Text Field type). I would like to get the unique collection of all vendor's values.
Solução
please try this.....................
$Collection=Mage::getModel('catalog/product')->getCollection() ->addAttributeToSelect('vendor')->groupByAttribute('vendor');
foreach($Collection as $each)
{
echo "<br/>".$each['vendor'];
}
Outras dicas
$attribute_value = $product->getVendor();
//for vendor attribute(type text field)
UNIQUE ATTRIBUTE
// 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));