Skip to content

Commit a56ed0f

Browse files
committed
MC-42486: Region ID and Country ID values and not properly converted in Email templates
- Backward compatible changes added.
1 parent 9da91f1 commit a56ed0f

File tree

10 files changed

+3
-156
lines changed

10 files changed

+3
-156
lines changed

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

Lines changed: 0 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@
1515
use Magento\Store\Model\ScopeInterface;
1616
use Magento\Store\Model\Store;
1717
use Magento\MediaStorage\Helper\File\Storage\Database;
18-
use \Magento\Directory\Api\CountryInformationAcquirerInterface;
19-
use \Magento\Directory\Model\RegionFactory;
2018

2119
/**
2220
* Template model class.
@@ -60,16 +58,6 @@ abstract class AbstractTemplate extends AbstractModel implements TemplateTypesIn
6058
*/
6159
const XML_PATH_DESIGN_EMAIL_LOGO_HEIGHT = 'design/email/logo_height';
6260

63-
/**
64-
* Email country id
65-
*/
66-
const XML_PATH_GENERAL_STORE_INFORMATION_COUNTRY_ID = 'general/store_information/country_id';
67-
68-
/**
69-
* Email region id
70-
*/
71-
const XML_PATH_GENERAL_STORE_INFORMATION_REGION_ID = 'general/store_information/region_id';
72-
7361
/**
7462
* Configuration of design package for template
7563
*
@@ -177,16 +165,6 @@ abstract class AbstractTemplate extends AbstractModel implements TemplateTypesIn
177165
*/
178166
private $urlModel;
179167

