/** * {@inheritdoc} */ public function valueExists(ProductValueInterface $value) { $productQueryBuilder = $this->queryBuilderFactory->create(); $qb = $productQueryBuilder->getQueryBuilder(); $productQueryBuilder->addFilter($value->getAttribute()->getCode(), '=', $value->getData()); $result = $qb->hydrate(false)->getQuery()->execute(); if (0 === $result->count() || 1 === $result->count() && $value->getEntity()->getId() === (string) $result->getNext()['_id']) { return false; } return true; }
/** * {@inheritdoc} */ public function findOneByWithValues($id) { $productQb = $this->queryBuilderFactory->create(); $qb = $productQb->getQueryBuilder(); $rootAlias = current($qb->getRootAliases()); $this->addJoinToValueTables($qb); $qb->leftJoin('Attribute.availableLocales', 'AttributeLocales'); $qb->addSelect('Value'); $qb->addSelect('Attribute'); $qb->addSelect('AttributeLocales'); $qb->leftJoin('Attribute.group', 'AttributeGroup'); $qb->addSelect('AttributeGroup'); $qb->andWhere($qb->expr()->eq($rootAlias . '.id', $id)); return $qb->getQuery()->getOneOrNullResult(); }
/** * @return ProductQueryBuilderInterface */ protected function getProductQueryBuilder() { return $this->pqbFactory->create(); }