Add new feature for edit product in back end (multilanguage categorie fixed)

Started by simjoom, April 13, 2013, 09:40:22 AM

Previous topic - Next topic

simjoom

when virtuemart is configurated for different languages we got some bug in the back end

i developped a little additionnal code to update the categorie for the language requested

When we change the language the categorie for the language is refreshed and not only the product name and the Product Alias

in function addStandardEditViewCommands in file vmview.php
around line 197
$j = '
         jQuery(function($) {
            var oldflag = "";
            $("select#vmlang").chosen().change(function() {
               langCode = $(this).find("option:selected").val();
               flagClass = "flag-"+langCode.substr(0,2) ;
               $.getJSON( "index.php?option=com_virtuemart&view=translate&task=paste&format=json&lg="+langCode+"&id='.$id.'&editView='.$editView.'&'.$token.'=1" ,
                  function(data) {
                     var items = [];

                     if (data.fields !== "error" ) {
                        if (data.structure == "empty") alert(data.msg);
                        $.each(data.fields , function(key, val) {
                           cible = jQuery("#"+key);
                           if (oldflag !== "") cible.parent().removeClass(oldflag)
                           if (cible.parent().addClass(flagClass).children().hasClass("mce_editable") && data.structure !== "empty" ) tinyMCE.execInstanceCommand(key,"mceSetContent",false,val);
                           else if (data.structure !== "empty") cible.val(val);
                           });
                        oldflag = flagClass ;
                     } else alert(data.msg);
                  }
               );';

///addcode
         if ($editView=='product'){
            $editView='category';
               $j .= '
               $.getJSON( "index.php?option=com_virtuemart&view=translate&task=paste&format=json&lg="+langCode+"&id='.$id.'&editView='.$editView.'&'.$token.'=1" ,
                  function(data) {
                     var items = [];

                     if (data.fields !== "error" ) {
                        if (data.structure == "empty") alert(data.msg);
                        $.each(data.fields , function(key, val) {
                           if (key=="category_name") {
                           $("#categories option[value='.$id.']").text(val);
                            $("#categories").trigger("liszt:updated");
                           }
                           });
                     } else alert(data.msg);
                  } );
                  ';
         }
         $j .= '});
         })';

///addcode
         $document->addScriptDeclaration ( $j);


the code inserted is between ///addcode

K&K media production

But why? The categories are always the same for each language. You can add the categories in your preferred language and must nothing changed in the other languages. The sense of the flags and refresh is, to show which information must be changed/add for the language.

And your code is wrong...it ends with the message "No translation in product category, please fill the fields with flag".