Skip to content

Commit bff891f

Browse files
committed
Product Media Gallery GQL response is sorted by image position
1 parent 2abc466 commit bff891f

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

app/code/Magento/CatalogGraphQl/Model/Resolver/Product/MediaGallery.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,14 @@ public function resolve(
5757
= $entry->getExtensionAttributes()->getVideoContent()->getData();
5858
}
5959
}
60+
if (!empty($mediaGalleryEntries)) {
61+
usort(
62+
$mediaGalleryEntries,
63+
function ($entryA, $entryB) {
64+
return ($entryA['position'] < $entryB['position']) ? -1 : 1;
65+
}
66+
);
67+
}
6068
return $mediaGalleryEntries;
6169
}
6270
}

0 commit comments

Comments
 (0)