# Eigenes Plugin auf bestimmte Subshops einschränken

**URL:** <https://forum.shopware.com/t/eigenes-plugin-auf-bestimmte-subshops-einschranken/37058>\
**Category:** Programmierung\
**Created:** [30. Mai 2016 um 06:37 UTC](https://forum.shopware.com/t/eigenes-plugin-auf-bestimmte-subshops-einschranken/37058 "2016-05-30T06:37:16Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![mtruebenbach](https://avatars.discourse-cdn.com/v4/letter/m/d9b06d/32.png) [@mtruebenbach](https://forum.shopware.com/u/mtruebenbach)\
**Post date:** [30. Mai 2016 um 06:37 UTC](https://forum.shopware.com/t/eigenes-plugin-auf-bestimmte-subshops-einschranken/37058/1 "2016-05-30T06:37:16Z")

</div>

Hallo zusammen,

ich habe eine Shopware PE mit diversen Subshops. Nun habe ich eine Plugin geschrieben. Dieses Plugin soll aber nicht bei allen Subshops ziehen. Wie kann ich generell eigene Plugins auf subshops eingrenzen. Mein Ansatz wäre jetzt der, dass ich mir die URL hole und in der Tabelle s\_core\_rewrite\_urls schaue welchem subshop die angefragte URL gehört und entsprechend darauf reagiere. Gibt es da grundsätzlich einen anderen Weg? Wie ist&nbsp;Eure Vorgehensweise…

&nbsp;

Danke  
Markus

---

<div class="post-metadata">

**Author:** ![sschreier](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.shopware.com/sschreier/32/23296_2.png) [@sschreier](https://forum.shopware.com/u/sschreier)\
**Post date:** [30. Mai 2016 um 07:23 UTC](https://forum.shopware.com/t/eigenes-plugin-auf-bestimmte-subshops-einschranken/37058/2 "2016-05-30T07:23:34Z")

</div>

Hallo,

ich würde einfach ein Auswahlfeld / Selectfeld innerhalb der Plugin-Konfiguration erstellen, das beispielsweise als Beschreibung „Plugin aktiv“ und als Optionen „Ja“ und „Nein“ enthält. Diese Feld sollte dann natürlich noch als subshopfähig deklariert werden, sodass man das Plugin pro Subshop aktivieren kann.

In den Events kann man dann ja einfach prüfen, ob die Option auf Ja oder Nein steht - bei Nein kann man ja einfach ein **return** zurückgeben, damit das (angepasste) Event nicht (weiter) ausgeführt wird.

Beste Grüße

Sebastian

---

<div class="post-metadata">

**Author:** ![mtruebenbach](https://avatars.discourse-cdn.com/v4/letter/m/d9b06d/32.png) [@mtruebenbach](https://forum.shopware.com/u/mtruebenbach)\
**Post date:** [30. Mai 2016 um 15:33 UTC](https://forum.shopware.com/t/eigenes-plugin-auf-bestimmte-subshops-einschranken/37058/3 "2016-05-30T15:33:05Z")

</div>

Hallo,

so sollte es gehen.&nbsp;

class Shopware\_Plugins\_Frontend\_DeinPlugin\_Bootstrap extends Shopware\_Components\_Plugin\_Bootstrap  
{  
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;public function install()  
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;{  
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;$this-\>createForm();  
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;return TRUE;  
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;}

&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;private function createForm()  
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;{  
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;$form = $this-\>Form();  
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;$form-\>setElement(‚checkbox‘, ‚show‘, array(  
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;‚label‘ =\> ‚Plugin aktiv?‘,  
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;‚value‘ =\> false,  
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;‚scope‘ =\> \Shopware\Models\Config\Element::SCOPE\_SHOP  
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;));  
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;}

&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;public function onPostDispatchFrontend( Enlight\_Event\_EventArgs $oArgs )  
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;{  
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;$config = $this-\>Config();

&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;if (!$config-\>show) {  
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;return;  
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;}  
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;.  
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;.  
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;.  
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;.  
&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;}  
}
