Based on this post,
Fixing Sort Order when Cloning Category Trees
we implemented a plugin that clones category trees.
But using this method, product associations are being cloned as well. Products with categories from the original tree will also have the same categories from the new tree.
Is there a way to prevent this?
You can add the association to the overwrites of the CloneBehavior
which should prevent cloning the corresponding assignments of the original.
$cloneBehavior = new CloneBehavior([
'parentId' => $newParentId,
'afterCategoryId' => $previousId,
'products' => null,
], false);