I have created an EVA (search API index) display block to display a user's nodes and products on his or her profile page.

In contextual filters, I added "Written by" (for nodes) and "Author" (for products).

I have an argument "Use tokens from the entity the view is attached to", "[profile:uid:target_id]".

The problem :

I can not display the products and the nodes at the same time on the page.

When I place the "Written By" contextual filter first, it only displays the nodes.

When I put the "Auteut" contextual filter first, it only displays the products.

Comments

zenimagine created an issue. See original summary.

lendude’s picture

Project: Drupal core » Search API
Version: 8.3.7 » 8.x-1.x-dev
Component: views.module » Views integration

Mixing entities is not possible in core Views. You've already went to the place that might offer a solution (Search API), so moving this to the Search API queue.

drunken monkey’s picture

Status: Active » Fixed

For normal filters, you can just create an OR filter group for the two filters, so that either will work.
That won't work with contextual filters, though, I guess. But if the argument is the same anyways, you can resolve this by just having the author information in a single field for either item type ("datasource" in Search API lingo). For that, just use an "Aggregated field" (listed as such when adding fields to the search index), selecting type "Union" (or almost any other, really) and then the two UID fields. Then just place the contextual filter on that new field and it should work as expected. (Give the aggregated field a meaningful machine name and label, to make things easier.)

zenimagine’s picture

I updated my view (index). How to put an OR between the two contextual filters?

zenimagine’s picture

@drunken monkey I did not know this feature. Thank you very much it works.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.