Explorar el Código

Performances

feature/export_comptable
Guillaume hace 4 años
padre
commit
9f43c8928f
Se han modificado 3 ficheros con 20 adiciones y 13 borrados
  1. +2
    -2
      ShopBundle/Model/ProductFamily.php
  2. +7
    -4
      ShopBundle/Repository/ProductFamilyRepository.php
  3. +11
    -7
      ShopBundle/Repository/ReductionCatalogRepository.php

+ 2
- 2
ShopBundle/Model/ProductFamily.php Ver fichero

@@ -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;


+ 7
- 4
ShopBundle/Repository/ProductFamilyRepository.php Ver fichero

@@ -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) ;

+ 11
- 7
ShopBundle/Repository/ReductionCatalogRepository.php Ver fichero

@@ -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();


}
}

Cargando…
Cancelar
Guardar