Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

When fetching a collection's products the sort parameter returns different result length

When fetching a collection's products the sort parameter returns different result length

haviva-wedev
Shopify Partner
1 0 0

Hello,

 

I am trying to fetch a collection's products using the storefront api (https://shopify.dev/docs/api/storefront/2023-04/queries/collection).

When I try to use the sortkey parameter I get different amount of results. for example the following requests return 13 results as expected:

URL: https://jdsport-il.myshopify.com/api/2023-07/graphql.json

BODY: {"query":"\n query {\n collection(id:\"gid://shopify/Collection/400253747446\") {\n products(\n sortKey:TITLE,\n filters:[{productVendor:\"Adidas\"},{productMetafield: {key: \"product_type\", value: \"ג'קטים\", namespace: \"custom\"}}],\n first: 250,\n reverse: false\n ) {\n edges {\n cursor\n node {\n id\n \n title\n handle\n vendor\n availableForSale\n priceRange {\n maxVariantPrice {\n amount\n currencyCode\n }\n minVariantPrice {\n amount\n currencyCode\n }\n }\n compareAtPriceRange {\n maxVariantPrice {\n amount\n currencyCode\n }\n minVariantPrice {\n amount\n currencyCode\n }\n }\n featuredImage {\n url\n }\n options {\n values\n }\n productType\n tags\n variantBySelectedOptions(selectedOptions: {name: \"\", value: \"\"}) {\n availableForSale\n compareAtPrice {\n amount\n currencyCode\n }\n compareAtPriceV2 {\n amount\n currencyCode\n }\n currentlyNotInStock\n id\n }\n }\n }\n filters {\n values {\n count\n id\n input\n label\n }\n id\n label\n type\n }\n pageInfo {\n endCursor\n hasNextPage\n hasPreviousPage\n startCursor\n }\n }\n }\n }\n "}
 
and when I change the sortkey to ID it returns 12, when I change it to PRICE it returns 2 (but if i pass reverse:true it shows the other 11).
 
Anyone has any idea why is that happening?
Replies 0 (0)