2

I'm having a real nightmare trying to import customers using "Single File" right now.

I've been using Firebear Importer for this, but I've since noticed that this is happening using the native importer too and I'm stumped.

So after much trial and error with the customer import I'm working with, I've generated the sample file and used that. This is what I'm trying to import:

note, I'm working with British Addresses here

email,_website,confirmation,disable_auto_group_change,firstname,gender,group_id,lastname,middlename,password_hash,prefix,rp_token,rp_token_created_at,store_id,suffix,taxvat,website_id,password,_address_city,_address_country_id,_address_firstname,_address_lastname,_address_middlename,_address_postcode,_address_prefix,_address_region,_address_street,_address_suffix,_address_telephone,_address_vat_id,_address_default_billing_,_address_default_shipping_
jondoe@example.com,base,,0,Jon,Male,1,Doe,,703feeb7a8a5195cf1cc9b759ba1e113:V2h36OrOJRh56MyGHw9NF1J855eL9X4P,,,,0,,,1,,Campbell,GB,Jon,Doe,,95008,,Lancashire,"Main Street 1
Suite 200",,123456789,,1,1

If I attempt to import this file, I get the error

  1. Please enter a valid region. in row(s): 1

However, if I switch the country to "US" and the region to "California", it will import. If I switch to US and then use something other than a state name or abbreviation, it will not import either. If I do the opposite (switch country to GB and use a state name) that won't import.

It just doesn't accept anything that's not USA and I'm really struggling.

Here's some additional notes:

  • This works on another magento store I tested with
  • My store locale is Great Britain
  • In configuration > State Options, "State is required For" has nothing selected now.
  • My store was migrated from M1
  • The directory_ db tables are identical between this store and another that works
  • On the frontend, I can create a customer using any old value in the region field.

I'm puzzled. The only instance of this error message is in /vendor/magento/module-customer-import-export/Model/Import/Address.php. In typical Magento fashion, I can find absolutely no documentation for this error anywhere. It would help to know what the specifics are because I haven't a scooby.

Thanks

  • Hey Thomas, did you find any solution for this? – Prashant May 21 at 18:40
  • 1
    Hey Prashant. My colleague managed to solve it. I'll post it in a separate answer now. – Thomas Harding May 22 at 8:33
4

Managed to solve it (well a colleague managed to solve it).

I think it was an issue with one of the updates up to Magento 2.3.4, it basically tries to validate a region against a country even if the country doesn't have region IDs already specified.

Here's what he changed.

The file that needs to be overridden is vendor/magento/module-customer-import-export/Model/Import/Address.php

At around line 896, there is this function:

            if (isset($rowData[self::COLUMN_REGION])
                && !empty($rowData[self::COLUMN_REGION])
                && false === $this->getCountryRegionId(
                    $rowData[self::COLUMN_COUNTRY_ID],
                    $rowData[self::COLUMN_REGION]
                )
            ) {
                $this->addRowError(self::ERROR_INVALID_REGION, $rowNumber, self::COLUMN_REGION);
            }

He replaced it with:

       if (isset($rowData[self::COLUMN_COUNTRY_ID]) && isset($rowData[self::COLUMN_REGION])) {
                        $countryRegions = isset(
                            $this->_countryRegions[strtolower($rowData[self::COLUMN_COUNTRY_ID])]
                        ) ? $this->_countryRegions[strtolower(
                            $rowData[self::COLUMN_COUNTRY_ID]
                        )] : [];

                        if (!empty($rowData[self::COLUMN_REGION]) && !empty($countryRegions) && !isset(
                                $countryRegions[strtolower($rowData[self::COLUMN_REGION])]
                            )
                        ) {
                            $this->addRowError(self::ERROR_INVALID_REGION, $rowNumber, self::COLUMN_REGION);
                        }
                    }

...and that seemed to do the trick.

| improve this answer | |
  • Hey Thomas, it worked. Thanks :) – Prashant May 22 at 14:31
  • Same bug on 2.3.5-p1. The solution provided by Thomas Harding seems to work here too. Thanks! – Valerio Masciotta Aug 4 at 9:57
  • Works beautifully Magento 2.3.5-p2 thank you for posting this. You'd think Adobe/Magento would take the rest of the world into account!! – Jaimie Dijstra Oct 14 at 9:52

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.