magento / magento2

Prior to making any Submission(s), you must sign an Adobe Contributor License Agreement, available here at: https://opensource.adobe.com/cla.html. All Submissions you make to Adobe Inc. and its affiliates, assigns and subsidiaries (collectively “Adobe”) are subject to the terms of the Adobe Contributor License Agreement.
http://www.magento.com
Open Software License 3.0
11.56k stars 9.32k forks source link

Custom zip code mask not working in 2.0.4 #4131

Closed thomasnordkvist closed 7 years ago

thomasnordkvist commented 8 years ago

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:

a:4:{i:0;s:37:"Object DOMDocument should be created.";i:1;s:14666:"#0 /Library/WebServer/Documents/develop/magento2/vendor/magento/framework/View/Element/UiComponent/Config/Reader.php(95): Magento\Framework\View\Element\UiComponent\Config\DomMerger->getDom()
#1 /Library/WebServer/Documents/develop/magento2/vendor/magento/module-ui/Model/Manager.php(261): Magento\Framework\View\Element\UiComponent\Config\Reader->read()
#2 /Library/WebServer/Documents/develop/magento2/vendor/magento/module-ui/Model/Manager.php(169): Magento\Ui\Model\Manager->prepare('checkout.root')
#3 /Library/WebServer/Documents/develop/magento2/vendor/magento/framework/View/Element/UiComponentFactory.php(139): Magento\Ui\Model\Manager->prepareData('checkout.root')
#4 /Library/WebServer/Documents/develop/magento2/vendor/magento/framework/View/Layout/Generator/UiComponent.php(125): Magento\Framework\View\Element\UiComponentFactory->create('checkout.root', NULL, Array)
#5 /Library/WebServer/Documents/develop/magento2/vendor/magento/framework/View/Layout/Generator/UiComponent.php(93): Magento\Framework\View\Layout\Generator\UiComponent->generateComponent(Object(Magento\Framework\View\Layout\Data\Structure), 'checkout.root', Array, Object(Magento\Framework\View\Layout\Interceptor))
#6 /Library/WebServer/Documents/develop/magento2/vendor/magento/framework/View/Layout/GeneratorPool.php(86): Magento\Framework\View\Layout\Generator\UiComponent->process(Object(Magento\Framework\View\Layout\Reader\Context), Object(Magento\Framework\View\Layout\Generator\Context))
#7 /Library/WebServer/Documents/develop/magento2/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))
#8 /Library/WebServer/Documents/develop/magento2/var/generation/Magento/Framework/View/Layout/Interceptor.php(89): Magento\Framework\View\Layout->generateElements()
#9 /Library/WebServer/Documents/develop/magento2/vendor/magento/framework/View/Layout/Builder.php(129): Magento\Framework\View\Layout\Interceptor->generateElements()
#10 /Library/WebServer/Documents/develop/magento2/vendor/magento/framework/View/Page/Builder.php(55): Magento\Framework\View\Layout\Builder->generateLayoutBlocks()
#11 /Library/WebServer/Documents/develop/magento2/vendor/magento/framework/View/Layout/Builder.php(65): Magento\Framework\View\Page\Builder->generateLayoutBlocks()
#12 /Library/WebServer/Documents/develop/magento2/vendor/magento/framework/View/Page/Config.php(166): Magento\Framework\View\Layout\Builder->build()
#13 /Library/WebServer/Documents/develop/magento2/vendor/magento/framework/View/Page/Config.php(186): Magento\Framework\View\Page\Config->build()
#14 /Library/WebServer/Documents/develop/magento2/vendor/magento/module-checkout/Controller/Index/Index.php(41): Magento\Framework\View\Page\Config->getTitle()
#15 [internal function]: Magento\Checkout\Controller\Index\Index->execute()
#16 /Library/WebServer/Documents/develop/magento2/vendor/magento/framework/Interception/Interceptor.php(144): call_user_func_array(Array, Array)
#17 /Library/WebServer/Documents/develop/magento2/var/generation/Magento/Checkout/Controller/Index/Index/Interceptor.php(26): Magento\Checkout\Controller\Index\Index\Interceptor->___callPlugins('execute', Array, Array)
#18 /Library/WebServer/Documents/develop/magento2/vendor/magento/framework/App/Action/Action.php(102): Magento\Checkout\Controller\Index\Index\Interceptor->execute()
#19 /Library/WebServer/Documents/develop/magento2/vendor/magento/module-checkout/Controller/Onepage.php(161): Magento\Framework\App\Action\Action->dispatch(Object(Magento\Framework\App\Request\Http))
#20 [internal function]: Magento\Checkout\Controller\Onepage->dispatch(Object(Magento\Framework\App\Request\Http))
#21 /Library/WebServer/Documents/develop/magento2/vendor/magento/framework/Interception/Interceptor.php(74): call_user_func_array(Array, Array)
#22 /Library/WebServer/Documents/develop/magento2/vendor/magento/framework/Interception/Chain/Chain.php(70): Magento\Checkout\Controller\Index\Index\Interceptor->___callParent('dispatch', Array)
#23 /Library/WebServer/Documents/develop/magento2/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, 'designLoader')
#24 /Library/WebServer/Documents/develop/magento2/vendor/magento/framework/App/Action/Plugin/Design.php(39): Magento\Framework\Interception\Chain\Chain->Magento\Framework\Interception\Chain\{closure}(Object(Magento\Framework\App\Request\Http))
#25 [internal function]: Magento\Framework\App\Action\Plugin\Design->aroundDispatch(Object(Magento\Checkout\Controller\Index\Index\Interceptor), Object(Closure), Object(Magento\Framework\App\Request\Http))
#26 /Library/WebServer/Documents/develop/magento2/vendor/magento/framework/Interception/Chain/Chain.php(68): call_user_func_array(Array, Array)
#27 /Library/WebServer/Documents/develop/magento2/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...')
#28 /Library/WebServer/Documents/develop/magento2/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))
#29 [internal function]: Magento\Customer\Model\App\Action\ContextPlugin->aroundDispatch(Object(Magento\Checkout\Controller\Index\Index\Interceptor), Object(Closure), Object(Magento\Framework\App\Request\Http))
#30 /Library/WebServer/Documents/develop/magento2/vendor/magento/framework/Interception/Chain/Chain.php(68): call_user_func_array(Array, Array)
#31 /Library/WebServer/Documents/develop/magento2/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')
#32 /Library/WebServer/Documents/develop/magento2/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))
#33 [internal function]: Magento\Store\App\Action\Plugin\StoreCheck->aroundDispatch(Object(Magento\Checkout\Controller\Index\Index\Interceptor), Object(Closure), Object(Magento\Framework\App\Request\Http))
#34 /Library/WebServer/Documents/develop/magento2/vendor/magento/framework/Interception/Chain/Chain.php(68): call_user_func_array(Array, Array)
#35 /Library/WebServer/Documents/develop/magento2/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')
#36 /Library/WebServer/Documents/develop/magento2/vendor/magento/module-store/App/Action/Plugin/Context.php(98): Magento\Framework\Interception\Chain\Chain->Magento\Framework\Interception\Chain\{closure}(Object(Magento\Framework\App\Request\Http))
#37 [internal function]: Magento\Store\App\Action\Plugin\Context->aroundDispatch(Object(Magento\Checkout\Controller\Index\Index\Interceptor), Object(Closure), Object(Magento\Framework\App\Request\Http))
#38 /Library/WebServer/Documents/develop/magento2/vendor/magento/framework/Interception/Chain/Chain.php(68): call_user_func_array(Array, Array)
#39 /Library/WebServer/Documents/develop/magento2/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, 'tax-app-action-...')
#40 /Library/WebServer/Documents/develop/magento2/vendor/magento/module-tax/Model/App/Action/ContextPlugin.php(91): Magento\Framework\Interception\Chain\Chain->Magento\Framework\Interception\Chain\{closure}(Object(Magento\Framework\App\Request\Http))
#41 [internal function]: Magento\Tax\Model\App\Action\ContextPlugin->aroundDispatch(Object(Magento\Checkout\Controller\Index\Index\Interceptor), Object(Closure), Object(Magento\Framework\App\Request\Http))
#42 /Library/WebServer/Documents/develop/magento2/vendor/magento/framework/Interception/Chain/Chain.php(68): call_user_func_array(Array, Array)
#43 /Library/WebServer/Documents/develop/magento2/vendor/magento/framework/Interception/Interceptor.php(136): Magento\Framework\Interception\Chain\Chain->invokeNext('Magento\\Checkou...', 'dispatch', Object(Magento\Checkout\Controller\Index\Index\Interceptor), Array, 'weee-app-action...')
#44 /Library/WebServer/Documents/develop/magento2/vendor/magento/module-weee/Model/App/Action/ContextPlugin.php(112): Magento\Checkout\Controller\Index\Index\Interceptor->Magento\Framework\Interception\{closure}(Object(Magento\Framework\App\Request\Http))
#45 [internal function]: Magento\Weee\Model\App\Action\ContextPlugin->aroundDispatch(Object(Magento\Checkout\Controller\Index\Index\Interceptor), Object(Closure), Object(Magento\Framework\App\Request\Http))
#46 /Library/WebServer/Documents/develop/magento2/vendor/magento/framework/Interception/Interceptor.php(141): call_user_func_array(Array, Array)
#47 /Library/WebServer/Documents/develop/magento2/var/generation/Magento/Checkout/Controller/Index/Index/Interceptor.php(39): Magento\Checkout\Controller\Index\Index\Interceptor->___callPlugins('dispatch', Array, Array)
#48 /Library/WebServer/Documents/develop/magento2/vendor/magento/framework/App/FrontController.php(55): Magento\Checkout\Controller\Index\Index\Interceptor->dispatch(Object(Magento\Framework\App\Request\Http))
#49 [internal function]: Magento\Framework\App\FrontController->dispatch(Object(Magento\Framework\App\Request\Http))
#50 /Library/WebServer/Documents/develop/magento2/vendor/magento/framework/Interception/Interceptor.php(74): call_user_func_array(Array, Array)
#51 /Library/WebServer/Documents/develop/magento2/vendor/magento/framework/Interception/Chain/Chain.php(70): Magento\Framework\App\FrontController\Interceptor->___callParent('dispatch', Array)
#52 /Library/WebServer/Documents/develop/magento2/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...')
#53 /Library/WebServer/Documents/develop/magento2/vendor/magento/module-store/App/FrontController/Plugin/RequestPreprocessor.php(89): Magento\Framework\Interception\Chain\Chain->Magento\Framework\Interception\Chain\{closure}(Object(Magento\Framework\App\Request\Http))
#54 [internal function]: Magento\Store\App\FrontController\Plugin\RequestPreprocessor->aroundDispatch(Object(Magento\Framework\App\FrontController\Interceptor), Object(Closure), Object(Magento\Framework\App\Request\Http))
#55 /Library/WebServer/Documents/develop/magento2/vendor/magento/framework/Interception/Chain/Chain.php(68): call_user_func_array(Array, Array)
#56 /Library/WebServer/Documents/develop/magento2/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')
#57 /Library/WebServer/Documents/develop/magento2/vendor/magento/framework/Module/Plugin/DbStatusValidator.php(69): Magento\Framework\Interception\Chain\Chain->Magento\Framework\Interception\Chain\{closure}(Object(Magento\Framework\App\Request\Http))
#58 [internal function]: Magento\Framework\Module\Plugin\DbStatusValidator->aroundDispatch(Object(Magento\Framework\App\FrontController\Interceptor), Object(Closure), Object(Magento\Framework\App\Request\Http))
#59 /Library/WebServer/Documents/develop/magento2/vendor/magento/framework/Interception/Chain/Chain.php(68): call_user_func_array(Array, Array)
#60 /Library/WebServer/Documents/develop/magento2/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...')
#61 /Library/WebServer/Documents/develop/magento2/vendor/magento/module-page-cache/Model/App/FrontController/BuiltinPlugin.php(73): Magento\Framework\Interception\Chain\Chain->Magento\Framework\Interception\Chain\{closure}(Object(Magento\Framework\App\Request\Http))
#62 [internal function]: Magento\PageCache\Model\App\FrontController\BuiltinPlugin->aroundDispatch(Object(Magento\Framework\App\FrontController\Interceptor), Object(Closure), Object(Magento\Framework\App\Request\Http))
#63 /Library/WebServer/Documents/develop/magento2/vendor/magento/framework/Interception/Chain/Chain.php(68): call_user_func_array(Array, Array)
#64 /Library/WebServer/Documents/develop/magento2/vendor/magento/framework/Interception/Interceptor.php(136): Magento\Framework\Interception\Chain\Chain->invokeNext('Magento\\Framewo...', 'dispatch', Object(Magento\Framework\App\FrontController\Interceptor), Array, 'front-controlle...')
#65 /Library/WebServer/Documents/develop/magento2/vendor/magento/module-page-cache/Model/App/FrontController/VarnishPlugin.php(55): Magento\Framework\App\FrontController\Interceptor->Magento\Framework\Interception\{closure}(Object(Magento\Framework\App\Request\Http))
#66 [internal function]: Magento\PageCache\Model\App\FrontController\VarnishPlugin->aroundDispatch(Object(Magento\Framework\App\FrontController\Interceptor), Object(Closure), Object(Magento\Framework\App\Request\Http))
#67 /Library/WebServer/Documents/develop/magento2/vendor/magento/framework/Interception/Interceptor.php(141): call_user_func_array(Array, Array)
#68 /Library/WebServer/Documents/develop/magento2/var/generation/Magento/Framework/App/FrontController/Interceptor.php(26): Magento\Framework\App\FrontController\Interceptor->___callPlugins('dispatch', Array, Array)
#69 /Library/WebServer/Documents/develop/magento2/vendor/magento/framework/App/Http.php(115): Magento\Framework\App\FrontController\Interceptor->dispatch(Object(Magento\Framework\App\Request\Http))
#70 /Library/WebServer/Documents/develop/magento2/vendor/magento/framework/App/Bootstrap.php(258): Magento\Framework\App\Http->launch()
#71 /Library/WebServer/Documents/develop/magento2/pub/index.php(37): Magento\Framework\App\Bootstrap->run(Object(Magento\Framework\App\Http))
#72 {main}";s:3:"url";s:10:"/checkout/";s:11:"script_name";s:10:"/index.php";}

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

ishakhsuvarov commented 8 years ago

@thomasnordkvist Thank you for reporting this issue. Could you please provide a sample of zip_codes.xml which causes error?

thomasnordkvist commented 8 years ago

@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>
Frits1980 commented 8 years ago

It's kinda quiet in here. Is this being investigated? Because it's a real pain.

Frits1980 commented 8 years ago

Still no patch or something?

farior commented 8 years ago

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;
    }
}
piotrekkaminski commented 8 years ago

Internal issue MAGETWO-53441

Fairlight60 commented 7 years ago

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.

tlygnersjo commented 7 years ago

I'm having the same problem with multiple zip code masks. Is there any solution to this problem yet?

veloraven commented 7 years ago

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.

MHayward89 commented 6 years ago

This is still a problem in Magento 2.1.12

I've bypassed the issue using the workaround provided by @farior

matheusgontijo commented 6 years ago

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.