/Admin inaccesible after adding tag prop in services.xml

I am new to shopware, I am getting familiar with it following the lessons provided in the accademy.
At a certain point of the Entity lesson after creating the migration, a markup is added to the element (it should contain name and entity) and for some reasons when I add that to my code as well I am not able to access http://localhost:8000/admin anymore:

     <service id="Tentingg\Core\Content\Tentingg\TentinggDefinition">
          <tag name="shopware.entity.definition" entity="testing_plugin" />
                <!--entity correspond with the name returned in the entity definition -->

if I remove the tag markup i can access /admin again, but if I write it back I will get the following error in the console:

        *XHRGEThttp://localhost:8000/api/_info/entity-schema.json[HTTP/1.1 500 Internal Server Error 1525ms]*
        *XHRGEThttp://localhost:8000/api/_info/open-api-schema.json[HTTP/1.1 500 Internal Server Error 1609ms]*
        *Object { message: "Request failed with status code 500", name: "AxiosError", code: "ERR_BAD_RESPONSE", config: {…}, request: XMLHttpRequest, response: {…}, stack: "" }*
        *Uncaught (in promise) TypeError: Shopware.Service(...) is undefined*
        *pLPA http://localhost:8000/bundles/administration/static/js/app.js?16535857926696175:1*
        *get http://localhost:8000/bundles/administration/static/js/vendors-node.js?16535857921632683:2*
        *Ue http://localhost:8000/bundles/administration/static/js/commons.js?1653585792226414:1*
        *value http://localhost:8000/bundles/administration/static/js/app.js?16535857926696175:1*
        *value http://localhost:8000/bundles/administration/static/js/app.js?16535857926696175:1*
        *value http://localhost:8000/bundles/administration/static/js/app.js?16535857926696175:1*
        *value http://localhost:8000/bundles/administration/static/js/commons.js?1653585792226414:1*
        *value http://localhost:8000/bundles/administration/static/js/commons.js?1653585792226414:1*
        *promise callback*value http://localhost:8000/bundles/administration/static/js/commons.js?1653585792226414:1*
        *value http://localhost:8000/bundles/administration/static/js/commons.js?1653585792226414:1*
        *value http://localhost:8000/bundles/administration/static/js/commons.js?1653585792226414:1*
        *<anonymous> http://localhost:8000/admin#/sw/dashboard/index:39*

I would like to ask why are we adding those values in the xml file (I am not familiar with xml) and what could cause the error above mentioned that prevents me to access /admin in the browser.

I think you have an error in your „Tentingg\Core\Content\Tentingg\TentinggDefinition“ class.

The XML Tag Element tags the service as a Shopware entity definition.

1 Like

Thanks Abdullah,
let me share my entiry definition with you:

<?php declare(strict_types=1);

namespace Tentingg\Core\Content\Tentingg;

use Shopware\Core\Framework\DataAbstractionLayer\EntityDefinition;
use Shopware\Core\Framework\DataAbstractionLayer\Field\ManyToOneAssociationField;
use Shopware\Core\Framework\DataAbstractionLayer\Field\OneToManyAssociationField;
use Shopware\Core\Framework\DataAbstractionLayer\FieldCollection;
use Shopware\Core\System\CustomEntity\Xml\Field\OneToManyField;

class TentinggDefinition extends EntityDefinition

    public function getEntityName(): string
        return 'testing_plugin';

    public function getCollectionClass(): string
        return TentinggCollection::class;

    public function getEntityClass(): string
        return TentinggEntity::class;

    protected function defineFields(): FieldCollection
        return new FieldCollection([

            (new IdField('id','id'))->addFlags(new Required(), new PrimaryKey()),
            new BoolField('active','active'),
            (new StringField('name','active'))->addFlags(new Required()),
            new FkField('country_id','countryId',CountryDefinition::class),

            new ManyToOneAssociationField(
                'country',  //property name
                'country_id', //storage_name
                 CountryDefinition::class, // reference class
                 'id', // reference field
                 false //autoload


new StringField(‚name‘,‚active‘)

could cause the problem?

Not really.
But if I return an empty array from the defineFields() function, it works - so I think you are right about the problem being in the entity definition, but I cant still figure out what’s the problem.

You have to import the classes IdField, BoolField, StringField and FkField.
I think that’s the problem.

Thanks, it did fix the problem indeed but I also had to import the flags classes (required, primary_key).

use Shopware\Core\Framework\DataAbstractionLayer\Field\IdField;
use Shopware\Core\Framework\DataAbstractionLayer\Field\Flag\PrimaryKey;
use Shopware\Core\Framework\DataAbstractionLayer\Field\Flag\Required;

It would have saved me time if the console errors were pointing directly at the problem, but maybe I could switch to phpStorm IDE to spot missing classes easily.

Thanks again!