# Plugin, das SQL ausführt

**URL:** <https://forum.shopware.com/t/plugin-das-sql-ausfuhrt/40099>\
**Category:** Programmierung\
**Created:** [25. September 2016 um 20:55 UTC](https://forum.shopware.com/t/plugin-das-sql-ausfuhrt/40099 "2016-09-25T20:55:24Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![brettvormkopp](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.shopware.com/brettvormkopp/32/7788_2.png) [@brettvormkopp](https://forum.shopware.com/u/brettvormkopp)\
**Post date:** [25. September 2016 um 20:55 UTC](https://forum.shopware.com/t/plugin-das-sql-ausfuhrt/40099/1 "2016-09-25T20:55:24Z")

</div>

Hallo,

ich bin auf der Suche nach einer Möglichkeit, dass man in einem Plugin eine bestimmte SQL ausführt, also nicht bei der Installation, sondern beim „speichern“ der Plugin Configs. Ich dachte erst an CronJob, allerdings sollte die SQL „relativ“ einmalig sein. Hat jemand eine Idee? THX und Gruss.

---

<div class="post-metadata">

**Author:** ![simkli](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.shopware.com/simkli/32/13124_2.png) [@simkli](https://forum.shopware.com/u/simkli)\
**Post date:** [26. September 2016 um 07:38 UTC](https://forum.shopware.com/t/plugin-das-sql-ausfuhrt/40099/2 "2016-09-26T07:38:05Z")

</div>

Hallo brettvormkopp,

das Problem dabei, eine Aktion auszuführen sobald die Pluginkonfiguration gespeichert wird,&nbsp;ist folgendes:  
Die Pluginkonfiguration kann gespeichert werden auch wenn dein Plugin gar nicht aktiv ist. Wenn dein Plugin allerdings nicht aktiv ist wird auch kein Event ausgeführt und du kannst nicht eingreifen.

Wenn dich das nicht stört und du die SQL Abfrage nur bei aktiviertem Plugin ausführen willst könntest du dich an das “Enlight\_Controller\_Action\_PostDispatchSecure\_Backend\_Config\_SaveForm” Event anhängen. Dort müsstest du Abfragen, ob das gespeicherte Formular zu deinem Plugin gehört und ggf. dann deine Aktion ausführen.

Viele Grüße

---

<div class="post-metadata">

**Author:** ![t2oh4e](https://avatars.discourse-cdn.com/v4/letter/t/a5b964/32.png) [@t2oh4e](https://forum.shopware.com/u/t2oh4e)\
**Post date:** [26. September 2016 um 07:43 UTC](https://forum.shopware.com/t/plugin-das-sql-ausfuhrt/40099/3 "2016-09-26T07:43:21Z")

</div>

Wenn es nicht im Backend sein muss würde ich dafür ein command für die console registrieren.

[http://community.shopware.com/Shopware-CLI\_detail\_1650.html#Code\_Beispiel](http://community.shopware.com/Shopware-CLI_detail_1650.html#Code_Beispiel) Ist glaube ich nicht mehr ganz aktuell, aber eine neue habe ich gerade nicht gefunden.

---

<div class="post-metadata">

**Author:** ![brettvormkopp](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.shopware.com/brettvormkopp/32/7788_2.png) [@brettvormkopp](https://forum.shopware.com/u/brettvormkopp)\
**Post date:** [27. September 2016 um 09:10 UTC](https://forum.shopware.com/t/plugin-das-sql-ausfuhrt/40099/4 "2016-09-27T09:10:23Z")

</div>

@simkli‍ &nbsp;Danke für den Tip. Hast du zufällig eine Resource woher du die&nbsp;Eventbezeichung her hast?

@t2oh4e‍ Danke für den Tip, es soll jedoch ein Plugin sein.

---

<div class="post-metadata">

**Author:** ![R4M](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.shopware.com/r4m/32/9983_2.png) [@R4M](https://forum.shopware.com/u/R4M)\
**Post date:** [27. September 2016 um 11:13 UTC](https://forum.shopware.com/t/plugin-das-sql-ausfuhrt/40099/5 "2016-09-27T11:13:23Z")

</div>

> [@brettvormkopp schrieb:](https://forum.shopware.com/profile/6611/brettvormkopp "brettvormkopp")
> 
> @simkli‍ &nbsp;Danke für den Tip. Hast du zufällig eine Resource woher du die&nbsp;Eventbezeichung her hast?

An diese Frage schließe ich mich mal mit an. In der SW 5.2.x. konnte ich diese Bezeichnung (Enlight\_Controller\_Action\_PostDispatchSecure\_Backend\_Config\_SaveForm) nicht finden.&nbsp;

---

<div class="post-metadata">

**Author:** ![waldicom](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.shopware.com/waldicom/32/12881_2.png) [@waldicom](https://forum.shopware.com/u/waldicom)\
**Post date:** [27. September 2016 um 11:19 UTC](https://forum.shopware.com/t/plugin-das-sql-ausfuhrt/40099/6 "2016-09-27T11:19:16Z")

</div>

> [@R4M schrieb:](https://forum.shopware.com/profile/17170/R4M "R4M")
> 
> > [@brettvormkopp schrieb:](https://forum.shopware.com/profile/6611/brettvormkopp "brettvormkopp")
> > 
> > @simkli‍ &nbsp;Danke für den Tip. Hast du zufällig eine Resource woher du die&nbsp;Eventbezeichung her hast?
> 
> An diese Frage schließe ich mich mal mit an. In der SW 5.2.x. konnte ich diese Bezeichnung (Enlight\_Controller\_Action\_PostDispatchSecure\_Backend\_Config\_SaveForm) nicht finden.&nbsp;

Das wird ja in der Form auch nirgendwo zu finden sein. Der Part „Enlight\_Controller\_Action\_PostDispatchSecure“ ist gleicvch für all/viele Event, danach kommt das Modul (\_Backend), dann der Controller (\_Config), dann die Action (\_SaveForm).  
Anderes Beispiel: &nbsp;Enlight\_Controller\_Action\_PostDispatchSecure\_Frontend\_Detail -\> wird im Frontend auf der Artikeldetailseite aufgerufen, nach dem alle Daten vorbereitet wurden. Usw.

Statt „Enlight\_Controller\_Action\_PostDispatchSecure“ kann es auch folgende geben:

Enlight\_Controller\_Action\_PreDispatch - wird davor aufgerufen ()  
Enlight\_Controller\_Action\_PostDispatch&nbsp;- wird danach aufgerufen

---

<div class="post-metadata">

**Author:** ![R4M](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.shopware.com/r4m/32/9983_2.png) [@R4M](https://forum.shopware.com/u/R4M)\
**Post date:** [27. September 2016 um 12:31 UTC](https://forum.shopware.com/t/plugin-das-sql-ausfuhrt/40099/7 "2016-09-27T12:31:34Z")

</div>

Nun ja, so weit ist das schon klar, aber ich konnte selbst die Action „SaveForm“ nicht finden, deshalb finde ich die Nachfrage schon gerechtfertigt.

---

<div class="post-metadata">

**Author:** ![waldicom](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.shopware.com/waldicom/32/12881_2.png) [@waldicom](https://forum.shopware.com/u/waldicom)\
**Post date:** [27. September 2016 um 12:35 UTC](https://forum.shopware.com/t/plugin-das-sql-ausfuhrt/40099/8 "2016-09-27T12:35:35Z")

</div>

> [@R4M schrieb:](https://forum.shopware.com/profile/17170/R4M "R4M")
> 
> Nun ja, so weit ist das schon klar, aber ich konnte selbst die Action „SaveForm“ nicht finden, deshalb finde ich die Nachfrage schon gerechtfertigt.

Ohne Zweifel ist die Nachfrage gerechtfertigt!!

Hier findest Du die saveFormAction: /engine/Shopware/Controllers/Backend/Config.php   
  
Wobei /Backend für „\_Backend“ steht, /Config.php für „\_Config“ und „SaveFormAction“ für \_SaveForm" (das Wort „Action“ wird in den Events, Urls usw nicht verwendet)

---

<div class="post-metadata">

**Author:** ![R4M](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.shopware.com/r4m/32/9983_2.png) [@R4M](https://forum.shopware.com/u/R4M)\
**Post date:** [27. September 2016 um 12:53 UTC](https://forum.shopware.com/t/plugin-das-sql-ausfuhrt/40099/9 "2016-09-27T12:53:22Z")

</div>

Ich schau mal ob der Hinweis auch Früchte trägt. Danke erst mal!
