fix so the generic importer works with already exisiting categories

This commit is contained in:
cocococosti 2024-05-09 17:40:26 -04:00
parent 0572d752be
commit 1008a064ee
No known key found for this signature in database
GPG Key ID: FDEE4E9ED2BD9B89
1 changed files with 6 additions and 4 deletions

View File

@ -1356,13 +1356,15 @@ 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
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
@categories[category[:imported_id].to_i] ||= category[:id]