cancel
Showing results for 
Search instead for 
Did you mean: 

Can I join ProductCollection on my Custom Collection

Can I join ProductCollection on my Custom Collection

I have a Custom Model, ResourceModel and Collection, with a separate MySQL Table: subscriptions

 

The subscriptions table has the following columns: id, name, product_id

 

Whenever I load my Collection, I get all the results from the database:

 

 

public function execute()
    {
        $subscription = $this->_subscriptionFactory->create();

        /** @var Subscription $item */
        foreach ($subscription as $item) {
            print_r($item->toArray());
        }

        exit();
    }

I'd like to "leftJoin" the products table on the product_id column from the subscriptions table. That's easily done with the left join, however I'd like to have all the EAV attributes from the product, so not just the SKU and Product ID.

 

How can one achieve such a thing?