We need to grab the top-level collections published to a channel and then grab the products inside of those collections that are active and published to the same channel of the collection. However, when we do it this way, we cannot get the “productPublicationsV3” on line 34 of this query.
Here is an almost exact query of what we need. You will see that products inside the collections will not be affected by the status now, however which is what we really need.
{
publication(id: "gid://shopify/Publication/67267264703") {
name
id
collectionPublicationsV3(first: 1) {
edges {
node {
publication {
id
name
collections(first: 10) {
edges {
node {
id
handle
title
descriptionHtml
image {
originalSrc
}
seo {
description
title
}
metafields(first: 1) {
edges {
node {
namespace
key
value
}
}
}
products(first: 5) {
edges {
node {
id
title
handle
tags
productType
vendor
descriptionHtml
productType
featuredImage {
originalSrc
}
seo {
title
description
}
metafields(first: 1) {
edges {
node {
namespace
key
value
}
}
}
variants(first: 1) {
edges {
node {
id
title
price
sku
barcode
compareAtPrice
availableForSale
weight
weightUnit
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}