there is a mistake in fetching the product attribute name. first of all, we have to get all options ids & attribute names than we have to fetch attribute name by its id & attribute slug.
please check below updated code snippet and let me know if this is worked for you or not.if not then please tell me I will definitely help you.
Thanks.
function add_product_column( $columns ) {
//add column
$columns['new_column'] = __( 'New column', 'woocommerce' );
return $columns;
}
add_filter( 'manage_edit-product_columns', 'add_product_column', 10, 1 );
function add_product_column_content( $column, $postid ) {
if ( $column == 'new_column' ) {
$product = wc_get_product( $postid );
$product_attributes = $product->get_attributes();
$attr_array = array();
foreach ( $product_attributes as $product_attribute ) {
$attribute_name = $product_attribute->get_name();
$attribute_options = $product_attribute->get_options();
foreach ($attribute_options as $key => $value) {
$term_data = get_term_by( 'id',$value,$attribute_name );
$term_name = $term_data->name;
array_push($attr_array, $term_name);
}
}
echo implode(', ', $attr_array);
}
}
add_action( 'manage_product_posts_custom_column', 'add_product_column_content', 10, 2 );