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

(-)a/C4/Biblio.pm (-1 / +1 lines)
Lines 1171-1177 sub GetMarcBiblio { Link Here
1171
1171
1172
    my $biblionumber = $params->{biblionumber};
1172
    my $biblionumber = $params->{biblionumber};
1173
    my $embeditems   = $params->{embed_items} || 0;
1173
    my $embeditems   = $params->{embed_items} || 0;
1174
    my $embedhostitems  = $params->{embed_host_items} // 0;
1174
    my $embedhostitems  = $params->{embed_host_items} && C4::Context->preference('EmbedHostItemsInSearchEngine') // 0;
1175
    my $opac         = $params->{opac} || 0;
1175
    my $opac         = $params->{opac} || 0;
1176
    my $borcat       = $params->{borcat} // q{};
1176
    my $borcat       = $params->{borcat} // q{};
1177
1177
(-)a/C4/Search.pm (+23 lines)
Lines 1773-1778 sub searchResults { Link Here
1773
        my @fields = $marcrecord->field($itemtag);
1773
        my @fields = $marcrecord->field($itemtag);
1774
        my $marcflavor = C4::Context->preference("marcflavour");
1774
        my $marcflavor = C4::Context->preference("marcflavour");
1775
1775
1776
        # adding linked items that belong to host records
1777
        if ( C4::Context->preference('EasyAnalyticalRecords') && !C4::Context->preference('EmbedHostItemsInSearchEngine') ) {
1778
            my $analyticsfield = '773';
1779
            if ($marcflavor eq 'MARC21' || $marcflavor eq 'NORMARC') {
1780
                $analyticsfield = '773';
1781
            } elsif ($marcflavor eq 'UNIMARC') {
1782
                $analyticsfield = '461';
1783
            }
1784
            foreach my $hostfield ( $marcrecord->field($analyticsfield)) {
1785
                my $hostbiblionumber = $hostfield->subfield("0");
1786
                my $linkeditemnumber = $hostfield->subfield("9");
1787
                if( $hostbiblionumber ) {
1788
                    my $linkeditemmarc = C4::Items::GetMarcItem( $hostbiblionumber, $linkeditemnumber );
1789
                    if ($linkeditemmarc) {
1790
                        my $linkeditemfield = $linkeditemmarc->field($itemtag);
1791
                        if ($linkeditemfield) {
1792
                            push( @fields, $linkeditemfield );
1793
                        }
1794
                    }
1795
                }
1796
            }
1797
        }
1798
1776
        # Setting item statuses for display
1799
        # Setting item statuses for display
1777
        my @available_items_loop;
1800
        my @available_items_loop;
1778
        my @onloan_items_loop;
1801
        my @onloan_items_loop;
(-)a/C4/XSLT.pm (-1 / +2 lines)
Lines 297-303 Is only used in this module currently. Link Here
297
sub buildKohaItemsNamespace {
297
sub buildKohaItemsNamespace {
298
    my ($biblionumber, $hidden_items) = @_;
298
    my ($biblionumber, $hidden_items) = @_;
299
299
300
    my @host_itemnumbers = C4::Items::get_hostitemnumbers_of( $biblionumber );
300
    my @host_itemnumbers = ();
301
    @host_itemnumbers = C4::Items::get_hostitemnumbers_of( $biblionumber ) if C4::Context->preference('EmbedHostItemsInSearchEngine');
301
    $hidden_items ||= [];
302
    $hidden_items ||= [];
302
    my @items = Koha::Items->search(
303
    my @items = Koha::Items->search(
303
        {
304
        {
(-)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 191-196 INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` Link Here
191
('EmailAddressForSuggestions','','',' If you choose EmailAddressForSuggestions you have to enter a valid email address: ','free'),
191
('EmailAddressForSuggestions','','',' If you choose EmailAddressForSuggestions you have to enter a valid email address: ','free'),
192
('emailLibrarianWhenHoldIsPlaced','0',NULL,'If ON, emails the librarian whenever a hold is placed','YesNo'),
192
('emailLibrarianWhenHoldIsPlaced','0',NULL,'If ON, emails the librarian whenever a hold is placed','YesNo'),
193
('EmailPurchaseSuggestions','0','0|EmailAddressForSuggestions|BranchEmailAddress|KohaAdminEmailAddress','Choose email address that new purchase suggestions will be sent to: ','Choice'),
193
('EmailPurchaseSuggestions','0','0|EmailAddressForSuggestions|BranchEmailAddress|KohaAdminEmailAddress','Choose email address that new purchase suggestions will be sent to: ','Choice'),
194
('EmbedHostItemsInSearchEngine','0','','Add host items to records in the search engine','YesNo'),
194
('EnableAdvancedCatalogingEditor','0','','Enable the Rancor advanced cataloging editor','YesNo'),
195
('EnableAdvancedCatalogingEditor','0','','Enable the Rancor advanced cataloging editor','YesNo'),
195
('EnableBorrowerFiles','0',NULL,'If enabled, allows librarians to upload and attach arbitrary files to a borrower record.','YesNo'),
196
('EnableBorrowerFiles','0',NULL,'If enabled, allows librarians to upload and attach arbitrary files to a borrower record.','YesNo'),
196
('EnableOpacSearchHistory','1','YesNo','Enable or disable opac search history',''),
197
('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