Skip to content

Commit 9c99217

Browse files
committed
Fixed test errors
1 parent afc1dbd commit 9c99217

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/Services/InfoProviderSystem/DTOtoEntityConverter.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
use App\Entity\PriceInformations\Currency;
3838
use App\Entity\PriceInformations\Orderdetail;
3939
use App\Entity\PriceInformations\Pricedetail;
40+
use App\Repository\Parts\CategoryRepository;
4041
use App\Services\InfoProviderSystem\DTOs\FileDTO;
4142
use App\Services\InfoProviderSystem\DTOs\ParameterDTO;
4243
use App\Services\InfoProviderSystem\DTOs\PartDetailDTO;
@@ -158,7 +159,11 @@ public function convertPart(PartDetailDTO $dto, Part $entity = new Part()): Part
158159
$entity->setMass($dto->mass);
159160

160161
//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+
if ($dto->category) {
163+
/** @var CategoryRepository<Category> $categoryRepo */
164+
$categoryRepo = $this->em->getRepository(Category::class);
165+
$entity->setCategory($categoryRepo->findForInfoProvider($dto->category));
166+
}
162167

163168
$entity->setManufacturer($this->getOrCreateEntity(Manufacturer::class, $dto->manufacturer));
164169
$entity->setFootprint($this->getOrCreateEntity(Footprint::class, $dto->footprint));

0 commit comments

Comments
 (0)