Magento 2 Right Join Collection


Magento 2 Right Join Collection– It is very simple to right join two collections or two tables in Magento 2. Let us create a simple example to understand the right join query in Magento 2.


Magento 2 Right Join Collection Example

You can right join two or more than simply as below-

Magento 2 Right Join Collection Example:

$objectManager =  \Magento\Framework\App\ObjectManager::getInstance();
$collection = $objectManager->get('Magento\Sales\Model\Order')->getCollection();
$collection->getSelect()
->joinRight( array('order_item'=> 'sales_order_item'), 'order_item.order_id = main_table.entity_id', array('order_item.sku')); 

On the same way you can join any collection.


Advertisements

Add Comment

📖 Read More