Model/Newsletter/Subscriber.php
public function exportSubscribersPerWebsite($website)
    {
        $isSubscriberSalesDataEnabled = $this->helper->getWebsiteConfig(
            \Dotdigitalgroup\Email\Helper\Config::XML_PATH_CONNECTOR_ENABLE_SUBSCRIBER_SALES_DATA,
            $website
        );

        $updated = 0;
        $limit = $this->helper->getSyncLimit($website->getId());
        //subscriber collection to import
        $emailContactModel = $this->contactFactory->create();
        //Customer Subscribers
        $subscribersAreCustomers = $emailContactModel->getSubscribersToImport($website, $limit);
        //Guest Subscribers
        $subscribersAreGuest = $emailContactModel->getSubscribersToImport($website, $limit, false);
        $subscribersGuestEmails = $subscribersAreGuest->getColumnValues('email');
        $existInSales = [];
        //Only if subscriber with sales data enabled
        if ($isSubscriberSalesDataEnabled && ! empty($subscribersGuestEmails)) {
            $existInSales = $this->checkInSales($subscribersGuestEmails);
        }

        $emailsNotInSales = array_diff($subscribersGuestEmails, $existInSales);
        $customerSubscribers = $subscribersAreCustomers->getColumnValues('email');
        $emailsWithNoSaleData = array_merge($emailsNotInSales, $customerSubscribers);
        //subscriber that are customer or/and the one that do not exist in sales order table.
        $subscribersWithNoSaleData = [];
        if (! empty($emailsWithNoSaleData)) {
            $subscribersWithNoSaleData = $emailContactModel
                ->getSubscribersToImportFromEmails($emailsWithNoSaleData);
        }
        if (! empty($subscribersWithNoSaleData)) {
            $updated += $this->subscriberExporter->exportSubscribers(
                $website,
                $subscribersWithNoSaleData
            );
            //add updated number for the website
            $this->countSubscribers += $updated;
        }
        //subscriber that are guest and also exist in sales order table.
        $subscribersWithSaleData = [];
        if (! empty($existInSales)) {
            $subscribersWithSaleData = $emailContactModel->getSubscribersToImportFromEmails($existInSales);
        }

        if (! empty($subscribersWithSaleData)) {
            $updated += $this->subscriberWithSalesExporter->exportSubscribersWithSales(
                $website,
                $subscribersWithSaleData
            );
            //add updated number for the website
            $this->countSubscribers += $updated;
        }
        return $updated;
    }
public function exportSubscribersPerWebsite($website)
    {
        $isSubscriberSalesDataEnabled = $this->helper->getWebsiteConfig(
            \Dotdigitalgroup\Email\Helper\Config::XML_PATH_CONNECTOR_ENABLE_SUBSCRIBER_SALES_DATA,
            $website
        );

        $updated = 0;
        $limit = $this->helper->getSyncLimit($website->getId());
        //subscriber collection to import
        $emailContactModel = $this->contactFactory->create();
        //Customer Subscribers
        $subscribersAreCustomers = $emailContactModel->getSubscribersToImport($website, $limit);
        //Guest Subscribers
        $subscribersAreGuest = $emailContactModel->getSubscribersToImport($website, $limit, false);
        $subscribersGuestEmails = $subscribersAreGuest->getColumnValues('email');
        $existInSales = [];
        //Only if subscriber with sales data enabled
        if ($isSubscriberSalesDataEnabled && ! empty($subscribersGuestEmails)) {
            $existInSales = $this->checkInSales($subscribersGuestEmails);
        }

        $emailsNotInSales = array_diff($subscribersGuestEmails, $existInSales);
        $customerSubscribers = $subscribersAreCustomers->getColumnValues('email');
        $emailsWithNoSaleData = array_merge($emailsNotInSales, $customerSubscribers);
        //subscriber that are customer or/and the one that do not exist in sales order table.
        $subscribersWithNoSaleData = [];
        if (! empty($emailsWithNoSaleData)) {
            $subscribersWithNoSaleData = $emailContactModel
                ->getSubscribersToImportFromEmails($emailsWithNoSaleData);
        }
        if (! empty($subscribersWithNoSaleData)) {
            $updated += $this->subscriberExporter->exportSubscribers(
                $website,
                $subscribersWithNoSaleData
            );
            //add updated number for the website
            $this->countSubscribers += $updated;
        }
        //subscriber that are guest and also exist in sales order table.
        $subscribersWithSaleData = [];
        if (! empty($existInSales)) {
            $subscribersWithSaleData = $emailContactModel->getSubscribersToImportFromEmails($existInSales);
        }

        if (! empty($subscribersWithSaleData)) {
            $updated += $this->subscriberWithSalesExporter->exportSubscribersWithSales(
                $website,
                $subscribersWithSaleData
            );
            //add updated number for the website
            $this->countSubscribers += $updated;
        }
        return $updated;
    }
public function exportSubscribersPerWebsite ( $ website ) { $ isSubscriberSalesDataEnabled = $ this -> helper -> getWebsiteConfig ( \ Dotdigitalgroup \ Email \ Helper \ Config :: XML_PATH_CONNECTOR_ENABLE_SUBSCRIBER_SALES_DATA , $ website ) ; $ updated = 0 ; $ limit = $ this -> helper -> getSyncLimit ( $ website -> getId ( ) ) ; //subscriber collection to import $ emailContactModel = $ this -> contactFactory -> create ( ) ; //Customer Subscribers $ subscribersAreCustomers = $ emailContactModel -> getSubscribersToImport ( $ website , $ limit ) ; //Guest Subscribers $ subscribersAreGuest = $ emailContactModel -> getSubscribersToImport ( $ website , $ limit , false ) ; $ subscribersGuestEmails = $ subscribersAreGuest -> getColumnValues ( 'email' ) ; $ existInSales = [ ] ; //Only if subscriber with sales data enabled if ( $ isSubscriberSalesDataEnabled && ! empty ( $ subscribersGuestEmails ) ) { $ existInSales = $ this -> checkInSales ( $ subscribersGuestEmails ) ; } $ emailsNotInSales = array_diff ( $ subscribersGuestEmails , $ existInSales ) ; $ customerSubscribers = $ subscribersAreCustomers -> getColumnValues ( 'email' ) ; $ emailsWithNoSaleData = array_merge ( $ emailsNotInSales , $ customerSubscribers ) ; //subscriber that are customer or/and the one that do not exist in sales order table. $ subscribersWithNoSaleData = [ ] ; if ( ! empty ( $ emailsWithNoSaleData ) ) { $ subscribersWithNoSaleData = $ emailContactModel -> getSubscribersToImportFromEmails ( $ emailsWithNoSaleData ) ; } if ( ! empty ( $ subscribersWithNoSaleData ) ) { $ updated += $ this -> subscriberExporter -> exportSubscribers ( $ website , $ subscribersWithNoSaleData ) ; //add updated number for the website $ this -> countSubscribers += $ updated ; } //subscriber that are guest and also exist in sales order table. $ subscribersWithSaleData = [ ] ; if ( ! empty ( $ existInSales ) ) { $ subscribersWithSaleData = $ emailContactModel -> getSubscribersToImportFromEmails ( $ existInSales ) ; } if ( ! empty ( $ subscribersWithSaleData ) ) { $ updated += $ this -> subscriberWithSalesExporter -> exportSubscribersWithSales ( $ website , $ subscribersWithSaleData ) ; //add updated number for the website $ this -> countSubscribers += $ updated ; } return $ updated ; }
Export subscribers per website.

@param \Magento\Store\Model\Website $website

@return int

@throws LocalizedException
Export subscribers per website .