<?php
namespace App\Repository;
use App\Entity\Product;
use App\Entity\ProductCategory;
use App\Entity\ProductFamily;
use App\Entity\ProductVariant;
use App\Utils\uString;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\ORM\QueryBuilder;
use Doctrine\Persistence\ManagerRegistry;
use Sulu\Bundle\MediaBundle\Entity\MediaRepositoryInterface;
use Sulu\Bundle\MediaBundle\Media\Manager\MediaManagerInterface;
use Sulu\Bundle\RouteBundle\Manager\RouteManagerInterface;
use PHPCR\Util\UUIDHelper;
/**
* @extends ServiceEntityRepository<ProductVariant>
*
* @method ProductVariant|null find($id, $lockMode = null, $lockVersion = null)
* @method ProductVariant|null findOneBy(array $criteria, array $orderBy = null)
* @method ProductVariant[] findAll()
* @method ProductVariant[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
*/
class ProductVariantRepository extends ServiceEntityRepository
{
public function __construct(
ManagerRegistry $registry,
protected readonly RouteManagerInterface $routeManager,
protected readonly ProductCategoryRepository $productCategoryRepository,
protected readonly ProductFamilyRepository $productFamilyRepository,
protected readonly MediaRepositoryInterface $mediaRepository,
protected readonly MediaManagerInterface $mediaManager,
)
{
parent::__construct($registry, ProductVariant::class);
}
public function save(ProductVariant $entity, bool $flush = false): void
{
$this->getEntityManager()->persist($entity);
if ($flush) {
$this->getEntityManager()->flush();
}
}
public function remove(ProductVariant $entity, bool $flush = false): void
{
$this->getEntityManager()->remove($entity);
if ($flush) {
$this->getEntityManager()->flush();
}
}
public function createFromImport(array $data): void
{
$entity = new ProductVariant();
$entity->setUuid(UUIDHelper::generateUUID());
$entity->setProductCode($data[0]);
$entity->setTitle($data[1]);
$entity->setCategory($data[2] ?? null);
$entity->setFamily($data[3] ?? null);
$entity->setActive($data[4] ?? null);
$entity->setDescription($data[5] ?? null);
$entity->setAccessories($data[8] ?? null);
$entity->setType($data[9] ?? null);
$entity->setFixation($data[12] ?? null);
$entity->setLuminousFlux((int)$data[15] ?? null);
$entity->setCri($data[16] ?? null);
$entity->setChromaticity($data[17] ?? null);
$entity->setDispersionVariant($data[20] ?? null);
$entity->setProtectClass($data[23] ?? null);
$entity->setRadiationDirect($data[24] ?? null);
$entity->setShape($data[27] ?? null);
$entity->setDimensionA((int)$data[30] ?? null);
$entity->setDimensionB((int)$data[31] ?? null);
$entity->setDimensionC((int)$data[32] ?? null);
$entity->setColor($data[33] ?? null);
$entity->setTempMax($data[39] ?? null);
$entity->setTempMin($data[40] ?? null);
$inputPower = str_replace(',', '.', $data[41]);
$entity->setInputPower((float)$inputPower ?? null);
$entity->setEfficiency((int)$data[42] ?? null);
$entity->setProtectClassEl($data[43] ?? null);
$entity->setSupplyVoltage($data[44] ?? null);
$entity->setResourceType($data[45] ?? null);
if ($data[48] == 'Novinka' || $data[48] == 'New') {
$entity->setStatusNew(true);
} else {
$entity->setStatusNew(false);
}
$entity->setMechanicalDurability($data[51] ?? null);
$entity->setDispersion($data[52] ?? null);
$entity->setDriver($data[55] ?? null);
$entity->setSupplements($data[58] ?? null);
$entity->setDimension($data[61] ?? null);
$entity->setColorRal($data[63] ?? null);
$entity->setMaterial($data[64] ?? null);
$entity->setDriverFunction($data[67] ?? null);
$weight = str_replace(',', '.', $data[62]);
$entity->setWeight((float)$weight ?? null);
$entity->setLuminousFluxSupply((int)$data[70] ?? null);
$entity->setAliveLed($data[71] ?? null);
$entity->setGuarantee((int)$data[72] ?? null);
$entity->setUsage($data[36] ?? null);
$entity->setWebspace('hormen');
$entity->setLocale('cs');
$entity->setState('published');
$this->updateProduct($entity, $data[1]);
$this->updateProductFamily($entity, $data[3]);
$this->updateProductCategory($entity, $data[2]);
// Schema
if (!empty($data[75])) {
$media = $this->mediaRepository->findMediaWithFilenameInCollectionWithId($data[75], 14);
if ($media) {
$this->updateImageSchemaFromImport($entity, $media);
}
}
// Curves
if (!empty($data[76])) {
$media = $this->mediaRepository->findMediaWithFilenameInCollectionWithId($data[76], 15);
if ($media) {
$this->updateImageCurvesFromImport($entity, $media);
}
}
if (!empty($data[77])) {
$media = $this->mediaRepository->findMediaWithFilenameInCollectionWithId($data[77], 15);
if ($media) {
$this->updateLtdCurvesFromImport($entity, $media);
}
}
// Images
if ($data[73]) {
$images = explode(',', $data[73]);
$media = $this->mediaRepository->findMediaWithFilenameInCollectionWithId($images[0], 10);
if ($media) {
$this->updateImageFromImport($entity, $media);
}
if (count($images) > 1) {
array_shift($images);
if ($images) {
$this->updateImagesFromImport($entity, $images);
}
}
}
// Renders
if ($data[74]) {
$images = explode(',', $data[74]);
if ($images) {
$this->updateRendersFromImport($entity, $images);
}
}
// Files
if ($data[78]) {
$files = explode(',', $data[78]);
if ($files) {
$this->updateFilesFromImport($entity, $files);
}
}
$this->save($entity, true);
}
public function updateFromImport(ProductVariant $entity, array $data): void
{
$entity->setProductCode($data[0]);
$entity->setTitle($data[1]);
$entity->setCategory($data[2] ?? null);
$entity->setFamily($data[3] ?? null);
$entity->setActive($data[4] ?? null);
$entity->setDescription($data[5] ?? null);
$entity->setAccessories($data[8] ?? null);
$entity->setType($data[9] ?? null);
$entity->setFixation($data[12] ?? null);
$entity->setLuminousFlux((int)$data[15] ?? null);
$entity->setCri($data[16] ?? null);
$entity->setChromaticity($data[17] ?? null);
$entity->setDispersionVariant($data[20] ?? null);
$entity->setProtectClass($data[23] ?? null);
$entity->setRadiationDirect($data[24] ?? null);
$entity->setShape($data[27] ?? null);
$entity->setDimensionA((int)$data[30] ?? null);
$entity->setDimensionB((int)$data[31] ?? null);
$entity->setDimensionC((int)$data[32] ?? null);
$entity->setColor($data[33] ?? null);
$entity->setTempMax($data[39] ?? null);
$entity->setTempMin($data[40] ?? null);
$inputPower = str_replace(',', '.', $data[41]);
$entity->setInputPower((float)$inputPower ?? null);
$entity->setEfficiency((int)$data[42] ?? null);
$entity->setProtectClassEl($data[43] ?? null);
$entity->setSupplyVoltage($data[44] ?? null);
$entity->setResourceType($data[45] ?? null);
if ($data[48] == 'Novinka' || $data[48] == 'New') {
$entity->setStatusNew(true);
} else {
$entity->setStatusNew(false);
}
$entity->setMechanicalDurability($data[51] ?? null);
$entity->setDispersion($data[52] ?? null);
$entity->setDriver($data[55] ?? null);
$entity->setSupplements($data[58] ?? null);
$entity->setDimension($data[61] ?? null);
$entity->setColorRal($data[63] ?? null);
$entity->setMaterial($data[64] ?? null);
$entity->setDriverFunction($data[67] ?? null);
$weight = str_replace(',', '.', $data[62]);
$entity->setWeight((float)$weight ?? null);
$entity->setLuminousFluxSupply((int)$data[70] ?? null);
$entity->setAliveLed($data[71] ?? null);
$entity->setGuarantee((int)$data[72] ?? null);
$entity->setUsage($data[36] ?? null);
$this->updateProduct($entity, $data[1]);
$this->updateProductFamily($entity, $data[3]);
$this->updateProductCategory($entity, $data[2]);
// Schema
if (!empty($data[75])) {
$media = $this->mediaRepository->findMediaWithFilenameInCollectionWithId($data[75], 14);
if ($media) {
$this->updateImageSchemaFromImport($entity, $media);
}
}
// Curves
if (!empty($data[76])) {
$media = $this->mediaRepository->findMediaWithFilenameInCollectionWithId($data[76], 15);
if ($media) {
$this->updateImageCurvesFromImport($entity, $media);
}
}
if (!empty($data[77])) {
$media = $this->mediaRepository->findMediaWithFilenameInCollectionWithId($data[77], 15);
if ($media) {
$this->updateLtdCurvesFromImport($entity, $media);
}
}
// Images
if ($data[73]) {
$images = explode(',', $data[73]);
$media = $this->mediaRepository->findMediaWithFilenameInCollectionWithId($images[0], 10);
if ($media) {
$this->updateImageFromImport($entity, $media);
}
if (count($images) > 1) {
array_shift($images);
if ($images) {
$this->updateImagesFromImport($entity, $images);
}
}
}
// Renders
if ($data[74]) {
$images = explode(',', $data[74]);
if ($images) {
$this->updateRendersFromImport($entity, $images);
}
}
// Files
if ($data[78]) {
$files = explode(',', $data[78]);
if ($files) {
$this->updateFilesFromImport($entity, $files);
}
}
$entity->setWebspace('hormen');
$entity->setLocale('cs');
$entity->setState('published');
$this->save($entity, true);
}
public function update(ProductVariant $entity, array $data, bool $preview = false): void
{
$entity->setTitle($data['title']);
$entity->setProductCode($data['product_code']);
$entity->setActive($data['active']);
$entity->setDescription($data['description'] ?? null);
$entity->setCategory($data['category'] ?? null);
$entity->setFamily($data['family'] ?? null);
$entity->setType($data['type'] ?? null);
$entity->setFixation($data['fixation'] ?? null);
$entity->setLuminousFlux($data['luminous_flux'] ?? null);
$entity->setCri($data['cri'] ?? null);
$entity->setChromaticity($data['chromaticity'] ?? null);
$entity->setDispersionVariant($data['dispersion_variant'] ?? null);
$entity->setProtectClass($data['protect_class'] ?? null);
$entity->setRadiationDirect($data['radiation_direct'] ?? null);
$entity->setShape($data['shape'] ?? null);
$entity->setDimensionA($data['dimension_a'] ?? null);
$entity->setDimensionB($data['dimension_b'] ?? null);
$entity->setDimensionC($data['dimension_c'] ?? null);
$entity->setColor($data['color'] ?? null);
$entity->setTempMax($data['temp_max'] ?? null);
$entity->setTempMin($data['temp_min'] ?? null);
$entity->setInputPower($data['input_power'] ?? null);
$entity->setEfficiency($data['efficiency'] ?? null);
$entity->setProtectClassEl($data['protect_class_el'] ?? null);
$entity->setSupplyVoltage($data['supply_voltage'] ?? null);
$entity->setResourceType($data['resource_type'] ?? null);
$entity->setStatusNew($data['status_new']);
$entity->setMechanicalDurability($data['mechanical_durability'] ?? null);
$entity->setDispersion($data['dispersion'] ?? null);
$entity->setDriver($data['driver'] ?? null);
$entity->setSupplements($data['supplements'] ?? null);
$entity->setDimension($data['dimension'] ?? null);
$entity->setColorRal($data['color_ral'] ?? null);
$entity->setMaterial($data['material'] ?? null);
$entity->setDriverFunction($data['driver_function'] ?? null);
$entity->setWeight($data['weight'] ?? null);
$entity->setLuminousFluxSupply($data['luminous_flux_supply'] ?? null);
$entity->setAliveLed($data['alive_led'] ?? null);
$entity->setGuarantee($data['guarantee'] ?? null);
$entity->setUsage($data['variant_use'] ?? null);
$entity->setAccessories($data['accessories'] ?? null);
$this->updateImage($entity, $data['image'] ?? null);
$this->updateImageSchema($entity, $data['image_schema'] ?? null);
$this->updateImageCurves($entity, $data['image_curves'] ?? null);
$this->updateLtdCurves($entity, $data['ltd_curves'] ?? null);
if (!$preview) {
$this->updateImages($entity, $data['images'] ?? null);
$this->updateRenders($entity, $data['renders'] ?? null);
$this->updateFiles($entity, $data['files'] ?? null);
$this->updateProduct($entity, $data['title']);
$this->updateProductFamily($entity, $data['family']);
$this->updateProductCategory($entity, $data['category']);
$this->save($entity, true);
}
}
public function updateImages(ProductVariant $entity, ?array $icons = null)
{
$entity->getImages()->clear();
if ($icons) {
if (isset($icons['ids'])) {
$iconsIds = $icons['ids'];
} else {
$iconsIds = $icons;
}
foreach ($iconsIds as $iconId) {
$icon = $this->mediaRepository->findMediaById($iconId);
if ($icon) {
$entity->addImage($icon);
}
}
}
}
public function updateImagesFromImport(ProductVariant $entity, ?array $icons = null)
{
$entity->getImages()->clear();
if ($icons) {
foreach ($icons as $icon) {
if ($icon) {
$media = $this->mediaRepository->findMediaWithFilenameInCollectionWithId($icon, 10);
if ($media) {
$entity->addImage($media);
}
}
}
}
}
public function updateRenders(ProductVariant $entity, ?array $renders = null)
{
$entity->getRenders()->clear();
if ($renders) {
if (isset($renders['ids'])) {
$rendersIds = $renders['ids'];
} else {
$rendersIds = $renders;
}
foreach ($rendersIds as $renderId) {
$render = $this->mediaRepository->findMediaById($renderId);
if ($render) {
$entity->addRender($render);
}
}
}
}
public function updateRendersFromImport(ProductVariant $entity, ?array $renders = null)
{
$entity->getRenders()->clear();
if ($renders) {
foreach ($renders as $render) {
if ($render) {
$media = $this->mediaRepository->findMediaWithFilenameInCollectionWithId($render, 12);
if ($media) {
$entity->addRender($media);
}
}
}
}
}
public function updateFiles(ProductVariant $entity, ?array $files = null)
{
$entity->getFiles()->clear();
if ($files) {
if (isset($files['ids'])) {
$filesIds = $files['ids'];
} else {
$filesIds = $files;
}
foreach ($filesIds as $fileId) {
$file = $this->mediaRepository->findMediaById($fileId);
if ($file) {
$entity->addFile($file);
}
}
}
}
public function updateFilesFromImport(ProductVariant $entity, ?array $files = null)
{
$entity->getFiles()->clear();
if ($files) {
foreach ($files as $file) {
if ($file) {
$media = $this->mediaRepository->findMediaWithFilenameInCollectionWithId($file, 13);
if ($media) {
$entity->addFile($media);
}
}
}
}
}
public function updateImage(ProductVariant $entity, ?array $mediaData): void
{
$media = null;
if (isset($mediaData['id']) && $mediaData['id']) {
$media = $this->mediaRepository->find($mediaData['id']);
}
$entity->setImage($media);
}
public function updateProduct(ProductVariant $entity, ?string $title): void
{
if (isset($title)) {
$product = $this->getEntityManager()->getRepository(Product::class)->findOneByTitle($title, 'cs');
$entity->setProduct($product);
} else {
$entity->setProduct(null);
}
}
public function updateProductFamily(ProductVariant $entity, ?string $importId): void
{
if (isset($importId)) {
$productFamily = $this->productFamilyRepository->findOneByImportId($importId, 'cs');
$entity->setProductFamily($productFamily);
} else {
$entity->setProductFamily(null);
}
}
public function updateProductCategory(ProductVariant $entity, ?string $importId): void
{
if (isset($importId)) {
$productCategory = $this->productCategoryRepository->findOneByImportId($importId, 'cs');
$entity->setProductCategory($productCategory);
} else {
$entity->setProductCategory(null);
}
}
public function updateImageFromImport(ProductVariant $entity, $media): void
{
$entity->setImage($media);
}
public function updateImageSchema(ProductVariant $entity, ?array $mediaData): void
{
$media = null;
if (isset($mediaData['id']) && $mediaData['id']) {
$media = $this->mediaRepository->find($mediaData['id']);
}
$entity->setImageSchema($media);
}
public function updateImageSchemaFromImport(ProductVariant $entity, $media): void
{
$entity->setImageSchema($media);
}
public function updateImageCurves(ProductVariant $entity, ?array $mediaData): void
{
$media = null;
if (isset($mediaData['id']) && $mediaData['id']) {
$media = $this->mediaRepository->find($mediaData['id']);
}
$entity->setImageCurves($media);
}
public function updateImageCurvesFromImport(ProductVariant $entity, $media): void
{
$entity->setImageCurves($media);
}
public function updateLtdCurves(ProductVariant $entity, ?array $mediaData): void
{
$media = null;
if (isset($mediaData['id']) && $mediaData['id']) {
$media = $this->mediaRepository->find($mediaData['id']);
}
$entity->setLtdCurves($media);
}
public function updateLtdCurvesFromImport(ProductVariant $entity, $media): void
{
$entity->setLtdCurves($media);
}
public function findOneByUuid(string $uuid, string $locale): ?ProductVariant
{
return $this->findOneBy([
'uuid' => $uuid,
'locale' => $locale,
]);
}
public function findOneByProductCode(string $productCode, string $locale): ?ProductVariant
{
return $this->findOneBy([
'productCode' => $productCode,
'locale' => $locale,
]);
}
public function exists(string $productCode, string $locale): ?ProductVariant
{
$productVariant = self::findOneByProductCode($productCode, $locale);
if ($productVariant) {
return $productVariant;
} else {
return null;
}
}
// TODO: move to ProductVariantFacade
public function getCodes(): ?array
{
$qb = $this->createQueryBuilder('i')
->select('i.productCode')
->getQuery();
$resultsForImport = [];
$result = $qb->getResult();
foreach ($result as $item) {
array_push($resultsForImport, $item['productCode']);
}
return $resultsForImport;
}
public function isNewProductVariant(?string $productName): bool
{
if ($productName) {
$productVariants = $this->findBy(['title' => $productName, 'active' => true]);
foreach ($productVariants as $productVariant) {
if ($productVariant->getStatusNew()) {
return true;
}
}
}
return false;
}
// TODO: move to ProductVariantFacade
public function getAccessories(?string $productName, string $webspace, string $locale): array
{
$accessories = [];
if ($productName) {
$productVariants = $this->findBy(['title' => $productName, 'active' => true]);
foreach ($productVariants as $productVariant) {
$variantAccessories = explode(",", $productVariant->getAccessories());
foreach ($variantAccessories as $variantAccessory) {
array_push($accessories, $variantAccessory);
}
}
}
$accessories = array_unique($accessories);
return $accessories;
}
private function andWhereInIn(QueryBuilder $qb, string $field, array $values): QueryBuilder
{
if (!empty($values)) {
$conditions = [];
foreach ($values as $value) {
$conditions[] = $qb->expr()->orX(
$qb->expr()->eq($field, $qb->expr()->literal($value)),
$qb->expr()->like($field, $qb->expr()->literal($value . ',%')),
$qb->expr()->like($field, $qb->expr()->literal('%,' . $value . ',%')),
$qb->expr()->like($field, $qb->expr()->literal('%,' . $value)),
);
}
$qb->andWhere($qb->expr()->orX(...$conditions));
}
return $qb;
}
private function prepareQueryBuilder(
string $webspace,
string $locale,
?ProductCategory $productCategory = null,
?ProductFamily $productFamily = null,
?Product $product = null,
): QueryBuilder
{
$qb = $this->createQueryBuilder('pv');
$qb->andWhere('pv.webspace = :webspace')
->setParameter('webspace', $webspace);
$qb->andWhere('pv.locale = :locale')
->setParameter('locale', $locale);
$qb->andWhere('pv.state = :state')
->setParameter('state', 'published');
$qb->andWhere('pv.active = :active')
->setParameter('active', true);
if ($productCategory !== null) {
$qb->andWhere('pv.productCategory = :productCategory')
->setParameter('productCategory', $productCategory);
}
if ($productFamily !== null) {
$qb->andWhere('pv.productFamily = :productFamily')
->setParameter('productFamily', $productFamily);
}
if ($product !== null) {
$qb->andWhere('pv.product = :product')
->setParameter('product', $product);
}
return $qb;
}
public function getProductVariantsQueryBuilder(
string $webspace,
string $locale,
?array $excludedIds = null,
?array $products = null,
?array $types = null,
?array $fixations = null,
?int $minLuminousFlux = null,
?int $maxLuminousFlux = null,
?array $cris = null,
?array $chromaticities = null,
?array $dispersionVariants = null,
?array $ips = null,
?array $radiationDirects = null,
?array $shapes = null,
?int $minLength = null,
?int $maxLength = null,
?int $minWidth = null,
?int $maxWidth = null,
?int $minHeight = null,
?int $maxHeight = null,
?array $colors = null,
?array $usages = null,
?array $maxTemperatures = null,
?array $minTemperatures = null,
?int $minInputPower = null,
?int $maxInputPower = null,
?int $minEfficiency = null,
?int $maxEfficiency = null,
?array $elProtects = null,
?array $powerMethods = null,
?array $resourceTypes = null,
// ?array $lightSources = null,
?array $statuses = null,
?array $mechanicalDurabilities = null,
?array $dispersions = null,
?array $drivers = null,
?array $accessories = null,
): QueryBuilder
{
$qb = $this->prepareQueryBuilder($webspace, $locale);
$qb->orderBy('pv.productCode', 'ASC');
if($excludedIds !== null) {
$qb->andWhere($qb->expr()->notIn('pv.id', ':excludedIds'))
->setParameter('excludedIds', $excludedIds);
}
if($products !== null) {
$qb->andWhere($qb->expr()->in('pv.product', ':products'))
->setParameter('products', $products);
}
$this->addTypesToQueryBuilder($qb, $types);
$this->addFixationsToQueryBuilder($qb, $fixations);
$this->addMinLuminousFluxToQueryBuilder($qb, $minLuminousFlux);
$this->addMaxLuminousFluxToQueryBuilder($qb, $maxLuminousFlux);
$this->addCrisToQueryBuilder($qb, $cris);
$this->addChromaticitiesToQueryBuilder($qb, $chromaticities);
$this->addDispersionVariantsToQueryBuilder($qb, $dispersionVariants);
$this->addIpsToQueryBuilder($qb, $ips);
$this->addRadiationDirectsToQueryBuilder($qb, $radiationDirects);
$this->addShapesToQueryBuilder($qb, $shapes);
$this->addMinLengthToQueryBuilder($qb, $minLength);
$this->addMaxLengthToQueryBuilder($qb, $maxLength);
$this->addMinWidthToQueryBuilder($qb, $minWidth);
$this->addMaxWidthToQueryBuilder($qb, $maxWidth);
$this->addMinHeightToQueryBuilder($qb, $minHeight);
$this->addMaxHeightToQueryBuilder($qb, $maxHeight);
$this->addColorsToQueryBuilder($qb, $colors);
$this->addUsagesToQueryBuilder($qb, $usages);
$this->addMaxTemperaturesToQueryBuilder($qb, $maxTemperatures);
$this->addMinTemperaturesToQueryBuilder($qb, $minTemperatures);
$this->addMinInputPowerToQueryBuilder($qb, $minInputPower);
$this->addMaxInputPowerToQueryBuilder($qb, $maxInputPower);
$this->addMinEfficiencyToQueryBuilder($qb, $minEfficiency);
$this->addMaxEfficiencyToQueryBuilder($qb, $maxEfficiency);
$this->addElProtectsToQueryBuilder($qb, $elProtects);
$this->addPowerMethodsToQueryBuilder($qb, $powerMethods);
$this->addResourceTypesToQueryBuilder($qb, $resourceTypes);
// $this->addLightSourcesToQueryBuilder($qb, $lightSources);
$this->addStatusesToQueryBuilder($qb, $statuses);
$this->addMechanicalDurabilitiesToQueryBuilder($qb, $mechanicalDurabilities);
$this->addDispersionsToQueryBuilder($qb, $dispersions);
$this->addDriversToQueryBuilder($qb, $drivers);
$this->addAccessoriesToQueryBuilder($qb, $accessories);
return $qb;
}
// Typ
// **********************************
public function getAllTypes(string $webspace, string $locale): array
{
$qb = $this->prepareQueryBuilder($webspace, $locale)
->select('pv.type')
->distinct();
$results = $qb->getQuery()->getSingleColumnResult();
$types = [];
foreach ($results as $result) {
$items = array_map('trim', explode(',', $result));
$types = array_merge($types, $items);
}
$types = uString::asort($types);
return array_unique($types);
}
public function addTypesToQueryBuilder(QueryBuilder $qb, ?array $types): void
{
if($types !== null) {
$this->andWhereInIn($qb, 'pv.type', $types);
}
}
// **********************************
// Způsob montáže
// **********************************
public function getAllFixations(string $webspace, string $locale): array
{
$qb = $this->prepareQueryBuilder($webspace, $locale)
->andWhere('pv.fixation <> \'\'')
->select('pv.fixation')
->distinct();
$results = $qb->getQuery()->getSingleColumnResult();
$fixations = [];
foreach ($results as $result) {
$items = array_map('trim', explode(',', $result));
$fixations = array_merge($fixations, $items);
}
$fixations = uString::asort($fixations);
return array_unique($fixations);
}
public function addFixationsToQueryBuilder(QueryBuilder $qb, ?array $fixations): void
{
if($fixations !== null) {
$this->andWhereInIn($qb, 'pv.fixation', $fixations);
}
}
// **********************************
// Světelný tok [lm]
// **********************************
public function getMinLuminousFlux(
string $webspace,
string $locale,
?ProductCategory $productCategory = null,
?ProductFamily $productFamily = null,
?Product $product = null,
): int
{
$qb = $this->prepareQueryBuilder(
webspace: $webspace,
locale: $locale,
productCategory: $productCategory,
productFamily: $productFamily,
product: $product,
);
$qb->select('MIN(pv.luminousFlux)');
return $qb->getQuery()->getSingleScalarResult() ?? 0;
}
public function getMaxLuminousFlux(
string $webspace,
string $locale,
?ProductCategory $productCategory = null,
?ProductFamily $productFamily = null,
?Product $product = null,
): int
{
$qb = $this->prepareQueryBuilder(
webspace: $webspace,
locale: $locale,
productCategory: $productCategory,
productFamily: $productFamily,
product: $product,
);
$qb->select('MAX(pv.luminousFlux)');
return $qb->getQuery()->getSingleScalarResult() ?? 0;
}
public function addMinLuminousFluxToQueryBuilder(QueryBuilder $qb, ?int $minLuminousFlux): void
{
if($minLuminousFlux !== null) {
$qb->andWhere('pv.luminousFlux >= :minLuminousFlux')
->setParameter('minLuminousFlux', $minLuminousFlux);
}
}
public function addMaxLuminousFluxToQueryBuilder(QueryBuilder $qb, ?int $maxLuminousFlux): void
{
if($maxLuminousFlux !== null) {
$qb->andWhere('pv.luminousFlux <= :maxLuminousFlux')
->setParameter('maxLuminousFlux', $maxLuminousFlux);
}
}
// **********************************
// Index podání barev
// **********************************
public function getAllCris(string $webspace, string $locale): array
{
$qb = $this->prepareQueryBuilder($webspace, $locale)
->andWhere('pv.cri <> \'\'')
->select('pv.cri')
->distinct();
$results = $qb->getQuery()->getSingleColumnResult();
$cris = [];
foreach ($results as $result) {
$items = array_map('trim', explode(',', $result));
$cris = array_merge($cris, $items);
}
$cris = uString::asort($cris);
return array_unique($cris);
}
public function addCrisToQueryBuilder(QueryBuilder $qb, ?array $cris): void
{
if($cris !== null) {
$this->andWhereInIn($qb, 'pv.cri', $cris);
}
}
// **********************************
// Teplota chromatičnosti
// **********************************
public function getAllChromaticities(string $webspace, string $locale): array
{
$qb = $this->prepareQueryBuilder($webspace, $locale)
->andWhere('pv.chromaticity <> \'\'')
->select('pv.chromaticity')
->orderBy('pv.chromaticity', 'ASC')
->distinct();
return $qb->getQuery()->getSingleColumnResult();
}
public function addChromaticitiesToQueryBuilder(QueryBuilder $qb, ?array $chromaticities): void
{
if($chromaticities !== null) {
$qb->andWhere($qb->expr()->in('pv.chromaticity', ':chromaticities'))
->setParameter('chromaticities', $chromaticities);
}
}
// **********************************
// Varianta difúzoru
// **********************************
public function getAllDispersionVariants(string $webspace, string $locale): array
{
$qb = $this->prepareQueryBuilder($webspace, $locale)
->andWhere('pv.dispersionVariant <> \'\'')
->select('pv.dispersionVariant')
->distinct();
$results = $qb->getQuery()->getSingleColumnResult();
$dispersionVariants = [];
foreach ($results as $result) {
$items = array_map('trim', explode(',', $result));
$dispersionVariants = array_merge($dispersionVariants, $items);
}
$dispersionVariants = uString::asort($dispersionVariants);
return array_unique($dispersionVariants);
}
public function addDispersionVariantsToQueryBuilder(QueryBuilder $qb, ?array $dispersionVariants): void
{
if($dispersionVariants !== null) {
$this->andWhereInIn($qb, 'pv.dispersionVariant', $dispersionVariants);
}
}
// **********************************
// IP stupeň krytí
// **********************************
public function getAllIps(string $webspace, string $locale): array
{
$qb = $this->prepareQueryBuilder($webspace, $locale)
->andWhere('pv.protectClass <> \'\'')
->select('pv.protectClass')
->distinct();
$results = $qb->getQuery()->getSingleColumnResult();
$ips = [];
foreach ($results as $result) {
$items = array_map('trim', explode(',', $result));
$ips = array_merge($ips, $items);
}
$ips = uString::asort($ips);
return array_unique($ips);
}
public function addIpsToQueryBuilder(QueryBuilder $qb, ?array $ips): void
{
if($ips !== null) {
$this->andWhereInIn($qb, 'pv.protectClass', $ips);
}
}
// **********************************
// Směr svícení
// **********************************
public function getAllRadiationDirects(string $webspace, string $locale): array
{
$qb = $this->prepareQueryBuilder($webspace, $locale)
->andWhere('pv.radiationDirect <> \'\'')
->select('pv.radiationDirect')
->orderBy('pv.radiationDirect', 'ASC')
->distinct();
return $qb->getQuery()->getSingleColumnResult();
}
public function addRadiationDirectsToQueryBuilder(QueryBuilder $qb, ?array $radiationDirects): void
{
if($radiationDirects !== null) {
$qb->andWhere($qb->expr()->in('pv.radiationDirect', ':radiationDirects'))
->setParameter('radiationDirects', $radiationDirects);
}
}
// **********************************
// Tvar
// **********************************
public function getAllShapes(string $webspace, string $locale): array
{
$qb = $this->prepareQueryBuilder($webspace, $locale)
->andWhere('pv.shape <> \'\'')
->select('pv.shape')
->distinct();
$results = $qb->getQuery()->getSingleColumnResult();
$shapes = [];
foreach ($results as $result) {
$items = array_map('trim', explode(',', $result));
$shapes = array_merge($shapes, $items);
}
$shapes = uString::asort($shapes);
return array_unique($shapes);
}
public function addShapesToQueryBuilder(QueryBuilder $qb, ?array $shapes): void
{
if($shapes !== null) {
$this->andWhereInIn($qb, 'pv.shape', $shapes);
}
}
// **********************************
// Délka [mm]
// **********************************
public function getMinLength(
string $webspace,
string $locale,
?ProductCategory $productCategory = null,
?ProductFamily $productFamily = null,
?Product $product = null,
): int
{
$qb = $this->prepareQueryBuilder(
webspace: $webspace,
locale: $locale,
productCategory: $productCategory,
productFamily: $productFamily,
product: $product,
);
$qb->select('MIN(pv.dimensionA)');
return $qb->getQuery()->getSingleScalarResult() ?? 0;
}
public function getMaxLength(
string $webspace,
string $locale,
?ProductCategory $productCategory = null,
?ProductFamily $productFamily = null,
?Product $product = null,
): int
{
$qb = $this->prepareQueryBuilder(
webspace: $webspace,
locale: $locale,
productCategory: $productCategory,
productFamily: $productFamily,
product: $product,
);
$qb->select('MAX(pv.dimensionA)');
return $qb->getQuery()->getSingleScalarResult() ?? 0;
}
public function addMinLengthToQueryBuilder(QueryBuilder $qb, ?int $minLength): void
{
if($minLength !== null) {
$qb->andWhere('pv.dimensionA >= :minLength')
->setParameter('minLength', $minLength);
}
}
public function addMaxLengthToQueryBuilder(QueryBuilder $qb, ?int $maxLength): void
{
if($maxLength !== null) {
$qb->andWhere('pv.dimensionA <= :maxLength')
->setParameter('maxLength', $maxLength);
}
}
// **********************************
// Šířka, Průměr [mm]
// **********************************
public function getMinWidth(
string $webspace,
string $locale,
?ProductCategory $productCategory = null,
?ProductFamily $productFamily = null,
?Product $product = null,
): int
{
$qb = $this->prepareQueryBuilder(
webspace: $webspace,
locale: $locale,
productCategory: $productCategory,
productFamily: $productFamily,
product: $product,
);
$qb->select('MIN(pv.dimensionB)');
return $qb->getQuery()->getSingleScalarResult() ?? 0;
}
public function getMaxWidth(
string $webspace,
string $locale,
?ProductCategory $productCategory = null,
?ProductFamily $productFamily = null,
?Product $product = null,
): int
{
$qb = $this->prepareQueryBuilder(
webspace: $webspace,
locale: $locale,
productCategory: $productCategory,
productFamily: $productFamily,
product: $product,
);
$qb->select('MAX(pv.dimensionB)');
return $qb->getQuery()->getSingleScalarResult() ?? 0;
}
public function addMinWidthToQueryBuilder(QueryBuilder $qb, ?int $minWidth): void
{
if($minWidth !== null) {
$qb->andWhere('pv.dimensionB >= :minWidth')
->setParameter('minWidth', $minWidth);
}
}
public function addMaxWidthToQueryBuilder(QueryBuilder $qb, ?int $maxWidth): void
{
if($maxWidth !== null) {
$qb->andWhere('pv.dimensionB <= :maxWidth')
->setParameter('maxWidth', $maxWidth);
}
}
// **********************************
// Výška [mm]
// **********************************
public function getMinHeight(
string $webspace,
string $locale,
?ProductCategory $productCategory = null,
?ProductFamily $productFamily = null,
?Product $product = null,
): int
{
$qb = $this->prepareQueryBuilder(
webspace: $webspace,
locale: $locale,
productCategory: $productCategory,
productFamily: $productFamily,
product: $product,
);
$qb->select('MIN(pv.dimensionC)');
return $qb->getQuery()->getSingleScalarResult() ?? 0;
}
public function getMaxHeight(
string $webspace,
string $locale,
?ProductCategory $productCategory = null,
?ProductFamily $productFamily = null,
?Product $product = null,
): int
{
$qb = $this->prepareQueryBuilder(
webspace: $webspace,
locale: $locale,
productCategory: $productCategory,
productFamily: $productFamily,
product: $product,
);
$qb->select('MAX(pv.dimensionC)');
return $qb->getQuery()->getSingleScalarResult() ?? 0;
}
public function addMinHeightToQueryBuilder(QueryBuilder $qb, ?int $minHeight): void
{
if($minHeight !== null) {
$qb->andWhere('pv.dimensionC >= :minHeight')
->setParameter('minHeight', $minHeight);
}
}
public function addMaxHeightToQueryBuilder(QueryBuilder $qb, ?int $maxHeight): void
{
if($maxHeight !== null) {
$qb->andWhere('pv.dimensionC <= :maxHeight')
->setParameter('maxHeight', $maxHeight);
}
}
// **********************************
// Barva svítidla
// **********************************
public function getAllColors(string $webspace, string $locale): array
{
$qb = $this->prepareQueryBuilder($webspace, $locale)
->andWhere('pv.color <> \'\'')
->select('pv.color')
->distinct();
$results = $qb->getQuery()->getSingleColumnResult();
$colors = [];
foreach ($results as $result) {
$items = array_map('trim', explode(',', $result));
$colors = array_merge($colors, $items);
}
$colors = uString::asort($colors);
return array_unique($colors);
}
public function addColorsToQueryBuilder(QueryBuilder $qb, ?array $colors): void
{
if($colors !== null) {
$this->andWhereInIn($qb, 'pv.color', $colors);
}
}
// **********************************
// Použití
// **********************************
public function getAllUsages(string $webspace, string $locale): array
{
$qb = $this->prepareQueryBuilder($webspace, $locale)
->andWhere('pv.variantUse <> \'\'')
->select('pv.variantUse')
->distinct();
$results = $qb->getQuery()->getSingleColumnResult();
$usages = [];
foreach ($results as $result) {
$items = array_map('trim', explode(',', $result));
$usages = array_merge($usages, $items);
}
$usages = uString::asort($usages);
return array_unique($usages);
}
public function addUsagesToQueryBuilder(QueryBuilder $qb, ?array $usages): void
{
if($usages !== null) {
$this->andWhereInIn($qb, 'pv.variantUse', $usages);
}
}
// **********************************
// Maximální teplota okolí
// **********************************
public function getAllMaxTemperatures(string $webspace, string $locale): array
{
$qb = $this->prepareQueryBuilder($webspace, $locale)
->andWhere('pv.tempMax <> \'\'')
->select('pv.tempMax')
->distinct();
$results = $qb->getQuery()->getSingleColumnResult();
$maxTemperatures = [];
foreach ($results as $result) {
$items = array_map('trim', explode(',', $result));
$maxTemperatures = array_merge($maxTemperatures, $items);
}
$maxTemperatures = uString::asort($maxTemperatures);
return array_unique($maxTemperatures);
}
public function addMaxTemperaturesToQueryBuilder(QueryBuilder $qb, ?array $maxTemperatures): void
{
if($maxTemperatures !== null) {
$this->andWhereInIn($qb, 'pv.tempMax', $maxTemperatures);
}
}
// **********************************
// Minimální teplota okolí
// **********************************
public function getAllMinTemperatures(string $webspace, string $locale): array
{
$qb = $this->prepareQueryBuilder($webspace, $locale)
->andWhere('pv.tempMin <> \'\'')
->select('pv.tempMin')
->distinct();
$results = $qb->getQuery()->getSingleColumnResult();
$minTemperatures = [];
foreach ($results as $result) {
$items = array_map('trim', explode(',', $result));
$minTemperatures = array_merge($minTemperatures, $items);
}
$minTemperatures = uString::asort($minTemperatures);
return array_unique($minTemperatures);
}
public function addMinTemperaturesToQueryBuilder(QueryBuilder $qb, ?array $minTemperatures): void
{
if($minTemperatures !== null) {
$this->andWhereInIn($qb, 'pv.tempMin', $minTemperatures);
}
}
// **********************************
// Příkon svítidla [W]
// **********************************
public function getMinInputPower(
string $webspace,
string $locale,
?ProductCategory $productCategory = null,
?ProductFamily $productFamily = null,
?Product $product = null,
): int
{
$qb = $this->prepareQueryBuilder(
webspace: $webspace,
locale: $locale,
productCategory: $productCategory,
productFamily: $productFamily,
product: $product,
);
$qb->select('MIN(pv.inputPower)');
return $qb->getQuery()->getSingleScalarResult() ?? 0;
}
public function getMaxInputPower(
string $webspace,
string $locale,
?ProductCategory $productCategory = null,
?ProductFamily $productFamily = null,
?Product $product = null,
): int
{
$qb = $this->prepareQueryBuilder(
webspace: $webspace,
locale: $locale,
productCategory: $productCategory,
productFamily: $productFamily,
product: $product,
);
$qb->select('MAX(pv.inputPower)');
return $qb->getQuery()->getSingleScalarResult() ?? 0;
}
public function addMinInputPowerToQueryBuilder(QueryBuilder $qb, ?int $minInputPower): void
{
if($minInputPower !== null) {
$qb->andWhere('pv.inputPower >= :minInputPower')
->setParameter('minInputPower', $minInputPower);
}
}
public function addMaxInputPowerToQueryBuilder(QueryBuilder $qb, ?int $maxInputPower): void
{
if($maxInputPower !== null) {
$qb->andWhere('pv.inputPower <= :maxInputPower')
->setParameter('maxInputPower', $maxInputPower);
}
}
// **********************************
// Měrný výkon [lm/W]
// **********************************
public function getMinEfficiency(
string $webspace,
string $locale,
?ProductCategory $productCategory = null,
?ProductFamily $productFamily = null,
?Product $product = null,
): int
{
$qb = $this->prepareQueryBuilder(
webspace: $webspace,
locale: $locale,
productCategory: $productCategory,
productFamily: $productFamily,
product: $product,
);
$qb->select('MIN(pv.efficiency)');
return $qb->getQuery()->getSingleScalarResult() ?? 0;
}
public function getMaxEfficiency(
string $webspace,
string $locale,
?ProductCategory $productCategory = null,
?ProductFamily $productFamily = null,
?Product $product = null,
): int
{
$qb = $this->prepareQueryBuilder(
webspace: $webspace,
locale: $locale,
productCategory: $productCategory,
productFamily: $productFamily,
product: $product,
);
$qb->select('MAX(pv.efficiency)');
return $qb->getQuery()->getSingleScalarResult() ?? 0;
}
public function addMinEfficiencyToQueryBuilder(QueryBuilder $qb, ?int $minEfficiency): void
{
if($minEfficiency !== null) {
$qb->andWhere('pv.efficiency >= :minEfficiency')
->setParameter('minEfficiency', $minEfficiency);
}
}
public function addMaxEfficiencyToQueryBuilder(QueryBuilder $qb, ?int $maxEfficiency): void
{
if($maxEfficiency !== null) {
$qb->andWhere('pv.efficiency <= :maxEfficiency')
->setParameter('maxEfficiency', $maxEfficiency);
}
}
// **********************************
// Elektrická třída ochrany
// **********************************
public function getAllElProtects(string $webspace, string $locale): array
{
$qb = $this->prepareQueryBuilder($webspace, $locale)
->andWhere('pv.protectClassEl <> \'\'')
->select('pv.protectClassEl')
->distinct();
$results = $qb->getQuery()->getSingleColumnResult();
$elProtects = [];
foreach ($results as $result) {
$items = array_map('trim', explode(',', $result));
$elProtects = array_merge($elProtects, $items);
}
$elProtects = uString::asort($elProtects);
return array_unique($elProtects);
}
public function addElProtectsToQueryBuilder(QueryBuilder $qb, ?array $elProtects): void
{
if($elProtects !== null) {
$this->andWhereInIn($qb, 'pv.protectClassEl', $elProtects);
}
}
// **********************************
// Metoda napájení
// **********************************
public function getAllPowerMethods(string $webspace, string $locale): array
{
$qb = $this->prepareQueryBuilder($webspace, $locale)
->andWhere('pv.supplyVoltage <> \'\'')
->select('pv.supplyVoltage')
->orderBy('pv.supplyVoltage', 'ASC')
->distinct();
return $qb->getQuery()->getSingleColumnResult();
}
public function addPowerMethodsToQueryBuilder(QueryBuilder $qb, ?array $powerMethods): void
{
if($powerMethods !== null) {
$qb->andWhere($qb->expr()->in('pv.supplyVoltage', ':powerMethods'))
->setParameter('powerMethods', $powerMethods);
}
}
// **********************************
// Světelný zdroj
// **********************************
public function getAllResourceTypes(string $webspace, string $locale): array
{
$qb = $this->prepareQueryBuilder($webspace, $locale)
->andWhere('pv.resourceType <> \'\'')
->select('pv.resourceType')
->distinct();
$results = $qb->getQuery()->getSingleColumnResult();
$resourceTypes = [];
foreach ($results as $result) {
$items = array_map('trim', explode(',', $result));
$resourceTypes = array_merge($resourceTypes, $items);
}
$resourceTypes = uString::asort($resourceTypes);
return array_unique($resourceTypes);
}
public function addResourceTypesToQueryBuilder(QueryBuilder $qb, ?array $resourceTypes): void
{
if($resourceTypes !== null) {
$this->andWhereInIn($qb, 'pv.resourceType', $resourceTypes);
}
}
// public function getAllLightSources(string $webspace, string $locale): array
// {
// $qb = $this->prepareQueryBuilder($webspace, $locale)
// ->andWhere('pv.luminousFluxSupply <> \'\'')
// ->select('pv.luminousFluxSupply')
// ->distinct();
//
// $results = $qb->getQuery()->getSingleColumnResult();
//
// $lightSources = [];
// foreach ($results as $result) {
// $items = array_map('trim', explode(',', $result));
// $lightSources = array_merge($lightSources, $items);
// }
// $lightSources = uString::asort($lightSources);
//
// return array_unique($lightSources);
// }
//
// public function addLightSourcesToQueryBuilder(QueryBuilder $qb, ?array $lightSources): void
// {
// if($lightSources !== null) {
// $this->andWhereInIn($qb, 'pv.luminousFluxSupply', $lightSources);
// }
// }
// **********************************
// Stav produktu
// **********************************
public function getAllStatuses(string $webspace, string $locale): array
{
$qb = $this->prepareQueryBuilder($webspace, $locale)
->andWhere('pv.statusNew <> \'\'')
->select('pv.statusNew')
->distinct();
$results = $qb->getQuery()->getSingleColumnResult();
$statuses = [];
foreach ($results as $result) {
$items = array_map('trim', explode(',', $result));
$statuses = array_merge($statuses, $items);
}
$statuses = uString::asort($statuses);
return array_unique($statuses);
}
public function addStatusesToQueryBuilder(QueryBuilder $qb, ?array $statuses): void
{
if($statuses !== null) {
$this->andWhereInIn($qb, 'pv.statusNew', $statuses);
}
}
// **********************************
// Mechanická odolnost
// **********************************
public function getAllMechanicalDurabilities(string $webspace, string $locale): array
{
$qb = $this->prepareQueryBuilder($webspace, $locale)
->andWhere('pv.mechanicalDurability <> \'\'')
->select('pv.mechanicalDurability')
->distinct();
$results = $qb->getQuery()->getSingleColumnResult();
$mechanicalDurabilities = [];
foreach ($results as $result) {
$items = array_map('trim', explode(',', $result));
$mechanicalDurabilities = array_merge($mechanicalDurabilities, $items);
}
$mechanicalDurabilities = uString::asort($mechanicalDurabilities);
return array_unique($mechanicalDurabilities);
}
public function addMechanicalDurabilitiesToQueryBuilder(QueryBuilder $qb, ?array $mechanicalDurabilities): void
{
if($mechanicalDurabilities !== null) {
$this->andWhereInIn($qb, 'pv.mechanicalDurability', $mechanicalDurabilities);
}
}
// **********************************
// Typ difúzoru
// **********************************
public function getAllDispersions(string $webspace, string $locale): array
{
$qb = $this->prepareQueryBuilder($webspace, $locale)
->andWhere('pv.dispersion <> \'\'')
->select('pv.dispersion')
->distinct();
$results = $qb->getQuery()->getSingleColumnResult();
$dispersions = [];
foreach ($results as $result) {
$items = array_map('trim', explode(',', $result));
$dispersions = array_merge($dispersions, $items);
}
$dispersions = uString::asort($dispersions);
return array_unique($dispersions);
}
public function addDispersionsToQueryBuilder(QueryBuilder $qb, ?array $dispersions): void
{
if($dispersions !== null) {
$this->andWhereInIn($qb, 'pv.dispersion', $dispersions);
}
}
// **********************************
// Předřadník
// **********************************
public function getAllDrivers(string $webspace, string $locale): array
{
$qb = $this->prepareQueryBuilder($webspace, $locale)
->andWhere('pv.driver <> \'\'')
->select('pv.driver')
->distinct();
$results = $qb->getQuery()->getSingleColumnResult();
$drivers = [];
foreach ($results as $result) {
$items = array_map('trim', explode(',', $result));
$drivers = array_merge($drivers, $items);
}
$drivers = uString::asort($drivers);
return array_unique($drivers);
}
public function addDriversToQueryBuilder(QueryBuilder $qb, ?array $drivers): void
{
if($drivers !== null) {
$this->andWhereInIn($qb, 'pv.driver', $drivers);
}
}
// **********************************
// Doplňující výbava
// **********************************
public function getAllAccessories(string $webspace, string $locale): array
{
$qb = $this->prepareQueryBuilder($webspace, $locale)
->andWhere('pv.supplements <> \'\'')
->select('pv.supplements')
->distinct();
$results = $qb->getQuery()->getSingleColumnResult();
$accessories = [];
foreach ($results as $result) {
$items = array_map('trim', explode(',', $result));
$accessories = array_merge($accessories, $items);
}
$accessories = uString::asort($accessories);
return array_unique($accessories);
}
public function getTitlesByAccessoryCodes(string $webspace, string $locale, array $accessoryIds): array
{
$qb = $this->prepareQueryBuilder($webspace, $locale)
->select('pv.productCode, pv.title')
->andWhere('pv.productCode IN (:codes)')
->setParameter('codes', $accessoryIds)
->distinct();
$results = $qb->getQuery()->getResult();
$titles = [];
foreach ($results as $result) {
$titles[$result['productCode']] = $result['title'];
}
return $titles;
}
public function addAccessoriesToQueryBuilder(QueryBuilder $qb, ?array $accessories): void
{
if($accessories !== null) {
$this->andWhereInIn($qb, 'pv.supplements', $accessories);
}
}
// **********************************
}