3636use Magento \Variable \Model \Variable ;
3737use Magento \Variable \Model \VariableFactory ;
3838use 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 }
0 commit comments