Skip to content

Commit f5f1847

Browse files
committed
MC-42486: Region ID and Country ID values and not properly converted in Email templates
- Converted country id and region id into country name and region name
1 parent a56ed0f commit f5f1847

File tree

4 files changed

+25
-10
lines changed

4 files changed

+25
-10
lines changed

app/code/Magento/Email/Model/Template/Filter.php

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
use Magento\Variable\Model\Variable;
3737
use Magento\Variable\Model\VariableFactory;
3838
use Psr\Log\LoggerInterface;
39+
use Magento\Store\Model\Information as StoreInformation;
3940

4041
/**
4142
* Core Email Template Filter Model
@@ -201,6 +202,11 @@ class Filter extends Template
201202
*/
202203
private $pubDirectoryRead;
203204

205+
/**
206+
* @var StoreInformation
207+
*/
208+
private $storeInformation;
209+
204210

205211
/**
206212
* Filter constructor.
@@ -222,6 +228,7 @@ class Filter extends Template
222228
* @param CssInliner $cssInliner
223229
* @param array $variables
224230
* @param array $directiveProcessors
231+
* @param StoreInformation|null $storeInformation
225232
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
226233
*/
227234
public function __construct(
@@ -242,7 +249,8 @@ public function __construct(
242249
Filesystem $pubDirectory,
243250
CssInliner $cssInliner,
244251
$variables = [],
245-
array $directiveProcessors = []
252+
array $directiveProcessors = [],
253+
StoreInformation $storeInformation = null
246254
) {
247255
$this->_escaper = $escaper;
248256
$this->_assetRepo = $assetRepo;
@@ -259,6 +267,8 @@ public function __construct(
259267
$this->cssProcessor = $cssProcessor;
260268
$this->pubDirectory = $pubDirectory;
261269
$this->configVariables = $configVariables;
270+
$this->storeInformation = $storeInformation ?:
271+
\Magento\Framework\App\ObjectManager::getInstance()->get(StoreInformation::class);
262272
parent::__construct($string, $variables, $directiveProcessors, $variableResolver);
263273
}
264274

@@ -825,18 +835,29 @@ private function validateProtocolDirectiveHttpScheme(array $params) : void
825835
*
826836
* @param string[] $construction
827837
* @return string
838+
* @throws NoSuchEntityException
828839
*/
829840
public function configDirective($construction)
830841
{
831842
$configValue = '';
832843
$params = $this->getParameters($construction[2]);
833844
$storeId = $this->getStoreId();
845+
$store = $this->_storeManager->getStore($storeId);
846+
$storeInformationObj = $this->storeInformation
847+
->getStoreInformationObject($store);
834848
if (isset($params['path']) && $this->isAvailableConfigVariable($params['path'])) {
835849
$configValue = $this->_scopeConfig->getValue(
836850
$params['path'],
837851
ScopeInterface::SCOPE_STORE,
838852
$storeId
839853
);
854+
if ($params['path'] == "general/store_information/country_id") {
855+
$configValue = $storeInformationObj->getData('country');
856+
} elseif ($params['path'] == "general/store_information/region_id") {
857+
$configValue = $storeInformationObj->getData('region')?
858+
$storeInformationObj->getData('region'):
859+
$configValue;
860+
}
840861
}
841862
return $configValue;
842863
}

app/code/Magento/Email/view/frontend/email/footer.html

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,7 @@
66
-->
77
<!--@subject {{trans "Footer"}} @-->
88
<!--@vars {
9-
"var store.frontend_name":"Store Name",
10-
"var store_country":"Country Name",
11-
"var store_region":"Region Name"
9+
"var store.frontend_name":"Store Name"
1210
} @-->
1311

1412
<!-- End Content -->

app/code/Magento/Email/view/frontend/email/header.html

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,7 @@
1010
"var logo_alt":"Email Logo Alt Text",
1111
"var logo_height":"Email Logo Image Height",
1212
"var logo_width":"Email Logo Image Width",
13-
"var template_styles|raw":"Template CSS",
14-
"var store_country":"Country Name",
15-
"var store_region":"Region Name"
13+
"var template_styles|raw":"Template CSS"
1614
} @-->
1715

1816
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

app/design/frontend/Magento/luma/Magento_Email/email/footer.html

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,7 @@
1111
"var url_customer_service":"Customer Service URL",
1212
"var store_phone":"Store Phone",
1313
"var store_hours":"Store Hours",
14-
"var store.formatted_address|raw":"Store Address",
15-
"var store_country":"Country Name",
16-
"var store_region":"Region Name"
14+
"var store.formatted_address|raw":"Store Address"
1715
} @-->
1816

1917
<!-- End Content -->

0 commit comments

Comments
 (0)