Mohd Riaz
Mohd Riaz

Reputation: 23

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

Upvotes: 1

Views: 2862

Answers (1)

Amit Bera
Amit Bera

Reputation: 7611

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.

Upvotes: 2

Related Questions