Expand my Community achievements bar.

SOLVED

CIF Product Retriever - extendProductQuery for ComplexT

Avatar

Level 3

Hi all,

 

I have to customize the CIF Product List Component to get some extra fields, like description, short description to be displayed.

I haven't been able to find an example of extending the query with complex attributes.

 

So, what I can do with simple fields is:

productsRetriever.extendProductQueryWith(p -> p.metaDescription());

I can't do the same with complex fields, like

productsRetriever.extendProductQueryWith(p -> p.shortDescription());

The error message I get is [{"message":"Field \"short_description\" of type \"ComplexTextValue\" must have a sub selection."

 

Any help will be appreciated here.

 

Thanks

Ruchi

1 Accepted Solution

Avatar

Correct answer by
Level 3

So, checked for the OOTB complex field, 

productsRetriever.extendProductQueryWith(p -> p.shortDescription(item -> item.html()) 

View solution in original post

3 Replies

Avatar

Community Advisor

@ruchim71073425 

You can add complex fields in below mentioned way

 

productRetriever.extendProductQueryWith(p -> p.addCustomObjectField("shortDescription", i -> i.addField("field1").addField("field2").addField("field3"))

 

field1, field2, field3 denotes the sub attributes of the field shortDescription

Avatar

Level 3

Thank you. Given short description is not a custom field, will it work?

Avatar

Correct answer by
Level 3

So, checked for the OOTB complex field, 

productsRetriever.extendProductQueryWith(p -> p.shortDescription(item -> item.html())