Skip to content

Commit a57dbd6

Browse files
committed
Remove related products that not exist in map list.
1 parent def5104 commit a57dbd6

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

app/code/Magento/RelatedProductGraphQl/Model/Resolver/Batch/AbstractLikedProducts.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,10 @@ private function findRelations(array $products, array $loadAttributes, int $link
110110
//Matching products with related products.
111111
$relationsData = [];
112112
foreach ($relations as $productId => $relatedIds) {
113+
//Remove related products that not exist in map list.
114+
$relatedIds = array_filter($relatedIds, function ($relatedId) use ($relatedProducts) {
115+
return isset($relatedProducts[$relatedId]);
116+
});
113117
$relationsData[$productId] = array_map(
114118
function ($id) use ($relatedProducts) {
115119
return $relatedProducts[$id];

0 commit comments

Comments
 (0)