Search for related references


(Mario Näther) #1

Hi,
I have a lot of example products, releated with many tags (references).

'Vendor.Package:Product':
....
properties:
tags:
type: references
ui:
label: 'Tags'
reloadIfChanged: FALSE
inspector:
group: related
editorOptions:
nodeTypes: ['Vendor.Package:Tag']

'Vendor.Package:Tag':
superTypes:
'Neos.Neos:Document': TRUE
....

Problem, I would view on the product page, all products with same related tags.
How can I to this with Fusion, without writing a new ViewHelper?

Thanks for Helping


(Martin Ficzel) #2

That depends on the exact number of “a lot” :slight_smile:

If you have 1000s of relations you will probably end up using ElasticSearch and configure how the tags property is indexed.

For fewer nodes using ${q(site).find('[instanceof Vendor.Package:Product]').filterByReference('tags', myTag).get()} might work.
The filterByReference Operation originates from https://github.com/Flowpack/Flowpack.Listable wich you have to install first for that.

If you have lots of products i would not even try the second approach since the “find” operation is not really fast and all products will have to be checked every time. So in that case go directly to elasticSearch.


(Mario Näther) #3

@martoro
Thank you, for your answer.

I add the Flow.Listable package and the following code

body {
   tags = ${q(q(node).property('tags')).get()}
   prodByTagCollection = ${q(node).siblings('[instanceof Vendor.Package:Product]').filterByReference('tags', q(tags)).get()}
}

But my prodByTagCollection var in fluid template stays empty.
Do you have any idea, whas wrong?