How to get the "collection_listing_id" from CollectionListing?

New Member
4 0 0

Where I can find the  "collection_listing_id" to use for this methods?

https://help.shopify.com/en/api/reference/sales-channels/collectionlisting#product_ids-2019-07

 

Like:

GET /admin/api/#{api_version}/collection_listings/#{collection_listing_id}/product_ids.json

 

0 Likes
Shopify Staff
Shopify Staff
1012 67 133

Hello @fedeb , 

 

If your app is a sales channel app, it can get potential collection listing IDs by first sending a GET request to /collection_listings.json. 

 

From that point, it can take a collection_id from the response to make the API call you had linked to and retrieve the product_ids that are published to that collection.

0 Likes
New Member
4 0 0

@Josh wrote:

Hello @fedeb , 

 

If your app is a sales channel app, it can get potential collection listing IDs by first sending a GET request to /collection_listings.json. 

 

From that point, it can take a collection_id from the response to make the API call you had linked to and retrieve the product_ids that are published to that collection.


I don't understand.

If I do this "/collection_listings.json" I got this:

 

"collection_listings": [{"collection_id": 95046172726, ... },{} ..
Only a list of collections that are published in the default channel I guess.
 
My goal is to publish to a specific date the collection / products in the channel "Online Store" the field "Publish product on".
The collection and products that I create are with null "Online Store" , later I want to modify that and enable the "Online Store" and customize what date will be enable.
 
How that can be done with the API Rest? (I try with graphQL but the publishedPublish method is bugged we can't have permission).
0 Likes
Shopify Staff
Shopify Staff
1012 67 133

Hey again @fedeb , 

 

How had you been trying to set a future publish date with GraphQL? The following mutation works for me for setting a future publish date for products, but it doesn't look like REST supports future publication dates according to our documentation : 

 

 

mutation {
  publishablePublish(id: "gid://shopify/Product/1931630510136", input: {publicationId: "gid://shopify/Publication/52220", publishDate: "2019-09-16T10:25:56-04:00"}) {
    publishable {
      publicationCount
      resourcePublications(first: 5) {
        edges {
          node {
            isPublished
            publication {
              id
              name
            }
          }
        }
      }
    }
  }
}

 

 

Where id is a product ID, and then the publicationID is the ID of my shop's 'Online Store' publication, which I got with this query : 

 

 

{
  publications(first: 10) {
    edges {
      node {
        id
        name
      }
    }
  }
}

 

Hopefully that gets you going in the right direction since my app doesn't have any special scopes that I'm aware of and is able to do this. If it doesn't do the trick for some reason though let me know! 

 

0 Likes
New Member
4 0 0

Yes for Products that work, I can set future date, but for the Collection I couldn't find to make the same like products.

 

0 Likes
Shopify Staff
Shopify Staff
1012 67 133

Hey again @fedeb , 

 

For a collection you should be able to use the same mutation as a product - you'd just swap in a collection ID instead like this : 

 

mutation {
  publishablePublish(id: "gid://shopify/Collection/70598524984", input: {publicationId: "gid://shopify/Publication/52220", publishDate: "2019-09-17T14:22:56-04:00"}) {
    publishable {
      publicationCount
      resourcePublications(first: 5) {
        edges {
          node {
            isPublished
            publication {
              id
              name
            }
          }
        }
      }
    }
  }
}

 

Edit : Correction - while it looks like this sets a future publishing date/time, once that time comes the collection doesn't end up being published to the selected channel. Looking into this!

0 Likes
New Member
4 0 0

FYI: We can't use "publishablePublish" , we don't have access "PublishablePublish access denied"

 

 
0 Likes
Shopify Staff
Shopify Staff
1012 67 133

Hey again @fedeb , 

 

Just realized that access to the mutation appears to be gated behind access to product listings, which is only open to apps using our Sales Channel SDK. To my knowledge, this then leaves sales channel apps as the only ones able to control publications via GraphQL. I've logged this with our product/collections team in hopes to get this addressed, but in the meantime it looks like REST may be the only way to do this, and it also doesn't appear to allow setting future publication dates. 

0 Likes