Pregunta

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.

¿Fue útil?

Solución

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

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

Otros consejos

$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));
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top