1

I keep getting this error in Magento 2.3.1 when viewing some customer address data in Customers > view customer > Addresses "Something went wrong with processing the default view and we have restored the filter to its original state."

The error doesn't appear if the customer has not got an address saved.

Digging in to the exception.log file I see this error:

main.CRITICAL: Please correct the country code: . {"exception":"[object] (Magento\Framework\Exception\LocalizedException(code: 0): Please correct the country code: . at /var/www/magento/vendor/magento/module-directory/Model/ResourceModel/Country.php:46)"} []

It happens on all new customer accounts whether they've registered on the frontend of the site or created in admin. The site has 3 store views (GBP, EUR and USD) and it happens on accounts created on all store views. The migrated accounts from 1.9 aren't affected. The grid at the bottom of the page never renders either. The spinner just spins.

Any ideas what might be causing this? spinner

2
  • Please check your 3party extension list?
    – Amit Bera
    Jun 6 '19 at 9:26
  • Good idea, it may be the GDPR extension. I will try disabling it. Jun 6 '19 at 18:01
5

For me the issue was that for some reason in the "customer_address_entity" table some address entities were missing a value in the "country_id" field. This might've been due to an upgrade, but I can not tell for certain as I did not set up that particular shop.

The solution would be to just add the correct country code for each address. Since that particular shop only allowed customers from one country, it was a quite simple SQL query:

UPDATE customer_address_entity SET country_id = '<Your country code>' WHERE  country_id = '';
4
  • thanks, that's got rid of the error but not sure if it's just cured the symptoms. It looks like a blank record was created in that table when the customer address was created. Jun 7 '19 at 21:01
  • It only cured the symptom. customer_address_entity is not populating when an address is added. Jun 7 '19 at 21:48
  • Quick update - when a new address is added the record is created in customer_address_entity but all the fields are NULL except for entity_id and parent_id Jul 4 '19 at 14:58
  • @DenialDesign ever figured this out? Having exactly the same issue atm May 20 '20 at 10:40
0

I encountered this same issue and fixed it in another simple way, might be useful for anyone reading this.

The error said

[2020-05-20 11:06:33] main.CRITICAL: Please correct the country code: . {"exception":"[object] (Magento\\Framework\\Exception\\LocalizedException(code: 0): Please correct the country code: . at /opt/magento/public_html/vendor/magento/module-directory/Model/ResourceModel/Country.php:78)"} []

So I figured this would have to do with a missing countryCode in the database, so I looked up this specific customer's address in all tables, but they all had the correct country. So I added logging to the loadByCode() function in /vendor/magento/module-directory/Model/ResourceModel/Country.php

Turns out that strlen returned both 2 and 0 when I loaded the customer data. So it would be a missing countryCode. I replaced the default case Exception, and hardcoded the correct countryCode;

default:
// throw new \Magento\Framework\Exception\LocalizedException(
//     __('Please correct the country code: %1.', $this->escaper->escapeHtml($code))
// );
$field = 'iso2_code';
$code = 'BE';

Forcing the admin to work again. This showed me that there were 2 address entities for this customer, one being all blank; so I wouldn't find it in the database because every value was NULL. With this hotfix in place I was able to delete the empty/faulty address record, save the customer, and all works fine!

Don't forget to undo that code change after you're done though!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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