当前位置: 首页>>代码示例>>PHP>>正文


PHP CustomerInterface::getId方法代码示例

本文整理汇总了PHP中Magento\Customer\Api\Data\CustomerInterface::getId方法的典型用法代码示例。如果您正苦于以下问题:PHP CustomerInterface::getId方法的具体用法?PHP CustomerInterface::getId怎么用?PHP CustomerInterface::getId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Magento\Customer\Api\Data\CustomerInterface的用法示例。


在下文中一共展示了CustomerInterface::getId方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: execute

 /**
  * @param CustomerInterface $entity
  * @param array $arguments
  * @return CustomerInterface
  * @throws \Exception
  * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  */
 public function execute($entity, $arguments = [])
 {
     $extensionAttribute = $entity->getExtensionAttributes()->getExtensionAttribute();
     $extensionAttribute->setCustomerId($entity->getId());
     $extensionAttribute = $this->entityManager->save($extensionAttribute);
     $entity->getExtensionAttributes()->setExtensionAttribute($extensionAttribute);
     return $entity;
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:15,代码来源:SaveHandler.php

示例2: 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;
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:34,代码来源:ServiceCollection.php

示例3: iHaveANewAddressWith

 /**
  * @Given I have a new address with :street :city :region :zip :country
  */
 public function iHaveANewAddressWith($street, $city, $region, $zip, $country)
 {
     $countryId = $this->getCountryId($country);
     $region = $this->loadRegionByName($region, $countryId);
     $address = $this->addressFactory->create()->setStreet((array) $street)->setCity($city)->setPostcode($zip)->setCountryId($countryId)->setRegion($region)->setRegionId($region->getRegionId())->setFirstname($this->customer->getFirstname())->setLastname($this->customer->getLastname())->setTelephone('555-555-5555')->setCustomerId($this->customer->getId());
     $this->customerAddress = $address;
 }
开发者ID:eBayEnterprise,项目名称:magento2-retail-order-management,代码行数:10,代码来源:IntegrationContext.php

示例4: 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

示例5: 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;
 }
开发者ID:degaray,项目名称:openpay-magento2-module,代码行数:15,代码来源:OpenpayCustomerRepository.php

