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

971 Views Asked by At

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.

1

There are 1 best solutions below

0
On BEST ANSWER

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();