Skip to Content
0
Feb 27, 2017 at 08:49 PM

Importing localized attribute with ImpEx using the language isocode from the value line

954 Views

Hi,

we would like to set the values of a localized attribute by using the isocode that is given with the CSV value line. Let me give an example of our CSV file first:

 code;language;name
 product1;en;The product
 product2;de;Das Produkt
 product3;de_DE;Das neuste Produkt

Now I have created an impex script that will set the current language to the value given in the import line, as follows:

 $productCatalogVersion = catalogVersion(catalog(id[default = 'ProductCatalog']), version[default = 'Staged'])[unique = true, default = 'ProductCatalog:Staged']
 
 INSERT_UPDATE Product[impex.legacy.mode = true]; code[unique = true];;name;$productCatalogVersion
 "#% beforeEach:
     Language language = C2LManager.getInstance().getLanguageByIsoCode(line.get(2));
     JaloSession.getCurrentSession().getSessionContext().setLanguage(language);
 "
 

The session language will get injected perfectly, but, unfortunately, in de.hybris.platform.impex.jalo.imp.DefaultImportProcessor#adjustSessionSettings, the session language will be nulled within the local execution context and the value will be stored within the defaultLanguage that was resolved during the initialization of the processor (which returns the same value for each value line).

     protected void adjustSessionSettings() {
         SessionContext ctx = JaloSession.getCurrentSession().createLocalSessionContext();
         ctx.setLanguage((Language)null);
         ctx.setAttribute("disableRestrictions", Boolean.TRUE);
         ctx.setAttribute("disableRestrictionGroupInheritance", Boolean.TRUE);
         ctx.setAttribute("use.fast.algorithms", Boolean.TRUE);
         ctx.setAttribute("import.mode", Boolean.TRUE);
         ctx.setAttribute("disable.attribute.check", Boolean.TRUE);
     }

Is there a way to circumstance this resetting? Or is there a way to execute some Beanshell command within the local session context?

Thanks for insights.

Bechte