I have a script, migrating Image to a custom type, for my Plone instance. Its partial code sample looks like this:
class ImagesToPhotosMigrator(InplaceATItemMigrator):
src_portal_type = 'Image'
src_meta_type = 'ATBlob'
dst_portal_type = 'Photo'
dst_meta_type = 'Photo'
def last_migrate_reindex(self):
self.new.reindexObject(idxs=['object_provides', 'portal_type',
'Type', 'UID'])
fields_map = {
}
def getImagesToPhotosMigrationWalker(self):
return getMigrationWalker(self, migrator=ImagesToPhotosMigrator)
def migrateImages(self):
walker = getImagesToPhotosMigrationWalker(self)
walker.go()
return walker.getOutput()
The script works, but I want the migration only happens in a specific folder, say /my-folder, what to add in the script?
You should have specified that you refer to Products.contentmigration, cause it’s not implicit in the words “content migration” (lately there are more kind of migrations than lines of code). Anyway, here your solution (
CustomQueryWalkeris the key):Note that the query parameter is a catalog query, therefore you can specify the path, the portal_type or any index in your catalog.