Skip to content

Commit 63893ff

Browse files
committed
Allow to automatically map categories from info providers to local categories using the "alternative names" system
This partially addresses issues discussed in discussion #808
1 parent c9e519d commit 63893ff

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/Services/InfoProviderSystem/DTOtoEntityConverter.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
use App\Entity\Attachments\PartAttachment;
2828
use App\Entity\Base\AbstractStructuralDBElement;
2929
use App\Entity\Parameters\PartParameter;
30+
use App\Entity\Parts\Category;
3031
use App\Entity\Parts\Footprint;
3132
use App\Entity\Parts\InfoProviderReference;
3233
use App\Entity\Parts\Manufacturer;
@@ -156,6 +157,9 @@ public function convertPart(PartDetailDTO $dto, Part $entity = new Part()): Part
156157

157158
$entity->setMass($dto->mass);
158159

160+
//Try to map the category to an existing entity (but never create a new one)
161+
$entity->setCategory($this->em->getRepository(Category::class)->findForInfoProvider($dto->category));
162+
159163
$entity->setManufacturer($this->getOrCreateEntity(Manufacturer::class, $dto->manufacturer));
160164
$entity->setFootprint($this->getOrCreateEntity(Footprint::class, $dto->footprint));
161165

0 commit comments

Comments
 (0)