vendor/shopware/core/Content/Product/SalesChannel/Listing/ResolveCriteriaProductListingRoute.php line 72

Open in your IDE?
  1. <?php declare(strict_types=1);
  2. namespace Shopware\Core\Content\Product\SalesChannel\Listing;
  3. use OpenApi\Annotations as OA;
  4. use Shopware\Core\Content\Product\Events\ProductListingCriteriaEvent;
  5. use Shopware\Core\Framework\DataAbstractionLayer\Search\Criteria;
  6. use Shopware\Core\Framework\Routing\Annotation\Entity;
  7. use Shopware\Core\Framework\Routing\Annotation\RouteScope;
  8. use Shopware\Core\Framework\Routing\Annotation\Since;
  9. use Shopware\Core\System\SalesChannel\SalesChannelContext;
  10. use Symfony\Component\HttpFoundation\Request;
  11. use Symfony\Component\Routing\Annotation\Route;
  12. use Symfony\Contracts\EventDispatcher\EventDispatcherInterface;
  13. /**
  14.  * @Route(defaults={"_routeScope"={"store-api"}})
  15.  */
  16. class ResolveCriteriaProductListingRoute extends AbstractProductListingRoute
  17. {
  18.     private AbstractProductListingRoute $decorated;
  19.     private EventDispatcherInterface $eventDispatcher;
  20.     /**
  21.      * @internal
  22.      */
  23.     public function __construct(AbstractProductListingRoute $decoratedEventDispatcherInterface $eventDispatcher)
  24.     {
  25.         $this->decorated $decorated;
  26.         $this->eventDispatcher $eventDispatcher;
  27.     }
  28.     public function getDecorated(): AbstractProductListingRoute
  29.     {
  30.         return $this->decorated;
  31.     }
  32.     /**
  33.      * @Since("6.2.0.0")
  34.      * @Entity("product")
  35.      * @OA\Post(
  36.      *      path="/product-listing/{categoryId}",
  37.      *      summary="Fetch a product listing by category",
  38.      *      description="Fetches a product listing for a specific category. It also provides filters, sortings and property aggregations, analogous to the /search endpoint.",
  39.      *      operationId="readProductListing",
  40.      *      tags={"Store API","Product"},
  41.      *      @OA\RequestBody(
  42.      *          @OA\JsonContent(
  43.      *                  type="object",
  44.      *                  allOf={
  45.      *                      @OA\Schema(ref="#/components/schemas/ProductListingCriteria"),
  46.      *                      @OA\Schema(ref="#/components/schemas/ProductListingFlags")
  47.      *                  }
  48.      *          )
  49.      *      ),
  50.      *      @OA\Parameter(
  51.      *          name="categoryId",
  52.      *          description="Identifier of a category.",
  53.      *          @OA\Schema(type="string"),
  54.      *          in="path",
  55.      *          required=true
  56.      *      ),
  57.      *      @OA\Response(
  58.      *          response="200",
  59.      *          description="Returns a product listing containing all products and additional fields to display a listing.",
  60.      *          @OA\JsonContent(ref="#/components/schemas/ProductListingResult")
  61.      *     )
  62.      * )
  63.      * @Route("/store-api/product-listing/{categoryId}", name="store-api.product.listing", methods={"POST"})
  64.      */
  65.     public function load(string $categoryIdRequest $requestSalesChannelContext $contextCriteria $criteria): ProductListingRouteResponse
  66.     {
  67.         $this->eventDispatcher->dispatch(
  68.             new ProductListingCriteriaEvent($request$criteria$context)
  69.         );
  70.         return $this->getDecorated()->load($categoryId$request$context$criteria);
  71.     }
  72. }