Example #1
0
 /**
  * @param Struct\ListProduct[] $listProducts
  * @param Struct\ProductContextInterface $context
  * @return Struct\Product[] indexed by order number
  */
 private function createFromListProducts(array $listProducts, Struct\ProductContextInterface $context)
 {
     $votes = $this->voteService->getList($listProducts, $context);
     $relatedProducts = $this->relatedProductsService->getList($listProducts, $context);
     $relatedProductStreams = $this->relatedProductStreamsService->getList($listProducts, $context);
     $similarProducts = $this->similarProductsService->getList($listProducts, $context);
     $downloads = $this->downloadService->getList($listProducts, $context);
     $links = $this->linkService->getList($listProducts, $context);
     $media = $this->mediaService->getProductsMedia($listProducts, $context);
     $properties = $this->propertyService->getList($listProducts, $context);
     $configuration = $this->configuratorService->getProductsConfigurations($listProducts, $context);
     $products = [];
     foreach ($listProducts as $listProduct) {
         $number = $listProduct->getNumber();
         $product = Struct\Product::createFromListProduct($listProduct);
         if (isset($relatedProducts[$number])) {
             $product->setRelatedProducts($relatedProducts[$number]);
         }
         if (isset($relatedProductStreams[$number])) {
             $product->setRelatedProductStreams($relatedProductStreams[$number]);
         }
         if (isset($similarProducts[$number])) {
             $product->setSimilarProducts($similarProducts[$number]);
         }
         if (isset($votes[$number])) {
             $product->setVotes($votes[$number]);
         }
         if (isset($downloads[$number])) {
             $product->setDownloads($downloads[$number]);
         }
         if (isset($links[$number])) {
             $product->setLinks($links[$number]);
         }
         if (isset($media[$number])) {
             $product->setMedia($media[$number]);
         }
         if (isset($properties[$number])) {
             $product->setPropertySet($properties[$number]);
         }
         if (isset($configuration[$number])) {
             $product->setConfiguration($configuration[$number]);
         }
         $products[$number] = $product;
     }
     return $products;
 }