Hello,
Try to replace this line in your code $attr['alt'] = $sku . ' | ' . $title . ' | ' . $brand;
$attr['alt'] = $sku . ' | ' . $title . ' | ' . $brand;
by the following one
foreach( $brand as $brand_item ) { $attr['alt'] = $sku . ' | ' . $title . ' | ' . $brand_item->name; }
Regards