on 01-04-2016 3:12 PM
Hi,
I am working on hybris 5.7.0.3 OCC V2 Services. I am using "products/search?fields=FULL" service to get list of products. In response I am getting two images tags separately for thumbnail & product format of a single product.
<product>
<images>
<format>thumbnail</format>
<imageType>PRIMARY</imageType>
</images>
<images>
<format>product</format>
<imageType>PRIMARY</imageType>
</images>
</product>
Now I want single Images tags under which two image tags will be displayed for thumbnail & product format (As mentioned below).
<product>
<images>
<image>
<format>thumbnail</format>
<imageType>PRIMARY</imageType>
</image>
<image>
<format>product</format>
<imageType>PRIMARY</imageType>
</image>
</images>
</product>
How to achieve this?
This is working fine for "/products/productCode?fields=FULL"
Thanks & Regards,
There is a bug in MoxyJaxbContextFactoryImpl class which prevents wrapping of collections for more than one level type hierarchy. It doesn't matter if you set wrapDepth to 2 or 100 it will work as set to 1. To fix this you need to change implementation of MoxyJaxbContextFactoryImpl.getInnerFields method. Possible solution would look like:
protected static Set getInnerFields(final Class clazz, final int depth) { final Set result = new HashSet(); if (depth <= 0) { return result; }
final Set<Class> visitedClesses = new HashSet<Class>();
final Queue<Tuple2<Class, Integer>> workQueue = new LinkedList<MoxyJaxbContextFactoryImpl.Tuple2<Class, Integer>>();
workQueue.add(new Tuple2<Class, Integer>(clazz, Integer.valueOf(0)));
while (!workQueue.isEmpty())
{
final Tuple2<Class, Integer> item = workQueue.poll();
final Class itemClass = item.getFirst();
//work on one class only once
if (visitedClesses.contains(itemClass))
{
continue;
}
final int itemDepth = item.getSecond().intValue();
final Field[] fields = itemClass.getDeclaredFields();
for (final Field field : fields)
{
final Class fieldClass = field.getType();
if (baseExcludeClasses.contains(fieldClass))
{
continue;
}
Class nextType = null;
if (Collection.class.isAssignableFrom(fieldClass))
{
final ParameterizedType pt = (ParameterizedType) field.getGenericType();
final Type[] typesInside = pt.getActualTypeArguments();
if (typesInside.length == 1 && typesInside[0] instanceof Class)
{
nextType = (Class) typesInside[0];
result.add(nextType);
}
}
else
{
nextType = fieldClass;
}
if (itemDepth < depth && nextType != null)
{
workQueue.add(new Tuple2<Class, Integer>(nextType, Integer.valueOf(itemDepth + 1)));
}
}
visitedClesses.add(itemClass);
}
return result;
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
5 | |
1 | |
1 | |
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.