nopSolutions/nopCommerce · error · ArgumentException

Admin.PriceLists.Import.ProductsDontExist

Error message

Admin.PriceLists.Import.ProductsDontExist

What it means

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.

Source

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

                //skip caption row
                if (!priceListItemManager.IsCaption)
                    allPriceListItemSkus.Add(priceListItemManager.GetDefaultProperty("Sku").StringValue);

                endRow++;
                continue;
            }

            //counting the number of orders
            countPriceListsInFile++;

            endRow++;
        }

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

        return (new ImportPriceListMetadata
        {
            EndRow = endRow,
            Manager = manager,
            Properties = defaultProperties,
            CountPriceListsInFile = countPriceListsInFile,
            PriceListItemManager = priceListItemManager
        }, worksheet);
    }

    /// <returns>A task that represents the asynchronous operation</returns>
    protected virtual async Task ImportOrderItemAsync(PropertyManager<OrderItem> orderItemManager, Order lastLoadedOrder)
    {
        if (lastLoadedOrder == null || orderItemManager.IsCaption)
            return;

        var orderItemGuid = Guid.TryParse(orderItemManager.GetDefaultProperty("OrderItemGuid").StringValue, out var guidValue) ? guidValue : Guid.NewGuid();

View on GitHub (pinned to 64bdf2ff08)

Solutions

  1. Import/seed the referenced products first so every SKU resolves, then re-run the price-list import.
  2. Export current SKUs and diff against the price-list file to catch typos/whitespace/casing.
  3. Remove price-list rows for SKUs that have no product.
  4. Keep SKUs stable across environments when migrating price lists.

Example fix

// before
await _importManager.ImportPriceListsFromXlsxAsync(stream);

// after — validate price-list SKUs up front
var existingSkus = (await _productService.SearchProductsAsync(0, int.MaxValue)).products.Select(p => p.Sku).Where(s => !string.IsNullOrWhiteSpace(s)).ToHashSet(StringComparer.OrdinalIgnoreCase);
var badSkus = priceListItemSkus.Where(s => !existingSkus.Contains(s.Trim())).ToList();
if (badSkus.Any())
    return BadRequest($"These product SKUs do not exist: {string.Join(", ", badSkus)}");
await _importManager.ImportPriceListsFromXlsxAsync(stream);
Defensive patterns

Strategy: validation

Validate before calling

// Pre-validate price-list-item SKUs against existing products
var skus = (await _productService.SearchProductsAsync(0, int.MaxValue)).products
    .Select(p => p.Sku).Where(s => !string.IsNullOrWhiteSpace(s))
    .ToHashSet(StringComparer.OrdinalIgnoreCase);
var bad = priceListItemSkus.Where(s => !skus.Contains(s.Trim())).ToList();
if (bad.Any())
    return BadRequest($"These product SKUs do not exist: {string.Join(", ", bad)}");
await _importManager.ImportPriceListsFromXlsxAsync(stream);

Try / catch

try { await _importManager.ImportPriceListsFromXlsxAsync(stream); }
catch (ArgumentException ex) when (ex.Message.Contains("ProductsDontExist"))
{ /* show the missing price-list SKUs */ }

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


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