3

I have such a problem on Magento 2.3.3 I checked this logic on stock Magento 2.3.3 and it also appears there.

enter image description here

Choose a 2-3 allowed countries.

Then go to All Customer -> Customer Address Edit Form in Admin area.

Country dropdown is not as we expected.

If I just use 1 country none will show up if you chose more then it will just take countries from the top.

In console i don't have error's.

Anyone had this issue ad anyone solve it?

4 Answers 4

2

vendor/magento/module-customer/view/adminhtml/ui_component open customer_address_form.xml and remove below code from line number.194

<formElements>
   <select>
       <settings>
           <options class="Magento\Directory\Model\ResourceModel\Country\Collection"/>
           </settings>
      </select>
 </formElements>

Remove the above code from the file.

2
  • Yes, it's work. But how to do this not in this vendor? Commented Jan 10, 2020 at 9:12
  • You need to override this file in app code or you can also try new code which I have given you it’s little thing and Magento will fix this issue in next version may be. And in above code we are just changing order of code even if you want to override Above any file then you can try if you have good knowledge of overriding. Commented Jan 10, 2020 at 15:38
0

You can also try this solution In This File.

vendor/magento/module-ui/Component/Form/Element/AbstractOptionsField.php

Line no. 73

From :-

$config['options'] = array_values(array_replace_recursive($config['options'], $options));

To :-

$config['options'] = array_values(array_replace_recursive($options,$config['options']));
0

Try these Below steps.

  1. Select all countries as allowed in Default View.
  2. Select the Particular website view and select the required countries and save.
  3. Now you can see the countries in admin form and selected countries in frontend form

Or else you can check this link for a proper patch - https://github.com/magento/magento2/issues/25218 (I didn't check the patch)

0

I had a similar problem only in my case many countries were missing from the dropdown despite the correct configuration.

So I created a file app/code/[Vendor]/[Module]/view/adminhtml/ui_component/customer_address_form.xml and replaced the class for the dropdown options:

<?xml version="1.0" encoding="UTF-8"?>
<form xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Ui:etc/ui_configuration.xsd"
      component="Magento_Customer/js/form/components/form">
    <fieldset name="general">
        <field name="country_id" component="Magento_Customer/js/form/element/country" sortOrder="90" formElement="select">
            <formElements>
                <select>
                    <settings>
                        <options class="Magento\Customer\Model\ResourceModel\Address\Attribute\Source\Country"/>
                    </settings>
                </select>
            </formElements>
        </field>
    </fieldset>
</form>

So instead of Magento\Directory\Model\ResourceModel\Country\Collection, Magento\Customer\Model\ResourceModel\Address\Attribute\Source\Country will be used for fetching the countries. In this case I only get allowed countries.

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.