/**
  * @inheritdoc
  */
 public function getList($products, Struct\ProductContextInterface $context)
 {
     /**
      * 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
     $listProducts = $this->listProductService->getList($this->extractNumbers($numbers), $context);
     $result = [];
     $fallback = [];
     foreach ($products as $product) {
         if (!isset($numbers[$product->getId()])) {
             $fallback[$product->getNumber()] = $product;
             continue;
         }
         $result[$product->getNumber()] = $this->getProductsByNumbers($listProducts, $numbers[$product->getId()]);
     }
     if (empty($fallback)) {
         return $result;
     }
     if ($this->config->get('similarLimit') <= 0) {
         return $result;
     }
     $fallback = $this->gateway->getListByCategory($fallback, $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
     $listProducts = $this->listProductService->getList($this->extractNumbers($fallback), $context);
     $fallbackResult = [];
     foreach ($products as $product) {
         if (!isset($fallback[$product->getId()])) {
             continue;
         }
         $fallbackResult[$product->getNumber()] = $this->getProductsByNumbers($listProducts, $fallback[$product->getId()]);
     }
     return $result + $fallbackResult;
 }
 /**
  * @param Struct\BaseProduct[] $products
  * @param Struct\ProductContextInterface $context
  * @return array
  */
 private function getDefined($products, Struct\ProductContextInterface $context)
 {
     /**
      * 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);
     if (empty($numbers)) {
         return [];
     }
     //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
     $listProducts = $this->listProductService->getList($this->extractNumbers($numbers), $context);
     $result = [];
     foreach ($products as $product) {
         if (!isset($numbers[$product->getId()])) {
             continue;
         }
         $result[$product->getNumber()] = $this->getProductsByNumbers($listProducts, $numbers[$product->getId()]);
     }
     return $result;
 }