public function getProductName($productId): ?string
    {
        $product = $this->productRepository->find($productId);
        if (!$product instanceof ProductInterface) {
            return null;
        }

        return $product->getName();
    }
public function getProductName($productId): ?string
    {
        $product = $this->productRepository->find($productId);
        if (!$product instanceof ProductInterface) {
            return null;
        }

        return $product->getName();
    }
public function getProductName ( $ productId ) : ? string { $ product = $ this -> productRepository -> find ( $ productId ) ; if ( ! $ product instanceof ProductInterface ) { return null ; } return $ product -> getName ( ) ; }
Returns the product name.

@param int|string $productId

@return string|null
Returns the product name .