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.

有帮助吗?

解决方案

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

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

其他提示

$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));
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top