4

I'm trying to create a relationship between a field on a user profile and a field on a content type.

User Profile Company Name - This is an entity reference that pulls names from a Company content type. Product - contains a field company which also pulls from a Company content type.

I'm trying to create a view which will show a user products his company carries. So the view is a user view. Contextual filter is the UID of the logged in user. Now trying to create the relationship to pull in fields from the product content type.

Basically, I'm trying to create a query that will show products where the product.company is equal to the user.companyname.

2

To achieve it with the current content architecture:

  1. Create view of users.
  2. Add a relationship Entity Reference: Referenced Entity. Mark it as required. This will make a connection between the user and the company.
  3. Add another relationship Entity Reference: Referencing entity. Before saving add the value of the Relationship select list and select the relationship created in step #2. Mark this relationship as required too. This will make the connection between user company and the product.
  4. You should now get the fields of products you could add to the view using the relationship you have built at step #3
1

The tutorial about Using Entity Reference in Views is about using Entity Reference in Views, primarily how to use with Views relationships. Some of the topics covered are:

  • Entity references available as a relationship.
  • Entity references available as a reverse relationship.
  • Using relationships will give you duplicate rows – because that is how relationships work.
  • Use entity references as contextual filters.
  • When Entity API is enabled, you can choose the "show" setting entity, in addition to fields and content.
  • ...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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