From 0a27db2a4a75e53d6531130a1f1b601477dc6e2f Mon Sep 17 00:00:00 2001 From: Nikola Lardev Date: Wed, 18 Nov 2020 00:37:15 +0200 Subject: [PATCH 1/3] Add regions for Albania,Denmark,Greece,Iceland,Portugal and Sweden --- .../Setup/Patch/Data/AddDataForAlbania.php | 99 ++++++++++++++++ .../Setup/Patch/Data/AddDataForDenmark.php | 92 +++++++++++++++ .../Setup/Patch/Data/AddDataForGreece.php | 101 ++++++++++++++++ .../Setup/Patch/Data/AddDataForIceland.php | 95 +++++++++++++++ .../Setup/Patch/Data/AddDataForPortugal.php | 107 +++++++++++++++++ .../Setup/Patch/Data/AddDataForSweden.php | 108 ++++++++++++++++++ .../Magento/Directory/Model/RegionTest.php | 8 +- 7 files changed, 609 insertions(+), 1 deletion(-) create mode 100644 app/code/Magento/Directory/Setup/Patch/Data/AddDataForAlbania.php create mode 100644 app/code/Magento/Directory/Setup/Patch/Data/AddDataForDenmark.php create mode 100644 app/code/Magento/Directory/Setup/Patch/Data/AddDataForGreece.php create mode 100644 app/code/Magento/Directory/Setup/Patch/Data/AddDataForIceland.php create mode 100644 app/code/Magento/Directory/Setup/Patch/Data/AddDataForPortugal.php create mode 100644 app/code/Magento/Directory/Setup/Patch/Data/AddDataForSweden.php diff --git a/app/code/Magento/Directory/Setup/Patch/Data/AddDataForAlbania.php b/app/code/Magento/Directory/Setup/Patch/Data/AddDataForAlbania.php new file mode 100644 index 0000000000000..14aaffa1857ef --- /dev/null +++ b/app/code/Magento/Directory/Setup/Patch/Data/AddDataForAlbania.php @@ -0,0 +1,99 @@ +moduleDataSetup = $moduleDataSetup; + $this->dataInstallerFactory = $dataInstallerFactory; + } + + /** + * @inheritdoc + */ + public function apply() + { + /** @var DataInstaller $dataInstaller */ + $dataInstaller = $this->dataInstallerFactory->create(); + $dataInstaller->addCountryRegions( + $this->moduleDataSetup->getConnection(), + $this->getDataForAlbania() + ); + + return $this; + } + + /** + * Albania states data. + * + * @return array + */ + private function getDataForAlbania() + { + return [ + ['AL', 'AL-01', 'Berat'], + ['AL', 'AL-09', 'Dibër'], + ['AL', 'AL-02', 'Durrës'], + ['AL', 'AL-03', 'Elbasan'], + ['AL', 'AL-04', 'Fier'], + ['AL', 'AL-05', 'Gjirokastër'], + ['AL', 'AL-06', 'Korçë'], + ['AL', 'AL-07', 'Kukës'], + ['AL', 'AL-08', 'Lezhë'], + ['AL', 'AL-10', 'Shkodër'], + ['AL', 'AL-11', 'Tiranë'], + ['AL', 'AL-12', 'Vlorë'] + ]; + } + + /** + * @inheritdoc + */ + public static function getDependencies() + { + return [ + InitializeDirectoryData::class, + ]; + } + + /** + * @inheritdoc + */ + public function getAliases() + { + return []; + } +} diff --git a/app/code/Magento/Directory/Setup/Patch/Data/AddDataForDenmark.php b/app/code/Magento/Directory/Setup/Patch/Data/AddDataForDenmark.php new file mode 100644 index 0000000000000..1415227a932e6 --- /dev/null +++ b/app/code/Magento/Directory/Setup/Patch/Data/AddDataForDenmark.php @@ -0,0 +1,92 @@ +moduleDataSetup = $moduleDataSetup; + $this->dataInstallerFactory = $dataInstallerFactory; + } + + /** + * @inheritdoc + */ + public function apply() + { + /** @var DataInstaller $dataInstaller */ + $dataInstaller = $this->dataInstallerFactory->create(); + $dataInstaller->addCountryRegions( + $this->moduleDataSetup->getConnection(), + $this->getDataForDenmark() + ); + + return $this; + } + + /** + * Denmark states data. + * + * @return array + */ + private function getDataForDenmark() + { + return [ + ['DK', 'DK-84', 'Hovedstaden'], + ['DK', 'DK-82', 'Midtjylland'], + ['DK', 'DK-81', 'Nordjylland'], + ['DK', 'DK-85', 'Sjælland'], + ['DK', 'DK-83', 'Syddanmark'], + ]; + } + + /** + * @inheritdoc + */ + public static function getDependencies() + { + return [ + InitializeDirectoryData::class, + ]; + } + + /** + * @inheritdoc + */ + public function getAliases() + { + return []; + } +} diff --git a/app/code/Magento/Directory/Setup/Patch/Data/AddDataForGreece.php b/app/code/Magento/Directory/Setup/Patch/Data/AddDataForGreece.php new file mode 100644 index 0000000000000..a756035f1af4e --- /dev/null +++ b/app/code/Magento/Directory/Setup/Patch/Data/AddDataForGreece.php @@ -0,0 +1,101 @@ +moduleDataSetup = $moduleDataSetup; + $this->dataInstallerFactory = $dataInstallerFactory; + } + + /** + * @inheritdoc + */ + public function apply() + { + /** @var DataInstaller $dataInstaller */ + $dataInstaller = $this->dataInstallerFactory->create(); + $dataInstaller->addCountryRegions( + $this->moduleDataSetup->getConnection(), + $this->getDataForGreece() + ); + + return $this; + } + + /** + * Greece states data. + * + * @return array + */ + private function getDataForGreece() + { + return [ + ['GR', 'GR-A', 'Anatolikí Makedonía kai Thráki'], + ['GR', 'GR-I', 'Attikí'], + ['GR', 'GR-G', 'Dytikí Elláda'], + ['GR', 'GR-C', 'Dytikí Makedonía'], + ['GR', 'GR-F', 'Ionía Nísia'], + ['GR', 'GR-D', 'Ípeiros'], + ['GR', 'GR-B', 'Kentrikí Makedonía'], + ['GR', 'GR-M', 'Kríti'], + ['GR', 'GR-L', 'Nótio Aigaío'], + ['GR', 'GR-J', 'Pelopónnisos'], + ['GR', 'GR-H', 'Stereá Elláda'], + ['GR', 'GR-E', 'Thessalía'], + ['GR', 'GR-K', 'Vóreio Aigaío'], + + ]; + } + + /** + * @inheritdoc + */ + public static function getDependencies() + { + return [ + InitializeDirectoryData::class, + ]; + } + + /** + * @inheritdoc + */ + public function getAliases() + { + return []; + } +} diff --git a/app/code/Magento/Directory/Setup/Patch/Data/AddDataForIceland.php b/app/code/Magento/Directory/Setup/Patch/Data/AddDataForIceland.php new file mode 100644 index 0000000000000..6339b8bb71db4 --- /dev/null +++ b/app/code/Magento/Directory/Setup/Patch/Data/AddDataForIceland.php @@ -0,0 +1,95 @@ +moduleDataSetup = $moduleDataSetup; + $this->dataInstallerFactory = $dataInstallerFactory; + } + + /** + * @inheritdoc + */ + public function apply() + { + /** @var DataInstaller $dataInstaller */ + $dataInstaller = $this->dataInstallerFactory->create(); + $dataInstaller->addCountryRegions( + $this->moduleDataSetup->getConnection(), + $this->getDataForIceland() + ); + + return $this; + } + + /** + * Iceland states data. + * + * @return array + */ + private function getDataForIceland() + { + return [ + ['IS', 'IS-01', 'Höfuðborgarsvæði'], + ['IS', 'IS-02', 'Suðurnes'], + ['IS', 'IS-03', 'Vesturland'], + ['IS', 'IS-04', 'Vestfirðir'], + ['IS', 'IS-05', 'Norðurland vestra'], + ['IS', 'IS-06', 'Norðurland eystra'], + ['IS', 'IS-07', 'Austurland'], + ['IS', 'IS-08', 'Suðurland'] + ]; + } + + /** + * @inheritdoc + */ + public static function getDependencies() + { + return [ + InitializeDirectoryData::class, + ]; + } + + /** + * @inheritdoc + */ + public function getAliases() + { + return []; + } +} diff --git a/app/code/Magento/Directory/Setup/Patch/Data/AddDataForPortugal.php b/app/code/Magento/Directory/Setup/Patch/Data/AddDataForPortugal.php new file mode 100644 index 0000000000000..9daeb1cf5bf1e --- /dev/null +++ b/app/code/Magento/Directory/Setup/Patch/Data/AddDataForPortugal.php @@ -0,0 +1,107 @@ +moduleDataSetup = $moduleDataSetup; + $this->dataInstallerFactory = $dataInstallerFactory; + } + + /** + * @inheritdoc + */ + public function apply() + { + /** @var DataInstaller $dataInstaller */ + $dataInstaller = $this->dataInstallerFactory->create(); + $dataInstaller->addCountryRegions( + $this->moduleDataSetup->getConnection(), + $this->getDataForPortugal() + ); + + return $this; + } + + /** + * Portugal states data. + * + * @return array + */ + private function getDataForPortugal() + { + return [ + ['PT', 'PT-01', 'Aveiro'], + ['PT', 'PT-02', 'Beja'], + ['PT', 'PT-03', 'Braga'], + ['PT', 'PT-04', 'Bragança'], + ['PT', 'PT-05', 'Castelo Branco'], + ['PT', 'PT-06', 'Coimbra'], + ['PT', 'PT-07', 'Évora'], + ['PT', 'PT-08', 'Faro'], + ['PT', 'PT-09', 'Guarda'], + ['PT', 'PT-10', 'Leiria'], + ['PT', 'PT-11', 'Lisboa'], + ['PT', 'PT-12', 'Portalegre'], + ['PT', 'PT-13', 'Porto'], + ['PT', 'PT-14', 'Santarém'], + ['PT', 'PT-15', 'Setúbal'], + ['PT', 'PT-16', 'Viana do Castelo'], + ['PT', 'PT-17', 'Vila Real'], + ['PT', 'PT-18', 'Viseu'], + ['PT', 'PT-19', 'Região Autónoma dos Açores'], + ['PT', 'PT-20', 'Região Autónoma da Madeira'] + ]; + } + + /** + * @inheritdoc + */ + public static function getDependencies() + { + return [ + InitializeDirectoryData::class, + ]; + } + + /** + * @inheritdoc + */ + public function getAliases() + { + return []; + } +} diff --git a/app/code/Magento/Directory/Setup/Patch/Data/AddDataForSweden.php b/app/code/Magento/Directory/Setup/Patch/Data/AddDataForSweden.php new file mode 100644 index 0000000000000..b4bed72a726bd --- /dev/null +++ b/app/code/Magento/Directory/Setup/Patch/Data/AddDataForSweden.php @@ -0,0 +1,108 @@ +moduleDataSetup = $moduleDataSetup; + $this->dataInstallerFactory = $dataInstallerFactory; + } + + /** + * @inheritdoc + */ + public function apply() + { + /** @var DataInstaller $dataInstaller */ + $dataInstaller = $this->dataInstallerFactory->create(); + $dataInstaller->addCountryRegions( + $this->moduleDataSetup->getConnection(), + $this->getDataForSweden() + ); + + return $this; + } + + /** + * Swedish states data. + * + * @return array + */ + private function getDataForSweden() + { + return [ + ['SE', 'SE-K', 'Blekinge län'], + ['SE', 'SE-W', 'Dalarnas län'], + ['SE', 'SE-I', 'Gotlands län'], + ['SE', 'SE-X', 'Gävleborgs län'], + ['SE', 'SE-N', 'Hallands län'], + ['SE', 'SE-Z', 'Jämtlands län'], + ['SE', 'SE-F', 'Jönköpings län'], + ['SE', 'SE-H', 'Kalmar län'], + ['SE', 'SE-G', 'Kronobergs län'], + ['SE', 'SE-BD', 'Norrbottens län'], + ['SE', 'SE-M', 'Skåne län'], + ['SE', 'SE-AB', 'Stockholms län'], + ['SE', 'SE-D', 'Södermanlands län'], + ['SE', 'SE-C', 'Uppsala län'], + ['SE', 'SE-S', 'Värmlands län'], + ['SE', 'SE-AC', 'Västerbottens län'], + ['SE', 'SE-Y', 'Västernorrlands län'], + ['SE', 'SE-U', 'Västmanlands län'], + ['SE', 'SE-O', 'Västra Götalands län'], + ['SE', 'SE-T', 'Örebro län'], + ['SE', 'SE-E', 'Östergötlands län'] + ]; + } + + /** + * @inheritdoc + */ + public static function getDependencies() + { + return [ + InitializeDirectoryData::class, + ]; + } + + /** + * @inheritdoc + */ + public function getAliases() + { + return []; + } +} diff --git a/dev/tests/integration/testsuite/Magento/Directory/Model/RegionTest.php b/dev/tests/integration/testsuite/Magento/Directory/Model/RegionTest.php index 774690617d861..44c8377f1eaf7 100644 --- a/dev/tests/integration/testsuite/Magento/Directory/Model/RegionTest.php +++ b/dev/tests/integration/testsuite/Magento/Directory/Model/RegionTest.php @@ -57,7 +57,13 @@ public function getCountryIdDataProvider():array ['countryId' => 'MX'], ['countryId' => 'PL'], ['countryId' => 'IT'], - ['countryId' => 'BG'] + ['countryId' => 'BG'], + ['countryId' => 'PT'], + ['countryId' => 'IS'], + ['countryId' => 'SE'], + ['countryId' => 'GR'], + ['countryId' => 'DK'], + ['countryId' => 'AL'] ]; } } From 876e37b6c907e542ecab093b5f67ca02c201d5cc Mon Sep 17 00:00:00 2001 From: Nikola Lardev Date: Sat, 21 Nov 2020 22:05:38 +0200 Subject: [PATCH 2/3] #30959 Add one more region for Greece and fix two Portugal states numbers --- .../Magento/Directory/Setup/Patch/Data/AddDataForGreece.php | 1 + .../Magento/Directory/Setup/Patch/Data/AddDataForPortugal.php | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/app/code/Magento/Directory/Setup/Patch/Data/AddDataForGreece.php b/app/code/Magento/Directory/Setup/Patch/Data/AddDataForGreece.php index a756035f1af4e..122a2b2bbc195 100644 --- a/app/code/Magento/Directory/Setup/Patch/Data/AddDataForGreece.php +++ b/app/code/Magento/Directory/Setup/Patch/Data/AddDataForGreece.php @@ -77,6 +77,7 @@ private function getDataForGreece() ['GR', 'GR-H', 'Stereá Elláda'], ['GR', 'GR-E', 'Thessalía'], ['GR', 'GR-K', 'Vóreio Aigaío'], + ['GR', 'GR-69', 'Ágion Óros'] ]; } diff --git a/app/code/Magento/Directory/Setup/Patch/Data/AddDataForPortugal.php b/app/code/Magento/Directory/Setup/Patch/Data/AddDataForPortugal.php index 9daeb1cf5bf1e..2960d431f123a 100644 --- a/app/code/Magento/Directory/Setup/Patch/Data/AddDataForPortugal.php +++ b/app/code/Magento/Directory/Setup/Patch/Data/AddDataForPortugal.php @@ -82,8 +82,8 @@ private function getDataForPortugal() ['PT', 'PT-16', 'Viana do Castelo'], ['PT', 'PT-17', 'Vila Real'], ['PT', 'PT-18', 'Viseu'], - ['PT', 'PT-19', 'Região Autónoma dos Açores'], - ['PT', 'PT-20', 'Região Autónoma da Madeira'] + ['PT', 'PT-20', 'Região Autónoma dos Açores'], + ['PT', 'PT-30', 'Região Autónoma da Madeira'] ]; } From c172dc17940946721a1ff28df714c7e398c2165a Mon Sep 17 00:00:00 2001 From: Nikola Lardev Date: Mon, 30 Nov 2020 13:35:24 +0200 Subject: [PATCH 3/3] #30959 Fix typo --- .../Directory/Setup/Patch/Data/AddDataForGreece.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/app/code/Magento/Directory/Setup/Patch/Data/AddDataForGreece.php b/app/code/Magento/Directory/Setup/Patch/Data/AddDataForGreece.php index 122a2b2bbc195..30b1021a3467d 100644 --- a/app/code/Magento/Directory/Setup/Patch/Data/AddDataForGreece.php +++ b/app/code/Magento/Directory/Setup/Patch/Data/AddDataForGreece.php @@ -1,15 +1,15 @@