Ejemplo n.º 1
0
 /**
  * @inheritdoc
  */
 public function getList(array $numbers, Struct\ProductContextInterface $context)
 {
     $products = $this->productGateway->getList($numbers, $context);
     $covers = $this->mediaService->getCovers($products, $context);
     $graduatedPrices = $this->graduatedPricesService->getList($products, $context);
     $cheapestPrices = $this->cheapestPriceService->getList($products, $context);
     $voteAverages = $this->voteService->getAverages($products, $context);
     $result = [];
     foreach ($numbers as $number) {
         if (!array_key_exists($number, $products)) {
             continue;
         }
         $product = $products[$number];
         if (isset($covers[$number])) {
             $product->setCover($covers[$number]);
         }
         if (isset($graduatedPrices[$number])) {
             $product->setPriceRules($graduatedPrices[$number]);
         }
         if (isset($cheapestPrices[$number])) {
             $product->setCheapestPriceRule($cheapestPrices[$number]);
         }
         if (isset($voteAverages[$number])) {
             $product->setVoteAverage($voteAverages[$number]);
         }
         $product->addAttribute('marketing', $this->marketingService->getProductAttribute($product));
         $this->priceCalculationService->calculateProduct($product, $context);
         if ($this->isProductValid($product, $context)) {
             $result[$number] = $product;
         }
     }
     return $result;
 }
Ejemplo n.º 2
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;
 }