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' => [
|
'variant_groups' => [
|
||||||
'pantalon_blanco' => ['stock' => 14],
|
'pantalon_blanco' => ['stock' => 14],
|
||||||
'pantalon_negro' => ['stock' => 14],
|
'pantalon_negro' => ['stock' => 14],
|
||||||
|
'pantalon_azul' => ['stock' => 0],
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
'remera' => [
|
'remera' => [
|
||||||
|
|
@ -38,6 +39,7 @@ class ProductCatalogFromImagesSeeder extends Seeder
|
||||||
'variant_groups' => [
|
'variant_groups' => [
|
||||||
'remera_blanca' => ['stock' => 22],
|
'remera_blanca' => ['stock' => 22],
|
||||||
'remera_negra' => ['stock' => 22],
|
'remera_negra' => ['stock' => 22],
|
||||||
|
'remera_azul' => ['stock' => 0],
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
'zapatillas_lecoq' => ['price' => 109999, 'stock' => 6],
|
'zapatillas_lecoq' => ['price' => 109999, 'stock' => 6],
|
||||||
|
|
@ -261,8 +263,23 @@ class ProductCatalogFromImagesSeeder extends Seeder
|
||||||
'value' => $size,
|
'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, [
|
$this->productService->createVariant($product, [
|
||||||
'stock' => $variantGroup['stock'],
|
'stock' => $stock,
|
||||||
'definitions' => $definitions,
|
'definitions' => $definitions,
|
||||||
'images' => $images,
|
'images' => $images,
|
||||||
]);
|
]);
|
||||||
|
|
@ -334,7 +351,7 @@ class ProductCatalogFromImagesSeeder extends Seeder
|
||||||
$color = null;
|
$color = null;
|
||||||
$brandSegments = $segments;
|
$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]);
|
$color = $this->normalizeColor($segments[0]);
|
||||||
$brandSegments = array_slice($segments, 1);
|
$brandSegments = array_slice($segments, 1);
|
||||||
}
|
}
|
||||||
|
|
@ -384,6 +401,7 @@ class ProductCatalogFromImagesSeeder extends Seeder
|
||||||
'blanco', 'blanca' => 'Blanco',
|
'blanco', 'blanca' => 'Blanco',
|
||||||
'negro', 'negra' => 'Negro',
|
'negro', 'negra' => 'Negro',
|
||||||
'gris' => 'Gris',
|
'gris' => 'Gris',
|
||||||
|
'azul' => 'Azul',
|
||||||
default => throw new RuntimeException("Unsupported color '{$color}'."),
|
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