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


PHP CustomerInterface::getMiddlename方法代码示例

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


在下文中一共展示了CustomerInterface::getMiddlename方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:34,代码来源:ServiceCollection.php

示例2: getCustomerName

 /**
  * Concatenate all customer name parts into full customer name.
  *
  * @param CustomerInterface $customerData
  * @return string
  */
 public function getCustomerName(CustomerInterface $customerData)
 {
     $name = '';
     $prefixMetadata = $this->_customerMetadataService->getAttributeMetadata('prefix');
     if ($prefixMetadata->isVisible() && $customerData->getPrefix()) {
         $name .= $customerData->getPrefix() . ' ';
     }
     $name .= $customerData->getFirstname();
     $middleNameMetadata = $this->_customerMetadataService->getAttributeMetadata('middlename');
     if ($middleNameMetadata->isVisible() && $customerData->getMiddlename()) {
         $name .= ' ' . $customerData->getMiddlename();
     }
     $name .= ' ' . $customerData->getLastname();
     $suffixMetadata = $this->_customerMetadataService->getAttributeMetadata('suffix');
     if ($suffixMetadata->isVisible() && $customerData->getSuffix()) {
         $name .= ' ' . $customerData->getSuffix();
     }
     return $name;
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:25,代码来源:View.php


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