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

(-)a/C4/Search.pm (-1 / +1 lines)
Lines 1759-1765 sub searchResults { Link Here
1759
        my $marcflavor = C4::Context->preference("marcflavour");
1759
        my $marcflavor = C4::Context->preference("marcflavour");
1760
1760
1761
        # adding linked items that belong to host records
1761
        # adding linked items that belong to host records
1762
        if ( C4::Context->preference('EasyAnalyticalRecords') ) {
1762
        if ( C4::Context->preference('EasyAnalyticalRecords') && !C4::Context->preference('EmbedHostItemsInSearchEngine') ) {
1763
            my $analyticsfield = '773';
1763
            my $analyticsfield = '773';
1764
            if ($marcflavor eq 'MARC21') {
1764
            if ($marcflavor eq 'MARC21') {
1765
                $analyticsfield = '773';
1765
                $analyticsfield = '773';
(-)a/C4/XSLT.pm (-1 / +2 lines)
Lines 265-271 Is only used in this module currently. Link Here
265
sub buildKohaItemsNamespace {
265
sub buildKohaItemsNamespace {
266
    my ($biblionumber, $hidden_items, $items_rs) = @_;
266
    my ($biblionumber, $hidden_items, $items_rs) = @_;
267
267
268
    my @host_itemnumbers = C4::Items::get_hostitemnumbers_of( $biblionumber );
268
    my @host_itemnumbers = ();
269
    @host_itemnumbers = C4::Items::get_hostitemnumbers_of( $biblionumber ) if C4::Context->preference('EmbedHostItemsInSearchEngine');
269
    $hidden_items ||= [];
270
    $hidden_items ||= [];
270
271
271
    my $query = {};
272
    my $query = {};
(-)a/Koha/Biblio/Metadata.pm (-1 / +2 lines)
Lines 157-163 sub _embed_items { Link Here
157
            $record->delete_field($field);
157
            $record->delete_field($field);
158
        }
158
        }
159
159
160
        push @$itemnumbers, C4::Items::get_hostitemnumbers_of( $biblionumber ) if $params->{embed_host_items};
160
        push @$itemnumbers, C4::Items::get_hostitemnumbers_of( $biblionumber )
161
            if $params->{embed_host_items} && C4::Context->preference('EmbedHostItemsInSearchEngine');
161
162
162
        my $items = Koha::Items->search([
163
        my $items = Koha::Items->search([
163
           'me.biblionumber' => $biblionumber,
164
           'me.biblionumber' => $biblionumber,
(-)a/installer/data/mysql/mandatory/sysprefs.sql (+1 lines)
Lines 212-217 INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` Link Here
212
('EmailOverduesNoEmail','1',NULL,'Send send overdues of patrons without email address to staff','YesNo'),
212
('EmailOverduesNoEmail','1',NULL,'Send send overdues of patrons without email address to staff','YesNo'),
213
('EmailPatronRegistrations', '0', '0|EmailAddressForPatronRegistrations|BranchEmailAddress|KohaAdminEmailAddress', 'Choose email address that new patron registrations will be sent to: ', 'Choice'),
213
('EmailPatronRegistrations', '0', '0|EmailAddressForPatronRegistrations|BranchEmailAddress|KohaAdminEmailAddress', 'Choose email address that new patron registrations will be sent to: ', 'Choice'),
214
('EmailPurchaseSuggestions','0','0|EmailAddressForSuggestions|BranchEmailAddress|KohaAdminEmailAddress','Choose email address that new purchase suggestions will be sent to: ','Choice'),
214
('EmailPurchaseSuggestions','0','0|EmailAddressForSuggestions|BranchEmailAddress|KohaAdminEmailAddress','Choose email address that new purchase suggestions will be sent to: ','Choice'),
215
('EmbedHostItemsInSearchEngine','0','','Add host items to records in the search engine','YesNo'),
215
('EnableAdvancedCatalogingEditor','0','','Enable the Rancor advanced cataloging editor','YesNo'),
216
('EnableAdvancedCatalogingEditor','0','','Enable the Rancor advanced cataloging editor','YesNo'),
216
('EnableBorrowerFiles','0',NULL,'If enabled, allows librarians to upload and attach arbitrary files to a borrower record.','YesNo'),
217
('EnableBorrowerFiles','0',NULL,'If enabled, allows librarians to upload and attach arbitrary files to a borrower record.','YesNo'),
217
('EnableExpiredPasswordReset', '0', NULL, 'Enable ability for patrons with expired password to reset their password directly', 'YesNo'),
218
('EnableExpiredPasswordReset', '0', NULL, 'Enable ability for patrons with expired password to reset their password directly', 'YesNo'),
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/searching.pref (+7 lines)
Lines 94-99 Searching: Link Here
94
                  1: Enable
94
                  1: Enable
95
                  0: Disable
95
                  0: Disable
96
            - "the option for staff with permission to create/edit custom saved search filters."
96
            - "the option for staff with permission to create/edit custom saved search filters."
97
        -
98
            - pref: EmbedHostItemsInSearchEngine
99
              default: 0
100
              choices:
101
                  1: Embed
102
                  0: Don't embed
103
            - 'host items in records in the search engine. Requires <a href="/cgi-bin/koha/admin/preferences.pl?op=search&searchfield=EasyAnalyticalRecords">EasyAnalyticalRecords</a>'
97
    Search form:
104
    Search form:
98
        -
105
        -
99
            - pref : LoadSearchHistoryToTheFirstLoggedUser
106
            - pref : LoadSearchHistoryToTheFirstLoggedUser
(-)a/misc/migration_tools/rebuild_zebra.pl (-6 / +3 lines)
Lines 511-517 sub export_marc_records_from_sth { Link Here
511
            if ($record_type eq 'biblio'){
511
            if ($record_type eq 'biblio'){
512
                my $biblio = Koha::Biblios->find($record_number);
512
                my $biblio = Koha::Biblios->find($record_number);
513
                next unless $biblio;
513
                next unless $biblio;
514
                my @host_itemnumbers = C4::Items::get_hostitemnumbers_of( $record_number );
514
                my @host_itemnumbers = ();
515
                @host_itemnumbers = C4::Items::get_hostitemnumbers_of( $record_number ) if C4::Context->preference('EmbedHostItemsInSearchEngine');
515
                my $items = Koha::Items->search({
516
                my $items = Koha::Items->search({
516
                    -or => [
517
                    -or => [
517
                        biblionumber => $record_number,
518
                        biblionumber => $record_number,
Lines 688-701 sub get_raw_marc_record { Link Here
688
689
689
    my $marc;
690
    my $marc;
690
    if ($record_type eq 'biblio') {
691
    if ($record_type eq 'biblio') {
691
<<<<<<< HEAD
692
        eval {
692
        eval {
693
            my $biblio = Koha::Biblios->find($record_number);
693
            my $biblio = Koha::Biblios->find($record_number);
694
            $marc = $biblio->metadata->record({ embed_items => 1 });
694
            $marc = $biblio->metadata->record({ embed_items => 1, embed_host_items => 1 });
695
        };
695
        };
696
=======
697
        eval { $marc = C4::Biblio::GetMarcBiblio({ biblionumber => $record_number, embed_items => 1, embed_host_items => 1 }); };
698
>>>>>>> Bug 27138: Index host items in child records when sending to search engine
699
        if ($@ || !$marc) {
696
        if ($@ || !$marc) {
700
            # here we do warn since catching an exception
697
            # here we do warn since catching an exception
701
            # means that the bib was found but failed
698
            # means that the bib was found but failed
(-)a/t/db_dependent/Items.t (-3 / +17 lines)
Lines 586-592 subtest 'Koha::Item(s) tests' => sub { Link Here
586
};
586
};
587
587
588
subtest 'C4::Biblio::EmbedItemsInMarcBiblio' => sub {
588
subtest 'C4::Biblio::EmbedItemsInMarcBiblio' => sub {
589
    plan tests => 11;
589
    plan tests => 12;
590
590
591
    $schema->storage->txn_begin();
591
    $schema->storage->txn_begin();
592
592
Lines 630-635 subtest 'C4::Biblio::EmbedItemsInMarcBiblio' => sub { Link Here
630
        push @itemnumbers, $itemnumber;
630
        push @itemnumbers, $itemnumber;
631
    }
631
    }
632
632
633
    t::lib::Mocks::mock_preference( 'EasyAnalyticalRecords', '1' );
633
    my $host_item = $builder->build_sample_item({ homebranch => $library2->{branchcode} });
634
    my $host_item = $builder->build_sample_item({ homebranch => $library2->{branchcode} });
634
    my $child_field = PrepHostMarcField( $host_item->biblionumber, $host_item->itemnumber, 'MARC21');
635
    my $child_field = PrepHostMarcField( $host_item->biblionumber, $host_item->itemnumber, 'MARC21');
635
    my $child_record = $biblio->metadata->record;
636
    my $child_record = $biblio->metadata->record;
Lines 665-676 subtest 'C4::Biblio::EmbedItemsInMarcBiblio' => sub { Link Here
665
    @items = $record->field($itemfield);
666
    @items = $record->field($itemfield);
666
    is( scalar @items, $number_of_items + 1, 'Should return all items plus host items' );
667
    is( scalar @items, $number_of_items + 1, 'Should return all items plus host items' );
667
668
669
    t::lib::Mocks::mock_preference('EmbedHostItemsInSearchEngine', '1');
668
    $marc_with_items = C4::Biblio::GetMarcBiblio({
670
    $marc_with_items = C4::Biblio::GetMarcBiblio({
669
        biblionumber => $biblio->biblionumber,
671
        biblionumber => $biblio->biblionumber,
670
        embed_items  => 1,
672
        embed_items  => 1,
671
        embed_host_items => 1
673
        embed_host_items => 1
672
    });
674
    });
673
    is_deeply( $record, $marc_with_items, 'A direct call to GetMarcBiblio with items matches');
675
    is_deeply( $record, $marc_with_items, 'A direct call to GetMarcBiblio with embed host items matches if embedding items in search engine');
676
    $record = C4::Biblio::GetMarcBiblio({ biblionumber => $biblio->biblionumber });
677
    C4::Biblio::EmbedItemsInMarcBiblio({
678
        marc_record  => $record,
679
        biblionumber => $biblio->biblionumber,
680
        embed_host_items => 0
681
    });
682
    t::lib::Mocks::mock_preference('EmbedHostItemsInSearchEngine', '0');
683
    $marc_with_items = C4::Biblio::GetMarcBiblio({
684
        biblionumber => $biblio->biblionumber,
685
        embed_items  => 1,
686
        embed_host_items => 1
687
    });
688
    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');
674
689
675
    C4::Biblio::EmbedItemsInMarcBiblio({
690
    C4::Biblio::EmbedItemsInMarcBiblio({
676
        marc_record  => $record,
691
        marc_record  => $record,
677
- 

Return to bug 27138