Frage

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.

War es hilfreich?

Lösung

please try this.....................

 $Collection=Mage::getModel('catalog/product')->getCollection() ->addAttributeToSelect('vendor')->groupByAttribute('vendor');
    foreach($Collection as $each)
    {
    echo "<br/>".$each['vendor'];
    }

Andere Tipps

$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));
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top