Changing portal_type of Content item

If I make an identical content type (For example by duplicating 'Document' and name it 'Boat Page'.

Would it be possible to change the content type by JUST changing obj.portal_type and rebuilding indexes? (or is it necessary to make a new item/copy everything over)

(I want to search for Pages (documents) with keyword (Subject) 'Boat' and change them to 'Boat Page'

No, this not sufficient because the underlying Python pickle within the ZODB contains a reference to the class definition. It's doable with some magic, but not with easy magic. It might be possible to use plone.api for search all related Documents, preserve the metadata, delete the documents and recreated them under a new portal type with the preserved metadata...workflow state must restored, perhaps other metadata too...

Aperfect use case for collective.exportimport? :smiley:

Create a custom content export, modify the JSON data and import it again.

Given that some downtime is ok, that should be the eaisest probably

1 Like

I think it should be possible to do what you propose if the two content types share the same class (see "Content type class" in

I did not test it anyway.

I am wondering if just applying a marker interface will be sufficient for your use case.

1 Like

Thanks. I will test it when I am finished migrating 'stuff'

I did test, duplicated Page TTW and named it 'ship' on one Document and just changed it's portal type to 'ship', and it seems to 'work'. As far as I know, they will have the same the same classes (when duplicated TTW) (?))

Not sure how to test if there are any 'pitfalls'.