0

I am having field_feature as a collection of fields (field-collection) in a content type called 'watches'. Those fields are,

field_water_resistance -> water_resistance(Term Reference)
field_gender -> gender(Term Reference)
field_function -> function(Term Reference)
field_sub_function -> sub_function(Term Reference)

And so on.

I have my query like this:

$query = new EntityFieldQuery();
$query->entityCondition('entity_type', 'node')
    ->propertyCondition('type', 'watches','=')
    ->propertyCondition('status', 1);
$query->range($offset, 15);
$query->addTag('joinentity');
$query->addTag('fieldcollection');
$query->addMetaData('termscollection', $filterparams); // $filterparams is array of tids

Now I want to add above field collections in the query with the parameters (array of tids). How can we do that?

I know the EntityFieldQuery with the entity_type as field_collection_item but I don't know the same for entity_type as node.

How can we do that?

1 Answer 1

0

I think you have to possibilities to solve this:

  1. Looks like you already got a tag for joining the field_group entities here:

    $query->addTag('joinentity');

You could then implement hook_query_joinentity_alter() to implement the join, see also EntityFieldQuery INNER JOIN

  1. You use db_select() or db_query() and add your joins there rather than an EFQ. I think this is preferable as implementing tags and hooks for those gets a bit messy IMO.

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.