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)
->condition('type', 'article');
$nids = $query->execute();
foreach ($nids as $key => $nid) {
$this->list[$key] = $this->createItem($key, $nid);
$i = 0;
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')
->range(0,12);
$ids = $query->execute();
foreach ($ids as $key => $id) {
$this->list[$key] = $this->createItem($key, $id);
$i = 0;
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();
shuffle($tids);
foreach ($tids as $key => $tid) {
$i=0;
foreach ($tids as $tid) {
$term = \Drupal::entityTypeManager()->getStorage('taxonomy_term')->load($tid);
$sid = WorkflowManager::getCurrentStateId($term, 'field_workflow');
if($sid != 'workflow_visible') continue;
$this->list[$key] = $this->createItem($key, $tid);
$this->list[$i] = $this->createItem($i, $tid);
$i++;
}
}