Liebes Forum,
ich habe das DCA eines Attributs (Select, Produkt) angepasst und um ein Feld (product) erweitert.
Somit kann ich jetzt einer bestimmten Option ein Produkt zuordnen.PHP-Code:<?php
// contao/dca/tl_iso_attribute_option.php
use Contao\CoreBundle\DataContainer\PaletteManipulator;
$GLOBALS['TL_DCA']['tl_iso_attribute_option']['fields']['product'] = [
'inputType' => 'select',
'foreignKey' => 'tl_iso_product.id',
'options_callback' => function (){
$option = array();
$data = \Database::getInstance()->execute("SELECT id, name, sku FROM tl_iso_product WHERE type = 4");
while ($data->next())
{
$options[$data->sku] = $data->name . ' (' . $data->sku. ')';
}
return $options;
},
'eval' => ['tl_class' => 'w50', 'multiple' => false],
'sql' => ['type' => 'integer', 'notnull' => false, 'unsigned' => true],
];
$GLOBALS['TL_DCA']['tl_iso_attribute_option']['list']['sorting'] = [
'headerFields' => array('name', 'field_name', 'type', 'variant_option', 'customer_defined', 'product'),
];
PaletteManipulator::create()
->addField('product', 'label_legend', PaletteManipulator::POSITION_APPEND)
->applyToPalette('option', 'tl_iso_attribute_option')
;
Wie schaffe ich es jetzt, dieses Feld in der Bearbeitungsmaske eines Produkt unter Produktoptions-Einstellungen mit anzuzeigen.
Bildschirmfoto 2025-09-19 um 15.58.52.png
Vielen Dank für jeden Hinweis und liebe Grüße
Micha

Zitieren