I need to retrieve a list of all values which are used for a specific product attribute, in (pseudo) SQL:
SELECT DISTINCT attribute FROM products;
How would I use the Magento ORM to generate an equivalent query? I've tried the distinct()
function but it doesn't perform as I'd expect:
// Returns an array of NULL with a length equal to all products in the catalog
Mage::getModel('catalog/product')->getCollection()
->addAttributeToSelect('attribute')
->distinct(true)
->getColumnValues('attribute');
What I'm working to get would be an array of attribute
values, without duplicates
array('some value', 'some other value', 'a really common value', 'etc...');