Woocommerce – Use SKU as unique identifier in the order creation with REST API

I have a website where I want to transfer woocommerce orders. Everything is working very well now but I have a strungle with product pairing. Products ids on testing are not the same as on live website. What do I need to add products to order and pair them not with their ID but with the SKU which is the same on both websites. My code is bellow.

I’m following this structure over here: https://woocommerce.github.io/woocommerce-rest-api-docs/?php#create-an-order

add_action( 'woocommerce_order_status_processing_to_gls', 'transfer_order_woo_api', 9999, 3 );
function transfer_order_woo_api( $order_id, $order ) {
   $live_ck = 'ck_some ID';
   $live_cs = 'cs_SOME ID';
   $live_url = 'https://testsite.com/wp-json/wc/v3/orders?consumer_key=' . $live_ck . '&consumer_secret=' . $live_cs;
   $order = wc_get_order( $order_id );
   
    // Line items - HERE IS THE PROBLEM 
    $lineitems = array();
    foreach ( $order->get_items() as $item_id => $item ) {
     $product_id = $item->get_product_id();
     $quantity = $item->get_quantity();
     $product = $item->get_product();
     
    $lineitem = array('quantity' => $quantity,
                     'product_id' => $product_id //I need to pair theese line items by the SKU because the product ID is not the same on different sites but the SKU is the same.
                
                      );
    $lineitems[] = $lineitem;
    }
   
   $body = array(
      'status' => 'processing',
      'meta_data' => array( 
      array( 
         'key' => 'carrier',
         'value' => ''.get_post_meta($order->id, 'ywot_carrier_id', true).''
      ),
      array( 
         'key' => 'order_number',
         'value' => ''.get_post_meta($order->id, '_alg_wc_custom_order_number', true).''
      ),
      array( 
         'key' => 'orderid',
         'value' => $order->get_id(),
      ),
      array( 
         'key' => 'shipped_date',
         'value' => ''.get_post_meta($order->id, 'shipped_date', true).''
      ),
      array( 
         'key' => 'ywot_tracking_code',
         'value' => ''.get_post_meta($order->id, 'ywot_tracking_code', true).''
      )),
      
      'billing' => array(
         'first_name' => $order->get_billing_first_name(),
         'last_name' => $order->get_billing_last_name(),
         'address1' => $order->get_billing_address_1(),
         'city' => $order->get_billing_city(),
         'postcode' => $order->get_billing_postcode(),
         'country' => $order->get_billing_country(),
         'phone' => $order->get_billing_phone(),
      ),
      'shipping' => array(
         'first_name' => $order->get_shipping_first_name(),
         'last_name' => $order->get_shipping_last_name(),
         'address1' => $order->get_shipping_address_1(),
         'city' => $order->get_shipping_city(),
         'postcode' => $order->get_shipping_postcode(),
         'country' => $order->get_shipping_country(),
      ),
      'line_items' => $lineitems,
     
   );
   
   
   $raw_response = wp_remote_post( $live_url, 
      array(
         'headers' => array( 'Content-Type' => 'application/json' ),
         'timeout' => 30,                    
         'body' => json_encode( $body ),
      )
   );

Thanks in advance for your ideas.