<?php
namespace App\Repository;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry;
use Evo\Infrastructure\MappingORM\Product;
/**
* @method Product|null find($id, $lockMode = null, $lockVersion = null)
* @method Product|null findOneBy(array $criteria, array $orderBy = null)
* @method Product[] findAll()
* @method Product[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
*/
class ProductRepository extends ServiceEntityRepository
{
public function __construct(ManagerRegistry $registry)
{
parent::__construct($registry, Product::class);
}
public function findStoreAdditionForStoreName(string $storeName): ?Product
{
return $this->createQueryBuilder('p')
->where('p.name LIKE :storeName')
->andWhere('p.active = false')
->setParameter('storeName', '%'.$storeName.'%')
->getQuery()->getOneOrNullResult();
}
public function getStoreAdditionFromProductIds(array $productIds): ?Product
{
return $this->createQueryBuilder('p')
->where('p.active = false')
->andWhere('p.uniqueKey LIKE :uniqueKey')
->andWhere('p.id IN (:productIds)')
->setParameter('uniqueKey', 'STORE_ADDITION_%')
->setParameter('productIds', $productIds)
->setMaxResults(1)
->getQuery()->getOneOrNullResult();
}
}