Model/Sales/Order.php
public function registerCampaign($collection, $websiteId)
    {
        //review campaign id
        $campaignId = $this->helper->getCampaign($websiteId);

        if ($campaignId) {
            foreach ($collection as $order) {
                $this->helper->log(
                    '-- Order Review: ' . $order->getIncrementId()
                    . ' Campaign Id: ' . $campaignId
                );

                try {
                    $emailCampaign = $this->campaignFactory->create()
                        ->setEmail($order->getCustomerEmail())
                        ->setStoreId($order->getStoreId())
                        ->setCampaignId($campaignId)
                        ->setEventName('Order Review')
                        ->setCreatedAt($this->dateTime->formatDate(true))
                        ->setOrderIncrementId($order->getIncrementId())
                        ->setQuoteId($order->getQuoteId());

                    if ($order->getCustomerId()) {
                        $emailCampaign->setCustomerId($order->getCustomerId());
                    }
                    $this->campaignResource->saveItem($emailCampaign);
                } catch (\Exception $e) {
                    $this->helper->debug((string)$e, []);
                }
            }
        }
    }
public function registerCampaign($collection, $websiteId)
    {
        //review campaign id
        $campaignId = $this->helper->getCampaign($websiteId);

        if ($campaignId) {
            foreach ($collection as $order) {
                $this->helper->log(
                    '-- Order Review: ' . $order->getIncrementId()
                    . ' Campaign Id: ' . $campaignId
                );

                try {
                    $emailCampaign = $this->campaignFactory->create()
                        ->setEmail($order->getCustomerEmail())
                        ->setStoreId($order->getStoreId())
                        ->setCampaignId($campaignId)
                        ->setEventName('Order Review')
                        ->setCreatedAt($this->dateTime->formatDate(true))
                        ->setOrderIncrementId($order->getIncrementId())
                        ->setQuoteId($order->getQuoteId());

                    if ($order->getCustomerId()) {
                        $emailCampaign->setCustomerId($order->getCustomerId());
                    }
                    $this->campaignResource->saveItem($emailCampaign);
                } catch (\Exception $e) {
                    $this->helper->debug((string)$e, []);
                }
            }
        }
    }
public function registerCampaign ( $ collection , $ websiteId ) { //review campaign id $ campaignId = $ this -> helper -> getCampaign ( $ websiteId ) ; if ( $ campaignId ) { foreach ( $ collection as $ order ) { $ this -> helper -> log ( '-- Order Review: ' . $ order -> getIncrementId ( ) . ' Campaign Id: ' . $ campaignId ) ; try { $ emailCampaign = $ this -> campaignFactory -> create ( ) -> setEmail ( $ order -> getCustomerEmail ( ) ) -> setStoreId ( $ order -> getStoreId ( ) ) -> setCampaignId ( $ campaignId ) -> setEventName ( 'Order Review' ) -> setCreatedAt ( $ this -> dateTime -> formatDate ( true ) ) -> setOrderIncrementId ( $ order -> getIncrementId ( ) ) -> setQuoteId ( $ order -> getQuoteId ( ) ) ; if ( $ order -> getCustomerId ( ) ) { $ emailCampaign -> setCustomerId ( $ order -> getCustomerId ( ) ) ; } $ this -> campaignResource -> saveItem ( $ emailCampaign ) ; } catch ( \ Exception $ e ) { $ this -> helper -> debug ( ( string ) $ e , [ ] ) ; } } } }
Register review campaign.

@param \Magento\Sales\Model\ResourceModel\Order\Collection $collection
@param int $websiteId

@return null
Register review campaign .