gsOnAfterImportValue
Triggered after importing values. Here we can perform some action after the import.
Available variables:
| Name | Description |
|---|---|
| success | Import status for each value |
| mode | Import mode: new||upd||null |
| object | Import object |
| targetObject | The target object that was created or updated |
| value | Values for importing a single object |
modUser
If the user was created, send them an email.
php
if ($modx->event->name === 'gsOnAfterImportValue') {
if ($object->model_class === 'modUser') {
if ($mode === 'new') {
$password = $targetObject->generatePassword();
$targetObject->set('password', $password);
$targetObject->save();
$message = "You login: $targetObject->username <br> You password: $password";
$name = $targetObject->fullname ?? $targetObject->username;
$targetObject->sendEmail($message, [
'subject' => "Hello, $name"
]);
}
}
}modResource
For created resources, update the publication date (publishedon).
php
if ($modx->event->name === 'gsOnAfterImportValue') {
if ($object->model_class === 'modResource') {
if ($mode === 'new') {
$targetObject->set('publishedon', time());
$targetObject->save();
}
}
}msProduct
Mark the "new" checkbox for new products.
php
if ($modx->event->name === 'gsOnAfterImportValue') {
if ($object->model_class === 'msProduct') {
if ($mode === 'new') {
$targetObject->set('new', 1);
$targetObject->save();
}
}
}