Bugzilla – Attachment 137450 Details for
Bug 29606
Include items from host record in XML for XSLT processing
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 29606: Include items from host record in XML for XSLT processing
Bug-29606-Include-items-from-host-record-in-XML-fo.patch (text/plain), 3.62 KB, created by
David Nind
on 2022-07-09 21:39:52 UTC
(
hide
)
Description:
Bug 29606: Include items from host record in XML for XSLT processing
Filename:
MIME Type:
Creator:
David Nind
Created:
2022-07-09 21:39:52 UTC
Size:
3.62 KB
patch
obsolete
>From c11955bd78a8175e92b0d71e16928571cab77f0b Mon Sep 17 00:00:00 2001 >From: Julian Maurice <julian.maurice@biblibre.com> >Date: Tue, 30 Nov 2021 14:04:21 +0100 >Subject: [PATCH] Bug 29606: Include items from host record in XML for XSLT > processing > >If EasyAnalyticalRecords is enabled, items from host records should be >included in the XML. Otherwise, OPAC search results show no items. > >Test plan: >0. Do not apply the patch yet >1. Enable syspref EasyAnalyticalRecords and set OPACXSLTResultsDisplay > to 'default' >2. Create a biblio record with title "parent" and create an item with a > barcode for this biblio >3. Create a biblio record with title "child" with no items. On the > biblio detail page, in the toolbar, click "Edit -> Link to host > record" and enter the barcode for the item you created at step 2 >4. Duplicate this biblio record, to be sure you will have at least two > results with the search "child" (and not be redirected to the detail > page) >5. Make sure your search index (zebra or elasticsearch) is up to date >6. Go to OPAC and search "child". > You should see two results, no items. > Click on one of them. On the detail page you should see one item (the > one from the host record) >7. Apply the patch >8. Go to OPAC and search "child". > You should now see one item (the same item) for each result. > >Signed-off-by: David Nind <david@davidnind.com> >--- > C4/XSLT.pm | 28 +++++++++++++++++++--------- > 1 file changed, 19 insertions(+), 9 deletions(-) > >diff --git a/C4/XSLT.pm b/C4/XSLT.pm >index 0fb7be0d6c..762de0992f 100644 >--- a/C4/XSLT.pm >+++ b/C4/XSLT.pm >@@ -263,7 +263,7 @@ sub XSLTParse4Display { > if ( $xslsyspref eq "OPACXSLTDetailsDisplay" || $xslsyspref eq "XSLTDetailsDisplay" || $xslsyspref eq "XSLTResultsDisplay" ) { > $itemsxml = ""; #We don't use XSLT for items display on these pages > } else { >- $itemsxml = buildKohaItemsNamespace($biblionumber, $hidden_items, $items_rs); >+ $itemsxml = buildKohaItemsNamespace($biblionumber, $hidden_items, $items_rs, $record); > } > my $xmlrecord = $record->as_xml(C4::Context->preference('marcflavour')); > >@@ -324,20 +324,30 @@ Is only used in this module currently. > =cut > > sub buildKohaItemsNamespace { >- my ($biblionumber, $hidden_items, $items_rs) = @_; >+ my ($biblionumber, $hidden_items, $items_rs, $record) = @_; > > $hidden_items ||= []; > >- my $query = {}; >- $query = { 'me.itemnumber' => { not_in => $hidden_items } } >- if $hidden_items; >- > unless ( $items_rs && ref($items_rs) eq 'Koha::Items' ) { >- $query->{'me.biblionumber'} = $biblionumber; >- $items_rs = Koha::Items->new; >+ # adding linked items that belong to host records >+ my @linkeditemnumbers; >+ if ( C4::Context->preference('EasyAnalyticalRecords') ) { >+ my $analyticsfield = C4::Context->preference("marcflavour") eq 'UNIMARC' ? '461' : '773'; >+ @linkeditemnumbers = map { $_->subfield('9') } $record->field($analyticsfield); >+ } >+ >+ $items_rs = Koha::Items->search( >+ [ >+ 'me.biblionumber' => $biblionumber, >+ 'me.itemnumber' => { in => \@linkeditemnumbers }, >+ ] >+ ); > } > >- my $items = $items_rs->search( $query, { prefetch => [ 'branchtransfers', 'reserves' ] } ); >+ my $items = $items_rs->search( >+ { 'me.itemnumber' => { not_in => $hidden_items } }, >+ { prefetch => [ 'branchtransfers', 'reserves' ] } >+ ); > > my $shelflocations = > { map { $_->{authorised_value} => $_->{opac_description} } Koha::AuthorisedValues->get_descriptions_by_koha_field( { frameworkcode => "", kohafield => 'items.location' } ) }; >-- >2.30.2
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 29606
:
128118
| 137450