예제 #1
0
 /**
  * @param string $formCode
  * @param RequestInterface $request
  * @return \Magento\Customer\Service\V1\Data\Customer
  */
 public function extract($formCode, RequestInterface $request)
 {
     $customerForm = $this->formFactory->create('customer', $formCode);
     $allowedAttributes = $customerForm->getAllowedAttributes();
     $isGroupIdEmpty = true;
     $customerData = array();
     foreach ($allowedAttributes as $attribute) {
         // confirmation in request param is the repeated password, not a confirmation code.
         if ($attribute === 'confirmation') {
             continue;
         }
         $attributeCode = $attribute->getAttributeCode();
         if ($attributeCode == 'group_id') {
             $isGroupIdEmpty = false;
         }
         $customerData[$attributeCode] = $request->getParam($attributeCode);
     }
     $this->customerBuilder->populateWithArray($customerData);
     $store = $this->storeManager->getStore();
     if ($isGroupIdEmpty) {
         $this->customerBuilder->setGroupId($this->groupService->getDefaultGroup($store->getId())->getId());
     }
     $this->customerBuilder->setWebsiteId($store->getWebsiteId());
     $this->customerBuilder->setStoreId($store->getId());
     return $this->customerBuilder->create();
 }
예제 #2
0
 /**
  * @param $testGroup
  * @param $storeId
  */
 private function assertDefaultGroupMatches($testGroup, $storeId)
 {
     $group = $this->_groupService->getDefaultGroup($storeId);
     $this->assertEquals($testGroup['id'], $group->getId());
     $this->assertEquals($testGroup['code'], $group->getCode());
     $this->assertEquals($testGroup['tax_class_id'], $group->getTaxClassId());
 }
예제 #3
0
파일: Tax.php 프로젝트: aiesh/magento2
 /**
  * Fetch default customer tax classId
  *
  * @param null|Store|string|int $store
  * @return int
  */
 private function _getDefaultCustomerTaxClassId($store = null)
 {
     if (is_null($this->_defaultCustomerTaxClassId)) {
         //Not catching the exception here since default group is expected
         $defaultCustomerGroup = $this->_groupService->getDefaultGroup($store);
         $this->_defaultCustomerTaxClassId = $defaultCustomerGroup->getTaxClassId();
     }
     return $this->_defaultCustomerTaxClassId;
 }
예제 #4
0
 /**
  * Fetch default customer tax class
  *
  * @param null|Store|string|int $store
  * @return int
  */
 public function getDefaultCustomerTaxClass($store = null)
 {
     if ($this->_defaultCustomerTaxClass === null) {
         //Not catching the exception here since default group is expected
         $defaultCustomerGroup = $this->_groupService->getDefaultGroup($store);
         $this->_defaultCustomerTaxClass = $defaultCustomerGroup->getTaxClassId();
     }
     return $this->_defaultCustomerTaxClass;
 }
예제 #5
0
파일: Data.php 프로젝트: aiesh/magento2
 /**
  * Get default customer group id
  *
  * @param \Magento\Store\Model\Store|string|int $store
  * @return int
  */
 public function getDefaultCustomerGroupId($store = null)
 {
     return $this->_groupService->getDefaultGroup($store)->getId();
 }
예제 #6
0
파일: Customer.php 프로젝트: aiesh/magento2
 /**
  * Retrieve customer group identifier
  *
  * @return int
  */
 public function getGroupId()
 {
     if (!$this->hasData('group_id')) {
         $storeId = $this->getStoreId() ? $this->getStoreId() : $this->_storeManager->getStore()->getId();
         $groupId = $this->_groupService->getDefaultGroup($storeId)->getId();
         $this->setData('group_id', $groupId);
     }
     return $this->getData('group_id');
 }