{"record":{"id":"bcae54f42fea2d36","repo":"nopSolutions/nopCommerce","slug":"admin-pricelists-import-productsdontexist","errorCode":null,"errorMessage":"Admin.PriceLists.Import.ProductsDontExist","messagePattern":"Admin\\.PriceLists\\.Import\\.ProductsDontExist","errorType":"validation","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/Libraries/Nop.Services/ExportImport/ImportManager.cs","lineNumber":1693,"sourceCode":"\r\n                //skip caption row\r\n                if (!priceListItemManager.IsCaption)\r\n                    allPriceListItemSkus.Add(priceListItemManager.GetDefaultProperty(\"Sku\").StringValue);\r\n\r\n                endRow++;\r\n                continue;\r\n            }\r\n\r\n            //counting the number of orders\r\n            countPriceListsInFile++;\r\n\r\n            endRow++;\r\n        }\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(allPriceListItemSkus.ToArray());\r\n        if (notExistingProductSkus.Any())\r\n            throw new ArgumentException(string.Format(await _localizationService.GetResourceAsync(\"Admin.PriceLists.Import.ProductsDontExist\"), string.Join(\", \", notExistingProductSkus)));\r\n\r\n        return (new ImportPriceListMetadata\r\n        {\r\n            EndRow = endRow,\r\n            Manager = manager,\r\n            Properties = defaultProperties,\r\n            CountPriceListsInFile = countPriceListsInFile,\r\n            PriceListItemManager = priceListItemManager\r\n        }, worksheet);\r\n    }\r\n\r\n    /// <returns>A task that represents the asynchronous operation</returns>\r\n    protected virtual async Task ImportOrderItemAsync(PropertyManager<OrderItem> orderItemManager, Order lastLoadedOrder)\r\n    {\r\n        if (lastLoadedOrder == null || orderItemManager.IsCaption)\r\n            return;\r\n\r\n        var orderItemGuid = Guid.TryParse(orderItemManager.GetDefaultProperty(\"OrderItemGuid\").StringValue, out var guidValue) ? guidValue : Guid.NewGuid();\r","sourceCodeStart":1675,"sourceCodeEnd":1711,"githubUrl":"https://github.com/nopSolutions/nopCommerce/blob/64bdf2ff08c8b39e65717bcf974fb43dc2ef68f2/src/Libraries/Nop.Services/ExportImport/ImportManager.cs#L1675-L1711","documentation":"Thrown during price-list XLSX import when product SKUs referenced by price-list items do not exist in the database. nopCommerce batches all referenced price-list-item SKUs into one SQL check (GetNotExistingProductsAsync) and aborts the import with an ArgumentException listing the missing SKUs.","triggerScenarios":"Calling the price-list import path with an XLSX whose price-list-item SKU column references SKUs that have no matching Product. Fires after the worksheet scan, just before ImportPriceListMetadata is returned.","commonSituations":"Price-list spreadsheet references products not yet imported; SKUs changed or were deleted after the price list was built; whitespace/casing mismatches in SKUs; importing a vendor price list against a catalog that lacks those products.","solutions":["Import/seed the referenced products first so every SKU resolves, then re-run the price-list import.","Export current SKUs and diff against the price-list file to catch typos/whitespace/casing.","Remove price-list rows for SKUs that have no product.","Keep SKUs stable across environments when migrating price lists."],"exampleFix":"// before\nawait _importManager.ImportPriceListsFromXlsxAsync(stream);\n\n// after — validate price-list SKUs up front\nvar existingSkus = (await _productService.SearchProductsAsync(0, int.MaxValue)).products.Select(p => p.Sku).Where(s => !string.IsNullOrWhiteSpace(s)).ToHashSet(StringComparer.OrdinalIgnoreCase);\nvar badSkus = priceListItemSkus.Where(s => !existingSkus.Contains(s.Trim())).ToList();\nif (badSkus.Any())\n    return BadRequest($\"These product SKUs do not exist: {string.Join(\", \", badSkus)}\");\nawait _importManager.ImportPriceListsFromXlsxAsync(stream);","handlingStrategy":"validation","validationCode":"// Pre-validate price-list-item SKUs against existing products\nvar skus = (await _productService.SearchProductsAsync(0, int.MaxValue)).products\n    .Select(p => p.Sku).Where(s => !string.IsNullOrWhiteSpace(s))\n    .ToHashSet(StringComparer.OrdinalIgnoreCase);\nvar bad = priceListItemSkus.Where(s => !skus.Contains(s.Trim())).ToList();\nif (bad.Any())\n    return BadRequest($\"These product SKUs do not exist: {string.Join(\", \", bad)}\");\nawait _importManager.ImportPriceListsFromXlsxAsync(stream);","typeGuard":null,"tryCatchPattern":"try { await _importManager.ImportPriceListsFromXlsxAsync(stream); }\ncatch (ArgumentException ex) when (ex.Message.Contains(\"ProductsDontExist\"))\n{ /* show the missing price-list SKUs */ }","preventionTips":["Ensure the catalog has the referenced products before importing a price list.","Reconcile SKUs (whitespace/casing) between the price list and the catalog.","Drop price-list rows whose SKUs are not in the catalog."],"tags":["import","pricelist","products","sku","nopcommerce"],"backgroundTag":null,"analyzedSha":"64bdf2ff08c8b39e65717bcf974fb43dc2ef68f2","analyzedAt":"2026-08-13T21:19:38.062Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}