Start working on handling multiple countries at once

This commit is contained in:
2026-01-17 09:56:40 +01:00
parent 03b74aa33d
commit 22e4034ae3
4 changed files with 28 additions and 19 deletions

View File

@@ -41,6 +41,7 @@ class Migrate extends Command
$this->createStocksTable();
$this->addColumns();
$this->createCountriesTable();
$this->index();
return Command::SUCCESS;
}
@@ -170,4 +171,12 @@ class Migrate extends Command
});
}
}
public function index(): void
{
Capsule::schema()->table('products', function (Blueprint $table) {
$table->integer('skuID')->unique(false)->change();
$table->unique(['skuID', 'country_id']);
});
}
}

View File

@@ -56,16 +56,16 @@ class ScrapeWebsite extends Command
$products = Product::all();
$progress->setMaxSteps(count($products));
$progress->start();
// foreach($products as $product) {
// $newestPrice = $product->newestPrice;
// $product->priceCurrent = $newestPrice->price;
// $product->productStandardPrice = $newestPrice->productStandardPrice;
// $product->lowestProductPrice30Days = $newestPrice->lowestProductPrice30Days;
// $product->priceLowest = $product->lowestPrice->price;
// $product->lastSeen = $newestPrice->created_at->format('Y-m-d');
// $product->save(['timestamps' => false]);
// $progress->advance();
// }
foreach($products as $product) {
$newestPrice = $product->newestPrice;
$product->priceCurrent = $newestPrice->price;
$product->productStandardPrice = $newestPrice->productStandardPrice;
$product->lowestProductPrice30Days = $newestPrice->lowestProductPrice30Days;
$product->priceLowest = $product->lowestPrice->price;
$product->lastSeen = $newestPrice->created_at->format('Y-m-d');
$product->save(['timestamps' => false]);
$progress->advance();
}
$progress->finish();
$output->writeln('');
$output->writeln('Update prices - DONE');