本文整理汇总了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;
}
示例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([]);
}
示例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;
}
示例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;
}