Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
hasAvailableFilter example
public
function
processCriteria
(
Criteria
$criteria
, SalesChannelContext
$context
)
: void
{
if
(
empty
(
$criteria
->
getFields
(
)
)
)
{
$criteria
->
addAssociation
(
'prices'
)
->
addAssociation
(
'unit'
)
->
addAssociation
(
'deliveryTime'
)
->
addAssociation
(
'cover.media'
)
;
}
if
(
!
$this
->
hasAvailableFilter
(
$criteria
)
)
{
$criteria
->
addFilter
(
new
ProductAvailableFilter
(
$context
->
getSalesChannel
(
)
->
getId
(
)
, ProductVisibilityDefinition::VISIBILITY_LINK
)
)
;
}
if
(
$criteria
->
hasAssociation
(
'productReviews'
)
)
{
$association
=
$criteria
->
getAssociation
(
'productReviews'
)
;
$activeReviewsFilter
=
new
MultiFilter
(
MultiFilter::CONNECTION_OR,
[
new
EqualsFilter
(
'status', true
)
]
)
;
if
(
$customer
=
$context
->
getCustomer
(
)
)
{
$activeReviewsFilter
->
addQuery
(
new
EqualsFilter
(
'customerId',
$customer
->
getId
(
)
)
)
;
}