Browse Source

fixed home computed fields

bach 2 years ago
parent
commit
0e8be15f74

+ 4 - 2
web/modules/custom/materio_home/src/Plugin/Field/FieldType/ComputedArticlesReferences.php

@@ -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++;
     }
   }
 

+ 4 - 2
web/modules/custom/materio_home/src/Plugin/Field/FieldType/ComputedCommerceProductReferences.php

@@ -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++;
     }
   }
 

+ 4 - 2
web/modules/custom/materio_home/src/Plugin/Field/FieldType/ComputedShowroomsReferences.php

@@ -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++;
     }
   }