/** * @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(); }
/** * @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()); }
/** * 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; }
/** * 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; }
/** * 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(); }
/** * 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'); }