# Shopware.Component.override kein Zugriff auf repositoryFactory

**URL:** <https://forum.shopware.com/t/shopware-component-override-kein-zugriff-auf-repositoryfactory/93656>\
**Category:** Shopware 6 (German)\
**Created:** [24. März 2022 um 17:27 UTC](https://forum.shopware.com/t/shopware-component-override-kein-zugriff-auf-repositoryfactory/93656 "2022-03-24T17:27:32Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Max\_Shop](https://avatars.discourse-cdn.com/v4/letter/m/58f4c7/32.png) [@Max\_Shop](https://forum.shopware.com/u/Max_Shop)\
**Post date:** [24. März 2022 um 17:27 UTC](https://forum.shopware.com/t/shopware-component-override-kein-zugriff-auf-repositoryfactory/93656/1 "2022-03-24T17:27:32Z")

</div>

Meine Kenntnisse in Vue sind gewiss ausbaufähig, aber ich verzweifle wirklich langsam.

Ich versuche eine Komponente zu überschreiben, in der sowohl

```auto
inject: [
        'repositoryFactory'
    ],

```

als auch

```auto
computed: {
        orderRepository() {
            return this.repositoryFactory.create('order');
        },
}

```

definiert sind.

Shopware.Component.override(‚sw-order-list‘, {

}

Egal ob per this. this.$super. this.$super(‚xxx‘). ich bekomme immer ein undefined zurück.

`TypeError: undefined is not an object (evaluating 'this.orderRepository')`

In der Dokumentation gibt es leider absolut keine Beispiele dazu. Hat jemand zufällig eine Ahnung wie ich auf auf die Variablen zugreifen kann?

---

<div class="post-metadata">

**Author:** ![Max\_Shop](https://avatars.discourse-cdn.com/v4/letter/m/58f4c7/32.png) [@Max\_Shop](https://forum.shopware.com/u/Max_Shop)\
**Post date:** [25. März 2022 um 12:07 UTC](https://forum.shopware.com/t/shopware-component-override-kein-zugriff-auf-repositoryfactory/93656/2 "2022-03-25T12:07:32Z")

</div>

@Moorleiche könntest du mir vielleicht kurz einen Tipp geben? Schätze du hast recht viel Erfahrung damit, was ich ggf. falsch mache. Danke.

---

<div class="post-metadata">

**Author:** ![Moorleiche](https://avatars.discourse-cdn.com/v4/letter/m/6f9a4e/32.png) [@Moorleiche](https://forum.shopware.com/u/Moorleiche)\
**Post date:** [25. März 2022 um 14:30 UTC](https://forum.shopware.com/t/shopware-component-override-kein-zugriff-auf-repositoryfactory/93656/3 "2022-03-25T14:30:19Z")

</div>

Keine Ahnung, hätte hier ein funktionierendes Bsp-

```auto
import template from './sw-order-list.html.twig';

const {Component} = Shopware;

Component.override('sw-order-list', {
    template,

    computed: {
        paymentMethodRepository() {
            return this.repositoryFactory.create('payment_method');
        },

        orderCriteria() {
            const criteria = this.$super('orderCriteria');

            criteria.addAssociation('transactions.paymentMethod');

            return criteria;
        }
    },

    methods: {
        getOrderColumns() {
            const orderColumns = this.$super('getOrderColumns');

            orderColumns.push({
                property: 'transactions.last().paymentMethod.name',
                dataIndex: 'transactions.paymentMethod.name',
                label: 'sw-order.list.columnPaymentMethod',
                allowResize: true,
            });

            return orderColumns;
        },

        getPaymentMethod(order) {
            return 'GRATIS';
        }
    },
});

```

```auto
{% block sw_order_list_grid_columns %}
    <template #column-transactions.last().paymentMethod.name="{ item }">
        <sw-label appearance="pill"
                  :variant="getVariantFromPaymentState(item)">
            {{ item.transactions.last().paymentMethod.name }}
        </sw-label>
    </template>

    {% parent %}
{% endblock %}

```

---

<div class="post-metadata">

**Author:** ![Max\_Shop](https://avatars.discourse-cdn.com/v4/letter/m/58f4c7/32.png) [@Max\_Shop](https://forum.shopware.com/u/Max_Shop)\
**Post date:** [25. März 2022 um 15:48 UTC](https://forum.shopware.com/t/shopware-component-override-kein-zugriff-auf-repositoryfactory/93656/4 "2022-03-25T15:48:53Z")

</div>

@Moorleiche vielen Dank für das Beispiel. Ich wollte gerade schon rausstellen, dass du paymentMethodRepository überhaupt nicht verwendest und es daher keinen Fehler werfen kann, aber ich kann tatsächlich auf die Variable zugreifen 🥹

Ich ergänze jetzt deinen Block um meine Befehle, Zeile für Zeile. Ich frage mich wirklich, wo das Problem liegt.

Nochmals vielen Dank!

---

<div class="post-metadata">

**Author:** ![Max\_Shop](https://avatars.discourse-cdn.com/v4/letter/m/58f4c7/32.png) [@Max\_Shop](https://forum.shopware.com/u/Max_Shop)\
**Post date:** [25. März 2022 um 16:16 UTC](https://forum.shopware.com/t/shopware-component-override-kein-zugriff-auf-repositoryfactory/93656/5 "2022-03-25T16:16:59Z")

</div>

Ich habe bei

```auto
this.orders.forEach(function(item){
   ...
}, this);

```

das this am Ende vergessen. Entsprechend war this undefined 😬

Unabhängig davon fällt mir gerade auf, dass der Ansatz völlig daneben ist. Man sollte mitten in der Nacht nicht mehr programmieren 😂

Nochmals vielen Dank!
