Hello,
I use the variants (combinations) quite a lot on my website and I've been wondering about the variant URL format and why it was chosen as such.
Here is an example of the current query parameters built for a variant:
?pvari2161-0-62-469=2562&pvari2161-0-61-470=2564
If we take a look at something like Shopify, they use a simple ?variantId=1234567890. I went looking into the code to implement something like this. I found that SmartStore actual currently supports this style of query parameter with something like this:
?pvari=5348
Which is parsed at ProductVariantQueryFactory.CreateFromQuery:
else if (item.Key.IsCaseInsensitiveEqual("pvari") && int.TryParse(item.Value.FirstOrDefault()?.NullEmpty() ?? "0", out var variantCombinationId) && variantCombinationId != 0) { query.VariantCombinationId = variantCombinationId; }
So my questions are:
- Why was the current query parameter format chosen over the more simple pvari=####?
- Were there some design implications for this decision?
- If I wanted to change it so that SmartStore used ?pvari=#### by default, can you advise the points in the code that I would need to consider if I were to make this change? Could I simply modify ProductVariantQueryItem.CreateKey to accept a variant combination ID and just return pvari=####?
Thank you for your time.