From 35bc266f881c0ce85270242cc5d125a584e0ae5d Mon Sep 17 00:00:00 2001
From: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Date: Thu, 8 Jun 2023 10:55:36 +0200
Subject: [PATCH] Bug 33952: Koha::Biblio->normalized_isbn

This is needed for bug 33947 where we need to call ->normalized_isbn on a Koha::Biblio object.

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
---
 Koha/Biblio.pm | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/Koha/Biblio.pm b/Koha/Biblio.pm
index f8d6fcdff44..d8c1c76a711 100644
--- a/Koha/Biblio.pm
+++ b/Koha/Biblio.pm
@@ -959,7 +959,7 @@ sub custom_cover_image_url {
         $url =~ s|{isbn}|$isbn|g;
     }
     if ( $url =~ m|{normalized_isbn}| ) {
-        my $normalized_isbn = C4::Koha::GetNormalizedISBN($self->biblioitem->isbn);
+        my $normalized_isbn = $self->normalized_isbn;
         return unless $normalized_isbn;
         $url =~ s|{normalized_isbn}|$normalized_isbn|g;
     }
@@ -1229,6 +1229,19 @@ sub get_marc_authors {
     return [@first_authors, @other_authors];
 }
 
+=head3 normalized_isbn
+
+    my $normalized_isbn = $biblio->normalized_isbn
+
+Normalizes and returns the first valid ISBN found in the record.
+ISBN13 are converted into ISBN10. This is required to get some book cover images.
+
+=cut
+
+sub normalized_isbn {
+    my ( $self) = @_;
+    return C4::Koha::GetNormalizedISBN($self->biblioitem->isbn);
+}
 
 =head3 to_api
 
-- 
2.25.1