Hi,
can I set the manual sort order within a collection programmatically?
Thanks
Zin
Hi,
can I set the manual sort order within a collection programmatically?
Thanks
Zin
You can add products to a manual collection via the API and specify the sort order with the position and sort_value fields. You should be able to have an app programatically add the products to a collection as long as you have them listed in the desired order on your end.
Hereâs a link to the relevant documentation - Collect is the endpoint that adds products to collections - https://shopify.dev/api/admin/rest/reference/products/collect
Hi, can you provide me some examples?
I am trying but doesnât work
curl -d â{âcollectâ:{âproduct_idâ:5015268524165,âcollection_idâ:263249199237,âsort_valueâ:â14â}}â -X POST âhttps://my-shop.myshopify.com/admin/api/2021-10/collects.jsonâ -H âX-Shopify-Access-Token: shppa_380de19cc965XXXXXXabaâ -H âContent-Type: application/jsonâ
{âcollectâ:{âidâ:28940172394629,âcollection_idâ:263249199237,âproduct_idâ:5015268524165,âcreated_atâ:â2021-12-29T21:20:51+01:00â,âupdated_atâ:â2021-12-29T21:20:51+01:00â,âpositionâ:7,âsort_valueâ:â0000000007â}}%
Did you ever figure this out? This does not work on my end either,
There seems to be two API endpoints that are made to reorder collections.
REST Api - Updates the ordering type of products in a smart collection
and
GraphQL - collectionReorderProducts
The REST endpoint seems to be broken when it comes to reordering products - donât waste your time with it. Ask it to move 20 products to the top of the collection, and youâre lucky if it moves anything.
Iâm testing the GraphQL endpoint now - hopefully it will work.
Something has to work, because the app âPower Tools Suiteâ is able to shuffle collections randomly, and I think the above endpoints are the only ways that they could achieve this.