Skip to content

Commit 3d6c64a

Browse files
author
Erik Hansen
committed
Revert "MAGETWO-37672: Responsive Email Foundation"
- This reverts commit c05b10d. - Reverting to previous method of adding email variables, since the addEmailVariables method will be called three times for most emails (main email template, plus once for header and footer {{template}} directives). So checking whether a variable exists before setting it will be more performant.
1 parent f4b21cf commit 3d6c64a

File tree

1 file changed

+37
-20
lines changed

1 file changed

+37
-20
lines changed

app/code/Magento/Email/Model/AbstractTemplate.php

Lines changed: 37 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -348,8 +348,8 @@ public function getProcessedTemplate(array $variables = [])
348348
}
349349
$processor->setStoreId($storeId);
350350

351-
// Populate the variables array with store, store info, logo, etc.
352-
$variables += $this->getEmailVariables($storeId);
351+
// Populate the variables array with store, store info, logo, etc. variables
352+
$variables = $this->addEmailVariables($variables, $storeId);
353353
$processor->setVariables($variables);
354354

355355
try {
@@ -425,45 +425,62 @@ protected function getLogoAlt($store)
425425
}
426426

427427
/**
428-
* Returns variables that are used by transactional and newsletter emails
428+
* Add variables that are used by transactional and newsletter emails
429429
*
430+
* @param array $variables
430431
* @param null|string|bool|int|\Magento\Store\Model\Store $storeId
431432
* @return mixed
433+
*
434+
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
435+
* @SuppressWarnings(PHPMD.NPathComplexity)
432436
*/
433-
protected function getEmailVariables($storeId)
437+
protected function addEmailVariables($variables, $storeId)
434438
{
435439
$store = $this->storeManager->getStore($storeId);
436-
437-
$variables = [
438-
'store' => $store,
439-
'logo_url' => $this->getLogoUrl($storeId),
440-
'logo_alt' => $this->getLogoAlt($storeId),
441-
'logo_width' => $this->scopeConfig->getValue(
440+
if (!isset($variables['store'])) {
441+
$variables['store'] = $store;
442+
}
443+
if (!isset($variables['logo_url'])) {
444+
$variables['logo_url'] = $this->getLogoUrl($storeId);
445+
}
446+
if (!isset($variables['logo_alt'])) {
447+
$variables['logo_alt'] = $this->getLogoAlt($storeId);
448+
}
449+
if (!isset($variables['logo_width'])) {
450+
$variables['logo_width'] = $this->scopeConfig->getValue(
442451
self::XML_PATH_DESIGN_EMAIL_LOGO_WIDTH,
443452
ScopeInterface::SCOPE_STORE,
444453
$store
445-
),
446-
'logo_height' => $this->scopeConfig->getValue(
454+
);
455+
}
456+
if (!isset($variables['logo_height'])) {
457+
$variables['logo_height'] = $this->scopeConfig->getValue(
447458
self::XML_PATH_DESIGN_EMAIL_LOGO_HEIGHT,
448459
ScopeInterface::SCOPE_STORE,
449460
$store
450-
),
451-
'store_phone' => $this->scopeConfig->getValue(
461+
);
462+
}
463+
if (!isset($variables['store_phone'])) {
464+
$variables['store_phone'] = $this->scopeConfig->getValue(
452465
\Magento\Store\Model\Store::XML_PATH_STORE_STORE_PHONE,
453466
ScopeInterface::SCOPE_STORE,
454467
$store
455-
),
456-
'store_hours' => $this->scopeConfig->getValue(
468+
);
469+
}
470+
if (!isset($variables['store_hours'])) {
471+
$variables['store_hours'] = $this->scopeConfig->getValue(
457472
\Magento\Store\Model\Store::XML_PATH_STORE_STORE_HOURS,
458473
ScopeInterface::SCOPE_STORE,
459474
$store
460-
),
461-
'store_email' => $this->scopeConfig->getValue(
475+
);
476+
}
477+
if (!isset($variables['store_email'])) {
478+
$variables['store_email'] = $this->scopeConfig->getValue(
462479
'trans_email/ident_support/email',
463480
ScopeInterface::SCOPE_STORE,
464481
$store
465-
),
466-
];
482+
);
483+
}
467484
// If template is text mode, don't include styles
468485
if (!$this->isPlain() && !isset($variables['template_styles'])) {
469486
$variables['template_styles'] = $this->getTemplateStyles();

0 commit comments

Comments
 (0)