Tushar Tushar - 3 months ago 13
C# Question

How to get product view count in NopCommerce?

I am using NopCommerce. I want to find top 10 most viewed products of particular category.

For that I have created new table named

ProductViewDetails
. I want to join "Product" table with this table to store product view count.

So, how can I get the number ff views for particular product?

Answer

You would need to write logic for increasing product view count at following action

public ActionResult Product(int productId)
        {
      _productViewService.IncreaseViewCount(productId);
}

In service you need to write actual logic to increase view count

 public virtual void IncreaseViewCount(int pId)
{
  //here get entry for product view details if exists or create new one
  //then increase count by 1
}