Needs review
Project:
Computed Field
Version:
8.x-2.x-dev
Component:
Code
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
25 Jul 2018 at 08:19 UTC
Updated:
17 Oct 2022 at 23:23 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
kohashi commentedI'm running into the same issue and haven't found a good solution.
These all failed:
I've tried bulk saving from admin/content.
I've tried saving by executing PHP code to load a node and $node->save();
Comment #3
bgilhome commentedThis worked for me - not sure if the appendItem() or preSave() calls are necessary.
I put it in an update hook and looped over nodes returned from an entity query.
Comment #4
hansrossel commentedYou can also do it on cron
Comment #5
mrogers commentedLeaving this for the less code literate (like me!), I was able to use Views Bulk Edit to bulk update computed fields for thousands of nodes in one go.
1. Create a new Page view listing the nodes you want to update.
2. Be sure to add the Views Bulk Operations field to the view with the "Modify Field Values" action.
3. Save and visit the view's page. Select the "Modify Field Values" action, check the "all results" checkbox, click "Apply", and then select the checkbox next to your computed field (you don't have to enter a value) and hit 'Apply' again.
Hope this helps someone!
Comment #6
webel commented@bgilhome and @hansrossel
Thanks, this one helped me a lot.
@hansrossel wrote:
Just
$node->save();definitely not enough (leading me to search and find this page).Comment #7
attisanor we could populate default values when there are none - saving us the trouble of updating possible large amounts of entities
Comment #8
osopolar@attisan: This may result in unexpected behavior on sorting view results on computed field.
Comment #9
osopolar#3 and #4 is working well so far, but I do not want to update changed time nor crate a new revision. I was able to reset changed time by re-saving the node a second time. But that leads to two new revisions. Any help on that?
I wrote a drush script to do the update, see https://drupal.stackexchange.com/q/282416/10316
Comment #10
liquidcms commentedNot sure if this is a View Bulk Edit issue; but i have this on 2 sites to update computed fields:
VBE 2.4: works
VBE 2.5: the computed fields don't show on the list of fields (so doesn't work).
Edit: nope, i updated site 1 to 2.5.. and it still shows the computed field fields
Comment #11
carsonwTo update all users:
Comment #12
webdrips commentedI just wanted to chime in here with a 2022 update: I was able to use views bulk edit, select all items for a given content type, and just run the "Save Content Item", and that updated all computed fields for the selected content type.
Of course you can still check the box for the computed field you want updated, and click Apply, and that will have the same affect.