- Issue created by @iseeaflyingcrane
- πΊπΈUnited States DamienMcKenna NH, USA
I think the root problem is that Commerce product variants don't have their own "canonical" route.
If you look at the Product entity file it has a "canonical" link specification in the entity's definition:
* links = { * "canonical" = "/product/{commerce_product}",
If you look at the ProductVariant entity file it doesn't have the "canonical" item in the links definition.
Metatag requires that the current page points to a specific route, especially in order to access the tokens that belong with that entity. This is how it works for nodes, users, terms, etc. Because product variants don't have their own route all of this entity logic doesn't work as expected.
I did open a feature request for Commerce to add this route ( β¨ Add a canonical URL for the ProductVariant entity Active ), we'll see what becomes of it.
The alternative approach is to use the [commerce:current_variation] tokens, as defined in commerce_product.tokens.inc, and add them on the Product entity's meta tag defaults. You might also take a look at the Token page of the Help page, it will show you the entire token tree and it might help track down what you need.
- πΊπΈUnited States iseeaflyingcrane
Thank you @DamienMcKenna for the response. I hope they will add the canonical link to the product variation entity. I am not sure how to use the current token. Can you elaborate how to to do this?
The alternative approach is to use the [commerce:current_variation] tokens, as defined in commerce_product.tokens.inc, and add them on the Product entity's meta tag defaults. You might also take a look at the Token page of the Help page, it will show you the entire token tree and it might help track down what you need.
Thanks again!
- πΊπΈUnited States iseeaflyingcrane
Never mind. I found it after upgrading commerce module. Thank you!