Skip to content

Magento 2.4.3: Cloned Product Overwrites Existing Entry in CatalogInvetory_Stock

I am working on a Magento 2.4.3 store and am cloning a product via the below methodology:

        $product_clone = $this->object_manager->create(Product::class);
        $product_clone->load($source_product_id);
        $product = $this->object_manager->create(Product::class);
        $product->setData($product_clone->getData()); 

However, after modifying and saving the cloned product, the inventory for the source product goes to 0. Moreover, I noticed that the entry within the cataloginventory_stock table, assigned to the source product, is updated so that the id becomes that of the clone product.

This methodology did work in Magento 2.1.10, so I am wondering what has changed.