Finding related articles

246 Views Asked by At

I am using Sulu 2.2 with the article bundle and have defined multiple article types, one of them has a single_article_selection type of field which I use to feature other articles.

ex : article 'A' is featured in articles 'B', 'C' and 'D'

When rendering article 'A', is it possible to access the collection of others articles who feature it ? Be it in the twig template file or via a custom controller ?

1

There are 1 best solutions below

0
On BEST ANSWER

The best would be that you index your single_article_selection into an own field in the ArticleViewDocument by extending it.

See the extend ArticleViewDocument Documentation here: https://github.com/sulu/SuluArticleBundle/blob/2.2.2/Resources/doc/article-view-document.md

Then you can use the SearchManager to query and filter by that specific field. You need to use the esManager of the live index to query live documents.