I am joining core_store_group with my custom table called foundation and I am Getting values also. My custom table contain 3 fields ID, STORE_ID, EMAIL Where ID is primary key and store_id is references to group_id of core_store_group table.
$collection = Mage::getModel('core/store_group')->getCollection()
->addFilter('website_id', 2);
$collection->getSelect()->join(
array('foundation' => $collection->getTable('foundation/foundation')),
'main_table.group_id = foundation.store_id');
$this->setCollection($collection);
parent::_prepareCollection();
return $this;
But whenever I foundation table contains records with same store_id example
id store_id member_email
1 2 man@gmail.com
2 11 man@gmail.com
3 2 man@gmail.com
I am getting error
Item (Mage_Core_Model_Store_Group) with the same id "2" already exist.
How can I get the records without error and I need to fetch the count of email id's present in the same store.