Search code examples
phppimcorepimcore-v5

Pimcore: Save a new version of an object but don't publish this version


If a published object is edited in the code, is there a possibility to save this as a new version of this object but leave the initially version as the published one?

So that a editor could check the new version first and if everything's ok he could publish it by hand.

The "Versioning" chapter in the documentation isn't very helpful.


Solution

  • try this snippet for $object you want to save:

    $version = new Model\Version();
    $version->setCid($object->getId());
    $version->setCtype('object');
    $version->setDate($object->getModificationDate());
    $version->setUserId($object->getUserModification());
    $version->setData($object);
    $version->setNote($versionNote);
    $version->save();