feat: enhance item attributes management by adding sort order; update related models, resources, and tests for visibility and ordering of variants

This commit is contained in:
2026-08-10 13:58:35 -03:00
parent e7c8807a67
commit 8542c03466
18 changed files with 252 additions and 19 deletions

View File

@@ -182,9 +182,10 @@ class CatalogService
'bundleComponents.variant.definitions.itemAttribute.attribute',
]);
$visibleVariants = $catalogItem->visibleVariants();
$selectedVariant = $variantId === null
? $catalogItem->variants->first()
: $catalogItem->variants->firstWhere('id', $variantId);
? $visibleVariants->first()
: $visibleVariants->firstWhere('id', $variantId);
if ($variantId !== null && $selectedVariant === null) {
throw new NotFoundHttpException('Variant not found for catalog item.');
@@ -227,6 +228,7 @@ class CatalogService
'attachments',
'inventory',
'validityTime',
'itemAttributes.attribute',
'variants.inventory',
'variants.attachments',
'variants.eventDate',
@@ -261,6 +263,7 @@ class CatalogService
'attachments',
'inventory',
'validityTime',
'itemAttributes.attribute',
'variants.inventory',
'variants.attachments',
'variants.eventDate',