# Nachricht in der Administration ausgeben in postUpdate Methode

**URL:** <https://forum.shopware.com/t/nachricht-in-der-administration-ausgeben-in-postupdate-methode/92870>\
**Category:** Programmierung\
**Created:** [10. Februar 2022 um 08:23 UTC](https://forum.shopware.com/t/nachricht-in-der-administration-ausgeben-in-postupdate-methode/92870 "2022-02-10T08:23:16Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![webwerk](https://avatars.discourse-cdn.com/v4/letter/w/fbc32d/32.png) [@webwerk](https://forum.shopware.com/u/webwerk)\
**Post date:** [10. Februar 2022 um 08:23 UTC](https://forum.shopware.com/t/nachricht-in-der-administration-ausgeben-in-postupdate-methode/92870/1 "2022-02-10T08:23:16Z")

</div>

Hallo Community,

ist es möglich in der Administration nach einem erfolgten Plugin-Update einen Hinweis auszugeben?  
Beispielsweise in der postUpdate Methode?

```auto
public function postUpdate(UpdateContext $updateContext): void
    {
        parent::postUpdate($updateContext);

        // Code für Hinweis / Nachricht

    }

```

![hinweis](https://europe1.discourse-cdn.com/flex013/uploads/shopware/original/3X/8/1/81d5dcf09f3d8cb3da37ea08095d7b208dc2c55e.png)

---

<div class="post-metadata">

**Author:** ![AlexGalax](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.shopware.com/alexgalax/32/9925_2.png) [@AlexGalax](https://forum.shopware.com/u/AlexGalax)\
**Post date:** [10. Februar 2022 um 08:28 UTC](https://forum.shopware.com/t/nachricht-in-der-administration-ausgeben-in-postupdate-methode/92870/2 "2022-02-10T08:28:22Z")

</div>

> **[Add custom action button](https://developer.shopware.com/docs/guides/plugins/apps/administration/add-custom-action-button#show-a-notification-to-the-user)**

---

<div class="post-metadata">

**Author:** ![webwerk](https://avatars.discourse-cdn.com/v4/letter/w/fbc32d/32.png) [@webwerk](https://forum.shopware.com/u/webwerk)\
**Post date:** [10. Februar 2022 um 08:31 UTC](https://forum.shopware.com/t/nachricht-in-der-administration-ausgeben-in-postupdate-methode/92870/3 "2022-02-10T08:31:08Z")

</div>

@AlexGalax Danke für Deine Nachricht.

Ich befinde mich im Plugin-Context… die Anleitung ist für Apps…

Ich weiß leider nicht, wie ich aus der Plugin-Bootstrap die Informationen aus der Doku umsetzen könnte.

---

<div class="post-metadata">

**Author:** ![AlexGalax](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.shopware.com/alexgalax/32/9925_2.png) [@AlexGalax](https://forum.shopware.com/u/AlexGalax)\
**Post date:** [10. Februar 2022 um 09:11 UTC](https://forum.shopware.com/t/nachricht-in-der-administration-ausgeben-in-postupdate-methode/92870/4 "2022-02-10T09:11:29Z")

</div>

Du kannst Notifications in den Modul-Komponenten triggern:

`custom/plugins/myPlugin/src/Resources/app/administration/src/module/my-plugin-module/page/my-plugin-module-detail/index.js`

```nohighlight
const { Component } = Shopware;

Component.register('my-plugin-module-detail', {
    this.createNotificationError({
        title: '',
        message: '',
    });
    this.createNotificationWarning({
        title: '',
        message: '',
    });
    this.createNotificationInfo({
        title: '',
        message: '',
    });
    this.createNotificationSuccess({
        title: '',
        message: '',
    });
})

```

Die Update-Notification von Shopware wird hier erzeugt:

> <https://github.com/shopware/platform/blob/7d92486d90d5bb14c6f6caca5eea0a26a3198fdb/src/Administration/Resources/app/administration/src/core/service/plugin-updates-listener.service.js#L38>

Müsstest du schauen ob du das für dein Project irgendwie übernehmen kannst. Sollte aber eigentlich machbar sein.

---

<div class="post-metadata">

**Author:** ![webwerk](https://avatars.discourse-cdn.com/v4/letter/w/fbc32d/32.png) [@webwerk](https://forum.shopware.com/u/webwerk)\
**Post date:** [10. Februar 2022 um 09:25 UTC](https://forum.shopware.com/t/nachricht-in-der-administration-ausgeben-in-postupdate-methode/92870/5 "2022-02-10T09:25:35Z")

</div>

hm…

okay, für einen „einfachen Hinweis“ ein ganzes Modul schreiben zu müssen erscheint mir irgendwie etwas oversized… zumal ich nicht weiß, wie man das dann in der PHP Methode aufrufen würden…

in Shopware 5 war das ein Zwei-Zeiler in der Update-Methode:

```auto
$message = 'foobar';
$updateContext->scheduleMessage($message);

```

---

<div class="post-metadata">

**Author:** ![shinroh](https://avatars.discourse-cdn.com/v4/letter/s/3ec8ea/32.png) [@shinroh](https://forum.shopware.com/u/shinroh)\
**Post date:** [11. November 2023 um 12:16 UTC](https://forum.shopware.com/t/nachricht-in-der-administration-ausgeben-in-postupdate-methode/92870/6 "2023-11-11T12:16:16Z")

</div>

Du kannst auf PHP Ebene den Notification Service `Shopware\Administration\Notification\NotificationService` nutzen.  
Auf JS/Vue Ebene gibt es das Mixin `notification`

> **[Using Mixins | Shopware Documentation](https://developer.shopware.com/docs/guides/plugins/plugins/administration/using-mixins.html#using-the-mixin)**
>
> Documentation for Shopware developers

---

<div class="post-metadata">

**Author:** ![gaxweb](https://avatars.discourse-cdn.com/v4/letter/g/ea5d25/32.png) [@gaxweb](https://forum.shopware.com/u/gaxweb)\
**Post date:** [19. Februar 2024 um 12:06 UTC](https://forum.shopware.com/t/nachricht-in-der-administration-ausgeben-in-postupdate-methode/92870/7 "2024-02-19T12:06:39Z")

</div>

Danke für den Hinweis. `NotificationService` ist allerdings als `@internal` markiert und schlecht dokumentiert, aber hilft ja nix… Hab’s in SW v6.5 jetzt einfach so gemacht:

```auto
try {
	$this->notificationService->createNotification([
		'id' => md5($message), 'message' => $message, 'status' => 'error'
	], $context);
} catch (\Shopware\Core\Framework\DataAbstractionLayer\Write\Command\WriteTypeIntendException $e7n){
	// ignore insert of duplicate message
}

```

Welche `status` es gibt ist mir nicht klar, aber passt so erst mal.

---

<div class="post-metadata">

**Author:** ![shinroh](https://avatars.discourse-cdn.com/v4/letter/s/3ec8ea/32.png) [@shinroh](https://forum.shopware.com/u/shinroh)\
**Post date:** [3. April 2024 um 10:37 UTC](https://forum.shopware.com/t/nachricht-in-der-administration-ausgeben-in-postupdate-methode/92870/8 "2024-04-03T10:37:30Z")

</div>

Die Status sollten die selben wie im vue part sein. Also error, success und info.  
Die @interal Markierung muss man in dem Fall in Kauf nehmen. Vielleicht im eigenen Code markieren und bei Major Realeases gegenprüfen.