示例6: execute

 /**
  * @param CustomerInterface $entity
  * @param array $arguments
  * @return CustomerInterface
  * @throws \Exception
  * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  */
 public function execute($entity, $arguments = [])
 {
     $metadata = $this->metadataPool->getMetadata(ExtensionAttributeInterface::class);
     $connection = $this->resourceConnection->getConnectionByName($metadata->getEntityConnectionName());
     $id = $connection->fetchOne($connection->select()->from($metadata->getEntityTable(), [$metadata->getIdentifierField()])->where('customer_id = ?', $entity->getId())->limit(1));
     $extensionAttribute = $this->extensionAttributeFactory->create();
     $extensionAttribute = $this->entityManager->load($extensionAttribute, $id);
     $customerExtension = $this->customerExtensionFactory->create(['data' => ['extension_attribute' => $extensionAttribute]]);
     $entity->setExtensionAttributes($customerExtension);
     return $entity;
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:18,代码来源:ReadHandler.php

示例7: createOrUpdateAndLogin

 /**
  * Create or update user by using data from facebook and login to store
  *
  * @param GraphUser   $facebookUser
  * @param AccessToken $accessToken
  *
  * @return CustomerInterface
  */
 private function createOrUpdateAndLogin(GraphUser $facebookUser, AccessToken $accessToken)
 {
     if (!$this->customer->getId()) {
         $this->customer->setEmail($facebookUser->getEmail());
         $this->customer->setFirstname($facebookUser->getFirstName());
         $this->customer->setLastname($facebookUser->getLastName());
         $this->customer->setMiddlename($facebookUser->getMiddleName());
         $this->customer->setGender((int) ($facebookUser->getGender() == 'male'));
     }
     $this->customer->setCustomAttribute('sf_id', $facebookUser->getId());
     $this->customer->setCustomAttribute('sf_access_token', serialize($accessToken));
     if ($this->customer->getId()) {
         $customer = $this->customerRepository->save($this->customer);
     } else {
         $customer = $this->accountManagement->createAccount($this->customer);
     }
     $this->login($customer->getId());
     return $customer;
 }
开发者ID:Viktor-V,项目名称:Facebook-Login,代码行数:27,代码来源:Index.php

示例8: getFullCustomerObject

 /**
  * Create an object with data merged from Customer and CustomerSecure
  *
  * @param CustomerInterface $customer
  * @return Data\CustomerSecure
  */
 protected function getFullCustomerObject($customer)
 {
     // No need to flatten the custom attributes or nested objects since the only usage is for email templates and
     // object passed for events
     $mergedCustomerData = $this->customerRegistry->retrieveSecureData($customer->getId());
     $customerData = $this->dataProcessor->buildOutputDataArray($customer, '\\Magento\\Customer\\Api\\Data\\CustomerInterface');
     $mergedCustomerData->addData($customerData);
     $mergedCustomerData->setData('name', $this->customerViewHelper->getCustomerName($customer));
     return $mergedCustomerData;
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:16,代码来源:AccountManagement.php

示例9: _prepareCustomerAddress

 /**
  * Create customer address and save it in the quote so that it can be used to persist later.
  *
  * @param \Magento\Customer\Api\Data\CustomerInterface $customer
  * @param \Magento\Quote\Model\Quote\Address $quoteCustomerAddress
  * @return void
  * @throws \InvalidArgumentException
  * @SuppressWarnings(PHPMD.CyclomaticComplexity)
  */
 protected function _prepareCustomerAddress($customer, $quoteCustomerAddress)
 {
     // Possible that customerId is null for new customers
     $quoteCustomerAddress->setCustomerId($customer->getId());
     $customerAddress = $quoteCustomerAddress->exportCustomerAddress();
     $quoteAddressId = $quoteCustomerAddress->getCustomerAddressId();
     $addressType = $quoteCustomerAddress->getAddressType();
     if ($quoteAddressId) {
         /** Update existing address */
         $existingAddressDataObject = $this->addressRepository->getById($quoteAddressId);
         /** Update customer address data */
         $this->dataObjectHelper->mergeDataObjects(get_class($existingAddressDataObject), $existingAddressDataObject, $customerAddress);
         $customerAddress = $existingAddressDataObject;
     } elseif ($addressType == \Magento\Quote\Model\Quote\Address::ADDRESS_TYPE_SHIPPING) {
         try {
             $billingAddressDataObject = $this->accountManagement->getDefaultBillingAddress($customer->getId());
         } catch (\Exception $e) {
             /** Billing address does not exist. */
         }
         $isShippingAsBilling = $quoteCustomerAddress->getSameAsBilling();
         if (isset($billingAddressDataObject) && $isShippingAsBilling) {
             /** Set existing billing address as default shipping */
             $customerAddress = $billingAddressDataObject;
             $customerAddress->setIsDefaultShipping(true);
         }
     }
     switch ($addressType) {
         case \Magento\Quote\Model\Quote\Address::ADDRESS_TYPE_BILLING:
             if (is_null($customer->getDefaultBilling())) {
                 $customerAddress->setIsDefaultBilling(true);
             }
             break;
         case \Magento\Quote\Model\Quote\Address::ADDRESS_TYPE_SHIPPING:
             if (is_null($customer->getDefaultShipping())) {
                 $customerAddress->setIsDefaultShipping(true);
             }
             break;
         default:
             throw new \InvalidArgumentException('Customer address type is invalid.');
     }
     $this->getQuote()->setCustomer($customer);
     $this->getQuote()->addCustomerAddress($customerAddress);
 }
开发者ID:whoople,项目名称:magento2-testing,代码行数:52,代码来源:Create.php

示例10: 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

示例11: delete

 /**
  * {@inheritdoc}
  */
 public function delete(\Magento\Customer\Api\Data\CustomerInterface $customer)
 {
     return $this->deleteById($customer->getId());
 }
开发者ID:whoople,项目名称:magento2-testing,代码行数:7,代码来源:CustomerRepository.php

示例12: 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 [];
 }
开发者ID:whoople,项目名称:magento2-testing,代码行数:20,代码来源:Subscriber.php

示例13: createQuote

 /**
  * Create a quote object with customer
  *
  * @param array $quoteData
  * @param \Magento\Customer\Api\Data\CustomerInterface $customer
  * @return \Magento\Quote\Model\Quote
  */
 protected function createQuote($quoteData, $customer)
 {
     /** @var \Magento\Customer\Api\AddressRepositoryInterface $addressService */
     $addressService = $this->objectManager->create('Magento\\Customer\\Api\\AddressRepositoryInterface');
     /** @var array $shippingAddressOverride */
     $shippingAddressOverride = empty($quoteData['shipping_address']) ? [] : $quoteData['shipping_address'];
     /** @var  \Magento\Customer\Model\Address $shippingAddress */
     $shippingAddress = $this->createCustomerAddress($shippingAddressOverride, $customer->getId());
     /** @var \Magento\Quote\Model\Quote\Address $quoteShippingAddress */
     $quoteShippingAddress = $this->objectManager->create('Magento\\Quote\\Model\\Quote\\Address');
     $quoteShippingAddress->importCustomerAddressData($addressService->getById($shippingAddress->getId()));
     /** @var array $billingAddressOverride */
     $billingAddressOverride = empty($quoteData['billing_address']) ? [] : $quoteData['billing_address'];
     /** @var  \Magento\Customer\Model\Address $billingAddress */
     $billingAddress = $this->createCustomerAddress($billingAddressOverride, $customer->getId());
     /** @var \Magento\Quote\Model\Quote\Address $quoteBillingAddress */
     $quoteBillingAddress = $this->objectManager->create('Magento\\Quote\\Model\\Quote\\Address');
     $quoteBillingAddress->importCustomerAddressData($addressService->getById($billingAddress->getId()));
     /** @var \Magento\Quote\Model\Quote $quote */
     $quote = $this->objectManager->create('Magento\\Quote\\Model\\Quote');
     $quote->setStoreId(1)->setIsActive(true)->setIsMultiShipping(false)->assignCustomerWithAddressChange($customer, $quoteBillingAddress, $quoteShippingAddress)->setCheckoutMethod('register')->setPasswordHash($this->accountManagement->getPasswordHash(static::CUSTOMER_PASSWORD));
     return $quote;
 }
开发者ID:BlackIkeEagle,项目名称:magento2-continuousphp,代码行数:30,代码来源:SetupUtil.php

示例14: getQuote

 /**
  * Get checkout quote instance by current session
  *
  * @return Quote
  * @SuppressWarnings(PHPMD.CyclomaticComplexity)
  * @SuppressWarnings(PHPMD.NPathComplexity)
  */
 public function getQuote()
 {
     $this->_eventManager->dispatch('custom_quote_process', ['checkout_session' => $this]);
     if ($this->_quote === null) {
         $quote = $this->quoteFactory->create();
         if ($this->getQuoteId()) {
             try {
                 if ($this->_loadInactive) {
                     $quote = $this->quoteRepository->get($this->getQuoteId());
                 } else {
                     $quote = $this->quoteRepository->getActive($this->getQuoteId());
                 }
                 /**
                  * If current currency code of quote is not equal current currency code of store,
                  * need recalculate totals of quote. It is possible if customer use currency switcher or
                  * store switcher.
                  */
                 if ($quote->getQuoteCurrencyCode() != $this->_storeManager->getStore()->getCurrentCurrencyCode()) {
                     $quote->setStore($this->_storeManager->getStore());
                     $this->quoteRepository->save($quote->collectTotals());
                     /*
                      * We mast to create new quote object, because collectTotals()
                      * can to create links with other objects.
                      */
                     $quote = $this->quoteRepository->get($this->getQuoteId());
                 }
             } catch (\Magento\Framework\Exception\NoSuchEntityException $e) {
                 $this->setQuoteId(null);
             }
         }
         if (!$this->getQuoteId()) {
             if ($this->_customerSession->isLoggedIn() || $this->_customer) {
                 $customerId = $this->_customer ? $this->_customer->getId() : $this->_customerSession->getCustomerId();
                 try {
                     $quote = $this->quoteRepository->getActiveForCustomer($customerId);
                     $this->setQuoteId($quote->getId());
                 } catch (\Magento\Framework\Exception\NoSuchEntityException $e) {
                 }
             } else {
                 $quote->setIsCheckoutCart(true);
                 $this->_eventManager->dispatch('checkout_quote_init', ['quote' => $quote]);
             }
         }
         if ($this->_customer) {
             $quote->setCustomer($this->_customer);
         } elseif ($this->_customerSession->isLoggedIn()) {
             $quote->setCustomer($this->customerRepository->getById($this->_customerSession->getCustomerId()));
         }
         $quote->setStore($this->_storeManager->getStore());
         $this->_quote = $quote;
     }
     if (!$this->isQuoteMasked() && !$this->_customerSession->isLoggedIn() && $this->getQuoteId()) {
         $quoteId = $this->getQuoteId();
         /** @var $quoteIdMask \Magento\Quote\Model\QuoteIdMask */
         $quoteIdMask = $this->quoteIdMaskFactory->create()->load($quoteId, 'quote_id');
         if ($quoteIdMask->getMaskedId() === null) {
             $quoteIdMask->setQuoteId($quoteId)->save();
         }
         $this->setIsQuoteMasked(true);
     }
     $remoteAddress = $this->_remoteAddress->getRemoteAddress();
     if ($remoteAddress) {
         $this->_quote->setRemoteIp($remoteAddress);
         $xForwardIp = $this->request->getServer('HTTP_X_FORWARDED_FOR');
         $this->_quote->setXForwardedFor($xForwardIp);
     }
     return $this->_quote;
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:75,代码来源:Session.php

示例15: processChangeEmailRequest

 /**
  * Process change email request
  *
  * @param \Magento\Customer\Api\Data\CustomerInterface $currentCustomerDataObject
  * @return void
  * @throws InvalidEmailOrPasswordException
  * @throws UserLockedException
  */
 private function processChangeEmailRequest(\Magento\Customer\Api\Data\CustomerInterface $currentCustomerDataObject)
 {
     if ($this->getRequest()->getParam('change_email')) {
         // authenticate user for changing email
         try {
             $this->getAuthentication()->authenticate($currentCustomerDataObject->getId(), $this->getRequest()->getPost('current_password'));
         } catch (InvalidEmailOrPasswordException $e) {
             throw new InvalidEmailOrPasswordException(__('The password doesn\'t match this account.'));
         }
     }
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:19,代码来源:EditPost.php


注:本文中的Magento\Customer\Api\Data\CustomerInterface::getId方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。