I created a view of Product Variations set to display Fields. Of the available Fields, there is a Link to delete a Product variation, a Link to edit a Product variation, but there is no link available to a Product variation.

I would like to create a View listing Product Variations title field, and be able to link to each Variation.

Comments

rovo created an issue. See original summary.

bojanz’s picture

Title: Views Link to Product Variation » Missing "Link to Product variation" views handler
Version: 8.x-2.13 » 8.x-2.x-dev
Category: Feature request » Bug report

In EntityViewsData:

  protected function addEntityLinks(array &$data) {
    $entity_type_id = $this->entityType->id();
    $t_arguments = ['@entity_type_label' => $this->entityType->getLabel()];
    if ($this->entityType->hasLinkTemplate('canonical')) {
      $data['view_' . $entity_type_id] = [
        'field' => [
          'title' => $this->t('Link to @entity_type_label', $t_arguments),
          'help' => $this->t('Provide a view link to the @entity_type_label.', $t_arguments),
          'id' => 'entity_link',
        ],
      ];
    }

This can't work because variations don't have a canonical link template.
We need to provide a ProductVariationViewsData class which overrides addEntityLinks() and adds a special field with a special handler for linking to a variation.

bojanz’s picture

Status: Active » Needs review
StatusFileSize
new3.42 KB

This was easy enough.

bojanz’s picture

Status: Needs review » Fixed

Committed.

  • bojanz committed df4f1b3 on 8.x-2.x
    Issue #3066704 by bojanz, rovo: Missing "Link to Product variation"...
rovo’s picture

I got to apply the patch this morning and test it out. Works great! Thanks

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.