Model/Sync/Automation.php
private function updateNewOrderDatafields($websiteId)
    {
        $website = $this->helper->storeManager->getWebsite($websiteId);
        $orderModel = $this->orderFactory->create()
            ->loadByIncrementId($this->typeId);

        //data fields
        if ($lastOrderId = $website->getConfig(
            \Dotdigitalgroup\Email\Helper\Config::XML_PATH_CONNECTOR_CUSTOMER_LAST_ORDER_ID
        )
        ) {
            $data[] = [
                'Key' => $lastOrderId,
                'Value' => $orderModel->getId(),
            ];
        }
        if ($orderIncrementId = $website->getConfig(
            \Dotdigitalgroup\Email\Helper\Config::XML_PATH_CONNECTOR_CUSTOMER_LAST_ORDER_INCREMENT_ID
        )
        ) {
            $data[] = [
                'Key' => $orderIncrementId,
                'Value' => $orderModel->getIncrementId(),
            ];
        }
        if ($storeName = $website->getConfig(
            \Dotdigitalgroup\Email\Helper\Config::XML_PATH_CONNECTOR_CUSTOMER_STORE_NAME
        )
        ) {
            $data[] = [
                'Key' => $storeName,
                'Value' => $this->storeName,
            ];
        }
        if ($websiteName = $website->getConfig(
            \Dotdigitalgroup\Email\Helper\Config::XML_PATH_CONNECTOR_CUSTOMER_WEBSITE_NAME
        )
        ) {
            $data[] = [
                'Key' => $websiteName,
                'Value' => $website->getName(),
            ];
        }
        if ($lastOrderDate = $website->getConfig(
            \Dotdigitalgroup\Email\Helper\Config::XML_PATH_CONNECTOR_CUSTOMER_LAST_ORDER_DATE
        )
        ) {
            $data[] = [
                'Key' => $lastOrderDate,
                'Value' => $orderModel->getCreatedAt(),
            ];
        }
        if (($customerId = $website->getConfig(
            \Dotdigitalgroup\Email\Helper\Config::XML_PATH_CONNECTOR_CUSTOMER_ID
        ))
            && $orderModel->getCustomerId()
        ) {
            $data[] = [
                'Key' => $customerId,
                'Value' => $orderModel->getCustomerId(),
            ];
        }
        if (!empty($data)) {
            //update data fields
            $client = $this->helper->getWebsiteApiClient($website);
            $client->updateContactDatafieldsByEmail(
                $orderModel->getCustomerEmail(),
                $data
            );
        }
    }
private function updateNewOrderDatafields($websiteId)
    {
        $website = $this->helper->storeManager->getWebsite($websiteId);
        $orderModel = $this->orderFactory->create()
            ->loadByIncrementId($this->typeId);

        //data fields
        if ($lastOrderId = $website->getConfig(
            \Dotdigitalgroup\Email\Helper\Config::XML_PATH_CONNECTOR_CUSTOMER_LAST_ORDER_ID
        )
        ) {
            $data[] = [
                'Key' => $lastOrderId,
                'Value' => $orderModel->getId(),
            ];
        }
        if ($orderIncrementId = $website->getConfig(
            \Dotdigitalgroup\Email\Helper\Config::XML_PATH_CONNECTOR_CUSTOMER_LAST_ORDER_INCREMENT_ID
        )
        ) {
            $data[] = [
                'Key' => $orderIncrementId,
                'Value' => $orderModel->getIncrementId(),
            ];
        }
        if ($storeName = $website->getConfig(
            \Dotdigitalgroup\Email\Helper\Config::XML_PATH_CONNECTOR_CUSTOMER_STORE_NAME
        )
        ) {
            $data[] = [
                'Key' => $storeName,
                'Value' => $this->storeName,
            ];
        }
        if ($websiteName = $website->getConfig(
            \Dotdigitalgroup\Email\Helper\Config::XML_PATH_CONNECTOR_CUSTOMER_WEBSITE_NAME
        )
        ) {
            $data[] = [
                'Key' => $websiteName,
                'Value' => $website->getName(),
            ];
        }
        if ($lastOrderDate = $website->getConfig(
            \Dotdigitalgroup\Email\Helper\Config::XML_PATH_CONNECTOR_CUSTOMER_LAST_ORDER_DATE
        )
        ) {
            $data[] = [
                'Key' => $lastOrderDate,
                'Value' => $orderModel->getCreatedAt(),
            ];
        }
        if (($customerId = $website->getConfig(
            \Dotdigitalgroup\Email\Helper\Config::XML_PATH_CONNECTOR_CUSTOMER_ID
        ))
            && $orderModel->getCustomerId()
        ) {
            $data[] = [
                'Key' => $customerId,
                'Value' => $orderModel->getCustomerId(),
            ];
        }
        if (!empty($data)) {
            //update data fields
            $client = $this->helper->getWebsiteApiClient($website);
            $client->updateContactDatafieldsByEmail(
                $orderModel->getCustomerEmail(),
                $data
            );
        }
    }
