- Added a call to sync properties JSON in UpdateProductRelations job if the method exists. - Updated ProductFieldsForDetail to provide a default value of '-' for missing property values. - Simplified the insertion logic in ProductPropertyValuesSeeder by replacing 'tm' with 'tk' in the value field and removed commented-out code for clarity.
41 lines
1.0 KiB
PHP
41 lines
1.0 KiB
PHP
<?php
|
|
|
|
namespace Database\Seeders\New;
|
|
|
|
use Illuminate\Database\Seeder;
|
|
use Illuminate\Support\Facades\DB;
|
|
use Illuminate\Support\Facades\File;
|
|
use JsonMachine\Items;
|
|
use JsonMachine\JsonDecoder\ExtJsonDecoder;
|
|
|
|
class ProductPropertyValuesSeeder extends Seeder
|
|
{
|
|
public function run()
|
|
{
|
|
$this->fillPropertyValues();
|
|
}
|
|
|
|
private function fillPropertyValues()
|
|
{
|
|
DB::transaction(function () {
|
|
$table = 'property_values.json';
|
|
|
|
DB::table($table)->truncate();
|
|
|
|
$items = Items::fromFile(
|
|
database_path('data/property_values.json'),
|
|
['decoder' => new ExtJsonDecoder(true)]
|
|
);
|
|
|
|
foreach ($items as $data) {
|
|
DB::table($table)->insert([
|
|
'id' => $data['id'],
|
|
'attribute_id' => $data['attribute_id'],
|
|
'value' => str_replace('"tm"', '"tk"', $data['name']),
|
|
]);
|
|
|
|
// "string_value": "Ci4wU42HuY",
|
|
}
|
|
});
|
|
}
|
|
} |