# 503 Fehler bei Programmierung eines Plugins

**URL:** <https://forum.shopware.com/t/503-fehler-bei-programmierung-eines-plugins/58877>\
**Category:** Programmierung\
**Created:** [1. April 2019 um 17:18 UTC](https://forum.shopware.com/t/503-fehler-bei-programmierung-eines-plugins/58877 "2019-04-01T17:18:44Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![YvesHoenicke](https://avatars.discourse-cdn.com/v4/letter/y/bbe5ce/32.png) [@YvesHoenicke](https://forum.shopware.com/u/YvesHoenicke)\
**Post date:** [1. April 2019 um 17:18 UTC](https://forum.shopware.com/t/503-fehler-bei-programmierung-eines-plugins/58877/1 "2019-04-01T17:18:44Z")

</div>

Hallo,

ich bin dabei, ein Plugin für den Export und Import von Bestellungen mit automatischer Änderung des Bestellstatus und Emailversand&nbsp;bei Export und automatischen hinzufügen einer Trackingnummer und Emailversand beim Import.&nbsp;

Folgende Ordner- und Dateistruktur habe ich bisher angelegt:  
&nbsp;

[![](https://adobe.ly/2WGEClf)](https://adobe.ly/2WGEClf)

Folgende Codes habe ich bisher geschrieben:

**BigBellyWawi/BigBellyWawi.php**  
&nbsp;

**BigBellyWawi/plugin.xml**

```
    BigBelly Wawi
    BigBelly Wawi

    1.0.0
    (c) Yves Hönicke
    MIT
    
    Yves Hönicke
    

    
        Erstveröffentlichung
        First release

```

**BigBellyWawi//Controllers/Backend/BigBellyWawi.php**

**BigBellyWawi//Models/BigBellyWawi.php**

**BigBellyWawi//Resources/menu.xml**

```
            BigBellyWawi
            BigBellyBank Wawi
            BigBellyBank Wawi
            BigBellyWawi
            index
            sprite-metronome
            Customer

```

**BigBellyWawi//Resources/services.xml**

**BigBellyWawi//Resources/views/backend/big\_belly\_wawi/app.js**

```
Ext.define('Shopware.apps.BigBellyWawi', {
    extend: 'Enlight.app.SubApplication',
 
    name:'Shopware.apps.BigBellyWawi',
 
    loadPath: '{url action=load}',
    bulkLoad: true,
 
    controllers: ['Main'],
 
    views:['main.Window','main.Settings'],
    
    models: ['BigBellyWawi'],
 
    launch: function() {
        return this.getController('Main').mainWindow;
    }
});

```

**BigBellyWawi//Resources/views/backend/big\_belly\_wawi/controller/main.js**

```
Ext.define('Shopware.apps.BigBellyWawi.controller.Main', {
    extend: 'Enlight.app.Controller',
 
    init: function() {
        var me = this;
        me.mainWindow = me.getView('main.Window').create({ }).show();
    }
});

```

**BigBellyWawi//Resources/views/backend/big\_belly\_wawi/model/bigbellywawi.js**

```
Ext.define('Shopware.apps.BigBellyWawi.model.BigBellyWawi', {
    extend: 'Shopware.data.Model',
 
    configure: function() {
        return {
            controller: 'BigBellyWawi',
            detail: 'Shopware.apps.BigBellyWawi.view.detail.Container'
        };
    }
});

```

**BigBellyWawi//Resources/views/backend/big\_belly\_wawi/view/detail/container.js**

```
Ext.define('Shopware.apps.BigBellyWawi.view.detail.Container', {
    extend: 'Shopware.model.Container',
    padding: 20,
 
    configure: function() {
        return {
        };
    }
});

```

**BigBellyWawi//Resources/views/backend/big\_belly\_wawi/view/detail/window.js**

```
Ext.define('Shopware.apps.BigBellyWawi.view.detail.Window', {
    extend: 'Shopware.window.Detail',
 
    title : 'BigBelly Wawi',
    height: 420,
    width: 900
});

```

**BigBellyWawi//Subscribers/Wawi.php**

```
pluginDirectory = $pluginDirectory;
    }
    
    /**
     * {@inheritdoc}
     */
    
    public static function getSubscribedEvents()
	{
        
		return [
            
			'Enlight_Controller_Action_PostDispatch_Backend_Order' => 'onBackendOrderPostDispatch'
		];
	}
    
    
    
    public function onBackendOrderPostDispatch(\Enlight_Event_EventArgs $arguments)
    {
        $controller = $args->getSubject();

        $view = $controller->View();
        $request = $controller->Request();

        $view->addTemplateDir($this->pluginDirectory . '/Resources/views');

        if ($request->getActionName() == 'index') {
            $view->extendsTemplate('backend/big_belly_wawi/app.js');
        }

        if ($request->getActionName() == 'load') {
            $view->extendsTemplate('backend/big_belly_wawi/view/detail/window.js');
        }
        
    }
}

```

Der Menüpunkt wird angezeigt. Wenn ich nun das Ganze aufrufen will, erhalte ich folgende Fehlermeldung:

## Ups! Ein Fehler ist aufgetreten!

Die nachfolgenden Hinweise sollten Ihnen weiterhelfen.

### Unable to load template snippet ‘backend/big\_belly\_wawi/app.js’ in engine/Library/Smarty/sysplugins/smarty\_internal\_templatebase.php on line 127

### Stack trace:

```
#0 engine/Library/Enlight/View/Default.php(300): Smarty\_Internal\_TemplateBase-\>fetch()
 #1 engine/Library/Enlight/Controller/Plugins/ViewRenderer/Bootstrap.php(216): Enlight\_View\_Default-\>render(Object(Enlight\_Template\_Default))
 ... 

&nbsp;

Wo liegt genau der Fehler?&nbsp;

&nbsp;

&nbsp;
```

---

<div class="post-metadata">

**Author:** ![Patrick\_Stahl](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.shopware.com/patrick_stahl/32/7679_2.png) [@Patrick\_Stahl](https://forum.shopware.com/u/Patrick_Stahl)\
**Post date:** [2. April 2019 um 06:05 UTC](https://forum.shopware.com/t/503-fehler-bei-programmierung-eines-plugins/58877/2 "2019-04-02T06:05:16Z")

</div>

Moin @YvesHoenicke‍,

schau am Besten mal zuerst, ob der Pfad beim Aufruf von&nbsp; **addTemplateDir** &nbsp;passt.  
Also der hier:

```
$view->addTemplateDir($this->pluginDirectory . '/Resources/views');

```

So wie ich das sehe, übergibst du deinem Subscriber nämlich diesen Pfad für den Konstruktor garnicht, also das **$this-\>pluginDirectory** &nbsp;ist vermutlich leer.

Gruß,  
Patrick&nbsp; ![Shopware](https://europe1.discourse-cdn.com/flex013/uploads/shopware/original/1X/86c57fbace799dd4eb1f1b8a2d3bdc1733f0aea1.png "Shopware")

---

<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:** [2. April 2019 um 06:21 UTC](https://forum.shopware.com/t/503-fehler-bei-programmierung-eines-plugins/58877/3 "2019-04-02T06:21:24Z")

</div>

Das passt was nicht zusammen:

> \Enlight\_Event\_EventArgs $arguments

> $controller = $args-\>getSubject();

&nbsp;Und eventuell über Enlight\_Template\_Manager laden.

---

<div class="post-metadata">

**Author:** ![YvesHoenicke](https://avatars.discourse-cdn.com/v4/letter/y/bbe5ce/32.png) [@YvesHoenicke](https://forum.shopware.com/u/YvesHoenicke)\
**Post date:** [2. April 2019 um 16:41 UTC](https://forum.shopware.com/t/503-fehler-bei-programmierung-eines-plugins/58877/4 "2019-04-02T16:41:16Z")

</div>

[@Patrick Stahl]([http://forum.shopware.com/profile/1869/Patrick](http://forum.shopware.com/profile/1869/Patrick) Stahl “Patrick Stahl”)‍

Der Pfad stimmt soweit.

@R4M‍

Den Fehler habe ich korrigiert.

Habe die Datei&nbsp;

**BigBellyWawi//Subscribers/Wawi.php**

nochmal angepasst mit folgenden Code:

```
pluginDirectory = $pluginDirectory;
		$this->templateManager = $templateManager;
	}
    
    /**
     * {@inheritdoc}
     */
    
    public static function getSubscribedEvents()
	{
        
		return [
            
			'Enlight_Controller_Action_PostDispatch_Backend_Order' => 'onBackendOrderPostDispatch'
		];
	}
    
    
    
    public function onBackendOrderPostDispatch(\Enlight_Event_EventArgs $args)
    {
        $controller = $args->get('subject');

        $view = $controller->View();
        $request = $controller->Request();

        //$view->addTemplateDir($this->pluginDirectory . '/Resources/views/');
        
        $this->templateManager->addTemplateDir($this->pluginDirectory . '/Resources/views');

        if ($request->getActionName() == 'index') {
            $view->extendsTemplate('backend/big_belly_wawi/app.js');
        }

        if ($request->getActionName() == 'load') {
            $view->extendsTemplate('backend/big_belly_wawi/view/detail/window.js');
        }
        
    }

}

```

Dennoch erhalte ich weiterhin die oben genannte Fehlermeldung.

Irgendwie steht ich da grad aufm Schlauch und komme nicht weiter.

---

<div class="post-metadata">

**Author:** ![Patrick\_Stahl](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.shopware.com/patrick_stahl/32/7679_2.png) [@Patrick\_Stahl](https://forum.shopware.com/u/Patrick_Stahl)\
**Post date:** [3. April 2019 um 05:42 UTC](https://forum.shopware.com/t/503-fehler-bei-programmierung-eines-plugins/58877/5 "2019-04-03T05:42:43Z")

</div>

Hey @YvesHoenicke‍,

das klingt auf jeden Fall nach einem Fehler, den ich schnell ausmerzen könnte.  
Kannst du mir das Plugin irgendwo hochladen und dann den Link dazu zukommen lassen?

Ich würde mir das dann mal 5 Minuten lokal anschauen und debuggen. Das dürfte schnell erledigt sein. 🙂

Gruß,  
Patrick&nbsp; ![Shopware](https://forum.shopware.com/plugins/CKEditor/plugins/smiley/images/shopware.png "Shopware")

---

<div class="post-metadata">

**Author:** ![YvesHoenicke](https://avatars.discourse-cdn.com/v4/letter/y/bbe5ce/32.png) [@YvesHoenicke](https://forum.shopware.com/u/YvesHoenicke)\
**Post date:** [3. April 2019 um 05:52 UTC](https://forum.shopware.com/t/503-fehler-bei-programmierung-eines-plugins/58877/6 "2019-04-03T05:52:59Z")

</div>

Vielen Danke erstmal. Habe es als ZIP in meine Cloud gepackt.&nbsp;

[https://adobe.ly/2CJbwKb](https://adobe.ly/2CJbwKb)

Gruß

Yves

---

<div class="post-metadata">

**Author:** ![Patrick\_Stahl](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.shopware.com/patrick_stahl/32/7679_2.png) [@Patrick\_Stahl](https://forum.shopware.com/u/Patrick_Stahl)\
**Post date:** [3. April 2019 um 06:21 UTC](https://forum.shopware.com/t/503-fehler-bei-programmierung-eines-plugins/58877/7 "2019-04-03T06:21:03Z")

</div>

Moin @YvesHoenicke‍,

ich habe dein Plugin mal fix installiert und habe dabei die folgenden zwei Dinge festgestellt:

1. Den TemplateManager aus deinem Subscriber habe ich wieder entfernt - den hast du deinem Subscriber momentan eh nicht über den DI Container (services.xml) übergeben und das führte bereits zu einem Fehler
2. Du hängst dich über den Code an das&nbsp; **Bestellungs-Modul** &nbsp;- wenn du also die Bestellungen öffnest, gibt es&nbsp; **keine&nbsp;** Fehlermeldung, weil du dort alles richtig gemacht hast.  
Dieser Code wird&nbsp; **nur ausgeführt, wenn du das Bestellungs-Modul öffnest**.  
Nicht aber, wenn du dein eigenes Modul öffnest - es kommt weiterhin zu der Fehlermeldung.

Warum?  
Wenn du dein eigenes Modul öffnest, ist nie die Zeile “$view-\>addTemplateDir” ausgeführt worden - das wird ja nur beim Bestellungs-Modul ausgeführt!  
In kurz: Wenn du die folgenden Zeilen deinem Controller anfügst, läuft es bereits - zumindest dieser spezifische Fehler ist dann gelöst:

```
View()->addTemplateDir( __DIR__. '/../../Resources/views');
    }
}

```

Du bekommst dann aber eine Folge-Fehlermeldung, die aber begründet ist: Er versucht eine Datei zu laden, die nicht existiert.  
Aber ab hier kommst du bestimmt wieder selber weiter! 🙂

Gruß,  
Patrick&nbsp; ![Shopware](https://europe1.discourse-cdn.com/flex013/uploads/shopware/original/1X/86c57fbace799dd4eb1f1b8a2d3bdc1733f0aea1.png "Shopware")

---

<div class="post-metadata">

**Author:** ![YvesHoenicke](https://avatars.discourse-cdn.com/v4/letter/y/bbe5ce/32.png) [@YvesHoenicke](https://forum.shopware.com/u/YvesHoenicke)\
**Post date:** [4. April 2019 um 08:07 UTC](https://forum.shopware.com/t/503-fehler-bei-programmierung-eines-plugins/58877/8 "2019-04-04T08:07:32Z")

</div>

[@Patrick Stahl]([http://forum.shopware.com/profile/1869/Patrick](http://forum.shopware.com/profile/1869/Patrick) Stahl “Patrick Stahl”)‍

Hi Patrick,

vielen vielen Dank erst einmal. Dank deiner Hilfe bin ich nun ein ganzes Stück weitergekommen.&nbsp;

Ich konnte nun die Oberfläche wie gewünscht umsetzen. Allerdings funktionieren die Buttons nicht. Es wird kein Event gefeuert. Zum Testen hatte ich eine kleine Funktion geschrieben, um zu prüfen, ob die Buttons überhaupt irgendetwas machen. Leider ohne Erfolg.

Folgende Änderungen am Code habe ich vorgenommen:

BigBellyWawi//Controllers/Backend/BigBellyWawi.php

```
alert('$messageTest');";
    } 
}

```

BigBellyWawi//Resources/views/backend/big\_belly\_wawi/app.js

```
/**
 *
*/
//{namespace name="backend/big_belly_wawi/view/main"}
//{block name="backend/big_belly_wawi/application"}
Ext.define('Shopware.apps.BigBellyWawi', {
    extend: 'Enlight.app.SubApplication',
 
    name:'Shopware.apps.BigBellyWawi',
 
    loadPath: '{url action=load}',
    
    bulkLoad: true,
 
    controllers: ['Main'],
 
   // views:['main.Window'],
    
    views: [
        'main.Container',
        'main.Window',
        'main.Settings'
    ],
    
    models: ['BigBellyWawi'],
 
    launch: function() {
        return this.getController('Main').mainWindow;
    }
});
//{/block}

```

&nbsp;

BigBellyWawi//Resources/views/backend/big\_belly\_wawi/view/main/settings.js

```
//{namespace name="backend/diw_wawi/view/main"}
//{block name="backend/diw_wawi/view/main/settings"}
Ext.define('Shopware.apps.BigBellyWawi.view.main.Settings', {
 
    extend: 'Ext.form.Panel',
    
    title:'Exportieren von Bestellungen und Kunden',
    border: false,
    flex:1,
    region:'center',
    autoHeight:true,
    bodyPadding:5,
    fieldDefaults: {
        labelWidth: 95
    },
    defaultType: 'textfield',
    
    /**
     * Called when the component will be initialed.
     */
    initComponent: function() {
        var self = this;

        self.items = [{
            xtype:'fieldset',
            title:'Export',
            items:[{
                xtype: 'container',
                layout:'hbox',
                items:[{
                    xtype:'checkbox',
                    fieldLabel: 'E-Mail nicht versenden?',
                    id:'exportFirst',
                    width:'150',
                    labelStyle: 'width:150px;padding:0;'
                },{
                    xtype: 'button',
                    width:'150',
                    margin:'0 0 0 7',
                    text : 'Export (nur offen1)',
                    cls: 'secondary small',
                    iconCls: 'sprite-document-export',
                    handler:function(){
                        //var link = '{url controller="BigBellyWawi" action="doExportAllCsv"}';
                        var link = '{url controller="BigBellyWawi" action="buttonTest"}';
                        //link+="?filter_=only_open&send_email_notification="+Ext.getCmp('exportFirst').getValue();
                        
                        self.fireEvent('exportAction',link);
                        
                    }
                }
                ]
            },{
                xtype: 'container',
                layout:'hbox',
                margin:'10 0 0 0',
                items:[{
                    xtype:'checkbox',
                    fieldLabel: 'E-Mail nicht versenden?',
                    width:'150',
                    labelStyle: 'width:150px;padding:0;',
                    id:'exportSecond'
                },{
                    xtype: 'button',
                    width:'150',
                    margin:'0 0 0 7',
                    text : 'Export (exkl. offen)',
                    cls: 'secondary small',
                    iconCls: 'sprite-document-export',
                    handler:function(){
                        var link = '{url controller="BigBellyWawi" action="doExportAllCsv"}';
                        //var secondLink = '{url controller="BigBellyWawi" action="doExportOrderCustomerCsv"}';
                        link+="?filter_=only_not_open&send_email_notification="+Ext.getCmp('exportSecond').getValue();
                       
                        self.fireEvent('exportAction',link,Ext.getCmp('exportSecond').getValue());
                        
                    }
                }
                ]
            },{
                xtype: 'container',
                layout:'hbox',
                margin:'10 0 0 0',
                items:[{
                    xtype:'checkbox',
                    fieldLabel: 'E-Mail nicht versenden?',
                    width:'150',
                    labelStyle: 'width:150px;padding:0;',
                    id:'exportThird'
                }, {
                    xtype: 'button',
                    width:'150',
                    margin:'0 0 0 7',
                    text : 'Export (alle)',
                    cls: 'secondary small',
                    iconCls: 'sprite-document-export',
                    handler:function(){
                        var link = '{url controller="BigBellyWawi" action="doExportAllCsv"}';
                        
                        link+="?send_email_notification="+Ext.getCmp('exportThird').getValue();
                        
                        self.fireEvent('exportAction',link,Ext.getCmp('exportSecond').getValue());
                       
                    }
                }
                ]
            }]
        },{
            xtype:'fieldset',
            title:'Import',
            items:[
            self.createUploadForm()
            ]
        }];
        
        
        self.callParent(arguments);
    },
    createUploadForm:function(){
        var self = this;
        return Ext.create('Ext.form.Panel', {
            border:false,
            frame: false,
            layout:'hbox',
            bodyStyle: 'background-color:#f0f2f4;',
            id:'uploadForm',
            items: [{
                xtype: 'filefield',
                name: 'importFile',
                style:'background-color:none;',
                width:240,
                allowBlank: false,
                buttonText: 'Datei wählen',
                blankText: 'Das Feld darf nicht leer sein!',
                msgTarget:'qtip',
                listeners: {
                    'change': function(button, value){
                        if(value.length>0){
                            Ext.getCmp("uploadButton").enable();
                        }else{
                            Ext.getCmp("uploadButton").disable();
                        }
                    },
                    'blur':function(fileField){
                        if(!fileField.isValid()){
                            Ext.getCmp("uploadButton").disable();
                        }else{
                            Ext.getCmp("uploadButton").enable();
                        }
                    }
                }
            }, {
                xtype:'button',
                cls: 'secondary small',
                id:'uploadButton',
                text: 'hochladen',
                margin:'4 0 0 5',
                disabled:true,
                handler:function(){
                    self.fireEvent('uploadFile');
                }
            }]
        });
    }
    
   
});
//{/block}

```

Das Event zum Testen liegt auf Button mit Beschriftung&nbsp;‘Export (nur offen1)’.&nbsp;

Es werden keinerlei Fehlermeldungen angezeigt noch irgendetwas anderes.&nbsp;

Den gesamten Code habe ich zur Sicherheit nochmal in die Cloud unter [https://adobe.ly/2CJbwKb](https://adobe.ly/2CJbwKb) hochgeladen.

Gruß

Yves

---

<div class="post-metadata">

**Author:** ![Patrick\_Stahl](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.shopware.com/patrick_stahl/32/7679_2.png) [@Patrick\_Stahl](https://forum.shopware.com/u/Patrick_Stahl)\
**Post date:** [4. April 2019 um 09:15 UTC](https://forum.shopware.com/t/503-fehler-bei-programmierung-eines-plugins/58877/9 "2019-04-04T09:15:55Z")

</div>

Moin @YvesHoenicke‍,  
hier fallen mir spontan zwei Dinge auf.

1. Deine Controller Action ist private. Die muss aber public sein. 🙂
2. Ich glaube du verwechselst hier etwas. Die Methode ‘fireEvent’ macht nur genau das, was der Name andeutet - ein Event abfeuern. Das ist&nbsp; **kein Request gegen deine Action**.  
Du feuerst lediglich ein Event, auf dass irgendjemand horchen und reagieren muss.  
Das machst du normalerweise in einem Controller, so wie bspw. [hier](https://github.com/FriendsOfShopware/FroshDataTableLayout/blob/master/Resources/views/backend/frosh_data_table_layout/controller/main.js#L14).

Im Prinzip rufst du in der ‘init’&nbsp;Methode des Controllers die Methode ‘control’ auf.  
Dort ist die Syntax wiefolgt:  
&nbsp;

```
me.control({
    'alias-deiner-view-komponente button[action=addColumn]' : {
          'event-name': this.exampleMethod
     }
});

...

exampleMethod: function(parameterDieDuÜbergebenHast) {
   ...
   // Mach einen Ajax Request gegen deine Action
}

```

Nun müsstest du dich in der ’ exampleMethod’ darum kümmern, einen AJAX-Request gegen deine Action zu feuern.  
Wie du das in ExtJS machst, siehst du bspw. [hier](https://github.com/FriendsOfShopware/FroshDataTableLayout/blob/master/Resources/views/backend/frosh_data_table_layout/controller/main.js#L116).

Zum Debuggen könntest du aber auch einfach mal in deine Button-Handler Funktion ein&nbsp;_console.log(‘test’);_&nbsp;einbauen, um zu sehen, dass ein Klick auf den Button durchaus etwas antriggert.

Hilft dir das erstmal weiter?

Gruß,  
Patrick&nbsp; ![Shopware](https://europe1.discourse-cdn.com/flex013/uploads/shopware/original/1X/86c57fbace799dd4eb1f1b8a2d3bdc1733f0aea1.png "Shopware")

---

<div class="post-metadata">

**Author:** ![ST\_DP](https://avatars.discourse-cdn.com/v4/letter/s/3d9bf3/32.png) [@ST\_DP](https://forum.shopware.com/u/ST_DP)\
**Post date:** [8. April 2019 um 21:30 UTC](https://forum.shopware.com/t/503-fehler-bei-programmierung-eines-plugins/58877/10 "2019-04-08T21:30:15Z")

</div>

Hello friends, please tell me how can I add a menu item in the frontend using a plugin?

---

<div class="post-metadata">

**Author:** ![YvesHoenicke](https://avatars.discourse-cdn.com/v4/letter/y/bbe5ce/32.png) [@YvesHoenicke](https://forum.shopware.com/u/YvesHoenicke)\
**Post date:** [10. April 2019 um 08:35 UTC](https://forum.shopware.com/t/503-fehler-bei-programmierung-eines-plugins/58877/11 "2019-04-10T08:35:41Z")

</div>

Hi [@Patrick Stahl]([http://forum.shopware.com/profile/1869/Patrick](http://forum.shopware.com/profile/1869/Patrick) Stahl “Patrick Stahl”)‍,

ich hab jetzt nochmal einiges&nbsp;geändert. Die Funktion hab ich&nbsp;in der control gesetzt und später auch beschrieben. Nun wird mir ein 503 Fehler angezeigt, dass er ein Template Snippet nicht laden kann. Das verwirrt mich allerdings total, da nirgends im Code nach einem Template verlangt wird.

Anbei dir Codes:

BigBellyWawi//Controllers/Backend/BigBellyWawi.php

```
View()->addTemplateDir( __DIR__. '/../../Resources/views');
    }
    
    public function doExportAllCsvAction() {
        $connection = $this->container->get('dbal_connection');
        
        $subshopData ='SELECT name FROM s_core_shops WHERE id=1';
        
        $subshopDataResult = $connection->query($subshopData)->fetch();
        
        echo $subshopDataResult['name'];
        //echo "console.log( 'Debug Objects: " . $subshopDataResult['name'] . "' );";
    }
    
}

```

&nbsp;

BigBellyWawi//Resources/views/backend/big\_belly\_wawi/controller/main.js

```
/**
 *
*/
//{namespace name="backend/big_belly_wawi/view/main"}
//{block name="backend/big_belly_wawi/controller/main"}
Ext.define('Shopware.apps.BigBellyWawi.controller.Main', {
    
    extend: 'Enlight.app.Controller',
    refs: [{
        ref:'uploadForm',
        selector: '#uploadForm'
    }
    ],
    
    init:function () {
        var me = this;
        me.mainWindow = me.getView('main.Window').create({ }).show();
        
        me.control({
            'bigbelly-main-settings-form': {
                exportAction : me.onExport
                
            }
        });
    },
    
    /**
     * Iframe erzeugen und Controller aufrufen
     * @param link
     */
    onExport:function(link){
        try {
            Ext.destroy(Ext.get('downloadIframe'));
        }
        catch(e) {}
        
        //DOWNLOAD IFRAME starten
        var iframe = Ext.DomHelper.append(document.body, {
            tag: 'iframe',
            id:'downloadIframe',
            frameBorder: 0,
            width: 200,
            height: 100,
            src: link
        });  
    },
});
    //{/block}

```

BigBellyWawi//Resources/views/backend/big\_belly\_wawi/view/main/settings.js

```
//{namespace name="backend/big_belly_wawi_wawi/view/main"}
//{block name="backend/big_belly_wawi/view/main/settings"}
Ext.define('Shopware.apps.BigBellyWawi.view.main.Settings', {
 
    extend: 'Ext.form.Panel',
    
    title:'Exportieren von Bestellungen und Kunden',
    border: false,
    flex:1,
    region:'center',
    autoHeight:true,
    bodyPadding:5,
    fieldDefaults: {
        labelWidth: 95
    },
    defaultType: 'textfield',
    
    cls:Ext.baseCSSPrefix + 'bigbelly-main-settings-form',
    
    alias:'widget.bigbelly-main-settings-form',
    
    /**
     * Called when the component will be initialed.
     */
    initComponent: function() {
        var me = this;

        me.items = [{
            xtype:'fieldset',
            title:'Export',
            items:[{
                xtype: 'container',
                layout:'hbox',
                items:[{
                    xtype:'checkbox',
                    fieldLabel: 'E-Mail nicht versenden?',
                    id:'exportFirst',
                    width:'150',
                    labelStyle: 'width:150px;padding:0;'
                },{
                    xtype: 'button',
                    width:'150',
                    margin:'0 0 0 7',
                    text : 'Export (nur offen1)',
                    cls: 'secondary small',
                    iconCls: 'sprite-document-export',
                    handler:function(){
                        var link = '{url controller="BigBellyWawi" action="doExportAllCsv"}';
                        
                        me.fireEvent('exportAction',link);
                       
                    }
                }
                ]
            },{
                xtype: 'container',
                layout:'hbox',
                margin:'10 0 0 0',
                items:[{
                    xtype:'checkbox',
                    fieldLabel: 'E-Mail nicht versenden?',
                    width:'150',
                    labelStyle: 'width:150px;padding:0;',
                    id:'exportSecond'
                },{
                    xtype: 'button',
                    width:'150',
                    margin:'0 0 0 7',
                    text : 'Export (exkl. offen)',
                    cls: 'secondary small',
                    iconCls: 'sprite-document-export',
                    handler:function(){
                        var link = '{url controller="BigBellyWawi" action="doExportAllCsv"}';
                        //var secondLink = '{url controller="BigBellyWawi" action="doExportOrderCustomerCsv"}';
                        link+="?filter_=only_not_open&send_email_notification="+Ext.getCmp('exportSecond').getValue();
                       
                        me.fireEvent('exportAction',link,Ext.getCmp('exportSecond').getValue());
                        
                    }
                }
                ]
            },{
                xtype: 'container',
                layout:'hbox',
                margin:'10 0 0 0',
                items:[{
                    xtype:'checkbox',
                    fieldLabel: 'E-Mail nicht versenden?',
                    width:'150',
                    labelStyle: 'width:150px;padding:0;',
                    id:'exportThird'
                }, {
                    xtype: 'button',
                    width:'150',
                    margin:'0 0 0 7',
                    text : 'Export (alle)',
                    cls: 'secondary small',
                    iconCls: 'sprite-document-export',
                    handler:function(){
                        var link = '{url controller="BigBellyWawi" action="doExportAllCsv"}';
                        
                        link+="?send_email_notification="+Ext.getCmp('exportThird').getValue();
                        
                        me.fireEvent('exportAction',link,Ext.getCmp('exportSecond').getValue());
                       
                    }
                }
                ]
            }]
        },{
            xtype:'fieldset',
            title:'Import',
            items:[
            me.createUploadForm()
            ]
        }];
        
        
        me.callParent(arguments);
    },
    createUploadForm:function(){
        var me = this;
        return Ext.create('Ext.form.Panel', {
            border:false,
            frame: false,
            layout:'hbox',
            bodyStyle: 'background-color:#f0f2f4;',
            id:'uploadForm',
            items: [{
                xtype: 'filefield',
                name: 'importFile',
                style:'background-color:none;',
                width:240,
                allowBlank: false,
                buttonText: 'Datei wählen',
                blankText: 'Das Feld darf nicht leer sein!',
                msgTarget:'qtip',
                listeners: {
                    'change': function(button, value){
                        if(value.length>0){
                            Ext.getCmp("uploadButton").enable();
                        }else{
                            Ext.getCmp("uploadButton").disable();
                        }
                    },
                    'blur':function(fileField){
                        if(!fileField.isValid()){
                            Ext.getCmp("uploadButton").disable();
                        }else{
                            Ext.getCmp("uploadButton").enable();
                        }
                    }
                }
            }, {
                xtype:'button',
                cls: 'secondary small',
                id:'uploadButton',
                text: 'hochladen',
                margin:'4 0 0 5',
                disabled:true,
                handler:function(){
                    me.fireEvent('uploadFile');
                }
            }]
        });
    }
    
   
});
//{/block}

```

Selbst wenn ich die Abfrage in ein console.log setzen würde, verlangt er immer nach dieser tpl Datei.&nbsp;

Gruß

Yves

---

<div class="post-metadata">

**Author:** ![YvesHoenicke](https://avatars.discourse-cdn.com/v4/letter/y/bbe5ce/32.png) [@YvesHoenicke](https://forum.shopware.com/u/YvesHoenicke)\
**Post date:** [10. April 2019 um 08:36 UTC](https://forum.shopware.com/t/503-fehler-bei-programmierung-eines-plugins/58877/12 "2019-04-10T08:36:07Z")

</div>

Und hier die Fehlermeldung:

```
SmartyException: Unable to load template snippet 'backend/big_belly_wawi/do_export_all_csv.tpl' in /engine/Library/Smarty/sysplugins/smarty_internal_templatebase.php:127 Stack trace:
#0 /engine/Library/Enlight/View/Default.php(300): Smarty_Internal_TemplateBase->fetch()
#1 /engine/Library/Enlight/Controller/Plugins/ViewRenderer/Bootstrap.php(216): Enlight_View_Default->render(Object(Enlight_Template_Default))
#2 /engine/Library/Enlight/Controller/Plugins/ViewRenderer/Bootstrap.php(242): Enlight_Controller_Plugins_ViewRenderer_Bootstrap->renderTemplate(Object(Enlight_Template_Default))
#3 /engine/Library/Enlight/Controller/Plugins/ViewRenderer/Bootstrap.php(136): Enlight_Controller_Plugins_ViewRenderer_Bootstrap->render()
#4 /engine/Library/Enlight/Event/Handler/Default.php(91): Enlight_Controller_Plugins_ViewRenderer_Bootstrap->onPostDispatch(Object(Enlight_Controller_ActionEventArgs))
#5 /engine/Library/Enlight/Event/EventManager.php(220): Enlight_Event_Handler_Default->execute(Object(Enlight_Controller_ActionEventArgs))
#6 /engine/Library/Enlight/Controller/Action.php(235): Enlight_Event_EventManager->notify('Enlight_Control...', Object(Enlight_Controller_ActionEventArgs))
#7 /engine/Library/Enlight/Controller/Dispatcher/Default.php(549): Enlight_Controller_Action->dispatch('doExportAllCsvA...')
#8 /engine/Library/Enlight/Controller/Front.php(222): Enlight_Controller_Dispatcher_Default->dispatch(Object(Enlight_Controller_Request_RequestHttp), Object(Enlight_Controller_Response_ResponseHttp))
#9 /engine/Shopware/Kernel.php(202): Enlight_Controller_Front->dispatch()
#10 /vendor/symfony/http-kernel/HttpCache/SubRequestHandler.php(102): Shopware\Kernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#11 /vendor/symfony/http-kernel/HttpCache/HttpCache.php(448): Symfony\Component\HttpKernel\HttpCache\SubRequestHandler::handle(Object(Shopware\Kernel), Object(Symfony\Component\HttpFoundation\Request), 1, true)
#12 /engine/Shopware/Components/HttpCache/AppCache.php(268): Symfony\Component\HttpKernel\HttpCache\HttpCache->forward(Object(Symfony\Component\HttpFoundation\Request), true, NULL)
#13 /vendor/symfony/http-kernel/HttpCache/HttpCache.php(238): Shopware\Components\HttpCache\AppCache->forward(Object(Symfony\Component\HttpFoundation\Request), true)
#14 /engine/Shopware/Components/HttpCache/AppCache.php(105): Symfony\Component\HttpKernel\HttpCache\HttpCache->pass(Object(Symfony\Component\HttpFoundation\Request), true)
#15 /Applications/MAMP/htdocs/bigbally/shopware.php(122): Shopware\Components\HttpCache\AppCache->handle(Object(Symfony\Component\HttpFoundation\Request))
#16 {main}

```

&nbsp;

---

<div class="post-metadata">

**Author:** ![Patrick\_Stahl](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.shopware.com/patrick_stahl/32/7679_2.png) [@Patrick\_Stahl](https://forum.shopware.com/u/Patrick_Stahl)\
**Post date:** [10. April 2019 um 12:51 UTC](https://forum.shopware.com/t/503-fehler-bei-programmierung-eines-plugins/58877/13 "2019-04-10T12:51:02Z")

</div>

Moin @YvesHoenicke‍,

jede Controller Action erwartet im Standard ein geichnamiges Template - das wird in unseren Backend-Controllern nur deswegen nicht gemacht, weil das in der „preDispatch“-Methode ausgeschlossen wird.

Leider überschreibst du diese Methode mit denem Controller.  
Füg’ deiner preDispatch-Methode mal den parent Call hinzu, also:&nbsp;_parent::preDispatch();_

Dann dürfte das schon einwandfrei funktionieren.

P.S.: Auskommentieren funktioniert nicht, weil die Backend JS Dateien durch den Smarty Parser laufen, bevor sie ausgeliefert werden.  
Der Aufruf von&nbsp;\_{url …}&nbsp;\_ist ja Smarty Code - der wird also so oder so ausgeführt, weil es eben nicht erst im Javascript Code, sondern schon deutlich geparsed wird.  
Ich hoffe, das war einigermaßen verständlich…

Gruß,  
Patrick&nbsp; ![Shopware](https://forum.shopware.com/plugins/CKEditor/plugins/smiley/images/shopware.png "Shopware")
