Score:0

How can I programmatically save node components?

cn flag

There is a site with number of nodes including layout canvas and site studio components available in a node.

When there will be changes in one of the components (new field added with default value), if I want new component changes to existing page/node, I will need to edit the node, save the component, and save the node. After these steps, I am getting the component change reflected on the node.

Is there any way to programmatically doing that?

With \Drupal::entityTypeManager()->getStorage('cohesion_layout')->load($uid), I get the older JSON component value.

Jaypan avatar
de flag
When you save an updated node, any updated fields on the node are also saved. So to update components, you load the node, update any fields, and save the node. It's not clear what JSON you are referring to here, and you haven't shown us enough code to say what your problem is.
Ankit Hinglajia avatar
cn flag
Hi @Jaypan There is a site studio component. This component is widely used and added to the number of pages. There is modification at the component (some new fields are added with default value). If I want to have new changes of component, I have to manually edit the node, edit the component, save the component (without any changes at component as default values are set to new fields) and save the node. I tried saving the node programmatically, but component related new changes are not coming by only saving the node. Is there any way to get component's new changes to existing pages of site?
Jaypan avatar
de flag
This sounds like something proprietary - Drupal core doesn't come with these components you are mentioning.
id flag
Is the question about Acquia Site Studio?
Ankit Hinglajia avatar
cn flag
@cilefen Yes this is related to Acquia Site Studio.
id flag
This Question needs a bit more information to be answerable with facts.
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.