We can join eav table to flat table. Below is the example for joining the wishlist table to the customer's eav tables:
$wishlistCollection = Mage::getModel('wishlist/wishlist')->getCollection();
$wishlistCollection = Mage::helper('abc')->joinEavTablesIntoCollection($wishlistCollection, 'customer_id', 'customer');
echo $wishlistCollection->getSelect()->__toString();
After that in your helper file i.e "abc" create the below function:
public function joinEavTablesIntoCollection($collection, $mainTableForeignKey, $eavType){
$entityType = Mage::getModel('eav/entity_type')->loadByCode($eavType);
$attributes = $entityType->getAttributeCollection();
$entityTable = $collection->getTable($entityType->getEntityTable());
$index = 1;
foreach ($attributes->getItems() as $attribute){
$alias = 'table'.$index;
if ($attribute->getBackendType() != 'static'){
$table = $entityTable. '_'.$attribute->getBackendType();
$field = $alias.'.value';
$collection->getSelect()
->joinLeft(array($alias => $table),
'main_table.'.$mainTableForeignKey.' = '.$alias.'.entity_id and'.$alias.'.attribute_id = '.$attribute->getAttributeId(),
array($attribute->getAttributeCode() => $field)
);
}
$index++;
}
$collection>getSelect()>joinLeft($entityTable,'main_table.'.$mainTableForeignKey.' = '.$entityTable.'.entity_id');
return $collection;
}
This is the answer to the first part of your question.