Add a canonical URL for the ProductVariant entity

Created on 30 June 2024, 2 months ago
Updated 2 July 2024, 2 months ago

There are many scenarios when the product variant wants to be displayed on its often, often for SEO purposes. Right now this is achieved by passing the "v" argument to the product's URL, e.g. "product/123?v=456", as added in Update product URL to include the selected variation ID Fixed . However, this is a bit kludgy - it should be possible to view the variant's display and have all of the expected route conditions and page contexts as would be expected when viewing any other entity type.

Feature request
Status

Closed: won't fix

Version

3.0

Component

Product

Created by

🇺🇸United States DamienMcKenna NH, USA

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

Comments & Activities

  • Issue created by @DamienMcKenna
  • 🇮🇱Israel jsacksick

    Hm... I don't really think it makes sense for variations to have their own url...
    Let's take t-shirts for example, I've never browsed a single site that offers a dedicated page for the RED small variation of a particular t shirt.

    If you take books, you often have the ability to get the digital version, or the hard copy, having a dedicated page for the digital version or the hard copy wouldn't really make sense either to me?

    So could you elaborate on:

    There are many scenarios when the product variant wants to be displayed on its own

    ?

  • 🇺🇸United States DamienMcKenna NH, USA

    a) Product = a course at a college, Product Variant = a specific instance of that course.
    b) Whatever scenario this person is using it for: 💬 Product Variation meta tags not working Active

    I'm not saying every scenario needs it, but it should be possible.

    Is there a hook or event that allows the entity's definition to be modified? I wonder if this could be done as a separate contrib module?

  • 🇮🇱Israel jsacksick

    @DamienMcKenna: yes, this can be done via a hook_entity_type_build(), see the following code from the core action module:

    /**
     * Implements hook_entity_type_build().
     */
    function action_entity_type_build(array &$entity_types) {
      /** @var \Drupal\Core\Entity\EntityTypeInterface[] $entity_types */
      $entity_types['action']
        ->setFormClass('add', ActionAddForm::class)
        ->setFormClass('edit', ActionEditForm::class)
        ->setFormClass('delete', 'Drupal\action\Form\ActionDeleteForm')
        ->setListBuilderClass('Drupal\action\ActionListBuilder')
        ->setLinkTemplate('delete-form', '/admin/config/system/actions/configure/{action}/delete')
        ->setLinkTemplate('edit-form', '/admin/config/system/actions/configure/{action}')
        ->setLinkTemplate('collection', '/admin/config/system/actions');
    }
    
  • Status changed to Closed: won't fix 2 months ago
  • 🇮🇱Israel jsacksick

    Closing this per #2.

Production build 0.71.5 2024