Model/Sync/Campaign.php
private function getCampaignsToSend($emailsToSend, $website)
    {
        $campaignsToSend = [];
        foreach ($emailsToSend as $campaign) {
            $email = $campaign->getEmail();
            $campaignId = $campaign->getCampaignId();
            $websiteId = $website->getId();
            $client = false;
            if ($this->helper->isEnabled($websiteId)) {
                $client = $this->helper->getWebsiteApiClient($websiteId);
            }
            //Only if valid client is returned
            if ($client && $this->isCampaignValid($campaign)) {
                $campaignsToSend[$campaignId]['client'] = $client;
                $contact = $this->helper->getContact(
                    $campaign->getEmail(),
                    $websiteId
                );
                if ($contact && isset($contact->id)) {
                    //update data fields
                    if ($campaign->getEventName() == 'Order Review') {
                        $this->updateDataFieldsForORderReviewCampaigns($campaign, $websiteId, $client, $email);
                    } elseif ($campaign->getEventName() ==
                        \Dotdigitalgroup\Email\Model\Campaign::CAMPAIGN_EVENT_LOST_BASKET
                    ) {
                        $campaignCollection = $this->campaignCollection->create();
                        // If AC campaigns found with status processing for given email then skip for current cron run
                        if ($campaignCollection->getNumberOfAcCampaignsWithStatusProcessingExistForContact($email)) {
                            continue;
                        }
                        $this->helper->updateLastQuoteId($campaign->getQuoteId(), $email, $websiteId);
                    }

                    $campaignsToSend[$campaignId]['contacts'][] = $contact->id;
                    $campaignsToSend[$campaignId]['ids'][] = $campaign->getId();
                } else {
                    //update the failed to send email message error message
                    $campaign->setSendStatus(\Dotdigitalgroup\Email\Model\Campaign::FAILED)
                        ->setMessage('Send not permitted. Contact is suppressed.');
                    $this->campaignResourceModel->saveItem($campaign);
                }
            }
        }

        return $campaignsToSend;
    }
private function getCampaignsToSend($emailsToSend, $website)
    {
        $campaignsToSend = [];
        foreach ($emailsToSend as $campaign) {
            $email = $campaign->getEmail();
            $campaignId = $campaign->getCampaignId();
            $websiteId = $website->getId();
            $client = false;
            if ($this->helper->isEnabled($websiteId)) {
                $client = $this->helper->getWebsiteApiClient($websiteId);
            }
            //Only if valid client is returned
            if ($client && $this->isCampaignValid($campaign)) {
                $campaignsToSend[$campaignId]['client'] = $client;
                $contact = $this->helper->getContact(
                    $campaign->getEmail(),
                    $websiteId
                );
                if ($contact && isset($contact->id)) {
                    //update data fields
                    if ($campaign->getEventName() == 'Order Review') {
                        $this->updateDataFieldsForORderReviewCampaigns($campaign, $websiteId, $client, $email);
                    } elseif ($campaign->getEventName() ==
                        \Dotdigitalgroup\Email\Model\Campaign::CAMPAIGN_EVENT_LOST_BASKET
                    ) {
                        $campaignCollection = $this->campaignCollection->create();
                        // If AC campaigns found with status processing for given email then skip for current cron run
                        if ($campaignCollection->getNumberOfAcCampaignsWithStatusProcessingExistForContact($email)) {
                            continue;
                        }
                        $this->helper->updateLastQuoteId($campaign->getQuoteId(), $email, $websiteId);
                    }

                    $campaignsToSend[$campaignId]['contacts'][] = $contact->id;
                    $campaignsToSend[$campaignId]['ids'][] = $campaign->getId();
                } else {
                    //update the failed to send email message error message
                    $campaign->setSendStatus(\Dotdigitalgroup\Email\Model\Campaign::FAILED)
                        ->setMessage('Send not permitted. Contact is suppressed.');
                    $this->campaignResourceModel->saveItem($campaign);
                }
            }
        }

        return $campaignsToSend;
    }
private function getCampaignsToSend ( $ emailsToSend , $ website ) { $ campaignsToSend = [ ] ; foreach ( $ emailsToSend as $ campaign ) { $ email = $ campaign -> getEmail ( ) ; $ campaignId = $ campaign -> getCampaignId ( ) ; $ websiteId = $ website -> getId ( ) ; $ client = false ; if ( $ this -> helper -> isEnabled ( $ websiteId ) ) { $ client = $ this -> helper -> getWebsiteApiClient ( $ websiteId ) ; } //Only if valid client is returned if ( $ client && $ this -> isCampaignValid ( $ campaign ) ) { $ campaignsToSend [ $ campaignId ] [ 'client' ] = $ client ; $ contact = $ this -> helper -> getContact ( $ campaign -> getEmail ( ) , $ websiteId ) ; if ( $ contact && isset ( $ contact -> id ) ) { //update data fields if ( $ campaign -> getEventName ( ) == 'Order Review' ) { $ this -> updateDataFieldsForORderReviewCampaigns ( $ campaign , $ websiteId , $ client , $ email ) ; } elseif ( $ campaign -> getEventName ( ) == \ Dotdigitalgroup \ Email \ Model \ Campaign :: CAMPAIGN_EVENT_LOST_BASKET ) { $ campaignCollection = $ this -> campaignCollection -> create ( ) ; // If AC campaigns found with status processing for given email then skip for current cron run if ( $ campaignCollection -> getNumberOfAcCampaignsWithStatusProcessingExistForContact ( $ email ) ) { continue ; } $ this -> helper -> updateLastQuoteId ( $ campaign -> getQuoteId ( ) , $ email , $ websiteId ) ; } $ campaignsToSend [ $ campaignId ] [ 'contacts' ] [ ] = $ contact -> id ; $ campaignsToSend [ $ campaignId ] [ 'ids' ] [ ] = $ campaign -> getId ( ) ; } else { //update the failed to send email message error message $ campaign -> setSendStatus ( \ Dotdigitalgroup \ Email \ Model \ Campaign :: FAILED ) -> setMessage ( 'Send not permitted. Contact is suppressed.' ) ; $ this -> campaignResourceModel -> saveItem ( $ campaign ) ; } } } return $ campaignsToSend ; }
Get campaigns to send.

@param \Dotdigitalgroup\Email\Model\ResourceModel\Campaign\Collection $emailsToSend
@param \Magento\Store\Api\Data\WebsiteInterface $website

@return array
Get campaigns to send .