$query->
from('product', 'product'
);
$query->
innerJoin('product', 'product_price', 'price', 'price.product_id = product.prices AND product.version_id = price.product_version_id'
);
$query->
leftJoin('product', 'product', 'parent', 'parent.id = product.parent_id'
);
$query->
andWhere('product.id IN (:ids) OR product.parent_id IN (:ids)'
);
$query->
andWhere('product.version_id = :version'
);
$query->
andWhere('IFNULL(product.active, parent.active) = 1'
);
$query->
andWhere('(product.child_count = 0 OR product.parent_id IS NOT NULL)'
);
$this->quantitySelector->
add($query);
$ids = Uuid::
fromHexToBytesList($ids);
$query->
setParameter('ids',
$ids, ArrayParameterType::STRING
);
$query->
setParameter('version', Uuid::
fromHexToBytes($context->
getVersionId()));
$data =
$query->
executeQuery()->
fetchAllAssociative();
$grouped =
[];
/** @var array<string, mixed> $row */
foreach ($data as $row) { $row['price'
] =
json_decode((string) $row['price'
], true, 512, \JSON_THROW_ON_ERROR
);
$grouped[$row['parent_id'
]][$row['variant_id'
]][$row['rule_id'
]] =
$row;
}