{"record":{"id":"26942da5bdf3f9f6","repo":"nopSolutions/nopCommerce","slug":"admin-orders-import-customersdontexist","errorCode":null,"errorMessage":"Admin.Orders.Import.CustomersDontExist","messagePattern":"Admin\\.Orders\\.Import\\.CustomersDontExist","errorType":"validation","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/Libraries/Nop.Services/ExportImport/ImportManager.cs","lineNumber":1618,"sourceCode":"            }\r\n\r\n            if (customerGuidCellNum > 0)\r\n            {\r\n                var customerGuidString = worksheet.Row(endRow).Cell(customerGuidCellNum).Value.ToString() ?? string.Empty;\r\n                if (!string.IsNullOrEmpty(customerGuidString) && Guid.TryParse(customerGuidString, out var customerGuid))\r\n                    allCustomerGuids.Add(customerGuid);\r\n            }\r\n\r\n            //counting the number of orders\r\n            countOrdersInFile++;\r\n\r\n            endRow++;\r\n        }\r\n\r\n        //performance optimization, the check for the existence of the customers in one SQL request\r\n        var notExistingCustomerGuids = await _customerService.GetNotExistingCustomersAsync(allCustomerGuids.ToArray());\r\n        if (notExistingCustomerGuids.Any())\r\n            throw new ArgumentException(string.Format(await _localizationService.GetResourceAsync(\"Admin.Orders.Import.CustomersDontExist\"), string.Join(\", \", notExistingCustomerGuids)));\r\n\r\n        //performance optimization, the check for the existence of the order items in one SQL request\r\n        var notExistingProductSkus = await _productService.GetNotExistingProductsAsync(allOrderItemSkus.ToArray());\r\n        if (notExistingProductSkus.Any())\r\n            throw new ArgumentException(string.Format(await _localizationService.GetResourceAsync(\"Admin.Orders.Import.ProductsDontExist\"), string.Join(\", \", notExistingProductSkus)));\r\n\r\n        return (new ImportOrderMetadata\r\n        {\r\n            EndRow = endRow,\r\n            Manager = manager,\r\n            Properties = defaultProperties,\r\n            CountOrdersInFile = countOrdersInFile,\r\n            OrderItemManager = orderItemManager,\r\n            AllOrderGuids = allOrderGuids,\r\n            AllCustomerGuids = allCustomerGuids\r\n        }, worksheet);\r\n    }\r\n\r","sourceCodeStart":1600,"sourceCodeEnd":1636,"githubUrl":"https://github.com/nopSolutions/nopCommerce/blob/64bdf2ff08c8b39e65717bcf974fb43dc2ef68f2/src/Libraries/Nop.Services/ExportImport/ImportManager.cs#L1600-L1636","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Migrate/create the referenced customers first so each GUID resolves, then re-run the order import.","Export current customers and confirm every GUID in the file matches an existing customer.","Remove order rows whose customer GUIDs cannot be satisfied.","When migrating environments, import customers before orders and preserve the GUIDs."],"exampleFix":"// before\nawait _importManager.ImportOrdersFromXlsxAsync(stream);\n\n// after — validate customer GUIDs up front\nvar validGuids = (await _customerService.GetAllCustomersAsync()).Select(c => c.CustomerGuid).ToHashSet();\nvar badGuids = referencedGuids.Where(g => !validGuids.Contains(g)).ToList();\nif (badGuids.Any())\n    return BadRequest($\"These customer GUIDs do not exist: {string.Join(\", \", badGuids)}\");\nawait _importManager.ImportOrdersFromXlsxAsync(stream);","handlingStrategy":"validation","validationCode":"// Pre-validate customer GUIDs referenced in the order import\nvar validGuids = (await _customerService.GetAllCustomersAsync()).Select(c => c.CustomerGuid).ToHashSet();\nvar bad = referencedGuids.Where(g => !validGuids.Contains(g)).ToList();\nif (bad.Any())\n    return BadRequest($\"These customer GUIDs do not exist: {string.Join(\", \", bad)}\");\nawait _importManager.ImportOrdersFromXlsxAsync(stream);","typeGuard":null,"tryCatchPattern":"try { await _importManager.ImportOrdersFromXlsxAsync(stream); }\ncatch (ArgumentException ex) when (ex.Message.Contains(\"CustomersDontExist\"))\n{ /* show the missing customer GUIDs to the user */ }","preventionTips":["Always import/migrate customers before orders, preserving GUIDs.","Confirm every GUID in the order file resolves to a current customer.","Remove order rows whose customers were deleted/anonymized."],"tags":["import","orders","customers","nopcommerce"],"backgroundTag":null,"analyzedSha":"64bdf2ff08c8b39e65717bcf974fb43dc2ef68f2","analyzedAt":"2026-08-13T21:19:38.062Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}