cancel
Showing results for 
Search instead for 
Did you mean: 

Category Best Seller Product

former_member712344
Discoverer
0 Kudos

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?

Accepted Solutions (0)

Answers (2)

Answers (2)

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
alemasetto
Participant
0 Kudos

Hi Tugce, what about a Flexible Search Query that extracts the best selling products, starting from a certain date?

You can extend the carousel component with its own Controller; the fillModel of the controller method will call a DAO with the below query. You can limit the results (eg. top 10).

Please note that Flexible Search results are cached but, in case you want to implement a job, you can persist the results.

Example:

SELECT DISTINCT {oe:product},{oe:quantity}
	FROM {OrderEntry AS oe}
		WHERE {oe:order} IN
		( 
		  {{
		  SELECT {o:PK}
		  FROM {Order AS o}
		  WHERE {o:date} >= '2023-01-01 23:59:59'
		  }}
		)
ORDER BY {oe:quantity} DESC