Tipps for migrating nodes to a different nodetype?

Hi everyone,

I think I’ve a quite challenging task (for me) to migrate nodes to a different nodetype.

The customer started to use the default page for a new “article” section in the past. Time went by and now there are hundreds of articles which don’t have a specific “article” nodetype instead they are all of type default page. Therefore it is hard to do any automatization as you can’t simply search for a nodetype.

This default page / article has in its mainCollection e.g. an article image and several text elements and so on.

The new article nodetype should have some properties like “article-image” and also a mainCollection.

So while the migration I want to:

  1. Figure out which node is an article (e.g. by its child nodes in the main collection)
  2. Change the node to the new article node
  3. Add the article image from the main collection to the articleImage property of the new nodetype
  4. Delete the image node from the main collection

Any tipps what would be a good way to achieve this?

Thank you!

Do you know about Node Migrations?
You can implement your own “filters” and “transformations” to achieve what you want to do.
Have a look at the existing implementations for reference.

That would be a custom implementation of the FilterInterface - it receives an instance of NodeData that you can use to figure out whether it is an article.

For this you can use the existing ChangeNodeType transformation

The rest can be done with a custom transformation.

Awesome! Thank you very much!
I have seen this once, but wasn’t aware of its exact purpose.
It’s the first time I have to do this.

Thx again!

1 Like