# Adminpanel Listing mit ManyToMany Column

**URL:** <https://forum.shopware.com/t/adminpanel-listing-mit-manytomany-column/65713>\
**Category:** Programmierung\
**Created:** [24. März 2020 um 11:37 UTC](https://forum.shopware.com/t/adminpanel-listing-mit-manytomany-column/65713 "2020-03-24T11:37:57Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![AlexGalax](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.shopware.com/alexgalax/32/9925_2.png) [@AlexGalax](https://forum.shopware.com/u/AlexGalax)\
**Post date:** [24. März 2020 um 11:37 UTC](https://forum.shopware.com/t/adminpanel-listing-mit-manytomany-column/65713/1 "2020-03-24T11:37:57Z")

</div>

Hallo zusammen,

ich habe ein Backendmodul, das eine eigene Entity mit normalen Feldern und einer `ManyToManyAssociation` zu products hat. List, create und update funktioniert.

Jetzt würde ich gerne das Feld `products` aus ausgeben. Wie muss ich das rendern?

```
import template from './kk-qanda-list.html.twig';

const { Component } = Shopware;
const { Criteria } = Shopware.Data;

Component.register('kk-qanda-list', {
  template,

  inject: [
      'repositoryFactory'
  ],

  data() {
    return {
        repository: null,
        qandas: null
    };
  },

  metaInfo() {
    return {
      title: this.$createTitle()
    };
  },

  computed: {
    columns() {
      return [{
        property: 'question',
        dataIndex: 'question',
        label: this.$tc('kk-qanda.list.columnQuestion'),
        routerLink: 'kk.qanda.detail',
        inlineEdit: 'string',
        allowResize: true,
        primary: true
      }, {
        property: 'answer',
        dataIndex: 'answer',
        label: this.$tc('kk-qanda.list.columnAnswer'),
        inlineEdit: 'number',
        allowResize: true
      }, {
        property: 'products',
        dataIndex: 'products',
        label: this.$tc('kk-qanda.list.columnProduct'),
        allowResize: true
      }];
    }
  },
  
  created() {
    this.repository = this.repositoryFactory.create('kk_qanda');

    this.repository
    .search(new Criteria(), Shopware.Context.api)
    .then((result) => {
        console.log(result);
        this.qandas = result;
    });

  }
});

```

Momentan wird in der Spalte nur eine leeres Array `[]` ausgegeben. D.h. das wird noch gar nicht geladen.

---

<div class="post-metadata">

**Author:** ![AlexGalax](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.shopware.com/alexgalax/32/9925_2.png) [@AlexGalax](https://forum.shopware.com/u/AlexGalax)\
**Post date:** [6. April 2020 um 09:53 UTC](https://forum.shopware.com/t/adminpanel-listing-mit-manytomany-column/65713/2 "2020-04-06T09:53:01Z")

</div>

so, ich habe es herausgefunden, hier die Lösung falls es jemand braucht - in der index.js vom admin listing, muss die association manuell über das criteria-objekt hinzugefügt werden:

```
  created() {
    this.repository = this.repositoryFactory.create('kk_qanda');

    const criteria = new Criteria();
    criteria.addAssociation('products'); // hier die ManyToMany association

    this.repository
    .search(criteria, Shopware.Context.api)
    .then((result) => {
        this.qandas = result;
    });
  }

```

Danach kann man die Namen in der list.html.twig ausgeben

```
    {% block kk_qanda_list_content %}
        

[...]

            {% block kk_qanda_list_grid_columns_products %}
                
                    
                        {{ (index > 0) ? `, ${product.translated.name}` : product.translated.name }}
                    
                    
                        , ...
                    
                
            {% endblock %}

[...]

        
    {% endblock %}

```

&nbsp;
