Skip to content

Commit 7e5bb80

Browse files
author
solwininfotech
committed
_getNewCustomerEmail seperate it in differnet method
1 parent 078bd69 commit 7e5bb80

File tree

1 file changed

+34
-14
lines changed

1 file changed

+34
-14
lines changed

app/code/Magento/Sales/Model/AdminOrder/Create.php

100755100644
Lines changed: 34 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2038,31 +2038,51 @@ protected function _validate()
20382038
*/
20392039
protected function _getNewCustomerEmail()
20402040
{
2041-
$emailrequired = $this->_scopeConfig->getValue(
2042-
self::XML_PATH_EMAIL_REQUIRED_CREATE_ORDER,
2043-
\Magento\Store\Model\ScopeInterface::SCOPE_STORE
2044-
);
2041+
$emailrequired = $this->getIsEmailRequired();
20452042

20462043
if ($emailrequired) {
20472044
return $this->getData('account/email');
20482045
} else {
20492046
$email = $this->getData('account/email');
20502047
if (empty($email)) {
2051-
$host = $this->_scopeConfig->getValue(
2052-
self::XML_PATH_DEFAULT_EMAIL_DOMAIN,
2053-
\Magento\Store\Model\ScopeInterface::SCOPE_STORE
2054-
);
2055-
$account = time();
2056-
$email = $account . '@' . $host;
2057-
$account = $this->getData('account');
2058-
$account['email'] = $email;
2059-
$this->setData('account', $account);
2048+
$email = $this-> generateEmail();
20602049
}
2061-
20622050
return $email;
20632051
}
20642052
}
20652053

2054+
/**
2055+
* Check email is require
2056+
*
2057+
* @return bool
2058+
*/
2059+
protected function getIsEmailRequired()
2060+
{
2061+
return $this->_scopeConfig->getValue(
2062+
self::XML_PATH_EMAIL_REQUIRED_CREATE_ORDER,
2063+
\Magento\Store\Model\ScopeInterface::SCOPE_STORE
2064+
);
2065+
}
2066+
2067+
/**
2068+
* Generate Email
2069+
*
2070+
* @return string
2071+
*/
2072+
protected function generateEmail()
2073+
{
2074+
$host = $this->_scopeConfig->getValue(
2075+
self::XML_PATH_DEFAULT_EMAIL_DOMAIN,
2076+
\Magento\Store\Model\ScopeInterface::SCOPE_STORE
2077+
);
2078+
$account = time();
2079+
$email = $account . '@' . $host;
2080+
$account = $this->getData('account');
2081+
$account['email'] = $email;
2082+
$this->setData('account', $account);
2083+
return $email;
2084+
}
2085+
20662086
/**
20672087
* Checks id shipping and billing addresses are equal.
20682088
*

0 commit comments

Comments
 (0)