From c3040cf09fb6d7db0acfa63e72bc2fe627fcd76d Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Fri, 24 Sep 2021 12:19:12 +0100 Subject: [PATCH] Bug 29105: Add effective_itemtype handling to items api This patch adds effective_itemtype handling to the items api. We overload the to_api method to replace the itype column value with that of the effective itemtype code. We also add in the notforloan fallback that is apparent in catalogue/details.tt status templates. --- Koha/Item.pm | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/Koha/Item.pm b/Koha/Item.pm index 60d80a5c3eb..b1310859c7d 100644 --- a/Koha/Item.pm +++ b/Koha/Item.pm @@ -1104,6 +1104,20 @@ sub _set_found_trigger { return $self; } +=head3 to_api + +Overloaded to_api method to ensure item-level itypes is adhered to. + +=cut + +sub to_api { + my ($self, $params) = @_; + + $self->itype( $self->effective_itemtype ); + $self->notforloan( $self->itemtype->notforloan ) unless $self->notforloan; + return $self->SUPER::to_api($params); +} + =head3 to_api_mapping This method returns the mapping for representing a Koha::Item object -- 2.20.1