Skip to content

Commit 2ff5e24

Browse files
committed
MAGETWO-59489: [Github] Can't change reset password template #6885
1 parent 100af87 commit 2ff5e24

File tree

2 files changed

+25
-3
lines changed

2 files changed

+25
-3
lines changed

app/code/Magento/Customer/Model/EmailNotification.php

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,10 @@ class EmailNotification implements EmailNotificationInterface
6060
self::NEW_ACCOUNT_EMAIL_CONFIRMATION => self::XML_PATH_CONFIRM_EMAIL_TEMPLATE,
6161
];
6262

63+
const TEMPLATE_MAP = [
64+
self::XML_PATH_FORGOT_EMAIL_TEMPLATE => self::XML_PATH_RESET_PASSWORD_TEMPLATE
65+
];
66+
6367
/**#@-*/
6468

6569
/**
@@ -241,11 +245,10 @@ private function sendEmailTemplate(
241245
$storeId = null,
242246
$email = null
243247
) {
244-
$templateId = $this->scopeConfig->getValue($template, 'store', $storeId);
248+
$templateId = $this->getCorrectTemplateId($template, 'store', $storeId);
245249
if ($email === null) {
246250
$email = $customer->getEmail();
247251
}
248-
249252
$transport = $this->transportBuilder->setTemplateIdentifier($templateId)
250253
->setTemplateOptions(['area' => 'frontend', 'store' => $storeId])
251254
->setTemplateVars($templateParams)
@@ -378,4 +381,23 @@ public function newAccount(
378381
$storeId
379382
);
380383
}
384+
385+
/**
386+
* Get templateId include considering template map
387+
*
388+
* @param string $template
389+
* @param string $scopeType
390+
* @param string $storeId
391+
* @return string
392+
*/
393+
private function getCorrectTemplateId($template, $scopeType, $storeId)
394+
{
395+
if (array_key_exists($template, self::TEMPLATE_MAP)) {
396+
$templateId = $this->scopeConfig->getValue(self::TEMPLATE_MAP[$template], $scopeType, $storeId);
397+
if ($templateId) {
398+
return $templateId;
399+
}
400+
}
401+
return $this->scopeConfig->getValue($template, $scopeType, $storeId);
402+
}
381403
}

app/code/Magento/Customer/Test/Unit/Model/EmailNotificationTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -545,7 +545,7 @@ public function testPasswordResetConfirmation()
545545

546546
$this->scopeConfigMock->expects($this->at(0))
547547
->method('getValue')
548-
->with(EmailNotification::XML_PATH_FORGOT_EMAIL_TEMPLATE, ScopeInterface::SCOPE_STORE, $customerStoreId)
548+
->with(EmailNotification::XML_PATH_RESET_PASSWORD_TEMPLATE, ScopeInterface::SCOPE_STORE, $customerStoreId)
549549
->willReturn($templateIdentifier);
550550
$this->scopeConfigMock->expects($this->at(1))
551551
->method('getValue')

0 commit comments

Comments
 (0)