In Magento 2.2.5, I have Custom Model Collection (followed this tutorial).

In that I want to add the Product Collection into this custom collection by default. How to achieve this.


1 Answer 1


You can override

Magento\Catalog\Model\ResourceModel\Product\Collection class and join your custom collection with using _initSelect() function


protected function _initSelect()
    $this->getSelect()->joinRight(['secondTable' => $this->getTable('custom_table')],'secondTable.id = main_table.entity_id');
    return $this;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.