From 1008a064ee3a5616dcf4643f3dc57fb6a8736197 Mon Sep 17 00:00:00 2001 From: cocococosti Date: Thu, 9 May 2024 17:40:26 -0400 Subject: [PATCH] fix so the generic importer works with already exisiting categories --- script/bulk_import/base.rb | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/script/bulk_import/base.rb b/script/bulk_import/base.rb index f054eb3fd98..f8d66f79133 100644 --- a/script/bulk_import/base.rb +++ b/script/bulk_import/base.rb @@ -1356,12 +1356,14 @@ class BulkImport::Base def process_category(category) if (existing_category_id = category[:existing_id]).present? if existing_category_id.is_a?(String) - existing_category_id = SiteSetting.get(category[:existing_id]) + existing_category_id = Category.find_by(id: category[:existing_id])&.id end - @categories[category[:imported_id].to_i] = existing_category_id - category[:skip] = true - return category + if existing_category_id + @categories[category[:imported_id].to_i] = existing_category_id + category[:skip] = true + return category + end end category[:id] ||= @last_category_id += 1