Developer forum

Forum » Development » Loop most sold products

Loop most sold products

Caro De Weze
Reply

Hi,

I want to call the 5 most sold products and show them in a div among each other. For the products I want to show their image, name and sku. How can I do this?

Caro


Replies

 
Nicolai Pedersen Dynamicweb Employee
Nicolai Pedersen
Reply

Hi Caro

You can create a query in repositories.

The index has a field called "order count" for each product. So if you search for what you need - and sort by the ordercount field, and limit the result to 5 products, then you get the most sold. You can add expressions to the query - to i.e. show the 5 most sold in a group, or in a specific color or whatever you need.

Something like this:

  1. Create a query (or resuse an existing)
  2. Create a paragraph with the productcatalog module using that query
  3. On ther paragraph with the product catalog module, you can overrule the sorting
  4. Set the sorting to sort by the order count field
  5. Limit the search result to 5.
  6. Choose a template to render the list of found products

 

 

You must be logged in to post in the forum