- Issue created by @tunic
- 🇪🇸Spain tunic Madrid
Just for reference, this code returns the nodes of a certain content type that have value (not null) on a given field:
$ct_name = "theContentType"; $field_name = "theField"; $node_storage = \Drupal::entityTypeManager()->getStorage('node'); $nids = $node_storage->getQuery()->condition($field_name, NULL, "IS NOT NULL")->condition("type", $ct_name)->execute(); $nodes = $node_storage->loadMultiple($nids);
- 🇪🇸Spain tunic Madrid
Why do this only for nodes when we can do it for all fieldable entities?
- 🇪🇸Spain lpeidro Madrid
Hello @Tuni, yes, this is indeed a very interesting and useful functionality for detecting fields that are not in use and thus being able to simplify the content architecture.
I just want to add a clarification to the description of the functionality: in a first iteration, at least, this check should be performed only on fields that are not basic fields of the entity. Since these are the fields that can be eliminated, and also we would reduce the amount of information in the report, resulting in something more manageable and useful.
- 🇪🇸Spain tunic Madrid
Ok to start with fields that are not basic fields of entities.
- Assigned to lpeidro
- 🇪🇸Spain lpeidro Madrid
Status
First approach completed.It has been implemented for the case of nodes. However, it would be advisable to implement a batch process since these queries might take some time. In the end, we performed an accounting of the usage of all fields.
It might be worthwhile to create another report from the perspective of the storage