How to get the publication id based on the name of the sales channel?

Hello everyone.

Im trying to make a product available on a sales channel. For context, I have already created the product via the APIs but they dont seem to be available on a sales channel by default. To do so, im using the publishablePublish mutation.

While using the publishablePublish mutation, it requires a publishing ID as a part of the variables in order to publish the resource to a particular sales channel. But how can we figure out what is the publishing id for a particular sales channel? Example, the defaulted “Online Sales Channel”.

I tried going through the publications type to see if I can find anything but it does not have a title/name to distinguish a sales channel. Used the following query. Catalog type does have a title property but it returns a null value always.

publications(first: 10) {
    nodes {
      id
      autoPublish
      catalog {
        id
        status
        title
      }
    }
  }

Is there a way to get the title of the publication so that I know which publication ID is associated to a sales channel?

Thanks in advance.

1 Like

Hey @sivansundar :waving_hand: - this is definitely a tricky one. There’s not a simple way to grab the Sales Channel name, but it’s usually tied to the Sales Channel app’s handle which we can grab through fragmenting the query. Here’s a quick example:

query saleschannelname {
  publications(first: 10, catalogType: APP) {
    nodes {
      id
      catalog {
        id
        ... on AppCatalog {
          apps(first: 10) {
            nodes {
              id
              handle
            }
          }
        }
      }
    }
  }
}

On my test shop I get this in the response body:


  "data": {
    "publications": {
      "nodes": [
        {
          "id": "gid://shopify/Publication/62813962262",
          "catalog": {
            "id": "gid://shopify/AppCatalog/5501550614",
            "apps": {
              "nodes": [
                {
                  "id": "gid://shopify/App/580111",
                  "handle": "online_store"
                }
              ]
            }
          }
        },
        {
          "id": "gid://shopify/Publication/62814388246",
          "catalog": {
            "id": "gid://shopify/AppCatalog/5501747222",
            "apps": {
              "nodes": [
                {
                  "id": "gid://shopify/App/129785",
                  "handle": "pos"
                }
              ]
            }
          }
        },
        {
          "id": "gid://shopify/Publication/62819893270",
          "catalog": {
            "id": "gid://shopify/AppCatalog/5503811606",
            "apps": {
              "nodes": [
                {
                  "id": "gid://shopify/App/88312",
                  "handle": "buy_button"
                }
              ]
            }
          }
        },
        {
          "id": "gid://shopify/Publication/72217952278",
          "catalog": {
            "id": "gid://shopify/AppCatalog/5653561366",
            "apps": {
              "nodes": [
                {
                  "id": "gid://shopify/App/1780363",
                  "handle": "google"
                }
              ]
            }
          }
        }

Hope this is what you were looking for/that it helps - let me know if I can clarify anything more on our end here.

1 Like

Thanks for helping out @Alan_G . This works perfectly fine. :raising_hands: