Variant Item SKU as Product Code

So I was able to get the result I am looking for but in so doing I have an error in the php error log. I added the following code in the section I showed above where I thought needed to be set. The code is as follows.

        $items = $this->order->get_items();
        // Line items can be added to a Transaction individually or as an array
        $lineItems = array();
        $itemcount = 0;
        foreach($items as $item_id => $item_data) {
            array_push($lineItems, new ConnectLineItem);
            ***$product_variation_id = $item_data['variation_id'];
            if ($product_variation_id) {
              $product = wc_get_product($item_data['variation_id']);}
              else {
              $product = wc_get_product($item_data['product_id']); }***  
            $lineItems[$itemcount]->ProductCode = $product->get_sku();
            $lineItems[$itemcount]->Category = "";
            $lineItems[$itemcount]->Description = substr($item_data['name'], 0, 50);
            $lineItems[$itemcount]->Quantity = $item_data['quantity'];
            $lineItems[$itemcount]->UnitOfMeasure = "PCE";
            $lineItems[$itemcount]->LineAmount = $item_data['total'];
            $lineItems[$itemcount]->UnitPrice = $item_data['total'] / $item_data['quantity'];
            $lineItems[$itemcount]->LineTaxAmount = $item_data['subtotal_tax'];
            $lineItems[$itemcount]->LineDiscountAmount = "0.00";
            $itemcount = $itemcount + 1;

The error message I get is this:
[06-Apr-2021 21:24:16 UTC] status was called incorrectly. Order properties should not be accessed directly. Backtrace: require(‘wp-blog-header.php’), require_once(‘wp-includes/template-loader.php’), do_action(‘template_redirect’), WP_Hook->do_action, WP_Hook->apply_filters, WC_AJAX::do_wc_ajax, do_action(‘wc_ajax_checkout’), WP_Hook->do_action, WP_Hook->apply_filters, WC_AJAX::checkout, WC_Checkout->process_checkout, WC_Checkout->process_order_payment, WC_CL_CONNECT_Gateway->process_payment, WC_CL_CONNECT_Gateway->do_order_complete_tasks, WC_Abstract_Legacy_Order->__get, wc_doing_it_wrong. This message was added in version 3.0.

How do I resolve this one.