We have an app that allows our users to “better group” customers based on what they purchase. More specifically things like “Red version of some shirt”. One thing the customers requested was the ability to keep tracking the same “item” when product and options are renamed. So, at most fine grained level, what we need to track are orders with a specific Option Value (mind you, not a variant because customers want Red shirts, not XL-Red shirts).
After implementing this logic, I was thrown off when I realized the ProductOptionValue Id
completely changes when you edit the option value name. This was completely unexpected as an Id is supposed to be that one stronghold that people can rely on to uniquely identify things as the extrinsic properties change freely.
It seems very much inefficient to capture the product updates and then update the potentially tens of thousands of entries in our database for each option value as well as the customer segments and other side entities created through our system linked to this option.
Is there any way for me to track orders with a specific option value (i.e. Red) even when the product/value/variant names might change?
Would also welcome some insight on why this particular Id changes along with the name. Genuinely curious why this decision was made
02:23:29 │ remix │ [
02:23:29 │ remix │ {
02:23:29 │ remix │ name: 'Date',
02:23:29 │ remix │ optionValue: {
02:23:29 │ remix │ id: 'gid://shopify/ProductOptionValue/5711658451218',
02:23:29 │ remix │ name: 'HOB2'
02:23:29 │ remix │ },
02:23:29 │ remix │ value: 'HOB2'
02:23:29 │ remix │ }
02:23:29 │ remix │ ]
After changing HOB2 → HOB3
02:27:39 │ remix │ [
02:27:39 │ remix │ {
02:27:39 │ remix │ name: 'Date',
02:27:39 │ remix │ optionValue: {
02:27:39 │ remix │ id: 'gid://shopify/ProductOptionValue/5711975612690',
02:27:39 │ remix │ name: 'HOB3'
02:27:39 │ remix │ },
02:27:39 │ remix │ value: 'HOB3'
02:27:39 │ remix │ }
02:27:39 │ remix │ ]
The query that the data is extracted from (printing out selectedOptions
`#graphql
query ($id: ID!){
productVariant(id: $id) {
id
title
displayName
selectedOptions{
name
optionValue {
id
name
}
value
}
title
}
}
`