<?php namespace BulkPriceEditor\ProductsTable\Columns;

use BulkPriceEditor\ProductsTable\WPListProductsTable;
use WC_Product;

class TitleColumn extends Column {
	
	public function getSlug(): string {
		return 'title';
	}
	
	public function getName(): string {
		return __( 'Name', 'bulk-price-editor' );
	}
	
	public function render( WC_Product $product, WPListProductsTable $table ): string {
		$productLink = sprintf( '<a href="%s">%s</a>', get_edit_post_link( $product->get_id() ),
			esc_html( $product->get_name() ) );
		
		
		if ( $product->get_sku() ) {
			$productLink .= '<br> SKU: <code>' . esc_html( $product->get_sku() ) . '</code>';
		}

		
		return $productLink;
	}
	
	public function sortable(): bool {
		return true;
	}
}
