I have two node types:
Exercise. A lesson contains several exercises, which are children. Lessons have a category field which is a reference field of type taxonomy term. Exercises point to lessons through a Lesson reference field, which I suppose indirectly maps exercises to terms.
When I create a lesson, I use the following code:
$node = Node::create([ // The node entity bundle. 'type' => 'lesson', 'langcode' => 'en', 'created' => $lesson->created, 'changed' => $lesson->changed, 'uid' => $lesson->uid, 'title' => $lesson->title, 'field_category' => $tid, 'body' => [ 'summary' => $lesson->summary, 'value' => $lesson->body, 'format' => 'full_html', ], ]); $node->save();
The above does not result in the
taxonomy_index table being updated. I could update it with an sql query, but I would like to know how to do it via the above core approach.
And for the
Exercise node type, I suppose I need to do likewise, unless my linking of an
Exercise to a Lesson already accomplishes the hierarchy.
How do I alter the above to result in the
taxonomy_index table being updated?