180-
/**
181-
* @var \Magento\Directory\Api\CountryInformationAcquirerInterface
182-
*/
183-
protected $countryInformationAcquirerInterface;
184-
185-
/**
186-
* @var \Magento\Directory\Model\RegionFactory
187-
*/
188-
protected $regionFactory;
189-
190168
/**
191169
* @var Database
192170
*/
@@ -205,8 +183,6 @@ abstract class AbstractTemplate extends AbstractModel implements TemplateTypesIn
205183
* @param \Magento\Email\Model\TemplateFactory $templateFactory
206184
* @param \Magento\Framework\Filter\FilterManager $filterManager
207185
* @param \Magento\Framework\UrlInterface $urlModel
208-
* @param CountryInformationAcquirerInterface $countryInformationAcquirerInterface
209-
* @param RegionFactory $regionFactory
210186
* @param array $data
211187
* @param Database $fileStorageDatabase
212188
*
@@ -225,8 +201,6 @@ public function __construct(
225201
\Magento\Email\Model\TemplateFactory $templateFactory,
226202
\Magento\Framework\Filter\FilterManager $filterManager,
227203
\Magento\Framework\UrlInterface $urlModel,
228-
CountryInformationAcquirerInterface $countryInformationAcquirerInterface,
229-
RegionFactory $regionFactory,
230204
array $data = [],
231205
Database $fileStorageDatabase = null
232206
) {
@@ -242,8 +216,6 @@ public function __construct(
242216
$this->templateFactory = $templateFactory;
243217
$this->filterManager = $filterManager;
244218
$this->urlModel = $urlModel;
245-
$this->countryInformationAcquirerInterface = $countryInformationAcquirerInterface;
246-
$this->regionFactory = $regionFactory;
247219
$this->fileStorageDatabase = $fileStorageDatabase ?:
248220
\Magento\Framework\App\ObjectManager::getInstance()->get(Database::class);
249221
parent::__construct($context, $registry, null, null, $data);
@@ -540,12 +512,6 @@ protected function addEmailVariables($variables, $storeId)
540512
$store
541513
);
542514
}
543-
if (!isset($variables['store_country'])) {
544-
$variables['store_country'] = $this->getCountryName($store);
545-
}
546-
if (!isset($variables['store_region'])) {
547-
$variables['store_region'] = $this->getRegionName($store);
548-
}
549515
// If template is text mode, don't include styles
550516
if (!$this->isPlain() && !isset($variables['template_styles'])) {
551517
$variables['template_styles'] = $this->getTemplateStyles();
@@ -807,46 +773,4 @@ public function getUrl(Store $store, $route = '', $params = [])
807773
}
808774
return $url->getUrl($route, $params);
809775
}
810-
811-
/**
812-
* Get country name for the specified store.
813-
*
814-
* @param Store $store
815-
* @return string
816-
*/
817-
protected function getCountryName($store)
818-
{
819-
$countryName = '';
820-
$store = $this->storeManager->getStore($store);
821-
$countryId = $this->scopeConfig->getValue(
822-
self::XML_PATH_GENERAL_STORE_INFORMATION_COUNTRY_ID,
823-
ScopeInterface::SCOPE_STORE,
824-
$store
825-
);
826-
if ($countryId) {
827-
$countryName = $this->countryInformationAcquirerInterface->getCountryInfo($countryId)->getFullNameLocale();
828-
}
829-
return $countryName;
830-
}
831-
832-
/**
833-
* Get region name for the specified store.
834-
*
835-
* @param Store $store
836-
* @return string
837-
*/
838-
protected function getRegionName($store)
839-
{
840-
$regionName = '';
841-
$store = $this->storeManager->getStore($store);
842-
$regionId = $this->scopeConfig->getValue(
843-
self::XML_PATH_GENERAL_STORE_INFORMATION_REGION_ID,
844-
ScopeInterface::SCOPE_STORE,
845-
$store
846-
);
847-
if ($regionId) {
848-
$regionName = $this->regionFactory->create()->load($regionId)->getName();
849-
}
850-
return $regionName;
851-
}
852776
}

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

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,6 @@ class BackendTemplate extends Template
3535
* @param \Magento\Email\Model\TemplateFactory $templateFactory
3636
* @param \Magento\Framework\Filter\FilterManager $filterManager
3737
* @param \Magento\Framework\UrlInterface $urlModel
38-
* @param \Magento\Directory\Api\CountryInformationAcquirerInterface $countryInformationAcquirerInterface
39-
* @param \Magento\Directory\Model\RegionFactory $regionFactory
4038
* @param \Magento\Email\Model\Template\FilterFactory $filterFactory
4139
* @param \Magento\Config\Model\Config\Structure $structure
4240
* @param array $data
@@ -57,8 +55,6 @@ public function __construct(
5755
\Magento\Email\Model\TemplateFactory $templateFactory,
5856
\Magento\Framework\Filter\FilterManager $filterManager,
5957
\Magento\Framework\UrlInterface $urlModel,
60-
\Magento\Directory\Api\CountryInformationAcquirerInterface $countryInformationAcquirerInterface,
61-
\Magento\Directory\Model\RegionFactory $regionFactory,
6258
\Magento\Email\Model\Template\FilterFactory $filterFactory,
6359
\Magento\Config\Model\Config\Structure $structure,
6460
array $data = [],
@@ -78,8 +74,6 @@ public function __construct(
7874
$templateFactory,
7975
$filterManager,
8076
$urlModel,
81-
$countryInformationAcquirerInterface,
82-
$regionFactory,
8377
$filterFactory,
8478
$data,
8579
$serializer

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

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,6 @@ class Template extends AbstractTemplate implements \Magento\Framework\Mail\Templ
118118
* @param TemplateFactory $templateFactory
119119
* @param \Magento\Framework\Filter\FilterManager $filterManager
120120
* @param \Magento\Framework\UrlInterface $urlModel
121-
* @param \Magento\Directory\Api\CountryInformationAcquirerInterface $countryInformationAcquirerInterface
122-
* @param \Magento\Directory\Model\RegionFactory $regionFactory
123121
* @param Template\FilterFactory $filterFactory
124122
* @param array $data
125123
* @param \Magento\Framework\Serialize\Serializer\Json|null $serializer
@@ -140,8 +138,6 @@ public function __construct(
140138
\Magento\Email\Model\TemplateFactory $templateFactory,
141139
\Magento\Framework\Filter\FilterManager $filterManager,
142140
\Magento\Framework\UrlInterface $urlModel,
143-
\Magento\Directory\Api\CountryInformationAcquirerInterface $countryInformationAcquirerInterface,
144-
\Magento\Directory\Model\RegionFactory $regionFactory,
145141
\Magento\Email\Model\Template\FilterFactory $filterFactory,
146142
array $data = [],
147143
\Magento\Framework\Serialize\Serializer\Json $serializer = null
@@ -162,8 +158,6 @@ public function __construct(
162158
$templateFactory,
163159
$filterManager,
164160
$urlModel,
165-
$countryInformationAcquirerInterface,
166-
$regionFactory,
167161
$data
168162
);
169163
}

app/code/Magento/Email/Test/Unit/Model/AbstractTemplateTest.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,7 @@ public function testGetProcessedTemplate($variables, $templateType, $storeId, $e
253253
->method('filter')
254254
->with($preparedTemplateText)
255255
->willReturn($expectedResult);
256+
256257
$this->assertEquals($expectedResult, $model->getProcessedTemplate($variables));
257258
}
258259

@@ -338,8 +339,6 @@ public function getProcessedTemplateProvider()
338339
'store_phone' => null,
339340
'store_hours' => null,
340341
'store_email' => null,
341-
'store_country' => null,
342-
'store_region' => null
343342
],
344343
'expectedResult' => 'expected result',
345344
],
@@ -360,8 +359,6 @@ public function getProcessedTemplateProvider()
360359
'store_hours' => null,
361360
'store_email' => null,
362361
'template_styles' => null,
363-
'store_country' => null,
364-
'store_region' => null
365362
],
366363
'expectedResult' => 'expected result',
367364
],

