Request for information on Collects REST API usage

Highlighted
Shopify Staff
Shopify Staff
2 0 3

Hi all!

 

I'm a Shopify developer that works on the Collect feature, and I'm looking to gather some information about how partners are currently using the Products Collect API.

 

I'm looking for information on how apps use the Products Collect REST API (/admin/collects) when working with automated collections. Here are a few questions I have to help start a discussion.

 

  • What are you trying to accomplish?
  • Are you using it to check membership or also for counts?
  • Is there anything more complicated which you are trying to accomplish?
  • If so, what exactly are you trying to do and what functionality are you currently missing?

You can either respond to this thread directly, or share your thoughts anonymously in this form. Thanks for all your input!
-Alex

3 Likes
Shopify Partner
20 0 6

Hi Alex,

 

We use it in our apps for finding membership of products in a collection (for both manual and automated collections) from the same REST endpoint regardless of collection type. When doing so, we assume the collects are coming back in the order that is seen in the Shopify Admin. We typically follow this up with a fetch for the products themselves and then do various filtering on the data. For example, we want to fetch the product details, but also filter those products to only those which are published to the online storefront and in stock. Presumably this could be done with a single query with GraphQL, but it requires 2+ queries with REST.

2 Likes
Shopify Staff
Shopify Staff
2 0 3

Thanks Marc!

0 Likes
Tourist
5 0 1

Hi, we are using Collects api do determine the products position within collection. This is especially needed for `manual` and `best-selling` sort order, as there is no way we can get this information otherwise. This is needed for displaying products in the same order as in shopify admin.

Unfortunately we have issues with the API since it sometimes does not in sync with shopify admin. Also it sometimes return different products at the same position within collection. Ticket id for this issue is 12203257.

1 Like
Shopify Staff
Shopify Staff
4 0 0

Hi  YuriyBrazhnyk

 

Thanks for the response.

 

Looks like you don't really need the actual values of the position, instead, you want to get the products in the same order that the collection sort order specifies.  If our API would return the products in the same order it's displayed in the storefront, without exposing the actual position, would it solve your problem?  Also, do you make any distinction between automatic and manual collections?

 

Ignacio

0 Likes
Tourist
5 0 1

Right now we are in the middle of implementing GraphQL for the new projects, and it's still a question how to achieve this using GraphQL. But even to maintain old projects it still required.

We actually store each product in the search engine and doing ordering by the position in collection for collection filter... So we need to know position.

I guess we can fetch all products filtered by collection_id, and they will be in the proper order(is it?), then find product_id and the index in array would be its position. But anyway how this would look like in GraphQL then, default order is what we can see in admin UI, or there should be a position on `edge`? 

Too many questions for now :D

0 Likes
Tourist
5 0 1

I guess two step process might work

1) Get all the products and related data trough GraphQL

2) Iterate over all collections through admin api just fetching product_id's and update product positions for each collection

 

It seems a little bit ugly, but might work. If you see a better solution please guide me...

Also please note we have stores with 60k products...

Thanks.

 

0 Likes
Shopify Staff
Shopify Staff
4 0 0

Thanks for the context.  I would be happy to chat about your special case. 

 

GraphQL API provides the option to get the products by a collection given. The list retrieved is the list of products sorted by the collection's sort order (it also lets you specify which order).  For instance:

 

{ collection(id: "<-id->") { products(first: 10) { edges { node { id } } } } } 

 

this would return the first 10 products sorted by the collection's sort order. 

 

Ignacio

 

Best,

Ignacio

0 Likes
Tourist
5 0 1

Can you confirm that the same is happening for admin api when filtered by `collection_id`? Does Collects or Products in admin api returned in collection order when filtered by `collection_id`?

As i said we have large shops with more than 60k products and speed is crucial.

 

0 Likes
Shopify Partner
4 0 2

Hello Alex,

 

Searchanise needs to have the data about all the store products with their names and their collection handles.

 

We tried to use the collects API but we have a lot of clients with 100, 300 or 500 thousand products and dozens of thousands of collections. If we requested Collects for each product, it would take way too much time.

 

That’s why we collect all the collection data, get into smart rules and find the connection between products and collections.

 

This process is rather complex and resource-intensive but we have to do it this way because it’s faster than using Collects API.

 

(We use Collects API for custom collections but fortunately in general there are a few custom collections in Shopify stores and doesn’t cause any issues)

 

We tried to use GraphQL but unfortunately requests like

{
  product(id: "gid://shopify/Product/9393762508") {
    id
    title
    collections(first:250) {
      edges {
        node {
          handle
          title
        }
      }
    }
  }
}

has too much query cost so requests should be sent too slowly and it doesn’t help us to make the process faster.

 

It would be great if the information about product collections was returned through the REST Products API the same way as the information about product images and product variants is returned.

 

Thanks in advance!

Instant search & autocomplete for Shopify
0 Likes