I have a table for my custom module with following columns:
---------------
| custom_table|
---------------
| id
| seller_id
| buyer_id
| ...
---------------
seller_id -> customer_enity [entity_id]
buyer_id -> customer_entity [entity_id]
Now i would like to show the seller name and buyer name in admin grid layout. I couldn’t figure out how to retrieve the seller name and buyer name from the customer entities. But i know how to retrieve their emails as:
protected function _prepareCollection()
{
$collection = Mage::getModel('custommodule/custommodule')->getCollection();
$collection->getSelect()
->join( array('ce1' => 'customer_entity'), 'ce1.entity_id=main_table.seller_id', array('seller_email' => 'email'))
->join( array('ce2' => 'customer_entity'), 'ce2.entity_id=main_table.buyer_id', array('buyer_email' => 'email'));
#echo $collection->getSelect()->__toString();
$this->setCollection($collection);
return parent::_prepareCollection();
}
This above code works fine. But i want to display their names instead of email. Can any body help me to modify this collection?
Any help is very much appreciated. Thanks
You need to join with customer_entity_varchar table where the name is store,
and the attribute_id = 5, 5 because it is the id of the attribute name in the table eav_attribute where all attributes are store
hope it help you
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With