improve the way linked categories are copied

This commit is contained in:
Herbert Maschke 2020-08-10 17:28:23 +02:00
parent 3aeb0c75df
commit 69dea2b8b3
1 changed files with 4 additions and 1 deletions

View File

@ -662,7 +662,10 @@ class ProductRepository extends Repository
if (! in_array('categories', $attributesToSkip)) {
foreach ($originalProduct->categories as $category) {
$copiedProduct->categories()->save($category->replicate());
DB::table('product_categories')->insert([
'product_id' => $copiedProduct->id,
'category_id' => $category->id,
]);
}
}