Skip to content

Commit

Permalink
Merge pull request #33758 from clotairer/patch-1
Browse files Browse the repository at this point in the history
  • Loading branch information
matthieu-rolland committed Sep 7, 2023
2 parents a9051ba + ee83e0b commit 46561fe
Showing 1 changed file with 15 additions and 14 deletions.
29 changes: 15 additions & 14 deletions src/Adapter/Product/Repository/ProductRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -889,26 +889,27 @@ protected function getSearchQueryBuilder(
->addGroupBy('p.id_product')
;

$dbSearchPhrase = sprintf('"%%%s%%"', pSQL($searchPhrase));
$qb->where($qb->expr()->or(
$qb->expr()->like('pl.name', $dbSearchPhrase),
$qb->expr()->like('pl.name', ':dbSearchPhrase'),

// Product references
$qb->expr()->like('p.isbn', $dbSearchPhrase),
$qb->expr()->like('p.upc', $dbSearchPhrase),
$qb->expr()->like('p.mpn', $dbSearchPhrase),
$qb->expr()->like('p.reference', $dbSearchPhrase),
$qb->expr()->like('p.ean13', $dbSearchPhrase),
$qb->expr()->like('p.supplier_reference', $dbSearchPhrase),
$qb->expr()->like('p.isbn', ':dbSearchPhrase'),
$qb->expr()->like('p.upc', ':dbSearchPhrase'),
$qb->expr()->like('p.mpn', ':dbSearchPhrase'),
$qb->expr()->like('p.reference', ':dbSearchPhrase'),
$qb->expr()->like('p.ean13', ':dbSearchPhrase'),
$qb->expr()->like('p.supplier_reference', ':dbSearchPhrase'),

// Combination attributes
$qb->expr()->like('pa.isbn', $dbSearchPhrase),
$qb->expr()->like('pa.upc', $dbSearchPhrase),
$qb->expr()->like('pa.mpn', $dbSearchPhrase),
$qb->expr()->like('pa.reference', $dbSearchPhrase),
$qb->expr()->like('pa.ean13', $dbSearchPhrase),
$qb->expr()->like('pa.supplier_reference', $dbSearchPhrase)
$qb->expr()->like('pa.isbn', ':dbSearchPhrase'),
$qb->expr()->like('pa.upc', ':dbSearchPhrase'),
$qb->expr()->like('pa.mpn', ':dbSearchPhrase'),
$qb->expr()->like('pa.reference', ':dbSearchPhrase'),
$qb->expr()->like('pa.ean13', ':dbSearchPhrase'),
$qb->expr()->like('pa.supplier_reference', ':dbSearchPhrase')
));
$dbSearchPhrase = sprintf('%%%s%%', $searchPhrase);
$qb->setParameter(':dbSearchPhrase', $dbSearchPhrase);

if (!empty($filters)) {
foreach ($filters as $type => $filter) {
Expand Down

0 comments on commit 46561fe

Please sign in to comment.