1

Here I want to fetch the nid of matching child term id from my content type product_categories.

I used the below code.

$query = new EntityFieldQuery();
$query->entityCondition('entity_type', 'node');
$query->entityCondition('bundle', 'product_categories');
$query->propertyCondition('status', 1);
$query->fieldCondition('field_product_sub_cat', 'tid', $child->tid, '=');
$result = $query->execute();

I execute the above query and it displays correct results.But now I want to fetch the nid, I used below code but its not working.

 $childnid = $result->nid; //Area to explore
//print "<pre>"; print_r ((int)$childnid);
print $childnid;`

can anybody please help me ??

1
  • If you get only nid then one logical way through which you can findout the nid. Try to export & find the nid.
    – Nishant
    Commented Mar 13, 2015 at 7:31

1 Answer 1

2

$result is in array of items.

Use this:

$first_nid = NULL; 
if (isset($result['node'])) {
   $first_nid = array_shift(array_keys($result['node']));
}
0

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.