Enhance product handling and seeding logic
- 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.
This commit is contained in:
@@ -59,6 +59,11 @@ class UpdateProductRelations implements ShouldQueue
|
||||
'product_custom_value' => in_array($attribute->type, ['text', 'number']) ? $this->properties[$attribute->slug] : null,
|
||||
]);
|
||||
});
|
||||
|
||||
// sync properties json
|
||||
if (method_exists($this->model, 'syncPropertiesJson')) {
|
||||
$this->model->syncPropertiesJson();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -134,8 +134,8 @@ class ProductFieldsForDetail
|
||||
'name' => $property->attribute->slug,
|
||||
'type' => $property->attribute->type,
|
||||
'default' => $property->attribute->type === 'select'
|
||||
? $property->values->first()->value?->id
|
||||
: $property->values->first()->product_custom_value,
|
||||
? $property->values->first()->value?->id ?? '-'
|
||||
: $property->values->first()->product_custom_value ?? '-',
|
||||
'options' => $property->attribute->values->map(fn ($value) => [
|
||||
'label' => $value->value,
|
||||
'value' => $value->id,
|
||||
|
||||
Reference in New Issue
Block a user