Add properties filtering and relationships in Product model

This commit is contained in:
2026-02-05 01:08:07 +05:00
parent 45bc0b61a1
commit 38fa0e2e45
11 changed files with 227 additions and 2 deletions

View File

@@ -0,0 +1,47 @@
<?php
namespace App\Console\Commands;
use App\Models\Ecommerce\Product\Product\Product;
use Illuminate\Console\Command;
class SyncProductPropertiesJson extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'products:sync-properties-json';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Syncs all product properties to the new JSON column';
/**
* Execute the console command.
*/
public function handle()
{
$this->info('Starting sync of product properties JSON...');
// Using cursor to be memory efficient
$products = Product::cursor();
$count = Product::count();
$bar = $this->output->createProgressBar($count);
$bar->start();
foreach ($products as $product) {
$product->syncPropertiesJson();
$bar->advance();
}
$bar->finish();
$this->newLine();
$this->info('Sync completed successfully!');
}
}