From 69dea2b8b387ef8b64fb193d24becbab5809d00b Mon Sep 17 00:00:00 2001 From: Herbert Maschke Date: Mon, 10 Aug 2020 17:28:23 +0200 Subject: [PATCH] improve the way linked categories are copied --- .../Webkul/Product/src/Repositories/ProductRepository.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/Webkul/Product/src/Repositories/ProductRepository.php b/packages/Webkul/Product/src/Repositories/ProductRepository.php index 2afa8ccb5..be532d14e 100755 --- a/packages/Webkul/Product/src/Repositories/ProductRepository.php +++ b/packages/Webkul/Product/src/Repositories/ProductRepository.php @@ -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, + ]); } }