I have an array full of produtcs SKU's that i search for the ID.
$ID = wc_get_product_id_by_sku($CodProduto);
then i initialize the object and set the stock for the current amount.
$Product = new WC_Product( $ID);
$return = wc_update_product_stock( $Product, $Stock);
So far so good! All works fine. My problem is when the $ID is for a product variation it wont initialize the object and will give an error. So i initialize all ID's with:
$Product = new WC_Product_Variation( $ID );
And then i update the stock like i did before. The problem is that when a product DONT have variation, the woocommerce puts the Name as (no title) but the stock works fine.
Is there a way to check if the ID is for a variation without initialize the object $Product???
