# \[AttributeSystem - Gelöst\] Neues Attribute Feld hinzufügen

**URL:** <https://forum.shopware.com/t/attributesystem-gelost-neues-attribute-feld-hinzufugen/38094>\
**Category:** Programmierung\
**Created:** [11. Juli 2016 um 08:56 UTC](https://forum.shopware.com/t/attributesystem-gelost-neues-attribute-feld-hinzufugen/38094 "2016-07-11T08:56:46Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![\_Geloschter\_Benutze7](https://avatars.discourse-cdn.com/v4/letter/_/cdc98d/32.png) [@\_Geloschter\_Benutze7](https://forum.shopware.com/u/_Geloschter_Benutze7)\
**Post date:** [11. Juli 2016 um 08:56 UTC](https://forum.shopware.com/t/attributesystem-gelost-neues-attribute-feld-hinzufugen/38094/1 "2016-07-11T08:56:46Z")

</div>

Hallo,

ich versuche ein neues Feld über ein Plugin zu registrieren, aber es wird mir nicht angezeigt weder bei „Freitext-Verwaltung“ noch bei den Artikeln oder in der Datanbank. ’  
Mein Frage ist was fehlt noch oder ob man noch ein Event Subscriben muss.&nbsp;

Habe das nach diesen&nbsp;Guide geschrieben:&nbsp;[Attribute system](https://developers.shopware.com/developers-guide/attribute-system/)

&nbsp;

> public function install()  
> &nbsp; &nbsp; {  
> &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;$this-\>createAtrributeFields();  
> &nbsp; &nbsp; }
> 
> &nbsp;
> 
> /\*\*  
> &nbsp;&nbsp; &nbsp; \* Create new Attribute Field  
> &nbsp;&nbsp; &nbsp; \*/  
> &nbsp;&nbsp; &nbsp;protected function createAtrributeFields() {  
> &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;try {  
> &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;$service = $this-\>container-\>get(‚shopware\_attribute.crud\_service‘);
> 
> &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;$service-\>update(‚s\_articles\_attributes‘, ‚article\_custom\_id‘, ‚combobox‘, [  
> &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;‚label‘ =\> ‚Custom ID‘,  
> &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;‚supportText‘ =\> ‚Custom ID‘,  
> &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;‚helpText‘ =\> ‚Set custom ID‘,
> 
> &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//user has the opportunity to translate the attribute field for each shop  
> &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;‚translatable‘ =\> true,
> 
> &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//attribute will be displayed in the backend module  
> &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;‚displayInBackend‘ =\> true,
> 
> &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//in case of multi\_selection or single\_selection type, article entities can be selected,  
> &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;‚entity‘ =\> ‚Shopware\Models\Article\Article‘,
> 
> &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//numeric position for the backend view, sorted ascending  
> &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;‚position‘ =\> 5,
> 
> &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//user can modify the attribute in the free text field module  
> &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;‚custom‘ =\> true,
> 
> &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//in case of combo box type, defines the selectable values  
> &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;‚arrayStore‘ =\> [  
> &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;[‚key‘ =\> ‚1‘, ‚value‘ =\> ‚first value‘]  
> &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;],  
> &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;], ‚energy\_id‘, false);  
> &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;} catch (Exception $e) {  
> &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;return array(‚success‘ =\> false, ‚message‘ =\> &nbsp;$e-\>getMessage());  
> &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;}  
> &nbsp;&nbsp; &nbsp;}

Vielen Dank,  
Brian&nbsp;

---

<div class="post-metadata">

**Author:** ![Synonymous](https://avatars.discourse-cdn.com/v4/letter/s/57b2e6/32.png) [@Synonymous](https://forum.shopware.com/u/Synonymous)\
**Post date:** [11. Juli 2016 um 09:48 UTC](https://forum.shopware.com/t/attributesystem-gelost-neues-attribute-feld-hinzufugen/38094/2 "2016-07-11T09:48:47Z")

</div>

Hi,

Sieht an sich korrekt aus… Möglicherweise gibt es aber eine Exception die nicht gezeigt wird…  
Bist Du sicher, dass der try-Block ausgeführt wird?

---

<div class="post-metadata">

**Author:** ![\_Geloschter\_Benutze7](https://avatars.discourse-cdn.com/v4/letter/_/cdc98d/32.png) [@\_Geloschter\_Benutze7](https://forum.shopware.com/u/_Geloschter_Benutze7)\
**Post date:** [11. Juli 2016 um 09:57 UTC](https://forum.shopware.com/t/attributesystem-gelost-neues-attribute-feld-hinzufugen/38094/3 "2016-07-11T09:57:38Z")

</div>

Hi,&nbsp;

ja, weil alle anderen Methoden korrekt ausgeführt werden.&nbsp;  
Aber die Frage ist, warum keine Exception aufgerufen wird, obwohl es die erste Methode ist in der Install Mehtod und nichts bewirkt.&nbsp;

&nbsp;

---

<div class="post-metadata">

**Author:** ![Synonymous](https://avatars.discourse-cdn.com/v4/letter/s/57b2e6/32.png) [@Synonymous](https://forum.shopware.com/u/Synonymous)\
**Post date:** [11. Juli 2016 um 10:40 UTC](https://forum.shopware.com/t/attributesystem-gelost-neues-attribute-feld-hinzufugen/38094/4 "2016-07-11T10:40:59Z")

</div>

Also bei mir sieht das so aus - vielleicht hilft es Dir ja:

```
/**
     * Add customer attributes
     */
    private function customer() {

        // Get the service
        $attributeService = Shopware()->Container()->get('shopware_attribute.crud_service');

        // Price list number
        $attributeService->update('s_user_attributes', 'pname_pricelist_number', 'integer');

        // Creation date
        $attributeService->update('s_user_attributes', 'pname_created', 'datetime', [
                'label' => 'Customer created date',
                'translatable' => false,
                'displayInBackend' => true,
                'position' => 600
            ]
        );

        // Modification date
        $attributeService->update('s_user_attributes', 'pname_modified', 'datetime', [
                'label' => 'Customer modified date',
                'translatable' => false,
                'displayInBackend' => true,
                'position' => 700
            ]
        );

        // Rebuild attribute models
        $metaDataCache = Shopware()->Models()->getConfiguration()->getMetadataCacheImpl();
        $metaDataCache->deleteAll();

        Shopware()->Models()->generateAttributeModels(
            array('s_articles_attributes')
        );

    }

```

&nbsp;

---

<div class="post-metadata">

**Author:** ![\_Geloschter\_Benutze7](https://avatars.discourse-cdn.com/v4/letter/_/cdc98d/32.png) [@\_Geloschter\_Benutze7](https://forum.shopware.com/u/_Geloschter_Benutze7)\
**Post date:** [11. Juli 2016 um 11:12 UTC](https://forum.shopware.com/t/attributesystem-gelost-neues-attribute-feld-hinzufugen/38094/5 "2016-07-11T11:12:58Z")

</div>

// Rebuild attribute models $metaDataCache = Shopware()-\>Models()-\>getConfiguration()-\>getMetadataCacheImpl(); $metaDataCache-\>deleteAll(); Shopware()-\>Models()-\>generateAttributeModels( array(‘s\_articles\_attributes’) );

Vielen Dank, das hat mir gefehlt.
