# Dokumenterstellung aus Plugin, kann Dokument Componente nicht ausführen

**URL:** <https://forum.shopware.com/t/dokumenterstellung-aus-plugin-kann-dokument-componente-nicht-ausfuehren/88466>\
**Category:** Programmierung\
**Created:** [20. Juni 2021 um 18:13 UTC](https://forum.shopware.com/t/dokumenterstellung-aus-plugin-kann-dokument-componente-nicht-ausfuehren/88466 "2021-06-20T18:13:59Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![pogolino](https://avatars.discourse-cdn.com/v4/letter/p/8797f3/32.png) [@pogolino](https://forum.shopware.com/u/pogolino)\
**Post date:** [20. Juni 2021 um 18:13 UTC](https://forum.shopware.com/t/dokumenterstellung-aus-plugin-kann-dokument-componente-nicht-ausfuehren/88466/1 "2021-06-20T18:13:59Z")

</div>

Ich habe ein simples Plugin geschrieben welche mir in der API „GetOne aufgerufen“ zurück gibt.  
Soweit so gut.

```auto
<?php

namespace Shopware\Components\Api\Resource;

class GreVoApi extends Resource
{
    public function create(array $params)
    {              
        return "Document created";
    }
        public function getOne($id)
    {
                                
        $this->checkPrivilege('read');      
        if (empty($id)) {
            throw new ApiException\ParameterMissingException();
        }                                  
             
        return "GetOne aufgerufen";
    }
    
}
?>

```

Nun möchte ich bei dem Aufruf ein Dokument erstellen. Dazu habe ich das Skript mal zum testen mit einer festen orderId wie folgt ergänzt:

```auto
<?php

namespace Shopware\Components\Api\Resource;

class GreVoApi extends Resource
{
    public function create(array $params)
    {              
        return "Document created";
    }
        public function getOne($id)
    {
                                
        $this->checkPrivilege('read');      
        if (empty($id)) {
            throw new ApiException\ParameterMissingException();
        }                                  
                                                           
        $orderId = 95912;
        $documentType = 1;
        $renderer = 'pdf';
        $displayDate = date("d.m.Y");
        $document = Shopware_Components_Document::initDocument(
            $orderId,
            $documentType,
            [
                'netto' => false,
                'bid' => null,
                'voucher' => null,
                'date' => $displayDate,
                'delivery_date' => $displayDate,
                // Don't show shipping costs on delivery note #SW-4303
                'shippingCostsAsPosition' => (int) $documentType !== 2,
                '_renderer' => $renderer,
                '_preview' => false,
                '_previewForcePagebreak' => null,
                '_previewSample' => null,
                'docComment' => null,
                'forceTaxCheck' => false,
            ]
        );
        $erfolg = $document->render();
    
        return "GetOne aufgerufen";
    }
    
}
?>

```

Ich erhalte aber die PHP Fehlermeldung:

```auto
PHP Fatal error: Uncaught Error: Class 'Shopware\\Components\\Api\\Resource\\Shopware_Components_Document' not found in [.../custom/plugins/GreVoApi/Components/Api/Resource/GreVoApi.php]

```

Weshalb kann denn die Klasse nicht gefunden werden?  
Diese Klasse initDocument() welche ich aufrufen will befindet sich in /engine/Shopware/Components/Documept.php  
Wie rufe ich diese denn korrekt auf?

Vielen Dank für jede Hilfe!
