Magento 2.4.6
I am trying to duplicate a product using the MagentoCatalogModelProductCopier
class which is also used in MagentoCatalogControllerAdminhtmlProductDuplicate
in the execute
function..
When I click the button in admin to duplicate a product, it works, all attributes are being set in the copy. Doing the same in my code does duplicate the product, but not all attributes are set.
My Code:
$original = $objectManager->create('MagentoCatalogModelProduct')->load(1234567);
$copy = $objectManager->create('MagentoCatalogModelProductCopier')->copy($original);
This creates a copy of the product, but most of the attributes are not set like in the original. Do I have to do something more?
Thanks!