<?php
require __DIR__ . '/vendor/autoload.php';
$app = require __DIR__ . '/bootstrap/app.php';
$app->make(\Illuminate\Contracts\Console\Kernel::class)->bootstrap();

// Fix: update SKUs to use slug-based values (matching new import command)
\DB::table('products')->where('slug', 'claas-webtic-offline')->update([
    'sku' => 'CLAAS-WEBTIC-OFFLINE',
]);

\DB::table('products')->where('slug', 'komatsu-css-net-epc-europe')->update([
    'sku' => 'KOMATSU-CSS-NET-EPC-EUROPE',
]);

// Also check for any other SKUs that might collide
$dupes = \DB::table('products')
    ->select('sku', \DB::raw('count(*) as cnt'))
    ->groupBy('sku')
    ->having('cnt', '>', 1)
    ->get();

if ($dupes->count() > 0) {
    echo "Remaining SKU duplicates:\n";
    foreach ($dupes as $d) {
        echo "  {$d->sku}: {$d->cnt} products\n";
    }
} else {
    echo "No remaining SKU duplicates\n";
}

echo "Done\n";
