I have nodes of content type "product" and this content type has an entity reference field with multiple values, that contains references to another product nodes.

Is it possible to set the filter of view block to show only products that are in current opended product's reference field?

2 Answers 2


What you want is views' right column.

You need to use a contextual filter of Content: nid, choose to provide a default value Content id from url. If you want to suppress the current product (eg. for a related products display use the Exclude option in the More fieldset at the bottom.)

Then add a relationship and select your entity reference field.

Finally you can add the field Content: rendered node and at the top choose your newly created relationship. This should give you a list of referenced products.

Update: I guess the exclude option takes no effect in this case, since you'll be only listing the referenced products.


I found solution by adding new filter criteria of Global:PHP(PHP) type, where you can type your own php logic, in my case:

$node = node_load(arg(1));

if(isset($node->field_recommended_products['und'][0])) {

  foreach($node->field_recommended_products['und'] as $prod)  {

     if($prod['target_id'] == $data->nid) {
       return true;
     } else { return false; }


} else {
  return false; 

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.