I have a series of artists (own page), artists have their products (own page), these products may be sold and if they are sold they appear in a structure item in an order (own page).
Now, given an artist I need to get all their products that have been sold.
The way I am doing it is, basically:
- get all the products of an artist - if all their products > 0 - foreach their products - foreach sitewide orders - foreach structure item within order - if item == this product - count +1 for this product
…but as each artist have several produts, and there are many orders, and many items in each order, with so many nested loops this process takes quite a long time.
What would be a more efficient approach in this case ?