feat: add product catalog image seeder and support assets
This commit is contained in:
parent
67c2a7350e
commit
6d0d600b4b
|
|
@ -31,6 +31,7 @@ class ProductCatalogFromImagesSeeder extends Seeder
|
|||
'variant_groups' => [
|
||||
'pantalon_blanco' => ['stock' => 14],
|
||||
'pantalon_negro' => ['stock' => 14],
|
||||
'pantalon_azul' => ['stock' => 0],
|
||||
],
|
||||
],
|
||||
'remera' => [
|
||||
|
|
@ -38,6 +39,7 @@ class ProductCatalogFromImagesSeeder extends Seeder
|
|||
'variant_groups' => [
|
||||
'remera_blanca' => ['stock' => 22],
|
||||
'remera_negra' => ['stock' => 22],
|
||||
'remera_azul' => ['stock' => 0],
|
||||
],
|
||||
],
|
||||
'zapatillas_lecoq' => ['price' => 109999, 'stock' => 6],
|
||||
|
|
@ -261,8 +263,23 @@ class ProductCatalogFromImagesSeeder extends Seeder
|
|||
'value' => $size,
|
||||
];
|
||||
|
||||
// Override stock for specific variants as requested by the user
|
||||
$stock = $variantGroup['stock'];
|
||||
$productType = $metadata['type'];
|
||||
$color = $variantGroup['metadata']['color'];
|
||||
|
||||
if ($productType === 'remera' && $color === 'Blanco' && $size === 'L') {
|
||||
$stock = 0;
|
||||
} elseif ($productType === 'remera' && $color === 'Negro' && $size === 'S') {
|
||||
$stock = 0;
|
||||
} elseif ($productType === 'pantalon' && $color === 'Negro' && $size === 'XL') {
|
||||
$stock = 0;
|
||||
} elseif ($productType === 'pantalon' && $color === 'Blanco' && $size === 'M') {
|
||||
$stock = 0;
|
||||
}
|
||||
|
||||
$this->productService->createVariant($product, [
|
||||
'stock' => $variantGroup['stock'],
|
||||
'stock' => $stock,
|
||||
'definitions' => $definitions,
|
||||
'images' => $images,
|
||||
]);
|
||||
|
|
@ -334,7 +351,7 @@ class ProductCatalogFromImagesSeeder extends Seeder
|
|||
$color = null;
|
||||
$brandSegments = $segments;
|
||||
|
||||
if (isset($segments[0]) && in_array($segments[0], ['blanco', 'blanca', 'negro', 'negra', 'gris'], true)) {
|
||||
if (isset($segments[0]) && in_array($segments[0], ['blanco', 'blanca', 'negro', 'negra', 'gris', 'azul'], true)) {
|
||||
$color = $this->normalizeColor($segments[0]);
|
||||
$brandSegments = array_slice($segments, 1);
|
||||
}
|
||||
|
|
@ -384,6 +401,7 @@ class ProductCatalogFromImagesSeeder extends Seeder
|
|||
'blanco', 'blanca' => 'Blanco',
|
||||
'negro', 'negra' => 'Negro',
|
||||
'gris' => 'Gris',
|
||||
'azul' => 'Azul',
|
||||
default => throw new RuntimeException("Unsupported color '{$color}'."),
|
||||
};
|
||||
}
|
||||
|
|
|
|||
Binary file not shown.
|
After Width: | Height: | Size: 128 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 40 KiB |
Loading…
Reference in New Issue