0

I need to set up a filter that will allow products to be ordered by:

  • Title
  • Price
  • Popularity

The first two seem simple enough but I'm not sure what the most efficient way of ordering by popularity might be?

  • Thanks everyone. I perhaps should have clarified precisely what I meant by "popularity". I meant which products are being purchased the most. Rob's answer fits this bill. – Andy Homan Feb 27 '14 at 22:42
2

You can use this SQL with the query module:

SELECT exp_channel_titles.*, COUNT(row_id) AS popularity
FROM exp_channel_titles
LEFT JOIN exp_cartthrob_order_items
ON exp_channel_titles.entry_id = exp_cartthrob_order_items.entry_id
WHERE channel_id = 1 #this is your products channel id
GROUP BY exp_channel_titles.entry_id
ORDER BY popularity DESC;

This will have the products that have been ordered the most at the top of the list. If you need more than just title, entry_id, and url_title, you'll need to use this query to collect a list of entry_id's to feed into {exp:channel:entries}. I hope this gets you pointed in the right direction.

| improve this answer | |
0

Your going to need to collect numbers on the total sales of a product and then show search results based upon this.

So as part of the checkout process i would suggest extending the PHP to update a field in the database with total sales for this item. Then when the user searched via popularity you could use PHP to find the top 10 items by comparing the total sales figures and put out the results accordingly.

I am assuming cart throb doesn't give you the ability to do this off the shelf.

| improve this answer | |
0

It depends on your definition of popularity.

If it's "how many people have looked at this?" then you can probably use track_views= and then sort by that.

Documentation at:- http://ellislab.com/expressionengine/user-guide/modules/channel/channel_entries.html#channel-entries-track-views

| improve this answer | |
0

The "People Also Purchased" option in CT might also be considered one way to chart popularity.

http://cartthrob.com/docs/tags_detail/also_purchased/

Title and price can be sorted with native EE tags.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.