Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

Data Model Questions /

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

Update a parameter of subclass of Page subclass

Go to End

3 Posts   1454 Views


Community Member, 25 Posts

8 January 2011 at 6:48am

Edited: 08/01/2011 10:56am

in my code I have a subclass of Page, and I am trying to update some of its additional parameters but unlike regular updates my changes do not take effect. They are visible in the admin console as unpublished versions, how can I just simply change some parameters?
I have overridden canEdit and canPublish to allow changes from any user (as that will be my intended use) but I am trying it out with admin anyway, the code looks similar to this:

$product->QuantityInStock -= 1;

I have also tried calling following:

$product->publish('Stage', 'Live');

None of it actually publishes the page, it only produces unpublished versions which I can review in the admin console and can "roll back" to them but that is not really what I want as I would like to have a counter on the page which any user can update via special form and code.

Also, I only want to update the product object, it is not created anew.

I would really appreciate some help!



Forum Moderator, 5523 Posts

8 January 2011 at 8:23pm

I believe you would need to call write() then publish().

$product->publish('Stage', 'Live');


Community Member, 25 Posts

19 January 2011 at 12:45pm

Just to give people a reply if they find this post via google - I have tried multiple ways (staging and publishing etc.) but did not manage to make it work.

I have done alternative solution - I have created an extra object with has_one relationship on the page which is not versioned and I have created a setter and getter on the page so it behaves like internal parameter. I did not need the versioning for that param so it was viable solution for me.