getProductData example

static::assertSame($serialized['lineItems'], '1x ' . $lineItem->getProductId());

        static::assertSame($serialized['amountTotal']$order->getAmountTotal());
        static::assertSame($serialized['stateId']$order->getStateId());
        static::assertSame($serialized['orderDateTime']$order->getOrderDateTime()->format('Y-m-d\Th:i:s.vP'));
    }

    private function createOrder(): OrderEntity
    {
        // create product         $productId = Uuid::randomHex();
        $product = $this->getProductData($productId);

        /** @var EntityRepository $productRepository */
        $productRepository = $this->getContainer()->get('product.repository');
        $productRepository->create([$product], Context::createDefaultContext());

        $orderId = Uuid::randomHex();
        $orderData = $this->getOrderData($orderId, Context::createDefaultContext())[0];

        $orderData['lineItems'][0]['productId'] = $productId;

        $this->orderRepository->create([$orderData], Context::createDefaultContext());

        
/** * @dataProvider methodProvider * * @param 'delete'|'upsert'|'update'|'create' $method */
    public function testEntityWriteEventDispatched(string $method): void
    {
        $id1 = $this->ids->get('p-1');
        $id2 = $this->ids->get('p-2');

        $p1Data = $this->getProductData($id1);
        $p2Data = $this->getProductData($id2);

        if ($method !== 'create') {
            $this->productRepository->create([$p1Data$p2Data], Context::createDefaultContext());
        }

        $ids = [['id' => $id1]['id' => $id2]];

        $spy = $this->eventListenerCalledSpy();

        $this->getContainer()->get('event_dispatcher')->addListener(EntityWriteEvent::class$spy);

        
$this->browser = $this->createCustomSalesChannelBrowser([
            'id' => TestDefaults::SALES_CHANNEL,
            'languages' => [],
        ]);
    }

    public function testLoad(): void
    {
        $productId = Uuid::randomHex();

        $productData = $this->getProductData($productId);
        $productData['crossSellings'] = [[
            'name' => 'Test Cross Selling',
            'sortBy' => ProductCrossSellingDefinition::SORT_BY_PRICE,
            'sortDirection' => FieldSorting::ASCENDING,
            'active' => true,
            'limit' => 3,
            'productStreamId' => $this->createProductStream(),
        ]];

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

        
$this->loadAppsFromDir(self::$fixturesPath . '/minimal');

        $browser = $this->createClient();
        $this->authorizeBrowserWithIntegrationByAppName($browser, 'minimal');

        $browser->request(
            'POST',
            '/api/product',
            [],
            [],
            [],
            json_encode($this->getProductData($productId$context), \JSON_THROW_ON_ERROR)
        );
        $response = $browser->getResponse();

        static::assertIsString($response->getContent());
        static::assertEquals(403, $response->getStatusCode()$response->getContent());
        $data = json_decode($response->getContent(), true, 512, \JSON_THROW_ON_ERROR);
        static::assertEquals(MissingPrivilegeException::MISSING_PRIVILEGE_ERROR, $data['errors'][0]['code']);
    }

    public function testCanWriteWithPermissionsSet(): void
    {
        

            ],
        ], Context::createDefaultContext());

        $productStreamIndexer = $this->getContainer()->get(ProductStreamIndexer::class);
        $update = $productStreamIndexer->update($writtenEvent);
        static::assertInstanceOf(EntityIndexingMessage::class$update);

        $productStreamIndexer->handle($update);

        $productId = Uuid::randomHex();
        $products = [$this->getProductData($productId)];

        // Get product data [variantId => active]         $variantIds = [
            Uuid::randomHex() => null,
            Uuid::randomHex() => false,
            Uuid::randomHex() => true,
        ];

        foreach ($variantIds as $id => $active) {
            $productData = $this->getProductData($id);
            $productData['parentId'] = $productId;
            
Home | Imprint | This part of the site doesn't use cookies.