I have two models:
Item / ItemTranslation (one to many relation).
I created ItemObserver to sync data with the Elasticsearch index for "created / updated / deleted" events.
It works fine for the Item model but "created" event is triggered before saving something in ItemTranslation so I do not have access yet to that data.
The only solution I found is to create another observer for the ItemTranslation.
Seems that I need have one observer foreach model.
Is there any way to have a common observer to see when something changes in its relations?
It will be hard to maintain the index if I will have data spread in multiple tables and updated "simultaneously" from the same form because I need to care in wich order the data is saved and when I have all the data to rebuild the index.
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire