I am adding products to my store using the REST API. The products are functional in every way, except that they aren’t getting added to my auto collections. I have a collection defined with three conditions: Product Type = Fabric, Compare At < $.01, and Inventory > 0. Even though my new products meet all three conditions, they aren’t getting added to the collection. I have also cleared, saved and reset the attributes on the product, but they still don’t get added. Is it possible that I am missing a key attribute when creating the product through the API?
Hi - what is the API call you’re making? You could also try using the GraphQL API, (testing with the GraphiQL app) using the productCreate mutation to confirm if products are added to collections with this method. The mutation would look something like:
mutation CreateProduct {
productCreate(input: {
title: "Sample Product",
productType: "Apparel",
vendor: "SampleVendor",
tags: ["tag1", "tag2", "tag3"],
variants: [{
price: "19.99",
sku: "SKU123",
inventoryQuantity: 100
}],
metafields: [{
namespace: "custom",
key: "material",
value: "Cotton",
type: "single_line_text_field"
}]
}) {
product {
id
title
productType
tags
variants(first: 5) {
edges {
node {
id
price
sku
}
}
}
}
userErrors {
field
message
}
}
}
Try this out and see if it works for you.