Reading list Switch to dark mode

    How to Apply join in Collection in UI Component Grid in Magento 2

    Updated 23 February 2024

    Magento-Code-Snippet-5

    To create a grid using UI-component in magento 2, please refer following link:

    http://webkul.com/blog/how-to-create-a-grid-using-ui-component/

    To apply join in grid collection you need to add following code in your grid collection file, which is defined in :Webkul\Hello\etc\di.xml

    Add Your code in file:

    Webkul\Hello\Model\ResourceModel\Employee\Grid\Collection

    Searching for an experienced
    Magento 2 Company ?
    Find out More
    protected function _renderFiltersBefore() {
           	$joinTable = $this->getTable('customer_grid_flat');
            $this->getSelect()->join($joinTable.' as customer','main_table.entity_id = customer.entity_id', array('*'));
            parent::_renderFiltersBefore();
        }

    Here, $JoinTable: is table with which you want to apply join.
    main_table:  is your grid collection table.
    array(‘*’):  use for accessing all the fields of the table.

    If you want to select specific columns then add those column names in place of ‘*’ under array().

    like: array(‘firstname’=>’firstname’)

    I hope this blog will help you with How to Apply join in Collection in UI Component Grid in Magento 2. You may also check our wide range of best Magento 2 Extensions.

    Please reach out to our team via a support ticket if you have any queries.

    Try this and if you have any queries then just comment below 🙂

     

    . . .

    Leave a Comment

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


    Be the first to comment.

    Back to Top

    Message Sent!

    If you have more details or questions, you can reply to the received confirmation email.

    Back to Home