fixed home computed fields

This commit is contained in:
Bachir Soussi Chiadmi 2021-07-28 15:11:28 +02:00
parent f2eb90d888
commit 0e8be15f74
3 changed files with 12 additions and 6 deletions

View File

@ -42,8 +42,10 @@ class ComputedArticlesReferences extends EntityReferenceFieldItemList
->range(0,12) ->range(0,12)
->condition('type', 'article'); ->condition('type', 'article');
$nids = $query->execute(); $nids = $query->execute();
foreach ($nids as $key => $nid) { $i = 0;
$this->list[$key] = $this->createItem($key, $nid); foreach ($nids as $nid) {
$this->list[$i] = $this->createItem($i, $nid);
$i++;
} }
} }

View File

@ -42,8 +42,10 @@ class ComputedCommerceProductReferences extends EntityReferenceFieldItemList
// ->condition('type', 'article') // ->condition('type', 'article')
->range(0,12); ->range(0,12);
$ids = $query->execute(); $ids = $query->execute();
foreach ($ids as $key => $id) { $i = 0;
$this->list[$key] = $this->createItem($key, $id); foreach ($ids as $id) {
$this->list[$i] = $this->createItem($i, $id);
$i++;
} }
} }

View File

@ -45,11 +45,13 @@ class ComputedShowroomsReferences extends EntityReferenceFieldItemList
$tids = $query->execute(); $tids = $query->execute();
shuffle($tids); shuffle($tids);
foreach ($tids as $key => $tid) { $i=0;
foreach ($tids as $tid) {
$term = \Drupal::entityTypeManager()->getStorage('taxonomy_term')->load($tid); $term = \Drupal::entityTypeManager()->getStorage('taxonomy_term')->load($tid);
$sid = WorkflowManager::getCurrentStateId($term, 'field_workflow'); $sid = WorkflowManager::getCurrentStateId($term, 'field_workflow');
if($sid != 'workflow_visible') continue; if($sid != 'workflow_visible') continue;
$this->list[$key] = $this->createItem($key, $tid); $this->list[$i] = $this->createItem($i, $tid);
$i++;
} }
} }