cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Impex Export: Colon in multivalue attribute is escaped by double backslash - How to remove this behavior?

geffchang
Active Contributor
0 Likes
811

Hybris: 6.3.0.0-SNAPSHOT (the behavior is the same with 6.3.0.21)

When exporting impex, we noticed a difference when exporting a non-multivalue Type attribute versus exporting a multivalue Type attribute.

When exporting data without colon, a non-multivalue attribute can be exported as Experts, while a multivalue attribute can be exported as Experts|Hybris.

When exporting data with colons (e.g. URL), the colon is escaped with a double backslash (for multivalue only). A non-multivalue attribute can be exported as https://experts.hybris.com, while a multivale attribute can be exported as https\\://experts.hybris.com if there is only 1 value or as https\\://experts.hybris.com|https\\://help.hybris.com if there are 2 values.

How can I stop the export from escaping the colon? Is there a method I can override to change this behavior? I would like to change the result to https://experts.hybris.com|https://help.hybris.com or to "https://experts.hybris.com"|"https://help.hybris.com".

Business Case: We want to copy the URL from the exported impex, but the URL contains double backslashes. The exported impex is not meant to be reimported.

Accepted Solutions (1)

Accepted Solutions (1)

geffchang
Active Contributor
0 Likes

For this specific case, I created a new translator, extending AbstractValueTranslator. Then, I implemented the exportValue method, joining the string data (which are URLs), without escaping them.

 public String exportValue(final Object value) throws JaloInvalidParameterException
 {
     String joinedString = "";
     if (value instanceof Collection)
     {
         final Collection valueCollection = (Collection) value;
         if (!valueCollection.isEmpty())
         {
             final ArrayList<CustomType> list = (ArrayList<CustomType>) valueCollection;
             final StringJoiner joiner = new StringJoiner("|");
             for (final CustomType customType : list)
             {
                 // data is a URL
                 joiner.add(customType.getData());
             }
             joinedString = joiner.toString();
         }
     }

     return joinedString;
 }

Reference:

Answers (0)