<?php declare(strict_types=1);
namespace Nd\Fashion\Subscriber;
use Shopware\Core\Content\Product\Events\ProductListingRouteCacheKeyEvent;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
class ModifyProductListingRouteCacheKey implements EventSubscriberInterface
{
public static function getSubscribedEvents(): array
{
return [
ProductListingRouteCacheKeyEvent::class => 'onProductListingRouteCacheKeyGeneration'
];
}
public function onProductListingRouteCacheKeyGeneration(ProductListingRouteCacheKeyEvent $event) {
$request = $event->getRequest();
if($request->get('productManufacturerId') && strlen($request->get('productManufacturerId')) > 0){
$event->addPart($request->get('productManufacturerId'));
}
}
}