# Felder aus s\_user\_attributes in PDF Dokument

**URL:** <https://forum.shopware.com/t/felder-aus-s-user-attributes-in-pdf-dokument/50314>\
**Category:** Themes & Design\
**Created:** [7. Januar 2018 um 00:42 UTC](https://forum.shopware.com/t/felder-aus-s-user-attributes-in-pdf-dokument/50314 "2018-01-07T00:42:04Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![Moritz\_Naczenski](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.shopware.com/moritz_naczenski/32/7792_2.png) [@Moritz\_Naczenski](https://forum.shopware.com/u/Moritz_Naczenski)\
**Post date:** [10. Januar 2018 um 06:18 UTC](https://forum.shopware.com/t/felder-aus-s-user-attributes-in-pdf-dokument/50314/4 "2018-01-10T06:18:50Z")

</div>

Habe heute auch nochmal geschaut, wie man das als Plugin lösen könnte. Gibt da keinen 100% sauberen Weg, aber so könnte man das machen:

```
scheduleClearCache(ActivateContext::CACHE_LIST_DEFAULT);
    }
    public function deactivate(DeactivateContext $context)
    {
        $context->scheduleClearCache(DeactivateContext::CACHE_LIST_DEFAULT);
    }

    public static function getSubscribedEvents()
    {
        return [
            'Shopware_Components_Document::assignValues::after' => 'addAttributes'
        ];
    }

    public function addAttributes(\Enlight_Hook_HookArgs $args)
    {
        /* @var \Shopware_Components_Document $document */
        $document = $args->getSubject();
        $order = $document->_order;
        $view = $document->_view;
        $userData = $view->getTemplateVars('User');

        $service = $this->container->get('shopware_attribute.data_loader');
        $sqlUserAttributes = [
            'attributes' => $service->load('s_user_attributes', $order->userID)
        ];

        $userData = $userData + $sqlUserAttributes;

        $view->assign('User', $userData);
    }
}

```

Eine Datei mit diesem Inhalt unter /custom/plugins/MNAddDocumentData/MNAddDocumentData.php erstellen und dann über den Plugin-Manager installieren. Ich bin aber zuversichtlich, dass das auch relativ zügig im Core landet. Wollte das nur hier gerne dokumentieren, wenn sich mal jemand dran versucht.

---

_[View the full topic](https://forum.shopware.com/t/felder-aus-s-user-attributes-in-pdf-dokument/50314)._
