How two Join Two Custom Tables in Magento?

Magento join two tables:  To join two custom table in the database you need to add specific query with table to get the desired result. Here is the code that will impart solution for joining two tables in Magento.

Magento Join Two Custom Tables Syntax:

$collection = Mage::getModel('module/model_name')->getCollection();
'table_name_for_join', 'main_table.your_table_field ='.Mage::getConfig()

Magento Join Two Custom Tables Example:

$collection = Mage::getModel('sales/order')->getCollection();
$collection->getSelect()->join( array('order_item'=> 'sales_flat_order_item'),
'order_item.order_id = main_table.entity_id',

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *