當前位置: 首頁>>代碼示例>>PHP>>正文


PHP CustomerInterface::setAddresses方法代碼示例

本文整理匯總了PHP中Magento\Customer\Api\Data\CustomerInterface::setAddresses方法的典型用法代碼示例。如果您正苦於以下問題:PHP CustomerInterface::setAddresses方法的具體用法?PHP CustomerInterface::setAddresses怎麽用?PHP CustomerInterface::setAddresses使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Magento\Customer\Api\Data\CustomerInterface的用法示例。


在下文中一共展示了CustomerInterface::setAddresses方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: execute

 /**
  * @param CustomerInterface $entity
  * @param array $arguments
  * @return CustomerInterface
  * @throws \Exception
  * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  */
 public function execute($entity, $arguments = [])
 {
     $newAddresses = [];
     foreach ($entity->getAddresses() as $address) {
         $address->setCustomerId($entity->getId());
         $newAddresses[] = $this->entityManager->save($address);
     }
     $entity->setAddresses($newAddresses);
     return $entity;
 }
開發者ID:Doability,項目名稱:magento2dev,代碼行數:17,代碼來源:SaveHandler.php

示例2: validate

 /**
  * {@inheritdoc}
  */
 public function validate(CustomerInterface $customer)
 {
     $validationResults = $this->validationResultsDataFactory->create();
     $oldAddresses = $customer->getAddresses();
     $customerModel = $this->customerFactory->create()->updateData($customer->setAddresses([]));
     $customer->setAddresses($oldAddresses);
     $result = $this->getEavValidator()->isValid($customerModel);
     if ($result === false && is_array($this->getEavValidator()->getMessages())) {
         return $validationResults->setIsValid(false)->setMessages(call_user_func_array('array_merge', $this->getEavValidator()->getMessages()));
     }
     return $validationResults->setIsValid(true)->setMessages([]);
 }
開發者ID:Doability,項目名稱:magento2dev,代碼行數:15,代碼來源:AccountManagement.php

示例3: setCustomer

 /**
  * Define customer object
  *
  * @param \Magento\Customer\Api\Data\CustomerInterface $customer
  * @return $this
  */
 public function setCustomer(\Magento\Customer\Api\Data\CustomerInterface $customer = null)
 {
     /* @TODO: Remove the method after all external usages are refactored in MAGETWO-19930 */
     $this->_customer = $customer;
     $this->setCustomerId($customer->getId());
     $origAddresses = $customer->getAddresses();
     $customer->setAddresses([]);
     $customerDataFlatArray = $this->objectFactory->create($this->extensibleDataObjectConverter->toFlatArray($customer, [], '\\Magento\\Customer\\Api\\Data\\CustomerInterface'));
     $customer->setAddresses($origAddresses);
     $this->_objectCopyService->copyFieldsetToTarget('customer_account', 'to_quote', $customerDataFlatArray, $this);
     return $this;
 }
開發者ID:niranjanssiet,項目名稱:magento2,代碼行數:18,代碼來源:Quote.php

示例4: execute

 /**
  * @param CustomerInterface $entity
  * @return CustomerInterface
  * @throws \Exception
  * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  */
 public function execute($entity, $arguments = [])
 {
     $searchCriteria = $this->searchCriteriaBuilder->addFilter('parent_id', $entity->getId())->create();
     $addressesResult = $this->addressRepository->getList($searchCriteria);
     $entity->setAddresses($addressesResult->getItems());
     return $entity;
 }
開發者ID:Doability,項目名稱:magento2dev,代碼行數:13,代碼來源:ReadHandler.php


注:本文中的Magento\Customer\Api\Data\CustomerInterface::setAddresses方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。