Add a canonical link template for product variations

Created on 8 July 2025, 1 day ago

Problem/Motivation

Looking at the code at https://git.drupalcode.org/project/commerce/-/blob/3.x/modules/product/s... and issues like

I'm wondering if it wouldn't make sense to add a canonical link template for product variations
From the "(outer) interface" perspective at product variations as entities and their functionality, this might be a very useful unification, while the internal handling of these canonical links might be special - still it might be good to have that logic unified within the product variation entities?

Otherwise it looks like it would need workarounds in generic modules using canonical links on entities?

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

Introduced terminology

API changes

Data model changes

Release notes snippet

📌 Task
Status

Active

Version

3.0

Component

Product

Created by

🇩🇪Germany Anybody Porta Westfalica

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @Anybody
  • 🇮🇱Israel jsacksick

    The thing is, there is no canonical link for product variations, we don't have a product variation view page per saY.

  • 🇩🇪Germany Anybody Porta Westfalica

    Thanks for the quick reply @jsacksick - yes my idea was something like using the parent product's route which represents the variation or a redirect route on that, but I see the issue with that... also not really perfect.

  • 🇩🇪Germany Anybody Porta Westfalica
  • 🇩🇪Germany Anybody Porta Westfalica

    Okay finally found out that our issue with field_formatter was not caused by this. So I think the canonical link template for product variations can still make sense, but wasn't the cause of an issue.

    Feel free to close this, if you think that a canonical link for product variations is worse than the current implementation.

    Thanks a lot!

  • 🇮🇱Israel jsacksick

    What issue were you experiencing exactly? I'm failing to see what problems exactly this causes?

  • 🇩🇪Germany Anybody Porta Westfalica

    field_formatter module allows placing links to the hosting entity (#url in render arrays) on fields (e.g. product variation image) using a boolean formatter setting. It uses the canonical, so I thought this edge-case lead to misbehaviour, but a wrongly configured view (core views settings non-inherited flaw) was the reason! -.-

Production build 0.71.5 2024