custom/plugins/LoyxxFullWidthProductListing/src/Subscribers/ProductListLoadedEventSubscriber.php line 20

Open in your IDE?
  1. <?php
  2. namespace LoyxxFullWidthProductListing\Subscribers;
  3. use Shopware\Core\Content\Product\Events\ProductListingCriteriaEvent;
  4. use Shopware\Core\Content\Product\Events\ProductSearchCriteriaEvent;
  5. use Shopware\Storefront\Page\Product\Configurator\ProductPageConfiguratorLoader;
  6. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  7. class ProductListLoadedEventSubscriber implements EventSubscriberInterface{
  8.     public static function getSubscribedEvents()
  9.     {
  10.         return [
  11.             ProductListingCriteriaEvent::class => 'onProductListingCriteriaEvent',
  12.             ProductSearchCriteriaEvent::class => 'onProductListingCriteriaEvent'
  13.         ];
  14.     }
  15.     public function onProductListingCriteriaEvent($event)
  16.     {
  17.         $this->addAssociation($event->getCriteria());
  18.     }
  19.     private function addAssociation(\Shopware\Core\Framework\DataAbstractionLayer\Search\Criteria $criteria)
  20.     {
  21.         $criteria->addAssociation('properties');
  22.         $criteria->addAssociation('properties.group');
  23.         $criteria->addAssociation('manufacturer');
  24.     }
  25. }