Focusing on managing products, variants, and collections through the API.
Hi I have a product, titled "7 Shakra Bracelet" and with the following query, I am able to include the product in the newly created collection and can see it in the collection page of my shop admin. But in the GraphQL response, the productsCount is 0 and the products list is empty. I also tested with the exact title "7 Shakra Bracelet", in that case, I can get the correct response.
{ "data": { "collectionCreate": { "userErrors": [], "collection": { "id": "gid://shopify/Collection/*************", "title": "TEST COLLECTIONCREATE", "descriptionHtml": "", "handle": "test-collectioncreate-6", "ruleSet": { "appliedDisjunctively": true, "rules": [ { "column": "TITLE", "relation": "EQUALS", "condition": "7 shakra Bracelet" } ] }, "productsCount": 0, "products": { "edges": [] } } } }, "extensions": { "cost": { "requestedQueryCost": 54, "actualQueryCost": 14, "throttleStatus": { "maximumAvailable": 1000, "currentlyAvailable": 986, "restoreRate": 50 } } } }
mutation CollectionCreate($input: CollectionInput!) { collectionCreate(input: $input) { userErrors { field message } collection { id title descriptionHtml handle ruleSet { appliedDisjunctively rules { column relation condition } } productsCount products(first: 10) { edges { node { title, id, images(first: 1) { edges { node { id } } } title } } } } } }
{ "input": { "title": "TEST COLLECTIONCREATE", "ruleSet": { "appliedDisjunctively": true, "rules": { "column": "TITLE", "relation": "EQUALS", "condition": "7 shakra Bracelet" } } } }
No, nothing wrong with capitalization. Shopify states that condition is case-insensitive and as I mentioned in my post, the collection was successfully created with the product included, the only problem was no product returned from the response.
------------------------
You can add a condition to include a product in a collection based on the product's title, variant title, type, or vendor. You can select from the options in the second drop-down list to control how a product needs to match the condition value that you enter in the third field. The text that you enter in the third field is compared to your products according to the condition's settings, and matching products are included in the collection. The condition is not case-sensitive. https://help.shopify.com/en/manual/products/collections/automated-collections/auto-select
Hey @emilyman
Sometimes the collections can take a moment to populate. Are you still seeing 0 when you query the collection directly (outside of a create)? If so, please DM me store details.
Scott | Developer Advocate @ Shopify
@SBD_Thanks for clarifying. I can see the collection with direct query by id, but is there any way to verify the population has finished? Especially if the store has large amount of products, it should take a longer time?
Unfortunately not with automatic collections - you might need to implement a delay / poll.
Are you able to use a manual collection / provide the Product ID(s) instead of the title?
Scott | Developer Advocate @ Shopify