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

(-)a/C4/Biblio.pm (-1 / +1 lines)
Lines 1210-1216 sub GetMarcBiblio { Link Here
1210
1210
1211
    my $biblionumber = $params->{biblionumber};
1211
    my $biblionumber = $params->{biblionumber};
1212
    my $embeditems   = $params->{embed_items} || 0;
1212
    my $embeditems   = $params->{embed_items} || 0;
1213
    my $embedhostitems  = $params->{embed_host_items} // 0;
1213
    my $embedhostitems  = $params->{embed_host_items} && C4::Context->preference('EmbedHostItemsInSearchEngine') // 0;
1214
    my $opac         = $params->{opac} || 0;
1214
    my $opac         = $params->{opac} || 0;
1215
    my $borcat       = $params->{borcat} // q{};
1215
    my $borcat       = $params->{borcat} // q{};
1216
1216
(-)a/C4/Search.pm (-1 / +1 lines)
Lines 1741-1747 sub searchResults { Link Here
1741
        my $marcflavor = C4::Context->preference("marcflavour");
1741
        my $marcflavor = C4::Context->preference("marcflavour");
1742
1742
1743
        # adding linked items that belong to host records
1743
        # adding linked items that belong to host records
1744
        if ( C4::Context->preference('EasyAnalyticalRecords') ) {
1744
        if ( C4::Context->preference('EasyAnalyticalRecords') && !C4::Context->preference('EmbedHostItemsInSearchEngine') ) {
1745
            my $analyticsfield = '773';
1745
            my $analyticsfield = '773';
1746
            if ($marcflavor eq 'MARC21') {
1746
            if ($marcflavor eq 'MARC21') {
1747
                $analyticsfield = '773';
1747
                $analyticsfield = '773';
(-)a/C4/XSLT.pm (-1 / +2 lines)
Lines 321-327 Is only used in this module currently. Link Here
321
sub buildKohaItemsNamespace {
321
sub buildKohaItemsNamespace {
322
    my ($biblionumber, $hidden_items, $items_rs) = @_;
322
    my ($biblionumber, $hidden_items, $items_rs) = @_;
323
323
324
    my @host_itemnumbers = C4::Items::get_hostitemnumbers_of( $biblionumber );
324
    my @host_itemnumbers = ();
325
    @host_itemnumbers = C4::Items::get_hostitemnumbers_of( $biblionumber ) if C4::Context->preference('EmbedHostItemsInSearchEngine');
325
    $hidden_items ||= [];
326
    $hidden_items ||= [];
326
327
327
    my $query = {};
328
    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 194-199 INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` Link Here
194
('EmailAddressForSuggestions','','',' If you choose EmailAddressForSuggestions you have to enter a valid email address: ','free'),
194
('EmailAddressForSuggestions','','',' If you choose EmailAddressForSuggestions you have to enter a valid email address: ','free'),
195
('emailLibrarianWhenHoldIsPlaced','0',NULL,'If ON, emails the librarian whenever a hold is placed','YesNo'),
195
('emailLibrarianWhenHoldIsPlaced','0',NULL,'If ON, emails the librarian whenever a hold is placed','YesNo'),
196
('EmailPurchaseSuggestions','0','0|EmailAddressForSuggestions|BranchEmailAddress|KohaAdminEmailAddress','Choose email address that new purchase suggestions will be sent to: ','Choice'),
196
('EmailPurchaseSuggestions','0','0|EmailAddressForSuggestions|BranchEmailAddress|KohaAdminEmailAddress','Choose email address that new purchase suggestions will be sent to: ','Choice'),
197
('EmbedHostItemsInSearchEngine','0','','Add host items to records in the search engine','YesNo'),
197
('EnableAdvancedCatalogingEditor','0','','Enable the Rancor advanced cataloging editor','YesNo'),
198
('EnableAdvancedCatalogingEditor','0','','Enable the Rancor advanced cataloging editor','YesNo'),
198
('EnableBorrowerFiles','0',NULL,'If enabled, allows librarians to upload and attach arbitrary files to a borrower record.','YesNo'),
199
('EnableBorrowerFiles','0',NULL,'If enabled, allows librarians to upload and attach arbitrary files to a borrower record.','YesNo'),
199
('EnableOpacSearchHistory','1','YesNo','Enable or disable opac search history',''),
200
('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