/**
  * @inheritdoc
  */
 public function buildAdditionalTextLists($products, ShopContextInterface $context)
 {
     $required = [];
     foreach ($products as &$product) {
         if (!$product->getAdditional()) {
             $required[] = $product;
         }
     }
     if (empty($required)) {
         return $products;
     }
     $configurations = $this->configuratorService->getProductsConfigurations($required, $context);
     /**@var $required ListProduct[]*/
     foreach ($required as &$product) {
         if (!array_key_exists($product->getNumber(), $configurations)) {
             continue;
         }
         $config = $configurations[$product->getNumber()];
         $product->setAdditional($this->buildTextDynamic($config));
     }
     return $products;
 }
Esempio 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;
 }
Esempio n. 3
0
 /**
  * Helper function which loads a full product struct and converts the product struct
  * to the shopware 3 array structure.
  *
  * @param Product $product
  * @param int     $categoryId
  * @param array   $selection
  * @return array
  */
 private function getLegacyProduct(Product $product, $categoryId, array $selection)
 {
     $data = $this->legacyStructConverter->convertProductStruct($product);
     $relatedArticles = array();
     foreach ($data['sRelatedArticles'] as $related) {
         $related = $this->legacyEventManager->firePromotionByIdEvents($related, null, $this);
         if ($related) {
             $relatedArticles[] = $related;
         }
     }
     $data['sRelatedArticles'] = $relatedArticles;
     $similarArticles = array();
     foreach ($data['sSimilarArticles'] as $similar) {
         $similar = $this->legacyEventManager->firePromotionByIdEvents($similar, null, $this);
         if ($similar) {
             $similarArticles[] = $similar;
         }
     }
     $data['sSimilarArticles'] = $similarArticles;
     $data['categoryID'] = $categoryId;
     if ($product->hasConfigurator()) {
         $configurator = $this->configuratorService->getProductConfigurator($product, $this->contextService->getProductContext(), $selection);
         $convertedConfigurator = $this->legacyStructConverter->convertConfiguratorStruct($product, $configurator);
         $data = array_merge($data, $convertedConfigurator);
         $convertedConfiguratorPrice = $this->legacyStructConverter->convertConfiguratorPrice($product, $configurator);
         $data = array_merge($data, $convertedConfiguratorPrice);
     }
     $data = array_merge($data, $this->getLinksOfProduct($product, $categoryId));
     $data["articleName"] = $this->sOptimizeText($data["articleName"]);
     $data["description_long"] = htmlspecialchars_decode($data["description_long"]);
     $data['mainVariantNumber'] = $this->db->fetchOne("SELECT variant.ordernumber\n             FROM s_articles_details variant\n             INNER JOIN s_articles product\n                ON product.main_detail_id = variant.id\n                AND product.id = ?", array($product->getId()));
     $data["sDescriptionKeywords"] = $this->getDescriptionKeywords($data["description_long"]);
     $data = $this->legacyEventManager->fireArticleByIdEvents($data, $this);
     return $data;
 }