private function updateNewOrderDatafields ( $ websiteId ) { $ website = $ this -> helper -> storeManager -> getWebsite ( $ websiteId ) ; $ orderModel = $ this -> orderFactory -> create ( ) -> loadByIncrementId ( $ this -> typeId ) ; //data fields if ( $ lastOrderId = $ website -> getConfig ( \ Dotdigitalgroup \ Email \ Helper \ Config :: XML_PATH_CONNECTOR_CUSTOMER_LAST_ORDER_ID ) ) { $ data [ ] = [ 'Key' => $ lastOrderId , 'Value' => $ orderModel -> getId ( ) , ] ; } if ( $ orderIncrementId = $ website -> getConfig ( \ Dotdigitalgroup \ Email \ Helper \ Config :: XML_PATH_CONNECTOR_CUSTOMER_LAST_ORDER_INCREMENT_ID ) ) { $ data [ ] = [ 'Key' => $ orderIncrementId , 'Value' => $ orderModel -> getIncrementId ( ) , ] ; } if ( $ storeName = $ website -> getConfig ( \ Dotdigitalgroup \ Email \ Helper \ Config :: XML_PATH_CONNECTOR_CUSTOMER_STORE_NAME ) ) { $ data [ ] = [ 'Key' => $ storeName , 'Value' => $ this -> storeName , ] ; } if ( $ websiteName = $ website -> getConfig ( \ Dotdigitalgroup \ Email \ Helper \ Config :: XML_PATH_CONNECTOR_CUSTOMER_WEBSITE_NAME ) ) { $ data [ ] = [ 'Key' => $ websiteName , 'Value' => $ website -> getName ( ) , ] ; } if ( $ lastOrderDate = $ website -> getConfig ( \ Dotdigitalgroup \ Email \ Helper \ Config :: XML_PATH_CONNECTOR_CUSTOMER_LAST_ORDER_DATE ) ) { $ data [ ] = [ 'Key' => $ lastOrderDate , 'Value' => $ orderModel -> getCreatedAt ( ) , ] ; } if ( ( $ customerId = $ website -> getConfig ( \ Dotdigitalgroup \ Email \ Helper \ Config :: XML_PATH_CONNECTOR_CUSTOMER_ID ) ) && $ orderModel -> getCustomerId ( ) ) { $ data [ ] = [ 'Key' => $ customerId , 'Value' => $ orderModel -> getCustomerId ( ) , ] ; } if ( ! empty ( $ data ) ) { //update data fields $ client = $ this -> helper -> getWebsiteApiClient ( $ website ) ; $ client -> updateContactDatafieldsByEmail ( $ orderModel -> getCustomerEmail ( ) , $ data ) ; } }
Update new order default datafields.

@param int $websiteId

@return null
@throws \Magento\Framework\Exception\LocalizedException
Update new order default datafields .