Rotating Top Sellers
Rotating Top Sellers
Is there a way to have the "Top Sellers" pull from a larger list of top selling items and show them randomly? Because of the nature of our business, the top three items are not going to change very often, if at all, so we would like to expand the list that the Top Sellers display pulls from to bring a bit of variety. We would still like to show only about three items, but pull from maybe the top dozen or so.
Rick Morris
Brewhaus (America) Inc.
Hot Sauce Depot
Brewhaus (America) Inc.
Hot Sauce Depot
- jmestep
- AbleCommerce Angel
- Posts: 8164
- Joined: Sun Feb 29, 2004 8:04 pm
- Location: Dayton, OH
- Contact:
Re: Rotating Top Sellers
I think you would use the MaxItems parameter - set it to 12 instead of 3. But leave your columns set at 3.
Judy Estep
Web Developer
jestep@web2market.com
http://www.web2market.com
708-653-3100 x209
New search report plugin for business intelligence:
http://www.web2market.com/Search-Report ... -P154.aspx
Web Developer
jestep@web2market.com
http://www.web2market.com
708-653-3100 x209
New search report plugin for business intelligence:
http://www.web2market.com/Search-Report ... -P154.aspx
Re: Rotating Top Sellers
Here is a workaround. The trick is to first load 100 top products and then pick specified number of products(MaxItems) randomly through those 100 top products.
Edit your ConLib/PopularProductsDialog.ascx.cs file and locate following code line
and replace code line with following code block
Save the file and try again, it will pick random products.
Edit your ConLib/PopularProductsDialog.ascx.cs file and locate following code line
Code: Select all
List<Product> products = ProductDataSource.GetPopularProducts(this.MaxItems, prefferedCategoryId);
Code: Select all
//List<Product> products = ProductDataSource.GetPopularProducts(this.MaxItems, prefferedCategoryId);
List<Product> products = ProductDataSource.GetPopularProducts(100, prefferedCategoryId);
List<Product> randomProducts = new List<Product>();
Random random = new Random();
int count = 0;
if (products.Count > 0)
{
if (MaxItems > products.Count)
MaxItems = products.Count;
while (count < MaxItems)
{
int index = random.Next(0, products.Count);
Product product = products[index];
if (!randomProducts.Contains(product))
{
randomProducts.Add(product);
count++;
}
}
}
products = randomProducts;
Re: Rotating Top Sellers
Judy- I had tried what you suggest before posting, and it expanded the list of Top Sellers to that quantity. That is where I became lost and decided to ask for help.
Mazhar- your code change worked perfectly- thank you. The great thing is that a person can control how much of a rolling list of items there will be by changing the number of products to pull from.

Mazhar- your code change worked perfectly- thank you. The great thing is that a person can control how much of a rolling list of items there will be by changing the number of products to pull from.
Rick Morris
Brewhaus (America) Inc.
Hot Sauce Depot
Brewhaus (America) Inc.
Hot Sauce Depot
Re: Rotating Top Sellers
I just updated the code. There was bug in previous code so please use the updated code from above post.Brewhaus wrote:Judy- I had tried what you suggest before posting, and it expanded the list of Top Sellers to that quantity. That is where I became lost and decided to ask for help.![]()
Mazhar- your code change worked perfectly- thank you. The great thing is that a person can control how much of a rolling list of items there will be by changing the number of products to pull from.
Re: Rotating Top Sellers
Thank you again, Mazhar. I have pulled the new code above.
Rick Morris
Brewhaus (America) Inc.
Hot Sauce Depot
Brewhaus (America) Inc.
Hot Sauce Depot
- rhuffman
- Lieutenant, Jr. Grade (LT JG)
- Posts: 24
- Joined: Thu May 19, 2005 6:36 pm
- Location: Dublin, OH
- Contact:
Re: Rotating Top Sellers
Mazahr:
Uploaded the above code and it works pretty well, except it is showing hidden items.
Anyway you can correct.
Thanks you Mazhar
Uploaded the above code and it works pretty well, except it is showing hidden items.
Anyway you can correct.
Thanks you Mazhar
Re: Rotating Top Sellers
In above code try replacingrhuffman wrote:Mazahr:
Uploaded the above code and it works pretty well, except it is showing hidden items.
Anyway you can correct.
Thanks you Mazhar
Code: Select all
List<Product> products = ProductDataSource.GetPopularProducts(100, prefferedCategoryId);
Code: Select all
List<Product> products = ProductDataSource.GetPopularProducts(100, prefferedCategoryId);
List<Product> tempProducts = new List<Product>();
foreach (Product product in products)
{
if (product.Visibility == CatalogVisibility.Public)
tempProducts.Add(product);
}
products.Clear();
products.AddRange(tempProducts);