cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Category Best Seller Product

former_member712344
Discoverer
0 Kudos
530

Hi,

I want to list the best-selling products in the product category in the product crousel on the product detail page, While doing this, I plan to keep the products as a list field on the components with a cronjob. Has anyone done anything like this before?

View Entire Topic
braveendra
Explorer
0 Kudos

Here is the solution for your requirement:

Product Top Sellers

       SELECT TOP 100 {P.PK}, SUM({OE.initialQuantiy}) as orderedQuantity 
       FROM 
        {Orderentry AS OE JOIN Product AS P ON {OE.PRODUCT}={P.PK}} 
       WHERE {OE.creationTime} > DATEADD(DAY,DATEDIFF(DAY,0, GETDATE())-1,0) 
       GROUP BY {P.PK},{OE.initialQuantiy} 
       ORDER BY orderedQuantity DESC