custom/plugins/MoorlFoundation/src/Core/Content/Product/SalesChannel/Listing/FoundationProductListingRoute.php line 49

Open in your IDE?
  1. <?php declare(strict_types=1);
  2. namespace MoorlFoundation\Core\Content\Product\SalesChannel\Listing;
  3. use MoorlFoundation\Core\Service\EntitySearchService;
  4. use Shopware\Core\Content\Product\SalesChannel\Listing\AbstractProductListingRoute;
  5. use Shopware\Core\Content\Product\SalesChannel\Listing\ProductListingRouteResponse;
  6. use Shopware\Core\Framework\DataAbstractionLayer\Search\Criteria;
  7. use Shopware\Core\Framework\Routing\Annotation\RouteScope;
  8. use Shopware\Core\System\SalesChannel\SalesChannelContext;
  9. use Symfony\Component\HttpFoundation\Request;
  10. use Symfony\Contracts\EventDispatcher\EventDispatcherInterface;
  11. /**
  12.  * @RouteScope(scopes={"store-api"})
  13.  */
  14. class FoundationProductListingRoute extends AbstractProductListingRoute
  15. {
  16.     private AbstractProductListingRoute $decorated;
  17.     private EventDispatcherInterface $dispatcher;
  18.     private EntitySearchService $searchService;
  19.     public function __construct(
  20.         AbstractProductListingRoute $decorated,
  21.         EntitySearchService $searchService,
  22.         EventDispatcherInterface $dispatcher
  23.     ) {
  24.         $this->decorated $decorated;
  25.         $this->dispatcher $dispatcher;
  26.         $this->searchService $searchService;
  27.     }
  28.     public function getDecorated(): AbstractProductListingRoute
  29.     {
  30.         return $this->decorated;
  31.     }
  32.     public function load(string $categoryIdRequest $requestSalesChannelContext $contextCriteria $criteria): ProductListingRouteResponse
  33.     {
  34.         $entityListing $this->searchService->getEntityListing($request$context->getContext());
  35.         if ($entityListing) {
  36.             $entityListing->setEventDispatcher($this->dispatcher);
  37.             $entityListing->setRequest($request);
  38.             $entityListing->setSalesChannelContext($context);
  39.             return $entityListing->listingRoute($criteria$categoryId);
  40.         }
  41.         return $this->decorated->load($categoryId$request$context$criteria);
  42.     }
  43. }