コード例 #1
0
ファイル: Quote.php プロジェクト: niranjanssiet/magento2
 /**
  * Retrieve customer model object
  *
  * @return \Magento\Customer\Api\Data\CustomerInterface|\Magento\Framework\Api\ExtensibleDataInterface
  */
 public function getCustomer()
 {
     /**
      * @TODO: Remove the method after all external usages are refactored in MAGETWO-19930
      * _customer and _customerFactory variables should be eliminated as well
      */
     if (null === $this->_customer) {
         try {
             $this->_customer = $this->customerRepository->getById($this->getCustomerId());
         } catch (\Magento\Framework\Exception\NoSuchEntityException $e) {
             $this->_customer = $this->customerDataFactory->create();
             $this->_customer->setId(null);
         }
     }
     return $this->_customer;
 }
コード例 #2
0
ファイル: Converter.php プロジェクト: pavelnovitsky/magento2
 /**
  * Update customer model with the data from the data object
  *
  * @param Customer $customerModel
  * @param CustomerDataObject $customerData
  * @return void
  */
 public function updateCustomerModel(\Magento\Customer\Model\Customer $customerModel, CustomerDataObject $customerData)
 {
     $attributes = ExtensibleDataObjectConverter::toFlatArray($customerData);
     foreach ($attributes as $attributeCode => $attributeValue) {
         $customerModel->setDataUsingMethod($attributeCode, $attributeValue);
     }
     $customerId = $customerData->getId();
     if ($customerId) {
         $customerModel->setId($customerId);
     }
     // Need to use attribute set or future calls to customerModel::save can cause data loss
     if (!$customerModel->getAttributeSetId()) {
         $customerModel->setAttributeSetId(CustomerMetadataServiceInterface::ATTRIBUTE_SET_ID_CUSTOMER);
     }
 }