@@ -36,7 +36,7 @@ abstract class ProductFamily extends AbstractDocumentEntity implements ProductPr | |||
protected $merchant; | |||
/** | |||
* @ORM\ManyToMany(targetEntity="Lc\ShopBundle\Context\ProductCategoryInterface", inversedBy="productFamilies", fetch="EAGER") | |||
* @ORM\ManyToMany(targetEntity="Lc\ShopBundle\Context\ProductCategoryInterface", inversedBy="productFamilies") | |||
*/ | |||
protected $productCategories; | |||
@@ -51,7 +51,7 @@ abstract class ProductFamily extends AbstractDocumentEntity implements ProductPr | |||
protected $productsType; | |||
/** | |||
* @ORM\OneToMany(targetEntity="Lc\ShopBundle\Context\ProductInterface", mappedBy="productFamily", orphanRemoval=true, cascade={"persist"}, fetch="EAGER") | |||
* @ORM\OneToMany(targetEntity="Lc\ShopBundle\Context\ProductInterface", mappedBy="productFamily", orphanRemoval=true, cascade={"persist"}) | |||
*/ | |||
protected $products; | |||
@@ -9,7 +9,6 @@ use Lc\ShopBundle\Context\ReductionCatalogInterface; | |||
/** | |||
* @method ProductFamilyInterface|null find($id, $lockMode = null, $lockVersion = null) | |||
* @method ProductFamilyInterface|null findOneBy(array $criteria, array $orderBy = null) | |||
* @method ProductFamilyInterface[] findAll() | |||
* @method ProductFamilyInterface[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) | |||
*/ | |||
class ProductFamilyRepository extends BaseRepository implements DefaultRepositoryInterface | |||
@@ -27,12 +26,16 @@ class ProductFamilyRepository extends BaseRepository implements DefaultRepositor | |||
$query->innerJoin('e.products', 'pfp'); | |||
$query->addSelect('pfp') ; | |||
$query->innerJoin('e.supplier', 'pfs'); | |||
$query->addSelect('pfs') ; | |||
return $query ; | |||
} | |||
public function findAll() | |||
{ | |||
$query = $this->findByMerchantQuery() ; | |||
$query = $this->joinRelations($query) ; | |||
return $query->getQuery()->getResult() ; | |||
} | |||
public function getProductFamiliesByCategory($category){ | |||
$query = $this->findByMerchantQuery() ; | |||
$query = $this->joinRelations($query) ; |
@@ -22,7 +22,6 @@ class ReductionCatalogRepository extends BaseRepository implements DefaultReposi | |||
public function getReductionCatalogByProductFamily($productFamily, $user) | |||
{ | |||
$query = $this->findByMerchantQuery(); | |||
$query->andWhere('e.status = 1'); | |||
$query->andWhere(':user MEMBER OF e.users OR e.users is empty'); | |||
@@ -36,19 +35,26 @@ class ReductionCatalogRepository extends BaseRepository implements DefaultReposi | |||
$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)'); | |||
$query->leftJoin('e.productFamilies', 'pfs') ; | |||
$query->addSelect('pfs') ; | |||
$query->leftJoin('e.productFamily', 'pf') ; | |||
$query->addSelect('pf') ; | |||
$query->leftJoin('e.productCategories', 'pc') ; | |||
$query->addSelect('pc') ; | |||
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'); | |||
@@ -65,7 +71,5 @@ class ReductionCatalogRepository extends BaseRepository implements DefaultReposi | |||
$query->setParameter(':now', new \DateTime()); | |||
return $query->getQuery()->getResult(); | |||
} | |||
} |