getReferencedDocumentId example

return $result;
        }

        $referenceInvoiceNumbers = [];

        $orders = new OrderCollection();

        /** @var DocumentGenerateOperation $operation */
        foreach ($operations as $operation) {
            try {
                $orderId = $operation->getOrderId();
                $invoice = $this->referenceInvoiceLoader->load($orderId$operation->getReferencedDocumentId()$rendererConfig->deepLinkCode);

                if (empty($invoice)) {
                    throw new DocumentGenerationException('Can not generate credit note document because no invoice document exists. OrderId: ' . $operation->getOrderId());
                }

                $documentRefer = json_decode((string) $invoice['config'], true, 512, \JSON_THROW_ON_ERROR);

                $referenceInvoiceNumbers[$orderId] = $documentRefer['documentNumber'];

                $order = $this->getOrder($orderId$invoice['orderVersionId']$context$rendererConfig->deepLinkCode);

                
return $result;
        }

        $referenceInvoiceNumbers = [];

        $orders = new OrderCollection();

        /** @var DocumentGenerateOperation $operation */
        foreach ($operations as $operation) {
            try {
                $orderId = $operation->getOrderId();
                $invoice = $this->referenceInvoiceLoader->load($orderId$operation->getReferencedDocumentId()$rendererConfig->deepLinkCode);

                if (empty($invoice)) {
                    throw new DocumentGenerationException('Can not generate storno document because no invoice document exists. OrderId: ' . $operation->getOrderId());
                }

                $documentRefer = json_decode((string) $invoice['config'], true, 512, \JSON_THROW_ON_ERROR);

                $referenceInvoiceNumbers[$orderId] = $documentRefer['documentNumber'];

                $order = $this->getOrder($orderId$invoice['orderVersionId']$context$rendererConfig->deepLinkCode);

                

        $documentMediaId = $document->getDocumentMediaFileId();

        if ($documentMediaId !== null || $document->isStatic()) {
            return $documentMediaId;
        }

        $operation = new DocumentGenerateOperation(
            $document->getOrderId(),
            FileTypes::PDF,
            $document->getConfig(),
            $document->getReferencedDocumentId()
        );

        $operation->setDocumentId($document->getId());

        /** @var DocumentTypeEntity $documentType */
        $documentType = $document->getDocumentType();

        $documentStruct = $this->documentGenerator->generate(
            $documentType->getTechnicalName(),
            [$document->getOrderId() => $operation],
            $context
        )
$records[] = [
                    'id' => $id,
                    'documentTypeId' => $documentTypeId,
                    'fileType' => $operation->getFileType(),
                    'orderId' => $orderId,
                    'orderVersionId' => $operation->getOrderVersionId(),
                    'static' => $operation->isStatic(),
                    'documentMediaFileId' => $mediaId,
                    'config' => $document->getConfig(),
                    'deepLinkCode' => $deepLinkCode,
                    'referencedDocumentId' => $operation->getReferencedDocumentId(),
                ];

                $result->addSuccess(new DocumentIdStruct($id$deepLinkCode$mediaId));
            } catch (\Throwable $exception) {
                $result->addError($orderId$exception);
            }
        }

        $this->writeRecords($records$context);

        return $result;
    }
        $operation = new DocumentGenerateOperation($this->orderId, FileTypes::PDF, []$invoice->getId());

        $stornoStruct = $this->documentGenerator->generate(StornoRenderer::TYPE, [$this->orderId => $operation]$this->context)->getSuccess()->first();

        static::assertNotNull($stornoStruct);
        static::assertTrue(Uuid::isValid($stornoStruct->getId()));

        /** @var DocumentEntity $storno */
        $storno = $this->documentRepository->search(new Criteria([$stornoStruct->getId()])$this->context)->get($stornoStruct->getId());

        static::assertNotNull($storno);
        static::assertEquals($invoice->getId()$storno->getReferencedDocumentId());
        static::assertSame($storno->getOrderVersionId()$invoice->getOrderVersionId());
    }

    /** * @group slow */
    public function testCreateFileIsWrittenInFs(): void
    {
        /** @var FilesystemOperator $fileSystem */
        $fileSystem = $this->getContainer()->get('shopware.filesystem.private');
        $document = $this->createDocumentWithFile();

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