Coding

Magento: Magento left join collection Example

Following syntax is used for left joining two tables in magento :
 
 
//load collection 
$collection = Mage::getModel('module/model_name')->getCollection();
$collection->getSelect()->joinLeft(Mage::getConfig()->getTablePrefix().'table_to_be_joined','main_table.table_field ='.Mage::getConfig()->getTablePrefix().'table_to_be_joined.table_field',array('field_name'));

 
Magento left join two custom tables Example
 
$collection = Mage::getModel('sales/order')->getCollection();
$collection->getSelect()->joinLeft( array('order_item'=> 'sales_flat_order_item'), 'order_item.order_id = main_table.entity_id', array('order_item.sku'));
 

  

0 Bình luận

Trở về
  • HTML5 Canvas
  • HTML5 Canvas

     The <canvas> element is used to draw graphics, on the fly, on a web page. Draw a red rectangle, a gradient rectangle,...