Try to fix "Iterate with fetch join in class App\Entity\Parts\PartLot using association part not allowed." when opening BOM

This commit is contained in:
Marc Kreidler 2026-03-29 22:04:10 +02:00
parent 2c607c7e26
commit 5c5c7cece1

View file

@ -185,7 +185,7 @@ class ProjectBomEntriesDataTable implements DataTableTypeInterface
]) ])
->add('storageLocations', TextColumn::class, [ ->add('storageLocations', TextColumn::class, [
'label' => 'part.table.storeLocations', 'label' => 'part.table.storeLocations',
'orderField' => 'NATSORT(MIN(storageLocations.name))', 'orderField' => 'NATSORT(storageLocationOrder)',
'visible' => false, 'visible' => false,
'render' => function ($value, ProjectBOMEntry $context) { 'render' => function ($value, ProjectBOMEntry $context) {
if ($context->getPart() !== null) { if ($context->getPart() !== null) {
@ -226,6 +226,7 @@ class ProjectBomEntriesDataTable implements DataTableTypeInterface
{ {
$builder->select('bom_entry') $builder->select('bom_entry')
->addSelect('part') ->addSelect('part')
->addSelect('(SELECT MIN(storageLocationSort.name) FROM ' . \App\Entity\Parts\PartLot::class . ' partLotSort LEFT JOIN partLotSort.storage_location storageLocationSort WHERE partLotSort.part = part) AS HIDDEN storageLocationOrder')
->from(ProjectBOMEntry::class, 'bom_entry') ->from(ProjectBOMEntry::class, 'bom_entry')
->leftJoin('bom_entry.part', 'part') ->leftJoin('bom_entry.part', 'part')
->leftJoin('part.category', 'category') ->leftJoin('part.category', 'category')