diff --git a/app/code/Magento/Directory/Model/Country/Postcode/Config/Reader.php b/app/code/Magento/Directory/Model/Country/Postcode/Config/Reader.php
index 9ea0babbfd998..ed36ad3ace22b 100644
--- a/app/code/Magento/Directory/Model/Country/Postcode/Config/Reader.php
+++ b/app/code/Magento/Directory/Model/Country/Postcode/Config/Reader.php
@@ -12,7 +12,10 @@ class Reader extends \Magento\Framework\Config\Reader\Filesystem
*
* @var array
*/
- protected $_idAttributes = ['/config/zip' => 'countryCode'];
+ protected $_idAttributes = [
+ '/config/zip' => 'countryCode',
+ '/config/zip/codes/code' => 'id',
+ ];
/**
* Construct the FileSystem Reader Class
diff --git a/dev/tests/integration/_files/Magento/TestModuleDirectoryZipCodes/etc/module.xml b/dev/tests/integration/_files/Magento/TestModuleDirectoryZipCodes/etc/module.xml
new file mode 100644
index 0000000000000..ce5ed9cb663a7
--- /dev/null
+++ b/dev/tests/integration/_files/Magento/TestModuleDirectoryZipCodes/etc/module.xml
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+
+
diff --git a/dev/tests/integration/_files/Magento/TestModuleDirectoryZipCodes/etc/zip_codes.xml b/dev/tests/integration/_files/Magento/TestModuleDirectoryZipCodes/etc/zip_codes.xml
new file mode 100644
index 0000000000000..a23d25f6047cd
--- /dev/null
+++ b/dev/tests/integration/_files/Magento/TestModuleDirectoryZipCodes/etc/zip_codes.xml
@@ -0,0 +1,14 @@
+
+
+
+
+ ^[0-9]{4}[a-zA-Z]{2}$
+ ^[0-5]{4}[a-z]{2}$
+
+
+
+
+ ^[0-2]{4}[A-Z]{2}$
+
+
+
diff --git a/dev/tests/integration/_files/Magento/TestModuleDirectoryZipCodes/registration.php b/dev/tests/integration/_files/Magento/TestModuleDirectoryZipCodes/registration.php
new file mode 100644
index 0000000000000..2ed368ecf3b23
--- /dev/null
+++ b/dev/tests/integration/_files/Magento/TestModuleDirectoryZipCodes/registration.php
@@ -0,0 +1,12 @@
+getPath(ComponentRegistrar::MODULE, 'Magento_TestModuleDirectoryZipCodes') === null) {
+ ComponentRegistrar::register(ComponentRegistrar::MODULE, 'Magento_TestModuleDirectoryZipCodes', __DIR__);
+}
diff --git a/dev/tests/integration/testsuite/Magento/Directory/Model/Country/Postcode/Config/ReaderTest.php b/dev/tests/integration/testsuite/Magento/Directory/Model/Country/Postcode/Config/ReaderTest.php
new file mode 100644
index 0000000000000..dee37eca6438c
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/Directory/Model/Country/Postcode/Config/ReaderTest.php
@@ -0,0 +1,43 @@
+reader = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(
+ \Magento\Directory\Model\Country\Postcode\Config\Reader::class
+ );
+ }
+
+ public function testRead()
+ {
+ $result = $this->reader->read();
+
+ $this->assertArrayHasKey('NL', $result);
+ $this->assertArrayHasKey('pattern_1', $result['NL']);
+ $this->assertArrayHasKey('pattern_2', $result['NL']);
+
+ $this->assertEquals('test1', $result['NL']['pattern_1']['example']);
+ $this->assertEquals('^[0-9]{4}[a-zA-Z]{2}$', $result['NL']['pattern_1']['pattern']);
+
+ $this->assertEquals('test2', $result['NL']['pattern_2']['example']);
+ $this->assertEquals('^[0-5]{4}[a-z]{2}$', $result['NL']['pattern_2']['pattern']);
+
+ $this->assertArrayHasKey('NL_NEW', $result);
+ $this->assertArrayHasKey('pattern_1', $result['NL_NEW']);
+
+ $this->assertEquals('test1', $result['NL_NEW']['pattern_1']['example']);
+ $this->assertEquals('^[0-2]{4}[A-Z]{2}$', $result['NL_NEW']['pattern_1']['pattern']);
+ }
+}