I made this query to show related products by Manufacturer.
It works perfectly with simple products, but it shows configurable products that are not available.
I would like to show only available configurable products in that list.
$manu = $product->getManufacturer();
$brand_name = $product->getAttributeText('manufacturer');
$brand = Mage::getSingleton('catalog/product')
->getCollection()
->addAttributeToSelect('*')
->addAttributeToFilter('visibility', array(
Mage_Catalog_Model_Product_Visibility::VISIBILITY_BOTH,
Mage_Catalog_Model_Product_Visibility::VISIBILITY_IN_CATALOG
))
->addAttributeToFilter('manufacturer', $manu)
->addAttributeToFilter('is_in_stock', 1)
->addAttributeToFilter('qty', array("gt" => 0))
->addAttributeToFilter('status', 1)
->setOrder('updated_at','DESC')
->setPageSize(5);
Mage::getModel('cataloginventory/stock')->addInStockFilterToCollection($brand);
if ($product) {
$brand->addAttributeToFilter('entity_id', array(
'neq' => Mage::registry('current_product')->getId())
);
}