0

PHP 7.0.22 and Magento 2.1.3

When I'm trying to add a customization to the US zipcodes masks, Magento throws out an exception Exception #0 (Magento\Framework\Exception\LocalizedException): More than one node matching the query: /config/zip[@countryCode='US']/codes/code

I followed throughly the documentation Add custom input mask for ZIP code but still not getting it working.

This is my app/code/Test/Directory/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="US">
        <codes>
            <code id="pattern_3" active="true" example="Any character [a-z]">^[a-z]+$</code>
        </codes>
    </zip>
</config>

This is the error trace:

1 exception(s):
Exception #0 (Magento\Framework\Exception\LocalizedException): More than one node matching the query: /config/zip[@countryCode='US']/codes/code

Exception #0 (Magento\Framework\Exception\LocalizedException): More than one node matching the query: /config/zip[@countryCode='US']/codes/code
#0 /vendor/magento/framework/Config/Dom.php(162): Magento\Framework\Config\Dom->_getMatchedNode('/config/zip[@co...')
#1 /vendor/magento/framework/Config/Dom.php(197): Magento\Framework\Config\Dom->_mergeNode(Object(DOMElement), '/config/zip[@co...')
#2 /vendor/magento/framework/Config/Dom.php(197): Magento\Framework\Config\Dom->_mergeNode(Object(DOMElement), '/config/zip[@co...')
#3 /vendor/magento/framework/Config/Dom.php(197): Magento\Framework\Config\Dom->_mergeNode(Object(DOMElement), '/config')
#4 /vendor/magento/framework/Config/Dom.php(142): Magento\Framework\Config\Dom->_mergeNode(Object(DOMElement), '')
#5 /vendor/magento/framework/Config/Reader/Filesystem.php(148): Magento\Framework\Config\Dom->merge('<?xml version="...')
#6 /vendor/magento/framework/Config/Reader/Filesystem.php(127): Magento\Framework\Config\Reader\Filesystem->_readFiles(Object(Magento\Framework\Config\FileIterator))
#7 /vendor/magento/framework/Config/Data.php(91): Magento\Framework\Config\Reader\Filesystem->read()
#8 /vendor/magento/framework/Config/Data.php(80): Magento\Framework\Config\Data->initData()
#9 /vendor/magento/module-directory/Model/Country/Postcode/Config/Data.php(18): Magento\Framework\Config\Data->__construct(Object(Magento\Directory\Model\Country\Postcode\Config\Reader), Object(Magento\Framework\App\Cache\Type\Config), 'country_postcod...')
#10 /vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php(93): Magento\Directory\Model\Country\Postcode\Config\Data->__construct(Object(Magento\Directory\Model\Country\Postcode\Config\Reader), Object(Magento\Framework\App\Cache\Type\Config))
#11 /vendor/magento/framework/ObjectManager/Factory/Compiled.php(88): Magento\Framework\ObjectManager\Factory\AbstractFactory->createObject('Magento\\Directo...', Array)
#12 /vendor/magento/framework/ObjectManager/Factory/Compiled.php(130): Magento\Framework\ObjectManager\Factory\Compiled->create('Magento\\Directo...')
#13 /vendor/magento/framework/ObjectManager/Factory/Compiled.php(67): Magento\Framework\ObjectManager\Factory\Compiled->get('Magento\\Directo...')
#14 /vendor/magento/framework/ObjectManager/Factory/Compiled.php(130): Magento\Framework\ObjectManager\Factory\Compiled->create('Magento\\Directo...')
#15 /vendor/magento/framework/ObjectManager/Factory/Compiled.php(67): Magento\Framework\ObjectManager\Factory\Compiled->get('Magento\\Directo...')
#16 /vendor/magento/framework/ObjectManager/Factory/Compiled.php(130): Magento\Framework\ObjectManager\Factory\Compiled->create('Magento\\Checkou...')
#17 /vendor/magento/framework/ObjectManager/Factory/Compiled.php(105): Magento\Framework\ObjectManager\Factory\Compiled->get('Magento\\Checkou...')
#18 /vendor/magento/framework/ObjectManager/Factory/Compiled.php(74): Magento\Framework\ObjectManager\Factory\Compiled->parseArray(Array)
#19 /vendor/magento/framework/ObjectManager/Factory/Compiled.php(130): Magento\Framework\ObjectManager\Factory\Compiled->create('Magento\\Checkou...')
#20 /vendor/magento/framework/ObjectManager/Factory/Compiled.php(67): Magento\Framework\ObjectManager\Factory\Compiled->get('Magento\\Checkou...')
#21 /vendor/magento/framework/ObjectManager/ObjectManager.php(57): Magento\Framework\ObjectManager\Factory\Compiled->create('Magento\\Checkou...', Array)
#22 /vendor/magento/framework/View/Element/BlockFactory.php(45): Magento\Framework\ObjectManager\ObjectManager->create('Magento\\Checkou...', Array)
#23 /vendor/magento/framework/View/Layout/Generator/Block.php(257): Magento\Framework\View\Element\BlockFactory->createBlock('Magento\\Checkou...', Array)
#24 /vendor/magento/framework/View/Layout/Generator/Block.php(237): Magento\Framework\View\Layout\Generator\Block->getBlockInstance('Magento\\Checkou...', Array)
#25 /vendor/magento/framework/View/Layout/Generator/Block.php(215): Magento\Framework\View\Layout\Generator\Block->createBlock('Magento\\Checkou...', 'checkout.root', Array)
#26 /vendor/magento/framework/View/Layout/Generator/Block.php(124): Magento\Framework\View\Layout\Generator\Block->generateBlock(Object(Magento\Framework\View\Layout\ScheduledStructure), Object(Magento\Framework\View\Layout\Data\Structure), 'checkout.root')
#27 /vendor/magento/framework/View/Layout/GeneratorPool.php(86): Magento\Framework\View\Layout\Generator\Block->process(Object(Magento\Framework\View\Layout\Reader\Context), Object(Magento\Framework\View\Layout\Generator\Context))
#28 /vendor/magento/framework/View/Layout.php(327): Magento\Framework\View\Layout\GeneratorPool->process(Object(Magento\Framework\View\Layout\Reader\Context), Object(Magento\Framework\View\Layout\Generator\Context))
#29 /var/generation/Magento/Framework/View/Layout/Interceptor.php(89): Magento\Framework\View\Layout->generateElements()
#30 /vendor/magento/framework/View/Layout/Builder.php(129): Magento\Framework\View\Layout\Interceptor->generateElements()
#31 /vendor/magento/framework/View/Page/Builder.php(55): Magento\Framework\View\Layout\Builder->generateLayoutBlocks()
#32 /vendor/magento/framework/View/Layout/Builder.php(65): Magento\Framework\View\Page\Builder->generateLayoutBlocks()
#33 /vendor/magento/framework/View/Page/Config.php(197): Magento\Framework\View\Layout\Builder->build()
#34 /vendor/magento/framework/View/Page/Config.php(217): Magento\Framework\View\Page\Config->build()
#35 /vendor/magento/module-checkout/Controller/Index/Index.php(39): Magento\Framework\View\Page\Config->getTitle()
#36 /vendor/magento/framework/Interception/Interceptor.php(146): Magento\Checkout\Controller\Index\Index->execute()
#37 /var/generation/Magento/Checkout/Controller/Index/Index/Interceptor.php(26): Magento\Checkout\Controller\Index\Index\Interceptor->___callPlugins('execute', Array, Array)
#38 /vendor/magento/framework/App/Action/Action.php(102): Magento\Checkout\Controller\Index\Index\Interceptor->execute()
#39 /vendor/magento/module-checkout/Controller/Onepage.php(161): Magento\Framework\App\Action\Action->dispatch(Object(Magento\Framework\App\Request\Http))
#40 /vendor/magento/framework/Interception/Interceptor.php(74): Magento\Checkout\Controller\Onepage->dispatch(Object(Magento\Framework\App\Request\Http))
#41 /vendor/magento/framework/Interception/Chain/Chain.php(70): Magento\Checkout\Controller\Index\Index\Interceptor->___callParent('dispatch', Array)
#42 /vendor/magento/framework/Interception/Chain/Chain.php(63): Magento\Framework\Interception\Chain\Chain->invokeNext('Magento\\Checkou...', 'dispatch', Object(Magento\Checkout\Controller\Index\Index\Interceptor), Array, 'contextPlugin')
#43 /vendor/magento/module-store/App/Action/Plugin/Context.php(106): Magento\Framework\Interception\Chain\Chain->Magento\Framework\Interception\Chain\{closure}(Object(Magento\Framework\App\Request\Http))
#44 /vendor/magento/framework/Interception/Chain/Chain.php(67): Magento\Store\App\Action\Plugin\Context->aroundDispatch(Object(Magento\Checkout\Controller\Index\Index\Interceptor), Object(Closure), Object(Magento\Framework\App\Request\Http))
#45 /vendor/magento/framework/Interception/Chain/Chain.php(63): Magento\Framework\Interception\Chain\Chain->invokeNext('Magento\\Checkou...', 'dispatch', Object(Magento\Checkout\Controller\Index\Index\Interceptor), Array, 'customer-app-ac...')
#46 /vendor/magento/module-customer/Model/App/Action/ContextPlugin.php(61): Magento\Framework\Interception\Chain\Chain->Magento\Framework\Interception\Chain\{closure}(Object(Magento\Framework\App\Request\Http))
#47 /vendor/magento/framework/Interception/Chain/Chain.php(67): Magento\Customer\Model\App\Action\ContextPlugin->aroundDispatch(Object(Magento\Checkout\Controller\Index\Index\Interceptor), Object(Closure), Object(Magento\Framework\App\Request\Http))
#48 /vendor/magento/framework/Interception/Chain/Chain.php(63): Magento\Framework\Interception\Chain\Chain->invokeNext('Magento\\Checkou...', 'dispatch', Object(Magento\Checkout\Controller\Index\Index\Interceptor), Array, 'storeCheck')
#49 /vendor/magento/module-store/App/Action/Plugin/StoreCheck.php(44): Magento\Framework\Interception\Chain\Chain->Magento\Framework\Interception\Chain\{closure}(Object(Magento\Framework\App\Request\Http))
#50 /vendor/magento/framework/Interception/Chain/Chain.php(67): Magento\Store\App\Action\Plugin\StoreCheck->aroundDispatch(Object(Magento\Checkout\Controller\Index\Index\Interceptor), Object(Closure), Object(Magento\Framework\App\Request\Http))
#51 /vendor/magento/framework/Interception/Chain/Chain.php(63): Magento\Framework\Interception\Chain\Chain->invokeNext('Magento\\Checkou...', 'dispatch', Object(Magento\Checkout\Controller\Index\Index\Interceptor), Array, 'weee-app-action...')
#52 /vendor/magento/module-weee/Model/App/Action/ContextPlugin.php(112): Magento\Framework\Interception\Chain\Chain->Magento\Framework\Interception\Chain\{closure}(Object(Magento\Framework\App\Request\Http))
#53 /vendor/magento/framework/Interception/Chain/Chain.php(67): Magento\Weee\Model\App\Action\ContextPlugin->aroundDispatch(Object(Magento\Checkout\Controller\Index\Index\Interceptor), Object(Closure), Object(Magento\Framework\App\Request\Http))
#54 /vendor/magento/framework/Interception/Interceptor.php(138): Magento\Framework\Interception\Chain\Chain->invokeNext('Magento\\Checkou...', 'dispatch', Object(Magento\Checkout\Controller\Index\Index\Interceptor), Array, 'tax-app-action-...')
#55 /vendor/magento/module-tax/Model/App/Action/ContextPlugin.php(91): Magento\Checkout\Controller\Index\Index\Interceptor->Magento\Framework\Interception\{closure}(Object(Magento\Framework\App\Request\Http))
#56 /vendor/magento/framework/Interception/Interceptor.php(142): Magento\Tax\Model\App\Action\ContextPlugin->aroundDispatch(Object(Magento\Checkout\Controller\Index\Index\Interceptor), Object(Closure), Object(Magento\Framework\App\Request\Http))
#57 /var/generation/Magento/Checkout/Controller/Index/Index/Interceptor.php(39): Magento\Checkout\Controller\Index\Index\Interceptor->___callPlugins('dispatch', Array, Array)
#58 /vendor/magento/framework/App/FrontController.php(55): Magento\Checkout\Controller\Index\Index\Interceptor->dispatch(Object(Magento\Framework\App\Request\Http))
#59 /vendor/magento/framework/Interception/Interceptor.php(74): Magento\Framework\App\FrontController->dispatch(Object(Magento\Framework\App\Request\Http))
#60 /vendor/magento/framework/Interception/Chain/Chain.php(70): Magento\Framework\App\FrontController\Interceptor->___callParent('dispatch', Array)
#61 /vendor/magento/framework/Interception/Chain/Chain.php(63): Magento\Framework\Interception\Chain\Chain->invokeNext('Magento\\Framewo...', 'dispatch', Object(Magento\Framework\App\FrontController\Interceptor), Array, 'requestPreproce...')
#62 /vendor/magento/module-store/App/FrontController/Plugin/RequestPreprocessor.php(94): Magento\Framework\Interception\Chain\Chain->Magento\Framework\Interception\Chain\{closure}(Object(Magento\Framework\App\Request\Http))
#63 /vendor/magento/framework/Interception/Chain/Chain.php(67): Magento\Store\App\FrontController\Plugin\RequestPreprocessor->aroundDispatch(Object(Magento\Framework\App\FrontController\Interceptor), Object(Closure), Object(Magento\Framework\App\Request\Http))
#64 /vendor/magento/framework/Interception/Chain/Chain.php(63): Magento\Framework\Interception\Chain\Chain->invokeNext('Magento\\Framewo...', 'dispatch', Object(Magento\Framework\App\FrontController\Interceptor), Array, 'install')
#65 /vendor/magento/framework/Module/Plugin/DbStatusValidator.php(69): Magento\Framework\Interception\Chain\Chain->Magento\Framework\Interception\Chain\{closure}(Object(Magento\Framework\App\Request\Http))
#66 /vendor/magento/framework/Interception/Chain/Chain.php(67): Magento\Framework\Module\Plugin\DbStatusValidator->aroundDispatch(Object(Magento\Framework\App\FrontController\Interceptor), Object(Closure), Object(Magento\Framework\App\Request\Http))
#67 /vendor/magento/framework/Interception/Chain/Chain.php(63): Magento\Framework\Interception\Chain\Chain->invokeNext('Magento\\Framewo...', 'dispatch', Object(Magento\Framework\App\FrontController\Interceptor), Array, 'front-controlle...')
#68 /vendor/magento/module-page-cache/Model/App/FrontController/VarnishPlugin.php(55): Magento\Framework\Interception\Chain\Chain->Magento\Framework\Interception\Chain\{closure}(Object(Magento\Framework\App\Request\Http))
#69 /vendor/magento/framework/Interception/Chain/Chain.php(67): Magento\PageCache\Model\App\FrontController\VarnishPlugin->aroundDispatch(Object(Magento\Framework\App\FrontController\Interceptor), Object(Closure), Object(Magento\Framework\App\Request\Http))
#70 /vendor/magento/framework/Interception/Interceptor.php(138): Magento\Framework\Interception\Chain\Chain->invokeNext('Magento\\Framewo...', 'dispatch', Object(Magento\Framework\App\FrontController\Interceptor), Array, 'front-controlle...')
#71 /vendor/magento/module-page-cache/Model/App/FrontController/BuiltinPlugin.php(68): Magento\Framework\App\FrontController\Interceptor->Magento\Framework\Interception\{closure}(Object(Magento\Framework\App\Request\Http))
#72 /vendor/magento/framework/Interception/Interceptor.php(142): Magento\PageCache\Model\App\FrontController\BuiltinPlugin->aroundDispatch(Object(Magento\Framework\App\FrontController\Interceptor), Object(Closure), Object(Magento\Framework\App\Request\Http))
#73 /var/generation/Magento/Framework/App/FrontController/Interceptor.php(26): Magento\Framework\App\FrontController\Interceptor->___callPlugins('dispatch', Array, Array)
#74 /vendor/magento/framework/App/Http.php(135): Magento\Framework\App\FrontController\Interceptor->dispatch(Object(Magento\Framework\App\Request\Http))
#75 /vendor/magento/framework/App/Bootstrap.php(258): Magento\Framework\App\Http->launch()
#76 /index.php(876): Magento\Framework\App\Bootstrap->run(Object(Magento\Framework\App\Http))
#77 {main}

1 Answer 1

1

This issue has been solved in release 2.2, as mentioned here by a Magento core member, on the commit 4ddb336.

The file app/code/Magento/Directory/Model/Country/Postcode/Config/Reader.php should be:

protected $_idAttributes = [
    '/config/zip' => 'countryCode',
    '/config/zip/codes/code' => 'id',
];

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.