Magento 2.4.6
I copied a product like that:
$childCopy = $objectManager->create('MagentoCatalogModelProductCopier');
$childCopy = $childCopy->copy($parent);
This works, I can set the SKU, the URL key and so on on the $childCopy
, but visibility and status do not work:
$childCopy->setSku('whatsever'); // works
$childCopy->setPrice(10); // works
$childCopy->setStatus(1); // does NOT work
$childCopy->setVisibility(1); // does NOT work
$childCopy->save();
Setting visibility and status only works when I set their scope to global, which I do not want to do. I am sure there is something I forgot to set … and ideas? Using a product repository does not solve the issue.
Thanks!