Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
wychoong committed Jan 22, 2025
1 parent e31e7bc commit c5fac26
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,24 +20,16 @@ public function setUp(): void

$record->customerGroups()->detach();

$record->variants()->each(function (Model $variant) {
$variant->values()->detach();

$variant->prices()->delete();
});

$record->urls()->delete();

$record->variants()->delete();
$record->variants()->get()->each->forceDelete();

$record->productOptions()->detach();

$record->associations()->delete();

$record->channels()->detach();

$record->clearMediaCollection('images');

return $record->forceDelete();
});
});
Expand Down
6 changes: 5 additions & 1 deletion packages/core/src/Observers/MediaObserver.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,11 @@ protected function ensureOnlyOnePrimary(Media $media, bool $isDelete = false): v
return;
}

$owner = $media->model()->sole();
$owner = $media->model()->first();

if (blank($owner)) {
return;
}

if (! $isDelete && $media->getCustomProperty('primary')) {
$owner->getMedia($media->collection_name)
Expand Down

0 comments on commit c5fac26

Please sign in to comment.