Compare new values to old values in DataObjectEvent / onPreUpdate

I am listening to pimcore.dataobject.preUpdate events.

DataObjectEvent::getObject() contains the new Object. Is there a way to access the old object values, to be able to compare new to old?

Thank You!
Thomas

Hi there,

in case someone else stumbles across this post here’s my solution:

ClassName::getById($event->getObject()->getId(), true);

The second parameter forces Pimcore to fetch the current state from the database.

1 Like

I think it might be safer to user the Version system.

https://pimcore.com/docs/5.x/Development_Documentation/Tools_and_Features/Versioning.html