Discussions

[HELP] major multilingual issues

Hello,

I've run into some serious issues with commerce and a multilingual setup. Before I submit an issue on d.o, I want to ask here wether you guys think this is an error on my behalf (improper implementation/usage) or wether it really is a more severe bug that needs to be tackled.

My site runs commerce, entity translation and field translation. The product type is translatable and has a few fields designated as translatable. When I create a product, the form features a language select as its first item, set to 'language neutral' (und). Keeping it that way I can save the product without issues. However, if I change the language for the new product to any defined language (lets say German), a notice is thrown:

'Notice: Undefined property: stdClass::$field_mytranslatable_field in commerce_product_ui_product_form_translation_submit() (line 540 of /commerce/modules/product/commerce_product_ui.module).'

<?php
 
/**
 * Submit callback for commerce_product_ui_product_form().
 *
 * Checks if translation is enabled for the product and handles language changes.
 * Since this handler may change the language of submitted form values it should
 * be the first submit handler called.
 *
 * @see commerce_product_ui_form_commerce_product_ui_product_form_alter()
 */
function commerce_product_ui_product_form_translation_submit($form, &$form_state) {
 
// Get an array of available languages.
 
$available_languages = field_content_languages();
  list(, ,
$bundle) = entity_extract_ids('commerce_product', $form_state['commerce_product']);

  foreach (
field_info_instances('commerce_product', $bundle) as $instance) {
   
$field_name = $instance['field_name'];
   
$field = field_info_field($field_name);
   
$previous_language = $form[$field_name]['#language'];

   
// Handle a possible language change; new language values are inserted and
    // the previous values are deleted.
   
if ($field['translatable'] && $previous_language != $form_state['values']['language']) {
// ##### LINE 540: ######
     
$form_state['values'][$field_name][$form_state['values']['language']] = $form_state['commerce_product']->{$field_name}[$previous_language];
     
$form_state['values'][$field_name][$previous_language] = array();
    }
  }
}
?>

My debugger tells me, both sides of the assignment are 'null'. The product is saved with all translatable fields being empty. Looking at the translate tab, it'll tell me English == Source and no other translations available... this is true for every language selected when initially creating the product (neutral, english german, french- in my case)

Something goes terrible wrong there and I'd like to know if anyone else has had this happen.

Any ideas welcome.

Posted: Jan 23, 2012

Comments

rfay Randy Fay on January 23, 2012

It sounds like you've identified an issue. I recommend that you see if you can recreate this in a regular plain-vanilla install of the required modules, and file an issue explaining it completely. It sounds like you have great debugging skills to do that. And of course, return here and link to the issue.

cjoy on January 23, 2012

I've tried to reproduce this on a clean install.
The issue outlined above didnt come up (no lost form input), but the language handling for product entities seems to be well bugged.

The issue can be found here: http://drupal.org/node/1414554
It should be easy to reproduce.

Now I'll try to find out what causes the more severe problems I experience in my particular use case. Maybe it'll point back to the same bug.

edit:
I have to correct myself.
The error notice pointing to commerce_product_ui.module now does show up, as does the loss of the fiels content occur. Why the loss of data did not occur for the first few products, I cant say.

cjoy on January 30, 2012

response by plach @ d.o. issue #1420572: setOriginalLanguage ignores language set in entity

"ET knows nothing about entity-specific details: Commerce needs to override the DefaultEntityTranslationHandler::getLanguage() method to return the proper value."

... as I cant find documentation or examples on how to implement this - does anyone else feel up to the task?
I doesn't seem too big of a problem.