I tried this answer:
https://drupal.stackexchange.com/a/298084/1082
But I can't seem to use
'field_scientists' => $entity_reference_uuid
where, in my case, field_scientists
is a field of type Entity Reference UUID - which is a field type provided by https://www.drupal.org/project/entity_reference_uuid module
What happens for me is that I get nothing back, my results array from that example is empty.
Looking to do this programmatically in my own custom module, rather than use a Drupal View.
If there's another way e.g. that uses the ->query
method for querying the database I'd be happy to use that programmatic approach.
Thank you.
Update
An example of a uuid
of a node
in my case is BMSSYS0000051988
.
This was set in a migration import from a field in a CSV.
My attempts are:
1. based on the example in the other question: https://drupal.stackexchange.com/a/298084/1082
$nodes = \Drupal::entityTypeManager()->getStorage('node')->loadByProperties([
'type' => 'bol',
'field_parent_uuid' => $taxonkey,
]);
2. db query
$query = \Drupal::entityQuery('node')
->condition('status', NODE_PUBLISHED)
->condition('type', 'bol');
$and = $query->andConditionGroup();
$and->condition('field_parent_uuid', $taxonkey);
$query->condition($and);
$result = $query->execute();
where $taxonkey
is BMSSYS0000051988
both 1 and 2 attempts above return an empty array.
Update 2
here is my migration config that shows uuid being written to from a field in the csv. Is this legal? Should a developer's code change the uuid value or should uuid only be handled by Drupal core?
dependencies: { }
id: bol_csv_import
class: null
field_plugin_method: null
cck_plugin_method: null
migration_tags: null
migration_group: defaultl: publicbins
label: 'Import bol species data'
source:
plugin: csv
path: ./data/taxonomy_species_with_unpacked_bold.csv
delimiter: ','
enclosure: '"'
header_offset: 0
ids:
- uuid
fields:
-
name: uuidl: publicbins
label: 'NBN id'
-
name: parent_uuid
label: 'NBN id of parent'
-
name: name
label: Name
-
name: rank
label: 'Taxonomic Rank'
-
name: taxon_key
label: 'Taxon Key'
-
name: authority
label: authority
-
name: specimenrecords
label: specimenrecords
-
name: publicrecords
label: publicrecords
-
name: publicbins
label: publicbins
-
name: taxid
label: 'NBN Taxon ID'
process:
title: name
uid:
plugin: default_value
default_value: 1
uuid: uuid
field_parent_uuid: parent_uuid
field_taxon_key: taxon_key
field_authority: authority
field_rank: rank
field_num_bold_barcode_specimens: specimenrecords
field_num_bold_public_records: publicrecords
field_num_bold_public_bins: publicbins
field_bold_taxon_id: taxid
type:
plugin: default_value
default_value: bol
destination:
plugin: 'entity:node'
migration_dependencies: null
Update 3
I'll write a db query to solve this issue. Running a command line sql indicates this approach could work:
MariaDB [db]> select * from node where nid = 246;
+-----+------+------+------------------+----------+
| nid | vid | type | uuid | langcode |
+-----+------+------+------------------+----------+
| 246 | 248 | bol | NBNORG0000041189 | en |
+-----+------+------+------------------+----------+
1 row in set (0.001 sec)