in

dashCommerce

An ASP.NET Open Source e-Commerce Application

Number of recently viewed items

Last post 11-07-2008 1:22 PM by Brian. 8 replies.
Page 1 of 1 (9 items)
Sort Posts: Previous Next
  • 10-11-2008 7:15 PM

    • Brian
    • Top 25 Contributor
    • Joined on 07-30-2008
    • Posts 28

    Number of recently viewed items

    I have edited CSK_Stats_FavouriteProducts stored procedure from TOP 100 PERCENT to TOP 3 PERCENT and TOP 3 but get the same 3 items under recently viewed regardless of which items have been viewed. How can it be modified to show the last 3 items viewed?

  • 10-21-2008 10:25 AM In reply to

    • Brian
    • Top 25 Contributor
    • Joined on 07-30-2008
    • Posts 28

    Re: Number of recently viewed items

    I am not having much luck with this. The list of recently viewed items worked fine when the number of items is set to 100 percent, but this list keeps growing. When I change the number of items it displays the same items. I have tried adding an order by statement by this didn't work.

    Can anybody help please?

    Filed under:
  • 10-21-2008 11:07 AM In reply to

    Re: Number of recently viewed items

    By seeing the storedprocedure it should return distinct 3 times only.

    But you can try adding DISTINCT in the stored procedure

    SELECT DISTINCT TOP 3

  • 10-21-2008 11:57 AM In reply to

    • Brian
    • Top 25 Contributor
    • Joined on 07-30-2008
    • Posts 28

    Re: Number of recently viewed items

    Thanks for this suggestion. This has helped as It is displaying three products and they are updating, but they are not updating every time a new product is viewed - I can't make out the criteria that is being applied.

    I need to modify the stored procedure further so that it displays the last three.

    Filed under:
  • 10-21-2008 12:17 PM In reply to

    • Brian
    • Top 25 Contributor
    • Joined on 07-30-2008
    • Posts 28

    Re: Number of recently viewed items

    I have paisted the stored procedure below. I need to update it so that the last three products viewed are shown. Currently is displays three recent products but not the last three.

    CREATE PROCEDURE [dbo].[CSK_Stats_FavoriteProducts]
     (
        @userName nvarchar(50)
     )
    AS
     
    SELECT     DISTINCT TOP 3 CSK_Stats_Tracker.userName, CSK_Store_Product.productGUID, CSK_Store_Product.productName,
                          COUNT(CSK_Stats_Tracker.trackingID) AS ViewCount, CSK_Store_Product.defaultImage, CSK_Store_Product.productID
    FROM         CSK_Stats_Tracker INNER JOIN
                          CSK_Store_Product ON CSK_Stats_Tracker.productSKU = CSK_Store_Product.sku
    WHERE     (CSK_Stats_Tracker.userName = @userName)
    GROUP BY CSK_Stats_Tracker.userName, CSK_Store_Product.productGUID, CSK_Store_Product.productName, CSK_Store_Product.defaultImage,
                          CSK_Store_Product.productID
    ORDER BY COUNT(CSK_Stats_Tracker.trackingID)

    RETURN

    Filed under:
  • 10-21-2008 7:07 PM In reply to

    Re: Number of recently viewed items

    you should change the order by clause

    ORDER BY CSK_Stats_Tracker.createdOn DESC

  • 10-22-2008 4:39 PM In reply to

    • Brian
    • Top 25 Contributor
    • Joined on 07-30-2008
    • Posts 28

    Re: Number of recently viewed items

    I have edited the stored procedure but it keeps crashing the database server when I try to run it. Any idea what I have done wrong? Sorry if this is a novice question, but should I change "CREATE" to "UPDATE" when I edit the procedure?

    CREATE PROCEDURE [dbo].[CSK_Stats_FavoriteProducts]
     (
        @userName nvarchar(50)
     )
    AS
     
    SELECT     DISTINCT TOP 3 CSK_Stats_Tracker.userName, CSK_Stats_Tracker.createdOn, CSK_Store_Product.productGUID, CSK_Store_Product.productName,
                          COUNT(CSK_Stats_Tracker.trackingID) AS ViewCount, CSK_Store_Product.defaultImage, CSK_Store_Product.productID
    FROM         CSK_Stats_Tracker INNER JOIN
                          CSK_Store_Product ON CSK_Stats_Tracker.productSKU = CSK_Store_Product.sku
    WHERE     (CSK_Stats_Tracker.userName = @userName)
    GROUP BY CSK_Stats_Tracker.userName, CSK_Store_Product.productGUID, CSK_Store_Product.productName, CSK_Store_Product.defaultImage,
                          CSK_Store_Product.productID
    ORDER BY CSK_Stats_Tracker.createdOn DESC

     RETURN

     

    Filed under:
  • 10-22-2008 6:23 PM In reply to

    Re: Number of recently viewed items

    its not UPDATE it should be ALTER

    ALTER PROCEDURE [dbo].[CSK_Stats_FavoriteProducts]

     

     

  • 11-07-2008 1:22 PM In reply to

    • Brian
    • Top 25 Contributor
    • Joined on 07-30-2008
    • Posts 28

    Re: Number of recently viewed items

    Answer

    I am now able to view the last 3 viewed products using the following code:

    SELECT

    TOP 3 CSK_Stats_Tracker.userName, CSK_Store_Product.productGUID, CSK_Store_Product.productName, CSK_Store_Product.defaultImage, CSK_Store_Product.productID FROM CSK_Stats_Tracker INNER JOIN CSK_Store_Product ON CSK_Stats_Tracker.productSKU = CSK_Store_Product.sku ORDER BY CSK_Stats_Tracker.CreatedOn DESC RETURN

    Filed under:
Page 1 of 1 (9 items)