SEO property not added to existing entries
Description
The SEO property is not saved for an entry object, unless you open the entry in control panel and save it manually. Is it possible to add the property dynamically to a bulk of existing entries?
Steps to reproduce
- Create some entries
- Install and activate SEO Plugin
- Try to get SEO property for existing entries:
var_dump($entry->seo); // output: null
Additional info
- Craft version: Craft Pro 3.1.4
- SEO version: 3.5.3
- PHP version: 7.1.12
Adding the field to the entry should be enough for SEO to generate the titles automatically (see The Field Type).
@Tam it should be, but I am experiencing an Issue where I manually have to save every entry in order for the field to be set, otherwise it is null
@lanzi8 @AlexandreKilian is this still an issue?
@lanzi8 @AlexandreKilian Am I correct in assuming that you are having this issue after adding an SEO field to existing entries? My understanding is that it is normal behavior for a field to not propagate field data until its element is saved, with the exception of field types that allow you to specify a default value (e.g. Lightswitch).
To get around having to manually resave each element, you can use the ./craft resave console command. It will automatically resave all of the elements you specify and propagate the SEO fields at that time. Use help to get details and options for specific subcommands, for example ./craft help resave/entries. For a more detailed explanation of using the console there is a great nystudio107 article.