View | Details | Raw Unified | Return to bug 27138
Collapse All | Expand All

(-)a/C4/Biblio.pm (-1 / +1 lines)
Lines 1177-1183 sub GetMarcBiblio { Link Here
1177
1177
1178
    my $biblionumber = $params->{biblionumber};
1178
    my $biblionumber = $params->{biblionumber};
1179
    my $embeditems   = $params->{embed_items} || 0;
1179
    my $embeditems   = $params->{embed_items} || 0;
1180
    my $embedhostitems  = $params->{embed_host_items} // 0;
1180
    my $embedhostitems  = $params->{embed_host_items} && C4::Context->preference('EmbedHostItemsInSearchEngine') // 0;
1181
    my $opac         = $params->{opac} || 0;
1181
    my $opac         = $params->{opac} || 0;
1182
    my $borcat       = $params->{borcat} // q{};
1182
    my $borcat       = $params->{borcat} // q{};
1183
1183
(-)a/C4/Search.pm (+23 lines)
Lines 1738-1743 sub searchResults { Link Here
1738
        $marcrecord->delete_fields( @fields ) unless C4::Context->preference('PassItemMarcToXSLT');
1738
        $marcrecord->delete_fields( @fields ) unless C4::Context->preference('PassItemMarcToXSLT');
1739
        my $marcflavor = C4::Context->preference("marcflavour");
1739
        my $marcflavor = C4::Context->preference("marcflavour");
1740
1740
1741
        # adding linked items that belong to host records
1742
        if ( C4::Context->preference('EasyAnalyticalRecords') && !C4::Context->preference('EmbedHostItemsInSearchEngine') ) {
1743
            my $analyticsfield = '773';
1744
            if ($marcflavor eq 'MARC21' || $marcflavor eq 'NORMARC') {
1745
                $analyticsfield = '773';
1746
            } elsif ($marcflavor eq 'UNIMARC') {
1747
                $analyticsfield = '461';
1748
            }
1749
            foreach my $hostfield ( $marcrecord->field($analyticsfield)) {
1750
                my $hostbiblionumber = $hostfield->subfield("0");
1751
                my $linkeditemnumber = $hostfield->subfield("9");
1752
                if( $hostbiblionumber ) {
1753
                    my $linkeditemmarc = C4::Items::GetMarcItem( $hostbiblionumber, $linkeditemnumber );
1754
                    if ($linkeditemmarc) {
1755
                        my $linkeditemfield = $linkeditemmarc->field($itemtag);
1756
                        if ($linkeditemfield) {
1757
                            push( @fields, $linkeditemfield );
1758
                        }
1759
                    }
1760
                }
1761
            }
1762
        }
1763
1741
        # Setting item statuses for display
1764
        # Setting item statuses for display
1742
        my @available_items_loop;
1765
        my @available_items_loop;
1743
        my @onloan_items_loop;
1766
        my @onloan_items_loop;
(-)a/C4/XSLT.pm (-1 / +2 lines)
Lines 322-328 Is only used in this module currently. Link Here
322
sub buildKohaItemsNamespace {
322
sub buildKohaItemsNamespace {
323
    my ($biblionumber, $hidden_items, $items_rs) = @_;
323
    my ($biblionumber, $hidden_items, $items_rs) = @_;
324
324
325
    my @host_itemnumbers = C4::Items::get_hostitemnumbers_of( $biblionumber );
325
    my @host_itemnumbers = ();
326
    @host_itemnumbers = C4::Items::get_hostitemnumbers_of( $biblionumber ) if C4::Context->preference('EmbedHostItemsInSearchEngine');
326
    $hidden_items ||= [];
327
    $hidden_items ||= [];
327
328
328
    my $query = {};
329
    my $query = {};
(-)a/installer/data/mysql/atomicupdate/bug_27138_add_embedHostItems_syspref.perl (+9 lines)
Line 0 Link Here
1
$DBversion = 'XXX';
2
if( CheckVersion( $DBversion ) ) {
3
    # you can use $dbh here like:
4
    $dbh->do(q{
5
        INSERT IGNORE INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` ) VALUES
6
        ('EmbedHostItemsInSearchEngine','0','','Add host items to records in the search engine','YesNo');
7
    });
8
    NewVersion( $DBversion, 27138, "Add system preference EmbedHostItemsInSearchEngine");
9
}
(-)a/installer/data/mysql/mandatory/sysprefs.sql (+1 lines)
Lines 195-200 INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` Link Here
195
('EmailAddressForSuggestions','','',' If you choose EmailAddressForSuggestions you have to enter a valid email address: ','free'),
195
('EmailAddressForSuggestions','','',' If you choose EmailAddressForSuggestions you have to enter a valid email address: ','free'),
196
('emailLibrarianWhenHoldIsPlaced','0',NULL,'If ON, emails the librarian whenever a hold is placed','YesNo'),
196
('emailLibrarianWhenHoldIsPlaced','0',NULL,'If ON, emails the librarian whenever a hold is placed','YesNo'),
197
('EmailPurchaseSuggestions','0','0|EmailAddressForSuggestions|BranchEmailAddress|KohaAdminEmailAddress','Choose email address that new purchase suggestions will be sent to: ','Choice'),
197
('EmailPurchaseSuggestions','0','0|EmailAddressForSuggestions|BranchEmailAddress|KohaAdminEmailAddress','Choose email address that new purchase suggestions will be sent to: ','Choice'),
198
('EmbedHostItemsInSearchEngine','0','','Add host items to records in the search engine','YesNo'),
198
('EnableAdvancedCatalogingEditor','0','','Enable the Rancor advanced cataloging editor','YesNo'),
199
('EnableAdvancedCatalogingEditor','0','','Enable the Rancor advanced cataloging editor','YesNo'),
199
('EnableBorrowerFiles','0',NULL,'If enabled, allows librarians to upload and attach arbitrary files to a borrower record.','YesNo'),
200
('EnableBorrowerFiles','0',NULL,'If enabled, allows librarians to upload and attach arbitrary files to a borrower record.','YesNo'),
200
('EnableOpacSearchHistory','1','YesNo','Enable or disable opac search history',''),
201
('EnableOpacSearchHistory','1','YesNo','Enable or disable opac search history',''),
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/searching.pref (+7 lines)
Lines 87-92 Searching: Link Here
87
                  0: Disable
87
                  0: Disable
88
            - "the cross_fields option for Elasticsearch searches, supported in Elasticsearch 6.X and above."
88
            - "the cross_fields option for Elasticsearch searches, supported in Elasticsearch 6.X and above."
89
            - "See documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-multi-match-query.html#type-cross-fields"
89
            - "See documentation at https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-multi-match-query.html#type-cross-fields"
90
        -
91
            - pref: EmbedHostItemsInSearchEngine
92
              default: 0
93
              choices:
94
                  1: Embed
95
                  0: Don't embed
96
            - 'host items in records in the search engine. Requires <a href="/cgi-bin/koha/admin/preferences.pl?op=search&searchfield=EasyAnalyticalRecords">EasyAnalyticalRecords</a>'
90
    Search form:
97
    Search form:
91
        -
98
        -
92
            - pref : LoadSearchHistoryToTheFirstLoggedUser
99
            - pref : LoadSearchHistoryToTheFirstLoggedUser
(-)a/misc/migration_tools/rebuild_zebra.pl (-1 / +2 lines)
Lines 509-515 sub export_marc_records_from_sth { Link Here
509
                          ? GetXmlBiblio( $record_number )
509
                          ? GetXmlBiblio( $record_number )
510
                          : GetAuthorityXML( $record_number );
510
                          : GetAuthorityXML( $record_number );
511
            if ($record_type eq 'biblio'){
511
            if ($record_type eq 'biblio'){
512
                my @host_itemnumbers = C4::Items::get_hostitemnumbers_of( $record_number );
512
                my @host_itemnumbers = ();
513
                @host_itemnumbers = C4::Items::get_hostitemnumbers_of( $record_number ) if C4::Context->preference('EmbedHostItemsInSearchEngine');
513
                my @items = Koha::Items->search({
514
                my @items = Koha::Items->search({
514
                    -or => [
515
                    -or => [
515
                        biblionumber => $record_number,
516
                        biblionumber => $record_number,
(-)a/t/db_dependent/Items.t (-3 / +17 lines)
Lines 680-686 subtest 'Koha::Item(s) tests' => sub { Link Here
680
};
680
};
681
681
682
subtest 'C4::Biblio::EmbedItemsInMarcBiblio' => sub {
682
subtest 'C4::Biblio::EmbedItemsInMarcBiblio' => sub {
683
    plan tests => 11;
683
    plan tests => 12;
684
684
685
    $schema->storage->txn_begin();
685
    $schema->storage->txn_begin();
686
686
Lines 724-729 subtest 'C4::Biblio::EmbedItemsInMarcBiblio' => sub { Link Here
724
        push @itemnumbers, $itemnumber;
724
        push @itemnumbers, $itemnumber;
725
    }
725
    }
726
726
727
    t::lib::Mocks::mock_preference( 'EasyAnalyticalRecords', '1' );
727
    my $host_item = $builder->build_sample_item({ homebranch => $library2->{branchcode} });
728
    my $host_item = $builder->build_sample_item({ homebranch => $library2->{branchcode} });
728
    my $child_field = PrepHostMarcField( $host_item->biblionumber, $host_item->itemnumber, 'MARC21');
729
    my $child_field = PrepHostMarcField( $host_item->biblionumber, $host_item->itemnumber, 'MARC21');
729
    my $child_record = $biblio->metadata->record;
730
    my $child_record = $biblio->metadata->record;
Lines 759-770 subtest 'C4::Biblio::EmbedItemsInMarcBiblio' => sub { Link Here
759
    @items = $record->field($itemfield);
760
    @items = $record->field($itemfield);
760
    is( scalar @items, $number_of_items + 1, 'Should return all items plus host items' );
761
    is( scalar @items, $number_of_items + 1, 'Should return all items plus host items' );
761
762
763
    t::lib::Mocks::mock_preference('EmbedHostItemsInSearchEngine', '1');
762
    $marc_with_items = C4::Biblio::GetMarcBiblio({
764
    $marc_with_items = C4::Biblio::GetMarcBiblio({
763
        biblionumber => $biblio->biblionumber,
765
        biblionumber => $biblio->biblionumber,
764
        embed_items  => 1,
766
        embed_items  => 1,
765
        embed_host_items => 1
767
        embed_host_items => 1
766
    });
768
    });
767
    is_deeply( $record, $marc_with_items, 'A direct call to GetMarcBiblio with items matches');
769
    is_deeply( $record, $marc_with_items, 'A direct call to GetMarcBiblio with embed host items matches if embedding items in search engine');
770
    $record = C4::Biblio::GetMarcBiblio({ biblionumber => $biblio->biblionumber });
771
    C4::Biblio::EmbedItemsInMarcBiblio({
772
        marc_record  => $record,
773
        biblionumber => $biblio->biblionumber,
774
        embed_host_items => 0
775
    });
776
    t::lib::Mocks::mock_preference('EmbedHostItemsInSearchEngine', '0');
777
    $marc_with_items = C4::Biblio::GetMarcBiblio({
778
        biblionumber => $biblio->biblionumber,
779
        embed_items  => 1,
780
        embed_host_items => 1
781
    });
782
    is_deeply( $record, $marc_with_items, 'A direct call to GetMarcBiblio with embed host items does not include host item if not embedding items in search engine');
768
783
769
    C4::Biblio::EmbedItemsInMarcBiblio({
784
    C4::Biblio::EmbedItemsInMarcBiblio({
770
        marc_record  => $record,
785
        marc_record  => $record,
771
- 

Return to bug 27138