Browse Source

[Frontend] Ordre des éléments home

develop
Fab 3 years ago
parent
commit
73461779b1
1 changed files with 10 additions and 2 deletions
  1. +10
    -2
      ShopBundle/Repository/ProductFamilyRepository.php

+ 10
- 2
ShopBundle/Repository/ProductFamilyRepository.php View File

$query = $this->findByMerchantQuery() ; $query = $this->findByMerchantQuery() ;
$query = $this->joinRelations($query) ; $query = $this->joinRelations($query) ;
$query->andWhere('e.status = 1') ; $query->andWhere('e.status = 1') ;
$query->orderBy('RAND()');
return $query->getQuery()->getResult() ; return $query->getQuery()->getResult() ;
} }


$query->andWhere('e.status = 1'); $query->andWhere('e.status = 1');
$query->andWhere(':now <= e.propertyNoveltyExpirationDate') $query->andWhere(':now <= e.propertyNoveltyExpirationDate')
->setParameter('now', new \DateTime()) ; ->setParameter('now', new \DateTime()) ;
$query->orderBy('e.createdAt', 'DESC');
$query->orderBy('RAND()');


return $query->getQuery()->getResult() ; return $query->getQuery()->getResult() ;
} }
return $query->getQuery()->getResult() ; return $query->getQuery()->getResult() ;
} }


public function getProductFamiliesBySection($section)
public function getProductFamiliesBySection($section, $maxResults = false, $sortField = 'productCategories.position', $sortDirection = 'ASC')
{ {
$query = $this->findByMerchantQuery() ; $query = $this->findByMerchantQuery() ;
$query = $this->joinRelations($query) ; $query = $this->joinRelations($query) ;


$query->andWhere(':section MEMBER OF e.sections') $query->andWhere(':section MEMBER OF e.sections')
->setParameter('section', $section) ; ->setParameter('section', $section) ;
$query->leftJoin('e.productCategories', 'productCategories');
if($sortField){
$query->orderBy($sortField,$sortDirection);
}
if($maxResults) {
$query->setMaxResults($maxResults) ;
}


return $query->getQuery()->getResult() ; return $query->getQuery()->getResult() ;
} }

Loading…
Cancel
Save