I'm using data from JSON to create new nodes or update fields on existing if node exist on my Drupal 8 website. So, when I use method to update nodes, I need to save in array node id of updated nodes and keys of fields with changed values in this node.
After update is finished I need to print table with all nodes of this content type where fields of updated nodes need to have different style (color, background, etc).
So if my old node have
body = "body1" and
description = "description 1" and new node have
body = "body2"and
description = "description 1" after update is finished i need to get output like this:
Here is an example:
$node = \Drupal\node\Entity\Node::load($nid); $node->set("body", 'New body text'); $node->set("description", 'New value'); $node->save();
Note: when I use
$node->save(); if all updated values is same nothing is changed (date of node in content from admin panel is same as before update), but if values is different I need to store node id, keys and values only of changed fields in array.