Wenn ich elseif
in if
ändere und 2 in den Eigenschaften der Konditionen ankreuze, reagiert die Seite nicht und erreicht schließlich den 504 Gateway Fehler. Wie kann ich das herausfinden?
<?php // declare(strict_types=1);
namespace CustomFilterBAsedOnCurrentPropertyOption\Subscriber;
class Subscriber implements EventSubscriberInterface
{
public static function getSubscribedEvents(): array
{
return [
ProductListingCriteriaEvent::class => [
['onListingCriteria', -200],
],
];
}
public function onListingCriteria(ProductListingCriteriaEvent $event): void
{
$event->getCriteria()->addAssociation('properties');
$event->getCriteria()->addAssociation('properties.group');
$criteria = $event->getCriteria();
$filters = $criteria->getExtension('filters');
if (!$filters instanceof FilterCollection) {
return;
}
$propertyFilter = $filters->get('properties');
if (!$propertyFilter instanceof Filter || !\is_array($propertyFilter->getValues())) {
return;
}
$currentPropertyOptions = $propertyFilter->getValues();
$event->getContext()->addExtension('currentPropertyOptionsCriteria', new ArrayEntity($currentPropertyOptions));
$criteria = $event->getCriteria();
if (in_array('c0d02d1738fd4293a489695787e06b5c', $currentPropertyOptions)) {
$criteria->addFilter(
new MultiFilter(
Multifilter::CONNECTION_OR,
[
new EqualsFilter('product.properties.group.name', 'Property1'),
new EqualsFilter('product.properties.group.name', 'Property2'),
new EqualsFilter('product.properties.group.name', 'Property3'),
new PrefixFilter('product.properties.name', 'PropertyOption1'),
new PrefixFilter('product.properties.name', 'PropertyOption2'),
new PrefixFilter('product.properties.name', 'PropertyOption3')
]
)
);
}
if (in_array('3f777000a2734deead391133cee3a6a9', $currentPropertyOptions)) {
$criteria->addFilter(
new MultiFilter(
Multifilter::CONNECTION_OR,
[
new EqualsFilter('product.properties.group.name', 'Property1'),
new EqualsFilter('product.properties.group.name', 'Property2'),
new EqualsFilter('product.properties.group.name', 'Property3'),
new PrefixFilter('product.properties.name', 'PropertyOption4'),
new PrefixFilter('product.properties.name', 'PropertyOption5'),
new PrefixFilter('product.properties.name', 'PropertyOption6'),
new PrefixFilter('product.properties.name', 'PropertyOption7')
]
)
);
}
}
}