Je pensais juste à cela, cela semble fonctionner, il est regrettable que l'API ne supporte pas cela d'une manière officielle.
function create_uc_product_type ($name , $pcid , $description)
{
$pcid = preg_replace (array ('/\s+/' , '/\W/') , array ('_' , '') , strtolower ($pcid));
db_query ("INSERT INTO {uc_product_classes} (pcid, name, description) VALUES ('%s', '%s', '%s')" , $pcid , $name , $description);
uc_product_node_info (TRUE);
variable_set ('node_options_' . $pcid , variable_get ('node_options_product' , array ('status' , 'promote')));
if (module_exists ('comment')) {
variable_set ('comment_' . $pcid , variable_get ('comment_product' , COMMENT_NODE_READ_WRITE));
}
module_invoke_all ('product_class' , $pcid , 'insert');
if (module_exists ('imagefield')) {
uc_product_add_default_image_field ($pcid);
}
$type = node_get_types('type', $pcid);
$type->custom = 1;
node_type_save($type);
node_types_rebuild ();
menu_rebuild ();
drupal_set_message (t ('Product class ' . $pcid . ' created.'));
}