I am currently trying to save a new entry with craft()->elements->saveElement()
, as I want to avoid triggering the onBeforeSave
and onAfterSave
events.
When I run my script, it returns a successful entry id, but there is no entry in the admin.
Here is my code:
$entry = new EntryModel();
$entry->sectionId = $sectionId;
$entry->typeId = $entryTypeId;
$entry->enabled = true;
$entry->authorId = 1;
$success = craft()->elements->saveElement($entry, false);
if ($success) {
echo $entry->id;
}
craft/app/controllers/EntriesController->saveEntry()
to see how an EntryModel is created and populated and passed off to the ElementsService. – Brad Bell Mar 7 '18 at 3:14saveEntry
method from theEntriesService
and ripping out anything event related. Additionally, I think it'd be amazing if there were a way to call saveEntry and disable any events, although I don't know if that would ever be possible. – Alex Glover Mar 8 '18 at 14:22