<?php
namespace LoyxxFullWidthProductListing\Subscribers;
use Shopware\Core\Content\Product\Events\ProductListingCriteriaEvent;
use Shopware\Core\Content\Product\Events\ProductSearchCriteriaEvent;
use Shopware\Storefront\Page\Product\Configurator\ProductPageConfiguratorLoader;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
class ProductListLoadedEventSubscriber implements EventSubscriberInterface{
public static function getSubscribedEvents()
{
return [
ProductListingCriteriaEvent::class => 'onProductListingCriteriaEvent',
ProductSearchCriteriaEvent::class => 'onProductListingCriteriaEvent'
];
}
public function onProductListingCriteriaEvent($event)
{
$this->addAssociation($event->getCriteria());
}
private function addAssociation(\Shopware\Core\Framework\DataAbstractionLayer\Search\Criteria $criteria)
{
$criteria->addAssociation('properties');
$criteria->addAssociation('properties.group');
$criteria->addAssociation('manufacturer');
}
}