findByMerchantQuery(); $query->andWhere('e.status = 1'); $query->andWhere(':user MEMBER OF e.users OR e.users is empty'); $query->andWhere(':groupUser MEMBER OF e.groupUsers OR e.groupUsers is empty'); $query->andWhere(':productFamily MEMBER OF e.productFamilies OR e.productFamilies is empty'); $query->andWhere(':productCategory MEMBER OF e.productCategories OR e.productCategories is empty'); $query->andWhere(':supplier MEMBER OF e.suppliers OR e.suppliers is empty'); $query->setParameter('user', $user); $query->setParameter('groupUser', $user->getGroupUsers()); $query->setParameter('productFamily', $productFamily); $query->setParameter('productCategory', $productFamily->getProductCategories()); $query->setParameter('supplier', $productFamily->getSupplier()); return $query->getQuery()->getResult(); } public function getReductionCatalogByProductFamilyConditions($productFamilyIds, $user) { $query = $this->findByMerchantQuery(); $query->andWhere('e.status = 1'); $query->andWhere('e.permanent = 1 OR (e.dateStart <= :now AND e.dateEnd >= :now)'); if($user){ $query->andWhere(':user MEMBER OF e.users OR e.users is empty'); $query->andWhere(':groupUser MEMBER OF e.groupUsers OR e.groupUsers is empty'); $query->setParameter('user', $user); $query->setParameter('groupUser', $user->getGroupUsers()); } $query->andWhere(':productFamily MEMBER OF e.productFamilies OR e.productFamilies is empty'); $query->andWhere(':productCategory MEMBER OF e.productCategories OR e.productCategories is empty'); $query->andWhere(':supplier MEMBER OF e.suppliers OR e.suppliers is empty'); $query->setParameter('productFamily', $productFamilyIds['ids']); $query->setParameter('productCategory', $productFamilyIds['categories']); $query->setParameter('supplier', $productFamilyIds['suppliers']); $query->setParameter(':now', new \DateTime()); return $query->getQuery()->getResult(); } }