/** * @inheritdoc */ public function get(Struct\BaseProduct $product, Struct\ShopContextInterface $context) { $query = $this->getQuery(); $query->addSelect($this->fieldHelper->getConfiguratorSetFields())->addSelect($this->fieldHelper->getConfiguratorGroupFields())->addSelect($this->fieldHelper->getConfiguratorOptionFields()); $this->fieldHelper->addConfiguratorTranslation($query, $context); $query->where('products.id = :id')->setParameter(':id', $product->getId()); /**@var $statement \Doctrine\DBAL\Driver\ResultStatement */ $statement = $query->execute(); $data = $statement->fetchAll(\PDO::FETCH_ASSOC); return $this->configuratorHydrator->hydrate($data); }
/** * @inheritdoc */ public function getList($products, Struct\ShopContextInterface $context) { if (empty($products)) { return []; } $ids = []; foreach ($products as $product) { $ids[] = $product->getVariantId(); } $ids = array_unique($ids); $query = $this->getQuery()->select('variants.ordernumber as number')->addSelect($this->fieldHelper->getConfiguratorGroupFields())->addSelect($this->fieldHelper->getConfiguratorOptionFields()); $this->fieldHelper->addConfiguratorTranslation($query, $context); $query->where('relations.article_id IN (:ids)')->setParameter(':ids', $ids, Connection::PARAM_INT_ARRAY); $query->addOrderBy('configuratorGroup.id'); /**@var $statement \Doctrine\DBAL\Driver\ResultStatement */ $statement = $query->execute(); $data = $statement->fetchAll(\PDO::FETCH_GROUP); $result = []; foreach ($data as $key => $groups) { $result[$key] = $this->configuratorHydrator->hydrateGroups($groups); } return $result; }