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.

General Questions

General questions about getting started with SilverStripe that don't fit in any of the categories above.

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

How to create php class for only


5 Posts   1828 Views


3 June 2010 at 7:41pm Forum Moderator, 435 Posts


What are steps to create a class for only update database ?
That is: I've a product class with some options. Then, after some action, a remote webservice return data on my site ( like PayPal IPN ) and I've update products info.
And How will be link for call that action?


3 June 2010 at 10:05pm (Last edited: 3 June 2010 10:05pm), Forum Moderator, 5511 Posts

Well if you want a blank php class then in SS you can do exactly as you do in standard php, simply don't extend page


class MyClass {

function foo() {
// update db you can use DB::query(), DataObject::get()...


And if thats in your mysite folder you can simply to this in any other function / class in your project you can do

$var = new MyClass();

Nothing fancy their, just standard PHP OOP. If you provide more specific information about what you want to do we may be able to help further.


4 June 2010 at 3:31am Forum Moderator, 435 Posts

Yes, I know.
But I wish to update fields of "product" that "product" is a SS class that extend page or
Do I made "Product" class as dataobject?


4 June 2010 at 9:17am Forum Moderator, 5511 Posts

Do I made "Product" class as dataobject?

Just to be clear, your "product" is not referring the the product class that is bundled with ecommerce? if it is you should have this in the ecommerce forum.

If your building your own Product class the option of extending Page or Dataobject depends on what you want. Do you want each product to have a page on the site? Do you want to manage products in the sitetree? If these are yes then extend Page, otherwise extend DataObject.


4 June 2010 at 9:04pm Forum Moderator, 435 Posts

I don't use ecommerce module. I need a simple simple cart. I simulate cart with simplejs javascript.

I need product to manage a Wedding-wishlist.
I simulated a list as a Product Categorie and each product with a page child of Categories.
After a person books a gift and payed via PayPal, I need to setup booked flag at true value. So, that product is not more in list.
So, I need a method to read returned value from PayPal.