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


PHP CustomerInterface::getGroupId方法代碼示例

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


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

 /** @inheritdoc */
 public function getBusCodeForCustomerGroup(\Magento\Customer\Api\Data\CustomerInterface $customer)
 {
     $result = self::B_CUST_GROUP_RETAIL;
     $groupId = $customer->getGroupId();
     if ($groupId == self::M_CUST_GROUP_DISTRIBUTOR) {
         $result = self::B_CUST_GROUP_DISTRIBUTOR;
     } elseif ($groupId == self::M_CUST_GROUP_WHOLESALE) {
         $result = self::B_CUST_GROUP_WHOLESALE;
     }
     return $result;
 }
開發者ID:praxigento,項目名稱:mobi_app_generic_mage2,代碼行數:12,代碼來源:BusinessCodesManager.php

示例3: send

 /**
  * Send customer email
  *
  * @return bool
  * @SuppressWarnings(PHPMD.CyclomaticComplexity)
  * @SuppressWarnings(PHPMD.NPathComplexity)
  * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
  */
 public function send()
 {
     if ($this->_website === null || $this->_customer === null) {
         return false;
     }
     if ($this->_type == 'price' && count($this->_priceProducts) == 0 || $this->_type == 'stock' && count($this->_stockProducts) == 0) {
         return false;
     }
     if (!$this->_website->getDefaultGroup() || !$this->_website->getDefaultGroup()->getDefaultStore()) {
         return false;
     }
     if ($this->_customer->getStoreId() > 0) {
         $store = $this->_storeManager->getStore($this->_customer->getStoreId());
     } else {
         $store = $this->_website->getDefaultStore();
     }
     $storeId = $store->getId();
     if ($this->_type == 'price' && !$this->_scopeConfig->getValue(self::XML_PATH_EMAIL_PRICE_TEMPLATE, \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $storeId)) {
         return false;
     } elseif ($this->_type == 'stock' && !$this->_scopeConfig->getValue(self::XML_PATH_EMAIL_STOCK_TEMPLATE, \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $storeId)) {
         return false;
     }
     if ($this->_type != 'price' && $this->_type != 'stock') {
         return false;
     }
     $this->_appEmulation->startEnvironmentEmulation($storeId);
     if ($this->_type == 'price') {
         $this->_getPriceBlock()->setStore($store)->reset();
         foreach ($this->_priceProducts as $product) {
             $product->setCustomerGroupId($this->_customer->getGroupId());
             $this->_getPriceBlock()->addProduct($product);
         }
         $block = $this->_getPriceBlock();
         $templateId = $this->_scopeConfig->getValue(self::XML_PATH_EMAIL_PRICE_TEMPLATE, \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $storeId);
     } else {
         $this->_getStockBlock()->setStore($store)->reset();
         foreach ($this->_stockProducts as $product) {
             $product->setCustomerGroupId($this->_customer->getGroupId());
             $this->_getStockBlock()->addProduct($product);
         }
         $block = $this->_getStockBlock();
         $templateId = $this->_scopeConfig->getValue(self::XML_PATH_EMAIL_STOCK_TEMPLATE, \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $storeId);
     }
     $alertGrid = $this->_appState->emulateAreaCode(\Magento\Framework\App\Area::AREA_FRONTEND, [$block, 'toHtml']);
     $this->_appEmulation->stopEnvironmentEmulation();
     $transport = $this->_transportBuilder->setTemplateIdentifier($templateId)->setTemplateOptions(['area' => \Magento\Framework\App\Area::AREA_FRONTEND, 'store' => $storeId])->setTemplateVars(['customerName' => $this->_customerHelper->getCustomerName($this->_customer), 'alertGrid' => $alertGrid])->setFrom($this->_scopeConfig->getValue(self::XML_PATH_EMAIL_IDENTITY, \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $storeId))->addTo($this->_customer->getEmail(), $this->_customerHelper->getCustomerName($this->_customer))->getTransport();
     $transport->sendMessage();
     return true;
 }
開發者ID:nja78,項目名稱:magento2,代碼行數:57,代碼來源:Email.php

示例4: setCustomerData

 /**
  * Set customer object and setting customer id in session
  *
  * @param   CustomerData $customer
  * @return  $this
  */
 public function setCustomerData(CustomerData $customer)
 {
     $this->_customer = $customer;
     if ($customer === null) {
         $this->setCustomerId(null);
     } else {
         $this->_httpContext->setValue(Context::CONTEXT_GROUP, $customer->getGroupId(), \Magento\Customer\Model\Group::NOT_LOGGED_IN_ID);
         $this->setCustomerId($customer->getId());
     }
     return $this;
 }
開發者ID:pradeep-wagento,項目名稱:magento2,代碼行數:17,代碼來源:Session.php

示例5: getAvataxTaxCodeForCustomer

 /**
  * Get AvaTax Customer Usage Type for customer
  *
  * @param \Magento\Customer\Api\Data\CustomerInterface $customer
  * @return null|string
  */
 public function getAvataxTaxCodeForCustomer(\Magento\Customer\Api\Data\CustomerInterface $customer)
 {
     $customerGroupId = $customer->getGroupId();
     if (!$customerGroupId) {
         return null;
     }
     try {
         $customerGroup = $this->customerGroupRepository->getById($customerGroupId);
         $taxClassId = $customerGroup->getTaxClassId();
     } catch (\Magento\Framework\Exception\NoSuchEntityException $e) {
         return null;
     }
     return $this->getAvaTaxTaxCode($taxClassId);
 }
開發者ID:classyllama,項目名稱:ClassyLlama_AvaTax,代碼行數:20,代碼來源:TaxClass.php


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