refactor(catalog): add ticket_label to item attributes and update related logic

This commit is contained in:
2026-08-19 11:22:46 -03:00
parent 67e6211857
commit 16bc657a31
12 changed files with 114 additions and 11 deletions

View File

@@ -29,19 +29,27 @@ class TicketPresentationResolver
return $catalogItem->nombre;
}
$properties = $variant->selectionOptions()
->flatMap(function (array $option): array {
if (array_is_list($option)) {
return collect($option)
->pluck('label')
->filter(fn ($label): bool => is_string($label) && $label !== '')
->all();
$itemAttributes = $variant->catalogItem->itemAttributes;
$properties = $variant->selectionOptions($itemAttributes)
->map(function (array $option, string $attributeCode) use ($itemAttributes): ?string {
$labels = collect(array_is_list($option) ? $option : [$option])
->pluck('label')
->filter(fn ($label): bool => is_string($label) && $label !== '')
->implode(', ');
if ($labels === '') {
return null;
}
$label = $option['label'] ?? null;
$ticketLabel = $itemAttributes->first(
fn ($itemAttribute): bool => $itemAttribute->attribute?->codigo === $attributeCode,
)?->ticket_label;
return is_string($label) && $label !== '' ? [$label] : [];
return is_string($ticketLabel) && trim($ticketLabel) !== ''
? trim($ticketLabel).' '.$labels
: $labels;
})
->filter()
->values();
return $properties->isEmpty()