Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

56 lines
2.5KB

  1. <?php
  2. namespace Lc\ShopBundle\Repository;
  3. use Lc\ShopBundle\Context\DefaultRepositoryInterface;
  4. use Lc\ShopBundle\Context\ProductInterface;
  5. use Lc\ShopBundle\Model\ProductFamily;
  6. /**
  7. * @method ProductInterface|null find($id, $lockMode = null, $lockVersion = null)
  8. * @method ProductInterface|null findOneBy(array $criteria, array $orderBy = null)
  9. * @method ProductInterface[] findAll()
  10. * @method ProductInterface[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
  11. */
  12. class ProductRepository extends BaseRepository implements DefaultRepositoryInterface
  13. {
  14. public function getInterfaceClass()
  15. {
  16. return ProductInterface::class;
  17. }
  18. public function findProductByAvailabilitiesNegative()
  19. {
  20. $qb = $this->createQueryBuilder('e');
  21. $qb->innerJoin('e.productFamily', 'productFamily');
  22. $qb->addSelect('productFamily');
  23. $qb->where('productFamily.merchant = :currentMerchant');
  24. $qb->andWhere('productFamily.status = 1');
  25. $qb->setParameter('currentMerchant', $this->merchantUtils->getMerchantCurrent()->getId());
  26. $qb->andWhere(
  27. $qb->expr()->orX(
  28. $qb->expr()->andX(
  29. $qb->expr()->orX(
  30. 'productFamily.behaviorCountStock LIKE :behaviorCountStockByProductFamily',
  31. 'productFamily.behaviorCountStock LIKE :behaviorCountStockByMeasure'
  32. ),
  33. 'productFamily.availableQuantity < 0 '
  34. ),
  35. $qb->expr()->andX(
  36. 'productFamily.behaviorCountStock LIKE :behaviorCountStockByProduct',
  37. 'e.availableQuantity < 0 '
  38. )
  39. )
  40. );
  41. $qb->setParameter('behaviorCountStockByProductFamily', ProductFamily::BEHAVIOR_COUNT_STOCK_BY_PRODUCT_FAMILY);
  42. $qb->setParameter('behaviorCountStockByMeasure', ProductFamily::BEHAVIOR_COUNT_STOCK_BY_MEASURE);
  43. $qb->setParameter('behaviorCountStockByProduct', ProductFamily::BEHAVIOR_COUNT_STOCK_BY_PRODUCT);
  44. $qb->groupBy('productFamily.id');
  45. return $qb->getQuery()->getResult();
  46. }
  47. }