diff --git a/conf/datasources.ini.sample b/conf/datasources.ini.sample index 1e1284f9..4155bece 100644 --- a/conf/datasources.ini.sample +++ b/conf/datasources.ini.sample @@ -191,6 +191,7 @@ ;; unsuppressed to suppressed won't be detected. ;;suppressedRecords = false ;suppressedBibCode3 = 'c,d,n' +;keepExisting852Fields = false ;institution = SierraLib ;format = marc ;dedup = true diff --git a/src/RecordManager/Base/Harvest/SierraApi.php b/src/RecordManager/Base/Harvest/SierraApi.php index 6854753c..858a6b69 100644 --- a/src/RecordManager/Base/Harvest/SierraApi.php +++ b/src/RecordManager/Base/Harvest/SierraApi.php @@ -108,6 +108,14 @@ class SierraApi extends AbstractBase */ protected $suppressedBibCode3 = []; + /** + * Whether to keep existing 852 fields in the MARC records before adding new ones + * for the item locations. + * + * @var bool + */ + protected $keepExisting852Fields = false; + /** * HTTP client options * @@ -154,7 +162,8 @@ public function init(string $source, bool $verbose, bool $reharvest): void ',', $settings['suppressedBibCode3'] ?? '' ); - $this->apiVersion = 'v' . ($settings['sierraApiVersion'] ?? '5'); + $this->apiVersion = 'v' . ($settings['sierraApiVersion'] ?? '6'); + $this->keepExisting852Fields = $settings['keepExisting852Fields'] ?? false; } /** @@ -540,7 +549,10 @@ protected function convertRecordToMarcArray($record) $marc['leader'] = $varField['content']; continue; } - if (!isset($varField['marcTag']) || $varField['marcTag'] == '852') { + if ( + !isset($varField['marcTag']) + || (!$this->keepExisting852Fields && $varField['marcTag'] == '852') + ) { continue; } // Make sure the tag has three characters