getCrossSelling example

$this->productRepository->create([$productData]$this->salesChannelContext->getContext());

        $result = $this->route->load($productIdnew Request()$this->salesChannelContext, new Criteria())
            ->getResult();

        static::assertEquals(1, $result->count());

        $element = $result->first();
        static::assertNotNull($element);
        static::assertEquals(3, $element->getTotal());
        static::assertEquals('Test Cross Selling', $element->getCrossSelling()->getName());

        $lastPrice = 0;
        foreach ($element->getProducts() as $product) {
            $productPrice = $product->getCurrencyPrice(Defaults::CURRENCY);
            static::assertNotNull($productPrice);
            static::assertGreaterThanOrEqual($lastPrice$productPrice->getGross());
            $lastPrice = $productPrice->getGross();
        }
    }

    public function testLoadForProduct(): void
    {
Home | Imprint | This part of the site doesn't use cookies.