Model/ResourceModel/Catalog/Collection.php
public function getProductsToExportByStore($store, $limit)
    {
        $connectorCollection = $this;
        $connectorCollection->addFieldToFilter(
            ['imported', 'modified'],
            [
                ['null' => 'true'],
                ['eq' => '1']
            ]
        );
        $connectorCollection->getSelect()->limit($limit);
        $connectorCollection->setOrder(
            'product_id',
            'asc'
        );

        //check number of products
        if ($connectorCollection->getSize()) {
            $productIds = $connectorCollection->getColumnValues('product_id');

            $productCollection = $this->productCollection->create()
                ->addAttributeToSelect('*')
                ->addAttributeToFilter(
                    'entity_id',
                    ['in' => $productIds]
                )->addUrlRewrite();

            if (!empty($store)) {
                $productCollection->addStoreFilter($store);
            }

            //visibility filter
            if ($visibility = $this->helper->getWebsiteConfig(
                \Dotdigitalgroup\Email\Helper\Config::XML_PATH_CONNECTOR_SYNC_CATALOG_VISIBILITY
            )
            ) {
                $visibility = explode(',', $visibility);
                //remove the default option from values
                $visibility = array_filter($visibility);
                $productCollection->addAttributeToFilter(
                    'visibility',
                    ['in' => $visibility]
                );
            }
            //type filter
            if ($type = $this->helper->getWebsiteConfig(
                \Dotdigitalgroup\Email\Helper\Config::XML_PATH_CONNECTOR_SYNC_CATALOG_TYPE
            )
            ) {
                $type = explode(',', $type);
                $productCollection->addAttributeToFilter(
                    'type_id',
                    ['in' => $type]
                );
            }

            $productCollection->addWebsiteNamesToResult()
                ->addCategoryIds()
                ->addOptionsToResult();

            $productCollection->clear();

            return $productCollection;
        }

        return [];
    }
public function getProductsToExportByStore($store, $limit)
    {
        $connectorCollection = $this;
        $connectorCollection->addFieldToFilter(
            ['imported', 'modified'],
            [
                ['null' => 'true'],
                ['eq' => '1']
            ]
        );
        $connectorCollection->getSelect()->limit($limit);
        $connectorCollection->setOrder(
            'product_id',
            'asc'
        );

        //check number of products
        if ($connectorCollection->getSize()) {
            $productIds = $connectorCollection->getColumnValues('product_id');

            $productCollection = $this->productCollection->create()
                ->addAttributeToSelect('*')
                ->addAttributeToFilter(
                    'entity_id',
                    ['in' => $productIds]
                )->addUrlRewrite();

            if (!empty($store)) {
                $productCollection->addStoreFilter($store);
            }

            //visibility filter
            if ($visibility = $this->helper->getWebsiteConfig(
                \Dotdigitalgroup\Email\Helper\Config::XML_PATH_CONNECTOR_SYNC_CATALOG_VISIBILITY
            )
            ) {
                $visibility = explode(',', $visibility);
                //remove the default option from values
                $visibility = array_filter($visibility);
                $productCollection->addAttributeToFilter(
                    'visibility',
                    ['in' => $visibility]
                );
            }
            //type filter
            if ($type = $this->helper->getWebsiteConfig(
                \Dotdigitalgroup\Email\Helper\Config::XML_PATH_CONNECTOR_SYNC_CATALOG_TYPE
            )
            ) {
                $type = explode(',', $type);
                $productCollection->addAttributeToFilter(
                    'type_id',
                    ['in' => $type]
                );
            }

            $productCollection->addWebsiteNamesToResult()
                ->addCategoryIds()
                ->addOptionsToResult();

            $productCollection->clear();

            return $productCollection;
        }

        return [];
    }
public function getProductsToExportByStore ( $ store , $ limit ) { $ connectorCollection = $ this ; $ connectorCollection -> addFieldToFilter ( [ 'imported' , 'modified' ] , [ [ 'null' => 'true' ] , [ 'eq' => '1' ] ] ) ; $ connectorCollection -> getSelect ( ) -> limit ( $ limit ) ; $ connectorCollection -> setOrder ( 'product_id' , 'asc' ) ; //check number of products if ( $ connectorCollection -> getSize ( ) ) { $ productIds = $ connectorCollection -> getColumnValues ( 'product_id' ) ; $ productCollection = $ this -> productCollection -> create ( ) -> addAttributeToSelect ( '*' ) -> addAttributeToFilter ( 'entity_id' , [ 'in' => $ productIds ] ) -> addUrlRewrite ( ) ; if ( ! empty ( $ store ) ) { $ productCollection -> addStoreFilter ( $ store ) ; } //visibility filter if ( $ visibility = $ this -> helper -> getWebsiteConfig ( \ Dotdigitalgroup \ Email \ Helper \ Config :: XML_PATH_CONNECTOR_SYNC_CATALOG_VISIBILITY ) ) { $ visibility = explode ( ',' , $ visibility ) ; //remove the default option from values $ visibility = array_filter ( $ visibility ) ; $ productCollection -> addAttributeToFilter ( 'visibility' , [ 'in' => $ visibility ] ) ; } //type filter if ( $ type = $ this -> helper -> getWebsiteConfig ( \ Dotdigitalgroup \ Email \ Helper \ Config :: XML_PATH_CONNECTOR_SYNC_CATALOG_TYPE ) ) { $ type = explode ( ',' , $ type ) ; $ productCollection -> addAttributeToFilter ( 'type_id' , [ 'in' => $ type ] ) ; } $ productCollection -> addWebsiteNamesToResult ( ) -> addCategoryIds ( ) -> addOptionsToResult ( ) ; $ productCollection -> clear ( ) ; return $ productCollection ; } return [ ] ; }
Get product collection to export.

@param null|string|bool|int|\Magento\Store\Model\Store $store
@param int $limit

@return \Magento\Catalog\Model\ResourceModel\Product\Collection|array
Get product collection to export .