nopSolutions/nopCommerce · error · Exception
Product is not found
Error message
Product is not found
What it means
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.
Source
Thrown at src/Presentation/Nop.Web/Areas/Admin/Factories/ShoppingCartModelFactory.cs:208
/// </returns>
public virtual async Task<ShoppingCartItemListModel> PrepareShoppingCartItemListModelAsync(ShoppingCartItemSearchModel searchModel, Customer customer)
{
ArgumentNullException.ThrowIfNull(searchModel);
ArgumentNullException.ThrowIfNull(customer);
//get shopping cart items
var items = (await _shoppingCartService
.GetShoppingCartAsync(customer, shoppingCartType: searchModel.ShoppingCartType, storeId: searchModel.StoreId, productId: searchModel.ProductId, createdFromUtc: searchModel.StartDate, createdToUtc: searchModel.EndDate, customWishlistId: 0))
.ToPagedList(searchModel);
var isSearchProduct = searchModel.ProductId > 0;
Product product = null;
if (isSearchProduct)
{
product = await _productService.GetProductByIdAsync(searchModel.ProductId)
?? throw new Exception("Product is not found");
}
var store = await _storeService.GetStoreByIdAsync(searchModel.StoreId);
var customWishlists = items.Any(item => item.ShoppingCartType == ShoppingCartType.Wishlist)
? await _customWishlistService.GetAllCustomWishlistsAsync(customer.Id)
: new List<CustomWishlist>();
//prepare list model
var model = await new ShoppingCartItemListModel().PrepareToGridAsync(searchModel, items, () =>
{
return items
.OrderByDescending(item => item.CreatedOnUtc)
.SelectAwait(async item =>
{
//fill in model values from the entity
var itemModel = item.ToModel<ShoppingCartItemModel>();
if (!isSearchProduct)View on GitHub (pinned to 64bdf2ff08)
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.
Example fix
// before
if (isSearchProduct)
{
product = await _productService.GetProductByIdAsync(searchModel.ProductId)
?? throw new Exception("Product is not found");
}
// after (graceful handling)
if (isSearchProduct)
{
product = await _productService.GetProductByIdAsync(searchModel.ProductId);
if (product is null)
{
_notificationService.WarningNotification("The selected product no longer exists.");
product = null;
}
} Defensive patterns
Strategy: validation
Validate before calling
// Validate the search product id before building the cart grid.
if (searchModel.ProductId > 0)
{
var product = await _productService.GetProductByIdAsync(searchModel.ProductId);
if (product is null)
{
_notificationService.WarningNotification("Selected product no longer exists.");
searchModel.ProductId = 0; // fall back to unfiltered search
}
} Type guard
static bool ProductExists(Product p) => p is not null;
Try / catch
try { /* PrepareShoppingCartItemListModelAsync body */ }
catch (Exception ex) when (ex.Message == "Product is not found")
{
_notificationService.WarningNotification(ex.Message);
/* return empty grid */
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- No specification attribute found with the specified id
- No activity log found with the specified id
- No address attribute found with the specified id
- No address attribute value found with the specified id
- No affiliate found with the specified id
AI-assisted analysis of nopSolutions/nopCommerce@64bdf2ff08 (2026-08-13).
Data as JSON: /api/errors/b6e09da76782320d.
Report an issue: GitHub.