app/code/Magento/Email/Test/Unit/Model/TemplateTest.php

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@
2424
use Magento\Framework\Registry;
2525
use Magento\Framework\Serialize\Serializer\Json;
2626
use Magento\Framework\Url;
27-
use Magento\Directory\Api\CountryInformationAcquirerInterface;
28-
use Magento\Directory\Model\RegionFactory;
2927
use Magento\Framework\View\Asset\Repository;
3028
use Magento\Framework\View\DesignInterface;
3129
use Magento\Setup\Module\I18n\Locale;
@@ -100,16 +98,6 @@ class TemplateTest extends TestCase
10098
*/
10199
private $urlModel;
102100

103-
/**
104-
* @var CountryInformationAcqirerInterface|MockObject
105-
*/
106-
private $countryInformationAcquirerInterface;
107-
108-
/**
109-
* @var RegionFactory|MockObject
110-
*/
111-
private $regionFactory;
112-
113101
/**
114102
* @var Config|MockObject
115103
*/
@@ -175,15 +163,6 @@ protected function setUp(): void
175163
->disableOriginalConstructor()
176164
->getMock();
177165

178-
$this->countryInformationAcquirerInterface = $this->getMockBuilder(CountryInformationAcquirerInterface::class)
179-
->disableOriginalConstructor()
180-
->getMock();
181-
182-
$this->regionFactory = $this->getMockBuilder(RegionFactory::class)
183-
->setMethods(['create'])
184-
->disableOriginalConstructor()
185-
->getMock();
186-
187166
$this->filterFactory = $this->getMockBuilder(FilterFactory::class)
188167
->setMethods(['create'])
189168
->disableOriginalConstructor()
@@ -217,8 +196,6 @@ protected function getModelMock(array $mockedMethods = [])
217196
$this->templateFactory,
218197
$this->filterManager,
219198
$this->urlModel,
220-
$this->countryInformationAcquirerInterface,
221-
$this->regionFactory,
222199
$this->filterFactory,
223200
[],
224201
$this->serializerMock
@@ -797,8 +774,6 @@ public function testGetType($templateType, $expectedResult)
797774
$this->createMock(TemplateFactory::class),
798775
$this->createMock(FilterManager::class),
799776
$this->createMock(Url::class),
800-
$this->createMock(CountryInformationAcquirerInterface::class),
801-
$this->createMock(RegionFactory::class),
802777
$this->createMock(FilterFactory::class),
803778
[],
804779
$this->createMock(Json::class)

