/** * @inheritdoc */ public function getList($products, Struct\ShopContextInterface $context) { $ids = []; foreach ($products as $product) { $ids[] = $product->getId(); } $ids = array_unique($ids); $query = $this->connection->createQueryBuilder(); $query->select($this->fieldHelper->getLinkFields()); $query->from('s_articles_information', 'link')->leftJoin('link', 's_articles_information_attributes', 'linkAttribute', 'linkAttribute.informationID = link.id'); $query->where('link.articleID IN (:ids)')->setParameter(':ids', $ids, Connection::PARAM_INT_ARRAY); /**@var $statement \Doctrine\DBAL\Driver\ResultStatement */ $statement = $query->execute(); $data = $statement->fetchAll(\PDO::FETCH_ASSOC); $links = []; foreach ($data as $row) { $key = $row['__link_articleID']; $link = $this->linkHydrator->hydrate($row); $links[$key][] = $link; } $result = []; foreach ($products as $product) { if (isset($links[$product->getId()])) { $result[$product->getNumber()] = $links[$product->getId()]; } } return $result; }