Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
getBooleanClause example
public
function
testMatchingBooleanClause
(
bool
$andLogic
, string
$expected
)
: void
{
$context
= Context::
createDefaultContext
(
)
;
$this
->productSearchConfigRepository->
update
(
[
[
'id' =>
$this
->productSearchConfigId, 'andLogic' =>
$andLogic
]
,
]
,
$context
)
;
$matches
=
$this
->interpreter->
interpret
(
'Random terms',
$context
)
;
$booleanClause
=
$matches
->
getBooleanClause
(
)
;
static
::
assertEquals
(
$expected
,
$booleanClause
)
;
}
/** * @dataProvider caseWithMatchingSearchPatternTermLength */
public
function
testMatchingSearchPatternTermLength
(
bool
$andLogic
, string
$words
)
: void
{
$context
= Context::
createDefaultContext
(
)
;
)
;
}
$criteria
->
addQuery
(
new
ScoreQuery
(
new
ContainsFilter
(
'product.searchKeywords.keyword',
$pattern
->
getOriginal
(
)
->
getTerm
(
)
)
,
$pattern
->
getOriginal
(
)
->
getScore
(
)
,
'product.searchKeywords.ranking'
)
)
;
if
(
$pattern
->
getBooleanClause
(
)
!== SearchPattern::BOOLEAN_CLAUSE_AND
)
{
$criteria
->
addFilter
(
new
AndFilter
(
[
new
EqualsAnyFilter
(
'product.searchKeywords.keyword',
array_values
(
$pattern
->
getAllTerms
(
)
)
)
,
new
EqualsFilter
(
'product.searchKeywords.languageId',
$context
->
getContext
(
)
->
getLanguageId
(
)
)
,
]
)
)
;
return
;
}
foreach
(
$pattern
->
getTokenTerms
(
)
as
$terms
)
{
$criteria
->
addFilter
(
new
AndFilter
(
[
new
EqualsFilter
(
'product.searchKeywords.languageId',
$context
->
getContext
(
)
->
getLanguageId
(
)
)
,