Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not possible to set userModification for object #4365

Open
caupo-roy opened this issue May 14, 2019 · 0 comments

Comments

Projects
None yet
1 participant
@caupo-roy
Copy link

commented May 14, 2019

I have a custom object (product) importer that create and update objects. The import is started from a front controller or a console command. I have created a pimcore admin user to represent this import. I am trying to set this user as the user modifying the object using the setUserModification method of the object. This does not work, the object is modified with user 0 instead of the user I set on the object.

I have located the problem in the method updateModificationInfos of class Pimcore\Model\Element\AbstractElement. Here the userModification value I have set is overwritten with the current admin user instead. In my case this will be the system user since there are no active admin user.

I am unsure how to best solve this. My first idea was to only get the current user if the userModification property of the object is null. The problem then is that it will rarely be null. When an existing object is loaded the userModification property has the value from the last save. There is, as I see it, no reliable way of knowing if the value of userModification is a new set value or the value from last save.

Or maybe I am looking at this elephant from the completely wrong angle?

Expected behavior

The user id set on object with setUserModification method should be saved to the objects table in database when calling save on the object.

Actual behavior

System (id 0) is used instead.

Code example

$product = new \Pimcore\Model\DataObject\Product();
$product->setSku('test-product');
$product->setParentId(1);
$product->setUserModification(3);
$product->save();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.