Closed thomasnordkvist closed 7 years ago
@thomasnordkvist Thank you for reporting this issue.
Could you please provide a sample of zip_codes.xml
which causes error?
@ishakhsuvarov
To begin i placed it in an existing module that i have. When that didn't work i made a module for just this with only the below three files.
app/code/Netrix/ZipCodeMask/registration.php
<?php
\Magento\Framework\Component\ComponentRegistrar::register(
\Magento\Framework\Component\ComponentRegistrar::MODULE,
'Netrix_ZipCodeMask',
__DIR__
);
app/code/Netrix/ZipCodeMask/etc/module.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Netrix_ZipCodeMask" setup_version="2.0.0">
<sequence>
<module name="Magento_Directory"/>
</sequence>
</module>
</config>
app/code/Netrix/ZipCodeMask/etc/zip_codes.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Directory:etc/zip_codes.xsd">
<zip countryCode="SE">
<codes>
<code id="pattern_2" active="true" example="12345">^[0-9]{5}$</code>
</codes>
</zip>
</config>
It's kinda quiet in here. Is this being investigated? Because it's a real pain.
Still no patch or something?
Temporary workaround using plugin:
di.xml
<type name="Magento\Directory\Model\Country\Postcode\Config">
<plugin name="my_module_directory_country_postcode_config_plugin" type="My\Module\Model\Directory\Country\Postcode\Config\Plugin" />
</type>
My\Module\Model\Directory\Country\Postcode\Config\Plugin.php
<?php
namespace My\Module\Model\Directory\Country\Postcode\Config;
class Plugin
{
/**
* @param \Magento\Directory\Model\Country\Postcode\Config $subject
* @param array $result
*
* @return array
*/
public function afterGetPostCodes(\Magento\Directory\Model\Country\Postcode\Config $subject, array $result)
{
$result['SE']['pattern_2'] = [
'example' => '12345',
'pattern' => '^[0-9]{5}$'
];
return $result;
}
}
Internal issue MAGETWO-53441
I got the "More than one node matching the query" problem in 2.1.2 too.
I found something interesting though : in my custom zip_codes.xml (in a custom module), when there is only one code node in a zip node, the problem doesn't appear but the custom validation is ignored.
EXAMPLE
<zip countryCode="CA">
<codes>
<code id="pattern_1" active="true" example="A1B 2C3">^[a-zA-Z]{1}[0-9]{1}[a-zA-Z]{1}\s*[0-9]{1}[a-zA-Z]{1}[0-9]{1}$</code>
</codes>
</zip>
Result : this custom validation is ignored, the original validation is triggered. Note that changing the code ID for i.e. "pattern_2" has no effect.
<zip countryCode="CA">
<codes>
<code id="pattern_1" active="true" example="A1B 2C3">^[a-zA-Z]{1}[0-9]{1}[a-zA-Z]{1}\s*[0-9]{1}[a-zA-Z]{1}[0-9]{1}$</code>
<code id="pattern_2" active="true" example="12345-678">^[0-9]{5}\-[0-9]{3}$</code>
</codes>
</zip>
Result : "More than one node matching the query" error. Again, changing the code IDs to "pattern_2" and "pattern_3" has no effect.
I'm having the same problem with multiple zip code masks. Is there any solution to this problem yet?
This issue has been fixed in 2.0.11. If this issue still reproduces please create new GitHub issue according to the Issue reporting guidelines and specifying exact Magento version. Closed.
This is still a problem in Magento 2.1.12
I've bypassed the issue using the workaround provided by @farior
Just a heads up:
Differently than @veloraven said, it seems it was not fixed... I'm using Magento 2.1.3
and still getting this issue although following the documentation thoroughly.
I have increased the amount of information in the ticket #14854, also following the description standards.
I tried to add a custom zip code mask by following the example from http://devdocs.magento.com/guides/v2.0/howdoi/checkout/checkout_zip.html
I'm using Magento 2.0.4
In system.log i get the following message:
main.CRITICAL: More than one node matching the query: /config/zip [] []
The checkout page gives an error report like this:
And it looks like more installations have this problem http://magento.stackexchange.com/questions/109710/how-do-you-add-zip-code-rules-in-a-module
/Thomas