How to clone Amazon Prime Now's "Shop past purchases" feature?

How would one sort a list products by the number of times a user has purchased them? In this screenshot of Amazon Prime Now, Amazon sorts the “Shop past purchases” in descending order.

Screenshot:

You could do a search of that user’s total orders filtered by the product in each cell and use :count to display the number of times the user has ordered that product as it would be a purchase order count.

2 Likes

I was already successful in doing that before. But I could not get it to sort. The dynamic field of sort does not show the product in the cell, therefore sorting is not possible?

Rather than using the Sort command, add a sort order to the Search command that you’re likely already using to select the items for the repeating group.

Make sense?

I’m actually not using a search command, but yeah i’m trying to use the sort order, but the only choice I have is parent group’s thing and not the cell itself which is what I would need in order to do the sort.

Can you post a link to your editor? I’m happy to take a look around.

Looks to me like you’re going to need to re-write the logic for what Things you’re displaying in the repeating group. Can’t tell whether it’s a dead simple change or fairly complex without looking into your app a bit more.

i just found out that the use of dynamic field is only to have a choice of field for the user to sort by and not something i can use for sort with another compound attribute like this.

The app is currently private, and I’m not sure if I’m allowed to make it public.

Fair enough.

2 potential solutions (without knowing more):

  1. Try converting dynamic field to a Search field and use the sorting that’s available from within that.
  2. You may be able to use what you’ve got and select “parent group’s thing” and then add a descriptor to it (i.e., “Product Past Order’s Product”).

it’s not the logic that’s wrong. I would just need add another data type in order to make it work.

Often times, there’s multiple ways to write the logic to get the same set of information out of a database. If you need to add a sort order, then I’d recommend using “search for” since that includes a built in sort-order, or you can add a “Sort:” to the query but I’ve been told that it’s generally best to avoid using “Sort:” for several reasons, namely performance.

Anyhow, I’m headed to bed. Best of luck!

Yep, that’s true. But there is still no way of sorting with a compound/created/searched attribute without changing the data structure. I keep forgetting that.

You may be able to use a search within a search. Get’s to be very powerful that way and less subject to do your data model. Just another idea for you.

A search within a search is possible, but in the end you cannot use the the attributes/cells from the first search. What can you sort with a search within a search? I have tried it countless of times and there always not usable.

Well in terms of efficiency a search within a search will always be worse rather than updating two tables each time.

For 1, it wouldn’t change because you’re accessing the same data type, all the fields are the same.
For 2, Parent group’s thing is the group outside of the repeating group, it would be of no use even if I use a state because you would only be able to use one element still and not the current cell you are accessing.

Because I’m trying to sort it with an attribute that is derived (you use a formula for it and not store it in the database) rather than stored, I think it isn’t possible. However, I was able to do it by creating a new entity called ‘Past Order’ that contained the ‘Product’ and a number ‘Quantity’, and update this accordingly.

This was also the solution of other people trying to sort a user based on their follower count. You normally only need the followers attribute. But in order to sort the users based on the count, you would have to add the followers_count attribute and update it each time another user adds to the followers. Here: Sorting a Repeating Group by Users in List - #3 by NigelG

Glad to hear that you got it. I hadn’t understood you were trying to sort based on a value that’s not in your database. Makes sense that adding it to your DB was the solution.

This topic was automatically closed after 70 days. New replies are no longer allowed.