# Eigenes Feld in der categorie Ansicht

**URL:** <https://forum.shopware.com/t/eigenes-feld-in-der-categorie-ansicht/41751>\
**Category:** International (English Only)\
**Tags:** programming\
**Created:** [27. November 2016 um 12:42 UTC](https://forum.shopware.com/t/eigenes-feld-in-der-categorie-ansicht/41751 "2016-11-27T12:42:32Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sign\_Sinn](https://avatars.discourse-cdn.com/v4/letter/s/45deac/32.png) [@Sign\_Sinn](https://forum.shopware.com/u/Sign_Sinn)\
**Post date:** [27. November 2016 um 12:42 UTC](https://forum.shopware.com/t/eigenes-feld-in-der-categorie-ansicht/41751/1 "2016-11-27T12:42:32Z")

</div>

Hallo zusammen,  
ich möchte in der Kategorieansicht das Backend um eine Variable Erweitern.  
Leider bekomme ich das nicht so hin wie ich das gerne hätte

Im FirePhp bekomme ich bei der URL Folgender Fehlermeldung  
URL/backend/AttributeData/loadData  
TypeError: form.attributes is undefined

Hier is meine Quellcode,  
hat einer eine Idee was ich falsch mache.

[//Bootstrap.php](https://Bootstrap.php)  
class Shopware\_Plugins\_frontend\_sisiListViewSlider\_Bootstrap extends Shopware\_Components\_Plugin\_Bootstrap

{  
&nbsp; &nbsp; public function getInfo()  
&nbsp; &nbsp; {  
&nbsp; &nbsp; &nbsp; &nbsp; return array(  
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ‘autor’ =\> ‘Sign&Sinn’,  
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ‘version’ =\> $this-\>getVersion(),  
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ‘label’ =\> $this-\>getLabel(),  
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ‘link’ =\> ‘[http://signundsinn.de](http://signundsinn.de)’,  
&nbsp; &nbsp; &nbsp; &nbsp; );  
&nbsp; &nbsp; }

&nbsp; &nbsp; public function getLabel()  
&nbsp; &nbsp; {  
&nbsp; &nbsp; &nbsp; &nbsp; return ‘SiSi Test’;  
&nbsp; &nbsp; }

&nbsp; &nbsp; public function getVersion()  
&nbsp; &nbsp; {  
&nbsp; &nbsp; &nbsp; &nbsp; return “1.0.0”;  
&nbsp; &nbsp; }

&nbsp; &nbsp; /\*\*  
&nbsp; &nbsp; &nbsp;\* @return \Shopware\Components\Model\ModelManager  
&nbsp; &nbsp; &nbsp;\*/  
&nbsp; &nbsp; protected function getEntityManager()  
&nbsp; &nbsp; {  
&nbsp; &nbsp; &nbsp; &nbsp; return Shopware()-\>Models();  
&nbsp; &nbsp; }

&nbsp; &nbsp; public function install()  
&nbsp; &nbsp; {

&nbsp; &nbsp; &nbsp; &nbsp; try {

&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $this-\>subscribeEvents();  
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $this-\>createAttributes();  
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // &nbsp;$this-\>createMainAttributes();

&nbsp; &nbsp; &nbsp; &nbsp; } catch (Exception $e) {  
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return array(  
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ‘success’ =\> false,  
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ‘message’ =\> $e-\>getMessage()  
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; );  
&nbsp; &nbsp; &nbsp; &nbsp; }

&nbsp; &nbsp; &nbsp; &nbsp; return true;  
&nbsp; &nbsp; }

&nbsp; &nbsp; private function subscribeEvents(){

&nbsp;

&nbsp; &nbsp; &nbsp; &nbsp; $this-\>subscribeEvent(  
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ‘Enlight\_Controller\_Action\_PostDispatchSecure\_Backend\_Category’,  
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ‘onCategoryPostDispatch’  
&nbsp; &nbsp; &nbsp; &nbsp; );

&nbsp; &nbsp; }

&nbsp; &nbsp; /\*\*  
&nbsp; &nbsp; &nbsp;\* create additional attributes in s\_user\_attributes and re-generate attribute models  
&nbsp; &nbsp; &nbsp;\*/  
&nbsp; &nbsp; private function createAttributes()  
&nbsp; &nbsp; {

&nbsp; &nbsp; &nbsp; &nbsp; $this-\>Application()-\>Models()-\>addAttribute(  
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ‘s\_categories\_attributes’,  
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ‘sisi’,  
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ‘start’,  
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ‘varchar(255)’,  
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; true,  
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; NULL  
&nbsp; &nbsp; &nbsp; &nbsp; );

&nbsp;

&nbsp; &nbsp; &nbsp; &nbsp; $this-\>getEntityManager()-\>generateAttributeModels(array(  
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ‘s\_categories\_attributes’  
&nbsp; &nbsp; &nbsp; &nbsp; ));

&nbsp; &nbsp; &nbsp; &nbsp; $metaDataCache &nbsp;= Shopware()-\>Models()-\>getConfiguration()-\>getMetadataCacheImpl();  
&nbsp; &nbsp; &nbsp; &nbsp; $metaDataCache-\>deleteAll();  
&nbsp; &nbsp; }

&nbsp;

&nbsp;

&nbsp; &nbsp; public function uninstall()  
&nbsp; &nbsp; {  
&nbsp; &nbsp; &nbsp; &nbsp; return true;  
&nbsp; &nbsp; }

&nbsp; &nbsp; public function onCategoryPostDispatch(Enlight\_Event\_EventArgs $args)  
&nbsp; &nbsp; {

&nbsp; &nbsp; &nbsp; &nbsp; /\*\*@var $view Enlight\_View\_Default \*/  
&nbsp; &nbsp; &nbsp; &nbsp; $view = $args-\>getSubject()-\>View();  
&nbsp; &nbsp; &nbsp; &nbsp; /\*\* @var \Enlight\_Controller\_Action $controller \*/

&nbsp; &nbsp; &nbsp; &nbsp; $controller = $args-\>getSubject();  
&nbsp; &nbsp; &nbsp; &nbsp; $view = $controller-\>View();  
&nbsp; &nbsp; &nbsp; &nbsp; $request = $controller-\>Request();

&nbsp; &nbsp; &nbsp; &nbsp; // Add template directory  
&nbsp; &nbsp; &nbsp; &nbsp; $args-\>getSubject()-\>View()-\>addTemplateDir(\_\_DIR\_\_ . ‘/Views/’);

&nbsp;

&nbsp; &nbsp; &nbsp; &nbsp; if ($request-\>getActionName() == ‘load’) {

&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $view-\>extendsTemplate(‘backend/category/view/sisi\_list\_slider/tabs/settings.js’);

&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;$view-\>extendsTemplate(‘backend/category/model/sisi\_list\_slider/detail.js’);

&nbsp; &nbsp; &nbsp; &nbsp; }  
&nbsp; &nbsp; }  
}

//Model

// {block name=“backend/base/model/category/fields” append}

{ name:‘sisi\_start’, &nbsp;type: ‘string’, useNull:true, defaultValue: null },

//{/block}

&nbsp;

// View

Ext.define(‘Shopware.apps.Category.view.sisiListSlider.tabs.Settings’, {  
&nbsp; &nbsp; override:‘Shopware.apps.Category.view.category.tabs.Settings’,

&nbsp; &nbsp; /\*\*  
&nbsp; &nbsp; &nbsp;\* This extjs override will call the original method first  
&nbsp; &nbsp; &nbsp;\* and then change the xtype of the 3rd field  
&nbsp; &nbsp; &nbsp;\*/  
&nbsp; &nbsp; getDefaultSettingItems: function() {  
&nbsp; &nbsp; &nbsp; &nbsp; var me = this,

&nbsp; &nbsp; &nbsp; &nbsp; result = me.callParent(arguments);

&nbsp; &nbsp; &nbsp; &nbsp; result[result.length+1]= &nbsp; &nbsp; {  
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; xtype:‘textfield’,  
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fieldLabel:‘List Slider Aktiv hurra’,  
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; name:‘attribute[sisi\_start]’,  
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; dataIndex:‘attribute[sisi\_start]’,

&nbsp; &nbsp; &nbsp; &nbsp; };

&nbsp;

&nbsp; &nbsp; &nbsp; &nbsp; return result;  
&nbsp; &nbsp; }  
});
