Update abandoned cart data fields.

@param string $email
@param int $websiteId
@param int $quoteId
@param string $parentStoreName

@return void
@throws \Magento\Framework\Exception\LocalizedException
16818
public function updateAbandonedCartDatafields($email, $websiteId, $quoteId, $parentStoreName)
    {
        $website = $this->storeManager->getWebsite($websiteId);

        // Load the origin quote
        $quoteModel = $this->magentoQuoteFactory->create()
            ->loadByIdWithoutStore($quoteId);
        $items = $quoteModel->getAllItems();

        // Nominate the most expensive item in the cart as the 'abandoned product'
        $nominatedAbandonedCartItem = $this->ddgQuoteFactory->create()
            ->getMostExpensiveItems($items);

        if ($lastQuoteId = $website->getConfig(
            \Dotdigitalgroup\Email\Helper\Config::XML_PATH_CONNECTOR_MAPPING_LAST_QUOTE_ID
        )
        ) {
            $data[] = [
                'Key' => $lastQuoteId,
                'Value' => $quoteId,
            ];
        }
        if ($abandonedProductName = $website->getConfig(
            \Dotdigitalgroup\Email\Helper\Config::XML_PATH_CONNECTOR_ABANDONED_PRODUCT_NAME
        )
        ) {
            $data[] = [
                'Key' => $abandonedProductName,
                'Value' => $nominatedAbandonedCartItem->getName(),
            ];
        }
        if ($storeName = $website->getConfig(
            \Dotdigitalgroup\Email\Helper\Config::XML_PATH_CONNECTOR_CUSTOMER_STORE_NAME
        )
        ) {
            $data[] = [
                'Key' => $storeName,
                'Value' => $parentStoreName,
            ];
        }
        if ($websiteName = $website->getConfig(
            \Dotdigitalgroup\Email\Helper\Config::XML_PATH_CONNECTOR_CUSTOMER_WEBSITE_NAME
        )
        ) {
            $data[] = [
                'Key' => $websiteName,
                'Value' => $website->getName(),
            ];
        }
        if (!empty($data)) {
            $client = $this->helper->getWebsiteApiClient($website);
            $client->updateContactDatafieldsByEmail(
                $email,
                $data
            );
        }
    }
258223
public void updateDatabaseDdl(String instanceId, String databaseId) {
    // [START updateDatabaseDdl]
    try {
      dbAdminClient
          .updateDatabaseDdl(
              instanceId,
              databaseId,
              Arrays.asList("ALTER TABLE Albums ADD COLUMN MarketingBudget INT64"),
              null)
          .get();
    } catch (ExecutionException e) {
      throw (SpannerException) e.getCause();
    } catch (InterruptedException e) {
      throw SpannerExceptionFactory.propagateInterrupt(e);
    }
    // [END updateDatabaseDdl]
  }
483004
public function setEmail($email)
    {
        if (!is_string($email) &&
            filter_var($email, FILTER_VALIDATE_EMAIL)
        ) {
            throw new TypeException(
                '$email must valid and be of type string.'
            );
        }
        $this->email = $email;
    }
313769
public function updateAbandonedProductName($name, $email, $websiteId)
    {
        if ($this->isEnabled($websiteId)) {
            $client = $this->getWebsiteApiClient($websiteId);
            // id config data mapped
            $field = $this->getAbandonedProductName();

            if ($field) {
                $data[] = [
                    'Key' => $field,
                    'Value' => $name,
                ];
                //update data field for contact
                $client->updateContactDatafieldsByEmail($email, $data);
            }
        }
    }
1346244
protected function _onEmailChange($email, $updateOrInsert = 'insert') {
        $authVars = Garp_Auth::getInstance()->getConfigValues('validateemail');

        // See if validation of email is enabled
        if (empty($authVars['enabled']) || !$authVars['enabled']) {
            return;
        }
        $validationTokenColumn = $authVars['token_column'];
        $emailValidColumn = $authVars['email_valid_column'];

        // Fetch fresh user data by email
        $users = $this->fetchAll(
            $this->select()->from(
                $this->getName(),
                array('id', 'email', $validationTokenColumn, $emailValidColumn)
            )
                ->where('email = ?', $email)
        );

        // Generate validation token for all the found users
        foreach ($users as $user) {
            $this->invalidateEmailAddress($user, $updateOrInsert);
        }
    }
473578
private function createCustomerFirstAbandonedCart($quoteCollection, $storeId, $campaignId)
    {
        $result = 0;
        foreach ($quoteCollection as $quote) {
            $websiteId = $this->helper->storeManager->getStore($storeId)->getWebsiteId();
            if (! $this->updateDataFieldAndCreateAc($quote, $websiteId, $storeId)) {
                continue;
            }

            //send campaign; check if valid to be sent
            if ($this->isLostBasketCustomerEnabled(self::CUSTOMER_LOST_BASKET_ONE, $storeId)) {
                $this->sendEmailCampaign(
                    $quote->getCustomerEmail(),
                    $quote,
                    $campaignId,
                    self::CUSTOMER_LOST_BASKET_ONE,
                    $websiteId
                );
            }

            $this->totalCustomers++;
            $result = $this->totalCustomers;
        }

        return $result;
    }
