0

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.

asked Mar 25, 2014 at 21:56

1 Answer 1

2
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

123
4331 gold badge4 silver badges11 bronze badges
answered Mar 25, 2014 at 22:33
1
  • 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')); Commented Mar 25, 2014 at 23:37

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.