I have a magento 2.2.5 based website and i need to get a custom product attribute on my order success page for each product. The custom attribute is called site_owned_buy
any suggestions how to get it on the below code for each product I loop through
<?php
$ga_data = [];
foreach ($order->getAllVisibleItems() as $item) {
$ga_item = array(
'name' => $item->getName(),
'sku' => $item->getSku(),
'qty' => $item->getQtyordered(),
'price' => $item->getPrice()
);
array_push($ga_data, $ga_item);
}
$subtotal = $order->getSubtotal();
$order_id = $block->getOrderId();
$gtotal = $order->getGrandTotal();
$address = $order->getBillingAddress()->getData();
$city = $address['city'];
$state = $address['region'];
$country = $address['country_id'];
$shippingVal = is_null($order->getShippingAmount()) ? 0 : $order->getShippingAmount();
$taxAmount=$order->getTaxAmount();
?>
<script type="text/javascript">
dataLayer.push({
'event': 'purchase',
'ecommerce': {
'purchase': {
'actionField': {
'id': '<?php echo $order_id; ?>', // Transaction ID. Required for purchases and refunds.
'revenue': '<?php echo $gtotal;?>', // Total transaction value (incl. tax and shipping)
'tax':'<?php echo $taxAmount;?>', // Total tax value
'shipping': '<?php echo $shippingVal;?>', // Total shipping value
'coupon': '' // Optional field and may be set to empty string
},
'products': [
<?php foreach ($ga_data as $item)
{
?>
{
'name': '<?php echo $item['name']; ?>', // Name or ID is required
'id': '<?php echo $item['sku']; ?>', // Name or ID is required
'price': '<?php echo $item['price']; ?>', // Insert product price
'brand': '', // Insert product brand
'category': '', // Insert product category
'variant': '', // Insert product variant (e.g. red, black, etc.)
'quantity': '<?php echo $item['qty']; ?>', // Insert product quantity
'coupon': '', // Optional field and may be set to empty string
'site': ''
},
<?php
}
?>
]
}
}
});