Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

ProductFamilyRepository.php 2.8KB

4 лет назад
4 лет назад
4 лет назад
4 лет назад
4 лет назад
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. <?php
  2. namespace Lc\ShopBundle\Repository;
  3. use Lc\ShopBundle\Context\DefaultRepositoryInterface;
  4. use Lc\ShopBundle\Context\ProductFamilyInterface;
  5. use Lc\ShopBundle\Context\ReductionCatalogInterface;
  6. /**
  7. * @method ProductFamilyInterface|null find($id, $lockMode = null, $lockVersion = null)
  8. * @method ProductFamilyInterface|null findOneBy(array $criteria, array $orderBy = null)
  9. * @method ProductFamilyInterface[] findAll()
  10. * @method ProductFamilyInterface[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
  11. */
  12. class ProductFamilyRepository extends BaseRepository implements DefaultRepositoryInterface
  13. {
  14. public function getInterfaceClass()
  15. {
  16. return ProductFamilyInterface::class;
  17. }
  18. public function getProductFamiliesByCategory($category){
  19. $query = $this->findByMerchantQuery() ;
  20. $query->leftJoin('e.productCategories', 'cat');
  21. $query->andWhere(':category MEMBER OF e.productCategories');
  22. $query->andWhere('e.status = 1');
  23. $query->setParameter('category', $category->getId());
  24. return $query->getQuery()->getResult() ;
  25. }
  26. public function getProductFamiliesNovelties(){
  27. $query = $this->findByMerchantQuery();
  28. $query->andWhere('e.status = 1');
  29. $query->andWhere(':now <= e.propertyNoveltyExpirationDate')
  30. ->setParameter('now', new \DateTime()) ;
  31. return $query->getQuery()->getResult() ;
  32. }
  33. public function getProductFamiliesLargeVolumes(){
  34. $query = $this->findByMerchantQuery() ;
  35. $query->leftJoin('e.productCategories', 'cat');
  36. $query->andWhere('e.status = 1');
  37. $query->andWhere('e.propertyLargeVolume = 1');
  38. return $query->getQuery()->getResult() ;
  39. }
  40. public function getProductFamiliesOrganics(){
  41. $query = $this->findByMerchantQuery() ;
  42. $query->leftJoin('e.productCategories', 'cat');
  43. $query->andWhere('e.status = 1');
  44. $query->andWhere('e.propertyOrganicLabel IS NOT NULL');
  45. return $query->getQuery()->getResult() ;
  46. }
  47. public function findByTerms($terms, $maxResults = false)
  48. {
  49. $query = $this->findByMerchantQuery() ;
  50. $query->leftJoin('e.productCategories', 'cat');
  51. $query->andWhere('e.status = 1');
  52. $query->andWhere('e.title LIKE :terms');
  53. $query->setParameter(':terms', '%'.$terms.'%') ;
  54. if($maxResults) {
  55. $query->setMaxResults($maxResults) ;
  56. }
  57. return $query->getQuery()->getResult() ;
  58. }
  59. }