I created a product content type with content reference to article(one product to many articles). Then I added field "Content: ID" "Content: Title" and "(field_article: Content) Content: Title" to a new REST export View. "(field_article: Content) Content: Title" come from the relationship "Content referenced from field_article" I added in advanced.
The output is:
[
{
"nid":"3",
"title":"Product1 title",
"article_title":"Article1 title"
},
{
"nid":"3",
"title":"Product1 title",
"article_title":"Article2 title"
}
]
What I would like to achieve is something like this:
[
{
"nid":"3",
"title":"Product1 title",
"articles":
[
{
"title":"Article1 title"
},
{
"title":"Article2 title"
}
]
}
]
How to implement this?
UPDATED: I also tried aggregation, but in case of REST export View as the format is Serializer, no "group by" option in format setting but hal_json, json and xml options, while "Aggregation settings" appears on each filed. In this case, I don't know how to set "aggregation settings" group by node id. Also I cannot find document about aggregation settings of field in "Fields" section.