In a product display node, when you make the product reference to be translated by the entity translation module. You will get the products with the default language.

Use this patch to get the correct products with the page language.

For ex,
When you create a product display in En, you get the product reference to be translated by the entity translation. The added 10 products to En. Then you add a translate display in Nl, you added 20 products to the Nl. Then you will find that in Nl, it still display the 10 products you added to En.

This patch just to get the products display node to show the correct products when a page use not the default language.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Sutharsan’s picture

Status: Active » Reviewed & tested by the community

The patch works correctly for me. It is a straight forward fix.

joelpittet’s picture

OMG thanks, I was just about to write a similar patch. RTBC++

joelpittet’s picture

Status: Reviewed & tested by the community » Needs review
FileSize
1.49 KB

Do we need the same thing for the default product as well?

I have a feeling this is not a commerce problem but an entity_translation or entity module problem because at one point in my dev cycle this worked as expected... though maybe someone a bit more familiar could let us know?

For me it may have been a related product field getting picked up from the field settings checkbox "Render fields from the referenced products when viewing this entity. ".

Still testing but, this patch may be a bit more complete. Though I'm going to try again without the patches.

joelpittet’s picture

Well that field settings was a problem (argh again, got reverted somewhere on me). This patch still fixing my problem. Still feel there is a bigger problem here.

joelpittet’s picture

Going to look into this issue in the morning #2335885: 'langcode' option in info array is not applied

joelpittet’s picture

michfuer’s picture

I need some guidance on how to reproduce the bug. Here's what I tried after enabling the entity_translation module ver. 7.x-1.0-beta3.

Edited my "Product" product type and set Multilingual support to "Enabled via Entity translation"

Created Product A with an Afrikaans, and English version.
Created Product B with an Afrikaans, and English version.

Edited my Product Display content type and went to Publishing options->Multilingual support and selected "Enabled, with field translation". Then went to "manage fields" and edited the product reference field to enable the "Users may translate all occurrences of this field" option.

Next I created a product display and set the original language to English, and added an Afrikaans translation. For both language versions I referenced Product A and Product B.

As a user I navigate to the product display and when I select "English" for the display I see the product's field content in English, and same when I switch to Afrikaans. This is expected behavior to me.

The scenario described by the OP appears to be adding different products per language version to the same display, i.e. English gets Products A, B, C and Afrikaans gets Products D,E,F. Why wouldn't you create separate displays for these groupings?

Chris Matthews’s picture

Status: Needs review » Needs work
Issue tags: +Needs reroll

The 4 year old patch in #3 does not apply to the latest commerce 7.x-1.x-dev and needs a reroll.

Checking patch modules/cart/commerce_cart.module...
Hunk #1 succeeded at 2836 (offset 132 lines).
Checking patch modules/product_reference/commerce_product_reference.module...
error: while searching for:
      // Load a wrapper for the entity being viewed.
      if (empty($wrapper)) {
        $wrapper = entity_metadata_wrapper($entity_type, $entity);
      }

      // Find the default product based on the cardinality of the field.

error: patch failed: modules/product_reference/commerce_product_reference.module:336
error: modules/product_reference/commerce_product_reference.module: patch does not apply
daiwik.addweb’s picture

Status: Needs work » Needs review
FileSize
1.56 KB

@Chris2, Here's the patch Kindly review it & provide your valuable feedback on the same... Thanks!..