I am trying to get a list of colors for the simple products in my store without showing the disabled ones. My function gives me all of the colors of products that are disabled or not.
public function getSimpleColors($productId){
$product = Mage::getModel('catalog/product')->load($productId);
$configurable= Mage::getModel('catalog/product_type_configurable')->setProduct($product);
$simpleCollection = $configurable->getUsedProductCollection()->addAttributeToSelect('*')->addFilterByRequiredOptions();
$colors=array();
foreach($simpleCollection as $simpleProduct){
$colors[]= $simpleProduct->getAttributeText('color');
}
$colors=array_unique($colors);
return $colors;
}