/** * @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; }
/** * Returns a minified product which can be used for listings, * sliders or emotions. * * @param $category * @param $number * @return array|bool */ private function getPromotion($category, $number) { $context = $this->contextService->getProductContext(); $product = $this->listProductService->get($number, $context); if (!$product) { return false; } $promotion = $this->legacyStructConverter->convertListProductStruct($product); if (!empty($category) && $category != $context->getShop()->getCategory()->getId()) { $promotion["linkDetails"] .= "&sCategory={$category}"; } //check if the product has a configured property set which stored in s_filter. //the mini product doesn't contains this data so we have to load this lazy. if (!$product->hasProperties()) { return $promotion; } $propertySet = $this->propertyService->get($product, $context); if (!$propertySet) { return $promotion; } $promotion['sProperties'] = $this->legacyStructConverter->convertPropertySetStruct($propertySet); $promotion['filtergroupID'] = $propertySet->getId(); return $promotion; }