Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
getExcludedCategoryIds example
foreach
(
$categoryIds
as
$id
)
{
$wheres
[
]
= '`category`.path LIKE ' .
$query
->
createNamedParameter
(
'%|' .
$id
. '|%'
)
;
}
$query
->
andWhere
(
'(' .
implode
(
' OR ',
$wheres
)
. ')'
)
;
$query
->
andWhere
(
'`category`.version_id = :versionId'
)
;
$query
->
andWhere
(
'`category`.active = 1'
)
;
$query
->
andWhere
(
'`category`.type != :linkType'
)
;
$excludedCategoryIds
=
$this
->
getExcludedCategoryIds
(
$context
)
;
if
(
!
empty
(
$excludedCategoryIds
)
)
{
$query
->
andWhere
(
'`category`.id NOT IN (:categoryIds)'
)
;
$query
->
setParameter
(
'categoryIds', Uuid::
fromHexToBytesList
(
$excludedCategoryIds
)
, ArrayParameterType::STRING
)
;
}
$query
->
setParameter
(
'versionId', Uuid::
fromHexToBytes
(
Defaults::LIVE_VERSION
)
)
;
$query
->
setParameter
(
'linkType', CategoryDefinition::TYPE_LINK
)
;
return
$query
->
executeQuery
(
)
->
fetchAllAssociative
(
)
;
}