nopSolutions/nopCommerce · error · ArgumentException

Admin.Orders.Import.CustomersDontExist

Error message

Admin.Orders.Import.CustomersDontExist

What it means

Thrown during order XLSX import when customer GUIDs referenced in the spreadsheet do not exist in the database. nopCommerce batches all referenced customer GUIDs into one SQL check (GetNotExistingCustomersAsync) and aborts the entire import with an ArgumentException listing the missing GUIDs.

Source

Thrown at src/Libraries/Nop.Services/ExportImport/ImportManager.cs:1618

            }

            if (customerGuidCellNum > 0)
            {
                var customerGuidString = worksheet.Row(endRow).Cell(customerGuidCellNum).Value.ToString() ?? string.Empty;
                if (!string.IsNullOrEmpty(customerGuidString) && Guid.TryParse(customerGuidString, out var customerGuid))
                    allCustomerGuids.Add(customerGuid);
            }

            //counting the number of orders
            countOrdersInFile++;

            endRow++;
        }

        //performance optimization, the check for the existence of the customers in one SQL request
        var notExistingCustomerGuids = await _customerService.GetNotExistingCustomersAsync(allCustomerGuids.ToArray());
        if (notExistingCustomerGuids.Any())
            throw new ArgumentException(string.Format(await _localizationService.GetResourceAsync("Admin.Orders.Import.CustomersDontExist"), string.Join(", ", notExistingCustomerGuids)));

        //performance optimization, the check for the existence of the order items in one SQL request
        var notExistingProductSkus = await _productService.GetNotExistingProductsAsync(allOrderItemSkus.ToArray());
        if (notExistingProductSkus.Any())
            throw new ArgumentException(string.Format(await _localizationService.GetResourceAsync("Admin.Orders.Import.ProductsDontExist"), string.Join(", ", notExistingProductSkus)));

        return (new ImportOrderMetadata
        {
            EndRow = endRow,
            Manager = manager,
            Properties = defaultProperties,
            CountOrdersInFile = countOrdersInFile,
            OrderItemManager = orderItemManager,
            AllOrderGuids = allOrderGuids,
            AllCustomerGuids = allCustomerGuids
        }, worksheet);
    }

View on GitHub (pinned to 64bdf2ff08)

Solutions

  1. Migrate/create the referenced customers first so each GUID resolves, then re-run the order import.
  2. Export current customers and confirm every GUID in the file matches an existing customer.
  3. Remove order rows whose customer GUIDs cannot be satisfied.
  4. When migrating environments, import customers before orders and preserve the GUIDs.

Example fix

// before
await _importManager.ImportOrdersFromXlsxAsync(stream);

// after — validate customer GUIDs up front
var validGuids = (await _customerService.GetAllCustomersAsync()).Select(c => c.CustomerGuid).ToHashSet();
var badGuids = referencedGuids.Where(g => !validGuids.Contains(g)).ToList();
if (badGuids.Any())
    return BadRequest($"These customer GUIDs do not exist: {string.Join(", ", badGuids)}");
await _importManager.ImportOrdersFromXlsxAsync(stream);
Defensive patterns

Strategy: validation

Validate before calling

// Pre-validate customer GUIDs referenced in the order import
var validGuids = (await _customerService.GetAllCustomersAsync()).Select(c => c.CustomerGuid).ToHashSet();
var bad = referencedGuids.Where(g => !validGuids.Contains(g)).ToList();
if (bad.Any())
    return BadRequest($"These customer GUIDs do not exist: {string.Join(", ", bad)}");
await _importManager.ImportOrdersFromXlsxAsync(stream);

Try / catch

try { await _importManager.ImportOrdersFromXlsxAsync(stream); }
catch (ArgumentException ex) when (ex.Message.Contains("CustomersDontExist"))
{ /* show the missing customer GUIDs to the user */ }

Prevention

When it happens

Trigger: Calling ImportOrdersFromXlsxAsync with an XLSX whose Customer GUID column references GUIDs that have no matching Customer record. Fires after the worksheet scan, before the product-SKU check.

Common situations: Order spreadsheet exported from another store whose customers were never migrated; customers were deleted/anonymized after export (GDPR cleanup); GUIDs hand-typed incorrectly; importing against a fresh DB with no customers.

Related errors


AI-assisted analysis of nopSolutions/nopCommerce@64bdf2ff08 (2026-08-13). Data as JSON: /api/errors/26942da5bdf3f9f6. Report an issue: GitHub.