BulkOpEvents & multisite #17244
-
I'm trying to implement the new Right now I'm looking over all Element types, and listening for the event like this foreach (Craft::$app->elements->allElementTypes as $elementType) {
BulkOpEvent::defer($elementType, Element::EVENT_AFTER_SAVE, function (BulkOpEvent $event) use ($elementType) {
$elements = $elementType::find()->inBulkOp($event->key);
// fire my own queue job here
});
} For how Scout functions - and probably for other plugins listening for these events - I also need to know in which site the event (in this case the save) happened. That's needed to check if the element in question matches my own criteria for sending the element to Algolia. Right now I don't see a way to get that site from the BulkOpEvent. Is there another (better) way to do this or is this something that isn't possible for the moment? Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Any time an element is saved, it is saved across all sites, so any non-translatable field values get copied over. So for Scout’s purposes, if an element is included within a bulk op, it should be safe to assume it needs to be re-indexed. |
Beta Was this translation helpful? Give feedback.
Any time an element is saved, it is saved across all sites, so any non-translatable field values get copied over. So for Scout’s purposes, if an element is included within a bulk op, it should be safe to assume it needs to be re-indexed.