# Core Backend Component ExtJS erweitern/anpassen funktioniert nicht

**URL:** <https://forum.shopware.com/t/core-backend-component-extjs-erweitern-anpassen-funktioniert-nicht/88706>\
**Category:** Programmierung\
**Created:** [30. Juni 2021 um 10:56 UTC](https://forum.shopware.com/t/core-backend-component-extjs-erweitern-anpassen-funktioniert-nicht/88706 "2021-06-30T10:56:12Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kappa](https://avatars.discourse-cdn.com/v4/letter/k/50afbb/32.png) [@Kappa](https://forum.shopware.com/u/Kappa)\
**Post date:** [30. Juni 2021 um 10:56 UTC](https://forum.shopware.com/t/core-backend-component-extjs-erweitern-anpassen-funktioniert-nicht/88706/1 "2021-06-30T10:56:12Z")

</div>

Hi zusammen,

ich versuche seit gestern eine SW Core Backend Component anzupassen. Es handelt sich dabei um die Länder Componente unter Grundeinstellungen/Shopeinstellungen. Leider wird meine country.js nicht geladen und ich bin mittlerweile am verzweifeln. Ich habe dazu ein neues Plugin erstellt.

In meiner Plugin Class habe ich folgendes:

```auto
<?php

namespace MaCoBackendExtended;

use Shopware\Components\Plugin;

class MaCoBackendExtended extends Plugin{

    /**
     * @return array|string[]
     */
    public static function getSubscribedEvents()
    {
        return [
            'Enlight_Controller_Action_PostDispatchSecure_Backend_Config' => 'extendConfigCountry'
        ];
    }

    /**
     * @param \Enlight_Controller_ActionEventArgs $args
     */
    public function extendConfigCountry(\Enlight_Controller_ActionEventArgs $args){

        $request = $args->getSubject()->Request();

        $view = $args->getSubject()->View();

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

        if($request->getActionName() === 'load'){
            $view->extendsTemplate('backend/config/view/form/country.js');
        }
    }
}

```

Das scheint hier auch alles zu funktionieren - wenn ich zb ein dd(„test“); direkt über $view-\>extendsTemplate setze, erhalte ich einen Fehler im Backend, sobald ich die Länder aufrufen will.

Meine country.js

```auto
//{namespace name=backend/config/view/form}
//{block name="backend/config/view/form/country"}
Ext.define('Shopware.apps.MaCoBackendExtended.view.form.Country', {
    override: 'Shopware.apps.Config.view.form.Country',

    getFormItems: function() {
        const me = this;
        me.callParent(arguments);

        return [{
            name: 'name',
            fieldLabel: '{s name=country/detail/name_label}Name{/s}',
            translatable: true,
            allowBlank: false
        },{
            name: 'isoName',
            fieldLabel: '{s name=country/detail/iso_name_label}International name{/s}'
        },{
            xtype: 'config-element-boolean',
            name: 'active',
            translatable: true,
            fieldLabel: '{s name=country/detail/active_label}Active{/s}'
        },{
            xtype: 'config-element-boolean',
            name: 'allowShipping',
            translatable: true,
            translationName: 'allow_shipping',
            fieldLabel: '{s name=country/detail/allow_shipping}Allow the usage as shipping country{/s}'
        },{
            xtype: 'config-element-select',
            name: 'areaId',
            fieldLabel: '{s name=country/detail/area_label}Area{/s}',
            store: 'base.CountryArea'
        },{
            name: 'iso',
            fieldLabel: '{s name=country/detail/iso_label}Short code{/s}'
        },{
            name: 'iso3',
            fieldLabel: '{s name=country/detail/iso_three_label}Short code (three-letter){/s}'
        },{
            xtype: 'config-element-number',
            name: 'position',
            translatable: true,
            fieldLabel: '{s name=country/detail/position_label}Position{/s}123',
            helpText: '{s name=country/detail/position_help}Position in select fields.{/s}'
        },{
            xtype: 'config-element-textarea',
            name: 'description',
            fieldLabel: '{s name=country/detail/description_label}Description{/s}',
            translatable: true,
            helpText: '{s name=country/detail/description_help}Notices to display in frontend.{/s}'
        },{
            xtype: 'config-element-boolean',
            name: 'taxFree',
            fieldLabel: '{s name=country/detail/tax_free_label}Tax free{/s}',
            helpText: '{s name=country/detail/tax_free_help}If true disable tax rules for this country.{/s}'
        },{
            xtype: 'config-element-boolean',
            name: 'taxFreeUstId',
            fieldLabel: '{s name=country/detail/tax_free_company_label}Tax free for companies{/s}',
            helpText: '{s name=country/detail/tax_free_company_help}If user entered a vat id disable tax.{/s}'
        },{
            xtype: 'config-element-boolean',
            name: 'displayStateInRegistration',
            fieldLabel: '{s name=country/detail/display_state_label}Display state selection{/s}',
            helpText: '{s name=country/detail/display_state_help}Display state selection in registration process{/s}'
        },{
            xtype: 'config-element-boolean',
            name: 'forceStateInRegistration',
            fieldLabel: '{s name=country/detail/required_state_label}Force state selection{/s}',
            helpText: '{s name=country/detail/required_state_help}Force state selection in registration process{/s}'
        },
            me.getStateGrid()]
    }
});
//{/block}

```

Egal was ich in der country.js anstelle, es passiert nichts und ich habe absolut keine Idee mehr, woran es liegen könnte.

Hier noch meine Ordnerstruktur:  
 ![image](https://europe1.discourse-cdn.com/flex013/uploads/shopware/original/2X/9/9859ce517a24c41f236664261a6de617b384455a.png)

Kann mir da jemand weiterhelfen?

Danke und viele Grüße  
Jochen

---

<div class="post-metadata">

**Author:** ![Kappa](https://avatars.discourse-cdn.com/v4/letter/k/50afbb/32.png) [@Kappa](https://forum.shopware.com/u/Kappa)\
**Post date:** [30. Juni 2021 um 14:18 UTC](https://forum.shopware.com/t/core-backend-component-extjs-erweitern-anpassen-funktioniert-nicht/88706/2 "2021-06-30T14:18:39Z")

</div>

Hallo nochmal,

ich habe mittlerweile ein paar Anpassungen vorgenommen:

Ich habe die Plugin Klasse geleert und die Registrierung des neuen Template Ordners und des Templates in eine neue Subscriber Klasse gepackt, die ich über die services.xml aufrufe.

services.xml

```auto
<?xml version="1.0" ?>

<container xmlns="http://symfony.com/schema/dic/services"
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">

    <services>
        <service id="ma_co_backend_extended.subscriber.templates" class="MaCoBackendExtended\Subscriber\MaCoExtendCountry">
            <argument>%ma_co_backend_extended.plugin_dir%</argument>
            <tag name="shopware.event_subscriber"/>
        </service>
    </services>
</container>

```

Der neue Subscriber:

```auto
<?php

namespace MaCoBackendExtended\Subscriber;

use Enlight\Event\SubscriberInterface;
use Enlight_Controller_ActionEventArgs;
use Enlight_Event_EventArgs;

class MaCoExtendCountry implements SubscriberInterface
{

    /**
     * @var string
     */
    private $pluginDirectory;

    /**
     * @param $pluginDirectory
     */
    public function __construct($pluginDirectory)
    {
        $this->pluginDirectory = $pluginDirectory;
    }
    /**
     * {@inheritdoc}
     */
    public static function getSubscribedEvents()
    {
        return [
            'Enlight_Controller_Action_PostDispatchSecure_Backend_Config' => 'extendConfigCountry'
        ];
    }

    public function extendConfigCountry(Enlight_Event_EventArgs $args)
    {
        $controller = $args->getSubject();

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

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

        if ($request->getActionName() == 'load') {
            $view->extendsTemplate('backend/ma_co_backend_extended/config/view/form/country.js');
        }
    }
}

```

Und ich habe in der Ordnerstruktur den config Ordner noch zusätzlich in einen neuen Ordner gesetzt, der meinen Namespace darstellt:  
 ![image](https://europe1.discourse-cdn.com/flex013/uploads/shopware/original/2X/9/99ff3bcf73bb13289d3354aef991afe8cbe22a3b.png)

Wenn ich nun versuche die Länger Config im backend aufzurufen, erhalte ich folgende Fehlermeldung in der Console:

```auto
base?file=bootstrap&loggedIn=1625062213:861 Uncaught TypeError: Cannot read property 'prototype' of null
    at i.getView (base?file=bootstrap&loggedIn=1625062213:861)
    at i.getView (base?file=bootstrap&loggedIn=1625062213:941)
    at i.getFormCountryView (ext-all.js?201912171122:21)
    at i.createGetters (ext-all.js?201912171122:21)
    at i.constructor (ext-all.js?201912171122:21)
    at new i (ext-all.js?201912171122:21)
    at eval (eval at getInstantiator (ext-all.js?201912171122:21), <anonymous>:3:8)
    at Object.Manager.instantiate (base?file=bootstrap&loggedIn=1625062213:3734)
    at Object.create (ext-all.js?201912171122:21)
    at i.addController (base?file=bootstrap&loggedIn=1625062213:738)

```

Was könnte fehlen? Ich bin echt ratlos…
