Browse Source

Merge branch 'develop'

master^2
Guillaume 3 years ago
parent
commit
c31fba0e6d
1 changed files with 10 additions and 2 deletions
  1. +10
    -2
      ShopBundle/Repository/ProductFamilyRepository.php

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

@@ -44,6 +44,7 @@ class ProductFamilyRepository extends BaseRepository implements DefaultRepositor
$query = $this->findByMerchantQuery() ;
$query = $this->joinRelations($query) ;
$query->andWhere('e.status = 1') ;
$query->orderBy('RAND()');
return $query->getQuery()->getResult() ;
}

@@ -75,7 +76,7 @@ class ProductFamilyRepository extends BaseRepository implements DefaultRepositor
$query->andWhere('e.status = 1');
$query->andWhere(':now <= e.propertyNoveltyExpirationDate')
->setParameter('now', new \DateTime()) ;
$query->orderBy('e.createdAt', 'DESC');
$query->orderBy('RAND()');

return $query->getQuery()->getResult() ;
}
@@ -122,13 +123,20 @@ class ProductFamilyRepository extends BaseRepository implements DefaultRepositor
return $query->getQuery()->getResult() ;
}

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

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

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

Loading…
Cancel
Save