{"record":{"id":"b6e09da76782320d","repo":"nopSolutions/nopCommerce","slug":"product-is-not-found","errorCode":null,"errorMessage":"Product is not found","messagePattern":"Product is not found","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"src/Presentation/Nop.Web/Areas/Admin/Factories/ShoppingCartModelFactory.cs","lineNumber":208,"sourceCode":"    /// </returns>\n    public virtual async Task<ShoppingCartItemListModel> PrepareShoppingCartItemListModelAsync(ShoppingCartItemSearchModel searchModel, Customer customer)\n    {\n        ArgumentNullException.ThrowIfNull(searchModel);\n        ArgumentNullException.ThrowIfNull(customer);\n\n        //get shopping cart items\n        var items = (await _shoppingCartService\n            .GetShoppingCartAsync(customer, shoppingCartType: searchModel.ShoppingCartType, storeId: searchModel.StoreId, productId: searchModel.ProductId, createdFromUtc: searchModel.StartDate, createdToUtc: searchModel.EndDate, customWishlistId: 0))\n            .ToPagedList(searchModel);\n\n        var isSearchProduct = searchModel.ProductId > 0;\n\n        Product product = null;\n\n        if (isSearchProduct)\n        {\n            product = await _productService.GetProductByIdAsync(searchModel.ProductId)\n                ?? throw new Exception(\"Product is not found\");\n        }\n\n        var store = await _storeService.GetStoreByIdAsync(searchModel.StoreId);\n        var customWishlists = items.Any(item => item.ShoppingCartType == ShoppingCartType.Wishlist)\n            ? await _customWishlistService.GetAllCustomWishlistsAsync(customer.Id)\n            : new List<CustomWishlist>();\n\n        //prepare list model\n        var model = await new ShoppingCartItemListModel().PrepareToGridAsync(searchModel, items, () =>\n        {\n            return items\n                .OrderByDescending(item => item.CreatedOnUtc)\n                .SelectAwait(async item =>\n                {\n                    //fill in model values from the entity\n                    var itemModel = item.ToModel<ShoppingCartItemModel>();\n\n                    if (!isSearchProduct)","sourceCodeStart":190,"sourceCodeEnd":226,"githubUrl":"https://github.com/nopSolutions/nopCommerce/blob/64bdf2ff08c8b39e65717bcf974fb43dc2ef68f2/src/Presentation/Nop.Web/Areas/Admin/Factories/ShoppingCartModelFactory.cs#L190-L226","documentation":"Thrown in PrepareShoppingCartItemListModelAsync (admin shopping-cart search) when searchModel.ProductId > 0 (isSearchProduct) but _productService.GetProductByIdAsync returns null. The search was filtered by a product that does not exist, so the factory cannot resolve product context for the grid and throws a bare Exception. It indicates a stale product id in the search filter.","triggerScenarios":"Admin opens the shopping cart/wishlist search grid and enters/links a ProductId that no longer exists (deleted or never created), and isSearchProduct evaluates true. The lookup returns null and the exception fires.","commonSituations":"Following a deep link with a product id that was deleted; product id passed from an external tool/report that is out of date; multi-store where the product is not in scope; copy-paste of a wrong id into the product filter.","solutions":["Clear the ProductId filter or pick a valid product from the autocomplete.","Verify the ProductId still exists (not Deleted) before submitting the search.","Guard the search model: if ProductId > 0 but the product is missing, show a friendly message and return an empty grid instead of throwing.","Refresh any cached/deep-linked search URLs."],"exampleFix":"// before\nif (isSearchProduct)\n{\n    product = await _productService.GetProductByIdAsync(searchModel.ProductId)\n        ?? throw new Exception(\"Product is not found\");\n}\n// after (graceful handling)\nif (isSearchProduct)\n{\n    product = await _productService.GetProductByIdAsync(searchModel.ProductId);\n    if (product is null)\n    {\n        _notificationService.WarningNotification(\"The selected product no longer exists.\");\n        product = null;\n    }\n}","handlingStrategy":"validation","validationCode":"// Validate the search product id before building the cart grid.\nif (searchModel.ProductId > 0)\n{\n    var product = await _productService.GetProductByIdAsync(searchModel.ProductId);\n    if (product is null)\n    {\n        _notificationService.WarningNotification(\"Selected product no longer exists.\");\n        searchModel.ProductId = 0; // fall back to unfiltered search\n    }\n}","typeGuard":"static bool ProductExists(Product p) => p is not null;","tryCatchPattern":"try { /* PrepareShoppingCartItemListModelAsync body */ }\ncatch (Exception ex) when (ex.Message == \"Product is not found\")\n{\n    _notificationService.WarningNotification(ex.Message);\n    /* return empty grid */\n}","preventionTips":["Avoid deep-linking cart searches with a fixed product id.","Validate productId > 0 and resolvable before submitting the search.","Clear stale product filters when products are deleted."],"tags":["nopcommerce","admin","shopping-cart","product","not-found","search-filter"],"backgroundTag":null,"analyzedSha":"64bdf2ff08c8b39e65717bcf974fb43dc2ef68f2","analyzedAt":"2026-08-13T21:19:38.062Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}