Update new order default datafields.

@param int $websiteId

@return null
@throws \Magento\Framework\Exception\LocalizedException
179011
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
            );
        }
    }
1147089
private function processFinishedItem($item, $websiteId)
    {
        $now = gmdate('Y-m-d H:i:s');

        $item->setImportStatus(self::IMPORTED)
            ->setImportFinished($now)
            ->setMessage('');

        if ($item->getImportType() == self::IMPORT_TYPE_CONTACT ||
            $item->getImportType() == self::IMPORT_TYPE_SUBSCRIBERS ||
            $item->getImportType() == self::IMPORT_TYPE_GUEST
        ) {
            //if file
            if ($file = $item->getImportFile()) {
                //remove the consent data for contacts before arhiving the file
                $log = $this->helper->fileHelper->cleanProcessedConsent(
                    $this->helper->fileHelper->getFilePathWithFallback($file)
                );
                if ($log) {
                    $this->helper->log($log);
                }
                if (! $this->helper->fileHelper->isFileAlreadyArchived($file)) {
                    $this->helper->fileHelper->archiveCSV($file);
                }
            }

            if ($item->getImportId()) {
                $this->_processContactImportReportFaults($item->getImportId(), $websiteId);
            }
        }

        return $item;
    }
1087160
private function updateNavigationListOrder($id, $listOrder, $parentId = 0)
    {
        $row = Page::find($id);
        $row->parent_id = $parentId;
        //if ($row->url_parent_id != 0) {
            // update the url parent id as well
            $row->url_parent_id = $parentId;
        //}

        $row->updateUrl();
        $row[$this->orderProperty] = $listOrder;
        $row->save();

        return $row;
    }
1301551
public function getApiResponseTimeLimit($websiteId = 0)
    {
        $website = $this->storeManager->getWebsite($websiteId);
        $limit = $website->getConfig(
            \Dotdigitalgroup\Email\Helper\Config::XML_PATH_CONNECTOR_DEBUG_API_REQUEST_LIMIT
        );

        return $limit;
    }
876733
public function getPushIntegrationCode($websiteID)
    {
        if (empty($websiteID)) {
            return $this->handleError('Empty website id');
        }

        $requestResult = $this->sendRequest('/push/websites/' . $websiteID . '/code');

        return $this->handleResult($requestResult);
    }
1224543
public function isOnlySubscribersForReview($websiteId)
    {
        $value = $this->scopeConfig->isSetFlag(
            \Dotdigitalgroup\Email\Helper\Config::XML_PATH_REVIEW_ALLOW_NON_SUBSCRIBERS,
            \Magento\Store\Model\ScopeInterface::SCOPE_WEBSITE,
            $websiteId
        );
        return ($value) ? false : true;
    }
685431
protected function reorder($parentId = 0)
    {
        $query = call_user_func("$this->ownerClassName::find")
            ->select("$this->primaryKey")
            ->orderBy("$this->sortField, $this->primaryKey");
        if ( $this->parentIdField ) {
            $query->where([ $this->parentIdField => $parentId ]);
        }
        $data = array_map('intval', $query->column());
        foreach ( $data as $i => $itemPK ) {
            call_user_func("$this->ownerClassName::updateAll",
                [ $this->sortField => ($i + 1) * 100 ],
                [ $this->primaryKey => $itemPK ]);
        }
    }
507061
public function update($itemId, Google_Service_Chromewebstore_Item $postBody, $optParams = array())
  {
    $params = array('itemId' => $itemId, 'postBody' => $postBody);
    $params = array_merge($params, $optParams);
    return $this->call('update', array($params), "Google_Service_Chromewebstore_Item");
  }
234542
private function updateDatafieldsByType($type, $email, $websiteId)
    {
        switch ($type) {
            case self::AUTOMATION_TYPE_NEW_ORDER:
            case self::AUTOMATION_TYPE_NEW_GUEST_ORDER:
            case self::ORDER_STATUS_AUTOMATION:
            case self::AUTOMATION_TYPE_CUSTOMER_FIRST_ORDER:
                $this->updateNewOrderDatafields($websiteId);
                break;
            case self::AUTOMATION_TYPE_ABANDONED_CART_PROGRAM_ENROLMENT:
                $this->updateAbandoned->updateAbandonedCartDatafields($email, $websiteId, $this->typeId, $this->storeName);
            default:
                $this->updateDefaultDatafields($email, $websiteId);
                break;
        }
    }
