src/Repository/ProductVariant/ProductVariantRepository.php line 11

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace App\Repository\ProductVariant;
  4. use Sylius\AdminOrderCreationPlugin\Doctrine\ORM\ProductVariantRepositoryInterface;
  5. use Sylius\AdminOrderCreationPlugin\Doctrine\ORM\ProductVariantRepositoryTrait;
  6. use BitBag\SyliusProductBundlePlugin\Repository\ProductVariantRepository as BaseProductVariantRepository;
  7. class ProductVariantRepository extends BaseProductVariantRepository implements  ProductVariantRepositoryInterface
  8. {
  9.     use ProductVariantRepositoryTrait;
  10.     public function findWithEmptyModelByPhrase (string $phrasestring $locale) {
  11.         $expr $this->getEntityManager()->getExpressionBuilder();
  12.         $qb $this->createQueryBuilder('o')
  13.             ->leftJoin('o.translations''translation''WITH''translation.locale = :locale')
  14.             ->innerJoin('o.product''product')
  15.             ->andWhere($expr->orX(
  16.                 'translation.name LIKE :phrase',
  17.                 'o.code LIKE :phrase',
  18.                 'product.code LIKE :phrase'
  19.             ))
  20.             ->andWhere($expr->isNull('o.model'))
  21.             ->setParameter('phrase''%' $phrase '%')
  22.             ->setParameter('locale'$locale)
  23.             ->setMaxResults(20)
  24.             ;
  25.         return $qb->getQuery()->getResult();
  26.     }
  27.     public function findAllOnHoldNotNull(): array
  28.     {
  29.         return $this->createQueryBuilder('v')
  30.             ->andWhere('v.onHold IS NOT NULL')
  31.             ->getQuery()
  32.             ->getResult()
  33.             ;
  34.     }
  35. }