FROM CACHE - en_header

How to differ product with one variant from product without variants

Shopify Partner
2 0 0

When you create a product with no explicitly variants set, Shopify creates an option with name: 'Title' and values: ['Default Title'] and a corresponding variant (at least those are present in the Admin API). In case of creating a product with single option and single variant the API representations of these products resource look the same way. We need to differ these two cases. 

I've compared responses for both ones and the only difference I can see is the option title and values combination – 'Title', ['Default Title'] (and the variant title, but it's just denormalized). If you create the option `Title` with value `Default Value` it would not appear in Admin UI so I guess it suggests that the variant was explicitly set if these values are different from the default ones. I might be using string comparison, however I find it better to rely on some kind of flag. 

Am I missing something? Is it possible to differ these cases another way?

Replies 0 (0)