<?php
declare(strict_types=1);
namespace App\Repository\ProductVariant;
use Sylius\AdminOrderCreationPlugin\Doctrine\ORM\ProductVariantRepositoryInterface;
use Sylius\AdminOrderCreationPlugin\Doctrine\ORM\ProductVariantRepositoryTrait;
use BitBag\SyliusProductBundlePlugin\Repository\ProductVariantRepository as BaseProductVariantRepository;
class ProductVariantRepository extends BaseProductVariantRepository implements ProductVariantRepositoryInterface
{
use ProductVariantRepositoryTrait;
public function findWithEmptyModelByPhrase (string $phrase, string $locale) {
$expr = $this->getEntityManager()->getExpressionBuilder();
$qb = $this->createQueryBuilder('o')
->leftJoin('o.translations', 'translation', 'WITH', 'translation.locale = :locale')
->innerJoin('o.product', 'product')
->andWhere($expr->orX(
'translation.name LIKE :phrase',
'o.code LIKE :phrase',
'product.code LIKE :phrase'
))
->andWhere($expr->isNull('o.model'))
->setParameter('phrase', '%' . $phrase . '%')
->setParameter('locale', $locale)
->setMaxResults(20)
;
return $qb->getQuery()->getResult();
}
public function findAllOnHoldNotNull(): array
{
return $this->createQueryBuilder('v')
->andWhere('v.onHold IS NOT NULL')
->getQuery()
->getResult()
;
}
}