The 'entity:commerce_product_variation' context is required and not present

Created on 21 August 2023, about 1 year ago
Updated 20 February 2024, 9 months ago

Problem/Motivation

When viewing a product page which has not variations, the following exception arise:

Drupal\Component\Plugin\Exception\ContextException: The 'entity:commerce_product_variation' context is required and not present. in Drupal\Core\Plugin\Context\Context->getContextValue() (line 73 of core/lib/Drupal/Core/Plugin/Context/Context.php).

In my case, I have some products that have no variations because they are not yet for sale (they are coming soon), and I don't have the information for the variations but I want the products to be shown. If I disable the "Google Tag" module, the product page is working properly, so the module should work either.

Steps to reproduce

  1. Enable Commerce
  2. Enable Google Tag
  3. Create a product without any variation
  4. Visit the product page

Proposed resolution

Check if there is any variation before adding the item to the event.

πŸ› Bug report
Status

Fixed

Version

2.0

Component

Code

Created by

πŸ‡ͺπŸ‡ΈSpain dtamajon

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

Merge Requests

Comments & Activities

Production build 0.71.5 2024