Given a taxonomy term id, how do we get the value of other fields; specifically the machine_id? A good example of getting the children is posted How to get fields...

I need the machine_id of the parent (or target)

Code below fetches the name;

$product_name_id = $product_name_reference-&gt;getValue()[0]['target_id'];
$product_name = \Drupal\taxonomy\Entity\Term::load($product_name_id)-&gt;label();


The machine_name is visible under 'values'. How do I get it!
The machine name is the vid:
if you search for machine_id inside taxonomy module there is no machine_id field declared.


But if you look at core/modules/taxonomy/config/schema/taxonomy.schema.yml you can see that:

vid:
  type: string
  label: 'Machine name'


So to get the vid (Machine name) you should use getVocabularyId
something like:

$product_name_id = $product_name_reference-&gt;getValue()[0]['target_id'];;
$product_name = \Drupal\taxonomy\Entity\Term::load($product_name_id);
// Vid or machine name.
$vid = $product_name-&gt;getVocabularyId();