Model/ResourceModel/Catalog.php
public function removeOrphanProducts()
    {
        $write = $this->getConnection();
        $catalogTable = $this->getTable(Schema::EMAIL_CATALOG_TABLE);
        $select = $write->select();
        $select->reset()
            ->from(
                ['c' => $catalogTable],
                ['c.product_id']
            )
            ->joinLeft(
                [
                    'e' => $this->getTable(
                        'catalog_product_entity'
                    ),
                ],
                'c.product_id = e.entity_id'
            )
            ->where('e.entity_id is NULL');

        //delete sql statement
        $deleteSql = $select->deleteFromSelect('c');

        //run query
        $write->query($deleteSql);
    }
public function removeOrphanProducts()
    {
        $write = $this->getConnection();
        $catalogTable = $this->getTable(Schema::EMAIL_CATALOG_TABLE);
        $select = $write->select();
        $select->reset()
            ->from(
                ['c' => $catalogTable],
                ['c.product_id']
            )
            ->joinLeft(
                [
                    'e' => $this->getTable(
                        'catalog_product_entity'
                    ),
                ],
                'c.product_id = e.entity_id'
            )
            ->where('e.entity_id is NULL');

        //delete sql statement
        $deleteSql = $select->deleteFromSelect('c');

        //run query
        $write->query($deleteSql);
    }
public function removeOrphanProducts ( ) { $ write = $ this -> getConnection ( ) ; $ catalogTable = $ this -> getTable ( Schema :: EMAIL_CATALOG_TABLE ) ; $ select = $ write -> select ( ) ; $ select -> reset ( ) -> from ( [ 'c' => $ catalogTable ] , [ 'c.product_id' ] ) -> joinLeft ( [ 'e' => $ this -> getTable ( 'catalog_product_entity' ) , ] , 'c.product_id = e.entity_id' ) -> where ( 'e.entity_id is NULL' ) ; //delete sql statement $ deleteSql = $ select -> deleteFromSelect ( 'c' ) ; //run query $ write -> query ( $ deleteSql ) ; }
Remove product with product id set and no product

@return null
Remove product with product id set and no product