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, Ed, frankmullenger, biapar, Willr, Ingo, Jedateach, swaiba

Edit the moduls php-code, but keep it updateable

Go to End

7 Posts   2018 Views


Community Member, 5 Posts

20 February 2009 at 4:15am


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)


Forum Moderator, 922 Posts

20 February 2009 at 11:14am

Edited: 20/02/2009 11:19am

You can do this without subclassing Product.

What you'll want to implement is a DataObjectDecorator class for Product - - 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.



Community Member, 5 Posts

21 February 2009 at 1:44am

Edited: 21/02/2009 2:31am

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?


Community Member, 7 Posts

24 February 2009 at 2:47am

Edited: 24/02/2009 2:49am


Did you found a solution meanwhile?



Community Member, 5 Posts

25 February 2009 at 5:20am


I will post it if I found one.

BLU42 Media

Community Member, 71 Posts

2 March 2009 at 4:07am

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

function updateCMSFields(&$fields) {

See if that helps!


Community Member, 5 Posts

12 March 2009 at 11:03am

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?