Hallo!
Ich versuche, Suppliers anhand eines attributs abzurufen. Leider noch kein glück.
Was ich getan habe:
$service = $this->container->get('shopware_attribute.crud_service');
$service->update('s_articles_supplier_attributes', 'show_in_slider', 'boolean', [
            'label' => 'Active for slider',
                'supportText' => 'Active',
                'helpText' => 'Only selected suppliers are shown within slider',
                // user has the opportunity to translate the attribute field for each shop
                'translatable' => false,
                // attribute will be displayed in the backend module
                'displayInBackend' => true,
                //user can modify the attribute in the free text field module
                'custom' => false,
            ]
        );
Shopware()->Container()->get('models')->generateAttributeModels();
Wenn ich versuche, den Lieferanten über das Attribut abzurufen, erhalte ich immer noch den fehler: Uncaught Doctrine\ORM\ORMException: Unrecognized field: showInSlider"
$params = ['showInSlider' => 1];
$sort = [];
$suppliers = Shopware()->Container()->get('models')->getRepository(Supplier::class)->findBy( $params, $sort );
Ich habe das Shopware-Entwickler-Cheatsheet (Cheat-Sheet for developers) überprüft, das Folgendes zeigt:
Naming - Attribute generationAnchor link for: naming attribute generation
If you get the Error: Unrecognized field: my_field when querying for your attribute it could be that you forgot to generate the attribute models:
$this->container()->get('models')->generateAttributeModels();
or ran into naming issues:
- the field name gets lower cased before added to the database
- when using underscores(_) in field names they must be queried in camel case
Was mache ich falsch?