예제 #1
0
 /**
  * @inheritdoc
  */
 public function search(Criteria $criteria, StoreFrontBundle\Struct\ProductContextInterface $context)
 {
     $numberResult = $this->searchGateway->search($criteria, $context);
     $numbers = array_keys($numberResult->getProducts());
     $products = $this->productService->getList($numbers, $context);
     $products = $this->assignAttributes($products, $numberResult->getProducts());
     $result = new ProductSearchResult($products, $numberResult->getTotalCount(), $numberResult->getFacets());
     $result->addAttributes($numberResult->getAttributes());
     return $result;
 }
예제 #2
0
 /**
  * @inheritdoc
  */
 public function getList(array $numbers, Struct\ProductContextInterface $context)
 {
     $products = $this->service->getList($numbers, $context);
     $categories = $this->seoCategoryService->getList($products, $context);
     /**@var $product Struct\ListProduct*/
     foreach ($products as $product) {
         $productId = $product->getId();
         if (!isset($categories[$productId])) {
             continue;
         }
         $attribute = new Struct\Attribute(['category' => $categories[$productId]]);
         $product->addAttribute('swag_plugin_system', $attribute);
     }
     return $products;
 }
 /**
  * @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);
     //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;
 }
예제 #4
0
 /**
  * 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;
 }
 /**
  * @param array $numbers
  * @param Struct\ProductContextInterface $context
  * @return Struct\ListProduct[]
  */
 public function getList(array $numbers, Struct\ProductContextInterface $context)
 {
     $getSortedNumbers = $this->sortingComponent->sortByNumber($numbers);
     $products = $this->coreService->getList($getSortedNumbers, $context);
     return $products;
 }