Joining Custom Table with EAV Table in Magento 1.8

magento-1.8

I am New to the Magento, I am using the Magento 1.8.
I am stucked while prepare collection function in custom admin module while adding values to the grid.

I have custom table called foundation [not a EAV table] their are 3 fields

|foundation_id | store_id | member_email|
I want to join it with inbuilt EAV table core_store_group

My prepareCollection Function is as follows

$collection = Mage::getModel('core/store_group')->getCollection()
->addFilter('website_id',2)
->addFilter('root_category_id',3);
$collection->getSelect()->join(Mage::getConfig()
->getTablePrefix().'foundation', 'core_store_group.group_id ='.Mage::getConfig()
->getTablePrefix().'foundation.store_id',array('member_email'));
$this->setCollection($collection);
parent::_prepareCollection();
return $this;

I am getting the following Error
SQLSTATE[42S22]: Column not found: 1054 Unknown column 'core_store_group.group_id' in 'on clause'

Best Answer

First of all the core_store_group table is not EAV.
But that's not important Try this:

$collection = Mage::getModel('core/store_group')->getCollection()
    ->addFilter('website_id',2)
    ->addFilter('root_category_id',3);
$collection->getSelect()->join(
            array('foundation' => $collection->getTable('[module]/foundation')),
            'main_table.group_id = foundation.store_id',
            array('member_email')
);
$this->setCollection($collection);
parent::_prepareCollection();
return $this;

Just replace [module] with your modulename in lowercase.