I'm creating a web service on AWS that can recommend specific products and more specifically, product variants (i.e sizes) to certain users. The recommendations are down to the barcode level so I would need to be able to tell Shopify which exact products+variants I want to be part of a custom collection. So far:
I managed to use the Admin API to create a custom collection with product ID's in there (this works fine and as intended).
Now my question:
I would like to use the Admin API to also send Variant ID's to my collections. As far as I can tell from the shopify documentation and forum, this is not natively possible in the API. Therefore I was looking for a potential solution. My proposed solution could look like this:
Create custom collection with metafield added to the collection. This metafield contains key:value pairs of productID:variantID pairs. This will be a dictionary for all product:variant pairs proposed by the webservice
Add product ID's to collection as usual
Parse metafield in liquid files so only the variants are shown in the collection (how, is this possible?)
Any feedback on this approach, feasibility and tips/tricks/findings?