/*
* Returns an array which is associated with the different product numbers.
* Each array contains a list of product numbers which are related to the reference product.
*/
$numbers =
$this->gateway->
getList($products,
$context);
/*
* Loads the list product data for the selected numbers.
* All numbers are joined in the `extractNumbers` function to prevent that a product will be loaded multiple times
*/
$similarProducts =
$this->listProductService->
getList( $this->
extractNumbers($numbers),
$context );
$result =
[];
$fallback =
[];
foreach ($products as $product) { if (!
isset($numbers[$product->
getId()])) { $fallback[$product->
getNumber()] =
$product;
continue;
}