refactor(variant-selection): update variant options retrieval to use catalog item's variants and enhance response structure
This commit is contained in:
@@ -38,7 +38,7 @@ class VariantSelectionService
|
||||
$matchingVariants = $variants
|
||||
->filter(fn (Variant $variant): bool => $this->matches($variant, $normalizedSelections))
|
||||
->values();
|
||||
$attributeKeys = $this->attributeKeys($catalogItem, $variants);
|
||||
$attributeKeys = $this->attributeKeys($catalogItem, $catalogItem->variants->values());
|
||||
$isComplete = $attributeKeys->isNotEmpty()
|
||||
&& $attributeKeys->every(fn (string $key): bool => array_key_exists($key, $normalizedSelections));
|
||||
$resolvedVariant = $isComplete && $matchingVariants->count() === 1
|
||||
@@ -46,6 +46,10 @@ class VariantSelectionService
|
||||
: null;
|
||||
|
||||
return [
|
||||
'variants' => $variants
|
||||
->map(fn (Variant $variant): array => $this->variantData($catalogItem, $variant))
|
||||
->values()
|
||||
->all(),
|
||||
'selectors' => $this->selectors(
|
||||
$catalogItem,
|
||||
$variants,
|
||||
|
||||
Reference in New Issue
Block a user