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();

          ->join(array('alise' => $collection->getTableName('foobar/foobar'))  ,'main_table.entity_id = alise.entity_id', array('party_name' => 'name'));
    return parent::_prepareCollection();

try this code in your module/block/adminhtml/module/grid.php

  • 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')); Mar 25, 2014 at 23:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.