804108
public function update($addressId, $params) 
    {
        $uri = $this->uri . $addressId . '/';
        $response = $this->client->update(
            $uri,
            $params
        );

        return json_encode($response->getContent(), JSON_FORCE_OBJECT);
    }
423587
public function update($id, $dbConnection = NULL)
    {
        $connection = DatabaseQuery::checkConnection($dbConnection);

        $updateQuery = $this->updateQuery(self::getTableName($connection), $id);
        $statement = $connection->prepare($updateQuery);
        if ($statement->execute()) {
            return true;
        }
        throw new  DataAlreadyExistException();
    }
159568
private function syncItemContactEmailUpdateMode($importData, $websiteId)
    {
        $emailBefore = $importData['emailBefore'];
        $email = $importData['email'];
        $isSubscribed = $importData['isSubscribed'];
        $subscribersAddressBook = $this->helper->getWebsiteConfig(
            \Dotdigitalgroup\Email\Helper\Config::XML_PATH_CONNECTOR_SUBSCRIBERS_ADDRESS_BOOK_ID,
            $websiteId
        );

        $result = $this->client->postContacts($emailBefore);

        //check for matching email
        if (isset($result->id)) {
            if ($email != $result->email) {
                $data = [
                    'Email' => $email,
                    'EmailType' => 'Html',
                ];
                //update the contact with same id - different email
                $this->client->updateContact($result->id, $data);
            }
            if (!$isSubscribed && $result->status == 'Subscribed') {
                $this->client->deleteAddressBookContact($subscribersAddressBook, $result->id);
            }
        }
        return $result;
    }
837968
public function get($page, $pageSize, $websiteId = null, $storeId = null)
    {
        $this
            ->initCollection()
            ->filterMixedParam($websiteId, 'website_id')
            ->filterMixedParam($storeId, 'store_id')
            ->joinAddress('billing')
            ->joinAddress('shipping')
            ->joinSubscriptionStatus()
            ->setPage($page, $pageSize);

        return $this->customersResponseFactory->create()
            ->setCurrentPage($this->customerCollection->getCurPage())
            ->setLastPage($this->customerCollection->getLastPageNumber())
            ->setPageSize($this->customerCollection->getPageSize())
            ->setTotalCount($this->customerCollection->getSize())
            ->setCustomers($this->handleCustomers());
    }
1153514
public function UpdateOrderById($iId)
    {
        $this->sqlData['shop_module_articlelist_orderby_id'] = $iId;
        $this->fieldShopModuleArticlelistOrderbyId = $iId;
        $oItem = null;
        $this->SetInternalCache('oLookupshop_module_articlelist_orderby_id', $oItem);
    }
338756
public function findCacheById(int $id, int $siteId = null)
    {

        // Resolve siteId
        $siteId = SiteHelper::resolveSiteId($siteId);

        // Check if already in addToCache
        if ($this->isCachedById($id, $siteId)) {
            return $this->cacheById[$siteId][$id];
        }

        return null;
    }
1358956
private function filterWebsite($websiteId = null)
    {
        if ($websiteId !== null) {
            if (!is_array($websiteId)) {
                $websiteId = explode(',', $websiteId);
            }
            $this->subscriptionCollection->addFieldToFilter('website_id', ['in' => $websiteId]);
        }

        return $this;
    }
603074
public function resetMultilangFields($langId, $tableName)
    {
        $langId = (int) $langId;

        if ($langId === 0) {
            return;
        }

        $sql = [];

        $fields = $this->getMultilangFields($tableName);
        if (is_array($fields) && count($fields) > 0) {
            foreach ($fields as $fieldName) {
                $fieldName = $fieldName . "_" . $langId;

                if ($this->fieldExists($fieldName, $tableName)) {
                    //resetting field value to default
                    $sql[] = "UPDATE {$tableName} SET {$fieldName} = DEFAULT;";
                }
            }
        }

        if (!empty($sql)) {
            $this->executeSql($sql);
        }
    }