createQueryBuilder('e'); $qb->innerJoin('e.productFamily', 'productFamily'); $qb->addSelect('productFamily'); $qb->where('productFamily.merchant = :currentMerchant'); $qb->setParameter('currentMerchant', $this->merchantUtils->getMerchantCurrent()->getId()); $qb->andWhere('productFamily.status = 1'); $qb->andWhere( $qb->expr()->orX( $qb->expr()->andX( $qb->expr()->orX( 'productFamily.behaviorCountStock LIKE :behaviorCountStockByProductFamily', 'productFamily.behaviorCountStock LIKE :behaviorCountStockByMeasure' ), 'productFamily.availableQuantity < 0 ' ), $qb->expr()->andX( 'productFamily.behaviorCountStock LIKE :behaviorCountStockByProduct', 'e.availableQuantity < 0 ' ) ) ); $qb->setParameter('behaviorCountStockByProductFamily', ProductFamily::BEHAVIOR_COUNT_STOCK_BY_PRODUCT_FAMILY); $qb->setParameter('behaviorCountStockByMeasure', ProductFamily::BEHAVIOR_COUNT_STOCK_BY_MEASURE); $qb->setParameter('behaviorCountStockByProduct', ProductFamily::BEHAVIOR_COUNT_STOCK_BY_PRODUCT); $qb->groupBy('productFamily.id'); return $qb->getQuery()->getResult(); } }