Skip to main content
drupalreleases

Use direct release data with your AI assistant.

Learn more

Referenced Entity Replace

No security coverage Under active development 3 sites

This module allows you to replace all references to one entity with another, which is useful for merging or removing duplicate entities. It finds and updates references across all relevant fields, including in translations, and provides a Drush command for performing these operations.

Replace references to one entity with another. Primary expected use case: to 'merge', or remove duplicate entities, updating every other entity that references the one to be removed the one being 'merged' into.

Features

The module's first audience is developers to use with drush having made a database backup.

It is active development but might also become suitable for developers to use as an API for creating a UI for 'merging' Taxonomy Terms or any other entities and updating all references to them.

  • Find all fields that could reference an entity
  • Update references on these fields with a batch operation
  • Handle references in translations

Usage

Install as standard module. A drush command referenced_entity_replace should become available.

drush --help referenced_entity_replace
Update all references to an entity to another and remove.

Examples:
 referenced_entity_replace taxonomy_term 5 6 Updates references to term 6 to 5 and removes
--batch-size=5                               term 6.

Arguments:
 entity_type_id Type of entity type.
 new_entity_id  The entity to reference.
 old_entity_id  The entity that is referenced to be removed.

Options:
 --batch-size[=BATCH-SIZE] Number of entities to update per batch. [default: 10]
 --no-delete-old           Set if you don't want to remove the old entity.

The two classes included are: BatchReplace used by the Drupal command, but could be used for a Form batch, to create the batch, and run the operations updating all field values, and optionally removing the old entity; and ReplaceHelper available as the service referenced_entity_replace.helper which will return reference fields, and actually update entities.

Similar projects

For taxonomy term references, without batch operations:

For more entities, without batch operations, but with a UI:

Ask your assistant about Referenced Entity Replace

Check compatibility with your Drupal and PHP version, maintenance and security coverage, from current release data. How it works

Depends on

Dependencies of the latest stable release

No dependencies recorded for this project.

Required by

Tracked projects that depend on this one

No tracked projects depend on this one yet.

Activity

Tracked releases
2
Tracked since
Feb 2024
Latest release
2 years ago
Releases (12 mo)
0
Maintenance
Dormant

Releases

Version Type Core PHP Release date
1.0.x-dev Dev 10 Feb 4, 2024
1.0.0-alpha1 Pre-release 10 Feb 4, 2024