src/Repository/ProductRepository.php line 19

Open in your IDE?
  1. <?php
  2. namespace App\Repository;
  3. use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
  4. use Doctrine\Persistence\ManagerRegistry;
  5. use Evo\Infrastructure\MappingORM\Product;
  6. /**
  7.  * @method Product|null find($id, $lockMode = null, $lockVersion = null)
  8.  * @method Product|null findOneBy(array $criteria, array $orderBy = null)
  9.  * @method Product[]    findAll()
  10.  * @method Product[]    findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
  11.  */
  12. class ProductRepository extends ServiceEntityRepository
  13. {
  14.     public function __construct(ManagerRegistry $registry)
  15.     {
  16.         parent::__construct($registryProduct::class);
  17.     }
  18.     public function findStoreAdditionForStoreName(string $storeName): ?Product
  19.     {
  20.         return $this->createQueryBuilder('p')
  21.             ->where('p.name LIKE :storeName')
  22.             ->andWhere('p.active = false')
  23.             ->setParameter('storeName''%'.$storeName.'%')
  24.             ->getQuery()->getOneOrNullResult();
  25.     }
  26.     public function getStoreAdditionFromProductIds(array $productIds): ?Product
  27.     {
  28.         return $this->createQueryBuilder('p')
  29.             ->where('p.active = false')
  30.             ->andWhere('p.uniqueKey LIKE :uniqueKey')
  31.             ->andWhere('p.id IN (:productIds)')
  32.             ->setParameter('uniqueKey''STORE_ADDITION_%')
  33.             ->setParameter('productIds'$productIds)
  34.             ->setMaxResults(1)
  35.             ->getQuery()->getOneOrNullResult();
  36.     }
  37. }