本文整理汇总了PHP中Magento\Customer\Api\Data\CustomerInterface::getEmail方法的典型用法代码示例。如果您正苦于以下问题:PHP CustomerInterface::getEmail方法的具体用法?PHP CustomerInterface::getEmail怎么用?PHP CustomerInterface::getEmail使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Customer\Api\Data\CustomerInterface
的用法示例。
在下文中一共展示了CustomerInterface::getEmail方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createCustomerItem
/**
* Creates a collection item that represents a customer for the customer Grid.
*
* @param CustomerInterface $customer Input data for creating the item.
* @return \Magento\Framework\Object Collection item that represents a customer
*/
protected function createCustomerItem(CustomerInterface $customer)
{
$customerNameParts = [$customer->getPrefix(), $customer->getFirstname(), $customer->getMiddlename(), $customer->getLastname(), $customer->getSuffix()];
$customerItem = new \Magento\Framework\Object();
$customerItem->setId($customer->getId());
$customerItem->setEntityId($customer->getId());
// All parts of the customer name must be displayed in the name column of the grid
$customerItem->setName(implode(' ', array_filter($customerNameParts)));
$customerItem->setEmail($customer->getEmail());
$customerItem->setWebsiteId($customer->getWebsiteId());
$customerItem->setCreatedAt($customer->getCreatedAt());
$customerItem->setGroupId($customer->getGroupId());
$billingAddress = null;
foreach ($customer->getAddresses() as $address) {
if ($address->isDefaultBilling()) {
$billingAddress = $address;
break;
}
}
if ($billingAddress !== null) {
$customerItem->setBillingTelephone($billingAddress->getTelephone());
$customerItem->setBillingPostcode($billingAddress->getPostcode());
$customerItem->setBillingCountryId($billingAddress->getCountryId());
$region = $billingAddress->getRegion() === null ? '' : $billingAddress->getRegion()->getRegion();
$customerItem->setBillingRegion($region);
}
return $customerItem;
}
示例2: save
/**
* @param CustomerInterface $customer
* @return \Openpay\Client\Type\OpenpayCustomerType
* @throws LocalizedException
*/
public function save(CustomerInterface $customer)
{
$params = ['name' => $customer->getFirstname(), 'last_name' => $customer->getLastname(), 'email' => $customer->getEmail(), 'requires_account' => self::CUSTOMER_REQUIRES_ACCOUNT, 'external_id' => $customer->getId()];
try {
$openpayCustomer = $this->customerAdapter->store($params);
} catch (OpenpayException $e) {
throw new LocalizedException(__($e->getDescription()), $e);
}
return $openpayCustomer;
}
示例3: send
/**
* Send customer email
*
* @return bool
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
* @SuppressWarnings(PHPMD.NPathComplexity)
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
*/
public function send()
{
if ($this->_website === null || $this->_customer === null) {
return false;
}
if ($this->_type == 'price' && count($this->_priceProducts) == 0 || $this->_type == 'stock' && count($this->_stockProducts) == 0) {
return false;
}
if (!$this->_website->getDefaultGroup() || !$this->_website->getDefaultGroup()->getDefaultStore()) {
return false;
}
if ($this->_customer->getStoreId() > 0) {
$store = $this->_storeManager->getStore($this->_customer->getStoreId());
} else {
$store = $this->_website->getDefaultStore();
}
$storeId = $store->getId();
if ($this->_type == 'price' && !$this->_scopeConfig->getValue(self::XML_PATH_EMAIL_PRICE_TEMPLATE, \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $storeId)) {
return false;
} elseif ($this->_type == 'stock' && !$this->_scopeConfig->getValue(self::XML_PATH_EMAIL_STOCK_TEMPLATE, \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $storeId)) {
return false;
}
if ($this->_type != 'price' && $this->_type != 'stock') {
return false;
}
$this->_appEmulation->startEnvironmentEmulation($storeId);
if ($this->_type == 'price') {
$this->_getPriceBlock()->setStore($store)->reset();
foreach ($this->_priceProducts as $product) {
$product->setCustomerGroupId($this->_customer->getGroupId());
$this->_getPriceBlock()->addProduct($product);
}
$block = $this->_getPriceBlock();
$templateId = $this->_scopeConfig->getValue(self::XML_PATH_EMAIL_PRICE_TEMPLATE, \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $storeId);
} else {
$this->_getStockBlock()->setStore($store)->reset();
foreach ($this->_stockProducts as $product) {
$product->setCustomerGroupId($this->_customer->getGroupId());
$this->_getStockBlock()->addProduct($product);
}
$block = $this->_getStockBlock();
$templateId = $this->_scopeConfig->getValue(self::XML_PATH_EMAIL_STOCK_TEMPLATE, \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $storeId);
}
$alertGrid = $this->_appState->emulateAreaCode(\Magento\Framework\App\Area::AREA_FRONTEND, [$block, 'toHtml']);
$this->_appEmulation->stopEnvironmentEmulation();
$transport = $this->_transportBuilder->setTemplateIdentifier($templateId)->setTemplateOptions(['area' => \Magento\Framework\App\Area::AREA_FRONTEND, 'store' => $storeId])->setTemplateVars(['customerName' => $this->_customerHelper->getCustomerName($this->_customer), 'alertGrid' => $alertGrid])->setFrom($this->_scopeConfig->getValue(self::XML_PATH_EMAIL_IDENTITY, \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $storeId))->addTo($this->_customer->getEmail(), $this->_customerHelper->getCustomerName($this->_customer))->getTransport();
$transport->sendMessage();
return true;
}
示例4: _populateQuoteAddrShipping
public function _populateQuoteAddrShipping(\Magento\Quote\Model\Quote $quote, \Magento\Customer\Api\Data\CustomerInterface $customerDo)
{
/** @var \Magento\Quote\Model\Quote\Address $addr */
$addr = $this->_manObj->create(\Magento\Quote\Model\Quote\Address::class);
$addr->setFirstname($customerDo->getFirstname());
$addr->setLastname($customerDo->getLastname());
$addr->setEmail($customerDo->getEmail());
$addr->setTelephone('23344556');
$addr->setStreet('Liela iela');
$addr->setCity('Riga');
$addr->setRegionId(362);
// Riga region
$addr->setPostcode('1010');
$addr->setCountryId('LV');
$quote->setShippingAddress($addr);
return $quote;
}
示例5: canSkipConfirmation
/**
* Check whether confirmation may be skipped when registering using certain email address
*
* @param CustomerInterface $customer
* @return bool
*/
protected function canSkipConfirmation($customer)
{
if (!$customer->getId()) {
return false;
}
/* If an email was used to start the registration process and it is the same email as the one
used to register, then this can skip confirmation.
*/
$skipConfirmationIfEmail = $this->registry->registry("skip_confirmation_if_email");
if (!$skipConfirmationIfEmail) {
return false;
}
return strtolower($skipConfirmationIfEmail) === strtolower($customer->getEmail());
}
示例6: validate
/**
* Validate customer attribute values.
*
* @param \Magento\Customer\Api\Data\CustomerInterface $customer
* @throws InputException
* @return void
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
* @SuppressWarnings(PHPMD.NPathComplexity)
*/
private function validate(\Magento\Customer\Api\Data\CustomerInterface $customer)
{
$exception = new InputException();
if (!\Zend_Validate::is(trim($customer->getFirstname()), 'NotEmpty')) {
$exception->addError(__(InputException::REQUIRED_FIELD, ['fieldName' => 'firstname']));
}
if (!\Zend_Validate::is(trim($customer->getLastname()), 'NotEmpty')) {
$exception->addError(__(InputException::REQUIRED_FIELD, ['fieldName' => 'lastname']));
}
$isEmailAddress = \Zend_Validate::is($customer->getEmail(), 'EmailAddress');
if (!$isEmailAddress) {
$exception->addError(__(InputException::INVALID_FIELD_VALUE, ['fieldName' => 'email', 'value' => $customer->getEmail()]));
}
$dob = $this->getAttributeMetadata('dob');
if ($dob !== null && $dob->isRequired() && '' == trim($customer->getDob())) {
$exception->addError(__(InputException::REQUIRED_FIELD, ['fieldName' => 'dob']));
}
$taxvat = $this->getAttributeMetadata('taxvat');
if ($taxvat !== null && $taxvat->isRequired() && '' == trim($customer->getTaxvat())) {
$exception->addError(__(InputException::REQUIRED_FIELD, ['fieldName' => 'taxvat']));
}
$gender = $this->getAttributeMetadata('gender');
if ($gender !== null && $gender->isRequired() && '' == trim($customer->getGender())) {
$exception->addError(__(InputException::REQUIRED_FIELD, ['fieldName' => 'gender']));
}
if ($exception->wasErrorAdded()) {
throw $exception;
}
}
示例7: loadByCustomerData
/**
* Load subscriber by customer
*
* @param \Magento\Customer\Api\Data\CustomerInterface $customer
* @return array
*/
public function loadByCustomerData(\Magento\Customer\Api\Data\CustomerInterface $customer)
{
$select = $this->connection->select()->from($this->getMainTable())->where('customer_id=:customer_id');
$result = $this->connection->fetchRow($select, ['customer_id' => $customer->getId()]);
if ($result) {
return $result;
}
$select = $this->connection->select()->from($this->getMainTable())->where('subscriber_email=:subscriber_email');
$result = $this->connection->fetchRow($select, ['subscriber_email' => $customer->getEmail()]);
if ($result) {
return $result;
}
return [];
}
示例8: populateNewCustomerDataObject
/**
* Create Data Transfer Object of customer candidate
*
* @param \Magento\Framework\App\RequestInterface $inputData
* @param \Magento\Customer\Api\Data\CustomerInterface $currentCustomerData
* @return \Magento\Customer\Api\Data\CustomerInterface
*/
private function populateNewCustomerDataObject(\Magento\Framework\App\RequestInterface $inputData, \Magento\Customer\Api\Data\CustomerInterface $currentCustomerData)
{
$customerDto = $this->customerExtractor->extract(self::FORM_DATA_EXTRACTOR_CODE, $inputData);
$customerDto->setId($currentCustomerData->getId());
if (!$customerDto->getAddresses()) {
$customerDto->setAddresses($currentCustomerData->getAddresses());
}
if (!$inputData->getParam('change_email')) {
$customerDto->setEmail($currentCustomerData->getEmail());
}
return $customerDto;
}
示例9: sendEmailTemplate
/**
* Send corresponding email template
*
* @param CustomerInterface $customer
* @param string $template configuration path of email template
* @param string $sender configuration path of email identity
* @param array $templateParams
* @param int|null $storeId
* @param string $email
* @return void
*/
private function sendEmailTemplate($customer, $template, $sender, $templateParams = [], $storeId = null, $email = null)
{
$templateId = $this->scopeConfig->getValue($template, 'store', $storeId);
if ($email === null) {
$email = $customer->getEmail();
}
$transport = $this->transportBuilder->setTemplateIdentifier($templateId)->setTemplateOptions(['area' => 'frontend', 'store' => $storeId])->setTemplateVars($templateParams)->setFrom($this->scopeConfig->getValue($sender, 'store', $storeId))->addTo($email, $this->customerViewHelper->getCustomerName($customer))->getTransport();
$transport->sendMessage();
}
示例10: sendEmailTemplate
/**
* Send corresponding email template
*
* @param CustomerInterface $customer
* @param string $template configuration path of email template
* @param string $sender configuration path of email identity
* @param array $templateParams
* @param int|null $storeId
* @param string $email
* @return $this
*/
protected function sendEmailTemplate($customer, $template, $sender, $templateParams = [], $storeId = null, $email = null)
{
$templateId = $this->scopeConfig->getValue($template, ScopeInterface::SCOPE_STORE, $storeId);
if ($email === null) {
$email = $customer->getEmail();
}
$transport = $this->transportBuilder->setTemplateIdentifier($templateId)->setTemplateOptions(['area' => Area::AREA_FRONTEND, 'store' => $storeId])->setTemplateVars($templateParams)->setFrom($this->scopeConfig->getValue($sender, ScopeInterface::SCOPE_STORE, $storeId))->addTo($email, $this->customerViewHelper->getCustomerName($customer))->getTransport();
$transport->sendMessage();
return $this;
}
示例11: validatePasswordAndLockStatus
/**
* Validate that password is correct and customer is not locked
*
* @param \Magento\Customer\Api\Data\CustomerInterface $customer
* @param string $password
* @return $this
* @throws InvalidEmailOrPasswordException
*/
public function validatePasswordAndLockStatus(\Magento\Customer\Api\Data\CustomerInterface $customer, $password)
{
$customerSecure = $this->customerRegistry->retrieveSecureData($customer->getId());
$hash = $customerSecure->getPasswordHash();
if (!$this->encryptor->validateHash($password, $hash)) {
$this->_eventManager->dispatch('customer_password_invalid', ['username' => $customer->getEmail(), 'password' => $password]);
$this->checkIfLocked($customer);
throw new InvalidEmailOrPasswordException(__('The password doesn\'t match this account.'));
}
return $this;
}