From b5265e8446441ebcb38981b69e3494653c106818 Mon Sep 17 00:00:00 2001 From: Oleksandr Kravchuk Date: Mon, 16 Sep 2019 10:36:46 +0300 Subject: [PATCH] Update Create.php --- .../Magento/Sales/Model/AdminOrder/Create.php | 23 ++++++++----------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/app/code/Magento/Sales/Model/AdminOrder/Create.php b/app/code/Magento/Sales/Model/AdminOrder/Create.php index 1446f4ad1153d..d51fa0778b192 100644 --- a/app/code/Magento/Sales/Model/AdminOrder/Create.php +++ b/app/code/Magento/Sales/Model/AdminOrder/Create.php @@ -2038,17 +2038,13 @@ protected function _validate() */ protected function _getNewCustomerEmail() { - $emailrequired = $this->getIsEmailRequired(); - - if ($emailrequired) { - return $this->getData('account/email'); - } else { - $email = $this->getData('account/email'); - if (empty($email)) { - $email = $this-> generateEmail(); - } - return $email; + $email = $this->getData('account/email'); + + if ($email || $this->getIsEmailRequired()) { + return $email; } + + return $this->generateEmail(); } /** @@ -2056,9 +2052,9 @@ protected function _getNewCustomerEmail() * * @return bool */ - protected function getIsEmailRequired() + private function getIsEmailRequired(): bool { - return $this->_scopeConfig->getValue( + return (bool)$this->_scopeConfig->getValue( self::XML_PATH_EMAIL_REQUIRED_CREATE_ORDER, \Magento\Store\Model\ScopeInterface::SCOPE_STORE ); @@ -2069,7 +2065,7 @@ protected function getIsEmailRequired() * * @return string */ - protected function generateEmail() + private function generateEmail(): string { $host = $this->_scopeConfig->getValue( self::XML_PATH_DEFAULT_EMAIL_DOMAIN, @@ -2080,6 +2076,7 @@ protected function generateEmail() $account = $this->getData('account'); $account['email'] = $email; $this->setData('account', $account); + return $email; }