Describe your bug or feature request.

Product attribute value labels displayed in the Add to Cart form dropdown are not translated.
For example, on a French language domain, the attribute select options still display in English.

The issue is in
ProductVariationAttributeMapper::getAttributeValues().
The method calls
$variation->getAttributeValue($field_name), which internally uses
CommerceContentEntityBase::ensureTranslations() to resolve the translation.

However, ensureTranslations() determines the target language based on the parent
variation entity's own language
($this->language()->getId() when translatable, or
getCurrentLanguage(TYPE_CONTENT) when not).
This is unreliable in several scenarios:

  • When the variation entity is translatable but was loaded in the original language
  • During AJAX requests where content language negotiation may not resolve correctly
  • On sites using domain-based language negotiation

Meanwhile, in the same class, the attribute entity itself is correctly translated on line 89
using EntityRepository::getTranslationFromContext(), but the attribute values do not receive the same treatment.

If a bug, provide steps to reproduce it from a clean install.

  • Use domain translation on current site
  • Add translation to the attributes
  • Add field formatter 'Add to cart'
  • Check the transltions

Issue fork commerce-3585248

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

foxy-vikvik created an issue. See original summary.

foxy-vikvik’s picture

ivnish’s picture

Version: 8.x-2.x-dev » 3.x-dev

ivnish’s picture

Status: Active » Needs review