/**
  * @inheritdoc
  */
 public function createBaseProducts($numbers)
 {
     $query = $this->connection->createQueryBuilder();
     $query->select(['variant.id as variantId', 'variant.ordernumber as number', 'variant.articleID as productId']);
     $query->from('s_articles_details', 'variant')->where('variant.ordernumber IN(:numbers)')->setParameter(':numbers', $numbers, Connection::PARAM_STR_ARRAY);
     /**@var $statement \PDOStatement*/
     $statement = $query->execute();
     $data = $statement->fetchAll(\PDO::FETCH_ASSOC);
     $products = [];
     foreach ($data as $row) {
         $product = new BaseProduct((int) $row['productId'], (int) $row['variantId'], $row['number']);
         $products[$product->getNumber()] = $product;
     }
     return $products;
 }
Ejemplo n.º 2
0
 /**
  * @param QueryBuilder $query
  * @return array
  */
 private function getProducts(QueryBuilder $query)
 {
     /**@var $statement \Doctrine\DBAL\Driver\ResultStatement */
     $statement = $query->execute();
     $data = $statement->fetchAll(\PDO::FETCH_ASSOC);
     $products = [];
     foreach ($data as $row) {
         $product = new BaseProduct((int) $row['__product_id'], (int) $row['__variant_id'], $row['__variant_ordernumber']);
         $product->addAttribute('search', $this->attributeHydrator->hydrate($row));
         $products[$product->getNumber()] = $product;
     }
     return $products;
 }
Ejemplo n.º 3
0
 /**
  * @param Struct\BaseProduct $product
  * @return NotFilter
  */
 protected function getProductNumberFilter(Struct\BaseProduct $product)
 {
     return new NotFilter(new IdsFilter([$product->getNumber()]));
 }
Ejemplo n.º 4
0
 /**
  * @param $data
  * @return BaseProduct[]
  */
 private function createProducts($data)
 {
     $products = [];
     foreach ($data['hits']['hits'] as $data) {
         $source = $data['_source'];
         $product = new BaseProduct((int) $source['id'], (int) $source['variantId'], $source['number']);
         $product->addAttribute('elastic_search', new Attribute(['score' => $data['_score']]));
         $products[$product->getNumber()] = $product;
     }
     return $products;
 }