4322
public function setOrganizer(string $email) : void
    {
        if ('' !== $email) {
            $this->event->setOrganizer(
                new Organizer($email, ['MAILTO' => $email])
            );
        }
    }
1078895
public function updateLastQuoteId($quoteId, $email, $websiteId)
    {
        if ($this->isEnabled($websiteId)) {
            $client = $this->getWebsiteApiClient($websiteId);
            //last quote id config data mapped
            $quoteIdField = $this->getLastQuoteId();

            $data[] = [
                'Key' => $quoteIdField,
                'Value' => $quoteId,
            ];
            //update datafields for conctact
            $client->updateContactDatafieldsByEmail($email, $data);
        }
    }
189259
public function setSender(
        $name,
        $email = null,
        $areaCode = null,
        $number = null,
        $documentType = null,
        $documentValue = null
    ) {
        $param = $name;
        if (is_array($param)) {
            $this->sender = new PagSeguroSender($param);
        } elseif ($param instanceof PagSeguroSender) {
            $this->sender = $param;
        } else {
            $sender = new PagSeguroSender();
            $sender->setName($param);
            $sender->setEmail($email);
            $sender->setPhone(new PagSeguroPhone($areaCode, $number));
            $sender->addDocument($documentType, $documentValue);
            $this->sender = $sender;
        }
    }
380452
public static function disableByParent( $parentId, $parentType ) {

		$tableName = static::tableName();

		// Disable all mappings
		$query		= "UPDATE $tableName SET `active`=0 WHERE `parentType`='$parentType' AND `parentId`=$parentId";
		$command	= Yii::$app->db->createCommand( $query );

		$command->execute();
	}
95439
public function setSender(string $email, string $displayName = null) : void
    {
        $this->sender = new Identity($email, $displayName);
    }
16944
function doUpdateEmail(Userinfo $userinfo, Userinfo &$existinguser, $overwrite)
	{
		$changed = false;

		if (strtolower($existinguser->email) != strtolower($userinfo->email)) {
			$this->debugger->addDebug(Text::_('EMAIL_CONFLICT'));
			$update_email = $this->params->get('update_email', false);
			if ($update_email || $overwrite) {
				$this->debugger->addDebug(Text::_('EMAIL_CONFLICT_OVERWITE_ENABLED'));
				try {
					$this->updateEmail($userinfo, $existinguser);
					$changed = true;
				} catch (Exception $e) {
					$this->debugger->addError(Text::_('EMAIL_UPDATE_ERROR') . ' ' . $e->getMessage());
				}
			} else {
				//return a email conflict
				$this->debugger->addDebug(Text::_('EMAIL_CONFLICT_OVERWITE_DISABLED'));

				$this->debugger->set('userinfo', $existinguser);
				throw new RuntimeException(Text::_('EMAIL') . ' ' . Text::_('CONFLICT') . ': ' . $existinguser->email . ' -> ' . $userinfo->email);
			}
		}
		return $changed;
	}
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;
        }
    }
405487
public function email($email = null) {
		$this->out('Email:');
		while (empty($email) || !Validation::email($email)) {
			$email = $this->in('New email address (must have a valid form at least)');
		}

		/** @var \App\Model\Table\UsersTable $Users */
		$Users = TableRegistry::get(CLASS_USERS);
		$this->Users = $Users;
		if (!$this->Users->hasField('email')) {
			$this->abort(CLASS_USERS . ' table doesnt have an email field!');
		}

		$this->hr();
		$this->out('Resetting...');

		if (empty($this->params['dry-run'])) {
			$count = $this->Users->updateAll(['email' => $email . ''], ['email !=' => $email]);
		} else {
			$count = $this->Users->find('all', ['conditions' => [CLASS_USERS . '.email !=' => $email]])->count();
		}
		$this->out($count . ' emails resetted - DONE');
	}
198326
public function updateDataFields($email, $website, $storeName)
    {
        $data = [];
        if ($storeNameKey = $website->getConfig(
            \Dotdigitalgroup\Email\Helper\Config::XML_PATH_CONNECTOR_CUSTOMER_STORE_NAME
        )
        ) {
            $data[] = [
                'Key' => $storeNameKey,
                'Value' => $storeName,
            ];
        }
        if ($websiteName = $website->getConfig(
            \Dotdigitalgroup\Email\Helper\Config::XML_PATH_CONNECTOR_CUSTOMER_WEBSITE_NAME
        )
        ) {
            $data[] = [
                'Key' => $websiteName,
                'Value' => $website->getName(),
            ];
        }
        if (!empty($data)) {
            //update data fields
            if ($this->isEnabled($website)) {
                $client = $this->getWebsiteApiClient($website);
                $client->updateContactDatafieldsByEmail($email, $data);
            }
        }
    }
738297
private function updateTotals(Quote $quote)
    {
        $quote->getShippingAddress()->setCollectShippingRates(true);
        $quote->setTotalsCollectedFlag(false);
        $quote->collectTotals();
        $quote->setDataChanges(true);
        $this->quoteRepository->save($quote);
    }
594911
public function setReplyTo($email) {
    if (!$this->checkValidEmail($email)) {
      throw new \InvalidArgumentException(
          "Invalid reply-to: ". htmlspecialchars($email));
    }
    $this->message->setReplyto($email);
  }