nopSolutions/nopCommerce · error · ArgumentException

Admin.Catalog.Products.ExceededMaximumNumber

Error message

Admin.Catalog.Products.ExceededMaximumNumber

What it means

Thrown during product XLSX import when the current vendor would exceed the configured maximum number of products per vendor (VendorSettings.MaximumProductNumber). nopCommerce computes newProductsCount = products in file minus already-existing SKUs, adds it to the vendor's current product count, and if the total exceeds the cap, aborts the import with an ArgumentException.

Source

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

        var defaultWorksheet = metadata.DefaultWorksheet;

        if (_catalogSettings.ExportImportSplitProductsFile && metadata.CountProductsInFile > _catalogSettings.ExportImportProductsCountInOneFile)
        {
            await ImportProductsFromSplitedXlsxAsync(defaultWorksheet, metadata);
            return;
        }

        //performance optimization, load all products by SKU in one SQL request
        var currentVendor = await _workContext.GetCurrentVendorAsync();
        var allProductsBySku = await _productService.GetProductsBySkuAsync(metadata.AllSku.ToArray(), currentVendor?.Id ?? 0);

        //validate maximum number of products per vendor
        if (_vendorSettings.MaximumProductNumber > 0 &&
            currentVendor != null)
        {
            var newProductsCount = metadata.CountProductsInFile - allProductsBySku.Count;
            if (await _productService.GetNumberOfProductsByVendorIdAsync(currentVendor.Id) + newProductsCount > _vendorSettings.MaximumProductNumber)
                throw new ArgumentException(string.Format(await _localizationService.GetResourceAsync("Admin.Catalog.Products.ExceededMaximumNumber"), _vendorSettings.MaximumProductNumber));
        }

        //validate Circular dependency for required products
        var circularDependencyProducts = new List<Product>();

        foreach (var data in metadata.RequiredProductsData)
        {
            if (isCyclicallyRequired(data, out var product))
                circularDependencyProducts.Add(product);
        }

        if (circularDependencyProducts.Any())
            throw new ArgumentException($"{await _localizationService.GetResourceAsync("Admin.Catalog.Products.RelatedProducts.CyclicallyRelated")} ({string.Join(", ", circularDependencyProducts.Select(p => p.Name).Distinct())})");

        //performance optimization, load all categories IDs for products in one SQL request
        var allProductsCategoryIds = await _categoryService.GetProductCategoryIdsAsync(allProductsBySku.Select(p => p.Id).ToArray());

        //performance optimization, load all categories in one SQL request

View on GitHub (pinned to 64bdf2ff08)

Solutions

  1. Reduce the number of new products in the import file so the vendor stays under the limit (update existing SKUs instead of adding new ones).
  2. Raise VendorSettings.MaximumProductNumber in Configuration > Vendors (or remove the limit by setting it to 0) if the quota is too low.
  3. Run the import as an administrator (no vendor scope) if the products are not vendor-owned.
  4. Pre-count: check the vendor's current product count plus new SKUs against the cap before importing.

Example fix

// before
await _importManager.ImportProductsFromXlsxAsync(stream);

// after — pre-check the vendor quota and surface it
var vendor = await _workContext.GetCurrentVendorAsync();
if (_vendorSettings.MaximumProductNumber > 0 && vendor != null)
{
    var existing = await _productService.GetNumberOfProductsByVendorIdAsync(vendor.Id);
    var newCount = newSkusInFile.Count;
    if (existing + newCount > _vendorSettings.MaximumProductNumber)
        return BadRequest($"Import would exceed the per-vendor limit of {_vendorSettings.MaximumProductNumber} products (current {existing}, adding {newCount}).");
}
await _importManager.ImportProductsFromXlsxAsync(stream);
Defensive patterns

Strategy: validation

Validate before calling

// Pre-check the vendor product quota before importing
var vendor = await _workContext.GetCurrentVendorAsync();
if (_vendorSettings.MaximumProductNumber > 0 && vendor != null)
{
    var existing = await _productService.GetNumberOfProductsByVendorIdAsync(vendor.Id);
    var newCount = newSkusInFile.Count;
    if (existing + newCount > _vendorSettings.MaximumProductNumber)
        return BadRequest($"Import would exceed the per-vendor limit of {_vendorSettings.MaximumProductNumber} (current {existing}, adding {newCount}).");
}
await _importManager.ImportProductsFromXlsxAsync(stream);

Try / catch

try { await _importManager.ImportProductsFromXlsxAsync(stream); }
catch (ArgumentException ex) when (ex.Message.Contains("ExceededMaximumNumber"))
{ /* show the vendor their quota and ask them to update existing SKUs instead */ }

Prevention

When it happens

Trigger: Importing products while logged in as a vendor, when MaximumProductNumber > 0 and the projected post-import product count (existing vendor products + new SKUs in the file) exceeds the limit. Does not fire for administrators/staff (currentVendor == null).

Common situations: Vendor quota set in admin but vendor tries to import past it; a vendor re-imports a file that also contains new products; an admin reduced the quota below a vendor's existing catalog; bulk import by a vendor with many new SKUs at once.

Related errors


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