Skip to content
Advertisement

Magento joining 2 tables

I want to join admin table and another profile table in magento how should I do this?

I want to join $userModel = Mage::getModel('admin/user'); table and

$vendorModel = Mage::getModel('vendorprofile/vendor');

Advertisement

Answer

Riaz.try the below code —

           $collection = Mage::getModel('admin/user')->getCollection();
    /* start inner join .vendorprofiletable is the 
Mage::getModel('vendorprofile/vendor') module table */
          $collection->getSelect()->join( array('vendorprofile'=> 'vendorprofiletable'), 
        'vendorprofile.vendor_id = main_table.entity_id', array('*'));

Here suppose vendorprofile.vendor_id = main_table.entity_id is the relation between two tables.

if you want to get query of join then echo $collection->getSelect();

Hope it will be help you.

1 People found this is helpful
Advertisement