# How to read/write custom entities?

**URL:** <https://forum.shopware.com/t/how-to-read-write-custom-entities/105343>\
**Category:** Shopware 6 (English)\
**Created:** [27. September 2024 um 11:38 UTC](https://forum.shopware.com/t/how-to-read-write-custom-entities/105343 "2024-09-27T11:38:43Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![mqkd](https://avatars.discourse-cdn.com/v4/letter/m/aca169/32.png) [@mqkd](https://forum.shopware.com/u/mqkd)\
**Post date:** [27. September 2024 um 11:38 UTC](https://forum.shopware.com/t/how-to-read-write-custom-entities/105343/1 "2024-09-27T11:38:43Z")

</div>

We are writing a plugin (not an App) and we have defined a custom entity in „entities.xml“ as described here: [Custom entities | Shopware Documentation](https://developer.shopware.com/docs/guides/plugins/apps/custom-data/custom-entities.html). This works: the database tables are created (for the `custom_entity_bundle` in the doc the tables `custom_entity_bundle`, `custom_entity_bundle_products`, `custom_entity_bundle_translation` are created).

Now we want to read/write to the `custom_entity_bundle` table. According to the doc

> All registered entities will get an automatically registered repository.

**HOW DO WE GET THIS REPOSITORY?**

We have tried the obvious: inject it as `custom_entity_bundle.repository` . Result:

> The service „MyCoolPlugin\Service\SomePriceCalculator“ has a dependency on a non-existent service „custom\_entity\_bundle.repository“. Did you mean this: „custom\_entity.repository“?

```auto
<!-- MyCoolPlugin/src/Resources/config/services.xml ... container ... services ... -->
<service id="MyCoolPlugin\Service\SomePriceCalculator" decorates="Shopware\Core\Content\Product\SalesChannel\Price\ProductPriceCalculator">
  <argument type="service" id="MyCoolPlugin\Service\SomePriceCalculator.inner" />
  <argument type="service" id="WHAT_GOES_HERE" />
  <!-- ______________ -->
</service>

```

If we really have to use the `custom_entity.repository` (as suggested in the error message), how would we use this to read/write `custom_entity_bundle` entities?
