Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue #20111 Fixed #20153

Closed
2 changes: 1 addition & 1 deletion app/code/Magento/Email/Model/Template.php
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ public function getVariablesOptionArray($withGroup = false)
$optionArray[] = ['value' => '{{' . $value . '}}', 'label' => __('%1', $label)];
}
if ($withGroup) {
$optionArray = ['label' => __('Template Variables'), 'value' => $optionArray];
$optionArray = [['label' => __('Template Variables'), 'value' => $optionArray]];
}
}
return $optionArray;
Expand Down
28 changes: 15 additions & 13 deletions app/code/Magento/Email/Test/Unit/Model/TemplateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -595,19 +595,21 @@ public function getVariablesOptionArrayDataProvider()
'templateVariables' => '{"store url=\"\"":"Store Url","var logo_url":"Email Logo Image Url",'
. '"var customer.name":"Customer Name"}',
'expectedResult' => [
'label' => __('Template Variables'),
'value' => [
[
'value' => '{{store url=""}}',
'label' => __('%1', 'Store Url'),
],
[
'value' => '{{var logo_url}}',
'label' => __('%1', 'Email Logo Image Url'),
],
[
'value' => '{{var customer.name}}',
'label' => __('%1', 'Customer Name'),
[
'label' => __('Template Variables'),
'value' => [
[
'value' => '{{store url=""}}',
'label' => __('%1', 'Store Url'),
],
[
'value' => '{{var logo_url}}',
'label' => __('%1', 'Email Logo Image Url'),
],
[
'value' => '{{var customer.name}}',
'label' => __('%1', 'Customer Name'),
],
],
],
],
Expand Down
17 changes: 11 additions & 6 deletions app/code/Magento/Email/view/adminhtml/web/js/variables.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,17 @@ define([
variables.each(function (variableGroup) {
if (variableGroup.label && variableGroup.value) {
this.variablesContent += '<li><b>' + variableGroup.label + '</b></li>';
variableGroup.value.each(function (variable) {
if (variable.value && variable.label) {
this.variablesContent += '<li>' +
this.prepareVariableRow(variable.value, variable.label) + '</li>';
}
}.bind(this));
if (typeof variableGroup.value === 'object' && !!variableGroup.value) {
variableGroup.value.each(function (variable) {
if (variable.value && variable.label) {
this.variablesContent += '<li>' +
this.prepareVariableRow(variable.value, variable.label) + '</li>';
}
}.bind(this));
} else {
this.variablesContent += '<li>' +
this.prepareVariableRow(variableGroup.value, variableGroup.label) + '</li>';
}
}
}.bind(this));
this.variablesContent += '</ul>';
Expand Down