I have build my own Plugin in Shopware 6. I allready have a custom module with custom route. Now I want to add data from my custom database table to my custom routes html.twig
.
My Route: http://localhost:8888/admin#/ankauf/module/overview
My Database Table: product_reservation
I have build my own controller but I can't get this controller to listen to my route. Maybe because my route is build from the module? The path in my module is: ankauf.module.overview
Is a controller the right way? And if yes, how can it listen to my path and don't overwrite it with his own route?
Is there a better way to push PHP Code to my custom Backend path?
If you have created an own entity with definition etc (like here or here described) there is an easy to get your data to an admin module. Shopware will automatically register routes for CRUD operations on your entity. So the entity is automatically available via the admin API. On the admin side there are also helper services to read out your API. In your vue.js component you need to inject the
inject: [
'repositoryFactory'
],
With this factory you are able to create a repository which requests your custom entity API route.
{
...
created() {
this.repository = this.repositoryFactory.create('product_reservation');
}
}
The repository has several methods like search
, get
, create
, delete
, etc.
With these methods you are able to read out your data in the vue.js component of your plugin and bring it to your module
Read more about an own module here