on 2020 Jul 06 11:59 PM
Hi Experts,
I have checked the forum and could not find any questions related to this. Hence posting it.
I have the below impex export.
"#% impex.setTargetFile( ""language.csv"", true, 1, -1 );"
INSERT_UPDATE Language;active;fallbackLanguages(isocode);isocode[unique=true]
"#% impex.exportItems( ""Language"" , true );"
Please note the fallbackLanguages attribute in the above impex. This is an OOTB attribute and is of type LanguageList. This exports successfully. The values after the export would be something like en,fr.
But, when I reference a collection type from an attribute, like in the impex export below,
"#% impex.setTargetFile( ""custlanguage.csv"", true, 1, -1 );"
INSERT_UPDATE Customer;uid[unique=true];sessionLanguage(fallbackLanguages(isocode))
"#% impex.exportItems( ""Customer"" , true );"
it is throwing an exception as below.
de.hybris.platform.impex.jalo.ImpExException: line 3 at main script: cannot reference type Language via attribute Language.fallbackLanguages since attribute type LanguageList is not supported[HY-0]
at de.hybris.platform.impex.jalo.exp.Exporter.export(Exporter.java:186)
It is either this is not supported or I do not know the way to do it. Any help would be highly appreciated.
Request clarification before answering.
Check out Translators: https://help.sap.com/viewer/d0224eca81e249cb821f2cdf45a82ace/1905/en-US/4ce7b82cbc574456ac197393f88e...
Create a custom translator which extends AbstractValueTranslator and override the exportValue method. Use this translator with the language(list) / collection attribute.
Let me know if the answer helped. If it did, please don't forget to upvote and accept the answer.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I am not trying to get any of the immediate attribute values of sessionLanguage, i.e. isocode, active, name, etc. If you take another look at my question above, I am trying to export the value of fallbackLanguages through sessionLanguage attribute. Now, if you ask, why am I trying to get the value of this, it is for a specific use case for my custom item model, however, the example I provided above is using all OOTB item models. The expected outcome for my second impex above should be as below.
dummy1@mailinator.com;en,fr
dummy2@mailinator.com;en,es
I am not sure if this is supported or not, or there is another way to get the value.
@geff.h.n.chang, Thank you for all your comments. Yes, I agree and know about the translators as well. I am looking to see if there is any OOTB provided before writing one. Also, the requirement I have is one-off. I am thinking to write one as a last resort making sure it is not possible and only after evaluating the time and effort. Probably I should have clarified even more before.
There is an OOTB translator as CollectionValueTranslator that by default converts value back and forth using both importValue and exportValue methods to provide an appropriate translation if the value is a collection type. As I provided in my first example, this translator does the job for me automatically, and by default, producing the result for fallbackLanguages(isocode) like en,fr if called directly.
Consider this example below. Here, I am getting the shipping country of the user by referencing CustomerModel.defaultShippingAddress.country.isocode.
"#% impex.setTargetFile( ""custlanguage.csv"", true, 1, -1 );"
INSERT_UPDATE Customer;uid[unique=true];defaultShipmentAddress(country(isocode))
"#% impex.exportItems( ""Customer"" , true );"
This gives me a response as below and is taken care of OOTB as well.
dummy1@mailinator.com;IN
dummy2@mailinator.com;IN
On the other hand, if I tried to reference a collection type as in CustomerModel.sessionLanguage.fallbackLanguages.isocode to get the values like en,fr, it is not working. Kindly let me know if there is anything provided OOTB.
| User | Count |
|---|---|
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.