Ich möchte eine Abfrage gestalten die mir alle Kategorien gibt welche einen Wortteil in einem Custom Field haben: $builder-\>select(['category', 'attribute']) -\>from(\Shopware\Models\Category\Category::class, 'category') -\>leftJoin('category.attribute', 'attribute') -\>where('attribute.ln\_my\_custom\_field like :test') -\>setParameter('test', '%test%');
Laut Exception hat aber Category das Feld ln_my_custom_field nicht.
[Semantical Error] line 0, col 130 near 'ln\_my\_custom\_field': Error: Class Shopware\\Models\\Attribute\\Category has no field or association named ln\_my\_custom\_field"
Geh jetzt vorerst mal nicht über die models sondern direkt per sql, was solls -_-
$builder = $this-\>container-\>get('dbal\_connection')-\>createQueryBuilder(); $builder-\>select(['categoryID', 'ln\_my\_custom\_field']) -\>from('s\_categories\_attributes', 'cat\_at') -\>where('cat\_at.ln\_my\_custom\_field like :test') -\>setParameter('test', '%test%'); $categoriesArrayData = $builder-\>execute()-\>fetchAll();
Hi,
das Feld ist im Model CamelCase Beispiel:
-\>where('attribute.lnMyCustomField like :test')
Gruß Heiner
1 „Gefällt mir“
Trifft dies auch zu wenn man das custom field so anlegt ?
$service->update(
's_categories_attributes',
'ln_my_custom_field',
TypeMapping::TYPE_STRING,
[
'displayInBackend' => true,
'label' => 'Test Field',
'supportText' => 'Testing'
]
);