Sorting Products in Products.json by price

Highlighted
Tourist
24 0 2

Im using the /admin/products.json api call to get all products.

Is there any option to get products sorted by price asc/desc or by title in alphabetically sorted asc/desc order ?

Thanks !

 

0 Likes
Highlighted
Shopify Staff
Shopify Staff
154 0 35

The default sort is by title A-Z, but you can sort by Z-A by order param to "title desc". 

It is not possible to sort by price via the API.

1 Like
Highlighted
Tourist
24 0 2

Hi Maarten,

Thanks !

What are possible options for 'order' ? 

On web store, possible sorting options are ,

- manual

- best selling

- price

- featured

- date

Can they be provided for order ?

 

0 Likes
Shopify Staff
Shopify Staff
154 0 35

Via the API you can sort the product index by total, title, created_at, and updated_at, where total is the total inventory quantity for that product across all its variants. The others are self-explanatory.

1 Like
Highlighted
Tourist
24 0 2

Hi Maarten,

Any other way to provide sort by discount, price (H-L), price (L-H), manual, best selling?

can it be possible by liquid?
 

0 Likes
Highlighted
Tourist
24 0 2

also,
I have found thing when I try to sort products with created_at+desc that
indexing of products with same created_at but with different updated_at is different on store and in api responce.


What is the actual logic shopify use when we have products has same created_at value.

0 Likes
Highlighted
Shopify Partner
1 0 0

Hi - I know it's been a while since this post has any action. 

 

Any updates on how to order products using the products endpoint with a specific collection:

 

/admin/products.json?collection_id=1234

 

In the backend, it's ordered by "best selling" but via the API the data is ordered by "A-Z". I'd love this to match what was specified in the backend.

 

Cheers   

0 Likes
Highlighted
Shopify Partner
8 0 0

@squizbris wrote:

Hi - I know it's been a while since this post has any action. 

 

Any updates on how to order products using the products endpoint with a specific collection:

 

/admin/products.json?collection_id=1234

 

In the backend, it's ordered by "best selling" but via the API the data is ordered by "A-Z". I'd love this to match what was specified in the backend.

 

Cheers   


Agreed!

 

  • GET /admin/api/2020-04/products.json?collection_id=841564295
    This returns the products AND variants but does not follow the order in the Collection in the admin

🤷🏻‍♂️

0 Likes
Highlighted
New Member
3 0 0

If you are working with NodeJs, you could use the Shopify Api Node Library there is a method to sort products in a collection:

 

 

shopify.smartCollection.order(collection.id, {products: your_sorted_ids_of_products});

 

 

Note: The sort_order of your collections must be set to Manual in order to work.

 

0 Likes