$this->fieldHelper->
addManufacturerTranslation($query,
$context);
$data =
$query->
execute()->
fetchAll(PDO::FETCH_ASSOC
);
$medias =
$this->mediaService->
getList(array_column($data, '__manufacturer_img_id'
),
$context);
$manufacturers =
[];
foreach ($data as $row) { $id =
$row['__manufacturer_id'
];
$manufacturers[$id] =
$this->manufacturerHydrator->
hydrate($row);
if (!
empty($row['__manufacturer_img'
]) && !
empty($medias[$row['__manufacturer_img_id'
]])) { $manufacturers[$id]->
setCoverMedia($medias[$row['__manufacturer_img_id'
]]);
} } // sort elements by provided ids, sorting is defined by other queries like `best term match` or `max articles` or `sort alphanumeric`
$sorted =
[];
foreach ($ids as $id) { if (!\
array_key_exists($id,
$manufacturers)) { continue;
} $sorted[$id] =
$manufacturers[$id];
}