app/code/Magento/Email/composer.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@
1515
"magento/module-require-js": "*",
1616
"magento/module-media-storage": "*",
1717
"magento/module-variable": "*",
18-
"magento/module-ui": "*",
19-
"magento/module-directory": "*"
18+
"magento/module-ui": "*"
2019
},
2120
"suggest": {
2221
"magento/module-theme": "*"

app/code/Magento/Newsletter/Model/Template.php

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,6 @@ class Template extends \Magento\Email\Model\AbstractTemplate
8181
* @param \Magento\Framework\Filter\FilterManager $filterManager
8282
* @param \Magento\Framework\Url|\Magento\Framework\UrlInterface $urlModel
8383
* @param \Magento\Framework\App\RequestInterface $request
84-
* @param \Magento\Directory\Api\CountryInformationAcquirerInterface $countryInformationAcquirerInterface
85-
* @param \Magento\Directory\Model\RegionFactory $regionFactory
8684
* @param \Magento\Newsletter\Model\Template\FilterFactory $filterFactory ,
8785
* @param array $data
8886
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
@@ -100,8 +98,6 @@ public function __construct(
10098
\Magento\Email\Model\TemplateFactory $templateFactory,
10199
\Magento\Framework\Filter\FilterManager $filterManager,
102100
\Magento\Framework\UrlInterface $urlModel,
103-
\Magento\Directory\Api\CountryInformationAcquirerInterface $countryInformationAcquirerInterface,
104-
\Magento\Directory\Model\RegionFactory $regionFactory,
105101
\Magento\Framework\App\RequestInterface $request,
106102
\Magento\Newsletter\Model\Template\FilterFactory $filterFactory,
107103
array $data = []
@@ -119,8 +115,6 @@ public function __construct(
119115
$templateFactory,
120116
$filterManager,
121117
$urlModel,
122-
$countryInformationAcquirerInterface,
123-
$regionFactory,
124118
$data
125119
);
126120
$this->_storeManager = $storeManager;

app/code/Magento/Newsletter/Test/Unit/Model/TemplateTest.php

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88
namespace Magento\Newsletter\Test\Unit\Model;
99

10-
use Magento\Directory\Model\RegionFactory;
1110
use Magento\Email\Model\Template\Config;
1211
use Magento\Email\Model\TemplateFactory;
1312
use Magento\Framework\App\Area;
@@ -20,7 +19,6 @@
2019
use Magento\Framework\Model\Context;
2120
use Magento\Framework\Registry;
2221
use Magento\Framework\Url;
23-
use Magento\Directory\Api\CountryInformationAcquirerInterface;
2422
use Magento\Framework\View\Asset\Repository;
2523
use Magento\Framework\View\DesignInterface;
2624
use Magento\Newsletter\Model\Subscriber;
@@ -105,16 +103,6 @@ class TemplateTest extends TestCase
105103
*/
106104
private $urlModelMock;
107105

108-
/**
109-
* @var CountryInformationAcqirerInterface|MockObject
110-
*/
111-
private $countryInformationAcquirerInterface;
112-
113-
/**
114-
* @var RegionFactory|MockObject
115-
*/
116-
private $regionFactory;
117-
118106
/**
119107
* @var RequestInterface|MockObject
120108
*/
@@ -192,15 +180,6 @@ protected function setUp(): void
192180
->disableOriginalConstructor()
193181
->getMock();
194182

195-
$this->countryInformationAcquirerInterface = $this->getMockBuilder(CountryInformationAcquirerInterface::class)
196-
->disableOriginalConstructor()
197-
->getMock();
198-
199-
$this->regionFactory = $this->getMockBuilder(RegionFactory::class)
200-
->setMethods(['create'])
201-
->disableOriginalConstructor()
202-
->getMock();
203-
204183
$this->requestMock = $this->getMockBuilder(RequestInterface::class)
205184
->disableOriginalConstructor()
206185
->getMockForAbstractClass();
@@ -234,8 +213,6 @@ protected function getModelMock(array $mockedMethods = [])
234213
$this->templateFactoryMock,
235214
$this->filterManagerMock,
236215
$this->urlModelMock,
237-
$this->countryInformationAcquirerInterface,
238-
$this->regionFactory,
239216
$this->requestMock,
240217
$this->filterFactoryMock,
241218
]
@@ -410,8 +387,6 @@ public function getProcessedTemplateDataProvider()
410387
'store_phone' => null,
411388
'store_hours' => null,
412389
'store_email' => null,
413-
'store_country' => null,
414-
'store_region' => null
415390
],
416391
'expectedResult' => 'expected result',
417392
],
@@ -432,8 +407,6 @@ public function getProcessedTemplateDataProvider()
432407
'store_hours' => null,
433408
'store_email' => null,
434409
'template_styles' => null,
435-
'store_country' => null,
436-
'store_region' => null
437410
],
438411
'expectedResult' => 'expected result',
439412
],

app/code/Magento/Newsletter/composer.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@
1515
"magento/module-require-js": "*",
1616
"magento/module-store": "*",
1717
"magento/module-widget": "*",
18-
"magento/module-ui": "*",
19-
"magento/module-directory": "*"
18+
"magento/module-ui": "*"
2019
},
2120
"type": "magento2-module",
2221
"license": [

0 commit comments

Comments
 (0)