Hallo Community,
bin gerade dabei für die „s_article_configurator_options“ Tabelle eine Attributes Tabelle zu erstellen, da aktuell keine vorhanden ist. In diese Attributes Tabelle will ich zusätzliche Informationen, wie z.B. Option Icon, speichern. Die Tabelle heißt „webcu_article_configurator_option_attributes“ und verfügt über folgende Spalten:
- id int(11)
- optionId int(11)
- optionIcon varchar(255)
Ein Doctrine Model für diese Tabelle habe ich bereits erstellt und beim Installieren von dem Plugin wird die Tabelle erfolgreich in der DB angelegt.
Um jetzt das Feld „optionIcon“ im Backend darstellen und bearbeiten zu können muss die „getConfiguratorGroupsQueryBuilder“ Funktion erweitert werden, also mache ich einen After Hook:
public function afterGetConfiguratorGroupsQueryBuilder(\Enlight_Hook_HookArgs $arguments)
{
// get original builder
$builder = $arguments->getReturn();
// add selection and join to original builder
$builder->addSelect('options_attributes.optionIcon');
$builder->leftJoin(
'Shopware\CustomModels\WebcuTestPlugin\Configurator\Option',
'options_attributes',
\Doctrine\ORM\Query\Expr\Join::WITH,
'options_attributes.optionId = options.id'
);
echo "";
print_r($builder->getQuery()->getArrayResult());
echo "";
exit();
$arguments->setReturn($builder);
}
Am Ende Debugge ich das Ergebnis:
Array(
[0] => Array(
[0] => Array(
[id] => 5
[name] => Stocklänge
[description] =>
[position] => 1
[options] => Array(
[0] => Array(
[id] => 45
[groupId] => 5
[name] => 100 cm
[position] => 4
)
[1] => Array(
[id] => 6
[groupId] => 5
[name] => 110 cm
[position] => 6
)
[2] => Array(
[id] => 5
[groupId] => 5
[name] => 115 cm
[position] => 5
)
)
)
[optionIcon] =>
)
Das Feld „optionIcon“ wurde erfolgreich hinzugefügt, aber an der falschen Stelle.
Wie kriege ich es so hin, dass das Feld „optionIcon“ bei jeder Option angelegt wird und nicht bei jeder Gruppe?
Gibt es vielleicht einen anderen Weg neue Felder hinzuzufügen ohne eine Attributes Tabelle?
Besten Gruß,
Nikita