Model/Sync/Automation.php
private function checkStatusForPendingContacts()
    {
        $updatedAt = $this->dateTime->formatDate(true);

        if ($this->isItTimeToCheckPendingContact()) {
            $collection = $this->automationFactory->create()
                ->getCollectionByPendingStatus();
            $idsToUpdateStatus = [];
            $idsToUpdateDate = [];

            foreach ($collection as $item) {
                $contact = $this->helper->getContact($item->getEmail(), $item->getWebsiteId());
                if (isset($contact->id) && $contact->status !== self::CONTACT_STATUS_PENDING) {
                    //add to array for update status
                    $idsToUpdateStatus[] = $item->getId();
                } else {
                    //add to array for update date
                    $idsToUpdateDate[] = $item->getId();
                }
            }

            if (! empty($idsToUpdateStatus)) {
                $this->automationResource
                    ->update(
                        $idsToUpdateStatus,
                        $updatedAt,
                        self::CONTACT_STATUS_CONFIRMED
                    );
            }

            if (! empty($idsToUpdateDate)) {
                $this->automationResource
                    ->update(
                        $idsToUpdateDate,
                        $updatedAt
                    );
            }
        }

        //Get pending with 24 house delay and expire it
        $collection = $this->automationFactory->create()
            ->getCollectionByPendingStatus($this->getDateTimeForExpiration());
        $ids = $collection->getColumnValues('id');
        if (! empty($ids)) {
            $this->automationResource
                ->update(
                    $ids,
                    $updatedAt,
                    self::CONTACT_STATUS_EXPIRED
                );
        }
    }
private function checkStatusForPendingContacts()
    {
        $updatedAt = $this->dateTime->formatDate(true);

        if ($this->isItTimeToCheckPendingContact()) {
            $collection = $this->automationFactory->create()
                ->getCollectionByPendingStatus();
            $idsToUpdateStatus = [];
            $idsToUpdateDate = [];

            foreach ($collection as $item) {
                $contact = $this->helper->getContact($item->getEmail(), $item->getWebsiteId());
                if (isset($contact->id) && $contact->status !== self::CONTACT_STATUS_PENDING) {
                    //add to array for update status
                    $idsToUpdateStatus[] = $item->getId();
                } else {
                    //add to array for update date
                    $idsToUpdateDate[] = $item->getId();
                }
            }

            if (! empty($idsToUpdateStatus)) {
                $this->automationResource
                    ->update(
                        $idsToUpdateStatus,
                        $updatedAt,
                        self::CONTACT_STATUS_CONFIRMED
                    );
            }

            if (! empty($idsToUpdateDate)) {
                $this->automationResource
                    ->update(
                        $idsToUpdateDate,
                        $updatedAt
                    );
            }
        }

        //Get pending with 24 house delay and expire it
        $collection = $this->automationFactory->create()
            ->getCollectionByPendingStatus($this->getDateTimeForExpiration());
        $ids = $collection->getColumnValues('id');
        if (! empty($ids)) {
            $this->automationResource
                ->update(
                    $ids,
                    $updatedAt,
                    self::CONTACT_STATUS_EXPIRED
                );
        }
    }
private function checkStatusForPendingContacts ( ) { $ updatedAt = $ this -> dateTime -> formatDate ( true ) ; if ( $ this -> isItTimeToCheckPendingContact ( ) ) { $ collection = $ this -> automationFactory -> create ( ) -> getCollectionByPendingStatus ( ) ; $ idsToUpdateStatus = [ ] ; $ idsToUpdateDate = [ ] ; foreach ( $ collection as $ item ) { $ contact = $ this -> helper -> getContact ( $ item -> getEmail ( ) , $ item -> getWebsiteId ( ) ) ; if ( isset ( $ contact -> id ) && $ contact -> status !== self :: CONTACT_STATUS_PENDING ) { //add to array for update status $ idsToUpdateStatus [ ] = $ item -> getId ( ) ; } else { //add to array for update date $ idsToUpdateDate [ ] = $ item -> getId ( ) ; } } if ( ! empty ( $ idsToUpdateStatus ) ) { $ this -> automationResource -> update ( $ idsToUpdateStatus , $ updatedAt , self :: CONTACT_STATUS_CONFIRMED ) ; } if ( ! empty ( $ idsToUpdateDate ) ) { $ this -> automationResource -> update ( $ idsToUpdateDate , $ updatedAt ) ; } } //Get pending with 24 house delay and expire it $ collection = $ this -> automationFactory -> create ( ) -> getCollectionByPendingStatus ( $ this -> getDateTimeForExpiration ( ) ) ; $ ids = $ collection -> getColumnValues ( 'id' ) ; if ( ! empty ( $ ids ) ) { $ this -> automationResource -> update ( $ ids , $ updatedAt , self :: CONTACT_STATUS_EXPIRED ) ; } }
check automation entries for pending contacts
check automation entries for pending contacts