-
Notifications
You must be signed in to change notification settings - Fork 684
set/to/if-empty options for resave/* commands #10356
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Nice one @brandonkelly, some really nice updates to the resave command. One thought, with the new functionality to now update content / attribute values as a part of this, should the Apologies if i'm missing something obvious. And if you currently needed to mark the elements as updated at that point would it be safe to set the dateUpdated attribute to now manually? |
|
@samhibberd It was intentional to not change |
|
Digging deeper into the craft I can see why you have decided that makes sense. In a situation that you would need to update the dateUpdated is updating the value set in the |
|
@samhibberd Yeah that’s the place to do it. |
|
@brandonkelly I'm attempting to use |
|
@Kashkin For that you would need to use the PHP arrow function syntax, because relational fields need to be set to an array of related element IDs. php craft resave/entries --set foo --to "fn(\$entry) => [1, 2, 3]" |
|
Thanks for the tip! That makes sense in retrospect, but it would be great to add that example to the docs! |
|
Example added @Kashkin, thank you! We’ll also get a link to that article from the Console Commands page in the docs. |
|
@mattstein Hi Matt! Thanks for the continuously improving documentation. I can't seem to figure out the syntax for |
|
@Kashkin You can use php craft resave/entries --set myLightswitchField --to "=1" |
|
Thanks @brandonkelly! I feel really silly for not noticing the |
|
Hah, no worries :) It’s required if you want to pass a literal value, as opposed to reference another field/attribute. |
Description
This adds new
--set,--to, and--if-emptyoptions to allresave/*commands, which can be used to bulk-set a new value on resaved elements’ attributes and custom fields.Examples:
Related issues