ProductListResponse example

$product3 = new ProductEntity();
            $product3->setUniqueIdentifier($criteria->getIds()[2]); /** @phpstan-ignore-line */
            $searchResult = new EntitySearchResult(
                'product',
                3,
                new ProductCollection([$product1$product2$product3]),
                null,
                $criteria,
                $context->getContext()
            );

            return new ProductListResponse($searchResult);
        };

        $this->productListRouteMock->expects(static::once())->method('load')->willReturnCallback($productRouteLoadClosure);

        $context = $this->salesChannelContextMock;

        $eventDidRun = null;
        $phpunit = $this;
        $listenerClosure = function DGuestWishlistPageletLoadedEvent $event) use (
            &$eventDidRun,
            $phpunit,
            

    }

    public function getDecorated(): AbstractProductListRoute
    {
        throw new DecorationPatternException(self::class);
    }

    #[Route(path: '/store-api/product', name: 'store-api.product.search', methods: ['GET', 'POST'], defaults: ['_entity' => 'product'])]     public function load(Criteria $criteria, SalesChannelContext $context): ProductListResponse
    {
        return new ProductListResponse($this->productRepository->search($criteria$context));
    }
}
 {
    }

    public function load(Request $request, SalesChannelContext $context): GuestWishlistPagelet
    {
        $page = new GuestWishlistPagelet();

        $criteria = $this->createCriteria($request$context);
        $this->eventDispatcher->dispatch(new GuestWishListPageletProductCriteriaEvent($criteria$context$request));

        if (empty($criteria->getIds())) {
            $response = new ProductListResponse(new EntitySearchResult(
                'wishlist',
                0,
                new ProductCollection(),
                null,
                $criteria,
                $context->getContext()
            ));
        } else {
            $response = $this->productListRoute->load($criteria$context);
        }

        
$cart = new Cart(Uuid::randomHex());
        $context = $this->createMock(SalesChannelContext::class);
        $product = new ProductEntity();
        $product->setUniqueIdentifier($id);
        $product->setId($id);
        $item = new LineItem($id, PromotionProcessor::LINE_ITEM_TYPE);

        $cart->add($item);
        $this->productListRouteMock->expects(static::once())
            ->method('load')
            ->willReturn(
                new ProductListResponse(
                    new EntitySearchResult(
                        ProductDefinition::ENTITY_NAME,
                        1,
                        new ProductCollection([$product]),
                        null,
                        new Criteria(),
                        Context::createDefaultContext()
                    )
                )
            );

        
Home | Imprint | This part of the site doesn't use cookies.