Download & Extend

Problem with Ubercart products sync, suggest a fix?

Project:Internationalization
Version:6.x-1.x-dev
Component:Code
Category:task
Priority:normal
Assigned:Unassigned
Status:closed (fixed)

Issue Summary

I'm looking at setting up an Ubercart [UC] store which will be in more than one language. The ussue is that admins can create their own product types in UC and these act as their own types. The i18nsync (Synchronization) modules readme.txt states:

The available list of fields to synchronize will include standard node fields and cck fields.
To have aditional fields, add the list in a variable in the settings.php file, like this:
...

<?php
// More fields for a specific content type 'nodetype' only.
$conf['i18nsync_fields_node_nodetype'] = array(
 
'field3' => t('Field 3 name'),
   ...
);
?>

Which is fine if you have a static type.

Well, actually even then this is far from automatic and doesn't give module authors the chance to integrate and take car of this for the use, and the module author is really the one who knows best about fields their types have and changes to those fields in the future. Also this approach makes handling dynamic types error prone.

I was thinking it would be much easier to just define a hook that returns this array, thus handing the job over to the module author and letting them be as tricky as they like. Something like:

<?php
i18nsync_get_fields
()
{
    return
module_invoke_all('i18n_get_fields');
}
?>

I guess cache the results per request... what do you think?

Comments

#1

Subscribe.

#2

Version:master» 6.x-1.x-dev
Status:needs review» fixed

Added an alter hook, this should be more flexible as it allows adding/changing/removing fields. And caching too, as suggested.

I think this should work for this and other casses, let me know if we need anything else.

/**
* Returns list of available fields for given content type.
*
* There are two hidden variables (without UI) that can be used to add fields
* with the form array('field' => 'Field name')
*  - i18nsync_fields_node
*  - i18nsync_fields_node_$type;
*
* Variables can also be changed using hook_i18nsync_fields_alter($fields, $type)
*
* @param $type
*   Node type.
*/
function i18nsync_node_available_fields($type) {}

#3

Thanks Jose, I'm not exactly clear how this is to work. Is there some module that is using this as an example?

#4

Status:fixed» closed (fixed)

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

#5

Category:feature request» task
Status:closed (fixed)» active

Need some examples here. This is important to Ubercart developers trying to do multi-lingual shops as many variables for a Product node are handled by other modules in other forms...?

#6

subscribing. i'll try to help but i'm not sure i totally understand what we're doing here... ;)

#7

You can use the new hook to add additional fields

like so:

function hook_i18nsync_fields_alter($fields, $type) {
  $fields['uc_products']['#title'] = 'Products';
  $fields['uc_products']['#options'] = array ('model' => 'SKU');
}

Didnt really test it yet but it seems to me this will work for normal text fields but things like attributes etc would require a litle bit more.

#8

Can someone help me to configure sync for "Features" field (for downloadable product) and for "Sell price"?

#9

please, help me

#10

Keereel, have a read here; http://www.firewing1.com/node/27

Cheers

#11

Status:active» fixed

This is now supported in Ubercart 6.x-2.x-dev.

#894760: Synchronize product data across translated nodes

#12

Status:fixed» closed (fixed)

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

nobody click here