Page 1 of 1

Display popular products from category, passing context

Posted: Tue May 12, 2009 8:02 am
by ZLA
My home page will display a grid of categories that contain popular products. For example, if the toy train product in the Toys for Boys category is a best seller, the home page will display that as one of the categories in the grid. When the user clicks on that home page category, it should display all popular products from the Toys for Boys category.

The wrinkle is that the user might have gotten to the Toys for Boys category from the main category list which includes all of it's products, not just the best sellers. Thus I have two different paths to the Toys for Boys products:

1. Normal - showing all products:
Home (main category list) > Toys For for Boys > All products in category

2. Best Sellers - showing popular products:
Home (Best Sellers) > Toys For for Boys (Best Sellers) > Best selling products in category

In both cases, I would be using the Category Details page to show Toys for Boys products. The only difference is which link (Normal vs Best Sellers) I started from on the home page.

What is the correct way to track my starting point and remember it for when I display the Category Details page? Thanks in advance.

Re: Display popular products from category, passing context

Posted: Tue May 12, 2009 8:06 am
by mazhar
You could place this information in session that what path is followed by current user.

Re: Display popular products from category, passing context

Posted: Tue May 12, 2009 8:40 am
by ZLA
I can do that but I'm not sure how to to track it correctly from the links. It looks like the category links are simple hrefs. So there wouldn't be any difference between clicking the category from the main list or from the Best Sellers section. I can probably modify the category URL to include an additional querystring parameter and process it from the category details page.

Is that the correct approach?

Also, to preserve navigation, I'd also have to make the bread crumbs be able to tell the difference between
Home (main category list) > Toys For Boys > All products in category
and
Home (Best Sellers) > Toys For Boys (Best Sellers) > Best selling products in category

The user could have gotten to the same product via either path. But the Bread Crumb Toys For Boys links represent different listings above. Can I also add the extra parameter to the Bread Crumb links as well?

Thanks again for your assistance. I really appreciate it. AC7 is so huge that it's hard to grok it. :)

Re: Display popular products from category, passing context

Posted: Tue May 12, 2009 9:02 am
by mazhar
Hmm, yes you are right. When building URL to category pages those are all links to respective category page. Regarding your trick to add an extra parameter in URL also sounds OK. I think when showing popular products on home page you can build category links with an extra parameter. Now on your display page where you can either list all products from that category or popular products you can decide upon that parameter. If parameter do exist in query string then you can load popular products other wise all products belonging to that category. It could be some if else block . I have seen that ProductDataSource.GetPopularProducts supports category option as well and each category URL contains cateogory id encoded within it. All you need is to first check your custom parameter and then either use ProductDataSource.GetPopularProducts to load popular products or load all products from that category. I am not clear about bread crumbs but if you want to keep information that these are normal products or popular products being shown in current page then I think you will be in need to update these links as well.

Re: Display popular products from category, passing context

Posted: Tue May 12, 2009 9:18 am
by ZLA
Thanks for the feedback. I'm checking with my client to see if the normal Popular Products Grid would be good enough since that would be so much simpler. If not, I'll have to go down the path I've outlined. -- ZLA