I have a grid in admin set up like so:
enter image description here
It's pulling data from MySQL table "party."
I'd like the column called "Real Party ID" to pull its value from another table, "foobar"
How can I achieve this result?
Let me know if you need more details or pieces of my code.
1 Answer 1
protected function _prepareCollection()
{
 $collection = Mage :: getModel('module/module')->getCollection();
 $collection->getSelect()
 ->join(array('alise' => $collection->getTableName('foobar/foobar')) ,'main_table.entity_id = alise.entity_id', array('party_name' => 'name'));
 $this->setCollection($collection);
 return parent::_prepareCollection();
 }
try this code in your module/block/adminhtml/module/grid.php
 answered Mar 25, 2014 at 22:33
 
 
 
 MeenakshiSundaram R 
 
 9,5977 gold badges35 silver badges56 bronze badges
 
 - 
 Thanks! This works great for me. I'd upvote the answer if I had enough reputation :) For anyone interested, here is the code I ended up using:$collection->getSelect()->joinLeft(array('party_details' => 'party_details'), 'main_table.party_id = party_details.partyid', array('party_real_id' => 'partyid'));123– 1232014年03月25日 23:37:54 +00:00Commented Mar 25, 2014 at 23:37
default