Model/ResourceModel/Rules.php
public function joinTablesOnCollectionByType($collection, $type)
    {
        if ($type == \Dotdigitalgroup\Email\Model\Rules::ABANDONED) {
            $collection->getSelect()
                ->joinLeft(
                    ['quote_address' => $this->getTable('quote_address')],
                    'main_table.entity_id = quote_address.quote_id',
                    ['shipping_method', 'country_id', 'city', 'region_id']
                )->joinLeft(
                    ['quote_payment' => $this->getTable('quote_payment')],
                    'main_table.entity_id = quote_payment.quote_id',
                    ['method']
                )->where('address_type = ?', 'shipping');
        } elseif ($type == \Dotdigitalgroup\Email\Model\Rules::REVIEW) {
            $collection->getSelect()
                ->join(
                    ['order_address' => $this->getTable('sales_order_address')],
                    'main_table.entity_id = order_address.parent_id',
                    ['country_id', 'city', 'region_id']
                )->join(
                    ['order_payment' => $this->getTable('sales_order_payment')],
                    'main_table.entity_id = order_payment.parent_id',
                    ['method']
                )->where('order_address.address_type = ?', 'shipping');
        }

        return $collection;
    }
public function joinTablesOnCollectionByType($collection, $type)
    {
        if ($type == \Dotdigitalgroup\Email\Model\Rules::ABANDONED) {
            $collection->getSelect()
                ->joinLeft(
                    ['quote_address' => $this->getTable('quote_address')],
                    'main_table.entity_id = quote_address.quote_id',
                    ['shipping_method', 'country_id', 'city', 'region_id']
                )->joinLeft(
                    ['quote_payment' => $this->getTable('quote_payment')],
                    'main_table.entity_id = quote_payment.quote_id',
                    ['method']
                )->where('address_type = ?', 'shipping');
        } elseif ($type == \Dotdigitalgroup\Email\Model\Rules::REVIEW) {
            $collection->getSelect()
                ->join(
                    ['order_address' => $this->getTable('sales_order_address')],
                    'main_table.entity_id = order_address.parent_id',
                    ['country_id', 'city', 'region_id']
                )->join(
                    ['order_payment' => $this->getTable('sales_order_payment')],
                    'main_table.entity_id = order_payment.parent_id',
                    ['method']
                )->where('order_address.address_type = ?', 'shipping');
        }

        return $collection;
    }
public function joinTablesOnCollectionByType ( $ collection , $ type ) { if ( $ type == \ Dotdigitalgroup \ Email \ Model \ Rules :: ABANDONED ) { $ collection -> getSelect ( ) -> joinLeft ( [ 'quote_address' => $ this -> getTable ( 'quote_address' ) ] , 'main_table.entity_id = quote_address.quote_id' , [ 'shipping_method' , 'country_id' , 'city' , 'region_id' ] ) -> joinLeft ( [ 'quote_payment' => $ this -> getTable ( 'quote_payment' ) ] , 'main_table.entity_id = quote_payment.quote_id' , [ 'method' ] ) -> where ( 'address_type = ?' , 'shipping' ) ; } elseif ( $ type == \ Dotdigitalgroup \ Email \ Model \ Rules :: REVIEW ) { $ collection -> getSelect ( ) -> join ( [ 'order_address' => $ this -> getTable ( 'sales_order_address' ) ] , 'main_table.entity_id = order_address.parent_id' , [ 'country_id' , 'city' , 'region_id' ] ) -> join ( [ 'order_payment' => $ this -> getTable ( 'sales_order_payment' ) ] , 'main_table.entity_id = order_payment.parent_id' , [ 'method' ] ) -> where ( 'order_address.address_type = ?' , 'shipping' ) ; } return $ collection ; }
Join tables on collection by type.

@param Collection $collection
@param string $type

@return Collection
Join tables on collection by type .