{"record":{"id":"59d2752ace32e8d1","repo":"nopSolutions/nopCommerce","slug":"admin-catalog-products-exceededmaximumnumber","errorCode":null,"errorMessage":"Admin.Catalog.Products.ExceededMaximumNumber","messagePattern":"Admin\\.Catalog\\.Products\\.ExceededMaximumNumber","errorType":"validation","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/Libraries/Nop.Services/ExportImport/ImportManager.cs","lineNumber":2205,"sourceCode":"        var defaultWorksheet = metadata.DefaultWorksheet;\r\n\r\n        if (_catalogSettings.ExportImportSplitProductsFile && metadata.CountProductsInFile > _catalogSettings.ExportImportProductsCountInOneFile)\r\n        {\r\n            await ImportProductsFromSplitedXlsxAsync(defaultWorksheet, metadata);\r\n            return;\r\n        }\r\n\r\n        //performance optimization, load all products by SKU in one SQL request\r\n        var currentVendor = await _workContext.GetCurrentVendorAsync();\r\n        var allProductsBySku = await _productService.GetProductsBySkuAsync(metadata.AllSku.ToArray(), currentVendor?.Id ?? 0);\r\n\r\n        //validate maximum number of products per vendor\r\n        if (_vendorSettings.MaximumProductNumber > 0 &&\r\n            currentVendor != null)\r\n        {\r\n            var newProductsCount = metadata.CountProductsInFile - allProductsBySku.Count;\r\n            if (await _productService.GetNumberOfProductsByVendorIdAsync(currentVendor.Id) + newProductsCount > _vendorSettings.MaximumProductNumber)\r\n                throw new ArgumentException(string.Format(await _localizationService.GetResourceAsync(\"Admin.Catalog.Products.ExceededMaximumNumber\"), _vendorSettings.MaximumProductNumber));\r\n        }\r\n\r\n        //validate Circular dependency for required products\r\n        var circularDependencyProducts = new List<Product>();\r\n\r\n        foreach (var data in metadata.RequiredProductsData)\r\n        {\r\n            if (isCyclicallyRequired(data, out var product))\r\n                circularDependencyProducts.Add(product);\r\n        }\r\n\r\n        if (circularDependencyProducts.Any())\r\n            throw new ArgumentException($\"{await _localizationService.GetResourceAsync(\"Admin.Catalog.Products.RelatedProducts.CyclicallyRelated\")} ({string.Join(\", \", circularDependencyProducts.Select(p => p.Name).Distinct())})\");\r\n\r\n        //performance optimization, load all categories IDs for products in one SQL request\r\n        var allProductsCategoryIds = await _categoryService.GetProductCategoryIdsAsync(allProductsBySku.Select(p => p.Id).ToArray());\r\n\r\n        //performance optimization, load all categories in one SQL request\r","sourceCodeStart":2187,"sourceCodeEnd":2223,"githubUrl":"https://github.com/nopSolutions/nopCommerce/blob/64bdf2ff08c8b39e65717bcf974fb43dc2ef68f2/src/Libraries/Nop.Services/ExportImport/ImportManager.cs#L2187-L2223","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","solutions":["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).","Raise VendorSettings.MaximumProductNumber in Configuration > Vendors (or remove the limit by setting it to 0) if the quota is too low.","Run the import as an administrator (no vendor scope) if the products are not vendor-owned.","Pre-count: check the vendor's current product count plus new SKUs against the cap before importing."],"exampleFix":"// before\nawait _importManager.ImportProductsFromXlsxAsync(stream);\n\n// after — pre-check the vendor quota and surface it\nvar vendor = await _workContext.GetCurrentVendorAsync();\nif (_vendorSettings.MaximumProductNumber > 0 && vendor != null)\n{\n    var existing = await _productService.GetNumberOfProductsByVendorIdAsync(vendor.Id);\n    var newCount = newSkusInFile.Count;\n    if (existing + newCount > _vendorSettings.MaximumProductNumber)\n        return BadRequest($\"Import would exceed the per-vendor limit of {_vendorSettings.MaximumProductNumber} products (current {existing}, adding {newCount}).\");\n}\nawait _importManager.ImportProductsFromXlsxAsync(stream);","handlingStrategy":"validation","validationCode":"// Pre-check the vendor product quota before importing\nvar vendor = await _workContext.GetCurrentVendorAsync();\nif (_vendorSettings.MaximumProductNumber > 0 && vendor != null)\n{\n    var existing = await _productService.GetNumberOfProductsByVendorIdAsync(vendor.Id);\n    var newCount = newSkusInFile.Count;\n    if (existing + newCount > _vendorSettings.MaximumProductNumber)\n        return BadRequest($\"Import would exceed the per-vendor limit of {_vendorSettings.MaximumProductNumber} (current {existing}, adding {newCount}).\");\n}\nawait _importManager.ImportProductsFromXlsxAsync(stream);","typeGuard":null,"tryCatchPattern":"try { await _importManager.ImportProductsFromXlsxAsync(stream); }\ncatch (ArgumentException ex) when (ex.Message.Contains(\"ExceededMaximumNumber\"))\n{ /* show the vendor their quota and ask them to update existing SKUs instead */ }","preventionTips":["Tell vendors their quota up front and count new vs. update SKUs before importing.","Raise or remove MaximumProductNumber in Vendor settings if the limit is wrong.","Run out-of-quota imports as an administrator when appropriate."],"tags":["import","vendor","quota","catalog","nopcommerce"],"backgroundTag":null,"analyzedSha":"64bdf2ff08c8b39e65717bcf974fb43dc2ef68f2","analyzedAt":"2026-08-13T21:19:38.062Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}