custom/plugins/RhiemRentalProducts/src/Subscriber/FrontendListing.php line 22

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace Rhiem\RhiemRentalProducts\Subscriber;
  4. use Shopware\Core\Content\Product\Events\ProductListingCriteriaEvent;
  5. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  6. class FrontendListing implements EventSubscriberInterface
  7. {
  8.     /**
  9.      * {@inheritDoc}
  10.      */
  11.     public static function getSubscribedEvents()
  12.     {
  13.         return [
  14.             ProductListingCriteriaEvent::class => 'listingCriteriaCreation',
  15.         ];
  16.     }
  17.     public function listingCriteriaCreation(ProductListingCriteriaEvent $event): void
  18.     {
  19.         $criteria $event->getCriteria();
  20.         $criteria->addAssociation('rentalProduct');
  21.         $criteria->addAssociation('rentalProduct.parent');
  22.         $criteria->addAssociation('rentalProduct.children');
  23.         $criteria->addAssociation('rentalProduct.prices');
  24.         $criteria->addAssociation('rentalProduct.product');
  25.     }
  26. }