-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMNAddDocumentData.php
More file actions
41 lines (35 loc) · 1.24 KB
/
Copy pathMNAddDocumentData.php
File metadata and controls
41 lines (35 loc) · 1.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<?php
namespace MNAddDocumentData;
use Shopware\Components\Plugin\Context\ActivateContext;
use Shopware\Components\Plugin\Context\DeactivateContext;
class MNAddDocumentData extends \Shopware\Components\Plugin
{
public function activate(ActivateContext $context)
{
$context->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);
}
}