H
H
Hubix2018-07-26 20:06:11
Drupal
Hubix, 2018-07-26 20:06:11

How to get the most viewed entities using EntityFieldQuery?

How to use EntityFieldQuery to get 10 objects with the best number of views per day (daycount from the statistics module)?
My code which renders an entity but how to get better views?

function rp_offer_page_active_offer($org_nid) {
$query = new EntityFieldQuery();
$query->entityCondition('entity_type', 'node')
  ->entityCondition('bundle', 'offer')
  ->propertyCondition('status', NODE_PUBLISHED)
  ->fieldCondition('field_offer_id_org', 'target_id', $org_nid)
  ->fieldCondition('field_offer_arch', 'value', '1', '<>')
  ->range(0, 10)
  ->addMetaData('account', user_load(1));
$result = $query->execute();

return array_keys($result['node']);

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
andead, 2018-07-26
@Hubix

No way

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question