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.

E-Commerce Modules

Discuss about the various e-commerce modules available:
Ecommerce, SS Shop, SilverCart and SwipeStripe
Alternatively, have a look the shared mailinglist.

Moderators: martimiz, Nicolaas, Sean, frankmullenger, biapar, Willr, Ingo, Jedateach, swaiba, simon_w

Edit the moduls php-code, but keep it updateable


7 Posts   1593 Views


20 February 2009 at 4:15am Community Member, 5 Posts


1. Thanks for Silverstripe. I love it!

2. I want to make same changes on the "Product" page (there's no need für a weight field etc). How can I do this without loosing the updateability?

The only way I see is to subclass "Product" to "myProduct" (for example), but than I have an useless page type in my list:
--> not very user friendly!

What do you recommend to do?

(sry for possible english mistakes)


20 February 2009 at 11:14am (Last edited: 20 February 2009 11:19am), Forum Moderator, 921 Posts

You can do this without subclassing Product.

What you'll want to implement is a DataObjectDecorator class for Product - [url][/url] - this is a standard way of modifying an existing class without harming upgradability.


Create a new file MyProductDecorator.php in the mysite/code/ directory with the following (or simiar) code:

class MyProductDecorator extends DataObjectDecorator {

   function updateCMSFields($fields) {


Add this line to your _config.php file in the mysite directory for your project to enable the decorator for Product:

Object::add_extension('Product', 'MyProductDecorator');

The decorator should be enabled after you run ?flush=1

The example decorator simply removes the Weight field from the product editing fields in the CMS. It doesn't manipulate the DB to remove the Weight column. This should be sufficient enough for you.

If you're wanting to update the Product HTML template, simply copy from the ecommerce module into your theme (or mysite) templates folder and change it from there, after you run ?flush=1 your should be used instead of the one in ecommerce.



21 February 2009 at 1:44am (Last edited: 21 February 2009 2:31am), Community Member, 5 Posts

Ahh! Thanks!

Sill have a Problem:
The "Weight" field doesn't disappear.
A "Debug::show("test")" in updateCMSFields works.

It seems that my "updateCMSFields" function is executed before(!) the "getCMSFields" function of the "Product" class.
I would say this is because "getCMSFields" misses the following line:
"$this->extend('updateCMSFields', $fields);"

Any tipps?


24 February 2009 at 2:47am (Last edited: 24 February 2009 2:49am), Community Member, 7 Posts


Did you found a solution meanwhile?



25 February 2009 at 5:20am Community Member, 5 Posts


I will post it if I found one.

BLU42 Media

2 March 2009 at 4:07am Community Member, 71 Posts

Try adding in the ampersand in your decorator's updateCMSFields function:

function updateCMSFields(&$fields) {

See if that helps!


12 March 2009 at 11:03am Community Member, 5 Posts

To: SmartPlugsDesign
Thanks for your tip. I had tried that already -> It does`t help. :-(

After some tests I'm pretty sure that my supposition is true:
The "getCMSFields()" function misses this line:
"$this->extend('updateCMSFields', $fields);"

I added it and everything works fine!
See for details.

In addition I found another problem:
The ProductGroup has no "static $has_one = array();"
So I can't add new relations (

Should I open a ticket?