optimized storefront page and images

This commit is contained in:
2026-09-24 14:12:49 -03:00
parent 8d5a12f212
commit a2439bf43b
517 changed files with 311 additions and 12 deletions

View File

@@ -11,7 +11,9 @@ return new class extends Migration
private const MANIFEST = 'data/mutual_smep_catalog_v1.json';
private const STORAGE_PREFIX = 'tenants/mutual_smep/catalog-v1/';
private const STORAGE_PREFIX = 'tenants/mutual_smep/catalog-v2/';
private const LEGACY_STORAGE_PREFIX = 'tenants/mutual_smep/catalog-v1/';
private const BRAND_MARKER = 'Provisioned by Mutual SMEP catalog migration v1.';
@@ -27,6 +29,8 @@ return new class extends Migration
private const HIGHLIGHTED_GROUP_CODE = 'productos-destacados-smep';
private const CATEGORY_FEATURED_ITEM_LIMIT = 6;
/** @var list<string> */
private const HIGHLIGHTED_PRODUCT_SLUGS = [
'acolchado-kavanagh-simil-plumon-reversible',
@@ -178,7 +182,9 @@ return new class extends Migration
->values();
$storedPaths = DB::table('attachments')
->whereIn('id', $attachmentIds)
->where('path', 'like', self::STORAGE_PREFIX.'%')
->where(fn ($query) => $query
->where('path', 'like', self::STORAGE_PREFIX.'%')
->orWhere('path', 'like', self::LEGACY_STORAGE_PREFIX.'%'))
->pluck('path')
->all();
@@ -360,6 +366,7 @@ return new class extends Migration
->where('categorias.categoria_id', $categoryId)
->orderBy('catalog_items.group_order')
->orderBy('catalog_items.id')
->limit(self::CATEGORY_FEATURED_ITEM_LIMIT)
->pluck('catalog_items.id');
foreach ($catalogItemIds as $itemOrder => $catalogItemId) {

View File

@@ -0,0 +1,88 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Support\Facades\DB;
return new class extends Migration
{
private const TENANT_CODE = 'mutual_smep';
private const ITEM_LIMIT = 6;
/** @var array<string, string> */
private const GROUPS = [
'smep-dormitorio-y-blanco' => 'Dormitorio y Blanco',
'smep-electrodomesticos' => 'Electrodomésticos',
'smep-climatizacion' => 'Climatización',
'smep-tecnologia' => 'Tecnología',
'smep-bicicletas-y-aire-libre' => 'Bicicletas y Aire Libre',
'smep-bazar' => 'Bazar',
];
public function up(): void
{
foreach (array_keys(self::GROUPS) as $code) {
$groupId = DB::table('featured_groups')
->where('tenant_code', self::TENANT_CODE)
->where('code', $code)
->value('id');
if ($groupId === null) {
continue;
}
$keptItemIds = DB::table('featured_items')
->where('featured_group_id', $groupId)
->orderBy('order')
->orderBy('id')
->limit(self::ITEM_LIMIT)
->pluck('id');
DB::table('featured_items')
->where('featured_group_id', $groupId)
->when(
$keptItemIds->isNotEmpty(),
fn ($query) => $query->whereNotIn('id', $keptItemIds),
)
->delete();
}
}
public function down(): void
{
foreach (self::GROUPS as $code => $parentCategoryName) {
$groupId = DB::table('featured_groups')
->where('tenant_code', self::TENANT_CODE)
->where('code', $code)
->value('id');
$parentCategoryId = DB::table('categorias')
->where('tenant_code', self::TENANT_CODE)
->whereNull('categoria_id')
->where('nombre', $parentCategoryName)
->value('id');
if ($groupId === null || $parentCategoryId === null) {
continue;
}
$catalogItemIds = DB::table('catalog_items')
->join('categorias', 'categorias.id', '=', 'catalog_items.category_id')
->where('catalog_items.tenant_code', self::TENANT_CODE)
->where('categorias.tenant_code', self::TENANT_CODE)
->where('categorias.categoria_id', $parentCategoryId)
->orderBy('catalog_items.group_order')
->orderBy('catalog_items.id')
->pluck('catalog_items.id');
DB::table('featured_items')->where('featured_group_id', $groupId)->delete();
foreach ($catalogItemIds as $order => $catalogItemId) {
DB::table('featured_items')->insert([
'featured_group_id' => $groupId,
'catalog_item_id' => $catalogItemId,
'order' => $order + 1,
]);
}
}
}
};

View File

@@ -0,0 +1,111 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Storage;
use Illuminate\Support\Str;
return new class extends Migration
{
private const TENANT_CODE = 'mutual_smep';
private const LEGACY_PREFIX = 'tenants/mutual_smep/catalog-v1/';
private const OPTIMIZED_PREFIX = 'tenants/mutual_smep/catalog-v2/';
private const LOCAL_PREFIX = 'images/tennants/mutual_smep/catalog/';
public function up(): void
{
$attachments = $this->attachments(self::LEGACY_PREFIX);
$uploadedPaths = [];
try {
foreach ($attachments as $attachment) {
$relativePath = Str::after($attachment->path, self::LEGACY_PREFIX);
$localPath = public_path(self::LOCAL_PREFIX.$relativePath);
if (! is_file($localPath)) {
throw new RuntimeException("Optimized catalog image not found: {$localPath}");
}
$contents = file_get_contents($localPath);
if ($contents === false) {
throw new RuntimeException("Optimized catalog image could not be read: {$localPath}");
}
$optimizedPath = self::OPTIMIZED_PREFIX.$relativePath;
if (! Storage::disk('s3')->put($optimizedPath, $contents)) {
throw new RuntimeException("Optimized catalog image could not be stored: {$optimizedPath}");
}
$uploadedPaths[] = $optimizedPath;
$attachment->optimized_path = $optimizedPath;
$attachment->optimized_size = strlen($contents);
}
DB::transaction(function () use ($attachments): void {
foreach ($attachments as $attachment) {
DB::table('attachments')->where('id', $attachment->id)->update([
'path' => $attachment->optimized_path,
'size' => $attachment->optimized_size,
'updated_at' => now(),
]);
}
});
} catch (Throwable $throwable) {
Storage::disk('s3')->delete($uploadedPaths);
throw $throwable;
}
}
public function down(): void
{
$attachments = $this->attachments(self::OPTIMIZED_PREFIX)
->filter(function (object $attachment): bool {
$relativePath = Str::after($attachment->path, self::OPTIMIZED_PREFIX);
$legacyPath = self::LEGACY_PREFIX.$relativePath;
if (! Storage::disk('s3')->exists($legacyPath)) {
return false;
}
$attachment->legacy_path = $legacyPath;
$attachment->legacy_size = Storage::disk('s3')->size($legacyPath);
return true;
})
->values();
DB::transaction(function () use ($attachments): void {
foreach ($attachments as $attachment) {
DB::table('attachments')->where('id', $attachment->id)->update([
'path' => $attachment->legacy_path,
'size' => $attachment->legacy_size,
'updated_at' => now(),
]);
}
});
Storage::disk('s3')->delete($attachments->pluck('path')->all());
}
private function attachments(string $prefix): \Illuminate\Support\Collection
{
return DB::table('attachments')
->join(
'catalog_items_attachments',
'catalog_items_attachments.attachment_id',
'=',
'attachments.id',
)
->join('catalog_items', 'catalog_items.id', '=', 'catalog_items_attachments.catalog_item_id')
->where('catalog_items.tenant_code', self::TENANT_CODE)
->where('attachments.path', 'like', $prefix.'%')
->select('attachments.id', 'attachments.path', 'attachments.size')
->distinct()
->orderBy('attachments.id')
->get();
}
};

View File

@@ -2,6 +2,9 @@
declare(strict_types=1);
const CATALOG_IMAGE_MAX_DIMENSION = 960;
const CATALOG_IMAGE_WEBP_QUALITY = 76;
$sourceRoot = 'C:\\Users\\ncoronel\\Documents\\catalogo_smep_limpio';
$projectRoot = dirname(__DIR__, 2);
$assetRoot = $projectRoot.'/public/images/tennants/mutual_smep/catalog';
@@ -153,7 +156,7 @@ function compressCatalogImage(string $source, string $destination): void
$width = imagesx($sourceImage);
$height = imagesy($sourceImage);
$scale = min(1, 1200 / max($width, $height));
$scale = min(1, CATALOG_IMAGE_MAX_DIMENSION / max($width, $height));
$targetWidth = max(1, (int) round($width * $scale));
$targetHeight = max(1, (int) round($height * $scale));
$targetImage = imagecreatetruecolor($targetWidth, $targetHeight);
@@ -181,7 +184,7 @@ function compressCatalogImage(string $source, string $destination): void
throw new RuntimeException("Unable to create directory: {$destinationDirectory}");
}
if (! imagewebp($targetImage, $destination, 82)) {
if (! imagewebp($targetImage, $destination, CATALOG_IMAGE_WEBP_QUALITY)) {
throw new RuntimeException("Unable to write WebP image: {$destination}");
}
}

View File

@@ -177,14 +177,14 @@ También se crearon seis filas adicionales, una por cada categoría principal:
| Sección | Productos incluidos |
|---|---:|
| Dormitorio y Blanco | 24 |
| Electrodomésticos | 53 |
| Climatización | 16 |
| Tecnología | 36 |
| Bicicletas y Aire Libre | 10 |
| Dormitorio y Blanco | 6 |
| Electrodomésticos | 6 |
| Climatización | 6 |
| Tecnología | 6 |
| Bicicletas y Aire Libre | 6 |
| Bazar | 3 |
Los **142 productos** aparecen dentro de la sección que les corresponde. Algunos también se repiten en “Productos destacados” de manera intencional, porque esa primera fila funciona como vidriera y no como una categoría adicional.
Estas filas funcionan como una vidriera breve: muestran una selección de cada rubro sin sobrecargar la portada. Los **142 productos** continúan disponibles mediante las categorías, subcategorías y el buscador. Algunos artículos también se repiten en “Productos destacados” de manera intencional.
## 7. Principales mejoras para los clientes

Binary file not shown.

Before

Width:  |  Height:  |  Size: 71 KiB

After

Width:  |  Height:  |  Size: 45 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 61 KiB

After

Width:  |  Height:  |  Size: 49 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 82 KiB

After

Width:  |  Height:  |  Size: 50 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 92 KiB

After

Width:  |  Height:  |  Size: 56 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 66 KiB

After

Width:  |  Height:  |  Size: 45 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 49 KiB

After

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 48 KiB

After

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 92 KiB

After

Width:  |  Height:  |  Size: 56 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 66 KiB

After

Width:  |  Height:  |  Size: 45 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 82 KiB

After

Width:  |  Height:  |  Size: 50 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 75 KiB

After

Width:  |  Height:  |  Size: 42 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 75 KiB

After

Width:  |  Height:  |  Size: 44 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 45 KiB

After

Width:  |  Height:  |  Size: 29 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 49 KiB

After

Width:  |  Height:  |  Size: 29 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 161 KiB

After

Width:  |  Height:  |  Size: 89 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 55 KiB

After

Width:  |  Height:  |  Size: 33 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 33 KiB

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 161 KiB

After

Width:  |  Height:  |  Size: 89 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 105 KiB

After

Width:  |  Height:  |  Size: 58 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 105 KiB

After

Width:  |  Height:  |  Size: 60 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 27 KiB

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 27 KiB

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 72 KiB

After

Width:  |  Height:  |  Size: 43 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 88 KiB

After

Width:  |  Height:  |  Size: 53 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 107 KiB

After

Width:  |  Height:  |  Size: 63 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 100 KiB

After

Width:  |  Height:  |  Size: 61 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 92 KiB

After

Width:  |  Height:  |  Size: 58 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 88 KiB

After

Width:  |  Height:  |  Size: 49 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 61 KiB

After

Width:  |  Height:  |  Size: 34 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 148 KiB

After

Width:  |  Height:  |  Size: 95 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.8 KiB

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.3 KiB

After

Width:  |  Height:  |  Size: 5.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.1 KiB

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 24 KiB

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 26 KiB

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 8.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.8 KiB

After

Width:  |  Height:  |  Size: 5.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 6.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 20 KiB

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 73 KiB

After

Width:  |  Height:  |  Size: 44 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.6 KiB

After

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 44 KiB

After

Width:  |  Height:  |  Size: 25 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 10 KiB

After

Width:  |  Height:  |  Size: 5.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 6.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.0 KiB

After

Width:  |  Height:  |  Size: 5.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.9 KiB

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.4 KiB

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.8 KiB

After

Width:  |  Height:  |  Size: 5.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.8 KiB

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 7.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 10 KiB

After

Width:  |  Height:  |  Size: 5.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.9 KiB

After

Width:  |  Height:  |  Size: 4.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 9.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 6.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 21 KiB

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 24 KiB

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 29 KiB

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 30 KiB

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 24 KiB

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 24 KiB

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 37 KiB

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 6.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 8.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 9.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 7.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 53 KiB

After

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 18 KiB

After

Width:  |  Height:  |  Size: 9.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 22 KiB

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 23 KiB

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 27 KiB

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 20 KiB

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 27 KiB

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 37 KiB

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.0 KiB

After

Width:  |  Height:  |  Size: 5.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 21 KiB

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.6 KiB

After

Width:  |  Height:  |  Size: 4.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 22 KiB

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 21 KiB

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.3 KiB

After

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.9 KiB

After

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 33 KiB

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 40 KiB

After

Width:  |  Height:  |  Size: 33 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.7 KiB

After

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

After

Width:  |  Height:  |  Size: 9.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 42 KiB

After

Width:  |  Height:  |  Size: 29 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 27 KiB

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 71 KiB

After

Width:  |  Height:  |  Size: 46 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 31 KiB

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 37 KiB

After

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.6 KiB

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.0 KiB

After

Width:  |  Height:  |  Size: 4.6 KiB

Some files were not shown because too many files have changed in this diff Show More