ProductDetailRouteResponse example

$criteria = (new Criteria())
            ->addAssociation('manufacturer.media')
            ->addAssociation('options.group')
            ->addAssociation('properties.group')
            ->addAssociation('mainCategories.category')
            ->addAssociation('media');

        $productDetailRouteMock = $this->createMock(ProductDetailRoute::class);
        $productDetailRouteMock
            ->method('load')
            ->with($productId$request$salesChannelContext$criteria)
            ->willReturn(new ProductDetailRouteResponse($product, null));

        return new ProductPageLoader(
            $this->createMock(GenericPageLoader::class),
            $this->createMock(EventDispatcherInterface::class),
            $productDetailRouteMock,
            $this->createMock(ProductReviewLoader::class),
            $this->createMock(ProductCrossSellingRoute::class)
        );
    }

    /** * @param array<string, array<string, array<string, array<string, array<string, string>>>>> $reviews */
$this->createCriteria($pageId$request),
                    $context,
                    $product->getTranslation('slotConfig'),
                    $resolverContext
                );

                if ($page = $pages->first()) {
                    $product->setCmsPage($page);
                }
            }

            return new ProductDetailRouteResponse($product$configurator);
        });
    }

    private function addFilters(SalesChannelContext $context, Criteria $criteria): void
    {
        $criteria->addFilter(
            new ProductAvailableFilter($context->getSalesChannel()->getId(), ProductVisibilityDefinition::VISIBILITY_LINK)
        );

        $salesChannelId = $context->getSalesChannel()->getId();

        
$salesChannel,
            new CurrencyEntity(),
            new CustomerGroupEntity(),
            new TaxCollection(),
            new PaymentMethodEntity(),
            new ShippingMethodEntity(),
            new ShippingLocation(new CountryEntity(), null, null),
            new CustomerEntity(),
            new CashRoundingConfig(1, 1.1, true),
            new CashRoundingConfig(1, 1.1, true)
        );
        $this->response = new ProductDetailRouteResponse(
            new SalesChannelProductEntity(),
            null
        );

        $this->cachedRoute = new CachedProductDetailRoute(
            $this->decorated,
            $this->cache,
            $this->createMock(EntityCacheKeyGenerator::class),
            $this->createMock(AbstractCacheTracer::class),
            $this->eventDispatcher,
            []
        );
Home | Imprint | This part of the site doesn't use cookies.