Bug 18951: Create data for TransformKohaToMarc.t
[koha.git] / C4 / XISBN.pm
index d04f2e7..5f3fd51 100644 (file)
@@ -26,13 +26,16 @@ use C4::External::Syndetics qw(get_syndetics_editions);
 use LWP::UserAgent;
 use HTTP::Request::Common;
 
+use Koha::Biblios;
+use Koha::SearchEngine;
+use Koha::SearchEngine::Search;
+
 use strict;
 #use warnings; FIXME - Bug 2505
-use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
+use vars qw(@ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
 
 BEGIN {
        require Exporter;
-    $VERSION = 3.07.00.049;
        @ISA = qw(Exporter);
        @EXPORT_OK = qw(
                &get_xisbns
@@ -64,17 +67,20 @@ sub _get_biblio_from_xisbn {
     my $xisbn = shift;
     my $dbh = C4::Context->dbh;
 
-    my ( $errors, $results, $total_hits ) = C4::Search::SimpleSearch( "nb=$xisbn", 0, 1 );
+    my $searcher = Koha::SearchEngine::Search->new({index => $Koha::SearchEngine::BIBLIOS_INDEX});
+    my ( $errors, $results, $total_hits ) = $searcher->simple_search_compat( "nb=$xisbn", 0, 1 );
     return unless ( !$errors && scalar @$results );
 
     my $record = C4::Search::new_record_from_zebra( 'biblioserver', $results->[0] );
     my $biblionumber = C4::Biblio::get_koha_field_from_marc('biblio', 'biblionumber', $record, '');
     return unless $biblionumber;
 
-    my $xbiblio = GetBiblioData($biblionumber);
-    return unless $xbiblio;
-    $xbiblio->{normalized_isbn} = GetNormalizedISBN($xbiblio->{isbn});
-    return $xbiblio;
+    my $biblio = Koha::Biblios->find( $biblionumber );
+    return unless $biblio;
+    my $isbn = $biblio->biblioitem->isbn;
+    $biblio = $biblio->unblessed;
+    $biblio->{normalized_isbn} = GetNormalizedISBN($isbn);
+    return $biblio;
 }
 
 =head1 get_xisbns($isbn);