Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
By webdevfreak on
I am using following code which is updating my node title fine but not URL PATH SETTING value.
// Update node.
$node_update = Node::load($node->id());
dpm($node_update);
$node_update->title->value = 'My modified title';
$node_update->path->value = ['alias' => '/en/my-new-link'];
$node_update->save();
Comments
Check this thread -> https:/
Check this thread -> https://drupal.stackexchange.com/questions/146286/is-it-possible-to-programmatically-add-a-path-alias-to-a-programmatically-create
Thanks but I want to UPDATE
Thanks but I want to UPDATE not ADD.
I can ADD url path fine but having problem updating the path when I UPDATE a node.
Did you try to update Alias
Did you try to update Alias in node object?
try that