Popular Products are showing random order?

For general questions and discussions specific to the AbleCommerce 7.0 Asp.Net product.
Post Reply
BWalt302
Lieutenant, Jr. Grade (LT JG)
Lieutenant, Jr. Grade (LT JG)
Posts: 23
Joined: Mon Oct 17, 2011 10:21 am

Popular Products are showing random order?

Post by BWalt302 » Wed May 15, 2013 12:18 pm

Ok, so I am trying to get my products to display in order from best selling to lowest selling (best being first, and lowest selling on bottom of page)

I have used : ProductList.DataSource = ProductDataSource.GetPopularProducts(_MaxItems,_CategoryId); - Everything is working great, except each time I load the page, the products are showing in random order?!?

It is pulling from the right category and only showing what I have defined my max items to be, just doesn't appear to be working the way I need it to. Any suggestions?

The way I call the script is:[[ConLib:custom/bestsell CategoryId="120" Caption="Best Sellers" MaxItems="360"]]

BWalt302
Lieutenant, Jr. Grade (LT JG)
Lieutenant, Jr. Grade (LT JG)
Posts: 23
Joined: Mon Oct 17, 2011 10:21 am

Re: Popular Products are showing random order?

Post by BWalt302 » Wed May 15, 2013 12:26 pm

I also was trying to figure something out maybe using this method: //ProductList.DataSource = ProductDataSource.LoadForCriteria(_CatrgoryID,_MaxItems,0,"OrderCount DESC"); no luck though...

Possibly I believe I could somehow pull the order count from the database and just put it inline with my code...

("SELECT P.ProductId AS ProductId, COUNT(OI.ProductId) AS OrderCount FROM ac_OrderItems AS OI RIGHT OUTER JOIN ac_Products AS P ON OI.ProductId = P.ProductId WHERE P.ProductId IN ({0}) GROUP BY OI.ProductId, P.ProductId ORDER BY OrderCount DESC",productIds)

User avatar
ForumsAdmin
AbleCommerce Moderator
AbleCommerce Moderator
Posts: 399
Joined: Wed Mar 13, 2013 7:19 am

Re: Popular Products are showing random order?

Post by ForumsAdmin » Thu May 16, 2013 4:59 am

Popular products control does not display products randomly. The ones that are purchased most are shown first. The order by clause uses something like this

Code: Select all

 ORDER BY SUM(ac_OrderItems.Quantity) DESC 

BWalt302
Lieutenant, Jr. Grade (LT JG)
Lieutenant, Jr. Grade (LT JG)
Posts: 23
Joined: Mon Oct 17, 2011 10:21 am

Re: Popular Products are showing random order?

Post by BWalt302 » Thu May 16, 2013 5:37 am

I dont know whats going on then, because my code //ProductList.DataSource = ProductDataSource.GetPopularProducts(_MaxItems,_CategoryId);
is displaying products, but it is not picking up the correct category, and it is showing them in different order every time.

How would I implement the loadforcriteria to replace: ProductList.DataSource = ProductDataSource.NarrowSearch("",_CategoryId,0,0,0,_MaxItems,0,"ProductId");
to only show best sellers form that category in order

User avatar
jmestep
AbleCommerce Angel
Posts: 8164
Joined: Sun Feb 29, 2004 8:04 pm
Location: Dayton, OH
Contact:

Re: Popular Products are showing random order?

Post by jmestep » Thu May 16, 2013 5:54 am

In Gold, you can't pass scriplet parameters anymore like this that you could do in Able 7

Code: Select all

[[ConLib:custom/bestsell CategoryId="120" Caption="Best Sellers" MaxItems="360"]]
You have to do it in the master page, like Layouts/ThreeColumn.Master

Code: Select all

<uc:PopularProductsDialog ID="PopularProductsDialogRight" MaxItems="360" runat="server" />
You can't pass a category id unless you have customized it.
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

BWalt302
Lieutenant, Jr. Grade (LT JG)
Lieutenant, Jr. Grade (LT JG)
Posts: 23
Joined: Mon Oct 17, 2011 10:21 am

Re: Popular Products are showing random order?

Post by BWalt302 » Thu May 16, 2013 6:55 am

I am actually using able commerce 7.

The issue is that I have 3 different categories on the home page that I am pulling product from. So I have the code 3 times with 3 different cats: such as

[[ConLib:custom/bestsell CategoryId="2" Caption="Best Sellers" MaxItems="360"]]

[[ConLib:custom/bestsell CategoryId="16" Caption="Best Sellers" MaxItems="360"]]

[[ConLib:custom/bestsell CategoryId="3" Caption="Best Sellers" MaxItems="360"]]

PopularProducts is pulling from both the parent and all subs before determining (randomly) which ones to display, so I think I need to use a SQL statement, and pull each category and sort via OrderCount method... how would I go about this.

BWalt302
Lieutenant, Jr. Grade (LT JG)
Lieutenant, Jr. Grade (LT JG)
Posts: 23
Joined: Mon Oct 17, 2011 10:21 am

Re: Popular Products are showing random order?

Post by BWalt302 » Thu May 16, 2013 6:59 am

Is there a way I could implement an SQL query (SELECT P.ProductId AS ProductId, COUNT(OI.ProductId) AS OrderCount FROM ac_OrderItems AS OI RIGHT OUTER JOIN ac_Products AS P ON OI.ProductId = P.ProductId WHERE P.ProductId IN ({0}) GROUP BY OI.ProductId, P.ProductId ORDER BY OrderCount DESC",productIds)

such as the one above and pull it based on results?

BWalt302
Lieutenant, Jr. Grade (LT JG)
Lieutenant, Jr. Grade (LT JG)
Posts: 23
Joined: Mon Oct 17, 2011 10:21 am

Re: Popular Products are showing random order?

Post by BWalt302 » Tue May 21, 2013 9:45 am

Anyone? Still needing help with this.

User avatar
jmestep
AbleCommerce Angel
Posts: 8164
Joined: Sun Feb 29, 2004 8:04 pm
Location: Dayton, OH
Contact:

Re: Popular Products are showing random order?

Post by jmestep » Wed May 22, 2013 5:20 am

You could try this method and see if it works before you do custom sql
GetPopularProductsByCategory(int categoryId, int limit)

If you need to do custom sql, this article will point you in the right direction.
http://wiki.ablecommerce.com/index.php/Custom_Queries
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

BWalt302
Lieutenant, Jr. Grade (LT JG)
Lieutenant, Jr. Grade (LT JG)
Posts: 23
Joined: Mon Oct 17, 2011 10:21 am

Re: Popular Products are showing random order?

Post by BWalt302 » Thu May 23, 2013 2:42 pm

I tried that, and unfortunately it is still displaying them in a different order each page load.

Post Reply