dataObjectHelper = $dataObjectHelper; $this->customerFactory = $customerFactory; $this->accountManagement = $accountManagement; $this->storeManager = $storeManager; } /** * Creates new customer account * * @param array $args * @return CustomerInterface * @throws LocalizedException * @throws NoSuchEntityException */ public function execute(array $args): CustomerInterface { $customerDataObject = $this->customerFactory->create(); $this->dataObjectHelper->populateWithArray( $customerDataObject, $args['input'], CustomerInterface::class ); $store = $this->storeManager->getStore(); $customerDataObject->setWebsiteId($store->getWebsiteId()); $customerDataObject->setStoreId($store->getId()); $password = array_key_exists('password', $args['input']) ? $args['input']['password'] : null; return $this->accountManagement->createAccount($customerDataObject, $password); } }